Commit 655d5336 authored by Lubos Slovak's avatar Lubos Slovak

Moved RDATA manipulation functions to rdata.h.

Also simplified, cleaned and fixed.

refs #109
parent 2fd9cd3c
......@@ -153,6 +153,7 @@ src/libknot/packet/query.c
src/libknot/packet/query.h
src/libknot/packet/response.c
src/libknot/packet/response.h
src/libknot/rdata.h
src/libknot/rrset-dump.c
src/libknot/rrset-dump.h
src/libknot/rrset.c
......
......@@ -30,6 +30,7 @@
#include "libknot/packet/response.h"
#include "libknot/nameserver/name-server.h"
#include "libknot/tsig-op.h"
#include "libknot/rdata.h"
#define KNOT_CTL_REALM "knot."
#define KNOT_CTL_REALM_EXT ("." KNOT_CTL_REALM)
......@@ -100,7 +101,7 @@ static int remote_rdata_apply(server_t *s, remote_cmdargs_t* a, remote_zonef_t *
for (uint16_t i = 0; i < knot_rrset_rdata_rr_count(rr); i++) {
/* Refresh zones. */
const knot_dname_t *dn =
knot_rrset_rdata_ns_name(rr, i);
knot_rdata_ns_name(rr, i);
rcu_read_lock();
zone = knot_zonedb_find_zone(ns->zone_db, dn);
if (cb(s, zone) != KNOT_EOK) {
......@@ -228,7 +229,7 @@ static int remote_c_zonestatus(server_t *s, remote_cmdargs_t* a)
soa_rrs = knot_node_rrset(knot_zone_contents_apex(contents),
KNOT_RRTYPE_SOA);
assert(soa_rrs != NULL);
serial = knot_rrset_rdata_soa_serial(soa_rrs);
serial = knot_rdata_soa_serial(soa_rrs);
}
/* Evalute zone type. */
......
......@@ -34,6 +34,7 @@
#include "common/evsched.h"
#include "knot/other/debug.h"
#include "knot/server/server.h"
#include "libknot/rdata.h"
/* Messages. */
......@@ -266,7 +267,7 @@ int notify_process_request(knot_nameserver_t *ns,
const knot_rrset_t *soa_rr = NULL;
soa_rr = knot_packet_answer_rrset(notify, 0);
if (soa_rr && knot_rrset_type(soa_rr) == KNOT_RRTYPE_SOA) {
serial = knot_rrset_rdata_soa_serial(soa_rr);
serial = knot_rdata_soa_serial(soa_rr);
}
}
rcu_read_unlock();
......
......@@ -42,6 +42,7 @@
#include "libknot/packet/response.h"
#include "libknot/zone/zone-diff.h"
#include "libknot/updates/ddns.h"
#include "libknot/rdata.h"
static const size_t XFRIN_CHANGESET_BINARY_SIZE = 100;
static const size_t XFRIN_CHANGESET_BINARY_STEP = 100;
......@@ -168,7 +169,7 @@ static int zonedata_init(conf_zone_t *cfg, knot_zone_t *zone)
soa_rrs = knot_node_rrset(knot_zone_contents_apex(contents),
KNOT_RRTYPE_SOA);
assert(soa_rrs != NULL);
int64_t serial = knot_rrset_rdata_soa_serial(soa_rrs);
int64_t serial = knot_rdata_soa_serial(soa_rrs);
zd->zonefile_serial = (uint32_t)serial;
if (serial < 0) {
return KNOT_EINVAL;
......@@ -238,7 +239,7 @@ static uint32_t zones_soa_timer(knot_zone_t *zone,
*/
static uint32_t zones_soa_refresh(knot_zone_t *zone)
{
return zones_soa_timer(zone, knot_rrset_rdata_soa_refresh);
return zones_soa_timer(zone, knot_rdata_soa_refresh);
}
/*!
......@@ -249,7 +250,7 @@ static uint32_t zones_soa_refresh(knot_zone_t *zone)
*/
static uint32_t zones_soa_retry(knot_zone_t *zone)
{
return zones_soa_timer(zone, knot_rrset_rdata_soa_retry);
return zones_soa_timer(zone, knot_rdata_soa_retry);
}
/*!
......@@ -260,7 +261,7 @@ static uint32_t zones_soa_retry(knot_zone_t *zone)
*/
static uint32_t zones_soa_expire(knot_zone_t *zone)
{
return zones_soa_timer(zone, knot_rrset_rdata_soa_expire);
return zones_soa_timer(zone, knot_rdata_soa_expire);
}
/*!
......@@ -710,7 +711,7 @@ int zones_changesets_from_binary(knot_changesets_t *chgsets)
knot_rrset_type(rrset));
assert(knot_rrset_type(rrset) == KNOT_RRTYPE_SOA);
assert(chs->serial_from ==
knot_rrset_rdata_soa_serial(rrset));
knot_rdata_soa_serial(rrset));
knot_changeset_store_soa(&chs->soa_from, &chs->serial_from,
rrset);
......@@ -945,7 +946,7 @@ static int zones_journal_apply(knot_zone_t *zone)
soa_rrs = knot_node_rrset(knot_zone_contents_apex(contents),
KNOT_RRTYPE_SOA);
assert(soa_rrs != NULL);
int64_t serial_ret = knot_rrset_rdata_soa_serial(soa_rrs);
int64_t serial_ret = knot_rdata_soa_serial(soa_rrs);
if (serial_ret < 0) {
rcu_read_unlock();
return KNOT_EINVAL;
......@@ -1095,7 +1096,7 @@ static int zones_insert_zone(conf_zone_t *z, knot_zone_t **dst,
KNOT_RRTYPE_SOA);
int64_t sn = 0;
if (apex && soa) {
sn = knot_rrset_rdata_soa_serial(soa);
sn = knot_rdata_soa_serial(soa);
if (sn < 0) sn = 0;
}
log_server_info("Loaded zone '%s' serial %u\n",
......@@ -1909,7 +1910,7 @@ int zones_zonefile_sync(knot_zone_t *zone, journal_t *journal)
KNOT_RRTYPE_SOA);
assert(soa_rrs != NULL);
int64_t serial_ret = knot_rrset_rdata_soa_serial(soa_rrs);
int64_t serial_ret = knot_rdata_soa_serial(soa_rrs);
if (serial_ret < 0) {
rcu_read_unlock();
pthread_mutex_unlock(&zd->lock);
......
......@@ -30,6 +30,7 @@
#include "common/crc.h"
#include "common/descriptor.h"
#include "common/mempattern.h"
#include "libknot/rdata.h"
#include "semantic-check.h"
......@@ -295,7 +296,7 @@ static int check_rrsig_rdata(err_handler_t *handler,
return KNOT_EOK;
}
if (knot_rrset_rdata_rrsig_type_covered(rrsig) !=
if (knot_rdata_rrsig_type_covered(rrsig, 1) !=
knot_rrset_type(rrset)) {
/* zoneparser would not let this happen
* but to be on the safe side
......@@ -306,7 +307,7 @@ static int check_rrsig_rdata(err_handler_t *handler,
}
/* label number at the 2nd index should be same as owner's */
uint8_t labels_rdata = knot_rrset_rdata_rrsig_labels(rrsig, rr_pos);
uint8_t labels_rdata = knot_rdata_rrsig_labels(rrsig, rr_pos);
int tmp = knot_dname_labels(knot_rrset_owner(rrset), NULL) - labels_rdata;
......@@ -327,7 +328,7 @@ static int check_rrsig_rdata(err_handler_t *handler,
/* check original TTL */
uint32_t original_ttl =
knot_rrset_rdata_rrsig_original_ttl(rrsig, rr_pos);
knot_rdata_rrsig_original_ttl(rrsig, rr_pos);
if (original_ttl != knot_rrset_ttl(rrset)) {
err_handler_handle_error(handler, node, ZC_ERR_RRSIG_RDATA_TTL,
......@@ -336,7 +337,7 @@ static int check_rrsig_rdata(err_handler_t *handler,
/* signer's name is same as in the zone apex */
const knot_dname_t *signer_name =
knot_rrset_rdata_rrsig_signer_name(rrsig, rr_pos);
knot_rdata_rrsig_signer_name(rrsig, rr_pos);
/* dnskey is in the apex node */
if (knot_dname_cmp(signer_name,
......@@ -351,12 +352,12 @@ static int check_rrsig_rdata(err_handler_t *handler,
* before */
int match = 0;
uint8_t rrsig_alg = knot_rrset_rdata_rrsig_algorithm(rrsig, rr_pos);
uint16_t key_tag_rrsig = knot_rrset_rdata_rrsig_key_tag(rrsig, rr_pos);
uint8_t rrsig_alg = knot_rdata_rrsig_algorithm(rrsig, rr_pos);
uint16_t key_tag_rrsig = knot_rdata_rrsig_key_tag(rrsig, rr_pos);
for (uint16_t i = 0; i < knot_rrset_rdata_rr_count(dnskey_rrset) &&
!match; ++i) {
uint8_t dnskey_alg =
knot_rrset_rdata_dnskey_alg(dnskey_rrset, i);
knot_rdata_dnskey_alg(dnskey_rrset, i);
if (rrsig_alg != dnskey_alg) {
continue;
}
......@@ -526,9 +527,9 @@ static int rdata_nsec_to_type_array(const knot_rrset_t *rrset, size_t pos,
uint8_t *data = NULL;
uint16_t rr_bitmap_size = 0;
if (rrset->type == KNOT_RRTYPE_NSEC) {
knot_rrset_rdata_nsec_bitmap(rrset, pos, &data, &rr_bitmap_size);
knot_rdata_nsec_bitmap(rrset, pos, &data, &rr_bitmap_size);
} else {
knot_rrset_rdata_nsec3_bitmap(rrset, pos, &data, &rr_bitmap_size);
knot_rdata_nsec3_bitmap(rrset, pos, &data, &rr_bitmap_size);
}
if (data == NULL) {
return KNOT_EMALF;
......@@ -636,7 +637,7 @@ static int check_nsec3_node_in_zone(knot_zone_contents_t *zone,
/* check for Opt-Out flag */
uint8_t flags =
knot_rrset_rdata_nsec3_flags(previous_rrset, 0);
knot_rdata_nsec3_flags(previous_rrset, 0);
uint8_t opt_out_mask = 1;
if (!(flags & opt_out_mask)) {
......@@ -658,7 +659,7 @@ static int check_nsec3_node_in_zone(knot_zone_contents_t *zone,
knot_node_rrset(knot_zone_contents_apex(zone),
KNOT_RRTYPE_SOA);
assert(soa_rrset);
uint32_t minimum_ttl = knot_rrset_rdata_soa_minimum(soa_rrset);
uint32_t minimum_ttl = knot_rdata_soa_minimum(soa_rrset);
if (knot_rrset_ttl(nsec3_rrset) != minimum_ttl) {
err_handler_handle_error(handler, node,
......@@ -669,7 +670,7 @@ static int check_nsec3_node_in_zone(knot_zone_contents_t *zone,
uint8_t *next_dname_str = NULL;
uint8_t next_dname_size = 0;
uint8_t *next_dname_decoded = NULL;
knot_rrset_rdata_nsec3_next_hashed(nsec3_rrset, 0, &next_dname_str,
knot_rdata_nsec3_next_hashed(nsec3_rrset, 0, &next_dname_str,
&next_dname_size);
size_t real_size =
base32hex_encode_alloc(next_dname_str,
......@@ -880,7 +881,7 @@ static int sem_check_node_optional(knot_zone_contents_t *zone,
/* TODO How about multiple RRs? */
knot_dname_t *ns_dname =
knot_dname_copy(knot_rrset_rdata_ns_name(ns_rrset,
knot_dname_copy(knot_rdata_ns_name(ns_rrset,
0));
if (ns_dname == NULL) {
return KNOT_ENOMEM;
......@@ -1076,7 +1077,7 @@ static int semantic_checks_dnssec(knot_zone_contents_t *zone,
if (nsec_rrset != NULL) {
const knot_dname_t *next_domain =
knot_rrset_rdata_nsec_next(nsec_rrset, 0);
knot_rdata_nsec_next(nsec_rrset, 0);
assert(next_domain);
if (knot_zone_contents_find_node(zone,
......@@ -1219,7 +1220,7 @@ void log_cyclic_errors_in_zone(err_handler_t *handler,
uint8_t *next_dname_str = NULL;
uint8_t next_dname_size = 0;
uint8_t *next_dname_decoded = NULL;
knot_rrset_rdata_nsec3_next_hashed(nsec3_rrset, 0, &next_dname_str,
knot_rdata_nsec3_next_hashed(nsec3_rrset, 0, &next_dname_str,
&next_dname_size);
size_t real_size =
base32hex_encode_alloc(next_dname_str,
......@@ -1287,7 +1288,7 @@ void log_cyclic_errors_in_zone(err_handler_t *handler,
}
const knot_dname_t *next_dname =
knot_rrset_rdata_nsec_next(nsec_rrset, 0);
knot_rdata_nsec_next(nsec_rrset, 0);
assert(next_dname);
const knot_dname_t *apex_dname =
......
......@@ -34,6 +34,7 @@
#include "knot/other/debug.h"
#include "knot/zone/zone-load.h"
#include "zscanner/file_loader.h"
#include "libknot/rdata.h"
/* ZONE LOADING FROM FILE USING RAGEL PARSER */
......@@ -94,16 +95,16 @@ static int find_rrset_for_rrsig_in_node(knot_zone_contents_t *zone,
knot_rrset_t *tmp_rrset =
knot_node_get_rrset(node,
knot_rrset_rdata_rrsig_type_covered(rrsig));
knot_rdata_rrsig_type_covered(rrsig, 1));
int ret;
if (tmp_rrset == NULL) {
dbg_zp("zp: find_rr_for_sig_in_node: Node does not contain "
"RRSet of type %d.\n",
knot_rrset_rdata_rrsig_type_covered(rrsig));
knot_rdata_rrsig_type_covered(rrsig, 1));
tmp_rrset = knot_rrset_new(knot_dname_copy(rrsig->owner),
knot_rrset_rdata_rrsig_type_covered(rrsig),
knot_rdata_rrsig_type_covered(rrsig, 1),
rrsig->rclass,
rrsig->ttl);
if (tmp_rrset == NULL) {
......@@ -130,7 +131,7 @@ static int find_rrset_for_rrsig_in_node(knot_zone_contents_t *zone,
log_zone_warning("RRSIG owned by: %s (covering type %d) cannot be added to "
"its RRSet, because their TTLs differ. "
"Changing TTL=%d to value=%d.\n",
name, knot_rrset_rdata_rrsig_type_covered(rrsig),
name, knot_rdata_rrsig_type_covered(rrsig, 1),
rrsig->ttl, tmp_rrset->ttl);
free(name);
}
......@@ -349,7 +350,7 @@ static void process_rr(const scanner_t *scanner)
uint16_t type_covered = 0;
if (current_rrset->type == KNOT_RRTYPE_RRSIG) {
type_covered =
knot_rrset_rdata_rrsig_type_covered(current_rrset);
knot_rdata_rrsig_type_covered(current_rrset, 1);
}
if (current_rrset->type != KNOT_RRTYPE_NSEC3 &&
......
......@@ -46,6 +46,7 @@
#include "zone/node.h"
#include "zone/zone.h"
#include "zone/zonedb.h"
#include "rdata.h"
#endif
......
......@@ -37,6 +37,7 @@
#include "updates/changesets.h"
#include "updates/ddns.h"
#include "tsig-op.h"
#include "libknot/rdata.h"
/*----------------------------------------------------------------------------*/
......@@ -425,7 +426,7 @@ dbg_ns_exec_verb(
// get the name from the CNAME RDATA
const knot_dname_t *cname =
knot_rrset_rdata_cname_name(cname_rrset);
knot_rdata_cname_name(cname_rrset);
dbg_ns_detail("CNAME name from RDATA: %p\n", cname);
/* Attempt to find mentioned name in zone. */
......@@ -651,7 +652,7 @@ static int ns_put_additional_for_rrset(knot_packet_t *resp,
for (uint16_t i = 0; i < knot_rrset_rdata_rr_count(rrset); i++) {
dbg_ns_verb("Getting name from RDATA, type %u..\n",
knot_rrset_type(rrset));
const knot_dname_t *dname = knot_rrset_rdata_name(rrset, i);
const knot_dname_t *dname = knot_rdata_name(rrset, i);
assert(dname);
dbg_ns_exec_detail(
char *name = knot_dname_to_str(dname);
......@@ -886,7 +887,7 @@ static int ns_put_authority_soa(const knot_zone_contents_t *zone,
// if SOA's TTL is larger than MINIMUM, copy the RRSet and set
// MINIMUM as TTL
uint32_t min = knot_rrset_rdata_soa_minimum(soa_rrset);
uint32_t min = knot_rdata_soa_minimum(soa_rrset);
if (min < knot_rrset_ttl(soa_rrset)) {
knot_rrset_t *soa_copy = NULL;
ret = knot_rrset_deep_copy(soa_rrset, &soa_copy);
......@@ -1963,7 +1964,7 @@ static knot_rrset_t *ns_cname_from_dname(const knot_rrset_t *dname_rrset,
/* Replace last labels of qname with DNAME. */
const knot_dname_t *dname_wire = knot_rrset_owner(dname_rrset);
size_t labels = knot_dname_labels(dname_wire, NULL);
const knot_dname_t *dname_tgt = knot_rrset_rdata_dname_target(dname_rrset);
const knot_dname_t *dname_tgt = knot_rdata_dname_target(dname_rrset);
knot_dname_t *cname = knot_dname_replace_suffix(qname, labels, dname_tgt);
if (cname == NULL) {
knot_rrset_free(&cname_rrset);
......@@ -2005,7 +2006,7 @@ static int ns_dname_is_too_long(const knot_rrset_t *rrset,
// TODO: add function for getting DNAME target
if (knot_dname_labels(qname, NULL)
- knot_dname_labels(knot_rrset_owner(rrset), NULL)
+ knot_dname_labels(knot_rrset_rdata_dname_target(rrset), NULL)
+ knot_dname_labels(knot_rdata_dname_target(rrset), NULL)
> KNOT_DNAME_MAXLEN) {
return 1;
} else {
......@@ -2071,7 +2072,7 @@ dbg_ns_exec_verb(
}
// get the next SNAME from the CNAME RDATA
const knot_dname_t *cname = knot_rrset_rdata_cname_name(synth_cname);
const knot_dname_t *cname = knot_rdata_cname_name(synth_cname);
dbg_ns_verb("CNAME name from RDATA: %p\n", cname);
// save the new name which should be used for replacing wildcard
......@@ -2932,8 +2933,8 @@ static int ns_ixfr_from_zone(knot_ns_xfr_t *xfr)
} else {
log_zone_info("%s Serial %u -> %u.\n",
xfr->msg,
knot_rrset_rdata_soa_serial(chs->soa_from),
knot_rrset_rdata_soa_serial(chs->soa_to));
knot_rdata_soa_serial(chs->soa_from),
knot_rdata_soa_serial(chs->soa_to));
}
}
......@@ -3904,9 +3905,9 @@ int ns_ixfr_load_serials(const knot_ns_xfr_t *xfr, uint32_t *serial_from,
}
// retrieve origin (xfr) serial and target (zone) serial
*serial_to = knot_rrset_rdata_soa_serial(zone_soa);
*serial_to = knot_rdata_soa_serial(zone_soa);
*serial_from =
knot_rrset_rdata_soa_serial(knot_packet_authority_rrset(xfr->query, 0));
knot_rdata_soa_serial(knot_packet_authority_rrset(xfr->query, 0));
return KNOT_EOK;
}
......@@ -4212,8 +4213,8 @@ int knot_ns_process_ixfrin(knot_nameserver_t *nameserver,
}
if (ns_serial_compare(
knot_rrset_rdata_soa_serial(chgsets->first_soa),
knot_rrset_rdata_soa_serial(zone_soa))
knot_rdata_soa_serial(chgsets->first_soa),
knot_rdata_soa_serial(zone_soa))
> 0) {
if ((xfr->flags & XFR_FLAG_UDP) != 0) {
// IXFR over UDP
......
......@@ -29,6 +29,7 @@
#include "util/utils.h"
#include "util/tolower.h"
#include "util/debug.h"
#include "rdata.h"
/*----------------------------------------------------------------------------*/
......@@ -42,11 +43,11 @@ int knot_nsec3_params_from_wire(knot_nsec3_params_t *params,
assert(knot_rrset_type(nsec3param) == KNOT_RRTYPE_NSEC3PARAM);
params->algorithm = knot_rrset_rdata_nsec3param_algorithm(nsec3param);
params->iterations = knot_rrset_rdata_nsec3param_iterations(nsec3param);
params->flags = knot_rrset_rdata_nsec3param_flags(nsec3param);
params->algorithm = knot_rdata_nsec3param_algorithm(nsec3param, 1);
params->iterations = knot_rdata_nsec3param_iterations(nsec3param, 1);
params->flags = knot_rdata_nsec3param_flags(nsec3param, 1);
params->salt_length =
knot_rrset_rdata_nsec3param_salt_length(nsec3param);
knot_rdata_nsec3param_salt_length(nsec3param, 1);
if (params->salt_length > 0) {
/* It is called also on reload, so we need to free if exists. */
......@@ -57,7 +58,7 @@ int knot_nsec3_params_from_wire(knot_nsec3_params_t *params,
params->salt = (uint8_t *)malloc(params->salt_length);
CHECK_ALLOC_LOG(params->salt, KNOT_ENOMEM);
memcpy(params->salt,
knot_rrset_rdata_nsec3param_salt(nsec3param),
knot_rdata_nsec3param_salt(nsec3param, 1),
params->salt_length);
} else {
params->salt = NULL;
......
This diff is collapsed.
This diff is collapsed.
......@@ -330,82 +330,6 @@ int knot_rrset_merge(knot_rrset_t *rrset1, const knot_rrset_t *rrset2);
int knot_rrset_merge_sort(knot_rrset_t *rrset1, const knot_rrset_t *rrset2,
int *merged, int *deleted_rrs);
const knot_dname_t *knot_rrset_rdata_cname_name(const knot_rrset_t *rrset);
const knot_dname_t *knot_rrset_rdata_dname_target(const knot_rrset_t *rrset);
void knot_rrset_rdata_set_cname_name(knot_rrset_t *rrset,
const knot_dname_t *name);
void knot_rrset_rdata_set_dname_target(knot_rrset_t *rrset,
const knot_dname_t *target);
const knot_dname_t *knot_rrset_rdata_soa_primary_ns(const knot_rrset_t *rrset);
const knot_dname_t *knot_rrset_rdata_soa_mailbox(const knot_rrset_t *rrset);
uint32_t knot_rrset_rdata_soa_serial(const knot_rrset_t *rrset);
void knot_rrset_rdata_soa_serial_set(knot_rrset_t *rrset, uint32_t serial);
uint32_t knot_rrset_rdata_soa_refresh(const knot_rrset_t *rrset);
uint32_t knot_rrset_rdata_soa_retry(const knot_rrset_t *rrset);
uint32_t knot_rrset_rdata_soa_expire(const knot_rrset_t *rrset);
uint32_t knot_rrset_rdata_soa_minimum(const knot_rrset_t *rrset);
uint16_t knot_rrset_rdata_rrsig_type_covered(const knot_rrset_t *rrset);
uint8_t knot_rrset_rdata_rrsig_algorithm(const knot_rrset_t *rrset,
size_t rr_pos);
uint8_t knot_rrset_rdata_rrsig_labels(const knot_rrset_t *rrset, size_t rr_pos);
uint32_t knot_rrset_rdata_rrsig_original_ttl(const knot_rrset_t *rrset,
size_t rr_pos);
uint32_t knot_rrset_rdata_rrsig_sig_expiration(const knot_rrset_t *rrset,
size_t rr_pos);
uint32_t knot_rrset_rdata_rrsig_sig_inception(const knot_rrset_t *rrset,
size_t rr_pos);
uint16_t knot_rrset_rdata_rrsig_key_tag(const knot_rrset_t *rrset,
size_t rr_pos);
const knot_dname_t *knot_rrset_rdata_rrsig_signer_name(const knot_rrset_t *rrset,
size_t rr_pos);
uint16_t knot_rrset_rdata_dnskey_flags(const knot_rrset_t *rrset, size_t rr_pos);
uint8_t knot_rrset_rdata_dnskey_proto(const knot_rrset_t *rrset, size_t rr_pos);
uint8_t knot_rrset_rdata_dnskey_alg(const knot_rrset_t *rrset, size_t rr_pos);
void knot_rrset_rdata_dnskey_key(const knot_rrset_t *rrset, size_t rr_pos,
uint8_t **key, uint16_t *key_size);
const knot_dname_t *knot_rrset_rdata_nsec_next(const knot_rrset_t *rrset,
size_t rr_pos);
void knot_rrset_rdata_nsec_bitmap(const knot_rrset_t *rrset, size_t rr_pos,
uint8_t **bitmap, uint16_t *size);
void knot_rrset_rdata_nsec3_bitmap(const knot_rrset_t *rrset, size_t rr_pos,
uint8_t **bitmap, uint16_t *size);
uint8_t knot_rrset_rdata_nsec3_algorithm(const knot_rrset_t *rrset,
size_t pos);
uint8_t knot_rrset_rdata_nsec3_flags(const knot_rrset_t *rrset,
size_t pos);
uint16_t knot_rrset_rdata_nsec3_iterations(const knot_rrset_t *rrset,
size_t pos);
uint8_t knot_rrset_rdata_nsec3_salt_length(const knot_rrset_t *rrset,
size_t pos);
void knot_rrset_rdata_nsec3_next_hashed(const knot_rrset_t *rrset, size_t pos,
uint8_t **name, uint8_t *name_size);
const uint8_t *knot_rrset_rdata_nsec3_salt(const knot_rrset_t *rrset,
size_t pos);
uint8_t knot_rrset_rdata_nsec3param_algorithm(const knot_rrset_t *rrset);
uint8_t knot_rrset_rdata_nsec3param_flags(const knot_rrset_t *rrset);
uint16_t knot_rrset_rdata_nsec3param_iterations(const knot_rrset_t *rrset);
uint8_t knot_rrset_rdata_nsec3param_salt_length(const knot_rrset_t *rrset);
const uint8_t *knot_rrset_rdata_nsec3param_salt(const knot_rrset_t *rrset);
const knot_dname_t *knot_rrset_rdata_rp_first_dname(const knot_rrset_t *rrset,
size_t pos);
const knot_dname_t *knot_rrset_rdata_rp_second_dname(const knot_rrset_t *rrset,
size_t pos);
const knot_dname_t *knot_rrset_rdata_minfo_first_dname(const knot_rrset_t *rrset,
size_t pos);
const knot_dname_t *knot_rrset_rdata_minfo_second_dname(const knot_rrset_t *rrset,
size_t pos);
const knot_dname_t *knot_rrset_rdata_ns_name(const knot_rrset_t *rrset,
size_t rdata_pos);
const knot_dname_t *knot_rrset_rdata_mx_name(const knot_rrset_t *rrset,
size_t rdata_pos);
const knot_dname_t *knot_rrset_rdata_srv_name(const knot_rrset_t *rrset,
size_t rdata_pos);
const knot_dname_t *knot_rrset_rdata_name(const knot_rrset_t *rrset,
size_t rdata_pos);
void knot_rrset_dump(const knot_rrset_t *rrset);
//TODO test
......@@ -442,6 +366,9 @@ int knot_rrset_rdata_from_wire_one(knot_rrset_t *rrset,
size_t total_size, size_t rdlength);
int knot_rrset_ds_check(const knot_rrset_t *rrset);
uint8_t *rrset_rdata_pointer(const knot_rrset_t *rrset, size_t pos);
#endif /* _KNOT_RRSET_H_ */
/*! @} */
......@@ -24,6 +24,7 @@
#include "common/descriptor.h"
#include "rrset.h"
#include "util/debug.h"
#include "rdata.h"
static const size_t KNOT_CHANGESET_COUNT = 5;
static const size_t KNOT_CHANGESET_STEP = 5;
......@@ -66,8 +67,8 @@ static int knot_changeset_rrsets_match(const knot_rrset_t *rrset1,
{
return knot_rrset_equal(rrset1, rrset2, KNOT_RRSET_COMPARE_HEADER)
&& (knot_rrset_type(rrset1) != KNOT_RRTYPE_RRSIG
|| knot_rrset_rdata_rrsig_type_covered(rrset1)
== knot_rrset_rdata_rrsig_type_covered(rrset2));
|| knot_rdata_rrsig_type_covered(rrset1, 1)
== knot_rdata_rrsig_type_covered(rrset2, 1));
}
/*----------------------------------------------------------------------------*/
......@@ -204,7 +205,7 @@ void knot_changeset_store_soa(knot_rrset_t **chg_soa,
uint32_t *chg_serial, knot_rrset_t *soa)
{
*chg_soa = soa;
*chg_serial = knot_rrset_rdata_soa_serial(soa);
*chg_serial = knot_rdata_soa_serial(soa);
}
/*----------------------------------------------------------------------------*/
......
......@@ -29,6 +29,7 @@
#include "nameserver/name-server.h" // ns_serial_compare() - TODO: extract
#include "updates/xfr-in.h"
#include "common/descriptor.h"
#include "rdata.h"
/*----------------------------------------------------------------------------*/
// Copied from XFR - maybe extract somewhere else
......@@ -677,7 +678,7 @@ int knot_ddns_process_update(const knot_zone_contents_t *zone,
}
/* Current SERIAL */
int64_t sn = knot_rrset_rdata_soa_serial(soa_begin);
int64_t sn = knot_rdata_soa_serial(soa_begin);
int64_t sn_new;
/* Incremented SERIAL
* We must set it now to be able to compare SERIAL from SOAs in the
......@@ -730,9 +731,9 @@ int knot_ddns_process_update(const knot_zone_contents_t *zone,
* RRSet. This should be handled somehow.
*/
if (knot_rrset_type(rrset) == KNOT_RRTYPE_SOA
&& ns_serial_compare(knot_rrset_rdata_soa_serial(rrset),
&& ns_serial_compare(knot_rdata_soa_serial(rrset),
sn_new) > 0) {
sn_new = knot_rrset_rdata_soa_serial(rrset);
sn_new = knot_rdata_soa_serial(rrset);
soa_end = (knot_rrset_t *)rrset_copy;
}
}
......@@ -747,7 +748,7 @@ int knot_ddns_process_update(const knot_zone_contents_t *zone,
knot_strerror(ret));
return ret;
}
knot_rrset_rdata_soa_serial_set(soa_end, sn_new);
knot_rdata_soa_serial_set(soa_end, sn_new);
}
knot_changeset_store_soa(&changeset->soa_to,
......@@ -903,7 +904,7 @@ static int knot_ddns_rr_is_nsec3(const knot_rrset_t *rr)
if ((knot_rrset_type(rr) == KNOT_RRTYPE_NSEC3)
|| (knot_rrset_type(rr) == KNOT_RRTYPE_RRSIG
&& knot_rrset_rdata_rr_count(rr)
&& knot_rrset_rdata_rrsig_type_covered(rr)
&& knot_rdata_rrsig_type_covered(rr, 1)
== KNOT_RRTYPE_NSEC3))
{
dbg_ddns_detail("This is NSEC3-related RRSet.\n");
......@@ -1117,8 +1118,8 @@ static int knot_ddns_process_add_soa(knot_node_t *node,
}
/* Check that the serial is indeed larger than the current one*/
assert(ns_serial_compare(knot_rrset_rdata_soa_serial(removed),
knot_rrset_rdata_soa_serial(rr)) < 0);
assert(ns_serial_compare(knot_rdata_soa_serial(removed),
knot_rdata_soa_serial(rr)) < 0);
/* 1) Store it to 'changes', together with its RRSIGs. */
ret = knot_changes_add_old_rrsets(
......@@ -1397,7 +1398,7 @@ static int knot_ddns_add_rr(knot_node_t *node, const knot_rrset_t *rr,
uint16_t type = knot_rrset_type(rr);
uint16_t type_covered = (type == KNOT_RRTYPE_RRSIG)
? knot_rrset_rdata_rrsig_type_covered(rr)
? knot_rdata_rrsig_type_covered(rr, 1)
: type;
/* If the RR belongs to a RRSet already present in the node, we must
......@@ -1686,7 +1687,7 @@ static int knot_ddns_process_rem_rr(const knot_rrset_t *rr,
* 1) Copy the RRSet.
*/
uint16_t type_to_copy = (type != KNOT_RRTYPE_RRSIG) ? type
: knot_rrset_rdata_rrsig_type_covered(rr);
: knot_rdata_rrsig_type_covered(rr, 1);
knot_rrset_t *rrset_copy = NULL;
int ret = xfrin_copy_rrset(node, type_to_copy, &rrset_copy, changes, 1);
if (ret < 0) {
......@@ -2317,7 +2318,7 @@ int knot_ddns_process_update2(knot_zone_contents_t *zone,
}
/* Current SERIAL */
int64_t sn = knot_rrset_rdata_soa_serial(soa_begin);
int64_t sn = knot_rdata_soa_serial(soa_begin);
int64_t sn_new;
/* Incremented SERIAL
......@@ -2369,7 +2370,7 @@ int knot_ddns_process_update2(knot_zone_contents_t *zone,
if (knot_rrset_type(rr) == KNOT_RRTYPE_SOA
&& (knot_rrset_class(rr) == KNOT_CLASS_NONE
|| knot_rrset_class(rr) == KNOT_CLASS_ANY
|| ns_serial_compare(knot_rrset_rdata_soa_serial(rr),
|| ns_serial_compare(knot_rdata_soa_serial(rr),
sn_new) < 0)) {
// This ignores also SOA removals
dbg_ddns_verb("Ignoring SOA...\n");
......@@ -2391,7 +2392,7 @@ int knot_ddns_process_update2(knot_zone_contents_t *zone,
// we need the RR copy, that's why this code is here
if (knot_rrset_type(rr) == KNOT_RRTYPE_SOA) {
int64_t sn_rr = knot_rrset_rdata_soa_serial(rr);
int64_t sn_rr = knot_rdata_soa_serial(rr);
dbg_ddns_verb("Replacing SOA. Old serial: %"PRId64", "
"new serial: %"PRId64"\n", sn_new, sn_rr);
assert(ns_serial_compare(sn_rr, sn_new) >= 0);
......@@ -2420,7 +2421,7 @@ int knot_ddns_process_update2(knot_zone_contents_t *zone,
*rcode = KNOT_RCODE_SERVFAIL;
return ret;
}
knot_rrset_rdata_soa_serial_set(soa_end, sn_new);
knot_rdata_soa_serial_set(soa_end, sn_new);
/* And replace it in the zone. */
ret = xfrin_replace_rrset_in_node(
......
......@@ -34,6 +34,7 @@
#include "tsig.h"
#include "tsig-op.h"
#include "common/descriptor.h"
#include "rdata.h"
/*----------------------------------------------------------------------------*/
/* Non-API functions */
......@@ -176,7 +177,7 @@ int xfrin_transfer_needed(const knot_zone_contents_t *zone,
return KNOT_ERROR;
}
int64_t local_serial = knot_rrset_rdata_soa_serial(soa_rrset);
int64_t local_serial = knot_rdata_soa_serial(soa_rrset);
if (local_serial < 0) {
dbg_xfrin_exec(
char *name = knot_dname_to_str(knot_rrset_owner(soa_rrset));
......@@ -196,7 +197,7 @@ dbg_xfrin_exec(
return KNOT_EMALF;
}
int64_t remote_serial = knot_rrset_rdata_soa_serial(soa_rrset);
int64_t remote_serial = knot_rdata_soa_serial(soa_rrset);
if (remote_serial < 0) {
return KNOT_EMALF; // maybe some other error
}
......@@ -265,7 +266,7 @@ static int xfrin_process_orphan_rrsigs(knot_zone_contents_t *zone,
char *name = knot_dname_to_str((*last)->rrsig->owner);
char type[16];
knot_rrtype_to_string(
knot_rrset_rdata_rrsig_type_covered((*last)->rrsig),
knot_rdata_rrsig_type_covered((*last)->rrsig, 1),
type, 16);
log_zone_warning("No RRSet for RRSIG: "
......@@ -1077,8 +1078,8 @@ dbg_xfrin_exec_verb(
goto cleanup;
}
if (knot_rrset_rdata_soa_serial(rr)
== knot_rrset_rdata_soa_serial((*chs)->first_soa)) {
if (knot_rdata_soa_serial(rr)
== knot_rdata_soa_serial((*chs)->first_soa)) {
/*! \note [TSIG] Check TSIG, we're at the end of
* transfer.
......@@ -1155,8 +1156,8 @@ dbg_xfrin_exec_verb(
if (knot_rrset_type(rr) == KNOT_RRTYPE_SOA) {
log_zone_info("%s Serial %u -> %u.\n",
xfr->msg,
knot_rrset_rdata_soa_serial(cur->soa_from),
knot_rrset_rdata_soa_serial(cur->soa_to));
knot_rdata_soa_serial(cur->soa_from),
knot_rdata_soa_serial(cur->soa_to));
state = -1;
continue;
} else {
......@@ -1395,15 +1396,14 @@ static int xfrin_apply_remove_rrsigs(knot_changes_t *changes,
if (*rrset
&& knot_dname_is_equal(knot_rrset_owner(*rrset), knot_node_owner(node))
&& knot_rrset_type(*rrset) == knot_rrset_rdata_rrsig_type_covered(remove)) {
&& knot_rrset_type(*rrset) == knot_rdata_rrsig_type_covered(remove, 1)) {
// this RRSet should be the already copied RRSet so we may
// update it right away
/*! \todo Does this case even occur? */
dbg_xfrin_verb("Using RRSet from previous iteration.\n");
} else {
// find RRSet based on the Type Covered
uint16_t type =
knot_rrset_rdata_rrsig_type_covered(remove);
uint16_t type = knot_rdata_rrsig_type_covered(remove, 1);