diff options
Diffstat (limited to 'lib/dns')
131 files changed, 4120 insertions, 2270 deletions
diff --git a/lib/dns/adb.c b/lib/dns/adb.c index da77bb6c92a5..ec4af599da93 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -30,6 +30,7 @@ #include <isc/mutexblock.h> #include <isc/netaddr.h> +#include <isc/print.h> #include <isc/random.h> #include <isc/stats.h> #include <isc/string.h> /* Required for HP/UX (and others?) */ @@ -162,6 +163,14 @@ struct dns_adb { isc_boolean_t growentries_sent; isc_event_t grownames; isc_boolean_t grownames_sent; + +#ifdef ENABLE_FETCHLIMIT + isc_uint32_t quota; + isc_uint32_t atr_freq; + double atr_low; + double atr_high; + double atr_discount; +#endif /* ENABLE_FETCHLIMIT */ }; /* @@ -238,9 +247,21 @@ struct dns_adbentry { int lock_bucket; unsigned int refcnt; + unsigned int nh; unsigned int flags; unsigned int srtt; + + unsigned int timeouts; + unsigned int completed; + +#ifdef ENABLE_FETCHLIMIT + isc_uint8_t mode; + isc_uint32_t quota; + isc_uint32_t active; + double atr; +#endif /* ENABLE_FETCHLIMIT */ + isc_sockaddr_t sockaddr; isc_stdtime_t expires; @@ -285,6 +306,7 @@ static inline dns_adbentry_t *find_entry_and_lock(dns_adb_t *, static void dump_adb(dns_adb_t *, FILE *, isc_boolean_t debug, isc_stdtime_t); static void print_dns_name(FILE *, dns_name_t *); static void print_namehook_list(FILE *, const char *legend, + dns_adb_t *adb, dns_adbnamehooklist_t *list, isc_boolean_t debug, isc_stdtime_t now); @@ -320,10 +342,15 @@ static inline void link_entry(dns_adb_t *, int, dns_adbentry_t *); static inline isc_boolean_t unlink_entry(dns_adb_t *, dns_adbentry_t *); static isc_boolean_t kill_name(dns_adbname_t **, isc_eventtype_t); static void water(void *, int); -static void dump_entry(FILE *, dns_adbentry_t *, isc_boolean_t, isc_stdtime_t); +static void dump_entry(FILE *, dns_adb_t *, dns_adbentry_t *, + isc_boolean_t, isc_stdtime_t); static void adjustsrtt(dns_adbaddrinfo_t *addr, unsigned int rtt, unsigned int factor, isc_stdtime_t now); static void shutdown_task(isc_task_t *task, isc_event_t *ev); +#ifdef ENABLE_FETCHLIMIT +static void log_quota(dns_adbentry_t *entry, const char *fmt, ...) + ISC_FORMAT_PRINTF(2, 3); +#endif /* ENABLE_FETCHLIMIT */ /* * MUST NOT overlap DNS_ADBFIND_* flags! @@ -887,6 +914,7 @@ import_rdataset(dns_adbname_t *adbname, dns_rdataset_t *rdataset, entry->sockaddr = sockaddr; entry->refcnt = 1; + entry->nh = 1; nh->entry = entry; @@ -899,6 +927,7 @@ import_rdataset(dns_adbname_t *adbname, dns_rdataset_t *rdataset, break; if (anh == NULL) { foundentry->refcnt++; + foundentry->nh++; nh->entry = foundentry; } else free_adbnamehook(adb, &nh); @@ -1293,6 +1322,7 @@ clean_namehooks(dns_adb_t *adb, dns_adbnamehooklist_t *namehooks) { LOCK(&adb->entrylocks[addr_bucket]); } + entry->nh--; result = dec_entry_refcnt(adb, overmem, entry, ISC_FALSE); } @@ -1479,6 +1509,7 @@ clean_finds_at_name(dns_adbname_t *name, isc_eventtype_t evtype, ev, task, find); isc_task_sendanddetach(&task, (isc_event_t **)&ev); + find->flags |= FIND_EVENT_SENT; } else { DP(DEF_LEVEL, "cfan: skipping find %p", find); } @@ -1759,11 +1790,20 @@ new_adbentry(dns_adb_t *adb) { e->magic = DNS_ADBENTRY_MAGIC; e->lock_bucket = DNS_ADB_INVALIDBUCKET; e->refcnt = 0; + e->nh = 0; e->flags = 0; + e->completed = 0; + e->timeouts = 0; isc_random_get(&r); e->srtt = (r & 0x1f) + 1; e->lastage = 0; e->expires = 0; +#ifdef ENABLE_FETCHLIMIT + e->active = 0; + e->mode = 0; + e->quota = adb->quota; + e->atr = 0.0; +#endif /* ENABLE_FETCHLIMIT */ ISC_LIST_INIT(e->lameinfo); ISC_LINK_INIT(e, plink); LOCK(&adb->entriescntlock); @@ -2072,6 +2112,27 @@ entry_is_lame(dns_adb_t *adb, dns_adbentry_t *entry, dns_name_t *qname, return (is_bad); } +#ifdef ENABLE_FETCHLIMIT +static void +log_quota(dns_adbentry_t *entry, const char *fmt, ...) { + va_list ap; + char msgbuf[2048]; + char addrbuf[ISC_NETADDR_FORMATSIZE]; + isc_netaddr_t netaddr; + + va_start(ap, fmt); + vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap); + va_end(ap); + + isc_netaddr_fromsockaddr(&netaddr, &entry->sockaddr); + isc_netaddr_format(&netaddr, addrbuf, sizeof(addrbuf)); + + isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_ADB, + ISC_LOG_INFO, "adb: quota %s (%d/%d): %s", + addrbuf, entry->active, entry->quota, msgbuf); +} +#endif /* ENABLE_FETCHLIMIT */ + static void copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find, dns_name_t *qname, dns_rdatatype_t qtype, dns_adbname_t *name, @@ -2092,6 +2153,17 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find, dns_name_t *qname, INSIST(bucket != DNS_ADB_INVALIDBUCKET); LOCK(&adb->entrylocks[bucket]); +#ifdef ENABLE_FETCHLIMIT + if (entry->quota != 0 && + entry->active >= entry->quota) + { + find->options |= + (DNS_ADBFIND_LAMEPRUNED| + DNS_ADBFIND_OVERQUOTA); + goto nextv4; + } +#endif /* ENABLE_FETCHLIMIT */ + if (!FIND_RETURNLAME(find) && entry_is_lame(adb, entry, qname, qtype, now)) { find->options |= DNS_ADBFIND_LAMEPRUNED; @@ -2123,6 +2195,17 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find, dns_name_t *qname, INSIST(bucket != DNS_ADB_INVALIDBUCKET); LOCK(&adb->entrylocks[bucket]); +#ifdef ENABLE_FETCHLIMIT + if (entry->quota != 0 && + entry->active >= entry->quota) + { + find->options |= + (DNS_ADBFIND_LAMEPRUNED| + DNS_ADBFIND_OVERQUOTA); + goto nextv6; + } +#endif /* ENABLE_FETCHLIMIT */ + if (!FIND_RETURNLAME(find) && entry_is_lame(adb, entry, qname, qtype, now)) { find->options |= DNS_ADBFIND_LAMEPRUNED; @@ -2455,6 +2538,14 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_timermgr_t *timermgr, adb, NULL, NULL); adb->growentries_sent = ISC_FALSE; +#ifdef ENABLE_FETCHLIMIT + adb->quota = 0; + adb->atr_freq = 0; + adb->atr_low = 0.0; + adb->atr_high = 0.0; + adb->atr_discount = 0.0; +#endif /* ENABLE_FETCHLIMIT */ + adb->nnames = nbuckets[0]; adb->namescnt = 0; adb->names = NULL; @@ -2474,7 +2565,6 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_timermgr_t *timermgr, nbuckets[11]); adb->nentries = nbuckets[11]; adb->nnames = nbuckets[11]; - } isc_mem_attach(mem, &adb->mctx); @@ -2667,6 +2757,8 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_timermgr_t *timermgr, fail0c: DESTROYLOCK(&adb->lock); fail0b: + if (adb->excl != NULL) + isc_task_detach(&adb->excl); isc_mem_putanddetach(&adb->mctx, adb, sizeof(dns_adb_t)); return (result); @@ -3349,14 +3441,15 @@ dump_adb(dns_adb_t *adb, FILE *f, isc_boolean_t debug, isc_stdtime_t now) { fprintf(f, "\n"); - print_namehook_list(f, "v4", &name->v4, debug, now); - print_namehook_list(f, "v6", &name->v6, debug, now); + print_namehook_list(f, "v4", adb, + &name->v4, debug, now); + print_namehook_list(f, "v6", adb, + &name->v6, debug, now); if (debug) print_fetch_list(f, name); if (debug) print_find_list(f, name); - } } @@ -3365,8 +3458,8 @@ dump_adb(dns_adb_t *adb, FILE *f, isc_boolean_t debug, isc_stdtime_t now) { for (i = 0; i < adb->nentries; i++) { entry = ISC_LIST_HEAD(adb->entries[i]); while (entry != NULL) { - if (entry->refcnt == 0) - dump_entry(f, entry, debug, now); + if (entry->nh == 0) + dump_entry(f, adb, entry, debug, now); entry = ISC_LIST_NEXT(entry, plink); } } @@ -3381,14 +3474,18 @@ dump_adb(dns_adb_t *adb, FILE *f, isc_boolean_t debug, isc_stdtime_t now) { } static void -dump_entry(FILE *f, dns_adbentry_t *entry, isc_boolean_t debug, - isc_stdtime_t now) +dump_entry(FILE *f, dns_adb_t *adb, dns_adbentry_t *entry, + isc_boolean_t debug, isc_stdtime_t now) { char addrbuf[ISC_NETADDR_FORMATSIZE]; char typebuf[DNS_RDATATYPE_FORMATSIZE]; isc_netaddr_t netaddr; dns_adblameinfo_t *li; +#ifndef ENABLE_FETCHLIMIT + UNUSED(adb); +#endif /* !ENABLE_FETCHLIMIT */ + isc_netaddr_fromsockaddr(&netaddr, &entry->sockaddr); isc_netaddr_format(&netaddr, addrbuf, sizeof(addrbuf)); @@ -3399,10 +3496,19 @@ dump_entry(FILE *f, dns_adbentry_t *entry, isc_boolean_t debug, addrbuf, entry->srtt, entry->flags); if (entry->expires != 0) fprintf(f, " [ttl %d]", entry->expires - now); + +#ifdef ENABLE_FETCHLIMIT + if (adb != NULL && adb->quota != 0 && adb->atr_freq != 0) { + fprintf(f, " [atr %0.2f] [quota %d]", + entry->atr, entry->quota); + } +#endif /* ENABLE_FETCHLIMIT */ + fprintf(f, "\n"); for (li = ISC_LIST_HEAD(entry->lameinfo); li != NULL; - li = ISC_LIST_NEXT(li, plink)) { + li = ISC_LIST_NEXT(li, plink)) + { fprintf(f, ";\t\t"); print_dns_name(f, &li->qname); dns_rdatatype_format(li->qtype, typebuf, sizeof(typebuf)); @@ -3474,7 +3580,8 @@ print_dns_name(FILE *f, dns_name_t *name) { } static void -print_namehook_list(FILE *f, const char *legend, dns_adbnamehooklist_t *list, +print_namehook_list(FILE *f, const char *legend, + dns_adb_t *adb, dns_adbnamehooklist_t *list, isc_boolean_t debug, isc_stdtime_t now) { dns_adbnamehook_t *nh; @@ -3485,7 +3592,7 @@ print_namehook_list(FILE *f, const char *legend, dns_adbnamehooklist_t *list, { if (debug) fprintf(f, ";\tHook(%s) %p\n", legend, nh); - dump_entry(f, nh->entry, debug, now); + dump_entry(f, adb, nh->entry, debug, now); } } @@ -4051,6 +4158,114 @@ dns_adb_changeflags(dns_adb_t *adb, dns_adbaddrinfo_t *addr, UNLOCK(&adb->entrylocks[bucket]); } +#ifdef ENABLE_FETCHLIMIT +/* + * (10000 / ((10 + n) / 10)^(3/2)) for n in 0..99. + * These will be used to make quota adjustments. + */ +static int quota_adj[] = { + 10000, 8668, 7607, 6747, 6037, 5443, 4941, 4512, 4141, + 3818, 3536, 3286, 3065, 2867, 2690, 2530, 2385, 2254, + 2134, 2025, 1925, 1832, 1747, 1668, 1595, 1527, 1464, + 1405, 1350, 1298, 1250, 1205, 1162, 1121, 1083, 1048, + 1014, 981, 922, 894, 868, 843, 820, 797, 775, 755, + 735, 716, 698, 680, 664, 648, 632, 618, 603, 590, 577, + 564, 552, 540, 529, 518, 507, 497, 487, 477, 468, 459, + 450, 442, 434, 426, 418, 411, 404, 397, 390, 383, 377, + 370, 364, 358, 353, 347, 342, 336, 331, 326, 321, 316, + 312, 307, 303, 298, 294, 290, 286, 282, 278 +}; + +/* + * Caller must hold adbentry lock + */ +static void +maybe_adjust_quota(dns_adb_t *adb, dns_adbaddrinfo_t *addr, + isc_boolean_t timeout) +{ + double tr; + + UNUSED(adb); + + if (adb->quota == 0 || adb->atr_freq == 0) + return; + + if (timeout) + addr->entry->timeouts++; + + if (addr->entry->completed++ <= adb->atr_freq) + return; + + /* + * Calculate an exponential rolling average of the timeout ratio + * + * XXX: Integer arithmetic might be better than floating point + */ + tr = (double) addr->entry->timeouts / addr->entry->completed; + addr->entry->timeouts = addr->entry->completed = 0; + INSIST(addr->entry->atr >= 0.0); + INSIST(addr->entry->atr <= 1.0); + INSIST(adb->atr_discount >= 0.0); + INSIST(adb->atr_discount <= 1.0); + addr->entry->atr *= 1.0 - adb->atr_discount; + addr->entry->atr += tr * adb->atr_discount; + addr->entry->atr = ISC_CLAMP(addr->entry->atr, 0.0, 1.0); + + if (addr->entry->atr < adb->atr_low && addr->entry->mode > 0) { + addr->entry->quota = adb->quota * + quota_adj[--addr->entry->mode] / 10000; + log_quota(addr->entry, "atr %0.2f, quota increased to %d", + addr->entry->atr, addr->entry->quota); + } else if (addr->entry->atr > adb->atr_high && addr->entry->mode < 99) { + addr->entry->quota = adb->quota * + quota_adj[++addr->entry->mode] / 10000; + log_quota(addr->entry, "atr %0.2f, quota decreased to %d", + addr->entry->atr, addr->entry->quota); + } + + /* Ensure we don't drop to zero */ + if (addr->entry->quota == 0) + addr->entry->quota = 1; +} +#endif /* ENABLE_FETCHLIMIT */ + +void +dns_adb_plainresponse(dns_adb_t *adb, dns_adbaddrinfo_t *addr) { + int bucket; + + REQUIRE(DNS_ADB_VALID(adb)); + REQUIRE(DNS_ADBADDRINFO_VALID(addr)); + + bucket = addr->entry->lock_bucket; + LOCK(&adb->entrylocks[bucket]); + +#ifdef ENABLE_FETCHLIMIT + maybe_adjust_quota(adb, addr, ISC_FALSE); +#endif /* ENABLE_FETCHLIMIT */ + + UNLOCK(&adb->entrylocks[bucket]); +} + +void +dns_adb_timeout(dns_adb_t *adb, dns_adbaddrinfo_t *addr) { +#ifdef ENABLE_FETCHLIMIT + int bucket; + + REQUIRE(DNS_ADB_VALID(adb)); + REQUIRE(DNS_ADBADDRINFO_VALID(addr)); + + bucket = addr->entry->lock_bucket; + LOCK(&adb->entrylocks[bucket]); + maybe_adjust_quota(adb, addr, ISC_TRUE); + UNLOCK(&adb->entrylocks[bucket]); +#else + UNUSED(adb); + UNUSED(addr); + + return; +#endif /* !ENABLE_FETCHLIMIT */ +} + isc_result_t dns_adb_findaddrinfo(dns_adb_t *adb, isc_sockaddr_t *sa, dns_adbaddrinfo_t **addrp, isc_stdtime_t now) @@ -4230,3 +4445,84 @@ dns_adb_setadbsize(dns_adb_t *adb, size_t size) { else isc_mem_setwater(adb->mctx, water, adb, hiwater, lowater); } + +void +dns_adb_setquota(dns_adb_t *adb, isc_uint32_t quota, isc_uint32_t freq, + double low, double high, double discount) +{ +#ifdef ENABLE_FETCHLIMIT + REQUIRE(DNS_ADB_VALID(adb)); + + adb->quota = quota; + adb->atr_freq = freq; + adb->atr_low = low; + adb->atr_high = high; + adb->atr_discount = discount; +#else + UNUSED(adb); + UNUSED(quota); + UNUSED(freq); + UNUSED(low); + UNUSED(high); + UNUSED(discount); + + return; +#endif /* !ENABLE_FETCHLIMIT */ +} + +isc_boolean_t +dns_adbentry_overquota(dns_adbentry_t *entry) { +#ifdef ENABLE_FETCHLIMIT + isc_boolean_t block; + REQUIRE(DNS_ADBENTRY_VALID(entry)); + block = ISC_TF(entry->quota != 0 && entry->active >= entry->quota); + return (block); +#else + UNUSED(entry); + + return (ISC_FALSE); +#endif /* !ENABLE_FETCHLIMIT */ +} + +void +dns_adb_beginudpfetch(dns_adb_t *adb, dns_adbaddrinfo_t *addr) { +#ifdef ENABLE_FETCHLIMIT + int bucket; + + REQUIRE(DNS_ADB_VALID(adb)); + REQUIRE(DNS_ADBADDRINFO_VALID(addr)); + + bucket = addr->entry->lock_bucket; + + LOCK(&adb->entrylocks[bucket]); + addr->entry->active++; + UNLOCK(&adb->entrylocks[bucket]); +#else + UNUSED(adb); + UNUSED(addr); + + return; +#endif /* !ENABLE_FETCHLIMIT */ +} + +void +dns_adb_endudpfetch(dns_adb_t *adb, dns_adbaddrinfo_t *addr) { +#ifdef ENABLE_FETCHLIMIT + int bucket; + + REQUIRE(DNS_ADB_VALID(adb)); + REQUIRE(DNS_ADBADDRINFO_VALID(addr)); + + bucket = addr->entry->lock_bucket; + + LOCK(&adb->entrylocks[bucket]); + if (addr->entry->active > 0) + addr->entry->active--; + UNLOCK(&adb->entrylocks[bucket]); +#else + UNUSED(adb); + UNUSED(addr); + + return; +#endif /* !ENABLE_FETCHLIMIT */ +} diff --git a/lib/dns/api b/lib/dns/api index b93481d12132..c1a2e99c964e 100644 --- a/lib/dns/api +++ b/lib/dns/api @@ -4,6 +4,6 @@ # 9.8: 80-89, 120-129 # 9.9: 90-109 # 9.9-sub: 130-139 -LIBINTERFACE = 107 -LIBREVISION = 2 +LIBINTERFACE = 109 +LIBREVISION = 0 LIBAGE = 1 diff --git a/lib/dns/cache.c b/lib/dns/cache.c index d0f05b9a09ab..098823314980 100644 --- a/lib/dns/cache.c +++ b/lib/dns/cache.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2009, 2011, 2013 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2009, 2011, 2013, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -1125,30 +1125,42 @@ cleaner_shutdown_action(isc_task_t *task, isc_event_t *event) { isc_result_t dns_cache_flush(dns_cache_t *cache) { - dns_db_t *db = NULL; + dns_db_t *db = NULL, *olddb; + dns_dbiterator_t *dbiterator = NULL, *olddbiterator = NULL; isc_result_t result; result = cache_create_db(cache, &db); if (result != ISC_R_SUCCESS) return (result); + result = dns_db_createiterator(db, ISC_FALSE, &dbiterator); + if (result != ISC_R_SUCCESS) { + dns_db_detach(&db); + return (result); + } + LOCK(&cache->lock); LOCK(&cache->cleaner.lock); if (cache->cleaner.state == cleaner_s_idle) { - if (cache->cleaner.iterator != NULL) - dns_dbiterator_destroy(&cache->cleaner.iterator); - (void) dns_db_createiterator(db, ISC_FALSE, - &cache->cleaner.iterator); + olddbiterator = cache->cleaner.iterator; + cache->cleaner.iterator = dbiterator; + dbiterator = NULL; } else { if (cache->cleaner.state == cleaner_s_busy) cache->cleaner.state = cleaner_s_done; cache->cleaner.replaceiterator = ISC_TRUE; } - dns_db_detach(&cache->db); + olddb = cache->db; cache->db = db; UNLOCK(&cache->cleaner.lock); UNLOCK(&cache->lock); + if (dbiterator != NULL) + dns_dbiterator_destroy(&dbiterator); + if (olddbiterator != NULL) + dns_dbiterator_destroy(&olddbiterator); + dns_db_detach(&olddb); + return (ISC_R_SUCCESS); } diff --git a/lib/dns/callbacks.c b/lib/dns/callbacks.c index 0ef17abce7bc..c12e0c0fed95 100644 --- a/lib/dns/callbacks.c +++ b/lib/dns/callbacks.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2011 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2011, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -21,6 +21,7 @@ #include <config.h> +#include <isc/print.h> #include <isc/util.h> #include <dns/callbacks.h> diff --git a/lib/dns/client.c b/lib/dns/client.c index cee4fb268d71..b433e348fe31 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2013 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2009-2013, 2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -14,8 +14,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: client.c,v 1.14 2011/03/12 04:59:47 tbox Exp $ */ - #include <config.h> #include <stddef.h> @@ -23,6 +21,7 @@ #include <isc/app.h> #include <isc/mem.h> #include <isc/mutex.h> +#include <isc/safe.h> #include <isc/sockaddr.h> #include <isc/socket.h> #include <isc/task.h> diff --git a/lib/dns/diff.c b/lib/dns/diff.c index b6d4152999f8..1c073ab75e2f 100644 --- a/lib/dns/diff.c +++ b/lib/dns/diff.c @@ -26,6 +26,7 @@ #include <isc/buffer.h> #include <isc/file.h> #include <isc/mem.h> +#include <isc/print.h> #include <isc/string.h> #include <isc/util.h> @@ -290,12 +291,11 @@ diff_apply(dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver, * of the diff itself is not affected. */ + dns_rdatalist_init(&rdl); rdl.type = type; rdl.covers = covers; rdl.rdclass = t->rdata.rdclass; rdl.ttl = t->ttl; - ISC_LIST_INIT(rdl.rdata); - ISC_LINK_INIT(&rdl, link); node = NULL; if (type != dns_rdatatype_nsec3 && @@ -462,12 +462,11 @@ dns_diff_load(dns_diff_t *diff, dns_addrdatasetfunc_t addfunc, type = t->rdata.type; covers = rdata_covers(&t->rdata); + dns_rdatalist_init(&rdl); rdl.type = type; rdl.covers = covers; rdl.rdclass = t->rdata.rdclass; rdl.ttl = t->ttl; - ISC_LIST_INIT(rdl.rdata); - ISC_LINK_INIT(&rdl, link); while (t != NULL && dns_name_equal(&t->name, name) && t->op == op && t->rdata.type == type && @@ -556,11 +555,10 @@ diff_tuple_tordataset(dns_difftuple_t *t, dns_rdata_t *rdata, REQUIRE(rdl != NULL); REQUIRE(rds != NULL); + dns_rdatalist_init(rdl); rdl->type = t->rdata.type; rdl->rdclass = t->rdata.rdclass; rdl->ttl = t->ttl; - ISC_LIST_INIT(rdl->rdata); - ISC_LINK_INIT(rdl, link); dns_rdataset_init(rds); ISC_LINK_INIT(rdata, link); dns_rdata_clone(&t->rdata, rdata); diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index 1c113eccb235..444bcedde322 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -1159,7 +1159,7 @@ free_sevent(isc_event_t *ev) { } static inline isc_socketevent_t * -allocate_sevent(dns_dispatch_t *disp, isc_socket_t *socket, +allocate_sevent(dns_dispatch_t *disp, isc_socket_t *sock, isc_eventtype_t type, isc_taskaction_t action, const void *arg) { isc_socketevent_t *ev; @@ -1170,7 +1170,7 @@ allocate_sevent(dns_dispatch_t *disp, isc_socket_t *socket, return (NULL); DE_CONST(arg, deconst_arg); ISC_EVENT_INIT(ev, sizeof(*ev), 0, NULL, type, - action, deconst_arg, socket, + action, deconst_arg, sock, free_sevent, disp->sepool); ev->result = ISC_R_UNSET; ISC_LINK_INIT(ev, ev_link); @@ -1709,7 +1709,7 @@ static isc_result_t startrecv(dns_dispatch_t *disp, dispsocket_t *dispsock) { isc_result_t res; isc_region_t region; - isc_socket_t *socket; + isc_socket_t *sock; if (disp->shutting_down == 1) return (ISC_R_SUCCESS); @@ -1728,10 +1728,10 @@ startrecv(dns_dispatch_t *disp, dispsocket_t *dispsock) { return (ISC_R_SUCCESS); if (dispsock != NULL) - socket = dispsock->socket; + sock = dispsock->socket; else - socket = disp->socket; - INSIST(socket != NULL); + sock = disp->socket; + INSIST(sock != NULL); switch (disp->socktype) { /* @@ -1745,7 +1745,7 @@ startrecv(dns_dispatch_t *disp, dispsocket_t *dispsock) { if (dispsock != NULL) { isc_task_t *dt = dispsock->task; isc_socketevent_t *sev = - allocate_sevent(disp, socket, + allocate_sevent(disp, sock, ISC_SOCKEVENT_RECVDONE, udp_exrecv, dispsock); if (sev == NULL) { @@ -1753,7 +1753,7 @@ startrecv(dns_dispatch_t *disp, dispsocket_t *dispsock) { return (ISC_R_NOMEMORY); } - res = isc_socket_recv2(socket, ®ion, 1, dt, sev, 0); + res = isc_socket_recv2(sock, ®ion, 1, dt, sev, 0); if (res != ISC_R_SUCCESS) { free_buffer(disp, region.base, region.length); return (res); @@ -1761,7 +1761,7 @@ startrecv(dns_dispatch_t *disp, dispsocket_t *dispsock) { } else { isc_task_t *dt = disp->task[0]; isc_socketevent_t *sev = - allocate_sevent(disp, socket, + allocate_sevent(disp, sock, ISC_SOCKEVENT_RECVDONE, udp_shrecv, disp); if (sev == NULL) { @@ -1769,7 +1769,7 @@ startrecv(dns_dispatch_t *disp, dispsocket_t *dispsock) { return (ISC_R_NOMEMORY); } - res = isc_socket_recv2(socket, ®ion, 1, dt, sev, 0); + res = isc_socket_recv2(sock, ®ion, 1, dt, sev, 0); if (res != ISC_R_SUCCESS) { free_buffer(disp, region.base, region.length); disp->shutdown_why = res; diff --git a/lib/dns/dlz.c b/lib/dns/dlz.c index 19c600c94126..a273156b5f95 100644 --- a/lib/dns/dlz.c +++ b/lib/dns/dlz.c @@ -1,5 +1,5 @@ /* - * Portions Copyright (C) 2005, 2007, 2009-2013 Internet Systems Consortium, Inc. ("ISC") + * Portions Copyright (C) 2005, 2007, 2009-2013, 2015 Internet Systems Consortium, Inc. ("ISC") * Portions Copyright (C) 1999-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -221,8 +221,8 @@ dns_dlzcreate(isc_mem_t *mctx, const char *dlzname, const char *drivername, void dns_dlzdestroy(dns_dlzdb_t **dbp) { - isc_mem_t *mctx; dns_dlzdestroy_t destroy; + dns_dlzdb_t *db; /* Write debugging message to log */ isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, @@ -234,23 +234,19 @@ dns_dlzdestroy(dns_dlzdb_t **dbp) { */ REQUIRE(dbp != NULL && DNS_DLZ_VALID(*dbp)); + db = *dbp; + *dbp = NULL; + #ifdef BIND9 - if ((*dbp)->ssutable != NULL) { - dns_ssutable_detach(&(*dbp)->ssutable); - } + if (db->ssutable != NULL) + dns_ssutable_detach(&db->ssutable); #endif /* call the drivers destroy method */ - if ((*dbp) != NULL) { - mctx = (*dbp)->mctx; - destroy = (*dbp)->implementation->methods->destroy; - (*destroy)((*dbp)->implementation->driverarg,(*dbp)->dbdata); - /* return memory */ - isc_mem_put(mctx, (*dbp), sizeof(dns_dlzdb_t)); - isc_mem_detach(&mctx); - } - - *dbp = NULL; + destroy = db->implementation->methods->destroy; + (*destroy)(db->implementation->driverarg, db->dbdata); + /* return memory and detach */ + isc_mem_putanddetach(&db->mctx, db, sizeof(dns_dlzdb_t)); } diff --git a/lib/dns/dnssec.c b/lib/dns/dnssec.c index 6a749ea56b32..341dbe6bc282 100644 --- a/lib/dns/dnssec.c +++ b/lib/dns/dnssec.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -934,9 +934,6 @@ dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key) { RETERR(dns_message_gettemprdatalist(msg, &datalist)); datalist->rdclass = dns_rdataclass_any; datalist->type = dns_rdatatype_sig; /* SIG(0) */ - datalist->covers = 0; - datalist->ttl = 0; - ISC_LIST_INIT(datalist->rdata); ISC_LIST_APPEND(datalist->rdata, rdata, link); dataset = NULL; RETERR(dns_message_gettemprdataset(msg, &dataset)); @@ -969,7 +966,7 @@ dns_dnssec_verifymessage(isc_buffer_t *source, dns_message_t *msg, dst_context_t *ctx = NULL; isc_mem_t *mctx; isc_result_t result; - isc_uint16_t addcount; + isc_uint16_t addcount, addcount_n; isc_boolean_t signeedsfree = ISC_FALSE; REQUIRE(source != NULL); @@ -1046,7 +1043,8 @@ dns_dnssec_verifymessage(isc_buffer_t *source, dns_message_t *msg, * Decrement the additional field counter. */ memmove(&addcount, &header[DNS_MESSAGE_HEADERLEN - 2], 2); - addcount = htons((isc_uint16_t)(ntohs(addcount) - 1)); + addcount_n = ntohs(addcount); + addcount = htons((isc_uint16_t)(addcount_n - 1)); memmove(&header[DNS_MESSAGE_HEADERLEN - 2], &addcount, 2); /* diff --git a/lib/dns/dst_api.c b/lib/dns/dst_api.c index 641627376047..680a0184319e 100644 --- a/lib/dns/dst_api.c +++ b/lib/dns/dst_api.c @@ -1,5 +1,5 @@ /* - * Portions Copyright (C) 2004-2013 Internet Systems Consortium, Inc. ("ISC") + * Portions Copyright (C) 2004-2013, 2015 Internet Systems Consortium, Inc. ("ISC") * Portions Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -1001,9 +1001,6 @@ comparekeys(const dst_key_t *key1, const dst_key_t *key2, if (key1 == key2) return (ISC_TRUE); - if (key1 == NULL || key2 == NULL) - return (ISC_FALSE); - if (key1->key_alg != key2->key_alg) return (ISC_FALSE); @@ -1093,8 +1090,6 @@ dst_key_paramcompare(const dst_key_t *key1, const dst_key_t *key2) { if (key1 == key2) return (ISC_TRUE); - if (key1 == NULL || key2 == NULL) - return (ISC_FALSE); if (key1->key_alg == key2->key_alg && key1->func->paramcompare != NULL && key1->func->paramcompare(key1, key2) == ISC_TRUE) diff --git a/lib/dns/dst_openssl.h b/lib/dns/dst_openssl.h index 99a43ef948ac..dd6740586d8a 100644 --- a/lib/dns/dst_openssl.h +++ b/lib/dns/dst_openssl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007-2009, 2011, 2012 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007-2009, 2011, 2012, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -29,12 +29,27 @@ #include <openssl/evp.h> #include <openssl/conf.h> #include <openssl/crypto.h> +#include <openssl/bn.h> #if !defined(OPENSSL_NO_ENGINE) && defined(CRYPTO_LOCK_ENGINE) && \ (OPENSSL_VERSION_NUMBER >= 0x0090707f) #define USE_ENGINE 1 #endif +#if OPENSSL_VERSION_NUMBER < 0x10100000L +/* + * These are new in OpenSSL 1.1.0. BN_GENCB _cb needs to be declared in + * the function like this before the BN_GENCB_new call: + * + * #if OPENSSL_VERSION_NUMBER < 0x10100000L + * _cb; + * #endif + */ +#define BN_GENCB_free(x) (x = NULL); +#define BN_GENCB_new() (&_cb) +#define BN_GENCB_get_arg(x) ((x)->arg) +#endif + ISC_LANG_BEGINDECLS isc_result_t diff --git a/lib/dns/dst_parse.c b/lib/dns/dst_parse.c index 2b950d5a3b9c..989dc86300f2 100644 --- a/lib/dns/dst_parse.c +++ b/lib/dns/dst_parse.c @@ -1,5 +1,5 @@ /* - * Portions Copyright (C) 2004-2013 Internet Systems Consortium, Inc. ("ISC") + * Portions Copyright (C) 2004-2013, 2015 Internet Systems Consortium, Inc. ("ISC") * Portions Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -38,13 +38,14 @@ #include <isc/base64.h> #include <isc/dir.h> +#include <isc/file.h> #include <isc/fsaccess.h> #include <isc/lex.h> #include <isc/mem.h> +#include <isc/print.h> #include <isc/stdtime.h> #include <isc/string.h> #include <isc/util.h> -#include <isc/file.h> #include <dns/time.h> #include <dns/log.h> diff --git a/lib/dns/gssapi_link.c b/lib/dns/gssapi_link.c index 2927b676d366..e404c96ceae1 100644 --- a/lib/dns/gssapi_link.c +++ b/lib/dns/gssapi_link.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2009, 2011-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2009, 2011-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -26,6 +26,7 @@ #include <isc/base64.h> #include <isc/buffer.h> #include <isc/mem.h> +#include <isc/print.h> #include <isc/string.h> #include <isc/util.h> diff --git a/lib/dns/gssapictx.c b/lib/dns/gssapictx.c index f28c07aba436..3a3af34a9861 100644 --- a/lib/dns/gssapictx.c +++ b/lib/dns/gssapictx.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -216,7 +216,7 @@ static void check_config(const char *gss_name) { const char *p; krb5_context krb5_ctx; - char *krb5_realm = NULL; + char *krb5_realm_name = NULL; if (strncasecmp(gss_name, "DNS/", 4) != 0) { gss_log(ISC_LOG_ERROR, "tkey-gssapi-credential (%s) " @@ -228,7 +228,7 @@ check_config(const char *gss_name) { gss_log(ISC_LOG_ERROR, "Unable to initialise krb5 context"); return; } - if (krb5_get_default_realm(krb5_ctx, &krb5_realm) != 0) { + if (krb5_get_default_realm(krb5_ctx, &krb5_realm_name) != 0) { gss_log(ISC_LOG_ERROR, "Unable to get krb5 default realm"); krb5_free_context(krb5_ctx); return; @@ -240,10 +240,10 @@ check_config(const char *gss_name) { krb5_free_context(krb5_ctx); return; } - if (strcasecmp(p + 1, krb5_realm) != 0) { + if (strcasecmp(p + 1, krb5_realm_name) != 0) { gss_log(ISC_LOG_ERROR, "default realm from krb5.conf (%s) " "does not match tkey-gssapi-credential (%s)", - krb5_realm, gss_name); + krb5_realm_name, gss_name); krb5_free_context(krb5_ctx); return; } @@ -633,7 +633,6 @@ dst_gssapi_initctx(dns_name_t *name, isc_buffer_t *intoken, if (gouttoken.length != 0U) { GBUFFER_TO_REGION(gouttoken, r); RETERR(isc_buffer_copyregion(outtoken, &r)); - (void)gss_release_buffer(&minor, &gouttoken); } if (gret == GSS_S_COMPLETE) @@ -642,6 +641,8 @@ dst_gssapi_initctx(dns_name_t *name, isc_buffer_t *intoken, result = DNS_R_CONTINUE; out: + if (gouttoken.length != 0U) + (void)gss_release_buffer(&minor, &gouttoken); (void)gss_release_name(&minor, &gname); return (result); #else diff --git a/lib/dns/hmac_link.c b/lib/dns/hmac_link.c index d99c5fb00f42..690301d7c236 100644 --- a/lib/dns/hmac_link.c +++ b/lib/dns/hmac_link.c @@ -1,5 +1,5 @@ /* - * Portions Copyright (C) 2004-2014 Internet Systems Consortium, Inc. ("ISC") + * Portions Copyright (C) 2004-2015 Internet Systems Consortium, Inc. ("ISC") * Portions Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -76,7 +76,7 @@ hmacmd5_createctx(dst_key_t *key, dst_context_t *dctx) { hmacmd5ctx = isc_mem_get(dctx->mctx, sizeof(isc_hmacmd5_t)); if (hmacmd5ctx == NULL) return (ISC_R_NOMEMORY); - isc_hmacmd5_init(hmacmd5ctx, hkey->key, ISC_SHA1_BLOCK_LENGTH); + isc_hmacmd5_init(hmacmd5ctx, hkey->key, ISC_MD5_BLOCK_LENGTH); dctx->ctxdata.hmacmd5ctx = hmacmd5ctx; return (ISC_R_SUCCESS); } @@ -139,7 +139,7 @@ hmacmd5_compare(const dst_key_t *key1, const dst_key_t *key2) { else if (hkey1 == NULL || hkey2 == NULL) return (ISC_FALSE); - if (isc_safe_memcmp(hkey1->key, hkey2->key, ISC_SHA1_BLOCK_LENGTH)) + if (isc_safe_memequal(hkey1->key, hkey2->key, ISC_MD5_BLOCK_LENGTH)) return (ISC_TRUE); else return (ISC_FALSE); @@ -150,17 +150,17 @@ hmacmd5_generate(dst_key_t *key, int pseudorandom_ok, void (*callback)(int)) { isc_buffer_t b; isc_result_t ret; unsigned int bytes; - unsigned char data[ISC_SHA1_BLOCK_LENGTH]; + unsigned char data[ISC_MD5_BLOCK_LENGTH]; UNUSED(callback); bytes = (key->key_size + 7) / 8; - if (bytes > ISC_SHA1_BLOCK_LENGTH) { - bytes = ISC_SHA1_BLOCK_LENGTH; - key->key_size = ISC_SHA1_BLOCK_LENGTH * 8; + if (bytes > ISC_MD5_BLOCK_LENGTH) { + bytes = ISC_MD5_BLOCK_LENGTH; + key->key_size = ISC_MD5_BLOCK_LENGTH * 8; } - memset(data, 0, ISC_SHA1_BLOCK_LENGTH); + memset(data, 0, ISC_MD5_BLOCK_LENGTH); ret = dst__entropy_getdata(data, bytes, ISC_TF(pseudorandom_ok != 0)); if (ret != ISC_R_SUCCESS) @@ -169,7 +169,7 @@ hmacmd5_generate(dst_key_t *key, int pseudorandom_ok, void (*callback)(int)) { isc_buffer_init(&b, data, bytes); isc_buffer_add(&b, bytes); ret = hmacmd5_fromdns(key, &b); - memset(data, 0, ISC_SHA1_BLOCK_LENGTH); + memset(data, 0, ISC_MD5_BLOCK_LENGTH); return (ret); } @@ -223,7 +223,7 @@ hmacmd5_fromdns(dst_key_t *key, isc_buffer_t *data) { memset(hkey->key, 0, sizeof(hkey->key)); - if (r.length > ISC_SHA1_BLOCK_LENGTH) { + if (r.length > ISC_MD5_BLOCK_LENGTH) { isc_md5_init(&md5ctx); isc_md5_update(&md5ctx, r.base, r.length); isc_md5_final(&md5ctx, hkey->key); @@ -236,6 +236,8 @@ hmacmd5_fromdns(dst_key_t *key, isc_buffer_t *data) { key->key_size = keylen * 8; key->keydata.hmacmd5 = hkey; + isc_buffer_forward(data, r.length); + return (ISC_R_SUCCESS); } @@ -415,7 +417,7 @@ hmacsha1_compare(const dst_key_t *key1, const dst_key_t *key2) { else if (hkey1 == NULL || hkey2 == NULL) return (ISC_FALSE); - if (isc_safe_memcmp(hkey1->key, hkey2->key, ISC_SHA1_BLOCK_LENGTH)) + if (isc_safe_memequal(hkey1->key, hkey2->key, ISC_SHA1_BLOCK_LENGTH)) return (ISC_TRUE); else return (ISC_FALSE); @@ -512,6 +514,8 @@ hmacsha1_fromdns(dst_key_t *key, isc_buffer_t *data) { key->key_size = keylen * 8; key->keydata.hmacsha1 = hkey; + isc_buffer_forward(data, r.length); + return (ISC_R_SUCCESS); } @@ -691,7 +695,7 @@ hmacsha224_compare(const dst_key_t *key1, const dst_key_t *key2) { else if (hkey1 == NULL || hkey2 == NULL) return (ISC_FALSE); - if (isc_safe_memcmp(hkey1->key, hkey2->key, ISC_SHA224_BLOCK_LENGTH)) + if (isc_safe_memequal(hkey1->key, hkey2->key, ISC_SHA224_BLOCK_LENGTH)) return (ISC_TRUE); else return (ISC_FALSE); @@ -790,6 +794,8 @@ hmacsha224_fromdns(dst_key_t *key, isc_buffer_t *data) { key->key_size = keylen * 8; key->keydata.hmacsha224 = hkey; + isc_buffer_forward(data, r.length); + return (ISC_R_SUCCESS); } @@ -969,7 +975,7 @@ hmacsha256_compare(const dst_key_t *key1, const dst_key_t *key2) { else if (hkey1 == NULL || hkey2 == NULL) return (ISC_FALSE); - if (isc_safe_memcmp(hkey1->key, hkey2->key, ISC_SHA256_BLOCK_LENGTH)) + if (isc_safe_memequal(hkey1->key, hkey2->key, ISC_SHA256_BLOCK_LENGTH)) return (ISC_TRUE); else return (ISC_FALSE); @@ -1068,6 +1074,8 @@ hmacsha256_fromdns(dst_key_t *key, isc_buffer_t *data) { key->key_size = keylen * 8; key->keydata.hmacsha256 = hkey; + isc_buffer_forward(data, r.length); + return (ISC_R_SUCCESS); } @@ -1247,7 +1255,7 @@ hmacsha384_compare(const dst_key_t *key1, const dst_key_t *key2) { else if (hkey1 == NULL || hkey2 == NULL) return (ISC_FALSE); - if (isc_safe_memcmp(hkey1->key, hkey2->key, ISC_SHA384_BLOCK_LENGTH)) + if (isc_safe_memequal(hkey1->key, hkey2->key, ISC_SHA384_BLOCK_LENGTH)) return (ISC_TRUE); else return (ISC_FALSE); @@ -1346,6 +1354,8 @@ hmacsha384_fromdns(dst_key_t *key, isc_buffer_t *data) { key->key_size = keylen * 8; key->keydata.hmacsha384 = hkey; + isc_buffer_forward(data, r.length); + return (ISC_R_SUCCESS); } @@ -1525,7 +1535,7 @@ hmacsha512_compare(const dst_key_t *key1, const dst_key_t *key2) { else if (hkey1 == NULL || hkey2 == NULL) return (ISC_FALSE); - if (isc_safe_memcmp(hkey1->key, hkey2->key, ISC_SHA512_BLOCK_LENGTH)) + if (isc_safe_memequal(hkey1->key, hkey2->key, ISC_SHA512_BLOCK_LENGTH)) return (ISC_TRUE); else return (ISC_FALSE); @@ -1624,6 +1634,8 @@ hmacsha512_fromdns(dst_key_t *key, isc_buffer_t *data) { key->key_size = keylen * 8; key->keydata.hmacsha512 = hkey; + isc_buffer_forward(data, r.length); + return (ISC_R_SUCCESS); } diff --git a/lib/dns/include/dns/adb.h b/lib/dns/include/dns/adb.h index 8222bd211006..12dd1190c3ca 100644 --- a/lib/dns/include/dns/adb.h +++ b/lib/dns/include/dns/adb.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2008, 2011, 2013, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2008, 2011, 2013-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -206,6 +206,11 @@ struct dns_adbfind { * Must set _WANTEVENT for this to be meaningful. */ #define DNS_ADBFIND_LAMEPRUNED 0x00000200 +/*% + * The server's fetch quota is exceeded; it will be treated as + * lame for this query. + */ +#define DNS_ADBFIND_OVERQUOTA 0x00000400 /*% * The answers to queries come back as a list of these. @@ -583,6 +588,30 @@ dns_adb_changeflags(dns_adb_t *adb, dns_adbaddrinfo_t *addr, *\li addr be valid. */ +void +dns_adb_plainresponse(dns_adb_t *adb, dns_adbaddrinfo_t *addr); +/*% + * Record a successful DNS response. + * + * Requires: + * + *\li adb be valid. + * + *\li addr be valid. + */ + +void +dns_adb_timeout(dns_adb_t *adb, dns_adbaddrinfo_t *addr); +/*% + * Record a DNS UDP query failed. + * + * Requires: + * + *\li adb be valid. + * + *\li addr be valid. + */ + isc_result_t dns_adb_findaddrinfo(dns_adb_t *adb, isc_sockaddr_t *sa, dns_adbaddrinfo_t **addrp, isc_stdtime_t now); @@ -647,6 +676,64 @@ dns_adb_flushname(dns_adb_t *adb, dns_name_t *name); *\li 'name' is valid. */ +void +dns_adb_setquota(dns_adb_t *adb, isc_uint32_t quota, isc_uint32_t freq, + double low, double high, double discount); +/*%< + * Set the baseline ADB quota, and configure parameters for the + * quota adjustment algorithm. + * + * If the number of fetches currently waiting for responses from this + * address exceeds the current quota, then additional fetches are spilled. + * + * 'quota' is the highest permissible quota; it will adjust itself + * downward in response to detected congestion. + * + * After every 'freq' fetches have either completed or timed out, an + * exponentially weighted moving average of the ratio of timeouts + * to responses is calculated. If the EWMA goes above a 'high' + * threshold, then the quota is adjusted down one step; if it drops + * below a 'low' threshold, then the quota is adjusted back up one + * step. + * + * The quota adjustment is based on the function (1 / 1 + (n/10)^(3/2)), + * for values of n from 0 to 99. It starts at 100% of the baseline + * quota, and descends after 100 steps to 2%. + * + * 'discount' represents the discount rate of the moving average. Higher + * values cause older values to be discounted sooner, providing a faster + * response to changes in the timeout ratio. + * + * Requires: + *\li 'adb' is valid. + */ + +isc_boolean_t +dns_adbentry_overquota(dns_adbentry_t *entry); +/*%< + * Returns true if the specified ADB has too many active fetches. + * + * Requires: + *\li 'entry' is valid. + */ + +void +dns_adb_beginudpfetch(dns_adb_t *adb, dns_adbaddrinfo_t *addr); +void +dns_adb_endudpfetch(dns_adb_t *adb, dns_adbaddrinfo_t *addr); +/*% + * Begin/end a UDP fetch on a particular address. + * + * These functions increment or decrement the fetch counter for + * the ADB entry so that the fetch quota can be enforced. + * + * Requires: + * + *\li adb be valid. + * + *\li addr be valid. + */ + ISC_LANG_ENDDECLS #endif /* DNS_ADB_H */ diff --git a/lib/dns/include/dns/log.h b/lib/dns/include/dns/log.h index 488b48e33de2..e7670f806e41 100644 --- a/lib/dns/include/dns/log.h +++ b/lib/dns/include/dns/log.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007, 2009, 2011-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2007, 2009, 2011-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,8 +15,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: log.h,v 1.47 2011/10/13 22:48:24 tbox Exp $ */ - /*! \file dns/log.h * \author Principal Authors: DCL */ @@ -45,6 +43,7 @@ LIBDNS_EXTERNAL_DATA extern isc_logmodule_t dns_modules[]; #define DNS_LOGCATEGORY_RPZ (&dns_categories[12]) #define DNS_LOGCATEGORY_RRL (&dns_categories[13]) #define DNS_LOGCATEGORY_CNAME (&dns_categories[14]) +#define DNS_LOGCATEGORY_SPILL (&dns_categories[15]) /* Backwards compatibility. */ #define DNS_LOGCATEGORY_GENERAL ISC_LOGCATEGORY_GENERAL diff --git a/lib/dns/include/dns/message.h b/lib/dns/include/dns/message.h index c678238d2224..76f78bfdfb80 100644 --- a/lib/dns/include/dns/message.h +++ b/lib/dns/include/dns/message.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2010, 2012-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2010, 2012-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -107,9 +107,10 @@ #define DNS_OPT_NSID 0x0003 /*%< NSID opt code */ #define DNS_OPT_CLIENT_SUBNET 0x0008 /*%< client subnet opt code */ #define DNS_OPT_EXPIRE 0x0009 /*%< EXPIRE opt code */ +#define DNS_OPT_COOKIE 0x000a /*%< COOKIE opt code */ /*%< The number of EDNS options we know about. */ -#define DNS_EDNSOPTIONS 3 +#define DNS_EDNSOPTIONS 4 #define DNS_MESSAGE_REPLYPRESERVE (DNS_MESSAGEFLAG_RD|DNS_MESSAGEFLAG_CD) #define DNS_MESSAGEEXTFLAG_REPLYPRESERVE (DNS_MESSAGEEXTFLAG_DO) @@ -193,7 +194,7 @@ struct dns_message { dns_messageid_t id; unsigned int flags; dns_rcode_t rcode; - unsigned int opcode; + dns_opcode_t opcode; dns_rdataclass_t rdclass; /* 4 real, 1 pseudo */ diff --git a/lib/dns/include/dns/name.h b/lib/dns/include/dns/name.h index 1a88e53264b4..d6e9a90c1eb5 100644 --- a/lib/dns/include/dns/name.h +++ b/lib/dns/include/dns/name.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007, 2009-2012 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2007, 2009-2012, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -989,10 +989,6 @@ dns_name_split(dns_name_t *name, unsigned int suffixlabels, * *\li 'suffix' is a valid name or NULL, and cannot be read-only. * - *\li If non-NULL, 'prefix' and 'suffix' must have dedicated buffers. - * - *\li 'prefix' and 'suffix' cannot point to the same buffer. - * * Ensures: * *\li On success: @@ -1161,6 +1157,7 @@ dns_name_tostring(dns_name_t *source, char **target, isc_mem_t *mctx); * Returns: * *\li ISC_R_SUCCESS + *\li ISC_R_NOMEMORY * *\li Any error that dns_name_totext() can return. */ @@ -1283,6 +1280,12 @@ dns_name_destroy(void); * non-NULL argument prior to calling dns_name_destroy(); */ +isc_boolean_t +dns_name_isdnssd(const dns_name_t *owner); +/*%< + * Determine if the 'owner' is a DNS-SD prefix. + */ + ISC_LANG_ENDDECLS /* diff --git a/lib/dns/include/dns/resolver.h b/lib/dns/include/dns/resolver.h index a533f4ed2b24..5ea2279eec37 100644 --- a/lib/dns/include/dns/resolver.h +++ b/lib/dns/include/dns/resolver.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2012, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2012, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,8 +15,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resolver.h,v 1.72 2011/12/05 17:10:51 each Exp $ */ - #ifndef DNS_RESOLVER_H #define DNS_RESOLVER_H 1 @@ -54,6 +52,7 @@ #include <isc/lang.h> #include <isc/socket.h> +#include <isc/stats.h> #include <dns/types.h> #include <dns/fixedname.h> @@ -84,6 +83,14 @@ typedef struct dns_fetchevent { isc_result_t vresult; } dns_fetchevent_t; +/*% + * The two quota types (fetches-per-zone and fetches-per-server) + */ +typedef enum { + dns_quotatype_zone = 0, + dns_quotatype_server +} dns_quotatype_t; + /* * Options that modify how a 'fetch' is done. */ @@ -532,6 +539,8 @@ dns_resolver_gettimeout(dns_resolver_t *resolver); void dns_resolver_setclientsperquery(dns_resolver_t *resolver, isc_uint32_t min, isc_uint32_t max); +void +dns_resolver_setfetchesperzone(dns_resolver_t *resolver, isc_uint32_t clients); void dns_resolver_getclientsperquery(dns_resolver_t *resolver, isc_uint32_t *cur, @@ -612,6 +621,30 @@ dns_resolver_getmaxqueries(dns_resolver_t *resolver); * \li resolver to be valid. */ +void +dns_resolver_dumpfetches(dns_resolver_t *resolver, FILE *fp); + +void +dns_resolver_setquotaresponse(dns_resolver_t *resolver, + dns_quotatype_t which, isc_result_t resp); +isc_result_t +dns_resolver_getquotaresponse(dns_resolver_t *resolver, dns_quotatype_t which); +/*% + * Get and set the result code that will be used when quotas + * are exceeded. If 'which' is set to quotatype "zone", then the + * result specified in 'resp' will be used when the fetches-per-zone + * quota is exceeded by a fetch. If 'which' is set to quotatype "server", + * then the reuslt specified in 'resp' will be used when the + * fetches-per-server quota has been exceeded for all the + * authoritative servers for a zone. Valid choices are + * DNS_R_DROP or DNS_R_SERVFAIL. + * + * Requires: + * \li 'resolver' to be valid. + * \li 'which' to be dns_quotatype_zone or dns_quotatype_server + * \li 'resp' to be DNS_R_DROP or DNS_R_SERVFAIL. + */ + ISC_LANG_ENDDECLS #endif /* DNS_RESOLVER_H */ diff --git a/lib/dns/include/dns/result.h b/lib/dns/include/dns/result.h index 12aacf9ba78a..7d11c2beb01e 100644 --- a/lib/dns/include/dns/result.h +++ b/lib/dns/include/dns/result.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2013 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2013, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -153,8 +153,12 @@ #define DNS_R_EXPIRED (ISC_RESULTCLASS_DNS + 107) #define DNS_R_NOTDYNAMIC (ISC_RESULTCLASS_DNS + 108) #define DNS_R_BADEUI (ISC_RESULTCLASS_DNS + 109) +#define DNS_R_NTACOVERED (ISC_RESULTCLASS_DNS + 110) +#define DNS_R_BADCDS (ISC_RESULTCLASS_DNS + 111) +#define DNS_R_BADCDNSKEY (ISC_RESULTCLASS_DNS + 112) +#define DNS_R_OPTERR (ISC_RESULTCLASS_DNS + 113) -#define DNS_R_NRESULTS 110 /*%< Number of results */ +#define DNS_R_NRESULTS 114 /*%< Number of results */ /* * DNS wire format rcodes. diff --git a/lib/dns/include/dns/rrl.h b/lib/dns/include/dns/rrl.h index ef6b72b4280d..140b99436aa9 100644 --- a/lib/dns/include/dns/rrl.h +++ b/lib/dns/include/dns/rrl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2013, 2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -90,16 +90,17 @@ typedef enum { */ #define DNS_RRL_MAX_PREFIX 64 typedef union dns_rrl_key dns_rrl_key_t; +struct dns__rrl_key { + isc_uint32_t ip[DNS_RRL_MAX_PREFIX/32]; + isc_uint32_t qname_hash; + dns_rdatatype_t qtype; + isc_uint8_t qclass; + dns_rrl_rtype_t rtype :4; /* 3 bits + sign bit */ + isc_boolean_t ipv6 :1; +}; union dns_rrl_key { - struct { - isc_uint32_t ip[DNS_RRL_MAX_PREFIX/32]; - isc_uint32_t qname_hash; - dns_rdatatype_t qtype; - isc_uint8_t qclass; - dns_rrl_rtype_t rtype :4; /* 3 bits + sign bit */ - isc_boolean_t ipv6 :1; - } s; - isc_uint16_t w[1]; + struct dns__rrl_key s; + isc_uint16_t w[sizeof(struct dns__rrl_key)/sizeof(isc_uint16_t)]; }; /* diff --git a/lib/dns/include/dns/stats.h b/lib/dns/include/dns/stats.h index 5364267272a0..b033163db682 100644 --- a/lib/dns/include/dns/stats.h +++ b/lib/dns/include/dns/stats.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2009, 2012 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2009, 2012, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -61,8 +61,10 @@ enum { dns_resstatscounter_queryrtt3 = 27, dns_resstatscounter_queryrtt4 = 28, dns_resstatscounter_queryrtt5 = 29, + dns_resstatscounter_zonequota = 30, + dns_resstatscounter_serverquota = 31, - dns_resstatscounter_max = 30, + dns_resstatscounter_max = 32, /* * DNSSEC stats. diff --git a/lib/dns/include/dns/types.h b/lib/dns/include/dns/types.h index 76167c2f88da..54194aa2a920 100644 --- a/lib/dns/include/dns/types.h +++ b/lib/dns/include/dns/types.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2013 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2013, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -127,6 +127,7 @@ typedef struct dns_tsec dns_tsec_t; typedef struct dns_tsig_keyring dns_tsig_keyring_t; typedef struct dns_tsigkey dns_tsigkey_t; typedef isc_uint32_t dns_ttl_t; +typedef struct dns_update_state dns_update_state_t; typedef struct dns_validator dns_validator_t; typedef struct dns_view dns_view_t; typedef ISC_LIST(dns_view_t) dns_viewlist_t; diff --git a/lib/dns/include/dns/update.h b/lib/dns/include/dns/update.h index 2d2c491f38a3..d08bea7e0b0a 100644 --- a/lib/dns/include/dns/update.h +++ b/lib/dns/include/dns/update.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2011, 2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -59,6 +59,12 @@ dns_update_signatures(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *oldver, dns_dbversion_t *newver, dns_diff_t *diff, isc_uint32_t sigvalidityinterval); +isc_result_t +dns_update_signaturesinc(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, + dns_dbversion_t *oldver, dns_dbversion_t *newver, + dns_diff_t *diff, isc_uint32_t sigvalidityinterval, + dns_update_state_t **state); + ISC_LANG_ENDDECLS #endif /* DNS_UPDATE_H */ diff --git a/lib/dns/include/dns/zone.h b/lib/dns/include/dns/zone.h index 9efa1e729767..987d06f70cec 100644 --- a/lib/dns/include/dns/zone.h +++ b/lib/dns/include/dns/zone.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2013 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2013, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -331,6 +331,15 @@ dns_zone_asyncload(dns_zone_t *zone, dns_zt_zoneloaded_t done, void *arg); * its first argument and 'zone' as its second. (Normally, 'arg' is * expected to point to the zone table but is left undefined for testing * purposes.) + * + * Require: + *\li 'zone' to be a valid zone. + * + * Returns: + *\li #ISC_R_ALREADYRUNNING + *\li #ISC_R_SUCCESS + *\li #ISC_R_FAILURE + *\li #ISC_R_NOMEMORY */ isc_boolean_t @@ -1791,6 +1800,16 @@ dns_zone_name(dns_zone_t *zone, char *buf, size_t len); *\li 'buf' to be non NULL. */ +void +dns_zone_nameonly(dns_zone_t *zone, char *buf, size_t len); +/*%< + * Return the name of the zone only. + * + * Requires: + *\li 'zone' to be valid. + *\li 'buf' to be non NULL. + */ + isc_result_t dns_zone_checknames(dns_zone_t *zone, dns_name_t *name, dns_rdata_t *rdata); /*%< @@ -1894,6 +1913,12 @@ dns_zone_setsignatures(dns_zone_t *zone, isc_uint32_t signatures); * Set the number of signatures that will be generated per quantum. */ +isc_uint32_t +dns_zone_getsignatures(dns_zone_t *zone); +/*%< + * Get the number of signatures that will be generated per quantum. + */ + isc_result_t dns_zone_signwithkey(dns_zone_t *zone, dns_secalg_t algorithm, isc_uint16_t keyid, isc_boolean_t deleteit); @@ -1946,6 +1971,23 @@ dns_zone_nscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version, * ISC_R_SUCCESS if there were no errors examining the zone contents. */ +isc_result_t +dns_zone_cdscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version); +/*% + * Check if CSD, CDNSKEY and DNSKEY are consistent. + * + * Requires: + * \li 'zone' to be valid. + * \li 'db' to be valid. + * \li 'version' to be valid or NULL. + * + * Returns: + *\li #ISC_R_SUCCESS + *\li #DNS_R_BADCDS + *\li #DNS_R_BADCDNSKEY + * Others + */ + void dns_zone_setadded(dns_zone_t *zone, isc_boolean_t added); /*% diff --git a/lib/dns/include/dst/dst.h b/lib/dns/include/dst/dst.h index 1fdce4cc44d7..1497edcb6561 100644 --- a/lib/dns/include/dst/dst.h +++ b/lib/dns/include/dst/dst.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2013 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2013, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -69,6 +69,7 @@ typedef struct dst_context dst_context_t; #define DST_ALG_HMACSHA256 163 /* XXXMPA */ #define DST_ALG_HMACSHA384 164 /* XXXMPA */ #define DST_ALG_HMACSHA512 165 /* XXXMPA */ +#define DST_ALG_INDIRECT 252 #define DST_ALG_PRIVATE 254 #define DST_ALG_EXPAND 255 #define DST_MAX_ALGS 255 diff --git a/lib/dns/journal.c b/lib/dns/journal.c index a21ec2e8a348..4811ebbd80b6 100644 --- a/lib/dns/journal.c +++ b/lib/dns/journal.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007-2011, 2013, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007-2011, 2013-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -25,6 +25,7 @@ #include <isc/file.h> #include <isc/mem.h> +#include <isc/print.h> #include <isc/stdio.h> #include <isc/string.h> #include <isc/util.h> @@ -555,7 +556,7 @@ journal_file_create(isc_mem_t *mctx, const char *filename) { } static isc_result_t -journal_open(isc_mem_t *mctx, const char *filename, isc_boolean_t write, +journal_open(isc_mem_t *mctx, const char *filename, isc_boolean_t writable, isc_boolean_t create, dns_journal_t **journalp) { FILE *fp = NULL; @@ -579,7 +580,7 @@ journal_open(isc_mem_t *mctx, const char *filename, isc_boolean_t write, if (j->filename == NULL) FAIL(ISC_R_NOMEMORY); - result = isc_stdio_open(j->filename, write ? "rb+" : "rb", &fp); + result = isc_stdio_open(j->filename, writable ? "rb+" : "rb", &fp); if (result == ISC_R_FILENOTFOUND) { if (create) { @@ -669,7 +670,7 @@ journal_open(isc_mem_t *mctx, const char *filename, isc_boolean_t write, dns_decompress_init(&j->it.dctx, -1, DNS_DECOMPRESS_NONE); j->state = - write ? JOURNAL_STATE_WRITE : JOURNAL_STATE_READ; + writable ? JOURNAL_STATE_WRITE : JOURNAL_STATE_READ; *journalp = j; return (ISC_R_SUCCESS); @@ -696,12 +697,12 @@ dns_journal_open(isc_mem_t *mctx, const char *filename, unsigned int mode, isc_result_t result; size_t namelen; char backup[1024]; - isc_boolean_t write, create; + isc_boolean_t writable, create; create = ISC_TF(mode & DNS_JOURNAL_CREATE); - write = ISC_TF(mode & (DNS_JOURNAL_WRITE|DNS_JOURNAL_CREATE)); + writable = ISC_TF(mode & (DNS_JOURNAL_WRITE|DNS_JOURNAL_CREATE)); - result = journal_open(mctx, filename, write, create, journalp); + result = journal_open(mctx, filename, writable, create, journalp); if (result == ISC_R_NOTFOUND) { namelen = strlen(filename); if (namelen > 4U && strcmp(filename + namelen - 4, ".jnl") == 0) @@ -711,7 +712,8 @@ dns_journal_open(isc_mem_t *mctx, const char *filename, unsigned int mode, (int)namelen, filename); if (result != ISC_R_SUCCESS) return (result); - result = journal_open(mctx, backup, write, write, journalp); + result = journal_open(mctx, backup, writable, writable, + journalp); } return (result); } @@ -2110,6 +2112,8 @@ dns_journal_compact(isc_mem_t *mctx, char *filename, isc_uint32_t serial, char backup[1024]; isc_boolean_t is_backup = ISC_FALSE; + REQUIRE(filename != NULL); + namelen = strlen(filename); if (namelen > 4U && strcmp(filename + namelen - 4, ".jnl") == 0) namelen -= 4; diff --git a/lib/dns/keytable.c b/lib/dns/keytable.c index 29f129ffbf5f..2ed49ffd311d 100644 --- a/lib/dns/keytable.c +++ b/lib/dns/keytable.c @@ -22,6 +22,7 @@ #include <config.h> #include <isc/mem.h> +#include <isc/print.h> #include <isc/rwlock.h> #include <isc/string.h> /* Required for HP/UX (and others?) */ #include <isc/util.h> diff --git a/lib/dns/log.c b/lib/dns/log.c index 70055aaf887b..7ebe015749b7 100644 --- a/lib/dns/log.c +++ b/lib/dns/log.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007, 2009, 2011-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2007, 2009, 2011-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,8 +15,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: log.c,v 1.49 2011/10/13 22:48:24 tbox Exp $ */ - /*! \file */ /* Principal Authors: DCL */ @@ -47,6 +45,7 @@ LIBDNS_EXTERNAL_DATA isc_logcategory_t dns_categories[] = { { "rpz", 0 }, { "rate-limit", 0 }, { "cname", 0 }, + { "spill", 0 }, { NULL, 0 } }; diff --git a/lib/dns/master.c b/lib/dns/master.c index 1fde70c3b6ec..4dba0d7c5558 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -280,7 +280,7 @@ loadctx_destroy(dns_loadctx_t *lctx); SETRESULT(lctx, result); \ LOGIT(result); \ read_till_eol = ISC_TRUE; \ - continue; \ + break; \ } else if (result != ISC_R_SUCCESS) \ goto log_and_cleanup; \ } \ @@ -352,7 +352,6 @@ static const dns_name_t ip6_arpa = {NULL, NULL} }; - static inline isc_result_t gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *token, isc_boolean_t eol, dns_rdatacallbacks_t *callbacks) @@ -860,8 +859,6 @@ generate(dns_loadctx_t *lctx, char *range, char *lhs, char *gtype, char *rhs, goto insist_cleanup; } - ISC_LIST_INIT(rdatalist.rdata); - ISC_LINK_INIT(&rdatalist, link); for (i = start; i <= stop; i += step) { result = genname(lhs, i, lhsbuf, DNS_MASTER_LHS); if (result != ISC_R_SUCCESS) @@ -911,8 +908,8 @@ generate(dns_loadctx_t *lctx, char *range, char *lhs, char *gtype, char *rhs, if (result != ISC_R_SUCCESS) goto error_cleanup; + dns_rdatalist_init(&rdatalist); rdatalist.type = type; - rdatalist.covers = 0; rdatalist.rdclass = lctx->zclass; rdatalist.ttl = lctx->ttl; ISC_LIST_PREPEND(head, &rdatalist, link); @@ -1793,6 +1790,7 @@ load_text(dns_loadctx_t *lctx) { } } if (type == dns_rdatatype_ptr && + !dns_name_isdnssd(name) && (dns_name_issubdomain(name, &in_addr_arpa) || dns_name_issubdomain(name, &ip6_arpa) || dns_name_issubdomain(name, &ip6_int))) @@ -1950,11 +1948,11 @@ load_text(dns_loadctx_t *lctx) { rdatalist_size += RDLSZ; } this = &rdatalist[rdlcount++]; + dns_rdatalist_init(this); this->type = type; this->covers = covers; this->rdclass = lctx->zclass; this->ttl = lctx->ttl; - ISC_LIST_INIT(this->rdata); if (ictx->glue != NULL) ISC_LIST_INITANDPREPEND(glue_list, this, link); else @@ -2200,7 +2198,6 @@ load_raw(dns_loadctx_t *lctx) { ISC_LIST_INIT(head); ISC_LIST_INIT(dummy); - dns_rdatalist_init(&rdatalist); /* * Allocate target_size of buffer space. This is greater than twice @@ -2291,6 +2288,7 @@ load_raw(dns_loadctx_t *lctx) { isc_buffer_add(&target, (unsigned int)readlen); /* Construct RRset headers */ + dns_rdatalist_init(&rdatalist); rdatalist.rdclass = isc_buffer_getuint16(&target); rdatalist.type = isc_buffer_getuint16(&target); rdatalist.covers = isc_buffer_getuint16(&target); diff --git a/lib/dns/message.c b/lib/dns/message.c index b95e48ea2641..cd0e89b8d20e 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -42,6 +42,7 @@ #include <dns/rdatastruct.h> #include <dns/result.h> #include <dns/tsig.h> +#include <dns/ttl.h> #include <dns/view.h> #ifdef SKAN_MSG_DEBUG @@ -329,7 +330,7 @@ newrdatalist(dns_message_t *msg) { rdatalist = ISC_LIST_HEAD(msg->freerdatalist); if (rdatalist != NULL) { ISC_LIST_UNLINK(msg->freerdatalist, rdatalist, link); - return (rdatalist); + goto out; } msgblock = ISC_LIST_TAIL(msg->rdatalists); @@ -345,6 +346,9 @@ newrdatalist(dns_message_t *msg) { rdatalist = msgblock_get(msgblock, dns_rdatalist_t); } + out: + if (rdatalist != NULL) + dns_rdatalist_init(rdatalist); return (rdatalist); } @@ -1825,9 +1829,19 @@ wrong_priority(dns_rdataset_t *rds, int pass, dns_rdatatype_t preferred_glue) { * Decide whether to not answer with an AAAA record and its RRSIG */ static inline isc_boolean_t -norender_rdataset(const dns_rdataset_t *rdataset, unsigned int options) +norender_rdataset(const dns_rdataset_t *rdataset, unsigned int options, + dns_section_t sectionid) { + if (sectionid == DNS_SECTION_QUESTION) + return (ISC_FALSE); + switch (rdataset->type) { + case dns_rdatatype_ns: + if ((options & DNS_MESSAGERENDER_FILTER_AAAA) == 0 || + sectionid != DNS_SECTION_AUTHORITY) + return (ISC_FALSE); + break; + case dns_rdatatype_aaaa: if ((options & DNS_MESSAGERENDER_FILTER_AAAA) == 0) return (ISC_FALSE); @@ -1835,7 +1849,11 @@ norender_rdataset(const dns_rdataset_t *rdataset, unsigned int options) case dns_rdatatype_rrsig: if ((options & DNS_MESSAGERENDER_FILTER_AAAA) == 0 || - rdataset->covers != dns_rdatatype_aaaa) + (rdataset->covers != dns_rdatatype_ns && + rdataset->covers != dns_rdatatype_aaaa)) + return (ISC_FALSE); + if ((rdataset->covers == dns_rdatatype_ns) && + (sectionid != DNS_SECTION_AUTHORITY)) return (ISC_FALSE); break; @@ -1983,8 +2001,7 @@ dns_message_rendersection(dns_message_t *msg, dns_section_t sectionid, * not doing DNSSEC or are breaking DNSSEC. * Say so in the AD bit if we break DNSSEC. */ - if (norender_rdataset(rdataset, options) && - sectionid != DNS_SECTION_QUESTION) { + if (norender_rdataset(rdataset, options, sectionid)) { if (sectionid == DNS_SECTION_ANSWER || sectionid == DNS_SECTION_AUTHORITY) msg->flags &= ~DNS_MESSAGEFLAG_AD; @@ -2532,7 +2549,7 @@ dns_message_peekheader(isc_buffer_t *source, dns_messageid_t *idp, isc_result_t dns_message_reply(dns_message_t *msg, isc_boolean_t want_question_section) { - unsigned int clear_after; + unsigned int clear_from; isc_result_t result; REQUIRE(DNS_MESSAGE_VALID(msg)); @@ -2544,15 +2561,15 @@ dns_message_reply(dns_message_t *msg, isc_boolean_t want_question_section) { msg->opcode != dns_opcode_notify) want_question_section = ISC_FALSE; if (msg->opcode == dns_opcode_update) - clear_after = DNS_SECTION_PREREQUISITE; + clear_from = DNS_SECTION_PREREQUISITE; else if (want_question_section) { if (!msg->question_ok) return (DNS_R_FORMERR); - clear_after = DNS_SECTION_ANSWER; + clear_from = DNS_SECTION_ANSWER; } else - clear_after = DNS_SECTION_QUESTION; + clear_from = DNS_SECTION_QUESTION; msg->from_to_wire = DNS_MESSAGE_INTENTRENDER; - msgresetnames(msg, clear_after); + msgresetnames(msg, clear_from); msgresetopt(msg); msgresetsigs(msg, ISC_TRUE); msginitprivate(msg); @@ -2752,7 +2769,6 @@ dns_message_setquerytsig(dns_message_t *msg, isc_buffer_t *querytsig) { dns_rdata_init(rdata); dns_rdata_fromregion(rdata, dns_rdataclass_any, dns_rdatatype_tsig, &r); dns_message_takebuffer(msg, &buf); - ISC_LIST_INIT(list->rdata); ISC_LIST_APPEND(list->rdata, rdata, link); result = dns_rdatalist_tordataset(list, set); if (result != ISC_R_SUCCESS) @@ -3264,6 +3280,21 @@ dns_message_pseudosectiontotext(dns_message_t *msg, if (optcode == DNS_OPT_NSID) { ADD_STRING(target, "; NSID"); + } else if (optcode == DNS_OPT_COOKIE) { + ADD_STRING(target, "; COOKIE"); + } else if (optcode == DNS_OPT_EXPIRE) { + if (optlen == 4) { + isc_uint32_t secs; + secs = isc_buffer_getuint32(&optbuf); + ADD_STRING(target, "; EXPIRE: "); + snprintf(buf, sizeof(buf), "%u", secs); + ADD_STRING(target, buf); + ADD_STRING(target, " ("); + dns_ttl_totext(secs, ISC_TRUE, target); + ADD_STRING(target, ")\n"); + continue; + } + ADD_STRING(target, "; EXPIRE"); } else { ADD_STRING(target, "; OPT="); snprintf(buf, sizeof(buf), "%u", optcode); @@ -3276,10 +3307,31 @@ dns_message_pseudosectiontotext(dns_message_t *msg, optdata = isc_buffer_current(&optbuf); for (i = 0; i < optlen; i++) { - sprintf(buf, "%02x ", optdata[i]); + const char *sep; + switch (optcode) { + case DNS_OPT_COOKIE: + sep = ""; + break; + default: + sep = " "; + break; + } + snprintf(buf, sizeof(buf), "%02x%s", + optdata[i], sep); ADD_STRING(target, buf); } + isc_buffer_forward(&optbuf, optlen); + + if (optcode == DNS_OPT_COOKIE) { + ADD_STRING(target, "\n"); + continue; + } + + /* + * For non-COOKIE options, add a printable + * version + */ for (i = 0; i < optlen; i++) { ADD_STRING(target, " ("); if (!isc_buffer_availablelength(target)) @@ -3292,7 +3344,6 @@ dns_message_pseudosectiontotext(dns_message_t *msg, isc_buffer_putstr(target, "."); ADD_STRING(target, ")"); } - isc_buffer_forward(&optbuf, optlen); } ADD_STRING(target, "\n"); } @@ -3497,7 +3548,6 @@ dns_message_buildopt(dns_message_t *message, dns_rdataset_t **rdatasetp, dns_rdataset_init(rdataset); rdatalist->type = dns_rdatatype_opt; - rdatalist->covers = 0; /* * Set Maximum UDP buffer size. @@ -3545,7 +3595,6 @@ dns_message_buildopt(dns_message_t *message, dns_rdataset_t **rdatasetp, rdata->type = rdatalist->type; rdata->flags = 0; - ISC_LIST_INIT(rdatalist->rdata); ISC_LIST_APPEND(rdatalist->rdata, rdata, link); result = dns_rdatalist_tordataset(rdatalist, rdataset); RUNTIME_CHECK(result == ISC_R_SUCCESS); diff --git a/lib/dns/name.c b/lib/dns/name.c index 3b7ff3f962bf..6db373c03b0e 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -2114,11 +2114,9 @@ dns_name_split(dns_name_t *name, unsigned int suffixlabels, REQUIRE(prefix != NULL || suffix != NULL); REQUIRE(prefix == NULL || (VALID_NAME(prefix) && - prefix->buffer != NULL && BINDABLE(prefix))); REQUIRE(suffix == NULL || (VALID_NAME(suffix) && - suffix->buffer != NULL && BINDABLE(suffix))); splitlabel = name->labels - suffixlabels; @@ -2387,6 +2385,8 @@ dns_name_tostring(dns_name_t *name, char **target, isc_mem_t *mctx) { isc_buffer_usedregion(&buf, ®); p = isc_mem_allocate(mctx, reg.length + 1); + if (p == NULL) + return (ISC_R_NOMEMORY); memmove(p, (char *) reg.base, (int) reg.length); p[reg.length] = '\0'; @@ -2501,3 +2501,76 @@ dns_name_destroy(void) { #endif } + +/* + * Service Discovery Prefixes RFC 6763. + */ +static unsigned char b_dns_sd_udp_data[] = "\001b\007_dns-sd\004_udp"; +static unsigned char b_dns_sd_udp_offsets[] = { 0, 2, 10 }; +static unsigned char db_dns_sd_udp_data[] = "\002db\007_dns-sd\004_udp"; +static unsigned char db_dns_sd_udp_offsets[] = { 0, 3, 11 }; +static unsigned char r_dns_sd_udp_data[] = "\001r\007_dns-sd\004_udp"; +static unsigned char r_dns_sd_udp_offsets[] = { 0, 2, 10 }; +static unsigned char dr_dns_sd_udp_data[] = "\002dr\007_dns-sd\004_udp"; +static unsigned char dr_dns_sd_udp_offsets[] = { 0, 3, 11 }; +static unsigned char lb_dns_sd_udp_data[] = "\002lb\007_dns-sd\004_udp"; +static unsigned char lb_dns_sd_udp_offsets[] = { 0, 3, 11 }; + +static const dns_name_t dns_sd[] = { + { + DNS_NAME_MAGIC, + b_dns_sd_udp_data, 15, 3, + DNS_NAMEATTR_READONLY, + b_dns_sd_udp_offsets, NULL, + {(void *)-1, (void *)-1}, + {NULL, NULL} + }, + { + DNS_NAME_MAGIC, + db_dns_sd_udp_data, 16, 3, + DNS_NAMEATTR_READONLY, + db_dns_sd_udp_offsets, NULL, + {(void *)-1, (void *)-1}, + {NULL, NULL} + }, + { + DNS_NAME_MAGIC, + r_dns_sd_udp_data, 15, 3, + DNS_NAMEATTR_READONLY, + r_dns_sd_udp_offsets, NULL, + {(void *)-1, (void *)-1}, + {NULL, NULL} + }, + { + DNS_NAME_MAGIC, + dr_dns_sd_udp_data, 16, 3, + DNS_NAMEATTR_READONLY, + dr_dns_sd_udp_offsets, NULL, + {(void *)-1, (void *)-1}, + {NULL, NULL} + }, + { + DNS_NAME_MAGIC, + lb_dns_sd_udp_data, 16, 3, + DNS_NAMEATTR_READONLY, + lb_dns_sd_udp_offsets, NULL, + {(void *)-1, (void *)-1}, + {NULL, NULL} + } +}; + +isc_boolean_t +dns_name_isdnssd(const dns_name_t *name) { + size_t i; + dns_name_t prefix; + + if (dns_name_countlabels(name) > 3U) { + dns_name_init(&prefix, NULL); + dns_name_getlabelsequence(name, 0, 3, &prefix); + for (i = 0; i < (sizeof(dns_sd)/sizeof(dns_sd[0])); i++) + if (dns_name_equal(&prefix, &dns_sd[i])) + return (ISC_TRUE); + } + + return (ISC_FALSE); +} diff --git a/lib/dns/ncache.c b/lib/dns/ncache.c index bcb3d057898d..013cba8a21c6 100644 --- a/lib/dns/ncache.c +++ b/lib/dns/ncache.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2008, 2010-2013 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2008, 2010-2013, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -151,12 +151,10 @@ addoptout(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node, /* * Initialize the list. */ + dns_rdatalist_init(&ncrdatalist); ncrdatalist.rdclass = dns_db_class(cache); - ncrdatalist.type = 0; ncrdatalist.covers = covers; ncrdatalist.ttl = maxttl; - ISC_LIST_INIT(ncrdatalist.rdata); - ISC_LINK_INIT(&ncrdatalist, link); /* * Build an ncache rdatas into buffer. @@ -614,13 +612,11 @@ dns_ncache_getsigrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name, dns_name_fromregion(&tname, &remaining); INSIST(remaining.length >= tname.length); isc_buffer_forward(&source, tname.length); - remaining.length -= tname.length; - remaining.base += tname.length; + isc_region_consume(&remaining, tname.length); INSIST(remaining.length >= 2); type = isc_buffer_getuint16(&source); - remaining.length -= 2; - remaining.base += 2; + isc_region_consume(&remaining, 2); if (type != dns_rdatatype_rrsig || !dns_name_equal(&tname, name)) { @@ -632,8 +628,7 @@ dns_ncache_getsigrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name, INSIST(remaining.length >= 1); trust = isc_buffer_getuint8(&source); INSIST(trust <= dns_trust_ultimate); - remaining.length -= 1; - remaining.base += 1; + isc_region_consume(&remaining, 1); raw = remaining.base; count = raw[0] * 256 + raw[1]; diff --git a/lib/dns/nsec.c b/lib/dns/nsec.c index 6183ef281c02..f04a4c1ce454 100644 --- a/lib/dns/nsec.c +++ b/lib/dns/nsec.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007-2009, 2011-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007-2009, 2011-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -189,11 +189,10 @@ dns_nsec_build(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node, RETERR(dns_nsec_buildrdata(db, version, node, target, data, &rdata)); + dns_rdatalist_init(&rdatalist); rdatalist.rdclass = dns_db_class(db); rdatalist.type = dns_rdatatype_nsec; - rdatalist.covers = 0; rdatalist.ttl = ttl; - ISC_LIST_INIT(rdatalist.rdata); ISC_LIST_APPEND(rdatalist.rdata, &rdata, link); RETERR(dns_rdatalist_tordataset(&rdatalist, &rdataset)); result = dns_db_addrdataset(db, node, version, 0, &rdataset, diff --git a/lib/dns/nsec3.c b/lib/dns/nsec3.c index 11ae837a54a8..74ab9ddf6497 100644 --- a/lib/dns/nsec3.c +++ b/lib/dns/nsec3.c @@ -25,6 +25,7 @@ #include <isc/log.h> #include <isc/string.h> #include <isc/util.h> +#include <isc/safe.h> #include <dst/dst.h> @@ -1929,7 +1930,7 @@ dns_nsec3_noexistnodata(dns_rdatatype_t type, dns_name_t* name, * Work out what this NSEC3 covers. * Inside (<0) or outside (>=0). */ - scope = memcmp(owner, nsec3.next, nsec3.next_length); + scope = isc_safe_memcompare(owner, nsec3.next, nsec3.next_length); /* * Prepare to compute all the hashes. @@ -1954,7 +1955,7 @@ dns_nsec3_noexistnodata(dns_rdatatype_t type, dns_name_t* name, return (ISC_R_IGNORE); } - order = memcmp(hash, owner, length); + order = isc_safe_memcompare(hash, owner, length); if (first && order == 0) { /* * The hashes are the same. diff --git a/lib/dns/openssl_link.c b/lib/dns/openssl_link.c index a0a2724f41c1..8683bee4d60e 100644 --- a/lib/dns/openssl_link.c +++ b/lib/dns/openssl_link.c @@ -1,5 +1,5 @@ /* - * Portions Copyright (C) 2004-2012, 2014 Internet Systems Consortium, Inc. ("ISC") + * Portions Copyright (C) 2004-2012, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Portions Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -88,6 +88,7 @@ entropy_getpseudo(unsigned char *buf, int num) { return (result == ISC_R_SUCCESS ? 1 : -1); } +#if OPENSSL_VERSION_NUMBER < 0x10100000L static void entropy_add(const void *buf, int num, double entropy) { /* @@ -97,6 +98,18 @@ entropy_add(const void *buf, int num, double entropy) { UNUSED(num); UNUSED(entropy); } +#else +static int +entropy_add(const void *buf, int num, double entropy) { + /* + * Do nothing. The only call to this provides no useful data anyway. + */ + UNUSED(buf); + UNUSED(num); + UNUSED(entropy); + return (1); +} +#endif static void lock_callback(int mode, int type, const char *file, int line) { @@ -108,10 +121,12 @@ lock_callback(int mode, int type, const char *file, int line) { UNLOCK(&locks[type]); } +#if OPENSSL_VERSION_NUMBER < 0x10100000L static unsigned long id_callback(void) { return ((unsigned long)isc_thread_self()); } +#endif static void * mem_alloc(size_t size) { @@ -172,7 +187,9 @@ dst__openssl_init(const char *engine) { if (result != ISC_R_SUCCESS) goto cleanup_mutexalloc; CRYPTO_set_locking_callback(lock_callback); +#if OPENSSL_VERSION_NUMBER < 0x10100000L CRYPTO_set_id_callback(id_callback); +#endif ERR_load_crypto_strings(); @@ -270,7 +287,9 @@ dst__openssl_destroy(void) { CRYPTO_cleanup_all_ex_data(); #endif ERR_clear_error(); +#if OPENSSL_VERSION_NUMBER < 0x10100000L ERR_remove_state(0); +#endif ERR_free_strings(); #ifdef DNS_CRYPTO_LEAKS diff --git a/lib/dns/openssldh_link.c b/lib/dns/openssldh_link.c index 953e8fd50e4a..4d77c5bf164f 100644 --- a/lib/dns/openssldh_link.c +++ b/lib/dns/openssldh_link.c @@ -1,5 +1,5 @@ /* - * Portions Copyright (C) 2004-2009, 2011-2014 Internet Systems Consortium, Inc. ("ISC") + * Portions Copyright (C) 2004-2009, 2011-2015 Internet Systems Consortium, Inc. ("ISC") * Portions Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -71,7 +71,7 @@ static isc_result_t openssldh_todns(const dst_key_t *key, isc_buffer_t *data); -static BIGNUM bn2, bn768, bn1024, bn1536; +static BIGNUM *bn2, *bn768, *bn1024, *bn1536; static isc_result_t openssldh_computesecret(const dst_key_t *pub, const dst_key_t *priv, @@ -161,7 +161,7 @@ progress_cb(int p, int n, BN_GENCB *cb) UNUSED(n); - u.dptr = cb->arg; + u.dptr = BN_GENCB_get_arg(cb); if (u.fptr != NULL) u.fptr(p); return (1); @@ -172,7 +172,10 @@ static isc_result_t openssldh_generate(dst_key_t *key, int generator, void (*callback)(int)) { DH *dh = NULL; #if OPENSSL_VERSION_NUMBER > 0x00908000L - BN_GENCB cb; + BN_GENCB *cb; +#if OPENSSL_VERSION_NUMBER < 0x10100000L + BN_GENCB _cb; +#endif union { void *dptr; void (*fptr)(int); @@ -191,12 +194,12 @@ openssldh_generate(dst_key_t *key, int generator, void (*callback)(int)) { if (dh == NULL) return (dst__openssl_toresult(ISC_R_NOMEMORY)); if (key->key_size == 768) - dh->p = &bn768; + dh->p = bn768; else if (key->key_size == 1024) - dh->p = &bn1024; + dh->p = bn1024; else - dh->p = &bn1536; - dh->g = &bn2; + dh->p = bn1536; + dh->g = bn2; } else generator = 2; } @@ -206,31 +209,39 @@ openssldh_generate(dst_key_t *key, int generator, void (*callback)(int)) { dh = DH_new(); if (dh == NULL) return (dst__openssl_toresult(ISC_R_NOMEMORY)); - + cb = BN_GENCB_new(); +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + if (cb == NULL) { + DH_free(dh); + return (dst__openssl_toresult(ISC_R_NOMEMORY)); + } +#endif if (callback == NULL) { - BN_GENCB_set_old(&cb, NULL, NULL); + BN_GENCB_set_old(cb, NULL, NULL); } else { u.fptr = callback; - BN_GENCB_set(&cb, &progress_cb, u.dptr); + BN_GENCB_set(cb, &progress_cb, u.dptr); } if (!DH_generate_parameters_ex(dh, key->key_size, generator, - &cb)) { + cb)) { DH_free(dh); + BN_GENCB_free(cb); return (dst__openssl_toresult2( "DH_generate_parameters_ex", DST_R_OPENSSLFAILURE)); } + BN_GENCB_free(cb); #else dh = DH_generate_parameters(key->key_size, generator, NULL, NULL); + if (dh == NULL) + return (dst__openssl_toresult2( + "DH_generate_parameters", + DST_R_OPENSSLFAILURE)); #endif } - if (dh == NULL) - return (dst__openssl_toresult2("DH_generate_parameters", - DST_R_OPENSSLFAILURE)); - if (DH_generate_key(dh) == 0) { DH_free(dh); return (dst__openssl_toresult2("DH_generate_key", @@ -256,9 +267,9 @@ openssldh_destroy(dst_key_t *key) { if (dh == NULL) return; - if (dh->p == &bn768 || dh->p == &bn1024 || dh->p == &bn1536) + if (dh->p == bn768 || dh->p == bn1024 || dh->p == bn1536) dh->p = NULL; - if (dh->g == &bn2) + if (dh->g == bn2) dh->g = NULL; DH_free(dh); key->keydata.dh = NULL; @@ -266,8 +277,10 @@ openssldh_destroy(dst_key_t *key) { static void uint16_toregion(isc_uint16_t val, isc_region_t *region) { - *region->base++ = (val & 0xff00) >> 8; - *region->base++ = (val & 0x00ff); + *region->base = (val & 0xff00) >> 8; + isc_region_consume(region, 1); + *region->base = (val & 0x00ff); + isc_region_consume(region, 1); } static isc_uint16_t @@ -278,7 +291,8 @@ uint16_fromregion(isc_region_t *region) { val = ((unsigned int)(cp[0])) << 8; val |= ((unsigned int)(cp[1])); - region->base += 2; + isc_region_consume(region, 2); + return (val); } @@ -294,8 +308,8 @@ openssldh_todns(const dst_key_t *key, isc_buffer_t *data) { isc_buffer_availableregion(data, &r); - if (dh->g == &bn2 && - (dh->p == &bn768 || dh->p == &bn1024 || dh->p == &bn1536)) { + if (dh->g == bn2 && + (dh->p == bn768 || dh->p == bn1024 || dh->p == bn1536)) { plen = 1; glen = 0; } @@ -310,25 +324,25 @@ openssldh_todns(const dst_key_t *key, isc_buffer_t *data) { uint16_toregion(plen, &r); if (plen == 1) { - if (dh->p == &bn768) + if (dh->p == bn768) *r.base = 1; - else if (dh->p == &bn1024) + else if (dh->p == bn1024) *r.base = 2; else *r.base = 3; } else BN_bn2bin(dh->p, r.base); - r.base += plen; + isc_region_consume(&r, plen); uint16_toregion(glen, &r); if (glen > 0) BN_bn2bin(dh->g, r.base); - r.base += glen; + isc_region_consume(&r, glen); uint16_toregion(publen, &r); BN_bn2bin(dh->pub_key, r.base); - r.base += publen; + isc_region_consume(&r, publen); isc_buffer_add(data, dnslen); @@ -369,28 +383,29 @@ openssldh_fromdns(dst_key_t *key, isc_buffer_t *data) { return (DST_R_INVALIDPUBLICKEY); } if (plen == 1 || plen == 2) { - if (plen == 1) - special = *r.base++; - else + if (plen == 1) { + special = *r.base; + isc_region_consume(&r, 1); + } else { special = uint16_fromregion(&r); + } switch (special) { case 1: - dh->p = &bn768; + dh->p = bn768; break; case 2: - dh->p = &bn1024; + dh->p = bn1024; break; case 3: - dh->p = &bn1536; + dh->p = bn1536; break; default: DH_free(dh); return (DST_R_INVALIDPUBLICKEY); } - } - else { + } else { dh->p = BN_bin2bn(r.base, plen, NULL); - r.base += plen; + isc_region_consume(&r, plen); } /* @@ -409,27 +424,26 @@ openssldh_fromdns(dst_key_t *key, isc_buffer_t *data) { } if (special != 0) { if (glen == 0) - dh->g = &bn2; + dh->g = bn2; else { dh->g = BN_bin2bn(r.base, glen, NULL); - if (BN_cmp(dh->g, &bn2) == 0) { + if (BN_cmp(dh->g, bn2) == 0) { BN_free(dh->g); - dh->g = &bn2; + dh->g = bn2; } else { DH_free(dh); return (DST_R_INVALIDPUBLICKEY); } } - } - else { + } else { if (glen == 0) { DH_free(dh); return (DST_R_INVALIDPUBLICKEY); } dh->g = BN_bin2bn(r.base, glen, NULL); } - r.base += glen; + isc_region_consume(&r, glen); if (r.length < 2) { DH_free(dh); @@ -441,7 +455,7 @@ openssldh_fromdns(dst_key_t *key, isc_buffer_t *data) { return (DST_R_INVALIDPUBLICKEY); } dh->pub_key = BN_bin2bn(r.base, publen, NULL); - r.base += publen; + isc_region_consume(&r, publen); key->key_size = BN_num_bits(dh->p); @@ -563,25 +577,25 @@ openssldh_parse(dst_key_t *key, isc_lex_t *lexer, dst_key_t *pub) { if ((key->key_size == 768 || key->key_size == 1024 || key->key_size == 1536) && - BN_cmp(dh->g, &bn2) == 0) + BN_cmp(dh->g, bn2) == 0) { - if (key->key_size == 768 && BN_cmp(dh->p, &bn768) == 0) { + if (key->key_size == 768 && BN_cmp(dh->p, bn768) == 0) { BN_free(dh->p); BN_free(dh->g); - dh->p = &bn768; - dh->g = &bn2; + dh->p = bn768; + dh->g = bn2; } else if (key->key_size == 1024 && - BN_cmp(dh->p, &bn1024) == 0) { + BN_cmp(dh->p, bn1024) == 0) { BN_free(dh->p); BN_free(dh->g); - dh->p = &bn1024; - dh->g = &bn2; + dh->p = bn1024; + dh->g = bn2; } else if (key->key_size == 1536 && - BN_cmp(dh->p, &bn1536) == 0) { + BN_cmp(dh->p, bn1536) == 0) { BN_free(dh->p); BN_free(dh->g); - dh->p = &bn1536; - dh->g = &bn2; + dh->p = bn1536; + dh->g = bn2; } } @@ -622,10 +636,10 @@ BN_fromhex(BIGNUM *b, const char *str) { static void openssldh_cleanup(void) { - BN_free(&bn2); - BN_free(&bn768); - BN_free(&bn1024); - BN_free(&bn1536); + BN_free(bn2); + BN_free(bn768); + BN_free(bn1024); + BN_free(bn1536); } static dst_func_t openssldh_functions = { @@ -655,17 +669,27 @@ isc_result_t dst__openssldh_init(dst_func_t **funcp) { REQUIRE(funcp != NULL); if (*funcp == NULL) { - BN_init(&bn2); - BN_init(&bn768); - BN_init(&bn1024); - BN_init(&bn1536); - BN_set_word(&bn2, 2); - BN_fromhex(&bn768, PRIME768); - BN_fromhex(&bn1024, PRIME1024); - BN_fromhex(&bn1536, PRIME1536); + bn2 = BN_new(); + bn768 = BN_new(); + bn1024 = BN_new(); + bn1536 = BN_new(); + if (bn2 == NULL || bn768 == NULL || + bn1024 == NULL || bn1536 == NULL) + goto cleanup; + BN_set_word(bn2, 2); + BN_fromhex(bn768, PRIME768); + BN_fromhex(bn1024, PRIME1024); + BN_fromhex(bn1536, PRIME1536); *funcp = &openssldh_functions; } return (ISC_R_SUCCESS); + + cleanup: + if (bn2 != NULL) BN_free(bn2); + if (bn768 != NULL) BN_free(bn768); + if (bn1024 != NULL) BN_free(bn1024); + if (bn1536 != NULL) BN_free(bn1536); + return (ISC_R_NOMEMORY); } #else /* OPENSSL */ diff --git a/lib/dns/openssldsa_link.c b/lib/dns/openssldsa_link.c index 61e64db0d4a5..34348f07767f 100644 --- a/lib/dns/openssldsa_link.c +++ b/lib/dns/openssldsa_link.c @@ -1,5 +1,5 @@ /* - * Portions Copyright (C) 2004-2009, 2011-2013 Internet Systems Consortium, Inc. ("ISC") + * Portions Copyright (C) 2004-2009, 2011-2013, 2015 Internet Systems Consortium, Inc. ("ISC") * Portions Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -29,8 +29,6 @@ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id$ */ - #ifdef OPENSSL #ifndef USE_EVP #define USE_EVP 1 @@ -137,6 +135,7 @@ openssldsa_sign(dst_context_t *dctx, isc_buffer_t *sig) { DSA *dsa = key->keydata.dsa; isc_region_t r; DSA_SIG *dsasig; + unsigned int klen; #if USE_EVP EVP_MD_CTX *evp_md_ctx = dctx->ctxdata.evp_md_ctx; EVP_PKEY *pkey; @@ -188,6 +187,7 @@ openssldsa_sign(dst_context_t *dctx, isc_buffer_t *sig) { ISC_R_FAILURE)); } free(sigbuf); + #elif 0 /* Only use EVP for the Digest */ if (!EVP_DigestFinal_ex(evp_md_ctx, digest, &siglen)) { @@ -209,11 +209,17 @@ openssldsa_sign(dst_context_t *dctx, isc_buffer_t *sig) { "DSA_do_sign", DST_R_SIGNFAILURE)); #endif - *r.base++ = (key->key_size - 512)/64; + + klen = (key->key_size - 512)/64; + if (klen > 255) + return (ISC_R_FAILURE); + *r.base = klen; + isc_region_consume(&r, 1); + BN_bn2bin_fixed(dsasig->r, r.base, ISC_SHA1_DIGESTLENGTH); - r.base += ISC_SHA1_DIGESTLENGTH; + isc_region_consume(&r, ISC_SHA1_DIGESTLENGTH); BN_bn2bin_fixed(dsasig->s, r.base, ISC_SHA1_DIGESTLENGTH); - r.base += ISC_SHA1_DIGESTLENGTH; + isc_region_consume(&r, ISC_SHA1_DIGESTLENGTH); DSA_SIG_free(dsasig); isc_buffer_add(sig, ISC_SHA1_DIGESTLENGTH * 2 + 1); @@ -339,7 +345,7 @@ progress_cb(int p, int n, BN_GENCB *cb) UNUSED(n); - u.dptr = cb->arg; + u.dptr = BN_GENCB_get_arg(cb); if (u.fptr != NULL) u.fptr(p); return (1); @@ -352,7 +358,10 @@ openssldsa_generate(dst_key_t *key, int unused, void (*callback)(int)) { unsigned char rand_array[ISC_SHA1_DIGESTLENGTH]; isc_result_t result; #if OPENSSL_VERSION_NUMBER > 0x00908000L - BN_GENCB cb; + BN_GENCB *cb; +#if OPENSSL_VERSION_NUMBER < 0x10100000L + BN_GENCB _cb; +#endif union { void *dptr; void (*fptr)(int); @@ -373,22 +382,30 @@ openssldsa_generate(dst_key_t *key, int unused, void (*callback)(int)) { dsa = DSA_new(); if (dsa == NULL) return (dst__openssl_toresult(DST_R_OPENSSLFAILURE)); - + cb = BN_GENCB_new(); +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + if (cb == NULL) { + DSA_free(dsa); + return (dst__openssl_toresult(DST_R_OPENSSLFAILURE)); + } +#endif if (callback == NULL) { - BN_GENCB_set_old(&cb, NULL, NULL); + BN_GENCB_set_old(cb, NULL, NULL); } else { u.fptr = callback; - BN_GENCB_set(&cb, &progress_cb, u.dptr); + BN_GENCB_set(cb, &progress_cb, u.dptr); } if (!DSA_generate_parameters_ex(dsa, key->key_size, rand_array, ISC_SHA1_DIGESTLENGTH, NULL, NULL, - &cb)) + cb)) { DSA_free(dsa); + BN_GENCB_free(cb); return (dst__openssl_toresult2("DSA_generate_parameters_ex", DST_R_OPENSSLFAILURE)); } + BN_GENCB_free(cb); #else dsa = DSA_generate_parameters(key->key_size, rand_array, ISC_SHA1_DIGESTLENGTH, NULL, NULL, @@ -446,15 +463,16 @@ openssldsa_todns(const dst_key_t *key, isc_buffer_t *data) { if (r.length < (unsigned int) dnslen) return (ISC_R_NOSPACE); - *r.base++ = t; + *r.base = t; + isc_region_consume(&r, 1); BN_bn2bin_fixed(dsa->q, r.base, ISC_SHA1_DIGESTLENGTH); - r.base += ISC_SHA1_DIGESTLENGTH; + isc_region_consume(&r, ISC_SHA1_DIGESTLENGTH); BN_bn2bin_fixed(dsa->p, r.base, key->key_size/8); - r.base += p_bytes; + isc_region_consume(&r, p_bytes); BN_bn2bin_fixed(dsa->g, r.base, key->key_size/8); - r.base += p_bytes; + isc_region_consume(&r, p_bytes); BN_bn2bin_fixed(dsa->pub_key, r.base, key->key_size/8); - r.base += p_bytes; + isc_region_consume(&r, p_bytes); isc_buffer_add(data, dnslen); @@ -479,29 +497,30 @@ openssldsa_fromdns(dst_key_t *key, isc_buffer_t *data) { return (ISC_R_NOMEMORY); dsa->flags &= ~DSA_FLAG_CACHE_MONT_P; - t = (unsigned int) *r.base++; + t = (unsigned int) *r.base; + isc_region_consume(&r, 1); if (t > 8) { DSA_free(dsa); return (DST_R_INVALIDPUBLICKEY); } p_bytes = 64 + 8 * t; - if (r.length < 1 + ISC_SHA1_DIGESTLENGTH + 3 * p_bytes) { + if (r.length < ISC_SHA1_DIGESTLENGTH + 3 * p_bytes) { DSA_free(dsa); return (DST_R_INVALIDPUBLICKEY); } dsa->q = BN_bin2bn(r.base, ISC_SHA1_DIGESTLENGTH, NULL); - r.base += ISC_SHA1_DIGESTLENGTH; + isc_region_consume(&r, ISC_SHA1_DIGESTLENGTH); dsa->p = BN_bin2bn(r.base, p_bytes, NULL); - r.base += p_bytes; + isc_region_consume(&r, p_bytes); dsa->g = BN_bin2bn(r.base, p_bytes, NULL); - r.base += p_bytes; + isc_region_consume(&r, p_bytes); dsa->pub_key = BN_bin2bn(r.base, p_bytes, NULL); - r.base += p_bytes; + isc_region_consume(&r, p_bytes); key->key_size = p_bytes * 8; diff --git a/lib/dns/opensslecdsa_link.c b/lib/dns/opensslecdsa_link.c index 34f8ba03b092..7a6f69bca00a 100644 --- a/lib/dns/opensslecdsa_link.c +++ b/lib/dns/opensslecdsa_link.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -14,8 +14,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id$ */ - #include <config.h> #ifdef HAVE_OPENSSL_ECDSA @@ -159,9 +157,9 @@ opensslecdsa_sign(dst_context_t *dctx, isc_buffer_t *sig) { "ECDSA_do_sign", DST_R_SIGNFAILURE)); BN_bn2bin_fixed(ecdsasig->r, r.base, siglen / 2); - r.base += siglen / 2; + isc_region_consume(&r, siglen / 2); BN_bn2bin_fixed(ecdsasig->s, r.base, siglen / 2); - r.base += siglen / 2; + isc_region_consume(&r, siglen / 2); ECDSA_SIG_free(ecdsasig); isc_buffer_add(sig, siglen); ret = ISC_R_SUCCESS; diff --git a/lib/dns/opensslgost_link.c b/lib/dns/opensslgost_link.c index a01e9f32bb25..dd421b8ddd9f 100644 --- a/lib/dns/opensslgost_link.c +++ b/lib/dns/opensslgost_link.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2010-2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -14,14 +14,13 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: opensslgost_link.c,v 1.5 2011/01/19 23:47:12 tbox Exp $ */ - #include <config.h> #ifdef HAVE_OPENSSL_GOST #include <isc/entropy.h> #include <isc/mem.h> +#include <isc/safe.h> #include <isc/string.h> #include <isc/util.h> @@ -253,7 +252,7 @@ opensslgost_todns(const dst_key_t *key, isc_buffer_t *data) { p = der; len = i2d_PUBKEY(pkey, &p); INSIST(len == sizeof(der)); - INSIST(memcmp(gost_prefix, der, 37) == 0); + INSIST(isc_safe_memequal(gost_prefix, der, 37)); memmove(r.base, der + 37, 64); isc_buffer_add(data, 64); diff --git a/lib/dns/opensslrsa_link.c b/lib/dns/opensslrsa_link.c index 8421c640708a..624b082fb00f 100644 --- a/lib/dns/opensslrsa_link.c +++ b/lib/dns/opensslrsa_link.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2009, 2011-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2009, 2011-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -33,9 +33,10 @@ #include <isc/entropy.h> #include <isc/md5.h> +#include <isc/mem.h> +#include <isc/safe.h> #include <isc/sha1.h> #include <isc/sha2.h> -#include <isc/mem.h> #include <isc/string.h> #include <isc/util.h> @@ -650,9 +651,10 @@ opensslrsa_verify2(dst_context_t *dctx, int maxbits, const isc_region_t *sig) { DST_R_VERIFYFAILURE)); if (status != (int)(prefixlen + digestlen)) return (DST_R_VERIFYFAILURE); - if (memcmp(original, prefix, prefixlen)) + if (!isc_safe_memequal(original, prefix, prefixlen)) return (DST_R_VERIFYFAILURE); - if (memcmp(original + prefixlen, digest, digestlen)) + if (!isc_safe_memequal(original + prefixlen, + digest, digestlen)) return (DST_R_VERIFYFAILURE); status = 1; } @@ -753,7 +755,7 @@ progress_cb(int p, int n, BN_GENCB *cb) UNUSED(n); - u.dptr = cb->arg; + u.dptr = BN_GENCB_get_arg(cb); if (u.fptr != NULL) u.fptr(p); return (1); @@ -764,18 +766,21 @@ static isc_result_t opensslrsa_generate(dst_key_t *key, int exp, void (*callback)(int)) { #if OPENSSL_VERSION_NUMBER > 0x00908000L isc_result_t ret = DST_R_OPENSSLFAILURE; - BN_GENCB cb; union { void *dptr; void (*fptr)(int); } u; RSA *rsa = RSA_new(); BIGNUM *e = BN_new(); +#if OPENSSL_VERSION_NUMBER < 0x10100000L + BN_GENCB _cb; +#endif + BN_GENCB *cb = BN_GENCB_new(); #if USE_EVP EVP_PKEY *pkey = EVP_PKEY_new(); #endif - if (rsa == NULL || e == NULL) + if (rsa == NULL || e == NULL || cb == NULL) goto err; #if USE_EVP if (pkey == NULL) @@ -795,14 +800,15 @@ opensslrsa_generate(dst_key_t *key, int exp, void (*callback)(int)) { } if (callback == NULL) { - BN_GENCB_set_old(&cb, NULL, NULL); + BN_GENCB_set_old(cb, NULL, NULL); } else { u.fptr = callback; - BN_GENCB_set(&cb, &progress_cb, u.dptr); + BN_GENCB_set(cb, &progress_cb, u.dptr); } - if (RSA_generate_key_ex(rsa, key->key_size, e, &cb)) { + if (RSA_generate_key_ex(rsa, key->key_size, e, cb)) { BN_free(e); + BN_GENCB_free(cb); SET_FLAGS(rsa); #if USE_EVP key->keydata.pkey = pkey; @@ -813,6 +819,7 @@ opensslrsa_generate(dst_key_t *key, int exp, void (*callback)(int)) { #endif return (ISC_R_SUCCESS); } + BN_GENCB_free(cb); ret = dst__openssl_toresult2("RSA_generate_key_ex", DST_R_OPENSSLFAILURE); @@ -825,6 +832,8 @@ err: BN_free(e); if (rsa != NULL) RSA_free(rsa); + if (cb != NULL) + BN_GENCB_free(cb); return (dst__openssl_toresult(ret)); #else RSA *rsa; @@ -965,6 +974,7 @@ opensslrsa_fromdns(dst_key_t *key, isc_buffer_t *data) { RSA *rsa; isc_region_t r; unsigned int e_bytes; + unsigned int length; #if USE_EVP EVP_PKEY *pkey; #endif @@ -972,6 +982,7 @@ opensslrsa_fromdns(dst_key_t *key, isc_buffer_t *data) { isc_buffer_remainingregion(data, &r); if (r.length == 0) return (ISC_R_SUCCESS); + length = r.length; rsa = RSA_new(); if (rsa == NULL) @@ -982,17 +993,18 @@ opensslrsa_fromdns(dst_key_t *key, isc_buffer_t *data) { RSA_free(rsa); return (DST_R_INVALIDPUBLICKEY); } - e_bytes = *r.base++; - r.length--; + e_bytes = *r.base; + isc_region_consume(&r, 1); if (e_bytes == 0) { if (r.length < 2) { RSA_free(rsa); return (DST_R_INVALIDPUBLICKEY); } - e_bytes = ((*r.base++) << 8); - e_bytes += *r.base++; - r.length -= 2; + e_bytes = (*r.base) << 8; + isc_region_consume(&r, 1); + e_bytes += *r.base; + isc_region_consume(&r, 1); } if (r.length < e_bytes) { @@ -1000,14 +1012,13 @@ opensslrsa_fromdns(dst_key_t *key, isc_buffer_t *data) { return (DST_R_INVALIDPUBLICKEY); } rsa->e = BN_bin2bn(r.base, e_bytes, NULL); - r.base += e_bytes; - r.length -= e_bytes; + isc_region_consume(&r, e_bytes); rsa->n = BN_bin2bn(r.base, r.length, NULL); key->key_size = BN_num_bits(rsa->n); - isc_buffer_forward(data, r.length); + isc_buffer_forward(data, length); #if USE_EVP pkey = EVP_PKEY_new(); @@ -1375,12 +1386,21 @@ opensslrsa_fromlabel(dst_key_t *key, const char *engine, const char *label, isc_result_t ret; EVP_PKEY *pkey = NULL; RSA *rsa = NULL, *pubrsa = NULL; - char *colon; + char *colon, *tmpengine = NULL; UNUSED(pin); - if (engine == NULL) - DST_RET(DST_R_NOENGINE); + if (engine == NULL) { + colon = strchr(label, ':'); + if (colon == NULL) + DST_RET(DST_R_NOENGINE); + tmpengine = isc_mem_strdup(key->mctx, label); + if (tmpengine == NULL) + DST_RET(ISC_R_NOMEMORY); + colon = strchr(tmpengine, ':'); + INSIST(colon != NULL); + *colon = '\0'; + } e = dst__openssl_getengine(engine); if (e == NULL) DST_RET(DST_R_NOENGINE); @@ -1395,17 +1415,13 @@ opensslrsa_fromlabel(dst_key_t *key, const char *engine, const char *label, if (pkey == NULL) DST_RET(dst__openssl_toresult2("ENGINE_load_private_key", ISC_R_NOTFOUND)); - if (engine != NULL) { - key->engine = isc_mem_strdup(key->mctx, engine); - if (key->engine == NULL) - DST_RET(ISC_R_NOMEMORY); + if (tmpengine != NULL) { + key->engine = tmpengine; + tmpengine = NULL; } else { - key->engine = isc_mem_strdup(key->mctx, label); + key->engine = isc_mem_strdup(key->mctx, engine); if (key->engine == NULL) DST_RET(ISC_R_NOMEMORY); - colon = strchr(key->engine, ':'); - if (colon != NULL) - *colon = '\0'; } key->label = isc_mem_strdup(key->mctx, label); if (key->label == NULL) @@ -1430,6 +1446,8 @@ opensslrsa_fromlabel(dst_key_t *key, const char *engine, const char *label, return (ISC_R_SUCCESS); err: + if (tmpengine != NULL) + isc_mem_free(key->mctx, tmpengine); if (rsa != NULL) RSA_free(rsa); if (pubrsa != NULL) diff --git a/lib/dns/order.c b/lib/dns/order.c index 853b00196d21..326b8f93cf14 100644 --- a/lib/dns/order.c +++ b/lib/dns/order.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -48,7 +48,7 @@ struct dns_order { ISC_LIST(dns_order_ent_t) ents; isc_mem_t *mctx; }; - + #define DNS_ORDER_MAGIC ISC_MAGIC('O','r','d','r') #define DNS_ORDER_VALID(order) ISC_MAGIC_VALID(order, DNS_ORDER_MAGIC) @@ -62,7 +62,7 @@ dns_order_create(isc_mem_t *mctx, dns_order_t **orderp) { order = isc_mem_get(mctx, sizeof(*order)); if (order == NULL) return (ISC_R_NOMEMORY); - + ISC_LIST_INIT(order->ents); /* Implicit attach. */ @@ -88,7 +88,7 @@ dns_order_add(dns_order_t *order, dns_name_t *name, REQUIRE(DNS_ORDER_VALID(order)); REQUIRE(mode == DNS_RDATASETATTR_RANDOMIZE || - mode == DNS_RDATASETATTR_FIXEDORDER || + mode == DNS_RDATASETATTR_FIXEDORDER || mode == 0 /* DNS_RDATASETATTR_CYCLIC */ ); ent = isc_mem_get(order->mctx, sizeof(*ent)); @@ -108,7 +108,7 @@ dns_order_add(dns_order_t *order, dns_name_t *name, static inline isc_boolean_t match(dns_name_t *name1, dns_name_t *name2) { - + if (dns_name_iswildcard(name2)) return(dns_name_matcheswildcard(name1, name2)); return (dns_name_equal(name1, name2)); @@ -132,7 +132,7 @@ dns_order_find(dns_order_t *order, dns_name_t *name, if (match(name, dns_fixedname_name(&ent->name))) return (ent->mode); } - return (0); + return (DNS_RDATASETATTR_RANDOMIZE); } void diff --git a/lib/dns/private.c b/lib/dns/private.c index c29522c52990..76a26e827728 100644 --- a/lib/dns/private.c +++ b/lib/dns/private.c @@ -18,10 +18,11 @@ #include "config.h" +#include <isc/base64.h> +#include <isc/print.h> #include <isc/result.h> #include <isc/string.h> #include <isc/types.h> -#include <isc/base64.h> #include <dns/nsec3.h> #include <dns/private.h> @@ -306,7 +307,7 @@ dns_private_totext(dns_rdata_t *private, isc_buffer_t *buf) { unsigned char newbuf[DNS_NSEC3PARAM_BUFFERSIZE]; dns_rdata_t rdata = DNS_RDATA_INIT; dns_rdata_nsec3param_t nsec3param; - isc_boolean_t remove, init, nonsec; + isc_boolean_t delete, init, nonsec; isc_buffer_t b; if (!dns_nsec3param_fromprivate(private, &rdata, nsec3buf, @@ -315,7 +316,7 @@ dns_private_totext(dns_rdata_t *private, isc_buffer_t *buf) { CHECK(dns_rdata_tostruct(&rdata, &nsec3param, NULL)); - remove = ISC_TF((nsec3param.flags & DNS_NSEC3FLAG_REMOVE) != 0); + delete = ISC_TF((nsec3param.flags & DNS_NSEC3FLAG_REMOVE) != 0); init = ISC_TF((nsec3param.flags & DNS_NSEC3FLAG_INITIAL) != 0); nonsec = ISC_TF((nsec3param.flags & DNS_NSEC3FLAG_NONSEC) != 0); @@ -326,7 +327,7 @@ dns_private_totext(dns_rdata_t *private, isc_buffer_t *buf) { if (init) isc_buffer_putstr(buf, "Pending NSEC3 chain "); - else if (remove) + else if (delete) isc_buffer_putstr(buf, "Removing NSEC3 chain "); else isc_buffer_putstr(buf, "Creating NSEC3 chain "); @@ -339,18 +340,18 @@ dns_private_totext(dns_rdata_t *private, isc_buffer_t *buf) { CHECK(dns_rdata_totext(&rdata, NULL, buf)); - if (remove && !nonsec) + if (delete && !nonsec) isc_buffer_putstr(buf, " / creating NSEC chain"); } else if (private->length == 5) { unsigned char alg = private->data[0]; dns_keytag_t keyid = (private->data[2] | private->data[1] << 8); char keybuf[BUFSIZ], algbuf[DNS_SECALG_FORMATSIZE]; - isc_boolean_t remove = ISC_TF(private->data[3] != 0); + isc_boolean_t delete = ISC_TF(private->data[3] != 0); isc_boolean_t complete = ISC_TF(private->data[4] != 0); - if (remove && complete) + if (delete && complete) isc_buffer_putstr(buf, "Done removing signatures for "); - else if (remove) + else if (delete) isc_buffer_putstr(buf, "Removing signatures for "); else if (complete) isc_buffer_putstr(buf, "Done signing with "); diff --git a/lib/dns/rbt.c b/lib/dns/rbt.c index 1b6121de7945..74aad1b3553f 100644 --- a/lib/dns/rbt.c +++ b/lib/dns/rbt.c @@ -1610,8 +1610,7 @@ rotate_left(dns_rbtnode_t *node, dns_rbtnode_t **rootp) { PARENT(LEFT(child)) = node; LEFT(child) = node; - if (child != NULL) - PARENT(child) = PARENT(node); + PARENT(child) = PARENT(node); if (IS_ROOT(node)) { *rootp = child; @@ -1643,8 +1642,7 @@ rotate_right(dns_rbtnode_t *node, dns_rbtnode_t **rootp) { PARENT(RIGHT(child)) = node; RIGHT(child) = node; - if (child != NULL) - PARENT(child) = PARENT(node); + PARENT(child) = PARENT(node); if (IS_ROOT(node)) { *rootp = child; diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index a1398d3d1ab1..a0fa148cf545 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -753,7 +753,7 @@ typedef struct rbtdb_dbiterator { static void free_rbtdb(dns_rbtdb_t *rbtdb, isc_boolean_t log, isc_event_t *event); -static void overmem(dns_db_t *db, isc_boolean_t overmem); +static void overmem(dns_db_t *db, isc_boolean_t over); #ifdef BIND9 static void setnsec3parameters(dns_db_t *db, rbtdb_version_t *version); #endif @@ -852,11 +852,14 @@ set_ttl(dns_rbtdb_t *rbtdb, rdatasetheader_t *header, dns_ttl_t newttl) { isc_heap_t *heap; dns_ttl_t oldttl; - oldttl = header->rdh_ttl; - header->rdh_ttl = newttl; - if (!IS_CACHE(rbtdb)) + if (!IS_CACHE(rbtdb)) { + header->rdh_ttl = newttl; return; + } + + oldttl = header->rdh_ttl; + header->rdh_ttl = newttl; /* * It's possible the rbtdb is not a cache. If this is the case, @@ -904,10 +907,10 @@ resign_sooner(void *v1, void *v2) { * This function sets the heap index into the header. */ static void -set_index(void *what, unsigned int index) { +set_index(void *what, unsigned int idx) { rdatasetheader_t *h = what; - h->heap_index = index; + h->heap_index = idx; } /*% @@ -1385,6 +1388,7 @@ new_rdataset(dns_rbtdb_t *rbtdb, isc_mem_t *mctx) fprintf(stderr, "allocated header: %p\n", h); #endif init_rdataset(rbtdb, h); + h->rdh_ttl = 0; return (h); } @@ -2192,6 +2196,7 @@ setnsec3parameters(dns_db_t *db, rbtdb_version_t *version) { unsigned int count, length; dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)db; + RWLOCK(&rbtdb->tree_lock, isc_rwlocktype_read); version->havensec3 = ISC_FALSE; node = rbtdb->origin_node; NODE_LOCK(&(rbtdb->node_locks[node->locknum].lock), @@ -2268,6 +2273,7 @@ setnsec3parameters(dns_db_t *db, rbtdb_version_t *version) { unlock: NODE_UNLOCK(&(rbtdb->node_locks[node->locknum].lock), isc_rwlocktype_read); + RWUNLOCK(&rbtdb->tree_lock, isc_rwlocktype_read); } #endif @@ -2330,6 +2336,13 @@ closeversion(dns_db_t *db, dns_dbversion_t **versionp, isc_boolean_t commit) { goto end; } + /* + * Update the zone's secure status in version before making + * it the current version. + */ + if (version->writer && commit && !IS_CACHE(rbtdb)) + iszonesecure(db, version, rbtdb->origin_node); + RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_write); serial = version->serial; if (version->writer) { @@ -2388,11 +2401,6 @@ closeversion(dns_db_t *db, dns_dbversion_t **versionp, isc_boolean_t commit) { link); } /* - * Update the zone's secure status. - */ - if (!IS_CACHE(rbtdb)) - iszonesecure(db, version, rbtdb->origin_node); - /* * Become the current version. */ version->writer = ISC_FALSE; @@ -5580,11 +5588,11 @@ expirenode(dns_db_t *db, dns_dbnode_t *node, isc_stdtime_t now) { } static void -overmem(dns_db_t *db, isc_boolean_t overmem) { +overmem(dns_db_t *db, isc_boolean_t over) { /* This is an empty callback. See adb.c:water() */ UNUSED(db); - UNUSED(overmem); + UNUSED(over); return; } diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index 9e1eebe70d29..6c0a3195379b 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -223,6 +223,21 @@ unknown_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, /*% IPv6 Address Size */ #define NS_LOCATORSZ 8 +/* + * Active Diretory gc._msdcs.<forest> prefix. + */ +static unsigned char gc_msdcs_data[] = "\002gc\006_msdcs"; +static unsigned char gc_msdcs_offset [] = { 0, 3 }; + +static const dns_name_t gc_msdcs = { + DNS_NAME_MAGIC, + gc_msdcs_data, 10, 2, + DNS_NAMEATTR_READONLY, + gc_msdcs_offset, NULL, + {(void *)-1, (void *)-1}, + {NULL, NULL} +}; + /*% * convert presentation level address to network order binary form. * \return @@ -313,15 +328,15 @@ name_duporclone(dns_name_t *source, isc_mem_t *mctx, dns_name_t *target) { static inline void * mem_maybedup(isc_mem_t *mctx, void *source, size_t length) { - void *new; + void *copy; if (mctx == NULL) return (source); - new = isc_mem_allocate(mctx, length); - if (new != NULL) - memmove(new, source, length); + copy = isc_mem_allocate(mctx, length); + if (copy != NULL) + memmove(copy, source, length); - return (new); + return (copy); } static const char hexdigits[] = "0123456789abcdef"; @@ -836,6 +851,7 @@ rdata_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, { isc_result_t result = ISC_R_NOTIMPLEMENTED; isc_boolean_t use_default = ISC_FALSE; + unsigned int cur; REQUIRE(rdata != NULL); REQUIRE(tctx->origin == NULL || @@ -849,10 +865,17 @@ rdata_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, return (ISC_R_SUCCESS); } + cur = isc_buffer_usedlength(target); + TOTEXTSWITCH - if (use_default) + if (use_default || (result == ISC_R_NOTIMPLEMENTED)) { + unsigned int u = isc_buffer_usedlength(target); + + INSIST(u >= cur); + isc_buffer_subtract(target, u - cur); result = unknown_totext(rdata, tctx, target); + } return (result); } @@ -1269,7 +1292,7 @@ txt_fromwire(isc_buffer_t *source, isc_buffer_t *target) { isc_buffer_activeregion(source, &sregion); if (sregion.length == 0) - return(ISC_R_UNEXPECTEDEND); + return (ISC_R_UNEXPECTEDEND); n = *sregion.base + 1; if (n > sregion.length) return (ISC_R_UNEXPECTEDEND); @@ -1398,7 +1421,7 @@ multitxt_fromtext(isc_textregion_t *source, isc_buffer_t *target) { if (escape) return (DNS_R_SYNTAX); - isc_buffer_add(target, t - t0); + isc_buffer_add(target, (unsigned int)(t - t0)); } while (n != 0); return (ISC_R_SUCCESS); } @@ -1579,7 +1602,7 @@ mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length) { static int hexvalue(char value) { - char *s; + const char *s; unsigned char c; c = (unsigned char)value; @@ -1595,7 +1618,7 @@ hexvalue(char value) { static int decvalue(char value) { - char *s; + const char *s; /* * isascii() is valid for full range of int values, no need to @@ -1653,7 +1676,7 @@ static isc_result_t byte_btoa(int c, isc_buffer_t *, struct state *state); */ static isc_result_t byte_atob(int c, isc_buffer_t *target, struct state *state) { - char *s; + const char *s; if (c == 'z') { if (bcount != 0) return(DNS_R_SYNTAX); @@ -1749,8 +1772,12 @@ atob_tobuffer(isc_lex_t *lexer, isc_buffer_t *target) { */ RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); - if ((token.value.as_ulong % 4) != 0U) - isc_buffer_subtract(target, 4 - (token.value.as_ulong % 4)); + if ((token.value.as_ulong % 4) != 0U) { + unsigned long padding = 4 - (token.value.as_ulong % 4); + if (isc_buffer_usedlength(target) < padding) + return (DNS_R_SYNTAX); + isc_buffer_subtract(target, padding); + } /* * Checksum. diff --git a/lib/dns/rdata/any_255/tsig_250.c b/lib/dns/rdata/any_255/tsig_250.c index 3f91f91c009a..65ceb84152c9 100644 --- a/lib/dns/rdata/any_255/tsig_250.c +++ b/lib/dns/rdata/any_255/tsig_250.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009, 2011, 2012 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2011, 2012, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -35,8 +35,8 @@ fromtext_any_tsig(ARGS_FROMTEXT) { long i; char *e; - REQUIRE(type == 250); - REQUIRE(rdclass == 255); + REQUIRE(type == dns_rdatatype_tsig); + REQUIRE(rdclass == dns_rdataclass_any); UNUSED(type); UNUSED(rdclass); @@ -141,8 +141,8 @@ totext_any_tsig(ARGS_TOTEXT) { isc_uint64_t sigtime; unsigned short n; - REQUIRE(rdata->type == 250); - REQUIRE(rdata->rdclass == 255); + REQUIRE(rdata->type == dns_rdatatype_tsig); + REQUIRE(rdata->rdclass == dns_rdataclass_any); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, &sr); @@ -251,8 +251,8 @@ fromwire_any_tsig(ARGS_FROMWIRE) { dns_name_t name; unsigned long n; - REQUIRE(type == 250); - REQUIRE(rdclass == 255); + REQUIRE(type == dns_rdatatype_tsig); + REQUIRE(rdclass == dns_rdataclass_any); UNUSED(type); UNUSED(rdclass); @@ -314,8 +314,8 @@ towire_any_tsig(ARGS_TOWIRE) { dns_name_t name; dns_offsets_t offsets; - REQUIRE(rdata->type == 250); - REQUIRE(rdata->rdclass == 255); + REQUIRE(rdata->type == dns_rdatatype_tsig); + REQUIRE(rdata->rdclass == dns_rdataclass_any); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); @@ -337,8 +337,8 @@ compare_any_tsig(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 250); - REQUIRE(rdata1->rdclass == 255); + REQUIRE(rdata1->type == dns_rdatatype_tsig); + REQUIRE(rdata1->rdclass == dns_rdataclass_any); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -361,8 +361,8 @@ fromstruct_any_tsig(ARGS_FROMSTRUCT) { dns_rdata_any_tsig_t *tsig = source; isc_region_t tr; - REQUIRE(type == 250); - REQUIRE(rdclass == 255); + REQUIRE(type == dns_rdatatype_tsig); + REQUIRE(rdclass == dns_rdataclass_any); REQUIRE(source != NULL); REQUIRE(tsig->common.rdclass == rdclass); REQUIRE(tsig->common.rdtype == type); @@ -433,8 +433,8 @@ tostruct_any_tsig(ARGS_TOSTRUCT) { dns_name_t alg; isc_region_t sr; - REQUIRE(rdata->type == 250); - REQUIRE(rdata->rdclass == 255); + REQUIRE(rdata->type == dns_rdatatype_tsig); + REQUIRE(rdata->rdclass == dns_rdataclass_any); REQUIRE(rdata->length != 0); tsig = (dns_rdata_any_tsig_t *) target; @@ -529,8 +529,8 @@ freestruct_any_tsig(ARGS_FREESTRUCT) { dns_rdata_any_tsig_t *tsig = (dns_rdata_any_tsig_t *) source; REQUIRE(source != NULL); - REQUIRE(tsig->common.rdclass == 255); - REQUIRE(tsig->common.rdtype == 250); + REQUIRE(tsig->common.rdtype == dns_rdatatype_tsig); + REQUIRE(tsig->common.rdclass == dns_rdataclass_any); if (tsig->mctx == NULL) return; @@ -545,8 +545,8 @@ freestruct_any_tsig(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_any_tsig(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 250); - REQUIRE(rdata->rdclass == 255); + REQUIRE(rdata->type == dns_rdatatype_tsig); + REQUIRE(rdata->rdclass == dns_rdataclass_any); UNUSED(rdata); UNUSED(add); @@ -558,8 +558,8 @@ additionaldata_any_tsig(ARGS_ADDLDATA) { static inline isc_result_t digest_any_tsig(ARGS_DIGEST) { - REQUIRE(rdata->type == 250); - REQUIRE(rdata->rdclass == 255); + REQUIRE(rdata->type == dns_rdatatype_tsig); + REQUIRE(rdata->rdclass == dns_rdataclass_any); UNUSED(rdata); UNUSED(digest); @@ -571,8 +571,8 @@ digest_any_tsig(ARGS_DIGEST) { static inline isc_boolean_t checkowner_any_tsig(ARGS_CHECKOWNER) { - REQUIRE(type == 250); - REQUIRE(rdclass == 255); + REQUIRE(type == dns_rdatatype_tsig); + REQUIRE(rdclass == dns_rdataclass_any); UNUSED(name); UNUSED(type); @@ -585,8 +585,8 @@ checkowner_any_tsig(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_any_tsig(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 250); - REQUIRE(rdata->rdclass == 250); + REQUIRE(rdata->type == dns_rdatatype_tsig); + REQUIRE(rdata->rdclass == dns_rdataclass_any); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/ch_3/a_1.c b/lib/dns/rdata/ch_3/a_1.c index d25fcb50ac40..34a059b34374 100644 --- a/lib/dns/rdata/ch_3/a_1.c +++ b/lib/dns/rdata/ch_3/a_1.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005, 2007, 2009, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2005, 2007, 2009, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -32,7 +32,7 @@ fromtext_ch_a(ARGS_FROMTEXT) { dns_name_t name; isc_buffer_t buffer; - REQUIRE(type == 1); + REQUIRE(type == dns_rdatatype_a); REQUIRE(rdclass == dns_rdataclass_ch); /* 3 */ UNUSED(type); @@ -72,7 +72,7 @@ totext_ch_a(ARGS_TOTEXT) { char buf[sizeof("0177777")]; isc_uint16_t addr; - REQUIRE(rdata->type == 1); + REQUIRE(rdata->type == dns_rdatatype_a); REQUIRE(rdata->rdclass == dns_rdataclass_ch); /* 3 */ REQUIRE(rdata->length != 0); @@ -98,7 +98,7 @@ fromwire_ch_a(ARGS_FROMWIRE) { isc_region_t tregion; dns_name_t name; - REQUIRE(type == 1); + REQUIRE(type == dns_rdatatype_a); REQUIRE(rdclass == dns_rdataclass_ch); UNUSED(type); @@ -131,7 +131,7 @@ towire_ch_a(ARGS_TOWIRE) { isc_region_t sregion; isc_region_t tregion; - REQUIRE(rdata->type == 1); + REQUIRE(rdata->type == dns_rdatatype_a); REQUIRE(rdata->rdclass == dns_rdataclass_ch); REQUIRE(rdata->length != 0); @@ -164,7 +164,7 @@ compare_ch_a(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 1); + REQUIRE(rdata1->type == dns_rdatatype_a); REQUIRE(rdata1->rdclass == dns_rdataclass_ch); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -195,7 +195,7 @@ fromstruct_ch_a(ARGS_FROMSTRUCT) { dns_rdata_ch_a_t *a = source; isc_region_t region; - REQUIRE(type == 1); + REQUIRE(type == dns_rdatatype_a); REQUIRE(source != NULL); REQUIRE(a->common.rdtype == type); REQUIRE(a->common.rdclass == rdclass); @@ -215,7 +215,7 @@ tostruct_ch_a(ARGS_TOSTRUCT) { isc_region_t region; dns_name_t name; - REQUIRE(rdata->type == 1); + REQUIRE(rdata->type == dns_rdatatype_a); REQUIRE(rdata->rdclass == dns_rdataclass_ch); REQUIRE(rdata->length != 0); @@ -241,7 +241,7 @@ freestruct_ch_a(ARGS_FREESTRUCT) { dns_rdata_ch_a_t *a = source; REQUIRE(source != NULL); - REQUIRE(a->common.rdtype == 1); + REQUIRE(a->common.rdtype == dns_rdatatype_a); if (a->mctx == NULL) return; @@ -253,7 +253,7 @@ freestruct_ch_a(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_ch_a(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 1); + REQUIRE(rdata->type == dns_rdatatype_a); REQUIRE(rdata->rdclass == dns_rdataclass_ch); UNUSED(rdata); @@ -266,10 +266,9 @@ additionaldata_ch_a(ARGS_ADDLDATA) { static inline isc_result_t digest_ch_a(ARGS_DIGEST) { isc_region_t r; - dns_name_t name; - REQUIRE(rdata->type == 1); + REQUIRE(rdata->type == dns_rdatatype_a); REQUIRE(rdata->rdclass == dns_rdataclass_ch); dns_rdata_toregion(rdata, &r); @@ -283,7 +282,7 @@ digest_ch_a(ARGS_DIGEST) { static inline isc_boolean_t checkowner_ch_a(ARGS_CHECKOWNER) { - REQUIRE(type == 1); + REQUIRE(type == dns_rdatatype_a); REQUIRE(rdclass == dns_rdataclass_ch); UNUSED(type); @@ -296,7 +295,7 @@ checknames_ch_a(ARGS_CHECKNAMES) { isc_region_t region; dns_name_t name; - REQUIRE(rdata->type == 1); + REQUIRE(rdata->type == dns_rdatatype_a); REQUIRE(rdata->rdclass == dns_rdataclass_ch); UNUSED(owner); diff --git a/lib/dns/rdata/generic/afsdb_18.c b/lib/dns/rdata/generic/afsdb_18.c index af95fa12e91b..75f644f2c7ab 100644 --- a/lib/dns/rdata/generic/afsdb_18.c +++ b/lib/dns/rdata/generic/afsdb_18.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -33,7 +33,7 @@ fromtext_afsdb(ARGS_FROMTEXT) { dns_name_t name; isc_boolean_t ok; - REQUIRE(type == 18); + REQUIRE(type == dns_rdatatype_afsdb); UNUSED(type); UNUSED(rdclass); @@ -76,7 +76,7 @@ totext_afsdb(ARGS_TOTEXT) { isc_boolean_t sub; unsigned int num; - REQUIRE(rdata->type == 18); + REQUIRE(rdata->type == dns_rdatatype_afsdb); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -98,7 +98,7 @@ fromwire_afsdb(ARGS_FROMWIRE) { isc_region_t sr; isc_region_t tr; - REQUIRE(type == 18); + REQUIRE(type == dns_rdatatype_afsdb); UNUSED(type); UNUSED(rdclass); @@ -126,7 +126,7 @@ towire_afsdb(ARGS_TOWIRE) { dns_name_t name; dns_offsets_t offsets; - REQUIRE(rdata->type == 18); + REQUIRE(rdata->type == dns_rdatatype_afsdb); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); @@ -154,7 +154,7 @@ compare_afsdb(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 18); + REQUIRE(rdata1->type == dns_rdatatype_afsdb); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -182,7 +182,7 @@ fromstruct_afsdb(ARGS_FROMSTRUCT) { dns_rdata_afsdb_t *afsdb = source; isc_region_t region; - REQUIRE(type == 18); + REQUIRE(type == dns_rdatatype_afsdb); REQUIRE(source != NULL); REQUIRE(afsdb->common.rdclass == rdclass); REQUIRE(afsdb->common.rdtype == type); @@ -201,7 +201,7 @@ tostruct_afsdb(ARGS_TOSTRUCT) { dns_rdata_afsdb_t *afsdb = target; dns_name_t name; - REQUIRE(rdata->type == 18); + REQUIRE(rdata->type == dns_rdatatype_afsdb); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -229,7 +229,7 @@ freestruct_afsdb(ARGS_FREESTRUCT) { dns_rdata_afsdb_t *afsdb = source; REQUIRE(source != NULL); - REQUIRE(afsdb->common.rdtype == 18); + REQUIRE(afsdb->common.rdtype == dns_rdatatype_afsdb); if (afsdb->mctx == NULL) return; @@ -244,7 +244,7 @@ additionaldata_afsdb(ARGS_ADDLDATA) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 18); + REQUIRE(rdata->type == dns_rdatatype_afsdb); dns_name_init(&name, offsets); dns_rdata_toregion(rdata, ®ion); @@ -259,7 +259,7 @@ digest_afsdb(ARGS_DIGEST) { isc_region_t r1, r2; dns_name_t name; - REQUIRE(rdata->type == 18); + REQUIRE(rdata->type == dns_rdatatype_afsdb); dns_rdata_toregion(rdata, &r1); r2 = r1; @@ -275,7 +275,7 @@ digest_afsdb(ARGS_DIGEST) { static inline isc_boolean_t checkowner_afsdb(ARGS_CHECKOWNER) { - REQUIRE(type == 18); + REQUIRE(type == dns_rdatatype_afsdb); UNUSED(name); UNUSED(type); @@ -290,7 +290,7 @@ checknames_afsdb(ARGS_CHECKNAMES) { isc_region_t region; dns_name_t name; - REQUIRE(rdata->type == 18); + REQUIRE(rdata->type == dns_rdatatype_afsdb); UNUSED(owner); diff --git a/lib/dns/rdata/generic/caa_257.c b/lib/dns/rdata/generic/caa_257.c index 993e3267e623..648f4afdc3b6 100644 --- a/lib/dns/rdata/generic/caa_257.c +++ b/lib/dns/rdata/generic/caa_257.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -45,7 +45,7 @@ fromtext_caa(ARGS_FROMTEXT) { isc_uint8_t flags; unsigned int i; - REQUIRE(type == 257); + REQUIRE(type == dns_rdatatype_caa); UNUSED(type); UNUSED(rdclass); @@ -68,7 +68,7 @@ fromtext_caa(ARGS_FROMTEXT) { ISC_FALSE)); tr = token.value.as_textregion; for (i = 0; i < tr.length; i++) - if (!alphanumeric[(unsigned int) tr.base[i]]) + if (!alphanumeric[(unsigned char) tr.base[i]]) RETTOK(DNS_R_SYNTAX); RETERR(uint8_tobuffer(tr.length, target)); RETERR(mem_tobuffer(target, tr.base, tr.length)); @@ -93,7 +93,7 @@ totext_caa(ARGS_TOTEXT) { UNUSED(tctx); - REQUIRE(rdata->type == 257); + REQUIRE(rdata->type == dns_rdatatype_caa); REQUIRE(rdata->length >= 3U); REQUIRE(rdata->data != NULL); @@ -124,7 +124,7 @@ fromwire_caa(ARGS_FROMWIRE) { isc_region_t sr; unsigned int len, i; - REQUIRE(type == 257); + REQUIRE(type == dns_rdatatype_caa); UNUSED(type); UNUSED(rdclass); @@ -167,7 +167,7 @@ static inline isc_result_t towire_caa(ARGS_TOWIRE) { isc_region_t region; - REQUIRE(rdata->type == 257); + REQUIRE(rdata->type == dns_rdatatype_caa); REQUIRE(rdata->length >= 3U); REQUIRE(rdata->data != NULL); @@ -183,7 +183,7 @@ compare_caa(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 257); + REQUIRE(rdata1->type == dns_rdatatype_caa); REQUIRE(rdata1->length >= 3U); REQUIRE(rdata2->length >= 3U); REQUIRE(rdata1->data != NULL); @@ -200,7 +200,7 @@ fromstruct_caa(ARGS_FROMSTRUCT) { isc_region_t region; unsigned int i; - REQUIRE(type == 257); + REQUIRE(type == dns_rdatatype_caa); REQUIRE(source != NULL); REQUIRE(caa->common.rdtype == type); REQUIRE(caa->common.rdclass == rdclass); @@ -243,7 +243,7 @@ tostruct_caa(ARGS_TOSTRUCT) { dns_rdata_caa_t *caa = target; isc_region_t sr; - REQUIRE(rdata->type == 257); + REQUIRE(rdata->type == dns_rdatatype_caa); REQUIRE(target != NULL); REQUIRE(rdata->length >= 3U); REQUIRE(rdata->data != NULL); @@ -297,7 +297,7 @@ freestruct_caa(ARGS_FREESTRUCT) { dns_rdata_caa_t *caa = (dns_rdata_caa_t *) source; REQUIRE(source != NULL); - REQUIRE(caa->common.rdtype == 257); + REQUIRE(caa->common.rdtype == dns_rdatatype_caa); if (caa->mctx == NULL) return; @@ -311,7 +311,7 @@ freestruct_caa(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_caa(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 257); + REQUIRE(rdata->type == dns_rdatatype_caa); REQUIRE(rdata->data != NULL); REQUIRE(rdata->length >= 3U); @@ -326,7 +326,7 @@ static inline isc_result_t digest_caa(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 257); + REQUIRE(rdata->type == dns_rdatatype_caa); REQUIRE(rdata->data != NULL); REQUIRE(rdata->length >= 3U); @@ -338,7 +338,7 @@ digest_caa(ARGS_DIGEST) { static inline isc_boolean_t checkowner_caa(ARGS_CHECKOWNER) { - REQUIRE(type == 257); + REQUIRE(type == dns_rdatatype_caa); UNUSED(name); UNUSED(type); @@ -351,7 +351,7 @@ checkowner_caa(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_caa(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 257); + REQUIRE(rdata->type == dns_rdatatype_caa); REQUIRE(rdata->data != NULL); REQUIRE(rdata->length >= 3U); diff --git a/lib/dns/rdata/generic/cdnskey_60.c b/lib/dns/rdata/generic/cdnskey_60.c index 624f581725e0..945b3644ce67 100644 --- a/lib/dns/rdata/generic/cdnskey_60.c +++ b/lib/dns/rdata/generic/cdnskey_60.c @@ -37,7 +37,7 @@ fromtext_cdnskey(ARGS_FROMTEXT) { dns_secproto_t proto; dns_keyflags_t flags; - REQUIRE(type == 60); + REQUIRE(type == dns_rdatatype_cdnskey); UNUSED(type); UNUSED(rdclass); @@ -87,7 +87,7 @@ totext_cdnskey(ARGS_TOTEXT) { char algbuf[DNS_NAME_FORMATSIZE]; const char *keyinfo; - REQUIRE(rdata->type == 60); + REQUIRE(rdata->type == dns_rdatatype_cdnskey); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, &sr); @@ -171,7 +171,7 @@ fromwire_cdnskey(ARGS_FROMWIRE) { unsigned char algorithm; isc_region_t sr; - REQUIRE(type == 60); + REQUIRE(type == dns_rdatatype_cdnskey); UNUSED(type); UNUSED(rdclass); @@ -211,7 +211,7 @@ static inline isc_result_t towire_cdnskey(ARGS_TOWIRE) { isc_region_t sr; - REQUIRE(rdata->type == 60); + REQUIRE(rdata->type == dns_rdatatype_cdnskey); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -227,7 +227,7 @@ compare_cdnskey(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 60); + REQUIRE(rdata1->type == dns_rdatatype_cdnskey); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -240,7 +240,7 @@ static inline isc_result_t fromstruct_cdnskey(ARGS_FROMSTRUCT) { dns_rdata_cdnskey_t *dnskey = source; - REQUIRE(type == 60); + REQUIRE(type == dns_rdatatype_cdnskey); REQUIRE(source != NULL); REQUIRE(dnskey->common.rdtype == type); REQUIRE(dnskey->common.rdclass == rdclass); @@ -266,7 +266,7 @@ tostruct_cdnskey(ARGS_TOSTRUCT) { dns_rdata_cdnskey_t *dnskey = target; isc_region_t sr; - REQUIRE(rdata->type == 60); + REQUIRE(rdata->type == dns_rdatatype_cdnskey); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -309,7 +309,7 @@ freestruct_cdnskey(ARGS_FREESTRUCT) { dns_rdata_cdnskey_t *dnskey = (dns_rdata_cdnskey_t *) source; REQUIRE(source != NULL); - REQUIRE(dnskey->common.rdtype == 60); + REQUIRE(dnskey->common.rdtype == dns_rdatatype_cdnskey); if (dnskey->mctx == NULL) return; @@ -321,7 +321,7 @@ freestruct_cdnskey(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_cdnskey(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 60); + REQUIRE(rdata->type == dns_rdatatype_cdnskey); UNUSED(rdata); UNUSED(add); @@ -334,7 +334,7 @@ static inline isc_result_t digest_cdnskey(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 60); + REQUIRE(rdata->type == dns_rdatatype_cdnskey); dns_rdata_toregion(rdata, &r); @@ -344,7 +344,7 @@ digest_cdnskey(ARGS_DIGEST) { static inline isc_boolean_t checkowner_cdnskey(ARGS_CHECKOWNER) { - REQUIRE(type == 60); + REQUIRE(type == dns_rdatatype_cdnskey); UNUSED(name); UNUSED(type); @@ -357,7 +357,7 @@ checkowner_cdnskey(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_cdnskey(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 60); + REQUIRE(rdata->type == dns_rdatatype_cdnskey); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/cds_59.c b/lib/dns/rdata/generic/cds_59.c index ff7ff6315790..b58d5f7999d2 100644 --- a/lib/dns/rdata/generic/cds_59.c +++ b/lib/dns/rdata/generic/cds_59.c @@ -34,7 +34,7 @@ fromtext_cds(ARGS_FROMTEXT) { unsigned char c; int length; - REQUIRE(type == 59); + REQUIRE(type == dns_rdatatype_cds); UNUSED(type); UNUSED(rdclass); @@ -98,7 +98,7 @@ totext_cds(ARGS_TOTEXT) { char buf[sizeof("64000 ")]; unsigned int n; - REQUIRE(rdata->type == 59); + REQUIRE(rdata->type == dns_rdatatype_cds); REQUIRE(rdata->length != 0); UNUSED(tctx); @@ -149,7 +149,7 @@ static inline isc_result_t fromwire_cds(ARGS_FROMWIRE) { isc_region_t sr; - REQUIRE(type == 59); + REQUIRE(type == dns_rdatatype_cds); UNUSED(type); UNUSED(rdclass); @@ -194,7 +194,7 @@ static inline isc_result_t towire_cds(ARGS_TOWIRE) { isc_region_t sr; - REQUIRE(rdata->type == 59); + REQUIRE(rdata->type == dns_rdatatype_cds); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -210,7 +210,7 @@ compare_cds(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 59); + REQUIRE(rdata1->type == dns_rdatatype_cds); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -223,7 +223,7 @@ static inline isc_result_t fromstruct_cds(ARGS_FROMSTRUCT) { dns_rdata_cds_t *ds = source; - REQUIRE(type == 59); + REQUIRE(type == dns_rdatatype_cds); REQUIRE(source != NULL); REQUIRE(ds->common.rdtype == type); REQUIRE(ds->common.rdclass == rdclass); @@ -257,7 +257,7 @@ tostruct_cds(ARGS_TOSTRUCT) { dns_rdata_cds_t *ds = target; isc_region_t region; - REQUIRE(rdata->type == 59); + REQUIRE(rdata->type == dns_rdatatype_cds); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -288,7 +288,7 @@ freestruct_cds(ARGS_FREESTRUCT) { dns_rdata_cds_t *ds = source; REQUIRE(ds != NULL); - REQUIRE(ds->common.rdtype == 59); + REQUIRE(ds->common.rdtype == dns_rdatatype_cds); if (ds->mctx == NULL) return; @@ -300,7 +300,7 @@ freestruct_cds(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_cds(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 59); + REQUIRE(rdata->type == dns_rdatatype_cds); UNUSED(rdata); UNUSED(add); @@ -313,7 +313,7 @@ static inline isc_result_t digest_cds(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 59); + REQUIRE(rdata->type == dns_rdatatype_cds); dns_rdata_toregion(rdata, &r); @@ -323,7 +323,7 @@ digest_cds(ARGS_DIGEST) { static inline isc_boolean_t checkowner_cds(ARGS_CHECKOWNER) { - REQUIRE(type == 59); + REQUIRE(type == dns_rdatatype_cds); UNUSED(name); UNUSED(type); @@ -336,7 +336,7 @@ checkowner_cds(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_cds(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 59); + REQUIRE(rdata->type == dns_rdatatype_cds); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/cert_37.c b/lib/dns/rdata/generic/cert_37.c index a03290a60a02..b9c171d6c392 100644 --- a/lib/dns/rdata/generic/cert_37.c +++ b/lib/dns/rdata/generic/cert_37.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009, 2011, 2012 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2011, 2012, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -32,7 +32,7 @@ fromtext_cert(ARGS_FROMTEXT) { dns_secalg_t secalg; dns_cert_t cert; - REQUIRE(type == 37); + REQUIRE(type == dns_rdatatype_cert); UNUSED(type); UNUSED(rdclass); @@ -74,7 +74,7 @@ totext_cert(ARGS_TOTEXT) { char buf[sizeof("64000 ")]; unsigned int n; - REQUIRE(rdata->type == 37); + REQUIRE(rdata->type == dns_rdatatype_cert); REQUIRE(rdata->length != 0); UNUSED(tctx); @@ -123,7 +123,7 @@ static inline isc_result_t fromwire_cert(ARGS_FROMWIRE) { isc_region_t sr; - REQUIRE(type == 37); + REQUIRE(type == dns_rdatatype_cert); UNUSED(type); UNUSED(rdclass); @@ -142,7 +142,7 @@ static inline isc_result_t towire_cert(ARGS_TOWIRE) { isc_region_t sr; - REQUIRE(rdata->type == 37); + REQUIRE(rdata->type == dns_rdatatype_cert); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -158,7 +158,7 @@ compare_cert(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 37); + REQUIRE(rdata1->type == dns_rdatatype_cert); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -171,7 +171,7 @@ static inline isc_result_t fromstruct_cert(ARGS_FROMSTRUCT) { dns_rdata_cert_t *cert = source; - REQUIRE(type == 37); + REQUIRE(type == dns_rdatatype_cert); REQUIRE(source != NULL); REQUIRE(cert->common.rdtype == type); REQUIRE(cert->common.rdclass == rdclass); @@ -191,7 +191,7 @@ tostruct_cert(ARGS_TOSTRUCT) { dns_rdata_cert_t *cert = target; isc_region_t region; - REQUIRE(rdata->type == 37); + REQUIRE(rdata->type == dns_rdatatype_cert); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -222,7 +222,7 @@ freestruct_cert(ARGS_FREESTRUCT) { dns_rdata_cert_t *cert = source; REQUIRE(cert != NULL); - REQUIRE(cert->common.rdtype == 37); + REQUIRE(cert->common.rdtype == dns_rdatatype_cert); if (cert->mctx == NULL) return; @@ -234,7 +234,7 @@ freestruct_cert(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_cert(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 37); + REQUIRE(rdata->type == dns_rdatatype_cert); UNUSED(rdata); UNUSED(add); @@ -247,7 +247,7 @@ static inline isc_result_t digest_cert(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 37); + REQUIRE(rdata->type == dns_rdatatype_cert); dns_rdata_toregion(rdata, &r); @@ -257,7 +257,7 @@ digest_cert(ARGS_DIGEST) { static inline isc_boolean_t checkowner_cert(ARGS_CHECKOWNER) { - REQUIRE(type == 37); + REQUIRE(type == dns_rdatatype_cert); UNUSED(name); UNUSED(type); @@ -270,7 +270,7 @@ checkowner_cert(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_cert(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 37); + REQUIRE(rdata->type == dns_rdatatype_cert); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/cname_5.c b/lib/dns/rdata/generic/cname_5.c index 45a48a897fc0..3f8a69b28dbf 100644 --- a/lib/dns/rdata/generic/cname_5.c +++ b/lib/dns/rdata/generic/cname_5.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -31,7 +31,7 @@ fromtext_cname(ARGS_FROMTEXT) { dns_name_t name; isc_buffer_t buffer; - REQUIRE(type == 5); + REQUIRE(type == dns_rdatatype_cname); UNUSED(type); UNUSED(rdclass); @@ -54,7 +54,7 @@ totext_cname(ARGS_TOTEXT) { dns_name_t prefix; isc_boolean_t sub; - REQUIRE(rdata->type == 5); + REQUIRE(rdata->type == dns_rdatatype_cname); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -72,7 +72,7 @@ static inline isc_result_t fromwire_cname(ARGS_FROMWIRE) { dns_name_t name; - REQUIRE(type == 5); + REQUIRE(type == dns_rdatatype_cname); UNUSED(type); UNUSED(rdclass); @@ -89,7 +89,7 @@ towire_cname(ARGS_TOWIRE) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 5); + REQUIRE(rdata->type == dns_rdatatype_cname); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); @@ -110,7 +110,7 @@ compare_cname(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 5); + REQUIRE(rdata1->type == dns_rdatatype_cname); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -131,7 +131,7 @@ fromstruct_cname(ARGS_FROMSTRUCT) { dns_rdata_cname_t *cname = source; isc_region_t region; - REQUIRE(type == 5); + REQUIRE(type == dns_rdatatype_cname); REQUIRE(source != NULL); REQUIRE(cname->common.rdtype == type); REQUIRE(cname->common.rdclass == rdclass); @@ -149,7 +149,7 @@ tostruct_cname(ARGS_TOSTRUCT) { dns_rdata_cname_t *cname = target; dns_name_t name; - REQUIRE(rdata->type == 5); + REQUIRE(rdata->type == dns_rdatatype_cname); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -185,7 +185,7 @@ additionaldata_cname(ARGS_ADDLDATA) { UNUSED(add); UNUSED(arg); - REQUIRE(rdata->type == 5); + REQUIRE(rdata->type == dns_rdatatype_cname); return (ISC_R_SUCCESS); } @@ -195,7 +195,7 @@ digest_cname(ARGS_DIGEST) { isc_region_t r; dns_name_t name; - REQUIRE(rdata->type == 5); + REQUIRE(rdata->type == dns_rdatatype_cname); dns_rdata_toregion(rdata, &r); dns_name_init(&name, NULL); @@ -207,7 +207,7 @@ digest_cname(ARGS_DIGEST) { static inline isc_boolean_t checkowner_cname(ARGS_CHECKOWNER) { - REQUIRE(type == 5); + REQUIRE(type == dns_rdatatype_cname); UNUSED(name); UNUSED(type); @@ -220,7 +220,7 @@ checkowner_cname(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_cname(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 5); + REQUIRE(rdata->type == dns_rdatatype_cname); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/dlv_32769.c b/lib/dns/rdata/generic/dlv_32769.c index 5751ad894527..3ff575766e3b 100644 --- a/lib/dns/rdata/generic/dlv_32769.c +++ b/lib/dns/rdata/generic/dlv_32769.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2006, 2007, 2009-2013 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2006, 2007, 2009-2013, 2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -35,7 +35,7 @@ fromtext_dlv(ARGS_FROMTEXT) { unsigned char c; int length; - REQUIRE(type == 32769); + REQUIRE(type == dns_rdatatype_dlv); UNUSED(type); UNUSED(rdclass); @@ -100,7 +100,7 @@ totext_dlv(ARGS_TOTEXT) { char buf[sizeof("64000 ")]; unsigned int n; - REQUIRE(rdata->type == 32769); + REQUIRE(rdata->type == dns_rdatatype_dlv); REQUIRE(rdata->length != 0); UNUSED(tctx); @@ -151,7 +151,7 @@ static inline isc_result_t fromwire_dlv(ARGS_FROMWIRE) { isc_region_t sr; - REQUIRE(type == 32769); + REQUIRE(type == dns_rdatatype_dlv); UNUSED(type); UNUSED(rdclass); @@ -196,7 +196,7 @@ static inline isc_result_t towire_dlv(ARGS_TOWIRE) { isc_region_t sr; - REQUIRE(rdata->type == 32769); + REQUIRE(rdata->type == dns_rdatatype_dlv); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -212,7 +212,7 @@ compare_dlv(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 32769); + REQUIRE(rdata1->type == dns_rdatatype_dlv); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -225,7 +225,7 @@ static inline isc_result_t fromstruct_dlv(ARGS_FROMSTRUCT) { dns_rdata_dlv_t *dlv = source; - REQUIRE(type == 32769); + REQUIRE(type == dns_rdatatype_dlv); REQUIRE(source != NULL); REQUIRE(dlv->common.rdtype == type); REQUIRE(dlv->common.rdclass == rdclass); @@ -259,7 +259,7 @@ tostruct_dlv(ARGS_TOSTRUCT) { dns_rdata_dlv_t *dlv = target; isc_region_t region; - REQUIRE(rdata->type == 32769); + REQUIRE(rdata->type == dns_rdatatype_dlv); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -290,7 +290,7 @@ freestruct_dlv(ARGS_FREESTRUCT) { dns_rdata_dlv_t *dlv = source; REQUIRE(dlv != NULL); - REQUIRE(dlv->common.rdtype == 32769); + REQUIRE(dlv->common.rdtype == dns_rdatatype_dlv); if (dlv->mctx == NULL) return; @@ -302,7 +302,7 @@ freestruct_dlv(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_dlv(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 32769); + REQUIRE(rdata->type == dns_rdatatype_dlv); UNUSED(rdata); UNUSED(add); @@ -315,7 +315,7 @@ static inline isc_result_t digest_dlv(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 32769); + REQUIRE(rdata->type == dns_rdatatype_dlv); dns_rdata_toregion(rdata, &r); @@ -325,7 +325,7 @@ digest_dlv(ARGS_DIGEST) { static inline isc_boolean_t checkowner_dlv(ARGS_CHECKOWNER) { - REQUIRE(type == 32769); + REQUIRE(type == dns_rdatatype_dlv); UNUSED(name); UNUSED(type); @@ -338,7 +338,7 @@ checkowner_dlv(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_dlv(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 32769); + REQUIRE(rdata->type == dns_rdatatype_dlv); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/dname_39.c b/lib/dns/rdata/generic/dname_39.c index d899494f5368..d181a6cd10c7 100644 --- a/lib/dns/rdata/generic/dname_39.c +++ b/lib/dns/rdata/generic/dname_39.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -32,7 +32,7 @@ fromtext_dname(ARGS_FROMTEXT) { dns_name_t name; isc_buffer_t buffer; - REQUIRE(type == 39); + REQUIRE(type == dns_rdatatype_dname); UNUSED(type); UNUSED(rdclass); @@ -55,7 +55,7 @@ totext_dname(ARGS_TOTEXT) { dns_name_t prefix; isc_boolean_t sub; - REQUIRE(rdata->type == 39); + REQUIRE(rdata->type == dns_rdatatype_dname); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -73,7 +73,7 @@ static inline isc_result_t fromwire_dname(ARGS_FROMWIRE) { dns_name_t name; - REQUIRE(type == 39); + REQUIRE(type == dns_rdatatype_dname); UNUSED(type); UNUSED(rdclass); @@ -90,7 +90,7 @@ towire_dname(ARGS_TOWIRE) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 39); + REQUIRE(rdata->type == dns_rdatatype_dname); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); @@ -110,7 +110,7 @@ compare_dname(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 39); + REQUIRE(rdata1->type == dns_rdatatype_dname); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -131,7 +131,7 @@ fromstruct_dname(ARGS_FROMSTRUCT) { dns_rdata_dname_t *dname = source; isc_region_t region; - REQUIRE(type == 39); + REQUIRE(type == dns_rdatatype_dname); REQUIRE(source != NULL); REQUIRE(dname->common.rdtype == type); REQUIRE(dname->common.rdclass == rdclass); @@ -149,7 +149,7 @@ tostruct_dname(ARGS_TOSTRUCT) { dns_rdata_dname_t *dname = target; dns_name_t name; - REQUIRE(rdata->type == 39); + REQUIRE(rdata->type == dns_rdatatype_dname); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -171,7 +171,7 @@ freestruct_dname(ARGS_FREESTRUCT) { dns_rdata_dname_t *dname = source; REQUIRE(source != NULL); - REQUIRE(dname->common.rdtype == 39); + REQUIRE(dname->common.rdtype == dns_rdatatype_dname); if (dname->mctx == NULL) return; @@ -186,7 +186,7 @@ additionaldata_dname(ARGS_ADDLDATA) { UNUSED(add); UNUSED(arg); - REQUIRE(rdata->type == 39); + REQUIRE(rdata->type == dns_rdatatype_dname); return (ISC_R_SUCCESS); } @@ -196,7 +196,7 @@ digest_dname(ARGS_DIGEST) { isc_region_t r; dns_name_t name; - REQUIRE(rdata->type == 39); + REQUIRE(rdata->type == dns_rdatatype_dname); dns_rdata_toregion(rdata, &r); dns_name_init(&name, NULL); @@ -208,7 +208,7 @@ digest_dname(ARGS_DIGEST) { static inline isc_boolean_t checkowner_dname(ARGS_CHECKOWNER) { - REQUIRE(type == 39); + REQUIRE(type == dns_rdatatype_dname); UNUSED(name); UNUSED(type); @@ -221,7 +221,7 @@ checkowner_dname(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_dname(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 39); + REQUIRE(rdata->type == dns_rdatatype_dname); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/dnskey_48.c b/lib/dns/rdata/generic/dnskey_48.c index aa705cab3684..3b0387503a1b 100644 --- a/lib/dns/rdata/generic/dnskey_48.c +++ b/lib/dns/rdata/generic/dnskey_48.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009, 2011-2013 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2011-2013, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -38,7 +38,7 @@ fromtext_dnskey(ARGS_FROMTEXT) { dns_secproto_t proto; dns_keyflags_t flags; - REQUIRE(type == 48); + REQUIRE(type == dns_rdatatype_dnskey); UNUSED(type); UNUSED(rdclass); @@ -88,7 +88,7 @@ totext_dnskey(ARGS_TOTEXT) { char algbuf[DNS_NAME_FORMATSIZE]; const char *keyinfo; - REQUIRE(rdata->type == 48); + REQUIRE(rdata->type == dns_rdatatype_dnskey); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, &sr); @@ -172,7 +172,7 @@ fromwire_dnskey(ARGS_FROMWIRE) { unsigned char algorithm; isc_region_t sr; - REQUIRE(type == 48); + REQUIRE(type == dns_rdatatype_dnskey); UNUSED(type); UNUSED(rdclass); @@ -212,7 +212,7 @@ static inline isc_result_t towire_dnskey(ARGS_TOWIRE) { isc_region_t sr; - REQUIRE(rdata->type == 48); + REQUIRE(rdata->type == dns_rdatatype_dnskey); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -228,7 +228,7 @@ compare_dnskey(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 48); + REQUIRE(rdata1->type == dns_rdatatype_dnskey); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -241,7 +241,7 @@ static inline isc_result_t fromstruct_dnskey(ARGS_FROMSTRUCT) { dns_rdata_dnskey_t *dnskey = source; - REQUIRE(type == 48); + REQUIRE(type == dns_rdatatype_dnskey); REQUIRE(source != NULL); REQUIRE(dnskey->common.rdtype == type); REQUIRE(dnskey->common.rdclass == rdclass); @@ -267,7 +267,7 @@ tostruct_dnskey(ARGS_TOSTRUCT) { dns_rdata_dnskey_t *dnskey = target; isc_region_t sr; - REQUIRE(rdata->type == 48); + REQUIRE(rdata->type == dns_rdatatype_dnskey); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -310,7 +310,7 @@ freestruct_dnskey(ARGS_FREESTRUCT) { dns_rdata_dnskey_t *dnskey = (dns_rdata_dnskey_t *) source; REQUIRE(source != NULL); - REQUIRE(dnskey->common.rdtype == 48); + REQUIRE(dnskey->common.rdtype == dns_rdatatype_dnskey); if (dnskey->mctx == NULL) return; @@ -322,7 +322,7 @@ freestruct_dnskey(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_dnskey(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 48); + REQUIRE(rdata->type == dns_rdatatype_dnskey); UNUSED(rdata); UNUSED(add); @@ -335,7 +335,7 @@ static inline isc_result_t digest_dnskey(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 48); + REQUIRE(rdata->type == dns_rdatatype_dnskey); dns_rdata_toregion(rdata, &r); @@ -345,7 +345,7 @@ digest_dnskey(ARGS_DIGEST) { static inline isc_boolean_t checkowner_dnskey(ARGS_CHECKOWNER) { - REQUIRE(type == 48); + REQUIRE(type == dns_rdatatype_dnskey); UNUSED(name); UNUSED(type); @@ -358,7 +358,7 @@ checkowner_dnskey(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_dnskey(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 48); + REQUIRE(rdata->type == dns_rdatatype_dnskey); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/ds_43.c b/lib/dns/rdata/generic/ds_43.c index dd47c8d5e83e..975fdfd2b3a6 100644 --- a/lib/dns/rdata/generic/ds_43.c +++ b/lib/dns/rdata/generic/ds_43.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009-2012 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009-2012, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -36,7 +36,7 @@ fromtext_ds(ARGS_FROMTEXT) { unsigned char c; int length; - REQUIRE(type == 43); + REQUIRE(type == dns_rdatatype_ds); UNUSED(type); UNUSED(rdclass); @@ -100,7 +100,7 @@ totext_ds(ARGS_TOTEXT) { char buf[sizeof("64000 ")]; unsigned int n; - REQUIRE(rdata->type == 43); + REQUIRE(rdata->type == dns_rdatatype_ds); REQUIRE(rdata->length != 0); UNUSED(tctx); @@ -151,7 +151,7 @@ static inline isc_result_t fromwire_ds(ARGS_FROMWIRE) { isc_region_t sr; - REQUIRE(type == 43); + REQUIRE(type == dns_rdatatype_ds); UNUSED(type); UNUSED(rdclass); @@ -196,7 +196,7 @@ static inline isc_result_t towire_ds(ARGS_TOWIRE) { isc_region_t sr; - REQUIRE(rdata->type == 43); + REQUIRE(rdata->type == dns_rdatatype_ds); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -212,7 +212,7 @@ compare_ds(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 43); + REQUIRE(rdata1->type == dns_rdatatype_ds); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -225,7 +225,7 @@ static inline isc_result_t fromstruct_ds(ARGS_FROMSTRUCT) { dns_rdata_ds_t *ds = source; - REQUIRE(type == 43); + REQUIRE(type == dns_rdatatype_ds); REQUIRE(source != NULL); REQUIRE(ds->common.rdtype == type); REQUIRE(ds->common.rdclass == rdclass); @@ -259,7 +259,7 @@ tostruct_ds(ARGS_TOSTRUCT) { dns_rdata_ds_t *ds = target; isc_region_t region; - REQUIRE(rdata->type == 43); + REQUIRE(rdata->type == dns_rdatatype_ds); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -290,7 +290,7 @@ freestruct_ds(ARGS_FREESTRUCT) { dns_rdata_ds_t *ds = source; REQUIRE(ds != NULL); - REQUIRE(ds->common.rdtype == 43); + REQUIRE(ds->common.rdtype == dns_rdatatype_ds); if (ds->mctx == NULL) return; @@ -302,7 +302,7 @@ freestruct_ds(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_ds(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 43); + REQUIRE(rdata->type == dns_rdatatype_ds); UNUSED(rdata); UNUSED(add); @@ -315,7 +315,7 @@ static inline isc_result_t digest_ds(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 43); + REQUIRE(rdata->type == dns_rdatatype_ds); dns_rdata_toregion(rdata, &r); @@ -325,7 +325,7 @@ digest_ds(ARGS_DIGEST) { static inline isc_boolean_t checkowner_ds(ARGS_CHECKOWNER) { - REQUIRE(type == 43); + REQUIRE(type == dns_rdatatype_ds); UNUSED(name); UNUSED(type); @@ -338,7 +338,7 @@ checkowner_ds(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_ds(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 43); + REQUIRE(rdata->type == dns_rdatatype_ds); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/eui48_108.c b/lib/dns/rdata/generic/eui48_108.c index b25a7b7e03e4..9910e48c3dcd 100644 --- a/lib/dns/rdata/generic/eui48_108.c +++ b/lib/dns/rdata/generic/eui48_108.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -28,7 +28,7 @@ fromtext_eui48(ARGS_FROMTEXT) { unsigned int l0, l1, l2, l3, l4, l5; int n; - REQUIRE(type == 108); + REQUIRE(type == dns_rdatatype_eui48); UNUSED(type); UNUSED(rdclass); @@ -57,7 +57,7 @@ static inline isc_result_t totext_eui48(ARGS_TOTEXT) { char buf[sizeof("xx-xx-xx-xx-xx-xx")]; - REQUIRE(rdata->type == 108); + REQUIRE(rdata->type == dns_rdatatype_eui48); REQUIRE(rdata->length == 6); UNUSED(tctx); @@ -72,7 +72,7 @@ static inline isc_result_t fromwire_eui48(ARGS_FROMWIRE) { isc_region_t sregion; - REQUIRE(type == 108); + REQUIRE(type == dns_rdatatype_eui48); UNUSED(type); UNUSED(options); @@ -89,7 +89,7 @@ fromwire_eui48(ARGS_FROMWIRE) { static inline isc_result_t towire_eui48(ARGS_TOWIRE) { - REQUIRE(rdata->type == 108); + REQUIRE(rdata->type == dns_rdatatype_eui48); REQUIRE(rdata->length == 6); UNUSED(cctx); @@ -104,7 +104,7 @@ compare_eui48(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 108); + REQUIRE(rdata1->type == dns_rdatatype_eui48); REQUIRE(rdata1->length == 6); REQUIRE(rdata2->length == 6); @@ -117,7 +117,7 @@ static inline isc_result_t fromstruct_eui48(ARGS_FROMSTRUCT) { dns_rdata_eui48_t *eui48 = source; - REQUIRE(type == 108); + REQUIRE(type == dns_rdatatype_eui48); REQUIRE(source != NULL); REQUIRE(eui48->common.rdtype == type); REQUIRE(eui48->common.rdclass == rdclass); @@ -132,7 +132,7 @@ static inline isc_result_t tostruct_eui48(ARGS_TOSTRUCT) { dns_rdata_eui48_t *eui48 = target; - REQUIRE(rdata->type == 108); + REQUIRE(rdata->type == dns_rdatatype_eui48); REQUIRE(target != NULL); REQUIRE(rdata->length == 6); @@ -151,7 +151,7 @@ freestruct_eui48(ARGS_FREESTRUCT) { dns_rdata_eui48_t *eui48 = source; REQUIRE(source != NULL); - REQUIRE(eui48->common.rdtype == 108); + REQUIRE(eui48->common.rdtype == dns_rdatatype_eui48); return; } @@ -159,7 +159,7 @@ freestruct_eui48(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_eui48(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 108); + REQUIRE(rdata->type == dns_rdatatype_eui48); REQUIRE(rdata->length == 6); UNUSED(rdata); @@ -173,7 +173,7 @@ static inline isc_result_t digest_eui48(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 108); + REQUIRE(rdata->type == dns_rdatatype_eui48); REQUIRE(rdata->length == 6); dns_rdata_toregion(rdata, &r); @@ -184,7 +184,7 @@ digest_eui48(ARGS_DIGEST) { static inline isc_boolean_t checkowner_eui48(ARGS_CHECKOWNER) { - REQUIRE(type == 108); + REQUIRE(type == dns_rdatatype_eui48); UNUSED(name); UNUSED(type); @@ -197,7 +197,7 @@ checkowner_eui48(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_eui48(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 108); + REQUIRE(rdata->type == dns_rdatatype_eui48); REQUIRE(rdata->length == 6); UNUSED(rdata); diff --git a/lib/dns/rdata/generic/eui64_109.c b/lib/dns/rdata/generic/eui64_109.c index 33d2f637c825..6ac7f0d619f7 100644 --- a/lib/dns/rdata/generic/eui64_109.c +++ b/lib/dns/rdata/generic/eui64_109.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -28,7 +28,7 @@ fromtext_eui64(ARGS_FROMTEXT) { unsigned int l0, l1, l2, l3, l4, l5, l6, l7; int n; - REQUIRE(type == 109); + REQUIRE(type == dns_rdatatype_eui64); UNUSED(type); UNUSED(rdclass); @@ -59,7 +59,7 @@ static inline isc_result_t totext_eui64(ARGS_TOTEXT) { char buf[sizeof("xx-xx-xx-xx-xx-xx-xx-xx")]; - REQUIRE(rdata->type == 109); + REQUIRE(rdata->type == dns_rdatatype_eui64); REQUIRE(rdata->length == 8); UNUSED(tctx); @@ -77,7 +77,7 @@ static inline isc_result_t fromwire_eui64(ARGS_FROMWIRE) { isc_region_t sregion; - REQUIRE(type == 109); + REQUIRE(type == dns_rdatatype_eui64); UNUSED(type); UNUSED(options); @@ -94,7 +94,7 @@ fromwire_eui64(ARGS_FROMWIRE) { static inline isc_result_t towire_eui64(ARGS_TOWIRE) { - REQUIRE(rdata->type == 109); + REQUIRE(rdata->type == dns_rdatatype_eui64); REQUIRE(rdata->length == 8); UNUSED(cctx); @@ -109,7 +109,7 @@ compare_eui64(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 109); + REQUIRE(rdata1->type == dns_rdatatype_eui64); REQUIRE(rdata1->length == 8); REQUIRE(rdata2->length == 8); @@ -122,7 +122,7 @@ static inline isc_result_t fromstruct_eui64(ARGS_FROMSTRUCT) { dns_rdata_eui64_t *eui64 = source; - REQUIRE(type == 109); + REQUIRE(type == dns_rdatatype_eui64); REQUIRE(source != NULL); REQUIRE(eui64->common.rdtype == type); REQUIRE(eui64->common.rdclass == rdclass); @@ -137,7 +137,7 @@ static inline isc_result_t tostruct_eui64(ARGS_TOSTRUCT) { dns_rdata_eui64_t *eui64 = target; - REQUIRE(rdata->type == 109); + REQUIRE(rdata->type == dns_rdatatype_eui64); REQUIRE(target != NULL); REQUIRE(rdata->length == 8); @@ -156,7 +156,7 @@ freestruct_eui64(ARGS_FREESTRUCT) { dns_rdata_eui64_t *eui64 = source; REQUIRE(source != NULL); - REQUIRE(eui64->common.rdtype == 109); + REQUIRE(eui64->common.rdtype == dns_rdatatype_eui64); return; } @@ -164,7 +164,7 @@ freestruct_eui64(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_eui64(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 109); + REQUIRE(rdata->type == dns_rdatatype_eui64); REQUIRE(rdata->length == 8); UNUSED(rdata); @@ -178,7 +178,7 @@ static inline isc_result_t digest_eui64(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 109); + REQUIRE(rdata->type == dns_rdatatype_eui64); REQUIRE(rdata->length == 8); dns_rdata_toregion(rdata, &r); @@ -189,7 +189,7 @@ digest_eui64(ARGS_DIGEST) { static inline isc_boolean_t checkowner_eui64(ARGS_CHECKOWNER) { - REQUIRE(type == 109); + REQUIRE(type == dns_rdatatype_eui64); UNUSED(name); UNUSED(type); @@ -202,7 +202,7 @@ checkowner_eui64(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_eui64(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 109); + REQUIRE(rdata->type == dns_rdatatype_eui64); REQUIRE(rdata->length == 8); UNUSED(rdata); diff --git a/lib/dns/rdata/generic/gpos_27.c b/lib/dns/rdata/generic/gpos_27.c index e9ba59eacb6a..d5fa6b6055fc 100644 --- a/lib/dns/rdata/generic/gpos_27.c +++ b/lib/dns/rdata/generic/gpos_27.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -31,7 +31,7 @@ fromtext_gpos(ARGS_FROMTEXT) { isc_token_t token; int i; - REQUIRE(type == 27); + REQUIRE(type == dns_rdatatype_gpos); UNUSED(type); UNUSED(rdclass); @@ -53,7 +53,7 @@ totext_gpos(ARGS_TOTEXT) { isc_region_t region; int i; - REQUIRE(rdata->type == 27); + REQUIRE(rdata->type == dns_rdatatype_gpos); REQUIRE(rdata->length != 0); UNUSED(tctx); @@ -73,7 +73,7 @@ static inline isc_result_t fromwire_gpos(ARGS_FROMWIRE) { int i; - REQUIRE(type == 27); + REQUIRE(type == dns_rdatatype_gpos); UNUSED(type); UNUSED(dctx); @@ -88,7 +88,7 @@ fromwire_gpos(ARGS_FROMWIRE) { static inline isc_result_t towire_gpos(ARGS_TOWIRE) { - REQUIRE(rdata->type == 27); + REQUIRE(rdata->type == dns_rdatatype_gpos); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -103,7 +103,7 @@ compare_gpos(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 27); + REQUIRE(rdata1->type == dns_rdatatype_gpos); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -116,7 +116,7 @@ static inline isc_result_t fromstruct_gpos(ARGS_FROMSTRUCT) { dns_rdata_gpos_t *gpos = source; - REQUIRE(type == 27); + REQUIRE(type == dns_rdatatype_gpos); REQUIRE(source != NULL); REQUIRE(gpos->common.rdtype == type); REQUIRE(gpos->common.rdclass == rdclass); @@ -137,7 +137,7 @@ tostruct_gpos(ARGS_TOSTRUCT) { dns_rdata_gpos_t *gpos = target; isc_region_t region; - REQUIRE(rdata->type == 27); + REQUIRE(rdata->type == dns_rdatatype_gpos); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -188,7 +188,7 @@ freestruct_gpos(ARGS_FREESTRUCT) { dns_rdata_gpos_t *gpos = source; REQUIRE(source != NULL); - REQUIRE(gpos->common.rdtype == 27); + REQUIRE(gpos->common.rdtype == dns_rdatatype_gpos); if (gpos->mctx == NULL) return; @@ -204,7 +204,7 @@ freestruct_gpos(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_gpos(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 27); + REQUIRE(rdata->type == dns_rdatatype_gpos); UNUSED(rdata); UNUSED(add); @@ -217,7 +217,7 @@ static inline isc_result_t digest_gpos(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 27); + REQUIRE(rdata->type == dns_rdatatype_gpos); dns_rdata_toregion(rdata, &r); @@ -227,7 +227,7 @@ digest_gpos(ARGS_DIGEST) { static inline isc_boolean_t checkowner_gpos(ARGS_CHECKOWNER) { - REQUIRE(type == 27); + REQUIRE(type == dns_rdatatype_gpos); UNUSED(name); UNUSED(type); @@ -240,7 +240,7 @@ checkowner_gpos(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_gpos(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 27); + REQUIRE(rdata->type == dns_rdatatype_gpos); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/hinfo_13.c b/lib/dns/rdata/generic/hinfo_13.c index 411d6b56866e..abac75134946 100644 --- a/lib/dns/rdata/generic/hinfo_13.c +++ b/lib/dns/rdata/generic/hinfo_13.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -37,7 +37,7 @@ fromtext_hinfo(ARGS_FROMTEXT) { UNUSED(options); UNUSED(callbacks); - REQUIRE(type == 13); + REQUIRE(type == dns_rdatatype_hinfo); for (i = 0; i < 2; i++) { RETERR(isc_lex_getmastertoken(lexer, &token, @@ -54,7 +54,7 @@ totext_hinfo(ARGS_TOTEXT) { UNUSED(tctx); - REQUIRE(rdata->type == 13); + REQUIRE(rdata->type == dns_rdatatype_hinfo); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, ®ion); @@ -66,7 +66,7 @@ totext_hinfo(ARGS_TOTEXT) { static inline isc_result_t fromwire_hinfo(ARGS_FROMWIRE) { - REQUIRE(type == 13); + REQUIRE(type == dns_rdatatype_hinfo); UNUSED(type); UNUSED(dctx); @@ -82,7 +82,7 @@ towire_hinfo(ARGS_TOWIRE) { UNUSED(cctx); - REQUIRE(rdata->type == 13); + REQUIRE(rdata->type == dns_rdatatype_hinfo); REQUIRE(rdata->length != 0); return (mem_tobuffer(target, rdata->data, rdata->length)); @@ -95,7 +95,7 @@ compare_hinfo(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 13); + REQUIRE(rdata1->type == dns_rdatatype_hinfo); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -108,7 +108,7 @@ static inline isc_result_t fromstruct_hinfo(ARGS_FROMSTRUCT) { dns_rdata_hinfo_t *hinfo = source; - REQUIRE(type == 13); + REQUIRE(type == dns_rdatatype_hinfo); REQUIRE(source != NULL); REQUIRE(hinfo->common.rdtype == type); REQUIRE(hinfo->common.rdclass == rdclass); @@ -127,7 +127,7 @@ tostruct_hinfo(ARGS_TOSTRUCT) { dns_rdata_hinfo_t *hinfo = target; isc_region_t region; - REQUIRE(rdata->type == 13); + REQUIRE(rdata->type == dns_rdatatype_hinfo); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -176,7 +176,7 @@ freestruct_hinfo(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_hinfo(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 13); + REQUIRE(rdata->type == dns_rdatatype_hinfo); UNUSED(add); UNUSED(arg); @@ -189,7 +189,7 @@ static inline isc_result_t digest_hinfo(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 13); + REQUIRE(rdata->type == dns_rdatatype_hinfo); dns_rdata_toregion(rdata, &r); @@ -199,7 +199,7 @@ digest_hinfo(ARGS_DIGEST) { static inline isc_boolean_t checkowner_hinfo(ARGS_CHECKOWNER) { - REQUIRE(type == 13); + REQUIRE(type == dns_rdatatype_hinfo); UNUSED(name); UNUSED(type); @@ -212,7 +212,7 @@ checkowner_hinfo(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_hinfo(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 13); + REQUIRE(rdata->type == dns_rdatatype_hinfo); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/hip_55.c b/lib/dns/rdata/generic/hip_55.c index eee581f26a95..7c51d1f72a54 100644 --- a/lib/dns/rdata/generic/hip_55.c +++ b/lib/dns/rdata/generic/hip_55.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009, 2011, 2013, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2009, 2011, 2013-2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -35,7 +35,7 @@ fromtext_hip(ARGS_FROMTEXT) { unsigned char *start; size_t len; - REQUIRE(type == 55); + REQUIRE(type == dns_rdatatype_hip); UNUSED(type); UNUSED(rdclass); @@ -126,7 +126,7 @@ totext_hip(ARGS_TOTEXT) { unsigned char algorithm; char buf[sizeof("225 ")]; - REQUIRE(rdata->type == 55); + REQUIRE(rdata->type == dns_rdatatype_hip); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, ®ion); @@ -193,7 +193,7 @@ fromwire_hip(ARGS_FROMWIRE) { isc_uint8_t hit_len; isc_uint16_t key_len; - REQUIRE(type == 55); + REQUIRE(type == dns_rdatatype_hip); UNUSED(type); UNUSED(rdclass); @@ -229,7 +229,7 @@ static inline isc_result_t towire_hip(ARGS_TOWIRE) { isc_region_t region; - REQUIRE(rdata->type == 55); + REQUIRE(rdata->type == dns_rdatatype_hip); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -245,7 +245,7 @@ compare_hip(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 55); + REQUIRE(rdata1->type == dns_rdatatype_hip); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -260,7 +260,7 @@ fromstruct_hip(ARGS_FROMSTRUCT) { dns_rdata_hip_t myhip; isc_result_t result; - REQUIRE(type == 55); + REQUIRE(type == dns_rdatatype_hip); REQUIRE(source != NULL); REQUIRE(hip->common.rdtype == type); REQUIRE(hip->common.rdclass == rdclass); @@ -292,7 +292,7 @@ tostruct_hip(ARGS_TOSTRUCT) { isc_region_t region; dns_rdata_hip_t *hip = target; - REQUIRE(rdata->type == 55); + REQUIRE(rdata->type == dns_rdatatype_hip); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -369,7 +369,7 @@ additionaldata_hip(ARGS_ADDLDATA) { UNUSED(add); UNUSED(arg); - REQUIRE(rdata->type == 55); + REQUIRE(rdata->type == dns_rdatatype_hip); return (ISC_R_SUCCESS); } @@ -378,7 +378,7 @@ static inline isc_result_t digest_hip(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 55); + REQUIRE(rdata->type == dns_rdatatype_hip); dns_rdata_toregion(rdata, &r); return ((digest)(arg, &r)); @@ -387,7 +387,7 @@ digest_hip(ARGS_DIGEST) { static inline isc_boolean_t checkowner_hip(ARGS_CHECKOWNER) { - REQUIRE(type == 55); + REQUIRE(type == dns_rdatatype_hip); UNUSED(name); UNUSED(type); @@ -400,7 +400,7 @@ checkowner_hip(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_hip(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 55); + REQUIRE(rdata->type == dns_rdatatype_hip); UNUSED(rdata); UNUSED(owner); @@ -459,7 +459,7 @@ casecompare_hip(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 55); + REQUIRE(rdata1->type == dns_rdatatype_hip); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); diff --git a/lib/dns/rdata/generic/ipseckey_45.c b/lib/dns/rdata/generic/ipseckey_45.c index 230d0d1e1e82..c5462c1a69a8 100644 --- a/lib/dns/rdata/generic/ipseckey_45.c +++ b/lib/dns/rdata/generic/ipseckey_45.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005, 2007, 2009, 2011, 2012, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2005, 2007, 2009, 2011, 2012, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -35,7 +35,7 @@ fromtext_ipseckey(ARGS_FROMTEXT) { unsigned char addr6[16]; isc_region_t region; - REQUIRE(type == 45); + REQUIRE(type == dns_rdatatype_ipseckey); UNUSED(type); UNUSED(rdclass); @@ -124,7 +124,7 @@ totext_ipseckey(ARGS_TOTEXT) { unsigned short num; unsigned short gateway; - REQUIRE(rdata->type == 45); + REQUIRE(rdata->type == dns_rdatatype_ipseckey); REQUIRE(rdata->length >= 3); dns_name_init(&name, NULL); @@ -207,7 +207,7 @@ fromwire_ipseckey(ARGS_FROMWIRE) { dns_name_t name; isc_region_t region; - REQUIRE(type == 45); + REQUIRE(type == dns_rdatatype_ipseckey); UNUSED(type); UNUSED(rdclass); @@ -254,7 +254,7 @@ static inline isc_result_t towire_ipseckey(ARGS_TOWIRE) { isc_region_t region; - REQUIRE(rdata->type == 45); + REQUIRE(rdata->type == dns_rdatatype_ipseckey); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -270,7 +270,7 @@ compare_ipseckey(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 45); + REQUIRE(rdata1->type == dns_rdatatype_ipseckey); REQUIRE(rdata1->length >= 3); REQUIRE(rdata2->length >= 3); @@ -286,7 +286,7 @@ fromstruct_ipseckey(ARGS_FROMSTRUCT) { isc_region_t region; isc_uint32_t n; - REQUIRE(type == 45); + REQUIRE(type == dns_rdatatype_ipseckey); REQUIRE(source != NULL); REQUIRE(ipseckey->common.rdtype == type); REQUIRE(ipseckey->common.rdclass == rdclass); @@ -330,7 +330,7 @@ tostruct_ipseckey(ARGS_TOSTRUCT) { dns_name_t name; isc_uint32_t n; - REQUIRE(rdata->type == 45); + REQUIRE(rdata->type == dns_rdatatype_ipseckey); REQUIRE(target != NULL); REQUIRE(rdata->length >= 3); @@ -398,7 +398,7 @@ freestruct_ipseckey(ARGS_FREESTRUCT) { dns_rdata_ipseckey_t *ipseckey = source; REQUIRE(source != NULL); - REQUIRE(ipseckey->common.rdtype == 45); + REQUIRE(ipseckey->common.rdtype == dns_rdatatype_ipseckey); if (ipseckey->mctx == NULL) return; @@ -415,7 +415,7 @@ freestruct_ipseckey(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_ipseckey(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 45); + REQUIRE(rdata->type == dns_rdatatype_ipseckey); UNUSED(rdata); UNUSED(add); @@ -428,7 +428,7 @@ static inline isc_result_t digest_ipseckey(ARGS_DIGEST) { isc_region_t region; - REQUIRE(rdata->type == 45); + REQUIRE(rdata->type == dns_rdatatype_ipseckey); dns_rdata_toregion(rdata, ®ion); return ((digest)(arg, ®ion)); @@ -437,7 +437,7 @@ digest_ipseckey(ARGS_DIGEST) { static inline isc_boolean_t checkowner_ipseckey(ARGS_CHECKOWNER) { - REQUIRE(type == 45); + REQUIRE(type == dns_rdatatype_ipseckey); UNUSED(name); UNUSED(type); @@ -450,7 +450,7 @@ checkowner_ipseckey(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_ipseckey(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 45); + REQUIRE(rdata->type == dns_rdatatype_ipseckey); UNUSED(rdata); UNUSED(owner); @@ -469,7 +469,7 @@ casecompare_ipseckey(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 45); + REQUIRE(rdata1->type == dns_rdatatype_ipseckey); REQUIRE(rdata1->length >= 3); REQUIRE(rdata2->length >= 3); diff --git a/lib/dns/rdata/generic/isdn_20.c b/lib/dns/rdata/generic/isdn_20.c index dea36f0f658a..bc566b25c3b9 100644 --- a/lib/dns/rdata/generic/isdn_20.c +++ b/lib/dns/rdata/generic/isdn_20.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009, 2013, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2013-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -30,7 +30,7 @@ static inline isc_result_t fromtext_isdn(ARGS_FROMTEXT) { isc_token_t token; - REQUIRE(type == 20); + REQUIRE(type == dns_rdatatype_isdn); UNUSED(type); UNUSED(rdclass); @@ -59,7 +59,7 @@ static inline isc_result_t totext_isdn(ARGS_TOTEXT) { isc_region_t region; - REQUIRE(rdata->type == 20); + REQUIRE(rdata->type == dns_rdatatype_isdn); REQUIRE(rdata->length != 0); UNUSED(tctx); @@ -74,7 +74,7 @@ totext_isdn(ARGS_TOTEXT) { static inline isc_result_t fromwire_isdn(ARGS_FROMWIRE) { - REQUIRE(type == 20); + REQUIRE(type == dns_rdatatype_isdn); UNUSED(type); UNUSED(dctx); @@ -91,7 +91,7 @@ static inline isc_result_t towire_isdn(ARGS_TOWIRE) { UNUSED(cctx); - REQUIRE(rdata->type == 20); + REQUIRE(rdata->type == dns_rdatatype_isdn); REQUIRE(rdata->length != 0); return (mem_tobuffer(target, rdata->data, rdata->length)); @@ -104,7 +104,7 @@ compare_isdn(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 20); + REQUIRE(rdata1->type == dns_rdatatype_isdn); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -117,7 +117,7 @@ static inline isc_result_t fromstruct_isdn(ARGS_FROMSTRUCT) { dns_rdata_isdn_t *isdn = source; - REQUIRE(type == 20); + REQUIRE(type == dns_rdatatype_isdn); REQUIRE(source != NULL); REQUIRE(isdn->common.rdtype == type); REQUIRE(isdn->common.rdclass == rdclass); @@ -138,7 +138,7 @@ tostruct_isdn(ARGS_TOSTRUCT) { dns_rdata_isdn_t *isdn = target; isc_region_t r; - REQUIRE(rdata->type == 20); + REQUIRE(rdata->type == dns_rdatatype_isdn); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -194,7 +194,7 @@ freestruct_isdn(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_isdn(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 20); + REQUIRE(rdata->type == dns_rdatatype_isdn); UNUSED(rdata); UNUSED(add); @@ -207,7 +207,7 @@ static inline isc_result_t digest_isdn(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 20); + REQUIRE(rdata->type == dns_rdatatype_isdn); dns_rdata_toregion(rdata, &r); @@ -217,7 +217,7 @@ digest_isdn(ARGS_DIGEST) { static inline isc_boolean_t checkowner_isdn(ARGS_CHECKOWNER) { - REQUIRE(type == 20); + REQUIRE(type == dns_rdatatype_isdn); UNUSED(name); UNUSED(type); @@ -230,7 +230,7 @@ checkowner_isdn(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_isdn(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 20); + REQUIRE(rdata->type == dns_rdatatype_isdn); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/key_25.c b/lib/dns/rdata/generic/key_25.c index f55401e1b8ac..c2ddd57fc108 100644 --- a/lib/dns/rdata/generic/key_25.c +++ b/lib/dns/rdata/generic/key_25.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009, 2011-2013 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2011-2013, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -38,7 +38,7 @@ fromtext_key(ARGS_FROMTEXT) { dns_secproto_t proto; dns_keyflags_t flags; - REQUIRE(type == 25); + REQUIRE(type == dns_rdatatype_key); UNUSED(type); UNUSED(rdclass); @@ -87,7 +87,7 @@ totext_key(ARGS_TOTEXT) { unsigned char algorithm; char namebuf[DNS_NAME_FORMATSIZE]; - REQUIRE(rdata->type == 25); + REQUIRE(rdata->type == dns_rdatatype_key); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, &sr); @@ -163,7 +163,7 @@ fromwire_key(ARGS_FROMWIRE) { unsigned char algorithm; isc_region_t sr; - REQUIRE(type == 25); + REQUIRE(type == dns_rdatatype_key); UNUSED(type); UNUSED(rdclass); @@ -203,7 +203,7 @@ static inline isc_result_t towire_key(ARGS_TOWIRE) { isc_region_t sr; - REQUIRE(rdata->type == 25); + REQUIRE(rdata->type == dns_rdatatype_key); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -219,7 +219,7 @@ compare_key(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 25); + REQUIRE(rdata1->type == dns_rdatatype_key); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -232,7 +232,7 @@ static inline isc_result_t fromstruct_key(ARGS_FROMSTRUCT) { dns_rdata_key_t *key = source; - REQUIRE(type == 25); + REQUIRE(type == dns_rdatatype_key); REQUIRE(source != NULL); REQUIRE(key->common.rdtype == type); REQUIRE(key->common.rdclass == rdclass); @@ -258,7 +258,7 @@ tostruct_key(ARGS_TOSTRUCT) { dns_rdata_key_t *key = target; isc_region_t sr; - REQUIRE(rdata->type == 25); + REQUIRE(rdata->type == dns_rdatatype_key); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -301,7 +301,7 @@ freestruct_key(ARGS_FREESTRUCT) { dns_rdata_key_t *key = (dns_rdata_key_t *) source; REQUIRE(source != NULL); - REQUIRE(key->common.rdtype == 25); + REQUIRE(key->common.rdtype == dns_rdatatype_key); if (key->mctx == NULL) return; @@ -313,7 +313,7 @@ freestruct_key(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_key(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 25); + REQUIRE(rdata->type == dns_rdatatype_key); UNUSED(rdata); UNUSED(add); @@ -326,7 +326,7 @@ static inline isc_result_t digest_key(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 25); + REQUIRE(rdata->type == dns_rdatatype_key); dns_rdata_toregion(rdata, &r); @@ -336,7 +336,7 @@ digest_key(ARGS_DIGEST) { static inline isc_boolean_t checkowner_key(ARGS_CHECKOWNER) { - REQUIRE(type == 25); + REQUIRE(type == dns_rdatatype_key); UNUSED(name); UNUSED(type); @@ -349,7 +349,7 @@ checkowner_key(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_key(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 25); + REQUIRE(rdata->type == dns_rdatatype_key); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/keydata_65533.c b/lib/dns/rdata/generic/keydata_65533.c index 00cf084eb62a..3be76989f7bf 100644 --- a/lib/dns/rdata/generic/keydata_65533.c +++ b/lib/dns/rdata/generic/keydata_65533.c @@ -33,7 +33,7 @@ fromtext_keydata(ARGS_FROMTEXT) { dns_keyflags_t flags; isc_uint32_t refresh, addhd, removehd; - REQUIRE(type == 65533); + REQUIRE(type == dns_rdatatype_keydata); UNUSED(type); UNUSED(rdclass); @@ -98,11 +98,11 @@ totext_keydata(ARGS_TOTEXT) { char buf[sizeof("64000")]; unsigned int flags; unsigned char algorithm; - unsigned long refresh, add, remove; + unsigned long refresh, add, delete; char algbuf[DNS_NAME_FORMATSIZE]; const char *keyinfo; - REQUIRE(rdata->type == 65533); + REQUIRE(rdata->type == dns_rdatatype_keydata); if ((tctx->flags & DNS_STYLEFLAG_KEYDATA) == 0 || rdata->length < 16) return (unknown_totext(rdata, tctx, target)); @@ -122,9 +122,9 @@ totext_keydata(ARGS_TOTEXT) { RETERR(str_totext(" ", target)); /* remove hold-down */ - remove = uint32_fromregion(&sr); + delete = uint32_fromregion(&sr); isc_region_consume(&sr, 4); - RETERR(dns_time32_totext(remove, target)); + RETERR(dns_time32_totext(delete, target)); RETERR(str_totext(" ", target)); /* flags */ @@ -206,7 +206,7 @@ totext_keydata(ARGS_TOTEXT) { isc_time_formathttptimestamp(&t, rbuf, sizeof(rbuf)); RETERR(str_totext(rbuf, target)); - if (add == 0) { + if (add == 0U) { RETERR(str_totext(tctx->linebreak, target)); RETERR(str_totext("; no trust", target)); } else { @@ -224,11 +224,11 @@ totext_keydata(ARGS_TOTEXT) { RETERR(str_totext(abuf, target)); } - if (remove != 0) { + if (delete != 0U) { RETERR(str_totext(tctx->linebreak, target)); RETERR(str_totext("; removal pending: ", target)); - isc_time_set(&t, remove, 0); + isc_time_set(&t, delete, 0); isc_time_formathttptimestamp(&t, dbuf, sizeof(dbuf)); RETERR(str_totext(dbuf, target)); @@ -243,7 +243,7 @@ static inline isc_result_t fromwire_keydata(ARGS_FROMWIRE) { isc_region_t sr; - REQUIRE(type == 65533); + REQUIRE(type == dns_rdatatype_keydata); UNUSED(type); UNUSED(rdclass); @@ -259,7 +259,7 @@ static inline isc_result_t towire_keydata(ARGS_TOWIRE) { isc_region_t sr; - REQUIRE(rdata->type == 65533); + REQUIRE(rdata->type == dns_rdatatype_keydata); UNUSED(cctx); @@ -274,7 +274,7 @@ compare_keydata(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 65533); + REQUIRE(rdata1->type == dns_rdatatype_keydata); dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); @@ -285,7 +285,7 @@ static inline isc_result_t fromstruct_keydata(ARGS_FROMSTRUCT) { dns_rdata_keydata_t *keydata = source; - REQUIRE(type == 65533); + REQUIRE(type == dns_rdatatype_keydata); REQUIRE(source != NULL); REQUIRE(keydata->common.rdtype == type); REQUIRE(keydata->common.rdclass == rdclass); @@ -320,7 +320,7 @@ tostruct_keydata(ARGS_TOSTRUCT) { dns_rdata_keydata_t *keydata = target; isc_region_t sr; - REQUIRE(rdata->type == 65533); + REQUIRE(rdata->type == dns_rdatatype_keydata); REQUIRE(target != NULL); keydata->common.rdclass = rdata->rdclass; @@ -380,7 +380,7 @@ freestruct_keydata(ARGS_FREESTRUCT) { dns_rdata_keydata_t *keydata = (dns_rdata_keydata_t *) source; REQUIRE(source != NULL); - REQUIRE(keydata->common.rdtype == 65533); + REQUIRE(keydata->common.rdtype == dns_rdatatype_keydata); if (keydata->mctx == NULL) return; @@ -392,7 +392,7 @@ freestruct_keydata(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_keydata(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 65533); + REQUIRE(rdata->type == dns_rdatatype_keydata); UNUSED(rdata); UNUSED(add); @@ -405,7 +405,7 @@ static inline isc_result_t digest_keydata(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 65533); + REQUIRE(rdata->type == dns_rdatatype_keydata); dns_rdata_toregion(rdata, &r); @@ -415,7 +415,7 @@ digest_keydata(ARGS_DIGEST) { static inline isc_boolean_t checkowner_keydata(ARGS_CHECKOWNER) { - REQUIRE(type == 65533); + REQUIRE(type == dns_rdatatype_keydata); UNUSED(name); UNUSED(type); @@ -428,7 +428,7 @@ checkowner_keydata(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_keydata(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 65533); + REQUIRE(rdata->type == dns_rdatatype_keydata); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/l32_105.c b/lib/dns/rdata/generic/l32_105.c index d191624ebc25..d721d04f65d0 100644 --- a/lib/dns/rdata/generic/l32_105.c +++ b/lib/dns/rdata/generic/l32_105.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -29,7 +29,7 @@ fromtext_l32(ARGS_FROMTEXT) { struct in_addr addr; isc_region_t region; - REQUIRE(type == 105); + REQUIRE(type == dns_rdatatype_l32); UNUSED(type); UNUSED(rdclass); @@ -62,7 +62,7 @@ totext_l32(ARGS_TOTEXT) { char buf[sizeof("65000")]; unsigned short num; - REQUIRE(rdata->type == 105); + REQUIRE(rdata->type == dns_rdatatype_l32); REQUIRE(rdata->length == 6); UNUSED(tctx); @@ -82,7 +82,7 @@ static inline isc_result_t fromwire_l32(ARGS_FROMWIRE) { isc_region_t sregion; - REQUIRE(type == 105); + REQUIRE(type == dns_rdatatype_l32); UNUSED(type); UNUSED(options); @@ -99,7 +99,7 @@ fromwire_l32(ARGS_FROMWIRE) { static inline isc_result_t towire_l32(ARGS_TOWIRE) { - REQUIRE(rdata->type == 105); + REQUIRE(rdata->type == dns_rdatatype_l32); REQUIRE(rdata->length == 6); UNUSED(cctx); @@ -114,7 +114,7 @@ compare_l32(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 105); + REQUIRE(rdata1->type == dns_rdatatype_l32); REQUIRE(rdata1->length == 6); REQUIRE(rdata2->length == 6); @@ -128,7 +128,7 @@ fromstruct_l32(ARGS_FROMSTRUCT) { dns_rdata_l32_t *l32 = source; isc_uint32_t n; - REQUIRE(type == 105); + REQUIRE(type == dns_rdatatype_l32); REQUIRE(source != NULL); REQUIRE(l32->common.rdtype == type); REQUIRE(l32->common.rdclass == rdclass); @@ -147,7 +147,7 @@ tostruct_l32(ARGS_TOSTRUCT) { dns_rdata_l32_t *l32 = target; isc_uint32_t n; - REQUIRE(rdata->type == 105); + REQUIRE(rdata->type == dns_rdatatype_l32); REQUIRE(target != NULL); REQUIRE(rdata->length == 6); @@ -169,7 +169,7 @@ freestruct_l32(ARGS_FREESTRUCT) { dns_rdata_l32_t *l32 = source; REQUIRE(source != NULL); - REQUIRE(l32->common.rdtype == 105); + REQUIRE(l32->common.rdtype == dns_rdatatype_l32); return; } @@ -177,7 +177,7 @@ freestruct_l32(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_l32(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 105); + REQUIRE(rdata->type == dns_rdatatype_l32); REQUIRE(rdata->length == 6); UNUSED(rdata); @@ -191,7 +191,7 @@ static inline isc_result_t digest_l32(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 105); + REQUIRE(rdata->type == dns_rdatatype_l32); REQUIRE(rdata->length == 6); dns_rdata_toregion(rdata, &r); @@ -202,7 +202,7 @@ digest_l32(ARGS_DIGEST) { static inline isc_boolean_t checkowner_l32(ARGS_CHECKOWNER) { - REQUIRE(type == 105); + REQUIRE(type == dns_rdatatype_l32); UNUSED(name); UNUSED(type); @@ -215,7 +215,7 @@ checkowner_l32(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_l32(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 105); + REQUIRE(rdata->type == dns_rdatatype_l32); REQUIRE(rdata->length == 6); UNUSED(rdata); diff --git a/lib/dns/rdata/generic/l64_106.c b/lib/dns/rdata/generic/l64_106.c index d811d29ae515..863e96461179 100644 --- a/lib/dns/rdata/generic/l64_106.c +++ b/lib/dns/rdata/generic/l64_106.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -28,7 +28,7 @@ fromtext_l64(ARGS_FROMTEXT) { isc_token_t token; unsigned char locator[NS_LOCATORSZ]; - REQUIRE(type == 106); + REQUIRE(type == dns_rdatatype_l64); UNUSED(type); UNUSED(rdclass); @@ -56,7 +56,7 @@ totext_l64(ARGS_TOTEXT) { char buf[sizeof("xxxx:xxxx:xxxx:xxxx")]; unsigned short num; - REQUIRE(rdata->type == 106); + REQUIRE(rdata->type == dns_rdatatype_l64); REQUIRE(rdata->length == 10); UNUSED(tctx); @@ -81,7 +81,7 @@ static inline isc_result_t fromwire_l64(ARGS_FROMWIRE) { isc_region_t sregion; - REQUIRE(type == 106); + REQUIRE(type == dns_rdatatype_l64); UNUSED(type); UNUSED(options); @@ -98,7 +98,7 @@ fromwire_l64(ARGS_FROMWIRE) { static inline isc_result_t towire_l64(ARGS_TOWIRE) { - REQUIRE(rdata->type == 106); + REQUIRE(rdata->type == dns_rdatatype_l64); REQUIRE(rdata->length == 10); UNUSED(cctx); @@ -113,7 +113,7 @@ compare_l64(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 106); + REQUIRE(rdata1->type == dns_rdatatype_l64); REQUIRE(rdata1->length == 10); REQUIRE(rdata2->length == 10); @@ -126,7 +126,7 @@ static inline isc_result_t fromstruct_l64(ARGS_FROMSTRUCT) { dns_rdata_l64_t *l64 = source; - REQUIRE(type == 106); + REQUIRE(type == dns_rdatatype_l64); REQUIRE(source != NULL); REQUIRE(l64->common.rdtype == type); REQUIRE(l64->common.rdclass == rdclass); @@ -143,7 +143,7 @@ tostruct_l64(ARGS_TOSTRUCT) { isc_region_t region; dns_rdata_l64_t *l64 = target; - REQUIRE(rdata->type == 106); + REQUIRE(rdata->type == dns_rdatatype_l64); REQUIRE(target != NULL); REQUIRE(rdata->length == 10); @@ -164,7 +164,7 @@ freestruct_l64(ARGS_FREESTRUCT) { dns_rdata_l64_t *l64 = source; REQUIRE(source != NULL); - REQUIRE(l64->common.rdtype == 106); + REQUIRE(l64->common.rdtype == dns_rdatatype_l64); return; } @@ -172,7 +172,7 @@ freestruct_l64(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_l64(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 106); + REQUIRE(rdata->type == dns_rdatatype_l64); REQUIRE(rdata->length == 10); UNUSED(rdata); @@ -186,7 +186,7 @@ static inline isc_result_t digest_l64(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 106); + REQUIRE(rdata->type == dns_rdatatype_l64); REQUIRE(rdata->length == 10); dns_rdata_toregion(rdata, &r); @@ -197,7 +197,7 @@ digest_l64(ARGS_DIGEST) { static inline isc_boolean_t checkowner_l64(ARGS_CHECKOWNER) { - REQUIRE(type == 106); + REQUIRE(type == dns_rdatatype_l64); UNUSED(name); UNUSED(type); @@ -210,7 +210,7 @@ checkowner_l64(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_l64(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 106); + REQUIRE(rdata->type == dns_rdatatype_l64); REQUIRE(rdata->length == 10); UNUSED(rdata); diff --git a/lib/dns/rdata/generic/loc_29.c b/lib/dns/rdata/generic/loc_29.c index 904dbb402a97..641daca25d68 100644 --- a/lib/dns/rdata/generic/loc_29.c +++ b/lib/dns/rdata/generic/loc_29.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -50,7 +50,7 @@ fromtext_loc(ARGS_FROMTEXT) { unsigned long longitude; unsigned long altitude; - REQUIRE(type == 29); + REQUIRE(type == dns_rdatatype_loc); UNUSED(type); UNUSED(rdclass); @@ -475,12 +475,16 @@ totext_loc(ARGS_TOTEXT) { UNUSED(tctx); - REQUIRE(rdata->type == 29); + REQUIRE(rdata->type == dns_rdatatype_loc); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, &sr); - /* version = sr.base[0]; */ + if (sr.base[0] != 0) + return (ISC_R_NOTIMPLEMENTED); + + REQUIRE(rdata->length == 16); + size = sr.base[1]; INSIST((size&0x0f) < 10 && (size>>4) < 10); if ((size&0x0f)> 1) @@ -563,7 +567,7 @@ fromwire_loc(ARGS_FROMWIRE) { unsigned long latitude; unsigned long longitude; - REQUIRE(type == 29); + REQUIRE(type == dns_rdatatype_loc); UNUSED(type); UNUSED(rdclass); @@ -573,8 +577,11 @@ fromwire_loc(ARGS_FROMWIRE) { isc_buffer_activeregion(source, &sr); if (sr.length < 1) return (ISC_R_UNEXPECTEDEND); - if (sr.base[0] != 0) - return (ISC_R_NOTIMPLEMENTED); + if (sr.base[0] != 0) { + /* Treat as unknown. */ + isc_buffer_forward(source, sr.length); + return (mem_tobuffer(target, sr.base, sr.length)); + } if (sr.length < 16) return (ISC_R_UNEXPECTEDEND); @@ -634,7 +641,7 @@ static inline isc_result_t towire_loc(ARGS_TOWIRE) { UNUSED(cctx); - REQUIRE(rdata->type == 29); + REQUIRE(rdata->type == dns_rdatatype_loc); REQUIRE(rdata->length != 0); return (mem_tobuffer(target, rdata->data, rdata->length)); @@ -647,7 +654,7 @@ compare_loc(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 29); + REQUIRE(rdata1->type == dns_rdatatype_loc); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -661,7 +668,7 @@ fromstruct_loc(ARGS_FROMSTRUCT) { dns_rdata_loc_t *loc = source; isc_uint8_t c; - REQUIRE(type == 29); + REQUIRE(type == dns_rdatatype_loc); REQUIRE(source != NULL); REQUIRE(loc->common.rdtype == type); REQUIRE(loc->common.rdclass == rdclass); @@ -706,7 +713,7 @@ tostruct_loc(ARGS_TOSTRUCT) { isc_region_t r; isc_uint8_t version; - REQUIRE(rdata->type == 29); + REQUIRE(rdata->type == dns_rdatatype_loc); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -743,7 +750,7 @@ freestruct_loc(ARGS_FREESTRUCT) { dns_rdata_loc_t *loc = source; REQUIRE(source != NULL); - REQUIRE(loc->common.rdtype == 29); + REQUIRE(loc->common.rdtype == dns_rdatatype_loc); UNUSED(source); UNUSED(loc); @@ -751,7 +758,7 @@ freestruct_loc(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_loc(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 29); + REQUIRE(rdata->type == dns_rdatatype_loc); UNUSED(rdata); UNUSED(add); @@ -764,7 +771,7 @@ static inline isc_result_t digest_loc(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 29); + REQUIRE(rdata->type == dns_rdatatype_loc); dns_rdata_toregion(rdata, &r); @@ -774,7 +781,7 @@ digest_loc(ARGS_DIGEST) { static inline isc_boolean_t checkowner_loc(ARGS_CHECKOWNER) { - REQUIRE(type == 29); + REQUIRE(type == dns_rdatatype_loc); UNUSED(name); UNUSED(type); @@ -787,7 +794,7 @@ checkowner_loc(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_loc(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 29); + REQUIRE(rdata->type == dns_rdatatype_loc); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/lp_107.c b/lib/dns/rdata/generic/lp_107.c index 732ef7fa88f5..08d6b1763593 100644 --- a/lib/dns/rdata/generic/lp_107.c +++ b/lib/dns/rdata/generic/lp_107.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2013, 2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -29,7 +29,7 @@ fromtext_lp(ARGS_FROMTEXT) { dns_name_t name; isc_buffer_t buffer; - REQUIRE(type == 107); + REQUIRE(type == dns_rdatatype_lp); UNUSED(type); UNUSED(rdclass); @@ -59,7 +59,7 @@ totext_lp(ARGS_TOTEXT) { char buf[sizeof("64000")]; unsigned short num; - REQUIRE(rdata->type == 107); + REQUIRE(rdata->type == dns_rdatatype_lp); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -83,7 +83,7 @@ fromwire_lp(ARGS_FROMWIRE) { dns_name_t name; isc_region_t sregion; - REQUIRE(type == 107); + REQUIRE(type == dns_rdatatype_lp); UNUSED(type); UNUSED(rdclass); @@ -103,7 +103,7 @@ fromwire_lp(ARGS_FROMWIRE) { static inline isc_result_t towire_lp(ARGS_TOWIRE) { - REQUIRE(rdata->type == 107); + REQUIRE(rdata->type == dns_rdatatype_lp); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -118,7 +118,7 @@ compare_lp(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 107); + REQUIRE(rdata1->type == dns_rdatatype_lp); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -133,7 +133,7 @@ fromstruct_lp(ARGS_FROMSTRUCT) { dns_rdata_lp_t *lp = source; isc_region_t region; - REQUIRE(type == 107); + REQUIRE(type == dns_rdatatype_lp); REQUIRE(source != NULL); REQUIRE(lp->common.rdtype == type); REQUIRE(lp->common.rdclass == rdclass); @@ -152,7 +152,7 @@ tostruct_lp(ARGS_TOSTRUCT) { dns_rdata_lp_t *lp = target; dns_name_t name; - REQUIRE(rdata->type == 107); + REQUIRE(rdata->type == dns_rdatatype_lp); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -176,7 +176,7 @@ freestruct_lp(ARGS_FREESTRUCT) { dns_rdata_lp_t *lp = source; REQUIRE(source != NULL); - REQUIRE(lp->common.rdtype == 107); + REQUIRE(lp->common.rdtype == dns_rdatatype_lp); if (lp->mctx == NULL) return; @@ -192,7 +192,7 @@ additionaldata_lp(ARGS_ADDLDATA) { isc_region_t region; isc_result_t result; - REQUIRE(rdata->type == 107); + REQUIRE(rdata->type == dns_rdatatype_lp); dns_name_init(&name, offsets); dns_rdata_toregion(rdata, ®ion); @@ -209,7 +209,7 @@ static inline isc_result_t digest_lp(ARGS_DIGEST) { isc_region_t region; - REQUIRE(rdata->type == 107); + REQUIRE(rdata->type == dns_rdatatype_lp); dns_rdata_toregion(rdata, ®ion); return ((digest)(arg, ®ion)); @@ -218,7 +218,7 @@ digest_lp(ARGS_DIGEST) { static inline isc_boolean_t checkowner_lp(ARGS_CHECKOWNER) { - REQUIRE(type == 107); + REQUIRE(type == dns_rdatatype_lp); UNUSED(type); UNUSED(rdclass); @@ -231,7 +231,7 @@ checkowner_lp(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_lp(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 107); + REQUIRE(rdata->type == dns_rdatatype_lp); UNUSED(bad); UNUSED(owner); @@ -249,7 +249,7 @@ casecompare_lp(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 107); + REQUIRE(rdata1->type == dns_rdatatype_lp); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); diff --git a/lib/dns/rdata/generic/mb_7.c b/lib/dns/rdata/generic/mb_7.c index 8e588fc7b8a5..47c7308ebb03 100644 --- a/lib/dns/rdata/generic/mb_7.c +++ b/lib/dns/rdata/generic/mb_7.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -30,7 +30,7 @@ fromtext_mb(ARGS_FROMTEXT) { dns_name_t name; isc_buffer_t buffer; - REQUIRE(type == 7); + REQUIRE(type == dns_rdatatype_mb); UNUSED(type); UNUSED(rdclass); @@ -53,7 +53,7 @@ totext_mb(ARGS_TOTEXT) { dns_name_t prefix; isc_boolean_t sub; - REQUIRE(rdata->type == 7); + REQUIRE(rdata->type == dns_rdatatype_mb); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -71,7 +71,7 @@ static inline isc_result_t fromwire_mb(ARGS_FROMWIRE) { dns_name_t name; - REQUIRE(type == 7); + REQUIRE(type == dns_rdatatype_mb); UNUSED(type); UNUSED(rdclass); @@ -88,7 +88,7 @@ towire_mb(ARGS_TOWIRE) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 7); + REQUIRE(rdata->type == dns_rdatatype_mb); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); @@ -109,7 +109,7 @@ compare_mb(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 7); + REQUIRE(rdata1->type == dns_rdatatype_mb); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -130,7 +130,7 @@ fromstruct_mb(ARGS_FROMSTRUCT) { dns_rdata_mb_t *mb = source; isc_region_t region; - REQUIRE(type == 7); + REQUIRE(type == dns_rdatatype_mb); REQUIRE(source != NULL); REQUIRE(mb->common.rdtype == type); REQUIRE(mb->common.rdclass == rdclass); @@ -148,7 +148,7 @@ tostruct_mb(ARGS_TOSTRUCT) { dns_rdata_mb_t *mb = target; dns_name_t name; - REQUIRE(rdata->type == 7); + REQUIRE(rdata->type == dns_rdatatype_mb); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -184,7 +184,7 @@ additionaldata_mb(ARGS_ADDLDATA) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 7); + REQUIRE(rdata->type == dns_rdatatype_mb); dns_name_init(&name, offsets); dns_rdata_toregion(rdata, ®ion); @@ -198,7 +198,7 @@ digest_mb(ARGS_DIGEST) { isc_region_t r; dns_name_t name; - REQUIRE(rdata->type == 7); + REQUIRE(rdata->type == dns_rdatatype_mb); dns_rdata_toregion(rdata, &r); dns_name_init(&name, NULL); @@ -210,7 +210,7 @@ digest_mb(ARGS_DIGEST) { static inline isc_boolean_t checkowner_mb(ARGS_CHECKOWNER) { - REQUIRE(type == 7); + REQUIRE(type == dns_rdatatype_mb); UNUSED(type); UNUSED(rdclass); @@ -222,7 +222,7 @@ checkowner_mb(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_mb(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 7); + REQUIRE(rdata->type == dns_rdatatype_mb); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/md_3.c b/lib/dns/rdata/generic/md_3.c index e00f1f6ca368..7485d1e49016 100644 --- a/lib/dns/rdata/generic/md_3.c +++ b/lib/dns/rdata/generic/md_3.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -30,7 +30,7 @@ fromtext_md(ARGS_FROMTEXT) { dns_name_t name; isc_buffer_t buffer; - REQUIRE(type == 3); + REQUIRE(type == dns_rdatatype_md); UNUSED(type); UNUSED(rdclass); @@ -53,7 +53,7 @@ totext_md(ARGS_TOTEXT) { dns_name_t prefix; isc_boolean_t sub; - REQUIRE(rdata->type == 3); + REQUIRE(rdata->type == dns_rdatatype_md); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -71,7 +71,7 @@ static inline isc_result_t fromwire_md(ARGS_FROMWIRE) { dns_name_t name; - REQUIRE(type == 3); + REQUIRE(type == dns_rdatatype_md); UNUSED(type); UNUSED(rdclass); @@ -88,7 +88,7 @@ towire_md(ARGS_TOWIRE) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 3); + REQUIRE(rdata->type == dns_rdatatype_md); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); @@ -109,7 +109,7 @@ compare_md(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 3); + REQUIRE(rdata1->type == dns_rdatatype_md); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -130,7 +130,7 @@ fromstruct_md(ARGS_FROMSTRUCT) { dns_rdata_md_t *md = source; isc_region_t region; - REQUIRE(type == 3); + REQUIRE(type == dns_rdatatype_md); REQUIRE(source != NULL); REQUIRE(md->common.rdtype == type); REQUIRE(md->common.rdclass == rdclass); @@ -148,7 +148,7 @@ tostruct_md(ARGS_TOSTRUCT) { isc_region_t r; dns_name_t name; - REQUIRE(rdata->type == 3); + REQUIRE(rdata->type == dns_rdatatype_md); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -170,7 +170,7 @@ freestruct_md(ARGS_FREESTRUCT) { dns_rdata_md_t *md = source; REQUIRE(source != NULL); - REQUIRE(md->common.rdtype == 3); + REQUIRE(md->common.rdtype == dns_rdatatype_md); if (md->mctx == NULL) return; @@ -185,7 +185,7 @@ additionaldata_md(ARGS_ADDLDATA) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 3); + REQUIRE(rdata->type == dns_rdatatype_md); dns_name_init(&name, offsets); dns_rdata_toregion(rdata, ®ion); @@ -199,7 +199,7 @@ digest_md(ARGS_DIGEST) { isc_region_t r; dns_name_t name; - REQUIRE(rdata->type == 3); + REQUIRE(rdata->type == dns_rdatatype_md); dns_rdata_toregion(rdata, &r); dns_name_init(&name, NULL); @@ -211,7 +211,7 @@ digest_md(ARGS_DIGEST) { static inline isc_boolean_t checkowner_md(ARGS_CHECKOWNER) { - REQUIRE(type == 3); + REQUIRE(type == dns_rdatatype_md); UNUSED(name); UNUSED(type); @@ -224,7 +224,7 @@ checkowner_md(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_md(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 3); + REQUIRE(rdata->type == dns_rdatatype_md); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/mf_4.c b/lib/dns/rdata/generic/mf_4.c index a85809aef223..97402a9dc6db 100644 --- a/lib/dns/rdata/generic/mf_4.c +++ b/lib/dns/rdata/generic/mf_4.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -30,7 +30,7 @@ fromtext_mf(ARGS_FROMTEXT) { dns_name_t name; isc_buffer_t buffer; - REQUIRE(type == 4); + REQUIRE(type == dns_rdatatype_mf); UNUSED(type); UNUSED(rdclass); @@ -53,7 +53,7 @@ totext_mf(ARGS_TOTEXT) { dns_name_t prefix; isc_boolean_t sub; - REQUIRE(rdata->type == 4); + REQUIRE(rdata->type == dns_rdatatype_mf); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -71,7 +71,7 @@ static inline isc_result_t fromwire_mf(ARGS_FROMWIRE) { dns_name_t name; - REQUIRE(type == 4); + REQUIRE(type == dns_rdatatype_mf); UNUSED(type); UNUSED(rdclass); @@ -88,7 +88,7 @@ towire_mf(ARGS_TOWIRE) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 4); + REQUIRE(rdata->type == dns_rdatatype_mf); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); @@ -109,7 +109,7 @@ compare_mf(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 4); + REQUIRE(rdata1->type == dns_rdatatype_mf); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -130,7 +130,7 @@ fromstruct_mf(ARGS_FROMSTRUCT) { dns_rdata_mf_t *mf = source; isc_region_t region; - REQUIRE(type == 4); + REQUIRE(type == dns_rdatatype_mf); REQUIRE(source != NULL); REQUIRE(mf->common.rdtype == type); REQUIRE(mf->common.rdclass == rdclass); @@ -148,7 +148,7 @@ tostruct_mf(ARGS_TOSTRUCT) { isc_region_t r; dns_name_t name; - REQUIRE(rdata->type == 4); + REQUIRE(rdata->type == dns_rdatatype_mf); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -170,7 +170,7 @@ freestruct_mf(ARGS_FREESTRUCT) { dns_rdata_mf_t *mf = source; REQUIRE(source != NULL); - REQUIRE(mf->common.rdtype == 4); + REQUIRE(mf->common.rdtype == dns_rdatatype_mf); if (mf->mctx == NULL) return; @@ -184,7 +184,7 @@ additionaldata_mf(ARGS_ADDLDATA) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 4); + REQUIRE(rdata->type == dns_rdatatype_mf); dns_name_init(&name, offsets); dns_rdata_toregion(rdata, ®ion); @@ -198,7 +198,7 @@ digest_mf(ARGS_DIGEST) { isc_region_t r; dns_name_t name; - REQUIRE(rdata->type == 4); + REQUIRE(rdata->type == dns_rdatatype_mf); dns_rdata_toregion(rdata, &r); dns_name_init(&name, NULL); @@ -210,7 +210,7 @@ digest_mf(ARGS_DIGEST) { static inline isc_boolean_t checkowner_mf(ARGS_CHECKOWNER) { - REQUIRE(type == 4); + REQUIRE(type == dns_rdatatype_mf); UNUSED(name); UNUSED(type); @@ -223,7 +223,7 @@ checkowner_mf(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_mf(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 4); + REQUIRE(rdata->type == dns_rdatatype_mf); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/mg_8.c b/lib/dns/rdata/generic/mg_8.c index d0af188e7373..6c3b7e2b2d41 100644 --- a/lib/dns/rdata/generic/mg_8.c +++ b/lib/dns/rdata/generic/mg_8.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -30,7 +30,7 @@ fromtext_mg(ARGS_FROMTEXT) { dns_name_t name; isc_buffer_t buffer; - REQUIRE(type == 8); + REQUIRE(type == dns_rdatatype_mg); UNUSED(type); UNUSED(rdclass); @@ -53,7 +53,7 @@ totext_mg(ARGS_TOTEXT) { dns_name_t prefix; isc_boolean_t sub; - REQUIRE(rdata->type == 8); + REQUIRE(rdata->type == dns_rdatatype_mg); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -71,7 +71,7 @@ static inline isc_result_t fromwire_mg(ARGS_FROMWIRE) { dns_name_t name; - REQUIRE(type == 8); + REQUIRE(type == dns_rdatatype_mg); UNUSED(type); UNUSED(rdclass); @@ -88,7 +88,7 @@ towire_mg(ARGS_TOWIRE) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 8); + REQUIRE(rdata->type == dns_rdatatype_mg); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); @@ -109,7 +109,7 @@ compare_mg(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 8); + REQUIRE(rdata1->type == dns_rdatatype_mg); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -130,7 +130,7 @@ fromstruct_mg(ARGS_FROMSTRUCT) { dns_rdata_mg_t *mg = source; isc_region_t region; - REQUIRE(type == 8); + REQUIRE(type == dns_rdatatype_mg); REQUIRE(source != NULL); REQUIRE(mg->common.rdtype == type); REQUIRE(mg->common.rdclass == rdclass); @@ -148,7 +148,7 @@ tostruct_mg(ARGS_TOSTRUCT) { dns_rdata_mg_t *mg = target; dns_name_t name; - REQUIRE(rdata->type == 8); + REQUIRE(rdata->type == dns_rdatatype_mg); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -170,7 +170,7 @@ freestruct_mg(ARGS_FREESTRUCT) { dns_rdata_mg_t *mg = source; REQUIRE(source != NULL); - REQUIRE(mg->common.rdtype == 8); + REQUIRE(mg->common.rdtype == dns_rdatatype_mg); if (mg->mctx == NULL) return; @@ -180,7 +180,7 @@ freestruct_mg(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_mg(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 8); + REQUIRE(rdata->type == dns_rdatatype_mg); UNUSED(add); UNUSED(arg); @@ -194,7 +194,7 @@ digest_mg(ARGS_DIGEST) { isc_region_t r; dns_name_t name; - REQUIRE(rdata->type == 8); + REQUIRE(rdata->type == dns_rdatatype_mg); dns_rdata_toregion(rdata, &r); dns_name_init(&name, NULL); @@ -206,7 +206,7 @@ digest_mg(ARGS_DIGEST) { static inline isc_boolean_t checkowner_mg(ARGS_CHECKOWNER) { - REQUIRE(type == 8); + REQUIRE(type == dns_rdatatype_mg); UNUSED(type); UNUSED(rdclass); @@ -218,7 +218,7 @@ checkowner_mg(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_mg(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 8); + REQUIRE(rdata->type == dns_rdatatype_mg); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/minfo_14.c b/lib/dns/rdata/generic/minfo_14.c index 9e2214c98aa3..2a868f857f8f 100644 --- a/lib/dns/rdata/generic/minfo_14.c +++ b/lib/dns/rdata/generic/minfo_14.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -32,7 +32,7 @@ fromtext_minfo(ARGS_FROMTEXT) { int i; isc_boolean_t ok; - REQUIRE(type == 14); + REQUIRE(type == dns_rdatatype_minfo); UNUSED(type); UNUSED(rdclass); @@ -66,7 +66,7 @@ totext_minfo(ARGS_TOTEXT) { dns_name_t prefix; isc_boolean_t sub; - REQUIRE(rdata->type == 14); + REQUIRE(rdata->type == dns_rdatatype_minfo); REQUIRE(rdata->length != 0); dns_name_init(&rmail, NULL); @@ -96,7 +96,7 @@ fromwire_minfo(ARGS_FROMWIRE) { dns_name_t rmail; dns_name_t email; - REQUIRE(type == 14); + REQUIRE(type == dns_rdatatype_minfo); UNUSED(type); UNUSED(rdclass); @@ -118,7 +118,7 @@ towire_minfo(ARGS_TOWIRE) { dns_offsets_t roffsets; dns_offsets_t eoffsets; - REQUIRE(rdata->type == 14); + REQUIRE(rdata->type == dns_rdatatype_minfo); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); @@ -149,7 +149,7 @@ compare_minfo(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 14); + REQUIRE(rdata1->type == dns_rdatatype_minfo); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -184,7 +184,7 @@ fromstruct_minfo(ARGS_FROMSTRUCT) { dns_rdata_minfo_t *minfo = source; isc_region_t region; - REQUIRE(type == 14); + REQUIRE(type == dns_rdatatype_minfo); REQUIRE(source != NULL); REQUIRE(minfo->common.rdtype == type); REQUIRE(minfo->common.rdclass == rdclass); @@ -205,7 +205,7 @@ tostruct_minfo(ARGS_TOSTRUCT) { dns_name_t name; isc_result_t result; - REQUIRE(rdata->type == 14); + REQUIRE(rdata->type == dns_rdatatype_minfo); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -239,7 +239,7 @@ freestruct_minfo(ARGS_FREESTRUCT) { dns_rdata_minfo_t *minfo = source; REQUIRE(source != NULL); - REQUIRE(minfo->common.rdtype == 14); + REQUIRE(minfo->common.rdtype == dns_rdatatype_minfo); if (minfo->mctx == NULL) return; @@ -251,7 +251,7 @@ freestruct_minfo(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_minfo(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 14); + REQUIRE(rdata->type == dns_rdatatype_minfo); UNUSED(rdata); UNUSED(add); @@ -266,7 +266,7 @@ digest_minfo(ARGS_DIGEST) { dns_name_t name; isc_result_t result; - REQUIRE(rdata->type == 14); + REQUIRE(rdata->type == dns_rdatatype_minfo); dns_rdata_toregion(rdata, &r); dns_name_init(&name, NULL); @@ -284,7 +284,7 @@ digest_minfo(ARGS_DIGEST) { static inline isc_boolean_t checkowner_minfo(ARGS_CHECKOWNER) { - REQUIRE(type == 14); + REQUIRE(type == dns_rdatatype_minfo); UNUSED(name); UNUSED(type); @@ -299,7 +299,7 @@ checknames_minfo(ARGS_CHECKNAMES) { isc_region_t region; dns_name_t name; - REQUIRE(rdata->type == 14); + REQUIRE(rdata->type == dns_rdatatype_minfo); UNUSED(owner); diff --git a/lib/dns/rdata/generic/mr_9.c b/lib/dns/rdata/generic/mr_9.c index 590235d961bb..7e69cf1cfe85 100644 --- a/lib/dns/rdata/generic/mr_9.c +++ b/lib/dns/rdata/generic/mr_9.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -30,7 +30,7 @@ fromtext_mr(ARGS_FROMTEXT) { dns_name_t name; isc_buffer_t buffer; - REQUIRE(type == 9); + REQUIRE(type == dns_rdatatype_mr); UNUSED(type); UNUSED(rdclass); @@ -53,7 +53,7 @@ totext_mr(ARGS_TOTEXT) { dns_name_t prefix; isc_boolean_t sub; - REQUIRE(rdata->type == 9); + REQUIRE(rdata->type == dns_rdatatype_mr); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -71,7 +71,7 @@ static inline isc_result_t fromwire_mr(ARGS_FROMWIRE) { dns_name_t name; - REQUIRE(type == 9); + REQUIRE(type == dns_rdatatype_mr); UNUSED(type); UNUSED(rdclass); @@ -88,7 +88,7 @@ towire_mr(ARGS_TOWIRE) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 9); + REQUIRE(rdata->type == dns_rdatatype_mr); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); @@ -109,7 +109,7 @@ compare_mr(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 9); + REQUIRE(rdata1->type == dns_rdatatype_mr); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -130,7 +130,7 @@ fromstruct_mr(ARGS_FROMSTRUCT) { dns_rdata_mr_t *mr = source; isc_region_t region; - REQUIRE(type == 9); + REQUIRE(type == dns_rdatatype_mr); REQUIRE(source != NULL); REQUIRE(mr->common.rdtype == type); REQUIRE(mr->common.rdclass == rdclass); @@ -148,7 +148,7 @@ tostruct_mr(ARGS_TOSTRUCT) { dns_rdata_mr_t *mr = target; dns_name_t name; - REQUIRE(rdata->type == 9); + REQUIRE(rdata->type == dns_rdatatype_mr); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -170,7 +170,7 @@ freestruct_mr(ARGS_FREESTRUCT) { dns_rdata_mr_t *mr = source; REQUIRE(source != NULL); - REQUIRE(mr->common.rdtype == 9); + REQUIRE(mr->common.rdtype == dns_rdatatype_mr); if (mr->mctx == NULL) return; @@ -180,7 +180,7 @@ freestruct_mr(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_mr(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 9); + REQUIRE(rdata->type == dns_rdatatype_mr); UNUSED(rdata); UNUSED(add); @@ -194,7 +194,7 @@ digest_mr(ARGS_DIGEST) { isc_region_t r; dns_name_t name; - REQUIRE(rdata->type == 9); + REQUIRE(rdata->type == dns_rdatatype_mr); dns_rdata_toregion(rdata, &r); dns_name_init(&name, NULL); @@ -206,7 +206,7 @@ digest_mr(ARGS_DIGEST) { static inline isc_boolean_t checkowner_mr(ARGS_CHECKOWNER) { - REQUIRE(type == 9); + REQUIRE(type == dns_rdatatype_mr); UNUSED(name); UNUSED(type); @@ -219,7 +219,7 @@ checkowner_mr(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_mr(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 9); + REQUIRE(rdata->type == dns_rdatatype_mr); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/mx_15.c b/lib/dns/rdata/generic/mx_15.c index 77eee158b705..7364b4ac1fd8 100644 --- a/lib/dns/rdata/generic/mx_15.c +++ b/lib/dns/rdata/generic/mx_15.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009, 2012 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2012, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -53,7 +53,7 @@ fromtext_mx(ARGS_FROMTEXT) { isc_buffer_t buffer; isc_boolean_t ok; - REQUIRE(type == 15); + REQUIRE(type == dns_rdatatype_mx); UNUSED(type); UNUSED(rdclass); @@ -98,7 +98,7 @@ totext_mx(ARGS_TOTEXT) { char buf[sizeof("64000")]; unsigned short num; - REQUIRE(rdata->type == 15); + REQUIRE(rdata->type == dns_rdatatype_mx); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -122,7 +122,7 @@ fromwire_mx(ARGS_FROMWIRE) { dns_name_t name; isc_region_t sregion; - REQUIRE(type == 15); + REQUIRE(type == dns_rdatatype_mx); UNUSED(type); UNUSED(rdclass); @@ -145,7 +145,7 @@ towire_mx(ARGS_TOWIRE) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 15); + REQUIRE(rdata->type == dns_rdatatype_mx); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); @@ -170,7 +170,7 @@ compare_mx(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 15); + REQUIRE(rdata1->type == dns_rdatatype_mx); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -198,7 +198,7 @@ fromstruct_mx(ARGS_FROMSTRUCT) { dns_rdata_mx_t *mx = source; isc_region_t region; - REQUIRE(type == 15); + REQUIRE(type == dns_rdatatype_mx); REQUIRE(source != NULL); REQUIRE(mx->common.rdtype == type); REQUIRE(mx->common.rdclass == rdclass); @@ -217,7 +217,7 @@ tostruct_mx(ARGS_TOSTRUCT) { dns_rdata_mx_t *mx = target; dns_name_t name; - REQUIRE(rdata->type == 15); + REQUIRE(rdata->type == dns_rdatatype_mx); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -241,7 +241,7 @@ freestruct_mx(ARGS_FREESTRUCT) { dns_rdata_mx_t *mx = source; REQUIRE(source != NULL); - REQUIRE(mx->common.rdtype == 15); + REQUIRE(mx->common.rdtype == dns_rdatatype_mx); if (mx->mctx == NULL) return; @@ -256,7 +256,7 @@ additionaldata_mx(ARGS_ADDLDATA) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 15); + REQUIRE(rdata->type == dns_rdatatype_mx); dns_name_init(&name, offsets); dns_rdata_toregion(rdata, ®ion); @@ -271,7 +271,7 @@ digest_mx(ARGS_DIGEST) { isc_region_t r1, r2; dns_name_t name; - REQUIRE(rdata->type == 15); + REQUIRE(rdata->type == dns_rdatatype_mx); dns_rdata_toregion(rdata, &r1); r2 = r1; @@ -286,7 +286,7 @@ digest_mx(ARGS_DIGEST) { static inline isc_boolean_t checkowner_mx(ARGS_CHECKOWNER) { - REQUIRE(type == 15); + REQUIRE(type == dns_rdatatype_mx); UNUSED(type); UNUSED(rdclass); @@ -299,7 +299,7 @@ checknames_mx(ARGS_CHECKNAMES) { isc_region_t region; dns_name_t name; - REQUIRE(rdata->type == 15); + REQUIRE(rdata->type == dns_rdatatype_mx); UNUSED(owner); diff --git a/lib/dns/rdata/generic/naptr_35.c b/lib/dns/rdata/generic/naptr_35.c index d7452ac176fe..e8cbda87b74e 100644 --- a/lib/dns/rdata/generic/naptr_35.c +++ b/lib/dns/rdata/generic/naptr_35.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007-2009, 2011-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007-2009, 2011-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -127,7 +127,7 @@ fromtext_naptr(ARGS_FROMTEXT) { isc_buffer_t buffer; unsigned char *regex; - REQUIRE(type == 35); + REQUIRE(type == dns_rdatatype_naptr); UNUSED(type); UNUSED(rdclass); @@ -195,7 +195,7 @@ totext_naptr(ARGS_TOTEXT) { char buf[sizeof("64000")]; unsigned short num; - REQUIRE(rdata->type == 35); + REQUIRE(rdata->type == dns_rdatatype_naptr); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -253,7 +253,7 @@ fromwire_naptr(ARGS_FROMWIRE) { isc_region_t sr; unsigned char *regex; - REQUIRE(type == 35); + REQUIRE(type == dns_rdatatype_naptr); UNUSED(type); UNUSED(rdclass); @@ -300,7 +300,7 @@ towire_naptr(ARGS_TOWIRE) { dns_offsets_t offsets; isc_region_t sr; - REQUIRE(rdata->type == 35); + REQUIRE(rdata->type == dns_rdatatype_naptr); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); @@ -347,7 +347,7 @@ compare_naptr(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 35); + REQUIRE(rdata1->type == dns_rdatatype_naptr); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -410,7 +410,7 @@ fromstruct_naptr(ARGS_FROMSTRUCT) { dns_rdata_naptr_t *naptr = source; isc_region_t region; - REQUIRE(type == 35); + REQUIRE(type == dns_rdatatype_naptr); REQUIRE(source != NULL); REQUIRE(naptr->common.rdtype == type); REQUIRE(naptr->common.rdclass == rdclass); @@ -440,7 +440,7 @@ tostruct_naptr(ARGS_TOSTRUCT) { isc_result_t result; dns_name_t name; - REQUIRE(rdata->type == 35); + REQUIRE(rdata->type == dns_rdatatype_naptr); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -508,7 +508,7 @@ freestruct_naptr(ARGS_FREESTRUCT) { dns_rdata_naptr_t *naptr = source; REQUIRE(source != NULL); - REQUIRE(naptr->common.rdtype == 35); + REQUIRE(naptr->common.rdtype == dns_rdatatype_naptr); if (naptr->mctx == NULL) return; @@ -532,7 +532,7 @@ additionaldata_naptr(ARGS_ADDLDATA) { unsigned int i, flagslen; char *cp; - REQUIRE(rdata->type == 35); + REQUIRE(rdata->type == dns_rdatatype_naptr); /* * Order, preference. @@ -587,7 +587,7 @@ digest_naptr(ARGS_DIGEST) { isc_result_t result; dns_name_t name; - REQUIRE(rdata->type == 35); + REQUIRE(rdata->type == dns_rdatatype_naptr); dns_rdata_toregion(rdata, &r1); r2 = r1; @@ -641,7 +641,7 @@ digest_naptr(ARGS_DIGEST) { static inline isc_boolean_t checkowner_naptr(ARGS_CHECKOWNER) { - REQUIRE(type == 35); + REQUIRE(type == dns_rdatatype_naptr); UNUSED(name); UNUSED(type); @@ -654,7 +654,7 @@ checkowner_naptr(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_naptr(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 35); + REQUIRE(rdata->type == dns_rdatatype_naptr); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/nid_104.c b/lib/dns/rdata/generic/nid_104.c index 39f16ed6f02b..6028676bcc12 100644 --- a/lib/dns/rdata/generic/nid_104.c +++ b/lib/dns/rdata/generic/nid_104.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -28,7 +28,7 @@ fromtext_nid(ARGS_FROMTEXT) { isc_token_t token; unsigned char locator[NS_LOCATORSZ]; - REQUIRE(type == 104); + REQUIRE(type == dns_rdatatype_nid); UNUSED(type); UNUSED(rdclass); @@ -56,7 +56,7 @@ totext_nid(ARGS_TOTEXT) { char buf[sizeof("xxxx:xxxx:xxxx:xxxx")]; unsigned short num; - REQUIRE(rdata->type == 104); + REQUIRE(rdata->type == dns_rdatatype_nid); REQUIRE(rdata->length != 0); UNUSED(tctx); @@ -81,7 +81,7 @@ static inline isc_result_t fromwire_nid(ARGS_FROMWIRE) { isc_region_t sregion; - REQUIRE(type == 104); + REQUIRE(type == dns_rdatatype_nid); UNUSED(type); UNUSED(options); @@ -98,7 +98,7 @@ fromwire_nid(ARGS_FROMWIRE) { static inline isc_result_t towire_nid(ARGS_TOWIRE) { - REQUIRE(rdata->type == 104); + REQUIRE(rdata->type == dns_rdatatype_nid); REQUIRE(rdata->length == 10); UNUSED(cctx); @@ -113,7 +113,7 @@ compare_nid(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 104); + REQUIRE(rdata1->type == dns_rdatatype_nid); REQUIRE(rdata1->length == 10); REQUIRE(rdata2->length == 10); @@ -126,7 +126,7 @@ static inline isc_result_t fromstruct_nid(ARGS_FROMSTRUCT) { dns_rdata_nid_t *nid = source; - REQUIRE(type == 104); + REQUIRE(type == dns_rdatatype_nid); REQUIRE(source != NULL); REQUIRE(nid->common.rdtype == type); REQUIRE(nid->common.rdclass == rdclass); @@ -143,7 +143,7 @@ tostruct_nid(ARGS_TOSTRUCT) { isc_region_t region; dns_rdata_nid_t *nid = target; - REQUIRE(rdata->type == 104); + REQUIRE(rdata->type == dns_rdatatype_nid); REQUIRE(target != NULL); REQUIRE(rdata->length == 10); @@ -164,7 +164,7 @@ freestruct_nid(ARGS_FREESTRUCT) { dns_rdata_nid_t *nid = source; REQUIRE(source != NULL); - REQUIRE(nid->common.rdtype == 104); + REQUIRE(nid->common.rdtype == dns_rdatatype_nid); return; } @@ -172,7 +172,7 @@ freestruct_nid(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_nid(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 104); + REQUIRE(rdata->type == dns_rdatatype_nid); REQUIRE(rdata->length == 10); UNUSED(rdata); @@ -186,7 +186,7 @@ static inline isc_result_t digest_nid(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 104); + REQUIRE(rdata->type == dns_rdatatype_nid); REQUIRE(rdata->length == 10); dns_rdata_toregion(rdata, &r); @@ -197,7 +197,7 @@ digest_nid(ARGS_DIGEST) { static inline isc_boolean_t checkowner_nid(ARGS_CHECKOWNER) { - REQUIRE(type == 104); + REQUIRE(type == dns_rdatatype_nid); UNUSED(name); UNUSED(type); @@ -210,7 +210,7 @@ checkowner_nid(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_nid(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 104); + REQUIRE(rdata->type == dns_rdatatype_nid); REQUIRE(rdata->length == 10); UNUSED(rdata); diff --git a/lib/dns/rdata/generic/ns_2.c b/lib/dns/rdata/generic/ns_2.c index 5db81e7cb390..d7e095b09bf2 100644 --- a/lib/dns/rdata/generic/ns_2.c +++ b/lib/dns/rdata/generic/ns_2.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -31,7 +31,7 @@ fromtext_ns(ARGS_FROMTEXT) { isc_buffer_t buffer; isc_boolean_t ok; - REQUIRE(type == 2); + REQUIRE(type == dns_rdatatype_ns); UNUSED(type); UNUSED(rdclass); @@ -61,7 +61,7 @@ totext_ns(ARGS_TOTEXT) { dns_name_t prefix; isc_boolean_t sub; - REQUIRE(rdata->type == 2); + REQUIRE(rdata->type == dns_rdatatype_ns); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -79,7 +79,7 @@ static inline isc_result_t fromwire_ns(ARGS_FROMWIRE) { dns_name_t name; - REQUIRE(type == 2); + REQUIRE(type == dns_rdatatype_ns); UNUSED(type); UNUSED(rdclass); @@ -96,7 +96,7 @@ towire_ns(ARGS_TOWIRE) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 2); + REQUIRE(rdata->type == dns_rdatatype_ns); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); @@ -117,7 +117,7 @@ compare_ns(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 2); + REQUIRE(rdata1->type == dns_rdatatype_ns); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -138,7 +138,7 @@ fromstruct_ns(ARGS_FROMSTRUCT) { dns_rdata_ns_t *ns = source; isc_region_t region; - REQUIRE(type == 2); + REQUIRE(type == dns_rdatatype_ns); REQUIRE(source != NULL); REQUIRE(ns->common.rdtype == type); REQUIRE(ns->common.rdclass == rdclass); @@ -156,7 +156,7 @@ tostruct_ns(ARGS_TOSTRUCT) { dns_rdata_ns_t *ns = target; dns_name_t name; - REQUIRE(rdata->type == 2); + REQUIRE(rdata->type == dns_rdatatype_ns); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -192,7 +192,7 @@ additionaldata_ns(ARGS_ADDLDATA) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 2); + REQUIRE(rdata->type == dns_rdatatype_ns); dns_name_init(&name, offsets); dns_rdata_toregion(rdata, ®ion); @@ -206,7 +206,7 @@ digest_ns(ARGS_DIGEST) { isc_region_t r; dns_name_t name; - REQUIRE(rdata->type == 2); + REQUIRE(rdata->type == dns_rdatatype_ns); dns_rdata_toregion(rdata, &r); dns_name_init(&name, NULL); @@ -218,7 +218,7 @@ digest_ns(ARGS_DIGEST) { static inline isc_boolean_t checkowner_ns(ARGS_CHECKOWNER) { - REQUIRE(type == 2); + REQUIRE(type == dns_rdatatype_ns); UNUSED(name); UNUSED(type); @@ -233,7 +233,7 @@ checknames_ns(ARGS_CHECKNAMES) { isc_region_t region; dns_name_t name; - REQUIRE(rdata->type == 2); + REQUIRE(rdata->type == dns_rdatatype_ns); UNUSED(owner); diff --git a/lib/dns/rdata/generic/nsec3_50.c b/lib/dns/rdata/generic/nsec3_50.c index eb4f68dca2a1..2aec339c2453 100644 --- a/lib/dns/rdata/generic/nsec3_50.c +++ b/lib/dns/rdata/generic/nsec3_50.c @@ -53,7 +53,7 @@ fromtext_nsec3(ARGS_FROMTEXT) { unsigned char hashalg; isc_buffer_t b; - REQUIRE(type == 50); + REQUIRE(type == dns_rdatatype_nsec3); UNUSED(type); UNUSED(rdclass); @@ -144,7 +144,7 @@ totext_nsec3(ARGS_TOTEXT) { isc_uint32_t iterations; isc_boolean_t first; - REQUIRE(rdata->type == 50); + REQUIRE(rdata->type == dns_rdatatype_nsec3); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, &sr); @@ -246,7 +246,7 @@ fromwire_nsec3(ARGS_FROMWIRE) { isc_boolean_t first = ISC_TRUE; unsigned int i; - REQUIRE(type == 50); + REQUIRE(type == dns_rdatatype_nsec3); UNUSED(type); UNUSED(rdclass); @@ -318,7 +318,7 @@ static inline isc_result_t towire_nsec3(ARGS_TOWIRE) { isc_region_t sr; - REQUIRE(rdata->type == 50); + REQUIRE(rdata->type == dns_rdatatype_nsec3); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -334,7 +334,7 @@ compare_nsec3(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 50); + REQUIRE(rdata1->type == dns_rdatatype_nsec3); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -349,7 +349,7 @@ fromstruct_nsec3(ARGS_FROMSTRUCT) { unsigned int i, len, window, lastwindow = 0; isc_boolean_t first = ISC_TRUE; - REQUIRE(type == 50); + REQUIRE(type == dns_rdatatype_nsec3); REQUIRE(source != NULL); REQUIRE(nsec3->common.rdtype == type); REQUIRE(nsec3->common.rdclass == rdclass); @@ -390,7 +390,7 @@ tostruct_nsec3(ARGS_TOSTRUCT) { isc_region_t region; dns_rdata_nsec3_t *nsec3 = target; - REQUIRE(rdata->type == 50); + REQUIRE(rdata->type == dns_rdatatype_nsec3); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -436,7 +436,7 @@ freestruct_nsec3(ARGS_FREESTRUCT) { dns_rdata_nsec3_t *nsec3 = source; REQUIRE(source != NULL); - REQUIRE(nsec3->common.rdtype == 50); + REQUIRE(nsec3->common.rdtype == dns_rdatatype_nsec3); if (nsec3->mctx == NULL) return; @@ -452,7 +452,7 @@ freestruct_nsec3(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_nsec3(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 50); + REQUIRE(rdata->type == dns_rdatatype_nsec3); UNUSED(rdata); UNUSED(add); @@ -465,7 +465,7 @@ static inline isc_result_t digest_nsec3(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 50); + REQUIRE(rdata->type == dns_rdatatype_nsec3); dns_rdata_toregion(rdata, &r); return ((digest)(arg, &r)); @@ -477,7 +477,7 @@ checkowner_nsec3(ARGS_CHECKOWNER) { isc_buffer_t buffer; dns_label_t label; - REQUIRE(type == 50); + REQUIRE(type == dns_rdatatype_nsec3); UNUSED(type); UNUSED(rdclass); @@ -498,7 +498,7 @@ checkowner_nsec3(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_nsec3(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 50); + REQUIRE(rdata->type == dns_rdatatype_nsec3); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/nsec3param_51.c b/lib/dns/rdata/generic/nsec3param_51.c index 379a46b53542..6ac152e31d61 100644 --- a/lib/dns/rdata/generic/nsec3param_51.c +++ b/lib/dns/rdata/generic/nsec3param_51.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2008, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -48,7 +48,7 @@ fromtext_nsec3param(ARGS_FROMTEXT) { unsigned int flags = 0; unsigned char hashalg; - REQUIRE(type == 51); + REQUIRE(type == dns_rdatatype_nsec3param); UNUSED(type); UNUSED(rdclass); @@ -101,7 +101,7 @@ totext_nsec3param(ARGS_TOTEXT) { char buf[sizeof("65535 ")]; isc_uint32_t iterations; - REQUIRE(rdata->type == 51); + REQUIRE(rdata->type == dns_rdatatype_nsec3param); REQUIRE(rdata->length != 0); UNUSED(tctx); @@ -146,7 +146,7 @@ fromwire_nsec3param(ARGS_FROMWIRE) { isc_region_t sr, rr; unsigned int saltlen; - REQUIRE(type == 51); + REQUIRE(type == dns_rdatatype_nsec3param); UNUSED(type); UNUSED(rdclass); @@ -174,7 +174,7 @@ static inline isc_result_t towire_nsec3param(ARGS_TOWIRE) { isc_region_t sr; - REQUIRE(rdata->type == 51); + REQUIRE(rdata->type == dns_rdatatype_nsec3param); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -190,7 +190,7 @@ compare_nsec3param(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 51); + REQUIRE(rdata1->type == dns_rdatatype_nsec3param); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -203,7 +203,7 @@ static inline isc_result_t fromstruct_nsec3param(ARGS_FROMSTRUCT) { dns_rdata_nsec3param_t *nsec3param = source; - REQUIRE(type == 51); + REQUIRE(type == dns_rdatatype_nsec3param); REQUIRE(source != NULL); REQUIRE(nsec3param->common.rdtype == type); REQUIRE(nsec3param->common.rdclass == rdclass); @@ -225,7 +225,7 @@ tostruct_nsec3param(ARGS_TOSTRUCT) { isc_region_t region; dns_rdata_nsec3param_t *nsec3param = target; - REQUIRE(rdata->type == 51); + REQUIRE(rdata->type == dns_rdatatype_nsec3param); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -255,7 +255,7 @@ freestruct_nsec3param(ARGS_FREESTRUCT) { dns_rdata_nsec3param_t *nsec3param = source; REQUIRE(source != NULL); - REQUIRE(nsec3param->common.rdtype == 51); + REQUIRE(nsec3param->common.rdtype == dns_rdatatype_nsec3param); if (nsec3param->mctx == NULL) return; @@ -267,7 +267,7 @@ freestruct_nsec3param(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_nsec3param(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 51); + REQUIRE(rdata->type == dns_rdatatype_nsec3param); UNUSED(rdata); UNUSED(add); @@ -280,7 +280,7 @@ static inline isc_result_t digest_nsec3param(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 51); + REQUIRE(rdata->type == dns_rdatatype_nsec3param); dns_rdata_toregion(rdata, &r); return ((digest)(arg, &r)); @@ -289,7 +289,7 @@ digest_nsec3param(ARGS_DIGEST) { static inline isc_boolean_t checkowner_nsec3param(ARGS_CHECKOWNER) { - REQUIRE(type == 51); + REQUIRE(type == dns_rdatatype_nsec3param); UNUSED(name); UNUSED(type); @@ -302,7 +302,7 @@ checkowner_nsec3param(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_nsec3param(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 51); + REQUIRE(rdata->type == dns_rdatatype_nsec3param); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/nsec_47.c b/lib/dns/rdata/generic/nsec_47.c index 095f42eba899..64bd757fd33a 100644 --- a/lib/dns/rdata/generic/nsec_47.c +++ b/lib/dns/rdata/generic/nsec_47.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007-2009, 2011 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007-2009, 2011, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -40,7 +40,7 @@ fromtext_nsec(ARGS_FROMTEXT) { int octet; int window; - REQUIRE(type == 47); + REQUIRE(type == dns_rdatatype_nsec); UNUSED(type); UNUSED(rdclass); @@ -90,7 +90,7 @@ totext_nsec(ARGS_TOTEXT) { dns_name_t name; unsigned int window, len; - REQUIRE(rdata->type == 47); + REQUIRE(rdata->type == dns_rdatatype_nsec); REQUIRE(rdata->length != 0); UNUSED(tctx); @@ -140,7 +140,7 @@ fromwire_nsec(ARGS_FROMWIRE) { isc_boolean_t first = ISC_TRUE; unsigned int i; - REQUIRE(type == 47); + REQUIRE(type == dns_rdatatype_nsec); UNUSED(type); UNUSED(rdclass); @@ -198,7 +198,7 @@ towire_nsec(ARGS_TOWIRE) { dns_name_t name; dns_offsets_t offsets; - REQUIRE(rdata->type == 47); + REQUIRE(rdata->type == dns_rdatatype_nsec); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); @@ -218,7 +218,7 @@ compare_nsec(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 47); + REQUIRE(rdata1->type == dns_rdatatype_nsec); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -234,7 +234,7 @@ fromstruct_nsec(ARGS_FROMSTRUCT) { unsigned int i, len, window, lastwindow = 0; isc_boolean_t first = ISC_TRUE; - REQUIRE(type == 47); + REQUIRE(type == dns_rdatatype_nsec); REQUIRE(source != NULL); REQUIRE(nsec->common.rdtype == type); REQUIRE(nsec->common.rdclass == rdclass); @@ -270,7 +270,7 @@ tostruct_nsec(ARGS_TOSTRUCT) { dns_rdata_nsec_t *nsec = target; dns_name_t name; - REQUIRE(rdata->type == 47); + REQUIRE(rdata->type == dns_rdatatype_nsec); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -304,7 +304,7 @@ freestruct_nsec(ARGS_FREESTRUCT) { dns_rdata_nsec_t *nsec = source; REQUIRE(source != NULL); - REQUIRE(nsec->common.rdtype == 47); + REQUIRE(nsec->common.rdtype == dns_rdatatype_nsec); if (nsec->mctx == NULL) return; @@ -317,7 +317,7 @@ freestruct_nsec(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_nsec(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 47); + REQUIRE(rdata->type == dns_rdatatype_nsec); UNUSED(rdata); UNUSED(add); @@ -330,7 +330,7 @@ static inline isc_result_t digest_nsec(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 47); + REQUIRE(rdata->type == dns_rdatatype_nsec); dns_rdata_toregion(rdata, &r); return ((digest)(arg, &r)); @@ -339,7 +339,7 @@ digest_nsec(ARGS_DIGEST) { static inline isc_boolean_t checkowner_nsec(ARGS_CHECKOWNER) { - REQUIRE(type == 47); + REQUIRE(type == dns_rdatatype_nsec); UNUSED(name); UNUSED(type); @@ -352,7 +352,7 @@ checkowner_nsec(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_nsec(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 47); + REQUIRE(rdata->type == dns_rdatatype_nsec); UNUSED(rdata); UNUSED(owner); @@ -371,7 +371,7 @@ casecompare_nsec(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 47); + REQUIRE(rdata1->type == dns_rdatatype_nsec); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); diff --git a/lib/dns/rdata/generic/null_10.c b/lib/dns/rdata/generic/null_10.c index 8ba86fbca9b7..38d4fdbb3f82 100644 --- a/lib/dns/rdata/generic/null_10.c +++ b/lib/dns/rdata/generic/null_10.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009, 2011, 2012 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2011, 2012, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -26,7 +26,7 @@ static inline isc_result_t fromtext_null(ARGS_FROMTEXT) { - REQUIRE(type == 10); + REQUIRE(type == dns_rdatatype_null); UNUSED(rdclass); UNUSED(type); @@ -41,7 +41,7 @@ fromtext_null(ARGS_FROMTEXT) { static inline isc_result_t totext_null(ARGS_TOTEXT) { - REQUIRE(rdata->type == 10); + REQUIRE(rdata->type == dns_rdatatype_null); return (unknown_totext(rdata, tctx, target)); } @@ -50,7 +50,7 @@ static inline isc_result_t fromwire_null(ARGS_FROMWIRE) { isc_region_t sr; - REQUIRE(type == 10); + REQUIRE(type == dns_rdatatype_null); UNUSED(type); UNUSED(rdclass); @@ -64,7 +64,7 @@ fromwire_null(ARGS_FROMWIRE) { static inline isc_result_t towire_null(ARGS_TOWIRE) { - REQUIRE(rdata->type == 10); + REQUIRE(rdata->type == dns_rdatatype_null); UNUSED(cctx); @@ -78,7 +78,7 @@ compare_null(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 10); + REQUIRE(rdata1->type == dns_rdatatype_null); dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); @@ -89,7 +89,7 @@ static inline isc_result_t fromstruct_null(ARGS_FROMSTRUCT) { dns_rdata_null_t *null = source; - REQUIRE(type == 10); + REQUIRE(type == dns_rdatatype_null); REQUIRE(source != NULL); REQUIRE(null->common.rdtype == type); REQUIRE(null->common.rdclass == rdclass); @@ -106,7 +106,7 @@ tostruct_null(ARGS_TOSTRUCT) { dns_rdata_null_t *null = target; isc_region_t r; - REQUIRE(rdata->type == 10); + REQUIRE(rdata->type == dns_rdatatype_null); REQUIRE(target != NULL); null->common.rdclass = rdata->rdclass; @@ -128,7 +128,7 @@ freestruct_null(ARGS_FREESTRUCT) { dns_rdata_null_t *null = source; REQUIRE(source != NULL); - REQUIRE(null->common.rdtype == 10); + REQUIRE(null->common.rdtype == dns_rdatatype_null); if (null->mctx == NULL) return; @@ -144,7 +144,7 @@ additionaldata_null(ARGS_ADDLDATA) { UNUSED(add); UNUSED(arg); - REQUIRE(rdata->type == 10); + REQUIRE(rdata->type == dns_rdatatype_null); return (ISC_R_SUCCESS); } @@ -153,7 +153,7 @@ static inline isc_result_t digest_null(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 10); + REQUIRE(rdata->type == dns_rdatatype_null); dns_rdata_toregion(rdata, &r); @@ -163,7 +163,7 @@ digest_null(ARGS_DIGEST) { static inline isc_boolean_t checkowner_null(ARGS_CHECKOWNER) { - REQUIRE(type == 10); + REQUIRE(type == dns_rdatatype_null); UNUSED(name); UNUSED(type); @@ -176,7 +176,7 @@ checkowner_null(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_null(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 10); + REQUIRE(rdata->type == dns_rdatatype_null); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/nxt_30.c b/lib/dns/rdata/generic/nxt_30.c index 4d291a8e6f6e..fbb34e9818ee 100644 --- a/lib/dns/rdata/generic/nxt_30.c +++ b/lib/dns/rdata/generic/nxt_30.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -42,7 +42,7 @@ fromtext_nxt(ARGS_FROMTEXT) { isc_boolean_t first = ISC_TRUE; long n; - REQUIRE(type == 30); + REQUIRE(type == dns_rdatatype_nxt); UNUSED(type); UNUSED(rdclass); @@ -95,7 +95,7 @@ totext_nxt(ARGS_TOTEXT) { dns_name_t prefix; isc_boolean_t sub; - REQUIRE(rdata->type == 30); + REQUIRE(rdata->type == dns_rdatatype_nxt); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -131,7 +131,7 @@ fromwire_nxt(ARGS_FROMWIRE) { isc_region_t sr; dns_name_t name; - REQUIRE(type == 30); + REQUIRE(type == dns_rdatatype_nxt); UNUSED(type); UNUSED(rdclass); @@ -156,7 +156,7 @@ towire_nxt(ARGS_TOWIRE) { dns_name_t name; dns_offsets_t offsets; - REQUIRE(rdata->type == 30); + REQUIRE(rdata->type == dns_rdatatype_nxt); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); @@ -179,7 +179,7 @@ compare_nxt(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 30); + REQUIRE(rdata1->type == dns_rdatatype_nxt); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -201,7 +201,7 @@ fromstruct_nxt(ARGS_FROMSTRUCT) { dns_rdata_nxt_t *nxt = source; isc_region_t region; - REQUIRE(type == 30); + REQUIRE(type == dns_rdatatype_nxt); REQUIRE(source != NULL); REQUIRE(nxt->common.rdtype == type); REQUIRE(nxt->common.rdclass == rdclass); @@ -226,7 +226,7 @@ tostruct_nxt(ARGS_TOSTRUCT) { dns_rdata_nxt_t *nxt = target; dns_name_t name; - REQUIRE(rdata->type == 30); + REQUIRE(rdata->type == dns_rdatatype_nxt); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -260,7 +260,7 @@ freestruct_nxt(ARGS_FREESTRUCT) { dns_rdata_nxt_t *nxt = source; REQUIRE(source != NULL); - REQUIRE(nxt->common.rdtype == 30); + REQUIRE(nxt->common.rdtype == dns_rdatatype_nxt); if (nxt->mctx == NULL) return; @@ -273,7 +273,7 @@ freestruct_nxt(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_nxt(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 30); + REQUIRE(rdata->type == dns_rdatatype_nxt); UNUSED(rdata); UNUSED(add); @@ -288,7 +288,7 @@ digest_nxt(ARGS_DIGEST) { dns_name_t name; isc_result_t result; - REQUIRE(rdata->type == 30); + REQUIRE(rdata->type == dns_rdatatype_nxt); dns_rdata_toregion(rdata, &r); dns_name_init(&name, NULL); @@ -304,7 +304,7 @@ digest_nxt(ARGS_DIGEST) { static inline isc_boolean_t checkowner_nxt(ARGS_CHECKOWNER) { - REQUIRE(type == 30); + REQUIRE(type == dns_rdatatype_nxt); UNUSED(name); UNUSED(type); @@ -317,7 +317,7 @@ checkowner_nxt(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_nxt(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 30); + REQUIRE(rdata->type == dns_rdatatype_nxt); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/openpgpkey_61.c b/lib/dns/rdata/generic/openpgpkey_61.c index 7b2a88bbd312..382be7e43220 100644 --- a/lib/dns/rdata/generic/openpgpkey_61.c +++ b/lib/dns/rdata/generic/openpgpkey_61.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -22,7 +22,7 @@ static inline isc_result_t fromtext_openpgpkey(ARGS_FROMTEXT) { - REQUIRE(type == 61); + REQUIRE(type == dns_rdatatype_openpgpkey); UNUSED(type); UNUSED(rdclass); @@ -40,7 +40,7 @@ static inline isc_result_t totext_openpgpkey(ARGS_TOTEXT) { isc_region_t sr; - REQUIRE(rdata->type == 61); + REQUIRE(rdata->type == dns_rdatatype_openpgpkey); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, &sr); @@ -65,7 +65,7 @@ static inline isc_result_t fromwire_openpgpkey(ARGS_FROMWIRE) { isc_region_t sr; - REQUIRE(type == 61); + REQUIRE(type == dns_rdatatype_openpgpkey); UNUSED(type); UNUSED(rdclass); @@ -76,6 +76,8 @@ fromwire_openpgpkey(ARGS_FROMWIRE) { * Keyring. */ isc_buffer_activeregion(source, &sr); + if (sr.length < 1) + return (ISC_R_UNEXPECTEDEND); isc_buffer_forward(source, sr.length); return (mem_tobuffer(target, sr.base, sr.length)); } @@ -84,7 +86,7 @@ static inline isc_result_t towire_openpgpkey(ARGS_TOWIRE) { isc_region_t sr; - REQUIRE(rdata->type == 61); + REQUIRE(rdata->type == dns_rdatatype_openpgpkey); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -100,7 +102,7 @@ compare_openpgpkey(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 61); + REQUIRE(rdata1->type == dns_rdatatype_openpgpkey); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -113,7 +115,7 @@ static inline isc_result_t fromstruct_openpgpkey(ARGS_FROMSTRUCT) { dns_rdata_openpgpkey_t *sig = source; - REQUIRE(type == 61); + REQUIRE(type == dns_rdatatype_openpgpkey); REQUIRE(source != NULL); REQUIRE(sig->common.rdtype == type); REQUIRE(sig->common.rdclass == rdclass); @@ -133,7 +135,7 @@ tostruct_openpgpkey(ARGS_TOSTRUCT) { isc_region_t sr; dns_rdata_openpgpkey_t *sig = target; - REQUIRE(rdata->type == 61); + REQUIRE(rdata->type == dns_rdatatype_openpgpkey); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -163,7 +165,7 @@ freestruct_openpgpkey(ARGS_FREESTRUCT) { dns_rdata_openpgpkey_t *sig = (dns_rdata_openpgpkey_t *) source; REQUIRE(source != NULL); - REQUIRE(sig->common.rdtype == 61); + REQUIRE(sig->common.rdtype == dns_rdatatype_openpgpkey); if (sig->mctx == NULL) return; @@ -175,7 +177,7 @@ freestruct_openpgpkey(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_openpgpkey(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 61); + REQUIRE(rdata->type == dns_rdatatype_openpgpkey); UNUSED(rdata); UNUSED(add); @@ -188,7 +190,7 @@ static inline isc_result_t digest_openpgpkey(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 61); + REQUIRE(rdata->type == dns_rdatatype_openpgpkey); dns_rdata_toregion(rdata, &r); @@ -198,7 +200,7 @@ digest_openpgpkey(ARGS_DIGEST) { static inline isc_boolean_t checkowner_openpgpkey(ARGS_CHECKOWNER) { - REQUIRE(type == 61); + REQUIRE(type == dns_rdatatype_openpgpkey); UNUSED(name); UNUSED(type); @@ -211,7 +213,7 @@ checkowner_openpgpkey(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_openpgpkey(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 61); + REQUIRE(rdata->type == dns_rdatatype_openpgpkey); UNUSED(rdata); UNUSED(owner); @@ -227,7 +229,7 @@ casecompare_openpgpkey(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 61); + REQUIRE(rdata1->type == dns_rdatatype_openpgpkey); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); diff --git a/lib/dns/rdata/generic/opt_41.c b/lib/dns/rdata/generic/opt_41.c index ba3fef001a15..bc2de3790884 100644 --- a/lib/dns/rdata/generic/opt_41.c +++ b/lib/dns/rdata/generic/opt_41.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009, 2011-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2011-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -34,7 +34,7 @@ fromtext_opt(ARGS_FROMTEXT) { * OPT records do not have a text format. */ - REQUIRE(type == 41); + REQUIRE(type == dns_rdatatype_opt); UNUSED(type); UNUSED(rdclass); @@ -59,7 +59,7 @@ totext_opt(ARGS_TOTEXT) { * OPT records do not have a text format. */ - REQUIRE(rdata->type == 41); + REQUIRE(rdata->type == dns_rdatatype_opt); dns_rdata_toregion(rdata, &r); while (r.length > 0) { @@ -101,7 +101,7 @@ fromwire_opt(ARGS_FROMWIRE) { isc_uint16_t length; unsigned int total; - REQUIRE(type == 41); + REQUIRE(type == dns_rdatatype_opt); UNUSED(type); UNUSED(rdclass); @@ -128,7 +128,7 @@ fromwire_opt(ARGS_FROMWIRE) { isc_uint8_t addrbytes; if (length < 4) - return (DNS_R_FORMERR); + return (DNS_R_OPTERR); family = uint16_fromregion(&sregion); isc_region_consume(&sregion, 2); addrlen = uint8_fromregion(&sregion); @@ -138,16 +138,25 @@ fromwire_opt(ARGS_FROMWIRE) { switch (family) { case 1: if (addrlen > 32U || scope > 32U) - return (DNS_R_FORMERR); + return (DNS_R_OPTERR); break; case 2: if (addrlen > 128U || scope > 128U) - return (DNS_R_FORMERR); + return (DNS_R_OPTERR); break; + default: + return (DNS_R_OPTERR); } addrbytes = (addrlen + 7) / 8; if (addrbytes + 4 != length) - return (DNS_R_FORMERR); + return (DNS_R_OPTERR); + + if (addrbytes != 0U && (addrlen % 8) != 0) { + isc_uint8_t bits = ~0 << (8 - (addrlen % 8)); + bits &= sregion.base[addrbytes - 1]; + if (bits != sregion.base[addrbytes - 1]) + return (DNS_R_OPTERR); + } isc_region_consume(&sregion, addrbytes); break; } @@ -156,7 +165,12 @@ fromwire_opt(ARGS_FROMWIRE) { * Request has zero length. Response is 32 bits. */ if (length != 0 && length != 4) - return (DNS_R_FORMERR); + return (DNS_R_OPTERR); + isc_region_consume(&sregion, length); + break; + case DNS_OPT_COOKIE: + if (length != 8 && (length < 16 || length > 40)) + return (DNS_R_OPTERR); isc_region_consume(&sregion, length); break; default: @@ -180,7 +194,7 @@ fromwire_opt(ARGS_FROMWIRE) { static inline isc_result_t towire_opt(ARGS_TOWIRE) { - REQUIRE(rdata->type == 41); + REQUIRE(rdata->type == dns_rdatatype_opt); UNUSED(cctx); @@ -194,7 +208,7 @@ compare_opt(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 41); + REQUIRE(rdata1->type == dns_rdatatype_opt); dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); @@ -207,7 +221,7 @@ fromstruct_opt(ARGS_FROMSTRUCT) { isc_region_t region; isc_uint16_t length; - REQUIRE(type == 41); + REQUIRE(type == dns_rdatatype_opt); REQUIRE(source != NULL); REQUIRE(opt->common.rdtype == type); REQUIRE(opt->common.rdclass == rdclass); @@ -237,7 +251,7 @@ tostruct_opt(ARGS_TOSTRUCT) { dns_rdata_opt_t *opt = target; isc_region_t r; - REQUIRE(rdata->type == 41); + REQUIRE(rdata->type == dns_rdatatype_opt); REQUIRE(target != NULL); opt->common.rdclass = rdata->rdclass; @@ -260,7 +274,7 @@ freestruct_opt(ARGS_FREESTRUCT) { dns_rdata_opt_t *opt = source; REQUIRE(source != NULL); - REQUIRE(opt->common.rdtype == 41); + REQUIRE(opt->common.rdtype == dns_rdatatype_opt); if (opt->mctx == NULL) return; @@ -272,7 +286,7 @@ freestruct_opt(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_opt(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 41); + REQUIRE(rdata->type == dns_rdatatype_opt); UNUSED(rdata); UNUSED(add); @@ -288,7 +302,7 @@ digest_opt(ARGS_DIGEST) { * OPT records are not digested. */ - REQUIRE(rdata->type == 41); + REQUIRE(rdata->type == dns_rdatatype_opt); UNUSED(rdata); UNUSED(digest); @@ -300,7 +314,7 @@ digest_opt(ARGS_DIGEST) { static inline isc_boolean_t checkowner_opt(ARGS_CHECKOWNER) { - REQUIRE(type == 41); + REQUIRE(type == dns_rdatatype_opt); UNUSED(type); UNUSED(rdclass); @@ -312,7 +326,7 @@ checkowner_opt(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_opt(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 41); + REQUIRE(rdata->type == dns_rdatatype_opt); UNUSED(rdata); UNUSED(owner); @@ -330,7 +344,7 @@ isc_result_t dns_rdata_opt_first(dns_rdata_opt_t *opt) { REQUIRE(opt != NULL); - REQUIRE(opt->common.rdtype == 41); + REQUIRE(opt->common.rdtype == dns_rdatatype_opt); REQUIRE(opt->options != NULL || opt->length == 0); if (opt->length == 0) @@ -346,7 +360,7 @@ dns_rdata_opt_next(dns_rdata_opt_t *opt) { isc_uint16_t length; REQUIRE(opt != NULL); - REQUIRE(opt->common.rdtype == 41); + REQUIRE(opt->common.rdtype == dns_rdatatype_opt); REQUIRE(opt->options != NULL && opt->length != 0); REQUIRE(opt->offset < opt->length); @@ -367,7 +381,7 @@ dns_rdata_opt_current(dns_rdata_opt_t *opt, dns_rdata_opt_opcode_t *opcode) { REQUIRE(opt != NULL); REQUIRE(opcode != NULL); - REQUIRE(opt->common.rdtype == 41); + REQUIRE(opt->common.rdtype == dns_rdatatype_opt); REQUIRE(opt->options != NULL); REQUIRE(opt->offset < opt->length); diff --git a/lib/dns/rdata/generic/proforma.c b/lib/dns/rdata/generic/proforma.c index d1a5ecd77cc2..afd67a4e31fe 100644 --- a/lib/dns/rdata/generic/proforma.c +++ b/lib/dns/rdata/generic/proforma.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -26,7 +26,7 @@ static inline isc_result_t fromtext_#(ARGS_FROMTEXT) { isc_token_t token; - REQUIRE(type == #); + REQUIRE(type == dns_rdatatype_proforma.c#); REQUIRE(rdclass == #); RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, @@ -38,7 +38,7 @@ fromtext_#(ARGS_FROMTEXT) { static inline isc_result_t totext_#(ARGS_TOTEXT) { - REQUIRE(rdata->type == #); + REQUIRE(rdata->type == dns_rdatatype_proforma.c#); REQUIRE(rdata->rdclass == #); REQUIRE(rdata->length != 0); /* XXX */ @@ -48,7 +48,7 @@ totext_#(ARGS_TOTEXT) { static inline isc_result_t fromwire_#(ARGS_FROMWIRE) { - REQUIRE(type == #); + REQUIRE(type == dns_rdatatype_proforma.c#); REQUIRE(rdclass == #); /* NONE or GLOBAL14 */ @@ -60,7 +60,7 @@ fromwire_#(ARGS_FROMWIRE) { static inline isc_result_t towire_#(ARGS_TOWIRE) { - REQUIRE(rdata->type == #); + REQUIRE(rdata->type == dns_rdatatype_proforma.c#); REQUIRE(rdata->rdclass == #); REQUIRE(rdata->length != 0); /* XXX */ @@ -75,9 +75,9 @@ compare_#(ARGS_COMPARE) { isc_region_t r1; isc_region_t r2; - REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->type == dns_rdatatype_proforma.crdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == #); + REQUIRE(rdata1->type == dns_rdatatype_proforma.c#); REQUIRE(rdata1->rdclass == #); REQUIRE(rdata1->length != 0); /* XXX */ REQUIRE(rdata2->length != 0); /* XXX */ @@ -91,10 +91,10 @@ static inline isc_result_t fromstruct_#(ARGS_FROMSTRUCT) { dns_rdata_#_t *# = source; - REQUIRE(type == #); + REQUIRE(type == dns_rdatatype_proforma.c#); REQUIRE(rdclass == #); REQUIRE(source != NULL); - REQUIRE(#->common.rdtype == type); + REQUIRE(#->common.rdtype == dns_rdatatype_proforma.ctype); REQUIRE(#->common.rdclass == rdclass); return (ISC_R_NOTIMPLEMENTED); @@ -103,7 +103,7 @@ fromstruct_#(ARGS_FROMSTRUCT) { static inline isc_result_t tostruct_#(ARGS_TOSTRUCT) { - REQUIRE(rdata->type == #); + REQUIRE(rdata->type == dns_rdatatype_proforma.c#); REQUIRE(rdata->rdclass == #); REQUIRE(rdata->length != 0); /* XXX */ @@ -115,14 +115,14 @@ freestruct_#(ARGS_FREESTRUCT) { dns_rdata_#_t *# = source; REQUIRE(source != NULL); - REQUIRE(#->common.rdtype == #); + REQUIRE(#->common.rdtype == dns_rdatatype_proforma.c#); REQUIRE(#->common.rdclass == #); } static inline isc_result_t additionaldata_#(ARGS_ADDLDATA) { - REQUIRE(rdata->type == #); + REQUIRE(rdata->type == dns_rdatatype_proforma.c#); REQUIRE(rdata->rdclass == #); (void)add; @@ -135,7 +135,7 @@ static inline isc_result_t digest_#(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == #); + REQUIRE(rdata->type == dns_rdatatype_proforma.c#); REQUIRE(rdata->rdclass == #); dns_rdata_toregion(rdata, &r); @@ -146,7 +146,7 @@ digest_#(ARGS_DIGEST) { static inline isc_boolean_t checkowner_#(ARGS_CHECKOWNER) { - REQUIRE(type == #); + REQUIRE(type == dns_rdatatype_proforma.c#); REQUIRE(rdclass == #); UNUSED(name); @@ -160,7 +160,7 @@ checkowner_#(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_#(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == #); + REQUIRE(rdata->type == dns_rdatatype_proforma.c#); REQUIRE(rdata->rdclass == #); UNUSED(rdata); @@ -175,9 +175,9 @@ casecompare_#(ARGS_COMPARE) { isc_region_t r1; isc_region_t r2; - REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->type == dns_rdatatype_proforma.crdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == #); + REQUIRE(rdata1->type == dns_rdatatype_proforma.c#); REQUIRE(rdata1->rdclass == #); REQUIRE(rdata1->length != 0); /* XXX */ REQUIRE(rdata2->length != 0); /* XXX */ diff --git a/lib/dns/rdata/generic/ptr_12.c b/lib/dns/rdata/generic/ptr_12.c index a619f137a877..e3f65cf28561 100644 --- a/lib/dns/rdata/generic/ptr_12.c +++ b/lib/dns/rdata/generic/ptr_12.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -30,7 +30,7 @@ fromtext_ptr(ARGS_FROMTEXT) { dns_name_t name; isc_buffer_t buffer; - REQUIRE(type == 12); + REQUIRE(type == dns_rdatatype_ptr); UNUSED(type); UNUSED(rdclass); @@ -63,7 +63,7 @@ totext_ptr(ARGS_TOTEXT) { dns_name_t prefix; isc_boolean_t sub; - REQUIRE(rdata->type == 12); + REQUIRE(rdata->type == dns_rdatatype_ptr); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -81,7 +81,7 @@ static inline isc_result_t fromwire_ptr(ARGS_FROMWIRE) { dns_name_t name; - REQUIRE(type == 12); + REQUIRE(type == dns_rdatatype_ptr); UNUSED(type); UNUSED(rdclass); @@ -98,7 +98,7 @@ towire_ptr(ARGS_TOWIRE) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 12); + REQUIRE(rdata->type == dns_rdatatype_ptr); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); @@ -119,7 +119,7 @@ compare_ptr(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 12); + REQUIRE(rdata1->type == dns_rdatatype_ptr); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -140,7 +140,7 @@ fromstruct_ptr(ARGS_FROMSTRUCT) { dns_rdata_ptr_t *ptr = source; isc_region_t region; - REQUIRE(type == 12); + REQUIRE(type == dns_rdatatype_ptr); REQUIRE(source != NULL); REQUIRE(ptr->common.rdtype == type); REQUIRE(ptr->common.rdclass == rdclass); @@ -158,7 +158,7 @@ tostruct_ptr(ARGS_TOSTRUCT) { dns_rdata_ptr_t *ptr = target; dns_name_t name; - REQUIRE(rdata->type == 12); + REQUIRE(rdata->type == dns_rdatatype_ptr); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -180,7 +180,7 @@ freestruct_ptr(ARGS_FREESTRUCT) { dns_rdata_ptr_t *ptr = source; REQUIRE(source != NULL); - REQUIRE(ptr->common.rdtype == 12); + REQUIRE(ptr->common.rdtype == dns_rdatatype_ptr); if (ptr->mctx == NULL) return; @@ -191,7 +191,7 @@ freestruct_ptr(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_ptr(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 12); + REQUIRE(rdata->type == dns_rdatatype_ptr); UNUSED(rdata); UNUSED(add); @@ -205,7 +205,7 @@ digest_ptr(ARGS_DIGEST) { isc_region_t r; dns_name_t name; - REQUIRE(rdata->type == 12); + REQUIRE(rdata->type == dns_rdatatype_ptr); dns_rdata_toregion(rdata, &r); dns_name_init(&name, NULL); @@ -217,7 +217,7 @@ digest_ptr(ARGS_DIGEST) { static inline isc_boolean_t checkowner_ptr(ARGS_CHECKOWNER) { - REQUIRE(type == 12); + REQUIRE(type == dns_rdatatype_ptr); UNUSED(name); UNUSED(type); @@ -268,11 +268,14 @@ checknames_ptr(ARGS_CHECKNAMES) { isc_region_t region; dns_name_t name; - REQUIRE(rdata->type == 12); + REQUIRE(rdata->type == dns_rdatatype_ptr); if (rdata->rdclass != dns_rdataclass_in) return (ISC_TRUE); + if (dns_name_isdnssd(owner)) + return (ISC_TRUE); + if (dns_name_issubdomain(owner, &in_addr_arpa) || dns_name_issubdomain(owner, &ip6_arpa) || dns_name_issubdomain(owner, &ip6_int)) { diff --git a/lib/dns/rdata/generic/rp_17.c b/lib/dns/rdata/generic/rp_17.c index 3291f7bb55cd..e67c25ec7a1e 100644 --- a/lib/dns/rdata/generic/rp_17.c +++ b/lib/dns/rdata/generic/rp_17.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -32,7 +32,7 @@ fromtext_rp(ARGS_FROMTEXT) { int i; isc_boolean_t ok; - REQUIRE(type == 17); + REQUIRE(type == dns_rdatatype_rp); UNUSED(type); UNUSED(rdclass); @@ -67,7 +67,7 @@ totext_rp(ARGS_TOTEXT) { dns_name_t prefix; isc_boolean_t sub; - REQUIRE(rdata->type == 17); + REQUIRE(rdata->type == dns_rdatatype_rp); REQUIRE(rdata->length != 0); dns_name_init(&rmail, NULL); @@ -96,7 +96,7 @@ fromwire_rp(ARGS_FROMWIRE) { dns_name_t rmail; dns_name_t email; - REQUIRE(type == 17); + REQUIRE(type == dns_rdatatype_rp); UNUSED(type); UNUSED(rdclass); @@ -118,7 +118,7 @@ towire_rp(ARGS_TOWIRE) { dns_offsets_t roffsets; dns_offsets_t eoffsets; - REQUIRE(rdata->type == 17); + REQUIRE(rdata->type == dns_rdatatype_rp); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); @@ -148,7 +148,7 @@ compare_rp(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 17); + REQUIRE(rdata1->type == dns_rdatatype_rp); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -182,7 +182,7 @@ fromstruct_rp(ARGS_FROMSTRUCT) { dns_rdata_rp_t *rp = source; isc_region_t region; - REQUIRE(type == 17); + REQUIRE(type == dns_rdatatype_rp); REQUIRE(source != NULL); REQUIRE(rp->common.rdtype == type); REQUIRE(rp->common.rdclass == rdclass); @@ -203,7 +203,7 @@ tostruct_rp(ARGS_TOSTRUCT) { dns_rdata_rp_t *rp = target; dns_name_t name; - REQUIRE(rdata->type == 17); + REQUIRE(rdata->type == dns_rdatatype_rp); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -237,7 +237,7 @@ freestruct_rp(ARGS_FREESTRUCT) { dns_rdata_rp_t *rp = source; REQUIRE(source != NULL); - REQUIRE(rp->common.rdtype == 17); + REQUIRE(rp->common.rdtype == dns_rdatatype_rp); if (rp->mctx == NULL) return; @@ -249,7 +249,7 @@ freestruct_rp(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_rp(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 17); + REQUIRE(rdata->type == dns_rdatatype_rp); UNUSED(rdata); UNUSED(add); @@ -263,7 +263,7 @@ digest_rp(ARGS_DIGEST) { isc_region_t r; dns_name_t name; - REQUIRE(rdata->type == 17); + REQUIRE(rdata->type == dns_rdatatype_rp); dns_rdata_toregion(rdata, &r); dns_name_init(&name, NULL); @@ -281,7 +281,7 @@ digest_rp(ARGS_DIGEST) { static inline isc_boolean_t checkowner_rp(ARGS_CHECKOWNER) { - REQUIRE(type == 17); + REQUIRE(type == dns_rdatatype_rp); UNUSED(name); UNUSED(type); @@ -296,7 +296,7 @@ checknames_rp(ARGS_CHECKNAMES) { isc_region_t region; dns_name_t name; - REQUIRE(rdata->type == 17); + REQUIRE(rdata->type == dns_rdatatype_rp); UNUSED(owner); diff --git a/lib/dns/rdata/generic/rrsig_46.c b/lib/dns/rdata/generic/rrsig_46.c index d4e8767fed88..8ae9319c5cf0 100644 --- a/lib/dns/rdata/generic/rrsig_46.c +++ b/lib/dns/rdata/generic/rrsig_46.c @@ -38,7 +38,7 @@ fromtext_rrsig(ARGS_FROMTEXT) { isc_buffer_t buffer; isc_uint32_t time_signed, time_expire; - REQUIRE(type == 46); + REQUIRE(type == dns_rdatatype_rrsig); UNUSED(type); UNUSED(rdclass); @@ -161,7 +161,7 @@ totext_rrsig(ARGS_TOTEXT) { unsigned long foot; dns_name_t name; - REQUIRE(rdata->type == 46); + REQUIRE(rdata->type == dns_rdatatype_rrsig); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, &sr); @@ -264,7 +264,7 @@ fromwire_rrsig(ARGS_FROMWIRE) { isc_region_t sr; dns_name_t name; - REQUIRE(type == 46); + REQUIRE(type == dns_rdatatype_rrsig); UNUSED(type); UNUSED(rdclass); @@ -307,7 +307,7 @@ towire_rrsig(ARGS_TOWIRE) { dns_name_t name; dns_offsets_t offsets; - REQUIRE(rdata->type == 46); + REQUIRE(rdata->type == dns_rdatatype_rrsig); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); @@ -345,7 +345,7 @@ compare_rrsig(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 46); + REQUIRE(rdata1->type == dns_rdatatype_rrsig); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -358,7 +358,7 @@ static inline isc_result_t fromstruct_rrsig(ARGS_FROMSTRUCT) { dns_rdata_rrsig_t *sig = source; - REQUIRE(type == 46); + REQUIRE(type == dns_rdatatype_rrsig); REQUIRE(source != NULL); REQUIRE(sig->common.rdtype == type); REQUIRE(sig->common.rdclass == rdclass); @@ -419,7 +419,7 @@ tostruct_rrsig(ARGS_TOSTRUCT) { dns_rdata_rrsig_t *sig = target; dns_name_t signer; - REQUIRE(rdata->type == 46); + REQUIRE(rdata->type == dns_rdatatype_rrsig); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -500,7 +500,7 @@ freestruct_rrsig(ARGS_FREESTRUCT) { dns_rdata_rrsig_t *sig = (dns_rdata_rrsig_t *) source; REQUIRE(source != NULL); - REQUIRE(sig->common.rdtype == 46); + REQUIRE(sig->common.rdtype == dns_rdatatype_rrsig); if (sig->mctx == NULL) return; @@ -513,7 +513,7 @@ freestruct_rrsig(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_rrsig(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 46); + REQUIRE(rdata->type == dns_rdatatype_rrsig); UNUSED(rdata); UNUSED(add); @@ -525,7 +525,7 @@ additionaldata_rrsig(ARGS_ADDLDATA) { static inline isc_result_t digest_rrsig(ARGS_DIGEST) { - REQUIRE(rdata->type == 46); + REQUIRE(rdata->type == dns_rdatatype_rrsig); UNUSED(rdata); UNUSED(digest); @@ -539,7 +539,7 @@ covers_rrsig(dns_rdata_t *rdata) { dns_rdatatype_t type; isc_region_t r; - REQUIRE(rdata->type == 46); + REQUIRE(rdata->type == dns_rdatatype_rrsig); dns_rdata_toregion(rdata, &r); type = uint16_fromregion(&r); @@ -550,7 +550,7 @@ covers_rrsig(dns_rdata_t *rdata) { static inline isc_boolean_t checkowner_rrsig(ARGS_CHECKOWNER) { - REQUIRE(type == 46); + REQUIRE(type == dns_rdatatype_rrsig); UNUSED(name); UNUSED(type); @@ -563,7 +563,7 @@ checkowner_rrsig(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_rrsig(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 46); + REQUIRE(rdata->type == dns_rdatatype_rrsig); UNUSED(rdata); UNUSED(owner); @@ -582,7 +582,7 @@ casecompare_rrsig(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 46); + REQUIRE(rdata1->type == dns_rdatatype_rrsig); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); diff --git a/lib/dns/rdata/generic/rt_21.c b/lib/dns/rdata/generic/rt_21.c index 86fe2480b799..a9a89b268f35 100644 --- a/lib/dns/rdata/generic/rt_21.c +++ b/lib/dns/rdata/generic/rt_21.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -33,7 +33,7 @@ fromtext_rt(ARGS_FROMTEXT) { isc_buffer_t buffer; isc_boolean_t ok; - REQUIRE(type == 21); + REQUIRE(type == dns_rdatatype_rt); UNUSED(type); UNUSED(rdclass); @@ -71,7 +71,7 @@ totext_rt(ARGS_TOTEXT) { char buf[sizeof("64000")]; unsigned short num; - REQUIRE(rdata->type == 21); + REQUIRE(rdata->type == dns_rdatatype_rt); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -94,7 +94,7 @@ fromwire_rt(ARGS_FROMWIRE) { isc_region_t sregion; isc_region_t tregion; - REQUIRE(type == 21); + REQUIRE(type == dns_rdatatype_rt); UNUSED(type); UNUSED(rdclass); @@ -122,7 +122,7 @@ towire_rt(ARGS_TOWIRE) { isc_region_t region; isc_region_t tr; - REQUIRE(rdata->type == 21); + REQUIRE(rdata->type == dns_rdatatype_rt); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); @@ -150,7 +150,7 @@ compare_rt(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 21); + REQUIRE(rdata1->type == dns_rdatatype_rt); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -178,7 +178,7 @@ fromstruct_rt(ARGS_FROMSTRUCT) { dns_rdata_rt_t *rt = source; isc_region_t region; - REQUIRE(type == 21); + REQUIRE(type == dns_rdatatype_rt); REQUIRE(source != NULL); REQUIRE(rt->common.rdtype == type); REQUIRE(rt->common.rdclass == rdclass); @@ -197,7 +197,7 @@ tostruct_rt(ARGS_TOSTRUCT) { dns_rdata_rt_t *rt = target; dns_name_t name; - REQUIRE(rdata->type == 21); + REQUIRE(rdata->type == dns_rdatatype_rt); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -222,7 +222,7 @@ freestruct_rt(ARGS_FREESTRUCT) { dns_rdata_rt_t *rt = source; REQUIRE(source != NULL); - REQUIRE(rt->common.rdtype == 21); + REQUIRE(rt->common.rdtype == dns_rdatatype_rt); if (rt->mctx == NULL) return; @@ -238,7 +238,7 @@ additionaldata_rt(ARGS_ADDLDATA) { isc_region_t region; isc_result_t result; - REQUIRE(rdata->type == 21); + REQUIRE(rdata->type == dns_rdatatype_rt); dns_name_init(&name, offsets); dns_rdata_toregion(rdata, ®ion); @@ -260,7 +260,7 @@ digest_rt(ARGS_DIGEST) { isc_result_t result; dns_name_t name; - REQUIRE(rdata->type == 21); + REQUIRE(rdata->type == dns_rdatatype_rt); dns_rdata_toregion(rdata, &r1); r2 = r1; @@ -277,7 +277,7 @@ digest_rt(ARGS_DIGEST) { static inline isc_boolean_t checkowner_rt(ARGS_CHECKOWNER) { - REQUIRE(type == 21); + REQUIRE(type == dns_rdatatype_rt); UNUSED(name); UNUSED(type); @@ -292,7 +292,7 @@ checknames_rt(ARGS_CHECKNAMES) { isc_region_t region; dns_name_t name; - REQUIRE(rdata->type == 21); + REQUIRE(rdata->type == dns_rdatatype_rt); UNUSED(owner); diff --git a/lib/dns/rdata/generic/sig_24.c b/lib/dns/rdata/generic/sig_24.c index 86aa38a696b6..af9c7daaa498 100644 --- a/lib/dns/rdata/generic/sig_24.c +++ b/lib/dns/rdata/generic/sig_24.c @@ -38,7 +38,7 @@ fromtext_sig(ARGS_FROMTEXT) { isc_buffer_t buffer; isc_uint32_t time_signed, time_expire; - REQUIRE(type == 24); + REQUIRE(type == dns_rdatatype_sig); UNUSED(type); UNUSED(rdclass); @@ -137,7 +137,7 @@ totext_sig(ARGS_TOTEXT) { dns_name_t prefix; isc_boolean_t sub; - REQUIRE(rdata->type == 24); + REQUIRE(rdata->type == dns_rdatatype_sig); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, &sr); @@ -242,7 +242,7 @@ fromwire_sig(ARGS_FROMWIRE) { isc_region_t sr; dns_name_t name; - REQUIRE(type == 24); + REQUIRE(type == dns_rdatatype_sig); UNUSED(type); UNUSED(rdclass); @@ -285,7 +285,7 @@ towire_sig(ARGS_TOWIRE) { dns_name_t name; dns_offsets_t offsets; - REQUIRE(rdata->type == 24); + REQUIRE(rdata->type == dns_rdatatype_sig); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); @@ -326,7 +326,7 @@ compare_sig(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 24); + REQUIRE(rdata1->type == dns_rdatatype_sig); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -363,7 +363,7 @@ static inline isc_result_t fromstruct_sig(ARGS_FROMSTRUCT) { dns_rdata_sig_t *sig = source; - REQUIRE(type == 24); + REQUIRE(type == dns_rdatatype_sig); REQUIRE(source != NULL); REQUIRE(sig->common.rdtype == type); REQUIRE(sig->common.rdclass == rdclass); @@ -424,7 +424,7 @@ tostruct_sig(ARGS_TOSTRUCT) { dns_rdata_sig_t *sig = target; dns_name_t signer; - REQUIRE(rdata->type == 24); + REQUIRE(rdata->type == dns_rdatatype_sig); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -505,7 +505,7 @@ freestruct_sig(ARGS_FREESTRUCT) { dns_rdata_sig_t *sig = (dns_rdata_sig_t *) source; REQUIRE(source != NULL); - REQUIRE(sig->common.rdtype == 24); + REQUIRE(sig->common.rdtype == dns_rdatatype_sig); if (sig->mctx == NULL) return; @@ -518,7 +518,7 @@ freestruct_sig(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_sig(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 24); + REQUIRE(rdata->type == dns_rdatatype_sig); UNUSED(rdata); UNUSED(add); @@ -530,7 +530,7 @@ additionaldata_sig(ARGS_ADDLDATA) { static inline isc_result_t digest_sig(ARGS_DIGEST) { - REQUIRE(rdata->type == 24); + REQUIRE(rdata->type == dns_rdatatype_sig); UNUSED(rdata); UNUSED(digest); @@ -544,7 +544,7 @@ covers_sig(dns_rdata_t *rdata) { dns_rdatatype_t type; isc_region_t r; - REQUIRE(rdata->type == 24); + REQUIRE(rdata->type == dns_rdatatype_sig); dns_rdata_toregion(rdata, &r); type = uint16_fromregion(&r); @@ -555,7 +555,7 @@ covers_sig(dns_rdata_t *rdata) { static inline isc_boolean_t checkowner_sig(ARGS_CHECKOWNER) { - REQUIRE(type == 24); + REQUIRE(type == dns_rdatatype_sig); UNUSED(name); UNUSED(type); @@ -568,7 +568,7 @@ checkowner_sig(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_sig(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 24); + REQUIRE(rdata->type == dns_rdatatype_sig); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/soa_6.c b/lib/dns/rdata/generic/soa_6.c index fe67d76f1ee3..b407813811a4 100644 --- a/lib/dns/rdata/generic/soa_6.c +++ b/lib/dns/rdata/generic/soa_6.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009, 2011, 2012, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2011, 2012, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -33,7 +33,7 @@ fromtext_soa(ARGS_FROMTEXT) { isc_uint32_t n; isc_boolean_t ok; - REQUIRE(type == 6); + REQUIRE(type == dns_rdatatype_soa); UNUSED(type); UNUSED(rdclass); @@ -95,16 +95,16 @@ totext_soa(ARGS_TOTEXT) { isc_boolean_t sub; int i; isc_boolean_t multiline; - isc_boolean_t comment; + isc_boolean_t comm; - REQUIRE(rdata->type == 6); + REQUIRE(rdata->type == dns_rdatatype_soa); REQUIRE(rdata->length != 0); multiline = ISC_TF((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0); if (multiline) - comment = ISC_TF((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0); + comm = ISC_TF((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0); else - comment = ISC_FALSE; + comm = ISC_FALSE; dns_name_init(&mname, NULL); @@ -136,9 +136,9 @@ totext_soa(ARGS_TOTEXT) { unsigned long num; num = uint32_fromregion(&dregion); isc_region_consume(&dregion, 4); - sprintf(buf, comment ? "%-10lu ; " : "%lu", num); + sprintf(buf, comm ? "%-10lu ; " : "%lu", num); RETERR(str_totext(buf, target)); - if (comment) { + if (comm) { RETERR(str_totext(soa_fieldnames[i], target)); /* Print times in week/day/hour/minute/second form */ if (i >= 1) { @@ -165,7 +165,7 @@ fromwire_soa(ARGS_FROMWIRE) { isc_region_t sregion; isc_region_t tregion; - REQUIRE(type == 6); + REQUIRE(type == dns_rdatatype_soa); UNUSED(type); UNUSED(rdclass); @@ -202,7 +202,7 @@ towire_soa(ARGS_TOWIRE) { dns_offsets_t moffsets; dns_offsets_t roffsets; - REQUIRE(rdata->type == 6); + REQUIRE(rdata->type == dns_rdatatype_soa); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); @@ -239,7 +239,7 @@ compare_soa(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 6); + REQUIRE(rdata1->type == dns_rdatatype_soa); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -280,7 +280,7 @@ fromstruct_soa(ARGS_FROMSTRUCT) { dns_rdata_soa_t *soa = source; isc_region_t region; - REQUIRE(type == 6); + REQUIRE(type == dns_rdatatype_soa); REQUIRE(source != NULL); REQUIRE(soa->common.rdtype == type); REQUIRE(soa->common.rdclass == rdclass); @@ -306,7 +306,7 @@ tostruct_soa(ARGS_TOSTRUCT) { dns_name_t name; isc_result_t result; - REQUIRE(rdata->type == 6); + REQUIRE(rdata->type == dns_rdatatype_soa); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -358,7 +358,7 @@ freestruct_soa(ARGS_FREESTRUCT) { dns_rdata_soa_t *soa = source; REQUIRE(source != NULL); - REQUIRE(soa->common.rdtype == 6); + REQUIRE(soa->common.rdtype == dns_rdatatype_soa); if (soa->mctx == NULL) return; @@ -374,7 +374,7 @@ additionaldata_soa(ARGS_ADDLDATA) { UNUSED(add); UNUSED(arg); - REQUIRE(rdata->type == 6); + REQUIRE(rdata->type == dns_rdatatype_soa); return (ISC_R_SUCCESS); } @@ -384,7 +384,7 @@ digest_soa(ARGS_DIGEST) { isc_region_t r; dns_name_t name; - REQUIRE(rdata->type == 6); + REQUIRE(rdata->type == dns_rdatatype_soa); dns_rdata_toregion(rdata, &r); @@ -404,7 +404,7 @@ digest_soa(ARGS_DIGEST) { static inline isc_boolean_t checkowner_soa(ARGS_CHECKOWNER) { - REQUIRE(type == 6); + REQUIRE(type == dns_rdatatype_soa); UNUSED(name); UNUSED(type); @@ -419,7 +419,7 @@ checknames_soa(ARGS_CHECKNAMES) { isc_region_t region; dns_name_t name; - REQUIRE(rdata->type == 6); + REQUIRE(rdata->type == dns_rdatatype_soa); UNUSED(owner); diff --git a/lib/dns/rdata/generic/spf_99.c b/lib/dns/rdata/generic/spf_99.c index 10e86b888f3a..8ad4f02b9af4 100644 --- a/lib/dns/rdata/generic/spf_99.c +++ b/lib/dns/rdata/generic/spf_99.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -29,7 +29,7 @@ fromtext_spf(ARGS_FROMTEXT) { isc_token_t token; int strings; - REQUIRE(type == 99); + REQUIRE(type == dns_rdatatype_spf); UNUSED(type); UNUSED(rdclass); @@ -59,7 +59,7 @@ totext_spf(ARGS_TOTEXT) { UNUSED(tctx); - REQUIRE(rdata->type == 99); + REQUIRE(rdata->type == dns_rdatatype_spf); dns_rdata_toregion(rdata, ®ion); @@ -76,7 +76,7 @@ static inline isc_result_t fromwire_spf(ARGS_FROMWIRE) { isc_result_t result; - REQUIRE(type == 99); + REQUIRE(type == dns_rdatatype_spf); UNUSED(type); UNUSED(dctx); @@ -95,7 +95,7 @@ static inline isc_result_t towire_spf(ARGS_TOWIRE) { isc_region_t region; - REQUIRE(rdata->type == 99); + REQUIRE(rdata->type == dns_rdatatype_spf); UNUSED(cctx); @@ -115,7 +115,7 @@ compare_spf(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 99); + REQUIRE(rdata1->type == dns_rdatatype_spf); dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); @@ -128,7 +128,7 @@ fromstruct_spf(ARGS_FROMSTRUCT) { isc_region_t region; isc_uint8_t length; - REQUIRE(type == 99); + REQUIRE(type == dns_rdatatype_spf); REQUIRE(source != NULL); REQUIRE(txt->common.rdtype == type); REQUIRE(txt->common.rdclass == rdclass); @@ -155,7 +155,7 @@ tostruct_spf(ARGS_TOSTRUCT) { dns_rdata_spf_t *txt = target; isc_region_t r; - REQUIRE(rdata->type == 99); + REQUIRE(rdata->type == dns_rdatatype_spf); REQUIRE(target != NULL); txt->common.rdclass = rdata->rdclass; @@ -178,7 +178,7 @@ freestruct_spf(ARGS_FREESTRUCT) { dns_rdata_spf_t *txt = source; REQUIRE(source != NULL); - REQUIRE(txt->common.rdtype == 99); + REQUIRE(txt->common.rdtype == dns_rdatatype_spf); if (txt->mctx == NULL) return; @@ -190,7 +190,7 @@ freestruct_spf(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_spf(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 99); + REQUIRE(rdata->type == dns_rdatatype_spf); UNUSED(rdata); UNUSED(add); @@ -203,7 +203,7 @@ static inline isc_result_t digest_spf(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 99); + REQUIRE(rdata->type == dns_rdatatype_spf); dns_rdata_toregion(rdata, &r); @@ -213,7 +213,7 @@ digest_spf(ARGS_DIGEST) { static inline isc_boolean_t checkowner_spf(ARGS_CHECKOWNER) { - REQUIRE(type == 99); + REQUIRE(type == dns_rdatatype_spf); UNUSED(name); UNUSED(type); @@ -226,7 +226,7 @@ checkowner_spf(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_spf(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 99); + REQUIRE(rdata->type == dns_rdatatype_spf); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/sshfp_44.c b/lib/dns/rdata/generic/sshfp_44.c index d553cd40380d..083c0fca4b8b 100644 --- a/lib/dns/rdata/generic/sshfp_44.c +++ b/lib/dns/rdata/generic/sshfp_44.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2006, 2007, 2009, 2011-2013 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2006, 2007, 2009, 2011-2013, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -28,7 +28,7 @@ static inline isc_result_t fromtext_sshfp(ARGS_FROMTEXT) { isc_token_t token; - REQUIRE(type == 44); + REQUIRE(type == dns_rdatatype_sshfp); UNUSED(type); UNUSED(rdclass); @@ -66,7 +66,7 @@ totext_sshfp(ARGS_TOTEXT) { char buf[sizeof("64000 ")]; unsigned int n; - REQUIRE(rdata->type == 44); + REQUIRE(rdata->type == dns_rdatatype_sshfp); REQUIRE(rdata->length != 0); UNUSED(tctx); @@ -109,7 +109,7 @@ static inline isc_result_t fromwire_sshfp(ARGS_FROMWIRE) { isc_region_t sr; - REQUIRE(type == 44); + REQUIRE(type == dns_rdatatype_sshfp); UNUSED(type); UNUSED(rdclass); @@ -128,7 +128,7 @@ static inline isc_result_t towire_sshfp(ARGS_TOWIRE) { isc_region_t sr; - REQUIRE(rdata->type == 44); + REQUIRE(rdata->type == dns_rdatatype_sshfp); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -144,7 +144,7 @@ compare_sshfp(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 44); + REQUIRE(rdata1->type == dns_rdatatype_sshfp); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -157,7 +157,7 @@ static inline isc_result_t fromstruct_sshfp(ARGS_FROMSTRUCT) { dns_rdata_sshfp_t *sshfp = source; - REQUIRE(type == 44); + REQUIRE(type == dns_rdatatype_sshfp); REQUIRE(source != NULL); REQUIRE(sshfp->common.rdtype == type); REQUIRE(sshfp->common.rdclass == rdclass); @@ -176,7 +176,7 @@ tostruct_sshfp(ARGS_TOSTRUCT) { dns_rdata_sshfp_t *sshfp = target; isc_region_t region; - REQUIRE(rdata->type == 44); + REQUIRE(rdata->type == dns_rdatatype_sshfp); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -205,7 +205,7 @@ freestruct_sshfp(ARGS_FREESTRUCT) { dns_rdata_sshfp_t *sshfp = source; REQUIRE(sshfp != NULL); - REQUIRE(sshfp->common.rdtype == 44); + REQUIRE(sshfp->common.rdtype == dns_rdatatype_sshfp); if (sshfp->mctx == NULL) return; @@ -217,7 +217,7 @@ freestruct_sshfp(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_sshfp(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 44); + REQUIRE(rdata->type == dns_rdatatype_sshfp); UNUSED(rdata); UNUSED(add); @@ -230,7 +230,7 @@ static inline isc_result_t digest_sshfp(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 44); + REQUIRE(rdata->type == dns_rdatatype_sshfp); dns_rdata_toregion(rdata, &r); @@ -240,7 +240,7 @@ digest_sshfp(ARGS_DIGEST) { static inline isc_boolean_t checkowner_sshfp(ARGS_CHECKOWNER) { - REQUIRE(type == 44); + REQUIRE(type == dns_rdatatype_sshfp); UNUSED(name); UNUSED(type); @@ -253,7 +253,7 @@ checkowner_sshfp(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_sshfp(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 44); + REQUIRE(rdata->type == dns_rdatatype_sshfp); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/tkey_249.c b/lib/dns/rdata/generic/tkey_249.c index 0c91fd221ed8..e87b88065c97 100644 --- a/lib/dns/rdata/generic/tkey_249.c +++ b/lib/dns/rdata/generic/tkey_249.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009, 2011, 2012, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2011, 2012, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -37,7 +37,7 @@ fromtext_tkey(ARGS_FROMTEXT) { long i; char *e; - REQUIRE(type == 249); + REQUIRE(type == dns_rdatatype_tkey); UNUSED(type); UNUSED(rdclass); @@ -132,7 +132,7 @@ totext_tkey(ARGS_TOTEXT) { dns_name_t prefix; isc_boolean_t sub; - REQUIRE(rdata->type == 249); + REQUIRE(rdata->type == dns_rdatatype_tkey); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, &sr); @@ -247,7 +247,7 @@ fromwire_tkey(ARGS_FROMWIRE) { unsigned long n; dns_name_t name; - REQUIRE(type == 249); + REQUIRE(type == dns_rdatatype_tkey); UNUSED(type); UNUSED(rdclass); @@ -303,7 +303,7 @@ towire_tkey(ARGS_TOWIRE) { dns_name_t name; dns_offsets_t offsets; - REQUIRE(rdata->type == 249); + REQUIRE(rdata->type == dns_rdatatype_tkey); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); @@ -329,7 +329,7 @@ compare_tkey(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 249); + REQUIRE(rdata1->type == dns_rdatatype_tkey); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -353,7 +353,7 @@ static inline isc_result_t fromstruct_tkey(ARGS_FROMSTRUCT) { dns_rdata_tkey_t *tkey = source; - REQUIRE(type == 249); + REQUIRE(type == dns_rdatatype_tkey); REQUIRE(source != NULL); REQUIRE(tkey->common.rdtype == type); REQUIRE(tkey->common.rdclass == rdclass); @@ -413,7 +413,7 @@ tostruct_tkey(ARGS_TOSTRUCT) { dns_name_t alg; isc_region_t sr; - REQUIRE(rdata->type == 249); + REQUIRE(rdata->type == dns_rdatatype_tkey); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -519,7 +519,7 @@ additionaldata_tkey(ARGS_ADDLDATA) { UNUSED(add); UNUSED(arg); - REQUIRE(rdata->type == 249); + REQUIRE(rdata->type == dns_rdatatype_tkey); return (ISC_R_SUCCESS); } @@ -530,7 +530,7 @@ digest_tkey(ARGS_DIGEST) { UNUSED(digest); UNUSED(arg); - REQUIRE(rdata->type == 249); + REQUIRE(rdata->type == dns_rdatatype_tkey); return (ISC_R_NOTIMPLEMENTED); } @@ -538,7 +538,7 @@ digest_tkey(ARGS_DIGEST) { static inline isc_boolean_t checkowner_tkey(ARGS_CHECKOWNER) { - REQUIRE(type == 249); + REQUIRE(type == dns_rdatatype_tkey); UNUSED(name); UNUSED(type); @@ -551,7 +551,7 @@ checkowner_tkey(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_tkey(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 249); + REQUIRE(rdata->type == dns_rdatatype_tkey); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/tlsa_52.c b/lib/dns/rdata/generic/tlsa_52.c index b46556d35d4e..d09a5289a805 100644 --- a/lib/dns/rdata/generic/tlsa_52.c +++ b/lib/dns/rdata/generic/tlsa_52.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2012, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -27,7 +27,7 @@ static inline isc_result_t fromtext_tlsa(ARGS_FROMTEXT) { isc_token_t token; - REQUIRE(type == 52); + REQUIRE(type == dns_rdatatype_tlsa); UNUSED(type); UNUSED(rdclass); @@ -74,7 +74,7 @@ totext_tlsa(ARGS_TOTEXT) { char buf[sizeof("64000 ")]; unsigned int n; - REQUIRE(rdata->type == 52); + REQUIRE(rdata->type == dns_rdatatype_tlsa); REQUIRE(rdata->length != 0); UNUSED(tctx); @@ -125,7 +125,7 @@ static inline isc_result_t fromwire_tlsa(ARGS_FROMWIRE) { isc_region_t sr; - REQUIRE(type == 52); + REQUIRE(type == dns_rdatatype_tlsa); UNUSED(type); UNUSED(rdclass); @@ -145,7 +145,7 @@ static inline isc_result_t towire_tlsa(ARGS_TOWIRE) { isc_region_t sr; - REQUIRE(rdata->type == 52); + REQUIRE(rdata->type == dns_rdatatype_tlsa); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -161,7 +161,7 @@ compare_tlsa(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 52); + REQUIRE(rdata1->type == dns_rdatatype_tlsa); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -174,7 +174,7 @@ static inline isc_result_t fromstruct_tlsa(ARGS_FROMSTRUCT) { dns_rdata_tlsa_t *tlsa = source; - REQUIRE(type == 52); + REQUIRE(type == dns_rdatatype_tlsa); REQUIRE(source != NULL); REQUIRE(tlsa->common.rdtype == type); REQUIRE(tlsa->common.rdclass == rdclass); @@ -194,7 +194,7 @@ tostruct_tlsa(ARGS_TOSTRUCT) { dns_rdata_tlsa_t *tlsa = target; isc_region_t region; - REQUIRE(rdata->type == 52); + REQUIRE(rdata->type == dns_rdatatype_tlsa); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -225,7 +225,7 @@ freestruct_tlsa(ARGS_FREESTRUCT) { dns_rdata_tlsa_t *tlsa = source; REQUIRE(tlsa != NULL); - REQUIRE(tlsa->common.rdtype == 52); + REQUIRE(tlsa->common.rdtype == dns_rdatatype_tlsa); if (tlsa->mctx == NULL) return; @@ -237,7 +237,7 @@ freestruct_tlsa(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_tlsa(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 52); + REQUIRE(rdata->type == dns_rdatatype_tlsa); UNUSED(rdata); UNUSED(add); @@ -250,7 +250,7 @@ static inline isc_result_t digest_tlsa(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 52); + REQUIRE(rdata->type == dns_rdatatype_tlsa); dns_rdata_toregion(rdata, &r); @@ -260,7 +260,7 @@ digest_tlsa(ARGS_DIGEST) { static inline isc_boolean_t checkowner_tlsa(ARGS_CHECKOWNER) { - REQUIRE(type == 52); + REQUIRE(type == dns_rdatatype_tlsa); UNUSED(name); UNUSED(type); @@ -273,7 +273,7 @@ checkowner_tlsa(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_tlsa(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 52); + REQUIRE(rdata->type == dns_rdatatype_tlsa); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/txt_16.c b/lib/dns/rdata/generic/txt_16.c index 0cbe3ea6f15a..aa7c3a0ab138 100644 --- a/lib/dns/rdata/generic/txt_16.c +++ b/lib/dns/rdata/generic/txt_16.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007-2009, 2012, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007-2009, 2012, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -29,7 +29,7 @@ fromtext_txt(ARGS_FROMTEXT) { isc_token_t token; int strings; - REQUIRE(type == 16); + REQUIRE(type == dns_rdatatype_txt); UNUSED(type); UNUSED(rdclass); @@ -66,7 +66,7 @@ totext_txt(ARGS_TOTEXT) { UNUSED(tctx); - REQUIRE(rdata->type == 16); + REQUIRE(rdata->type == dns_rdatatype_txt); dns_rdata_toregion(rdata, ®ion); @@ -83,7 +83,7 @@ static inline isc_result_t fromwire_txt(ARGS_FROMWIRE) { isc_result_t result; - REQUIRE(type == 16); + REQUIRE(type == dns_rdatatype_txt); UNUSED(type); UNUSED(dctx); @@ -102,7 +102,7 @@ static inline isc_result_t towire_txt(ARGS_TOWIRE) { isc_region_t region; - REQUIRE(rdata->type == 16); + REQUIRE(rdata->type == dns_rdatatype_txt); UNUSED(cctx); @@ -122,7 +122,7 @@ compare_txt(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 16); + REQUIRE(rdata1->type == dns_rdatatype_txt); dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); @@ -135,7 +135,7 @@ fromstruct_txt(ARGS_FROMSTRUCT) { isc_region_t region; isc_uint8_t length; - REQUIRE(type == 16); + REQUIRE(type == dns_rdatatype_txt); REQUIRE(source != NULL); REQUIRE(txt->common.rdtype == type); REQUIRE(txt->common.rdclass == rdclass); @@ -162,7 +162,7 @@ tostruct_txt(ARGS_TOSTRUCT) { dns_rdata_txt_t *txt = target; isc_region_t r; - REQUIRE(rdata->type == 16); + REQUIRE(rdata->type == dns_rdatatype_txt); REQUIRE(target != NULL); txt->common.rdclass = rdata->rdclass; @@ -185,7 +185,7 @@ freestruct_txt(ARGS_FREESTRUCT) { dns_rdata_txt_t *txt = source; REQUIRE(source != NULL); - REQUIRE(txt->common.rdtype == 16); + REQUIRE(txt->common.rdtype == dns_rdatatype_txt); if (txt->mctx == NULL) return; @@ -197,7 +197,7 @@ freestruct_txt(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_txt(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 16); + REQUIRE(rdata->type == dns_rdatatype_txt); UNUSED(rdata); UNUSED(add); @@ -210,7 +210,7 @@ static inline isc_result_t digest_txt(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 16); + REQUIRE(rdata->type == dns_rdatatype_txt); dns_rdata_toregion(rdata, &r); @@ -220,7 +220,7 @@ digest_txt(ARGS_DIGEST) { static inline isc_boolean_t checkowner_txt(ARGS_CHECKOWNER) { - REQUIRE(type == 16); + REQUIRE(type == dns_rdatatype_txt); UNUSED(name); UNUSED(type); @@ -233,7 +233,7 @@ checkowner_txt(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_txt(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 16); + REQUIRE(rdata->type == dns_rdatatype_txt); UNUSED(rdata); UNUSED(owner); @@ -251,7 +251,7 @@ isc_result_t dns_rdata_txt_first(dns_rdata_txt_t *txt) { REQUIRE(txt != NULL); - REQUIRE(txt->common.rdtype == 16); + REQUIRE(txt->common.rdtype == dns_rdatatype_txt); REQUIRE(txt->txt != NULL || txt->txt_len == 0); if (txt->txt_len == 0) @@ -267,7 +267,7 @@ dns_rdata_txt_next(dns_rdata_txt_t *txt) { isc_uint8_t length; REQUIRE(txt != NULL); - REQUIRE(txt->common.rdtype == 16); + REQUIRE(txt->common.rdtype == dns_rdatatype_txt); REQUIRE(txt->txt != NULL && txt->txt_len != 0); INSIST(txt->offset + 1 <= txt->txt_len); @@ -287,7 +287,7 @@ dns_rdata_txt_current(dns_rdata_txt_t *txt, dns_rdata_txt_string_t *string) { REQUIRE(txt != NULL); REQUIRE(string != NULL); - REQUIRE(txt->common.rdtype == 16); + REQUIRE(txt->common.rdtype == dns_rdatatype_txt); REQUIRE(txt->txt != NULL); REQUIRE(txt->offset < txt->txt_len); diff --git a/lib/dns/rdata/generic/unspec_103.c b/lib/dns/rdata/generic/unspec_103.c index c335c6751da7..016d7a64f9f2 100644 --- a/lib/dns/rdata/generic/unspec_103.c +++ b/lib/dns/rdata/generic/unspec_103.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -25,7 +25,7 @@ static inline isc_result_t fromtext_unspec(ARGS_FROMTEXT) { - REQUIRE(type == 103); + REQUIRE(type == dns_rdatatype_unspec); UNUSED(type); UNUSED(rdclass); @@ -39,7 +39,7 @@ fromtext_unspec(ARGS_FROMTEXT) { static inline isc_result_t totext_unspec(ARGS_TOTEXT) { - REQUIRE(rdata->type == 103); + REQUIRE(rdata->type == dns_rdatatype_unspec); UNUSED(tctx); @@ -50,7 +50,7 @@ static inline isc_result_t fromwire_unspec(ARGS_FROMWIRE) { isc_region_t sr; - REQUIRE(type == 103); + REQUIRE(type == dns_rdatatype_unspec); UNUSED(type); UNUSED(rdclass); @@ -65,7 +65,7 @@ fromwire_unspec(ARGS_FROMWIRE) { static inline isc_result_t towire_unspec(ARGS_TOWIRE) { - REQUIRE(rdata->type == 103); + REQUIRE(rdata->type == dns_rdatatype_unspec); UNUSED(cctx); @@ -79,7 +79,7 @@ compare_unspec(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 103); + REQUIRE(rdata1->type == dns_rdatatype_unspec); dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); @@ -90,7 +90,7 @@ static inline isc_result_t fromstruct_unspec(ARGS_FROMSTRUCT) { dns_rdata_unspec_t *unspec = source; - REQUIRE(type == 103); + REQUIRE(type == dns_rdatatype_unspec); REQUIRE(source != NULL); REQUIRE(unspec->common.rdtype == type); REQUIRE(unspec->common.rdclass == rdclass); @@ -107,7 +107,7 @@ tostruct_unspec(ARGS_TOSTRUCT) { dns_rdata_unspec_t *unspec = target; isc_region_t r; - REQUIRE(rdata->type == 103); + REQUIRE(rdata->type == dns_rdatatype_unspec); REQUIRE(target != NULL); unspec->common.rdclass = rdata->rdclass; @@ -129,7 +129,7 @@ freestruct_unspec(ARGS_FREESTRUCT) { dns_rdata_unspec_t *unspec = source; REQUIRE(source != NULL); - REQUIRE(unspec->common.rdtype == 103); + REQUIRE(unspec->common.rdtype == dns_rdatatype_unspec); if (unspec->mctx == NULL) return; @@ -141,7 +141,7 @@ freestruct_unspec(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_unspec(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 103); + REQUIRE(rdata->type == dns_rdatatype_unspec); UNUSED(rdata); UNUSED(add); @@ -154,7 +154,7 @@ static inline isc_result_t digest_unspec(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 103); + REQUIRE(rdata->type == dns_rdatatype_unspec); dns_rdata_toregion(rdata, &r); @@ -164,7 +164,7 @@ digest_unspec(ARGS_DIGEST) { static inline isc_boolean_t checkowner_unspec(ARGS_CHECKOWNER) { - REQUIRE(type == 103); + REQUIRE(type == dns_rdatatype_unspec); UNUSED(name); UNUSED(type); @@ -177,7 +177,7 @@ checkowner_unspec(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_unspec(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 103); + REQUIRE(rdata->type == dns_rdatatype_unspec); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/uri_256.c b/lib/dns/rdata/generic/uri_256.c index 3ddd790847ac..7e4b41cb7092 100644 --- a/lib/dns/rdata/generic/uri_256.c +++ b/lib/dns/rdata/generic/uri_256.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011, 2012, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2011, 2012, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -25,7 +25,7 @@ static inline isc_result_t fromtext_uri(ARGS_FROMTEXT) { isc_token_t token; - REQUIRE(type == 256); + REQUIRE(type == dns_rdatatype_uri); UNUSED(type); UNUSED(rdclass); @@ -70,7 +70,7 @@ totext_uri(ARGS_TOTEXT) { UNUSED(tctx); - REQUIRE(rdata->type == 256); + REQUIRE(rdata->type == dns_rdatatype_uri); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, ®ion); @@ -102,7 +102,7 @@ static inline isc_result_t fromwire_uri(ARGS_FROMWIRE) { isc_region_t region; - REQUIRE(type == 256); + REQUIRE(type == dns_rdatatype_uri); UNUSED(type); UNUSED(rdclass); @@ -127,7 +127,7 @@ static inline isc_result_t towire_uri(ARGS_TOWIRE) { isc_region_t region; - REQUIRE(rdata->type == 256); + REQUIRE(rdata->type == dns_rdatatype_uri); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -144,7 +144,7 @@ compare_uri(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 256); + REQUIRE(rdata1->type == dns_rdatatype_uri); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -176,7 +176,7 @@ static inline isc_result_t fromstruct_uri(ARGS_FROMSTRUCT) { dns_rdata_uri_t *uri = source; - REQUIRE(type == 256); + REQUIRE(type == dns_rdatatype_uri); REQUIRE(source != NULL); REQUIRE(uri->common.rdtype == type); REQUIRE(uri->common.rdclass == rdclass); @@ -206,7 +206,7 @@ tostruct_uri(ARGS_TOSTRUCT) { dns_rdata_uri_t *uri = target; isc_region_t sr; - REQUIRE(rdata->type == 256); + REQUIRE(rdata->type == dns_rdatatype_uri); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -249,7 +249,7 @@ freestruct_uri(ARGS_FREESTRUCT) { dns_rdata_uri_t *uri = (dns_rdata_uri_t *) source; REQUIRE(source != NULL); - REQUIRE(uri->common.rdtype == 256); + REQUIRE(uri->common.rdtype == dns_rdatatype_uri); if (uri->mctx == NULL) return; @@ -261,7 +261,7 @@ freestruct_uri(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_uri(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 256); + REQUIRE(rdata->type == dns_rdatatype_uri); UNUSED(rdata); UNUSED(add); @@ -274,7 +274,7 @@ static inline isc_result_t digest_uri(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 256); + REQUIRE(rdata->type == dns_rdatatype_uri); dns_rdata_toregion(rdata, &r); @@ -284,7 +284,7 @@ digest_uri(ARGS_DIGEST) { static inline isc_boolean_t checkowner_uri(ARGS_CHECKOWNER) { - REQUIRE(type == 256); + REQUIRE(type == dns_rdatatype_uri); UNUSED(name); UNUSED(type); @@ -297,7 +297,7 @@ checkowner_uri(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_uri(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 256); + REQUIRE(rdata->type == dns_rdatatype_uri); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/generic/x25_19.c b/lib/dns/rdata/generic/x25_19.c index c5fe2d18b08c..81543f63fa97 100644 --- a/lib/dns/rdata/generic/x25_19.c +++ b/lib/dns/rdata/generic/x25_19.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -31,7 +31,7 @@ fromtext_x25(ARGS_FROMTEXT) { isc_token_t token; unsigned int i; - REQUIRE(type == 19); + REQUIRE(type == dns_rdatatype_x25); UNUSED(type); UNUSED(rdclass); @@ -56,7 +56,7 @@ totext_x25(ARGS_TOTEXT) { UNUSED(tctx); - REQUIRE(rdata->type == 19); + REQUIRE(rdata->type == dns_rdatatype_x25); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, ®ion); @@ -67,7 +67,7 @@ static inline isc_result_t fromwire_x25(ARGS_FROMWIRE) { isc_region_t sr; - REQUIRE(type == 19); + REQUIRE(type == dns_rdatatype_x25); UNUSED(type); UNUSED(dctx); @@ -84,7 +84,7 @@ static inline isc_result_t towire_x25(ARGS_TOWIRE) { UNUSED(cctx); - REQUIRE(rdata->type == 19); + REQUIRE(rdata->type == dns_rdatatype_x25); REQUIRE(rdata->length != 0); return (mem_tobuffer(target, rdata->data, rdata->length)); @@ -97,7 +97,7 @@ compare_x25(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 19); + REQUIRE(rdata1->type == dns_rdatatype_x25); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -111,7 +111,7 @@ fromstruct_x25(ARGS_FROMSTRUCT) { dns_rdata_x25_t *x25 = source; isc_uint8_t i; - REQUIRE(type == 19); + REQUIRE(type == dns_rdatatype_x25); REQUIRE(source != NULL); REQUIRE(x25->common.rdtype == type); REQUIRE(x25->common.rdclass == rdclass); @@ -136,7 +136,7 @@ tostruct_x25(ARGS_TOSTRUCT) { dns_rdata_x25_t *x25 = target; isc_region_t r; - REQUIRE(rdata->type == 19); + REQUIRE(rdata->type == dns_rdatatype_x25); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -159,7 +159,7 @@ static inline void freestruct_x25(ARGS_FREESTRUCT) { dns_rdata_x25_t *x25 = source; REQUIRE(source != NULL); - REQUIRE(x25->common.rdtype == 19); + REQUIRE(x25->common.rdtype == dns_rdatatype_x25); if (x25->mctx == NULL) return; @@ -171,7 +171,7 @@ freestruct_x25(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_x25(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 19); + REQUIRE(rdata->type == dns_rdatatype_x25); UNUSED(rdata); UNUSED(add); @@ -184,7 +184,7 @@ static inline isc_result_t digest_x25(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 19); + REQUIRE(rdata->type == dns_rdatatype_x25); dns_rdata_toregion(rdata, &r); @@ -194,7 +194,7 @@ digest_x25(ARGS_DIGEST) { static inline isc_boolean_t checkowner_x25(ARGS_CHECKOWNER) { - REQUIRE(type == 19); + REQUIRE(type == dns_rdatatype_x25); UNUSED(name); UNUSED(type); @@ -207,7 +207,7 @@ checkowner_x25(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_x25(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 19); + REQUIRE(rdata->type == dns_rdatatype_x25); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/hs_4/a_1.c b/lib/dns/rdata/hs_4/a_1.c index 5f8a87504c0e..dc543a962c3c 100644 --- a/lib/dns/rdata/hs_4/a_1.c +++ b/lib/dns/rdata/hs_4/a_1.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -32,8 +32,8 @@ fromtext_hs_a(ARGS_FROMTEXT) { struct in_addr addr; isc_region_t region; - REQUIRE(type == 1); - REQUIRE(rdclass == 4); + REQUIRE(type == dns_rdatatype_a); + REQUIRE(rdclass == dns_rdataclass_hs); UNUSED(type); UNUSED(origin); @@ -57,8 +57,8 @@ static inline isc_result_t totext_hs_a(ARGS_TOTEXT) { isc_region_t region; - REQUIRE(rdata->type == 1); - REQUIRE(rdata->rdclass == 4); + REQUIRE(rdata->type == dns_rdatatype_a); + REQUIRE(rdata->rdclass == dns_rdataclass_hs); REQUIRE(rdata->length == 4); UNUSED(tctx); @@ -72,8 +72,8 @@ fromwire_hs_a(ARGS_FROMWIRE) { isc_region_t sregion; isc_region_t tregion; - REQUIRE(type == 1); - REQUIRE(rdclass == 4); + REQUIRE(type == dns_rdatatype_a); + REQUIRE(rdclass == dns_rdataclass_hs); UNUSED(type); UNUSED(dctx); @@ -97,8 +97,8 @@ static inline isc_result_t towire_hs_a(ARGS_TOWIRE) { isc_region_t region; - REQUIRE(rdata->type == 1); - REQUIRE(rdata->rdclass == 4); + REQUIRE(rdata->type == dns_rdatatype_a); + REQUIRE(rdata->rdclass == dns_rdataclass_hs); REQUIRE(rdata->length == 4); UNUSED(cctx); @@ -117,8 +117,8 @@ compare_hs_a(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 1); - REQUIRE(rdata1->rdclass == 4); + REQUIRE(rdata1->type == dns_rdatatype_a); + REQUIRE(rdata1->rdclass == dns_rdataclass_hs); REQUIRE(rdata1->length == 4); REQUIRE(rdata2->length == 4); @@ -134,8 +134,8 @@ fromstruct_hs_a(ARGS_FROMSTRUCT) { dns_rdata_hs_a_t *a = source; isc_uint32_t n; - REQUIRE(type == 1); - REQUIRE(rdclass == 4); + REQUIRE(type == dns_rdatatype_a); + REQUIRE(rdclass == dns_rdataclass_hs); REQUIRE(source != NULL); REQUIRE(a->common.rdtype == type); REQUIRE(a->common.rdclass == rdclass); @@ -154,8 +154,8 @@ tostruct_hs_a(ARGS_TOSTRUCT) { isc_uint32_t n; isc_region_t region; - REQUIRE(rdata->type == 1); - REQUIRE(rdata->rdclass == 4); + REQUIRE(rdata->type == dns_rdatatype_a); + REQUIRE(rdata->rdclass == dns_rdataclass_hs); REQUIRE(rdata->length == 4); UNUSED(mctx); @@ -180,8 +180,8 @@ freestruct_hs_a(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_hs_a(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 1); - REQUIRE(rdata->rdclass == 4); + REQUIRE(rdata->type == dns_rdatatype_a); + REQUIRE(rdata->rdclass == dns_rdataclass_hs); UNUSED(rdata); UNUSED(add); @@ -194,8 +194,8 @@ static inline isc_result_t digest_hs_a(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 1); - REQUIRE(rdata->rdclass == 4); + REQUIRE(rdata->type == dns_rdatatype_a); + REQUIRE(rdata->rdclass == dns_rdataclass_hs); dns_rdata_toregion(rdata, &r); @@ -205,8 +205,8 @@ digest_hs_a(ARGS_DIGEST) { static inline isc_boolean_t checkowner_hs_a(ARGS_CHECKOWNER) { - REQUIRE(type == 1); - REQUIRE(rdclass == 4); + REQUIRE(type == dns_rdatatype_a); + REQUIRE(rdclass == dns_rdataclass_hs); UNUSED(name); UNUSED(type); @@ -219,8 +219,8 @@ checkowner_hs_a(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_hs_a(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 1); - REQUIRE(rdata->rdclass == 4); + REQUIRE(rdata->type == dns_rdatatype_a); + REQUIRE(rdata->rdclass == dns_rdataclass_hs); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/in_1/a6_38.c b/lib/dns/rdata/in_1/a6_38.c index b6ef68878e2f..05a21ade89d2 100644 --- a/lib/dns/rdata/in_1/a6_38.c +++ b/lib/dns/rdata/in_1/a6_38.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -37,8 +37,8 @@ fromtext_in_a6(ARGS_FROMTEXT) { isc_buffer_t buffer; isc_boolean_t ok; - REQUIRE(type == 38); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_a6); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(rdclass); @@ -107,8 +107,8 @@ totext_in_a6(ARGS_TOTEXT) { dns_name_t prefix; isc_boolean_t sub; - REQUIRE(rdata->type == 38); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_a6); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, &sr); @@ -150,8 +150,8 @@ fromwire_in_a6(ARGS_FROMWIRE) { unsigned char mask; dns_name_t name; - REQUIRE(type == 38); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_a6); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(rdclass); @@ -199,8 +199,8 @@ towire_in_a6(ARGS_TOWIRE) { unsigned char prefixlen; unsigned char octets; - REQUIRE(rdata->type == 38); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_a6); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); @@ -232,8 +232,8 @@ compare_in_a6(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 38); - REQUIRE(rdata1->rdclass == 1); + REQUIRE(rdata1->type == dns_rdatatype_a6); + REQUIRE(rdata1->rdclass == dns_rdataclass_in); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -283,8 +283,8 @@ fromstruct_in_a6(ARGS_FROMSTRUCT) { isc_uint8_t first; isc_uint8_t mask; - REQUIRE(type == 38); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_a6); + REQUIRE(rdclass == dns_rdataclass_in); REQUIRE(source != NULL); REQUIRE(a6->common.rdtype == type); REQUIRE(a6->common.rdclass == rdclass); @@ -326,8 +326,8 @@ tostruct_in_a6(ARGS_TOSTRUCT) { dns_name_t name; isc_region_t r; - REQUIRE(rdata->type == 38); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_a6); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -369,8 +369,8 @@ freestruct_in_a6(ARGS_FREESTRUCT) { dns_rdata_in_a6_t *a6 = source; REQUIRE(source != NULL); - REQUIRE(a6->common.rdclass == 1); - REQUIRE(a6->common.rdtype == 38); + REQUIRE(a6->common.rdclass == dns_rdataclass_in); + REQUIRE(a6->common.rdtype == dns_rdatatype_a6); if (a6->mctx == NULL) return; @@ -382,8 +382,8 @@ freestruct_in_a6(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_in_a6(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 38); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_a6); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(rdata); UNUSED(add); @@ -399,8 +399,8 @@ digest_in_a6(ARGS_DIGEST) { isc_result_t result; dns_name_t name; - REQUIRE(rdata->type == 38); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_a6); + REQUIRE(rdata->rdclass == dns_rdataclass_in); dns_rdata_toregion(rdata, &r1); r2 = r1; @@ -423,8 +423,8 @@ digest_in_a6(ARGS_DIGEST) { static inline isc_boolean_t checkowner_in_a6(ARGS_CHECKOWNER) { - REQUIRE(type == 38); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_a6); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(rdclass); @@ -438,8 +438,8 @@ checknames_in_a6(ARGS_CHECKNAMES) { dns_name_t name; unsigned int prefixlen; - REQUIRE(rdata->type == 38); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_a6); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(owner); diff --git a/lib/dns/rdata/in_1/a_1.c b/lib/dns/rdata/in_1/a_1.c index fcdcaae0545b..3a5f4cb3c5a1 100644 --- a/lib/dns/rdata/in_1/a_1.c +++ b/lib/dns/rdata/in_1/a_1.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -34,8 +34,8 @@ fromtext_in_a(ARGS_FROMTEXT) { struct in_addr addr; isc_region_t region; - REQUIRE(type == 1); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_a); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(origin); @@ -59,8 +59,8 @@ static inline isc_result_t totext_in_a(ARGS_TOTEXT) { isc_region_t region; - REQUIRE(rdata->type == 1); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_a); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length == 4); UNUSED(tctx); @@ -74,8 +74,8 @@ fromwire_in_a(ARGS_FROMWIRE) { isc_region_t sregion; isc_region_t tregion; - REQUIRE(type == 1); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_a); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(dctx); @@ -99,8 +99,8 @@ static inline isc_result_t towire_in_a(ARGS_TOWIRE) { isc_region_t region; - REQUIRE(rdata->type == 1); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_a); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length == 4); UNUSED(cctx); @@ -120,8 +120,8 @@ compare_in_a(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 1); - REQUIRE(rdata1->rdclass == 1); + REQUIRE(rdata1->type == dns_rdatatype_a); + REQUIRE(rdata1->rdclass == dns_rdataclass_in); REQUIRE(rdata1->length == 4); REQUIRE(rdata2->length == 4); @@ -135,8 +135,8 @@ fromstruct_in_a(ARGS_FROMSTRUCT) { dns_rdata_in_a_t *a = source; isc_uint32_t n; - REQUIRE(type == 1); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_a); + REQUIRE(rdclass == dns_rdataclass_in); REQUIRE(source != NULL); REQUIRE(a->common.rdtype == type); REQUIRE(a->common.rdclass == rdclass); @@ -156,8 +156,8 @@ tostruct_in_a(ARGS_TOSTRUCT) { isc_uint32_t n; isc_region_t region; - REQUIRE(rdata->type == 1); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_a); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length == 4); UNUSED(mctx); @@ -178,16 +178,16 @@ freestruct_in_a(ARGS_FREESTRUCT) { dns_rdata_in_a_t *a = source; REQUIRE(source != NULL); - REQUIRE(a->common.rdtype == 1); - REQUIRE(a->common.rdclass == 1); + REQUIRE(a->common.rdtype == dns_rdatatype_a); + REQUIRE(a->common.rdclass == dns_rdataclass_in); UNUSED(a); } static inline isc_result_t additionaldata_in_a(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 1); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_a); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(rdata); UNUSED(add); @@ -200,8 +200,8 @@ static inline isc_result_t digest_in_a(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 1); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_a); + REQUIRE(rdata->rdclass == dns_rdataclass_in); dns_rdata_toregion(rdata, &r); @@ -210,21 +210,35 @@ digest_in_a(ARGS_DIGEST) { static inline isc_boolean_t checkowner_in_a(ARGS_CHECKOWNER) { + dns_name_t prefix, suffix; - REQUIRE(type == 1); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_a); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(rdclass); + /* + * Handle Active Diretory gc._msdcs.<forest> name. + */ + if (dns_name_countlabels(name) > 2U) { + dns_name_init(&prefix, NULL); + dns_name_init(&suffix, NULL); + dns_name_split(name, dns_name_countlabels(name) - 2, + &prefix, &suffix); + if (dns_name_equal(&gc_msdcs, &prefix) && + dns_name_ishostname(&suffix, ISC_FALSE)) + return (ISC_TRUE); + } + return (dns_name_ishostname(name, wildcard)); } static inline isc_boolean_t checknames_in_a(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 1); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_a); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/in_1/aaaa_28.c b/lib/dns/rdata/in_1/aaaa_28.c index 3f88c4db0f2f..f0a40ebbd747 100644 --- a/lib/dns/rdata/in_1/aaaa_28.c +++ b/lib/dns/rdata/in_1/aaaa_28.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -34,8 +34,8 @@ fromtext_in_aaaa(ARGS_FROMTEXT) { unsigned char addr[16]; isc_region_t region; - REQUIRE(type == 28); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_aaaa); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(origin); @@ -62,8 +62,8 @@ totext_in_aaaa(ARGS_TOTEXT) { UNUSED(tctx); - REQUIRE(rdata->type == 28); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_aaaa); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length == 16); dns_rdata_toregion(rdata, ®ion); @@ -75,8 +75,8 @@ fromwire_in_aaaa(ARGS_FROMWIRE) { isc_region_t sregion; isc_region_t tregion; - REQUIRE(type == 28); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_aaaa); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(dctx); @@ -102,8 +102,8 @@ towire_in_aaaa(ARGS_TOWIRE) { UNUSED(cctx); - REQUIRE(rdata->type == 28); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_aaaa); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length == 16); isc_buffer_availableregion(target, ®ion); @@ -121,8 +121,8 @@ compare_in_aaaa(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 28); - REQUIRE(rdata1->rdclass == 1); + REQUIRE(rdata1->type == dns_rdatatype_aaaa); + REQUIRE(rdata1->rdclass == dns_rdataclass_in); REQUIRE(rdata1->length == 16); REQUIRE(rdata2->length == 16); @@ -135,8 +135,8 @@ static inline isc_result_t fromstruct_in_aaaa(ARGS_FROMSTRUCT) { dns_rdata_in_aaaa_t *aaaa = source; - REQUIRE(type == 28); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_aaaa); + REQUIRE(rdclass == dns_rdataclass_in); REQUIRE(source != NULL); REQUIRE(aaaa->common.rdtype == type); REQUIRE(aaaa->common.rdclass == rdclass); @@ -152,8 +152,8 @@ tostruct_in_aaaa(ARGS_TOSTRUCT) { dns_rdata_in_aaaa_t *aaaa = target; isc_region_t r; - REQUIRE(rdata->type == 28); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_aaaa); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(target != NULL); REQUIRE(rdata->length == 16); @@ -175,16 +175,16 @@ freestruct_in_aaaa(ARGS_FREESTRUCT) { dns_rdata_in_aaaa_t *aaaa = source; REQUIRE(source != NULL); - REQUIRE(aaaa->common.rdclass == 1); - REQUIRE(aaaa->common.rdtype == 28); + REQUIRE(aaaa->common.rdclass == dns_rdataclass_in); + REQUIRE(aaaa->common.rdtype == dns_rdatatype_aaaa); UNUSED(aaaa); } static inline isc_result_t additionaldata_in_aaaa(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 28); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_aaaa); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(rdata); UNUSED(add); @@ -197,8 +197,8 @@ static inline isc_result_t digest_in_aaaa(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 28); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_aaaa); + REQUIRE(rdata->rdclass == dns_rdataclass_in); dns_rdata_toregion(rdata, &r); @@ -207,21 +207,35 @@ digest_in_aaaa(ARGS_DIGEST) { static inline isc_boolean_t checkowner_in_aaaa(ARGS_CHECKOWNER) { + dns_name_t prefix, suffix; - REQUIRE(type == 28); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_aaaa); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(rdclass); + /* + * Handle Active Diretory gc._msdcs.<forest> name. + */ + if (dns_name_countlabels(name) > 2U) { + dns_name_init(&prefix, NULL); + dns_name_init(&suffix, NULL); + dns_name_split(name, dns_name_countlabels(name) - 2, + &prefix, &suffix); + if (dns_name_equal(&gc_msdcs, &prefix) && + dns_name_ishostname(&suffix, ISC_FALSE)) + return (ISC_TRUE); + } + return (dns_name_ishostname(name, wildcard)); } static inline isc_boolean_t checknames_in_aaaa(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 28); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_aaaa); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/in_1/apl_42.c b/lib/dns/rdata/in_1/apl_42.c index 94133bae6296..bedd38ebaab8 100644 --- a/lib/dns/rdata/in_1/apl_42.c +++ b/lib/dns/rdata/in_1/apl_42.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007-2009, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007-2009, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -35,8 +35,8 @@ fromtext_in_apl(ARGS_FROMTEXT) { char *cp, *ap, *slash; int n; - REQUIRE(type == 42); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_apl); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(rdclass); @@ -120,8 +120,8 @@ totext_in_apl(ARGS_TOTEXT) { const char *sep = ""; int n; - REQUIRE(rdata->type == 42); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_apl); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(tctx); @@ -180,8 +180,8 @@ fromwire_in_apl(ARGS_FROMWIRE) { isc_uint8_t prefix; isc_uint8_t len; - REQUIRE(type == 42); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_apl); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(dctx); @@ -227,8 +227,8 @@ static inline isc_result_t towire_in_apl(ARGS_TOWIRE) { UNUSED(cctx); - REQUIRE(rdata->type == 42); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_apl); + REQUIRE(rdata->rdclass == dns_rdataclass_in); return (mem_tobuffer(target, rdata->data, rdata->length)); } @@ -240,8 +240,8 @@ compare_in_apl(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 42); - REQUIRE(rdata1->rdclass == 1); + REQUIRE(rdata1->type == dns_rdatatype_apl); + REQUIRE(rdata1->rdclass == dns_rdataclass_in); dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); @@ -253,8 +253,8 @@ fromstruct_in_apl(ARGS_FROMSTRUCT) { dns_rdata_in_apl_t *apl = source; isc_buffer_t b; - REQUIRE(type == 42); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_apl); + REQUIRE(rdclass == dns_rdataclass_in); REQUIRE(source != NULL); REQUIRE(apl->common.rdtype == type); REQUIRE(apl->common.rdclass == rdclass); @@ -271,8 +271,8 @@ tostruct_in_apl(ARGS_TOSTRUCT) { dns_rdata_in_apl_t *apl = target; isc_region_t r; - REQUIRE(rdata->type == 42); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_apl); + REQUIRE(rdata->rdclass == dns_rdataclass_in); apl->common.rdclass = rdata->rdclass; apl->common.rdtype = rdata->type; @@ -294,8 +294,8 @@ freestruct_in_apl(ARGS_FREESTRUCT) { dns_rdata_in_apl_t *apl = source; REQUIRE(source != NULL); - REQUIRE(apl->common.rdtype == 42); - REQUIRE(apl->common.rdclass == 1); + REQUIRE(apl->common.rdtype == dns_rdatatype_apl); + REQUIRE(apl->common.rdclass == dns_rdataclass_in); if (apl->mctx == NULL) return; @@ -309,8 +309,8 @@ dns_rdata_apl_first(dns_rdata_in_apl_t *apl) { isc_uint32_t length; REQUIRE(apl != NULL); - REQUIRE(apl->common.rdtype == 42); - REQUIRE(apl->common.rdclass == 1); + REQUIRE(apl->common.rdtype == dns_rdatatype_apl); + REQUIRE(apl->common.rdclass == dns_rdataclass_in); REQUIRE(apl->apl != NULL || apl->apl_len == 0); /* @@ -335,8 +335,8 @@ dns_rdata_apl_next(dns_rdata_in_apl_t *apl) { isc_uint32_t length; REQUIRE(apl != NULL); - REQUIRE(apl->common.rdtype == 42); - REQUIRE(apl->common.rdclass == 1); + REQUIRE(apl->common.rdtype == dns_rdatatype_apl); + REQUIRE(apl->common.rdclass == dns_rdataclass_in); REQUIRE(apl->apl != NULL || apl->apl_len == 0); /* @@ -367,8 +367,8 @@ dns_rdata_apl_current(dns_rdata_in_apl_t *apl, dns_rdata_apl_ent_t *ent) { isc_uint32_t length; REQUIRE(apl != NULL); - REQUIRE(apl->common.rdtype == 42); - REQUIRE(apl->common.rdclass == 1); + REQUIRE(apl->common.rdtype == dns_rdatatype_apl); + REQUIRE(apl->common.rdclass == dns_rdataclass_in); REQUIRE(ent != NULL); REQUIRE(apl->apl != NULL || apl->apl_len == 0); REQUIRE(apl->offset <= apl->apl_len); @@ -401,8 +401,8 @@ dns_rdata_apl_current(dns_rdata_in_apl_t *apl, dns_rdata_apl_ent_t *ent) { static inline isc_result_t additionaldata_in_apl(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 42); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_apl); + REQUIRE(rdata->rdclass == dns_rdataclass_in); (void)add; (void)arg; @@ -414,8 +414,8 @@ static inline isc_result_t digest_in_apl(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 42); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_apl); + REQUIRE(rdata->rdclass == dns_rdataclass_in); dns_rdata_toregion(rdata, &r); @@ -425,8 +425,8 @@ digest_in_apl(ARGS_DIGEST) { static inline isc_boolean_t checkowner_in_apl(ARGS_CHECKOWNER) { - REQUIRE(type == 42); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_apl); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(name); UNUSED(type); @@ -440,8 +440,8 @@ checkowner_in_apl(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_in_apl(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 42); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_apl); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/in_1/dhcid_49.c b/lib/dns/rdata/in_1/dhcid_49.c index 7575da0d1930..261e41ea8acb 100644 --- a/lib/dns/rdata/in_1/dhcid_49.c +++ b/lib/dns/rdata/in_1/dhcid_49.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007, 2009, 2011, 2012 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2006, 2007, 2009, 2011, 2012, 2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -26,8 +26,8 @@ static inline isc_result_t fromtext_in_dhcid(ARGS_FROMTEXT) { - REQUIRE(type == 49); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_dhcid); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(rdclass); @@ -44,8 +44,8 @@ totext_in_dhcid(ARGS_TOTEXT) { char buf[sizeof(" ; 64000 255 64000")]; size_t n; - REQUIRE(rdata->type == 49); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_dhcid); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, &sr); @@ -74,8 +74,8 @@ static inline isc_result_t fromwire_in_dhcid(ARGS_FROMWIRE) { isc_region_t sr; - REQUIRE(type == 49); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_dhcid); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(rdclass); @@ -94,8 +94,8 @@ static inline isc_result_t towire_in_dhcid(ARGS_TOWIRE) { isc_region_t sr; - REQUIRE(rdata->type == 49); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_dhcid); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -111,8 +111,8 @@ compare_in_dhcid(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 49); - REQUIRE(rdata1->rdclass == 1); + REQUIRE(rdata1->type == dns_rdatatype_dhcid); + REQUIRE(rdata1->rdclass == dns_rdataclass_in); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -125,8 +125,8 @@ static inline isc_result_t fromstruct_in_dhcid(ARGS_FROMSTRUCT) { dns_rdata_in_dhcid_t *dhcid = source; - REQUIRE(type == 49); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_dhcid); + REQUIRE(rdclass == dns_rdataclass_in); REQUIRE(source != NULL); REQUIRE(dhcid->common.rdtype == type); REQUIRE(dhcid->common.rdclass == rdclass); @@ -143,8 +143,8 @@ tostruct_in_dhcid(ARGS_TOSTRUCT) { dns_rdata_in_dhcid_t *dhcid = target; isc_region_t region; - REQUIRE(rdata->type == 49); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_dhcid); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -167,8 +167,8 @@ freestruct_in_dhcid(ARGS_FREESTRUCT) { dns_rdata_in_dhcid_t *dhcid = source; REQUIRE(dhcid != NULL); - REQUIRE(dhcid->common.rdtype == 49); - REQUIRE(dhcid->common.rdclass == 1); + REQUIRE(dhcid->common.rdtype == dns_rdatatype_dhcid); + REQUIRE(dhcid->common.rdclass == dns_rdataclass_in); if (dhcid->mctx == NULL) return; @@ -180,8 +180,8 @@ freestruct_in_dhcid(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_in_dhcid(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 49); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_dhcid); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(rdata); UNUSED(add); @@ -194,8 +194,8 @@ static inline isc_result_t digest_in_dhcid(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 49); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_dhcid); + REQUIRE(rdata->rdclass == dns_rdataclass_in); dns_rdata_toregion(rdata, &r); @@ -205,8 +205,8 @@ digest_in_dhcid(ARGS_DIGEST) { static inline isc_boolean_t checkowner_in_dhcid(ARGS_CHECKOWNER) { - REQUIRE(type == 49); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_dhcid); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(name); UNUSED(type); @@ -219,8 +219,8 @@ checkowner_in_dhcid(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_in_dhcid(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 49); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_dhcid); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/in_1/kx_36.c b/lib/dns/rdata/in_1/kx_36.c index fbe3b71deaa0..8b911eb07c2a 100644 --- a/lib/dns/rdata/in_1/kx_36.c +++ b/lib/dns/rdata/in_1/kx_36.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -32,8 +32,8 @@ fromtext_in_kx(ARGS_FROMTEXT) { dns_name_t name; isc_buffer_t buffer; - REQUIRE(type == 36); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_kx); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(rdclass); @@ -63,8 +63,8 @@ totext_in_kx(ARGS_TOTEXT) { char buf[sizeof("64000")]; unsigned short num; - REQUIRE(rdata->type == 36); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_kx); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -88,8 +88,8 @@ fromwire_in_kx(ARGS_FROMWIRE) { dns_name_t name; isc_region_t sregion; - REQUIRE(type == 36); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_kx); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(rdclass); @@ -112,8 +112,8 @@ towire_in_kx(ARGS_TOWIRE) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 36); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_kx); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); @@ -137,8 +137,8 @@ compare_in_kx(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 36); - REQUIRE(rdata1->rdclass == 1); + REQUIRE(rdata1->type == dns_rdatatype_kx); + REQUIRE(rdata1->rdclass == dns_rdataclass_in); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -166,8 +166,8 @@ fromstruct_in_kx(ARGS_FROMSTRUCT) { dns_rdata_in_kx_t *kx = source; isc_region_t region; - REQUIRE(type == 36); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_kx); + REQUIRE(rdclass == dns_rdataclass_in); REQUIRE(source != NULL); REQUIRE(kx->common.rdtype == type); REQUIRE(kx->common.rdclass == rdclass); @@ -186,8 +186,8 @@ tostruct_in_kx(ARGS_TOSTRUCT) { dns_rdata_in_kx_t *kx = target; dns_name_t name; - REQUIRE(rdata->type == 36); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_kx); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -213,8 +213,8 @@ freestruct_in_kx(ARGS_FREESTRUCT) { dns_rdata_in_kx_t *kx = source; REQUIRE(source != NULL); - REQUIRE(kx->common.rdclass == 1); - REQUIRE(kx->common.rdtype == 36); + REQUIRE(kx->common.rdclass == dns_rdataclass_in); + REQUIRE(kx->common.rdtype == dns_rdatatype_kx); if (kx->mctx == NULL) return; @@ -229,8 +229,8 @@ additionaldata_in_kx(ARGS_ADDLDATA) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 36); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_kx); + REQUIRE(rdata->rdclass == dns_rdataclass_in); dns_name_init(&name, offsets); dns_rdata_toregion(rdata, ®ion); @@ -245,8 +245,8 @@ digest_in_kx(ARGS_DIGEST) { isc_region_t r1, r2; dns_name_t name; - REQUIRE(rdata->type == 36); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_kx); + REQUIRE(rdata->rdclass == dns_rdataclass_in); dns_rdata_toregion(rdata, &r1); r2 = r1; @@ -261,8 +261,8 @@ digest_in_kx(ARGS_DIGEST) { static inline isc_boolean_t checkowner_in_kx(ARGS_CHECKOWNER) { - REQUIRE(type == 36); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_kx); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(name); UNUSED(type); @@ -275,8 +275,8 @@ checkowner_in_kx(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_in_kx(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 36); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_kx); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/in_1/nsap-ptr_23.c b/lib/dns/rdata/in_1/nsap-ptr_23.c index 78df645a2a1f..d8b43f2edca4 100644 --- a/lib/dns/rdata/in_1/nsap-ptr_23.c +++ b/lib/dns/rdata/in_1/nsap-ptr_23.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -32,8 +32,8 @@ fromtext_in_nsap_ptr(ARGS_FROMTEXT) { dns_name_t name; isc_buffer_t buffer; - REQUIRE(type == 23); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_nsap_ptr); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(rdclass); @@ -56,8 +56,8 @@ totext_in_nsap_ptr(ARGS_TOTEXT) { dns_name_t prefix; isc_boolean_t sub; - REQUIRE(rdata->type == 23); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_nsap_ptr); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -75,8 +75,8 @@ static inline isc_result_t fromwire_in_nsap_ptr(ARGS_FROMWIRE) { dns_name_t name; - REQUIRE(type == 23); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_nsap_ptr); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(rdclass); @@ -93,8 +93,8 @@ towire_in_nsap_ptr(ARGS_TOWIRE) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 23); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_nsap_ptr); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); @@ -114,8 +114,8 @@ compare_in_nsap_ptr(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 23); - REQUIRE(rdata1->rdclass == 1); + REQUIRE(rdata1->type == dns_rdatatype_nsap_ptr); + REQUIRE(rdata1->rdclass == dns_rdataclass_in); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -136,8 +136,8 @@ fromstruct_in_nsap_ptr(ARGS_FROMSTRUCT) { dns_rdata_in_nsap_ptr_t *nsap_ptr = source; isc_region_t region; - REQUIRE(type == 23); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_nsap_ptr); + REQUIRE(rdclass == dns_rdataclass_in); REQUIRE(source != NULL); REQUIRE(nsap_ptr->common.rdtype == type); REQUIRE(nsap_ptr->common.rdclass == rdclass); @@ -155,8 +155,8 @@ tostruct_in_nsap_ptr(ARGS_TOSTRUCT) { dns_rdata_in_nsap_ptr_t *nsap_ptr = target; dns_name_t name; - REQUIRE(rdata->type == 23); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_nsap_ptr); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -178,8 +178,8 @@ freestruct_in_nsap_ptr(ARGS_FREESTRUCT) { dns_rdata_in_nsap_ptr_t *nsap_ptr = source; REQUIRE(source != NULL); - REQUIRE(nsap_ptr->common.rdclass == 1); - REQUIRE(nsap_ptr->common.rdtype == 23); + REQUIRE(nsap_ptr->common.rdclass == dns_rdataclass_in); + REQUIRE(nsap_ptr->common.rdtype == dns_rdatatype_nsap_ptr); if (nsap_ptr->mctx == NULL) return; @@ -190,8 +190,8 @@ freestruct_in_nsap_ptr(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_in_nsap_ptr(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 23); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_nsap_ptr); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(rdata); UNUSED(add); @@ -205,8 +205,8 @@ digest_in_nsap_ptr(ARGS_DIGEST) { isc_region_t r; dns_name_t name; - REQUIRE(rdata->type == 23); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_nsap_ptr); + REQUIRE(rdata->rdclass == dns_rdataclass_in); dns_rdata_toregion(rdata, &r); dns_name_init(&name, NULL); @@ -218,8 +218,8 @@ digest_in_nsap_ptr(ARGS_DIGEST) { static inline isc_boolean_t checkowner_in_nsap_ptr(ARGS_CHECKOWNER) { - REQUIRE(type == 23); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_nsap_ptr); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(name); UNUSED(type); @@ -232,8 +232,8 @@ checkowner_in_nsap_ptr(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_in_nsap_ptr(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 23); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_nsap_ptr); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/in_1/nsap_22.c b/lib/dns/rdata/in_1/nsap_22.c index 66129fe0fdfa..d0e460e85fc8 100644 --- a/lib/dns/rdata/in_1/nsap_22.c +++ b/lib/dns/rdata/in_1/nsap_22.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009, 2013 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2013, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -31,11 +31,12 @@ fromtext_in_nsap(ARGS_FROMTEXT) { isc_token_t token; isc_textregion_t *sr; int n; - int digits; + isc_boolean_t valid = ISC_FALSE; + int digits = 0; unsigned char c = 0; - REQUIRE(type == 22); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_nsap); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(origin); @@ -52,7 +53,6 @@ fromtext_in_nsap(ARGS_FROMTEXT) { if (sr->base[0] != '0' || (sr->base[1] != 'x' && sr->base[1] != 'X')) RETTOK(DNS_R_SYNTAX); isc_textregion_consume(sr, 2); - digits = 0; while (sr->length > 0) { if (sr->base[0] == '.') { isc_textregion_consume(sr, 1); @@ -64,11 +64,13 @@ fromtext_in_nsap(ARGS_FROMTEXT) { c += n; if (++digits == 2) { RETERR(mem_tobuffer(target, &c, 1)); + valid = ISC_TRUE; digits = 0; + c = 0; } isc_textregion_consume(sr, 1); } - if (digits) + if (digits != 0 || !valid) RETTOK(ISC_R_UNEXPECTEDEND); return (ISC_R_SUCCESS); } @@ -78,8 +80,8 @@ totext_in_nsap(ARGS_TOTEXT) { isc_region_t region; char buf[sizeof("xx")]; - REQUIRE(rdata->type == 22); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_nsap); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length != 0); UNUSED(tctx); @@ -98,8 +100,8 @@ static inline isc_result_t fromwire_in_nsap(ARGS_FROMWIRE) { isc_region_t region; - REQUIRE(type == 22); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_nsap); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(dctx); @@ -117,8 +119,8 @@ fromwire_in_nsap(ARGS_FROMWIRE) { static inline isc_result_t towire_in_nsap(ARGS_TOWIRE) { - REQUIRE(rdata->type == 22); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_nsap); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length != 0); UNUSED(cctx); @@ -133,8 +135,8 @@ compare_in_nsap(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 22); - REQUIRE(rdata1->rdclass == 1); + REQUIRE(rdata1->type == dns_rdatatype_nsap); + REQUIRE(rdata1->rdclass == dns_rdataclass_in); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -147,8 +149,8 @@ static inline isc_result_t fromstruct_in_nsap(ARGS_FROMSTRUCT) { dns_rdata_in_nsap_t *nsap = source; - REQUIRE(type == 22); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_nsap); + REQUIRE(rdclass == dns_rdataclass_in); REQUIRE(source != NULL); REQUIRE(nsap->common.rdtype == type); REQUIRE(nsap->common.rdclass == rdclass); @@ -165,8 +167,8 @@ tostruct_in_nsap(ARGS_TOSTRUCT) { dns_rdata_in_nsap_t *nsap = target; isc_region_t r; - REQUIRE(rdata->type == 22); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_nsap); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -189,8 +191,8 @@ freestruct_in_nsap(ARGS_FREESTRUCT) { dns_rdata_in_nsap_t *nsap = source; REQUIRE(source != NULL); - REQUIRE(nsap->common.rdclass == 1); - REQUIRE(nsap->common.rdtype == 22); + REQUIRE(nsap->common.rdclass == dns_rdataclass_in); + REQUIRE(nsap->common.rdtype == dns_rdatatype_nsap); if (nsap->mctx == NULL) return; @@ -202,8 +204,8 @@ freestruct_in_nsap(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_in_nsap(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 22); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_nsap); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(rdata); UNUSED(add); @@ -216,8 +218,8 @@ static inline isc_result_t digest_in_nsap(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 22); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_nsap); + REQUIRE(rdata->rdclass == dns_rdataclass_in); dns_rdata_toregion(rdata, &r); @@ -227,8 +229,8 @@ digest_in_nsap(ARGS_DIGEST) { static inline isc_boolean_t checkowner_in_nsap(ARGS_CHECKOWNER) { - REQUIRE(type == 22); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_nsap); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(name); UNUSED(type); @@ -241,8 +243,8 @@ checkowner_in_nsap(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_in_nsap(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 22); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_nsap); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/in_1/px_26.c b/lib/dns/rdata/in_1/px_26.c index a4111ad5bb76..4cf0ae418ac0 100644 --- a/lib/dns/rdata/in_1/px_26.c +++ b/lib/dns/rdata/in_1/px_26.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -32,8 +32,8 @@ fromtext_in_px(ARGS_FROMTEXT) { dns_name_t name; isc_buffer_t buffer; - REQUIRE(type == 26); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_px); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(rdclass); @@ -79,8 +79,8 @@ totext_in_px(ARGS_TOTEXT) { char buf[sizeof("64000")]; unsigned short num; - REQUIRE(rdata->type == 26); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_px); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -118,8 +118,8 @@ fromwire_in_px(ARGS_FROMWIRE) { dns_name_t name; isc_region_t sregion; - REQUIRE(type == 26); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_px); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(rdclass); @@ -154,8 +154,8 @@ towire_in_px(ARGS_TOWIRE) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 26); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_px); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); @@ -192,8 +192,8 @@ compare_in_px(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 26); - REQUIRE(rdata1->rdclass == 1); + REQUIRE(rdata1->type == dns_rdatatype_px); + REQUIRE(rdata1->rdclass == dns_rdataclass_in); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -231,8 +231,8 @@ fromstruct_in_px(ARGS_FROMSTRUCT) { dns_rdata_in_px_t *px = source; isc_region_t region; - REQUIRE(type == 26); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_px); + REQUIRE(rdclass == dns_rdataclass_in); REQUIRE(source != NULL); REQUIRE(px->common.rdtype == type); REQUIRE(px->common.rdclass == rdclass); @@ -254,8 +254,8 @@ tostruct_in_px(ARGS_TOSTRUCT) { isc_region_t region; isc_result_t result; - REQUIRE(rdata->type == 26); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_px); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -293,8 +293,8 @@ freestruct_in_px(ARGS_FREESTRUCT) { dns_rdata_in_px_t *px = source; REQUIRE(source != NULL); - REQUIRE(px->common.rdclass == 1); - REQUIRE(px->common.rdtype == 26); + REQUIRE(px->common.rdclass == dns_rdataclass_in); + REQUIRE(px->common.rdtype == dns_rdatatype_px); if (px->mctx == NULL) return; @@ -306,8 +306,8 @@ freestruct_in_px(ARGS_FREESTRUCT) { static inline isc_result_t additionaldata_in_px(ARGS_ADDLDATA) { - REQUIRE(rdata->type == 26); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_px); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(rdata); UNUSED(add); @@ -322,8 +322,8 @@ digest_in_px(ARGS_DIGEST) { dns_name_t name; isc_result_t result; - REQUIRE(rdata->type == 26); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_px); + REQUIRE(rdata->rdclass == dns_rdataclass_in); dns_rdata_toregion(rdata, &r1); r2 = r1; @@ -347,8 +347,8 @@ digest_in_px(ARGS_DIGEST) { static inline isc_boolean_t checkowner_in_px(ARGS_CHECKOWNER) { - REQUIRE(type == 26); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_px); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(name); UNUSED(type); @@ -361,8 +361,8 @@ checkowner_in_px(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_in_px(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 26); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_px); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/rdata/in_1/srv_33.c b/lib/dns/rdata/in_1/srv_33.c index ea4f3edbcdef..b97d410272f6 100644 --- a/lib/dns/rdata/in_1/srv_33.c +++ b/lib/dns/rdata/in_1/srv_33.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -33,8 +33,8 @@ fromtext_in_srv(ARGS_FROMTEXT) { isc_buffer_t buffer; isc_boolean_t ok; - REQUIRE(type == 33); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_srv); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(rdclass); @@ -95,8 +95,8 @@ totext_in_srv(ARGS_TOTEXT) { char buf[sizeof("64000")]; unsigned short num; - REQUIRE(rdata->type == 33); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_srv); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); @@ -143,8 +143,8 @@ fromwire_in_srv(ARGS_FROMWIRE) { dns_name_t name; isc_region_t sr; - REQUIRE(type == 33); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_srv); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(rdclass); @@ -174,7 +174,7 @@ towire_in_srv(ARGS_TOWIRE) { dns_offsets_t offsets; isc_region_t sr; - REQUIRE(rdata->type == 33); + REQUIRE(rdata->type == dns_rdatatype_srv); REQUIRE(rdata->length != 0); dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); @@ -203,8 +203,8 @@ compare_in_srv(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 33); - REQUIRE(rdata1->rdclass == 1); + REQUIRE(rdata1->type == dns_rdatatype_srv); + REQUIRE(rdata1->rdclass == dns_rdataclass_in); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -238,8 +238,8 @@ fromstruct_in_srv(ARGS_FROMSTRUCT) { dns_rdata_in_srv_t *srv = source; isc_region_t region; - REQUIRE(type == 33); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_srv); + REQUIRE(rdclass == dns_rdataclass_in); REQUIRE(source != NULL); REQUIRE(srv->common.rdtype == type); REQUIRE(srv->common.rdclass == rdclass); @@ -260,8 +260,8 @@ tostruct_in_srv(ARGS_TOSTRUCT) { dns_rdata_in_srv_t *srv = target; dns_name_t name; - REQUIRE(rdata->rdclass == 1); - REQUIRE(rdata->type == 33); + REQUIRE(rdata->rdclass == dns_rdataclass_in); + REQUIRE(rdata->type == dns_rdatatype_srv); REQUIRE(target != NULL); REQUIRE(rdata->length != 0); @@ -289,8 +289,8 @@ freestruct_in_srv(ARGS_FREESTRUCT) { dns_rdata_in_srv_t *srv = source; REQUIRE(source != NULL); - REQUIRE(srv->common.rdclass == 1); - REQUIRE(srv->common.rdtype == 33); + REQUIRE(srv->common.rdclass == dns_rdataclass_in); + REQUIRE(srv->common.rdtype == dns_rdatatype_srv); if (srv->mctx == NULL) return; @@ -305,8 +305,8 @@ additionaldata_in_srv(ARGS_ADDLDATA) { dns_offsets_t offsets; isc_region_t region; - REQUIRE(rdata->type == 33); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_srv); + REQUIRE(rdata->rdclass == dns_rdataclass_in); dns_name_init(&name, offsets); dns_rdata_toregion(rdata, ®ion); @@ -321,8 +321,8 @@ digest_in_srv(ARGS_DIGEST) { isc_region_t r1, r2; dns_name_t name; - REQUIRE(rdata->type == 33); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_srv); + REQUIRE(rdata->rdclass == dns_rdataclass_in); dns_rdata_toregion(rdata, &r1); r2 = r1; @@ -337,8 +337,8 @@ digest_in_srv(ARGS_DIGEST) { static inline isc_boolean_t checkowner_in_srv(ARGS_CHECKOWNER) { - REQUIRE(type == 33); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_srv); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(name); UNUSED(type); @@ -353,8 +353,8 @@ checknames_in_srv(ARGS_CHECKNAMES) { isc_region_t region; dns_name_t name; - REQUIRE(rdata->type == 33); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_srv); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(owner); diff --git a/lib/dns/rdata/in_1/wks_11.c b/lib/dns/rdata/in_1/wks_11.c index 4587c813afab..0eb9504c89c3 100644 --- a/lib/dns/rdata/in_1/wks_11.c +++ b/lib/dns/rdata/in_1/wks_11.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007, 2009, 2011-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2009, 2011-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -77,8 +77,8 @@ fromtext_in_wks(ARGS_FROMTEXT) { char service[32]; int i; - REQUIRE(type == 11); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_wks); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(origin); @@ -171,8 +171,8 @@ totext_in_wks(ARGS_TOTEXT) { UNUSED(tctx); - REQUIRE(rdata->type == 11); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_wks); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length >= 5); dns_rdata_toregion(rdata, &sr); @@ -204,8 +204,8 @@ fromwire_in_wks(ARGS_FROMWIRE) { isc_region_t sr; isc_region_t tr; - REQUIRE(type == 11); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_wks); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(dctx); @@ -235,8 +235,8 @@ towire_in_wks(ARGS_TOWIRE) { UNUSED(cctx); - REQUIRE(rdata->type == 11); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_wks); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, &sr); @@ -250,8 +250,8 @@ compare_in_wks(ARGS_COMPARE) { REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); - REQUIRE(rdata1->type == 11); - REQUIRE(rdata1->rdclass == 1); + REQUIRE(rdata1->type == dns_rdatatype_wks); + REQUIRE(rdata1->rdclass == dns_rdataclass_in); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); @@ -265,8 +265,8 @@ fromstruct_in_wks(ARGS_FROMSTRUCT) { dns_rdata_in_wks_t *wks = source; isc_uint32_t a; - REQUIRE(type == 11); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_wks); + REQUIRE(rdclass == dns_rdataclass_in); REQUIRE(source != NULL); REQUIRE(wks->common.rdtype == type); REQUIRE(wks->common.rdclass == rdclass); @@ -288,8 +288,8 @@ tostruct_in_wks(ARGS_TOSTRUCT) { isc_uint32_t n; isc_region_t region; - REQUIRE(rdata->type == 11); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_wks); + REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length != 0); wks->common.rdclass = rdata->rdclass; @@ -315,8 +315,8 @@ freestruct_in_wks(ARGS_FREESTRUCT) { dns_rdata_in_wks_t *wks = source; REQUIRE(source != NULL); - REQUIRE(wks->common.rdtype == 11); - REQUIRE(wks->common.rdclass == 1); + REQUIRE(wks->common.rdtype == dns_rdatatype_wks); + REQUIRE(wks->common.rdclass == dns_rdataclass_in); if (wks->mctx == NULL) return; @@ -332,8 +332,8 @@ additionaldata_in_wks(ARGS_ADDLDATA) { UNUSED(add); UNUSED(arg); - REQUIRE(rdata->type == 11); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_wks); + REQUIRE(rdata->rdclass == dns_rdataclass_in); return (ISC_R_SUCCESS); } @@ -342,8 +342,8 @@ static inline isc_result_t digest_in_wks(ARGS_DIGEST) { isc_region_t r; - REQUIRE(rdata->type == 11); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_wks); + REQUIRE(rdata->rdclass == dns_rdataclass_in); dns_rdata_toregion(rdata, &r); @@ -353,8 +353,8 @@ digest_in_wks(ARGS_DIGEST) { static inline isc_boolean_t checkowner_in_wks(ARGS_CHECKOWNER) { - REQUIRE(type == 11); - REQUIRE(rdclass == 1); + REQUIRE(type == dns_rdatatype_wks); + REQUIRE(rdclass == dns_rdataclass_in); UNUSED(type); UNUSED(rdclass); @@ -365,8 +365,8 @@ checkowner_in_wks(ARGS_CHECKOWNER) { static inline isc_boolean_t checknames_in_wks(ARGS_CHECKNAMES) { - REQUIRE(rdata->type == 11); - REQUIRE(rdata->rdclass == 1); + REQUIRE(rdata->type == dns_rdatatype_wks); + REQUIRE(rdata->rdclass == dns_rdataclass_in); UNUSED(rdata); UNUSED(owner); diff --git a/lib/dns/request.c b/lib/dns/request.c index 59e166eb0257..71707586f1e5 100644 --- a/lib/dns/request.c +++ b/lib/dns/request.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -144,7 +144,7 @@ dns_requestmgr_create(isc_mem_t *mctx, dns_requestmgr_t **requestmgrp) { dns_requestmgr_t *requestmgr; - isc_socket_t *socket; + isc_socket_t *sock; isc_result_t result; int i; unsigned int dispattr; @@ -156,7 +156,7 @@ dns_requestmgr_create(isc_mem_t *mctx, REQUIRE(socketmgr != NULL); REQUIRE(taskmgr != NULL); REQUIRE(dispatchmgr != NULL); - UNUSED(socket); + UNUSED(sock); if (dispatchv4 != NULL) { dispattr = dns_dispatch_getattributes(dispatchv4); REQUIRE((dispattr & DNS_DISPATCHATTR_UDP) != 0); @@ -426,20 +426,20 @@ mgr_gethash(dns_requestmgr_t *requestmgr) { static inline isc_result_t req_send(dns_request_t *request, isc_task_t *task, isc_sockaddr_t *address) { isc_region_t r; - isc_socket_t *socket; + isc_socket_t *sock; isc_result_t result; req_log(ISC_LOG_DEBUG(3), "req_send: request %p", request); REQUIRE(VALID_REQUEST(request)); - socket = req_getsocket(request); + sock = req_getsocket(request); isc_buffer_usedregion(request->query, &r); /* * We could connect the socket when we are using an exclusive dispatch * as we do in resolver.c, but we prefer implementation simplicity * at this moment. */ - result = isc_socket_sendto(socket, &r, task, req_senddone, + result = isc_socket_sendto(sock, &r, task, req_senddone, request, address, NULL); if (result == ISC_R_SUCCESS) request->flags |= DNS_REQUEST_F_SENDING; @@ -513,25 +513,25 @@ create_tcp_dispatch(dns_requestmgr_t *requestmgr, isc_sockaddr_t *srcaddr, isc_sockaddr_t *destaddr, dns_dispatch_t **dispatchp) { isc_result_t result; - isc_socket_t *socket = NULL; + isc_socket_t *sock = NULL; isc_sockaddr_t src; unsigned int attrs; isc_sockaddr_t bind_any; result = isc_socket_create(requestmgr->socketmgr, isc_sockaddr_pf(destaddr), - isc_sockettype_tcp, &socket); + isc_sockettype_tcp, &sock); if (result != ISC_R_SUCCESS) return (result); #ifndef BROKEN_TCP_BIND_BEFORE_CONNECT if (srcaddr == NULL) { isc_sockaddr_anyofpf(&bind_any, isc_sockaddr_pf(destaddr)); - result = isc_socket_bind(socket, &bind_any, 0); + result = isc_socket_bind(sock, &bind_any, 0); } else { src = *srcaddr; isc_sockaddr_setport(&src, 0); - result = isc_socket_bind(socket, &src, 0); + result = isc_socket_bind(sock, &src, 0); } if (result != ISC_R_SUCCESS) goto cleanup; @@ -545,11 +545,11 @@ create_tcp_dispatch(dns_requestmgr_t *requestmgr, isc_sockaddr_t *srcaddr, attrs |= DNS_DISPATCHATTR_IPV6; attrs |= DNS_DISPATCHATTR_MAKEQUERY; result = dns_dispatch_createtcp(requestmgr->dispatchmgr, - socket, requestmgr->taskmgr, + sock, requestmgr->taskmgr, 4096, 2, 1, 1, 3, attrs, dispatchp); cleanup: - isc_socket_detach(&socket); + isc_socket_detach(&sock); return (result); } @@ -680,7 +680,7 @@ dns_request_createraw3(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf, { dns_request_t *request = NULL; isc_task_t *tclone = NULL; - isc_socket_t *socket = NULL; + isc_socket_t *sock = NULL; isc_result_t result; isc_mem_t *mctx; dns_messageid_t id; @@ -764,8 +764,8 @@ dns_request_createraw3(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf, if (result != ISC_R_SUCCESS) goto cleanup; - socket = req_getsocket(request); - INSIST(socket != NULL); + sock = req_getsocket(request); + INSIST(sock != NULL); result = isc_buffer_allocate(mctx, &request->query, r.length + (tcp ? 2 : 0)); @@ -801,7 +801,7 @@ dns_request_createraw3(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf, request->destaddr = *destaddr; if (tcp) { - result = isc_socket_connect(socket, destaddr, task, + result = isc_socket_connect(sock, destaddr, task, req_connected, request); if (result != ISC_R_SUCCESS) goto unlink; @@ -886,12 +886,12 @@ dns_request_createvia3(dns_requestmgr_t *requestmgr, dns_message_t *message, { dns_request_t *request = NULL; isc_task_t *tclone = NULL; - isc_socket_t *socket = NULL; + isc_socket_t *sock = NULL; isc_result_t result; isc_mem_t *mctx; dns_messageid_t id; isc_boolean_t tcp; - isc_boolean_t setkey = ISC_TRUE; + isc_boolean_t settsigkey = ISC_TRUE; REQUIRE(VALID_REQUESTMGR(requestmgr)); REQUIRE(message != NULL); @@ -960,11 +960,11 @@ dns_request_createvia3(dns_requestmgr_t *requestmgr, dns_message_t *message, requestmgr->socketmgr); if (result != ISC_R_SUCCESS) goto cleanup; - socket = req_getsocket(request); - INSIST(socket != NULL); + sock = req_getsocket(request); + INSIST(sock != NULL); message->id = id; - if (setkey) { + if (settsigkey) { result = dns_message_settsigkey(message, request->tsigkey); if (result != ISC_R_SUCCESS) goto cleanup; @@ -978,9 +978,9 @@ dns_request_createvia3(dns_requestmgr_t *requestmgr, dns_message_t *message, dns_message_renderreset(message); dns_dispatch_removeresponse(&request->dispentry, NULL); dns_dispatch_detach(&request->dispatch); - socket = NULL; + sock = NULL; options |= DNS_REQUESTOPT_TCP; - setkey = ISC_FALSE; + settsigkey = ISC_FALSE; goto use_tcp; } if (result != ISC_R_SUCCESS) @@ -1007,7 +1007,7 @@ dns_request_createvia3(dns_requestmgr_t *requestmgr, dns_message_t *message, request->destaddr = *destaddr; if (tcp) { - result = isc_socket_connect(socket, destaddr, task, + result = isc_socket_connect(sock, destaddr, task, req_connected, request); if (result != ISC_R_SUCCESS) goto unlink; @@ -1250,16 +1250,16 @@ dns_request_destroy(dns_request_t **requestp) { static isc_socket_t * req_getsocket(dns_request_t *request) { unsigned int dispattr; - isc_socket_t *socket; + isc_socket_t *sock; dispattr = dns_dispatch_getattributes(request->dispatch); if ((dispattr & DNS_DISPATCHATTR_EXCLUSIVE) != 0) { INSIST(request->dispentry != NULL); - socket = dns_dispatch_getentrysocket(request->dispentry); + sock = dns_dispatch_getentrysocket(request->dispentry); } else - socket = dns_dispatch_getsocket(request->dispatch); + sock = dns_dispatch_getsocket(request->dispatch); - return (socket); + return (sock); } static void @@ -1460,7 +1460,7 @@ req_destroy(dns_request_t *request) { */ static void req_cancel(dns_request_t *request) { - isc_socket_t *socket; + isc_socket_t *sock; unsigned int dispattr; REQUIRE(VALID_REQUEST(request)); @@ -1475,19 +1475,19 @@ req_cancel(dns_request_t *request) { if (request->timer != NULL) isc_timer_detach(&request->timer); dispattr = dns_dispatch_getattributes(request->dispatch); - socket = NULL; + sock = NULL; if (DNS_REQUEST_CONNECTING(request) || DNS_REQUEST_SENDING(request)) { if ((dispattr & DNS_DISPATCHATTR_EXCLUSIVE) != 0) { if (request->dispentry != NULL) { - socket = dns_dispatch_getentrysocket( + sock = dns_dispatch_getentrysocket( request->dispentry); } } else - socket = dns_dispatch_getsocket(request->dispatch); - if (DNS_REQUEST_CONNECTING(request) && socket != NULL) - isc_socket_cancel(socket, NULL, ISC_SOCKCANCEL_CONNECT); - if (DNS_REQUEST_SENDING(request) && socket != NULL) - isc_socket_cancel(socket, NULL, ISC_SOCKCANCEL_SEND); + sock = dns_dispatch_getsocket(request->dispatch); + if (DNS_REQUEST_CONNECTING(request) && sock != NULL) + isc_socket_cancel(sock, NULL, ISC_SOCKCANCEL_CONNECT); + if (DNS_REQUEST_SENDING(request) && sock != NULL) + isc_socket_cancel(sock, NULL, ISC_SOCKCANCEL_SEND); } if (request->dispentry != NULL) dns_dispatch_removeresponse(&request->dispentry, NULL); diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index d33c43ed82af..1aaca2b0620a 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,8 +15,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id$ */ - /*! \file */ #include <config.h> @@ -64,8 +62,7 @@ #include <dns/tsig.h> #include <dns/validator.h> -#define DNS_RESOLVER_TRACE -#ifdef DNS_RESOLVER_TRACE +#ifdef WANT_QUERYTRACE #define RTRACE(m) isc_log_write(dns_lctx, \ DNS_LOGCATEGORY_RESOLVER, \ DNS_LOGMODULE_RESOLVER, \ @@ -76,11 +73,13 @@ DNS_LOGMODULE_RESOLVER, \ ISC_LOG_DEBUG(3), \ "res %p: %s", (r), (m)) -#define FCTXTRACE(m) isc_log_write(dns_lctx, \ +#define FCTXTRACE(m) \ + isc_log_write(dns_lctx, \ DNS_LOGCATEGORY_RESOLVER, \ DNS_LOGMODULE_RESOLVER, \ ISC_LOG_DEBUG(3), \ - "fctx %p(%s): %s", fctx, fctx->info, (m)) + "fctx %p(%s): %s", \ + fctx, fctx->info, (m)) #define FCTXTRACE2(m1, m2) \ isc_log_write(dns_lctx, \ DNS_LOGCATEGORY_RESOLVER, \ @@ -88,6 +87,22 @@ ISC_LOG_DEBUG(3), \ "fctx %p(%s): %s %s", \ fctx, fctx->info, (m1), (m2)) +#define FCTXTRACE3(m, res) \ + isc_log_write(dns_lctx, \ + DNS_LOGCATEGORY_RESOLVER, \ + DNS_LOGMODULE_RESOLVER, \ + ISC_LOG_DEBUG(3), \ + "fctx %p(%s): [result: %s] %s", \ + fctx, fctx->info, \ + isc_result_totext(res), (m)) +#define FCTXTRACE4(m1, m2, res) \ + isc_log_write(dns_lctx, \ + DNS_LOGCATEGORY_RESOLVER, \ + DNS_LOGMODULE_RESOLVER, \ + ISC_LOG_DEBUG(3), \ + "fctx %p(%s): [result: %s] %s %s", \ + fctx, fctx->info, \ + isc_result_totext(res), (m1), (m2)) #define FTRACE(m) isc_log_write(dns_lctx, \ DNS_LOGCATEGORY_RESOLVER, \ DNS_LOGMODULE_RESOLVER, \ @@ -103,13 +118,16 @@ query, query->fctx, \ query->fctx->info, (m)) #else -#define RTRACE(m) -#define RRTRACE(r, m) -#define FCTXTRACE(m) -#define FCTXTRACE2(m1, m2) -#define FTRACE(m) -#define QTRACE(m) -#endif +#define RTRACE(m) do { UNUSED(m); } while (0) +#define RRTRACE(r, m) do { UNUSED(r); UNUSED(m); } while (0) +#define FCTXTRACE(m) do { UNUSED(m); } while (0) +#define FCTXTRACE2(m1, m2) do { UNUSED(m1); UNUSED(m2); } while (0) +#define FCTXTRACE3(m1, res) do { UNUSED(m1); UNUSED(res); } while (0) +#define FCTXTRACE4(m1, m2, res) \ + do { UNUSED(m1); UNUSED(m2); UNUSED(res); } while (0) +#define FTRACE(m) do { UNUSED(m); } while (0) +#define QTRACE(m) do { UNUSED(m); } while (0) +#endif /* WANT_QUERYTRACE */ #define US_PER_SEC 1000000U /* @@ -128,8 +146,9 @@ #define DEFAULT_QUERY_TIMEOUT MINIMUM_QUERY_TIMEOUT #endif +/* The maximum time in seconds for the whole query to live. */ #ifndef MAXIMUM_QUERY_TIMEOUT -#define MAXIMUM_QUERY_TIMEOUT 30 /* The maximum time in seconds for the whole query to live. */ +#define MAXIMUM_QUERY_TIMEOUT 30 #endif /* The default maximum number of recursions to follow before giving up. */ @@ -142,6 +161,12 @@ #define DEFAULT_MAX_QUERIES 50 #endif +/* Number of hash buckets for zone counters */ +#ifndef RES_DOMAIN_BUCKETS +#define RES_DOMAIN_BUCKETS 523 +#endif +#define RES_NOBUCKET 0xffffffff + /*% * Maximum EDNS0 input packet size. */ @@ -211,6 +236,7 @@ struct fetchctx { dns_rdatatype_t type; unsigned int options; unsigned int bucketnum; + unsigned int dbucketnum; char * info; isc_mem_t * mctx; @@ -311,6 +337,7 @@ struct fetchctx { unsigned int querysent; unsigned int referrals; unsigned int lamecount; + unsigned int quotacount; unsigned int neterr; unsigned int badresp; unsigned int adberr; @@ -371,6 +398,25 @@ typedef struct fctxbucket { isc_mem_t * mctx; } fctxbucket_t; +#ifdef ENABLE_FETCHLIMIT +typedef struct fctxcount fctxcount_t; +struct fctxcount { + dns_fixedname_t fdname; + dns_name_t *domain; + isc_uint32_t count; + isc_uint32_t allowed; + isc_uint32_t dropped; + isc_stdtime_t logged; + ISC_LINK(fctxcount_t) link; +}; + +typedef struct zonebucket { + isc_mutex_t lock; + isc_mem_t *mctx; + ISC_LIST(fctxcount_t) list; +} zonebucket_t; +#endif /* ENABLE_FETCHLIMIT */ + typedef struct alternate { isc_boolean_t isaddress; union { @@ -416,6 +462,9 @@ struct dns_resolver { isc_boolean_t exclusivev6; unsigned int nbuckets; fctxbucket_t * buckets; +#ifdef ENABLE_FETCHLIMIT + zonebucket_t * dbuckets; +#endif /* ENABLE_FETCHLIMIT */ isc_uint32_t lame_ttl; ISC_LIST(alternate_t) alternates; isc_uint16_t udpsize; @@ -434,6 +483,7 @@ struct dns_resolver { unsigned int query_timeout; unsigned int maxdepth; unsigned int maxqueries; + isc_result_t quotaresp[2]; /* Locked by lock. */ unsigned int references; @@ -442,6 +492,7 @@ struct dns_resolver { unsigned int activebuckets; isc_boolean_t priming; unsigned int spillat; /* clients-per-query */ + unsigned int zspill; /* fetches-per-zone */ /* Bad cache. */ dns_badcache_t ** badcache; @@ -503,6 +554,8 @@ static void add_bad(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo, static inline isc_result_t findnoqname(fetchctx_t *fctx, dns_name_t *name, dns_rdatatype_t type, dns_name_t **noqname); +static void fctx_increference(fetchctx_t *fctx); +static isc_boolean_t fctx_decreference(fetchctx_t *fctx); /*% * Increment resolver-related statistics counters. @@ -779,10 +832,13 @@ fctx_startidletimer(fetchctx_t *fctx, isc_interval_t *interval) { */ #define fctx_stopidletimer fctx_starttimer - static inline void resquery_destroy(resquery_t **queryp) { + dns_resolver_t *res; + isc_boolean_t empty; resquery_t *query; + fetchctx_t *fctx; + unsigned int bucket; REQUIRE(queryp != NULL); query = *queryp; @@ -790,15 +846,22 @@ resquery_destroy(resquery_t **queryp) { INSIST(query->tcpsocket == NULL); - query->fctx->nqueries--; - if (SHUTTINGDOWN(query->fctx)) { - dns_resolver_t *res = query->fctx->res; - if (maybe_destroy(query->fctx, ISC_FALSE)) - empty_bucket(res); - } + fctx = query->fctx; + res = fctx->res; + bucket = fctx->bucketnum; + + fctx->nqueries--; + + LOCK(&res->buckets[bucket].lock); + empty = fctx_decreference(query->fctx); + UNLOCK(&res->buckets[bucket].lock); + query->magic = 0; isc_mem_put(query->mctx, query, sizeof(*query)); *queryp = NULL; + + if (empty) + empty_bucket(res); } static void @@ -811,7 +874,7 @@ fctx_cancelquery(resquery_t **queryp, dns_dispatchevent_t **deventp, unsigned int factor; dns_adbfind_t *find; dns_adbaddrinfo_t *addrinfo; - isc_socket_t *socket; + isc_socket_t *sock; isc_stdtime_t now; query = *queryp; @@ -866,19 +929,20 @@ fctx_cancelquery(resquery_t **queryp, dns_dispatchevent_t **deventp, rtt = query->addrinfo->srtt + 200000; if (rtt > MAX_SINGLE_QUERY_TIMEOUT_US) rtt = MAX_SINGLE_QUERY_TIMEOUT_US; + /* * Replace the current RTT with our value. */ factor = DNS_ADB_RTTADJREPLACE; + dns_adb_timeout(fctx->adb, query->addrinfo); } + dns_adb_adjustsrtt(fctx->adb, query->addrinfo, rtt, factor); } - /* Remember that the server has been tried. */ - if (!TRIED(query->addrinfo)) { - dns_adb_changeflags(fctx->adb, query->addrinfo, - FCTX_ADDRINFO_TRIED, FCTX_ADDRINFO_TRIED); - } +#ifdef ENABLE_FETCHLIMIT + dns_adb_endudpfetch(fctx->adb, query->addrinfo); +#endif /* ENABLE_FETCHLIMIT */ /* * Age RTTs of servers not tried. @@ -934,9 +998,9 @@ fctx_cancelquery(resquery_t **queryp, dns_dispatchevent_t **deventp, ISC_SOCKCANCEL_CONNECT); } else if (query->dispentry != NULL) { INSIST(query->exclusivesocket); - socket = dns_dispatch_getentrysocket(query->dispentry); - if (socket != NULL) - isc_socket_cancel(socket, NULL, + sock = dns_dispatch_getentrysocket(query->dispentry); + if (sock != NULL) + isc_socket_cancel(sock, NULL, ISC_SOCKCANCEL_CONNECT); } } else if (RESQUERY_SENDING(query)) { @@ -944,11 +1008,11 @@ fctx_cancelquery(resquery_t **queryp, dns_dispatchevent_t **deventp, * Cancel the pending send. */ if (query->exclusivesocket && query->dispentry != NULL) - socket = dns_dispatch_getentrysocket(query->dispentry); + sock = dns_dispatch_getentrysocket(query->dispentry); else - socket = dns_dispatch_getsocket(query->dispatch); - if (socket != NULL) - isc_socket_cancel(socket, NULL, ISC_SOCKCANCEL_SEND); + sock = dns_dispatch_getsocket(query->dispatch); + if (sock != NULL) + isc_socket_cancel(sock, NULL, ISC_SOCKCANCEL_SEND); } if (query->dispentry != NULL) @@ -1059,6 +1123,128 @@ fctx_stopeverything(fetchctx_t *fctx, isc_boolean_t no_response) { fctx_stoptimer(fctx); } +#ifdef ENABLE_FETCHLIMIT +static void +fcount_logspill(fetchctx_t *fctx, fctxcount_t *counter) { + char dbuf[DNS_NAME_FORMATSIZE]; + isc_stdtime_t now; + + if (! isc_log_wouldlog(dns_lctx, ISC_LOG_INFO)) + return; + + isc_stdtime_get(&now); + if (counter->logged > now - 60) + return; + + dns_name_format(&fctx->domain, dbuf, sizeof(dbuf)); + + isc_log_write(dns_lctx, DNS_LOGCATEGORY_SPILL, + DNS_LOGMODULE_RESOLVER, ISC_LOG_INFO, + "too many simultaneous fetches for %s " + "(allowed %d spilled %d)", + dbuf, counter->allowed, counter->dropped); + + counter->logged = now; +} + +static isc_result_t +fcount_incr(fetchctx_t *fctx, isc_boolean_t force) { + isc_result_t result = ISC_R_SUCCESS; + zonebucket_t *dbucket; + fctxcount_t *counter; + unsigned int bucketnum, spill; + + REQUIRE(fctx != NULL); + REQUIRE(fctx->res != NULL); + + INSIST(fctx->dbucketnum == RES_NOBUCKET); + bucketnum = dns_name_fullhash(&fctx->domain, ISC_FALSE) + % RES_DOMAIN_BUCKETS; + + LOCK(&fctx->res->lock); + spill = fctx->res->zspill; + UNLOCK(&fctx->res->lock); + + dbucket = &fctx->res->dbuckets[bucketnum]; + + LOCK(&dbucket->lock); + for (counter = ISC_LIST_HEAD(dbucket->list); + counter != NULL; + counter = ISC_LIST_NEXT(counter, link)) + { + if (dns_name_equal(counter->domain, &fctx->domain)) + break; + } + + if (counter == NULL) { + counter = isc_mem_get(dbucket->mctx, sizeof(fctxcount_t)); + if (counter == NULL) + result = ISC_R_NOMEMORY; + else { + ISC_LINK_INIT(counter, link); + counter->count = 1; + counter->logged = 0; + counter->allowed = 1; + counter->dropped = 0; + dns_fixedname_init(&counter->fdname); + counter->domain = dns_fixedname_name(&counter->fdname); + dns_name_copy(&fctx->domain, counter->domain, NULL); + ISC_LIST_APPEND(dbucket->list, counter, link); + } + } else { + if (!force && spill != 0 && counter->count >= spill) { + counter->dropped++; + fcount_logspill(fctx, counter); + result = ISC_R_QUOTA; + } else { + counter->count++; + counter->allowed++; + } + } + UNLOCK(&dbucket->lock); + + if (result == ISC_R_SUCCESS) + fctx->dbucketnum = bucketnum; + + return (result); +} + +static void +fcount_decr(fetchctx_t *fctx) { + zonebucket_t *dbucket; + fctxcount_t *counter; + + REQUIRE(fctx != NULL); + + if (fctx->dbucketnum == RES_NOBUCKET) + return; + + dbucket = &fctx->res->dbuckets[fctx->dbucketnum]; + + LOCK(&dbucket->lock); + for (counter = ISC_LIST_HEAD(dbucket->list); + counter != NULL; + counter = ISC_LIST_NEXT(counter, link)) + { + if (dns_name_equal(counter->domain, &fctx->domain)) + break; + } + + if (counter != NULL) { + INSIST(counter->count != 0); + counter->count--; + fctx->dbucketnum = RES_NOBUCKET; + + if (counter->count == 0) { + ISC_LIST_UNLINK(dbucket->list, counter, link); + isc_mem_put(dbucket->mctx, counter, sizeof(*counter)); + } + } + + UNLOCK(&dbucket->lock); +} +#endif /* ENABLE_FETCHLIMIT */ + static inline void fctx_sendevents(fetchctx_t *fctx, isc_result_t result, int line) { dns_fetchevent_t *event, *next_event; @@ -1200,6 +1386,7 @@ fctx_done(fetchctx_t *fctx, isc_result_t result, int line) { static void process_sendevent(resquery_t *query, isc_event_t *event) { isc_socketevent_t *sevent = (isc_socketevent_t *)event; + isc_boolean_t destroy_query = ISC_FALSE; isc_boolean_t retry = ISC_FALSE; isc_result_t result; fetchctx_t *fctx; @@ -1214,7 +1401,7 @@ process_sendevent(resquery_t *query, isc_event_t *event) { */ if (query->tcpsocket != NULL) isc_socket_detach(&query->tcpsocket); - resquery_destroy(&query); + destroy_query = ISC_TRUE; } } else { switch (sevent->result) { @@ -1226,6 +1413,9 @@ process_sendevent(resquery_t *query, isc_event_t *event) { case ISC_R_NOPERM: case ISC_R_ADDRNOTAVAIL: case ISC_R_CONNREFUSED: + FCTXTRACE3("query canceled in sendevent(): " + "no route to host; no response", + sevent->result); /* * No route to remote. @@ -1237,6 +1427,10 @@ process_sendevent(resquery_t *query, isc_event_t *event) { break; default: + FCTXTRACE3("query canceled in sendevent() due to " + "unexpected event result; responding", + sevent->result); + fctx_cancelquery(&query, NULL, NULL, ISC_FALSE); break; } @@ -1257,6 +1451,9 @@ process_sendevent(resquery_t *query, isc_event_t *event) { else fctx_try(fctx, ISC_TRUE, ISC_FALSE); } + + if (destroy_query) + resquery_destroy(&query); } static void @@ -1528,6 +1725,7 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo, } query->dispentry = NULL; + fctx_increference(fctx); query->fctx = fctx; query->tsig = NULL; query->tsigkey = NULL; @@ -1548,6 +1746,14 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo, query->connects++; QTRACE("connecting via TCP"); } else { +#ifdef ENABLE_FETCHLIMIT + if (dns_adbentry_overquota(addrinfo->entry)) + goto cleanup_dispatch; + + /* Inform the ADB that we're starting a fetch */ + dns_adb_beginudpfetch(fctx->adb, addrinfo); +#endif /* ENABLE_FETCHLIMIT */ + result = resquery_send(query); if (result != ISC_R_SUCCESS) goto cleanup_dispatch; @@ -1574,6 +1780,11 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo, if (query->dispatch != NULL) dns_dispatch_detach(&query->dispatch); + LOCK(&res->buckets[fctx->bucketnum].lock); + INSIST(fctx->references > 1); + fctx->references--; + UNLOCK(&res->buckets[fctx->bucketnum].lock); + cleanup_query: if (query->connects == 0) { query->magic = 0; @@ -1700,7 +1911,7 @@ resquery_send(resquery_t *query) { isc_region_t r; dns_resolver_t *res; isc_task_t *task; - isc_socket_t *socket; + isc_socket_t *sock; isc_buffer_t tcpbuffer; isc_sockaddr_t *address; isc_buffer_t *buffer; @@ -2002,16 +2213,16 @@ resquery_send(resquery_t *query) { dns_message_reset(fctx->qmessage, DNS_MESSAGE_INTENTRENDER); if (query->exclusivesocket) - socket = dns_dispatch_getentrysocket(query->dispentry); + sock = dns_dispatch_getentrysocket(query->dispentry); else - socket = dns_dispatch_getsocket(query->dispatch); + sock = dns_dispatch_getsocket(query->dispatch); /* * Send the query! */ if ((query->options & DNS_FETCHOPT_TCP) == 0) { address = &query->addrinfo->sockaddr; if (query->exclusivesocket) { - result = isc_socket_connect(socket, address, task, + result = isc_socket_connect(sock, address, task, resquery_udpconnected, query); if (result != ISC_R_SUCCESS) @@ -2029,7 +2240,7 @@ resquery_send(resquery_t *query) { ISC_EVENT_INIT(&query->sendevent, sizeof(query->sendevent), 0, NULL, ISC_SOCKEVENT_SENDDONE, resquery_senddone, query, NULL, NULL, NULL); - result = isc_socket_sendto2(socket, &r, task, address, NULL, + result = isc_socket_sendto2(sock, &r, task, address, NULL, &query->sendevent, 0); if (result != ISC_R_SUCCESS) { if (connecting) { @@ -2119,6 +2330,9 @@ resquery_connected(isc_task_t *task, isc_event_t *event) { isc_interval_set(&interval, 20, 0); result = fctx_startidletimer(query->fctx, &interval); if (result != ISC_R_SUCCESS) { + FCTXTRACE("query canceled: idle timer failed; " + "responding"); + fctx_cancelquery(&query, NULL, NULL, ISC_FALSE); fctx_done(fctx, result, __LINE__); break; @@ -2155,6 +2369,9 @@ resquery_connected(isc_task_t *task, isc_event_t *event) { result = resquery_send(query); if (result != ISC_R_SUCCESS) { + FCTXTRACE("query canceled: " + "resquery_send() failed; responding"); + fctx_cancelquery(&query, NULL, NULL, ISC_FALSE); fctx_done(fctx, result, __LINE__); } @@ -2166,6 +2383,10 @@ resquery_connected(isc_task_t *task, isc_event_t *event) { case ISC_R_NOPERM: case ISC_R_ADDRNOTAVAIL: case ISC_R_CONNECTIONRESET: + FCTXTRACE3("query canceled in connected(): " + "no route to host; no response", + sevent->result); + /* * No route to remote. */ @@ -2175,6 +2396,10 @@ resquery_connected(isc_task_t *task, isc_event_t *event) { break; default: + FCTXTRACE3("query canceled in connected() due to " + "unexpected event result; responding", + sevent->result); + isc_socket_detach(&query->tcpsocket); fctx_cancelquery(&query, NULL, NULL, ISC_FALSE); break; @@ -2206,7 +2431,7 @@ fctx_finddone(isc_task_t *task, isc_event_t *event) { isc_boolean_t want_done = ISC_FALSE; isc_boolean_t bucket_empty = ISC_FALSE; unsigned int bucketnum; - isc_boolean_t destroy = ISC_FALSE; + isc_boolean_t dodestroy = ISC_FALSE; find = event->ev_sender; fctx = event->ev_arg; @@ -2247,7 +2472,7 @@ fctx_finddone(isc_task_t *task, isc_event_t *event) { if (fctx->references == 0) { bucket_empty = fctx_unlink(fctx); - destroy = ISC_TRUE; + dodestroy = ISC_TRUE; } } UNLOCK(&res->buckets[bucketnum].lock); @@ -2255,11 +2480,12 @@ fctx_finddone(isc_task_t *task, isc_event_t *event) { isc_event_free(&event); dns_adb_destroyfind(&find); - if (want_try) + if (want_try) { fctx_try(fctx, ISC_TRUE, ISC_FALSE); - else if (want_done) + } else if (want_done) { + FCTXTRACE("fetch failed in finddone(); return ISC_R_FAILURE"); fctx_done(fctx, ISC_R_FAILURE, __LINE__); - else if (destroy) { + } else if (dodestroy) { fctx_destroy(fctx); if (bucket_empty) empty_bucket(res); @@ -2488,7 +2714,7 @@ sort_finds(dns_adbfindlist_t *findlist) { static void findname(fetchctx_t *fctx, dns_name_t *name, in_port_t port, unsigned int options, unsigned int flags, isc_stdtime_t now, - isc_boolean_t *need_alternate) + isc_boolean_t *overquota, isc_boolean_t *need_alternate) { dns_adbaddrinfo_t *ai; dns_adbfind_t *find; @@ -2496,6 +2722,10 @@ findname(fetchctx_t *fctx, dns_name_t *name, in_port_t port, isc_boolean_t unshared; isc_result_t result; +#ifndef ENABLE_FETCHLIMIT + UNUSED(overquota); +#endif /* !ENABLE_FETCHLIMIT */ + res = fctx->res; unshared = ISC_TF((fctx->options & DNS_FETCHOPT_UNSHARED) != 0); /* @@ -2579,6 +2809,14 @@ findname(fetchctx_t *fctx, dns_name_t *name, in_port_t port, find->result_v4 != DNS_R_NXDOMAIN))) *need_alternate = ISC_TRUE; } else { +#ifdef ENABLE_FETCHLIMIT + if ((find->options & DNS_ADBFIND_OVERQUOTA) != 0) { + if (overquota != NULL) + *overquota = ISC_TRUE; + fctx->quotacount++; /* quota exceeded */ + } + else +#endif /* ENABLE_FETCHLIMIT */ if ((find->options & DNS_ADBFIND_LAMEPRUNED) != 0) fctx->lamecount++; /* cached lame server */ else @@ -2622,6 +2860,9 @@ fctx_getaddresses(fetchctx_t *fctx, isc_boolean_t badcache) { isc_boolean_t all_bad; dns_rdata_ns_t ns; isc_boolean_t need_alternate = ISC_FALSE; +#ifdef ENABLE_FETCHLIMIT + isc_boolean_t all_spilled = ISC_TRUE; +#endif /* ENABLE_FETCHLIMIT */ FCTXTRACE("getaddresses"); @@ -2679,19 +2920,27 @@ fctx_getaddresses(fetchctx_t *fctx, isc_boolean_t badcache) { dns_fixedname_init(&fixed); domain = dns_fixedname_name(&fixed); - result = dns_fwdtable_find2(fctx->res->view->fwdtable, name, + result = dns_fwdtable_find2(res->view->fwdtable, name, domain, &forwarders); if (result == ISC_R_SUCCESS) { sa = ISC_LIST_HEAD(forwarders->addrs); fctx->fwdpolicy = forwarders->fwdpolicy; if (fctx->fwdpolicy == dns_fwdpolicy_only && isstrictsubdomain(domain, &fctx->domain)) { +#ifdef ENABLE_FETCHLIMIT + fcount_decr(fctx); +#endif /* ENABLE_FETCHLIMIT */ dns_name_free(&fctx->domain, fctx->mctx); dns_name_init(&fctx->domain, NULL); result = dns_name_dup(domain, fctx->mctx, &fctx->domain); if (result != ISC_R_SUCCESS) return (result); +#ifdef ENABLE_FETCHLIMIT + result = fcount_incr(fctx, ISC_TRUE); + if (result != ISC_R_SUCCESS) + return (result); +#endif /* ENABLE_FETCHLIMIT */ } } } @@ -2765,6 +3014,8 @@ fctx_getaddresses(fetchctx_t *fctx, isc_boolean_t badcache) { result == ISC_R_SUCCESS; result = dns_rdataset_next(&fctx->nameservers)) { + isc_boolean_t overquota = ISC_FALSE; + dns_rdataset_current(&fctx->nameservers, &rdata); /* * Extract the name from the NS record. @@ -2774,7 +3025,13 @@ fctx_getaddresses(fetchctx_t *fctx, isc_boolean_t badcache) { continue; findname(fctx, &ns.name, 0, stdoptions, 0, now, - &need_alternate); + &overquota, &need_alternate); + +#ifdef ENABLE_FETCHLIMIT + if (!overquota) + all_spilled = ISC_FALSE; +#endif /* ENABLE_FETCHLIMIT */ + dns_rdata_reset(&rdata); dns_rdata_freestruct(&ns); } @@ -2788,13 +3045,13 @@ fctx_getaddresses(fetchctx_t *fctx, isc_boolean_t badcache) { int family; alternate_t *a; family = (res->dispatches6 != NULL) ? AF_INET6 : AF_INET; - for (a = ISC_LIST_HEAD(fctx->res->alternates); + for (a = ISC_LIST_HEAD(res->alternates); a != NULL; a = ISC_LIST_NEXT(a, link)) { if (!a->isaddress) { findname(fctx, &a->_u._n.name, a->_u._n.port, stdoptions, FCTX_ADDRINFO_FORWARDER, - now, NULL); + now, NULL, NULL); continue; } if (isc_sockaddr_pf(&a->_u.addr) != family) @@ -2853,10 +3110,21 @@ fctx_getaddresses(fetchctx_t *fctx, isc_boolean_t badcache) { fctx->type == dns_rdatatype_dlv || fctx->type == dns_rdatatype_ds) && result == ISC_R_SUCCESS) - dns_resolver_addbadcache(fctx->res, - &fctx->name, + dns_resolver_addbadcache(res, &fctx->name, fctx->type, &expire); - result = ISC_R_FAILURE; + +#ifdef ENABLE_FETCHLIMIT + /* + * If all of the addresses found were over the + * fetches-per-server quota, return the configured + * response. + */ + if (all_spilled) { + result = res->quotaresp[dns_quotatype_server]; + inc_stats(res, dns_resstatscounter_serverquota); + } else + result = ISC_R_FAILURE; +#endif /* ENABLE_FETCHLIMIT */ } } else { /* @@ -2907,6 +3175,9 @@ possibly_mark(fetchctx_t *fctx, dns_adbaddrinfo_t *addr) bogus) aborted = ISC_TRUE; + if (!isc_log_wouldlog(dns_lctx, ISC_LOG_DEBUG(3))) + return; + if (aborted) { addr->flags |= FCTX_ADDRINFO_MARK; msg = "ignoring blackholed / bogus server: "; @@ -2927,9 +3198,6 @@ possibly_mark(fetchctx_t *fctx, dns_adbaddrinfo_t *addr) } else return; - if (!isc_log_wouldlog(dns_lctx, ISC_LOG_DEBUG(3))) - return; - isc_netaddr_fromsockaddr(&na, sa); isc_netaddr_format(&na, buf, sizeof(buf)); FCTXTRACE2(msg, buf); @@ -3080,14 +3348,17 @@ fctx_nextaddress(fetchctx_t *fctx) { static void fctx_try(fetchctx_t *fctx, isc_boolean_t retrying, isc_boolean_t badcache) { isc_result_t result; - dns_adbaddrinfo_t *addrinfo; + dns_adbaddrinfo_t *addrinfo = NULL; + dns_resolver_t *res; FCTXTRACE("try"); REQUIRE(!ADDRWAIT(fctx)); + res = fctx->res; + /* We've already exceeded maximum query count */ - if (isc_counter_used(fctx->qc) > fctx->res->maxqueries) { + if (isc_counter_used(fctx->qc) > res->maxqueries) { isc_log_write(dns_lctx, DNS_LOGCATEGORY_RESOLVER, DNS_LOGMODULE_RESOLVER, ISC_LOG_DEBUG(3), "exceeded max queries resolving '%s'", @@ -3096,11 +3367,15 @@ fctx_try(fetchctx_t *fctx, isc_boolean_t retrying, isc_boolean_t badcache) { return; } - addrinfo = fctx_nextaddress(fctx); +#ifdef ENABLE_FETCHLIMIT + /* Try to find an address that isn't over quota */ + while ((addrinfo = fctx_nextaddress(fctx)) != NULL) + if (! dns_adbentry_overquota(addrinfo->entry)) + break; +#endif /* ENABLE_FETCHLIMIT */ + if (addrinfo == NULL) { - /* - * We have no more addresses. Start over. - */ + /* We have no more addresses. Start over. */ fctx_cancelqueries(fctx, ISC_TRUE); fctx_cleanupfinds(fctx); fctx_cleanupaltfinds(fctx); @@ -3122,7 +3397,15 @@ fctx_try(fetchctx_t *fctx, isc_boolean_t retrying, isc_boolean_t badcache) { return; } +#ifdef ENABLE_FETCHLIMIT + while ((addrinfo = fctx_nextaddress(fctx)) != NULL) { + if (! dns_adbentry_overquota(addrinfo->entry)) + break; + } +#else addrinfo = fctx_nextaddress(fctx); +#endif /* !ENABLE_FETCHLIMIT */ + /* * While we may have addresses from the ADB, they * might be bad ones. In this case, return SERVFAIL. @@ -3149,7 +3432,7 @@ fctx_try(fetchctx_t *fctx, isc_boolean_t retrying, isc_boolean_t badcache) { if (result != ISC_R_SUCCESS) fctx_done(fctx, result, __LINE__); else if (retrying) - inc_stats(fctx->res, dns_resstatscounter_retry); + inc_stats(res, dns_resstatscounter_retry); } static isc_boolean_t @@ -3244,6 +3527,11 @@ fctx_destroy(fetchctx_t *fctx) { } isc_counter_detach(&fctx->qc); + +#ifdef ENABLE_FETCHLIMIT + fcount_decr(fctx); +#endif /* ENABLE_FETCHLIMIT */ + isc_timer_detach(&fctx->timer); dns_message_destroy(&fctx->rmessage); dns_message_destroy(&fctx->qmessage); @@ -3284,6 +3572,7 @@ fctx_timeout(isc_task_t *task, isc_event_t *event) { fctx->timeouts++; fctx->timeout = ISC_TRUE; + /* * We could cancel the running queries here, or we could let * them keep going. Since we normally use separate sockets for @@ -3295,10 +3584,13 @@ fctx_timeout(isc_task_t *task, isc_event_t *event) { */ query = ISC_LIST_HEAD(fctx->queries); if (query != NULL && - isc_time_compare(&tevent->due, &query->start) >= 0) { + isc_time_compare(&tevent->due, &query->start) >= 0) + { + FCTXTRACE("query timed out; no response"); fctx_cancelquery(&query, NULL, NULL, ISC_TRUE); } fctx->attributes &= ~FCTX_ATTR_ADDRWAIT; + /* * Our timer has triggered. Reestablish the fctx lifetime * timer. @@ -3355,7 +3647,7 @@ fctx_doshutdown(isc_task_t *task, isc_event_t *event) { dns_resolver_t *res; unsigned int bucketnum; dns_validator_t *validator; - isc_boolean_t destroy = ISC_FALSE; + isc_boolean_t dodestroy = ISC_FALSE; REQUIRE(VALID_FCTX(fctx)); @@ -3407,12 +3699,12 @@ fctx_doshutdown(isc_task_t *task, isc_event_t *event) { if (fctx->references == 0 && fctx->pending == 0 && fctx->nqueries == 0 && ISC_LIST_EMPTY(fctx->validators)) { bucket_empty = fctx_unlink(fctx); - destroy = ISC_TRUE; + dodestroy = ISC_TRUE; } UNLOCK(&res->buckets[bucketnum].lock); - if (destroy) { + if (dodestroy) { fctx_destroy(fctx); if (bucket_empty) empty_bucket(res); @@ -3425,7 +3717,7 @@ fctx_start(isc_task_t *task, isc_event_t *event) { isc_boolean_t done = ISC_FALSE, bucket_empty = ISC_FALSE; dns_resolver_t *res; unsigned int bucketnum; - isc_boolean_t destroy = ISC_FALSE; + isc_boolean_t dodestroy = ISC_FALSE; REQUIRE(VALID_FCTX(fctx)); @@ -3459,7 +3751,7 @@ fctx_start(isc_task_t *task, isc_event_t *event) { * It's now safe to destroy this fctx. */ bucket_empty = fctx_unlink(fctx); - destroy = ISC_TRUE; + dodestroy = ISC_TRUE; } done = ISC_TRUE; } else { @@ -3481,7 +3773,7 @@ fctx_start(isc_task_t *task, isc_event_t *event) { if (!done) { isc_result_t result; - INSIST(!destroy); + INSIST(!dodestroy); /* * All is well. Start working on the fetch. @@ -3491,7 +3783,7 @@ fctx_start(isc_task_t *task, isc_event_t *event) { fctx_done(fctx, result, __LINE__); else fctx_try(fctx, ISC_FALSE, ISC_FALSE); - } else if (destroy) { + } else if (dodestroy) { fctx_destroy(fctx); if (bucket_empty) empty_bucket(res); @@ -3583,7 +3875,6 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type, unsigned int findoptions = 0; char buf[DNS_NAME_FORMATSIZE + DNS_RDATATYPE_FORMATSIZE]; char typebuf[DNS_RDATATYPE_FORMATSIZE]; - dns_name_t suffix; isc_mem_t *mctx; /* @@ -3619,6 +3910,7 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type, result = ISC_R_NOMEMORY; goto cleanup_counter; } + FCTXTRACE("create"); dns_name_init(&fctx->name, NULL); result = dns_name_dup(name, mctx, &fctx->name); @@ -3637,6 +3929,7 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type, fctx->res = res; fctx->references = 0; fctx->bucketnum = bucketnum; + fctx->dbucketnum = RES_NOBUCKET; fctx->state = fetchstate_init; fctx->want_shutdown = ISC_FALSE; fctx->cloned = ISC_FALSE; @@ -3663,6 +3956,7 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type, TIME_NOW(&fctx->start); fctx->timeouts = 0; fctx->lamecount = 0; + fctx->quotacount = 0; fctx->adberr = 0; fctx->neterr = 0; fctx->badresp = 0; @@ -3692,10 +3986,12 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type, dns_forwarders_t *forwarders = NULL; unsigned int labels; dns_name_t *fwdname = name; + dns_name_t suffix; /* - * DS records are found in the parent server. - * Strip label to get the correct forwarder (if any). + * DS records are found in the parent server. Strip one + * leading label from the name (to be used in finding + * the forwarder). */ if (dns_rdatatype_atparent(fctx->type) && dns_name_countlabels(name) > 1) { @@ -3704,6 +4000,8 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type, dns_name_getlabelsequence(name, 1, labels - 1, &suffix); fwdname = &suffix; } + + /* Find the forwarder for this name. */ dns_fixedname_init(&fixed); domain = dns_fixedname_name(&fixed); result = dns_fwdtable_find2(fctx->res->view->fwdtable, fwdname, @@ -3751,6 +4049,18 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type, fctx->ns_ttl_ok = ISC_TRUE; } +#ifdef ENABLE_FETCHLIMIT + /* + * Are there too many simultaneous queries for this domain? + */ + result = fcount_incr(fctx, ISC_FALSE); + if (result != ISC_R_SUCCESS) { + result = fctx->res->quotaresp[dns_quotatype_zone]; + inc_stats(res, dns_resstatscounter_zonequota); + goto cleanup_domain; + } +#endif /* ENABLE_FETCHLIMIT */ + log_ns_ttl(fctx, "fctx_create"); INSIST(dns_name_issubdomain(&fctx->name, &fctx->domain)); @@ -3760,7 +4070,11 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type, &fctx->qmessage); if (result != ISC_R_SUCCESS) +#ifdef ENABLE_FETCHLIMIT + goto cleanup_fcount; +#else goto cleanup_domain; +#endif /* !ENABLE_FETCHLIMIT */ fctx->rmessage = NULL; result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, @@ -3836,6 +4150,11 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type, cleanup_qmessage: dns_message_destroy(&fctx->qmessage); +#ifdef ENABLE_FETCHLIMIT + cleanup_fcount: + fcount_decr(fctx); +#endif /* ENABLE_FETCHLIMIT */ + cleanup_domain: if (dns_name_countlabels(&fctx->domain) > 0) dns_name_free(&fctx->domain, mctx); @@ -4062,7 +4381,7 @@ maybe_destroy(fetchctx_t *fctx, isc_boolean_t locked) { isc_boolean_t bucket_empty = ISC_FALSE; dns_resolver_t *res = fctx->res; dns_validator_t *validator, *next_validator; - isc_boolean_t destroy = ISC_FALSE; + isc_boolean_t dodestroy = ISC_FALSE; REQUIRE(SHUTTINGDOWN(fctx)); @@ -4080,12 +4399,12 @@ maybe_destroy(fetchctx_t *fctx, isc_boolean_t locked) { if (fctx->references == 0 && ISC_LIST_EMPTY(fctx->validators)) { bucket_empty = fctx_unlink(fctx); - destroy = ISC_TRUE; + dodestroy = ISC_TRUE; } unlock: if (!locked) UNLOCK(&res->buckets[bucketnum].lock); - if (destroy) + if (dodestroy) fctx_destroy(fctx); return (bucket_empty); } @@ -6093,6 +6412,11 @@ noanswer_response(fetchctx_t *fctx, dns_name_t *oqname, * if so we should bail out. */ INSIST(dns_name_countlabels(&fctx->domain) > 0); + +#ifdef ENABLE_FETCHLIMIT + fcount_decr(fctx); +#endif /* ENABLE_FETCHLIMIT */ + dns_name_free(&fctx->domain, fctx->mctx); if (dns_rdataset_isassociated(&fctx->nameservers)) dns_rdataset_disassociate(&fctx->nameservers); @@ -6100,6 +6424,13 @@ noanswer_response(fetchctx_t *fctx, dns_name_t *oqname, result = dns_name_dup(ns_name, fctx->mctx, &fctx->domain); if (result != ISC_R_SUCCESS) return (result); + +#ifdef ENABLE_FETCHLIMIT + result = fcount_incr(fctx, ISC_TRUE); + if (result != ISC_R_SUCCESS) + return (result); +#endif /* ENABLE_FETCHLIMIT */ + fctx->attributes |= FCTX_ATTR_WANTCACHE; fctx->ns_ttl_ok = ISC_FALSE; log_ns_ttl(fctx, "DELEGATION"); @@ -6583,10 +6914,21 @@ answer_response(fetchctx_t *fctx) { return (result); } +static void +fctx_increference(fetchctx_t *fctx) { + REQUIRE(VALID_FCTX(fctx)); + + LOCK(&fctx->res->buckets[fctx->bucketnum].lock); + fctx->references++; + UNLOCK(&fctx->res->buckets[fctx->bucketnum].lock); +} + static isc_boolean_t fctx_decreference(fetchctx_t *fctx) { isc_boolean_t bucket_empty = ISC_FALSE; + REQUIRE(VALID_FCTX(fctx)); + INSIST(fctx->references > 0); fctx->references--; if (fctx->references == 0) { @@ -6655,6 +6997,11 @@ resume_dslookup(isc_task_t *task, isc_event_t *event) { fctx->ns_ttl = fctx->nameservers.ttl; fctx->ns_ttl_ok = ISC_TRUE; log_ns_ttl(fctx, "resume_dslookup"); + +#ifdef ENABLE_FETCHLIMIT + fcount_decr(fctx); +#endif /* ENABLE_FETCHLIMIT */ + dns_name_free(&fctx->domain, fctx->mctx); dns_name_init(&fctx->domain, NULL); result = dns_name_dup(&fctx->nsname, fctx->mctx, &fctx->domain); @@ -6662,6 +7009,15 @@ resume_dslookup(isc_task_t *task, isc_event_t *event) { fctx_done(fctx, DNS_R_SERVFAIL, __LINE__); goto cleanup; } + +#ifdef ENABLE_FETCHLIMIT + result = fcount_incr(fctx, ISC_TRUE); + if (result != ISC_R_SUCCESS) { + fctx_done(fctx, DNS_R_SERVFAIL, __LINE__); + goto cleanup; + } +#endif /* ENABLE_FETCHLIMIT */ + /* * Try again. */ @@ -6959,6 +7315,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) { if (fctx->res->exiting) { result = ISC_R_SHUTTINGDOWN; + FCTXTRACE("resolver shutting down"); goto done; } @@ -7013,6 +7370,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) { no_response = ISC_TRUE; } } + FCTXTRACE3("dispatcher failure", devent->result); goto done; } @@ -7020,18 +7378,25 @@ resquery_response(isc_task_t *task, isc_event_t *event) { if (query->tsig != NULL) { result = dns_message_setquerytsig(message, query->tsig); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { + FCTXTRACE3("unable to set query tsig", result); goto done; + } } if (query->tsigkey) { result = dns_message_settsigkey(message, query->tsigkey); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { + FCTXTRACE3("unable to set tsig key", result); goto done; + } } + if ((options & DNS_FETCHOPT_TCP) == 0) + dns_adb_plainresponse(fctx->adb, query->addrinfo); result = dns_message_parse(message, &devent->buffer, 0); if (result != ISC_R_SUCCESS) { + FCTXTRACE3("message failed to parse", result); switch (result) { case ISC_R_UNEXPECTEDEND: if (!message->question_ok || @@ -7114,8 +7479,10 @@ resquery_response(isc_task_t *task, isc_event_t *event) { * returns success anyway. */ result = dns_message_checksig(message, fctx->res->view); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { + FCTXTRACE3("signature check failed", result); goto done; + } /* * The dispatcher should ensure we only get responses with QR set. @@ -7176,6 +7543,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) { options |= DNS_FETCHOPT_TCP; resend = ISC_TRUE; } + FCTXTRACE3("message truncated", result); goto done; } @@ -7186,6 +7554,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) { /* XXXRTH Log */ broken_server = DNS_R_UNEXPECTEDOPCODE; keep_trying = ISC_TRUE; + FCTXTRACE("invalid message opcode"); goto done; } @@ -7214,6 +7583,8 @@ resquery_response(isc_task_t *task, isc_event_t *event) { */ if (message->rcode != dns_rcode_noerror && message->rcode != dns_rcode_nxdomain) { + isc_buffer_t b; + char code[64]; if (((message->rcode == dns_rcode_formerr || message->rcode == dns_rcode_notimp) || (message->rcode == dns_rcode_servfail && @@ -7265,38 +7636,13 @@ resquery_response(isc_task_t *task, isc_event_t *event) { */ result = DNS_R_YXDOMAIN; } else if (message->rcode == dns_rcode_badvers) { - unsigned int flags, mask; - unsigned int version; - - resend = ISC_TRUE; - INSIST(opt != NULL); - version = (opt->ttl >> 16) & 0xff; - flags = (version << DNS_FETCHOPT_EDNSVERSIONSHIFT) | - DNS_FETCHOPT_EDNSVERSIONSET; - mask = DNS_FETCHOPT_EDNSVERSIONMASK | - DNS_FETCHOPT_EDNSVERSIONSET; - /* - * Record that we got a good EDNS response. - */ - if (query->ednsversion > (int)version && - !EDNSOK(query->addrinfo)) { - dns_adb_changeflags(fctx->adb, query->addrinfo, - FCTX_ADDRINFO_EDNSOK, - FCTX_ADDRINFO_EDNSOK); - } /* - * Record the supported EDNS version. + * This should be impossible as we only send EDNS + * version 0 requests and to return BADVERS you + * need to support EDNS as it is a extended rcode. */ - switch (version) { - case 0: - dns_adb_changeflags(fctx->adb, query->addrinfo, - flags, mask); - break; - default: - broken_server = DNS_R_BADVERS; - keep_trying = ISC_TRUE; - break; - } + broken_server = DNS_R_BADVERS; + keep_trying = ISC_TRUE; } else { /* * XXXRTH log. @@ -7305,6 +7651,11 @@ resquery_response(isc_task_t *task, isc_event_t *event) { INSIST(broken_server != ISC_R_SUCCESS); keep_trying = ISC_TRUE; } + + isc_buffer_init(&b, code, sizeof(code) - 1); + dns_rcode_totext(fctx->rmessage->rcode, &b); + code[isc_buffer_usedlength(&b)] = '\0'; + FCTXTRACE2("remote server broken: returned ", code); goto done; } @@ -7316,6 +7667,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) { /* XXXRTH Log */ if (result == DNS_R_FORMERR) keep_trying = ISC_TRUE; + FCTXTRACE3("response did not match question", result); goto done; } @@ -7336,6 +7688,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) { isc_result_totext(result)); broken_server = DNS_R_LAME; keep_trying = ISC_TRUE; + FCTXTRACE("lame server"); goto done; } @@ -7388,22 +7741,31 @@ resquery_response(isc_task_t *task, isc_event_t *event) { */ if ((message->flags & DNS_MESSAGEFLAG_AA) != 0 || ISFORWARDER(query->addrinfo)) + { result = answer_response(fctx); - else if (iscname(fctx) && + if (result != ISC_R_SUCCESS) + FCTXTRACE3("answer_response (AA/fwd)", result); + } else if (iscname(fctx) && fctx->type != dns_rdatatype_any && - fctx->type != dns_rdatatype_cname) { + fctx->type != dns_rdatatype_cname) + { /* * A BIND8 server could return a non-authoritative * answer when a CNAME is followed. We should treat * it as a valid answer. */ result = answer_response(fctx); + if (result != ISC_R_SUCCESS) + FCTXTRACE3("answer_response (!ANY/!CNAME)", + result); } else if (fctx->type != dns_rdatatype_ns && !betterreferral(fctx)) { /* * Lame response !!!. */ result = answer_response(fctx); + if (result != ISC_R_SUCCESS) + FCTXTRACE3("answer_response (!NS)", result); } else { if (fctx->type == dns_rdatatype_ns) { /* @@ -7416,6 +7778,9 @@ resquery_response(isc_task_t *task, isc_event_t *event) { */ result = noanswer_response(fctx, NULL, LOOK_FOR_NS_IN_ANSWER); + if (result != ISC_R_SUCCESS) + FCTXTRACE3("noanswer_response (NS)", + result); } else { /* * Some other servers may still somehow include @@ -7431,6 +7796,8 @@ resquery_response(isc_task_t *task, isc_event_t *event) { */ result = noanswer_response(fctx, NULL, LOOK_FOR_GLUE_IN_ANSWER); + if (result != ISC_R_SUCCESS) + FCTXTRACE3("noanswer_response", result); } if (result != DNS_R_DELEGATION) { /* @@ -7483,6 +7850,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) { fctx->referrals++; fctx->querysent = 0; fctx->lamecount = 0; + fctx->quotacount = 0; fctx->neterr = 0; fctx->badresp = 0; fctx->adberr = 0; @@ -7495,6 +7863,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) { */ if (result == DNS_R_FORMERR) keep_trying = ISC_TRUE; + FCTXTRACE3("noanswer_response", result); goto done; } } else { @@ -7504,6 +7873,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) { /* XXXRTH Log */ broken_server = DNS_R_UNEXPECTEDRCODE; keep_trying = ISC_TRUE; + FCTXTRACE("broken server: unexpected rcode"); goto done; } @@ -7518,8 +7888,10 @@ resquery_response(isc_task_t *task, isc_event_t *event) { */ if (WANTCACHE(fctx)) { result = cache_message(fctx, query->addrinfo, now); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { + FCTXTRACE3("cache_message complete", result); goto done; + } } /* @@ -7542,6 +7914,8 @@ resquery_response(isc_task_t *task, isc_event_t *event) { * Cache any negative cache entries in the message. */ result = ncache_message(fctx, query->addrinfo, covers, now); + if (result != ISC_R_SUCCESS) + FCTXTRACE3("ncache_message complete", result); } done: @@ -7551,6 +7925,10 @@ resquery_response(isc_task_t *task, isc_event_t *event) { */ addrinfo = query->addrinfo; + FCTXTRACE4("query canceled in response(); ", + no_response ? "no response" : "responding", + result); + /* * Cancel the query. * @@ -7604,6 +7982,11 @@ resquery_response(isc_task_t *task, isc_event_t *event) { fctx_done(fctx, DNS_R_SERVFAIL, __LINE__); return; } + +#ifdef ENABLE_FETCHLIMIT + fcount_decr(fctx); +#endif /* ENABLE_FETCHLIMIT */ + dns_name_free(&fctx->domain, fctx->mctx); dns_name_init(&fctx->domain, NULL); result = dns_name_dup(fname, fctx->mctx, &fctx->domain); @@ -7611,6 +7994,15 @@ resquery_response(isc_task_t *task, isc_event_t *event) { fctx_done(fctx, DNS_R_SERVFAIL, __LINE__); return; } + +#ifdef ENABLE_FETCHLIMIT + result = fcount_incr(fctx, ISC_TRUE); + if (result != ISC_R_SUCCESS) { + fctx_done(fctx, DNS_R_SERVFAIL, __LINE__); + return; + } +#endif /* ENABLE_FETCHLIMIT */ + fctx->ns_ttl = fctx->nameservers.ttl; fctx->ns_ttl_ok = ISC_TRUE; fctx_cancelqueries(fctx, ISC_TRUE); @@ -7667,9 +8059,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) { if (result != ISC_R_SUCCESS) fctx_done(fctx, result, __LINE__); else { - LOCK(&fctx->res->buckets[fctx->bucketnum].lock); - fctx->references++; - UNLOCK(&fctx->res->buckets[fctx->bucketnum].lock); + fctx_increference(fctx); result = fctx_stopidletimer(fctx); if (result != ISC_R_SUCCESS) fctx_done(fctx, result, __LINE__); @@ -7733,6 +8123,15 @@ destroy(dns_resolver_t *res) { } isc_mem_put(res->mctx, res->buckets, res->nbuckets * sizeof(fctxbucket_t)); +#ifdef ENABLE_FETCHLIMIT + for (i = 0; i < RES_DOMAIN_BUCKETS; i++) { + INSIST(ISC_LIST_EMPTY(res->dbuckets[i].list)); + isc_mem_detach(&res->dbuckets[i].mctx); + DESTROYLOCK(&res->dbuckets[i].lock); + } + isc_mem_put(res->mctx, res->dbuckets, + RES_DOMAIN_BUCKETS * sizeof(zonebucket_t)); +#endif /* ENABLE_FETCHLIMIT */ if (res->dispatches4 != NULL) dns_dispatchset_destroy(&res->dispatches4); if (res->dispatches6 != NULL) @@ -7842,6 +8241,9 @@ dns_resolver_create(dns_view_t *view, isc_task_t *task = NULL; char name[16]; unsigned dispattr; +#ifdef ENABLE_FETCHLIMIT + unsigned int dbuckets_created = 0; +#endif /* ENABLE_FETCHLIMIT */ /* * Create a resolver. @@ -7878,10 +8280,13 @@ dns_resolver_create(dns_view_t *view, res->spillatmin = res->spillat = 10; res->spillatmax = 100; res->spillattimer = NULL; + res->zspill = 0; res->zero_no_soa_ttl = ISC_FALSE; res->query_timeout = DEFAULT_QUERY_TIMEOUT; res->maxdepth = DEFAULT_RECURSION_DEPTH; res->maxqueries = DEFAULT_MAX_QUERIES; + res->quotaresp[dns_quotatype_zone] = DNS_R_DROP; + res->quotaresp[dns_quotatype_server] = DNS_R_SERVFAIL; res->nbuckets = ntasks; res->activebuckets = ntasks; res->buckets = isc_mem_get(view->mctx, @@ -7924,6 +8329,26 @@ dns_resolver_create(dns_view_t *view, buckets_created++; } +#ifdef ENABLE_FETCHLIMIT + res->dbuckets = isc_mem_get(view->mctx, + RES_DOMAIN_BUCKETS * sizeof(zonebucket_t)); + if (res->dbuckets == NULL) { + result = ISC_R_NOMEMORY; + goto cleanup_buckets; + } + for (i = 0; i < RES_DOMAIN_BUCKETS; i++) { + ISC_LIST_INIT(res->dbuckets[i].list); + res->dbuckets[i].mctx = NULL; + isc_mem_attach(view->mctx, &res->dbuckets[i].mctx); + result = isc_mutex_init(&res->dbuckets[i].lock); + if (result != ISC_R_SUCCESS) { + isc_mem_detach(&res->dbuckets[i].mctx); + goto cleanup_dbuckets; + } + dbuckets_created++; + } +#endif /* ENABLE_FETCHLIMIT */ + res->dispatches4 = NULL; if (dispatchv4 != NULL) { dns_dispatchset_create(view->mctx, socketmgr, taskmgr, @@ -8017,6 +8442,16 @@ dns_resolver_create(dns_view_t *view, if (res->dispatches4 != NULL) dns_dispatchset_destroy(&res->dispatches4); +#ifdef ENABLE_FETCHLIMIT + cleanup_dbuckets: + for (i = 0; i < dbuckets_created; i++) { + DESTROYLOCK(&res->dbuckets[i].lock); + isc_mem_detach(&res->dbuckets[i].mctx); + } + isc_mem_put(view->mctx, res->dbuckets, + RES_DOMAIN_BUCKETS * sizeof(zonebucket_t)); +#endif /* ENABLE_FETCHLIMIT*/ + cleanup_buckets: for (i = 0; i < buckets_created; i++) { isc_mem_detach(&res->buckets[i].mctx); @@ -8298,6 +8733,10 @@ log_fetch(dns_name_t *name, dns_rdatatype_t type) { char typebuf[DNS_RDATATYPE_FORMATSIZE]; int level = ISC_LOG_DEBUG(1); + /* + * If there's no chance of logging it, don't render (format) the + * name and RDATA type (further below), and return early. + */ if (! isc_log_wouldlog(dns_lctx, level)) return; @@ -8366,7 +8805,7 @@ dns_resolver_createfetch3(dns_resolver_t *res, dns_name_t *name, unsigned int count = 0; unsigned int spillat; unsigned int spillatmin; - isc_boolean_t destroy = ISC_FALSE; + isc_boolean_t dodestroy = ISC_FALSE; UNUSED(forwarders); @@ -8471,14 +8910,14 @@ dns_resolver_createfetch3(dns_resolver_t *res, dns_name_t *name, * since we know we're not exiting. */ (void)fctx_unlink(fctx); - destroy = ISC_TRUE; + dodestroy = ISC_TRUE; } } unlock: UNLOCK(&res->buckets[bucketnum].lock); - if (destroy) + if (dodestroy) fctx_destroy(fctx); if (result == ISC_R_SUCCESS) { @@ -8607,8 +9046,12 @@ dns_resolver_logfetch(dns_fetch_t *fetch, isc_log_t *lctx, "%" ISC_PRINT_QUADFORMAT "u." "%06" ISC_PRINT_QUADFORMAT "u: %s/%s " "[domain:%s,referral:%u,restart:%u,qrysent:%u," - "timeout:%u,lame:%u,neterr:%u,badresp:%u," - "adberr:%u,findfail:%u,valfail:%u]", + "timeout:%u,lame:%u," +#ifdef ENABLE_FETCHLIMIT + "quota:%u," +#endif /* ENABLE_FETCHLIMIT */ + "neterr:%u," + "badresp:%u,adberr:%u,findfail:%u,valfail:%u]", __FILE__, fctx->exitline, fctx->info, fctx->duration / US_PER_SEC, fctx->duration % US_PER_SEC, @@ -8616,6 +9059,9 @@ dns_resolver_logfetch(dns_fetch_t *fetch, isc_log_t *lctx, isc_result_totext(fctx->vresult), domainbuf, fctx->referrals, fctx->restarts, fctx->querysent, fctx->timeouts, fctx->lamecount, +#ifdef ENABLE_FETCHLIMIT + fctx->quotacount, +#endif /* ENABLE_FETCHLIMIT */ fctx->neterr, fctx->badresp, fctx->adberr, fctx->findfail, fctx->valfail); fctx->logged = ISC_TRUE; @@ -8724,6 +9170,11 @@ dns_resolver_flushbadcache(dns_resolver_t *resolver, dns_name_t *name) { unsigned int i; dns_badcache_t *bad, *prev, *next; + /* + * Drop all entries that match the name, and also all expired + * entries from the badcache. + */ + REQUIRE(VALID_RESOLVER(resolver)); LOCK(&resolver->lock); @@ -8767,6 +9218,13 @@ resizehash(dns_resolver_t *resolver, isc_time_t *now, isc_boolean_t grow) { dns_badcache_t **new, *bad, *next; unsigned int i; + /* + * The number of buckets in the hashtable is modified in this + * function. Afterwards, all the entries are remapped into the + * corresponding new slot. Rehashing (hash computation) is + * unnecessary as the hash values had been saved. + */ + if (grow) newsize = resolver->badhash * 2 + 1; else @@ -8777,6 +9235,13 @@ resizehash(dns_resolver_t *resolver, isc_time_t *now, isc_boolean_t grow) { if (new == NULL) return; memset(new, 0, sizeof(*resolver->badcache) * newsize); + + /* + * Because the hashtable implements a simple modulus mapping + * from hash to bucket (no extendible hashing is used), every + * name in the hashtable has to be remapped to its new slot. + * Entries that have expired (time) are dropped. + */ for (i = 0; i < resolver->badhash; i++) { for (bad = resolver->badcache[i]; bad != NULL; bad = next) { next = bad->next; @@ -8805,6 +9270,18 @@ dns_resolver_addbadcache(dns_resolver_t *resolver, dns_name_t *name, unsigned int i, hashval; dns_badcache_t *bad, *prev, *next; + /* + * The badcache is implemented as a hashtable keyed on the name, + * and each bucket slot points to a linked list (separate + * chaining). + * + * To avoid long list chains, if the number of entries in the + * hashtable goes over number-of-buckets * 8, the + * number-of-buckets is doubled. Similarly, if the number of + * entries goes below number-of-buckets * 2, the number-of-buckets + * is halved. See resizehash(). + */ + REQUIRE(VALID_RESOLVER(resolver)); LOCK(&resolver->lock); @@ -8829,6 +9306,7 @@ dns_resolver_addbadcache(dns_resolver_t *resolver, dns_name_t *name, next = bad->next; if (bad->type == type && dns_name_equal(name, &bad->name)) break; + /* Drop expired entries when walking the chain. */ if (isc_time_compare(&bad->expire, &now) < 0) { if (prev == NULL) resolver->badcache[i] = bad->next; @@ -8841,6 +9319,12 @@ dns_resolver_addbadcache(dns_resolver_t *resolver, dns_name_t *name, prev = bad; } if (bad == NULL) { + /* + * Insert the name into the badcache hashtable at the + * head of the linked list at the appropriate slot. The + * name data follows right after the allocation for the + * linked list node. + */ isc_buffer_t buffer; bad = isc_mem_get(resolver->mctx, sizeof(*bad) + name->length); if (bad == NULL) @@ -8999,6 +9483,12 @@ dns_resolver_disable_algorithm(dns_resolver_t *resolver, dns_name_t *name, isc_result_t result; dns_rbtnode_t *node = NULL; + /* + * Whether an algorithm is disabled (or not) is stored in a + * per-name bitfield that is stored as the node data of an + * RBT. + */ + REQUIRE(VALID_RESOLVER(resolver)); if (alg > 255) return (ISC_R_RANGE); @@ -9020,7 +9510,17 @@ dns_resolver_disable_algorithm(dns_resolver_t *resolver, dns_name_t *name, if (result == ISC_R_SUCCESS || result == ISC_R_EXISTS) { algorithms = node->data; + /* + * If algorithms is set, algorithms[0] contains its + * length. + */ if (algorithms == NULL || len > *algorithms) { + /* + * If no bitfield exists in the node data, or if + * it is not long enough, allocate a new + * bitfield and copy the old (smaller) bitfield + * into it if one exists. + */ new = isc_mem_get(resolver->mctx, len); if (new == NULL) { result = ISC_R_NOMEMORY; @@ -9030,8 +9530,10 @@ dns_resolver_disable_algorithm(dns_resolver_t *resolver, dns_name_t *name, if (algorithms != NULL) memmove(new, algorithms, *algorithms); new[len-1] |= mask; + /* new[0] should contain the length of new. */ *new = len; node->data = new; + /* Free the older bitfield. */ if (algorithms != NULL) isc_mem_put(resolver->mctx, algorithms, *algorithms); @@ -9058,6 +9560,12 @@ dns_resolver_algorithm_supported(dns_resolver_t *resolver, dns_name_t *name, REQUIRE(VALID_RESOLVER(resolver)); + /* + * DH is unsupported for DNSKEYs, see RFC 4034 sec. A.1. + */ + if ((alg == DST_ALG_DH) || (alg == DST_ALG_INDIRECT)) + return (ISC_FALSE); + #if USE_ALGLOCK RWLOCK(&resolver->alglock, isc_rwlocktype_read); #endif @@ -9077,6 +9585,7 @@ dns_resolver_algorithm_supported(dns_resolver_t *resolver, dns_name_t *name, #endif if (found) return (ISC_FALSE); + return (dst_algorithm_supported(alg)); } @@ -9181,6 +9690,24 @@ dns_resolver_setclientsperquery(dns_resolver_t *resolver, isc_uint32_t min, UNLOCK(&resolver->lock); } +void +dns_resolver_setfetchesperzone(dns_resolver_t *resolver, isc_uint32_t clients) +{ +#ifdef ENABLE_FETCHLIMIT + REQUIRE(VALID_RESOLVER(resolver)); + + LOCK(&resolver->lock); + resolver->zspill = clients; + UNLOCK(&resolver->lock); +#else + UNUSED(resolver); + UNUSED(clients); + + return; +#endif /* !ENABLE_FETCHLIMIT */ +} + + isc_boolean_t dns_resolver_getzeronosoattl(dns_resolver_t *resolver) { REQUIRE(VALID_RESOLVER(resolver)); @@ -9246,3 +9773,67 @@ dns_resolver_getmaxqueries(dns_resolver_t *resolver) { REQUIRE(VALID_RESOLVER(resolver)); return (resolver->maxqueries); } + +void +dns_resolver_dumpfetches(dns_resolver_t *resolver, FILE *fp) { +#ifdef ENABLE_FETCHLIMIT + int i; + + REQUIRE(VALID_RESOLVER(resolver)); + REQUIRE(fp != NULL); + + for (i = 0; i < RES_DOMAIN_BUCKETS; i++) { + fctxcount_t *fc; + LOCK(&resolver->dbuckets[i].lock); + for (fc = ISC_LIST_HEAD(resolver->dbuckets[i].list); + fc != NULL; + fc = ISC_LIST_NEXT(fc, link)) + { + dns_name_print(fc->domain, fp); + fprintf(fp, ": %d active (%d spilled, %d allowed)\n", + fc->count, fc->dropped, fc->allowed); + } + UNLOCK(&resolver->dbuckets[i].lock); + } +#else + UNUSED(resolver); + UNUSED(fp); + + return; +#endif /* !ENABLE_FETCHLIMIT */ +} + +void +dns_resolver_setquotaresponse(dns_resolver_t *resolver, + dns_quotatype_t which, isc_result_t resp) +{ +#ifdef ENABLE_FETCHLIMIT + REQUIRE(VALID_RESOLVER(resolver)); + REQUIRE(which == dns_quotatype_zone || which == dns_quotatype_server); + REQUIRE(resp == DNS_R_DROP || resp == DNS_R_SERVFAIL); + + resolver->quotaresp[which] = resp; +#else + UNUSED(resolver); + UNUSED(which); + UNUSED(resp); + + return; +#endif /* !ENABLE_FETCHLIMIT */ +} + +isc_result_t +dns_resolver_getquotaresponse(dns_resolver_t *resolver, dns_quotatype_t which) +{ +#ifdef ENABLE_FETCHLIMIT + REQUIRE(VALID_RESOLVER(resolver)); + REQUIRE(which == dns_quotatype_zone || which == dns_quotatype_server); + + return (resolver->quotaresp[which]); +#else + UNUSED(resolver); + UNUSED(which); + + return (ISC_R_NOTIMPLEMENTED); +#endif /* !ENABLE_FETCHLIMIT */ +} diff --git a/lib/dns/result.c b/lib/dns/result.c index 39879532d485..7be4f577ed86 100644 --- a/lib/dns/result.c +++ b/lib/dns/result.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007-2013 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007-2013, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -162,7 +162,12 @@ static const char *text[DNS_R_NRESULTS] = { "broken trust chain", /*%< 106 DNS_R_BROKENCHAIN */ "expired", /*%< 107 DNS_R_EXPIRED */ "not dynamic", /*%< 108 DNS_R_NOTDYNAMIC */ - "bad EUI" /*%< 109 DNS_R_BADEUI */ + "bad EUI", /*%< 109 DNS_R_BADEUI */ + + "covered by negative trust anchor", /*%< 110 DNS_R_NTACOVERED */ + "bad CDS", /*%< 111 DNS_R_BADCSD */ + "bad CDNSKEY", /*%< 112 DNS_R_BADCDNSKEY */ + "malformed OPT option" /*%< 113 DNS_R_OPTERR */ }; static const char *rcode_text[DNS_R_NRCODERESULTS] = { @@ -238,6 +243,7 @@ dns_result_torcode(isc_result_t result) { */ return ((dns_rcode_t)((result) & 0xFFF)); } + /* * Try to supply an appropriate rcode. */ @@ -267,6 +273,7 @@ dns_result_torcode(isc_result_t result) { case DNS_R_TSIGERRORSET: case DNS_R_UNKNOWN: case DNS_R_NAMETOOLONG: + case DNS_R_OPTERR: rcode = dns_rcode_formerr; break; case DNS_R_DISALLOWED: diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index 3dd80664c7dc..dc8c2c920443 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -14,9 +14,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id$ */ - - /*! \file */ #include <config.h> @@ -741,13 +738,14 @@ diff_keys(const dns_rpz_cidr_key_t *key1, dns_rpz_cidr_bits_t bits1, dns_rpz_cidr_bits_t maxbit, bit; int i; + bit = 0; maxbit = ISC_MIN(bits1, bits2); /* * find the first differing words */ - for (i = 0, bit = 0; - bit <= maxbit; + for (i = 0; + bit < maxbit; i++, bit += DNS_RPZ_CIDR_WORD_BITS) { delta = key1->w[i] ^ key2->w[i]; if (delta != 0) { diff --git a/lib/dns/rrl.c b/lib/dns/rrl.c index 08fc8e712ffa..0c247e95cf7f 100644 --- a/lib/dns/rrl.c +++ b/lib/dns/rrl.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -376,7 +376,7 @@ hash_key(const dns_rrl_key_t *key) { int i; hval = key->w[0]; - for (i = sizeof(*key) / sizeof(key->w[0]) - 1; i >= 0; --i) { + for (i = sizeof(key->w) / sizeof(key->w[0]) - 1; i >= 0; --i) { hval = key->w[i] + (hval<<1); } return (hval); @@ -1161,22 +1161,17 @@ dns_rrl(dns_view_t *view, client_addr, now, log_buf, log_buf_len); if (rrl_all_result != DNS_RRL_RESULT_OK) { - int level; - e = e_all; rrl_result = rrl_all_result; - if (rrl_result == DNS_RRL_RESULT_OK) - level = DNS_RRL_LOG_DEBUG2; - else - level = DNS_RRL_LOG_DEBUG1; - if (isc_log_wouldlog(dns_lctx, level)) { + if (isc_log_wouldlog(dns_lctx, DNS_RRL_LOG_DEBUG1)) { make_log_buf(rrl, e, "prefer all-per-second limiting ", NULL, ISC_TRUE, qname, ISC_FALSE, DNS_RRL_RESULT_OK, resp_result, log_buf, log_buf_len); isc_log_write(dns_lctx, DNS_LOGCATEGORY_RRL, - DNS_LOGMODULE_REQUEST, level, + DNS_LOGMODULE_REQUEST, + DNS_RRL_LOG_DEBUG1, "%s", log_buf); } } diff --git a/lib/dns/sdb.c b/lib/dns/sdb.c index 191fda219f46..f0ffc3d6f384 100644 --- a/lib/dns/sdb.c +++ b/lib/dns/sdb.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2012 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2012, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -305,12 +305,10 @@ dns_sdb_putrdata(dns_sdblookup_t *lookup, dns_rdatatype_t typeval, rdatalist = isc_mem_get(mctx, sizeof(dns_rdatalist_t)); if (rdatalist == NULL) return (ISC_R_NOMEMORY); + dns_rdatalist_init(rdatalist); rdatalist->rdclass = lookup->sdb->common.rdclass; rdatalist->type = typeval; - rdatalist->covers = 0; rdatalist->ttl = ttl; - ISC_LIST_INIT(rdatalist->rdata); - ISC_LINK_INIT(rdatalist, link); ISC_LIST_APPEND(lookup->lists, rdatalist, link); } else if (rdatalist->ttl != ttl) @@ -1246,9 +1244,9 @@ ispersistent(dns_db_t *db) { } static void -overmem(dns_db_t *db, isc_boolean_t overmem) { +overmem(dns_db_t *db, isc_boolean_t over) { UNUSED(db); - UNUSED(overmem); + UNUSED(over); } static void diff --git a/lib/dns/sdlz.c b/lib/dns/sdlz.c index 9d4e615802fa..3b245419d099 100644 --- a/lib/dns/sdlz.c +++ b/lib/dns/sdlz.c @@ -1,5 +1,5 @@ /* - * Portions Copyright (C) 2005-2012 Internet Systems Consortium, Inc. ("ISC") + * Portions Copyright (C) 2005-2012, 2015 Internet Systems Consortium, Inc. ("ISC") * Portions Copyright (C) 1999-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -1190,9 +1190,9 @@ ispersistent(dns_db_t *db) { } static void -overmem(dns_db_t *db, isc_boolean_t overmem) { +overmem(dns_db_t *db, isc_boolean_t over) { UNUSED(db); - UNUSED(overmem); + UNUSED(over); } static void @@ -1805,12 +1805,10 @@ dns_sdlz_putrr(dns_sdlzlookup_t *lookup, const char *type, dns_ttl_t ttl, rdatalist = isc_mem_get(mctx, sizeof(dns_rdatalist_t)); if (rdatalist == NULL) return (ISC_R_NOMEMORY); + dns_rdatalist_init(rdatalist); rdatalist->rdclass = lookup->sdlz->common.rdclass; rdatalist->type = typeval; - rdatalist->covers = 0; rdatalist->ttl = ttl; - ISC_LIST_INIT(rdatalist->rdata); - ISC_LINK_INIT(rdatalist, link); ISC_LIST_APPEND(lookup->lists, rdatalist, link); } else if (rdatalist->ttl > ttl) { diff --git a/lib/dns/spnego.c b/lib/dns/spnego.c index 2da79f8b55ce..0de332fc6a68 100644 --- a/lib/dns/spnego.c +++ b/lib/dns/spnego.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2006-2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -14,8 +14,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id$ */ - /*! \file * \brief * Portable SPNEGO implementation. @@ -146,6 +144,7 @@ #include <isc/mem.h> #include <isc/once.h> #include <isc/random.h> +#include <isc/safe.h> #include <isc/string.h> #include <isc/time.h> #include <isc/util.h> @@ -372,7 +371,7 @@ gssapi_spnego_decapsulate(OM_uint32 *, /* mod_auth_kerb.c */ static int -cmp_gss_type(gss_buffer_t token, gss_OID oid) +cmp_gss_type(gss_buffer_t token, gss_OID gssoid) { unsigned char *p; size_t len; @@ -392,10 +391,10 @@ cmp_gss_type(gss_buffer_t token, gss_OID oid) if (*p++ != 0x06) return (GSS_S_DEFECTIVE_TOKEN); - if (((OM_uint32) *p++) != oid->length) + if (((OM_uint32) *p++) != gssoid->length) return (GSS_S_DEFECTIVE_TOKEN); - return (memcmp(p, oid->elements, oid->length)); + return (isc_safe_memcompare(p, gssoid->elements, gssoid->length)); } /* accept_sec_context.c */ @@ -635,16 +634,18 @@ gss_accept_sec_context_spnego(OM_uint32 *minor_status, return (GSS_S_DEFECTIVE_TOKEN); } if (mech_len == GSS_KRB5_MECH->length && - memcmp(GSS_KRB5_MECH->elements, - mechbuf + sizeof(mechbuf) - mech_len, - mech_len) == 0) { + isc_safe_memequal(GSS_KRB5_MECH->elements, + mechbuf + sizeof(mechbuf) - mech_len, + mech_len)) + { found = 1; break; } if (mech_len == GSS_MSKRB5_MECH->length && - memcmp(GSS_MSKRB5_MECH->elements, - mechbuf + sizeof(mechbuf) - mech_len, - mech_len) == 0) { + isc_safe_memequal(GSS_MSKRB5_MECH->elements, + mechbuf + sizeof(mechbuf) - mech_len, + mech_len)) + { found = 1; if (i == 0) pref = GSS_MSKRB5_MECH; @@ -715,7 +716,7 @@ gssapi_verify_mech_header(u_char ** str, p += foo; if (mech_len != mech->length) return (GSS_S_BAD_MECH); - if (memcmp(p, mech->elements, mech->length) != 0) + if (!isc_safe_memequal(p, mech->elements, mech->length)) return (GSS_S_BAD_MECH); p += mech_len; *str = p; @@ -1668,7 +1669,7 @@ spnego_reply(OM_uint32 *minor_status, buf = input_token->value; buf_size = input_token->length; } else if ((size_t)mech_len == GSS_KRB5_MECH->length && - memcmp(GSS_KRB5_MECH->elements, p, mech_len) == 0) + isc_safe_memequal(GSS_KRB5_MECH->elements, p, mech_len)) return (gss_init_sec_context(minor_status, initiator_cred_handle, context_handle, @@ -1683,7 +1684,7 @@ spnego_reply(OM_uint32 *minor_status, ret_flags, time_rec)); else if ((size_t)mech_len == GSS_SPNEGO_MECH->length && - memcmp(GSS_SPNEGO_MECH->elements, p, mech_len) == 0) { + isc_safe_memequal(GSS_SPNEGO_MECH->elements, p, mech_len)) { ret = gssapi_spnego_decapsulate(minor_status, input_token, &buf, @@ -1721,9 +1722,9 @@ spnego_reply(OM_uint32 *minor_status, resp.supportedMech, &oidlen); if (ret || oidlen != GSS_KRB5_MECH->length || - memcmp(oidbuf + sizeof(oidbuf) - oidlen, - GSS_KRB5_MECH->elements, - oidlen) != 0) { + !isc_safe_memequal(oidbuf + sizeof(oidbuf) - oidlen, + GSS_KRB5_MECH->elements, oidlen)) + { free_NegTokenResp(&resp); return GSS_S_BAD_MECH; } diff --git a/lib/dns/tcpmsg.c b/lib/dns/tcpmsg.c index 49add56f37a6..bffb0c50c145 100644 --- a/lib/dns/tcpmsg.c +++ b/lib/dns/tcpmsg.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2007, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -22,6 +22,7 @@ #include <config.h> #include <isc/mem.h> +#include <isc/print.h> #include <isc/task.h> #include <isc/util.h> diff --git a/lib/dns/tkey.c b/lib/dns/tkey.c index 0bfc7ef6c5dc..0b5440a67d80 100644 --- a/lib/dns/tkey.c +++ b/lib/dns/tkey.c @@ -15,9 +15,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* - * $Id$ - */ /*! \file */ #include <config.h> @@ -25,6 +22,7 @@ #include <isc/entropy.h> #include <isc/md5.h> #include <isc/mem.h> +#include <isc/print.h> #include <isc/string.h> #include <isc/util.h> @@ -45,6 +43,7 @@ #include <dst/dst.h> #include <dst/gssapi.h> +#define TEMP_BUFFER_SZ 8192 #define TKEY_RANDOM_AMOUNT 16 #define RETERR(x) do { \ @@ -67,19 +66,38 @@ tkey_log(const char *fmt, ...) { } static void -_dns_tkey_dumpmessage(dns_message_t *msg) { +dumpmessage(dns_message_t *msg) { isc_buffer_t outbuf; - unsigned char output[4096]; + unsigned char *output; + int len = TEMP_BUFFER_SZ; isc_result_t result; - isc_buffer_init(&outbuf, output, sizeof(output)); - result = dns_message_totext(msg, &dns_master_style_debug, 0, - &outbuf); - if (result != ISC_R_SUCCESS) - fprintf(stderr, "Warning: dns_message_totext returned: %s\n", - dns_result_totext(result)); - fprintf(stderr, "%.*s\n", (int)isc_buffer_usedlength(&outbuf), - (char *)isc_buffer_base(&outbuf)); + for (;;) { + output = isc_mem_get(msg->mctx, len); + if (output == NULL) + return; + + isc_buffer_init(&outbuf, output, len); + result = dns_message_totext(msg, &dns_master_style_debug, + 0, &outbuf); + if (result == ISC_R_NOSPACE) { + isc_mem_put(msg->mctx, output, len); + len *= 2; + continue; + } + + if (result == ISC_R_SUCCESS) + tkey_log("%.*s", + (int)isc_buffer_usedlength(&outbuf), + (char *)isc_buffer_base(&outbuf)); + else + tkey_log("Warning: dns_message_totext: %s", + dns_result_totext(result)); + break; + } + + if (output != NULL) + isc_mem_put(msg->mctx, output, len); } isc_result_t @@ -163,9 +181,7 @@ add_rdata_to_list(dns_message_t *msg, dns_name_t *name, dns_rdata_t *rdata, RETERR(dns_message_gettemprdatalist(msg, &newlist)); newlist->rdclass = newrdata->rdclass; newlist->type = newrdata->type; - newlist->covers = 0; newlist->ttl = ttl; - ISC_LIST_INIT(newlist->rdata); ISC_LIST_APPEND(newlist->rdata, newrdata, link); RETERR(dns_message_gettemprdataset(msg, &newset)); @@ -862,6 +878,7 @@ buildquery(dns_message_t *msg, dns_name_t *name, dns_rdata_t *rdata = NULL; isc_buffer_t *dynbuf = NULL, *anamebuf = NULL, *qnamebuf = NULL; isc_result_t result; + unsigned int len; REQUIRE(msg != NULL); REQUIRE(name != NULL); @@ -875,9 +892,10 @@ buildquery(dns_message_t *msg, dns_name_t *name, dns_rdataset_makequestion(question, dns_rdataclass_any, dns_rdatatype_tkey); - RETERR(isc_buffer_allocate(msg->mctx, &dynbuf, 4096)); - RETERR(isc_buffer_allocate(msg->mctx, &anamebuf, DNS_NAME_MAXWIRE)); - RETERR(isc_buffer_allocate(msg->mctx, &qnamebuf, DNS_NAME_MAXWIRE)); + len = 16 + tkey->algorithm.length + tkey->keylen + tkey->otherlen; + RETERR(isc_buffer_allocate(msg->mctx, &dynbuf, len)); + RETERR(isc_buffer_allocate(msg->mctx, &anamebuf, name->length)); + RETERR(isc_buffer_allocate(msg->mctx, &qnamebuf, name->length)); RETERR(dns_message_gettemprdata(msg, &rdata)); RETERR(dns_rdata_fromstruct(rdata, dns_rdataclass_any, @@ -887,9 +905,6 @@ buildquery(dns_message_t *msg, dns_name_t *name, RETERR(dns_message_gettemprdatalist(msg, &tkeylist)); tkeylist->rdclass = dns_rdataclass_any; tkeylist->type = dns_rdatatype_tkey; - tkeylist->covers = 0; - tkeylist->ttl = 0; - ISC_LIST_INIT(tkeylist->rdata); ISC_LIST_APPEND(tkeylist->rdata, rdata, link); RETERR(dns_message_gettemprdataset(msg, &tkeyset)); @@ -897,10 +912,10 @@ buildquery(dns_message_t *msg, dns_name_t *name, RETERR(dns_rdatalist_tordataset(tkeylist, tkeyset)); dns_name_init(qname, NULL); - dns_name_copy(name, qname, qnamebuf); + RETERR(dns_name_copy(name, qname, qnamebuf)); dns_name_init(aname, NULL); - dns_name_copy(name, aname, anamebuf); + RETERR(dns_name_copy(name, aname, anamebuf)); ISC_LIST_APPEND(qname->list, question, link); ISC_LIST_APPEND(aname->list, tkeyset, link); @@ -935,7 +950,6 @@ buildquery(dns_message_t *msg, dns_name_t *name, isc_buffer_free(&qnamebuf); if (anamebuf != NULL) isc_buffer_free(&anamebuf); - printf("buildquery error\n"); return (result); } @@ -1027,7 +1041,7 @@ dns_tkey_buildgssquery(dns_message_t *msg, dns_name_t *name, dns_name_t *gname, isc_result_t result; isc_stdtime_t now; isc_buffer_t token; - unsigned char array[4096]; + unsigned char array[TEMP_BUFFER_SZ]; UNUSED(intoken); @@ -1064,12 +1078,7 @@ dns_tkey_buildgssquery(dns_message_t *msg, dns_name_t *name, dns_name_t *gname, tkey.other = NULL; tkey.otherlen = 0; - RETERR(buildquery(msg, name, &tkey, win2k)); - - return (ISC_R_SUCCESS); - - failure: - return (result); + return (buildquery(msg, name, &tkey, win2k)); } isc_result_t @@ -1299,8 +1308,8 @@ dns_tkey_processgssresponse(dns_message_t *qmsg, dns_message_t *rmsg, !dns_name_equal(&rtkey.algorithm, &qtkey.algorithm)) { tkey_log("dns_tkey_processgssresponse: tkey mode invalid " "or error set(2) %d", rtkey.error); - _dns_tkey_dumpmessage(qmsg); - _dns_tkey_dumpmessage(rmsg); + dumpmessage(qmsg); + dumpmessage(rmsg); result = DNS_R_INVALIDTKEY; goto failure; } diff --git a/lib/dns/tsig.c b/lib/dns/tsig.c index 307cb2577b41..05f98ad7bb27 100644 --- a/lib/dns/tsig.c +++ b/lib/dns/tsig.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -1133,9 +1133,6 @@ dns_tsig_sign(dns_message_t *msg) { goto cleanup_rdatalist; datalist->rdclass = dns_rdataclass_any; datalist->type = dns_rdatatype_tsig; - datalist->covers = 0; - datalist->ttl = 0; - ISC_LIST_INIT(datalist->rdata); ISC_LIST_APPEND(datalist->rdata, rdata, link); dns_rdataset_init(dataset); RUNTIME_CHECK(dns_rdatalist_tordataset(datalist, dataset) @@ -1343,6 +1340,8 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg, } if (tsig.siglen > 0) { + isc_uint16_t addcount_n; + sig_r.base = tsig.signature; sig_r.length = tsig.siglen; @@ -1378,7 +1377,8 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg, * Decrement the additional field counter. */ memmove(&addcount, &header[DNS_MESSAGE_HEADERLEN - 2], 2); - addcount = htons((isc_uint16_t)(ntohs(addcount) - 1)); + addcount_n = ntohs(addcount); + addcount = htons((isc_uint16_t)(addcount_n - 1)); memmove(&header[DNS_MESSAGE_HEADERLEN - 2], &addcount, 2); /* @@ -1617,8 +1617,11 @@ tsig_verify_tcp(isc_buffer_t *source, dns_message_t *msg) { * Decrement the additional field counter if necessary. */ if (has_tsig) { + isc_uint16_t addcount_n; + memmove(&addcount, &header[DNS_MESSAGE_HEADERLEN - 2], 2); - addcount = htons((isc_uint16_t)(ntohs(addcount) - 1)); + addcount_n = ntohs(addcount); + addcount = htons((isc_uint16_t)(addcount_n - 1)); memmove(&header[DNS_MESSAGE_HEADERLEN - 2], &addcount, 2); } diff --git a/lib/dns/update.c b/lib/dns/update.c index e727c347ce93..268e25047241 100644 --- a/lib/dns/update.c +++ b/lib/dns/update.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2013 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2011-2013, 2015 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -19,6 +19,8 @@ #include <config.h> #include <isc/log.h> +#include <isc/magic.h> +#include <isc/mem.h> #include <isc/netaddr.h> #include <isc/print.h> #include <isc/serial.h> @@ -58,6 +60,9 @@ /**************************************************************************/ +#define STATE_MAGIC ISC_MAGIC('S', 'T', 'T', 'E') +#define DNS_STATE_VALID(state) ISC_MAGIC_VALID(state, STATE_MAGIC) + /*% * Log level for tracing dynamic update protocol requests. */ @@ -563,6 +568,7 @@ rrset_visible(dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, result = ISC_R_SUCCESS; break; default: + *visible = ISC_FALSE; /* silence false compiler warning */ break; } return (result); @@ -1134,8 +1140,15 @@ add_sigs(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, if (type == dns_rdatatype_dnskey) { if (!KSK(keys[i]) && keyset_kskonly) continue; - } else if (KSK(keys[i])) - continue; + } else if (KSK(keys[i])) { + /* + * CDS and CDNSKEY are signed with KSK + * (RFC 7344, 4.1). + */ + if (type != dns_rdatatype_cds && + type != dns_rdatatype_cdnskey) + continue; + } } else if (REVOKE(keys[i]) && type != dns_rdatatype_dnskey) continue; @@ -1250,7 +1263,8 @@ add_exposed_sigs(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, isc_boolean_t cut, dns_diff_t *diff, dst_key_t **keys, unsigned int nkeys, isc_stdtime_t inception, isc_stdtime_t expire, - isc_boolean_t check_ksk, isc_boolean_t keyset_kskonly) + isc_boolean_t check_ksk, isc_boolean_t keyset_kskonly, + unsigned int *sigs) { isc_result_t result; dns_dbnode_t *node; @@ -1296,10 +1310,11 @@ add_exposed_sigs(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, if (flag) continue;; result = add_sigs(log, zone, db, ver, name, type, diff, - keys, nkeys, inception, expire, - check_ksk, keyset_kskonly); + keys, nkeys, inception, expire, + check_ksk, keyset_kskonly); if (result != ISC_R_SUCCESS) goto cleanup_iterator; + (*sigs)++; } if (result == ISC_R_NOMORE) result = ISC_R_SUCCESS; @@ -1329,519 +1344,684 @@ dns_update_signatures(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *oldver, dns_dbversion_t *newver, dns_diff_t *diff, isc_uint32_t sigvalidityinterval) { - isc_result_t result; - dns_difftuple_t *t; + return (dns_update_signaturesinc(log, zone, db, oldver, newver, diff, + sigvalidityinterval, NULL)); +} + +struct dns_update_state { + unsigned int magic; dns_diff_t diffnames; dns_diff_t affected; dns_diff_t sig_diff; dns_diff_t nsec_diff; dns_diff_t nsec_mindiff; - isc_boolean_t flag, build_nsec, build_nsec3; + dns_diff_t work; dst_key_t *zone_keys[DNS_MAXZONEKEYS]; - unsigned int nkeys = 0; - unsigned int i; - isc_stdtime_t now, inception, expire; + unsigned int nkeys; + isc_stdtime_t inception, expire; dns_ttl_t nsecttl; + isc_boolean_t check_ksk, keyset_kskonly; + enum { sign_updates, remove_orphaned, build_chain, process_nsec, + sign_nsec, update_nsec3, process_nsec3, sign_nsec3 } state; +}; + +isc_result_t +dns_update_signaturesinc(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, + dns_dbversion_t *oldver, dns_dbversion_t *newver, + dns_diff_t *diff, isc_uint32_t sigvalidityinterval, + dns_update_state_t **statep) +{ + isc_result_t result = ISC_R_SUCCESS; + dns_update_state_t mystate, *state; + + dns_difftuple_t *t, *next; + isc_boolean_t flag, build_nsec, build_nsec3; + unsigned int i; + isc_stdtime_t now; dns_rdata_soa_t soa; dns_rdata_t rdata = DNS_RDATA_INIT; dns_rdataset_t rdataset; dns_dbnode_t *node = NULL; - isc_boolean_t check_ksk, keyset_kskonly; isc_boolean_t unsecure; isc_boolean_t cut; dns_rdatatype_t privatetype = dns_zone_getprivatetype(zone); + unsigned int sigs = 0; + unsigned int maxsigs = dns_zone_getsignatures(zone); - dns_diff_init(diff->mctx, &diffnames); - dns_diff_init(diff->mctx, &affected); - - dns_diff_init(diff->mctx, &sig_diff); - dns_diff_init(diff->mctx, &nsec_diff); - dns_diff_init(diff->mctx, &nsec_mindiff); - - result = find_zone_keys(zone, db, newver, diff->mctx, - DNS_MAXZONEKEYS, zone_keys, &nkeys); - if (result != ISC_R_SUCCESS) { - update_log(log, zone, ISC_LOG_ERROR, - "could not get zone keys for secure dynamic update"); - goto failure; - } - - isc_stdtime_get(&now); - inception = now - 3600; /* Allow for some clock skew. */ - expire = now + sigvalidityinterval; - - /* - * Do we look at the KSK flag on the DNSKEY to determining which - * keys sign which RRsets? First check the zone option then - * check the keys flags to make sure at least one has a ksk set - * and one doesn't. - */ - check_ksk = ISC_TF((dns_zone_getoptions(zone) & - DNS_ZONEOPT_UPDATECHECKKSK) != 0); - keyset_kskonly = ISC_TF((dns_zone_getoptions(zone) & - DNS_ZONEOPT_DNSKEYKSKONLY) != 0); - - /* - * Get the NSEC/NSEC3 TTL from the SOA MINIMUM field. - */ - CHECK(dns_db_findnode(db, dns_db_origin(db), ISC_FALSE, &node)); - dns_rdataset_init(&rdataset); - CHECK(dns_db_findrdataset(db, node, newver, dns_rdatatype_soa, 0, - (isc_stdtime_t) 0, &rdataset, NULL)); - CHECK(dns_rdataset_first(&rdataset)); - dns_rdataset_current(&rdataset, &rdata); - CHECK(dns_rdata_tostruct(&rdata, &soa, NULL)); - nsecttl = soa.minimum; - dns_rdataset_disassociate(&rdataset); - dns_db_detachnode(db, &node); - - /* - * Find all RRsets directly affected by the update, and - * update their RRSIGs. Also build a list of names affected - * by the update in "diffnames". - */ - CHECK(dns_diff_sort(diff, temp_order)); + if (statep == NULL || (statep != NULL && *statep == NULL)) { + if (statep == NULL) { + state = &mystate; + } else { + state = isc_mem_get(diff->mctx, sizeof(*state)); + if (state == NULL) + return (ISC_R_NOMEMORY); + } - t = ISC_LIST_HEAD(diff->tuples); - while (t != NULL) { - dns_name_t *name = &t->name; - /* Now "name" is a new, unique name affected by the update. */ + dns_diff_init(diff->mctx, &state->diffnames); + dns_diff_init(diff->mctx, &state->affected); + dns_diff_init(diff->mctx, &state->sig_diff); + dns_diff_init(diff->mctx, &state->nsec_diff); + dns_diff_init(diff->mctx, &state->nsec_mindiff); + dns_diff_init(diff->mctx, &state->work); + state->nkeys = 0; + + result = find_zone_keys(zone, db, newver, diff->mctx, + DNS_MAXZONEKEYS, state->zone_keys, + &state->nkeys); + if (result != ISC_R_SUCCESS) { + update_log(log, zone, ISC_LOG_ERROR, + "could not get zone keys for secure " + "dynamic update"); + goto failure; + } - CHECK(namelist_append_name(&diffnames, name)); + isc_stdtime_get(&now); + state->inception = now - 3600; /* Allow for some clock skew. */ + state->expire = now + sigvalidityinterval; - while (t != NULL && dns_name_equal(&t->name, name)) { - dns_rdatatype_t type; - type = t->rdata.type; + /* + * Do we look at the KSK flag on the DNSKEY to determining which + * keys sign which RRsets? First check the zone option then + * check the keys flags to make sure at least one has a ksk set + * and one doesn't. + */ + state->check_ksk = ISC_TF((dns_zone_getoptions(zone) & + DNS_ZONEOPT_UPDATECHECKKSK) != 0); + state->keyset_kskonly = ISC_TF((dns_zone_getoptions(zone) & + DNS_ZONEOPT_DNSKEYKSKONLY) != 0); - /* - * Now "name" and "type" denote a new unique RRset - * affected by the update. - */ + /* + * Get the NSEC/NSEC3 TTL from the SOA MINIMUM field. + */ + CHECK(dns_db_findnode(db, dns_db_origin(db), ISC_FALSE, &node)); + dns_rdataset_init(&rdataset); + CHECK(dns_db_findrdataset(db, node, newver, dns_rdatatype_soa, + 0, (isc_stdtime_t) 0, &rdataset, + NULL)); + CHECK(dns_rdataset_first(&rdataset)); + dns_rdataset_current(&rdataset, &rdata); + CHECK(dns_rdata_tostruct(&rdata, &soa, NULL)); + state->nsecttl = soa.minimum; + dns_rdataset_disassociate(&rdataset); + dns_db_detachnode(db, &node); - /* Don't sign RRSIGs. */ - if (type == dns_rdatatype_rrsig) - goto skip; + /* + * Find all RRsets directly affected by the update, and + * update their RRSIGs. Also build a list of names affected + * by the update in "diffnames". + */ + CHECK(dns_diff_sort(diff, temp_order)); + state->state = sign_updates; + state->magic = STATE_MAGIC; + if (statep != NULL) + *statep = state; + } else { + REQUIRE(DNS_STATE_VALID(*statep)); + state = *statep; + } + next_state: + switch (state->state) { + case sign_updates: + t = ISC_LIST_HEAD(diff->tuples); + while (t != NULL) { + dns_name_t *name = &t->name; /* - * Delete all old RRSIGs covering this type, since they - * are all invalid when the signed RRset has changed. - * We may not be able to recreate all of them - tough. - * Special case changes to the zone's DNSKEY records - * to support offline KSKs. + * Now "name" is a new, unique name affected by the + * update. */ - if (type == dns_rdatatype_dnskey) - del_keysigs(db, newver, name, &sig_diff, - zone_keys, nkeys); - else - CHECK(delete_if(true_p, db, newver, name, - dns_rdatatype_rrsig, type, - NULL, &sig_diff)); - /* - * If this RRset is still visible after the update, - * add a new signature for it. - */ - CHECK(rrset_visible(db, newver, name, type, &flag)); - if (flag) { - CHECK(add_sigs(log, zone, db, newver, name, - type, &sig_diff, zone_keys, - nkeys, inception, expire, - check_ksk, keyset_kskonly)); - } - skip: - /* Skip any other updates to the same RRset. */ - while (t != NULL && - dns_name_equal(&t->name, name) && - t->rdata.type == type) - { - t = ISC_LIST_NEXT(t, link); + CHECK(namelist_append_name(&state->diffnames, name)); + + while (t != NULL && dns_name_equal(&t->name, name)) { + dns_rdatatype_t type; + type = t->rdata.type; + + /* + * Now "name" and "type" denote a new unique + * RRset affected by the update. + */ + + /* Don't sign RRSIGs. */ + if (type == dns_rdatatype_rrsig) + goto skip; + + /* + * Delete all old RRSIGs covering this type, + * since they are all invalid when the signed + * RRset has changed. We may not be able to + * recreate all of them - tough. + * Special case changes to the zone's DNSKEY + * records to support offline KSKs. + */ + if (type == dns_rdatatype_dnskey) + del_keysigs(db, newver, name, + &state->sig_diff, + state->zone_keys, + state->nkeys); + else + CHECK(delete_if(true_p, db, newver, + name, + dns_rdatatype_rrsig, + type, NULL, + &state->sig_diff)); + + /* + * If this RRset is still visible after the + * update, add a new signature for it. + */ + CHECK(rrset_visible(db, newver, name, type, + &flag)); + if (flag) { + CHECK(add_sigs(log, zone, db, newver, + name, type, + &state->sig_diff, + state->zone_keys, + state->nkeys, + state->inception, + state->expire, + state->check_ksk, + state->keyset_kskonly)); + sigs++; + } + skip: + /* Skip any other updates to the same RRset. */ + while (t != NULL && + dns_name_equal(&t->name, name) && + t->rdata.type == type) + { + next = ISC_LIST_NEXT(t, link); + ISC_LIST_UNLINK(diff->tuples, t, link); + ISC_LIST_APPEND(state->work.tuples, t, + link); + t = next; + } } + if (state != &mystate && sigs > maxsigs) + return (DNS_R_CONTINUE); } - } - update_log(log, zone, ISC_LOG_DEBUG(3), "updated data signatures"); + ISC_LIST_APPENDLIST(diff->tuples, state->work.tuples, link); - /* Remove orphaned NSECs and RRSIG NSECs. */ - for (t = ISC_LIST_HEAD(diffnames.tuples); - t != NULL; - t = ISC_LIST_NEXT(t, link)) - { - CHECK(non_nsec_rrset_exists(db, newver, &t->name, &flag)); - if (! flag) { - CHECK(delete_if(true_p, db, newver, &t->name, - dns_rdatatype_any, 0, - NULL, &sig_diff)); + update_log(log, zone, ISC_LOG_DEBUG(3), + "updated data signatures"); + /*FALLTHROUGH*/ + case remove_orphaned: + state->state = remove_orphaned; + + /* Remove orphaned NSECs and RRSIG NSECs. */ + for (t = ISC_LIST_HEAD(state->diffnames.tuples); + t != NULL; + t = ISC_LIST_NEXT(t, link)) + { + CHECK(non_nsec_rrset_exists(db, newver, + &t->name, &flag)); + if (!flag) { + CHECK(delete_if(true_p, db, newver, &t->name, + dns_rdatatype_any, 0, + NULL, &state->sig_diff)); + } } - } - update_log(log, zone, ISC_LOG_DEBUG(3), - "removed any orphaned NSEC records"); - - /* - * See if we need to build NSEC or NSEC3 chains. - */ - CHECK(dns_private_chains(db, newver, privatetype, &build_nsec, - &build_nsec3)); - if (!build_nsec) - goto update_nsec3; - - update_log(log, zone, ISC_LOG_DEBUG(3), "rebuilding NSEC chain"); - - /* - * When a name is created or deleted, its predecessor needs to - * have its NSEC updated. - */ - for (t = ISC_LIST_HEAD(diffnames.tuples); - t != NULL; - t = ISC_LIST_NEXT(t, link)) - { - isc_boolean_t existed, exists; - dns_fixedname_t fixedname; - dns_name_t *prevname; - - dns_fixedname_init(&fixedname); - prevname = dns_fixedname_name(&fixedname); - - if (oldver != NULL) - CHECK(name_exists(db, oldver, &t->name, &existed)); - else - existed = ISC_FALSE; - CHECK(name_exists(db, newver, &t->name, &exists)); - if (exists == existed) - continue; + update_log(log, zone, ISC_LOG_DEBUG(3), + "removed any orphaned NSEC records"); /* - * Find the predecessor. - * When names become obscured or unobscured in this update - * transaction, we may find the wrong predecessor because - * the NSECs have not yet been updated to reflect the delegation - * change. This should not matter because in this case, - * the correct predecessor is either the delegation node or - * a newly unobscured node, and those nodes are on the - * "affected" list in any case. + * See if we need to build NSEC or NSEC3 chains. */ - CHECK(next_active(log, zone, db, newver, - &t->name, prevname, ISC_FALSE)); - CHECK(namelist_append_name(&affected, prevname)); - } + CHECK(dns_private_chains(db, newver, privatetype, &build_nsec, + &build_nsec3)); + if (!build_nsec) { + state->state = update_nsec3; + goto next_state; + } - /* - * Find names potentially affected by delegation changes - * (obscured by adding an NS or DNAME, or unobscured by - * removing one). - */ - for (t = ISC_LIST_HEAD(diffnames.tuples); - t != NULL; - t = ISC_LIST_NEXT(t, link)) - { - isc_boolean_t ns_existed, dname_existed; - isc_boolean_t ns_exists, dname_exists; + update_log(log, zone, ISC_LOG_DEBUG(3), + "rebuilding NSEC chain"); - if (oldver != NULL) - CHECK(rrset_exists(db, oldver, &t->name, - dns_rdatatype_ns, 0, &ns_existed)); - else - ns_existed = ISC_FALSE; - if (oldver != NULL) - CHECK(rrset_exists(db, oldver, &t->name, - dns_rdatatype_dname, 0, - &dname_existed)); - else - dname_existed = ISC_FALSE; - CHECK(rrset_exists(db, newver, &t->name, dns_rdatatype_ns, 0, - &ns_exists)); - CHECK(rrset_exists(db, newver, &t->name, dns_rdatatype_dname, 0, - &dname_exists)); - if ((ns_exists || dname_exists) == (ns_existed || dname_existed)) - continue; + /*FALLTHROUGH*/ + case build_chain: + state->state = build_chain; /* - * There was a delegation change. Mark all subdomains - * of t->name as potentially needing a NSEC update. + * When a name is created or deleted, its predecessor needs to + * have its NSEC updated. */ - CHECK(namelist_append_subdomain(db, &t->name, &affected)); - } - - ISC_LIST_APPENDLIST(affected.tuples, diffnames.tuples, link); - INSIST(ISC_LIST_EMPTY(diffnames.tuples)); - - CHECK(uniqify_name_list(&affected)); - - /* - * Determine which names should have NSECs, and delete/create - * NSECs to make it so. We don't know the final NSEC targets yet, - * so we just create placeholder NSECs with arbitrary contents - * to indicate that their respective owner names should be part of - * the NSEC chain. - */ - for (t = ISC_LIST_HEAD(affected.tuples); - t != NULL; - t = ISC_LIST_NEXT(t, link)) - { - isc_boolean_t exists; - dns_name_t *name = &t->name; + for (t = ISC_LIST_HEAD(state->diffnames.tuples); + t != NULL; + t = ISC_LIST_NEXT(t, link)) + { + isc_boolean_t existed, exists; + dns_fixedname_t fixedname; + dns_name_t *prevname; + + dns_fixedname_init(&fixedname); + prevname = dns_fixedname_name(&fixedname); + + if (oldver != NULL) + CHECK(name_exists(db, oldver, &t->name, + &existed)); + else + existed = ISC_FALSE; + CHECK(name_exists(db, newver, &t->name, &exists)); + if (exists == existed) + continue; - CHECK(name_exists(db, newver, name, &exists)); - if (! exists) - continue; - CHECK(is_active(db, newver, name, &flag, &cut, NULL)); - if (!flag) { /* - * This name is obscured. Delete any - * existing NSEC record. + * Find the predecessor. + * When names become obscured or unobscured in this + * update transaction, we may find the wrong + * predecessor because the NSECs have not yet been + * updated to reflect the delegation change. This + * should not matter because in this case, the correct + * predecessor is either the delegation node or a + * newly unobscured node, and those nodes are on the + * "affected" list in any case. */ - CHECK(delete_if(true_p, db, newver, name, - dns_rdatatype_nsec, 0, - NULL, &nsec_diff)); - CHECK(delete_if(rrsig_p, db, newver, name, - dns_rdatatype_any, 0, NULL, diff)); - } else { - /* - * This name is not obscured. It needs to have a - * NSEC unless it is the at the origin, in which - * case it should already exist if there is a complete - * NSEC chain and if there isn't a complete NSEC chain - * we don't want to add one as that would signal that - * there is a complete NSEC chain. - */ - if (!dns_name_equal(name, dns_db_origin(db))) { - CHECK(rrset_exists(db, newver, name, - dns_rdatatype_nsec, 0, - &flag)); - if (!flag) - CHECK(add_placeholder_nsec(db, newver, - name, diff)); - } - CHECK(add_exposed_sigs(log, zone, db, newver, name, - cut, &sig_diff, zone_keys, nkeys, - inception, expire, check_ksk, - keyset_kskonly)); + CHECK(next_active(log, zone, db, newver, + &t->name, prevname, ISC_FALSE)); + CHECK(namelist_append_name(&state->affected, prevname)); } - } - /* - * Now we know which names are part of the NSEC chain. - * Make them all point at their correct targets. - */ - for (t = ISC_LIST_HEAD(affected.tuples); - t != NULL; - t = ISC_LIST_NEXT(t, link)) - { - CHECK(rrset_exists(db, newver, &t->name, - dns_rdatatype_nsec, 0, &flag)); - if (flag) { + /* + * Find names potentially affected by delegation changes + * (obscured by adding an NS or DNAME, or unobscured by + * removing one). + */ + for (t = ISC_LIST_HEAD(state->diffnames.tuples); + t != NULL; + t = ISC_LIST_NEXT(t, link)) + { + isc_boolean_t ns_existed, dname_existed; + isc_boolean_t ns_exists, dname_exists; + + if (oldver != NULL) + CHECK(rrset_exists(db, oldver, &t->name, + dns_rdatatype_ns, 0, + &ns_existed)); + else + ns_existed = ISC_FALSE; + if (oldver != NULL) + CHECK(rrset_exists(db, oldver, &t->name, + dns_rdatatype_dname, 0, + &dname_existed)); + else + dname_existed = ISC_FALSE; + CHECK(rrset_exists(db, newver, &t->name, + dns_rdatatype_ns, 0, &ns_exists)); + CHECK(rrset_exists(db, newver, &t->name, + dns_rdatatype_dname, 0, + &dname_exists)); + if ((ns_exists || dname_exists) == + (ns_existed || dname_existed)) + continue; /* - * There is a NSEC, but we don't know if it is correct. - * Delete it and create a correct one to be sure. - * If the update was unnecessary, the diff minimization - * will take care of eliminating it from the journal, - * IXFRs, etc. - * - * The RRSIG bit should always be set in the NSECs - * we generate, because they will all get RRSIG NSECs. - * (XXX what if the zone keys are missing?). - * Because the RRSIG NSECs have not necessarily been - * created yet, the correctness of the bit mask relies - * on the assumption that NSECs are only created if - * there is other data, and if there is other data, - * there are other RRSIGs. + * There was a delegation change. Mark all subdomains + * of t->name as potentially needing a NSEC update. */ - CHECK(add_nsec(log, zone, db, newver, &t->name, - nsecttl, &nsec_diff)); + CHECK(namelist_append_subdomain(db, &t->name, + &state->affected)); } - } + ISC_LIST_APPENDLIST(state->affected.tuples, + state->diffnames.tuples, link); + INSIST(ISC_LIST_EMPTY(state->diffnames.tuples)); - /* - * Minimize the set of NSEC updates so that we don't - * have to regenerate the RRSIG NSECs for NSECs that were - * replaced with identical ones. - */ - while ((t = ISC_LIST_HEAD(nsec_diff.tuples)) != NULL) { - ISC_LIST_UNLINK(nsec_diff.tuples, t, link); - dns_diff_appendminimal(&nsec_mindiff, &t); - } + CHECK(uniqify_name_list(&state->affected)); - update_log(log, zone, ISC_LOG_DEBUG(3), "signing rebuilt NSEC chain"); + /*FALLTHROUGH*/ + case process_nsec: + state->state = process_nsec; - /* Update RRSIG NSECs. */ - for (t = ISC_LIST_HEAD(nsec_mindiff.tuples); - t != NULL; - t = ISC_LIST_NEXT(t, link)) - { - if (t->op == DNS_DIFFOP_DEL) { - CHECK(delete_if(true_p, db, newver, &t->name, - dns_rdatatype_rrsig, dns_rdatatype_nsec, - NULL, &sig_diff)); - } else if (t->op == DNS_DIFFOP_ADD) { - CHECK(add_sigs(log, zone, db, newver, &t->name, - dns_rdatatype_nsec, &sig_diff, - zone_keys, nkeys, inception, expire, - check_ksk, keyset_kskonly)); - } else { - INSIST(0); + /* + * Determine which names should have NSECs, and delete/create + * NSECs to make it so. We don't know the final NSEC targets + * yet, so we just create placeholder NSECs with arbitrary + * contents to indicate that their respective owner names + * should be part of the NSEC chain. + */ + while ((t = ISC_LIST_HEAD(state->affected.tuples)) != NULL) { + isc_boolean_t exists; + dns_name_t *name = &t->name; + + CHECK(name_exists(db, newver, name, &exists)); + if (! exists) + goto unlink; + CHECK(is_active(db, newver, name, &flag, &cut, NULL)); + if (!flag) { + /* + * This name is obscured. Delete any + * existing NSEC record. + */ + CHECK(delete_if(true_p, db, newver, name, + dns_rdatatype_nsec, 0, + NULL, &state->nsec_diff)); + CHECK(delete_if(rrsig_p, db, newver, name, + dns_rdatatype_any, 0, NULL, + diff)); + } else { + /* + * This name is not obscured. It needs to have + * a NSEC unless it is the at the origin, in + * which case it should already exist if there + * is a complete NSEC chain and if there isn't + * a complete NSEC chain we don't want to add + * one as that would signal that there is a + * complete NSEC chain. + */ + if (!dns_name_equal(name, dns_db_origin(db))) { + CHECK(rrset_exists(db, newver, name, + dns_rdatatype_nsec, + 0, &flag)); + if (!flag) + CHECK(add_placeholder_nsec(db, + newver, name, diff)); + } + CHECK(add_exposed_sigs(log, zone, db, newver, + name, cut, + &state->sig_diff, + state->zone_keys, + state->nkeys, + state->inception, + state->expire, + state->check_ksk, + state->keyset_kskonly, + &sigs)); + } + unlink: + ISC_LIST_UNLINK(state->affected.tuples, t, link); + ISC_LIST_APPEND(state->work.tuples, t, link); + if (state != &mystate && sigs > maxsigs) + return (DNS_R_CONTINUE); } - } + ISC_LIST_APPENDLIST(state->affected.tuples, + state->work.tuples, link); - update_nsec3: - - /* Record our changes for the journal. */ - while ((t = ISC_LIST_HEAD(sig_diff.tuples)) != NULL) { - ISC_LIST_UNLINK(sig_diff.tuples, t, link); - dns_diff_appendminimal(diff, &t); - } - while ((t = ISC_LIST_HEAD(nsec_mindiff.tuples)) != NULL) { - ISC_LIST_UNLINK(nsec_mindiff.tuples, t, link); - dns_diff_appendminimal(diff, &t); - } + /* + * Now we know which names are part of the NSEC chain. + * Make them all point at their correct targets. + */ + for (t = ISC_LIST_HEAD(state->affected.tuples); + t != NULL; + t = ISC_LIST_NEXT(t, link)) + { + CHECK(rrset_exists(db, newver, &t->name, + dns_rdatatype_nsec, 0, &flag)); + if (flag) { + /* + * There is a NSEC, but we don't know if it + * is correct. Delete it and create a correct + * one to be sure. If the update was + * unnecessary, the diff minimization + * will take care of eliminating it from the + * journal, IXFRs, etc. + * + * The RRSIG bit should always be set in the + * NSECs we generate, because they will all + * get RRSIG NSECs. + * (XXX what if the zone keys are missing?). + * Because the RRSIG NSECs have not necessarily + * been created yet, the correctness of the + * bit mask relies on the assumption that NSECs + * are only created if there is other data, and + * if there is other data, there are other + * RRSIGs. + */ + CHECK(add_nsec(log, zone, db, newver, &t->name, + state->nsecttl, + &state->nsec_diff)); + } + } - INSIST(ISC_LIST_EMPTY(sig_diff.tuples)); - INSIST(ISC_LIST_EMPTY(nsec_diff.tuples)); - INSIST(ISC_LIST_EMPTY(nsec_mindiff.tuples)); + /* + * Minimize the set of NSEC updates so that we don't + * have to regenerate the RRSIG NSECs for NSECs that were + * replaced with identical ones. + */ + while ((t = ISC_LIST_HEAD(state->nsec_diff.tuples)) != NULL) { + ISC_LIST_UNLINK(state->nsec_diff.tuples, t, link); + dns_diff_appendminimal(&state->nsec_mindiff, &t); + } - if (!build_nsec3) { update_log(log, zone, ISC_LOG_DEBUG(3), - "no NSEC3 chains to rebuild"); - goto failure; - } - - update_log(log, zone, ISC_LOG_DEBUG(3), "rebuilding NSEC3 chains"); - - dns_diff_clear(&diffnames); - dns_diff_clear(&affected); + "signing rebuilt NSEC chain"); + + /*FALLTHROUGH*/ + case sign_nsec: + state->state = sign_nsec; + /* Update RRSIG NSECs. */ + while ((t = ISC_LIST_HEAD(state->nsec_mindiff.tuples)) != NULL) + { + if (t->op == DNS_DIFFOP_DEL) { + CHECK(delete_if(true_p, db, newver, &t->name, + dns_rdatatype_rrsig, + dns_rdatatype_nsec, + NULL, &state->sig_diff)); + } else if (t->op == DNS_DIFFOP_ADD) { + CHECK(add_sigs(log, zone, db, newver, &t->name, + dns_rdatatype_nsec, + &state->sig_diff, + state->zone_keys, state->nkeys, + state->inception, state->expire, + state->check_ksk, + state->keyset_kskonly)); + sigs++; + } else { + INSIST(0); + } + ISC_LIST_UNLINK(state->nsec_mindiff.tuples, t, link); + ISC_LIST_APPEND(state->work.tuples, t, link); + if (state != &mystate && sigs > maxsigs) + return (DNS_R_CONTINUE); + } + ISC_LIST_APPENDLIST(state->nsec_mindiff.tuples, + state->work.tuples, link); + /*FALLTHROUGH*/ + case update_nsec3: + state->state = update_nsec3; + + /* Record our changes for the journal. */ + while ((t = ISC_LIST_HEAD(state->sig_diff.tuples)) != NULL) { + ISC_LIST_UNLINK(state->sig_diff.tuples, t, link); + dns_diff_appendminimal(diff, &t); + } + while ((t = ISC_LIST_HEAD(state->nsec_mindiff.tuples)) != NULL) + { + ISC_LIST_UNLINK(state->nsec_mindiff.tuples, t, link); + dns_diff_appendminimal(diff, &t); + } - CHECK(dns_diff_sort(diff, temp_order)); + INSIST(ISC_LIST_EMPTY(state->sig_diff.tuples)); + INSIST(ISC_LIST_EMPTY(state->nsec_diff.tuples)); + INSIST(ISC_LIST_EMPTY(state->nsec_mindiff.tuples)); - /* - * Find names potentially affected by delegation changes - * (obscured by adding an NS or DNAME, or unobscured by - * removing one). - */ - t = ISC_LIST_HEAD(diff->tuples); - while (t != NULL) { - dns_name_t *name = &t->name; + if (!build_nsec3) { + update_log(log, zone, ISC_LOG_DEBUG(3), + "no NSEC3 chains to rebuild"); + goto failure; + } - isc_boolean_t ns_existed, dname_existed; - isc_boolean_t ns_exists, dname_exists; - isc_boolean_t exists, existed; + update_log(log, zone, ISC_LOG_DEBUG(3), + "rebuilding NSEC3 chains"); - if (t->rdata.type == dns_rdatatype_nsec || - t->rdata.type == dns_rdatatype_rrsig) { - t = ISC_LIST_NEXT(t, link); - continue; - } + dns_diff_clear(&state->diffnames); + dns_diff_clear(&state->affected); - CHECK(namelist_append_name(&affected, name)); + CHECK(dns_diff_sort(diff, temp_order)); - if (oldver != NULL) - CHECK(rrset_exists(db, oldver, name, dns_rdatatype_ns, - 0, &ns_existed)); - else - ns_existed = ISC_FALSE; - if (oldver != NULL) - CHECK(rrset_exists(db, oldver, name, - dns_rdatatype_dname, 0, - &dname_existed)); - else - dname_existed = ISC_FALSE; - CHECK(rrset_exists(db, newver, name, dns_rdatatype_ns, 0, - &ns_exists)); - CHECK(rrset_exists(db, newver, name, dns_rdatatype_dname, 0, - &dname_exists)); - - exists = ns_exists || dname_exists; - existed = ns_existed || dname_existed; - if (exists == existed) - goto nextname; /* - * There was a delegation change. Mark all subdomains - * of t->name as potentially needing a NSEC3 update. + * Find names potentially affected by delegation changes + * (obscured by adding an NS or DNAME, or unobscured by + * removing one). */ - CHECK(namelist_append_subdomain(db, name, &affected)); + t = ISC_LIST_HEAD(diff->tuples); + while (t != NULL) { + dns_name_t *name = &t->name; - nextname: - while (t != NULL && dns_name_equal(&t->name, name)) - t = ISC_LIST_NEXT(t, link); - } + isc_boolean_t ns_existed, dname_existed; + isc_boolean_t ns_exists, dname_exists; + isc_boolean_t exists, existed; - for (t = ISC_LIST_HEAD(affected.tuples); - t != NULL; - t = ISC_LIST_NEXT(t, link)) { - dns_name_t *name = &t->name; + if (t->rdata.type == dns_rdatatype_nsec || + t->rdata.type == dns_rdatatype_rrsig) { + t = ISC_LIST_NEXT(t, link); + continue; + } - unsecure = ISC_FALSE; /* Silence compiler warning. */ - CHECK(is_active(db, newver, name, &flag, &cut, &unsecure)); + CHECK(namelist_append_name(&state->affected, name)); - if (!flag) { - CHECK(delete_if(rrsig_p, db, newver, name, - dns_rdatatype_any, 0, NULL, diff)); - CHECK(dns_nsec3_delnsec3sx(db, newver, name, - privatetype, &nsec_diff)); - } else { - CHECK(add_exposed_sigs(log, zone, db, newver, name, - cut, &sig_diff, zone_keys, nkeys, - inception, expire, check_ksk, - keyset_kskonly)); - CHECK(dns_nsec3_addnsec3sx(db, newver, name, nsecttl, - unsecure, privatetype, - &nsec_diff)); + if (oldver != NULL) + CHECK(rrset_exists(db, oldver, name, + dns_rdatatype_ns, + 0, &ns_existed)); + else + ns_existed = ISC_FALSE; + if (oldver != NULL) + CHECK(rrset_exists(db, oldver, name, + dns_rdatatype_dname, 0, + &dname_existed)); + else + dname_existed = ISC_FALSE; + CHECK(rrset_exists(db, newver, name, dns_rdatatype_ns, + 0, &ns_exists)); + CHECK(rrset_exists(db, newver, name, + dns_rdatatype_dname, 0, + &dname_exists)); + + exists = ns_exists || dname_exists; + existed = ns_existed || dname_existed; + if (exists == existed) + goto nextname; + /* + * There was a delegation change. Mark all subdomains + * of t->name as potentially needing a NSEC3 update. + */ + CHECK(namelist_append_subdomain(db, name, + &state->affected)); + + nextname: + while (t != NULL && dns_name_equal(&t->name, name)) + t = ISC_LIST_NEXT(t, link); } - } - /* - * Minimize the set of NSEC3 updates so that we don't - * have to regenerate the RRSIG NSEC3s for NSEC3s that were - * replaced with identical ones. - */ - while ((t = ISC_LIST_HEAD(nsec_diff.tuples)) != NULL) { - ISC_LIST_UNLINK(nsec_diff.tuples, t, link); - dns_diff_appendminimal(&nsec_mindiff, &t); - } + /*FALLTHROUGH*/ + case process_nsec3: + state->state = process_nsec3; + while ((t = ISC_LIST_HEAD(state->affected.tuples)) != NULL) { + dns_name_t *name = &t->name; + + unsecure = ISC_FALSE; /* Silence compiler warning. */ + CHECK(is_active(db, newver, name, &flag, &cut, + &unsecure)); + + if (!flag) { + CHECK(delete_if(rrsig_p, db, newver, name, + dns_rdatatype_any, 0, NULL, + diff)); + CHECK(dns_nsec3_delnsec3sx(db, newver, name, + privatetype, + &state->nsec_diff)); + } else { + CHECK(add_exposed_sigs(log, zone, db, newver, + name, cut, + &state->sig_diff, + state->zone_keys, + state->nkeys, + state->inception, + state->expire, + state->check_ksk, + state->keyset_kskonly, + &sigs)); + CHECK(dns_nsec3_addnsec3sx(db, newver, name, + state->nsecttl, + unsecure, + privatetype, + &state->nsec_diff)); + } + ISC_LIST_UNLINK(state->affected.tuples, t, link); + ISC_LIST_APPEND(state->work.tuples, t, link); + if (state != &mystate && sigs > maxsigs) + return (DNS_R_CONTINUE); + } + ISC_LIST_APPENDLIST(state->affected.tuples, + state->work.tuples, link); - update_log(log, zone, ISC_LOG_DEBUG(3), - "signing rebuilt NSEC3 chain"); + /* + * Minimize the set of NSEC3 updates so that we don't + * have to regenerate the RRSIG NSEC3s for NSEC3s that were + * replaced with identical ones. + */ + while ((t = ISC_LIST_HEAD(state->nsec_diff.tuples)) != NULL) { + ISC_LIST_UNLINK(state->nsec_diff.tuples, t, link); + dns_diff_appendminimal(&state->nsec_mindiff, &t); + } - /* Update RRSIG NSEC3s. */ - for (t = ISC_LIST_HEAD(nsec_mindiff.tuples); - t != NULL; - t = ISC_LIST_NEXT(t, link)) - { - if (t->op == DNS_DIFFOP_DEL) { - CHECK(delete_if(true_p, db, newver, &t->name, - dns_rdatatype_rrsig, - dns_rdatatype_nsec3, - NULL, &sig_diff)); - } else if (t->op == DNS_DIFFOP_ADD) { - CHECK(add_sigs(log, zone, db, newver, &t->name, - dns_rdatatype_nsec3, - &sig_diff, zone_keys, nkeys, - inception, expire, check_ksk, - keyset_kskonly)); - } else { - INSIST(0); + update_log(log, zone, ISC_LOG_DEBUG(3), + "signing rebuilt NSEC3 chain"); + + /*FALLTHROUGH*/ + case sign_nsec3: + state->state = sign_nsec3; + /* Update RRSIG NSEC3s. */ + while ((t = ISC_LIST_HEAD(state->nsec_mindiff.tuples)) != NULL) + { + if (t->op == DNS_DIFFOP_DEL) { + CHECK(delete_if(true_p, db, newver, &t->name, + dns_rdatatype_rrsig, + dns_rdatatype_nsec3, + NULL, &state->sig_diff)); + } else if (t->op == DNS_DIFFOP_ADD) { + CHECK(add_sigs(log, zone, db, newver, &t->name, + dns_rdatatype_nsec3, + &state->sig_diff, + state->zone_keys, + state->nkeys, state->inception, + state->expire, state->check_ksk, + state->keyset_kskonly)); + sigs++; + } else { + INSIST(0); + } + ISC_LIST_UNLINK(state->nsec_mindiff.tuples, t, link); + ISC_LIST_APPEND(state->work.tuples, t, link); + if (state != &mystate && sigs > maxsigs) + return (DNS_R_CONTINUE); } - } + ISC_LIST_APPENDLIST(state->nsec_mindiff.tuples, + state->work.tuples, link); - /* Record our changes for the journal. */ - while ((t = ISC_LIST_HEAD(sig_diff.tuples)) != NULL) { - ISC_LIST_UNLINK(sig_diff.tuples, t, link); - dns_diff_appendminimal(diff, &t); - } - while ((t = ISC_LIST_HEAD(nsec_mindiff.tuples)) != NULL) { - ISC_LIST_UNLINK(nsec_mindiff.tuples, t, link); - dns_diff_appendminimal(diff, &t); - } + /* Record our changes for the journal. */ + while ((t = ISC_LIST_HEAD(state->sig_diff.tuples)) != NULL) { + ISC_LIST_UNLINK(state->sig_diff.tuples, t, link); + dns_diff_appendminimal(diff, &t); + } + while ((t = ISC_LIST_HEAD(state->nsec_mindiff.tuples)) != NULL) + { + ISC_LIST_UNLINK(state->nsec_mindiff.tuples, t, link); + dns_diff_appendminimal(diff, &t); + } - INSIST(ISC_LIST_EMPTY(sig_diff.tuples)); - INSIST(ISC_LIST_EMPTY(nsec_diff.tuples)); - INSIST(ISC_LIST_EMPTY(nsec_mindiff.tuples)); + INSIST(ISC_LIST_EMPTY(state->sig_diff.tuples)); + INSIST(ISC_LIST_EMPTY(state->nsec_diff.tuples)); + INSIST(ISC_LIST_EMPTY(state->nsec_mindiff.tuples)); + break; + default: + INSIST(0); + } failure: - dns_diff_clear(&sig_diff); - dns_diff_clear(&nsec_diff); - dns_diff_clear(&nsec_mindiff); + dns_diff_clear(&state->sig_diff); + dns_diff_clear(&state->nsec_diff); + dns_diff_clear(&state->nsec_mindiff); + + dns_diff_clear(&state->affected); + dns_diff_clear(&state->diffnames); + dns_diff_clear(&state->work); - dns_diff_clear(&affected); - dns_diff_clear(&diffnames); + for (i = 0; i < state->nkeys; i++) + dst_key_free(&state->zone_keys[i]); - for (i = 0; i < nkeys; i++) - dst_key_free(&zone_keys[i]); + if (state != &mystate && state != NULL) { + *statep = NULL; + state->magic = 0; + isc_mem_put(diff->mctx, state, sizeof(*state)); + } return (result); } diff --git a/lib/dns/view.c b/lib/dns/view.c index 3730593b9e37..da1136c075ac 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,8 +15,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id$ */ - /*! \file */ #include <config.h> @@ -688,7 +686,8 @@ req_shutdown(isc_task_t *task, isc_event_t *event) { isc_result_t dns_view_createresolver(dns_view_t *view, isc_taskmgr_t *taskmgr, - unsigned int ntasks, unsigned int ndisp, + unsigned int ntasks, + unsigned int ndisp, isc_socketmgr_t *socketmgr, isc_timermgr_t *timermgr, unsigned int options, @@ -1322,10 +1321,16 @@ dns_view_findzonecut2(dns_view_t *view, dns_name_t *name, dns_name_t *fname, result = dns_db_findzonecut(db, name, options, now, NULL, fname, rdataset, sigrdataset); if (result == ISC_R_SUCCESS) { +#ifdef BIND9 if (zfname != NULL && (!dns_name_issubdomain(fname, zfname) || - (dns_zone_staticstub && - dns_name_equal(fname, zfname)))) { + (dns_zone_gettype(zone) == dns_zone_staticstub && + dns_name_equal(fname, zfname)))) +#else + if (zfname != NULL && + !dns_name_issubdomain(fname, zfname)) +#endif + { /* * We found a zonecut in the cache, but our * zone delegation is better. diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index 30f2f3b347f4..a5e4bf874219 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2008, 2011-2013 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2008, 2011-2013, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -107,6 +107,7 @@ struct dns_xfrin_ctx { int sends; /*%< Send in progress */ int recvs; /*%< Receive in progress */ isc_boolean_t shuttingdown; + isc_result_t shutdown_result; dns_name_t name; /*%< Name of zone to transfer */ dns_rdataclass_t rdclass; @@ -657,7 +658,8 @@ dns_xfrin_create2(dns_zone_t *zone, dns_rdatatype_t xfrtype, CHECK(xfrin_start(xfr)); xfr->done = done; - xfr->refcount++; + if (xfr->done != NULL) + xfr->refcount++; *xfrp = xfr; failure: @@ -762,6 +764,7 @@ xfrin_fail(dns_xfrin_ctx_t *xfr, isc_result_t result, const char *msg) { xfr->done = NULL; } xfr->shuttingdown = ISC_TRUE; + xfr->shutdown_result = result; maybe_free(xfr); } @@ -802,6 +805,7 @@ xfrin_create(isc_mem_t *mctx, xfr->sends = 0; xfr->recvs = 0; xfr->shuttingdown = ISC_FALSE; + xfr->shutdown_result = ISC_R_UNSET; dns_name_init(&xfr->name, NULL); xfr->rdclass = rdclass; @@ -1365,6 +1369,7 @@ xfrin_recv_done(isc_task_t *task, isc_event_t *ev) { * point, thus maybe_free() should succeed. */ xfr->shuttingdown = ISC_TRUE; + xfr->shutdown_result = ISC_R_SUCCESS; maybe_free(xfr); break; default: @@ -1403,6 +1408,7 @@ static void maybe_free(dns_xfrin_ctx_t *xfr) { isc_uint64_t msecs; isc_uint64_t persec; + const char *result_str; REQUIRE(VALID_XFRIN(xfr)); @@ -1411,6 +1417,16 @@ maybe_free(dns_xfrin_ctx_t *xfr) { xfr->recvs != 0) return; + INSIST(! xfr->shuttingdown || xfr->shutdown_result != ISC_R_UNSET); + + /* If we're called through dns_xfrin_detach() and are not + * shutting down, we can't know what the transfer status is as + * we are only called when the last reference is lost. + */ + result_str = (xfr->shuttingdown ? + isc_result_totext(xfr->shutdown_result) : "unknown"); + xfrin_log(xfr, ISC_LOG_INFO, "Transfer status: %s", result_str); + /* * Calculate the length of time the transfer took, * and print a log message with the bytes and rate. diff --git a/lib/dns/zone.c b/lib/dns/zone.c index fbaeab14c699..d334bebc436c 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -46,6 +46,7 @@ #include <dns/db.h> #include <dns/dbiterator.h> #include <dns/dnssec.h> +#include <dns/ds.h> #include <dns/events.h> #include <dns/journal.h> #include <dns/keydata.h> @@ -379,6 +380,23 @@ struct dns_zone { isc_boolean_t sourceserialset; isc_uint32_t sourceserial; + + /*% + * maximum zone ttl + */ + dns_ttl_t maxttl; + + /* + * Inline zone signing state. + */ + dns_diff_t rss_diff; + isc_eventlist_t rss_events; + dns_dbversion_t *rss_newver; + dns_dbversion_t *rss_oldver; + dns_db_t *rss_db; + dns_zone_t *rss_raw; + isc_event_t *rss_event; + dns_update_state_t *rss_state; }; typedef struct { @@ -667,9 +685,8 @@ struct dns_asyncload { * RFC 5011. */ unsigned int dns_zone_mkey_hour = HOUR; -unsigned int dns_zone_mkey_day = (24 * HOUR); -unsigned int dns_zone_mkey_month = (30 * DAY); - +unsigned int dns_zone_mkey_day = DAY; +unsigned int dns_zone_mkey_month = MONTH; #define SEND_BUFFER_SIZE 2048 @@ -968,6 +985,14 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) { zone->secure = NULL; zone->sourceserial = 0; zone->sourceserialset = ISC_FALSE; + ISC_LIST_INIT(zone->rss_events); + zone->rss_db = NULL; + zone->rss_raw = NULL; + zone->rss_newver = NULL; + zone->rss_oldver = NULL; + zone->rss_event = NULL; + zone->rss_state = NULL; + zone->updatemethod = dns_updatemethod_increment; zone->magic = ZONE_MAGIC; @@ -1591,7 +1616,7 @@ dns_zone_rpz_enable_db(dns_zone_t *zone, dns_db_t *db) { } static isc_result_t -zone_load(dns_zone_t *zone, unsigned int flags) { +zone_load(dns_zone_t *zone, unsigned int flags, isc_boolean_t locked) { isc_result_t result; isc_time_t now; isc_time_t loadtime, filetime; @@ -1600,12 +1625,14 @@ zone_load(dns_zone_t *zone, unsigned int flags) { REQUIRE(DNS_ZONE_VALID(zone)); - LOCK_ZONE(zone); + if (!locked) + LOCK_ZONE(zone); hasraw = inline_secure(zone); if (hasraw) { - result = zone_load(zone->raw, flags); + result = zone_load(zone->raw, flags, ISC_FALSE); if (result != ISC_R_SUCCESS) { - UNLOCK_ZONE(zone); + if (!locked) + UNLOCK_ZONE(zone); return(result); } LOCK_ZONE(zone->raw); @@ -1763,7 +1790,8 @@ zone_load(dns_zone_t *zone, unsigned int flags) { cleanup: if (hasraw) UNLOCK_ZONE(zone->raw); - UNLOCK_ZONE(zone); + if (!locked) + UNLOCK_ZONE(zone); if (db != NULL) dns_db_detach(&db); return (result); @@ -1771,12 +1799,12 @@ zone_load(dns_zone_t *zone, unsigned int flags) { isc_result_t dns_zone_load(dns_zone_t *zone) { - return (zone_load(zone, 0)); + return (zone_load(zone, 0, ISC_FALSE)); } isc_result_t dns_zone_loadnew(dns_zone_t *zone) { - return (zone_load(zone, DNS_ZONELOADFLAG_NOSTAT)); + return (zone_load(zone, DNS_ZONELOADFLAG_NOSTAT, ISC_FALSE)); } static void @@ -1784,6 +1812,7 @@ zone_asyncload(isc_task_t *task, isc_event_t *event) { dns_asyncload_t *asl = event->ev_arg; dns_zone_t *zone = asl->zone; isc_result_t result = ISC_R_SUCCESS; + isc_boolean_t load_pending; UNUSED(task); @@ -1792,13 +1821,21 @@ zone_asyncload(isc_task_t *task, isc_event_t *event) { if ((event->ev_attributes & ISC_EVENTATTR_CANCELED) != 0) result = ISC_R_CANCELED; isc_event_free(&event); - if (result == ISC_R_CANCELED || - !DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADPENDING)) - goto cleanup; - zone_load(zone, 0); + if (result == ISC_R_CANCELED) + goto cleanup; + /* Make sure load is still pending */ LOCK_ZONE(zone); + load_pending = ISC_TF(DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADPENDING)); + + if (!load_pending) { + UNLOCK_ZONE(zone); + goto cleanup; + } + + zone_load(zone, 0, ISC_TRUE); + DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_LOADPENDING); UNLOCK_ZONE(zone); @@ -1822,6 +1859,10 @@ dns_zone_asyncload(dns_zone_t *zone, dns_zt_zoneloaded_t done, void *arg) { if (zone->zmgr == NULL) return (ISC_R_FAILURE); + /* If we already have a load pending, stop now */ + if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADPENDING)) + return (ISC_R_ALREADYRUNNING); + asl = isc_mem_get(zone->mctx, sizeof (*asl)); if (asl == NULL) CHECK(ISC_R_NOMEMORY); @@ -1863,9 +1904,10 @@ dns_zone_loadandthaw(dns_zone_t *zone) { isc_result_t result; if (inline_raw(zone)) - result = zone_load(zone->secure, DNS_ZONELOADFLAG_THAW); + result = zone_load(zone->secure, DNS_ZONELOADFLAG_THAW, + ISC_FALSE); else - result = zone_load(zone, DNS_ZONELOADFLAG_THAW); + result = zone_load(zone, DNS_ZONELOADFLAG_THAW, ISC_FALSE); switch (result) { case DNS_R_CONTINUE: @@ -4328,10 +4370,14 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, zone->type == dns_zone_stub || zone->type == dns_zone_key || (zone->type == dns_zone_redirect && zone->masters != NULL)) { - if (zone->journal != NULL) - zone_saveunique(zone, zone->journal, "jn-XXXXXXXX"); - if (zone->masterfile != NULL) - zone_saveunique(zone, zone->masterfile, "db-XXXXXXXX"); + if (result != ISC_R_NOMEMORY) { + if (zone->journal != NULL) + zone_saveunique(zone, zone->journal, + "jn-XXXXXXXX"); + if (zone->masterfile != NULL) + zone_saveunique(zone, zone->masterfile, + "db-XXXXXXXX"); + } /* Mark the zone for immediate refresh. */ zone->refreshtime = now; @@ -6073,8 +6119,14 @@ sign_a_node(dns_db_t *db, dns_name_t *name, dns_dbnode_t *node, if (rdataset.type == dns_rdatatype_dnskey) { if (!is_ksk && keyset_kskonly) goto next_rdataset; - } else if (is_ksk) - goto next_rdataset; + } else if (is_ksk) { + /* + * CDS and CDNSKEY are signed with KSK (RFC 7344, 4.1). + */ + if (rdataset.type != dns_rdatatype_cds && + rdataset.type != dns_rdatatype_cdnskey) + goto next_rdataset; + } if (*delegation && rdataset.type != dns_rdatatype_ds && rdataset.type != dns_rdatatype_nsec) @@ -8999,7 +9051,8 @@ zone_maintenance(dns_zone_t *zone) { break; case dns_zone_master: if (!isc_time_isepoch(&zone->refreshkeytime) && - isc_time_compare(&now, &zone->refreshkeytime) >= 0) + isc_time_compare(&now, &zone->refreshkeytime) >= 0 && + zone->rss_event == NULL) zone_rekey(zone); default: break; @@ -9012,6 +9065,8 @@ zone_maintenance(dns_zone_t *zone) { /* * Do we need to sign/resign some RRsets? */ + if (zone->rss_event != NULL) + break; if (!isc_time_isepoch(&zone->signingtime) && isc_time_compare(&now, &zone->signingtime) >= 0) zone_sign(zone); @@ -9619,8 +9674,6 @@ notify_isqueued(dns_zone_t *zone, unsigned int flags, dns_name_t *name, notify = ISC_LIST_NEXT(notify, link)) { if (notify->request != NULL) continue; - if ((flags & DNS_NOTIFY_STARTUP) == 0) - notify->flags &= ~DNS_NOTIFY_STARTUP; if (name != NULL && dns_name_dynamic(¬ify->ns) && dns_name_equal(name, ¬ify->ns)) goto requeue; @@ -9636,12 +9689,15 @@ requeue: * not a startup notify, re-enqueue on the normal notify * ratelimiter. */ - if (notify->event != NULL && (flags & DNS_NOTIFY_STARTUP) == 0) { + if (notify->event != NULL && (flags & DNS_NOTIFY_STARTUP) == 0 && + (notify->flags & DNS_NOTIFY_STARTUP) != 0) { zmgr = notify->zone->zmgr; result = isc_ratelimiter_dequeue(zmgr->startupnotifyrl, notify->event); if (result != ISC_R_SUCCESS) return (ISC_TRUE); + + notify->flags &= ~DNS_NOTIFY_STARTUP; result = isc_ratelimiter_enqueue(notify->zone->zmgr->notifyrl, notify->zone->task, ¬ify->event); @@ -9701,9 +9757,6 @@ static void notify_destroy(dns_notify_t *notify, isc_boolean_t locked) { isc_mem_t *mctx; - /* - * Caller holds zone lock. - */ REQUIRE(DNS_NOTIFY_VALID(notify)); if (notify->zone != NULL) { @@ -11695,7 +11748,8 @@ zone_settimer(dns_zone_t *zone, isc_time_t *now) { case dns_zone_slave: treat_as_slave: - if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDNOTIFY)) + if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDNOTIFY) || + DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDSTARTUPNOTIFY)) next = zone->notifytime; /* FALLTHROUGH */ @@ -11890,9 +11944,7 @@ notify_createmessage(dns_zone_t *zone, unsigned int flags, goto soa_cleanup; temprdatalist->rdclass = rdata.rdclass; temprdatalist->type = rdata.type; - temprdatalist->covers = 0; temprdatalist->ttl = rdataset.ttl; - ISC_LIST_INIT(temprdatalist->rdata); ISC_LIST_APPEND(temprdatalist->rdata, temprdata, link); dns_rdataset_init(temprdataset); @@ -12113,10 +12165,10 @@ dns_zone_notifyreceive(dns_zone_t *zone, isc_sockaddr_t *from, return (ISC_R_SUCCESS); } zone->notifyfrom = *from; - local = zone->masteraddr; - remote = zone->sourceaddr; + remote = zone->masteraddr; + local = zone->sourceaddr; UNLOCK_ZONE(zone); - dns_zonemgr_unreachabledel(zone->zmgr, &local, &remote); + dns_zonemgr_unreachabledel(zone->zmgr, &remote, &local); dns_zone_refresh(zone); return (ISC_R_SUCCESS); } @@ -12472,6 +12524,13 @@ dns_zone_name(dns_zone_t *zone, char *buf, size_t length) { zone_namerd_tostr(zone, buf, length); } +void +dns_zone_nameonly(dns_zone_t *zone, char *buf, size_t length) { + REQUIRE(DNS_ZONE_VALID(zone)); + REQUIRE(buf != NULL); + zone_name_tostr(zone, buf, length); +} + static void notify_log(dns_zone_t *zone, int level, const char *fmt, ...) { va_list ap; @@ -12921,61 +12980,74 @@ sync_secure_db(dns_zone_t *seczone, dns_zone_t *raw, dns_db_t *secdb, static void receive_secure_serial(isc_task_t *task, isc_event_t *event) { static char me[] = "receive_secure_serial"; - isc_result_t result; + isc_result_t result = ISC_R_SUCCESS; dns_journal_t *rjournal = NULL; + dns_journal_t *sjournal = NULL; isc_uint32_t start, end; - dns_zone_t *zone, *raw = NULL; - dns_db_t *db = NULL; - dns_dbversion_t *newver = NULL, *oldver = NULL; - dns_diff_t diff; + dns_zone_t *zone; dns_difftuple_t *tuple = NULL, *soatuple = NULL; dns_update_log_t log = { update_log_cb, NULL }; isc_time_t timenow; + UNUSED(task); + zone = event->ev_arg; end = ((struct secure_event *)event)->serial; - isc_event_free(&event); ENTER; LOCK_ZONE(zone); - dns_diff_init(zone->mctx, &diff); + /* + * If we are already processing a receive secure serial event + * for the zone, just queue the new one and exit. + */ + if (zone->rss_event != NULL && zone->rss_event != event) { + ISC_LIST_APPEND(zone->rss_events, event, ev_link); + UNLOCK_ZONE(zone); + return; + } - UNUSED(task); + nextevent: + if (zone->rss_event != NULL) { + INSIST(zone->rss_event == event); + UNLOCK_ZONE(zone); + } else { + zone->rss_event = event; + dns_diff_init(zone->mctx, &zone->rss_diff); - ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read); - if (zone->db != NULL) - dns_db_attach(zone->db, &db); - ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_read); + /* + * zone->db may be NULL, if the load from disk failed. + */ + result = ISC_R_SUCCESS; + ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read); + if (zone->db != NULL) + dns_db_attach(zone->db, &zone->rss_db); + else + result = ISC_R_FAILURE; + ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_read); - if (zone->raw != NULL) - dns_zone_attach(zone->raw, &raw); - UNLOCK_ZONE(zone); + if (result == ISC_R_SUCCESS && zone->raw != NULL) + dns_zone_attach(zone->raw, &zone->rss_raw); + else + result = ISC_R_FAILURE; - /* - * zone->db may be NULL if the load from disk failed. - */ - if (db == NULL || raw == NULL) { - result = ISC_R_FAILURE; - goto failure; - } + UNLOCK_ZONE(zone); - /* - * We first attempt to sync the raw zone to the secure zone - * by using the raw zone's journal, applying all the deltas - * from the latest source-serial of the secure zone up to - * the current serial number of the raw zone. - * - * If that fails, then we'll fall back to a direct comparison - * between raw and secure zones. - */ - result = dns_journal_open(raw->mctx, raw->journal, - DNS_JOURNAL_WRITE, &rjournal); - if (result != ISC_R_SUCCESS) - goto failure; - else { - dns_journal_t *sjournal = NULL; + CHECK(result); + + /* + * We first attempt to sync the raw zone to the secure zone + * by using the raw zone's journal, applying all the deltas + * from the latest source-serial of the secure zone up to + * the current serial number of the raw zone. + * + * If that fails, then we'll fall back to a direct comparison + * between raw and secure zones. + */ + CHECK(dns_journal_open(zone->rss_raw->mctx, + zone->rss_raw->journal, + DNS_JOURNAL_WRITE, &rjournal)); result = dns_journal_open(zone->mctx, zone->journal, DNS_JOURNAL_READ, &sjournal); @@ -12989,9 +13061,9 @@ receive_secure_serial(isc_task_t *task, isc_event_t *event) { if (sjournal != NULL) { isc_uint32_t serial; /* - * We read the secure journal first, if that exists - * use its value provided it is greater that from the - * raw journal. + * We read the secure journal first, if that + * exists use its value provided it is greater + * that from the raw journal. */ if (dns_journal_get_sourceserial(sjournal, &serial)) { if (isc_serial_gt(serial, start)) @@ -12999,50 +13071,78 @@ receive_secure_serial(isc_task_t *task, isc_event_t *event) { } dns_journal_destroy(&sjournal); } - } - dns_db_currentversion(db, &oldver); - CHECK(dns_db_newversion(db, &newver)); + dns_db_currentversion(zone->rss_db, &zone->rss_oldver); + CHECK(dns_db_newversion(zone->rss_db, &zone->rss_newver)); - /* - * Try to apply diffs from the raw zone's journal to the secure - * zone. If that fails, we recover by syncing up the databases - * directly. - */ - result = sync_secure_journal(zone, raw, rjournal, start, end, - &soatuple, &diff); - if (result == DNS_R_UNCHANGED) - goto failure; - else if (result != ISC_R_SUCCESS) - CHECK(sync_secure_db(zone, raw, db, oldver, &soatuple, &diff)); - - CHECK(dns_diff_apply(&diff, db, newver)); - - if (soatuple != NULL) { - isc_uint32_t oldserial, newserial, desired; - - CHECK(dns_db_createsoatuple(db, oldver, diff.mctx, - DNS_DIFFOP_DEL, &tuple)); - oldserial = dns_soa_getserial(&tuple->rdata); - newserial = desired = dns_soa_getserial(&soatuple->rdata); - if (!isc_serial_gt(newserial, oldserial)) { - newserial = oldserial + 1; - if (newserial == 0) - newserial++; - dns_soa_setserial(newserial, &soatuple->rdata); - } - CHECK(do_one_tuple(&tuple, db, newver, &diff)); - CHECK(do_one_tuple(&soatuple, db, newver, &diff)); - dns_zone_log(zone, ISC_LOG_INFO, "serial %u (unsigned %u)", - newserial, desired); - } else - CHECK(update_soa_serial(db, newver, &diff, zone->mctx, - zone->updatemethod)); + /* + * Try to apply diffs from the raw zone's journal to the secure + * zone. If that fails, we recover by syncing up the databases + * directly. + */ + result = sync_secure_journal(zone, zone->rss_raw, rjournal, + start, end, &soatuple, + &zone->rss_diff); + if (result == DNS_R_UNCHANGED) + goto failure; + else if (result != ISC_R_SUCCESS) + CHECK(sync_secure_db(zone, zone->rss_raw, zone->rss_db, + zone->rss_oldver, &soatuple, + &zone->rss_diff)); + + CHECK(dns_diff_apply(&zone->rss_diff, zone->rss_db, + zone->rss_newver)); + + if (soatuple != NULL) { + isc_uint32_t oldserial, newserial, desired; + + CHECK(dns_db_createsoatuple(zone->rss_db, + zone->rss_oldver, + zone->rss_diff.mctx, + DNS_DIFFOP_DEL, &tuple)); + oldserial = dns_soa_getserial(&tuple->rdata); + newserial = desired = + dns_soa_getserial(&soatuple->rdata); + if (!isc_serial_gt(newserial, oldserial)) { + newserial = oldserial + 1; + if (newserial == 0) + newserial++; + dns_soa_setserial(newserial, &soatuple->rdata); + } + CHECK(do_one_tuple(&tuple, zone->rss_db, + zone->rss_newver, &zone->rss_diff)); + CHECK(do_one_tuple(&soatuple, zone->rss_db, + zone->rss_newver, &zone->rss_diff)); + dns_zone_log(zone, ISC_LOG_INFO, + "serial %u (unsigned %u)", + newserial, desired); + } else + CHECK(update_soa_serial(zone->rss_db, zone->rss_newver, + &zone->rss_diff, zone->mctx, + zone->updatemethod)); - CHECK(dns_update_signatures(&log, zone, db, oldver, newver, - &diff, zone->sigvalidityinterval)); + } + result = dns_update_signaturesinc(&log, zone, zone->rss_db, + zone->rss_oldver, zone->rss_newver, + &zone->rss_diff, + zone->sigvalidityinterval, + &zone->rss_state); + if (result == DNS_R_CONTINUE) { + if (rjournal != NULL) + dns_journal_destroy(&rjournal); + isc_task_send(task, &event); + fprintf(stderr, "looping on dns_update_signaturesinc\n"); + return; + } + if (result != ISC_R_SUCCESS) + goto failure; - CHECK(zone_journal(zone, &diff, &end, "receive_secure_serial")); + if (rjournal == NULL) + CHECK(dns_journal_open(zone->rss_raw->mctx, + zone->rss_raw->journal, + DNS_JOURNAL_WRITE, &rjournal)); + CHECK(zone_journal(zone, &zone->rss_diff, &end, + "receive_secure_serial")); dns_journal_set_sourceserial(rjournal, end); dns_journal_commit(rjournal); @@ -13058,12 +13158,15 @@ receive_secure_serial(isc_task_t *task, isc_event_t *event) { zone_settimer(zone, &timenow); UNLOCK_ZONE(zone); - dns_db_closeversion(db, &oldver, ISC_FALSE); - dns_db_closeversion(db, &newver, ISC_TRUE); + dns_db_closeversion(zone->rss_db, &zone->rss_oldver, ISC_FALSE); + dns_db_closeversion(zone->rss_db, &zone->rss_newver, ISC_TRUE); failure: - if (raw != NULL) - dns_zone_detach(&raw); + isc_event_free(&zone->rss_event); + event = ISC_LIST_HEAD(zone->rss_events); + + if (zone->rss_raw != NULL) + dns_zone_detach(&zone->rss_raw); if (result != ISC_R_SUCCESS) dns_zone_log(zone, ISC_LOG_ERROR, "receive_secure_serial: %s", dns_result_totext(result)); @@ -13071,20 +13174,28 @@ receive_secure_serial(isc_task_t *task, isc_event_t *event) { dns_difftuple_free(&tuple); if (soatuple != NULL) dns_difftuple_free(&soatuple); - if (db != NULL) { - if (oldver != NULL) - dns_db_closeversion(db, &oldver, ISC_FALSE); - if (newver != NULL) - dns_db_closeversion(db, &newver, ISC_FALSE); - dns_db_detach(&db); + if (zone->rss_db != NULL) { + if (zone->rss_oldver != NULL) + dns_db_closeversion(zone->rss_db, &zone->rss_oldver, + ISC_FALSE); + if (zone->rss_newver != NULL) + dns_db_closeversion(zone->rss_db, &zone->rss_newver, + ISC_FALSE); + dns_db_detach(&zone->rss_db); } + INSIST(zone->rss_oldver == NULL); + INSIST(zone->rss_newver == NULL); if (rjournal != NULL) dns_journal_destroy(&rjournal); - dns_diff_clear(&diff); - dns_zone_idetach(&zone); + dns_diff_clear(&zone->rss_diff); - INSIST(oldver == NULL); - INSIST(newver == NULL); + if (event != NULL) { + LOCK_ZONE(zone); + INSIST(zone->irefs > 1); + zone->irefs--; + goto nextevent; + } + dns_zone_idetach(&zone); } static isc_result_t @@ -13144,11 +13255,10 @@ checkandaddsoa(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, result = dns_rdata_fromstruct(&rdata, rdataset->rdclass, dns_rdatatype_soa, &soa, &b); RUNTIME_CHECK(result == ISC_R_SUCCESS); + dns_rdatalist_init(&temprdatalist); temprdatalist.rdclass = rdata.rdclass; temprdatalist.type = rdata.type; - temprdatalist.covers = 0; temprdatalist.ttl = rdataset->ttl; - ISC_LIST_INIT(temprdatalist.rdata); ISC_LIST_APPEND(temprdatalist.rdata, &rdata, link); dns_rdataset_init(&temprdataset); @@ -15477,8 +15587,8 @@ dns_zonemgr_setserialqueryrate(dns_zonemgr_t *zmgr, unsigned int value) { setrl(zmgr->refreshrl, &zmgr->serialqueryrate, value); /* Seperately controlled in BIND 9.11.x */ - setrl(zmgr->notifyrl, &zmgr->notifyrate, 20); - setrl(zmgr->startupnotifyrl, &zmgr->startupnotifyrate, 20); + setrl(zmgr->notifyrl, &zmgr->notifyrate, value); + setrl(zmgr->startupnotifyrl, &zmgr->startupnotifyrate, value); /* XXXMPA seperate out once we have the code to support this. */ setrl(zmgr->startuprefreshrl, &zmgr->startupserialqueryrate, value); @@ -16016,6 +16126,12 @@ dns_zone_setsignatures(dns_zone_t *zone, isc_uint32_t signatures) { zone->signatures = signatures; } +isc_uint32_t +dns_zone_getsignatures(dns_zone_t *zone) { + REQUIRE(DNS_ZONE_VALID(zone)); + return (zone->signatures); +} + void dns_zone_setprivatetype(dns_zone_t *zone, dns_rdatatype_t type) { REQUIRE(DNS_ZONE_VALID(zone)); @@ -16853,6 +16969,148 @@ dns_zone_nscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version, return (result); } +isc_result_t +dns_zone_cdscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version) { + isc_result_t result; + dns_dbnode_t *node = NULL; + dns_rdataset_t dnskey, cds, cdnskey; + unsigned char buffer[DNS_DS_BUFFERSIZE]; + unsigned char algorithms[256]; + unsigned int i; + + REQUIRE(DNS_ZONE_VALID(zone)); + + result = dns_db_getoriginnode(db, &node); + if (result != ISC_R_SUCCESS) + return (result); + + dns_rdataset_init(&cds); + dns_rdataset_init(&dnskey); + dns_rdataset_init(&cdnskey); + + result = dns_db_findrdataset(db, node, version, dns_rdatatype_cds, + dns_rdatatype_none, 0, &cds, NULL); + if (result != ISC_R_SUCCESS && result != ISC_R_NOTFOUND) + goto failure; + + result = dns_db_findrdataset(db, node, version, dns_rdatatype_cdnskey, + dns_rdatatype_none, 0, &cdnskey, NULL); + if (result != ISC_R_SUCCESS && result != ISC_R_NOTFOUND) + goto failure; + + if (!dns_rdataset_isassociated(&cds) && + !dns_rdataset_isassociated(&cdnskey)) { + result = ISC_R_SUCCESS; + goto failure; + } + + result = dns_db_findrdataset(db, node, version, dns_rdatatype_dnskey, + dns_rdatatype_none, 0, &dnskey, NULL); + if (result == ISC_R_NOTFOUND) { + if (dns_rdataset_isassociated(&cds)) + result = DNS_R_BADCDS; + else + result = DNS_R_BADCDNSKEY; + goto failure; + } + if (result != ISC_R_SUCCESS) + goto failure; + + /* + * For each DNSSEC algorithm in the CDS RRset there must be + * a matching DNSKEY record. + */ + if (dns_rdataset_isassociated(&cds)) { + memset(algorithms, 0, sizeof(algorithms)); + for (result = dns_rdataset_first(&cds); + result == ISC_R_SUCCESS; + result = dns_rdataset_next(&cds)) { + dns_rdata_t crdata = DNS_RDATA_INIT; + dns_rdata_cds_t structcds; + + dns_rdataset_current(&cds, &crdata); + CHECK(dns_rdata_tostruct(&crdata, &structcds, NULL)); + if (algorithms[structcds.algorithm] == 0) + algorithms[structcds.algorithm] = 1; + for (result = dns_rdataset_first(&dnskey); + result == ISC_R_SUCCESS; + result = dns_rdataset_next(&dnskey)) { + dns_rdata_t rdata = DNS_RDATA_INIT; + dns_rdata_t dsrdata = DNS_RDATA_INIT; + + dns_rdataset_current(&dnskey, &rdata); + CHECK(dns_ds_buildrdata(&zone->origin, &rdata, + structcds.digest_type, + buffer, &dsrdata)); + if (crdata.length == dsrdata.length && + memcmp(crdata.data, dsrdata.data, + dsrdata.length) == 0) { + algorithms[structcds.algorithm] = 2; + } + } + if (result != ISC_R_NOMORE) + goto failure; + } + for (i = 0; i < sizeof(algorithms); i++) { + if (algorithms[i] == 1) { + result = DNS_R_BADCDNSKEY; + goto failure; + } + } + } + + /* + * For each DNSSEC algorithm in the CDNSKEY RRset there must be + * a matching DNSKEY record. + */ + if (dns_rdataset_isassociated(&cdnskey)) { + memset(algorithms, 0, sizeof(algorithms)); + for (result = dns_rdataset_first(&cdnskey); + result == ISC_R_SUCCESS; + result = dns_rdataset_next(&cdnskey)) { + dns_rdata_t crdata = DNS_RDATA_INIT; + dns_rdata_cdnskey_t structcdnskey; + + dns_rdataset_current(&cdnskey, &crdata); + CHECK(dns_rdata_tostruct(&crdata, &structcdnskey, + NULL)); + if (algorithms[structcdnskey.algorithm] == 0) + algorithms[structcdnskey.algorithm] = 1; + for (result = dns_rdataset_first(&dnskey); + result == ISC_R_SUCCESS; + result = dns_rdataset_next(&dnskey)) { + dns_rdata_t rdata = DNS_RDATA_INIT; + + dns_rdataset_current(&dnskey, &rdata); + if (crdata.length == rdata.length && + memcmp(crdata.data, rdata.data, + rdata.length) == 0) { + algorithms[structcdnskey.algorithm] = 2; + } + } + if (result != ISC_R_NOMORE) + goto failure; + } + for (i = 0; i < sizeof(algorithms); i++) { + if (algorithms[i] == 1) { + result = DNS_R_BADCDS; + goto failure; + } + } + } + result = ISC_R_SUCCESS; + + failure: + if (dns_rdataset_isassociated(&cds)) + dns_rdataset_disassociate(&cds); + if (dns_rdataset_isassociated(&dnskey)) + dns_rdataset_disassociate(&dnskey); + if (dns_rdataset_isassociated(&cdnskey)) + dns_rdataset_disassociate(&cdnskey); + dns_db_detachnode(db, &node); + return (result); +} + void dns_zone_setadded(dns_zone_t *zone, isc_boolean_t added) { REQUIRE(DNS_ZONE_VALID(zone)); @@ -17034,7 +17292,7 @@ keydone(isc_task_t *task, isc_event_t *event) { dns_dbnode_t *node = NULL; dns_rdataset_t rdataset; dns_diff_t diff; - struct keydone *keydone = (struct keydone *)event; + struct keydone *kd = (struct keydone *)event; dns_update_log_t log = { update_log_cb, NULL }; isc_boolean_t clear_pending = ISC_FALSE; @@ -17086,7 +17344,7 @@ keydone(isc_task_t *task, isc_event_t *event) { dns_rdataset_current(&rdataset, &rdata); - if (keydone->all) { + if (kd->all) { if (rdata.length == 5 && rdata.data[0] != 0 && rdata.data[3] == 0 && rdata.data[4] == 1) found = ISC_TRUE; @@ -17096,7 +17354,7 @@ keydone(isc_task_t *task, isc_event_t *event) { clear_pending = ISC_TRUE; } } else if (rdata.length == 5 && - memcmp(rdata.data, keydone->data, 5) == 0) + memcmp(rdata.data, kd->data, 5) == 0) found = ISC_TRUE; if (found) |