*** bind-9.2.5/lib/dns/master.c.~1~ 2004-03-09 07:11:03.000000000 +0100 --- bind-9.2.5/lib/dns/master.c 2005-05-16 15:00:21.000000000 +0200 *************** *** 662,667 **** --- 662,668 ---- case dns_rdatatype_a: case dns_rdatatype_aaaa: if (lctx->zclass == dns_rdataclass_in || + lctx->zclass == dns_rdataclass_ch || lctx->zclass == dns_rdataclass_hs) break; /* FALLTHROUGH */ *** bind-9.2.5/lib/dns/gen.c.~1~ 2004-03-15 05:45:00.000000000 +0100 --- bind-9.2.5/lib/dns/gen.c 2005-05-16 15:00:21.000000000 +0200 *************** *** 820,825 **** --- 820,826 ---- } else if (cc->rdclass == 255) { PRINTCLASS("none", 254); } + if (cc->rdclass != 3) PRINTCLASS(cc->classname, cc->rdclass); } *** /dev/null 2005-05-16 08:20:01.323955288 +0200 --- bind-9.2.5/lib/dns/rdata/ch_3/a_1.c 2005-05-16 16:24:16.000000000 +0200 *************** *** 0 **** --- 1,286 ---- + /* + * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 1999-2002 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 ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + + /* by Bjorn.Victor@it.uu.se, 2005-05-07 */ + /* Based on generic/soa_6.c and generic/mx_15.c */ + + #ifndef RDATA_CH_3_A_1_C + #define RDATA_CH_3_A_1_C + + #include + + #define RRTYPE_A_ATTRIBUTES (0) + + static inline isc_result_t + fromtext_ch_a(ARGS_FROMTEXT) { + isc_token_t token; + dns_name_t name; + isc_buffer_t buffer; + + REQUIRE(type == 1); + REQUIRE(rdclass == dns_rdataclass_ch); /* 3 */ + + UNUSED(type); + UNUSED(callbacks); + + RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, + ISC_FALSE)); + + /* get domain name */ + dns_name_init(&name, NULL); + buffer_fromregion(&buffer, &token.value.as_region); + origin = (origin != NULL) ? origin : dns_rootname; + RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + + /* 16-bit octal address */ + RETERR(isc_lex_getoctaltoken(lexer, &token, ISC_FALSE)); + if (token.value.as_ulong > 0xffff) + RETTOK(ISC_R_RANGE); + return (uint16_tobuffer(token.value.as_ulong, target)); + } + + static inline isc_result_t + totext_ch_a(ARGS_TOTEXT) { + isc_region_t region; + dns_name_t name; + dns_name_t prefix; + isc_boolean_t sub; + char buf[sizeof("0177777")]; + isc_uint16_t addr; + + REQUIRE(rdata->type == 1); + REQUIRE(rdata->rdclass == dns_rdataclass_ch); /* 3 */ + REQUIRE(rdata->length != 0); + + dns_name_init(&name, NULL); + dns_name_init(&prefix, NULL); + + dns_rdata_toregion(rdata, ®ion); + dns_name_fromregion(&name, ®ion); + isc_region_consume(®ion, name_length(&name)); + addr = uint16_fromregion(®ion); + + sub = name_prefix(&name, tctx->origin, &prefix); + RETERR(dns_name_totext(&prefix, sub, target)); + + sprintf(buf, "%o", addr); /* note octal */ + RETERR(str_totext(" ", target)); + return (str_totext(buf, target)); + } + + static inline isc_result_t + fromwire_ch_a(ARGS_FROMWIRE) { + isc_region_t sregion; + isc_region_t tregion; + dns_name_t name; + + REQUIRE(type == 1); + REQUIRE(rdclass == dns_rdataclass_ch); + + UNUSED(type); + UNUSED(rdclass); + + dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); + + dns_name_init(&name, NULL); + + RETERR(dns_name_fromwire(&name, source, dctx, downcase, target)); + + isc_buffer_activeregion(source, &sregion); + isc_buffer_availableregion(target, &tregion); + if (sregion.length < 2) + return (ISC_R_UNEXPECTEDEND); + if (tregion.length < 2) + return (ISC_R_NOSPACE); + + memcpy(tregion.base, sregion.base, 2); + isc_buffer_forward(source, 2); + isc_buffer_add(target, 2); + + return (ISC_R_SUCCESS); + } + + static inline isc_result_t + towire_ch_a(ARGS_TOWIRE) { + dns_name_t name; + dns_offsets_t offsets; + isc_region_t sregion; + isc_region_t tregion; + + REQUIRE(rdata->type == 1); + REQUIRE(rdata->rdclass == dns_rdataclass_ch); + REQUIRE(rdata->length != 0); + + dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); + + dns_name_init(&name, offsets); + + dns_rdata_toregion(rdata, &sregion); + + dns_name_fromregion(&name, &sregion); + isc_region_consume(&sregion, name_length(&name)); + RETERR(dns_name_towire(&name, cctx, target)); + + isc_buffer_availableregion(target, &tregion); + if (tregion.length < 2) + return (ISC_R_NOSPACE); + + memcpy(tregion.base, sregion.base, 2); + isc_buffer_add(target, 2); + return (ISC_R_SUCCESS); + } + + static inline int + compare_ch_a(ARGS_COMPARE) { + dns_name_t name1; + dns_name_t name2; + isc_region_t region1; + isc_region_t region2; + int order; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == 1); + REQUIRE(rdata1->rdclass == dns_rdataclass_ch); + REQUIRE(rdata1->length != 0); + REQUIRE(rdata2->length != 0); + + 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); + isc_region_consume(®ion1, name_length(&name1)); + isc_region_consume(®ion2, name_length(&name2)); + + order = dns_name_rdatacompare(&name1, &name2); + if (order != 0) + return (order); + + order = memcmp(rdata1->data, rdata2->data, 2); + if (order != 0) + order = (order < 0) ? -1 : 1; + return (order); + } + + static inline isc_result_t + fromstruct_ch_a(ARGS_FROMSTRUCT) { + dns_rdata_ch_a_t *a = source; + isc_region_t region; + + REQUIRE(type == 1); + REQUIRE(source != NULL); + REQUIRE(a->common.rdtype == type); + REQUIRE(a->common.rdclass == rdclass); + + UNUSED(type); + UNUSED(rdclass); + + dns_name_toregion(&a->ch_addr_dom, ®ion); + RETERR(isc_buffer_copyregion(target, ®ion)); + + return (uint16_tobuffer(ntohs(a->ch_addr), target)); + } + + static inline isc_result_t + tostruct_ch_a(ARGS_TOSTRUCT) { + dns_rdata_ch_a_t *a = target; + isc_region_t region; + dns_name_t name; + + REQUIRE(rdata->type == 1); + REQUIRE(rdata->rdclass == dns_rdataclass_ch); + REQUIRE(rdata->length != 0); + + a->common.rdclass = rdata->rdclass; + a->common.rdtype = rdata->type; + ISC_LINK_INIT(&a->common, link); + + dns_rdata_toregion(rdata, ®ion); + + dns_name_init(&name, NULL); + dns_name_fromregion(&name, ®ion); + isc_region_consume(®ion, name_length(&name)); + + dns_name_init(&a->ch_addr_dom, NULL); + RETERR(name_duporclone(&name, mctx, &a->ch_addr_dom)); + a->ch_addr = htons(uint16_fromregion(®ion)); + a->mctx = mctx; + return (ISC_R_SUCCESS); + } + + static inline void + freestruct_ch_a(ARGS_FREESTRUCT) { + dns_rdata_ch_a_t *a = source; + + REQUIRE(source != NULL); + REQUIRE(a->common.rdtype == 1); + + if (a->mctx == NULL) + return; + + dns_name_free(&a->ch_addr_dom, a->mctx); + a->mctx = NULL; + } + + static inline isc_result_t + additionaldata_ch_a(ARGS_ADDLDATA) { + #ifdef DNS_CHAOS_A_NS + dns_name_t name; + dns_offsets_t offsets; + isc_region_t region; + #endif + + REQUIRE(rdata->type == 1); + REQUIRE(rdata->rdclass == dns_rdataclass_ch); + + #ifdef DNS_CHAOS_A_NS + dns_name_init(&name, offsets); + dns_rdata_toregion(rdata, ®ion); + dns_name_fromregion(&name, ®ion); + + return ((add)(arg, &name, dns_rdatatype_ns)); + #else + UNUSED(rdata); + UNUSED(add); + UNUSED(arg); + + return (ISC_R_SUCCESS); + #endif + } + + static inline isc_result_t + digest_ch_a(ARGS_DIGEST) { + isc_region_t r; + + dns_name_t name; + + REQUIRE(rdata->type == 1); + REQUIRE(rdata->rdclass == dns_rdataclass_ch); + + dns_rdata_toregion(rdata, &r); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, &r); + isc_region_consume(&r, name_length(&name)); + RETERR(dns_name_digest(&name, digest, arg)); + return ((digest)(arg, &r)); + } + + #endif /* RDATA_CH_3_A_1_C */ *** /dev/null 2005-05-16 08:20:01.323955288 +0200 --- bind-9.2.5/lib/dns/rdata/ch_3/a_1.h 2005-05-16 15:00:21.000000000 +0200 *************** *** 0 **** --- 1,33 ---- + /* + * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 1999-2001 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 ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + + /* by Bjorn.Victor@it.uu.se, 2005-05-07 */ + /* Based on generic/mx_15.h */ + + #ifndef CH_3_A_1_H + #define CH_3_A_1_H 1 + + typedef isc_uint16_t ch_addr_t; + + typedef struct dns_rdata_ch_a { + dns_rdatacommon_t common; + isc_mem_t *mctx; + dns_name_t ch_addr_dom; /* ch-addr domain for back mapping */ + ch_addr_t ch_addr; /* chaos address (16 bit) */ + } dns_rdata_ch_a_t; + + #endif /* CH_3_A_1_H */ *** bind-9.2.5/lib/isc/lex.c.~1~ 2004-03-09 07:11:47.000000000 +0100 --- bind-9.2.5/lib/isc/lex.c 2005-05-16 16:26:11.000000000 +0200 *************** *** 565,571 **** } else if (isdigit((unsigned char)c) && (options & ISC_LEXOPT_NUMBER) != 0) { lex->last_was_eol = ISC_FALSE; ! state = lexstate_number; goto no_read; } else { lex->last_was_eol = ISC_FALSE; --- 565,575 ---- } else if (isdigit((unsigned char)c) && (options & ISC_LEXOPT_NUMBER) != 0) { lex->last_was_eol = ISC_FALSE; ! if ((options & ISC_LEXOPT_OCTAL) != 0 && ! (c == '8' || c == '9')) ! state = lexstate_string; ! else ! state = lexstate_number; goto no_read; } else { lex->last_was_eol = ISC_FALSE; *************** *** 586,592 **** c == '\n' || c == EOF || lex->specials[c]) { int base; ! if ((options & ISC_LEXOPT_CNUMBER) != 0) base = 0; else base = 10; --- 590,598 ---- c == '\n' || c == EOF || lex->specials[c]) { int base; ! if ((options & ISC_LEXOPT_OCTAL) != 0) ! base = 8; ! else if ((options & ISC_LEXOPT_CNUMBER) != 0) base = 0; else base = 10; *************** *** 621,626 **** --- 627,635 ---- (lex->data[0] != '0'))) { /* Above test supports hex numbers */ state = lexstate_string; + } else if ((options & ISC_LEXOPT_OCTAL) != 0 && + (c == '8' || c == '9')) { + state = lexstate_string; } } if (remaining == 0U) { *************** *** 819,824 **** --- 828,860 ---- return (ISC_R_SUCCESS); } + isc_result_t + isc_lex_getoctaltoken(isc_lex_t *lex, isc_token_t *token, isc_boolean_t eol) + { + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF | + ISC_LEXOPT_DNSMULTILINE | ISC_LEXOPT_ESCAPE| + ISC_LEXOPT_NUMBER | ISC_LEXOPT_OCTAL; + isc_result_t result; + + result = isc_lex_gettoken(lex, options, token); + if (result == ISC_R_RANGE) + isc_lex_ungettoken(lex, token); + if (result != ISC_R_SUCCESS) + return (result); + + if (eol && ((token->type == isc_tokentype_eol) || + (token->type == isc_tokentype_eof))) + return (ISC_R_SUCCESS); + if (token->type != isc_tokentype_number) { + isc_lex_ungettoken(lex, token); + if (token->type == isc_tokentype_eol || + token->type == isc_tokentype_eof) + return (ISC_R_UNEXPECTEDEND); + return (ISC_R_BADNUMBER); + } + return (ISC_R_SUCCESS); + } + void isc_lex_ungettoken(isc_lex_t *lex, isc_token_t *tokenp) { inputsource *source; *** bind-9.2.5/lib/isc/include/isc/lex.h.~1~ 2004-03-09 07:11:57.000000000 +0100 --- bind-9.2.5/lib/isc/include/isc/lex.h 2005-05-16 16:26:29.000000000 +0200 *************** *** 88,93 **** --- 88,94 ---- #define ISC_LEXOPT_CNUMBER 0x80 /* Regognise octal and hex */ #define ISC_LEXOPT_ESCAPE 0x100 /* Recognize escapes. */ #define ISC_LEXOPT_QSTRINGMULTILINE 0x200 /* Allow multiline "" strings */ + #define ISC_LEXOPT_OCTAL 0x400 /* Expect a octal number. */ /* * Various commenting styles, which may be changed at any time with *************** *** 311,316 **** --- 312,334 ---- * unexpected tokens. * * Requires: + *\li 'lex' is a valid lexer. + * + *\li 'token' is a valid pointer + * + * Returns: + * + * \li any return code from isc_lex_gettoken(). + */ + + isc_result_t + isc_lex_getoctaltoken(isc_lex_t *lex, isc_token_t *token, isc_boolean_t eol); + /* + * Get the next token from a DNS master file type stream. This is a + * convenience function that sets appropriate options and handles end + * of line correctly for master files. It also ungets unexpected tokens. + * + * Requires: * 'lex' is a valid lexer. * * 'token' is a valid pointer