Skip to content

Commit

Permalink
- direct-rdata-storage, fix compile.
Browse files Browse the repository at this point in the history
  • Loading branch information
wcawijngaards committed Jan 14, 2025
1 parent a296b49 commit aafa83c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
6 changes: 3 additions & 3 deletions axfr.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ query_axfr(struct nsd *nsd, struct query *query, int wstats)
added = packet_encode_rr(query,
query->axfr_zone->apex,
&query->axfr_zone->soa_rrset->rrs[0],
query->axfr_zone->soa_rrset->rrs[0].ttl);
query->axfr_zone->soa_rrset->rrs[0]->ttl);
if (!added) {
/* XXX: This should never happen... generate error code? */
abort();
Expand Down Expand Up @@ -124,7 +124,7 @@ query_axfr(struct nsd *nsd, struct query *query, int wstats)
query,
query->axfr_current_domain,
&query->axfr_current_rrset->rrs[query->axfr_current_rr],
query->axfr_current_rrset->rrs[query->axfr_current_rr].ttl);
query->axfr_current_rrset->rrs[query->axfr_current_rr]->ttl);
if(total_added == 0) {
query->maxlen = oldmaxlen;
if(query_overflow(query)) {
Expand Down Expand Up @@ -155,7 +155,7 @@ query_axfr(struct nsd *nsd, struct query *query, int wstats)
added = packet_encode_rr(query,
query->axfr_zone->apex,
&query->axfr_zone->soa_rrset->rrs[0],
query->axfr_zone->soa_rrset->rrs[0].ttl);
query->axfr_zone->soa_rrset->rrs[0]->ttl);
if (added) {
++total_added;
query->tsig_sign_it = 1; /* sign last packet */
Expand Down
32 changes: 28 additions & 4 deletions dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

#ifndef DNS_H
#define DNS_H
struct rr;
struct buffer;
struct domain_table;
struct query;

enum rr_section {
QUESTION_SECTION,
Expand Down Expand Up @@ -234,14 +238,34 @@ typedef int32_t(*nsd_rdata_length_t)(
// offset is required for the ipsecgateway where we need to read a couple
// bytes back

/**
* Function signature to determine field length
* @param rdlength: remaining length of rdata.
* @param rdata: current byte position in rdata.
* @return a length or NSD_COMPRESSED_NAME and such.
*/
typedef int32_t(*nsd_rdata_field_length_t)(
uint16_t rdlength,
const uint8_t *rdata);

/**
* Function signature to print RR
* @param buffer: output buffer for text string.
* @param rr: the resource record to print.
* @return length, or MALFORMED.
*/
typedef int32_t(*nsd_print_rdata_field_t)(
struct buffer* buffer,
const struct rr* rr);

typedef struct nsd_rdata_descriptor nsd_rdata_descriptor_t;
// the descriptor table shouldn't be used for validation.
// the read function will take care of that. it's used for
// implementing copy functions that are very specific, but where
// the data has already been checked for validity..
struct nsd_rdata_descriptor {
const char *name;
bool is_optional; // << whether or not this field is optional...
int is_optional; // << whether or not this field is optional...
int32_t length; // << will be set to a specialized value if
// the length function should be used. i.e.
// for any type where the length depends on a value
Expand Down Expand Up @@ -332,9 +356,9 @@ struct nsd_type_descriptor {
/** Mnemonic. */
const char *name;
/** Whether internal RDATA contains direct pointers. */
bool has_references;
int has_references;
/** Whether RDATA contains compressible names. */
bool is_compressible;
int is_compressible;
nsd_read_rdata_t read_rdata;
nsd_write_rdata_t write_data;
nsd_print_rdata_t print_rdata;
Expand All @@ -353,7 +377,7 @@ struct nsd_type_descriptor {
* CLA + 1
*/
#define RRTYPE_DESCRIPTORS_LENGTH (TYPE_CLA + 1)
rrtype_descriptor_type *rrtype_descriptor_by_type(uint16_t type);
nsd_type_descriptor_t *rrtype_descriptor_by_type(uint16_t type);

const char *rrtype_to_string(uint16_t rrtype);

Expand Down
4 changes: 2 additions & 2 deletions namedb.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,15 @@ rrset_rrtype(rrset_type* rrset)
{
assert(rrset);
assert(rrset->rr_count > 0);
return rrset->rrs[0].type;
return rrset->rrs[0]->type;
}

static inline uint16_t
rrset_rrclass(rrset_type* rrset)
{
assert(rrset);
assert(rrset->rr_count > 0);
return rrset->rrs[0].klass;
return rrset->rrs[0]->klass;
}

/*
Expand Down

0 comments on commit aafa83c

Please sign in to comment.