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;
......
/*!
* \file rrset.h
*
* \author Lubos Slovak <lubos.slovak@nic.cz>
*
* \brief API for manipulating RDATA contents.
*
* \addtogroup libknot
* @{
*/
/* Copyright (C) 2013 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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _KNOT_RDATA_H_
#define _KNOT_RDATA_H_
#include "util/utils.h"
#include "rrset.h"
#include "dname.h"
static inline const knot_dname_t *knot_rdata_cname_name(
const knot_rrset_t *rrset)
{
if (rrset == NULL) {
return NULL;
}
return rrset->rdata;
}
static inline const knot_dname_t *knot_rdata_dname_target(
const knot_rrset_t *rrset)
{
if (rrset == NULL) {
return NULL;
}
return rrset->rdata;
}
static inline const knot_dname_t *knot_rdata_soa_primary_ns(
const knot_rrset_t *rrset)
{
if (rrset == NULL) {
return NULL;
}
return rrset->rdata;
}
static inline const knot_dname_t *knot_rdata_soa_mailbox(
const knot_rrset_t *rrset)
{
if (rrset == NULL) {
return NULL;
}
return rrset->rdata + knot_dname_size(rrset->rdata);
}
static inline size_t knot_rrset_rdata_soa_names_len(const knot_rrset_t *rrset)
{
if (rrset == NULL) {
return 0;
}
return knot_dname_size(knot_rdata_soa_primary_ns(rrset))
+ knot_dname_size(knot_rdata_soa_mailbox(rrset));
}
static inline uint32_t knot_rdata_soa_serial(const knot_rrset_t *rrset)
{
if (rrset == NULL) {
return 0;
}
return knot_wire_read_u32(rrset->rdata
+ knot_rrset_rdata_soa_names_len(rrset));
}
static inline void knot_rdata_soa_serial_set(knot_rrset_t *rrset,
uint32_t serial)
{
if (rrset == NULL) {
return;
}
// the number is in network byte order, transform it
knot_wire_write_u32(rrset->rdata
+ knot_rrset_rdata_soa_names_len(rrset), serial);
}
static inline uint32_t knot_rdata_soa_refresh(const knot_rrset_t *rrset)
{
if (rrset == NULL) {
return 0;
}
return knot_wire_read_u32(rrset->rdata
+ knot_rrset_rdata_soa_names_len(rrset) + 4);
}
static inline uint32_t knot_rdata_soa_retry(const knot_rrset_t *rrset)
{
if (rrset == NULL) {
return 0;
}
return knot_wire_read_u32(rrset->rdata
+ knot_rrset_rdata_soa_names_len(rrset) + 8);
}
static inline uint32_t knot_rdata_soa_expire(const knot_rrset_t *rrset)
{
if (rrset == NULL) {
return 0;
}
return knot_wire_read_u32(rrset->rdata
+ knot_rrset_rdata_soa_names_len(rrset) + 12);
}
static inline uint32_t knot_rdata_soa_minimum(const knot_rrset_t *rrset)
{
if (rrset == NULL) {
return 0;
}
return knot_wire_read_u32(rrset->rdata
+ knot_rrset_rdata_soa_names_len(rrset) + 16);
}
static inline uint16_t knot_rdata_rrsig_type_covered(const knot_rrset_t *rrset,
size_t pos)
{
if (rrset == NULL || rrset->rdata_count <= pos) {
return 0;
}
return knot_wire_read_u16(knot_rrset_get_rdata(rrset, pos));
}
static inline uint8_t knot_rdata_rrsig_algorithm(const knot_rrset_t *rrset,
size_t pos)
{
if (rrset == NULL || pos >= rrset->rdata_count) {
return 0;
}
return *(knot_rrset_get_rdata(rrset, pos) + 2);
}
static inline uint8_t knot_rdata_rrsig_labels(const knot_rrset_t *rrset,
size_t pos)
{
if (rrset == NULL || pos >= rrset->rdata_count) {
return 0;
}
return *(knot_rrset_get_rdata(rrset, pos) + 3);
}
static inline uint32_t knot_rdata_rrsig_original_ttl(const knot_rrset_t *rrset,
size_t pos)
{
if (rrset == NULL || pos >= rrset->rdata_count) {
return 0;
}
return knot_wire_read_u32(knot_rrset_get_rdata(rrset, pos) + 4);
}
static inline uint32_t knot_rdata_rrsig_sig_expiration(const knot_rrset_t *rrset,
size_t pos)
{
if (rrset == NULL || pos >= rrset->rdata_count) {
return 0;
}
return knot_wire_read_u32(knot_rrset_get_rdata(rrset, pos) + 8);
}
static inline uint32_t knot_rdata_rrsig_sig_inception(const knot_rrset_t *rrset,
size_t pos)
{
if (rrset == NULL || pos >= rrset->rdata_count) {
return 0;
}
return knot_wire_read_u32(knot_rrset_get_rdata(rrset, pos) + 12);
}
static inline uint16_t knot_rdata_rrsig_key_tag(const knot_rrset_t *rrset,
size_t pos)
{
if (rrset == NULL || pos >= rrset->rdata_count) {
return 0;
}
return knot_wire_read_u16(knot_rrset_get_rdata(rrset, pos) + 16);