Skip to content

Commit

Permalink
Support for ATMA
Browse files Browse the repository at this point in the history
  • Loading branch information
wtoorop committed Jan 21, 2025
1 parent df63fac commit 6ba9428
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static rrtype_descriptor_type rrtype_descriptors[(RRTYPE_DESCRIPTORS_LENGTH+2)]
RDATA_WF_UNCOMPRESSED_DNAME },
{ RDATA_ZF_SHORT, RDATA_ZF_SHORT, RDATA_ZF_SHORT, RDATA_ZF_DNAME } },
/* 34 */
{ 34, NULL, 1, 1, { RDATA_WF_BINARY }, { RDATA_ZF_UNKNOWN } },
{ TYPE_ATMA, "ATMA", 1, 1, { RDATA_WF_BINARY }, { RDATA_ZF_ATMA } },
/* 35 */
{ TYPE_NAPTR, "NAPTR", 6, 6,
{ RDATA_WF_SHORT, RDATA_WF_SHORT, RDATA_WF_TEXT, RDATA_WF_TEXT,
Expand Down
3 changes: 2 additions & 1 deletion dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ typedef enum nsd_rc nsd_rc_type;
#define TYPE_EID 31 /* draft-ietf-nimrod-dns-01 */
#define TYPE_NIMLOC 32 /* draft-ietf-nimrod-dns-01 */
#define TYPE_SRV 33 /* SRV record RFC2782 */

#define TYPE_ATMA 34 /* ATM Address */
#define TYPE_NAPTR 35 /* RFC2915 */
#define TYPE_KX 36 /* RFC2230 Key Exchange Delegation Record */
#define TYPE_CERT 37 /* RFC2538 */
Expand Down Expand Up @@ -272,6 +272,7 @@ enum rdata_zoneformat
RDATA_ZF_TAG, /* A sequence of letters and numbers. */
RDATA_ZF_SVCPARAM, /* SvcParam <key>[=<value>] */
RDATA_ZF_HIP, /* HIP rdata up to the Rendezvous Servers */
RDATA_ZF_ATMA, /* ATM Address */
RDATA_ZF_UNKNOWN /* Unknown data. */
};
typedef enum rdata_zoneformat rdata_zoneformat_type;
Expand Down
24 changes: 23 additions & 1 deletion rdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ static int
rdata_hip_to_string(buffer_type *output, rdata_atom_type rdata,
rr_type* ATTR_UNUSED(rr))
{
uint16_t size = rdata_atom_size(rdata);
uint16_t size = rdata_atom_size(rdata);
uint8_t hit_length;
uint16_t pk_length;
int length = 0;
Expand All @@ -974,6 +974,27 @@ rdata_hip_to_string(buffer_type *output, rdata_atom_type rdata,
return length != -1;
}

static int
rdata_atma_to_string(buffer_type *output, rdata_atom_type rdata,
rr_type* ATTR_UNUSED(rr))
{
uint16_t size = rdata_atom_size(rdata), i;

if(size < 2 || rdata_atom_data(rdata)[0] > 1)
return 0;
if(!rdata_atom_data(rdata)[0]) {
hex_to_string(output, rdata_atom_data(rdata) + 1, size - 1);
return 1;
}
for(i = 1; i < size; i++) {
if(!isdigit(rdata_atom_data(rdata)[i]))
return 0;
}
buffer_write_u8(output, '+');
buffer_write(output, rdata_atom_data(rdata) + 1, size - 1);
return 1;
}

static int
rdata_unknown_to_string(buffer_type *output, rdata_atom_type rdata,
rr_type* ATTR_UNUSED(rr))
Expand Down Expand Up @@ -1019,6 +1040,7 @@ static rdata_to_string_type rdata_to_string_table[RDATA_ZF_UNKNOWN + 1] = {
rdata_tag_to_string,
rdata_svcparam_to_string,
rdata_hip_to_string,
rdata_atma_to_string,
rdata_unknown_to_string
};

Expand Down
2 changes: 2 additions & 0 deletions tpkg/rr-test.tdir/rr-test.cmp_zone
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ blaat 3600 IN SOA elektron.atoom.net. miekg.atoom.net. (
3600 IN TALINK h0.blaat.nl. h2.blaat.nl.
3600 IN DOA 0 1 2 "" bWFpbHRvOmxhYnNAbmxuZXRsYWJzLm5s
3600 IN DOA 0 100000 200 "example/nothing" -
3600 IN ATMA 39246f000e7c9c03120001000100001234567800
3600 IN ATMA +3584001234567
$ORIGIN _dsync.blaat.nl.
* 3600 IN DSYNC CDS 1 5359 cds-scanner.example.net.
3600 IN DSYNC CSYNC 1 5360 csync-scanner.example.net.
Expand Down
4 changes: 4 additions & 0 deletions tpkg/rr-test.tdir/rr-test.zone
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ h2 IN TALINK h1 .
@ IN DOA 0 1 2 "" bWFpbHRvOmxhYnNAbmxuZXRsYWJzLm5s
IN DOA 0 100000 200 example/nothing -

; https://web.archive.org/web/20190112072924/http://www.broadband-forum.org/ftp/pub/approved-specs/af-dans-0152.000.pdf
@ IN ATMA 39.246f.00.0e7c9c.0312.0001.0001.000012345678.00
IN ATMA +358.400.1234567

*._dsync IN DSYNC CDS 1 5359 cds-scanner.example.net.
*._dsync IN DSYNC CSYNC 1 5360 csync-scanner.example.net.

Expand Down

0 comments on commit 6ba9428

Please sign in to comment.