Commit 3a6d62c5 authored by Mark Andrews's avatar Mark Andrews
Browse files

3546. [func] Add EUI48 and EUI64 types. [RT #33082]

parent c2838610
3546. [func] Add EUI48 and EUI64 types. [RT #33082]
3545. [bug] RRL slip behavior was incorrect when set to 1.
[RT #33111]
......
......@@ -61,7 +61,7 @@ tags:
rm -f TAGS
find lib bin -name "*.[ch]" -print | @ETAGS@ -
test:
test check:
@if test -n "`${PERL} ${top_srcdir}/bin/tests/system/testsock.pl 2>&- || echo fail`"; then \
echo I: NOTE: The tests were not run because they require that; \
echo I: the IP addresses 10.53.0.1 through 10.53.0.8 are configured; \
......
......@@ -283,6 +283,10 @@ l64 L64 10 0014:4fff:ff20:ee64
lp LP 10 example.net.
eui48 EUI48 01-23-45-67-89-ab
eui64 EUI64 01-23-45-67-89-ab-cd-ef
; type 255
; TSIG is a meta-type and should never occur in master files.
......
......@@ -16,6 +16,8 @@ cname03.example. 3600 IN CNAME .
dname01.example. 3600 IN DNAME dname-target.
dname02.example. 3600 IN DNAME dname-target.example.
dname03.example. 3600 IN DNAME .
eui48.example. 3600 IN EUI48 01-23-45-67-89-ab
eui64.example. 3600 IN EUI64 01-23-45-67-89-ab-cd-ef
gpos01.example. 3600 IN GPOS "-22.6882" "116.8652" "250.0"
gpos02.example. 3600 IN GPOS "" "" ""
hinfo01.example. 3600 IN HINFO "Generic PC clone" "NetBSD-1.4"
......
......@@ -16,6 +16,8 @@ cname03.example. 3600 IN CNAME .
dname01.example. 3600 IN DNAME dname-target.
dname02.example. 3600 IN DNAME dname-target.example.
dname03.example. 3600 IN DNAME .
eui48.example. 3600 IN EUI48 01-23-45-67-89-ab
eui64.example. 3600 IN EUI64 01-23-45-67-89-ab-cd-ef
gpos01.example. 3600 IN GPOS "-22.6882" "116.8652" "250.0"
gpos02.example. 3600 IN GPOS "" "" ""
hinfo01.example. 3600 IN HINFO "Generic PC clone" "NetBSD-1.4"
......
......@@ -152,8 +152,9 @@
#define DNS_R_BROKENCHAIN (ISC_RESULTCLASS_DNS + 106)
#define DNS_R_EXPIRED (ISC_RESULTCLASS_DNS + 107)
#define DNS_R_NOTDYNAMIC (ISC_RESULTCLASS_DNS + 108)
#define DNS_R_BADEUI (ISC_RESULTCLASS_DNS + 109)
#define DNS_R_NRESULTS 109 /*%< Number of results */
#define DNS_R_NRESULTS 110 /*%< Number of results */
/*
* DNS wire format rcodes.
......
/*
* Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef RDATA_GENERIC_EUI48_108_C
#define RDATA_GENERIC_EUI48_108_C
#include <string.h>
#define RRTYPE_EUI48_ATTRIBUTES (0)
static inline isc_result_t
fromtext_eui48(ARGS_FROMTEXT) {
isc_token_t token;
unsigned char eui48[6];
unsigned int l0, l1, l2, l3, l4, l5;
int n;
REQUIRE(type == 108);
UNUSED(type);
UNUSED(rdclass);
UNUSED(origin);
UNUSED(options);
UNUSED(callbacks);
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
ISC_FALSE));
n = sscanf(DNS_AS_STR(token), "%2x-%2x-%2x-%2x-%2x-%2x",
&l0, &l1, &l2, &l3, &l4, &l5);
if (n != 6 || l0 > 255U || l1 > 255U || l2 > 255U || l3 > 255U ||
l4 > 255U || l5 > 255U)
return (DNS_R_BADEUI);
eui48[0] = l0;
eui48[1] = l1;
eui48[2] = l2;
eui48[3] = l3;
eui48[4] = l4;
eui48[5] = l5;
return (mem_tobuffer(target, eui48, sizeof(eui48)));
}
static inline isc_result_t
totext_eui48(ARGS_TOTEXT) {
char buf[sizeof("xx-xx-xx-xx-xx-xx")];
REQUIRE(rdata->type == 108);
REQUIRE(rdata->length == 6);
UNUSED(tctx);
(void)snprintf(buf, sizeof(buf), "%02x-%02x-%02x-%02x-%02x-%02x",
rdata->data[0], rdata->data[1], rdata->data[2],
rdata->data[3], rdata->data[4], rdata->data[5]);
return (str_totext(buf, target));
}
static inline isc_result_t
fromwire_eui48(ARGS_FROMWIRE) {
isc_region_t sregion;
REQUIRE(type == 108);
UNUSED(type);
UNUSED(options);
UNUSED(rdclass);
UNUSED(dctx);
isc_buffer_activeregion(source, &sregion);
if (sregion.length != 6)
return (DNS_R_FORMERR);
isc_buffer_forward(source, sregion.length);
return (mem_tobuffer(target, sregion.base, sregion.length));
}
static inline isc_result_t
towire_eui48(ARGS_TOWIRE) {
REQUIRE(rdata->type == 108);
REQUIRE(rdata->length == 6);
UNUSED(cctx);
return (mem_tobuffer(target, rdata->data, rdata->length));
}
static inline int
compare_eui48(ARGS_COMPARE) {
isc_region_t region1;
isc_region_t region2;
REQUIRE(rdata1->type == rdata2->type);
REQUIRE(rdata1->rdclass == rdata2->rdclass);
REQUIRE(rdata1->type == 108);
REQUIRE(rdata1->length == 6);
REQUIRE(rdata2->length == 6);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
return (isc_region_compare(&region1, &region2));
}
static inline isc_result_t
fromstruct_eui48(ARGS_FROMSTRUCT) {
dns_rdata_eui48_t *eui48 = source;
REQUIRE(type == 108);
REQUIRE(source != NULL);
REQUIRE(eui48->common.rdtype == type);
REQUIRE(eui48->common.rdclass == rdclass);
UNUSED(type);
UNUSED(rdclass);
return (mem_tobuffer(target, eui48->eui48, sizeof(eui48->eui48)));
}
static inline isc_result_t
tostruct_eui48(ARGS_TOSTRUCT) {
dns_rdata_eui48_t *eui48 = target;
REQUIRE(rdata->type == 108);
REQUIRE(target != NULL);
REQUIRE(rdata->length == 6);
UNUSED(mctx);
eui48->common.rdclass = rdata->rdclass;
eui48->common.rdtype = rdata->type;
ISC_LINK_INIT(&eui48->common, link);
memcpy(eui48->eui48, rdata->data, rdata->length);
return (ISC_R_SUCCESS);
}
static inline void
freestruct_eui48(ARGS_FREESTRUCT) {
dns_rdata_eui48_t *eui48 = source;
REQUIRE(source != NULL);
REQUIRE(eui48->common.rdtype == 108);
return;
}
static inline isc_result_t
additionaldata_eui48(ARGS_ADDLDATA) {
REQUIRE(rdata->type == 108);
REQUIRE(rdata->length == 6);
UNUSED(rdata);
UNUSED(add);
UNUSED(arg);
return (ISC_R_SUCCESS);
}
static inline isc_result_t
digest_eui48(ARGS_DIGEST) {
isc_region_t r;
REQUIRE(rdata->type == 108);
REQUIRE(rdata->length == 6);
dns_rdata_toregion(rdata, &r);
return ((digest)(arg, &r));
}
static inline isc_boolean_t
checkowner_eui48(ARGS_CHECKOWNER) {
REQUIRE(type == 108);
UNUSED(name);
UNUSED(type);
UNUSED(rdclass);
UNUSED(wildcard);
return (ISC_TRUE);
}
static inline isc_boolean_t
checknames_eui48(ARGS_CHECKNAMES) {
REQUIRE(rdata->type == 108);
REQUIRE(rdata->length == 6);
UNUSED(rdata);
UNUSED(owner);
UNUSED(bad);
return (ISC_TRUE);
}
static inline int
casecompare_eui48(ARGS_COMPARE) {
return (compare_eui48(rdata1, rdata2));
}
#endif /* RDATA_GENERIC_EUI48_108_C */
/*
* Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* */
#ifndef GENERIC_EUI48_108_H
#define GENERIC_EUI48_108_H 1
typedef struct dns_rdata_eui48 {
dns_rdatacommon_t common;
unsigned char eui48[6];
} dns_rdata_eui48_t;
#endif /* GENERIC_EUI48_10k_H */
/*
* Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef RDATA_GENERIC_EUI64_109_C
#define RDATA_GENERIC_EUI64_109_C
#include <string.h>
#define RRTYPE_EUI64_ATTRIBUTES (0)
static inline isc_result_t
fromtext_eui64(ARGS_FROMTEXT) {
isc_token_t token;
unsigned char eui64[8];
unsigned int l0, l1, l2, l3, l4, l5, l6, l7;
int n;
REQUIRE(type == 109);
UNUSED(type);
UNUSED(rdclass);
UNUSED(origin);
UNUSED(options);
UNUSED(callbacks);
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
ISC_FALSE));
n = sscanf(DNS_AS_STR(token), "%2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x",
&l0, &l1, &l2, &l3, &l4, &l5, &l6, &l7);
if (n != 8 || l0 > 255U || l1 > 255U || l2 > 255U || l3 > 255U ||
l4 > 255U || l5 > 255U || l6 > 255U || l7 > 255U)
return (DNS_R_BADEUI);
eui64[0] = l0;
eui64[1] = l1;
eui64[2] = l2;
eui64[3] = l3;
eui64[4] = l4;
eui64[5] = l5;
eui64[6] = l6;
eui64[7] = l7;
return (mem_tobuffer(target, eui64, sizeof(eui64)));
}
static inline isc_result_t
totext_eui64(ARGS_TOTEXT) {
char buf[sizeof("xx-xx-xx-xx-xx-xx-xx-xx")];
REQUIRE(rdata->type == 109);
REQUIRE(rdata->length == 8);
UNUSED(tctx);
(void)snprintf(buf, sizeof(buf),
"%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x",
rdata->data[0], rdata->data[1],
rdata->data[2], rdata->data[3],
rdata->data[4], rdata->data[5],
rdata->data[6], rdata->data[7]);
return (str_totext(buf, target));
}
static inline isc_result_t
fromwire_eui64(ARGS_FROMWIRE) {
isc_region_t sregion;
REQUIRE(type == 109);
UNUSED(type);
UNUSED(options);
UNUSED(rdclass);
UNUSED(dctx);
isc_buffer_activeregion(source, &sregion);
if (sregion.length != 8)
return (DNS_R_FORMERR);
isc_buffer_forward(source, sregion.length);
return (mem_tobuffer(target, sregion.base, sregion.length));
}
static inline isc_result_t
towire_eui64(ARGS_TOWIRE) {
REQUIRE(rdata->type == 109);
REQUIRE(rdata->length == 8);
UNUSED(cctx);
return (mem_tobuffer(target, rdata->data, rdata->length));
}
static inline int
compare_eui64(ARGS_COMPARE) {
isc_region_t region1;
isc_region_t region2;
REQUIRE(rdata1->type == rdata2->type);
REQUIRE(rdata1->rdclass == rdata2->rdclass);
REQUIRE(rdata1->type == 109);
REQUIRE(rdata1->length == 8);
REQUIRE(rdata2->length == 8);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
return (isc_region_compare(&region1, &region2));
}
static inline isc_result_t
fromstruct_eui64(ARGS_FROMSTRUCT) {
dns_rdata_eui64_t *eui64 = source;
REQUIRE(type == 109);
REQUIRE(source != NULL);
REQUIRE(eui64->common.rdtype == type);
REQUIRE(eui64->common.rdclass == rdclass);
UNUSED(type);
UNUSED(rdclass);
return (mem_tobuffer(target, eui64->eui64, sizeof(eui64->eui64)));
}
static inline isc_result_t
tostruct_eui64(ARGS_TOSTRUCT) {
dns_rdata_eui64_t *eui64 = target;
REQUIRE(rdata->type == 109);
REQUIRE(target != NULL);
REQUIRE(rdata->length == 8);
UNUSED(mctx);
eui64->common.rdclass = rdata->rdclass;
eui64->common.rdtype = rdata->type;
ISC_LINK_INIT(&eui64->common, link);
memcpy(eui64->eui64, rdata->data, rdata->length);
return (ISC_R_SUCCESS);
}
static inline void
freestruct_eui64(ARGS_FREESTRUCT) {
dns_rdata_eui64_t *eui64 = source;
REQUIRE(source != NULL);
REQUIRE(eui64->common.rdtype == 109);
return;
}
static inline isc_result_t
additionaldata_eui64(ARGS_ADDLDATA) {
REQUIRE(rdata->type == 109);
REQUIRE(rdata->length == 8);
UNUSED(rdata);
UNUSED(add);
UNUSED(arg);
return (ISC_R_SUCCESS);
}
static inline isc_result_t
digest_eui64(ARGS_DIGEST) {
isc_region_t r;
REQUIRE(rdata->type == 109);
REQUIRE(rdata->length == 8);
dns_rdata_toregion(rdata, &r);
return ((digest)(arg, &r));
}
static inline isc_boolean_t
checkowner_eui64(ARGS_CHECKOWNER) {
REQUIRE(type == 109);
UNUSED(name);
UNUSED(type);
UNUSED(rdclass);
UNUSED(wildcard);
return (ISC_TRUE);
}
static inline isc_boolean_t
checknames_eui64(ARGS_CHECKNAMES) {
REQUIRE(rdata->type == 109);
REQUIRE(rdata->length == 8);
UNUSED(rdata);
UNUSED(owner);
UNUSED(bad);
return (ISC_TRUE);
}
static inline int
casecompare_eui64(ARGS_COMPARE) {
return (compare_eui64(rdata1, rdata2));
}
#endif /* RDATA_GENERIC_EUI64_109_C */
/*
* Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* */
#ifndef GENERIC_EUI64_109_H
#define GENERIC_EUI64_109_H 1
typedef struct dns_rdata_eui64 {
dns_rdatacommon_t common;
unsigned char eui64[8];
} dns_rdata_eui64_t;
#endif /* GENERIC_EUI64_10k_H */
......@@ -161,7 +161,8 @@ static const char *text[DNS_R_NRESULTS] = {
"not master", /*%< 105 DNS_R_NOTMASTER */
"broken trust chain", /*%< 106 DNS_R_BROKENCHAIN */
"expired", /*%< 107 DNS_R_EXPIRED */
"not dynamic" /*%< 108 DNS_R_NOTDYNAMIC */
"not dynamic", /*%< 108 DNS_R_NOTDYNAMIC */
"bad EUI" /*%< 109 DNS_R_BADEUI */
};
static const char *rcode_text[DNS_R_NRCODERESULTS] = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment