Commit c6f4b294 authored by Daniel Salzman's avatar Daniel Salzman

rrset-wire: header cleanup

parent ffc9b4ea
......@@ -691,7 +691,7 @@ int knot_pkt_parse_rr(knot_pkt_t *pkt, unsigned flags)
size_t rr_size = pkt->parsed;
knot_rrset_t *rr = &pkt->rr[pkt->rrset_count];
ret = knot_rrset_rr_from_wire(pkt->wire, &pkt->parsed, pkt->size,
&pkt->mm, rr, !(flags & KNOT_PF_NOCANON));
rr, &pkt->mm, !(flags & KNOT_PF_NOCANON));
if (ret != KNOT_EOK) {
return ret;
}
......
......@@ -847,26 +847,26 @@ static int parse_rdata(const uint8_t *pkt_wire, size_t *pos, size_t pkt_size,
}
_public_
int knot_rrset_rr_from_wire(const uint8_t *pkt_wire, size_t *pos, size_t pkt_size,
knot_mm_t *mm, knot_rrset_t *rrset, bool canonical)
int knot_rrset_rr_from_wire(const uint8_t *wire, size_t *pos, size_t max_size,
knot_rrset_t *rrset, knot_mm_t *mm, bool canonical)
{
if (!pkt_wire || !pos || !rrset || *pos > pkt_size) {
if (wire == NULL || pos == NULL || *pos > max_size || rrset == NULL) {
return KNOT_EINVAL;
}
uint16_t rdlen = 0;
int ret = parse_header(pkt_wire, pos, pkt_size, mm, rrset, &rdlen);
int ret = parse_header(wire, pos, max_size, mm, rrset, &rdlen);
if (ret != KNOT_EOK) {
return ret;
}
ret = parse_rdata(pkt_wire, pos, pkt_size, mm, rdlen, rrset);
ret = parse_rdata(wire, pos, max_size, mm, rdlen, rrset);
if (ret != KNOT_EOK) {
knot_rrset_clear(rrset, mm);
return ret;
}
/* Convert RR to canonical format. */
// Convert RR to the canonical format.
if (canonical) {
ret = knot_rrset_rr_to_canonical(rrset);
if (ret != KNOT_EOK) {
......
......@@ -52,16 +52,16 @@ static inline int knot_rrset_to_wire(const knot_rrset_t *rrset, uint8_t *wire,
/*!
* \brief Creates one RR from wire, stores it into \a rrset.
*
* \param pkt_wire Source wire (the whole packet).
* \param pos Position in \a wire where to start parsing.
* \param pkt_size Total size of data in \a wire (size of the packet).
* \param mm Memory context.
* \param rrset Destination RRSet.
* \param canonical Convert rrset to canonical format indication.
* \param wire Source wire (the whole packet).
* \param pos Position in \a wire where to start parsing.
* \param max_size Total size of data in \a wire (size of the packet).
* \param rrset Destination RRSet.
* \param mm Memory context.
* \param canonical Convert rrset to canonical format indication.
*
* \return KNOT_E*
*/
int knot_rrset_rr_from_wire(const uint8_t *pkt_wire, size_t *pos, size_t pkt_size,
knot_mm_t *mm, knot_rrset_t *rrset, bool canonical);
int knot_rrset_rr_from_wire(const uint8_t *wire, size_t *pos, size_t max_size,
knot_rrset_t *rrset, knot_mm_t *mm, bool canonical);
/*! @} */
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -192,7 +192,7 @@ static const struct wire_data FROM_CASES[FROM_CASE_COUNT] = {
#define TEST_CASE_FROM(rrset, i) size_t _pos##i = FROM_CASES[i].pos; \
ok(knot_rrset_rr_from_wire(FROM_CASES[i].wire, &_pos##i, FROM_CASES[i].size, \
NULL, rrset, true) == FROM_CASES[i].code, "rrset wire: %s", FROM_CASES[i].msg)
rrset, NULL, true) == FROM_CASES[i].code, "rrset wire: %s", FROM_CASES[i].msg)
static void test_inputs(void)
{
......@@ -210,7 +210,7 @@ static void check_canon(uint8_t *wire, size_t size, size_t pos, bool canon,
knot_rrset_t rrset;
knot_rrset_init_empty(&rrset);
int ret = knot_rrset_rr_from_wire(wire, &pos, size, NULL, &rrset, canon);
int ret = knot_rrset_rr_from_wire(wire, &pos, size, &rrset, NULL, canon);
is_int(KNOT_EOK, ret, "OK %s canonization", canon ? "with" : "without");
ok(memcmp(rrset.owner, qname, knot_dname_size(qname)) == 0, "compare owner");
......
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