summaryrefslogtreecommitdiffstats
path: root/src/libknot/packet/rrset-wire.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/libknot/packet/rrset-wire.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/libknot/packet/rrset-wire.c b/src/libknot/packet/rrset-wire.c
index ef3a068..1d4f78e 100644
--- a/src/libknot/packet/rrset-wire.c
+++ b/src/libknot/packet/rrset-wire.c
@@ -73,6 +73,7 @@ static bool dname_equal_wire(const knot_dname_t *d1, const knot_dname_t *d2,
{
assert(d1);
assert(d2);
+ assert(wire);
d2 = knot_wire_seek_label(d2, wire);
@@ -80,7 +81,7 @@ static bool dname_equal_wire(const knot_dname_t *d1, const knot_dname_t *d2,
if (!label_is_equal(d1, d2)) {
return false;
}
- d1 = knot_wire_next_label(d1, NULL);
+ d1 = knot_dname_next_label(d1);
d2 = knot_wire_next_label(d2, wire);
}
@@ -170,7 +171,7 @@ static int write_rdata_naptr_header(const uint8_t **src, size_t *src_avail,
written += (len); \
}
-#define CHECK_NEXT_LABEL(res) \
+#define CHECK_WIRE_NEXT_LABEL(res) \
if (res == NULL) { return KNOT_EINVAL; }
/*!
@@ -201,7 +202,7 @@ static int compr_put_dname(const knot_dname_t *dname, uint8_t *dst, uint16_t max
int suffix_labels = compr->suffix.labels;
while (suffix_labels > name_labels) {
suffix = knot_wire_next_label(suffix, compr->wire);
- CHECK_NEXT_LABEL(suffix);
+ CHECK_WIRE_NEXT_LABEL(suffix);
--suffix_labels;
}
@@ -210,8 +211,7 @@ static int compr_put_dname(const knot_dname_t *dname, uint8_t *dst, uint16_t max
uint16_t written = 0;
while (name_labels > suffix_labels) {
WRITE_LABEL(dst, written, dname, max, (*dname + 1));
- dname = knot_wire_next_label(dname, NULL);
- CHECK_NEXT_LABEL(dname);
+ dname = knot_dname_next_label(dname);
--name_labels;
}
@@ -221,10 +221,9 @@ static int compr_put_dname(const knot_dname_t *dname, uint8_t *dst, uint16_t max
const knot_dname_t *compr_ptr = suffix;
while (dname[0] != '\0') {
// Next labels.
- const knot_dname_t *next_dname = knot_wire_next_label(dname, NULL);
- CHECK_NEXT_LABEL(next_dname);
+ const knot_dname_t *next_dname = knot_dname_next_label(dname);
const knot_dname_t *next_suffix = knot_wire_next_label(suffix, compr->wire);
- CHECK_NEXT_LABEL(next_suffix);
+ CHECK_WIRE_NEXT_LABEL(next_suffix);
// Two labels match, extend suffix length.
if (!label_is_equal(dname, suffix)) {
@@ -495,7 +494,7 @@ static int write_rr(const knot_rrset_t *rrset, uint16_t rrset_index,
_public_
int knot_rrset_to_wire_extra(const knot_rrset_t *rrset, uint8_t *wire,
- uint16_t max_size, uint16_t rotate,
+ uint32_t max_size, uint16_t rotate,
knot_compr_t *compr, uint16_t flags)
{
if (rrset == NULL || wire == NULL) {
@@ -511,11 +510,6 @@ int knot_rrset_to_wire_extra(const knot_rrset_t *rrset, uint8_t *wire,
uint8_t *write = wire;
size_t capacity = max_size;
- // FIXME remove this and make the max_size parameter uint32_t in next major libknot release!
- if ((flags & KNOT_PF_BUFENOUGH)) {
- capacity = SIZE_MAX;
- }
-
uint16_t count = rrset->rrs.count;
knot_rdata_t *rdata = rotate > 1 ? knot_rdataset_at(&rrset->rrs, rotate - 1) : rrset->rrs.rdata;
for (int i = rotate; i < count + rotate; i++) {