diff options
author | Internet Software Consortium, Inc <@isc.org> | 2007-09-07 14:08:16 -0600 |
---|---|---|
committer | LaMont Jones <lamont@debian.org> | 2007-09-07 14:08:16 -0600 |
commit | ab47e90612dcdb02c4b134cfb1be0697007c0dac (patch) | |
tree | 88602431bff8a63ef57fb16f35e30d93f7455d41 /lib/dns/rdata/in_1 | |
download | bind9-ab47e90612dcdb02c4b134cfb1be0697007c0dac.tar.gz |
9.0.0b1
Diffstat (limited to 'lib/dns/rdata/in_1')
-rw-r--r-- | lib/dns/rdata/in_1/a6_38.c | 349 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/a6_38.h | 29 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/a_1.c | 204 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/a_1.h | 23 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/aaaa_28.c | 195 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/aaaa_28.h | 26 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/kx_36.c | 256 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/kx_36.h | 27 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/naptr_35.c | 379 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/naptr_35.h | 31 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/nsap-ptr_23.c | 194 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/nsap-ptr_23.h | 26 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/nsap_22.c | 200 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/nsap_22.h | 27 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/px_26.c | 315 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/px_26.h | 28 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/srv_33.c | 260 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/srv_33.h | 30 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/wks_11.c | 267 | ||||
-rw-r--r-- | lib/dns/rdata/in_1/wks_11.h | 27 |
20 files changed, 2893 insertions, 0 deletions
diff --git a/lib/dns/rdata/in_1/a6_38.c b/lib/dns/rdata/in_1/a6_38.c new file mode 100644 index 00000000..532d63c7 --- /dev/null +++ b/lib/dns/rdata/in_1/a6_38.c @@ -0,0 +1,349 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: a6_38.c,v 1.20 2000/02/03 23:43:16 halley Exp $ */ + + /* draft-ietf-ipngwg-dns-lookups-03.txt */ + +#ifndef RDATA_IN_1_A6_28_C +#define RDATA_IN_1_A6_28_C + +#include <string.h> + +#include <isc/net.h> + +static inline isc_result_t +fromtext_in_a6(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_lex_t *lexer, dns_name_t *origin, + isc_boolean_t downcase, isc_buffer_t *target) +{ + isc_token_t token; + unsigned char addr[16]; + unsigned char prefixlen; + unsigned char octets; + unsigned char mask; + dns_name_t name; + isc_buffer_t buffer; + + REQUIRE(type == 38); + REQUIRE(rdclass == 1); + + /* prefix length */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + if (token.value.as_ulong > 128) + return (DNS_R_RANGE); + + prefixlen = (unsigned char)token.value.as_ulong; + RETERR(mem_tobuffer(target, &prefixlen, 1)); + + /* suffix */ + if (prefixlen != 128) { + /* prefix 0..127 */ + octets = prefixlen/8; + /* octets 0..15 */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, + ISC_FALSE)); + if (inet_pton(AF_INET6, token.value.as_pointer, addr) != 1) + return (DNS_R_BADAAAA); + mask = 0xff >> (prefixlen % 8); + addr[octets] &= mask; + RETERR(mem_tobuffer(target, &addr[octets], 16 - octets)); + } + + if (prefixlen == 0) + return (DNS_R_SUCCESS); + + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + dns_name_init(&name, NULL); + buffer_fromregion(&buffer, &token.value.as_region, + ISC_BUFFERTYPE_TEXT); + origin = (origin != NULL) ? origin : dns_rootname; + return (dns_name_fromtext(&name, &buffer, origin, downcase, target)); +} + +static inline isc_result_t +totext_in_a6(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t tr; + isc_region_t sr; + unsigned char addr[16]; + unsigned char prefixlen; + unsigned char octets; + unsigned char mask; + char buf[sizeof "128"]; + dns_name_t name; + dns_name_t prefix; + isc_boolean_t sub; + + REQUIRE(rdata->type == 38); + REQUIRE(rdata->rdclass == 1); + + dns_rdata_toregion(rdata, &sr); + prefixlen = sr.base[0]; + INSIST(prefixlen <= 128); + isc_region_consume(&sr, 1); + sprintf(buf, "%u", prefixlen); + RETERR(str_totext(buf, target)); + RETERR(str_totext(" ", target)); + + if (prefixlen != 128) { + octets = prefixlen/8; + memset(addr, 0, sizeof addr); + memcpy(&addr[octets], sr.base, 16 - octets); + mask = 0xff >> (prefixlen % 8); + addr[octets] &= mask; + isc_buffer_available(target, &tr); + if (inet_ntop(AF_INET6, addr, + (char *)tr.base, tr.length) == NULL) + return (DNS_R_NOSPACE); + + isc_buffer_add(target, strlen((char *)tr.base)); + isc_region_consume(&sr, 16 - octets); + } + + if (prefixlen == 0) + return (DNS_R_SUCCESS); + + RETERR(str_totext(" ", target)); + dns_name_init(&name, NULL); + dns_name_init(&prefix, NULL); + dns_name_fromregion(&name, &sr); + sub = name_prefix(&name, tctx->origin, &prefix); + return(dns_name_totext(&prefix, sub, target)); +} + +static inline isc_result_t +fromwire_in_a6(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_buffer_t *source, dns_decompress_t *dctx, + isc_boolean_t downcase, isc_buffer_t *target) +{ + isc_region_t sr; + unsigned char prefixlen; + unsigned char octets; + unsigned char mask; + dns_name_t name; + + REQUIRE(type == 38); + REQUIRE(rdclass == 1); + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE); + + isc_buffer_active(source, &sr); + /* prefix length */ + if (sr.length < 1) + return (DNS_R_UNEXPECTEDEND); + prefixlen = sr.base[0]; + if (prefixlen > 128) + return (DNS_R_RANGE); + isc_region_consume(&sr, 1); + RETERR(mem_tobuffer(target, &prefixlen, 1)); + isc_buffer_forward(source, 1); + + /* suffix */ + if (prefixlen != 128) { + octets = 16 - prefixlen / 8; + if (sr.length < octets) + return (DNS_R_UNEXPECTEDEND); + mask = 0xff >> (prefixlen % 8); + sr.base[0] &= mask; /* ensure pad bits are zero */ + RETERR(mem_tobuffer(target, sr.base, octets)); + isc_buffer_forward(source, octets); + } + + if (prefixlen == 0) + return (DNS_R_SUCCESS); + + dns_name_init(&name, NULL); + return (dns_name_fromwire(&name, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_in_a6(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + isc_region_t sr; + dns_name_t name; + unsigned char prefixlen; + unsigned char octets; + + REQUIRE(rdata->type == 38); + REQUIRE(rdata->rdclass == 1); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); + + dns_rdata_toregion(rdata, &sr); + prefixlen = sr.base[0]; + INSIST(prefixlen <= 128); + + octets = 1 + 16 - prefixlen / 8; + RETERR(mem_tobuffer(target, sr.base, octets)); + isc_region_consume(&sr, octets); + + if (prefixlen == 0) + return (DNS_R_SUCCESS); + + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &sr); + return (dns_name_towire(&name, cctx, target)); +} + +static inline int +compare_in_a6(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + int result; + unsigned char prefixlen1, prefixlen2; + unsigned char octets; + dns_name_t name1; + dns_name_t name2; + isc_region_t region1; + isc_region_t region2; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 38); + REQUIRE(rdata1->rdclass == 1); + + dns_rdata_toregion(rdata1, ®ion1); + dns_rdata_toregion(rdata2, ®ion2); + prefixlen1 = region1.base[0]; + prefixlen2 = region2.base[0]; + isc_region_consume(®ion1, 1); + isc_region_consume(®ion2, 1); + if (prefixlen1 < prefixlen2) + return (-1); + else if (prefixlen1 > prefixlen2) + return (1); + /* + * Prefix lengths are equal. + */ + octets = 16 - prefixlen1 / 8; + + if (octets > 0) { + result = memcmp(region1.base, region2.base, octets); + if (result < 0) + return (-1); + else if (result > 0) + return (1); + /* + * Address suffixes are equal. + */ + if (prefixlen1 == 0) + return (result); + isc_region_consume(®ion1, octets); + isc_region_consume(®ion2, octets); + } + + dns_name_init(&name1, NULL); + dns_name_init(&name2, NULL); + dns_name_fromregion(&name1, ®ion1); + dns_name_fromregion(&name2, ®ion2); + return (dns_name_rdatacompare(&name1, &name2)); +} + +static inline isc_result_t +fromstruct_in_a6(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + dns_rdata_in_a6_t *a6 = source; + unsigned char prefixlen; + unsigned char octets; + + REQUIRE(type == 1); + REQUIRE(rdclass == 1); + REQUIRE(source != NULL); + REQUIRE(a6->common.rdtype == type); + REQUIRE(a6->common.rdclass == rdclass); + + if (a6->prefixlen > 128) + return (DNS_R_RANGE); + + prefixlen = a6->prefixlen; + RETERR(mem_tobuffer(target, &prefixlen, 1)); + + if (a6->prefixlen != 128) { + + } + + octets = 16 - prefixlen / 8; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_in_a6(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 38); + REQUIRE(rdata->rdclass == 1); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_in_a6(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ +} + +static inline isc_result_t +additionaldata_in_a6(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 38); + REQUIRE(rdata->rdclass == 1); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_in_a6(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r1, r2; + unsigned char prefixlen, octets; + isc_result_t result; + dns_name_t name; + + REQUIRE(rdata->type == 38); + REQUIRE(rdata->rdclass == 1); + + dns_rdata_toregion(rdata, &r1); + r2 = r1; + prefixlen = r1.base[0]; + octets = 1 + 16 - prefixlen / 8; + + r1.length = octets; + result = (digest)(arg, &r1); + if (result != DNS_R_SUCCESS) + return (result); + if (prefixlen == 0) + return (DNS_R_SUCCESS); + + isc_region_consume(&r2, octets); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r2); + return (dns_name_digest(&name, digest, arg)); +} + +#endif /* RDATA_IN_1_A6_38_C */ diff --git a/lib/dns/rdata/in_1/a6_38.h b/lib/dns/rdata/in_1/a6_38.h new file mode 100644 index 00000000..4728244a --- /dev/null +++ b/lib/dns/rdata/in_1/a6_38.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: a6_38.h,v 1.12 2000/02/03 23:43:16 halley Exp $ */ + + /* draft-ietf-ipngwg-dns-lookups-03.txt */ + +typedef struct dns_rdata_in_a6 { + dns_rdatacommon_t common; + isc_mem_t *mctx; + dns_name_t prefix; + isc_uint32_t prefixlen; + struct in6_addr in6_addr; +} dns_rdata_in_a6_t; + diff --git a/lib/dns/rdata/in_1/a_1.c b/lib/dns/rdata/in_1/a_1.c new file mode 100644 index 00000000..3f588c05 --- /dev/null +++ b/lib/dns/rdata/in_1/a_1.c @@ -0,0 +1,204 @@ +/* + * Copyright (C) 1998, 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: a_1.c,v 1.23 2000/02/03 23:43:16 halley Exp $ */ + +#ifndef RDATA_IN_1_A_1_C +#define RDATA_IN_1_A_1_C + +#include <string.h> + +#include <isc/net.h> + +static inline isc_result_t +fromtext_in_a(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_lex_t *lexer, dns_name_t *origin, + isc_boolean_t downcase, isc_buffer_t *target) +{ + isc_token_t token; + struct in_addr addr; + isc_region_t region; + + REQUIRE(type == 1); + REQUIRE(rdclass == 1); + + origin = origin; /*unused*/ + downcase = downcase; /*unused*/ + + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + + if (inet_aton(token.value.as_pointer, &addr) != 1) + return (DNS_R_BADDOTTEDQUAD); + isc_buffer_available(target, ®ion); + if (region.length < 4) + return (DNS_R_NOSPACE); + memcpy(region.base, &addr, 4); + isc_buffer_add(target, 4); + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +totext_in_a(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t region; + + REQUIRE(rdata->type == 1); + REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->length == 4); + + tctx = tctx; /* unused */ + + isc_buffer_available(target, ®ion); + if (inet_ntop(AF_INET, rdata->data, + (char *)region.base, region.length) == NULL) + return (DNS_R_NOSPACE); + + isc_buffer_add(target, strlen((char *)region.base)); + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +fromwire_in_a(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_buffer_t *source, dns_decompress_t *dctx, + isc_boolean_t downcase, isc_buffer_t *target) +{ + isc_region_t sregion; + isc_region_t tregion; + + REQUIRE(type == 1); + REQUIRE(rdclass == 1); + + dctx = dctx; /* unused */ + downcase = downcase; /* unused */ + + + isc_buffer_active(source, &sregion); + isc_buffer_available(target, &tregion); + if (sregion.length < 4) + return (DNS_R_UNEXPECTEDEND); + if (tregion.length < 4) + return (DNS_R_NOSPACE); + + memcpy(tregion.base, sregion.base, 4); + isc_buffer_forward(source, 4); + isc_buffer_add(target, 4); + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +towire_in_a(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + isc_region_t region; + + REQUIRE(rdata->type == 1); + REQUIRE(rdata->rdclass == 1); + + cctx = cctx; /*unused*/ + + isc_buffer_available(target, ®ion); + if (region.length < rdata->length) + return (DNS_R_NOSPACE); + memcpy(region.base, rdata->data, rdata->length); + isc_buffer_add(target, 4); + return (DNS_R_SUCCESS); +} + +static inline int +compare_in_a(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + int result; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->type); + REQUIRE(rdata1->type == 1); + REQUIRE(rdata1->rdclass == 1); + + result = memcmp(rdata1->data, rdata2->data, 4); + if (result != 0) + result = (result < 0) ? -1 : 1; + + return (result); +} + +static inline isc_result_t +fromstruct_in_a(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 1); + REQUIRE(rdclass == 1); + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_in_a(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + dns_rdata_in_a_t *a = target; + isc_uint32_t n; + isc_region_t region; + + REQUIRE(rdata->type == 1); + REQUIRE(rdata->rdclass == 1); + + mctx = mctx; /* unused */ + + a->common.rdclass = rdata->rdclass; + a->common.rdtype = rdata->type; + ISC_LINK_INIT(&a->common, link); + + dns_rdata_toregion(rdata, ®ion); + n = uint32_fromregion(®ion); + a->in_addr.s_addr = htonl(n); + + return (DNS_R_SUCCESS); +} + +static inline void +freestruct_in_a(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ + +} + +static inline isc_result_t +additionaldata_in_a(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 1); + REQUIRE(rdata->rdclass == 1); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_in_a(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + + REQUIRE(rdata->type == 1); + REQUIRE(rdata->rdclass == 1); + + dns_rdata_toregion(rdata, &r); + + return ((digest)(arg, &r)); +} + +#endif /* RDATA_IN_1_A_1_C */ diff --git a/lib/dns/rdata/in_1/a_1.h b/lib/dns/rdata/in_1/a_1.h new file mode 100644 index 00000000..47852726 --- /dev/null +++ b/lib/dns/rdata/in_1/a_1.h @@ -0,0 +1,23 @@ +/* + * Copyright (C) 1998, 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: a_1.h,v 1.17 2000/02/03 23:43:17 halley Exp $ */ + +typedef struct dns_rdata_in_a { + dns_rdatacommon_t common; + struct in_addr in_addr; +} dns_rdata_in_a_t; diff --git a/lib/dns/rdata/in_1/aaaa_28.c b/lib/dns/rdata/in_1/aaaa_28.c new file mode 100644 index 00000000..b3265c3c --- /dev/null +++ b/lib/dns/rdata/in_1/aaaa_28.c @@ -0,0 +1,195 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: aaaa_28.c,v 1.16 2000/02/03 23:43:17 halley Exp $ */ + + /* RFC 1886 */ + +#ifndef RDATA_IN_1_AAAA_28_C +#define RDATA_IN_1_AAAA_28_C + +#include <string.h> + +#include <isc/net.h> + +static inline isc_result_t +fromtext_in_aaaa(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_lex_t *lexer, dns_name_t *origin, + isc_boolean_t downcase, isc_buffer_t *target) +{ + isc_token_t token; + unsigned char addr[16]; + isc_region_t region; + + REQUIRE(type == 28); + REQUIRE(rdclass == 1); + + origin = origin; /*unused*/ + downcase = downcase; /*unused*/ + + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + + if (inet_pton(AF_INET6, token.value.as_pointer, addr) != 1) + return (DNS_R_BADAAAA); + isc_buffer_available(target, ®ion); + if (region.length < 16) + return (DNS_R_NOSPACE); + memcpy(region.base, addr, 16); + isc_buffer_add(target, 16); + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +totext_in_aaaa(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t region; + + REQUIRE(rdata->type == 28); + REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->length == 16); + + tctx = tctx; /* unused */ + + isc_buffer_available(target, ®ion); + if (inet_ntop(AF_INET6, rdata->data, + (char *)region.base, region.length) == NULL) + return (DNS_R_NOSPACE); + + isc_buffer_add(target, strlen((char *)region.base)); + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +fromwire_in_aaaa(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_buffer_t *source, dns_decompress_t *dctx, + isc_boolean_t downcase, isc_buffer_t *target) +{ + isc_region_t sregion; + isc_region_t tregion; + + REQUIRE(type == 28); + REQUIRE(rdclass == 1); + + dctx = dctx; /* unused */ + downcase = downcase; /* unused */ + + + isc_buffer_active(source, &sregion); + isc_buffer_available(target, &tregion); + if (sregion.length < 16) + return (DNS_R_UNEXPECTEDEND); + if (tregion.length < 16) + return (DNS_R_NOSPACE); + + memcpy(tregion.base, sregion.base, 16); + isc_buffer_forward(source, 16); + isc_buffer_add(target, 16); + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +towire_in_aaaa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + isc_region_t region; + + REQUIRE(rdata->type == 28); + REQUIRE(rdata->rdclass == 1); + + cctx = cctx; /*unused*/ + + isc_buffer_available(target, ®ion); + if (region.length < rdata->length) + return (DNS_R_NOSPACE); + memcpy(region.base, rdata->data, rdata->length); + isc_buffer_add(target, 16); + return (DNS_R_SUCCESS); +} + +static inline int +compare_in_aaaa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + int result; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 28); + REQUIRE(rdata1->rdclass == 1); + + result = memcmp(rdata1->data, rdata2->data, 16); + if (result != 0) + result = (result < 0) ? -1 : 1; + + return (result); +} + +static inline isc_result_t +fromstruct_in_aaaa(dns_rdataclass_t rdclass, dns_rdatatype_t type, + void *source, isc_buffer_t *target) +{ + + REQUIRE(type == 1); + REQUIRE(rdclass == 1); + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_in_aaaa(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 28); + REQUIRE(rdata->rdclass == 1); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_in_aaaa(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ +} + +static inline isc_result_t +additionaldata_in_aaaa(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 28); + REQUIRE(rdata->rdclass == 1); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_in_aaaa(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + + REQUIRE(rdata->type == 28); + REQUIRE(rdata->rdclass == 1); + + dns_rdata_toregion(rdata, &r); + + return ((digest)(arg, &r)); +} + +#endif /* RDATA_IN_1_AAAA_28_C */ diff --git a/lib/dns/rdata/in_1/aaaa_28.h b/lib/dns/rdata/in_1/aaaa_28.h new file mode 100644 index 00000000..5ef4521b --- /dev/null +++ b/lib/dns/rdata/in_1/aaaa_28.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: aaaa_28.h,v 1.11 2000/02/03 23:43:17 halley Exp $ */ + + /* RFC 1886 */ + +typedef struct dns_rdata_in_aaaa { + dns_rdatacommon_t common; + struct in6_addr in6_addr; +} dns_rdata_in_aaaa_t; + diff --git a/lib/dns/rdata/in_1/kx_36.c b/lib/dns/rdata/in_1/kx_36.c new file mode 100644 index 00000000..5b91ac57 --- /dev/null +++ b/lib/dns/rdata/in_1/kx_36.c @@ -0,0 +1,256 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: kx_36.c,v 1.16 2000/02/03 23:43:17 halley Exp $ */ + + /* RFC 2230 */ + +#ifndef RDATA_GENERIC_KX_36_C +#define RDATA_GENERIC_KX_36_C + +static inline isc_result_t +fromtext_in_kx(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_lex_t *lexer, dns_name_t *origin, + isc_boolean_t downcase, isc_buffer_t *target) +{ + isc_token_t token; + dns_name_t name; + isc_buffer_t buffer; + + REQUIRE(type == 36); + REQUIRE(rdclass == 1); + + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + RETERR(uint16_tobuffer(token.value.as_ulong, target)); + + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + dns_name_init(&name, NULL); + buffer_fromregion(&buffer, &token.value.as_region, + ISC_BUFFERTYPE_TEXT); + origin = (origin != NULL) ? origin : dns_rootname; + return (dns_name_fromtext(&name, &buffer, origin, downcase, target)); +} + +static inline isc_result_t +totext_in_kx(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t region; + dns_name_t name; + dns_name_t prefix; + isc_boolean_t sub; + char buf[sizeof "64000"]; + unsigned short num; + + REQUIRE(rdata->type == 36); + REQUIRE(rdata->rdclass == 1); + + dns_name_init(&name, NULL); + dns_name_init(&prefix, NULL); + + dns_rdata_toregion(rdata, ®ion); + num = uint16_fromregion(®ion); + isc_region_consume(®ion, 2); + sprintf(buf, "%u", num); + RETERR(str_totext(buf, target)); + RETERR(str_totext(" ", target)); + + dns_name_fromregion(&name, ®ion); + sub = name_prefix(&name, tctx->origin, &prefix); + return(dns_name_totext(&prefix, sub, target)); +} + +static inline isc_result_t +fromwire_in_kx(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_buffer_t *source, dns_decompress_t *dctx, + isc_boolean_t downcase, isc_buffer_t *target) +{ + dns_name_t name; + isc_region_t sregion; + + REQUIRE(type == 36); + REQUIRE(rdclass == 1); + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE); + + dns_name_init(&name, NULL); + + isc_buffer_active(source, &sregion); + if (sregion.length < 2) + return (DNS_R_UNEXPECTEDEND); + RETERR(mem_tobuffer(target, sregion.base, 2)); + isc_buffer_forward(source, 2); + return (dns_name_fromwire(&name, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_in_kx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 36); + REQUIRE(rdata->rdclass == 1); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); + + dns_rdata_toregion(rdata, ®ion); + RETERR(mem_tobuffer(target, region.base, 2)); + isc_region_consume(®ion, 2); + + dns_name_init(&name, NULL); + dns_name_fromregion(&name, ®ion); + + return (dns_name_towire(&name, cctx, target)); +} + +static inline int +compare_in_kx(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + dns_name_t name1; + dns_name_t name2; + isc_region_t region1; + isc_region_t region2; + int result; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 36); + REQUIRE(rdata1->rdclass == 1); + + result = memcmp(rdata1->data, rdata2->data, 2); + if (result != 0) + return (result < 0 ? -1 : 1); + + dns_name_init(&name1, NULL); + dns_name_init(&name2, NULL); + + dns_rdata_toregion(rdata1, ®ion1); + dns_rdata_toregion(rdata2, ®ion2); + + isc_region_consume(®ion1, 2); + isc_region_consume(®ion2, 2); + + dns_name_fromregion(&name1, ®ion1); + dns_name_fromregion(&name2, ®ion2); + + return (dns_name_rdatacompare(&name1, &name2)); +} + +static inline isc_result_t +fromstruct_in_kx(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + dns_rdata_in_kx_t *kx = source; + isc_region_t region; + + REQUIRE(type == 36); + REQUIRE(rdclass == 1); + REQUIRE(source != NULL); + REQUIRE(kx->common.rdtype == type); + REQUIRE(kx->common.rdclass == rdclass); + + RETERR(uint16_tobuffer(kx->preference, target)); + dns_name_toregion(&kx->exchange, ®ion); + return (isc_buffer_copyregion(target, ®ion)); +} + +static inline isc_result_t +tostruct_in_kx(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + isc_region_t region; + dns_rdata_in_kx_t *kx = target; + dns_name_t name; + isc_result_t result; + + REQUIRE(rdata->type == 36); + REQUIRE(rdata->rdclass == 1); + REQUIRE(target != NULL); + REQUIRE(mctx != NULL); + + kx->common.rdclass = rdata->rdclass; + kx->common.rdtype = rdata->type; + ISC_LINK_INIT(&kx->common, link); + + dns_name_init(&name, NULL); + dns_rdata_toregion(rdata, ®ion); + + kx->preference = uint16_fromregion(®ion); + isc_region_consume(®ion, 2); + + dns_name_fromregion(&name, ®ion); + kx->mctx = mctx; + dns_name_init(&kx->exchange, NULL); + result = dns_name_dup(&name, kx->mctx, &kx->exchange); + if (result != ISC_R_SUCCESS) + kx->mctx = NULL; + return (result); +} + +static inline void +freestruct_in_kx(void *source) { + dns_rdata_in_kx_t *kx = source; + + REQUIRE(source != NULL); + + dns_name_free(&kx->exchange, kx->mctx); + kx->mctx = NULL; +} + +static inline isc_result_t +additionaldata_in_kx(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 36); + REQUIRE(rdata->rdclass == 1); + + dns_name_init(&name, NULL); + dns_rdata_toregion(rdata, ®ion); + isc_region_consume(®ion, 2); + dns_name_fromregion(&name, ®ion); + + return ((add)(arg, &name, dns_rdatatype_a)); +} + +static inline isc_result_t +digest_in_kx(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r1, r2; + isc_result_t result; + dns_name_t name; + + REQUIRE(rdata->type == 36); + REQUIRE(rdata->rdclass == 1); + + dns_rdata_toregion(rdata, &r1); + r2 = r1; + isc_region_consume(&r2, 2); + r1.length = 2; + result = (digest)(arg, &r1); + if (result != ISC_R_SUCCESS) + return (result); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r2); + return (dns_name_digest(&name, digest, arg)); +} + +#endif /* RDATA_GENERIC_KX_15_C */ diff --git a/lib/dns/rdata/in_1/kx_36.h b/lib/dns/rdata/in_1/kx_36.h new file mode 100644 index 00000000..90c96b27 --- /dev/null +++ b/lib/dns/rdata/in_1/kx_36.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: kx_36.h,v 1.10 2000/02/03 23:43:17 halley Exp $ */ + + /* RFC 2230 */ + +typedef struct dns_rdata_in_kx { + dns_rdatacommon_t common; + isc_mem_t *mctx; + isc_uint16_t preference; + dns_name_t exchange; +} dns_rdata_in_kx_t; diff --git a/lib/dns/rdata/in_1/naptr_35.c b/lib/dns/rdata/in_1/naptr_35.c new file mode 100644 index 00000000..313759d6 --- /dev/null +++ b/lib/dns/rdata/in_1/naptr_35.c @@ -0,0 +1,379 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: naptr_35.c,v 1.16 2000/02/03 23:43:17 halley Exp $ */ + + /* RFC 2168 */ + +#ifndef RDATA_IN_1_NAPTR_35_C +#define RDATA_IN_1_NAPTR_35_C + +static inline isc_result_t +fromtext_in_naptr(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_lex_t *lexer, dns_name_t *origin, + isc_boolean_t downcase, isc_buffer_t *target) +{ + isc_token_t token; + dns_name_t name; + isc_buffer_t buffer; + + REQUIRE(type == 35); + REQUIRE(rdclass == 1); + + /* priority */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + RETERR(uint16_tobuffer(token.value.as_ulong, target)); + + /* weight */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + RETERR(uint16_tobuffer(token.value.as_ulong, target)); + + /* flags */ + RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_FALSE)); + RETERR(txt_fromtext(&token.value.as_textregion, target)); + + /* service */ + RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_FALSE)); + RETERR(txt_fromtext(&token.value.as_textregion, target)); + + /* regexp */ + RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_FALSE)); + RETERR(txt_fromtext(&token.value.as_textregion, target)); + + /* replacement */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + dns_name_init(&name, NULL); + buffer_fromregion(&buffer, &token.value.as_region, + ISC_BUFFERTYPE_TEXT); + origin = (origin != NULL) ? origin : dns_rootname; + return (dns_name_fromtext(&name, &buffer, origin, downcase, target)); +} + +static inline isc_result_t +totext_in_naptr(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t region; + dns_name_t name; + dns_name_t prefix; + isc_boolean_t sub; + char buf[sizeof "64000"]; + unsigned short num; + + REQUIRE(rdata->type == 35); + REQUIRE(rdata->rdclass == 1); + + dns_name_init(&name, NULL); + dns_name_init(&prefix, NULL); + + /* priority */ + dns_rdata_toregion(rdata, ®ion); + num = uint16_fromregion(®ion); + isc_region_consume(®ion, 2); + sprintf(buf, "%u", num); + RETERR(str_totext(buf, target)); + RETERR(str_totext(" ", target)); + + /* weight */ + num = uint16_fromregion(®ion); + isc_region_consume(®ion, 2); + sprintf(buf, "%u", num); + RETERR(str_totext(buf, target)); + RETERR(str_totext(" ", target)); + + /* flags */ + RETERR(txt_totext(®ion, target)); + RETERR(str_totext(" ", target)); + + /* service */ + RETERR(txt_totext(®ion, target)); + RETERR(str_totext(" ", target)); + + /* regexp */ + RETERR(txt_totext(®ion, target)); + RETERR(str_totext(" ", target)); + + /* replacement */ + dns_name_fromregion(&name, ®ion); + sub = name_prefix(&name, tctx->origin, &prefix); + return(dns_name_totext(&prefix, sub, target)); +} + +static inline isc_result_t +fromwire_in_naptr(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_buffer_t *source, dns_decompress_t *dctx, + isc_boolean_t downcase, isc_buffer_t *target) +{ + dns_name_t name; + isc_region_t sr; + + REQUIRE(type == 35); + REQUIRE(rdclass == 1); + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE); + + dns_name_init(&name, NULL); + + /* priority, weight */ + isc_buffer_active(source, &sr); + if (sr.length < 4) + return (DNS_R_UNEXPECTEDEND); + RETERR(mem_tobuffer(target, sr.base, 4)); + isc_buffer_forward(source, 4); + + /* flags */ + RETERR(txt_fromwire(source, target)); + + /* service */ + RETERR(txt_fromwire(source, target)); + + /* regexp */ + RETERR(txt_fromwire(source, target)); + + /* replacement */ + return (dns_name_fromwire(&name, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_in_naptr(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + dns_name_t name; + isc_region_t sr; + + REQUIRE(rdata->type == 35); + REQUIRE(rdata->rdclass == 1); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); + + /* priority, weight */ + dns_rdata_toregion(rdata, &sr); + RETERR(mem_tobuffer(target, sr.base, 4)); + isc_region_consume(&sr, 4); + + /* flags */ + RETERR(mem_tobuffer(target, sr.base, sr.base[0] + 1)); + isc_region_consume(&sr, sr.base[0] + 1); + + /* service */ + RETERR(mem_tobuffer(target, sr.base, sr.base[0] + 1)); + isc_region_consume(&sr, sr.base[0] + 1); + + /* regexp */ + RETERR(mem_tobuffer(target, sr.base, sr.base[0] + 1)); + isc_region_consume(&sr, sr.base[0] + 1); + + /* replacement */ + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &sr); + return (dns_name_towire(&name, cctx, target)); +} + +static inline int +compare_in_naptr(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + dns_name_t name1; + dns_name_t name2; + isc_region_t region1; + isc_region_t region2; + int result; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 35); + REQUIRE(rdata1->rdclass == 1); + + dns_rdata_toregion(rdata1, ®ion1); + dns_rdata_toregion(rdata2, ®ion2); + + /* priority, weight */ + result = memcmp(region1.base, region2.base, 4); + if (result != 0) + return (result < 0 ? -1 : 1); + isc_region_consume(®ion1, 4); + isc_region_consume(®ion2, 4); + + /* flags */ + result = memcmp(region1.base, region2.base, region1.base[0] + 1); + if (result != 0) + return (result < 0 ? -1 : 1); + isc_region_consume(®ion1, region1.base[0] + 1); + isc_region_consume(®ion2, region2.base[0] + 1); + + /* service */ + result = memcmp(region1.base, region2.base, region1.base[0] + 1); + if (result != 0) + return (result < 0 ? -1 : 1); + isc_region_consume(®ion1, region1.base[0] + 1); + isc_region_consume(®ion2, region2.base[0] + 1); + + /* regexp */ + result = memcmp(region1.base, region2.base, region1.base[0] + 1); + if (result != 0) + return (result < 0 ? -1 : 1); + isc_region_consume(®ion1, region1.base[0] + 1); + isc_region_consume(®ion2, region2.base[0] + 1); + + /* replacement */ + dns_name_init(&name1, NULL); + dns_name_init(&name2, NULL); + + dns_name_fromregion(&name1, ®ion1); + dns_name_fromregion(&name2, ®ion2); + + return (dns_name_rdatacompare(&name1, &name2)); +} + +static inline isc_result_t +fromstruct_in_naptr(dns_rdataclass_t rdclass, dns_rdatatype_t type, + void *source, isc_buffer_t *target) +{ + + REQUIRE(type == 35); + REQUIRE(rdclass == 1); + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_in_naptr(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 35); + REQUIRE(rdata->rdclass == 1); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_in_naptr(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); +} + +static inline isc_result_t +additionaldata_in_naptr(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + dns_name_t name; + isc_region_t sr; + dns_rdatatype_t atype; + unsigned int i, flagslen; + char *cp; + + REQUIRE(rdata->type == 35); + REQUIRE(rdata->rdclass == 1); + + /* + * We do not currently do type SRV additional data section + * processing for terminal NAPTRs. + */ + + /* priority, weight */ + dns_rdata_toregion(rdata, &sr); + isc_region_consume(&sr, 4); + + /* flags */ + atype = 0; + flagslen = sr.base[0]; + cp = (char *)&sr.base[1]; + for (i = 0; i < flagslen; i++, cp++) { + if (*cp == 'S' || *cp == 's') { + atype = dns_rdatatype_srv; + break; + } + if (*cp == 'A' || *cp == 'a') { + atype = dns_rdatatype_a; + break; + } + } + isc_region_consume(&sr, flagslen + 1); + + /* service */ + isc_region_consume(&sr, sr.base[0] + 1); + + /* regexp */ + isc_region_consume(&sr, sr.base[0] + 1); + + /* replacement */ + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &sr); + + if (atype != 0) + return ((add)(arg, &name, atype)); + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_in_naptr(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r1, r2; + unsigned int length, n; + isc_result_t result; + dns_name_t name; + + REQUIRE(rdata->type == 35); + REQUIRE(rdata->rdclass == 1); + + dns_rdata_toregion(rdata, &r1); + r2 = r1; + length = 0; + + /* priority, weight */ + length += 4; + isc_region_consume(&r2, 4); + + /* flags */ + n = r2.base[0] + 1; + length += n; + isc_region_consume(&r2, n); + + /* service */ + n = r2.base[0] + 1; + length += n; + isc_region_consume(&r2, n); + + /* regexp */ + n = r2.base[0] + 1; + length += n; + isc_region_consume(&r2, n); + + /* + * Digest the RR up to the replacement name. + */ + r1.length = length; + result = (digest)(arg, &r1); + if (result != DNS_R_SUCCESS) + return (result); + + /* replacement */ + + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r2); + + return (dns_name_digest(&name, digest, arg)); +} + +#endif /* RDATA_IN_1_NAPTR_35_C */ diff --git a/lib/dns/rdata/in_1/naptr_35.h b/lib/dns/rdata/in_1/naptr_35.h new file mode 100644 index 00000000..85b3afc4 --- /dev/null +++ b/lib/dns/rdata/in_1/naptr_35.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: naptr_35.h,v 1.10 2000/02/03 23:43:18 halley Exp $ */ + + /* RFC 2168 */ + +typedef struct dns_rdata_in_naptr { + dns_rdatacommon_t common; + isc_mem_t *mctx; + isc_uint16_t order; + isc_uint16_t preference; + char *flags; + char *service; + char *regexp; + dns_name_t replacement; +} dns_rdata_in_naptr_t; diff --git a/lib/dns/rdata/in_1/nsap-ptr_23.c b/lib/dns/rdata/in_1/nsap-ptr_23.c new file mode 100644 index 00000000..99bdc88e --- /dev/null +++ b/lib/dns/rdata/in_1/nsap-ptr_23.c @@ -0,0 +1,194 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: nsap-ptr_23.c,v 1.13 2000/02/03 23:43:18 halley Exp $ */ + + /* RFC 1348 */ + +#ifndef RDATA_IN_1_NSAP_PTR_23_C +#define RDATA_IN_1_NSAP_PTR_23_C + +static inline isc_result_t +fromtext_in_nsap_ptr(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_lex_t *lexer, dns_name_t *origin, + isc_boolean_t downcase, isc_buffer_t *target) +{ + isc_token_t token; + dns_name_t name; + isc_buffer_t buffer; + + REQUIRE(type == 23); + REQUIRE(rdclass == 1); + + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + + dns_name_init(&name, NULL); + buffer_fromregion(&buffer, &token.value.as_region, + ISC_BUFFERTYPE_TEXT); + origin = (origin != NULL) ? origin : dns_rootname; + return (dns_name_fromtext(&name, &buffer, origin, downcase, target)); +} + +static inline isc_result_t +totext_in_nsap_ptr(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t region; + dns_name_t name; + dns_name_t prefix; + isc_boolean_t sub; + + REQUIRE(rdata->type == 23); + REQUIRE(rdata->rdclass == 1); + + dns_name_init(&name, NULL); + dns_name_init(&prefix, NULL); + + dns_rdata_toregion(rdata, ®ion); + dns_name_fromregion(&name, ®ion); + + sub = name_prefix(&name, tctx->origin, &prefix); + + return (dns_name_totext(&prefix, sub, target)); +} + +static inline isc_result_t +fromwire_in_nsap_ptr(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_buffer_t *source, dns_decompress_t *dctx, + isc_boolean_t downcase, isc_buffer_t *target) +{ + dns_name_t name; + + REQUIRE(type == 23); + REQUIRE(rdclass == 1); + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE); + + dns_name_init(&name, NULL); + return (dns_name_fromwire(&name, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_in_nsap_ptr(dns_rdata_t *rdata, dns_compress_t *cctx, + isc_buffer_t *target) +{ + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 23); + REQUIRE(rdata->rdclass == 1); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); + + dns_name_init(&name, NULL); + dns_rdata_toregion(rdata, ®ion); + dns_name_fromregion(&name, ®ion); + + return (dns_name_towire(&name, cctx, target)); +} + +static inline int +compare_in_nsap_ptr(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + dns_name_t name1; + dns_name_t name2; + isc_region_t region1; + isc_region_t region2; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 23); + REQUIRE(rdata1->rdclass == 1); + + dns_name_init(&name1, NULL); + dns_name_init(&name2, NULL); + + dns_rdata_toregion(rdata1, ®ion1); + dns_rdata_toregion(rdata2, ®ion2); + + dns_name_fromregion(&name1, ®ion1); + dns_name_fromregion(&name2, ®ion2); + + return (dns_name_rdatacompare(&name1, &name2)); +} + +static inline isc_result_t +fromstruct_in_nsap_ptr(dns_rdataclass_t rdclass, dns_rdatatype_t type, + void *source, isc_buffer_t *target) +{ + + REQUIRE(type == 23); + REQUIRE(rdclass == 1); + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_in_nsap_ptr(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 23); + REQUIRE(rdata->rdclass == 1); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_in_nsap_ptr(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); +} + +static inline isc_result_t +additionaldata_in_nsap_ptr(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 23); + REQUIRE(rdata->rdclass == 1); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_in_nsap_ptr(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + dns_name_t name; + + REQUIRE(rdata->type == 23); + REQUIRE(rdata->rdclass == 1); + + dns_rdata_toregion(rdata, &r); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r); + + return (dns_name_digest(&name, digest, arg)); +} + +#endif /* RDATA_IN_1_NSAP_PTR_23_C */ diff --git a/lib/dns/rdata/in_1/nsap-ptr_23.h b/lib/dns/rdata/in_1/nsap-ptr_23.h new file mode 100644 index 00000000..d7287658 --- /dev/null +++ b/lib/dns/rdata/in_1/nsap-ptr_23.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: nsap-ptr_23.h,v 1.9 2000/02/03 23:43:18 halley Exp $ */ + + /* RFC 1348 */ + +typedef struct dns_rdata_in_nsap_ptr { + dns_rdatacommon_t common; + isc_mem_t *mctx; + dns_name_t owner; +} dns_rdata_in_nsap_ptr_t; diff --git a/lib/dns/rdata/in_1/nsap_22.c b/lib/dns/rdata/in_1/nsap_22.c new file mode 100644 index 00000000..f7ed7a42 --- /dev/null +++ b/lib/dns/rdata/in_1/nsap_22.c @@ -0,0 +1,200 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: nsap_22.c,v 1.12 2000/02/03 23:43:18 halley Exp $ */ + + /* RFC 1706 */ + +#ifndef RDATA_IN_1_NSAP_22_C +#define RDATA_IN_1_NSAP_22_C + +#include <string.h> + +static inline isc_result_t +fromtext_in_nsap(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_lex_t *lexer, dns_name_t *origin, + isc_boolean_t downcase, isc_buffer_t *target) { + isc_token_t token; + isc_textregion_t *sr; + int n; + int digits; + unsigned char c; + + REQUIRE(type == 22); + REQUIRE(rdclass == 1); + + origin = origin; /*unused*/ + downcase = downcase; /*unused*/ + + /* 0x<hex.string.with.periods> */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + sr = &token.value.as_textregion; + if (sr->length < 2) + return (DNS_R_UNEXPECTEDEND); + if (sr->base[0] != '0' || (sr->base[1] != 'x' && sr->base[1] != 'X')) + return (DNS_R_SYNTAX); + isc_textregion_consume(sr, 2); + digits = 0; + n = 0; + while (sr->length > 0) { + if (sr->base[0] == '.') { + isc_textregion_consume(sr, 1); + continue; + } + if ((n = hexvalue(sr->base[0])) == -1) + return (DNS_R_SYNTAX); + c <<= 4; + c += n; + if (++digits == 2) { + RETERR(mem_tobuffer(target, &c, 1)); + digits = 0; + } + isc_textregion_consume(sr, 1); + } + if (digits) { + return (DNS_R_UNEXPECTEDEND); + } + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +totext_in_nsap(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t region; + char buf[sizeof "xx"]; + + REQUIRE(rdata->type == 22); + REQUIRE(rdata->rdclass == 1); + + tctx = tctx; /* unused */ + + dns_rdata_toregion(rdata, ®ion); + RETERR(str_totext("0x", target)); + while (region.length) { + sprintf(buf, "%02x", region.base[0]); + isc_region_consume(®ion, 1); + RETERR(str_totext(buf, target)); + } + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +fromwire_in_nsap(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_buffer_t *source, dns_decompress_t *dctx, + isc_boolean_t downcase, isc_buffer_t *target) +{ + isc_region_t region; + + REQUIRE(type == 22); + REQUIRE(rdclass == 1); + + dctx = dctx; /* unused */ + downcase = downcase; /* unused */ + + + isc_buffer_active(source, ®ion); + if (region.length < 1) + return (DNS_R_UNEXPECTEDEND); + + return (mem_tobuffer(target, region.base, region.length)); +} + +static inline isc_result_t +towire_in_nsap(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + + REQUIRE(rdata->type == 22); + REQUIRE(rdata->rdclass == 1); + + cctx = cctx; /*unused*/ + + return (mem_tobuffer(target, rdata->data, rdata->length)); +} + +static inline int +compare_in_nsap(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + isc_region_t r1; + isc_region_t r2; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 22); + REQUIRE(rdata1->rdclass == 1); + + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + return (compare_region(&r1, &r2)); +} + +static inline isc_result_t +fromstruct_in_nsap(dns_rdataclass_t rdclass, dns_rdatatype_t type, + void *source, isc_buffer_t *target) +{ + + REQUIRE(type == 22); + REQUIRE(rdclass == 1); + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_in_nsap(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 22); + REQUIRE(rdata->rdclass == 1); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_in_nsap(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ +} + +static inline isc_result_t +additionaldata_in_nsap(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 22); + REQUIRE(rdata->rdclass == 1); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_in_nsap(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + + REQUIRE(rdata->type == 22); + REQUIRE(rdata->rdclass == 1); + + dns_rdata_toregion(rdata, &r); + + return ((digest)(arg, &r)); +} + +#endif /* RDATA_IN_1_NSAP_22_C */ diff --git a/lib/dns/rdata/in_1/nsap_22.h b/lib/dns/rdata/in_1/nsap_22.h new file mode 100644 index 00000000..779b3a71 --- /dev/null +++ b/lib/dns/rdata/in_1/nsap_22.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: nsap_22.h,v 1.7 2000/02/03 23:43:18 halley Exp $ */ + + /* RFC 1706 */ + +typedef struct dns_rdata_in_nsap { + dns_rdatacommon_t common; + isc_mem_t *mctx; + unsigned char *nsap; + isc_uint16_t length; +} dns_rdata_in_nsap_t; diff --git a/lib/dns/rdata/in_1/px_26.c b/lib/dns/rdata/in_1/px_26.c new file mode 100644 index 00000000..b1480e3a --- /dev/null +++ b/lib/dns/rdata/in_1/px_26.c @@ -0,0 +1,315 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: px_26.c,v 1.14 2000/02/03 23:43:19 halley Exp $ */ + + /* RFC 2163 */ + +#ifndef RDATA_IN_1_PX_26_C +#define RDATA_IN_1_PX_26_C + +static inline isc_result_t +fromtext_in_px(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_lex_t *lexer, dns_name_t *origin, + isc_boolean_t downcase, isc_buffer_t *target) +{ + isc_token_t token; + dns_name_t name; + isc_buffer_t buffer; + + REQUIRE(type == 26); + REQUIRE(rdclass == 1); + + /* preference */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + RETERR(uint16_tobuffer(token.value.as_ulong, target)); + + /* MAP822 */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + dns_name_init(&name, NULL); + buffer_fromregion(&buffer, &token.value.as_region, + ISC_BUFFERTYPE_TEXT); + origin = (origin != NULL) ? origin : dns_rootname; + RETERR(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + + /* MAPX400 */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + dns_name_init(&name, NULL); + buffer_fromregion(&buffer, &token.value.as_region, + ISC_BUFFERTYPE_TEXT); + origin = (origin != NULL) ? origin : dns_rootname; + return (dns_name_fromtext(&name, &buffer, origin, downcase, target)); +} + +static inline isc_result_t +totext_in_px(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t region; + dns_name_t name; + dns_name_t prefix; + isc_boolean_t sub; + char buf[sizeof "64000"]; + unsigned short num; + + REQUIRE(rdata->type == 26); + REQUIRE(rdata->rdclass == 1); + + dns_name_init(&name, NULL); + dns_name_init(&prefix, NULL); + + /* preference */ + dns_rdata_toregion(rdata, ®ion); + num = uint16_fromregion(®ion); + isc_region_consume(®ion, 2); + sprintf(buf, "%u", num); + RETERR(str_totext(buf, target)); + RETERR(str_totext(" ", target)); + + /* MAP822 */ + dns_name_fromregion(&name, ®ion); + sub = name_prefix(&name, tctx->origin, &prefix); + isc_region_consume(®ion, name_length(&name)); + RETERR(dns_name_totext(&prefix, sub, target)); + RETERR(str_totext(" ", target)); + + /* MAPX400 */ + dns_name_fromregion(&name, ®ion); + sub = name_prefix(&name, tctx->origin, &prefix); + return(dns_name_totext(&prefix, sub, target)); +} + +static inline isc_result_t +fromwire_in_px(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_buffer_t *source, dns_decompress_t *dctx, + isc_boolean_t downcase, isc_buffer_t *target) +{ + dns_name_t name; + isc_region_t sregion; + + REQUIRE(type == 26); + REQUIRE(rdclass == 1); + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE); + + dns_name_init(&name, NULL); + + /* preference */ + isc_buffer_active(source, &sregion); + if (sregion.length < 2) + return (DNS_R_UNEXPECTEDEND); + RETERR(mem_tobuffer(target, sregion.base, 2)); + isc_buffer_forward(source, 2); + + /* MAP822 */ + RETERR(dns_name_fromwire(&name, source, dctx, downcase, target)); + + /* MAPX400 */ + return (dns_name_fromwire(&name, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_in_px(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 26); + REQUIRE(rdata->rdclass == 1); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); + + /* preference */ + dns_rdata_toregion(rdata, ®ion); + RETERR(mem_tobuffer(target, region.base, 2)); + isc_region_consume(®ion, 2); + + /* MAP822 */ + dns_name_init(&name, NULL); + dns_name_fromregion(&name, ®ion); + RETERR(dns_name_towire(&name, cctx, target)); + isc_region_consume(®ion, name_length(&name)); + + /* MAPX400 */ + dns_name_init(&name, NULL); + dns_name_fromregion(&name, ®ion); + return (dns_name_towire(&name, cctx, target)); +} + +static inline int +compare_in_px(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + dns_name_t name1; + dns_name_t name2; + isc_region_t region1; + isc_region_t region2; + int result; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 26); + REQUIRE(rdata1->rdclass == 1); + + result = memcmp(rdata1->data, rdata2->data, 2); + if (result != 0) + return (result < 0 ? -1 : 1); + + dns_name_init(&name1, NULL); + dns_name_init(&name2, NULL); + + dns_rdata_toregion(rdata1, ®ion1); + dns_rdata_toregion(rdata2, ®ion2); + + isc_region_consume(®ion1, 2); + isc_region_consume(®ion2, 2); + + dns_name_fromregion(&name1, ®ion1); + dns_name_fromregion(&name2, ®ion2); + + result = dns_name_rdatacompare(&name1, &name2); + if (result != 0) + return (result); + + isc_region_consume(®ion1, name_length(&name1)); + isc_region_consume(®ion2, name_length(&name2)); + + dns_name_fromregion(&name1, ®ion1); + dns_name_fromregion(&name2, ®ion2); + + return (dns_name_rdatacompare(&name1, &name2)); +} + +static inline isc_result_t +fromstruct_in_px(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + dns_rdata_in_px_t *px = source; + isc_region_t region; + + REQUIRE(type == 26); + REQUIRE(rdclass == 1); + REQUIRE(source != NULL); + REQUIRE(px->common.rdtype == type); + REQUIRE(px->common.rdclass == rdclass); + + RETERR(uint16_tobuffer(px->preference, target)); + dns_name_toregion(&px->map822, ®ion); + RETERR(isc_buffer_copyregion(target, ®ion)); + dns_name_toregion(&px->mapx400, ®ion); + return (isc_buffer_copyregion(target, ®ion)); +} + +static inline isc_result_t +tostruct_in_px(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + isc_region_t region; + isc_region_t nr; + dns_rdata_in_px_t *px = target; + dns_name_t name; + isc_result_t result; + + REQUIRE(rdata->type == 26); + REQUIRE(rdata->rdclass == 1); + REQUIRE(target != NULL); + REQUIRE(mctx != NULL); + + px->common.rdclass = rdata->rdclass; + px->common.rdtype = rdata->type; + ISC_LINK_INIT(&px->common, link); + + dns_name_init(&name, NULL); + dns_rdata_toregion(rdata, ®ion); + + px->preference = uint16_fromregion(®ion); + isc_region_consume(®ion, 2); + + dns_name_fromregion(&name, ®ion); + dns_name_toregion(&name, &nr); + isc_region_consume(®ion, nr.length); + px->mctx = mctx; + dns_name_init(&px->map822, NULL); + result = dns_name_dup(&name, px->mctx, &px->map822); + if (result != ISC_R_SUCCESS) { + px->mctx = NULL; + return (result); + } + + dns_name_init(&px->mapx400, NULL); + result = dns_name_dup(&name, px->mctx, &px->map822); + if (result != ISC_R_SUCCESS) { + dns_name_free(&px->map822, px->mctx); + px->mctx = NULL; + } + return (result); +} + +static inline void +freestruct_in_px(void *source) { + dns_rdata_in_px_t *px = source; + + REQUIRE(source != NULL); + + dns_name_free(&px->map822, px->mctx); + dns_name_free(&px->mapx400, px->mctx); + px->mctx = NULL; +} + +static inline isc_result_t +additionaldata_in_px(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 26); + REQUIRE(rdata->rdclass == 1); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_in_px(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r1, r2; + dns_name_t name; + isc_result_t result; + + REQUIRE(rdata->type == 26); + REQUIRE(rdata->rdclass == 1); + + dns_rdata_toregion(rdata, &r1); + r2 = r1; + isc_region_consume(&r2, 2); + r1.length = 2; + result = (digest)(arg, &r1); + if (result != DNS_R_SUCCESS) + return (result); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r2); + result = dns_name_digest(&name, digest, arg); + if (result != DNS_R_SUCCESS) + return (result); + isc_region_consume(&r2, name_length(&name)); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r2); + + return (dns_name_digest(&name, digest, arg)); +} + +#endif /* RDATA_IN_1_PX_26_C */ diff --git a/lib/dns/rdata/in_1/px_26.h b/lib/dns/rdata/in_1/px_26.h new file mode 100644 index 00000000..3a528190 --- /dev/null +++ b/lib/dns/rdata/in_1/px_26.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: px_26.h,v 1.9 2000/02/03 23:43:19 halley Exp $ */ + + /* RFC 2163 */ + +typedef struct dns_rdata_in_px { + dns_rdatacommon_t common; + isc_mem_t *mctx; + isc_uint16_t preference; + dns_name_t map822; + dns_name_t mapx400; +} dns_rdata_in_px_t; diff --git a/lib/dns/rdata/in_1/srv_33.c b/lib/dns/rdata/in_1/srv_33.c new file mode 100644 index 00000000..40133b91 --- /dev/null +++ b/lib/dns/rdata/in_1/srv_33.c @@ -0,0 +1,260 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: srv_33.c,v 1.14 2000/02/03 23:43:19 halley Exp $ */ + + /* RFC 2052 bis */ + +#ifndef RDATA_IN_1_SRV_33_C +#define RDATA_IN_1_SRV_33_C + +static inline isc_result_t +fromtext_in_srv(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_lex_t *lexer, dns_name_t *origin, + isc_boolean_t downcase, isc_buffer_t *target) +{ + isc_token_t token; + dns_name_t name; + isc_buffer_t buffer; + + REQUIRE(type == 33); + REQUIRE(rdclass == 1); + + /* priority */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + RETERR(uint16_tobuffer(token.value.as_ulong, target)); + + /* weight */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + RETERR(uint16_tobuffer(token.value.as_ulong, target)); + + /* port */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + RETERR(uint16_tobuffer(token.value.as_ulong, target)); + + /* target */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + dns_name_init(&name, NULL); + buffer_fromregion(&buffer, &token.value.as_region, + ISC_BUFFERTYPE_TEXT); + origin = (origin != NULL) ? origin : dns_rootname; + return (dns_name_fromtext(&name, &buffer, origin, downcase, target)); +} + +static inline isc_result_t +totext_in_srv(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t region; + dns_name_t name; + dns_name_t prefix; + isc_boolean_t sub; + char buf[sizeof "64000"]; + unsigned short num; + + REQUIRE(rdata->type == 33); + REQUIRE(rdata->rdclass == 1); + + dns_name_init(&name, NULL); + dns_name_init(&prefix, NULL); + + /* priority */ + dns_rdata_toregion(rdata, ®ion); + num = uint16_fromregion(®ion); + isc_region_consume(®ion, 2); + sprintf(buf, "%u", num); + RETERR(str_totext(buf, target)); + RETERR(str_totext(" ", target)); + + /* weight */ + num = uint16_fromregion(®ion); + isc_region_consume(®ion, 2); + sprintf(buf, "%u", num); + RETERR(str_totext(buf, target)); + RETERR(str_totext(" ", target)); + + /* port */ + num = uint16_fromregion(®ion); + isc_region_consume(®ion, 2); + sprintf(buf, "%u", num); + RETERR(str_totext(buf, target)); + RETERR(str_totext(" ", target)); + + /* target */ + dns_name_fromregion(&name, ®ion); + sub = name_prefix(&name, tctx->origin, &prefix); + return(dns_name_totext(&prefix, sub, target)); +} + +static inline isc_result_t +fromwire_in_srv(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_buffer_t *source, dns_decompress_t *dctx, + isc_boolean_t downcase, isc_buffer_t *target) +{ + dns_name_t name; + isc_region_t sr; + + REQUIRE(type == 33); + REQUIRE(rdclass == 1); + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE); + + dns_name_init(&name, NULL); + + /* priority, weight, port */ + isc_buffer_active(source, &sr); + if (sr.length < 6) + return (DNS_R_UNEXPECTEDEND); + RETERR(mem_tobuffer(target, sr.base, 6)); + isc_buffer_forward(source, 6); + + /* target */ + return (dns_name_fromwire(&name, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_in_srv(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + dns_name_t name; + isc_region_t sr; + + REQUIRE(rdata->type == 33); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); + + /* priority, weight, port */ + dns_rdata_toregion(rdata, &sr); + RETERR(mem_tobuffer(target, sr.base, 6)); + isc_region_consume(&sr, 6); + + /* target */ + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &sr); + return (dns_name_towire(&name, cctx, target)); +} + +static inline int +compare_in_srv(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + dns_name_t name1; + dns_name_t name2; + isc_region_t region1; + isc_region_t region2; + int result; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 33); + REQUIRE(rdata1->rdclass == 1); + + /* priority, weight, port */ + result = memcmp(rdata1->data, rdata2->data, 6); + if (result != 0) + return (result < 0 ? -1 : 1); + + /* target */ + dns_name_init(&name1, NULL); + dns_name_init(&name2, NULL); + + dns_rdata_toregion(rdata1, ®ion1); + dns_rdata_toregion(rdata2, ®ion2); + + isc_region_consume(®ion1, 6); + isc_region_consume(®ion2, 6); + + dns_name_fromregion(&name1, ®ion1); + dns_name_fromregion(&name2, ®ion2); + + return (dns_name_rdatacompare(&name1, &name2)); +} + +static inline isc_result_t +fromstruct_in_srv(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 33); + REQUIRE(rdclass == 1); + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_in_srv(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 33); + REQUIRE(rdata->rdclass == 1); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_in_srv(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ +} + +static inline isc_result_t +additionaldata_in_srv(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 33); + REQUIRE(rdata->rdclass == 1); + + dns_name_init(&name, NULL); + dns_rdata_toregion(rdata, ®ion); + isc_region_consume(®ion, 6); + dns_name_fromregion(&name, ®ion); + + return ((add)(arg, &name, dns_rdatatype_a)); +} + +static inline isc_result_t +digest_in_srv(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r1, r2; + isc_result_t result; + dns_name_t name; + + REQUIRE(rdata->type == 33); + REQUIRE(rdata->rdclass == 1); + + dns_rdata_toregion(rdata, &r1); + r2 = r1; + isc_region_consume(&r2, 6); + r1.length = 6; + result = (digest)(arg, &r1); + if (result != ISC_R_SUCCESS) + return (result); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r2); + return (dns_name_digest(&name, digest, arg)); +} + +#endif /* RDATA_IN_1_SRV_33_C */ diff --git a/lib/dns/rdata/in_1/srv_33.h b/lib/dns/rdata/in_1/srv_33.h new file mode 100644 index 00000000..09832b38 --- /dev/null +++ b/lib/dns/rdata/in_1/srv_33.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: srv_33.h,v 1.9 2000/02/03 23:43:19 halley Exp $ */ + + /* RFC 2052 bis */ + +typedef struct dns_rdata_in_srv { + dns_rdatacommon_t common; + isc_mem_t *mctx; + isc_uint16_t priority; + isc_uint16_t weight; + isc_uint16_t port; + dns_name_t target; +} dns_rdata_in_srv_t; + diff --git a/lib/dns/rdata/in_1/wks_11.c b/lib/dns/rdata/in_1/wks_11.c new file mode 100644 index 00000000..3500e9b1 --- /dev/null +++ b/lib/dns/rdata/in_1/wks_11.c @@ -0,0 +1,267 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: wks_11.c,v 1.20 2000/02/03 23:43:19 halley Exp $ */ + +#ifndef RDATA_IN_1_WKS_11_C +#define RDATA_IN_1_WKS_11_C + +#include <limits.h> +#include <stdlib.h> +#include <string.h> + +#include <isc/net.h> +#include <isc/netdb.h> + +static inline isc_result_t +fromtext_in_wks(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_lex_t *lexer, dns_name_t *origin, + isc_boolean_t downcase, isc_buffer_t *target) +{ + isc_token_t token; + isc_region_t region; + struct in_addr addr; + struct protoent *pe; + struct servent *se; + char *e; + long proto; + unsigned char bm[8*1024]; /* 64k bits */ + long port; + long maxport = -1; + char *ps = NULL; + unsigned int n; + + REQUIRE(type == 11); + REQUIRE(rdclass == 1); + + origin = origin; /*unused*/ + downcase = downcase; /*unused*/ + + /* IPv4 dotted quad */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + + isc_buffer_available(target, ®ion); + if (inet_aton(token.value.as_pointer, &addr) != 1) + return (DNS_R_BADDOTTEDQUAD); + if (region.length < 4) + return (DNS_R_NOSPACE); + memcpy(region.base, &addr, 4); + isc_buffer_add(target, 4); + + /* protocol */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + + proto = strtol(token.value.as_pointer, &e, 10); + if (*e == 0) + (void)NULL; + else if ((pe = getprotobyname(token.value.as_pointer)) != NULL) + proto = pe->p_proto; + else + return (DNS_R_UNEXPECTED); + if (proto < 0 || proto > 0xff) + return (DNS_R_RANGE); + + if (proto == IPPROTO_TCP) + ps = "tcp"; + else if (proto == IPPROTO_UDP) + ps = "udp"; + + RETERR(uint8_tobuffer(proto, target)); + + memset(bm, 0, sizeof bm); + do { + RETERR(gettoken(lexer, &token, isc_tokentype_string, + ISC_TRUE)); + if (token.type != isc_tokentype_string) + break; + port = strtol(token.value.as_pointer, &e, 10); + if (*e == 0) + (void) NULL; + else if ((se = getservbyname(token.value.as_pointer, ps)) + != NULL) + port = ntohs(se->s_port); + else + return (DNS_R_UNEXPECTED); + if (port < 0 || port > 0xffff) + return (DNS_R_RANGE); + if (port > maxport) + maxport = port; + bm[port/8] |= (0x80>>(port%8)); + } while (1); + isc_lex_ungettoken(lexer, &token); + n = (maxport + 8) / 8; + return (mem_tobuffer(target, bm, n)); +} + +static inline isc_result_t +totext_in_wks(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t sr; + isc_region_t tr; + unsigned short proto; + char buf[sizeof "65535"]; + unsigned int i, j; + + REQUIRE(rdata->type == 11); + REQUIRE(rdata->rdclass == 1); + + tctx = tctx; + dns_rdata_toregion(rdata, &sr); + isc_buffer_available(target, &tr); + if (inet_ntop(AF_INET, sr.base, (char *)tr.base, tr.length) == NULL) + return (DNS_R_NOSPACE); + isc_buffer_add(target, strlen((char *)tr.base)); + isc_region_consume(&sr, 4); + + proto = uint8_fromregion(&sr); + sprintf(buf, "%u", proto); + RETERR(str_totext(" ", target)); + RETERR(str_totext(buf, target)); + isc_region_consume(&sr, 2); + RETERR(str_totext(" (", target)); + + for (i = 0 ; i < sr.length ; i++) { + if (sr.base[i] != 0) + for (j = 0; j < 8; j++) + if ((sr.base[i] & (0x80>>j)) != 0) { + sprintf(buf, "%u", i * 8 + j); + RETERR(str_totext(" ", target)); + RETERR(str_totext(buf, target)); + } + } + RETERR(str_totext(" )", target)); + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +fromwire_in_wks(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_buffer_t *source, dns_decompress_t *dctx, + isc_boolean_t downcase, isc_buffer_t *target) +{ + isc_region_t sr; + isc_region_t tr; + + REQUIRE(type == 11); + REQUIRE(rdclass == 1); + + dctx = dctx; /*unused*/ + downcase = downcase; /*unused*/ + + isc_buffer_active(source, &sr); + isc_buffer_available(target, &tr); + + if (sr.length < 5) + return (DNS_R_UNEXPECTEDEND); + if (sr.length > 8 * 1024 + 5) + return (DNS_R_EXTRADATA); + if (tr.length < sr.length) + return (DNS_R_NOSPACE); + + memcpy(tr.base, sr.base, sr.length); + isc_buffer_add(target, sr.length); + isc_buffer_forward(source, sr.length); + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +towire_in_wks(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + isc_region_t sr; + + REQUIRE(rdata->type == 11); + REQUIRE(rdata->rdclass == 1); + + cctx = cctx; /*unused*/ + + dns_rdata_toregion(rdata, &sr); + return (mem_tobuffer(target, sr.base, sr.length)); +} + +static inline int +compare_in_wks(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + isc_region_t r1; + isc_region_t r2; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 11); + REQUIRE(rdata1->rdclass == 1); + + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + return (compare_region(&r1, &r2)); +} + +static inline isc_result_t +fromstruct_in_wks(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + + REQUIRE(type == 11); + REQUIRE(rdclass == 1); + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_in_wks(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 11); + REQUIRE(rdata->rdclass == 1); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_in_wks(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ +} + +static inline isc_result_t +additionaldata_in_wks(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 11); + REQUIRE(rdata->rdclass == 1); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_in_wks(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + + REQUIRE(rdata->type == 11); + REQUIRE(rdata->rdclass == 1); + + dns_rdata_toregion(rdata, &r); + + return ((digest)(arg, &r)); +} + +#endif /* RDATA_IN_1_WKS_11_C */ diff --git a/lib/dns/rdata/in_1/wks_11.h b/lib/dns/rdata/in_1/wks_11.h new file mode 100644 index 00000000..b3f1b8c3 --- /dev/null +++ b/lib/dns/rdata/in_1/wks_11.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM 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. + */ + + /* $Id: wks_11.h,v 1.13 2000/02/03 23:43:20 halley Exp $ */ + +typedef struct dns_rdata_in_wks { + dns_rdatacommon_t common; + isc_mem_t *mctx; + struct in_addr in_addr; + isc_uint16_t protocol; + unsigned char *map; + isc_uint16_t length; +} dns_rdata_in_wks_t; |