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/generic | |
download | bind9-ab47e90612dcdb02c4b134cfb1be0697007c0dac.tar.gz |
9.0.0b1
Diffstat (limited to 'lib/dns/rdata/generic')
60 files changed, 7757 insertions, 0 deletions
diff --git a/lib/dns/rdata/generic/afsdb_18.c b/lib/dns/rdata/generic/afsdb_18.c new file mode 100644 index 00000000..e09954d0 --- /dev/null +++ b/lib/dns/rdata/generic/afsdb_18.c @@ -0,0 +1,241 @@ +/* + * 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: afsdb_18.c,v 1.15 2000/02/03 23:42:57 halley Exp $ */ + + /* RFC 1183 */ + +#ifndef RDATA_GENERIC_AFSDB_18_C +#define RDATA_GENERIC_AFSDB_18_C + +static inline isc_result_t +fromtext_afsdb(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_buffer_t buffer; + dns_name_t name; + + REQUIRE(type == 18); + + rdclass = rdclass; /*unused*/ + + /* subtype */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + RETERR(uint16_tobuffer(token.value.as_ulong, target)); + + /* hostname */ + 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_afsdb(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + dns_name_t name; + dns_name_t prefix; + isc_region_t region; + char buf[sizeof "64000 "]; + isc_boolean_t sub; + unsigned int num; + + + REQUIRE(rdata->type == 18); + + 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)); + 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_afsdb(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; + isc_region_t tr; + + REQUIRE(type == 18); + + rdclass = rdclass; /*unused*/ + + 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, &sr); + isc_buffer_available(target, &tr); + if (tr.length < 2) + return (DNS_R_NOSPACE); + if (sr.length < 2) + return (DNS_R_UNEXPECTEDEND); + memcpy(tr.base, sr.base, 2); + isc_buffer_forward(source, 2); + isc_buffer_add(target, 2); + return (dns_name_fromwire(&name, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_afsdb(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + isc_region_t tr; + isc_region_t sr; + dns_name_t name; + + REQUIRE(rdata->type == 18); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); + + isc_buffer_available(target, &tr); + dns_rdata_toregion(rdata, &sr); + if (tr.length < 2) + return (DNS_R_NOSPACE); + memcpy(tr.base, sr.base, 2); + isc_region_consume(&sr, 2); + isc_buffer_add(target, 2); + + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &sr); + + return (dns_name_towire(&name, cctx, target)); +} + +static inline int +compare_afsdb(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + int result; + 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 == 18); + + 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_afsdb(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 18); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_afsdb(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 18); + REQUIRE(target != NULL); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_afsdb(void *source) { + dns_rdata_afsdb_t *afsdb = source; + + REQUIRE(source != NULL); + REQUIRE(afsdb->common.rdtype == 18); + REQUIRE(ISC_FALSE); +} + +static inline isc_result_t +additionaldata_afsdb(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 18); + + 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_afsdb(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 == 18); + + 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_AFSDB_18_C */ diff --git a/lib/dns/rdata/generic/afsdb_18.h b/lib/dns/rdata/generic/afsdb_18.h new file mode 100644 index 00000000..24693c1b --- /dev/null +++ b/lib/dns/rdata/generic/afsdb_18.h @@ -0,0 +1,25 @@ +/* + * 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: afsdb_18.h,v 1.9 2000/02/03 23:42:57 halley Exp $ */ + + /* RFC 1183 */ + +typedef struct dns_rdata_afsdb { + dns_rdatacommon_t common; + /*XXX*/ +} dns_rdata_afsdb_t; diff --git a/lib/dns/rdata/generic/cert_37.c b/lib/dns/rdata/generic/cert_37.c new file mode 100644 index 00000000..32a4f44e --- /dev/null +++ b/lib/dns/rdata/generic/cert_37.c @@ -0,0 +1,206 @@ +/* + * 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: cert_37.c,v 1.18 2000/02/03 23:42:57 halley Exp $ */ + + /* draft-ietf-dnssec-certs-04.txt */ + +#ifndef RDATA_GENERIC_CERT_37_C +#define RDATA_GENERIC_CERT_37_C + +static inline isc_result_t +fromtext_cert(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; + long n; + dns_secalg_t secalg; + char *e; + dns_cert_t cert; + + REQUIRE(type == 37); + + rdclass = rdclass; /*unused*/ + origin = origin; /*unused*/ + downcase = downcase; /*unused*/ + + /* cert type */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + n = strtol(token.value.as_pointer, &e, 10); + RETERR(dns_cert_fromtext(&cert, &token.value.as_textregion)); + RETERR(uint16_tobuffer(cert, target)); + + /* key tag */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + if (token.value.as_ulong > 0xffff) + return (DNS_R_RANGE); + RETERR(uint16_tobuffer(token.value.as_ulong, target)); + + /* algorithm */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + RETERR(dns_secalg_fromtext(&secalg, &token.value.as_textregion)); + RETERR(mem_tobuffer(target, &secalg, 1)); + + return (isc_base64_tobuffer(lexer, target, -1)); +} + +static inline isc_result_t +totext_cert(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t sr; + char buf[sizeof "64000 "]; + unsigned int n; + + REQUIRE(rdata->type == 37); + + tctx = tctx; /*unused*/ + + dns_rdata_toregion(rdata, &sr); + + /* type */ + n = uint16_fromregion(&sr); + isc_region_consume(&sr, 2); + RETERR(dns_cert_totext((dns_cert_t)n, target)); + RETERR(str_totext(" ", target)); + + /* key tag */ + n = uint16_fromregion(&sr); + isc_region_consume(&sr, 2); + sprintf(buf, "%u ", n); + RETERR(str_totext(buf, target)); + + /* algorithm */ + RETERR(dns_secalg_totext(sr.base[0], target)); + isc_region_consume(&sr, 1); + + /* cert */ + if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) + RETERR(str_totext(" (", target)); + RETERR(str_totext(tctx->linebreak, target)); + RETERR(isc_base64_totext(&sr, tctx->width - 2, + tctx->linebreak, target)); + if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) + RETERR(str_totext(" )", target)); + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +fromwire_cert(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; + + REQUIRE(type == 37); + + rdclass = rdclass; /*unused*/ + dctx = dctx; /*unused*/ + downcase = downcase; /*unused*/ + + isc_buffer_active(source, &sr); + if (sr.length < 5) + return (DNS_R_UNEXPECTEDEND); + + isc_buffer_forward(source, sr.length); + return (mem_tobuffer(target, sr.base, sr.length)); +} + +static inline isc_result_t +towire_cert(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + isc_region_t sr; + + REQUIRE(rdata->type == 37); + + cctx = cctx; /*unused*/ + + dns_rdata_toregion(rdata, &sr); + return (mem_tobuffer(target, sr.base, sr.length)); +} + +static inline int +compare_cert(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 == 37); + + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + return (compare_region(&r1, &r2)); +} + +static inline isc_result_t +fromstruct_cert(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 37); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_cert(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 37); + REQUIRE(target != NULL && target == NULL); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_cert(void *target) { + REQUIRE(target != NULL && target != NULL); + REQUIRE(ISC_FALSE); /* XXX */ +} + +static inline isc_result_t +additionaldata_cert(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 37); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_cert(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + + REQUIRE(rdata->type == 37); + + dns_rdata_toregion(rdata, &r); + + return ((digest)(arg, &r)); +} + +#endif /* RDATA_GENERIC_CERT_37_C */ diff --git a/lib/dns/rdata/generic/cert_37.h b/lib/dns/rdata/generic/cert_37.h new file mode 100644 index 00000000..1aaddff2 --- /dev/null +++ b/lib/dns/rdata/generic/cert_37.h @@ -0,0 +1,21 @@ +/* + * 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: cert_37.h,v 1.9 2000/02/03 23:42:58 halley Exp $ */ + + /* draft-ietf-dnssec-certs-04.txt */ + diff --git a/lib/dns/rdata/generic/cname_5.c b/lib/dns/rdata/generic/cname_5.c new file mode 100644 index 00000000..8386b5a5 --- /dev/null +++ b/lib/dns/rdata/generic/cname_5.c @@ -0,0 +1,188 @@ +/* + * 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: cname_5.c,v 1.20 2000/02/03 23:42:58 halley Exp $ */ + +#ifndef RDATA_GENERIC_CNAME_5_C +#define RDATA_GENERIC_CNAME_5_C + +static inline isc_result_t +fromtext_cname(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 == 5); + + rdclass = rdclass; /*unused*/ + + 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_cname(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 == 5); + + 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_cname(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 == 5); + + rdclass = rdclass; /*unused*/ + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); + + dns_name_init(&name, NULL); + return(dns_name_fromwire(&name, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_cname(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 5); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); + + 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_cname(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 == 5); + + 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_cname(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 5); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_cname(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 5); + REQUIRE(target != NULL); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_cname(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); +} + +static inline isc_result_t +additionaldata_cname(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 5); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_cname(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + dns_name_t name; + + REQUIRE(rdata->type == 5); + + dns_rdata_toregion(rdata, &r); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r); + + return (dns_name_digest(&name, digest, arg)); +} + +#endif /* RDATA_GENERIC_CNAME_5_C */ diff --git a/lib/dns/rdata/generic/cname_5.h b/lib/dns/rdata/generic/cname_5.h new file mode 100644 index 00000000..bd900f92 --- /dev/null +++ b/lib/dns/rdata/generic/cname_5.h @@ -0,0 +1,19 @@ +/* + * 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: cname_5.h,v 1.15 2000/02/03 23:42:58 halley Exp $ */ + diff --git a/lib/dns/rdata/generic/dname_39.c b/lib/dns/rdata/generic/dname_39.c new file mode 100644 index 00000000..4c0eddf4 --- /dev/null +++ b/lib/dns/rdata/generic/dname_39.c @@ -0,0 +1,188 @@ +/* + * 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: dname_39.c,v 1.13 2000/02/03 23:42:58 halley Exp $ */ + + /* draft-ietf-dnsind-dname-02.txt */ + +#ifndef RDATA_GENERIC_DNAME_39_C +#define RDATA_GENERIC_DNAME_39_C + +static inline isc_result_t +fromtext_dname(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 == 39); + rdclass = rdclass; /*unused*/ + + 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_dname(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 == 39); + + 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_dname(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 == 39); + rdclass = rdclass; /*unused*/ + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_LOCAL); + + dns_name_init(&name, NULL); + return(dns_name_fromwire(&name, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_dname(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 39); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_LOCAL); + + 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_dname(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 == 39); + + 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_dname(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 39); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_dname(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 39); + REQUIRE(target != NULL && target == NULL); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_dname(void *source) { + REQUIRE(source != NULL && source != NULL); + REQUIRE(ISC_FALSE); /* XXX */ +} + +static inline isc_result_t +additionaldata_dname(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 39); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_dname(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + dns_name_t name; + + REQUIRE(rdata->type == 39); + + dns_rdata_toregion(rdata, &r); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r); + + return (dns_name_digest(&name, digest, arg)); +} + +#endif /* RDATA_GENERIC_DNAME_39_C */ diff --git a/lib/dns/rdata/generic/dname_39.h b/lib/dns/rdata/generic/dname_39.h new file mode 100644 index 00000000..fac92d43 --- /dev/null +++ b/lib/dns/rdata/generic/dname_39.h @@ -0,0 +1,21 @@ +/* + * 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: dname_39.h,v 1.8 2000/02/03 23:42:58 halley Exp $ */ + + /* draft-ietf-dnsind-dname-02.txt */ + diff --git a/lib/dns/rdata/generic/gpos_27.c b/lib/dns/rdata/generic/gpos_27.c new file mode 100644 index 00000000..1b4302ab --- /dev/null +++ b/lib/dns/rdata/generic/gpos_27.c @@ -0,0 +1,166 @@ +/* + * 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: gpos_27.c,v 1.11 2000/02/03 23:42:59 halley Exp $ */ + + /* RFC 1712 */ + +#ifndef RDATA_GENERIC_GPOS_27_C +#define RDATA_GENERIC_GPOS_27_C + +static inline isc_result_t +fromtext_gpos(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; + int i; + + REQUIRE(type == 27); + + rdclass = rdclass; /*unused*/ + origin = origin; /*unused*/ + downcase = downcase; /*unused*/ + + for (i = 0; i < 3 ; i++) { + RETERR(gettoken(lexer, &token, isc_tokentype_qstring, + ISC_FALSE)); + RETERR(txt_fromtext(&token.value.as_textregion, target)); + } + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +totext_gpos(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t region; + int i; + + REQUIRE(rdata->type == 27); + + tctx = tctx; /*unused*/ + + dns_rdata_toregion(rdata, ®ion); + + for (i = 0; i < 3 ; i++) { + RETERR(txt_totext(®ion, target)); + if (i != 2) + RETERR(str_totext(" ", target)); + } + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +fromwire_gpos(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_buffer_t *source, dns_decompress_t *dctx, + isc_boolean_t downcase, isc_buffer_t *target) +{ + int i; + + REQUIRE(type == 27); + + dctx = dctx; /*unused*/ + rdclass = rdclass; /*unused*/ + downcase = downcase; /*unused*/ + + for (i = 0 ; i < 3; i++) + RETERR(txt_fromwire(source, target)); + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +towire_gpos(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + + REQUIRE(rdata->type == 27); + + cctx = cctx; /*unused*/ + + return (mem_tobuffer(target, rdata->data, rdata->length)); +} + +static inline int +compare_gpos(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 == 27); + + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + return (compare_region(&r1, &r2)); +} + +static inline isc_result_t +fromstruct_gpos(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 27); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_gpos(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 27); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_gpos(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /* XXX */ +} + +static inline isc_result_t +additionaldata_gpos(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 27); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_gpos(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + + REQUIRE(rdata->type == 27); + + dns_rdata_toregion(rdata, &r); + + return ((digest)(arg, &r)); +} + +#endif /* RDATA_GENERIC_GPOS_27_C */ diff --git a/lib/dns/rdata/generic/gpos_27.h b/lib/dns/rdata/generic/gpos_27.h new file mode 100644 index 00000000..09871635 --- /dev/null +++ b/lib/dns/rdata/generic/gpos_27.h @@ -0,0 +1,21 @@ +/* + * 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: gpos_27.h,v 1.6 2000/02/03 23:42:59 halley Exp $ */ + + /* RFC 1712 */ + diff --git a/lib/dns/rdata/generic/hinfo_13.c b/lib/dns/rdata/generic/hinfo_13.c new file mode 100644 index 00000000..37788a69 --- /dev/null +++ b/lib/dns/rdata/generic/hinfo_13.c @@ -0,0 +1,156 @@ +/* + * 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: hinfo_13.c,v 1.19 2000/02/03 23:42:59 halley Exp $ */ + +#ifndef RDATA_GENERIC_HINFO_13_C +#define RDATA_GENERIC_HINFO_13_C + +static inline isc_result_t +fromtext_hinfo(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; + int i; + + REQUIRE(type == 13); + + rdclass = rdclass; /*unused*/ + origin = origin; /*unused*/ + downcase = downcase; /*unused*/ + + for (i = 0; i < 2 ; i++) { + RETERR(gettoken(lexer, &token, isc_tokentype_qstring, + ISC_FALSE)); + RETERR(txt_fromtext(&token.value.as_textregion, target)); + } + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +totext_hinfo(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t region; + + REQUIRE(rdata->type == 13); + + tctx = tctx; /*unused*/ + + dns_rdata_toregion(rdata, ®ion); + RETERR(txt_totext(®ion, target)); + RETERR(str_totext(" ", target)); + return (txt_totext(®ion, target)); +} + +static inline isc_result_t +fromwire_hinfo(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_buffer_t *source, dns_decompress_t *dctx, + isc_boolean_t downcase, isc_buffer_t *target) +{ + + REQUIRE(type == 13); + + dctx = dctx; /* unused */ + rdclass = rdclass; /* unused */ + downcase = downcase; /* unused */ + + RETERR(txt_fromwire(source, target)); + return (txt_fromwire(source, target)); +} + +static inline isc_result_t +towire_hinfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + + REQUIRE(rdata->type == 13); + + cctx = cctx; /*unused*/ + + return (mem_tobuffer(target, rdata->data, rdata->length)); +} + +static inline int +compare_hinfo(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 == 13); + + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + return (compare_region(&r1, &r2)); +} + +static inline isc_result_t +fromstruct_hinfo(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 13); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_hinfo(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 13); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_hinfo(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /* XXX */ +} + +static inline isc_result_t +additionaldata_hinfo(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 13); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_hinfo(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + + REQUIRE(rdata->type == 13); + + dns_rdata_toregion(rdata, &r); + + return ((digest)(arg, &r)); +} + +#endif /* RDATA_GENERIC_HINFO_13_C */ diff --git a/lib/dns/rdata/generic/hinfo_13.h b/lib/dns/rdata/generic/hinfo_13.h new file mode 100644 index 00000000..fecb2173 --- /dev/null +++ b/lib/dns/rdata/generic/hinfo_13.h @@ -0,0 +1,19 @@ +/* + * 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: hinfo_13.h,v 1.14 2000/02/03 23:42:59 halley Exp $ */ + diff --git a/lib/dns/rdata/generic/isdn_20.c b/lib/dns/rdata/generic/isdn_20.c new file mode 100644 index 00000000..14d60b9c --- /dev/null +++ b/lib/dns/rdata/generic/isdn_20.c @@ -0,0 +1,167 @@ +/* + * 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: isdn_20.c,v 1.12 2000/02/03 23:42:59 halley Exp $ */ + + /* RFC 1183 */ + +#ifndef RDATA_GENERIC_ISDN_20_C +#define RDATA_GENERIC_ISDN_20_C + +static inline isc_result_t +fromtext_isdn(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; + + REQUIRE(type == 20); + + rdclass = rdclass; /*unused*/ + origin = origin; /*unused*/ + downcase = downcase; /*unused*/ + + /* ISDN-address */ + RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_FALSE)); + RETERR(txt_fromtext(&token.value.as_textregion, target)); + + /* sa: optional */ + RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_TRUE)); + if (token.type != isc_tokentype_string && + token.type != isc_tokentype_qstring) { + isc_lex_ungettoken(lexer, &token); + return (DNS_R_SUCCESS); + } + return (txt_fromtext(&token.value.as_textregion, target)); +} + +static inline isc_result_t +totext_isdn(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t region; + + REQUIRE(rdata->type == 20); + + tctx = tctx; /*unused*/ + + dns_rdata_toregion(rdata, ®ion); + RETERR(txt_totext(®ion, target)); + if (region.length == 0) + return (DNS_R_SUCCESS); + RETERR(str_totext(" ", target)); + return (txt_totext(®ion, target)); +} + +static inline isc_result_t +fromwire_isdn(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_buffer_t *source, dns_decompress_t *dctx, + isc_boolean_t downcase, isc_buffer_t *target) +{ + + REQUIRE(type == 20); + + dctx = dctx; /* unused */ + rdclass = rdclass; /* unused */ + downcase = downcase; /* unused */ + + RETERR(txt_fromwire(source, target)); + if (buffer_empty(source)) + return (DNS_R_SUCCESS); + return (txt_fromwire(source, target)); +} + +static inline isc_result_t +towire_isdn(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + + REQUIRE(rdata->type == 20); + + cctx = cctx; /*unused*/ + + return (mem_tobuffer(target, rdata->data, rdata->length)); +} + +static inline int +compare_isdn(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 == 20); + + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + return (compare_region(&r1, &r2)); +} + +static inline isc_result_t +fromstruct_isdn(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 20); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_isdn(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 20); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_isdn(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ +} + +static inline isc_result_t +additionaldata_isdn(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 20); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_isdn(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + + REQUIRE(rdata->type == 20); + + dns_rdata_toregion(rdata, &r); + + return ((digest)(arg, &r)); +} + +#endif /* RDATA_GENERIC_ISDN_20_C */ diff --git a/lib/dns/rdata/generic/isdn_20.h b/lib/dns/rdata/generic/isdn_20.h new file mode 100644 index 00000000..ce272801 --- /dev/null +++ b/lib/dns/rdata/generic/isdn_20.h @@ -0,0 +1,21 @@ +/* + * 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*/ + + /* RFC 1183 */ + diff --git a/lib/dns/rdata/generic/key_25.c b/lib/dns/rdata/generic/key_25.c new file mode 100644 index 00000000..99c0e70a --- /dev/null +++ b/lib/dns/rdata/generic/key_25.c @@ -0,0 +1,280 @@ +/* + * 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: key_25.c,v 1.16 2000/02/03 23:43:00 halley Exp $ */ + + /* RFC 2065 */ + +#ifndef RDATA_GENERIC_KEY_25_C +#define RDATA_GENERIC_KEY_25_C + +static inline isc_result_t +fromtext_key(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_secalg_t alg; + dns_secproto_t proto; + dns_keyflags_t flags; + + REQUIRE(type == 25); + + rdclass = rdclass; /*unused*/ + origin = origin; /*unused*/ + downcase = downcase; /*unused*/ + + /* flags */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + RETERR(dns_keyflags_fromtext(&flags, &token.value.as_textregion)); + RETERR(uint16_tobuffer(flags, target)); + + /* protocol */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + RETERR(dns_secproto_fromtext(&proto, &token.value.as_textregion)); + RETERR(mem_tobuffer(target, &proto, 1)); + + /* algorithm */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + RETERR(dns_secalg_fromtext(&alg, &token.value.as_textregion)); + RETERR(mem_tobuffer(target, &alg, 1)); + + /* No Key? */ + if ((flags & 0xc000) == 0xc000) + return (DNS_R_SUCCESS); + + return (isc_base64_tobuffer(lexer, target, -1)); +} + +static inline isc_result_t +totext_key(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t sr; + char buf[sizeof "64000"]; + unsigned int flags; + + REQUIRE(rdata->type == 25); + + tctx = tctx; /*unused*/ + + dns_rdata_toregion(rdata, &sr); + + /* flags */ + flags = uint16_fromregion(&sr); + isc_region_consume(&sr, 2); + sprintf(buf, "%u", flags); + RETERR(str_totext(buf, target)); + RETERR(str_totext(" ", target)); + + /* protocol */ + sprintf(buf, "%u", sr.base[0]); + isc_region_consume(&sr, 1); + RETERR(str_totext(buf, target)); + RETERR(str_totext(" ", target)); + + /* algorithm */ + sprintf(buf, "%u", sr.base[0]); + isc_region_consume(&sr, 1); + RETERR(str_totext(buf, target)); + + /* No Key? */ + if ((flags & 0xc000) == 0xc00) + return (DNS_R_SUCCESS); + + /* key */ + if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) + RETERR(str_totext(" (", target)); + RETERR(str_totext(tctx->linebreak, target)); + RETERR(isc_base64_totext(&sr, tctx->width - 2, + tctx->linebreak, target)); + if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) + RETERR(str_totext(" )", target)); + + return DNS_R_SUCCESS; +} + +static inline isc_result_t +fromwire_key(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; + + REQUIRE(type == 25); + + rdclass = rdclass; /*unused*/ + dctx = dctx; /*unused*/ + downcase = downcase; /*unused*/ + + isc_buffer_active(source, &sr); + if (sr.length < 4) + return (DNS_R_UNEXPECTEDEND); + + isc_buffer_forward(source, sr.length); + return (mem_tobuffer(target, sr.base, sr.length)); +} + +static inline isc_result_t +towire_key(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + isc_region_t sr; + + REQUIRE(rdata->type == 25); + + cctx = cctx; /*unused*/ + + dns_rdata_toregion(rdata, &sr); + return (mem_tobuffer(target, sr.base, sr.length)); +} + +static inline int +compare_key(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 == 25); + + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + return (compare_region(&r1, &r2)); +} + +static inline isc_result_t +fromstruct_key(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + dns_rdata_generic_key_t *key; + isc_region_t tr; + + REQUIRE(type == 25); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + key = (dns_rdata_generic_key_t *) source; + REQUIRE(key->mctx != NULL); + + /* Flags */ + RETERR(uint16_tobuffer(key->flags, target)); + + /* Protocol */ + RETERR(uint8_tobuffer(key->protocol, target)); + + /* Algorithm */ + RETERR(uint8_tobuffer(key->algorithm, target)); + + /* Data */ + if (key->datalen > 0) { + isc_buffer_available(target, &tr); + if (tr.length < key->datalen) + return (DNS_R_NOSPACE); + memcpy(tr.base, key->data, key->datalen); + isc_buffer_add(target, key->datalen); + } + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +tostruct_key(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + dns_rdata_generic_key_t *key; + isc_region_t sr; + + REQUIRE(rdata->type == 25); + + target = target; + mctx = mctx; + + key = (dns_rdata_generic_key_t *) target; + key->common.rdclass = rdata->rdclass; + key->common.rdtype = rdata->type; + ISC_LINK_INIT(&key->common, link); + key->mctx = mctx; + dns_rdata_toregion(rdata, &sr); + + /* Flags */ + if (sr.length < 2) + return (ISC_R_UNEXPECTEDEND); + key->flags = uint16_fromregion(&sr); + isc_region_consume(&sr, 2); + + /* Protocol */ + if (sr.length < 1) + return (ISC_R_UNEXPECTEDEND); + key->flags = uint8_fromregion(&sr); + isc_region_consume(&sr, 1); + + /* Algorithm */ + if (sr.length < 1) + return (ISC_R_UNEXPECTEDEND); + key->flags = uint8_fromregion(&sr); + isc_region_consume(&sr, 1); + + /* Data */ + key->datalen = sr.length; + if (key->datalen > 0) { + key->data = isc_mem_get(mctx, key->datalen); + if (key->data == NULL) + return (DNS_R_NOMEMORY); + memcpy(key->data, sr.base, key->datalen); + isc_region_consume(&sr, key->datalen); + } + else + key->data = NULL; + + return (DNS_R_SUCCESS); +} + +static inline void +freestruct_key(void *source) { + dns_rdata_generic_key_t *key = (dns_rdata_generic_key_t *) source; + + REQUIRE(source != NULL); + REQUIRE(key->common.rdtype == 25); + + if (key->datalen > 0) + isc_mem_put(key->mctx, key->data, key->datalen); +} + +static inline isc_result_t +additionaldata_key(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 25); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_key(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + + REQUIRE(rdata->type == 25); + + dns_rdata_toregion(rdata, &r); + + return ((digest)(arg, &r)); +} + +#endif /* RDATA_GENERIC_KEY_25_C */ diff --git a/lib/dns/rdata/generic/key_25.h b/lib/dns/rdata/generic/key_25.h new file mode 100644 index 00000000..f127a64e --- /dev/null +++ b/lib/dns/rdata/generic/key_25.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: key_25.h,v 1.8 2000/02/03 23:43:00 halley Exp $ */ + + /* RFC 2535 */ + +typedef struct dns_rdata_generic_key_t { + dns_rdatacommon_t common; + isc_mem_t * mctx; + isc_uint16_t flags; + isc_uint8_t protocol; + isc_uint8_t algorithm; + isc_uint16_t datalen; + unsigned char * data; +} dns_rdata_generic_key_t; + diff --git a/lib/dns/rdata/generic/loc_29.c b/lib/dns/rdata/generic/loc_29.c new file mode 100644 index 00000000..ace48ecb --- /dev/null +++ b/lib/dns/rdata/generic/loc_29.c @@ -0,0 +1,620 @@ +/* + * 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: loc_29.c,v 1.11 2000/02/03 23:43:00 halley Exp $ */ + + /* RFC 1876 */ + +#ifndef RDATA_GENERIC_LOC_29_C +#define RDATA_GENERIC_LOC_29_C + +static inline isc_result_t +fromtext_loc(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; + int d1, m1, s1; + int d2, m2, s2; + unsigned char size; + unsigned char hp; + unsigned char vp; + unsigned char version; + isc_boolean_t east = ISC_FALSE; + isc_boolean_t north = ISC_FALSE; + long tmp; + long m; + long cm; + long poweroften[8] = { 1, 10, 100, 1000, + 10000, 100000, 1000000, 10000000 }; + int man; + int exp; + char *e; + int i; + unsigned long latitude; + unsigned long longitude; + unsigned long altitude; + + REQUIRE(type == 29); + + rdclass = rdclass; /*unused*/ + origin = origin; /*unused*/ + downcase = downcase; /*unused*/ + + /* defaults */ + m1 = s1 = 0; + m2 = s2 = 0; + size = 0x12; /* 1.00m */ + hp = 0x16; /* 10000.00 m */ + vp = 0x13; /* 10.00 m */ + version = 0; + + /* degree */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + if (token.value.as_ulong > 90) + return (DNS_R_RANGE); + d1 = token.value.as_ulong; + /* minute */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + if (strcasecmp(token.value.as_pointer, "N") == 0) + north = ISC_TRUE; + if (north || strcasecmp(token.value.as_pointer, "S") == 0) + goto getlong; + m1 = strtol(token.value.as_pointer, &e, 10); + if (*e != 0) + return (DNS_R_SYNTAX); + if (m1 < 0 || m1 > 59) + return (DNS_R_RANGE); + if (d1 == 90 && m1 != 0) + return (DNS_R_RANGE); + + /* second */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + if (strcasecmp(token.value.as_pointer, "N") == 0) + north = ISC_TRUE; + if (north || strcasecmp(token.value.as_pointer, "S") == 0) + goto getlong; + s1 = strtol(token.value.as_pointer, &e, 10); + if (*e != 0 && *e != '.') + return (DNS_R_SYNTAX); + if (s1 < 0 || s1 > 59) + return (DNS_R_RANGE); + if (*e == '.') { + e++; + for (i = 0; i < 3 ; i++) { + if (*e == 0) + break; + if ((tmp = decvalue(*e++)) < 0) + return (DNS_R_SYNTAX); + s1 *= 10; + s1 += tmp; + } + for ( ; i < 3 ; i++) + s1 *= 10; + if (*e != 0) + return (DNS_R_SYNTAX); + } else + s1 *= 1000; + if (d1 == 90 && s1 != 0) + return (DNS_R_RANGE); + + /* direction */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + if (strcasecmp(token.value.as_pointer, "N") == 0) + north = ISC_TRUE; + if (!north && strcasecmp(token.value.as_pointer, "S") != 0) + return (DNS_R_SYNTAX); + + getlong: + /* degree */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + if (token.value.as_ulong > 180) + return (DNS_R_RANGE); + d2 = token.value.as_ulong; + + /* minute */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + if (strcasecmp(token.value.as_pointer, "E") == 0) + east = ISC_TRUE; + if (east || strcasecmp(token.value.as_pointer, "W") == 0) + goto getalt; + m2 = strtol(token.value.as_pointer, &e, 10); + if (*e != 0) + return (DNS_R_SYNTAX); + if (m2 < 0 || m2 > 59) + return (DNS_R_RANGE); + if (d2 == 180 && m2 != 0) + return (DNS_R_RANGE); + + /* second */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + if (strcasecmp(token.value.as_pointer, "E") == 0) + east = ISC_TRUE; + if (east || strcasecmp(token.value.as_pointer, "W") == 0) + goto getalt; + s2 = strtol(token.value.as_pointer, &e, 10); + if (*e != 0 && *e != '.') + return (DNS_R_SYNTAX); + if (s2 < 0 || s2 > 59) + return (DNS_R_RANGE); + if (*e == '.') { + e++; + for (i = 0; i < 3 ; i++) { + if (*e == 0) + break; + if ((tmp = decvalue(*e++)) < 0) + return (DNS_R_SYNTAX); + s2 *= 10; + s2 += tmp; + } + for ( ; i < 3 ; i++) + s2 *= 10; + if (*e != 0) + return (DNS_R_SYNTAX); + } else + s2 *= 1000; + if (d2 == 180 && s2 != 0) + return (DNS_R_RANGE); + + /* direction */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + if (strcasecmp(token.value.as_pointer, "E") == 0) + east = ISC_TRUE; + if (!east && strcasecmp(token.value.as_pointer, "W") != 0) + return (DNS_R_SYNTAX); + + getalt: + /* alt */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + m = strtol(token.value.as_pointer, &e, 10); + if (*e != 0 && *e != '.' && *e != 'm') + return (DNS_R_SYNTAX); + if (m < -100000 || m > 42849672) + return (DNS_R_RANGE); + cm = 0; + if (*e == '.') { + e++; + for (i = 0; i < 2 ; i++) { + if (*e == 0 || *e == 'm') + break; + if ((tmp = decvalue(*e++)) < 0) + return (DNS_R_SYNTAX); + cm *= 10; + if (m < 0) + cm -= tmp; + else + cm += tmp; + } + for ( ; i < 2 ; i++) + cm *= 10; + } + if (*e == 'm') + e++; + if (*e != 0) + return (DNS_R_SYNTAX); + if (m == -100000 && cm != 0) + return (DNS_R_RANGE); + if (m == 42849672 && cm > 95) + return (DNS_R_RANGE); + /* adjust base */ + altitude = m + 100000; + altitude *= 100; + altitude += cm; + + /* size: optional */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_TRUE)); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) { + isc_lex_ungettoken(lexer, &token); + goto encode; + } + m = strtol(token.value.as_pointer, &e, 10); + if (*e != 0 && *e != '.' && *e != 'm') + return (DNS_R_SYNTAX); + if (m < 0 || m > 90000000) + return (DNS_R_RANGE); + cm = 0; + if (*e == '.') { + e++; + for (i = 0; i < 2 ; i++) { + if (*e == 0 || *e == 'm') + break; + if ((tmp = decvalue(*e++)) < 0) + return (DNS_R_SYNTAX); + cm *= 10; + cm += tmp; + } + for ( ; i < 2 ; i++) + cm *= 10; + } + if (*e == 'm') + e++; + if (*e != 0) + return (DNS_R_SYNTAX); + /* we don't just multiply out as we will overflow */ + if (m > 0) { + for (exp = 0 ; exp < 7 ; exp++) + if (m < poweroften[exp+1]) + break; + man = m / poweroften[exp]; + exp += 2; + } else { + if (cm > 10) { + man = cm / 10; + exp = 1; + } else { + man = cm; + exp = 0; + } + } + size = (man << 4) + exp; + + /* hp: optional */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_TRUE)); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) { + isc_lex_ungettoken(lexer, &token); + goto encode; + } + m = strtol(token.value.as_pointer, &e, 10); + if (*e != 0 && *e != '.' && *e != 'm') + return (DNS_R_SYNTAX); + if (m < 0 || m > 90000000) + return (DNS_R_RANGE); + cm = 0; + if (*e == '.') { + e++; + for (i = 0; i < 2 ; i++) { + if (*e == 0 || *e == 'm') + break; + if ((tmp = decvalue(*e++)) < 0) + return (DNS_R_SYNTAX); + cm *= 10; + cm += tmp; + } + for ( ; i < 2 ; i++) + cm *= 10; + } + if (*e == 'm') + e++; + if (*e != 0) + return (DNS_R_SYNTAX); + /* we don't just multiply out as we will overflow */ + if (m > 0) { + for (exp = 0 ; exp < 7 ; exp++) + if (m < poweroften[exp+1]) + break; + man = m / poweroften[exp]; + exp += 2; + } else if (cm > 10) { + man = cm / 10; + exp = 1; + } else { + man = cm; + exp = 0; + } + hp = (man << 4) + exp; + + /* vp: optional */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_TRUE)); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) { + isc_lex_ungettoken(lexer, &token); + goto encode; + } + m = strtol(token.value.as_pointer, &e, 10); + if (*e != 0 && *e != '.' && *e != 'm') + return (DNS_R_SYNTAX); + if (m < 0 || m > 90000000) + return (DNS_R_RANGE); + cm = 0; + if (*e == '.') { + e++; + for (i = 0; i < 2 ; i++) { + if (*e == 0 || *e == 'm') + break; + if ((tmp = decvalue(*e++)) < 0) + return (DNS_R_SYNTAX); + cm *= 10; + cm += tmp; + } + for ( ; i < 2 ; i++) + cm *= 10; + } + if (*e == 'm') + e++; + if (*e != 0) + return (DNS_R_SYNTAX); + /* we don't just multiply out as we will overflow */ + if (m > 0) { + for (exp = 0 ; exp < 7 ; exp++) + if (m < poweroften[exp+1]) + break; + man = m / poweroften[exp]; + exp += 2; + } else if (cm > 10) { + man = cm / 10; + exp = 1; + } else { + man = cm; + exp = 0; + } + vp = (man << 4) + exp; + + encode: + RETERR(mem_tobuffer(target, &version, 1)); + RETERR(mem_tobuffer(target, &size, 1)); + RETERR(mem_tobuffer(target, &hp, 1)); + RETERR(mem_tobuffer(target, &vp, 1)); + if (north) + latitude = 0x80000000 + ( d1 * 3600 + m1 * 60 ) * 1000 + s1; + else + latitude = 0x80000000 - ( d1 * 3600 + m1 * 60 ) * 1000 - s1; + RETERR(uint32_tobuffer(latitude, target)); + + if (east) + longitude = 0x80000000 + ( d2 * 3600 + m2 * 60 ) * 1000 + s2; + else + longitude = 0x80000000 - ( d2 * 3600 + m2 * 60 ) * 1000 - s2; + RETERR(uint32_tobuffer(longitude, target)); + + return (uint32_tobuffer(altitude, target)); +} + +static inline isc_result_t +totext_loc(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + int d1, m1, s1, fs1; + int d2, m2, s2, fs2; + unsigned long latitude; + unsigned long longitude; + unsigned long altitude; + isc_boolean_t north; + isc_boolean_t east; + isc_boolean_t below; + isc_region_t sr; + char buf[sizeof + "89 59 59.999 N 179 59 59.999 E 42849672.95m 90000000m 90000000m 90000000m"]; + char sbuf[sizeof "90000000m"]; + char hbuf[sizeof "90000000m"]; + char vbuf[sizeof "90000000m"]; + unsigned char size, hp, vp; + unsigned long poweroften[8] = { 1, 10, 100, 1000, + 10000, 100000, 1000000, 10000000 }; + + REQUIRE(rdata->type == 29); + + tctx = tctx; /*unused*/ + + dns_rdata_toregion(rdata, &sr); + + /* version = sr.base[0]; */ + size = sr.base[1]; + if ((size&0x0f)> 1) + sprintf(sbuf, "%lum", (size>>4) * poweroften[(size&0x0f)-2]); + else + sprintf(sbuf, "0.%02lum", (size>>4) * poweroften[(size&0x0f)]); + hp = sr.base[2]; + if ((hp&0x0f)> 1) + sprintf(hbuf, "%lum", (hp>>4) * poweroften[(hp&0x0f)-2]); + else + sprintf(hbuf, "0.%02lum", (hp>>4) * poweroften[(hp&0x0f)]); + vp = sr.base[3]; + if ((vp&0x0f)> 1) + sprintf(vbuf, "%lum", (vp>>4) * poweroften[(vp&0x0f)-2]); + else + sprintf(vbuf, "0.%02lum", (vp>>4) * poweroften[(vp&0x0f)]); + isc_region_consume(&sr, 4); + + latitude = uint32_fromregion(&sr); + isc_region_consume(&sr, 4); + if (latitude >= 0x80000000) { + north = ISC_TRUE; + latitude -= 0x80000000; + } else { + north = ISC_FALSE; + latitude = 0x80000000 - latitude; + } + fs1 = latitude % 1000; + latitude /= 1000; + s1 = latitude % 60; + latitude /= 60; + m1 = latitude % 60; + latitude /= 60; + d1 = latitude; + + longitude = uint32_fromregion(&sr); + isc_region_consume(&sr, 4); + if (longitude >= 0x80000000) { + east = ISC_TRUE; + longitude -= 0x80000000; + } else { + east = ISC_FALSE; + longitude = 0x80000000 - longitude; + } + fs2 = longitude % 1000; + longitude /= 1000; + s2 = longitude % 60; + longitude /= 60; + m2 = longitude % 60; + longitude /= 60; + d2 = longitude; + + altitude = uint32_fromregion(&sr); + isc_region_consume(&sr, 4); + if (altitude < 10000000) { + below = ISC_TRUE; + altitude = 10000000 - altitude; + } else { + below =ISC_FALSE; + altitude -= 10000000; + } + + sprintf(buf, "%d %d %d.%03d %s %d %d %d.%03d %s %s%ld.%02ldm %s %s %s", + d1, m1, s1, fs1, north ? "N" : "S", + d2, m2, s2, fs2, east ? "E" : "W", + below ? "-" : "", altitude/100, altitude % 100, + sbuf, hbuf, vbuf); + + return (str_totext(buf, target)); +} + +static inline isc_result_t +fromwire_loc(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 c; + unsigned long latitude; + unsigned long longitude; + + REQUIRE(type == 29); + + rdclass = rdclass; /*unused*/ + dctx = dctx; /*unused*/ + downcase = downcase; /*unused*/ + + isc_buffer_active(source, &sr); + if (sr.length < 1) + return (DNS_R_UNEXPECTEDEND); + if (sr.base[0] != 0) + return (DNS_R_NOTIMPLEMENTED); + if (sr.length < 16) + return (DNS_R_UNEXPECTEDEND); + + /* size */ + c = sr.base[1]; + if (c != 0) + if ((c&0xf) > 9 || ((c>>4)&0xf) > 9 || ((c>>4)&0xf) == 0) + return (DNS_R_RANGE); + + /* horiz pre */ + c = sr.base[2]; + if (c != 0) + if ((c&0xf) > 9 || ((c>>4)&0xf) > 9 || ((c>>4)&0xf) == 0) + return (DNS_R_RANGE); + + /* vert pre */ + c = sr.base[3]; + if (c != 0) + if ((c&0xf) > 9 || ((c>>4)&0xf) > 9 || ((c>>4)&0xf) == 0) + return (DNS_R_RANGE); + isc_region_consume(&sr, 4); + + /* latitude */ + latitude = uint32_fromregion(&sr); + if (latitude < (0x80000000UL - 90 * 3600000) || + latitude > (0x80000000UL + 90 * 3600000)) + return (DNS_R_RANGE); + isc_region_consume(&sr, 4); + + /* longitude */ + longitude = uint32_fromregion(&sr); + if (longitude < (0x80000000UL - 180 * 3600000) || + longitude > (0x80000000UL + 180 * 3600000)) + return (DNS_R_RANGE); + + /* altitiude */ + /* all values possible */ + + isc_buffer_active(source, &sr); + isc_buffer_forward(source, 16); + return (mem_tobuffer(target, sr.base, 16)); +} + +static inline isc_result_t +towire_loc(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + + REQUIRE(rdata->type == 29); + + cctx = cctx; /*unused*/ + + return(mem_tobuffer(target, rdata->data, rdata->length)); +} + +static inline int +compare_loc(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 == 29); + + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + return (compare_region(&r1, &r2)); +} + +static inline isc_result_t +fromstruct_loc(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 29); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_loc(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 29); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_loc(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ +} + +static inline isc_result_t +additionaldata_loc(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 29); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_loc(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + + REQUIRE(rdata->type == 29); + + dns_rdata_toregion(rdata, &r); + + return ((digest)(arg, &r)); +} + +#endif /* RDATA_GENERIC_LOC_29_C */ diff --git a/lib/dns/rdata/generic/loc_29.h b/lib/dns/rdata/generic/loc_29.h new file mode 100644 index 00000000..1e32989e --- /dev/null +++ b/lib/dns/rdata/generic/loc_29.h @@ -0,0 +1,21 @@ +/* + * 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: loc_29.h,v 1.6 2000/02/03 23:43:00 halley Exp $ */ + + /* RFC 1876 */ + diff --git a/lib/dns/rdata/generic/mb_7.c b/lib/dns/rdata/generic/mb_7.c new file mode 100644 index 00000000..e9f6e4d5 --- /dev/null +++ b/lib/dns/rdata/generic/mb_7.c @@ -0,0 +1,191 @@ +/* + * 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: mb_7.c,v 1.20 2000/02/03 23:43:01 halley Exp $ */ + +#ifndef RDATA_GENERIC_MB_7_C +#define RDATA_GENERIC_MB_7_C + +static inline isc_result_t +fromtext_mb(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 == 7); + + rdclass = rdclass; /*unused*/ + + 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_mb(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 == 7); + + 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_mb(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 == 7); + + rdclass = rdclass; /*unused*/ + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); + + dns_name_init(&name, NULL); + return (dns_name_fromwire(&name, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_mb(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 7); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); + + 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_mb(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 == 7); + + 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_mb(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 7); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_mb(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 7); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_mb(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ +} + +static inline isc_result_t +additionaldata_mb(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 7); + + dns_name_init(&name, NULL); + dns_rdata_toregion(rdata, ®ion); + dns_name_fromregion(&name, ®ion); + + return ((add)(arg, &name, dns_rdatatype_a)); +} + +static inline isc_result_t +digest_mb(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + dns_name_t name; + + REQUIRE(rdata->type == 7); + + dns_rdata_toregion(rdata, &r); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r); + + return (dns_name_digest(&name, digest, arg)); +} + +#endif /* RDATA_GENERIC_MB_7_C */ diff --git a/lib/dns/rdata/generic/mb_7.h b/lib/dns/rdata/generic/mb_7.h new file mode 100644 index 00000000..f3191b3f --- /dev/null +++ b/lib/dns/rdata/generic/mb_7.h @@ -0,0 +1,19 @@ +/* + * 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: mb_7.h,v 1.14 2000/02/03 23:43:01 halley Exp $ */ + diff --git a/lib/dns/rdata/generic/md_3.c b/lib/dns/rdata/generic/md_3.c new file mode 100644 index 00000000..80c968f4 --- /dev/null +++ b/lib/dns/rdata/generic/md_3.c @@ -0,0 +1,191 @@ +/* + * 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: md_3.c,v 1.21 2000/02/03 23:43:01 halley Exp $ */ + +#ifndef RDATA_GENERIC_MD_3_C +#define RDATA_GENERIC_MD_3_C + +static inline isc_result_t +fromtext_md(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 == 3); + + rdclass = rdclass; /*unused*/ + + 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_md(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 == 3); + + 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_md(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 == 3); + + rdclass = rdclass; /*unused*/ + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); + + dns_name_init(&name, NULL); + return (dns_name_fromwire(&name, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_md(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 3); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); + + 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_md(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 == 3); + + 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_md(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 3); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_md(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 3); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_md(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ +} + +static inline isc_result_t +additionaldata_md(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 3); + + dns_name_init(&name, NULL); + dns_rdata_toregion(rdata, ®ion); + dns_name_fromregion(&name, ®ion); + + return ((add)(arg, &name, dns_rdatatype_a)); +} + +static inline isc_result_t +digest_md(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + dns_name_t name; + + REQUIRE(rdata->type == 3); + + dns_rdata_toregion(rdata, &r); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r); + + return (dns_name_digest(&name, digest, arg)); +} + +#endif /* RDATA_GENERIC_MD_3_C */ diff --git a/lib/dns/rdata/generic/md_3.h b/lib/dns/rdata/generic/md_3.h new file mode 100644 index 00000000..f34cf1b6 --- /dev/null +++ b/lib/dns/rdata/generic/md_3.h @@ -0,0 +1,19 @@ +/* + * 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: md_3.h,v 1.15 2000/02/03 23:43:01 halley Exp $ */ + diff --git a/lib/dns/rdata/generic/mf_4.c b/lib/dns/rdata/generic/mf_4.c new file mode 100644 index 00000000..f1614b09 --- /dev/null +++ b/lib/dns/rdata/generic/mf_4.c @@ -0,0 +1,191 @@ +/* + * 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: mf_4.c,v 1.19 2000/02/03 23:43:01 halley Exp $ */ + +#ifndef RDATA_GENERIC_MF_4_C +#define RDATA_GENERIC_MF_4_C + +static inline isc_result_t +fromtext_mf(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 == 4); + + rdclass = rdclass; /*unused*/ + + 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_mf(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 == 4); + + 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_mf(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 == 4); + + rdclass = rdclass; /*unused*/ + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); + + dns_name_init(&name, NULL); + return (dns_name_fromwire(&name, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_mf(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 4); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); + + 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_mf(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 == 4); + + 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_mf(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 4); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_mf(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 4); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_mf(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ +} + +static inline isc_result_t +additionaldata_mf(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 4); + + dns_name_init(&name, NULL); + dns_rdata_toregion(rdata, ®ion); + dns_name_fromregion(&name, ®ion); + + return ((add)(arg, &name, dns_rdatatype_a)); +} + +static inline isc_result_t +digest_mf(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + dns_name_t name; + + REQUIRE(rdata->type == 4); + + dns_rdata_toregion(rdata, &r); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r); + + return (dns_name_digest(&name, digest, arg)); +} + +#endif /* RDATA_GENERIC_MF_4_C */ diff --git a/lib/dns/rdata/generic/mf_4.h b/lib/dns/rdata/generic/mf_4.h new file mode 100644 index 00000000..1fd5ca4d --- /dev/null +++ b/lib/dns/rdata/generic/mf_4.h @@ -0,0 +1,19 @@ +/* + * 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: mf_4.h,v 1.13 2000/02/03 23:43:02 halley Exp $ */ + diff --git a/lib/dns/rdata/generic/mg_8.c b/lib/dns/rdata/generic/mg_8.c new file mode 100644 index 00000000..c1cb4edc --- /dev/null +++ b/lib/dns/rdata/generic/mg_8.c @@ -0,0 +1,187 @@ +/* + * 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: mg_8.c,v 1.18 2000/02/03 23:43:02 halley Exp $ */ + +#ifndef RDATA_GENERIC_MG_8_C +#define RDATA_GENERIC_MG_8_C + +static inline isc_result_t +fromtext_mg(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 == 8); + + rdclass = rdclass; /*unused*/ + + 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_mg(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 == 8); + + 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_mg(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 == 8); + + rdclass = rdclass; /*unused*/ + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); + + dns_name_init(&name, NULL); + return (dns_name_fromwire(&name, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_mg(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 8); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); + + 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_mg(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 == 8); + + 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_mg(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 8); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_mg(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 8); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_mg(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ +} + +static inline isc_result_t +additionaldata_mg(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 8); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_mg(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + dns_name_t name; + + REQUIRE(rdata->type == 8); + + dns_rdata_toregion(rdata, &r); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r); + + return (dns_name_digest(&name, digest, arg)); +} + +#endif /* RDATA_GENERIC_MG_8_C */ diff --git a/lib/dns/rdata/generic/mg_8.h b/lib/dns/rdata/generic/mg_8.h new file mode 100644 index 00000000..6f81265b --- /dev/null +++ b/lib/dns/rdata/generic/mg_8.h @@ -0,0 +1,19 @@ +/* + * 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: mg_8.h,v 1.13 2000/02/03 23:43:02 halley Exp $ */ + diff --git a/lib/dns/rdata/generic/minfo_14.c b/lib/dns/rdata/generic/minfo_14.c new file mode 100644 index 00000000..1ce75207 --- /dev/null +++ b/lib/dns/rdata/generic/minfo_14.c @@ -0,0 +1,240 @@ +/* + * 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: minfo_14.c,v 1.19 2000/02/03 23:43:02 halley Exp $ */ + +#ifndef RDATA_GENERIC_MINFO_14_C +#define RDATA_GENERIC_MINFO_14_C + +static inline isc_result_t +fromtext_minfo(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; + int i; + + REQUIRE(type == 14); + + rdclass = rdclass; /*unused*/ + + for (i = 0; i < 2 ; i++) { + 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)); + } + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +totext_minfo(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t region; + dns_name_t rmail; + dns_name_t email; + dns_name_t prefix; + isc_boolean_t sub; + + REQUIRE(rdata->type == 14); + + dns_name_init(&rmail, NULL); + dns_name_init(&email, NULL); + dns_name_init(&prefix, NULL); + + dns_rdata_toregion(rdata, ®ion); + + dns_name_fromregion(&rmail, ®ion); + isc_region_consume(®ion, rmail.length); + + dns_name_fromregion(&email, ®ion); + isc_region_consume(®ion, email.length); + + sub = name_prefix(&rmail, tctx->origin, &prefix); + + RETERR(dns_name_totext(&prefix, sub, target)); + + RETERR(str_totext(" ", target)); + + sub = name_prefix(&email, tctx->origin, &prefix); + return (dns_name_totext(&prefix, sub, target)); +} + +static inline isc_result_t +fromwire_minfo(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 rmail; + dns_name_t email; + + REQUIRE(type == 14); + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); + + rdclass = rdclass; /*unused*/ + + dns_name_init(&rmail, NULL); + dns_name_init(&email, NULL); + + RETERR(dns_name_fromwire(&rmail, source, dctx, downcase, target)); + return (dns_name_fromwire(&email, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_minfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + isc_region_t region; + dns_name_t rmail; + dns_name_t email; + + REQUIRE(rdata->type == 14); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); + + dns_name_init(&rmail, NULL); + dns_name_init(&email, NULL); + + dns_rdata_toregion(rdata, ®ion); + + dns_name_fromregion(&rmail, ®ion); + isc_region_consume(®ion, name_length(&rmail)); + + RETERR(dns_name_towire(&rmail, cctx, target)); + + dns_name_fromregion(&rmail, ®ion); + isc_region_consume(®ion, rmail.length); + + return (dns_name_towire(&rmail, cctx, target)); +} + +static inline int +compare_minfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + isc_region_t region1; + isc_region_t region2; + dns_name_t name1; + dns_name_t name2; + int result; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 14); + + 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); + + 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_init(&name1, NULL); + dns_name_init(&name2, NULL); + + dns_name_fromregion(&name1, ®ion1); + dns_name_fromregion(&name2, ®ion2); + + result = dns_name_rdatacompare(&name1, &name2); + return (result); +} + +static inline isc_result_t +fromstruct_minfo(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 14); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_minfo(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 14); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_minfo(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ +} + +static inline isc_result_t +additionaldata_minfo(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 14); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_minfo(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + dns_name_t name; + isc_result_t result; + + REQUIRE(rdata->type == 14); + + dns_rdata_toregion(rdata, &r); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r); + result = dns_name_digest(&name, digest, arg); + if (result != DNS_R_SUCCESS) + return (result); + isc_region_consume(&r, name_length(&name)); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r); + + return (dns_name_digest(&name, digest, arg)); +} + +#endif /* RDATA_GENERIC_MINFO_14_C */ diff --git a/lib/dns/rdata/generic/minfo_14.h b/lib/dns/rdata/generic/minfo_14.h new file mode 100644 index 00000000..6c238a7e --- /dev/null +++ b/lib/dns/rdata/generic/minfo_14.h @@ -0,0 +1,19 @@ +/* + * 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: minfo_14.h,v 1.14 2000/02/03 23:43:02 halley Exp $ */ + diff --git a/lib/dns/rdata/generic/mr_9.c b/lib/dns/rdata/generic/mr_9.c new file mode 100644 index 00000000..dcfc0177 --- /dev/null +++ b/lib/dns/rdata/generic/mr_9.c @@ -0,0 +1,187 @@ +/* + * 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: mr_9.c,v 1.18 2000/02/03 23:43:03 halley Exp $ */ + +#ifndef RDATA_GENERIC_MR_9_C +#define RDATA_GENERIC_MR_9_C + +static inline isc_result_t +fromtext_mr(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 == 9); + + rdclass = rdclass; /*unused*/ + + 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_mr(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 == 9); + + 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_mr(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 == 9); + + rdclass = rdclass; /*unused*/ + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); + + dns_name_init(&name, NULL); + return (dns_name_fromwire(&name, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_mr(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 9); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); + + 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_mr(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 == 9); + + 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_mr(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 9); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_mr(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 9); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_mr(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ +} + +static inline isc_result_t +additionaldata_mr(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 9); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_mr(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + dns_name_t name; + + REQUIRE(rdata->type == 9); + + dns_rdata_toregion(rdata, &r); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r); + + return (dns_name_digest(&name, digest, arg)); +} + +#endif /* RDATA_GENERIC_MR_9_C */ diff --git a/lib/dns/rdata/generic/mr_9.h b/lib/dns/rdata/generic/mr_9.h new file mode 100644 index 00000000..c6850bf1 --- /dev/null +++ b/lib/dns/rdata/generic/mr_9.h @@ -0,0 +1,19 @@ +/* + * 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: mr_9.h,v 1.13 2000/02/03 23:43:03 halley Exp $ */ + diff --git a/lib/dns/rdata/generic/mx_15.c b/lib/dns/rdata/generic/mx_15.c new file mode 100644 index 00000000..60974e8e --- /dev/null +++ b/lib/dns/rdata/generic/mx_15.c @@ -0,0 +1,235 @@ +/* + * 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: mx_15.c,v 1.22 2000/02/03 23:43:03 halley Exp $ */ + +#ifndef RDATA_GENERIC_MX_15_C +#define RDATA_GENERIC_MX_15_C + +static inline isc_result_t +fromtext_mx(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 == 15); + + rdclass = rdclass; /*unused*/ + + 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_mx(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 == 15); + + 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_mx(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; + isc_region_t tregion; + + REQUIRE(type == 15); + + rdclass = rdclass; /* unused */ + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); + + dns_name_init(&name, NULL); + + isc_buffer_active(source, &sregion); + isc_buffer_available(target, &tregion); + if (tregion.length < 2) + return (DNS_R_NOSPACE); + if (sregion.length < 2) + return (DNS_R_UNEXPECTEDEND); + memcpy(tregion.base, sregion.base, 2); + isc_buffer_forward(source, 2); + isc_buffer_add(target, 2); + return (dns_name_fromwire(&name, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_mx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + dns_name_t name; + isc_region_t region; + isc_region_t tr; + + REQUIRE(rdata->type == 15); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); + + isc_buffer_available(target, &tr); + dns_rdata_toregion(rdata, ®ion); + if (tr.length < 2) + return (DNS_R_NOSPACE); + memcpy(tr.base, region.base, 2); + isc_region_consume(®ion, 2); + isc_buffer_add(target, 2); + + dns_name_init(&name, NULL); + dns_name_fromregion(&name, ®ion); + + return (dns_name_towire(&name, cctx, target)); +} + +static inline int +compare_mx(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 == 15); + + 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_mx(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 15); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_mx(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 15); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_mx(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ +} + +static inline isc_result_t +additionaldata_mx(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 15); + + 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_mx(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 == 15); + + 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_MX_15_C */ diff --git a/lib/dns/rdata/generic/mx_15.h b/lib/dns/rdata/generic/mx_15.h new file mode 100644 index 00000000..749f7518 --- /dev/null +++ b/lib/dns/rdata/generic/mx_15.h @@ -0,0 +1,19 @@ +/* + * 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: mx_15.h,v 1.16 2000/02/03 23:43:03 halley Exp $ */ + diff --git a/lib/dns/rdata/generic/ns_2.c b/lib/dns/rdata/generic/ns_2.c new file mode 100644 index 00000000..ebdaafb6 --- /dev/null +++ b/lib/dns/rdata/generic/ns_2.c @@ -0,0 +1,211 @@ +/* + * 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: ns_2.c,v 1.21 2000/02/03 23:43:03 halley Exp $ */ + +#ifndef RDATA_GENERIC_NS_2_C +#define RDATA_GENERIC_NS_2_C + +static inline isc_result_t +fromtext_ns(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 == 2); + + UNUSED(rdclass); + + 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_ns(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 == 2); + + 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_ns(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 == 2); + + UNUSED(rdclass); + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); + + dns_name_init(&name, NULL); + return (dns_name_fromwire(&name, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_ns(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 2); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); + + 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_ns(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 == 2); + + 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_ns(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 2); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_ns(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + isc_region_t region; + dns_rdata_ns_t *ns = target; + dns_name_t name; + isc_result_t result; + + REQUIRE(rdata->type == 2); + REQUIRE(target != NULL); + REQUIRE(mctx != NULL); + + ns->common.rdclass = rdata->rdclass; + ns->common.rdtype = rdata->type; + ISC_LINK_INIT(&ns->common, link); + + dns_name_init(&name, NULL); + dns_rdata_toregion(rdata, ®ion); + dns_name_fromregion(&name, ®ion); + ns->mctx = mctx; + dns_name_init(&ns->name, NULL); + result = dns_name_dup(&name, ns->mctx, &ns->name); + if (result != ISC_R_SUCCESS) + ns->mctx = NULL; + + return (result); +} + +static inline void +freestruct_ns(void *source) { + dns_rdata_ns_t *ns = source; + + REQUIRE(source != NULL); + + dns_name_free(&ns->name, ns->mctx); + ns->mctx = NULL; +} + +static inline isc_result_t +additionaldata_ns(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 2); + + dns_name_init(&name, NULL); + dns_rdata_toregion(rdata, ®ion); + dns_name_fromregion(&name, ®ion); + + return ((add)(arg, &name, dns_rdatatype_a)); +} + +static inline isc_result_t +digest_ns(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + dns_name_t name; + + REQUIRE(rdata->type == 2); + + dns_rdata_toregion(rdata, &r); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r); + + return (dns_name_digest(&name, digest, arg)); +} + +#endif /* RDATA_GENERIC_NS_2_C */ diff --git a/lib/dns/rdata/generic/ns_2.h b/lib/dns/rdata/generic/ns_2.h new file mode 100644 index 00000000..f4c07781 --- /dev/null +++ b/lib/dns/rdata/generic/ns_2.h @@ -0,0 +1,27 @@ +/* + * 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: ns_2.h,v 1.15 2000/02/03 23:43:04 halley Exp $ */ + +#include <dns/fixedname.h> + +typedef struct dns_rdata_ns { + dns_rdatacommon_t common; + isc_mem_t *mctx; + dns_name_t name; +} dns_rdata_ns_t; + diff --git a/lib/dns/rdata/generic/null_10.c b/lib/dns/rdata/generic/null_10.c new file mode 100644 index 00000000..f03ddb3a --- /dev/null +++ b/lib/dns/rdata/generic/null_10.c @@ -0,0 +1,154 @@ +/* + * 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: null_10.c,v 1.16 2000/02/03 23:43:04 halley Exp $ */ + +#ifndef RDATA_GENERIC_NULL_10_C +#define RDATA_GENERIC_NULL_10_C + +static inline isc_result_t +fromtext_null(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_lex_t *lexer, dns_name_t *origin, + isc_boolean_t downcase, isc_buffer_t *target) +{ + + REQUIRE(type == 10); + + rdclass = rdclass; /*unused*/ + type = type; /*unused*/ + lexer = lexer; /*unused*/ + origin = origin; /*unused*/ + downcase = downcase; /*unused*/ + target = target; /*unused*/ + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +totext_null(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + + + REQUIRE(rdata->type == 10); + REQUIRE(rdata->length == 0); + + tctx = tctx; /*unused*/ + target = target; /*unused*/ + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +fromwire_null(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_buffer_t *source, dns_decompress_t *dctx, + isc_boolean_t downcase, isc_buffer_t *target) +{ + + REQUIRE(type == 10); + + rdclass = rdclass; /*unused*/ + dctx = dctx; /*unused*/ + downcase = downcase; /*unused*/ + target = target; /*unused*/ + source = source; /*unused*/ + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +towire_null(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + + REQUIRE(rdata->type == 10); + + cctx = cctx; /*unused*/ + target = target; /*unused*/ + + return (DNS_R_SUCCESS); +} + +static inline int +compare_null(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + + REQUIRE(rdata1->type == rdata1->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 10); + + return (0); +} + +static inline isc_result_t +fromstruct_null(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 10); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_null(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + dns_rdata_null_t *null = target; + + REQUIRE(rdata->type == 10); + REQUIRE(target != NULL); + + mctx = mctx; + + null->common.rdtype = rdata->type; + null->common.rdclass = rdata->rdclass; + ISC_LINK_INIT(&null->common, link); + + return (DNS_R_SUCCESS); +} + +static inline void +freestruct_null(void *source) { + REQUIRE(source != NULL); + /* No action required. */ +} + +static inline isc_result_t +additionaldata_null(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 10); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_null(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + + REQUIRE(rdata->type == 10); + + (void)digest; + (void)arg; + + return (DNS_R_SUCCESS); +} + +#endif /* RDATA_GENERIC_NULL_10_C */ diff --git a/lib/dns/rdata/generic/null_10.h b/lib/dns/rdata/generic/null_10.h new file mode 100644 index 00000000..4a4b1324 --- /dev/null +++ b/lib/dns/rdata/generic/null_10.h @@ -0,0 +1,22 @@ +/* + * 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: null_10.h,v 1.11 2000/02/03 23:43:04 halley Exp $ */ + +typedef struct dns_rdata_null { + dns_rdatacommon_t common; +} dns_rdata_null_t; diff --git a/lib/dns/rdata/generic/nxt_30.c b/lib/dns/rdata/generic/nxt_30.c new file mode 100644 index 00000000..3d5a01f1 --- /dev/null +++ b/lib/dns/rdata/generic/nxt_30.c @@ -0,0 +1,268 @@ +/* + * 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: nxt_30.c,v 1.20 2000/02/03 23:43:04 halley Exp $ */ + + /* RFC 2065 */ + +#ifndef RDATA_GENERIC_NXT_30_C +#define RDATA_GENERIC_NXT_30_C + +static inline isc_result_t +fromtext_nxt(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; + char *e; + unsigned char bm[8*1024]; /* 64k bits */ + dns_rdatatype_t covered; + dns_rdatatype_t maxcovered = 0; + isc_boolean_t first = ISC_TRUE; + long n; + + REQUIRE(type == 30); + + rdclass = rdclass; /*unused*/ + + /* next domain */ + 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)); + + memset(bm, 0, sizeof bm); + do { + RETERR(gettoken(lexer, &token, isc_tokentype_string, + ISC_TRUE)); + if (token.type != isc_tokentype_string) + break; + n = strtol(token.value.as_pointer, &e, 10); + if (e != token.value.as_pointer && *e == '\0') { + covered = (dns_rdatatype_t)n; + } else if (dns_rdatatype_fromtext(&covered, + &token.value.as_textregion) == DNS_R_UNKNOWN) + return (DNS_R_UNKNOWN); + /* + * NXT is only specified for types 1..127. + */ + if (covered < 1 || covered > 127) + return (DNS_R_RANGE); + if (first || covered > maxcovered) + maxcovered = covered; + first = ISC_FALSE; + bm[covered/8] |= (0x80>>(covered%8)); + } while (1); + isc_lex_ungettoken(lexer, &token); + if (first) + return (DNS_R_SUCCESS); + n = (maxcovered + 8) / 8; + return (mem_tobuffer(target, bm, n)); +} + +static inline isc_result_t +totext_nxt(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t sr; + char buf[sizeof "65535"]; + unsigned int i, j; + dns_name_t name; + dns_name_t prefix; + isc_result_t result; + isc_boolean_t sub; + + REQUIRE(rdata->type == 30); + + dns_name_init(&name, NULL); + dns_name_init(&prefix, NULL); + dns_rdata_toregion(rdata, &sr); + dns_name_fromregion(&name, &sr); + isc_region_consume(&sr, name_length(&name)); + sub = name_prefix(&name, tctx->origin, &prefix); + RETERR(dns_name_totext(&prefix, sub, target)); + + 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) { + result = dns_rdatatype_totext( + (dns_rdatatype_t)(i * 8 + j), + target); + if (result == DNS_R_SUCCESS) { + RETERR(str_totext(" ", + target)); + continue; + } + if (result != DNS_R_UNKNOWN) + return (result); + sprintf(buf, "%u", i * 8 + j); + RETERR(str_totext(" ", target)); + RETERR(str_totext(buf, target)); + } + } + return (str_totext(")", target)); +} + +static inline isc_result_t +fromwire_nxt(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; + dns_name_t name; + + REQUIRE(type == 30); + + rdclass = rdclass; /*unused*/ + + 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); + RETERR(dns_name_fromwire(&name, source, dctx, downcase, target)); + + isc_buffer_active(source, &sr); + /* XXXRTH Enforce RFC 2535 length rules if bit 0 is not set. */ + if (sr.length > 8 * 1024) + return (DNS_R_EXTRADATA); + RETERR(mem_tobuffer(target, sr.base, sr.length)); + isc_buffer_forward(source, sr.length); + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +towire_nxt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + isc_region_t sr; + dns_name_t name; + + REQUIRE(rdata->type == 30); + + 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, &sr); + dns_name_fromregion(&name, &sr); + isc_region_consume(&sr, name_length(&name)); + RETERR(dns_name_towire(&name, cctx, target)); + + return (mem_tobuffer(target, sr.base, sr.length)); +} + +static inline int +compare_nxt(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + isc_region_t r1; + isc_region_t r2; + dns_name_t name1; + dns_name_t name2; + int result; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 30); + + dns_name_init(&name1, NULL); + dns_name_init(&name2, NULL); + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + dns_name_fromregion(&name1, &r1); + dns_name_fromregion(&name2, &r2); + result = dns_name_rdatacompare(&name1, &name2); + if (result != 0) + return (result); + + return (compare_region(&r1, &r2)); +} + +static inline isc_result_t +fromstruct_nxt(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 30); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_nxt(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 30); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_nxt(void *source) { + dns_rdata_nxt_t *nxt = source; + + REQUIRE(source != NULL); + REQUIRE(nxt->common.rdtype == 30); + REQUIRE(ISC_FALSE); +} + +static inline isc_result_t +additionaldata_nxt(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 30); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_nxt(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + dns_name_t name; + isc_result_t result; + + REQUIRE(rdata->type == 30); + + dns_rdata_toregion(rdata, &r); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r); + result = dns_name_digest(&name, digest, arg); + if (result != DNS_R_SUCCESS) + return (result); + isc_region_consume(&r, name_length(&name)); + + return ((digest)(arg, &r)); +} + +#endif /* RDATA_GENERIC_NXT_30_C */ diff --git a/lib/dns/rdata/generic/nxt_30.h b/lib/dns/rdata/generic/nxt_30.h new file mode 100644 index 00000000..a22a96c8 --- /dev/null +++ b/lib/dns/rdata/generic/nxt_30.h @@ -0,0 +1,25 @@ +/* + * 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: nxt_30.h,v 1.11 2000/02/03 23:43:04 halley Exp $ */ + + /* RFC 2065 */ + +typedef struct dns_rdata_nxt { + dns_rdatacommon_t common; + /*XXX*/ +} dns_rdata_nxt_t; diff --git a/lib/dns/rdata/generic/opt_41.c b/lib/dns/rdata/generic/opt_41.c new file mode 100644 index 00000000..0c6fc547 --- /dev/null +++ b/lib/dns/rdata/generic/opt_41.c @@ -0,0 +1,181 @@ +/* + * 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: opt_41.c,v 1.4 2000/02/03 23:43:05 halley Exp $ */ + +#ifndef RDATA_GENERIC_OPT_41_C +#define RDATA_GENERIC_OPT_41_C + +static inline isc_result_t +fromtext_opt(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_lex_t *lexer, dns_name_t *origin, + isc_boolean_t downcase, isc_buffer_t *target) +{ + /* + * OPT records do not have a text format. + */ + + REQUIRE(type == 41); + + (void)rdclass; + (void)lexer; + (void)origin; + (void)downcase; + (void)target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +totext_opt(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + /* + * OPT records do not have a text format. + */ + + REQUIRE(rdata->type == 41); + + (void)tctx; + (void)target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +fromwire_opt(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; + isc_uint16_t option, length; + unsigned int total; + + REQUIRE(type == 41); + + (void)rdclass; + (void)dctx; + (void)downcase; + + isc_buffer_active(source, &sregion); + total = 0; + while (sregion.length != 0) { + if (sregion.length < 4) + return (DNS_R_UNEXPECTEDEND); + option = uint16_fromregion(&sregion); + length = uint16_fromregion(&sregion); + isc_region_consume(&sregion, 4); + total += 4; + if (sregion.length < length) + return (DNS_R_UNEXPECTEDEND); + isc_region_consume(&sregion, length); + total += length; + } + + isc_buffer_active(source, &sregion); + isc_buffer_available(target, &tregion); + if (tregion.length < total) + return (DNS_R_NOSPACE); + memcpy(tregion.base, sregion.base, total); + isc_buffer_forward(source, total); + isc_buffer_add(target, total); + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +towire_opt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + + REQUIRE(rdata->type == 41); + + (void)cctx; + + return (mem_tobuffer(target, rdata->data, rdata->length)); +} + +static inline int +compare_opt(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 == 41); + + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + return (compare_region(&r1, &r2)); +} + +static inline isc_result_t +fromstruct_opt(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + REQUIRE(type == 41); + + (void)rdclass; + (void)source; + (void)target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_opt(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 41); + + (void)target; + (void)mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_opt(void *source) { + (void)source; +} + +static inline isc_result_t +additionaldata_opt(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 41); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_opt(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + + /* + * OPT records are not digested. + */ + + REQUIRE(rdata->type == 41); + + (void)digest; + (void)arg; + + return (DNS_R_NOTIMPLEMENTED); +} + +#endif /* RDATA_GENERIC_OPT_41_C */ diff --git a/lib/dns/rdata/generic/opt_41.h b/lib/dns/rdata/generic/opt_41.h new file mode 100644 index 00000000..b0931e2c --- /dev/null +++ b/lib/dns/rdata/generic/opt_41.h @@ -0,0 +1,24 @@ +/* + * 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: opt_41.h,v 1.3 2000/02/03 23:43:05 halley Exp $ */ + +typedef struct dns_rdata_opt { + dns_rdatacommon_t common; + isc_mem_t *mctx; /* if required */ + /* XXXRTH Not implemented. */ +} dns_rdata_opt_t; diff --git a/lib/dns/rdata/generic/proforma.c b/lib/dns/rdata/generic/proforma.c new file mode 100644 index 00000000..16d94916 --- /dev/null +++ b/lib/dns/rdata/generic/proforma.c @@ -0,0 +1,147 @@ +/* + * 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: proforma.c,v 1.17 2000/02/03 23:43:05 halley Exp $ */ + +#ifndef RDATA_GENERIC_#_#_C +#define RDATA_GENERIC_#_#_C + +static inline isc_result_t +fromtext_#(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; + + REQUIRE(type == #); + REQUIRE(rdclass == #); + + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +totext_#(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + + REQUIRE(rdata->type == #); + REQUIRE(rdata->rdclass == #); + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +fromwire_#(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_buffer_t *source, dns_decompress_t *dctx, + isc_boolean_t downcase, isc_buffer_t *target) { + + REQUIRE(type == #); + REQUIRE(rdclass == #); + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_LOCAL); + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +towire_#(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + + REQUIRE(rdata->type == #); + REQUIRE(rdata->rdclass == #); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL): + else + dns_compress_setmethods(cctx, DNS_COMPRESS_LOCAL); + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline int +compare_#(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 == #); + REQUIRE(rdata1->rdclass == #); + + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + return (compare_region(&r1, &r2)); +} + +static inline isc_result_t +fromstruct_#(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) { + + REQUIRE(type == #); + REQUIRE(rdclass == #); + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_#(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == #); + REQUIRE(rdata->rdclass == #); + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_#(void *source) { + dns_rdata_#_t *# = source; + + REQUIRE(source != NULL); + REQUIRE(#->common.rdtype == #); + REQUIRE(#->common.rdclass == #); + +} + +static inline isc_result_t +additionaldata_#(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == #); + REQUIRE(rdata->rdclass == #); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_#(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + + REQUIRE(rdata->type == #); + REQUIRE(rdata->rdclass == #); + + dns_rdata_toregion(rdata, &r); + + return ((digest)(arg, &r)); +} + +#endif /* RDATA_GENERIC_#_#_C */ diff --git a/lib/dns/rdata/generic/proforma.h b/lib/dns/rdata/generic/proforma.h new file mode 100644 index 00000000..5682f41b --- /dev/null +++ b/lib/dns/rdata/generic/proforma.h @@ -0,0 +1,24 @@ +/* + * 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: proforma.h,v 1.12 2000/02/03 23:43:05 halley Exp $ */ + +typedef struct dns_rdata_# { + dns_rdatacommon_t common; + isc_mem_t *mctx; /* if required */ + /* type & class specific elements */ +} dns_rdata_#_t; diff --git a/lib/dns/rdata/generic/ptr_12.c b/lib/dns/rdata/generic/ptr_12.c new file mode 100644 index 00000000..94b9b1f9 --- /dev/null +++ b/lib/dns/rdata/generic/ptr_12.c @@ -0,0 +1,187 @@ +/* + * 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: ptr_12.c,v 1.19 2000/02/03 23:43:05 halley Exp $ */ + +#ifndef RDATA_GENERIC_PTR_12_C +#define RDATA_GENERIC_PTR_12_C + +static inline isc_result_t +fromtext_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 == 12); + + rdclass = rdclass; /*unused*/ + + 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_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 == 12); + + 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_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 == 12); + + rdclass = rdclass; /* unused */ + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); + + dns_name_init(&name, NULL); + return (dns_name_fromwire(&name, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_ptr(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + dns_name_t name; + isc_region_t region; + + REQUIRE(rdata->type == 12); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); + + 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_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 == 12); + + 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_ptr(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 12); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_ptr(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 12); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_ptr(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); +} + +static inline isc_result_t +additionaldata_ptr(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 12); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_ptr(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + dns_name_t name; + + REQUIRE(rdata->type == 12); + + dns_rdata_toregion(rdata, &r); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r); + + return (dns_name_digest(&name, digest, arg)); +} + +#endif /* RDATA_GENERIC_PTR_12_C */ diff --git a/lib/dns/rdata/generic/ptr_12.h b/lib/dns/rdata/generic/ptr_12.h new file mode 100644 index 00000000..6dcb1980 --- /dev/null +++ b/lib/dns/rdata/generic/ptr_12.h @@ -0,0 +1,19 @@ +/* + * 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: ptr_12.h,v 1.14 2000/02/03 23:43:05 halley Exp $ */ + diff --git a/lib/dns/rdata/generic/rp_17.c b/lib/dns/rdata/generic/rp_17.c new file mode 100644 index 00000000..a38a7530 --- /dev/null +++ b/lib/dns/rdata/generic/rp_17.c @@ -0,0 +1,242 @@ +/* + * 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: rp_17.c,v 1.14 2000/02/03 23:43:06 halley Exp $ */ + + /* RFC 1183 */ + +#ifndef RDATA_GENERIC_RP_17_C +#define RDATA_GENERIC_RP_17_C + +static inline isc_result_t +fromtext_rp(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; + int i; + + REQUIRE(type == 17); + + rdclass = rdclass; /*unused*/ + + for (i = 0; i < 2 ; i++) { + 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)); + } + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +totext_rp(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t region; + dns_name_t rmail; + dns_name_t email; + dns_name_t prefix; + isc_boolean_t sub; + + REQUIRE(rdata->type == 17); + + dns_name_init(&rmail, NULL); + dns_name_init(&email, NULL); + dns_name_init(&prefix, NULL); + + dns_rdata_toregion(rdata, ®ion); + + dns_name_fromregion(&rmail, ®ion); + isc_region_consume(®ion, rmail.length); + + dns_name_fromregion(&email, ®ion); + isc_region_consume(®ion, email.length); + + sub = name_prefix(&rmail, tctx->origin, &prefix); + + RETERR(dns_name_totext(&prefix, sub, target)); + + RETERR(str_totext(" ", target)); + + sub = name_prefix(&email, tctx->origin, &prefix); + return (dns_name_totext(&prefix, sub, target)); +} + +static inline isc_result_t +fromwire_rp(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 rmail; + dns_name_t email; + + REQUIRE(type == 17); + + rdclass = rdclass; /*unused*/ + + 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(&rmail, NULL); + dns_name_init(&email, NULL); + + RETERR(dns_name_fromwire(&rmail, source, dctx, downcase, target)); + return (dns_name_fromwire(&email, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_rp(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + isc_region_t region; + dns_name_t rmail; + dns_name_t email; + + REQUIRE(rdata->type == 17); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); + + dns_name_init(&rmail, NULL); + dns_name_init(&email, NULL); + + dns_rdata_toregion(rdata, ®ion); + + dns_name_fromregion(&rmail, ®ion); + isc_region_consume(®ion, rmail.length); + + RETERR(dns_name_towire(&rmail, cctx, target)); + + dns_name_fromregion(&rmail, ®ion); + isc_region_consume(®ion, rmail.length); + + return (dns_name_towire(&rmail, cctx, target)); +} + +static inline int +compare_rp(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + isc_region_t region1; + isc_region_t region2; + dns_name_t name1; + dns_name_t name2; + int result; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 17); + + 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); + + 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_init(&name1, NULL); + dns_name_init(&name2, NULL); + + dns_name_fromregion(&name1, ®ion1); + dns_name_fromregion(&name2, ®ion2); + + result = dns_name_rdatacompare(&name1, &name2); + return (result); +} + +static inline isc_result_t +fromstruct_rp(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 17); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_rp(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 17); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_rp(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ +} + +static inline isc_result_t +additionaldata_rp(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 17); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_rp(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + dns_name_t name; + isc_result_t result; + + REQUIRE(rdata->type == 17); + + dns_rdata_toregion(rdata, &r); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r); + result = dns_name_digest(&name, digest, arg); + if (result != DNS_R_SUCCESS) + return (result); + isc_region_consume(&r, name_length(&name)); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r); + + return (dns_name_digest(&name, digest, arg)); +} + +#endif /* RDATA_GENERIC_RP_17_C */ diff --git a/lib/dns/rdata/generic/rp_17.h b/lib/dns/rdata/generic/rp_17.h new file mode 100644 index 00000000..0b83845b --- /dev/null +++ b/lib/dns/rdata/generic/rp_17.h @@ -0,0 +1,21 @@ +/* + * 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: rp_17.h,v 1.9 2000/02/03 23:43:06 halley Exp $ */ + + /* RFC 1183 */ + diff --git a/lib/dns/rdata/generic/rt_21.c b/lib/dns/rdata/generic/rt_21.c new file mode 100644 index 00000000..7a22a218 --- /dev/null +++ b/lib/dns/rdata/generic/rt_21.c @@ -0,0 +1,243 @@ +/* + * 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: rt_21.c,v 1.15 2000/02/03 23:43:06 halley Exp $ */ + + /* RFC 1183 */ + +#ifndef RDATA_GENERIC_RT_21_C +#define RDATA_GENERIC_RT_21_C + +static inline isc_result_t +fromtext_rt(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 == 21); + + rdclass = rdclass; /*unused*/ + + 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_rt(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 == 21); + + 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_rt(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; + isc_region_t tregion; + + REQUIRE(type == 21); + rdclass = rdclass; /* unused */ + + 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); + isc_buffer_available(target, &tregion); + if (tregion.length < 2) + return (DNS_R_NOSPACE); + if (sregion.length < 2) + return (DNS_R_UNEXPECTEDEND); + memcpy(tregion.base, sregion.base, 2); + isc_buffer_forward(source, 2); + isc_buffer_add(target, 2); + return (dns_name_fromwire(&name, source, dctx, downcase, target)); +} + +static inline isc_result_t +towire_rt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + dns_name_t name; + isc_region_t region; + isc_region_t tr; + + REQUIRE(rdata->type == 21); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); + + isc_buffer_available(target, &tr); + dns_rdata_toregion(rdata, ®ion); + if (tr.length < 2) + return (DNS_R_NOSPACE); + memcpy(tr.base, region.base, 2); + isc_region_consume(®ion, 2); + isc_buffer_add(target, 2); + + dns_name_init(&name, NULL); + dns_name_fromregion(&name, ®ion); + + return (dns_name_towire(&name, cctx, target)); +} + +static inline int +compare_rt(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 == 21); + + 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_rt(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 21); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_rt(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 21); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_rt(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ +} + +static inline isc_result_t +additionaldata_rt(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + dns_name_t name; + isc_region_t region; + isc_result_t result; + + REQUIRE(rdata->type == 21); + + dns_name_init(&name, NULL); + dns_rdata_toregion(rdata, ®ion); + isc_region_consume(®ion, 2); + dns_name_fromregion(&name, ®ion); + + result = (add)(arg, &name, dns_rdatatype_x25); + if (result != ISC_R_SUCCESS) + return (result); + result = (add)(arg, &name, dns_rdatatype_isdn); + if (result != ISC_R_SUCCESS) + return (result); + return ((add)(arg, &name, dns_rdatatype_a)); +} + +static inline isc_result_t +digest_rt(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 == 21); + + 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_RT_21_C */ diff --git a/lib/dns/rdata/generic/rt_21.h b/lib/dns/rdata/generic/rt_21.h new file mode 100644 index 00000000..3a28ea98 --- /dev/null +++ b/lib/dns/rdata/generic/rt_21.h @@ -0,0 +1,21 @@ +/* + * 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: rt_21.h,v 1.9 2000/02/03 23:43:06 halley Exp $ */ + + /* RFC 1183 */ + diff --git a/lib/dns/rdata/generic/sig_24.c b/lib/dns/rdata/generic/sig_24.c new file mode 100644 index 00000000..7d3b6ee4 --- /dev/null +++ b/lib/dns/rdata/generic/sig_24.c @@ -0,0 +1,493 @@ +/* + * 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: sig_24.c,v 1.27 2000/02/03 23:43:06 halley Exp $ */ + + /* RFC 2065 */ + +#ifndef RDATA_GENERIC_SIG_24_C +#define RDATA_GENERIC_SIG_24_C + +static inline isc_result_t +fromtext_sig(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 c; + long i; + dns_rdatatype_t covered; + isc_textregion_t *tsr; + char *e; + isc_result_t result; + dns_name_t name; + isc_buffer_t buffer; + isc_uint32_t time_signed, time_expire; + + REQUIRE(type == 24); + + rdclass = rdclass; /*unused*/ + origin = origin; /*unused*/ + downcase = downcase; /*unused*/ + + /* type covered */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + tsr = &token.value.as_textregion; + result = dns_rdatatype_fromtext(&covered, tsr); + if (result != DNS_R_SUCCESS && result != DNS_R_NOTIMPLEMENTED) { + i = strtol(token.value.as_pointer, &e, 10); + if (i < 0 || i > 65535) + return (DNS_R_RANGE); + if (*e != 0) + return (result); + covered = (dns_rdatatype_t)i; + } + RETERR(uint16_tobuffer(covered, target)); + + /* algorithm */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + RETERR(dns_secalg_fromtext(&c, &token.value.as_textregion)); + RETERR(mem_tobuffer(target, &c, 1)); + + /* labels */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + if (token.value.as_ulong > 0xff) + return (DNS_R_RANGE); + c = (unsigned char)token.value.as_ulong; + RETERR(mem_tobuffer(target, &c, 1)); + + /* original ttl */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + RETERR(uint32_tobuffer(token.value.as_ulong, target)); + + /* signature expiration */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + RETERR(dns_time32_fromtext(token.value.as_pointer, &time_expire)); + RETERR(uint32_tobuffer(time_expire, target)); + + /* time signed */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + RETERR(dns_time32_fromtext(token.value.as_pointer, &time_signed)); + RETERR(uint32_tobuffer(time_signed, target)); + + /* key footprint */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + RETERR(uint16_tobuffer(token.value.as_ulong, target)); + + /* signer */ + 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)); + + /* sig */ + return (isc_base64_tobuffer(lexer, target, -1)); +} + +static inline isc_result_t +totext_sig(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t sr; + char buf[sizeof "4294967295"]; + dns_rdatatype_t covered; + unsigned long ttl; + unsigned long when; + unsigned long exp; + unsigned long foot; + dns_name_t name; + dns_name_t prefix; + isc_boolean_t sub; + + REQUIRE(rdata->type == 24); + + tctx = tctx; /*unused*/ + + dns_rdata_toregion(rdata, &sr); + + /* type covered */ + covered = uint16_fromregion(&sr); + isc_region_consume(&sr, 2); + RETERR(dns_rdatatype_totext(covered, target)); + RETERR(str_totext(" ", target)); + + /* algorithm */ + sprintf(buf, "%u", sr.base[0]); + isc_region_consume(&sr, 1); + RETERR(str_totext(buf, target)); + RETERR(str_totext(" ", target)); + + /* labels */ + sprintf(buf, "%u", sr.base[0]); + isc_region_consume(&sr, 1); + RETERR(str_totext(buf, target)); + RETERR(str_totext(" ", target)); + + /* ttl */ + ttl = uint32_fromregion(&sr); + isc_region_consume(&sr, 4); + sprintf(buf, "%lu", ttl); + RETERR(str_totext(buf, target)); + RETERR(str_totext(" ", target)); + + /* sig exp */ + exp = uint32_fromregion(&sr); + isc_region_consume(&sr, 4); + RETERR(dns_time32_totext(exp, target)); + + if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) + RETERR(str_totext(" (", target)); + RETERR(str_totext(tctx->linebreak, target)); + + /* time signed */ + when = uint32_fromregion(&sr); + isc_region_consume(&sr, 4); + RETERR(dns_time32_totext(when, target)); + RETERR(str_totext(" ", target)); + + /* footprint */ + foot = uint16_fromregion(&sr); + isc_region_consume(&sr, 2); + sprintf(buf, "%lu", foot); + RETERR(str_totext(buf, target)); + RETERR(str_totext(" ", target)); + + /* signer */ + dns_name_init(&name, NULL); + dns_name_init(&prefix, NULL); + dns_name_fromregion(&name, &sr); + isc_region_consume(&sr, name_length(&name)); + sub = name_prefix(&name, tctx->origin, &prefix); + RETERR(dns_name_totext(&prefix, sub, target)); + + /* sig */ + RETERR(str_totext(tctx->linebreak, target)); + RETERR(isc_base64_totext(&sr, tctx->width - 2, + tctx->linebreak, target)); + if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) + RETERR(str_totext(" )", target)); + + return DNS_R_SUCCESS; +} + +static inline isc_result_t +fromwire_sig(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; + dns_name_t name; + + REQUIRE(type == 24); + + 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); + + rdclass = rdclass; /*unused*/ + + isc_buffer_active(source, &sr); + /* + * type covered: 2 + * algorithm: 1 + * labels: 1 + * original ttl: 4 + * signature expiration: 4 + * time signed: 4 + * key footprint: 2 + */ + if (sr.length < 18) + return (DNS_R_UNEXPECTEDEND); + + isc_buffer_forward(source, 18); + RETERR(mem_tobuffer(target, sr.base, 18)); + + /* signer */ + dns_name_init(&name, NULL); + RETERR(dns_name_fromwire(&name, source, dctx, downcase, target)); + + /* sig */ + isc_buffer_active(source, &sr); + isc_buffer_forward(source, sr.length); + return(mem_tobuffer(target, sr.base, sr.length)); +} + +static inline isc_result_t +towire_sig(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + isc_region_t sr; + dns_name_t name; + + REQUIRE(rdata->type == 24); + + 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); + /* + * type covered: 2 + * algorithm: 1 + * labels: 1 + * original ttl: 4 + * signature expiration: 4 + * time signed: 4 + * key footprint: 2 + */ + RETERR(mem_tobuffer(target, sr.base, 18)); + isc_region_consume(&sr, 18); + + /* signer */ + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &sr); + isc_region_consume(&sr, name_length(&name)); + RETERR(dns_name_towire(&name, cctx, target)); + + /* signature */ + return (mem_tobuffer(target, sr.base, sr.length)); +} + +static inline int +compare_sig(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + isc_region_t r1; + isc_region_t r2; + dns_name_t name1; + dns_name_t name2; + int result; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 24); + + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + + INSIST(r1.length > 18); + INSIST(r2.length > 18); + r1.length = 18; + r2.length = 18; + result = compare_region(&r1, &r2); + if (result != 0) + return (result); + + dns_name_init(&name1, NULL); + dns_name_init(&name2, NULL); + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + isc_region_consume(&r1, 18); + isc_region_consume(&r2, 18); + dns_name_fromregion(&name1, &r1); + dns_name_fromregion(&name2, &r2); + result = dns_name_rdatacompare(&name1, &name2); + if (result != 0) + return (result); + isc_region_consume(&r1, name_length(&name1)); + isc_region_consume(&r2, name_length(&name2)); + + return (compare_region(&r1, &r2)); +} + +static inline isc_result_t +fromstruct_sig(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + isc_region_t tr; + dns_rdata_generic_sig_t *sig; + dns_compress_t cctx; + + REQUIRE(type == 24); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + sig = (dns_rdata_generic_sig_t *) source; + REQUIRE(sig->mctx != NULL); + + /* Type covered */ + RETERR(uint16_tobuffer(sig->covered, target)); + + /* Algorithm */ + RETERR(uint8_tobuffer(sig->algorithm, target)); + + /* Labels */ + RETERR(uint8_tobuffer(sig->labels, target)); + + /* Original TTL */ + RETERR(uint32_tobuffer(sig->originalttl, target)); + + /* Expire time */ + RETERR(uint32_tobuffer(sig->timeexpire, target)); + + /* Time signed */ + RETERR(uint32_tobuffer(sig->timesigned, target)); + + /* Key ID */ + RETERR(uint16_tobuffer(sig->keyid, target)); + + /* Signer name */ + RETERR(dns_compress_init(&cctx, -1, sig->mctx)); + dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE); + RETERR(dns_name_towire(&sig->signer, &cctx, target)); + dns_compress_invalidate(&cctx); + + /* Signature */ + if (sig->siglen > 0) { + isc_buffer_available(target, &tr); + if (tr.length < sig->siglen) + return (DNS_R_NOSPACE); + memcpy(tr.base, sig->signature, sig->siglen); + isc_buffer_add(target, sig->siglen); + } + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +tostruct_sig(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + isc_region_t sr; + dns_rdata_generic_sig_t *sig; + dns_name_t signer; + + REQUIRE(rdata->type == 24); + + target = target; + mctx = mctx; + + sig = (dns_rdata_generic_sig_t *) target; + sig->common.rdclass = rdata->rdclass; + sig->common.rdtype = rdata->type; + ISC_LINK_INIT(&sig->common, link); + sig->mctx = mctx; + dns_rdata_toregion(rdata, &sr); + + /* Type covered */ + if (sr.length < 2) + return (ISC_R_UNEXPECTEDEND); + sig->covered = uint16_fromregion(&sr); + isc_region_consume(&sr, 2); + + /* Algorithm */ + if (sr.length < 1) + return (ISC_R_UNEXPECTEDEND); + sig->algorithm = uint8_fromregion(&sr); + isc_region_consume(&sr, 1); + + /* Labels */ + if (sr.length < 1) + return (ISC_R_UNEXPECTEDEND); + sig->labels = uint8_fromregion(&sr); + isc_region_consume(&sr, 1); + + /* Original TTL */ + if (sr.length < 4) + return (ISC_R_UNEXPECTEDEND); + sig->originalttl = uint32_fromregion(&sr); + isc_region_consume(&sr, 4); + + /* Expire time */ + if (sr.length < 4) + return (ISC_R_UNEXPECTEDEND); + sig->timeexpire = uint32_fromregion(&sr); + isc_region_consume(&sr, 4); + + /* Time signed */ + if (sr.length < 4) + return (ISC_R_UNEXPECTEDEND); + sig->timesigned = uint32_fromregion(&sr); + isc_region_consume(&sr, 4); + + /* Key ID */ + if (sr.length < 2) + return (ISC_R_UNEXPECTEDEND); + sig->keyid = uint16_fromregion(&sr); + isc_region_consume(&sr, 2); + + dns_name_init(&signer, NULL); + dns_name_fromregion(&signer, &sr); + dns_name_init(&sig->signer, NULL); + RETERR(dns_name_dup(&signer, mctx, &sig->signer)); + isc_region_consume(&sr, name_length(&sig->signer)); + + /* Signature */ + sig->siglen = sr.length; + if (sig->siglen > 0) { + sig->signature = isc_mem_get(mctx, sig->siglen); + if (sig->signature == NULL) + return (DNS_R_NOMEMORY); + memcpy(sig->signature, sr.base, sig->siglen); + isc_region_consume(&sr, sig->siglen); + } + else + sig->signature = NULL; + + return (DNS_R_SUCCESS); +} + +static inline void +freestruct_sig(void *source) { + dns_rdata_generic_sig_t *sig = (dns_rdata_generic_sig_t *) source; + + REQUIRE(source != NULL); + REQUIRE(sig->common.rdtype == 24); + + dns_name_free(&sig->signer, sig->mctx); + if (sig->siglen > 0) + isc_mem_put(sig->mctx, sig->signature, sig->siglen); +} + +static inline isc_result_t +additionaldata_sig(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 24); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_sig(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + + REQUIRE(rdata->type == 24); + + (void)digest; + (void)arg; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline dns_rdatatype_t +covers_sig(dns_rdata_t *rdata) { + dns_rdatatype_t type; + isc_region_t r; + + REQUIRE(rdata->type == 24); + + dns_rdata_toregion(rdata, &r); + type = uint16_fromregion(&r); + + return (type); +} + +#endif /* RDATA_GENERIC_SIG_24_C */ diff --git a/lib/dns/rdata/generic/sig_24.h b/lib/dns/rdata/generic/sig_24.h new file mode 100644 index 00000000..897756f6 --- /dev/null +++ b/lib/dns/rdata/generic/sig_24.h @@ -0,0 +1,36 @@ +/* + * 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: sig_24.h,v 1.15 2000/02/03 23:43:07 halley Exp $ */ + + /* RFC 2065 */ + +typedef struct dns_rdata_generic_sig_t { + dns_rdatacommon_t common; + isc_mem_t * mctx; + dns_rdatatype_t covered; + dns_secalg_t algorithm; + isc_uint8_t labels; + isc_uint32_t originalttl; + isc_uint32_t timeexpire; + isc_uint32_t timesigned; + isc_uint16_t keyid; + dns_name_t signer; + isc_uint16_t siglen; + unsigned char * signature; +} dns_rdata_generic_sig_t; + diff --git a/lib/dns/rdata/generic/soa_6.c b/lib/dns/rdata/generic/soa_6.c new file mode 100644 index 00000000..4b7078d1 --- /dev/null +++ b/lib/dns/rdata/generic/soa_6.c @@ -0,0 +1,362 @@ +/* + * 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: soa_6.c,v 1.27 2000/02/03 23:43:07 halley Exp $ */ + +#ifndef RDATA_GENERIC_SOA_6_C +#define RDATA_GENERIC_SOA_6_C + +static inline isc_result_t +fromtext_soa(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; + int i; + isc_uint32_t n; + + REQUIRE(type == 6); + + rdclass = rdclass; /*unused*/ + + for (i = 0 ; i < 2 ; i++) { + 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)); + } + + RETERR(gettoken(lexer, &token, isc_tokentype_number, + ISC_FALSE)); + RETERR(uint32_tobuffer(token.value.as_ulong, target)); + for (i = 0; i < 4; i++) { + RETERR(gettoken(lexer, &token, isc_tokentype_string, + ISC_FALSE)); + RETERR(dns_counter_fromtext(&token.value.as_textregion, &n)); + RETERR(uint32_tobuffer(n, target)); + } + + return (DNS_R_SUCCESS); +} + +static char *soa_fieldnames[5] = { + "serial", "refresh", "retry", "expire", "minimum" +} ; + +static inline isc_result_t +totext_soa(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t dregion; + dns_name_t mname; + dns_name_t rname; + dns_name_t prefix; + isc_boolean_t sub; + int i; + + REQUIRE(rdata->type == 6); + + dns_name_init(&mname, NULL); + dns_name_init(&rname, NULL); + dns_name_init(&prefix, NULL); + + dns_rdata_toregion(rdata, &dregion); + + dns_name_fromregion(&mname, &dregion); + isc_region_consume(&dregion, name_length(&mname)); + + dns_name_fromregion(&rname, &dregion); + isc_region_consume(&dregion, name_length(&rname)); + + sub = name_prefix(&mname, tctx->origin, &prefix); + RETERR(dns_name_totext(&prefix, sub, target)); + + RETERR(str_totext(" ", target)); + + sub = name_prefix(&rname, tctx->origin, &prefix); + RETERR(dns_name_totext(&prefix, sub, target)); + + RETERR(str_totext(" (" , target)); + RETERR(str_totext(tctx->linebreak, target)); + + for (i = 0; i < 5 ; i++) { + char buf[sizeof "2147483647"]; + unsigned long num; + unsigned int numlen; + num = uint32_fromregion(&dregion); + isc_region_consume(&dregion, 4); + numlen = sprintf(buf, "%lu", num); + INSIST(numlen > 0 && numlen < sizeof "2147483647"); + RETERR(str_totext(buf, target)); + if ((tctx->flags & (DNS_STYLEFLAG_MULTILINE | + DNS_STYLEFLAG_COMMENT)) == + (DNS_STYLEFLAG_MULTILINE | + DNS_STYLEFLAG_COMMENT)) + { + RETERR(str_totext(" ; " + numlen, target)); + RETERR(str_totext(soa_fieldnames[i], target)); + /* Print times in week/day/hour/minute/second form */ + if (i >= 1) { + RETERR(str_totext(" (", target)); + RETERR(dns_ttl_totext(num, ISC_TRUE, target)); + RETERR(str_totext(")", target)); + } + RETERR(str_totext(tctx->linebreak, target)); + } else { + RETERR(str_totext(" ", target)); + } + } + + RETERR(str_totext(")", target)); + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +fromwire_soa(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 mname; + dns_name_t rname; + isc_region_t sregion; + isc_region_t tregion; + + REQUIRE(type == 6); + + rdclass = rdclass; /*unused*/ + + if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) + dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); + else + dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); + + dns_name_init(&mname, NULL); + dns_name_init(&rname, NULL); + + RETERR(dns_name_fromwire(&mname, source, dctx, downcase, target)); + RETERR(dns_name_fromwire(&rname, source, dctx, downcase, target)); + + isc_buffer_active(source, &sregion); + isc_buffer_available(target, &tregion); + + if (sregion.length < 20) + return (DNS_R_UNEXPECTEDEND); + if (tregion.length < 20) + return (DNS_R_NOSPACE); + + memcpy(tregion.base, sregion.base, 20); + isc_buffer_forward(source, 20); + isc_buffer_add(target, 20); + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +towire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + isc_region_t sregion; + isc_region_t tregion; + dns_name_t mname; + dns_name_t rname; + + REQUIRE(rdata->type == 6); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); + + dns_name_init(&mname, NULL); + dns_name_init(&rname, NULL); + + dns_rdata_toregion(rdata, &sregion); + dns_name_fromregion(&mname, &sregion); + isc_region_consume(&sregion, name_length(&mname)); + RETERR(dns_name_towire(&mname, cctx, target)); + + dns_name_fromregion(&rname, &sregion); + isc_region_consume(&sregion, name_length(&rname)); + RETERR(dns_name_towire(&rname, cctx, target)); + + isc_buffer_available(target, &tregion); + if (tregion.length < 20) + return (DNS_R_NOSPACE); + + memcpy(tregion.base, sregion.base, 20); + isc_buffer_add(target, 20); + return (DNS_R_SUCCESS); +} + +static inline int +compare_soa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + isc_region_t region1; + isc_region_t region2; + dns_name_t name1; + dns_name_t name2; + int result; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 6); + + 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); + + 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_init(&name1, NULL); + dns_name_init(&name2, NULL); + + 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)); + + return (compare_region(®ion1, ®ion2)); +} + +static inline isc_result_t +fromstruct_soa(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + REQUIRE(type == 6); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_soa(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + isc_region_t region; + dns_rdata_soa_t *soa = target; + dns_name_t name; + isc_result_t result; + + REQUIRE(rdata->type == 6); + REQUIRE(target != NULL); + + soa->common.rdclass = rdata->rdclass; + soa->common.rdtype = rdata->type; + ISC_LINK_INIT(&soa->common, link); + + soa->mctx = mctx; + + dns_name_init(&name, NULL); + dns_rdata_toregion(rdata, ®ion); + dns_name_fromregion(&name, ®ion); + isc_region_consume(®ion, name_length(&name)); + dns_name_init(&soa->origin, NULL); + result = dns_name_dup(&name, soa->mctx, &soa->origin); + if (result != DNS_R_SUCCESS) + return (result); + + dns_name_fromregion(&name, ®ion); + isc_region_consume(®ion, name_length(&name)); + dns_name_init(&soa->mname, NULL); + result = dns_name_dup(&name, soa->mctx, &soa->mname); + if (result != DNS_R_SUCCESS) + return (result); + + soa->serial = uint32_fromregion(®ion); + isc_region_consume(®ion, 4); + soa->refresh = uint32_fromregion(®ion); + isc_region_consume(®ion, 4); + soa->retry = uint32_fromregion(®ion); + isc_region_consume(®ion, 4); + soa->expire = uint32_fromregion(®ion); + isc_region_consume(®ion, 4); + soa->minimum = uint32_fromregion(®ion); + + return (DNS_R_SUCCESS); +} + +static inline void +freestruct_soa(void *source) { + dns_rdata_soa_t *soa = source; + + REQUIRE(source != NULL); + REQUIRE(soa->common.rdtype == 6); + dns_name_free(&soa->origin, soa->mctx); + dns_name_free(&soa->mname, soa->mctx); + soa->mctx = NULL; + /* No action required */ +} + +static inline isc_result_t +additionaldata_soa(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 6); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_soa(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + dns_name_t name; + isc_result_t result; + + REQUIRE(rdata->type == 6); + + dns_rdata_toregion(rdata, &r); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r); + result = dns_name_digest(&name, digest, arg); + if (result != DNS_R_SUCCESS) + return (result); + isc_region_consume(&r, name_length(&name)); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r); + result = dns_name_digest(&name, digest, arg); + if (result != DNS_R_SUCCESS) + return (result); + isc_region_consume(&r, name_length(&name)); + + return ((digest)(arg, &r)); +} + +#endif /* RDATA_GENERIC_SOA_6_C */ diff --git a/lib/dns/rdata/generic/soa_6.h b/lib/dns/rdata/generic/soa_6.h new file mode 100644 index 00000000..d4df6f5e --- /dev/null +++ b/lib/dns/rdata/generic/soa_6.h @@ -0,0 +1,33 @@ +/* + * 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: soa_6.h,v 1.19 2000/02/03 23:43:07 halley Exp $ */ + +#include <dns/name.h> + +typedef struct dns_rdata_soa { + dns_rdatacommon_t common; + isc_mem_t *mctx; + dns_name_t origin; + dns_name_t mname; + isc_uint32_t serial; /* host order */ + isc_uint32_t refresh; /* host order */ + isc_uint32_t retry; /* host order */ + isc_uint32_t expire; /* host order */ + isc_uint32_t minimum; /* host order */ +} dns_rdata_soa_t; + diff --git a/lib/dns/rdata/generic/tkey_249.c b/lib/dns/rdata/generic/tkey_249.c new file mode 100644 index 00000000..d082513f --- /dev/null +++ b/lib/dns/rdata/generic/tkey_249.c @@ -0,0 +1,470 @@ +/* + * 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: tkey_249.c,v 1.20 2000/02/03 23:43:08 halley Exp $ */ + + /* draft-ietf-dnssec-tkey-01.txt */ + +#ifndef RDATA_GENERIC_TKEY_249_C +#define RDATA_GENERIC_TKEY_249_C + +static inline isc_result_t +fromtext_tkey(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_rcode_t rcode; + dns_name_t name; + isc_buffer_t buffer; + long i; + char *e; + + REQUIRE(type == 249); + + rdclass = rdclass; /*unused*/ + + + /* Algorithm */ + 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)); + + + /* Inception */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + RETERR(uint32_tobuffer(token.value.as_ulong, target)); + + /* Expiration */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + RETERR(uint32_tobuffer(token.value.as_ulong, target)); + + /* Mode */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + if (token.value.as_ulong > 0xffff) + return (DNS_R_RANGE); + RETERR(uint16_tobuffer(token.value.as_ulong, target)); + + /* Error */ + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); + if (dns_rcode_fromtext(&rcode, &token.value.as_textregion) + != DNS_R_SUCCESS) { + i = strtol(token.value.as_pointer, &e, 10); + if (*e != 0) + return (DNS_R_UNKNOWN); + if (i < 0 || i > 0xffff) + return (DNS_R_RANGE); + rcode = (dns_rcode_t)i; + } + RETERR(uint16_tobuffer(rcode, target)); + + /* Signature Size */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + if (token.value.as_ulong > 0xffff) + return (DNS_R_RANGE); + RETERR(uint16_tobuffer(token.value.as_ulong, target)); + + /* Signature */ + RETERR(isc_base64_tobuffer(lexer, target, token.value.as_ulong)); + + /* Other Len */ + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); + if (token.value.as_ulong > 0xffff) + return (DNS_R_RANGE); + RETERR(uint16_tobuffer(token.value.as_ulong, target)); + + /* Other Data */ + return (isc_base64_tobuffer(lexer, target, token.value.as_ulong)); +} + +static inline isc_result_t +totext_tkey(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t sr; + isc_region_t sigr; + char buf[sizeof "4294967295 "]; + unsigned long n; + dns_name_t name; + dns_name_t prefix; + isc_boolean_t sub; + + REQUIRE(rdata->type == 249); + + dns_rdata_toregion(rdata, &sr); + + /* Algorithm */ + dns_name_init(&name, NULL); + dns_name_init(&prefix, NULL); + dns_name_fromregion(&name, &sr); + sub = name_prefix(&name, tctx->origin, &prefix); + RETERR(dns_name_totext(&prefix, sub, target)); + RETERR(str_totext(" ", target)); + isc_region_consume(&sr, name_length(&name)); + + /* Inception */ + n = uint32_fromregion(&sr); + isc_region_consume(&sr, 4); + sprintf(buf, "%lu ", n); + RETERR(str_totext(buf, target)); + + /* Expiration */ + n = uint32_fromregion(&sr); + isc_region_consume(&sr, 4); + sprintf(buf, "%lu ", n); + RETERR(str_totext(buf, target)); + + /* Mode */ + n = uint16_fromregion(&sr); + isc_region_consume(&sr, 2); + sprintf(buf, "%lu ", n); + RETERR(str_totext(buf, target)); + + /* Error */ + n = uint16_fromregion(&sr); + isc_region_consume(&sr, 2); + if (dns_rcode_totext((dns_rcode_t)n, target) == DNS_R_SUCCESS) + RETERR(str_totext(" ", target)); + else { + sprintf(buf, "%lu ", n); + RETERR(str_totext(buf, target)); + } + + /* Signature Size */ + n = uint16_fromregion(&sr); + isc_region_consume(&sr, 2); + sprintf(buf, "%lu", n); + RETERR(str_totext(buf, target)); + + /* Signature */ + REQUIRE(n <= sr.length); + sigr = sr; + sigr.length = n; + if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) + RETERR(str_totext(" (", target)); + RETERR(str_totext(tctx->linebreak, target)); + RETERR(isc_base64_totext(&sigr, tctx->width - 2, + tctx->linebreak, target)); + if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) + RETERR(str_totext(" ) ", target)); + else + RETERR(str_totext(" ", target)); + isc_region_consume(&sr, n); + + /* Other Size */ + n = uint16_fromregion(&sr); + isc_region_consume(&sr, 2); + sprintf(buf, "%lu ", n); + RETERR(str_totext(buf, target)); + + /* Other */ + return (isc_base64_totext(&sr, 60, " ", target)); +} + +static inline isc_result_t +fromwire_tkey(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 long n; + dns_name_t name; + + REQUIRE(type == 249); + + rdclass = rdclass; /*unused*/ + + 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); + + /* Algorithm */ + dns_name_init(&name, NULL); + RETERR(dns_name_fromwire(&name, source, dctx, downcase, target)); + + /* + * Inception: 4 + * Expiration: 4 + * Mode: 2 + * Error: 2 + */ + isc_buffer_active(source, &sr); + if (sr.length < 12) + return (DNS_R_UNEXPECTEDEND); + RETERR(mem_tobuffer(target, sr.base, 12)); + isc_region_consume(&sr, 12); + isc_buffer_forward(source, 12); + + /* Signature Length + Signature */ + if (sr.length < 2) + return (DNS_R_UNEXPECTEDEND); + n = uint16_fromregion(&sr); + if (sr.length < n + 2) + return (DNS_R_UNEXPECTEDEND); + RETERR(mem_tobuffer(target, sr.base, n + 2)); + isc_region_consume(&sr, n + 2); + isc_buffer_forward(source, n + 2); + + /* Other Length + Other */ + if (sr.length < 2) + return (DNS_R_UNEXPECTEDEND); + n = uint16_fromregion(&sr); + if (sr.length < n + 2) + return (DNS_R_UNEXPECTEDEND); + isc_buffer_forward(source, n + 2); + return (mem_tobuffer(target, sr.base, n + 2)); +} + +static inline isc_result_t +towire_tkey(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + isc_region_t sr; + dns_name_t name; + + REQUIRE(rdata->type == 249); + + if (dns_compress_getedns(cctx) >= 1) + dns_compress_setmethods(cctx, DNS_COMPRESS_ALL); + else + dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); + + /* Algorithm */ + dns_rdata_toregion(rdata, &sr); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &sr); + RETERR(dns_name_towire(&name, cctx, target)); + isc_region_consume(&sr, name_length(&name)); + + return (mem_tobuffer(target, sr.base, sr.length)); +} + +static inline int +compare_tkey(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + isc_region_t r1; + isc_region_t r2; + dns_name_t name1; + dns_name_t name2; + int result; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 249); + + /* Algorithm */ + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + dns_name_init(&name1, NULL); + dns_name_init(&name2, NULL); + dns_name_fromregion(&name1, &r1); + dns_name_fromregion(&name2, &r2); + if ((result = dns_name_rdatacompare(&name1, &name2)) != 0) + return (result); + isc_region_consume(&r1, name_length(&name1)); + isc_region_consume(&r2, name_length(&name2)); + return (compare_region(&r1, &r2)); +} + +static inline isc_result_t +fromstruct_tkey(dns_rdataclass_t rdclass, dns_rdatatype_t type, + void *source, isc_buffer_t *target) +{ + isc_region_t tr; + dns_rdata_generic_tkey_t *tkey; + dns_compress_t cctx; + + REQUIRE(type == 249); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + tkey = (dns_rdata_generic_tkey_t *) source; + REQUIRE(tkey->mctx != NULL); + + /* Algorithm Name */ + RETERR(dns_compress_init(&cctx, -1, tkey->mctx)); + dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE); + RETERR(dns_name_towire(&tkey->algorithm, &cctx, target)); + dns_compress_invalidate(&cctx); + + /* Inception: 32 bits */ + RETERR(uint32_tobuffer(tkey->inception, target)); + + /* Expire: 32 bits */ + RETERR(uint32_tobuffer(tkey->expire, target)); + + /* Mode: 16 bits */ + RETERR(uint16_tobuffer(tkey->mode, target)); + + /* Error: 16 bits */ + RETERR(uint16_tobuffer(tkey->error, target)); + + /* Key size: 16 bits */ + RETERR(uint16_tobuffer(tkey->keylen, target)); + + /* Key */ + if (tkey->keylen > 0) { + isc_buffer_available(target, &tr); + if (tr.length < tkey->keylen) + return (DNS_R_NOSPACE); + memcpy(tr.base, tkey->key, tkey->keylen); + isc_buffer_add(target, tkey->keylen); + } + + /* Other size: 16 bits */ + RETERR(uint16_tobuffer(tkey->otherlen, target)); + + /* Other data */ + if (tkey->otherlen > 0) { + isc_buffer_available(target, &tr); + if (tr.length < tkey->otherlen) + return (DNS_R_NOSPACE); + memcpy(tr.base, tkey->other, tkey->otherlen); + isc_buffer_add(target, tkey->otherlen); + } + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +tostruct_tkey(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + dns_rdata_generic_tkey_t *tkey; + dns_name_t alg; + isc_region_t sr; + + REQUIRE(rdata->type == 249); + + target = target; + mctx = mctx; + + tkey = (dns_rdata_generic_tkey_t *) target; + + tkey->common.rdclass = rdata->rdclass; + tkey->common.rdtype = rdata->type; + ISC_LINK_INIT(&tkey->common, link); + tkey->mctx = mctx; + dns_rdata_toregion(rdata, &sr); + + /* Algorithm Name */ + dns_name_init(&alg, NULL); + dns_name_fromregion(&alg, &sr); + dns_name_init(&tkey->algorithm, NULL); + RETERR(dns_name_dup(&alg, mctx, &tkey->algorithm)); + isc_region_consume(&sr, name_length(&tkey->algorithm)); + + /* Inception */ + if (sr.length < 4) + return (ISC_R_UNEXPECTEDEND); + tkey->inception = uint32_fromregion(&sr); + isc_region_consume(&sr, 4); + + /* Expire */ + if (sr.length < 4) + return (ISC_R_UNEXPECTEDEND); + tkey->expire = uint32_fromregion(&sr); + isc_region_consume(&sr, 4); + + /* Mode */ + if (sr.length < 2) + return (ISC_R_UNEXPECTEDEND); + tkey->mode = uint16_fromregion(&sr); + isc_region_consume(&sr, 2); + + /* Error */ + if (sr.length < 2) + return (ISC_R_UNEXPECTEDEND); + tkey->error = uint16_fromregion(&sr); + isc_region_consume(&sr, 2); + + /* Key size */ + if (sr.length < 2) + return (ISC_R_UNEXPECTEDEND); + tkey->keylen = uint16_fromregion(&sr); + isc_region_consume(&sr, 2); + + /* Key */ + if (tkey->keylen > 0) { + tkey->key = isc_mem_get(mctx, tkey->keylen); + if (tkey->key == NULL) + return (DNS_R_NOMEMORY); + memcpy(tkey->key, sr.base, tkey->keylen); + isc_region_consume(&sr, tkey->keylen); + } + else + tkey->key = NULL; + + /* Other size */ + if (sr.length < 2) + return (ISC_R_UNEXPECTEDEND); + tkey->otherlen = uint16_fromregion(&sr); + isc_region_consume(&sr, 2); + + /* Other */ + if (tkey->otherlen > 0) { + tkey->other = isc_mem_get(mctx, tkey->otherlen); + if (tkey->other == NULL) + return (DNS_R_NOMEMORY); + memcpy(tkey->other, sr.base, tkey->otherlen); + isc_region_consume(&sr, tkey->otherlen); + } + else + tkey->other = NULL; + + return (DNS_R_SUCCESS); +} + +static inline void +freestruct_tkey(void *source) { + dns_rdata_generic_tkey_t *tkey = (dns_rdata_generic_tkey_t *) source; + + REQUIRE(source != NULL); + + dns_name_free(&tkey->algorithm, tkey->mctx); + if (tkey->keylen > 0) + isc_mem_put(tkey->mctx, tkey->key, tkey->keylen); + if (tkey->otherlen > 0) + isc_mem_put(tkey->mctx, tkey->other, tkey->otherlen); +} + +static inline isc_result_t +additionaldata_tkey(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 249); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_tkey(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + + REQUIRE(rdata->type == 249); + + (void)digest; + (void)arg; + + return (DNS_R_NOTIMPLEMENTED); +} + +#endif /* RDATA_GENERIC_TKEY_249_C */ diff --git a/lib/dns/rdata/generic/tkey_249.h b/lib/dns/rdata/generic/tkey_249.h new file mode 100644 index 00000000..1db1df3e --- /dev/null +++ b/lib/dns/rdata/generic/tkey_249.h @@ -0,0 +1,35 @@ +/* + * 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: tkey_249.h,v 1.12 2000/02/03 23:43:08 halley Exp $ */ + + /* draft-ietf-dnsind-tkey-00.txt */ + +typedef struct dns_rdata_generic_tkey { + dns_rdatacommon_t common; + isc_mem_t * mctx; + dns_name_t algorithm; + isc_uint32_t inception; + isc_uint32_t expire; + isc_uint16_t mode; + isc_uint16_t error; + isc_uint16_t keylen; + unsigned char * key; + isc_uint16_t otherlen; + unsigned char * other; +} dns_rdata_generic_tkey_t; + diff --git a/lib/dns/rdata/generic/txt_16.c b/lib/dns/rdata/generic/txt_16.c new file mode 100644 index 00000000..ce96a7d9 --- /dev/null +++ b/lib/dns/rdata/generic/txt_16.c @@ -0,0 +1,177 @@ +/* + * 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: txt_16.c,v 1.19 2000/02/03 23:43:08 halley Exp $ */ + +#ifndef RDATA_GENERIC_TXT_16_C +#define RDATA_GENERIC_TXT_16_C + +static inline isc_result_t +fromtext_txt(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; + + REQUIRE(type == 16); + + rdclass = rdclass; /*unused*/ + origin = origin; /*unused*/ + downcase = downcase; /*unused*/ + + do { + RETERR(gettoken(lexer, &token, isc_tokentype_qstring, + ISC_TRUE)); + if (token.type != isc_tokentype_qstring && + token.type != isc_tokentype_string) + break; + RETERR(txt_fromtext(&token.value.as_textregion, target)); + } while (1); + /* Let upper layer handle eol/eof. */ + isc_lex_ungettoken(lexer, &token); + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +totext_txt(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t region; + + REQUIRE(rdata->type == 16); + + tctx = tctx; /*unused*/ + + dns_rdata_toregion(rdata, ®ion); + + while (region.length) { + RETERR(txt_totext(®ion, target)); + if (region.length) + RETERR(str_totext(" ", target)); + } + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +fromwire_txt(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_result_t result; + + REQUIRE(type == 16); + + dctx = dctx; /*unused*/ + rdclass = rdclass; /*unused*/ + downcase = downcase; /*unused*/ + + while (!buffer_empty(source)) { + result = txt_fromwire(source, target); + if (result != DNS_R_SUCCESS) + return (result); + } + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +towire_txt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + isc_region_t region; + + REQUIRE(rdata->type == 16); + + 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, rdata->length); + return (DNS_R_SUCCESS); +} + +static inline int +compare_txt(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 == 16); + + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + return (compare_region(&r1, &r2)); +} + +static inline isc_result_t +fromstruct_txt(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 16); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_txt(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 16); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_txt(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); +} + +static inline isc_result_t +additionaldata_txt(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 16); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_txt(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + + REQUIRE(rdata->type == 16); + + dns_rdata_toregion(rdata, &r); + + return ((digest)(arg, &r)); +} + +#endif /* RDATA_GENERIC_TXT_16_C */ diff --git a/lib/dns/rdata/generic/txt_16.h b/lib/dns/rdata/generic/txt_16.h new file mode 100644 index 00000000..451f46e0 --- /dev/null +++ b/lib/dns/rdata/generic/txt_16.h @@ -0,0 +1,19 @@ +/* + * 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: txt_16.h,v 1.13 2000/02/03 23:43:08 halley Exp $ */ + diff --git a/lib/dns/rdata/generic/unspec_103.c b/lib/dns/rdata/generic/unspec_103.c new file mode 100644 index 00000000..f46603cb --- /dev/null +++ b/lib/dns/rdata/generic/unspec_103.c @@ -0,0 +1,147 @@ +/* + * 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: unspec_103.c,v 1.11 2000/02/03 23:43:09 halley Exp $ */ + +#ifndef RDATA_GENERIC_UNSPEC_103_C +#define RDATA_GENERIC_UNSPEC_103_C + +static inline isc_result_t +fromtext_unspec(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_lex_t *lexer, dns_name_t *origin, + isc_boolean_t downcase, isc_buffer_t *target) +{ + + REQUIRE(type == 103); + + rdclass = rdclass; /*unused*/ + origin = origin; /*unused*/ + downcase = downcase; /*unused*/ + + return (atob_tobuffer(lexer, target)); +} + +static inline isc_result_t +totext_unspec(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + + + REQUIRE(rdata->type == 103); + + tctx = tctx; /*unused*/ + + return (btoa_totext(rdata->data, rdata->length, target)); +} + +static inline isc_result_t +fromwire_unspec(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; + + REQUIRE(type == 103); + + rdclass = rdclass; /*unused*/ + dctx = dctx; /*unused*/ + downcase = downcase; /*unused*/ + isc_buffer_active(source, &sr); + isc_buffer_forward(source, sr.length); + return (mem_tobuffer(target, sr.base, sr.length)); +} + +static inline isc_result_t +towire_unspec(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + + REQUIRE(rdata->type == 103); + + cctx = cctx; /*unused*/ + + return (mem_tobuffer(target, rdata->data, rdata->length)); +} + +static inline int +compare_unspec(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + isc_region_t r1; + isc_region_t r2; + + REQUIRE(rdata1->type == rdata1->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 103); + + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + return (compare_region(&r1, &r2)); +} + +static inline isc_result_t +fromstruct_unspec(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 103); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_unspec(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 103); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_unspec(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ +} + +static inline isc_result_t +additionaldata_unspec(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 103); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_unspec(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + + REQUIRE(rdata->type == 103); + + dns_rdata_toregion(rdata, &r); + + return ((digest)(arg, &r)); +} + +#endif /* RDATA_GENERIC_UNSPEC_103_C */ diff --git a/lib/dns/rdata/generic/unspec_103.h b/lib/dns/rdata/generic/unspec_103.h new file mode 100644 index 00000000..5ebc11f8 --- /dev/null +++ b/lib/dns/rdata/generic/unspec_103.h @@ -0,0 +1,19 @@ +/* + * 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: unspec_103.h,v 1.6 2000/02/03 23:43:09 halley Exp $ */ + diff --git a/lib/dns/rdata/generic/x25_19.c b/lib/dns/rdata/generic/x25_19.c new file mode 100644 index 00000000..041fe979 --- /dev/null +++ b/lib/dns/rdata/generic/x25_19.c @@ -0,0 +1,163 @@ +/* + * 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: x25_19.c,v 1.11 2000/02/03 23:43:09 halley Exp $ */ + + /* RFC 1183 */ + +#ifndef RDATA_GENERIC_X25_19_C +#define RDATA_GENERIC_X25_19_C + +#include <ctype.h> + +static inline isc_result_t +fromtext_x25(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 int i; + + REQUIRE(type == 19); + + rdclass = rdclass; /*unused*/ + origin = origin; /*unused*/ + downcase = downcase; /*unused*/ + + RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_FALSE)); + for (i = 0; i < token.value.as_textregion.length; i++) + if (!isascii(token.value.as_textregion.base[i]&0xff) || + !isdigit(token.value.as_textregion.base[i]&0xff)) + return (DNS_R_RANGE); + return (txt_fromtext(&token.value.as_textregion, target)); +} + +static inline isc_result_t +totext_x25(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, + isc_buffer_t *target) +{ + isc_region_t region; + + REQUIRE(rdata->type == 19); + + tctx = tctx; /*unused*/ + + dns_rdata_toregion(rdata, ®ion); + return (txt_totext(®ion, target)); +} + +static inline isc_result_t +fromwire_x25(dns_rdataclass_t rdclass, dns_rdatatype_t type, + isc_buffer_t *source, dns_decompress_t *dctx, + isc_boolean_t downcase, isc_buffer_t *target) +{ + + REQUIRE(type == 19); + + dctx = dctx; /* unused */ + rdclass = rdclass; /* unused */ + downcase = downcase; /* unused */ + + return (txt_fromwire(source, target)); +} + +static inline isc_result_t +towire_x25(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { + + REQUIRE(rdata->type == 19); + + cctx = cctx; + + return (mem_tobuffer(target, rdata->data, rdata->length)); +} + +static inline int +compare_x25(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { + int l; + int result; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 19); + + l = (rdata1->length < rdata2->length) ? rdata1->length : rdata2->length; + result = memcmp(rdata1->data, rdata2->data, l); + + if (result != 0) + result = (result < 0) ? -1 : 1; + else if (rdata1->length != rdata2->length) + result = (rdata1->length < rdata2->length) ? -1 : 1; + + return (result); +} + +static inline isc_result_t +fromstruct_x25(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, + isc_buffer_t *target) +{ + + REQUIRE(type == 19); + + rdclass = rdclass; /*unused*/ + + source = source; + target = target; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline isc_result_t +tostruct_x25(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + + REQUIRE(rdata->type == 19); + + target = target; + mctx = mctx; + + return (DNS_R_NOTIMPLEMENTED); +} + +static inline void +freestruct_x25(void *source) { + REQUIRE(source != NULL); + REQUIRE(ISC_FALSE); /*XXX*/ +} + +static inline isc_result_t +additionaldata_x25(dns_rdata_t *rdata, dns_additionaldatafunc_t add, + void *arg) +{ + REQUIRE(rdata->type == 19); + + (void)add; + (void)arg; + + return (DNS_R_SUCCESS); +} + +static inline isc_result_t +digest_x25(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { + isc_region_t r; + + REQUIRE(rdata->type == 19); + + dns_rdata_toregion(rdata, &r); + + return ((digest)(arg, &r)); +} + +#endif /* RDATA_GENERIC_X25_19_C */ diff --git a/lib/dns/rdata/generic/x25_19.h b/lib/dns/rdata/generic/x25_19.h new file mode 100644 index 00000000..ed95f748 --- /dev/null +++ b/lib/dns/rdata/generic/x25_19.h @@ -0,0 +1,21 @@ +/* + * 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: x25_19.h,v 1.6 2000/02/03 23:43:09 halley Exp $ */ + + /* RFC 1183 */ + |