Commit 2f59d47d authored by Lubos Slovak's avatar Lubos Slovak

RRSet wire: Utils not to use obsolete function.

parent c9100436
......@@ -228,6 +228,9 @@ static int naptr_header_size(const uint8_t **src, size_t *src_avail)
return size;
}
/*!
* \brief Compresses and stores one RDATA dname from \a src to \a dst.
*/
static int compress_dname(const uint8_t **src, size_t *src_avail,
uint8_t **dst, size_t *dst_avail,
knot_compr_t *compr, int compr_hint, int type,
......@@ -280,6 +283,9 @@ static int compress_dname(const uint8_t **src, size_t *src_avail,
return KNOT_EOK;
}
/*!
* \brief Parses and decompresses one RDATA dname from \a src to \a dst.
*/
static int decompress_dname(const uint8_t **src, size_t *src_avail,
uint8_t **dst, size_t *dst_avail,
knot_compr_t *compr, int compr_hint, int type,
......@@ -337,6 +343,9 @@ typedef int (*dname_callback_t)(const uint8_t **, size_t *, uint8_t **,
size_t *, knot_compr_t *, int, int,
knot_rrset_wire_flags_t, const uint8_t *);
/*!
* \brief Generic function from processing RDATA with de/compression of dnames.
*/
static int traverse_rdata(const rdata_descriptor_t *desc, const uint8_t **src,
size_t *src_avail, uint8_t **wire, size_t *capacity,
knot_compr_t *compr, int compr_hint,
......@@ -441,7 +450,7 @@ static int write_rdata(const knot_rrset_t *rrset, uint16_t rrset_index,
}
/*!
* Write one RR from a RR Set to wire.
* \brief Write one RR from a RR Set to wire.
*/
static int write_rr(const knot_rrset_t *rrset, uint16_t rrset_index,
uint8_t **wire, size_t *capacity, knot_compr_t *compr,
......@@ -576,7 +585,10 @@ static bool allow_zero_rdata(const knot_rrset_t *rr, const rdata_descriptor_t *d
desc->type_name == NULL; // Unknown RR types can have 0 RDLENGTH
}
int knot_rrset_parse_rdata(const uint8_t *pkt_wire, size_t *pos, size_t pkt_size,
/*!
* \brief Parse RDATA part of one RR from packet wireformat.
*/
static int parse_rdata(const uint8_t *pkt_wire, size_t *pos, size_t pkt_size,
mm_ctx_t *mm, uint32_t ttl, uint16_t rdlength,
knot_rrset_t *rrset)
{
......@@ -627,6 +639,9 @@ int knot_rrset_parse_rdata(const uint8_t *pkt_wire, size_t *pos, size_t pkt_size
return knot_rrset_add_rdata(rrset, rdata_buffer, dst_size, ttl, mm);
}
/*!
* \brief Parse header of one RR from packet wireformat.
*/
static int parse_header(const uint8_t *pkt_wire, size_t *pos,
size_t pkt_size, mm_ctx_t *mm, knot_rrset_t *rrset,
uint32_t *ttl, uint16_t *rdlen)
......@@ -676,7 +691,7 @@ int knot_rrset_rr_from_wire(const uint8_t *pkt_wire, size_t *pos,
uint16_t rdlen = 0;
int ret = parse_header(pkt_wire, pos, pkt_size, mm, rrset, &ttl, &rdlen);
if (ret == KNOT_EOK) {
ret = knot_rrset_parse_rdata(pkt_wire, pos, pkt_size, mm, ttl, rdlen,
ret = parse_rdata(pkt_wire, pos, pkt_size, mm, ttl, rdlen,
rrset);
if (ret != KNOT_EOK) {
knot_rrset_clear(rrset, mm);
......
......@@ -152,10 +152,6 @@ typedef enum knot_rrset_wire_flags knot_rrset_wire_flags_t;
int knot_rrset_to_wire(const knot_rrset_t *rrset, uint8_t *wire, uint16_t max_size,
struct knot_compr *compr, knot_rrset_wire_flags_t flags);
int knot_rrset_parse_rdata(const uint8_t *pkt_wire, size_t *pos, size_t pkt_size,
mm_ctx_t *mm, uint32_t ttl, uint16_t rdlength,
knot_rrset_t *rrset);
/*!
* \brief Creates one RR from wire, stores it into \a rrset.
*
......
......@@ -337,7 +337,6 @@ static knot_pkt_t* create_query_packet(const query_t *query)
if (query->type_num == KNOT_RRTYPE_IXFR) {
// SOA rdata in wireformat.
uint8_t wire[22] = { 0x0 };
size_t pos = 0;
// Create rrset with SOA record.
knot_rrset_t *soa = knot_rrset_new(qname,
......@@ -350,10 +349,9 @@ static knot_pkt_t* create_query_packet(const query_t *query)
return NULL;
}
/* TODO [rrset]: replace */
// Fill in blank SOA rdata to rrset.
ret = knot_rrset_parse_rdata(wire, &pos, sizeof(wire),
&packet->mm, 0, sizeof(wire), soa);
ret = knot_rrset_add_rdata(soa, wire, sizeof(wire), 0,
&packet->mm);
if (ret != KNOT_EOK) {
knot_rrset_free(&soa, &packet->mm);
knot_pkt_free(&packet);
......
......@@ -342,10 +342,8 @@ static int rr_list_append(zs_scanner_t *s, list_t *target_list, mm_ctx_t *mm)
}
/* Create RDATA. */
size_t pos = 0;
/* TODO [rrset]: replace */
int ret = knot_rrset_parse_rdata(s->r_data, &pos, s->r_data_length,
NULL, s->r_ttl, s->r_data_length, rr);
int ret = knot_rrset_add_rdata(rr, s->r_data, s->r_data_length,
s->r_ttl, NULL);
if (ret != KNOT_EOK) {
DBG("%s: failed to set rrset from wire - %s\n",
__func__, knot_strerror(ret));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment