Skip to content

Commit

Permalink
- direct-rdata-storage, implement RR type ATMA.
Browse files Browse the repository at this point in the history
  • Loading branch information
wcawijngaards committed Jan 21, 2025
1 parent 25023a3 commit 03b0c07
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
10 changes: 7 additions & 3 deletions dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ static const struct nsd_rdata_descriptor srv_rdata_fields[] = {
FIELD("target", RDATA_UNCOMPRESSED_DNAME)
};

static const struct nsd_rdata_descriptor atma_rdata_fields[] = {
FIELD("address", RDATA_REMAINDER)
};

static const struct nsd_rdata_descriptor naptr_rdata_fields[] = {
FIELD("order", 2),
FIELD("preference", 2),
Expand Down Expand Up @@ -554,9 +558,9 @@ const nsd_type_descriptor_t type_descriptors[] = {
TYPE("SRV", TYPE_SRV, TYPE_HAS_UNCOMPRESSED_DNAME,
read_srv_rdata, write_srv_rdata,
print_srv_rdata, srv_rdata_fields),

UNKNOWN_TYPE(34),

TYPE("ATMA", TYPE_ATMA, TYPE_HAS_NO_REFS,
read_generic_rdata, write_generic_rdata, print_atma_rdata,
atma_rdata_fields),
TYPE("NAPTR", TYPE_NAPTR, TYPE_HAS_UNCOMPRESSED_DNAME,
read_naptr_rdata, write_naptr_rdata,
print_naptr_rdata, naptr_rdata_fields),
Expand Down
2 changes: 1 addition & 1 deletion dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ typedef enum nsd_rc nsd_rc_type;
#define TYPE_NXT 30 /* 2535typecode */

#define TYPE_SRV 33 /* SRV record RFC2782 */

#define TYPE_ATMA 34 /* http://www.jhsoft.com/rfc/af-saa-0069.000.rtf */
#define TYPE_NAPTR 35 /* RFC2915 */
#define TYPE_KX 36 /* RFC2230 Key Exchange Delegation Record */
#define TYPE_CERT 37 /* RFC2538 */
Expand Down
30 changes: 30 additions & 0 deletions rdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,36 @@ print_srv_rdata(struct buffer *output, const struct rr *rr)
return 1;
}

int
print_atma_rdata(struct buffer *output, const struct rr *rr)
{
uint8_t format;
if(rr->rdlength < 1)
return 0;
format = rr->rdata[0];
if(format == 0) {
/* AESA format (ATM End System Address). */
uint16_t length = 1;
if (!print_base16(output, rr->rdlength, rr->rdata, &length))
return 0;
assert(rr->rdlength == length);
return 1;
} else if(format == 1) {
/* E.164 format. */
/* '+' and then digits '0'-'9' from the rdata string. */
buffer_printf(output, "+");
for (size_t i = 1; i < rr->rdlength; i++) {
char ch = (char)rr->rdata[i];
if(!isdigit((unsigned char)ch))
return 0;
buffer_printf(output, "%c", ch);
}
return 1;
}
/* Unknown format. */
return 0;
}

int32_t
read_naptr_rdata(struct domain_table *domains, uint16_t rdlength,
struct buffer *packet, struct rr **rr)
Expand Down
3 changes: 3 additions & 0 deletions rdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ void write_srv_rdata(struct query *query, const struct rr *rr);
/* Print rdata for type SRV. */
int print_srv_rdata(struct buffer *buffer, const struct rr *rr);

/* Print rdata for type ATMA. */
int print_atma_rdata(struct buffer *buffer, const struct rr *rr);

/* Read rdata for type NAPTR. */
int32_t read_naptr_rdata(struct domain_table *domains, uint16_t rdlength,
struct buffer *packet, struct rr **rr);
Expand Down

0 comments on commit 03b0c07

Please sign in to comment.