From 029e4bda60e74dec6fccfdd0e62e1589d43ae0a1 Mon Sep 17 00:00:00 2001 From: purplerain Date: Thu, 25 Jan 2024 01:55:28 +0000 Subject: [PATCH] remove whitespace and tab --- lib/libarch/alpha/bwx.c | 16 +- lib/libarch/alpha/io.c | 10 +- lib/libkeynote/sample-app.c | 2 +- lib/libutil/imsg.c | 2 +- libexec/security/security | 2 +- .../unwind/libunbound/iterator/iter_delegpt.c | 60 +- .../unwind/libunbound/iterator/iter_delegpt.h | 54 +- sbin/unwind/libunbound/iterator/iter_donotq.c | 26 +- sbin/unwind/libunbound/iterator/iter_donotq.h | 16 +- sbin/unwind/libunbound/iterator/iter_fwd.c | 44 +- sbin/unwind/libunbound/iterator/iter_fwd.h | 28 +- sbin/unwind/libunbound/iterator/iter_hints.c | 62 +-- sbin/unwind/libunbound/iterator/iter_hints.h | 20 +- sbin/unwind/libunbound/iterator/iter_priv.c | 28 +- sbin/unwind/libunbound/iterator/iter_priv.h | 18 +- .../libunbound/iterator/iter_resptype.c | 100 ++-- .../libunbound/iterator/iter_resptype.h | 32 +- sbin/unwind/libunbound/iterator/iter_scrub.c | 134 ++--- sbin/unwind/libunbound/iterator/iter_scrub.h | 16 +- sbin/unwind/libunbound/iterator/iter_utils.h | 44 +- sbin/unwind/libunbound/iterator/iterator.c | 518 +++++++++--------- sbin/unwind/libunbound/iterator/iterator.h | 84 +-- sbin/unwind/libunbound/libunbound/context.c | 40 +- sbin/unwind/libunbound/libunbound/context.h | 36 +- .../unwind/libunbound/libunbound/libunbound.c | 112 ++-- sbin/unwind/libunbound/libunbound/libworker.c | 72 +-- sbin/unwind/libunbound/libunbound/libworker.h | 22 +- .../libunbound/libunbound/unbound-event.h | 20 +- sbin/unwind/libunbound/libunbound/worker.h | 22 +- sbin/unwind/libunbound/respip/respip.c | 4 +- sbin/unwind/libunbound/respip/respip.h | 2 +- sbin/unwind/libunbound/services/authzone.c | 62 +-- sbin/unwind/libunbound/services/authzone.h | 20 +- sbin/unwind/libunbound/services/cache/dns.c | 116 ++-- sbin/unwind/libunbound/services/cache/dns.h | 30 +- sbin/unwind/libunbound/services/cache/infra.c | 64 +-- sbin/unwind/libunbound/services/cache/infra.h | 26 +- sbin/unwind/libunbound/services/cache/rrset.c | 70 +-- sbin/unwind/libunbound/services/cache/rrset.h | 34 +- .../libunbound/services/listen_dnsport.h | 26 +- sbin/unwind/libunbound/services/localzone.c | 98 ++-- sbin/unwind/libunbound/services/localzone.h | 44 +- sbin/unwind/libunbound/services/mesh.h | 40 +- sbin/unwind/libunbound/services/modstack.c | 16 +- sbin/unwind/libunbound/services/modstack.h | 12 +- .../libunbound/services/outbound_list.c | 18 +- .../libunbound/services/outbound_list.h | 16 +- .../libunbound/services/outside_network.c | 166 +++--- .../libunbound/services/outside_network.h | 32 +- sbin/unwind/libunbound/services/rpz.c | 18 +- sbin/unwind/libunbound/services/rpz.h | 10 +- sbin/unwind/libunbound/services/view.c | 26 +- sbin/unwind/libunbound/services/view.h | 16 +- sbin/unwind/libunbound/sldns/keyraw.c | 14 +- sbin/unwind/libunbound/sldns/keyraw.h | 8 +- sbin/unwind/libunbound/sldns/parse.h | 22 +- sbin/unwind/libunbound/sldns/parseutil.c | 16 +- sbin/unwind/libunbound/sldns/parseutil.h | 6 +- sbin/unwind/libunbound/sldns/pkthdr.h | 2 +- sbin/unwind/libunbound/sldns/rrdef.c | 2 +- sbin/unwind/libunbound/sldns/rrdef.h | 2 +- sbin/unwind/libunbound/sldns/sbuffer.c | 18 +- sbin/unwind/libunbound/sldns/sbuffer.h | 8 +- sbin/unwind/libunbound/sldns/str2wire.c | 2 +- sbin/unwind/libunbound/util/alloc.c | 58 +- sbin/unwind/libunbound/util/alloc.h | 14 +- sbin/unwind/libunbound/util/as112.c | 10 +- sbin/unwind/libunbound/util/as112.h | 12 +- sbin/unwind/libunbound/util/configlexer.c | 80 +-- sbin/unwind/libunbound/util/data/dname.c | 68 +-- sbin/unwind/libunbound/util/data/dname.h | 36 +- sbin/unwind/libunbound/util/data/msgencode.c | 92 ++-- sbin/unwind/libunbound/util/data/msgencode.h | 22 +- sbin/unwind/libunbound/util/data/msgparse.c | 158 +++--- sbin/unwind/libunbound/util/data/msgparse.h | 28 +- sbin/unwind/libunbound/util/data/msgreply.c | 140 ++--- sbin/unwind/libunbound/util/data/msgreply.h | 66 +-- .../libunbound/util/data/packed_rrset.c | 58 +- .../libunbound/util/data/packed_rrset.h | 62 +-- sbin/unwind/libunbound/util/fptr_wlist.c | 66 +-- sbin/unwind/libunbound/util/fptr_wlist.h | 32 +- sbin/unwind/libunbound/util/locks.c | 28 +- sbin/unwind/libunbound/util/locks.h | 18 +- sbin/unwind/libunbound/util/log.c | 40 +- sbin/unwind/libunbound/util/log.h | 18 +- sbin/unwind/libunbound/util/mini_event.c | 30 +- sbin/unwind/libunbound/util/mini_event.h | 24 +- sbin/unwind/libunbound/util/module.c | 20 +- sbin/unwind/libunbound/util/module.h | 86 +-- sbin/unwind/libunbound/util/net_help.c | 60 +- sbin/unwind/libunbound/util/net_help.h | 34 +- sbin/unwind/libunbound/util/proxy_protocol.c | 10 +- sbin/unwind/libunbound/util/proxy_protocol.h | 10 +- sbin/unwind/libunbound/util/random.c | 22 +- sbin/unwind/libunbound/util/random.h | 16 +- sbin/unwind/libunbound/util/rbtree.c | 38 +- sbin/unwind/libunbound/util/rbtree.h | 44 +- sbin/unwind/libunbound/util/regional.c | 24 +- sbin/unwind/libunbound/util/regional.h | 22 +- sbin/unwind/libunbound/util/rtt.c | 20 +- sbin/unwind/libunbound/util/rtt.h | 16 +- sbin/unwind/libunbound/util/storage/dnstree.c | 16 +- sbin/unwind/libunbound/util/storage/dnstree.h | 24 +- sbin/unwind/libunbound/util/storage/lookup3.c | 42 +- sbin/unwind/libunbound/util/storage/lookup3.h | 10 +- sbin/unwind/libunbound/util/storage/lruhash.c | 74 +-- sbin/unwind/libunbound/util/storage/lruhash.h | 46 +- .../unwind/libunbound/util/storage/slabhash.c | 30 +- .../unwind/libunbound/util/storage/slabhash.h | 28 +- sbin/unwind/libunbound/util/tcp_conn_limit.c | 10 +- sbin/unwind/libunbound/util/timehist.h | 14 +- sbin/unwind/libunbound/util/tube.c | 50 +- sbin/unwind/libunbound/util/tube.h | 20 +- sbin/unwind/libunbound/util/ub_event.h | 14 +- .../libunbound/util/ub_event_pluggable.c | 12 +- sbin/unwind/libunbound/util/winsock_event.c | 48 +- sbin/unwind/libunbound/util/winsock_event.h | 24 +- sbin/unwind/libunbound/validator/autotrust.c | 156 +++--- sbin/unwind/libunbound/validator/autotrust.h | 22 +- sbin/unwind/libunbound/validator/val_anchor.c | 74 +-- sbin/unwind/libunbound/validator/val_anchor.h | 16 +- sbin/unwind/libunbound/validator/val_kcache.c | 32 +- sbin/unwind/libunbound/validator/val_kcache.h | 14 +- sbin/unwind/libunbound/validator/val_kentry.c | 50 +- sbin/unwind/libunbound/validator/val_kentry.h | 14 +- sbin/unwind/libunbound/validator/val_neg.c | 128 ++--- sbin/unwind/libunbound/validator/val_neg.h | 36 +- sbin/unwind/libunbound/validator/val_nsec.c | 114 ++-- sbin/unwind/libunbound/validator/val_nsec.h | 28 +- sbin/unwind/libunbound/validator/val_nsec3.c | 186 +++---- sbin/unwind/libunbound/validator/val_nsec3.h | 52 +- .../unwind/libunbound/validator/val_secalgo.c | 42 +- .../unwind/libunbound/validator/val_secalgo.h | 12 +- .../libunbound/validator/val_sigcrypt.c | 136 ++--- .../libunbound/validator/val_sigcrypt.h | 58 +- sbin/unwind/libunbound/validator/val_utils.c | 174 +++--- sbin/unwind/libunbound/validator/val_utils.h | 38 +- sbin/unwind/libunbound/validator/validator.c | 438 +++++++-------- sbin/unwind/libunbound/validator/validator.h | 28 +- sys/arch/arm64/dev/apldc.c | 2 +- sys/dev/fdt/sncodec.c | 2 +- sys/dev/ic/qwx.c | 34 +- sys/dev/ic/qwxreg.h | 2 +- sys/dev/ic/qwxvar.h | 2 +- sys/dev/pci/drm/i915/display/intel_hdcp.c | 2 +- sys/dev/pci/drm/include/linux/device.h | 2 +- sys/dev/pci/drm/ttm/ttm_bo_util.c | 2 +- sys/dev/pci/if_iwm.c | 2 +- sys/dev/pci/if_qwx_pci.c | 4 +- sys/dev/usb/ugold.c | 2 +- sys/miscfs/fuse/fuse_device.c | 4 +- sys/uvm/uvm_map.c | 2 +- usr.sbin/httpd/css.h.in | 22 +- usr.sbin/httpd/js.h.in | 8 +- usr.sbin/httpd/server_file.c | 8 +- usr.sbin/nsd/util/proxy_protocol.c | 10 +- usr.sbin/nsd/util/proxy_protocol.h | 10 +- usr.sbin/pppd/chat/chat.c | 2 +- usr.sbin/rdate/ntp.c | 2 +- usr.sbin/snmpd/application.c | 2 +- usr.sbin/snmpd/parse.y | 2 +- 161 files changed, 3363 insertions(+), 3363 deletions(-) diff --git a/lib/libarch/alpha/bwx.c b/lib/libarch/alpha/bwx.c index 1d0dc856a..bb2f6753e 100644 --- a/lib/libarch/alpha/bwx.c +++ b/lib/libarch/alpha/bwx.c @@ -59,17 +59,17 @@ static void bwx_open_mem(void) { - if (mem_fd != -1) + if (mem_fd != -1) return; mem_fd = open(_PATH_MEM, O_RDWR); - if (mem_fd < 0) + if (mem_fd < 0) mem_fd = open(PATH_APERTURE, O_RDWR); if (mem_fd < 0) - err(1, "Failed to open both %s and %s", _PATH_MEM, + err(1, "Failed to open both %s and %s", _PATH_MEM, PATH_APERTURE); } -static void +static void bwx_close_mem(void) { @@ -85,7 +85,7 @@ bwx_init(void) size_t len = sizeof(u_int64_t); int error; int mib[3]; - + page_mask = getpagesize() - 1; mib[0] = CTL_MACHDEP; @@ -111,13 +111,13 @@ bwx_ioperm(u_int32_t from, u_int32_t num, int on) if (bwx_int1_ports != MAP_FAILED) return 0; - + bwx_open_mem(); start = trunc_page(from); end = round_page(from + num); if ((bwx_int1_ports = mmap(0, end-start, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, bwx_io_base + BWX_EV56_INT1 + start)) == - MAP_FAILED) + MAP_FAILED) err(1, "mmap int1"); if ((bwx_int2_ports = mmap(0, end-start, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, bwx_io_base + BWX_EV56_INT2 + start)) == @@ -125,7 +125,7 @@ bwx_ioperm(u_int32_t from, u_int32_t num, int on) err(1, "mmap int2"); if ((bwx_int4_ports = mmap(0, end-start, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, bwx_io_base + BWX_EV56_INT4 + start)) == - MAP_FAILED) + MAP_FAILED) err(1, "mmap int4"); bwx_close_mem(); return 0; diff --git a/lib/libarch/alpha/io.c b/lib/libarch/alpha/io.c index b5b6238c3..b37d0f76c 100644 --- a/lib/libarch/alpha/io.c +++ b/lib/libarch/alpha/io.c @@ -56,7 +56,7 @@ ioperm(unsigned long from, unsigned long num, int on) #else errx(1, "libio is only available on bwx capable machines"); #endif - + return ops->ioperm(from, num, on); } @@ -169,19 +169,19 @@ u_int64_t dense_base(void) { static u_int64_t base = 0; - + if (base == 0) { size_t len = sizeof(base); int error; int mib[3]; - + mib[0] = CTL_MACHDEP; mib[1] = CPU_CHIPSET; mib[2] = CPU_CHIPSET_DENSE; - + if ((error = sysctl(mib, 3, &base, &len, NULL, 0)) < 0) err(1, "machdep.chipset.dense_base"); } - + return base; } diff --git a/lib/libkeynote/sample-app.c b/lib/libkeynote/sample-app.c index 2768c42f6..a5b67ed4e 100644 --- a/lib/libkeynote/sample-app.c +++ b/lib/libkeynote/sample-app.c @@ -27,7 +27,7 @@ #include -char policy_assertions[] = +char policy_assertions[] = "Authorizer: \"POLICY\"\n" \ "Licensees: \"rsa-hex:3048024100d15d08ce7d2103d93ef21a87330361\\\n" \ " ff123096b14330f9f0936e8f2064ef815ffdaabbb7d3ba47b\\\n" \ diff --git a/lib/libutil/imsg.c b/lib/libutil/imsg.c index 0aff226bf..ab744fcb1 100644 --- a/lib/libutil/imsg.c +++ b/lib/libutil/imsg.c @@ -279,7 +279,7 @@ imsg_composev(struct imsgbuf *imsgbuf, uint32_t type, uint32_t id, pid_t pid, } /* - * Enqueue imsg with payload from ibuf buf. fd passing is not possible + * Enqueue imsg with payload from ibuf buf. fd passing is not possible * with this function. */ int diff --git a/libexec/security/security b/libexec/security/security index 20fe8e958..5ad160da5 100644 --- a/libexec/security/security +++ b/libexec/security/security @@ -686,7 +686,7 @@ sub check_disks { my $disk_re = qr/ \/ (?:ccd|dk|fd|hd|hk|hp|jb|kra|ra|rb|rd|rl|rx|rz|sd|up|vnd|wd|xd) - \d+ [B-H]? [a-p] + \d+ [B-H]? [a-p] $ /x; diff --git a/sbin/unwind/libunbound/iterator/iter_delegpt.c b/sbin/unwind/libunbound/iterator/iter_delegpt.c index c8b9a3ffe..61a7bccdc 100644 --- a/sbin/unwind/libunbound/iterator/iter_delegpt.c +++ b/sbin/unwind/libunbound/iterator/iter_delegpt.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -50,7 +50,7 @@ #include "sldns/rrdef.h" #include "sldns/sbuffer.h" -struct delegpt* +struct delegpt* delegpt_create(struct regional* region) { struct delegpt* dp=(struct delegpt*)regional_alloc( @@ -66,7 +66,7 @@ struct delegpt* delegpt_copy(struct delegpt* dp, struct regional* region) struct delegpt* copy = delegpt_create(region); struct delegpt_ns* ns; struct delegpt_addr* a; - if(!copy) + if(!copy) return NULL; if(!delegpt_set_name(copy, region, dp->name)) return NULL; @@ -93,7 +93,7 @@ struct delegpt* delegpt_copy(struct delegpt* dp, struct regional* region) return copy; } -int +int delegpt_set_name(struct delegpt* dp, struct regional* region, uint8_t* name) { log_assert(!dp->dp_type_mlc); @@ -102,7 +102,7 @@ delegpt_set_name(struct delegpt* dp, struct regional* region, uint8_t* name) return dp->name != 0; } -int +int delegpt_add_ns(struct delegpt* dp, struct regional* region, uint8_t* name, uint8_t lame, char* tls_auth_name, int port) { @@ -145,7 +145,7 @@ delegpt_find_ns(struct delegpt* dp, uint8_t* name, size_t namelen) { struct delegpt_ns* p = dp->nslist; while(p) { - if(namelen == p->namelen && + if(namelen == p->namelen && query_dname_compare(name, p->name) == 0) { return p; } @@ -155,7 +155,7 @@ delegpt_find_ns(struct delegpt* dp, uint8_t* name, size_t namelen) } struct delegpt_addr* -delegpt_find_addr(struct delegpt* dp, struct sockaddr_storage* addr, +delegpt_find_addr(struct delegpt* dp, struct sockaddr_storage* addr, socklen_t addrlen) { struct delegpt_addr* p = dp->target_list; @@ -258,7 +258,7 @@ delegpt_count_ns(struct delegpt* dp, size_t* numns, size_t* missing) } void -delegpt_count_addr(struct delegpt* dp, size_t* numaddr, size_t* numres, +delegpt_count_addr(struct delegpt* dp, size_t* numaddr, size_t* numres, size_t* numavail) { struct delegpt_addr* a; @@ -292,14 +292,14 @@ void delegpt_log(enum verbosity_value v, struct delegpt* dp) delegpt_count_ns(dp, &numns, &missing); delegpt_count_addr(dp, &numaddr, &numres, &numavail); log_info("DelegationPoint<%s>: %u names (%u missing), " - "%u addrs (%u result, %u avail)%s", - buf, (unsigned)numns, (unsigned)missing, + "%u addrs (%u result, %u avail)%s", + buf, (unsigned)numns, (unsigned)missing, (unsigned)numaddr, (unsigned)numres, (unsigned)numavail, (dp->has_parent_side_NS?" parentNS":" cacheNS")); if(verbosity >= VERB_ALGO) { for(ns = dp->nslist; ns; ns = ns->next) { dname_str(ns->name, buf); - log_info(" %s %s%s%s%s%s%s%s", buf, + log_info(" %s %s%s%s%s%s%s%s", buf, (ns->resolved?"*":""), (ns->got4?" A":""), (ns->got6?" AAAA":""), (dp->bogus?" BOGUS":""), (ns->lame?" PARENTSIDE":""), @@ -360,7 +360,7 @@ delegpt_add_to_result_list(struct delegpt* dp, struct delegpt_addr* a) dp->result_list = a; } -void +void delegpt_add_unused_targets(struct delegpt* dp) { struct delegpt_addr* usa = dp->usable_list; @@ -382,7 +382,7 @@ delegpt_count_targets(struct delegpt* dp) return n; } -size_t +size_t delegpt_count_missing_targets(struct delegpt* dp, int* alllame) { struct delegpt_ns* ns; @@ -408,27 +408,27 @@ find_NS(struct reply_info* rep, size_t from, size_t to) return NULL; } -struct delegpt* +struct delegpt* delegpt_from_message(struct dns_msg* msg, struct regional* region) { struct ub_packed_rrset_key* ns_rrset = NULL; struct delegpt* dp; size_t i; /* look for NS records in the authority section... */ - ns_rrset = find_NS(msg->rep, msg->rep->an_numrrsets, + ns_rrset = find_NS(msg->rep, msg->rep->an_numrrsets, msg->rep->an_numrrsets+msg->rep->ns_numrrsets); - /* In some cases (even legitimate, perfectly legal cases), the + /* In some cases (even legitimate, perfectly legal cases), the * NS set for the "referral" might be in the answer section. */ if(!ns_rrset) ns_rrset = find_NS(msg->rep, 0, msg->rep->an_numrrsets); - - /* If there was no NS rrset in the authority section, then this - * wasn't a referral message. (It might not actually be a + + /* If there was no NS rrset in the authority section, then this + * wasn't a referral message. (It might not actually be a * referral message anyway) */ if(!ns_rrset) return NULL; - + /* If we found any, then Yay! we have a delegation point. */ dp = delegpt_create(region); if(!dp) @@ -443,7 +443,7 @@ delegpt_from_message(struct dns_msg* msg, struct regional* region) for(i=0; irep->rrset_count; i++) { struct ub_packed_rrset_key* s = msg->rep->rrsets[i]; /* skip auth section. FIXME really needed?*/ - if(msg->rep->an_numrrsets <= i && + if(msg->rep->an_numrrsets <= i && i < (msg->rep->an_numrrsets+msg->rep->ns_numrrsets)) continue; @@ -458,7 +458,7 @@ delegpt_from_message(struct dns_msg* msg, struct regional* region) return dp; } -int +int delegpt_rrset_add_ns(struct delegpt* dp, struct regional* region, struct ub_packed_rrset_key* ns_rrset, uint8_t lame) { @@ -481,7 +481,7 @@ delegpt_rrset_add_ns(struct delegpt* dp, struct regional* region, return 1; } -int +int delegpt_add_rrset_A(struct delegpt* dp, struct regional* region, struct ub_packed_rrset_key* ak, uint8_t lame, int* additions) { @@ -504,7 +504,7 @@ delegpt_add_rrset_A(struct delegpt* dp, struct regional* region, return 1; } -int +int delegpt_add_rrset_AAAA(struct delegpt* dp, struct regional* region, struct ub_packed_rrset_key* ak, uint8_t lame, int* additions) { @@ -527,7 +527,7 @@ delegpt_add_rrset_AAAA(struct delegpt* dp, struct regional* region, return 1; } -int +int delegpt_add_rrset(struct delegpt* dp, struct regional* region, struct ub_packed_rrset_key* rrset, uint8_t lame, int* additions) { @@ -563,7 +563,7 @@ void delegpt_add_neg_msg(struct delegpt* dp, struct msgreply_entry* msg) /* if error or no answers */ if(FLAGS_GET_RCODE(rep->flags) != 0 || rep->an_numrrsets == 0) { - struct delegpt_ns* ns = delegpt_find_ns(dp, msg->key.qname, + struct delegpt_ns* ns = delegpt_find_ns(dp, msg->key.qname, msg->key.qname_len); delegpt_mark_neg(ns, msg->key.qtype); } diff --git a/sbin/unwind/libunbound/iterator/iter_delegpt.h b/sbin/unwind/libunbound/iterator/iter_delegpt.h index 49f6f6b81..f49aac28a 100644 --- a/sbin/unwind/libunbound/iterator/iter_delegpt.h +++ b/sbin/unwind/libunbound/iterator/iter_delegpt.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -66,7 +66,7 @@ struct delegpt { struct delegpt_ns* nslist; /** the target addresses for delegation */ struct delegpt_addr* target_list; - /** the list of usable targets; subset of target_list + /** the list of usable targets; subset of target_list * the items in this list are not part of the result list. */ struct delegpt_addr* usable_list; /** the list of returned targets; subset of target_list */ @@ -103,7 +103,7 @@ struct delegpt_ns { size_t namelen; /** number of cache lookups for the name */ int cache_lookup_count; - /** + /** * If the name has been resolved. false if not queried for yet. * true if the A, AAAA queries have been generated. * marked true if those queries fail. @@ -189,7 +189,7 @@ struct delegpt* delegpt_copy(struct delegpt* dp, struct regional* regional); * @param name: name to use. * @return false on error. */ -int delegpt_set_name(struct delegpt* dp, struct regional* regional, +int delegpt_set_name(struct delegpt* dp, struct regional* regional, uint8_t* name); /** @@ -230,8 +230,8 @@ int delegpt_rrset_add_ns(struct delegpt* dp, struct regional* regional, * @param additions: will be set to 1 if a new address is added * @return false on error. */ -int delegpt_add_target(struct delegpt* dp, struct regional* regional, - uint8_t* name, size_t namelen, struct sockaddr_storage* addr, +int delegpt_add_target(struct delegpt* dp, struct regional* regional, + uint8_t* name, size_t namelen, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t bogus, uint8_t lame, int* additions); /** @@ -243,7 +243,7 @@ int delegpt_add_target(struct delegpt* dp, struct regional* regional, * @param additions: will be set to 1 if a new address is added * @return 0 on alloc error. */ -int delegpt_add_rrset_A(struct delegpt* dp, struct regional* regional, +int delegpt_add_rrset_A(struct delegpt* dp, struct regional* regional, struct ub_packed_rrset_key* rrset, uint8_t lame, int* additions); /** @@ -255,7 +255,7 @@ int delegpt_add_rrset_A(struct delegpt* dp, struct regional* regional, * @param additions: will be set to 1 if a new address is added * @return 0 on alloc error. */ -int delegpt_add_rrset_AAAA(struct delegpt* dp, struct regional* regional, +int delegpt_add_rrset_AAAA(struct delegpt* dp, struct regional* regional, struct ub_packed_rrset_key* rrset, uint8_t lame, int* additions); /** @@ -268,7 +268,7 @@ int delegpt_add_rrset_AAAA(struct delegpt* dp, struct regional* regional, * @param additions: will be set to 1 if a new address is added * @return 0 on alloc error. */ -int delegpt_add_rrset(struct delegpt* dp, struct regional* regional, +int delegpt_add_rrset(struct delegpt* dp, struct regional* regional, struct ub_packed_rrset_key* rrset, uint8_t lame, int* additions); /** @@ -289,24 +289,24 @@ int delegpt_add_addr(struct delegpt* dp, struct regional* regional, uint8_t bogus, uint8_t lame, char* tls_auth_name, int port, int* additions); -/** +/** * Find NS record in name list of delegation point. * @param dp: delegation point. * @param name: name of nameserver to look for, uncompressed wireformat. * @param namelen: length of name. * @return the ns structure or NULL if not found. */ -struct delegpt_ns* delegpt_find_ns(struct delegpt* dp, uint8_t* name, +struct delegpt_ns* delegpt_find_ns(struct delegpt* dp, uint8_t* name, size_t namelen); -/** +/** * Find address record in total list of delegation point. * @param dp: delegation point. * @param addr: address * @param addrlen: length of addr * @return the addr structure or NULL if not found. */ -struct delegpt_addr* delegpt_find_addr(struct delegpt* dp, +struct delegpt_addr* delegpt_find_addr(struct delegpt* dp, struct sockaddr_storage* addr, socklen_t addrlen); /** @@ -320,7 +320,7 @@ void delegpt_log(enum verbosity_value v, struct delegpt* dp); void delegpt_count_ns(struct delegpt* dp, size_t* numns, size_t* missing); /** count addresses, and number in result and available lists, for logging */ -void delegpt_count_addr(struct delegpt* dp, size_t* numaddr, size_t* numres, +void delegpt_count_addr(struct delegpt* dp, size_t* numaddr, size_t* numres, size_t* numavail); /** @@ -358,7 +358,7 @@ size_t delegpt_count_targets(struct delegpt* dp); * @return new delegation point or NULL on alloc error, or if the * message was not appropriate. */ -struct delegpt* delegpt_from_message(struct dns_msg* msg, +struct delegpt* delegpt_from_message(struct dns_msg* msg, struct regional* regional); /** @@ -377,29 +377,29 @@ void delegpt_mark_neg(struct delegpt_ns* ns, uint16_t qtype); void delegpt_add_neg_msg(struct delegpt* dp, struct msgreply_entry* msg); /** - * Register the fact that there is no ipv6 and thus AAAAs are not going + * Register the fact that there is no ipv6 and thus AAAAs are not going * to be queried for or be useful. * @param dp: the delegation point. Updated to reflect no ipv6. */ void delegpt_no_ipv6(struct delegpt* dp); /** - * Register the fact that there is no ipv4 and thus As are not going + * Register the fact that there is no ipv4 and thus As are not going * to be queried for or be useful. * @param dp: the delegation point. Updated to reflect no ipv4. */ void delegpt_no_ipv4(struct delegpt* dp); -/** - * create malloced delegation point, with the given name +/** + * create malloced delegation point, with the given name * @param name: uncompressed wireformat of delegpt name. * @return NULL on alloc failure */ struct delegpt* delegpt_create_mlc(uint8_t* name); -/** +/** * free malloced delegation point. - * @param dp: must have been created with delegpt_create_mlc, free'd. + * @param dp: must have been created with delegpt_create_mlc, free'd. */ void delegpt_free_mlc(struct delegpt* dp); @@ -413,7 +413,7 @@ int delegpt_set_name_mlc(struct delegpt* dp, uint8_t* name); /** * add a name to malloced delegation point. - * @param dp: must have been created with delegpt_create_mlc. + * @param dp: must have been created with delegpt_create_mlc. * @param name: the name to add. * @param lame: the name is lame, disprefer. * @param tls_auth_name: TLS authentication name (or NULL). @@ -440,7 +440,7 @@ int delegpt_add_addr_mlc(struct delegpt* dp, struct sockaddr_storage* addr, /** * Add target address to the delegation point. - * @param dp: must have been created with delegpt_create_mlc. + * @param dp: must have been created with delegpt_create_mlc. * @param name: name for which target was found (must be in nslist). * This name is marked resolved. * @param namelen: length of name. diff --git a/sbin/unwind/libunbound/iterator/iter_donotq.c b/sbin/unwind/libunbound/iterator/iter_donotq.c index 40ffb45c4..3fb7bdeed 100644 --- a/sbin/unwind/libunbound/iterator/iter_donotq.c +++ b/sbin/unwind/libunbound/iterator/iter_donotq.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -48,7 +48,7 @@ #include "util/config_file.h" #include "util/net_help.h" -struct iter_donotq* +struct iter_donotq* donotq_create(void) { struct iter_donotq* dq = (struct iter_donotq*)calloc(1, @@ -63,10 +63,10 @@ donotq_create(void) return dq; } -void +void donotq_delete(struct iter_donotq* dq) { - if(!dq) + if(!dq) return; regional_destroy(dq->region); free(dq); @@ -74,7 +74,7 @@ donotq_delete(struct iter_donotq* dq) /** insert new address into donotq structure */ static int -donotq_insert(struct iter_donotq* dq, struct sockaddr_storage* addr, +donotq_insert(struct iter_donotq* dq, struct sockaddr_storage* addr, socklen_t addrlen, int net) { struct addr_tree_node* node = (struct addr_tree_node*)regional_alloc( @@ -107,7 +107,7 @@ donotq_str_cfg(struct iter_donotq* dq, const char* str) } /** read donotq config */ -static int +static int read_donotq(struct iter_donotq* dq, struct config_file* cfg) { struct config_strlist* p; @@ -119,7 +119,7 @@ read_donotq(struct iter_donotq* dq, struct config_file* cfg) return 1; } -int +int donotq_apply_cfg(struct iter_donotq* dq, struct config_file* cfg) { regional_free_all(dq->region); @@ -138,14 +138,14 @@ donotq_apply_cfg(struct iter_donotq* dq, struct config_file* cfg) return 1; } -int +int donotq_lookup(struct iter_donotq* donotq, struct sockaddr_storage* addr, socklen_t addrlen) { return addr_tree_lookup(&donotq->tree, addr, addrlen) != NULL; } -size_t +size_t donotq_get_mem(struct iter_donotq* donotq) { if(!donotq) return 0; diff --git a/sbin/unwind/libunbound/iterator/iter_donotq.h b/sbin/unwind/libunbound/iterator/iter_donotq.h index 14105073a..591fe5fd6 100644 --- a/sbin/unwind/libunbound/iterator/iter_donotq.h +++ b/sbin/unwind/libunbound/iterator/iter_donotq.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -53,16 +53,16 @@ struct regional; struct iter_donotq { /** regional for allocation */ struct regional* region; - /** + /** * Tree of the address spans that are blocked. - * contents of type addr_tree_node. Each node is an address span + * contents of type addr_tree_node. Each node is an address span * that must not be used to send queries to. */ rbtree_type tree; }; /** - * Create donotqueryaddresses structure + * Create donotqueryaddresses structure * @return new structure or NULL on error. */ struct iter_donotq* donotq_create(void); diff --git a/sbin/unwind/libunbound/iterator/iter_fwd.c b/sbin/unwind/libunbound/iterator/iter_fwd.c index 151372912..e1d37382b 100644 --- a/sbin/unwind/libunbound/iterator/iter_fwd.c +++ b/sbin/unwind/libunbound/iterator/iter_fwd.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -60,11 +60,11 @@ fwd_cmp(const void* k1, const void* k2) return -1; return 1; } - return dname_lab_cmp(n1->name, n1->namelabs, n2->name, n2->namelabs, + return dname_lab_cmp(n1->name, n1->namelabs, n2->name, n2->namelabs, &m); } -struct iter_forwards* +struct iter_forwards* forwards_create(void) { struct iter_forwards* fwd = (struct iter_forwards*)calloc(1, @@ -95,10 +95,10 @@ static void fwd_del_tree(struct iter_forwards* fwd) free(fwd->tree); } -void +void forwards_delete(struct iter_forwards* fwd) { - if(!fwd) + if(!fwd) return; fwd_del_tree(fwd); free(fwd); @@ -106,7 +106,7 @@ forwards_delete(struct iter_forwards* fwd) /** insert info into forward structure */ static int -forwards_insert_data(struct iter_forwards* fwd, uint16_t c, uint8_t* nm, +forwards_insert_data(struct iter_forwards* fwd, uint16_t c, uint8_t* nm, size_t nmlen, int nmlabs, struct delegpt* dp) { struct iter_forward_zone* node = (struct iter_forward_zone*)malloc( @@ -175,7 +175,7 @@ fwd_init_parents(struct iter_forwards* fwd) } /** set zone name */ -static struct delegpt* +static struct delegpt* read_fwds_name(struct config_stub* s) { struct delegpt* dp; @@ -211,7 +211,7 @@ read_fwds_host(struct config_stub* s, struct delegpt* dp) log_assert(p->str); dname = authextstrtodname(p->str, &port, &tls_auth_name); if(!dname) { - log_err("cannot parse forward %s server name: '%s'", + log_err("cannot parse forward %s server name: '%s'", s->name, p->str); return 0; } @@ -231,7 +231,7 @@ read_fwds_host(struct config_stub* s, struct delegpt* dp) } /** set fwd server addresses */ -static int +static int read_fwds_addr(struct config_stub* s, struct delegpt* dp) { struct config_strlist* p; @@ -241,7 +241,7 @@ read_fwds_addr(struct config_stub* s, struct delegpt* dp) for(p = s->addrs; p; p = p->next) { log_assert(p->str); if(!authextstrtoaddr(p->str, &addr, &addrlen, &tls_auth_name)) { - log_err("cannot parse forward %s ip address: '%s'", + log_err("cannot parse forward %s ip address: '%s'", s->name, p->str); return 0; } @@ -260,7 +260,7 @@ read_fwds_addr(struct config_stub* s, struct delegpt* dp) } /** read forwards config */ -static int +static int read_forwards(struct iter_forwards* fwd, struct config_file* cfg) { struct config_stub* s; @@ -329,7 +329,7 @@ make_stub_holes(struct iter_forwards* fwd, struct config_file* cfg) return 1; } -int +int forwards_apply_cfg(struct iter_forwards* fwd, struct config_file* cfg) { fwd_del_tree(fwd); @@ -346,7 +346,7 @@ forwards_apply_cfg(struct iter_forwards* fwd, struct config_file* cfg) return 1; } -struct delegpt* +struct delegpt* forwards_find(struct iter_forwards* fwd, uint8_t* qname, uint16_t qclass) { rbnode_type* res = NULL; @@ -360,7 +360,7 @@ forwards_find(struct iter_forwards* fwd, uint8_t* qname, uint16_t qclass) return NULL; } -struct delegpt* +struct delegpt* forwards_lookup(struct iter_forwards* fwd, uint8_t* qname, uint16_t qclass) { /* lookup the forward zone in the tree */ @@ -394,7 +394,7 @@ forwards_lookup(struct iter_forwards* fwd, uint8_t* qname, uint16_t qclass) return NULL; } -struct delegpt* +struct delegpt* forwards_lookup_root(struct iter_forwards* fwd, uint16_t qclass) { uint8_t root = 0; @@ -451,7 +451,7 @@ forwards_next_root(struct iter_forwards* fwd, uint16_t* dclass) } } -size_t +size_t forwards_get_mem(struct iter_forwards* fwd) { struct iter_forward_zone* p; @@ -476,7 +476,7 @@ fwd_zone_find(struct iter_forwards* fwd, uint16_t c, uint8_t* nm) return (struct iter_forward_zone*)rbtree_search(fwd->tree, &key); } -int +int forwards_add_zone(struct iter_forwards* fwd, uint16_t c, struct delegpt* dp) { struct iter_forward_zone *z; @@ -490,7 +490,7 @@ forwards_add_zone(struct iter_forwards* fwd, uint16_t c, struct delegpt* dp) return 1; } -void +void forwards_delete_zone(struct iter_forwards* fwd, uint16_t c, uint8_t* nm) { struct iter_forward_zone *z; diff --git a/sbin/unwind/libunbound/iterator/iter_fwd.h b/sbin/unwind/libunbound/iterator/iter_fwd.h index e90b74c16..72dd43478 100644 --- a/sbin/unwind/libunbound/iterator/iter_fwd.h +++ b/sbin/unwind/libunbound/iterator/iter_fwd.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -50,7 +50,7 @@ struct delegpt; * Iterator forward zones structure */ struct iter_forwards { - /** + /** * Zones are stored in this tree. Sort order is specially chosen. * first sorted on qclass. Then on dname in nsec-like order, so that * a lookup on class, name will return an exact match or the closest @@ -72,9 +72,9 @@ struct iter_forward_zone { size_t namelen; /** number of labels in name */ int namelabs; - /** delegation point with forward server information for this zone. + /** delegation point with forward server information for this zone. * If NULL then this forward entry is used to indicate that a - * stub-zone with the same name exists, and should be used. + * stub-zone with the same name exists, and should be used. * This delegation point is malloced. */ struct delegpt* dp; @@ -85,7 +85,7 @@ struct iter_forward_zone { }; /** - * Create forwards + * Create forwards * @return new forwards or NULL on error. */ struct iter_forwards* forwards_create(void); @@ -125,7 +125,7 @@ struct delegpt* forwards_find(struct iter_forwards* fwd, uint8_t* qname, * @return: A delegation point if the query has to be forwarded to that list, * otherwise null. */ -struct delegpt* forwards_lookup(struct iter_forwards* fwd, +struct delegpt* forwards_lookup(struct iter_forwards* fwd, uint8_t* qname, uint16_t qclass); /** @@ -134,7 +134,7 @@ struct delegpt* forwards_lookup(struct iter_forwards* fwd, * @param qclass: The qclass of the query. * @return: A delegation point if root forward exists, otherwise null. */ -struct delegpt* forwards_lookup_root(struct iter_forwards* fwd, +struct delegpt* forwards_lookup_root(struct iter_forwards* fwd, uint16_t qclass); /** @@ -156,7 +156,7 @@ size_t forwards_get_mem(struct iter_forwards* fwd); int fwd_cmp(const void* k1, const void* k2); /** - * Add zone to forward structure. For external use since it recalcs + * Add zone to forward structure. For external use since it recalcs * the tree parents. * @param fwd: the forward data structure * @param c: class of zone @@ -164,11 +164,11 @@ int fwd_cmp(const void* k1, const void* k2); * forward zone. malloced. * @return false on failure (out of memory); */ -int forwards_add_zone(struct iter_forwards* fwd, uint16_t c, +int forwards_add_zone(struct iter_forwards* fwd, uint16_t c, struct delegpt* dp); /** - * Remove zone from forward structure. For external use since it + * Remove zone from forward structure. For external use since it * recalcs the tree parents. * @param fwd: the forward data structure * @param c: class of zone diff --git a/sbin/unwind/libunbound/iterator/iter_hints.c b/sbin/unwind/libunbound/iterator/iter_hints.c index a60d9a6b1..573c9b55b 100644 --- a/sbin/unwind/libunbound/iterator/iter_hints.c +++ b/sbin/unwind/libunbound/iterator/iter_hints.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -50,7 +50,7 @@ #include "sldns/str2wire.h" #include "sldns/wire2str.h" -struct iter_hints* +struct iter_hints* hints_create(void) { struct iter_hints* hints = (struct iter_hints*)calloc(1, @@ -78,10 +78,10 @@ static void hints_del_tree(struct iter_hints* hints) traverse_postorder(&hints->tree, &delhintnode, NULL); } -void +void hints_delete(struct iter_hints* hints) { - if(!hints) + if(!hints) return; hints_del_tree(hints); free(hints); @@ -111,7 +111,7 @@ ah(struct delegpt* dp, const char* sv, const char* ip) } /** obtain compiletime provided root hints */ -static struct delegpt* +static struct delegpt* compile_time_root_prime(int do_ip4, int do_ip6) { /* from: @@ -188,7 +188,7 @@ hints_insert(struct iter_hints* hints, uint16_t c, struct delegpt* dp, } /** set stub name */ -static struct delegpt* +static struct delegpt* read_stubs_name(struct config_stub* s) { struct delegpt* dp; @@ -224,7 +224,7 @@ read_stubs_host(struct config_stub* s, struct delegpt* dp) log_assert(p->str); dname = authextstrtodname(p->str, &port, &tls_auth_name); if(!dname) { - log_err("cannot parse stub %s nameserver name: '%s'", + log_err("cannot parse stub %s nameserver name: '%s'", s->name, p->str); return 0; } @@ -244,7 +244,7 @@ read_stubs_host(struct config_stub* s, struct delegpt* dp) } /** set stub server addresses */ -static int +static int read_stubs_addr(struct config_stub* s, struct delegpt* dp) { struct config_strlist* p; @@ -254,7 +254,7 @@ read_stubs_addr(struct config_stub* s, struct delegpt* dp) for(p = s->addrs; p; p = p->next) { log_assert(p->str); if(!authextstrtoaddr(p->str, &addr, &addrlen, &auth_name)) { - log_err("cannot parse stub %s ip address: '%s'", + log_err("cannot parse stub %s ip address: '%s'", s->name, p->str); return 0; } @@ -273,7 +273,7 @@ read_stubs_addr(struct config_stub* s, struct delegpt* dp) } /** read stubs config */ -static int +static int read_stubs(struct iter_hints* hints, struct config_file* cfg) { struct config_stub* s; @@ -303,7 +303,7 @@ read_stubs(struct iter_hints* hints, struct config_file* cfg) } /** read root hints from file */ -static int +static int read_root_hints(struct iter_hints* hints, char* fname) { struct sldns_file_parse_state pstate; @@ -363,11 +363,11 @@ read_root_hints(struct iter_hints* hints, char* fname) memset(&sa, 0, len); sa.sin_family = AF_INET; sa.sin_port = (in_port_t)htons(UNBOUND_DNS_PORT); - memmove(&sa.sin_addr, + memmove(&sa.sin_addr, sldns_wirerr_get_rdata(rr, rr_len, dname_len), INET_SIZE); if(!delegpt_add_target_mlc(dp, rr, dname_len, - (struct sockaddr_storage*)&sa, len, + (struct sockaddr_storage*)&sa, len, 0, 0)) { log_err("out of memory reading root hints"); goto stop_read; @@ -380,7 +380,7 @@ read_root_hints(struct iter_hints* hints, char* fname) memset(&sa, 0, len); sa.sin6_family = AF_INET6; sa.sin6_port = (in_port_t)htons(UNBOUND_DNS_PORT); - memmove(&sa.sin6_addr, + memmove(&sa.sin6_addr, sldns_wirerr_get_rdata(rr, rr_len, dname_len), INET6_SIZE); if(!delegpt_add_target_mlc(dp, rr, dname_len, @@ -416,7 +416,7 @@ stop_read: } /** read root hints list */ -static int +static int read_root_hints_list(struct iter_hints* hints, struct config_file* cfg) { struct config_strlist* p; @@ -425,7 +425,7 @@ read_root_hints_list(struct iter_hints* hints, struct config_file* cfg) if(p->str && p->str[0]) { char* f = p->str; if(cfg->chrootdir && cfg->chrootdir[0] && - strncmp(p->str, cfg->chrootdir, + strncmp(p->str, cfg->chrootdir, strlen(cfg->chrootdir)) == 0) f += strlen(cfg->chrootdir); if(!read_root_hints(hints, f)) @@ -435,12 +435,12 @@ read_root_hints_list(struct iter_hints* hints, struct config_file* cfg) return 1; } -int +int hints_apply_cfg(struct iter_hints* hints, struct config_file* cfg) { hints_del_tree(hints); name_tree_init(&hints->tree); - + /* read root hints */ if(!read_root_hints_list(hints, cfg)) return 0; @@ -454,7 +454,7 @@ hints_apply_cfg(struct iter_hints* hints, struct config_file* cfg) struct delegpt* dp = compile_time_root_prime(cfg->do_ip4, cfg->do_ip6); verbose(VERB_ALGO, "no config, using builtin root hints."); - if(!dp) + if(!dp) return 0; if(!hints_insert(hints, LDNS_RR_CLASS_IN, dp, 0)) return 0; @@ -464,7 +464,7 @@ hints_apply_cfg(struct iter_hints* hints, struct config_file* cfg) return 1; } -struct delegpt* +struct delegpt* hints_lookup_root(struct iter_hints* hints, uint16_t qclass) { uint8_t rootlab = 0; @@ -476,8 +476,8 @@ hints_lookup_root(struct iter_hints* hints, uint16_t qclass) return stub->dp; } -struct iter_hints_stub* -hints_lookup_stub(struct iter_hints* hints, uint8_t* qname, +struct iter_hints_stub* +hints_lookup_stub(struct iter_hints* hints, uint8_t* qname, uint16_t qclass, struct delegpt* cache_dp) { size_t len; @@ -503,8 +503,8 @@ hints_lookup_stub(struct iter_hints* hints, uint8_t* qname, */ if(r->noprime && query_dname_compare(cache_dp->name, r->dp->name)==0) return r; /* use this stub instead of cached dp */ - - /* + + /* * If our cached delegation point is above the hint, we need to prime. */ if(dname_strict_subdomain(r->dp->name, r->dp->namelabs, @@ -518,7 +518,7 @@ int hints_next_root(struct iter_hints* hints, uint16_t* qclass) return name_tree_next_root(&hints->tree, qclass); } -size_t +size_t hints_get_mem(struct iter_hints* hints) { size_t s; @@ -531,7 +531,7 @@ hints_get_mem(struct iter_hints* hints) return s; } -int +int hints_add_stub(struct iter_hints* hints, uint16_t c, struct delegpt* dp, int noprime) { @@ -547,7 +547,7 @@ hints_add_stub(struct iter_hints* hints, uint16_t c, struct delegpt* dp, return 1; } -void +void hints_delete_stub(struct iter_hints* hints, uint16_t c, uint8_t* nm) { struct iter_hints_stub *z; diff --git a/sbin/unwind/libunbound/iterator/iter_hints.h b/sbin/unwind/libunbound/iterator/iter_hints.h index 06b4b9667..b0b6378b1 100644 --- a/sbin/unwind/libunbound/iterator/iter_hints.h +++ b/sbin/unwind/libunbound/iterator/iter_hints.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -51,7 +51,7 @@ struct delegpt; * Iterator hints structure */ struct iter_hints { - /** + /** * Hints are stored in this tree. Sort order is specially chosen. * first sorted on qclass. Then on dname in nsec-like order, so that * a lookup on class, name will return an exact match or the closest @@ -75,7 +75,7 @@ struct iter_hints_stub { }; /** - * Create hints + * Create hints * @return new hints or NULL on error. */ struct iter_hints* hints_create(void); @@ -126,7 +126,7 @@ int hints_next_root(struct iter_hints* hints, uint16_t* qclass); * @return: A priming delegation point if there is a stub hint that must * be primed, otherwise null. */ -struct iter_hints_stub* hints_lookup_stub(struct iter_hints* hints, +struct iter_hints_stub* hints_lookup_stub(struct iter_hints* hints, uint8_t* qname, uint16_t qclass, struct delegpt* dp); /** @@ -137,7 +137,7 @@ struct iter_hints_stub* hints_lookup_stub(struct iter_hints* hints, size_t hints_get_mem(struct iter_hints* hints); /** - * Add stub to hints structure. For external use since it recalcs + * Add stub to hints structure. For external use since it recalcs * the tree parents. * @param hints: the hints data structure * @param c: class of zone @@ -150,7 +150,7 @@ int hints_add_stub(struct iter_hints* hints, uint16_t c, struct delegpt* dp, int noprime); /** - * Remove stub from hints structure. For external use since it + * Remove stub from hints structure. For external use since it * recalcs the tree parents. * @param hints: the hints data structure * @param c: class of stub zone diff --git a/sbin/unwind/libunbound/iterator/iter_priv.c b/sbin/unwind/libunbound/iterator/iter_priv.c index 90bea1746..038bc5d87 100644 --- a/sbin/unwind/libunbound/iterator/iter_priv.c +++ b/sbin/unwind/libunbound/iterator/iter_priv.c @@ -4,22 +4,22 @@ * Copyright (c) 2008, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -86,7 +86,7 @@ static int read_addrs(struct iter_priv* priv, struct config_file* cfg) for(p = cfg->private_address; p; p = p->next) { log_assert(p->str); - if(!netblockstrtoaddr(p->str, UNBOUND_DNS_PORT, &addr, + if(!netblockstrtoaddr(p->str, UNBOUND_DNS_PORT, &addr, &addrlen, &net)) { log_err("cannot parse private-address: %s", p->str); return 0; @@ -170,7 +170,7 @@ int priv_apply_cfg(struct iter_priv* priv, struct config_file* cfg) * @param addrlen: length of addr. * @return: true if the address must not be queried. false if unlisted. */ -static int +static int priv_lookup_addr(struct iter_priv* priv, struct sockaddr_storage* addr, socklen_t addrlen) { @@ -186,7 +186,7 @@ priv_lookup_addr(struct iter_priv* priv, struct sockaddr_storage* addr, * @param dclass: class to check. * @return: true if the name is OK. false if unlisted. */ -static int +static int priv_lookup_name(struct iter_priv* priv, sldns_buffer* pkt, uint8_t* name, size_t name_len, uint16_t dclass) { @@ -232,7 +232,7 @@ remove_rr(const char* str, sldns_buffer* pkt, struct rrset_parse* rrset, int priv_rrset_bad(struct iter_priv* priv, sldns_buffer* pkt, struct rrset_parse* rrset) { - if(priv->a.count == 0) + if(priv->a.count == 0) return 0; /* there are no blocked addresses */ /* see if it is a private name, that is allowed to have any */ @@ -252,12 +252,12 @@ int priv_rrset_bad(struct iter_priv* priv, sldns_buffer* pkt, sa.sin_family = AF_INET; sa.sin_port = (in_port_t)htons(UNBOUND_DNS_PORT); for(rr = rrset->rr_first; rr; rr = rr->next) { - if(sldns_read_uint16(rr->ttl_data+4) + if(sldns_read_uint16(rr->ttl_data+4) != INET_SIZE) { prev = rr; continue; } - memmove(&sa.sin_addr, rr->ttl_data+4+2, + memmove(&sa.sin_addr, rr->ttl_data+4+2, INET_SIZE); memmove(&addr, &sa, len); if(priv_lookup_addr(priv, &addr, len)) { @@ -275,12 +275,12 @@ int priv_rrset_bad(struct iter_priv* priv, sldns_buffer* pkt, sa.sin6_family = AF_INET6; sa.sin6_port = (in_port_t)htons(UNBOUND_DNS_PORT); for(rr = rrset->rr_first; rr; rr = rr->next) { - if(sldns_read_uint16(rr->ttl_data+4) + if(sldns_read_uint16(rr->ttl_data+4) != INET6_SIZE) { prev = rr; continue; } - memmove(&sa.sin6_addr, rr->ttl_data+4+2, + memmove(&sa.sin6_addr, rr->ttl_data+4+2, INET6_SIZE); memmove(&addr, &sa, len); if(priv_lookup_addr(priv, &addr, len)) { @@ -290,7 +290,7 @@ int priv_rrset_bad(struct iter_priv* priv, sldns_buffer* pkt, } prev = rr; } - } + } } return 0; } diff --git a/sbin/unwind/libunbound/iterator/iter_priv.h b/sbin/unwind/libunbound/iterator/iter_priv.h index 0430d57e3..523f0f6fe 100644 --- a/sbin/unwind/libunbound/iterator/iter_priv.h +++ b/sbin/unwind/libunbound/iterator/iter_priv.h @@ -4,22 +4,22 @@ * Copyright (c) 2008, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -55,13 +55,13 @@ struct rrset_parse; struct iter_priv { /** regional for allocation */ struct regional* region; - /** + /** * Tree of the address spans that are blocked. * contents of type addr_tree_node. * No further data need, only presence or absence. */ rbtree_type a; - /** + /** * Tree of the domains spans that are allowed to contain * the blocked address spans. * contents of type name_tree_node. @@ -71,7 +71,7 @@ struct iter_priv { }; /** - * Create priv structure + * Create priv structure * @return new structure or NULL on error. */ struct iter_priv* priv_create(void); @@ -99,7 +99,7 @@ int priv_apply_cfg(struct iter_priv* priv, struct config_file* cfg); * @param rrset: the rrset to examine, A or AAAA. * @return true if the rrset is bad and should be removed. */ -int priv_rrset_bad(struct iter_priv* priv, struct sldns_buffer* pkt, +int priv_rrset_bad(struct iter_priv* priv, struct sldns_buffer* pkt, struct rrset_parse* rrset); /** diff --git a/sbin/unwind/libunbound/iterator/iter_resptype.c b/sbin/unwind/libunbound/iterator/iter_resptype.c index e85595b84..e284987e0 100644 --- a/sbin/unwind/libunbound/iterator/iter_resptype.c +++ b/sbin/unwind/libunbound/iterator/iter_resptype.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -48,8 +48,8 @@ #include "sldns/rrdef.h" #include "sldns/pkthdr.h" -enum response_type -response_type_from_cache(struct dns_msg* msg, +enum response_type +response_type_from_cache(struct dns_msg* msg, struct query_info* request) { /* If the message is NXDOMAIN, then it is an ANSWER. */ @@ -57,11 +57,11 @@ response_type_from_cache(struct dns_msg* msg, return RESPONSE_TYPE_ANSWER; if(request->qtype == LDNS_RR_TYPE_ANY) return RESPONSE_TYPE_ANSWER; - + /* First we look at the answer section. This can tell us if this is * CNAME or positive ANSWER. */ if(msg->rep->an_numrrsets > 0) { - /* Now look at the answer section first. 3 states: + /* Now look at the answer section first. 3 states: * o our answer is there directly, * o our answer is there after a cname, * o or there is just a cname. */ @@ -71,10 +71,10 @@ response_type_from_cache(struct dns_msg* msg, for(i=0; irep->an_numrrsets; i++) { struct ub_packed_rrset_key* s = msg->rep->rrsets[i]; - /* If we have encountered an answer (before or - * after a CNAME), then we are done! Note that - * if qtype == CNAME then this will be noted as - * an ANSWER before it gets treated as a CNAME, + /* If we have encountered an answer (before or + * after a CNAME), then we are done! Note that + * if qtype == CNAME then this will be noted as + * an ANSWER before it gets treated as a CNAME, * as it should */ if(ntohs(s->rk.type) == request->qtype && ntohs(s->rk.rrset_class) == request->qclass && @@ -82,7 +82,7 @@ response_type_from_cache(struct dns_msg* msg, return RESPONSE_TYPE_ANSWER; } - /* If we have encountered a CNAME, make sure that + /* If we have encountered a CNAME, make sure that * it is relevant. */ if(ntohs(s->rk.type) == LDNS_RR_TYPE_CNAME && query_dname_compare(mname, s->rk.dname) == 0) { @@ -90,20 +90,20 @@ response_type_from_cache(struct dns_msg* msg, } } - /* if we encountered a CNAME (or a bunch of CNAMEs), and - * still got to here, then it is a CNAME response. (i.e., + /* if we encountered a CNAME (or a bunch of CNAMEs), and + * still got to here, then it is a CNAME response. (i.e., * the CNAME chain didn't terminate in an answer rrset.) */ if(mname != request->qname) { return RESPONSE_TYPE_CNAME; } } - /* At this point, since we don't need to detect REFERRAL or LAME + /* At this point, since we don't need to detect REFERRAL or LAME * messages, it can only be an ANSWER. */ return RESPONSE_TYPE_ANSWER; } -enum response_type +enum response_type response_type_from_server(int rdset, struct dns_msg* msg, struct query_info* request, struct delegpt* dp) { @@ -135,7 +135,7 @@ response_type_from_server(int rdset, } return RESPONSE_TYPE_ANSWER; } - + /* Other response codes mean (so far) to throw the response away as * meaningless and move on to the next nameserver. */ if(FLAGS_GET_RCODE(msg->rep->flags) != LDNS_RCODE_NOERROR) @@ -153,44 +153,44 @@ response_type_from_server(int rdset, uint8_t* mname = request->qname; size_t mname_len = request->qname_len; - /* Now look at the answer section first. 3 states: our - * answer is there directly, our answer is there after + /* Now look at the answer section first. 3 states: our + * answer is there directly, our answer is there after * a cname, or there is just a cname. */ for(i=0; irep->an_numrrsets; i++) { s = msg->rep->rrsets[i]; - - /* if the answer section has NS rrset, and qtype ANY + + /* if the answer section has NS rrset, and qtype ANY * and the delegation is lower, and no CNAMEs followed, * this is a referral where the NS went to AN section */ if((request->qtype == LDNS_RR_TYPE_ANY || request->qtype == LDNS_RR_TYPE_NS) && ntohs(s->rk.type) == LDNS_RR_TYPE_NS && ntohs(s->rk.rrset_class) == request->qclass && - dname_strict_subdomain_c(s->rk.dname, + dname_strict_subdomain_c(s->rk.dname, origzone)) { if((msg->rep->flags&BIT_AA)) return RESPONSE_TYPE_ANSWER; return RESPONSE_TYPE_REFERRAL; } - /* If we have encountered an answer (before or - * after a CNAME), then we are done! Note that + /* If we have encountered an answer (before or + * after a CNAME), then we are done! Note that * if qtype == CNAME then this will be noted as an - * ANSWER before it gets treated as a CNAME, as + * ANSWER before it gets treated as a CNAME, as * it should. */ if(ntohs(s->rk.type) == request->qtype && ntohs(s->rk.rrset_class) == request->qclass && query_dname_compare(mname, s->rk.dname) == 0) { if((msg->rep->flags&BIT_AA)) return RESPONSE_TYPE_ANSWER; - /* If the AA bit isn't on, and we've seen - * the answer, we only provisionally say - * 'ANSWER' -- it very well could be a + /* If the AA bit isn't on, and we've seen + * the answer, we only provisionally say + * 'ANSWER' -- it very well could be a * REFERRAL. */ break; } - /* If we have encountered a CNAME, make sure that + /* If we have encountered a CNAME, make sure that * it is relevant. */ if(ntohs(s->rk.type) == LDNS_RR_TYPE_CNAME && query_dname_compare(mname, s->rk.dname) == 0) { @@ -200,15 +200,15 @@ response_type_from_server(int rdset, /* not a referral, and qtype any, thus an answer */ if(request->qtype == LDNS_RR_TYPE_ANY) return RESPONSE_TYPE_ANSWER; - /* if we encountered a CNAME (or a bunch of CNAMEs), and - * still got to here, then it is a CNAME response. + /* if we encountered a CNAME (or a bunch of CNAMEs), and + * still got to here, then it is a CNAME response. * (This is regardless of the AA bit at this point) */ if(mname != request->qname) { return RESPONSE_TYPE_CNAME; } } - /* Looking at the authority section, we just look and see if + /* Looking at the authority section, we just look and see if * there is a SOA record, that means a NOERROR/NODATA */ for(i = msg->rep->an_numrrsets; i < (msg->rep->an_numrrsets + msg->rep->ns_numrrsets); i++) { @@ -224,18 +224,18 @@ response_type_from_server(int rdset, return RESPONSE_TYPE_ANSWER; } } - /* Looking at the authority section, we just look and see if - * there is a delegation NS set, turning it into a delegation. - * Otherwise, we will have to conclude ANSWER (either it is + /* Looking at the authority section, we just look and see if + * there is a delegation NS set, turning it into a delegation. + * Otherwise, we will have to conclude ANSWER (either it is * NOERROR/NODATA, or an non-authoritative answer). */ for(i = msg->rep->an_numrrsets; i < (msg->rep->an_numrrsets + msg->rep->ns_numrrsets); i++) { s = msg->rep->rrsets[i]; - /* Detect REFERRAL/LAME/ANSWER based on the relationship + /* Detect REFERRAL/LAME/ANSWER based on the relationship * of the NS set to the originating zone name. */ if(ntohs(s->rk.type) == LDNS_RR_TYPE_NS) { - /* If we are getting an NS set for the zone we + /* If we are getting an NS set for the zone we * thought we were contacting, then it is an answer.*/ if(query_dname_compare(s->rk.dname, origzone) == 0) { /* see if mistakenly a recursive server was @@ -244,7 +244,7 @@ response_type_from_server(int rdset, !(msg->rep->flags&BIT_AA) && !rdset) return RESPONSE_TYPE_REC_LAME; /* Or if a lame server is deployed, - * which gives ns==zone delegation from cache + * which gives ns==zone delegation from cache * without AA bit as well, with nodata nosoa*/ /* real answer must be +AA and SOA RFC(2308), * so this is wrong, and we SERVFAIL it if @@ -256,24 +256,24 @@ response_type_from_server(int rdset, return RESPONSE_TYPE_THROWAWAY; return RESPONSE_TYPE_ANSWER; } - /* If we are getting a referral upwards (or to + /* If we are getting a referral upwards (or to * the same zone), then the server is 'lame'. */ if(dname_subdomain_c(origzone, s->rk.dname)) { if(rdset) /* forward or reclame not LAME */ return RESPONSE_TYPE_THROWAWAY; return RESPONSE_TYPE_LAME; } - /* If the NS set is below the delegation point we - * are on, and it is non-authoritative, then it is + /* If the NS set is below the delegation point we + * are on, and it is non-authoritative, then it is * a referral, otherwise it is an answer. */ if(dname_subdomain_c(s->rk.dname, origzone)) { - /* NOTE: I no longer remember in what case - * we would like this to be an answer. - * NODATA should have a SOA or nothing, - * not an NS rrset. - * True, referrals should not have the AA + /* NOTE: I no longer remember in what case + * we would like this to be an answer. + * NODATA should have a SOA or nothing, + * not an NS rrset. + * True, referrals should not have the AA * bit set, but... */ - + /* if((msg->rep->flags&BIT_AA)) return RESPONSE_TYPE_ANSWER; */ return RESPONSE_TYPE_REFERRAL; @@ -282,7 +282,7 @@ response_type_from_server(int rdset, } } - /* If we've gotten this far, this is NOERROR/NODATA (which could + /* If we've gotten this far, this is NOERROR/NODATA (which could * be an entirely empty message) */ /* but ignore entirely empty messages, noerror/nodata has a soa * negative ttl value in the authority section, this makes it try diff --git a/sbin/unwind/libunbound/iterator/iter_resptype.h b/sbin/unwind/libunbound/iterator/iter_resptype.h index fee9ef35f..d253c0195 100644 --- a/sbin/unwind/libunbound/iterator/iter_resptype.h +++ b/sbin/unwind/libunbound/iterator/iter_resptype.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -50,15 +50,15 @@ struct delegpt; * The response type is used to interpret the response. */ enum response_type { - /** - * 'untyped' means that the type of this response hasn't been - * assigned. + /** + * 'untyped' means that the type of this response hasn't been + * assigned. */ RESPONSE_TYPE_UNTYPED = 0, - /** - * 'answer' means that the response terminates the resolution - * process. + /** + * 'answer' means that the response terminates the resolution + * process. */ RESPONSE_TYPE_ANSWER, @@ -66,19 +66,19 @@ enum response_type { RESPONSE_TYPE_REFERRAL, /** - * 'cname' means that the response is a cname without the final + * 'cname' means that the response is a cname without the final * answer, and thus must be restarted. */ RESPONSE_TYPE_CNAME, /** - * 'throwaway' means that this particular response should be + * 'throwaway' means that this particular response should be * discarded and the next nameserver should be contacted */ RESPONSE_TYPE_THROWAWAY, /** - * 'lame' means that this particular response indicates that + * 'lame' means that this particular response indicates that * the nameserver knew nothing about the question. */ RESPONSE_TYPE_LAME, @@ -102,7 +102,7 @@ enum response_type { * @param request: the request that generated the response. * @return the response type (CNAME or ANSWER). */ -enum response_type response_type_from_cache(struct dns_msg* msg, +enum response_type response_type_from_cache(struct dns_msg* msg, struct query_info* request); /** @@ -121,7 +121,7 @@ enum response_type response_type_from_cache(struct dns_msg* msg, * when the response was returned. * @return the response type (CNAME or ANSWER). */ -enum response_type response_type_from_server(int rdset, +enum response_type response_type_from_server(int rdset, struct dns_msg* msg, struct query_info* request, struct delegpt* dp); #endif /* ITERATOR_ITER_RESPTYPE_H */ diff --git a/sbin/unwind/libunbound/iterator/iter_scrub.c b/sbin/unwind/libunbound/iterator/iter_scrub.c index d1fedcd0f..8d8aa8a4f 100644 --- a/sbin/unwind/libunbound/iterator/iter_scrub.c +++ b/sbin/unwind/libunbound/iterator/iter_scrub.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -36,7 +36,7 @@ /** * \file * - * This file has routine(s) for cleaning up incoming DNS messages from + * This file has routine(s) for cleaning up incoming DNS messages from * possible useless or malicious junk in it. */ #include "config.h" @@ -60,14 +60,14 @@ /** remove rrset, update loop variables */ static void -remove_rrset(const char* str, sldns_buffer* pkt, struct msg_parse* msg, +remove_rrset(const char* str, sldns_buffer* pkt, struct msg_parse* msg, struct rrset_parse* prev, struct rrset_parse** rrset) { if(verbosity >= VERB_QUERY && str && (*rrset)->dname_len <= LDNS_MAX_DOMAINLEN) { uint8_t buf[LDNS_MAX_DOMAINLEN+1]; dname_pkt_copy(pkt, buf, (*rrset)->dname); - log_nametypeclass(VERB_QUERY, str, buf, + log_nametypeclass(VERB_QUERY, str, buf, (*rrset)->type, ntohs((*rrset)->rrset_class)); } if(prev) @@ -108,8 +108,8 @@ has_additional(uint16_t t) /** get additional name from rrset RR, return false if no name present */ static int -get_additional_name(struct rrset_parse* rrset, struct rr_parse* rr, - uint8_t** nm, size_t* nmlen, sldns_buffer* pkt) +get_additional_name(struct rrset_parse* rrset, struct rr_parse* rr, + uint8_t** nm, size_t* nmlen, sldns_buffer* pkt) { size_t offset = 0; size_t len, oldpos; @@ -148,7 +148,7 @@ get_additional_name(struct rrset_parse* rrset, struct rr_parse* rr, /** Place mark on rrsets in additional section they are OK */ static void -mark_additional_rrset(sldns_buffer* pkt, struct msg_parse* msg, +mark_additional_rrset(sldns_buffer* pkt, struct msg_parse* msg, struct rrset_parse* rrset) { /* Mark A and AAAA for NS as appropriate additional section info. */ @@ -164,16 +164,16 @@ mark_additional_rrset(sldns_buffer* pkt, struct msg_parse* msg, hashvalue_type h = pkt_hash_rrset(pkt, nm, LDNS_RR_TYPE_A, rrset->rrset_class, 0); struct rrset_parse* r = msgparse_hashtable_lookup( - msg, pkt, h, 0, nm, nmlen, + msg, pkt, h, 0, nm, nmlen, LDNS_RR_TYPE_A, rrset->rrset_class); if(r && r->section == LDNS_SECTION_ADDITIONAL) { r->flags |= RRSET_SCRUB_OK; } - + /* mark AAAA */ - h = pkt_hash_rrset(pkt, nm, LDNS_RR_TYPE_AAAA, + h = pkt_hash_rrset(pkt, nm, LDNS_RR_TYPE_AAAA, rrset->rrset_class, 0); - r = msgparse_hashtable_lookup(msg, pkt, h, 0, nm, + r = msgparse_hashtable_lookup(msg, pkt, h, 0, nm, nmlen, LDNS_RR_TYPE_AAAA, rrset->rrset_class); if(r && r->section == LDNS_SECTION_ADDITIONAL) { r->flags |= RRSET_SCRUB_OK; @@ -184,7 +184,7 @@ mark_additional_rrset(sldns_buffer* pkt, struct msg_parse* msg, /** Get target name of a CNAME */ static int -parse_get_cname_target(struct rrset_parse* rrset, uint8_t** sname, +parse_get_cname_target(struct rrset_parse* rrset, uint8_t** sname, size_t* snamelen, sldns_buffer* pkt) { size_t oldpos, dlen; @@ -222,15 +222,15 @@ parse_get_cname_target(struct rrset_parse* rrset, uint8_t** sname, } /** Synthesize CNAME from DNAME, false if too long */ -static int -synth_cname(uint8_t* qname, size_t qnamelen, struct rrset_parse* dname_rrset, +static int +synth_cname(uint8_t* qname, size_t qnamelen, struct rrset_parse* dname_rrset, uint8_t* alias, size_t* aliaslen, sldns_buffer* pkt) { /* we already know that sname is a strict subdomain of DNAME owner */ uint8_t* dtarg = NULL; size_t dtarglen; if(!parse_get_cname_target(dname_rrset, &dtarg, &dtarglen, pkt)) - return 0; + return 0; if(qnamelen <= dname_rrset->dname_len) return 0; if(qnamelen == 0) @@ -249,8 +249,8 @@ synth_cname(uint8_t* qname, size_t qnamelen, struct rrset_parse* dname_rrset, /** synthesize a CNAME rrset */ static struct rrset_parse* -synth_cname_rrset(uint8_t** sname, size_t* snamelen, uint8_t* alias, - size_t aliaslen, struct regional* region, struct msg_parse* msg, +synth_cname_rrset(uint8_t** sname, size_t* snamelen, uint8_t* alias, + size_t aliaslen, struct regional* region, struct msg_parse* msg, struct rrset_parse* rrset, struct rrset_parse* prev, struct rrset_parse* nx, sldns_buffer* pkt) { @@ -259,7 +259,7 @@ synth_cname_rrset(uint8_t** sname, size_t* snamelen, uint8_t* alias, if(!cn) return NULL; memset(cn, 0, sizeof(*cn)); - cn->rr_first = (struct rr_parse*)regional_alloc(region, + cn->rr_first = (struct rr_parse*)regional_alloc(region, sizeof(struct rr_parse)); if(!cn->rr_first) return NULL; @@ -279,7 +279,7 @@ synth_cname_rrset(uint8_t** sname, size_t* snamelen, uint8_t* alias, /* allocate TTL + rdatalen + uncompressed dname */ memset(cn->rr_first, 0, sizeof(struct rr_parse)); cn->rr_first->outside_packet = 1; - cn->rr_first->ttl_data = (uint8_t*)regional_alloc(region, + cn->rr_first->ttl_data = (uint8_t*)regional_alloc(region, sizeof(uint32_t)+sizeof(uint16_t)+aliaslen); if(!cn->rr_first->ttl_data) return NULL; @@ -341,7 +341,7 @@ soa_in_auth(struct msg_parse* msg) struct rrset_parse* rrset; for(rrset = msg->rrset_first; rrset; rrset = rrset->rrset_all_next) if(rrset->type == LDNS_RR_TYPE_SOA && - rrset->section == LDNS_SECTION_AUTHORITY) + rrset->section == LDNS_SECTION_AUTHORITY) return 1; return 0; } @@ -379,7 +379,7 @@ type_allowed_in_additional_section(uint16_t tp) * @return 0 on error. */ static int -scrub_normalize(sldns_buffer* pkt, struct msg_parse* msg, +scrub_normalize(sldns_buffer* pkt, struct msg_parse* msg, struct query_info* qinfo, struct regional* region, struct module_env* env) { @@ -400,7 +400,7 @@ scrub_normalize(sldns_buffer* pkt, struct msg_parse* msg, prev = NULL; rrset = msg->rrset_first; while(rrset && rrset->section == LDNS_SECTION_ANSWER) { - if(rrset->type == LDNS_RR_TYPE_DNAME && + if(rrset->type == LDNS_RR_TYPE_DNAME && pkt_strict_sub(pkt, sname, rrset->dname)) { /* check if next rrset is correct CNAME. else, * synthesize a CNAME */ @@ -409,17 +409,17 @@ scrub_normalize(sldns_buffer* pkt, struct msg_parse* msg, size_t aliaslen = 0; if(rrset->rr_count != 1) { verbose(VERB_ALGO, "Found DNAME rrset with " - "size > 1: %u", + "size > 1: %u", (unsigned)rrset->rr_count); return 0; } - if(!synth_cname(sname, snamelen, rrset, alias, + if(!synth_cname(sname, snamelen, rrset, alias, &aliaslen, pkt)) { verbose(VERB_ALGO, "synthesized CNAME " "too long"); return 0; } - if(nx && nx->type == LDNS_RR_TYPE_CNAME && + if(nx && nx->type == LDNS_RR_TYPE_CNAME && dname_pkt_compare(pkt, sname, nx->dname) == 0) { /* check next cname */ uint8_t* t = NULL; @@ -435,13 +435,13 @@ scrub_normalize(sldns_buffer* pkt, struct msg_parse* msg, /* synth ourselves */ } /* synth a CNAME rrset */ - prev = synth_cname_rrset(&sname, &snamelen, alias, + prev = synth_cname_rrset(&sname, &snamelen, alias, aliaslen, region, msg, rrset, rrset, nx, pkt); if(!prev) { log_err("out of memory synthesizing CNAME"); return 0; } - /* FIXME: resolve the conflict between synthesized + /* FIXME: resolve the conflict between synthesized * CNAME ttls and the cache. */ rrset = nx; continue; @@ -450,7 +450,7 @@ scrub_normalize(sldns_buffer* pkt, struct msg_parse* msg, /* The only records in the ANSWER section not allowed to */ if(dname_pkt_compare(pkt, sname, rrset->dname) != 0) { - remove_rrset("normalize: removing irrelevant RRset:", + remove_rrset("normalize: removing irrelevant RRset:", pkt, msg, prev, &rrset); continue; } @@ -464,7 +464,7 @@ scrub_normalize(sldns_buffer* pkt, struct msg_parse* msg, nx->type == LDNS_RR_TYPE_DNAME && nx->rr_count == 1 && pkt_strict_sub(pkt, sname, nx->dname)) { - /* there is a DNAME after this CNAME, it + /* there is a DNAME after this CNAME, it * is in the ANSWER section, and the DNAME * applies to the name we cover */ /* check if the alias of the DNAME equals @@ -514,9 +514,9 @@ scrub_normalize(sldns_buffer* pkt, struct msg_parse* msg, } /* Otherwise, make sure that the RRset matches the qtype. */ - if(qinfo->qtype != LDNS_RR_TYPE_ANY && + if(qinfo->qtype != LDNS_RR_TYPE_ANY && qinfo->qtype != rrset->type) { - remove_rrset("normalize: removing irrelevant RRset:", + remove_rrset("normalize: removing irrelevant RRset:", pkt, msg, prev, &rrset); continue; } @@ -526,7 +526,7 @@ scrub_normalize(sldns_buffer* pkt, struct msg_parse* msg, * will be removed by sanitize, so no additional for them */ if(dname_pkt_compare(pkt, qinfo->qname, rrset->dname) == 0) mark_additional_rrset(pkt, msg, rrset); - + prev = rrset; rrset = rrset->rrset_all_next; } @@ -602,12 +602,12 @@ scrub_normalize(sldns_buffer* pkt, struct msg_parse* msg, } /* For each record in the additional section, remove it if it is an - * address record and not in the collection of additional names + * address record and not in the collection of additional names * found in ANSWER and AUTHORITY. */ /* These records have not been marked OK previously */ while(rrset && rrset->section == LDNS_SECTION_ADDITIONAL) { - if(rrset->type==LDNS_RR_TYPE_A || - rrset->type==LDNS_RR_TYPE_AAAA) + if(rrset->type==LDNS_RR_TYPE_A || + rrset->type==LDNS_RR_TYPE_AAAA) { if((rrset->flags & RRSET_SCRUB_OK)) { /* remove flag to clean up flags variable */ @@ -619,7 +619,7 @@ scrub_normalize(sldns_buffer* pkt, struct msg_parse* msg, } } /* protect internals of recursor by making sure to del these */ - if(rrset->type==LDNS_RR_TYPE_DNAME || + if(rrset->type==LDNS_RR_TYPE_DNAME || rrset->type==LDNS_RR_TYPE_CNAME || rrset->type==LDNS_RR_TYPE_NS) { remove_rrset("normalize: removing irrelevant " @@ -636,14 +636,14 @@ scrub_normalize(sldns_buffer* pkt, struct msg_parse* msg, prev = rrset; rrset = rrset->rrset_all_next; } - + return 1; } /** * Store potential poison in the cache (only if hardening disabled). * The rrset is stored in the cache but removed from the message. - * So that it will be used for infrastructure purposes, but not be + * So that it will be used for infrastructure purposes, but not be * returned to the client. * @param pkt: packet * @param msg: message parsed @@ -731,7 +731,7 @@ static int sanitize_nsec_is_overreach(sldns_buffer* pkt, * @return 0 on error. */ static int -scrub_sanitize(sldns_buffer* pkt, struct msg_parse* msg, +scrub_sanitize(sldns_buffer* pkt, struct msg_parse* msg, struct query_info* qinfo, uint8_t* zonename, struct module_env* env, struct iter_env* ie) { @@ -742,17 +742,17 @@ scrub_sanitize(sldns_buffer* pkt, struct msg_parse* msg, rrset = msg->rrset_first; /* the first DNAME is allowed to stay. It needs checking before - * it can be used from the cache. After normalization, an initial + * it can be used from the cache. After normalization, an initial * DNAME will have a correctly synthesized CNAME after it. */ - if(rrset && rrset->type == LDNS_RR_TYPE_DNAME && + if(rrset && rrset->type == LDNS_RR_TYPE_DNAME && rrset->section == LDNS_SECTION_ANSWER && pkt_strict_sub(pkt, qinfo->qname, rrset->dname) && pkt_sub(pkt, rrset->dname, zonename)) { prev = rrset; /* DNAME allowed to stay in answer section */ rrset = rrset->rrset_all_next; } - - /* remove all records from the answer section that are + + /* remove all records from the answer section that are * not the same domain name as the query domain name. * The answer section should contain rrsets with the same name * as the question. For DNAMEs a CNAME has been synthesized. @@ -770,19 +770,19 @@ scrub_sanitize(sldns_buffer* pkt, struct msg_parse* msg, rrset = rrset->rrset_all_next; } - /* At this point, we brutally remove ALL rrsets that aren't - * children of the originating zone. The idea here is that, - * as far as we know, the server that we contacted is ONLY - * authoritative for the originating zone. It, of course, MAY - * be authoritative for any other zones, and of course, MAY - * NOT be authoritative for some subdomains of the originating + /* At this point, we brutally remove ALL rrsets that aren't + * children of the originating zone. The idea here is that, + * as far as we know, the server that we contacted is ONLY + * authoritative for the originating zone. It, of course, MAY + * be authoritative for any other zones, and of course, MAY + * NOT be authoritative for some subdomains of the originating * zone. */ prev = NULL; rrset = msg->rrset_first; while(rrset) { /* remove private addresses */ - if( (rrset->type == LDNS_RR_TYPE_A || + if( (rrset->type == LDNS_RR_TYPE_A || rrset->type == LDNS_RR_TYPE_AAAA)) { /* do not set servfail since this leads to too @@ -794,23 +794,23 @@ scrub_sanitize(sldns_buffer* pkt, struct msg_parse* msg, continue; } } - - /* skip DNAME records -- they will always be followed by a + + /* skip DNAME records -- they will always be followed by a * synthesized CNAME, which will be relevant. - * FIXME: should this do something differently with DNAME + * FIXME: should this do something differently with DNAME * rrsets NOT in Section.ANSWER? */ /* But since DNAME records are also subdomains of the zone, * same check can be used */ if(!pkt_sub(pkt, rrset->dname, zonename)) { - if(msg->an_rrsets == 0 && - rrset->type == LDNS_RR_TYPE_NS && + if(msg->an_rrsets == 0 && + rrset->type == LDNS_RR_TYPE_NS && rrset->section == LDNS_SECTION_AUTHORITY && - FLAGS_GET_RCODE(msg->flags) == + FLAGS_GET_RCODE(msg->flags) == LDNS_RCODE_NOERROR && !soa_in_auth(msg) && sub_of_pkt(pkt, zonename, rrset->dname)) { /* noerror, nodata and this NS rrset is above - * the zone. This is LAME! + * the zone. This is LAME! * Leave in the NS for lame classification. */ /* remove everything from the additional * (we dont want its glue that was approved @@ -820,7 +820,7 @@ scrub_sanitize(sldns_buffer* pkt, struct msg_parse* msg, rrset->type == LDNS_RR_TYPE_A || rrset->type == LDNS_RR_TYPE_AAAA)) { /* store in cache! Since it is relevant - * (from normalize) it will be picked up + * (from normalize) it will be picked up * from the cache to be used later */ store_rrset(pkt, msg, env, rrset); remove_rrset("sanitize: storing potential " @@ -851,22 +851,22 @@ scrub_sanitize(sldns_buffer* pkt, struct msg_parse* msg, return 1; } -int -scrub_message(sldns_buffer* pkt, struct msg_parse* msg, +int +scrub_message(sldns_buffer* pkt, struct msg_parse* msg, struct query_info* qinfo, uint8_t* zonename, struct regional* region, struct module_env* env, struct iter_env* ie) { /* basic sanity checks */ - log_nametypeclass(VERB_ALGO, "scrub for", zonename, LDNS_RR_TYPE_NS, + log_nametypeclass(VERB_ALGO, "scrub for", zonename, LDNS_RR_TYPE_NS, qinfo->qclass); if(msg->qdcount > 1) return 0; if( !(msg->flags&BIT_QR) ) return 0; msg->flags &= ~(BIT_AD|BIT_Z); /* force off bit AD and Z */ - + /* make sure that a query is echoed back when NOERROR or NXDOMAIN */ - /* this is not required for basic operation but is a forgery + /* this is not required for basic operation but is a forgery * resistance (security) feature */ if((FLAGS_GET_RCODE(msg->flags) == LDNS_RCODE_NOERROR || FLAGS_GET_RCODE(msg->flags) == LDNS_RCODE_NXDOMAIN) && diff --git a/sbin/unwind/libunbound/iterator/iter_scrub.h b/sbin/unwind/libunbound/iterator/iter_scrub.h index cbbaf73c9..2756c1a8e 100644 --- a/sbin/unwind/libunbound/iterator/iter_scrub.h +++ b/sbin/unwind/libunbound/iterator/iter_scrub.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -36,7 +36,7 @@ /** * \file * - * This file has routine(s) for cleaning up incoming DNS messages from + * This file has routine(s) for cleaning up incoming DNS messages from * possible useless or malicious junk in it. */ @@ -58,11 +58,11 @@ struct iter_env; * @param zonename: the name of the last delegation point. * Used to determine out of bailiwick information. * @param regional: where to allocate (new) parts of the message. - * @param env: module environment with config settings and cache. + * @param env: module environment with config settings and cache. * @param ie: iterator module environment data. * @return: false if the message is total waste. true if scrubbed with success. */ -int scrub_message(struct sldns_buffer* pkt, struct msg_parse* msg, +int scrub_message(struct sldns_buffer* pkt, struct msg_parse* msg, struct query_info* qinfo, uint8_t* zonename, struct regional* regional, struct module_env* env, struct iter_env* ie); diff --git a/sbin/unwind/libunbound/iterator/iter_utils.h b/sbin/unwind/libunbound/iterator/iter_utils.h index fa860fa68..fa9066ba5 100644 --- a/sbin/unwind/libunbound/iterator/iter_utils.h +++ b/sbin/unwind/libunbound/iterator/iter_utils.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -37,7 +37,7 @@ * \file * * This file contains functions to assist the iterator module. - * Configuration options. Forward zones. + * Configuration options. Forward zones. */ #ifndef ITERATOR_ITER_UTILS_H @@ -84,7 +84,7 @@ int iter_apply_cfg(struct iter_env* iter_env, struct config_file* cfg); * Select a valid, nice target to send query to. * Sorting and removing unsuitable targets is combined. * - * @param iter_env: iterator module global state, with ip6 enabled and + * @param iter_env: iterator module global state, with ip6 enabled and * do-not-query-addresses. * @param env: environment with infra cache (lameness, rtt info). * @param dp: delegation point with result list. @@ -105,8 +105,8 @@ int iter_apply_cfg(struct iter_env* iter_env, struct config_file* cfg); * @return best target or NULL if no target. * if not null, that target is removed from the result list in the dp. */ -struct delegpt_addr* iter_server_selection(struct iter_env* iter_env, - struct module_env* env, struct delegpt* dp, uint8_t* name, +struct delegpt_addr* iter_server_selection(struct iter_env* iter_env, + struct module_env* env, struct delegpt* dp, uint8_t* name, size_t namelen, uint16_t qtype, int* dnssec_lame, int* chase_to_rd, int open_target, struct sock_list* blacklist, time_t prefetch); @@ -118,7 +118,7 @@ struct delegpt_addr* iter_server_selection(struct iter_env* iter_env, * @param regional: regional to use for allocation. * @return newly allocated dns_msg, or NULL on memory error. */ -struct dns_msg* dns_alloc_msg(struct sldns_buffer* pkt, struct msg_parse* msg, +struct dns_msg* dns_alloc_msg(struct sldns_buffer* pkt, struct msg_parse* msg, struct regional* regional); /** @@ -180,7 +180,7 @@ void iter_mark_pside_cycle_targets(struct module_qstate* qstate, struct delegpt* dp); /** - * See if delegation is useful or offers immediately no targets for + * See if delegation is useful or offers immediately no targets for * further recursion. * @param qinfo: query name and type * @param qflags: query flags with RD flag @@ -209,7 +209,7 @@ int iter_qname_indicates_dnssec(struct module_env* env, struct query_info *qinfo); /** - * See if delegation is expected to have DNSSEC information (RRSIGs) in + * See if delegation is expected to have DNSSEC information (RRSIGs) in * its answers, or not. Inspects delegation point (name), trust anchors, * and delegation message (DS RRset) to determine this. * @param env: module env with trust anchors. @@ -223,8 +223,8 @@ int iter_indicates_dnssec(struct module_env* env, struct delegpt* dp, /** * See if a message contains DNSSEC. - * This is examined by looking for RRSIGs. With DNSSEC a valid answer, - * nxdomain, nodata, referral or cname reply has RRSIGs in answer or auth + * This is examined by looking for RRSIGs. With DNSSEC a valid answer, + * nxdomain, nodata, referral or cname reply has RRSIGs in answer or auth * sections, sigs on answer data, SOA, DS, or NSEC/NSEC3 records. * @param msg: message to examine. * @return true if DNSSEC information was found. @@ -243,7 +243,7 @@ int iter_msg_has_dnssec(struct dns_msg* msg); * @return true if message is certain to be from zone in dp->name. * false if not sure (empty msg), or not from the zone. */ -int iter_msg_from_zone(struct dns_msg* msg, struct delegpt* dp, +int iter_msg_from_zone(struct dns_msg* msg, struct delegpt* dp, enum response_type type, uint16_t dclass); /** @@ -275,14 +275,14 @@ void caps_strip_reply(struct reply_info* rep); int caps_failed_rcode(struct reply_info* rep); /** - * Store parent-side rrset in separate rrset cache entries for later - * last-resort * lookups in case the child-side versions of this information + * Store parent-side rrset in separate rrset cache entries for later + * last-resort * lookups in case the child-side versions of this information * fails. * @param env: environment with cache, time, ... * @param rrset: the rrset to store (copied). * Failure to store is logged, but otherwise ignored. */ -void iter_store_parentside_rrset(struct module_env* env, +void iter_store_parentside_rrset(struct module_env* env, struct ub_packed_rrset_key* rrset); /** @@ -301,7 +301,7 @@ void iter_store_parentside_NS(struct module_env* env, struct reply_info* rep); * @param rep: delegation response or answer response, to glean TTL from. * (malloc) failure is logged but otherwise ignored. */ -void iter_store_parentside_neg(struct module_env* env, +void iter_store_parentside_neg(struct module_env* env, struct query_info* qinfo, struct reply_info* rep); /** @@ -313,7 +313,7 @@ void iter_store_parentside_neg(struct module_env* env, * @param region: region to alloc result in. * @param qinfo: pertinent information, the qclass. * @return false on malloc failure. - * if true, the routine worked and if such cached information + * if true, the routine worked and if such cached information * existed dp->has_parent_side_NS is set true. */ int iter_lookup_parent_NS_from_cache(struct module_env* env, @@ -379,7 +379,7 @@ void iter_merge_retry_counts(struct delegpt* dp, struct delegpt* old, int outbound_msg_retry); /** - * See if a DS response (type ANSWER) is too low: a nodata answer with + * See if a DS response (type ANSWER) is too low: a nodata answer with * a SOA record in the authority section at-or-below the qchase.qname. * Also returns true if we are not sure (i.e. empty message, CNAME nosig). * @param msg: the response. @@ -398,7 +398,7 @@ int iter_ds_toolow(struct dns_msg* msg, struct delegpt* dp); */ int iter_dp_cangodown(struct query_info* qinfo, struct delegpt* dp); -/** +/** * Lookup if no_cache is set in stub or fwd. * @param qstate: query state with env with hints and fwds. * @param qinf: query name to lookup for. diff --git a/sbin/unwind/libunbound/iterator/iterator.c b/sbin/unwind/libunbound/iterator/iterator.c index 1548dfcae..290273176 100644 --- a/sbin/unwind/libunbound/iterator/iterator.c +++ b/sbin/unwind/libunbound/iterator/iterator.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -78,7 +78,7 @@ int BLACKLIST_PENALTY = (120000*4); static void target_count_increase_nx(struct iter_qstate* iq, int num); -int +int iter_init(struct module_env* env, int id) { struct iter_env* iter_env = (struct iter_env*)calloc(1, @@ -112,7 +112,7 @@ caps_free(struct rbnode_type* n, void* ATTR_UNUSED(d)) } } -void +void iter_deinit(struct module_env* env, int id) { struct iter_env* iter_env; @@ -138,7 +138,7 @@ iter_new(struct module_qstate* qstate, int id) struct iter_qstate* iq = (struct iter_qstate*)regional_alloc( qstate->region, sizeof(struct iter_qstate)); qstate->minfo[id] = iq; - if(!iq) + if(!iq) return 0; memset(iq, 0, sizeof(*iq)); iq->state = INIT_REQUEST_STATE; @@ -171,7 +171,7 @@ iter_new(struct module_qstate* qstate, int id) iq->minimisation_state = INIT_MINIMISE_STATE; else iq->minimisation_state = DONOT_MINIMISE_STATE; - + memset(&iq->qinfo_out, 0, sizeof(struct query_info)); return 1; } @@ -235,9 +235,9 @@ error_supers(struct module_qstate* qstate, int id, struct module_qstate* super) qstate->qinfo.qtype == LDNS_RR_TYPE_AAAA) { /* mark address as failed. */ struct delegpt_ns* dpns = NULL; - super_iq->num_target_queries--; + super_iq->num_target_queries--; if(super_iq->dp) - dpns = delegpt_find_ns(super_iq->dp, + dpns = delegpt_find_ns(super_iq->dp, qstate->qinfo.qname, qstate->qinfo.qname_len); if(!dpns) { /* not interested */ @@ -266,7 +266,7 @@ error_supers(struct module_qstate* qstate, int id, struct module_qstate* super) super_iq->dp = NULL; } /* evaluate targets again */ - super_iq->state = QUERYTARGETS_STATE; + super_iq->state = QUERYTARGETS_STATE; /* super becomes runnable, and will process this change */ } @@ -276,12 +276,12 @@ error_supers(struct module_qstate* qstate, int id, struct module_qstate* super) * @param id: module id * @param rcode: error code (DNS errcode). * @return: 0 for use by caller, to make notation easy, like: - * return error_response(..). + * return error_response(..). */ static int error_response(struct module_qstate* qstate, int id, int rcode) { - verbose(VERB_QUERY, "return error response %s", + verbose(VERB_QUERY, "return error response %s", sldns_lookup_by_id(sldns_rcodes, rcode)? sldns_lookup_by_id(sldns_rcodes, rcode)->name:"??"); qstate->return_rcode = rcode; @@ -297,7 +297,7 @@ error_response(struct module_qstate* qstate, int id, int rcode) * @param id: module id * @param rcode: error code (DNS errcode). * @return: 0 for use by caller, to make notation easy, like: - * return error_response(..). + * return error_response(..). */ static int error_response_cache(struct module_qstate* qstate, int id, int rcode) @@ -383,7 +383,7 @@ prepend_is_duplicate(struct ub_packed_rrset_key** sets, size_t to, /** prepend the prepend list in the answer and authority section of dns_msg */ static int -iter_prepend(struct iter_qstate* iq, struct dns_msg* msg, +iter_prepend(struct iter_qstate* iq, struct dns_msg* msg, struct regional* region) { struct iter_prep_list* p; @@ -400,7 +400,7 @@ iter_prepend(struct iter_qstate* iq, struct dns_msg* msg, msg->rep->rrset_count > RR_COUNT_MAX) return 0; /* overflow */ sets = regional_alloc(region, (num_an+num_ns+msg->rep->rrset_count) * sizeof(struct ub_packed_rrset_key*)); - if(!sets) + if(!sets) return 0; /* ANSWER section */ num_an = 0; @@ -416,15 +416,15 @@ iter_prepend(struct iter_qstate* iq, struct dns_msg* msg, for(p = iq->ns_prepend_list; p; p = p->next) { if(prepend_is_duplicate(sets+msg->rep->an_numrrsets+num_an, num_ns, p->rrset) || prepend_is_duplicate( - msg->rep->rrsets+msg->rep->an_numrrsets, + msg->rep->rrsets+msg->rep->an_numrrsets, msg->rep->ns_numrrsets, p->rrset)) continue; sets[msg->rep->an_numrrsets + num_an + num_ns++] = p->rrset; if(ub_packed_rrset_ttl(p->rrset) < msg->rep->ttl) msg->rep->ttl = ub_packed_rrset_ttl(p->rrset); } - memcpy(sets + num_an + msg->rep->an_numrrsets + num_ns, - msg->rep->rrsets + msg->rep->an_numrrsets, + memcpy(sets + num_an + msg->rep->an_numrrsets + num_ns, + msg->rep->rrsets + msg->rep->an_numrrsets, (msg->rep->ns_numrrsets + msg->rep->ar_numrrsets) * sizeof(struct ub_packed_rrset_key*)); @@ -533,13 +533,13 @@ handle_cname_response(struct module_qstate* qstate, struct iter_qstate* iq, *mname = iq->qchase.qname; *mname_len = iq->qchase.qname_len; - /* Iterate over the ANSWER rrsets in order, looking for CNAMEs and + /* Iterate over the ANSWER rrsets in order, looking for CNAMEs and * DNAMES. */ for(i=0; irep->an_numrrsets; i++) { struct ub_packed_rrset_key* r = msg->rep->rrsets[i]; /* If there is a (relevant) DNAME, add it to the list. - * We always expect there to be CNAME that was generated - * by this DNAME following, so we don't process the DNAME + * We always expect there to be CNAME that was generated + * by this DNAME following, so we don't process the DNAME * directly. */ if(ntohs(r->rk.type) == LDNS_RR_TYPE_DNAME && dname_strict_subdomain_c(*mname, r->rk.dname) && @@ -773,9 +773,9 @@ target_count_increase_nx(struct iter_qstate* iq, int num) * @return false on error (malloc). */ static int -generate_sub_request(uint8_t* qname, size_t qnamelen, uint16_t qtype, +generate_sub_request(uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, struct module_qstate* qstate, int id, - struct iter_qstate* iq, enum iter_state initial_state, + struct iter_qstate* iq, enum iter_state initial_state, enum iter_state finalstate, struct module_qstate** subq_ret, int v, int detached) { @@ -795,15 +795,15 @@ generate_sub_request(uint8_t* qname, size_t qnamelen, uint16_t qtype, * state. */ if(initial_state == INIT_REQUEST_STATE) qflags |= BIT_RD; - /* We set the CD flag so we can send this through the "head" of - * the resolution chain, which might have a validator. We are - * uninterested in validating things not on the direct resolution + /* We set the CD flag so we can send this through the "head" of + * the resolution chain, which might have a validator. We are + * uninterested in validating things not on the direct resolution * path. */ if(!v) { qflags |= BIT_CD; valrec = 1; } - + if(detached) { struct mesh_state* sub = NULL; fptr_ok(fptr_whitelist_modenv_add_sub( @@ -827,7 +827,7 @@ generate_sub_request(uint8_t* qname, size_t qnamelen, uint16_t qtype, /* initialise the new subquery */ subq->curmod = id; subq->ext_state[id] = module_state_initial; - subq->minfo[id] = regional_alloc(subq->region, + subq->minfo[id] = regional_alloc(subq->region, sizeof(struct iter_qstate)); if(!subq->minfo[id]) { log_err("init subq: out of memory"); @@ -877,7 +877,7 @@ prime_root(struct module_qstate* qstate, struct iter_qstate* iq, int id, { struct delegpt* dp; struct module_qstate* subq; - verbose(VERB_DETAIL, "priming . %s NS", + verbose(VERB_DETAIL, "priming . %s NS", sldns_lookup_by_id(sldns_rr_classes, (int)qclass)? sldns_lookup_by_id(sldns_rr_classes, (int)qclass)->name:"??"); dp = hints_lookup_root(qstate->env->hints, qclass); @@ -885,19 +885,19 @@ prime_root(struct module_qstate* qstate, struct iter_qstate* iq, int id, verbose(VERB_ALGO, "Cannot prime due to lack of hints"); return 0; } - /* Priming requests start at the QUERYTARGETS state, skipping + /* Priming requests start at the QUERYTARGETS state, skipping * the normal INIT state logic (which would cause an infloop). */ - if(!generate_sub_request((uint8_t*)"\000", 1, LDNS_RR_TYPE_NS, + if(!generate_sub_request((uint8_t*)"\000", 1, LDNS_RR_TYPE_NS, qclass, qstate, id, iq, QUERYTARGETS_STATE, PRIME_RESP_STATE, &subq, 0, 0)) { verbose(VERB_ALGO, "could not prime root"); return 0; } if(subq) { - struct iter_qstate* subiq = + struct iter_qstate* subiq = (struct iter_qstate*)subq->minfo[id]; /* Set the initial delegation point to the hint. - * copy dp, it is now part of the root prime query. + * copy dp, it is now part of the root prime query. * dp was part of in the fixed hints structure. */ subiq->dp = delegpt_copy(dp, subq->region); if(!subiq->dp) { @@ -908,11 +908,11 @@ prime_root(struct module_qstate* qstate, struct iter_qstate* iq, int id, return 0; } /* there should not be any target queries. */ - subiq->num_target_queries = 0; + subiq->num_target_queries = 0; subiq->dnssec_expected = iter_indicates_dnssec( qstate->env, subiq->dp, NULL, subq->qinfo.qclass); } - + /* this module stops, our submodule starts, and does the query. */ qstate->ext_state[id] = module_wait_subquery; return 1; @@ -936,7 +936,7 @@ static int prime_stub(struct module_qstate* qstate, struct iter_qstate* iq, int id, uint8_t* qname, uint16_t qclass) { - /* Lookup the stub hint. This will return null if the stub doesn't + /* Lookup the stub hint. This will return null if the stub doesn't * need to be re-primed. */ struct iter_hints_stub* stub; struct delegpt* stub_dp; @@ -950,7 +950,7 @@ prime_stub(struct module_qstate* qstate, struct iter_qstate* iq, int id, stub_dp = stub->dp; /* if we have an auth_zone dp, and stub is equal, don't prime stub * yet, unless we want to fallback and avoid the auth_zone */ - if(!iq->auth_zone_avoid && iq->dp && iq->dp->auth_dp && + if(!iq->auth_zone_avoid && iq->dp && iq->dp->auth_dp && query_dname_compare(iq->dp->name, stub_dp->name) == 0) return 0; @@ -967,18 +967,18 @@ prime_stub(struct module_qstate* qstate, struct iter_qstate* iq, int id, (void)error_response(qstate, id, LDNS_RCODE_SERVFAIL); return 1; /* return 1 to make module stop, with error */ } - log_nametypeclass(VERB_DETAIL, "use stub", stub_dp->name, + log_nametypeclass(VERB_DETAIL, "use stub", stub_dp->name, LDNS_RR_TYPE_NS, qclass); return r; } /* Otherwise, we need to (re)prime the stub. */ - log_nametypeclass(VERB_DETAIL, "priming stub", stub_dp->name, + log_nametypeclass(VERB_DETAIL, "priming stub", stub_dp->name, LDNS_RR_TYPE_NS, qclass); /* Stub priming events start at the QUERYTARGETS state to avoid the * redundant INIT state processing. */ - if(!generate_sub_request(stub_dp->name, stub_dp->namelen, + if(!generate_sub_request(stub_dp->name, stub_dp->namelen, LDNS_RR_TYPE_NS, qclass, qstate, id, iq, QUERYTARGETS_STATE, PRIME_RESP_STATE, &subq, 0, 0)) { verbose(VERB_ALGO, "could not prime stub"); @@ -987,7 +987,7 @@ prime_stub(struct module_qstate* qstate, struct iter_qstate* iq, int id, return 1; /* return 1 to make module stop, with error */ } if(subq) { - struct iter_qstate* subiq = + struct iter_qstate* subiq = (struct iter_qstate*)subq->minfo[id]; /* Set the initial delegation point to the hint. */ @@ -1002,15 +1002,15 @@ prime_stub(struct module_qstate* qstate, struct iter_qstate* iq, int id, (void)error_response(qstate, id, LDNS_RCODE_SERVFAIL); return 1; /* return 1 to make module stop, with error */ } - /* there should not be any target queries -- although there - * wouldn't be anyway, since stub hints never have + /* there should not be any target queries -- although there + * wouldn't be anyway, since stub hints never have * missing targets. */ - subiq->num_target_queries = 0; + subiq->num_target_queries = 0; subiq->wait_priming_stub = 1; subiq->dnssec_expected = iter_indicates_dnssec( qstate->env, subiq->dp, NULL, subq->qinfo.qclass); } - + /* this module stops, our submodule starts, and does the query. */ qstate->ext_state[id] = module_wait_subquery; return 1; @@ -1117,7 +1117,7 @@ auth_zone_delegpt(struct module_qstate* qstate, struct iter_qstate* iq, * @param id: module id. */ static void -generate_a_aaaa_check(struct module_qstate* qstate, struct iter_qstate* iq, +generate_a_aaaa_check(struct module_qstate* qstate, struct iter_qstate* iq, int id) { struct iter_env* ie = (struct iter_env*)qstate->env->modinfo[id]; @@ -1142,17 +1142,17 @@ generate_a_aaaa_check(struct module_qstate* qstate, struct iter_qstate* iq, /* is this query the same as the A/AAAA check for it */ if(qstate->qinfo.qtype == ntohs(s->rk.type) && qstate->qinfo.qclass == ntohs(s->rk.rrset_class) && - query_dname_compare(qstate->qinfo.qname, + query_dname_compare(qstate->qinfo.qname, s->rk.dname)==0 && - (qstate->query_flags&BIT_RD) && + (qstate->query_flags&BIT_RD) && !(qstate->query_flags&BIT_CD)) continue; /* generate subrequest for it */ - log_nametypeclass(VERB_ALGO, "schedule addr fetch", - s->rk.dname, ntohs(s->rk.type), + log_nametypeclass(VERB_ALGO, "schedule addr fetch", + s->rk.dname, ntohs(s->rk.type), ntohs(s->rk.rrset_class)); - if(!generate_sub_request(s->rk.dname, s->rk.dname_len, + if(!generate_sub_request(s->rk.dname, s->rk.dname_len, ntohs(s->rk.type), ntohs(s->rk.rrset_class), qstate, id, iq, INIT_REQUEST_STATE, FINISHED_STATE, &subq, 1, 0)) { @@ -1195,16 +1195,16 @@ generate_ns_check(struct module_qstate* qstate, struct iter_qstate* iq, int id) if(qstate->qinfo.qtype == LDNS_RR_TYPE_DS) return; - log_nametypeclass(VERB_ALGO, "schedule ns fetch", + log_nametypeclass(VERB_ALGO, "schedule ns fetch", iq->dp->name, LDNS_RR_TYPE_NS, iq->qchase.qclass); - if(!generate_sub_request(iq->dp->name, iq->dp->namelen, + if(!generate_sub_request(iq->dp->name, iq->dp->namelen, LDNS_RR_TYPE_NS, iq->qchase.qclass, qstate, id, iq, INIT_REQUEST_STATE, FINISHED_STATE, &subq, 1, 0)) { verbose(VERB_ALGO, "could not generate ns check"); return; } if(subq) { - struct iter_qstate* subiq = + struct iter_qstate* subiq = (struct iter_qstate*)subq->minfo[id]; /* make copy to avoid use of stub dp by different qs/threads */ @@ -1238,7 +1238,7 @@ generate_ns_check(struct module_qstate* qstate, struct iter_qstate* iq, int id) * @param id: module id. */ static void -generate_dnskey_prefetch(struct module_qstate* qstate, +generate_dnskey_prefetch(struct module_qstate* qstate, struct iter_qstate* iq, int id) { struct module_qstate* subq; @@ -1261,9 +1261,9 @@ generate_dnskey_prefetch(struct module_qstate* qstate, return; /* if the DNSKEY is in the cache this lookup will stop quickly */ - log_nametypeclass(VERB_ALGO, "schedule dnskey prefetch", + log_nametypeclass(VERB_ALGO, "schedule dnskey prefetch", iq->dp->name, LDNS_RR_TYPE_DNSKEY, iq->qchase.qclass); - if(!generate_sub_request(iq->dp->name, iq->dp->namelen, + if(!generate_sub_request(iq->dp->name, iq->dp->namelen, LDNS_RR_TYPE_DNSKEY, iq->qchase.qclass, qstate, id, iq, INIT_REQUEST_STATE, FINISHED_STATE, &subq, 0, 0)) { /* we'll be slower, but it'll work */ @@ -1271,7 +1271,7 @@ generate_dnskey_prefetch(struct module_qstate* qstate, return; } if(subq) { - struct iter_qstate* subiq = + struct iter_qstate* subiq = (struct iter_qstate*)subq->minfo[id]; /* this qstate has the right delegation for the dnskey lookup*/ /* make copy to avoid use of stub dp by different qs/threads */ @@ -1282,7 +1282,7 @@ generate_dnskey_prefetch(struct module_qstate* qstate, /** * See if the query needs forwarding. - * + * * @param qstate: query state. * @param iq: iterator query state. * @return true if the request is forwarded, false if not. @@ -1303,17 +1303,17 @@ forward_request(struct module_qstate* qstate, struct iter_qstate* iq) && !dname_is_root(iq->qchase.qname)) dname_remove_label(&delname, &delnamelen); dp = forwards_lookup(qstate->env->fwds, delname, iq->qchase.qclass); - if(!dp) + if(!dp) return 0; /* send recursion desired to forward addr */ - iq->chase_flags |= BIT_RD; + iq->chase_flags |= BIT_RD; iq->dp = delegpt_copy(dp, qstate->region); /* iq->dp checked by caller */ verbose(VERB_ALGO, "forwarding request"); return 1; } -/** +/** * Process the initial part of the request handling. This state roughly * corresponds to resolver algorithms steps 1 (find answer in cache) and 2 * (find the best servers to ask). @@ -1354,9 +1354,9 @@ processInitRequest(struct module_qstate* qstate, struct iter_qstate* iq, return error_response(qstate, id, LDNS_RCODE_SERVFAIL); } - /* We enforce a maximum recursion/dependency depth -- in general, - * this is unnecessary for dependency loops (although it will - * catch those), but it provides a sensible limit to the amount + /* We enforce a maximum recursion/dependency depth -- in general, + * this is unnecessary for dependency loops (although it will + * catch those), but it provides a sensible limit to the amount * of work required to answer a given query. */ verbose(VERB_ALGO, "request has dependency depth of %d", iq->depth); if(iq->depth > ie->max_dependency_depth) { @@ -1389,7 +1389,7 @@ processInitRequest(struct module_qstate* qstate, struct iter_qstate* iq, /* This either results in a query restart (CNAME cache response), a * terminating response (ANSWER), or a cache miss (null). */ - + if (iter_stub_fwd_no_cache(qstate, &iq->qchase, &dpname, &dpnamelen)) { /* Asked to not query cache. */ verbose(VERB_ALGO, "no-cache set, going to the network"); @@ -1402,8 +1402,8 @@ processInitRequest(struct module_qstate* qstate, struct iter_qstate* iq, verbose(VERB_ALGO, "cache blacklisted, going to the network"); msg = NULL; } else if(!qstate->no_cache_lookup) { - msg = dns_cache_lookup(qstate->env, iq->qchase.qname, - iq->qchase.qname_len, iq->qchase.qtype, + msg = dns_cache_lookup(qstate->env, iq->qchase.qname, + iq->qchase.qname_len, iq->qchase.qtype, iq->qchase.qclass, qstate->query_flags, qstate->region, qstate->env->scratch, 0, dpname, dpnamelen); @@ -1413,8 +1413,8 @@ processInitRequest(struct module_qstate* qstate, struct iter_qstate* iq, * NOERROR/NODATA or NXDOMAIN answers that need validation */ msg = val_neg_getmsg(qstate->env->neg_cache, &iq->qchase, qstate->region, qstate->env->rrset_cache, - qstate->env->scratch_buffer, - *qstate->env->now, 1/*add SOA*/, NULL, + qstate->env->scratch_buffer, + *qstate->env->now, 1/*add SOA*/, NULL, qstate->env->cfg); } /* item taken from cache does not match our query name, thus @@ -1425,13 +1425,13 @@ processInitRequest(struct module_qstate* qstate, struct iter_qstate* iq, } if(msg) { /* handle positive cache response */ - enum response_type type = response_type_from_cache(msg, + enum response_type type = response_type_from_cache(msg, &iq->qchase); if(verbosity >= VERB_ALGO) { - log_dns_msg("msg from cache lookup", &msg->qinfo, + log_dns_msg("msg from cache lookup", &msg->qinfo, msg->rep); - verbose(VERB_ALGO, "msg ttl is %d, prefetch ttl %d", - (int)msg->rep->ttl, + verbose(VERB_ALGO, "msg ttl is %d, prefetch ttl %d", + (int)msg->rep->ttl, (int)msg->rep->prefetch_ttl); } @@ -1440,16 +1440,16 @@ processInitRequest(struct module_qstate* qstate, struct iter_qstate* iq, size_t slen = 0; verbose(VERB_ALGO, "returning CNAME response from " "cache"); - if(!handle_cname_response(qstate, iq, msg, + if(!handle_cname_response(qstate, iq, msg, &sname, &slen)) { errinf(qstate, "failed to prepend CNAME " "components, malloc failure"); - return error_response(qstate, id, + return error_response(qstate, id, LDNS_RCODE_SERVFAIL); } iq->qchase.qname = sname; iq->qchase.qname_len = slen; - /* This *is* a query restart, even if it is a cheap + /* This *is* a query restart, even if it is a cheap * one. */ iq->dp = NULL; iq->refetch_glue = 0; @@ -1497,14 +1497,14 @@ processInitRequest(struct module_qstate* qstate, struct iter_qstate* iq, iq->refetch_glue = 0; iq->minimisation_state = DONOT_MINIMISE_STATE; /* the request has been forwarded. - * forwarded requests need to be immediately sent to the + * forwarded requests need to be immediately sent to the * next state, QUERYTARGETS. */ return next_state(iq, QUERYTARGETS_STATE); } /* Resolver Algorithm Step 2 -- find the "best" servers. */ - /* first, adjust for DS queries. To avoid the grandparent problem, + /* first, adjust for DS queries. To avoid the grandparent problem, * we just look for the closest set of server to the parent of qname. * When re-fetching glue we also need to ask the parent. */ @@ -1536,24 +1536,24 @@ processInitRequest(struct module_qstate* qstate, struct iter_qstate* iq, } /* delname is the name to lookup a delegation for. If NULL rootprime */ while(1) { - - /* Lookup the delegation in the cache. If null, then the + + /* Lookup the delegation in the cache. If null, then the * cache needs to be primed for the qclass. */ if(delname) - iq->dp = dns_cache_find_delegation(qstate->env, delname, - delnamelen, iq->qchase.qtype, iq->qchase.qclass, + iq->dp = dns_cache_find_delegation(qstate->env, delname, + delnamelen, iq->qchase.qtype, iq->qchase.qclass, qstate->region, &iq->deleg_msg, *qstate->env->now+qstate->prefetch_leeway, 1, dpname, dpnamelen); else iq->dp = NULL; - /* If the cache has returned nothing, then we have a + /* If the cache has returned nothing, then we have a * root priming situation. */ if(iq->dp == NULL) { int r; /* if under auth zone, no prime needed */ if(!auth_zone_delegpt(qstate, iq, delname, delnamelen)) - return error_response(qstate, id, + return error_response(qstate, id, LDNS_RCODE_SERVFAIL); if(iq->dp) /* use auth zone dp */ return next_state(iq, INIT_REQUEST_2_STATE); @@ -1564,23 +1564,23 @@ processInitRequest(struct module_qstate* qstate, struct iter_qstate* iq, break; /* got noprime-stub-zone, continue */ else if(r) return 0; /* stub prime request made */ - if(forwards_lookup_root(qstate->env->fwds, + if(forwards_lookup_root(qstate->env->fwds, iq->qchase.qclass)) { /* forward zone root, no root prime needed */ /* fill in some dp - safety belt */ - iq->dp = hints_lookup_root(qstate->env->hints, + iq->dp = hints_lookup_root(qstate->env->hints, iq->qchase.qclass); if(!iq->dp) { log_err("internal error: no hints dp"); errinf(qstate, "no hints for this class"); - return error_response(qstate, id, + return error_response(qstate, id, LDNS_RCODE_SERVFAIL); } iq->dp = delegpt_copy(iq->dp, qstate->region); if(!iq->dp) { log_err("out of memory in safety belt"); errinf(qstate, "malloc failure, in safety belt"); - return error_response(qstate, id, + return error_response(qstate, id, LDNS_RCODE_SERVFAIL); } return next_state(iq, INIT_REQUEST_2_STATE); @@ -1588,12 +1588,12 @@ processInitRequest(struct module_qstate* qstate, struct iter_qstate* iq, /* Note that the result of this will set a new * DelegationPoint based on the result of priming. */ if(!prime_root(qstate, iq, id, iq->qchase.qclass)) - return error_response(qstate, id, + return error_response(qstate, id, LDNS_RCODE_REFUSED); - /* priming creates and sends a subordinate query, with - * this query as the parent. So further processing for - * this event will stop until reactivated by the + /* priming creates and sends a subordinate query, with + * this query as the parent. So further processing for + * this event will stop until reactivated by the * results of priming. */ return 0; } @@ -1639,32 +1639,32 @@ processInitRequest(struct module_qstate* qstate, struct iter_qstate* iq, errinf(qstate, "no useful nameservers, " "and cannot go up"); errinf_dname(qstate, "for zone", iq->dp->name); - return error_response(qstate, id, + return error_response(qstate, id, LDNS_RCODE_SERVFAIL); } if(dname_is_root(iq->dp->name)) { /* use safety belt */ verbose(VERB_QUERY, "Cache has root NS but " "no addresses. Fallback to the safety belt."); - iq->dp = hints_lookup_root(qstate->env->hints, + iq->dp = hints_lookup_root(qstate->env->hints, iq->qchase.qclass); /* note deleg_msg is from previous lookup, * but RD is on, so it is not used */ if(!iq->dp) { log_err("internal error: no hints dp"); - return error_response(qstate, id, + return error_response(qstate, id, LDNS_RCODE_REFUSED); } iq->dp = delegpt_copy(iq->dp, qstate->region); if(!iq->dp) { log_err("out of memory in safety belt"); errinf(qstate, "malloc failure, in safety belt, for root"); - return error_response(qstate, id, + return error_response(qstate, id, LDNS_RCODE_SERVFAIL); } break; } else { - verbose(VERB_ALGO, + verbose(VERB_ALGO, "cache delegation was useless:"); delegpt_log(VERB_ALGO, iq->dp); /* go up */ @@ -1678,12 +1678,12 @@ processInitRequest(struct module_qstate* qstate, struct iter_qstate* iq, verbose(VERB_ALGO, "cache delegation returns delegpt"); delegpt_log(VERB_ALGO, iq->dp); - /* Otherwise, set the current delegation point and move on to the + /* Otherwise, set the current delegation point and move on to the * next state. */ return next_state(iq, INIT_REQUEST_2_STATE); } -/** +/** * Process the second part of the initial request handling. This state * basically exists so that queries that generate root priming events have * the same init processing as ones that do not. Request events that reach @@ -1704,7 +1704,7 @@ processInitRequest2(struct module_qstate* qstate, struct iter_qstate* iq, { uint8_t* delname; size_t delnamelen; - log_query_info(VERB_QUERY, "resolving (init part 2): ", + log_query_info(VERB_QUERY, "resolving (init part 2): ", &qstate->qinfo); delname = iq->qchase.qname; @@ -1721,7 +1721,7 @@ processInitRequest2(struct module_qstate* qstate, struct iter_qstate* iq, stub = hints_lookup_stub( qstate->env->hints, iq->qchase.qname, iq->qchase.qclass, iq->dp); - if(!stub || !stub->dp->has_parent_side_NS || + if(!stub || !stub->dp->has_parent_side_NS || dname_subdomain_c(iq->dp->name, stub->dp->name)) { delname = iq->dp->name; delnamelen = iq->dp->namelen; @@ -1748,7 +1748,7 @@ processInitRequest2(struct module_qstate* qstate, struct iter_qstate* iq, return next_state(iq, INIT_REQUEST_3_STATE); } -/** +/** * Process the third part of the initial request handling. This state exists * as a separate state so that queries that generate stub priming events * will get the tail end of the init process but not repeat the stub priming @@ -1760,28 +1760,28 @@ processInitRequest2(struct module_qstate* qstate, struct iter_qstate* iq, * @return true, advancing the event to the QUERYTARGETS_STATE. */ static int -processInitRequest3(struct module_qstate* qstate, struct iter_qstate* iq, +processInitRequest3(struct module_qstate* qstate, struct iter_qstate* iq, int id) { - log_query_info(VERB_QUERY, "resolving (init part 3): ", + log_query_info(VERB_QUERY, "resolving (init part 3): ", &qstate->qinfo); /* if the cache reply dp equals a validation anchor or msg has DS, * then DNSSEC RRSIGs are expected in the reply */ - iq->dnssec_expected = iter_indicates_dnssec(qstate->env, iq->dp, + iq->dnssec_expected = iter_indicates_dnssec(qstate->env, iq->dp, iq->deleg_msg, iq->qchase.qclass); - /* If the RD flag wasn't set, then we just finish with the + /* If the RD flag wasn't set, then we just finish with the * cached referral as the response. */ if(!(qstate->query_flags & BIT_RD) && iq->deleg_msg) { iq->response = iq->deleg_msg; if(verbosity >= VERB_ALGO && iq->response) - log_dns_msg("no RD requested, using delegation msg", + log_dns_msg("no RD requested, using delegation msg", &iq->response->qinfo, iq->response->rep); if(qstate->reply_origin) sock_list_insert(&qstate->reply_origin, NULL, 0, qstate->region); return final_state(iq); } - /* After this point, unset the RD flag -- this query is going to + /* After this point, unset the RD flag -- this query is going to * be sent to an auth. server. */ iq->chase_flags &= ~BIT_RD; @@ -1799,7 +1799,7 @@ processInitRequest3(struct module_qstate* qstate, struct iter_qstate* iq, } /** - * Given a basic query, generate a parent-side "target" query. + * Given a basic query, generate a parent-side "target" query. * These are subordinate queries for missing delegation point target addresses, * for which only the parent of the delegation provides correct IP addresses. * @@ -1813,16 +1813,16 @@ processInitRequest3(struct module_qstate* qstate, struct iter_qstate* iq, * @return true on success, false on failure. */ static int -generate_parentside_target_query(struct module_qstate* qstate, - struct iter_qstate* iq, int id, uint8_t* name, size_t namelen, +generate_parentside_target_query(struct module_qstate* qstate, + struct iter_qstate* iq, int id, uint8_t* name, size_t namelen, uint16_t qtype, uint16_t qclass) { struct module_qstate* subq; - if(!generate_sub_request(name, namelen, qtype, qclass, qstate, + if(!generate_sub_request(name, namelen, qtype, qclass, qstate, id, iq, INIT_REQUEST_STATE, FINISHED_STATE, &subq, 0, 0)) return 0; if(subq) { - struct iter_qstate* subiq = + struct iter_qstate* subiq = (struct iter_qstate*)subq->minfo[id]; /* blacklist the cache - we want to fetch parent stuff */ sock_list_insert(&subq->blacklist, NULL, 0, subq->region); @@ -1830,19 +1830,19 @@ generate_parentside_target_query(struct module_qstate* qstate, if(dname_subdomain_c(name, iq->dp->name)) { subiq->dp = delegpt_copy(iq->dp, subq->region); subiq->dnssec_expected = iter_indicates_dnssec( - qstate->env, subiq->dp, NULL, + qstate->env, subiq->dp, NULL, subq->qinfo.qclass); subiq->refetch_glue = 1; } else { - subiq->dp = dns_cache_find_delegation(qstate->env, + subiq->dp = dns_cache_find_delegation(qstate->env, name, namelen, qtype, qclass, subq->region, &subiq->deleg_msg, *qstate->env->now+subq->prefetch_leeway, 1, NULL, 0); /* if no dp, then it's from root, refetch unneeded */ - if(subiq->dp) { + if(subiq->dp) { subiq->dnssec_expected = iter_indicates_dnssec( - qstate->env, subiq->dp, NULL, + qstate->env, subiq->dp, NULL, subq->qinfo.qclass); subiq->refetch_glue = 1; } @@ -1870,7 +1870,7 @@ generate_target_query(struct module_qstate* qstate, struct iter_qstate* iq, int id, uint8_t* name, size_t namelen, uint16_t qtype, uint16_t qclass) { struct module_qstate* subq; - if(!generate_sub_request(name, namelen, qtype, qclass, qstate, + if(!generate_sub_request(name, namelen, qtype, qclass, qstate, id, iq, INIT_REQUEST_STATE, FINISHED_STATE, &subq, 0, 0)) return 0; log_nametypeclass(VERB_QUERY, "new target", name, qtype, qclass); @@ -1887,7 +1887,7 @@ generate_target_query(struct module_qstate* qstate, struct iter_qstate* iq, * @param id: module id. * @param maxtargets: The maximum number of targets to query for. * if it is negative, there is no maximum number of targets. - * @param num: returns the number of queries generated and processed, + * @param num: returns the number of queries generated and processed, * which may be zero if there were no missing targets. * @return false on error. */ @@ -1957,7 +1957,7 @@ query_for_targets(struct module_qstate* qstate, struct iter_qstate* iq, ((ns->lame && !ns->done_pside6) || (!ns->lame && !ns->got6))) { /* Send the AAAA request. */ - if(!generate_target_query(qstate, iq, id, + if(!generate_target_query(qstate, iq, id, ns->name, ns->namelen, LDNS_RR_TYPE_AAAA, iq->qchase.qclass)) { *num = query_count; @@ -1979,8 +1979,8 @@ query_for_targets(struct module_qstate* qstate, struct iter_qstate* iq, if((ie->supports_ipv4 || ie->use_nat64) && ((ns->lame && !ns->done_pside4) || (!ns->lame && !ns->got4))) { - if(!generate_target_query(qstate, iq, id, - ns->name, ns->namelen, + if(!generate_target_query(qstate, iq, id, + ns->name, ns->namelen, LDNS_RR_TYPE_A, iq->qchase.qclass)) { *num = query_count; if(query_count > 0) @@ -2017,7 +2017,7 @@ query_for_targets(struct module_qstate* qstate, struct iter_qstate* iq, * @param ie: iterator shared global environment. * @param id: module id. * @return true if the event requires more request processing immediately, - * false if not. + * false if not. */ static int processLastResort(struct module_qstate* qstate, struct iter_qstate* iq, @@ -2030,7 +2030,7 @@ processLastResort(struct module_qstate* qstate, struct iter_qstate* iq, if(!can_have_last_resort(qstate->env, iq->dp->name, iq->dp->namelen, iq->qchase.qclass, NULL)) { - /* fail -- no more targets, no more hope of targets, no hope + /* fail -- no more targets, no more hope of targets, no hope * of a response. */ errinf(qstate, "all the configured stub or forward servers failed,"); errinf_dname(qstate, "at zone", iq->dp->name); @@ -2058,7 +2058,7 @@ processLastResort(struct module_qstate* qstate, struct iter_qstate* iq, iq->dp->has_parent_side_NS = 1; } else if(!iq->dp->has_parent_side_NS) { if(!iter_lookup_parent_NS_from_cache(qstate->env, iq->dp, - qstate->region, &qstate->qinfo) + qstate->region, &qstate->qinfo) || !iq->dp->has_parent_side_NS) { /* if: malloc failure in lookup go up to try */ /* if: no parent NS in cache - go up one level */ @@ -2076,7 +2076,7 @@ processLastResort(struct module_qstate* qstate, struct iter_qstate* iq, } } /* see if that makes new names available */ - if(!cache_fill_missing(qstate->env, iq->qchase.qclass, + if(!cache_fill_missing(qstate->env, iq->qchase.qclass, qstate->region, iq->dp)) log_err("out of memory in cache_fill_missing"); if(iq->dp->usable_list) { @@ -2142,7 +2142,7 @@ processLastResort(struct module_qstate* qstate, struct iter_qstate* iq, /* query for parent-side A and AAAA for nameservers */ if(ie->supports_ipv6 && !ns->done_pside6) { /* Send the AAAA request. */ - if(!generate_parentside_target_query(qstate, iq, id, + if(!generate_parentside_target_query(qstate, iq, id, ns->name, ns->namelen, LDNS_RR_TYPE_AAAA, iq->qchase.qclass)) { errinf_dname(qstate, "could not generate nameserver AAAA lookup for", ns->name); @@ -2163,8 +2163,8 @@ processLastResort(struct module_qstate* qstate, struct iter_qstate* iq, } if((ie->supports_ipv4 || ie->use_nat64) && !ns->done_pside4) { /* Send the A request. */ - if(!generate_parentside_target_query(qstate, iq, id, - ns->name, ns->namelen, + if(!generate_parentside_target_query(qstate, iq, id, + ns->name, ns->namelen, LDNS_RR_TYPE_A, iq->qchase.qclass)) { errinf_dname(qstate, "could not generate nameserver A lookup for", ns->name); return error_response(qstate, id, @@ -2194,18 +2194,18 @@ processLastResort(struct module_qstate* qstate, struct iter_qstate* iq, errinf_dname(qstate, "at zone", iq->dp->name); errinf_reply(qstate, iq); verbose(VERB_QUERY, "out of query targets -- returning SERVFAIL"); - /* fail -- no more targets, no more hope of targets, no hope + /* fail -- no more targets, no more hope of targets, no hope * of a response. */ return error_response_cache(qstate, id, LDNS_RCODE_SERVFAIL); } -/** +/** * Try to find the NS record set that will resolve a qtype DS query. Due * to grandparent/grandchild reasons we did not get a proper lookup right * away. We need to create type NS queries until we get the right parent * for this lookup. We remove labels from the query to find the right point. * If we end up at the old dp name, then there is no solution. - * + * * @param qstate: query state. * @param iq: iterator query state. * @param id: module id. @@ -2242,9 +2242,9 @@ processDSNSFind(struct module_qstate* qstate, struct iter_qstate* iq, int id) iq->state = DSNS_FIND_STATE; /* spawn NS lookup (validation not needed, this is for DS lookup) */ - log_nametypeclass(VERB_ALGO, "fetch nameservers", + log_nametypeclass(VERB_ALGO, "fetch nameservers", iq->dsns_point, LDNS_RR_TYPE_NS, iq->qchase.qclass); - if(!generate_sub_request(iq->dsns_point, iq->dsns_point_len, + if(!generate_sub_request(iq->dsns_point, iq->dsns_point_len, LDNS_RR_TYPE_NS, iq->qchase.qclass, qstate, id, iq, INIT_REQUEST_STATE, FINISHED_STATE, &subq, 0, 0)) { errinf_dname(qstate, "for DS query parent-child nameserver search, could not generate NS lookup for", iq->dsns_point); @@ -2279,8 +2279,8 @@ check_waiting_queries(struct iter_qstate* iq, struct module_qstate* qstate, qstate->ext_state[id] = module_wait_reply; } } - -/** + +/** * This is the request event state where the request will be sent to one of * its current query targets. This state also handles issuing target lookup * queries for missing target IP addresses. Queries typically iterate on @@ -2318,7 +2318,7 @@ processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq, log_query_info(VERB_QUERY, "processQueryTargets:", &qstate->qinfo); verbose(VERB_ALGO, "processQueryTargets: targetqueries %d, " - "currentqueries %d sentcount %d", iq->num_target_queries, + "currentqueries %d sentcount %d", iq->num_target_queries, iq->num_current_queries, iq->sent_count); /* Make sure that we haven't run away */ @@ -2420,7 +2420,7 @@ processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq, } } } - + /* Make sure we have a delegation point, otherwise priming failed * or another failure occurred */ if(!iq->dp) { @@ -2449,10 +2449,10 @@ processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq, * qinfo_out is already a subdomain of dp. This happens when * increasing by more than one label at once (QNAMEs with more * than MAX_MINIMISE_COUNT labels). */ - if(!(iq->qinfo_out.qname_len - && dname_subdomain_c(iq->qchase.qname, + if(!(iq->qinfo_out.qname_len + && dname_subdomain_c(iq->qchase.qname, iq->qinfo_out.qname) - && dname_subdomain_c(iq->qinfo_out.qname, + && dname_subdomain_c(iq->qinfo_out.qname, iq->dp->name))) { iq->qinfo_out.qname = iq->dp->name; iq->qinfo_out.qname_len = iq->dp->namelen; @@ -2482,15 +2482,15 @@ processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq, * than MAX_MINIMISE_COUNT labels. Send first MINIMISE_ONE_LAB * labels of QNAME always individually. */ - if(qchaselabs > MAX_MINIMISE_COUNT && labdiff > 1 && + if(qchaselabs > MAX_MINIMISE_COUNT && labdiff > 1 && iq->minimise_count > MINIMISE_ONE_LAB) { if(iq->minimise_count < MAX_MINIMISE_COUNT) { - int multilabs = qchaselabs - 1 - + int multilabs = qchaselabs - 1 - MINIMISE_ONE_LAB; - int extralabs = multilabs / + int extralabs = multilabs / MINIMISE_MULTIPLE_LABS; - if (MAX_MINIMISE_COUNT - iq->minimise_count >= + if (MAX_MINIMISE_COUNT - iq->minimise_count >= multilabs % MINIMISE_MULTIPLE_LABS) /* Default behaviour is to add 1 label * every iteration. Therefore, decrement @@ -2509,25 +2509,25 @@ processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq, if(labdiff > 1) { verbose(VERB_QUERY, "removing %d labels", labdiff-1); - dname_remove_labels(&iq->qinfo_out.qname, - &iq->qinfo_out.qname_len, + dname_remove_labels(&iq->qinfo_out.qname, + &iq->qinfo_out.qname_len, labdiff-1); } - if(labdiff < 1 || (labdiff < 2 + if(labdiff < 1 || (labdiff < 2 && (iq->qchase.qtype == LDNS_RR_TYPE_DS || iq->qchase.qtype == LDNS_RR_TYPE_A))) /* Stop minimising this query, resolve "as usual" */ iq->minimisation_state = DONOT_MINIMISE_STATE; else if(!qstate->no_cache_lookup) { - struct dns_msg* msg = dns_cache_lookup(qstate->env, - iq->qinfo_out.qname, iq->qinfo_out.qname_len, - iq->qinfo_out.qtype, iq->qinfo_out.qclass, - qstate->query_flags, qstate->region, + struct dns_msg* msg = dns_cache_lookup(qstate->env, + iq->qinfo_out.qname, iq->qinfo_out.qname_len, + iq->qinfo_out.qtype, iq->qinfo_out.qclass, + qstate->query_flags, qstate->region, qstate->env->scratch, 0, iq->dp->name, iq->dp->namelen); if(msg && FLAGS_GET_RCODE(msg->rep->flags) == LDNS_RCODE_NOERROR) - /* no need to send query if it is already + /* no need to send query if it is already * cached as NOERROR */ return 1; if(msg && FLAGS_GET_RCODE(msg->rep->flags) == @@ -2564,7 +2564,7 @@ processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq, } if(iq->minimisation_state == SKIP_MINIMISE_STATE) { if(iq->timeout_count < MAX_MINIMISE_TIMEOUT_COUNT) - /* Do not increment qname, continue incrementing next + /* Do not increment qname, continue incrementing next * iteration */ iq->minimisation_state = MINIMISE_STATE; else if(!qstate->env->cfg->qname_minimisation_strict) @@ -2679,7 +2679,7 @@ processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq, /* *2 on sentcount check because ipv6 may fail */ /* we're done, process the response */ verbose(VERB_ALGO, "0x20 fallback had %d responses " - "match for %d wanted, done.", + "match for %d wanted, done.", (int)iq->caps_server+1, (int)naddr*3); iq->response = iq->caps_response; iq->caps_fallback = 0; @@ -2691,16 +2691,16 @@ processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq, iq->state = QUERY_RESP_STATE; return 1; } - verbose(VERB_ALGO, "0x20 fallback number %d", + verbose(VERB_ALGO, "0x20 fallback number %d", (int)iq->caps_server); - /* if there is a policy to fetch missing targets - * opportunistically, do it. we rely on the fact that once a - * query (or queries) for a missing name have been issued, + /* if there is a policy to fetch missing targets + * opportunistically, do it. we rely on the fact that once a + * query (or queries) for a missing name have been issued, * they will not show up again. */ } else if(tf_policy != 0) { int extra = 0; - verbose(VERB_ALGO, "attempt to get extra %d targets", + verbose(VERB_ALGO, "attempt to get extra %d targets", tf_policy); (void)query_for_targets(qstate, iq, ie, id, tf_policy, &extra); /* errors ignored, these targets are not strictly necessary for @@ -2738,31 +2738,31 @@ processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq, /* If no usable target was selected... */ if(!target) { - /* Here we distinguish between three states: generate a new + /* Here we distinguish between three states: generate a new * target query, just wait, or quit (with a SERVFAIL). - * We have the following information: number of active - * target queries, number of active current queries, - * the presence of missing targets at this delegation + * We have the following information: number of active + * target queries, number of active current queries, + * the presence of missing targets at this delegation * point, and the given query target policy. */ - - /* Check for the wait condition. If this is true, then + + /* Check for the wait condition. If this is true, then * an action must be taken. */ if(iq->num_target_queries==0 && iq->num_current_queries==0) { - /* If there is nothing to wait for, then we need - * to distinguish between generating (a) new target + /* If there is nothing to wait for, then we need + * to distinguish between generating (a) new target * query, or failing. */ if(delegpt_count_missing_targets(iq->dp, NULL) > 0) { int qs = 0; verbose(VERB_ALGO, "querying for next " "missing target"); - if(!query_for_targets(qstate, iq, ie, id, + if(!query_for_targets(qstate, iq, ie, id, 1, &qs)) { errinf(qstate, "could not fetch nameserver"); errinf_dname(qstate, "at zone", iq->dp->name); return error_response(qstate, id, LDNS_RCODE_SERVFAIL); } - if(qs == 0 && + if(qs == 0 && delegpt_count_missing_targets(iq->dp, NULL) == 0){ /* it looked like there were missing * targets, but they did not turn up. @@ -2774,7 +2774,7 @@ processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq, iq->num_target_queries += qs; target_count_increase(iq, qs); } - /* Since a target query might have been made, we + /* Since a target query might have been made, we * need to check again. */ if(iq->num_target_queries == 0) { /* if in capsforid fallback, instead of last @@ -2784,7 +2784,7 @@ processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq, /* we're done, process the response */ verbose(VERB_ALGO, "0x20 fallback had %d responses, " "but no more servers except " - "last resort, done.", + "last resort, done.", (int)iq->caps_server+1); iq->response = iq->caps_response; iq->caps_fallback = 0; @@ -2800,7 +2800,7 @@ processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq, } } - /* otherwise, we have no current targets, so submerge + /* otherwise, we have no current targets, so submerge * until one of the target or direct queries return. */ verbose(VERB_ALGO, "no current targets"); check_waiting_queries(iq, qstate, id); @@ -2922,12 +2922,12 @@ find_NS(struct reply_info* rep, size_t from, size_t to) } -/** +/** * Process the query response. All queries end up at this state first. This * process generally consists of analyzing the response and routing the * event to the next state (either bouncing it back to a request state, or * terminating the processing for this event). - * + * * @param qstate: query state. * @param iq: iterator query state. * @param ie: iterator shared global environment. @@ -2968,17 +2968,17 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, iq->response->rep->flags &= ~BIT_TC; if(type == RESPONSE_TYPE_REFERRAL && (iq->chase_flags&BIT_RD) && !iq->auth_zone_response) { - /* When forwarding (RD bit is set), we handle referrals + /* When forwarding (RD bit is set), we handle referrals * differently. No queries should be sent elsewhere */ type = RESPONSE_TYPE_ANSWER; } - if(!qstate->env->cfg->disable_dnssec_lame_check && iq->dnssec_expected + if(!qstate->env->cfg->disable_dnssec_lame_check && iq->dnssec_expected && !iq->dnssec_lame_query && - !(iq->chase_flags&BIT_RD) + !(iq->chase_flags&BIT_RD) && iq->sent_count < DNSSEC_LAME_DETECT_COUNT - && type != RESPONSE_TYPE_LAME - && type != RESPONSE_TYPE_REC_LAME - && type != RESPONSE_TYPE_THROWAWAY + && type != RESPONSE_TYPE_LAME + && type != RESPONSE_TYPE_REC_LAME + && type != RESPONSE_TYPE_THROWAWAY && type != RESPONSE_TYPE_UNTYPED) { /* a possible answer, see if it is missing DNSSEC */ /* but not when forwarding, so we dont mark fwder lame */ @@ -3007,11 +3007,11 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, if(type == RESPONSE_TYPE_REFERRAL) { struct ub_packed_rrset_key* ns = find_NS( iq->response->rep, iq->response->rep->an_numrrsets, - iq->response->rep->an_numrrsets + iq->response->rep->an_numrrsets + iq->response->rep->ns_numrrsets); - if(!ns) ns = find_NS(iq->response->rep, 0, + if(!ns) ns = find_NS(iq->response->rep, 0, iq->response->rep->an_numrrsets); - if(!ns || !dname_strict_subdomain_c(ns->rk.dname, iq->dp->name) + if(!ns || !dname_strict_subdomain_c(ns->rk.dname, iq->dp->name) || !dname_subdomain_c(iq->qchase.qname, ns->rk.dname)){ verbose(VERB_ALGO, "bad referral, throwaway"); type = RESPONSE_TYPE_THROWAWAY; @@ -3048,7 +3048,7 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, /* handle each of the type cases */ if(type == RESPONSE_TYPE_ANSWER) { - /* ANSWER type responses terminate the query algorithm, + /* ANSWER type responses terminate the query algorithm, * so they sent on their */ if(verbosity >= VERB_DETAIL) { verbose(VERB_DETAIL, "query response was %s", @@ -3093,7 +3093,7 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, qstate->reply->remote_addrlen, qstate->region); if(iq->minimisation_state != DONOT_MINIMISE_STATE && !(iq->chase_flags & BIT_RD)) { - if(FLAGS_GET_RCODE(iq->response->rep->flags) != + if(FLAGS_GET_RCODE(iq->response->rep->flags) != LDNS_RCODE_NOERROR) { if(qstate->env->cfg->qname_minimisation_strict) { if(FLAGS_GET_RCODE(iq->response->rep->flags) == @@ -3104,7 +3104,7 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, return error_response(qstate, id, LDNS_RCODE_SERVFAIL); } - /* Best effort qname-minimisation. + /* Best effort qname-minimisation. * Stop minimising and send full query when * RCODE is not NOERROR. */ iq->minimisation_state = DONOT_MINIMISE_STATE; @@ -3146,15 +3146,15 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, } return final_state(iq); } else if(type == RESPONSE_TYPE_REFERRAL) { - /* REFERRAL type responses get a reset of the + /* REFERRAL type responses get a reset of the * delegation point, and back to the QUERYTARGETS_STATE. */ verbose(VERB_DETAIL, "query response was REFERRAL"); /* if hardened, only store referral if we asked for it */ if(!qstate->no_cache_store && (!qstate->env->cfg->harden_referral_path || - ( qstate->qinfo.qtype == LDNS_RR_TYPE_NS - && (qstate->query_flags&BIT_RD) + ( qstate->qinfo.qtype == LDNS_RR_TYPE_NS + && (qstate->query_flags&BIT_RD) && !(qstate->query_flags&BIT_CD) /* we know that all other NS rrsets are scrubbed * away, thus on referral only one is left. @@ -3174,17 +3174,17 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, iq->response->rep, 1, 0, 0, NULL, 0, qstate->qstarttime); if(iq->store_parent_NS) - iter_store_parentside_NS(qstate->env, + iter_store_parentside_NS(qstate->env, iq->response->rep); if(qstate->env->neg_cache) - val_neg_addreferral(qstate->env->neg_cache, + val_neg_addreferral(qstate->env->neg_cache, iq->response->rep, iq->dp->name); } /* store parent-side-in-zone-glue, if directly queried for */ if(!qstate->no_cache_store && iq->query_for_pside_glue && !iq->pside_glue) { - iq->pside_glue = reply_find_rrset(iq->response->rep, - iq->qchase.qname, iq->qchase.qname_len, + iq->pside_glue = reply_find_rrset(iq->response->rep, + iq->qchase.qname, iq->qchase.qname_len, iq->qchase.qtype, iq->qchase.qclass); if(iq->pside_glue) { log_rrset_key(VERB_ALGO, "found parent-side " @@ -3194,7 +3194,7 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, } } - /* Reset the event state, setting the current delegation + /* Reset the event state, setting the current delegation * point to the referral. */ iq->deleg_msg = iq->response; iq->dp = delegpt_from_message(iq->response, qstate->region); @@ -3204,7 +3204,7 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, errinf(qstate, "malloc failure, for delegation point"); return error_response(qstate, id, LDNS_RCODE_SERVFAIL); } - if(!cache_fill_missing(qstate->env, iq->qchase.qclass, + if(!cache_fill_missing(qstate->env, iq->qchase.qclass, qstate->region, iq->dp)) { errinf(qstate, "malloc failure, copy extra info into delegation point"); return error_response(qstate, id, LDNS_RCODE_SERVFAIL); @@ -3220,7 +3220,7 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, iq->dp_target_count = 0; /* see if the next dp is a trust anchor, or a DS was sent * along, indicating dnssec is expected for next zone */ - iq->dnssec_expected = iter_indicates_dnssec(qstate->env, + iq->dnssec_expected = iter_indicates_dnssec(qstate->env, iq->dp, iq->response, iq->qchase.qclass); /* if dnssec, validating then also fetch the key for the DS */ if(iq->dnssec_expected && qstate->env->cfg->prefetch_key && @@ -3229,12 +3229,12 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, /* spawn off NS and addr to auth servers for the NS we just * got in the referral. This gets authoritative answer - * (answer section trust level) rrset. + * (answer section trust level) rrset. * right after, we detach the subs, answer goes to cache. */ if(qstate->env->cfg->harden_referral_path) generate_ns_check(qstate, iq, id); - /* stop current outstanding queries. + /* stop current outstanding queries. * FIXME: should the outstanding queries be waited for and * handled? Say by a subquery that inherits the outbound_entry. */ @@ -3251,12 +3251,12 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, } else if(type == RESPONSE_TYPE_CNAME) { uint8_t* sname = NULL; size_t snamelen = 0; - /* CNAME type responses get a query restart (i.e., get a + /* CNAME type responses get a query restart (i.e., get a * reset of the query state and go back to INIT_REQUEST_STATE). */ verbose(VERB_DETAIL, "query response was CNAME"); if(verbosity >= VERB_ALGO) - log_dns_msg("cname msg", &iq->response->qinfo, + log_dns_msg("cname msg", &iq->response->qinfo, iq->response->rep); /* if qtype is DS, check we have the right level of answer, * like grandchild answer but we need the middle, reject it */ @@ -3273,13 +3273,13 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, return processDSNSFind(qstate, iq, id); } /* Process the CNAME response. */ - if(!handle_cname_response(qstate, iq, iq->response, + if(!handle_cname_response(qstate, iq, iq->response, &sname, &snamelen)) { errinf(qstate, "malloc failure, CNAME info"); return error_response(qstate, id, LDNS_RCODE_SERVFAIL); } /* cache the CNAME response under the current query */ - /* NOTE : set referral=1, so that rrsets get stored but not + /* NOTE : set referral=1, so that rrsets get stored but not * the partial query answer (CNAME only). */ /* prefetchleeway applied because this updates answer parts */ if(!qstate->no_cache_store) @@ -3337,7 +3337,7 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, if(qstate->env->cfg->qname_minimisation) iq->minimisation_state = INIT_MINIMISE_STATE; - /* stop current outstanding queries. + /* stop current outstanding queries. * FIXME: should the outstanding queries be waited for and * handled? Say by a subquery that inherits the outbound_entry. */ @@ -3383,17 +3383,17 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, /* need addr for lameness cache, but we may have * gotten this from cache, so test to be sure */ verbose(VERB_DETAIL, "mark as REC_LAME"); - if(!infra_set_lame(qstate->env->infra_cache, + if(!infra_set_lame(qstate->env->infra_cache, &qstate->reply->remote_addr, qstate->reply->remote_addrlen, iq->dp->name, iq->dp->namelen, *qstate->env->now, 0, 1, iq->qchase.qtype)) log_err("mark host lame: out of memory"); - } + } } else if(type == RESPONSE_TYPE_THROWAWAY) { - /* LAME and THROWAWAY responses are handled the same way. - * In this case, the event is just sent directly back to - * the QUERYTARGETS_STATE without resetting anything, + /* LAME and THROWAWAY responses are handled the same way. + * In this case, the event is just sent directly back to + * the QUERYTARGETS_STATE without resetting anything, * because, clearly, the next target must be tried. */ verbose(VERB_DETAIL, "query response was THROWAWAY"); } else { @@ -3402,7 +3402,7 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, } /* LAME, THROWAWAY and "unknown" all end up here. - * Recycle to the QUERYTARGETS state to hopefully try a + * Recycle to the QUERYTARGETS state to hopefully try a * different target. */ if (qstate->env->cfg->qname_minimisation && !qstate->env->cfg->qname_minimisation_strict) @@ -3433,7 +3433,7 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, /** * Return priming query results to interested super querystates. - * + * * Sets the delegation point and delegation message (not nonRD queries). * This is a callback from walk_supers. * @@ -3452,7 +3452,7 @@ prime_supers(struct module_qstate* qstate, int id, struct module_qstate* forq) /* Convert our response to a delegation point */ dp = delegpt_from_message(qstate->return_msg, forq->region); if(!dp) { - /* if there is no convertible delegation point, then + /* if there is no convertible delegation point, then * the ANSWER type was (presumably) a negative answer. */ verbose(VERB_ALGO, "prime response was not a positive " "ANSWER; failing"); @@ -3472,7 +3472,7 @@ prime_supers(struct module_qstate* qstate, int id, struct module_qstate* forq) return; } - /* root priming responses go to init stage 2, priming stub + /* root priming responses go to init stage 2, priming stub * responses to to stage 3. */ if(foriq->wait_priming_stub) { foriq->state = INIT_REQUEST_3_STATE; @@ -3481,7 +3481,7 @@ prime_supers(struct module_qstate* qstate, int id, struct module_qstate* forq) /* because we are finished, the parent will be reactivated */ } -/** +/** * This handles the response to a priming query. This is used to handle both * root and stub priming responses. This is basically the equivalent of the * QUERY_RESP_STATE, but will not handle CNAME responses and will treat @@ -3500,7 +3500,7 @@ processPrimeResponse(struct module_qstate* qstate, int id) enum response_type type; iq->response->rep->flags &= ~(BIT_RD|BIT_RA); /* ignore rec-lame */ type = response_type_from_server( - (int)((iq->chase_flags&BIT_RD) || iq->chase_to_rd), + (int)((iq->chase_flags&BIT_RD) || iq->chase_to_rd), iq->response, &iq->qchase, iq->dp); if(type == RESPONSE_TYPE_ANSWER) { qstate->return_rcode = LDNS_RCODE_NOERROR; @@ -3518,10 +3518,10 @@ processPrimeResponse(struct module_qstate* qstate, int id) * may need can be resolved. */ if(qstate->env->cfg->harden_referral_path) { struct module_qstate* subq = NULL; - log_nametypeclass(VERB_ALGO, "schedule prime validation", + log_nametypeclass(VERB_ALGO, "schedule prime validation", qstate->qinfo.qname, qstate->qinfo.qtype, qstate->qinfo.qclass); - if(!generate_sub_request(qstate->qinfo.qname, + if(!generate_sub_request(qstate->qinfo.qname, qstate->qinfo.qname_len, qstate->qinfo.qtype, qstate->qinfo.qclass, qstate, id, iq, INIT_REQUEST_STATE, FINISHED_STATE, &subq, 1, 0)) { @@ -3535,13 +3535,13 @@ processPrimeResponse(struct module_qstate* qstate, int id) return 0; } -/** +/** * Do final processing on responses to target queries. Events reach this * state after the iterative resolution algorithm terminates. This state is * responsible for reactivating the original event, and housekeeping related * to received target responses (caching, updating the current delegation * point, etc). - * Callback from walk_supers for every super state that is interested in + * Callback from walk_supers for every super state that is interested in * the results from this query. * * @param qstate: query state. @@ -3587,9 +3587,9 @@ processTargetResponse(struct module_qstate* qstate, int id, /* if the pside_glue is NULL, then it could not be found, * the done_pside is already set when created and a cache * entry created in processFinished so nothing to do here */ - log_rrset_key(VERB_ALGO, "add parentside glue to dp", + log_rrset_key(VERB_ALGO, "add parentside glue to dp", iq->pside_glue); - if(!delegpt_add_rrset(foriq->dp, forq->region, + if(!delegpt_add_rrset(foriq->dp, forq->region, iq->pside_glue, 1, NULL)) log_err("out of memory adding pside glue"); } @@ -3613,7 +3613,7 @@ processTargetResponse(struct module_qstate* qstate, int id, log_err("out of memory adding cnamed-ns"); } /* if dpns->lame then set the address(es) lame too */ - if(!delegpt_add_rrset(foriq->dp, forq->region, rrset, + if(!delegpt_add_rrset(foriq->dp, forq->region, rrset, dpns->lame, &additions)) log_err("out of memory adding targets"); if(!additions) { @@ -3701,13 +3701,13 @@ processClassResponse(struct module_qstate* qstate, int id, /* allocate the response: copy RCODE, sec_state */ foriq->response = dns_copy_msg(from, forq->region); if(!foriq->response) { - log_err("malloc failed for qclass ANY response"); + log_err("malloc failed for qclass ANY response"); foriq->state = FINISHED_STATE; return; } foriq->response->qinfo.qclass = forq->qinfo.qclass; /* qclass ANY does not receive the AA flag on replies */ - foriq->response->rep->authoritative = 0; + foriq->response->rep->authoritative = 0; } else { struct dns_msg* to = foriq->response; /* add _from_ this response _to_ existing collection */ @@ -3721,13 +3721,13 @@ processClassResponse(struct module_qstate* qstate, int id, /* copy rrsets */ if(from->rep->rrset_count > RR_COUNT_MAX || to->rep->rrset_count > RR_COUNT_MAX) { - log_err("malloc failed (too many rrsets) in collect ANY"); + log_err("malloc failed (too many rrsets) in collect ANY"); foriq->state = FINISHED_STATE; return; /* integer overflow protection */ } dest = regional_alloc(forq->region, sizeof(dest[0])*n); if(!dest) { - log_err("malloc failed in collect ANY"); + log_err("malloc failed in collect ANY"); foriq->state = FINISHED_STATE; return; } @@ -3777,8 +3777,8 @@ processClassResponse(struct module_qstate* qstate, int id, if(foriq->num_current_queries == 0) foriq->state = FINISHED_STATE; } - -/** + +/** * Collect class ANY responses and make them into one response. This * state is started and it creates queries for all classes (that have * root hints). The answers are then collected. @@ -3807,11 +3807,11 @@ processCollectClass(struct module_qstate* qstate, int id) if(!generate_sub_request(qstate->qinfo.qname, qstate->qinfo.qname_len, qstate->qinfo.qtype, c, qstate, id, iq, INIT_REQUEST_STATE, - FINISHED_STATE, &subq, + FINISHED_STATE, &subq, (int)!(qstate->query_flags&BIT_CD), 0)) { errinf(qstate, "could not generate class ANY" " lookup query"); - return error_response(qstate, id, + return error_response(qstate, id, LDNS_RCODE_SERVFAIL); } /* ignore subq, no special init required */ @@ -3832,7 +3832,7 @@ processCollectClass(struct module_qstate* qstate, int id) return 0; } -/** +/** * This handles the final state for first-tier responses (i.e., responses to * externally generated queries). * @@ -3846,7 +3846,7 @@ static int processFinished(struct module_qstate* qstate, struct iter_qstate* iq, int id) { - log_query_info(VERB_QUERY, "finishing processing for", + log_query_info(VERB_QUERY, "finishing processing for", &qstate->qinfo); /* store negative cache element for parent side glue. */ @@ -3861,7 +3861,7 @@ processFinished(struct module_qstate* qstate, struct iter_qstate* iq, return error_response(qstate, id, LDNS_RCODE_SERVFAIL); } - /* Make sure that the RA flag is set (since the presence of + /* Make sure that the RA flag is set (since the presence of * this module means that recursion is available) */ iq->response->rep->flags |= BIT_RA; @@ -3895,7 +3895,7 @@ processFinished(struct module_qstate* qstate, struct iter_qstate* iq, * but only if we did recursion. The nonrecursion referral * from cache does not need to be stored in the msg cache. */ if(!qstate->no_cache_store && qstate->query_flags&BIT_RD) { - iter_dns_store(qstate->env, &qstate->qinfo, + iter_dns_store(qstate->env, &qstate->qinfo, iq->response->rep, 0, qstate->prefetch_leeway, iq->dp&&iq->dp->has_parent_side_NS, qstate->region, qstate->query_flags, @@ -3909,7 +3909,7 @@ processFinished(struct module_qstate* qstate, struct iter_qstate* iq, /* * Return priming query results to interested super querystates. - * + * * Sets the delegation point and delegation message (not nonRD queries). * This is a callback from walk_supers. * @@ -3918,7 +3918,7 @@ processFinished(struct module_qstate* qstate, struct iter_qstate* iq, * @param super: the qstate to inform. */ void -iter_inform_super(struct module_qstate* qstate, int id, +iter_inform_super(struct module_qstate* qstate, int id, struct module_qstate* super) { if(!qstate->is_priming && super->qinfo.qclass == LDNS_RR_CLASS_ANY) @@ -3990,7 +3990,7 @@ iter_handle(struct module_qstate* qstate, struct iter_qstate* iq, } } -/** +/** * This is the primary entry point for processing request events. Note that * this method should only be used by external modules. * @param qstate: query state. @@ -4012,7 +4012,7 @@ process_request(struct module_qstate* qstate, struct iter_qstate* iq, /** process authoritative server reply */ static void -process_response(struct module_qstate* qstate, struct iter_qstate* iq, +process_response(struct module_qstate* qstate, struct iter_qstate* iq, struct iter_env* ie, int id, struct outbound_entry* outbound, enum module_ev event) { @@ -4055,7 +4055,7 @@ process_response(struct module_qstate* qstate, struct iter_qstate* iq, /* parse message */ fill_fail_addr(iq, &qstate->reply->remote_addr, qstate->reply->remote_addrlen); - prs = (struct msg_parse*)regional_alloc(qstate->env->scratch, + prs = (struct msg_parse*)regional_alloc(qstate->env->scratch, sizeof(struct msg_parse)); if(!prs) { log_err("out of memory on incoming message"); @@ -4097,7 +4097,7 @@ process_response(struct module_qstate* qstate, struct iter_qstate* iq, prs->flags &= ~BIT_CD; /* normalize and sanitize: easy to delete items from linked lists */ - if(!scrub_message(pkt, prs, &iq->qinfo_out, iq->dp->name, + if(!scrub_message(pkt, prs, &iq->qinfo_out, iq->dp->name, qstate->env->scratch, qstate->env, ie)) { /* if 0x20 enabled, start fallback, but we have no message */ if(event == module_event_capsfail && !iq->caps_fallback) { @@ -4122,9 +4122,9 @@ process_response(struct module_qstate* qstate, struct iter_qstate* iq, log_name_addr(VERB_DETAIL, "reply from", iq->dp->name, &qstate->reply->remote_addr, qstate->reply->remote_addrlen); if(verbosity >= VERB_ALGO) - log_dns_msg("incoming scrubbed packet:", &iq->response->qinfo, + log_dns_msg("incoming scrubbed packet:", &iq->response->qinfo, iq->response->rep); - + if(event == module_event_capsfail || iq->caps_fallback) { if(qstate->env->cfg->qname_minimisation && iq->minimisation_state != DONOT_MINIMISE_STATE) { @@ -4168,7 +4168,7 @@ process_response(struct module_qstate* qstate, struct iter_qstate* iq, iq->caps_response = iq->response; } else if(!caps_failed_rcode(iq->caps_reply) && caps_failed_rcode(iq->response->rep)) { - /* if we have non-SERVFAIL as answer then + /* if we have non-SERVFAIL as answer then * we can ignore SERVFAILs for the equality * comparison */ /* no instructions here, skip other else */ @@ -4182,7 +4182,7 @@ process_response(struct module_qstate* qstate, struct iter_qstate* iq, "getting different replies, failed"); outbound_list_remove(&iq->outlist, outbound); errinf(qstate, "0x20 failed, then got different replies in fallback"); - (void)error_response(qstate, id, + (void)error_response(qstate, id, LDNS_RCODE_SERVFAIL); return; } @@ -4202,22 +4202,22 @@ handle_it: iter_handle(qstate, iq, ie, id); } -void +void iter_operate(struct module_qstate* qstate, enum module_ev event, int id, struct outbound_entry* outbound) { struct iter_env* ie = (struct iter_env*)qstate->env->modinfo[id]; struct iter_qstate* iq = (struct iter_qstate*)qstate->minfo[id]; - verbose(VERB_QUERY, "iterator[module %d] operate: extstate:%s event:%s", + verbose(VERB_QUERY, "iterator[module %d] operate: extstate:%s event:%s", id, strextstate(qstate->ext_state[id]), strmodulevent(event)); - if(iq) log_query_info(VERB_QUERY, "iterator operate: query", + if(iq) log_query_info(VERB_QUERY, "iterator operate: query", &qstate->qinfo); if(iq && qstate->qinfo.qname != iq->qchase.qname) - log_query_info(VERB_QUERY, "iterator operate: chased to", + log_query_info(VERB_QUERY, "iterator operate: chased to", &iq->qchase); /* perform iterator state machine */ - if((event == module_event_new || event == module_event_pass) && + if((event == module_event_new || event == module_event_pass) && iq == NULL) { if(!iter_new(qstate, id)) { errinf(qstate, "malloc failure, new iterator module allocation"); @@ -4248,7 +4248,7 @@ iter_operate(struct module_qstate* qstate, enum module_ev event, int id, (void)error_response(qstate, id, LDNS_RCODE_SERVFAIL); } -void +void iter_clear(struct module_qstate* qstate, int id) { struct iter_qstate* iq; @@ -4267,7 +4267,7 @@ iter_clear(struct module_qstate* qstate, int id) qstate->minfo[id] = NULL; } -size_t +size_t iter_get_mem(struct module_env* env, int id) { struct iter_env* ie = (struct iter_env*)env->modinfo[id]; @@ -4278,21 +4278,21 @@ iter_get_mem(struct module_env* env, int id) } /** - * The iterator function block + * The iterator function block */ static struct module_func_block iter_block = { "iterator", - &iter_init, &iter_deinit, &iter_operate, &iter_inform_super, + &iter_init, &iter_deinit, &iter_operate, &iter_inform_super, &iter_clear, &iter_get_mem }; -struct module_func_block* +struct module_func_block* iter_get_funcblock(void) { return &iter_block; } -const char* +const char* iter_state_to_string(enum iter_state state) { switch (state) @@ -4320,7 +4320,7 @@ iter_state_to_string(enum iter_state state) } } -int +int iter_state_is_responsestate(enum iter_state s) { switch(s) { diff --git a/sbin/unwind/libunbound/iterator/iterator.h b/sbin/unwind/libunbound/iterator/iterator.h index fad7f03e6..0fe160beb 100644 --- a/sbin/unwind/libunbound/iterator/iterator.h +++ b/sbin/unwind/libunbound/iterator/iterator.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -84,12 +84,12 @@ struct rbtree_type; #define MINIMISE_MULTIPLE_LABS (MAX_MINIMISE_COUNT - MINIMISE_ONE_LAB) /** at what query-sent-count to stop target fetch policy */ #define TARGET_FETCH_STOP 3 -/** how nice is a server without further information, in msec +/** how nice is a server without further information, in msec * Equals rtt initial timeout value. */ extern int UNKNOWN_SERVER_NICENESS; -/** maximum timeout before a host is deemed unsuitable, in msec. - * After host_ttl this will be timed out and the host will be tried again. +/** maximum timeout before a host is deemed unsuitable, in msec. + * After host_ttl this will be timed out and the host will be tried again. * Equals RTT_MAX_TIMEOUT, and thus when RTT_MAX_TIMEOUT is overwritten by * config infra_cache_max_rtt, it will be overwritten as well. */ extern int USEFUL_SERVER_TOP_TIMEOUT; @@ -98,7 +98,7 @@ extern int USEFUL_SERVER_TOP_TIMEOUT; * overwritten by config infra_cache_max_rtt, it will be overwritten as well. */ extern int BLACKLIST_PENALTY; /** RTT band, within this amount from the best, servers are chosen randomly. - * Chosen so that the UNKNOWN_SERVER_NICENESS falls within the band of a + * Chosen so that the UNKNOWN_SERVER_NICENESS falls within the band of a * fast server, this causes server exploration as a side benefit. msec. */ #define RTT_BAND 400 @@ -137,10 +137,10 @@ struct iter_env { int max_dependency_depth; /** - * The target fetch policy for each dependency level. This is - * described as a simple number (per dependency level): - * negative numbers (usually just -1) mean fetch-all, - * 0 means only fetch on demand, and + * The target fetch policy for each dependency level. This is + * described as a simple number (per dependency level): + * negative numbers (usually just -1) mean fetch-all, + * 0 means only fetch on demand, and * positive numbers mean to fetch at most that many targets. * array of max_dependency_depth+1 size. */ @@ -195,27 +195,27 @@ enum iter_state { INIT_REQUEST_STATE = 0, /** - * Root priming events reactivate here, most other events pass + * Root priming events reactivate here, most other events pass * through this naturally as the 2nd part of the INIT_REQUEST_STATE. */ INIT_REQUEST_2_STATE, /** - * Stub priming events reactivate here, most other events pass + * Stub priming events reactivate here, most other events pass * through this naturally as the 3rd part of the INIT_REQUEST_STATE. */ INIT_REQUEST_3_STATE, /** - * Each time a delegation point changes for a given query or a - * query times out and/or wakes up, this state is (re)visited. - * This state is responsible for iterating through a list of + * Each time a delegation point changes for a given query or a + * query times out and/or wakes up, this state is (re)visited. + * This state is responsible for iterating through a list of * nameserver targets. */ QUERYTARGETS_STATE, /** - * Responses to queries start at this state. This state handles + * Responses to queries start at this state. This state handles * the decision tree associated with handling responses. */ QUERY_RESP_STATE, @@ -231,7 +231,7 @@ enum iter_state { * NS spot until we find it */ DSNS_FIND_STATE, - /** Responses that are to be returned upstream end at this state. + /** Responses that are to be returned upstream end at this state. * As well as responses to target queries. */ FINISHED_STATE }; @@ -255,25 +255,25 @@ enum target_count_variables { * Per query state for the iterator module. */ struct iter_qstate { - /** + /** * State of the iterator module. - * This is the state that event is in or should sent to -- all - * requests should start with the INIT_REQUEST_STATE. All - * responses should start with QUERY_RESP_STATE. Subsequent + * This is the state that event is in or should sent to -- all + * requests should start with the INIT_REQUEST_STATE. All + * responses should start with QUERY_RESP_STATE. Subsequent * processing of the event will change this state. */ enum iter_state state; - /** + /** * Final state for the iterator module. - * This is the state that responses should be routed to once the - * response is final. For externally initiated queries, this - * will be FINISHED_STATE, locally initiated queries will have + * This is the state that responses should be routed to once the + * response is final. For externally initiated queries, this + * will be FINISHED_STATE, locally initiated queries will have * different final states. */ enum iter_state final_state; - /** + /** * The depth of this query, this means the depth of recursion. * This address is needed for another query, which is an address * needed for another query, etc. Original client query has depth 0. @@ -285,8 +285,8 @@ struct iter_qstate { */ struct dns_msg* response; - /** - * This is a list of RRsets that must be prepended to the + /** + * This is a list of RRsets that must be prepended to the * ANSWER section of a response before being sent upstream. */ struct iter_prep_list* an_prepend_list; @@ -302,7 +302,7 @@ struct iter_qstate { struct iter_prep_list* ns_prepend_last; /** query name used for chasing the results. Initially the same as - * the state qinfo, but after CNAMEs this will be different. + * the state qinfo, but after CNAMEs this will be different. * The query info used to elicit the results needed. */ struct query_info qchase; /** query flags to use when chasing the answer (i.e. RD flag) */ @@ -310,7 +310,7 @@ struct iter_qstate { /** true if we set RD bit because of last resort recursion lame query*/ int chase_to_rd; - /** + /** * This is the current delegation point for an in-progress query. This * object retains state as to which delegation targets need to be * (sub)queried for vs which ones have already been visited. @@ -343,7 +343,7 @@ struct iter_qstate { /** number of queries fired off */ int sent_count; - + /** malloced-array shared with this query and its subqueries. It keeps * track of the defined enum target_count_variables counters. */ int* target_count; @@ -373,8 +373,8 @@ struct iter_qstate { * The query is for parent-side glue(A or AAAA) for a nameserver. * If the item is seen as glue in a referral, and pside_glue is NULL, * then it is stored in pside_glue for later. - * If it was never seen, at the end, then a negative caching element - * must be created. + * If it was never seen, at the end, then a negative caching element + * must be created. * The (data or negative) RR cache element then throttles retries. */ int query_for_pside_glue; @@ -386,8 +386,8 @@ struct iter_qstate { /** length of the dname in dsns_point */ size_t dsns_point_len; - /** - * expected dnssec information for this iteration step. + /** + * expected dnssec information for this iteration step. * If dnssec rrsigs are expected and not given, the server is marked * lame (dnssec-lame). */ @@ -400,8 +400,8 @@ struct iter_qstate { int dnssec_lame_query; /** - * This is flag that, if true, means that this event is - * waiting for a stub priming query. + * This is flag that, if true, means that this event is + * waiting for a stub priming query. */ int wait_priming_stub; @@ -503,7 +503,7 @@ void iter_operate(struct module_qstate* qstate, enum module_ev event, int id, /** * Return priming query results to interested super querystates. - * + * * Sets the delegation point and delegation message (not nonRD queries). * This is a callback from walk_supers. * @@ -511,7 +511,7 @@ void iter_operate(struct module_qstate* qstate, enum module_ev event, int id, * @param id: module id. * @param super: the qstate to inform. */ -void iter_inform_super(struct module_qstate* qstate, int id, +void iter_inform_super(struct module_qstate* qstate, int id, struct module_qstate* super); /** iterator cleanup query state */ diff --git a/sbin/unwind/libunbound/libunbound/context.c b/sbin/unwind/libunbound/libunbound/context.c index f7c0a2cd5..cd12b2a19 100644 --- a/sbin/unwind/libunbound/libunbound/context.c +++ b/sbin/unwind/libunbound/libunbound/context.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -54,7 +54,7 @@ #include "util/edns.h" #include "sldns/sbuffer.h" -int +int context_finalize(struct ub_ctx* ctx) { int is_rpz = 0; @@ -118,7 +118,7 @@ int context_query_cmp(const void* a, const void* b) } void -context_query_delete(struct ctx_query* q) +context_query_delete(struct ctx_query* q) { if(!q) return; ub_resolve_free(q->res); @@ -143,8 +143,8 @@ find_id(struct ub_ctx* ctx, int* id) return 1; } -struct ctx_query* -context_new(struct ub_ctx* ctx, const char* name, int rrtype, int rrclass, +struct ctx_query* +context_new(struct ub_ctx* ctx, const char* name, int rrtype, int rrclass, ub_callback_type cb, ub_event_callback_type cb_event, void* cbarg) { struct ctx_query* q = (struct ctx_query*)calloc(1, sizeof(*q)); @@ -184,7 +184,7 @@ context_new(struct ub_ctx* ctx, const char* name, int rrtype, int rrclass, return q; } -struct alloc_cache* +struct alloc_cache* context_obtain_alloc(struct ub_ctx* ctx, int locking) { struct alloc_cache* a; @@ -210,7 +210,7 @@ context_obtain_alloc(struct ub_ctx* ctx, int locking) return a; } -void +void context_release_alloc(struct ub_ctx* ctx, struct alloc_cache* alloc, int locking) { @@ -226,7 +226,7 @@ context_release_alloc(struct ub_ctx* ctx, struct alloc_cache* alloc, } } -uint8_t* +uint8_t* context_serialize_new_query(struct ctx_query* q, uint32_t* len) { /* format for new query is @@ -249,7 +249,7 @@ context_serialize_new_query(struct ctx_query* q, uint32_t* len) return p; } -struct ctx_query* +struct ctx_query* context_deserialize_new_query(struct ub_ctx* ctx, uint8_t* p, uint32_t len) { struct ctx_query* q = (struct ctx_query*)calloc(1, sizeof(*q)); @@ -282,7 +282,7 @@ context_deserialize_new_query(struct ub_ctx* ctx, uint8_t* p, uint32_t len) return q; } -struct ctx_query* +struct ctx_query* context_lookup_new_query(struct ub_ctx* ctx, uint8_t* p, uint32_t len) { struct ctx_query* q; @@ -300,7 +300,7 @@ context_lookup_new_query(struct ub_ctx* ctx, uint8_t* p, uint32_t len) return q; } -uint8_t* +uint8_t* context_serialize_answer(struct ctx_query* q, int err, sldns_buffer* pkt, uint32_t* len) { @@ -336,7 +336,7 @@ context_serialize_answer(struct ctx_query* q, int err, sldns_buffer* pkt, return p; } -struct ctx_query* +struct ctx_query* context_deserialize_answer(struct ub_ctx* ctx, uint8_t* p, uint32_t len, int* err) { @@ -348,7 +348,7 @@ context_deserialize_answer(struct ub_ctx* ctx, log_assert( sldns_read_uint32(p) == UB_LIBCMD_ANSWER); id = (int)sldns_read_uint32(p+sizeof(uint32_t)); q = (struct ctx_query*)rbtree_search(&ctx->queries, &id); - if(!q) return NULL; + if(!q) return NULL; *err = (int)sldns_read_uint32(p+2*sizeof(uint32_t)); q->msg_security = sldns_read_uint32(p+3*sizeof(uint32_t)); q->res->was_ratelimited = (int)sldns_read_uint32(p+4*sizeof(uint32_t)); @@ -375,11 +375,11 @@ context_deserialize_answer(struct ub_ctx* ctx, *err = UB_NOMEM; return q; } - } + } return q; } -uint8_t* +uint8_t* context_serialize_cancel(struct ctx_query* q, uint32_t* len) { /* format of cancel: @@ -405,7 +405,7 @@ struct ctx_query* context_deserialize_cancel(struct ub_ctx* ctx, return q; } -uint8_t* +uint8_t* context_serialize_quit(uint32_t* len) { uint32_t* p = (uint32_t*)malloc(sizeof(uint32_t)); diff --git a/sbin/unwind/libunbound/libunbound/context.h b/sbin/unwind/libunbound/libunbound/context.h index c0fc80e57..098ac3556 100644 --- a/sbin/unwind/libunbound/libunbound/context.h +++ b/sbin/unwind/libunbound/libunbound/context.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -76,8 +76,8 @@ struct ub_ctx { /* --- shared data --- */ /** mutex for access to env.cfg, finalized and dothread */ lock_basic_type cfglock; - /** - * The context has been finalized + /** + * The context has been finalized * This is after config when the first resolve is done. * The modules are inited (module-init()) and shared caches created. */ @@ -104,7 +104,7 @@ struct ub_ctx { int logfile_override; /** what logfile to use instead */ FILE* log_out; - /** + /** * List of alloc-cache-id points per threadnum for notinuse threads. * Simply the entire struct alloc_cache with the 'super' member used * to link a simply linked list. Reset super member to the superalloc @@ -135,13 +135,13 @@ struct ub_ctx { int next_querynum; /** number of async queries outstanding */ size_t num_async; - /** - * Tree of outstanding queries. Indexed by querynum + /** + * Tree of outstanding queries. Indexed by querynum * Used when results come in for async to lookup. * Used when cancel is done for lookup (and delete). * Used to see if querynum is free for use. * Content of type ctx_query. - */ + */ rbtree_type queries; }; @@ -201,7 +201,7 @@ enum ub_ctx_cmd { UB_LIBCMD_ANSWER }; -/** +/** * finalize a context. * @param ctx: context to finalize. creates shared data. * @return 0 if OK, or errcode. @@ -211,7 +211,7 @@ int context_finalize(struct ub_ctx* ctx); /** compare two ctx_query elements */ int context_query_cmp(const void* a, const void* b); -/** +/** * delete context query * @param q: query to delete, including message packet and prealloc result */ @@ -269,7 +269,7 @@ uint8_t* context_serialize_new_query(struct ctx_query* q, uint32_t* len); * @param len: the length of the allocation is returned. * @return: an alloc, or NULL on mem error. */ -uint8_t* context_serialize_answer(struct ctx_query* q, int err, +uint8_t* context_serialize_answer(struct ctx_query* q, int err, struct sldns_buffer* pkt, uint32_t* len); /** @@ -303,7 +303,7 @@ enum ub_ctx_cmd context_serial_getcmd(uint8_t* p, uint32_t len); * @param len: length of buffer. * @return looked up ctx_query or NULL for malloc failure. */ -struct ctx_query* context_lookup_new_query(struct ub_ctx* ctx, +struct ctx_query* context_lookup_new_query(struct ub_ctx* ctx, uint8_t* p, uint32_t len); /** @@ -313,7 +313,7 @@ struct ctx_query* context_lookup_new_query(struct ub_ctx* ctx, * @param len: length of buffer. * @return new ctx_query or NULL for malloc failure. */ -struct ctx_query* context_deserialize_new_query(struct ub_ctx* ctx, +struct ctx_query* context_deserialize_new_query(struct ub_ctx* ctx, uint8_t* p, uint32_t len); /** @@ -324,7 +324,7 @@ struct ctx_query* context_deserialize_new_query(struct ub_ctx* ctx, * @param err: error code to be returned to client is passed. * @return ctx_query with answer added or NULL for malloc failure. */ -struct ctx_query* context_deserialize_answer(struct ub_ctx* ctx, +struct ctx_query* context_deserialize_answer(struct ub_ctx* ctx, uint8_t* p, uint32_t len, int* err); /** @@ -334,7 +334,7 @@ struct ctx_query* context_deserialize_answer(struct ub_ctx* ctx, * @param len: length of buffer. * @return ctx_query to cancel or NULL for failure. */ -struct ctx_query* context_deserialize_cancel(struct ub_ctx* ctx, +struct ctx_query* context_deserialize_cancel(struct ub_ctx* ctx, uint8_t* p, uint32_t len); #endif /* LIBUNBOUND_CONTEXT_H */ diff --git a/sbin/unwind/libunbound/libunbound/libunbound.c b/sbin/unwind/libunbound/libunbound/libunbound.c index 80a82bb47..389d02a85 100644 --- a/sbin/unwind/libunbound/libunbound/libunbound.c +++ b/sbin/unwind/libunbound/libunbound/libunbound.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -36,7 +36,7 @@ /** * \file * - * This file contains functions to resolve DNS queries and + * This file contains functions to resolve DNS queries and * validate the answers. Synchronously and asynchronously. * */ @@ -92,7 +92,7 @@ static struct ub_ctx* ub_ctx_create_nopipe(void) int r; WSADATA wsa_data; #endif - + checklock_start(); if(!ctx_logfile_overridden) log_init(NULL, 0, NULL); /* logs to stderr */ @@ -175,7 +175,7 @@ static struct ub_ctx* ub_ctx_create_nopipe(void) return ctx; } -struct ub_ctx* +struct ub_ctx* ub_ctx_create(void) { struct ub_ctx* ctx = ub_ctx_create_nopipe(); @@ -211,7 +211,7 @@ ub_ctx_create(void) return ctx; } -struct ub_ctx* +struct ub_ctx* ub_ctx_create_ub_event(struct ub_event_base* ueb) { struct ub_ctx* ctx = ub_ctx_create_nopipe(); @@ -225,7 +225,7 @@ ub_ctx_create_ub_event(struct ub_event_base* ueb) return ctx; } -struct ub_ctx* +struct ub_ctx* ub_ctx_create_event(struct event_base* eb) { struct ub_ctx* ctx = ub_ctx_create_nopipe(); @@ -243,7 +243,7 @@ ub_ctx_create_event(struct event_base* eb) ctx->event_base_malloced = 1; return ctx; } - + /** delete q */ static void delq(rbnode_type* n, void* ATTR_UNUSED(arg)) @@ -263,7 +263,7 @@ static void ub_stop_bg(struct ub_ctx* ctx) uint32_t cmd = UB_LIBCMD_QUIT; lock_basic_unlock(&ctx->cfglock); lock_basic_lock(&ctx->qqpipe_lock); - (void)tube_write_msg(ctx->qq_pipe, (uint8_t*)&cmd, + (void)tube_write_msg(ctx->qq_pipe, (uint8_t*)&cmd, (uint32_t)sizeof(cmd), 0); lock_basic_unlock(&ctx->qqpipe_lock); lock_basic_lock(&ctx->rrpipe_lock); @@ -298,7 +298,7 @@ static void ub_stop_bg(struct ub_ctx* ctx) } } -void +void ub_ctx_delete(struct ub_ctx* ctx) { struct alloc_cache* a, *na; @@ -398,7 +398,7 @@ ub_ctx_delete(struct ub_ctx* ctx) #endif } -int +int ub_ctx_set_option(struct ub_ctx* ctx, const char* opt, const char* val) { lock_basic_lock(&ctx->cfglock); @@ -427,7 +427,7 @@ ub_ctx_get_option(struct ub_ctx* ctx, const char* opt, char** str) return r; } -int +int ub_ctx_config(struct ub_ctx* ctx, const char* fname) { lock_basic_lock(&ctx->cfglock); @@ -443,7 +443,7 @@ ub_ctx_config(struct ub_ctx* ctx, const char* fname) return UB_NOERROR; } -int +int ub_ctx_add_ta(struct ub_ctx* ctx, const char* ta) { char* dup = strdup(ta); @@ -462,7 +462,7 @@ ub_ctx_add_ta(struct ub_ctx* ctx, const char* ta) return UB_NOERROR; } -int +int ub_ctx_add_ta_file(struct ub_ctx* ctx, const char* fname) { char* dup = strdup(fname); @@ -500,7 +500,7 @@ int ub_ctx_add_ta_autr(struct ub_ctx* ctx, const char* fname) return UB_NOERROR; } -int +int ub_ctx_trustedkeys(struct ub_ctx* ctx, const char* fname) { char* dup = strdup(fname); @@ -540,7 +540,7 @@ int ub_ctx_debugout(struct ub_ctx* ctx, void* out) return UB_NOERROR; } -int +int ub_ctx_async(struct ub_ctx* ctx, int dothread) { #ifdef THREADS_DISABLED @@ -557,14 +557,14 @@ ub_ctx_async(struct ub_ctx* ctx, int dothread) return UB_NOERROR; } -int +int ub_poll(struct ub_ctx* ctx) { /* no need to hold lock while testing for readability. */ return tube_poll(ctx->rr_pipe); } -int +int ub_fd(struct ub_ctx* ctx) { return tube_read_fd(ctx->rr_pipe); @@ -655,7 +655,7 @@ process_answer(struct ub_ctx* ctx, uint8_t* msg, uint32_t len) return r; } -int +int ub_process(struct ub_ctx* ctx) { int r; @@ -679,7 +679,7 @@ ub_process(struct ub_ctx* ctx) return UB_NOERROR; } -int +int ub_wait(struct ub_ctx* ctx) { int err; @@ -718,7 +718,7 @@ ub_wait(struct ub_ctx* ctx) lock_basic_unlock(&ctx->rrpipe_lock); continue; } - r = process_answer_detail(ctx, msg, len, + r = process_answer_detail(ctx, msg, len, &cb, &cbarg, &err, &res); lock_basic_unlock(&ctx->rrpipe_lock); free(msg); @@ -733,8 +733,8 @@ ub_wait(struct ub_ctx* ctx) return UB_NOERROR; } -int -ub_resolve(struct ub_ctx* ctx, const char* name, int rrtype, +int +ub_resolve(struct ub_ctx* ctx, const char* name, int rrtype, int rrclass, struct ub_result** result) { struct ctx_query* q; @@ -777,8 +777,8 @@ ub_resolve(struct ub_ctx* ctx, const char* name, int rrtype, return UB_NOERROR; } -int -ub_resolve_event(struct ub_ctx* ctx, const char* name, int rrtype, +int +ub_resolve_event(struct ub_ctx* ctx, const char* name, int rrtype, int rrclass, void* mydata, ub_event_callback_type callback, int* async_id) { @@ -819,8 +819,8 @@ ub_resolve_event(struct ub_ctx* ctx, const char* name, int rrtype, } -int -ub_resolve_async(struct ub_ctx* ctx, const char* name, int rrtype, +int +ub_resolve_async(struct ub_ctx* ctx, const char* name, int rrtype, int rrclass, void* mydata, ub_callback_type callback, int* async_id) { struct ctx_query* q; @@ -870,7 +870,7 @@ ub_resolve_async(struct ub_ctx* ctx, const char* name, int rrtype, if(async_id) *async_id = q->querynum; lock_basic_unlock(&ctx->cfglock); - + lock_basic_lock(&ctx->qqpipe_lock); if(!tube_write_msg(ctx->qq_pipe, msg, len, 0)) { lock_basic_unlock(&ctx->qqpipe_lock); @@ -882,7 +882,7 @@ ub_resolve_async(struct ub_ctx* ctx, const char* name, int rrtype, return UB_NOERROR; } -int +int ub_cancel(struct ub_ctx* ctx, int async_id) { struct ctx_query* q; @@ -897,7 +897,7 @@ ub_cancel(struct ub_ctx* ctx, int async_id) } log_assert(q->async); q->cancelled = 1; - + /* delete it */ if(!ctx->dothread) { /* if forked */ (void)rbtree_delete(&ctx->queries, q->node.key); @@ -923,7 +923,7 @@ ub_cancel(struct ub_ctx* ctx, int async_id) return UB_NOERROR; } -void +void ub_resolve_free(struct ub_result* result) { char** p; @@ -941,7 +941,7 @@ ub_resolve_free(struct ub_result* result) free(result); } -const char* +const char* ub_strerror(int err) { switch(err) { @@ -960,7 +960,7 @@ ub_strerror(int err) } } -int +int ub_ctx_set_fwd(struct ub_ctx* ctx, const char* addr) { struct sockaddr_storage storage; @@ -992,7 +992,7 @@ ub_ctx_set_fwd(struct ub_ctx* ctx, const char* addr) errno=EINVAL; return UB_SYNTAX; } - + /* it parses, add root stub in front of list */ lock_basic_lock(&ctx->cfglock); if(!ctx->env->cfg->forwards || @@ -1125,7 +1125,7 @@ int ub_ctx_set_stub(struct ub_ctx* ctx, const char* zone, const char* addr, return UB_NOERROR; } -int +int ub_ctx_resolvconf(struct ub_ctx* ctx, const char* fname) { FILE* in; @@ -1143,7 +1143,7 @@ ub_ctx_resolvconf(struct ub_ctx* ctx, const char* fname) IP_ADDR_STRING *ptr; info = (FIXED_INFO *) malloc(sizeof (FIXED_INFO)); - if (info == NULL) + if (info == NULL) return UB_READFILE; if (GetNetworkParams(info, &buflen) == ERROR_BUFFER_OVERFLOW) { @@ -1158,7 +1158,7 @@ ub_ctx_resolvconf(struct ub_ctx* ctx, const char* fname) ptr = &(info->DnsServerList); while (ptr) { numserv++; - if((retval=ub_ctx_set_fwd(ctx, + if((retval=ub_ctx_set_fwd(ctx, ptr->IpAddress.String))!=0) { free(info); return retval; @@ -1196,7 +1196,7 @@ ub_ctx_resolvconf(struct ub_ctx* ctx, const char* fname) parse++; /* terminate after the address, remove newline */ *parse = 0; - + if((r = ub_ctx_set_fwd(ctx, addr)) != UB_NOERROR) { fclose(in); return r; @@ -1234,10 +1234,10 @@ ub_ctx_hosts(struct ub_ctx* ctx, const char* fname) name = getenv("WINDIR"); if (name != NULL) { int retval=0; - snprintf(buf, sizeof(buf), "%s%s", name, + snprintf(buf, sizeof(buf), "%s%s", name, "\\system32\\drivers\\etc\\hosts"); if((retval=ub_ctx_hosts(ctx, buf)) !=0 ) { - snprintf(buf, sizeof(buf), "%s%s", name, + snprintf(buf, sizeof(buf), "%s%s", name, "\\hosts"); retval=ub_ctx_hosts(ctx, buf); } @@ -1269,7 +1269,7 @@ ub_ctx_hosts(struct ub_ctx* ctx, const char* fname) parse++; if(*parse == '\n' || *parse == 0) continue; - if(*parse == '%') + if(*parse == '%') continue; /* ignore macOSX fe80::1%lo0 localhost */ if(*parse != ' ' && *parse != '\t') { /* must have whitespace after address */ @@ -1301,7 +1301,7 @@ ub_ctx_hosts(struct ub_ctx* ctx, const char* fname) return UB_NOMEM; } lock_basic_lock(&ctx->cfglock); - if(!cfg_strlist_insert(&ctx->env->cfg->local_data, + if(!cfg_strlist_insert(&ctx->env->cfg->local_data, ins)) { lock_basic_unlock(&ctx->cfglock); fclose(in); @@ -1329,7 +1329,7 @@ static int ub_ctx_finalize(struct ub_ctx* ctx) /* Print local zones and RR data */ int ub_ctx_print_local_zones(struct ub_ctx* ctx) -{ +{ int res = ub_ctx_finalize(ctx); if (res) return res; @@ -1339,7 +1339,7 @@ int ub_ctx_print_local_zones(struct ub_ctx* ctx) } /* Add a new zone */ -int ub_ctx_zone_add(struct ub_ctx* ctx, const char *zone_name, +int ub_ctx_zone_add(struct ub_ctx* ctx, const char *zone_name, const char *zone_type) { enum localzone_type t; @@ -1360,7 +1360,7 @@ int ub_ctx_zone_add(struct ub_ctx* ctx, const char *zone_name, } lock_rw_wrlock(&ctx->local_zones->lock); - if((z=local_zones_find(ctx->local_zones, nm, nmlen, nmlabs, + if((z=local_zones_find(ctx->local_zones, nm, nmlen, nmlabs, LDNS_RR_CLASS_IN))) { /* already present in tree */ lock_rw_wrlock(&z->lock); @@ -1370,7 +1370,7 @@ int ub_ctx_zone_add(struct ub_ctx* ctx, const char *zone_name, free(nm); return UB_NOERROR; } - if(!local_zones_add_zone(ctx->local_zones, nm, nmlen, nmlabs, + if(!local_zones_add_zone(ctx->local_zones, nm, nmlen, nmlabs, LDNS_RR_CLASS_IN, t)) { lock_rw_unlock(&ctx->local_zones->lock); return UB_NOMEM; @@ -1381,7 +1381,7 @@ int ub_ctx_zone_add(struct ub_ctx* ctx, const char *zone_name, /* Remove zone */ int ub_ctx_zone_remove(struct ub_ctx* ctx, const char *zone_name) -{ +{ struct local_zone* z; uint8_t* nm; int nmlabs; @@ -1395,7 +1395,7 @@ int ub_ctx_zone_remove(struct ub_ctx* ctx, const char *zone_name) } lock_rw_wrlock(&ctx->local_zones->lock); - if((z=local_zones_find(ctx->local_zones, nm, nmlen, nmlabs, + if((z=local_zones_find(ctx->local_zones, nm, nmlen, nmlabs, LDNS_RR_CLASS_IN))) { /* present in tree */ local_zones_del_zone(ctx->local_zones, z); @@ -1424,10 +1424,10 @@ int ub_ctx_data_remove(struct ub_ctx* ctx, const char *data) int res = ub_ctx_finalize(ctx); if (res) return res; - if(!parse_dname(data, &nm, &nmlen, &nmlabs)) + if(!parse_dname(data, &nm, &nmlen, &nmlabs)) return UB_SYNTAX; - local_zones_del_data(ctx->local_zones, nm, nmlen, nmlabs, + local_zones_del_data(ctx->local_zones, nm, nmlen, nmlabs, LDNS_RR_CLASS_IN); free(nm); @@ -1439,7 +1439,7 @@ const char* ub_version(void) return PACKAGE_VERSION; } -int +int ub_ctx_set_event(struct ub_ctx* ctx, struct event_base* base) { struct ub_event_base* new_base; @@ -1450,14 +1450,14 @@ ub_ctx_set_event(struct ub_ctx* ctx, struct event_base* base) { /* already set */ return UB_NOERROR; } - + lock_basic_lock(&ctx->cfglock); /* destroy the current worker - safe to pass in NULL */ libworker_delete_event(ctx->event_worker); ctx->event_worker = NULL; new_base = ub_libevent_event_base(base); if (new_base) - ctx->event_base = new_base; + ctx->event_base = new_base; ctx->created_bg = 0; ctx->dothread = 1; lock_basic_unlock(&ctx->cfglock); diff --git a/sbin/unwind/libunbound/libunbound/libworker.c b/sbin/unwind/libunbound/libunbound/libworker.c index 104244937..1b0f2f1f1 100644 --- a/sbin/unwind/libunbound/libunbound/libworker.c +++ b/sbin/unwind/libunbound/libunbound/libworker.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -95,7 +95,7 @@ libworker_delete_env(struct libworker* w) if(w->env) { outside_network_quit_prepare(w->back); mesh_delete(w->env->mesh); - context_release_alloc(w->ctx, w->env->alloc, + context_release_alloc(w->ctx, w->env->alloc, !w->is_bg || w->is_bg_thread); sldns_buffer_free(w->env->scratch_buffer); regional_destroy(w->env->scratch); @@ -159,12 +159,12 @@ libworker_setup(struct ub_ctx* ctx, int is_bg, struct ub_event_base* eb) w->env->scratch = regional_create_custom(cfg->msg_buffer_size); w->env->scratch_buffer = sldns_buffer_new(cfg->msg_buffer_size); w->env->fwds = forwards_create(); - if(w->env->fwds && !forwards_apply_cfg(w->env->fwds, cfg)) { + if(w->env->fwds && !forwards_apply_cfg(w->env->fwds, cfg)) { forwards_delete(w->env->fwds); w->env->fwds = NULL; } w->env->hints = hints_create(); - if(w->env->hints && !hints_apply_cfg(w->env->hints, cfg)) { + if(w->env->hints && !hints_apply_cfg(w->env->hints, cfg)) { hints_delete(w->env->hints); w->env->hints = NULL; } @@ -233,7 +233,7 @@ libworker_setup(struct ub_ctx* ctx, int is_bg, struct ub_event_base* eb) } w->back = outside_network_create(w->base, cfg->msg_buffer_size, (size_t)cfg->outgoing_num_ports, cfg->out_ifs, - cfg->num_out_ifs, cfg->do_ip4, cfg->do_ip6, + cfg->num_out_ifs, cfg->do_ip4, cfg->do_ip6, cfg->do_tcp?cfg->outgoing_num_tcp:0, cfg->ip_dscp, w->env->infra_cache, w->env->rnd, cfg->use_caps_bits_for_id, ports, numports, cfg->unwanted_threshold, @@ -300,7 +300,7 @@ libworker_do_cmd(struct libworker* w, uint8_t* msg, uint32_t len) switch(context_serial_getcmd(msg, len)) { default: case UB_LIBCMD_ANSWER: - log_err("unknown command for bg worker %d", + log_err("unknown command for bg worker %d", (int)context_serial_getcmd(msg, len)); /* and fall through to quit */ /* fallthrough */ @@ -318,8 +318,8 @@ libworker_do_cmd(struct libworker* w, uint8_t* msg, uint32_t len) } /** handle control command coming into server */ -void -libworker_handle_control_cmd(struct tube* ATTR_UNUSED(tube), +void +libworker_handle_control_cmd(struct tube* ATTR_UNUSED(tube), uint8_t* msg, size_t len, int err, void* arg) { struct libworker* w = (struct libworker*)arg; @@ -354,7 +354,7 @@ libworker_dobg(void* arg) tube_close_write(ctx->qq_pipe); tube_close_read(ctx->rr_pipe); #endif - if(!tube_setup_bg_listen(ctx->qq_pipe, w->base, + if(!tube_setup_bg_listen(ctx->qq_pipe, w->base, libworker_handle_control_cmd, w)) { log_err("libunbound bg worker init failed, no bglisten"); return NULL; @@ -373,7 +373,7 @@ libworker_dobg(void* arg) tube_remove_bg_listen(w->ctx->qq_pipe); tube_remove_bg_write(w->ctx->rr_pipe); libworker_delete(w); - (void)tube_write_msg(ctx->rr_pipe, (uint8_t*)&m, + (void)tube_write_msg(ctx->rr_pipe, (uint8_t*)&m, (uint32_t)sizeof(m), 0); #ifdef THREADS_DISABLED /* close pipes from forked process before exit */ @@ -424,7 +424,7 @@ int libworker_bg(struct ub_ctx* ctx) tube_close_write(ctx->rr_pipe); break; } -#endif /* HAVE_FORK */ +#endif /* HAVE_FORK */ } return UB_NOERROR; } @@ -529,7 +529,7 @@ libworker_enter_result(struct ub_result* res, sldns_buffer* buf, log_err("cannot parse buf"); return; /* error parsing buf, or out of memory */ } - if(!fill_res(res, reply_find_answer_rrset(&rq, rep), + if(!fill_res(res, reply_find_answer_rrset(&rq, rep), reply_find_final_cname_target(&rq, rep), &rq, rep)) return; /* out of memory */ /* rcode, havedata, nxdomain, secure, bogus */ @@ -547,7 +547,7 @@ libworker_enter_result(struct ub_result* res, sldns_buffer* buf, /** fillup fg results */ static void -libworker_fillup_fg(struct ctx_query* q, int rcode, sldns_buffer* buf, +libworker_fillup_fg(struct ctx_query* q, int rcode, sldns_buffer* buf, enum sec_status s, char* why_bogus, int was_ratelimited) { q->res->was_ratelimited = was_ratelimited; @@ -585,7 +585,7 @@ libworker_fg_done_cb(void* arg, int rcode, sldns_buffer* buf, enum sec_status s, /** setup qinfo and edns */ static int -setup_qinfo_edns(struct libworker* w, struct ctx_query* q, +setup_qinfo_edns(struct libworker* w, struct ctx_query* q, struct query_info* qinfo, struct edns_data* edns) { qinfo->qtype = (uint16_t)q->res->qtype; @@ -630,11 +630,11 @@ int libworker_fg(struct ub_ctx* ctx, struct ctx_query* q) /* see if there is a fixed answer */ sldns_buffer_write_u16_at(w->back->udp_buff, 0, qid); sldns_buffer_write_u16_at(w->back->udp_buff, 2, qflags); - if(local_zones_answer(ctx->local_zones, w->env, &qinfo, &edns, + if(local_zones_answer(ctx->local_zones, w->env, &qinfo, &edns, w->back->udp_buff, w->env->scratch, NULL, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL)) { regional_free_all(w->env->scratch); - libworker_fillup_fg(q, LDNS_RCODE_NOERROR, + libworker_fillup_fg(q, LDNS_RCODE_NOERROR, w->back->udp_buff, sec_status_insecure, NULL, 0); libworker_delete(w); free(qinfo.qname); @@ -643,14 +643,14 @@ int libworker_fg(struct ub_ctx* ctx, struct ctx_query* q) if(ctx->env->auth_zones && auth_zones_answer(ctx->env->auth_zones, w->env, &qinfo, &edns, NULL, w->back->udp_buff, w->env->scratch)) { regional_free_all(w->env->scratch); - libworker_fillup_fg(q, LDNS_RCODE_NOERROR, + libworker_fillup_fg(q, LDNS_RCODE_NOERROR, w->back->udp_buff, sec_status_insecure, NULL, 0); libworker_delete(w); free(qinfo.qname); return UB_NOERROR; } /* process new query */ - if(!mesh_new_callback(w->env->mesh, &qinfo, qflags, &edns, + if(!mesh_new_callback(w->env->mesh, &qinfo, qflags, &edns, w->back->udp_buff, qid, libworker_fg_done_cb, q, 0)) { free(qinfo.qname); return UB_NOMEM; @@ -710,7 +710,7 @@ int libworker_attach_mesh(struct ub_ctx* ctx, struct ctx_query* q, /* see if there is a fixed answer */ sldns_buffer_write_u16_at(w->back->udp_buff, 0, qid); sldns_buffer_write_u16_at(w->back->udp_buff, 2, qflags); - if(local_zones_answer(ctx->local_zones, w->env, &qinfo, &edns, + if(local_zones_answer(ctx->local_zones, w->env, &qinfo, &edns, w->back->udp_buff, w->env->scratch, NULL, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL)) { regional_free_all(w->env->scratch); @@ -730,7 +730,7 @@ int libworker_attach_mesh(struct ub_ctx* ctx, struct ctx_query* q, /* process new query */ if(async_id) *async_id = q->querynum; - if(!mesh_new_callback(w->env->mesh, &qinfo, qflags, &edns, + if(!mesh_new_callback(w->env->mesh, &qinfo, qflags, &edns, w->back->udp_buff, qid, libworker_event_done_cb, q, 0)) { free(qinfo.qname); return UB_NOMEM; @@ -741,7 +741,7 @@ int libworker_attach_mesh(struct ub_ctx* ctx, struct ctx_query* q, /** add result to the bg worker result queue */ static void -add_bg_result(struct libworker* w, struct ctx_query* q, sldns_buffer* pkt, +add_bg_result(struct libworker* w, struct ctx_query* q, sldns_buffer* pkt, int err, char* reason, int was_ratelimited) { uint8_t* msg = NULL; @@ -848,7 +848,7 @@ handle_newq(struct libworker* w, uint8_t* buf, uint32_t len) /* see if there is a fixed answer */ sldns_buffer_write_u16_at(w->back->udp_buff, 0, qid); sldns_buffer_write_u16_at(w->back->udp_buff, 2, qflags); - if(local_zones_answer(w->ctx->local_zones, w->env, &qinfo, &edns, + if(local_zones_answer(w->ctx->local_zones, w->env, &qinfo, &edns, w->back->udp_buff, w->env->scratch, NULL, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL)) { regional_free_all(w->env->scratch); @@ -867,7 +867,7 @@ handle_newq(struct libworker* w, uint8_t* buf, uint32_t len) } q->w = w; /* process new query */ - if(!mesh_new_callback(w->env->mesh, &qinfo, qflags, &edns, + if(!mesh_new_callback(w->env->mesh, &qinfo, qflags, &edns, w->back->udp_buff, qid, libworker_bg_done_cb, q, 0)) { add_bg_result(w, q, NULL, UB_NOMEM, NULL, 0); } @@ -905,7 +905,7 @@ struct outbound_entry* libworker_send_query(struct query_info* qinfo, return e; } -int +int libworker_handle_service_reply(struct comm_point* c, void* arg, int error, struct comm_reply* reply_info) { @@ -923,7 +923,7 @@ libworker_handle_service_reply(struct comm_point* c, void* arg, int error, || LDNS_QDCOUNT(sldns_buffer_begin(c->buffer)) > 1) { /* error becomes timeout for the module as if this reply * never arrived. */ - mesh_report_reply(lw->env->mesh, e, reply_info, + mesh_report_reply(lw->env->mesh, e, reply_info, NETEVENT_TIMEOUT); return 0; } @@ -932,14 +932,14 @@ libworker_handle_service_reply(struct comm_point* c, void* arg, int error, } /* --- fake callbacks for fptr_wlist to work --- */ -void worker_handle_control_cmd(struct tube* ATTR_UNUSED(tube), +void worker_handle_control_cmd(struct tube* ATTR_UNUSED(tube), uint8_t* ATTR_UNUSED(buffer), size_t ATTR_UNUSED(len), int ATTR_UNUSED(error), void* ATTR_UNUSED(arg)) { log_assert(0); } -int worker_handle_request(struct comm_point* ATTR_UNUSED(c), +int worker_handle_request(struct comm_point* ATTR_UNUSED(c), void* ATTR_UNUSED(arg), int ATTR_UNUSED(error), struct comm_reply* ATTR_UNUSED(repinfo)) { @@ -947,7 +947,7 @@ int worker_handle_request(struct comm_point* ATTR_UNUSED(c), return 0; } -int worker_handle_service_reply(struct comm_point* ATTR_UNUSED(c), +int worker_handle_service_reply(struct comm_point* ATTR_UNUSED(c), void* ATTR_UNUSED(arg), int ATTR_UNUSED(error), struct comm_reply* ATTR_UNUSED(reply_info)) { @@ -955,7 +955,7 @@ int worker_handle_service_reply(struct comm_point* ATTR_UNUSED(c), return 0; } -int remote_accept_callback(struct comm_point* ATTR_UNUSED(c), +int remote_accept_callback(struct comm_point* ATTR_UNUSED(c), void* ATTR_UNUSED(arg), int ATTR_UNUSED(error), struct comm_reply* ATTR_UNUSED(repinfo)) { @@ -963,7 +963,7 @@ int remote_accept_callback(struct comm_point* ATTR_UNUSED(c), return 0; } -int remote_control_callback(struct comm_point* ATTR_UNUSED(c), +int remote_control_callback(struct comm_point* ATTR_UNUSED(c), void* ATTR_UNUSED(arg), int ATTR_UNUSED(error), struct comm_reply* ATTR_UNUSED(repinfo)) { @@ -989,7 +989,7 @@ struct outbound_entry* worker_send_query(struct query_info* ATTR_UNUSED(qinfo), return 0; } -void +void worker_alloc_cleanup(void* ATTR_UNUSED(arg)) { log_assert(0); @@ -1041,7 +1041,7 @@ void remote_get_opt_ssl(char* ATTR_UNUSED(str), void* ATTR_UNUSED(arg)) #ifdef UB_ON_WINDOWS void -worker_win_stop_cb(int ATTR_UNUSED(fd), short ATTR_UNUSED(ev), void* +worker_win_stop_cb(int ATTR_UNUSED(fd), short ATTR_UNUSED(ev), void* ATTR_UNUSED(arg)) { log_assert(0); } diff --git a/sbin/unwind/libunbound/libunbound/libworker.h b/sbin/unwind/libunbound/libunbound/libworker.h index 42aa5bae3..0a93a1b01 100644 --- a/sbin/unwind/libunbound/libunbound/libworker.h +++ b/sbin/unwind/libunbound/libunbound/libworker.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -61,7 +61,7 @@ struct sldns_buffer; struct ub_event_base; struct query_info; -/** +/** * The library-worker status structure * Internal to the worker. */ @@ -96,7 +96,7 @@ struct libworker { * a new allocation cache is obtained from ctx. It contains the * threadnumber and unique id for further (shared) cache insertions. * @return 0 if OK, else error. - * Further communication is done via the pipes in ctx. + * Further communication is done via the pipes in ctx. */ int libworker_bg(struct ub_ctx* ctx); @@ -130,7 +130,7 @@ struct libworker* libworker_create_event(struct ub_ctx* ctx, int libworker_attach_mesh(struct ub_ctx* ctx, struct ctx_query* q, int* async_id); -/** +/** * delete worker for event-based interface. does not free the event_base. * @param w: event-based worker to delete. */ @@ -139,13 +139,13 @@ void libworker_delete_event(struct libworker* w); /** cleanup the cache to remove all rrset IDs from it, arg is libworker */ void libworker_alloc_cleanup(void* arg); -/** - * fill result from parsed message, on error fills servfail +/** + * fill result from parsed message, on error fills servfail * @param res: is clear at start, filled in at end. * @param buf: contains DNS message. * @param temp: temporary buffer for parse. * @param msg_security: security status of the DNS message. - * On error, the res may contain a different status + * On error, the res may contain a different status * (out of memory is not secure, not bogus). */ void libworker_enter_result(struct ub_result* res, struct sldns_buffer* buf, diff --git a/sbin/unwind/libunbound/libunbound/unbound-event.h b/sbin/unwind/libunbound/libunbound/unbound-event.h index 5ca81908a..97e573f63 100644 --- a/sbin/unwind/libunbound/libunbound/unbound-event.h +++ b/sbin/unwind/libunbound/libunbound/unbound-event.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -126,10 +126,10 @@ struct ub_event_vmt { /** Add event bits for this event to fire on. * The event will be deactivated before this function is called. */ void (*add_bits)(struct ub_event*, short); - /** Configure the event so it will not longer fire on given bits + /** Configure the event so it will not longer fire on given bits * The event will be deactivated before this function is called. */ void (*del_bits)(struct ub_event*, short); - /** Change or set the file descriptor on the event + /** Change or set the file descriptor on the event * The event will be deactivated before this function is called. */ void (*set_fd)(struct ub_event*, int); /** Destructor for the ub_event object */ @@ -213,7 +213,7 @@ struct ub_ctx* ub_ctx_create_event(struct event_base* base); * @param base the new event_base to attach to the ctx * @return 0 if OK, else error */ -int ub_ctx_set_event(struct ub_ctx* ctx, struct event_base* base); +int ub_ctx_set_event(struct ub_ctx* ctx, struct event_base* base); /** * Perform resolution and validation of the target name. @@ -250,11 +250,11 @@ int ub_ctx_set_event(struct ub_ctx* ctx, struct event_base* base); * For localdata (etc/hosts) the callback is called immediately, before * resolve_event returns, async_id=0 is returned. * @param async_id: if you pass a non-NULL value, an identifier number is - * returned for the query as it is in progress. It can be used to + * returned for the query as it is in progress. It can be used to * cancel the query. * @return 0 if OK, else error. */ -int ub_resolve_event(struct ub_ctx* ctx, const char* name, int rrtype, +int ub_resolve_event(struct ub_ctx* ctx, const char* name, int rrtype, int rrclass, void* mydata, ub_event_callback_type callback, int* async_id); diff --git a/sbin/unwind/libunbound/libunbound/worker.h b/sbin/unwind/libunbound/libunbound/worker.h index 0fa5bfa99..244b588db 100644 --- a/sbin/unwind/libunbound/libunbound/worker.h +++ b/sbin/unwind/libunbound/libunbound/worker.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -89,15 +89,15 @@ void libworker_handle_control_cmd(struct tube* tube, uint8_t* msg, size_t len, int err, void* arg); /** mesh callback with fg results */ -void libworker_fg_done_cb(void* arg, int rcode, sldns_buffer* buf, +void libworker_fg_done_cb(void* arg, int rcode, sldns_buffer* buf, enum sec_status s, char* why_bogus, int was_ratelimited); /** mesh callback with bg results */ -void libworker_bg_done_cb(void* arg, int rcode, sldns_buffer* buf, +void libworker_bg_done_cb(void* arg, int rcode, sldns_buffer* buf, enum sec_status s, char* why_bogus, int was_ratelimited); /** mesh callback with event results */ -void libworker_event_done_cb(void* arg, int rcode, struct sldns_buffer* buf, +void libworker_event_done_cb(void* arg, int rcode, struct sldns_buffer* buf, enum sec_status s, char* why_bogus, int was_ratelimited); /** @@ -136,8 +136,8 @@ struct outbound_entry* worker_send_query(struct query_info* qinfo, size_t zonelen, int tcp_upstream, int ssl_upstream, char* tls_auth_name, struct module_qstate* q, int* was_ratelimited); -/** - * process control messages from the main thread. Frees the control +/** + * process control messages from the main thread. Frees the control * command message. * @param tube: tube control message came on. * @param msg: message contents. Is freed. @@ -153,7 +153,7 @@ int worker_handle_request(struct comm_point* c, void* arg, int error, struct comm_reply* repinfo); /** process incoming serviced query replies from the network */ -int worker_handle_service_reply(struct comm_point* c, void* arg, int error, +int worker_handle_service_reply(struct comm_point* c, void* arg, int error, struct comm_reply* reply_info); /** cleanup the cache to remove all rrset IDs from it, arg is worker */ diff --git a/sbin/unwind/libunbound/respip/respip.c b/sbin/unwind/libunbound/respip/respip.c index 942e082b9..2613e80bf 100644 --- a/sbin/unwind/libunbound/respip/respip.c +++ b/sbin/unwind/libunbound/respip/respip.c @@ -128,7 +128,7 @@ void respip_sockaddr_delete(struct respip_set* set, struct resp_addr* node) { struct resp_addr* prev; - prev = (struct resp_addr*)rbtree_previous((struct rbnode_type*)node); + prev = (struct resp_addr*)rbtree_previous((struct rbnode_type*)node); lock_rw_destroy(&node->lock); (void)rbtree_delete(&set->ip_tree, node); /* no free'ing, all allocated in region */ @@ -943,7 +943,7 @@ respip_rewrite_reply(const struct query_info* qinfo, for(a = az->rpz_first; a && !raddr && !(rpz_passthru && *rpz_passthru); a = a->rpz_az_next) { lock_rw_rdlock(&a->lock); r = a->rpz; - if(!r->taglist || taglist_intersect(r->taglist, + if(!r->taglist || taglist_intersect(r->taglist, r->taglistlen, ctaglist, ctaglen)) { if((raddr = respip_addr_lookup(rep, r->respip_set, &rrset_id, &rr_id))) { diff --git a/sbin/unwind/libunbound/respip/respip.h b/sbin/unwind/libunbound/respip/respip.h index e4ab5cc9c..b520673c6 100644 --- a/sbin/unwind/libunbound/respip/respip.h +++ b/sbin/unwind/libunbound/respip/respip.h @@ -139,7 +139,7 @@ int respip_views_apply_cfg(struct views* vs, struct config_file* cfg, * reply is assumed to be faked due to a response-ip action and can't be * considered secure in terms of DNSSEC. * The caller must ensure that neither 'base_rep' nor 'tgt_rep' can be modified - * until this function returns. + * until this function returns. * @param base_rep: the reply info containing an incomplete CNAME. * @param qinfo: query info corresponding to 'base_rep'. * @param tgt_rep: the reply info that completes the CNAME chain. diff --git a/sbin/unwind/libunbound/services/authzone.c b/sbin/unwind/libunbound/services/authzone.c index cd3ef8dbb..61493cc3b 100644 --- a/sbin/unwind/libunbound/services/authzone.c +++ b/sbin/unwind/libunbound/services/authzone.c @@ -4,22 +4,22 @@ * Copyright (c) 2017, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -517,7 +517,7 @@ auth_zones_find_zone(struct auth_zones* az, uint8_t* name, size_t name_len, return NULL; } -/** find or create zone with name str. caller must have lock on az. +/** find or create zone with name str. caller must have lock on az. * returns a wrlocked zone */ static struct auth_zone* auth_zones_find_or_add_zone(struct auth_zones* az, char* name) @@ -540,7 +540,7 @@ auth_zones_find_or_add_zone(struct auth_zones* az, char* name) return z; } -/** find or create xfer zone with name str. caller must have lock on az. +/** find or create xfer zone with name str. caller must have lock on az. * returns a locked xfer */ static struct auth_xfer* auth_zones_find_or_add_xfer(struct auth_zones* az, struct auth_zone* z) @@ -767,7 +767,7 @@ rrset_remove_rr(struct auth_rrset* rrset, size_t index) if(index+1 < old->count+old->rrsig_count) memmove(&d->rr_ttl[index], &old->rr_ttl[index+1], (old->count+old->rrsig_count - (index+1))*sizeof(time_t)); - + /* move over rr_data */ for(i=0; icount+d->rrsig_count; i++) { size_t oldi; @@ -789,7 +789,7 @@ rrset_remove_rr(struct auth_rrset* rrset, size_t index) return 1; } -/** add RR to existing RRset. If insert_sig is true, add to rrsigs. +/** add RR to existing RRset. If insert_sig is true, add to rrsigs. * This reallocates the packed rrset for a new one */ static int rrset_add_rr(struct auth_rrset* rrset, uint32_t rr_ttl, uint8_t* rdata, @@ -1373,7 +1373,7 @@ decompress_rr_into_buffer(struct sldns_buffer* buf, uint8_t* pkt, uncompressed_len)) /* dname too long for buffer */ return 0; - dname_pkt_copy(&pktbuf, + dname_pkt_copy(&pktbuf, sldns_buffer_current(buf), rd); sldns_buffer_skip(buf, (ssize_t)uncompressed_len); compressed_len = sldns_buffer_position( @@ -1456,7 +1456,7 @@ az_remove_rr_decompress(struct auth_zone* z, uint8_t* pkt, size_t pktlen, return az_remove_rr(z, rr, rr_len, dname_len, nonexist); } -/** +/** * Parse zonefile * @param z: zone to read in. * @param in: file to read from (just opened). @@ -1572,7 +1572,7 @@ auth_zone_read_zonefile(struct auth_zone* z, struct config_file* cfg) FILE* in; if(!z || !z->zonefile || z->zonefile[0]==0) return 1; /* no file, or "", nothing to read */ - + zfilename = z->zonefile; if(cfg->chrootdir && cfg->chrootdir[0] && strncmp(zfilename, cfg->chrootdir, strlen(cfg->chrootdir)) == 0) @@ -2034,7 +2034,7 @@ xfr_find_soa(struct auth_zone* z, struct auth_xfer* xfr) return 1; } -/** +/** * Setup auth_xfer zone * This populates the have_zone, soa values, and so on times. * Doesn't do network traffic yet, can set option flags. @@ -2499,7 +2499,7 @@ az_find_ce(struct auth_zone* z, struct query_info* qinfo, if(n->namelen != z->namelen && (*rrset=az_domain_rrset(n, LDNS_RR_TYPE_NS)) && /* delegate here, but DS at exact the dp has notype */ - (qinfo->qtype != LDNS_RR_TYPE_DS || + (qinfo->qtype != LDNS_RR_TYPE_DS || n->namelen != qinfo->qname_len)) { /* referral */ /* this is ce and the lowernode is nonexisting */ @@ -3277,7 +3277,7 @@ az_generate_dname_answer(struct auth_zone* z, struct query_info* qinfo, if(msg->rep->rrset_count == 0 || !msg->rep->rrsets[msg->rep->rrset_count-1]) return 0; - if(!follow_cname_chain(z, qinfo->qtype, region, msg, + if(!follow_cname_chain(z, qinfo->qtype, region, msg, (struct packed_rrset_data*)msg->rep->rrsets[ msg->rep->rrset_count-1]->entry.data)) return 0; @@ -3695,7 +3695,7 @@ addr_matches_master(struct auth_master* master, struct sockaddr_storage* addr, int net = 0; if(addr_in_list(master->list, addr, addrlen)) { *fromhost = master; - return 1; + return 1; } /* compare address (but not port number, that is the destination * port of the master, the port number of the received notify is @@ -3814,7 +3814,7 @@ int auth_zones_notify(struct auth_zones* az, struct module_env* env, } lock_basic_lock(&xfr->lock); lock_rw_unlock(&az->lock); - + /* check access list for notifies */ if(!az_xfr_allowed_notify(xfr, addr, addrlen, &fromhost)) { lock_basic_unlock(&xfr->lock); @@ -4009,7 +4009,7 @@ xfr_transfer_move_to_next_lookup(struct auth_xfer* xfr, struct module_env* env) xfr->task_transfer->lookup_aaaa = 1; return; } - xfr->task_transfer->lookup_target = + xfr->task_transfer->lookup_target = xfr->task_transfer->lookup_target->next; xfr->task_transfer->lookup_aaaa = 0; if(!env->cfg->do_ip4 && xfr->task_transfer->lookup_target!=NULL) @@ -4048,7 +4048,7 @@ xfr_probe_move_to_next_lookup(struct auth_xfer* xfr, struct module_env* env) /** start the iteration of the task_transfer list of masters */ static void -xfr_transfer_start_list(struct auth_xfer* xfr, struct auth_master* spec) +xfr_transfer_start_list(struct auth_xfer* xfr, struct auth_master* spec) { if(spec) { xfr->task_transfer->scan_specific = find_master_by_host( @@ -4075,7 +4075,7 @@ xfr_transfer_start_list(struct auth_xfer* xfr, struct auth_master* spec) /** start the iteration of the task_probe list of masters */ static void -xfr_probe_start_list(struct auth_xfer* xfr, struct auth_master* spec) +xfr_probe_start_list(struct auth_xfer* xfr, struct auth_master* spec) { if(spec) { xfr->task_probe->scan_specific = find_master_by_host( @@ -4196,7 +4196,7 @@ xfr_probe_nextmaster(struct auth_xfer* xfr) /** create SOA probe packet for xfr */ static void -xfr_create_soa_probe_packet(struct auth_xfer* xfr, sldns_buffer* buf, +xfr_create_soa_probe_packet(struct auth_xfer* xfr, sldns_buffer* buf, uint16_t id) { struct query_info qinfo; @@ -4915,7 +4915,7 @@ apply_ixfr(struct auth_xfer* xfr, struct auth_zone* z, delmode = !delmode; } /* process this RR */ - /* if the RR is deleted twice or added twice, then we + /* if the RR is deleted twice or added twice, then we * softfail, and continue with the rest of the IXFR, so * that we serve something fairly nice during the refetch */ if(verbosity>=7) log_rrlist_position((delmode?"del":"add"), @@ -5545,7 +5545,7 @@ xfr_transfer_init_fetch(struct auth_xfer* xfr, struct module_env* env) char zname[255+1], as[256]; dname_str(xfr->name, zname); addr_to_str(&addr, addrlen, as, sizeof(as)); - verbose(VERB_ALGO, "auth zone %s transfer next %s fetch from %s started", zname, + verbose(VERB_ALGO, "auth zone %s transfer next %s fetch from %s started", zname, (xfr->task_transfer->on_ixfr?"IXFR":"AXFR"), as); } return 1; @@ -5623,7 +5623,7 @@ xfr_master_add_addrs(struct auth_master* m, struct ub_packed_rrset_key* rrset, continue; /* wrong length for A */ if(rrtype == LDNS_RR_TYPE_AAAA && len != INET6_SIZE) continue; /* wrong length for AAAA */ - + /* add and alloc it */ a = (struct auth_addr*)calloc(1, sizeof(*a)); if(!a) { @@ -6059,7 +6059,7 @@ process_list_end_transfer(struct auth_xfer* xfr, struct module_env* env) xfr_transfer_disown(xfr); if(xfr->notify_received && (!xfr->notify_has_serial || - (xfr->notify_has_serial && + (xfr->notify_has_serial && xfr_serial_means_update(xfr, xfr->notify_serial)))) { uint32_t sr = xfr->notify_serial; int has_sr = xfr->notify_has_serial; @@ -6158,7 +6158,7 @@ auth_xfer_transfer_tcp_callback(struct comm_point* c, void* arg, int err, if(err != NETEVENT_NOERROR) { /* connection failed, closed, or timeout */ - /* stop this transfer, cleanup + /* stop this transfer, cleanup * and continue task_transfer*/ verbose(VERB_ALGO, "xfr stopped, connection lost to %s", xfr->task_transfer->master->host); @@ -6240,7 +6240,7 @@ auth_xfer_transfer_http_callback(struct comm_point* c, void* arg, int err, if(err != NETEVENT_NOERROR && err != NETEVENT_DONE) { /* connection failed, closed, or timeout */ - /* stop this transfer, cleanup + /* stop this transfer, cleanup * and continue task_transfer*/ verbose(VERB_ALGO, "http stopped, connection lost to %s", xfr->task_transfer->master->host); @@ -6374,7 +6374,7 @@ xfr_probe_send_probe(struct auth_xfer* xfr, struct module_env* env, * this means we'll accept replies to previous retries to same ip */ if(timeout == AUTH_PROBE_TIMEOUT) xfr->task_probe->id = GET_RANDOM_ID(env->rnd); - xfr_create_soa_probe_packet(xfr, env->scratch_buffer, + xfr_create_soa_probe_packet(xfr, env->scratch_buffer, xfr->task_probe->id); /* we need to remove the cp if we have a different ip4/ip6 type now */ if(xfr->task_probe->cp && @@ -6549,7 +6549,7 @@ auth_xfer_probe_udp_callback(struct comm_point* c, void* arg, int err, verbose(VERB_ALGO, "auth zone %s: soa probe failed", buf); } } - + /* failed lookup or not an update */ /* delete commpoint so a new one is created, with a fresh port nr */ comm_point_delete(xfr->task_probe->cp); @@ -6906,7 +6906,7 @@ xfr_set_timeout(struct auth_xfer* xfr, struct module_env* env, xfr->task_nextprobe->next_probe = *env->now; if(xfr->lease_time && !failure) xfr->task_nextprobe->next_probe = xfr->lease_time; - + if(!failure) { xfr->task_nextprobe->backoff = 0; } else { @@ -6954,7 +6954,7 @@ xfr_set_timeout(struct auth_xfer* xfr, struct module_env* env, xfr->task_nextprobe->worker = env->worker; xfr->task_nextprobe->env = env; if(*(xfr->task_nextprobe->env->now) <= xfr->task_nextprobe->next_probe) - tv.tv_sec = xfr->task_nextprobe->next_probe - + tv.tv_sec = xfr->task_nextprobe->next_probe - *(xfr->task_nextprobe->env->now); else tv.tv_sec = 0; if(tv.tv_sec != 0 && lookup_only && xfr->task_probe->masters) { diff --git a/sbin/unwind/libunbound/services/authzone.h b/sbin/unwind/libunbound/services/authzone.h index 07614ed82..04a8b68fc 100644 --- a/sbin/unwind/libunbound/services/authzone.h +++ b/sbin/unwind/libunbound/services/authzone.h @@ -4,22 +4,22 @@ * Copyright (c) 2017, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -194,7 +194,7 @@ struct auth_rrset { * The structure consists of different tasks. Each can be unowned (-1) or * owner by a worker (worker-num). A worker can pick up a task and then do * it. This means the events (timeouts, sockets) are for that worker. - * + * * (move this to tasks). * They don't have locks themselves, the worker (that owns it) uses it, * also as part of callbacks, hence it has separate zonename pointers for @@ -208,7 +208,7 @@ struct auth_xfer { /** lock on this structure, and on the workernum elements of the * tasks. First hold the tree-lock in auth_zones, find the auth_xfer, * lock this lock. Then a worker can reassign itself to fill up - * one of the tasks. + * one of the tasks. * Once it has the task assigned to it, the worker can access the * other elements of the task structure without a lock, because that * is necessary for the eventloop and callbacks from that. */ @@ -340,7 +340,7 @@ struct auth_probe { /** once notified, or the timeout has been reached. a scan starts. */ /** the scan specific target (notify source), or NULL if none */ struct auth_master* scan_specific; - /** scan tries all the upstream masters. the scan current target. + /** scan tries all the upstream masters. the scan current target. * or NULL if not working on sequential scan */ struct auth_master* scan_target; /** if not NULL, the specific addr for the current master */ @@ -388,7 +388,7 @@ struct auth_transfer { /** once notified, or the timeout has been reached. a scan starts. */ /** the scan specific target (notify source), or NULL if none */ struct auth_master* scan_specific; - /** scan tries all the upstream masters. the scan current target. + /** scan tries all the upstream masters. the scan current target. * or NULL if not working on sequential scan */ struct auth_master* scan_target; /** what address we are scanning for the master, or NULL if the @@ -555,7 +555,7 @@ int auth_zones_answer(struct auth_zones* az, struct module_env* env, struct query_info* qinfo, struct edns_data* edns, struct comm_reply* repinfo, struct sldns_buffer* buf, struct regional* temp); -/** +/** * Find the auth zone that is above the given qname. * Return NULL when there is no auth_zone above the give name, otherwise * returns the closest auth_zone above the qname that pertains to it. diff --git a/sbin/unwind/libunbound/services/cache/dns.c b/sbin/unwind/libunbound/services/cache/dns.c index 9b4ad5888..58003ebe2 100644 --- a/sbin/unwind/libunbound/services/cache/dns.c +++ b/sbin/unwind/libunbound/services/cache/dns.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -55,7 +55,7 @@ #include "util/config_file.h" #include "sldns/sbuffer.h" -/** store rrsets in the rrset cache. +/** store rrsets in the rrset cache. * @param env: module environment with caches. * @param rep: contains list of rrsets to store. * @param now: current time. @@ -117,7 +117,7 @@ store_rrsets(struct module_env* env, struct reply_info* rep, time_t now, /** delete message from message cache */ void -msg_cache_remove(struct module_env* env, uint8_t* qname, size_t qnamelen, +msg_cache_remove(struct module_env* env, uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, uint16_t flags) { struct query_info k; @@ -132,7 +132,7 @@ msg_cache_remove(struct module_env* env, uint8_t* qname, size_t qnamelen, slabhash_remove(env->msg_cache, h, &k); } -void +void dns_cache_store_msg(struct module_env* env, struct query_info* qinfo, hashvalue_type hash, struct reply_info* rep, time_t leeway, int pside, struct reply_info* qrep, uint32_t flags, struct regional* region, @@ -225,7 +225,7 @@ rrset_expired_above(struct module_env* env, uint8_t** qname, size_t* qnamelen, /** find closest NS or DNAME and returns the rrset (locked) */ static struct ub_packed_rrset_key* -find_closest_of_type(struct module_env* env, uint8_t* qname, size_t qnamelen, +find_closest_of_type(struct module_env* env, uint8_t* qname, size_t qnamelen, uint16_t qclass, time_t now, uint16_t searchtype, int stripfront, int noexpiredabove, uint8_t* expiretop, size_t expiretoplen) { @@ -241,7 +241,7 @@ find_closest_of_type(struct module_env* env, uint8_t* qname, size_t qnamelen, /* snip off front part of qname until the type is found */ while(qnamelen > 0) { - if((rrset = rrset_cache_lookup(env->rrset_cache, qname, + if((rrset = rrset_cache_lookup(env->rrset_cache, qname, qnamelen, searchtype, qclass, 0, now, 0))) { uint8_t* origqname = qname; size_t origqnamelen = qnamelen; @@ -290,7 +290,7 @@ static void addr_to_additional(struct ub_packed_rrset_key* rrset, struct regional* region, struct dns_msg* msg, time_t now) { - if((msg->rep->rrsets[msg->rep->rrset_count] = + if((msg->rep->rrsets[msg->rep->rrset_count] = packed_rrset_copy_region(rrset, region, now))) { msg->rep->ar_numrrsets++; msg->rep->rrset_count++; @@ -298,8 +298,8 @@ addr_to_additional(struct ub_packed_rrset_key* rrset, struct regional* region, } /** lookup message in message cache */ -struct msgreply_entry* -msg_cache_lookup(struct module_env* env, uint8_t* qname, size_t qnamelen, +struct msgreply_entry* +msg_cache_lookup(struct module_env* env, uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, uint16_t flags, time_t now, int wr) { struct lruhash_entry* e; @@ -324,15 +324,15 @@ msg_cache_lookup(struct module_env* env, uint8_t* qname, size_t qnamelen, /** find and add A and AAAA records for nameservers in delegpt */ static int -find_add_addrs(struct module_env* env, uint16_t qclass, - struct regional* region, struct delegpt* dp, time_t now, +find_add_addrs(struct module_env* env, uint16_t qclass, + struct regional* region, struct delegpt* dp, time_t now, struct dns_msg** msg) { struct delegpt_ns* ns; struct msgreply_entry* neg; struct ub_packed_rrset_key* akey; for(ns = dp->nslist; ns; ns = ns->next) { - akey = rrset_cache_lookup(env->rrset_cache, ns->name, + akey = rrset_cache_lookup(env->rrset_cache, ns->name, ns->namelen, LDNS_RR_TYPE_A, qclass, 0, now, 0); if(akey) { if(!delegpt_add_rrset_A(dp, region, akey, 0, NULL)) { @@ -352,7 +352,7 @@ find_add_addrs(struct module_env* env, uint16_t qclass, lock_rw_unlock(&neg->entry.lock); } } - akey = rrset_cache_lookup(env->rrset_cache, ns->name, + akey = rrset_cache_lookup(env->rrset_cache, ns->name, ns->namelen, LDNS_RR_TYPE_AAAA, qclass, 0, now, 0); if(akey) { if(!delegpt_add_rrset_AAAA(dp, region, akey, 0, NULL)) { @@ -378,7 +378,7 @@ find_add_addrs(struct module_env* env, uint16_t qclass, /** find and add A and AAAA records for missing nameservers in delegpt */ int -cache_fill_missing(struct module_env* env, uint16_t qclass, +cache_fill_missing(struct module_env* env, uint16_t qclass, struct regional* region, struct delegpt* dp) { struct delegpt_ns* ns; @@ -389,7 +389,7 @@ cache_fill_missing(struct module_env* env, uint16_t qclass, if(ns->cache_lookup_count > ITERATOR_NAME_CACHELOOKUP_MAX) continue; ns->cache_lookup_count++; - akey = rrset_cache_lookup(env->rrset_cache, ns->name, + akey = rrset_cache_lookup(env->rrset_cache, ns->name, ns->namelen, LDNS_RR_TYPE_A, qclass, 0, now, 0); if(akey) { if(!delegpt_add_rrset_A(dp, region, akey, ns->lame, @@ -410,7 +410,7 @@ cache_fill_missing(struct module_env* env, uint16_t qclass, lock_rw_unlock(&neg->entry.lock); } } - akey = rrset_cache_lookup(env->rrset_cache, ns->name, + akey = rrset_cache_lookup(env->rrset_cache, ns->name, ns->namelen, LDNS_RR_TYPE_AAAA, qclass, 0, now, 0); if(akey) { if(!delegpt_add_rrset_AAAA(dp, region, akey, ns->lame, @@ -437,18 +437,18 @@ cache_fill_missing(struct module_env* env, uint16_t qclass, /** find and add DS or NSEC to delegation msg */ static void -find_add_ds(struct module_env* env, struct regional* region, +find_add_ds(struct module_env* env, struct regional* region, struct dns_msg* msg, struct delegpt* dp, time_t now) { /* Lookup the DS or NSEC at the delegation point. */ struct ub_packed_rrset_key* rrset = rrset_cache_lookup( - env->rrset_cache, dp->name, dp->namelen, LDNS_RR_TYPE_DS, + env->rrset_cache, dp->name, dp->namelen, LDNS_RR_TYPE_DS, msg->qinfo.qclass, 0, now, 0); if(!rrset) { - /* NOTE: this won't work for alternate NSEC schemes + /* NOTE: this won't work for alternate NSEC schemes * (opt-in, NSEC3) */ - rrset = rrset_cache_lookup(env->rrset_cache, dp->name, - dp->namelen, LDNS_RR_TYPE_NSEC, msg->qinfo.qclass, + rrset = rrset_cache_lookup(env->rrset_cache, dp->name, + dp->namelen, LDNS_RR_TYPE_NSEC, msg->qinfo.qclass, 0, now, 0); /* Note: the PACKED_RRSET_NSEC_AT_APEX flag is not used. * since this is a referral, we need the NSEC at the parent @@ -460,7 +460,7 @@ find_add_ds(struct module_env* env, struct regional* region, } if(rrset) { /* add it to auth section. This is the second rrset. */ - if((msg->rep->rrsets[msg->rep->rrset_count] = + if((msg->rep->rrsets[msg->rep->rrset_count] = packed_rrset_copy_region(rrset, region, now))) { msg->rep->ns_numrrsets++; msg->rep->rrset_count++; @@ -470,7 +470,7 @@ find_add_ds(struct module_env* env, struct regional* region, } struct dns_msg* -dns_msg_create(uint8_t* qname, size_t qnamelen, uint16_t qtype, +dns_msg_create(uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, struct regional* region, size_t capacity) { struct dns_msg* msg = (struct dns_msg*)regional_alloc(region, @@ -485,7 +485,7 @@ dns_msg_create(uint8_t* qname, size_t qnamelen, uint16_t qtype, msg->qinfo.qclass = qclass; msg->qinfo.local_alias = NULL; /* non-packed reply_info, because it needs to grow the array */ - msg->rep = (struct reply_info*)regional_alloc_zero(region, + msg->rep = (struct reply_info*)regional_alloc_zero(region, sizeof(struct reply_info)-sizeof(struct rrset_ref)); if(!msg->rep) return NULL; @@ -495,7 +495,7 @@ dns_msg_create(uint8_t* qname, size_t qnamelen, uint16_t qtype, msg->rep->qdcount = 1; msg->rep->reason_bogus = LDNS_EDE_NONE; msg->rep->rrsets = (struct ub_packed_rrset_key**) - regional_alloc(region, + regional_alloc(region, capacity*sizeof(struct ub_packed_rrset_key*)); if(!msg->rep->rrsets) return NULL; @@ -503,10 +503,10 @@ dns_msg_create(uint8_t* qname, size_t qnamelen, uint16_t qtype, } int -dns_msg_authadd(struct dns_msg* msg, struct regional* region, +dns_msg_authadd(struct dns_msg* msg, struct regional* region, struct ub_packed_rrset_key* rrset, time_t now) { - if(!(msg->rep->rrsets[msg->rep->rrset_count++] = + if(!(msg->rep->rrsets[msg->rep->rrset_count++] = packed_rrset_copy_region(rrset, region, now))) return 0; msg->rep->ns_numrrsets++; @@ -514,19 +514,19 @@ dns_msg_authadd(struct dns_msg* msg, struct regional* region, } int -dns_msg_ansadd(struct dns_msg* msg, struct regional* region, +dns_msg_ansadd(struct dns_msg* msg, struct regional* region, struct ub_packed_rrset_key* rrset, time_t now) { - if(!(msg->rep->rrsets[msg->rep->rrset_count++] = + if(!(msg->rep->rrsets[msg->rep->rrset_count++] = packed_rrset_copy_region(rrset, region, now))) return 0; msg->rep->an_numrrsets++; return 1; } -struct delegpt* -dns_cache_find_delegation(struct module_env* env, uint8_t* qname, - size_t qnamelen, uint16_t qtype, uint16_t qclass, +struct delegpt* +dns_cache_find_delegation(struct module_env* env, uint8_t* qname, + size_t qnamelen, uint16_t qtype, uint16_t qclass, struct regional* region, struct dns_msg** msg, time_t now, int noexpiredabove, uint8_t* expiretop, size_t expiretoplen) { @@ -554,7 +554,7 @@ dns_cache_find_delegation(struct module_env* env, uint8_t* qname, * A rrset for every NS RR * AAAA rrset for every NS RR */ - *msg = dns_msg_create(qname, qnamelen, qtype, qclass, region, + *msg = dns_msg_create(qname, qnamelen, qtype, qclass, region, 2 + nsdata->count*2); if(!*msg || !dns_msg_authadd(*msg, region, nskey, now)) { lock_rw_unlock(&nskey->entry.lock); @@ -578,7 +578,7 @@ dns_cache_find_delegation(struct module_env* env, uint8_t* qname, static struct dns_msg* gen_dns_msg(struct regional* region, struct query_info* q, size_t num) { - struct dns_msg* msg = (struct dns_msg*)regional_alloc(region, + struct dns_msg* msg = (struct dns_msg*)regional_alloc(region, sizeof(struct dns_msg)); if(!msg) return NULL; @@ -683,7 +683,7 @@ tomsg(struct module_env* env, struct query_info* q, struct reply_info* r, } } if(env) - rrset_array_unlock_touch(env->rrset_cache, scratch, r->ref, + rrset_array_unlock_touch(env->rrset_cache, scratch, r->ref, r->rrset_count); else rrset_array_unlock(r->ref, r->rrset_count); @@ -692,7 +692,7 @@ tomsg(struct module_env* env, struct query_info* q, struct reply_info* r, /** synthesize RRset-only response from cached RRset item */ static struct dns_msg* -rrset_msg(struct ub_packed_rrset_key* rrset, struct regional* region, +rrset_msg(struct ub_packed_rrset_key* rrset, struct regional* region, time_t now, struct query_info* q) { struct dns_msg* msg; @@ -723,7 +723,7 @@ rrset_msg(struct ub_packed_rrset_key* rrset, struct regional* region, /** synthesize DNAME+CNAME response from cached DNAME item */ static struct dns_msg* -synth_dname_msg(struct ub_packed_rrset_key* rrset, struct regional* region, +synth_dname_msg(struct ub_packed_rrset_key* rrset, struct regional* region, time_t now, struct query_info* q, enum sec_status* sec_status) { struct dns_msg* msg; @@ -734,7 +734,7 @@ synth_dname_msg(struct ub_packed_rrset_key* rrset, struct regional* region, size_t newlen, dtarglen; if(now > d->ttl) return NULL; - /* only allow validated (with DNSSEC) DNAMEs used from cache + /* only allow validated (with DNSSEC) DNAMEs used from cache * for insecure DNAMEs, query again. */ *sec_status = d->security; /* return sec status, so the status of the CNAME can be checked @@ -774,7 +774,7 @@ synth_dname_msg(struct ub_packed_rrset_key* rrset, struct regional* region, memcpy(newname, q->qname, q->qname_len-rrset->rk.dname_len); memmove(newname+(q->qname_len-rrset->rk.dname_len), dtarg, dtarglen); /* create rest of CNAME rrset */ - ck = (struct ub_packed_rrset_key*)regional_alloc(region, + ck = (struct ub_packed_rrset_key*)regional_alloc(region, sizeof(struct ub_packed_rrset_key)); if(!ck) return NULL; @@ -790,8 +790,8 @@ synth_dname_msg(struct ub_packed_rrset_key* rrset, struct regional* region, ck->rk.dname_len = q->qname_len; ck->entry.hash = rrset_key_hash(&ck->rk); newd = (struct packed_rrset_data*)regional_alloc_zero(region, - sizeof(struct packed_rrset_data) + sizeof(size_t) + - sizeof(uint8_t*) + sizeof(time_t) + sizeof(uint16_t) + sizeof(struct packed_rrset_data) + sizeof(size_t) + + sizeof(uint8_t*) + sizeof(time_t) + sizeof(uint16_t) + newlen); if(!newd) return NULL; @@ -800,7 +800,7 @@ synth_dname_msg(struct ub_packed_rrset_key* rrset, struct regional* region, newd->count = 1; newd->rrsig_count = 0; newd->trust = rrset_trust_ans_noAA; - newd->rr_len = (size_t*)((uint8_t*)newd + + newd->rr_len = (size_t*)((uint8_t*)newd + sizeof(struct packed_rrset_data)); newd->rr_len[0] = newlen + sizeof(uint16_t); packed_rrset_ptr_fixup(newd); @@ -881,7 +881,7 @@ fill_any(struct module_env* env, return msg; } -struct dns_msg* +struct dns_msg* dns_cache_lookup(struct module_env* env, uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, uint16_t flags, struct regional* region, struct regional* scratch, @@ -915,7 +915,7 @@ dns_cache_lookup(struct module_env* env, } /* see if a DNAME exists. Checked for first, to enforce that DNAMEs - * are more important, the CNAME is resynthesized and thus + * are more important, the CNAME is resynthesized and thus * consistent with the DNAME */ if(!no_partial && (rrset=find_closest_of_type(env, qname, qnamelen, qclass, now, @@ -957,7 +957,7 @@ dns_cache_lookup(struct module_env* env, /* see if we have CNAME for this domain, * but not for DS records (which are part of the parent) */ if(!no_partial && qtype != LDNS_RR_TYPE_DS && - (rrset=rrset_cache_lookup(env->rrset_cache, qname, qnamelen, + (rrset=rrset_cache_lookup(env->rrset_cache, qname, qnamelen, LDNS_RR_TYPE_CNAME, qclass, 0, now, 0))) { uint8_t* wc = NULL; size_t wl; @@ -976,7 +976,7 @@ dns_cache_lookup(struct module_env* env, /* construct DS, DNSKEY messages from rrset cache. */ if((qtype == LDNS_RR_TYPE_DS || qtype == LDNS_RR_TYPE_DNSKEY) && - (rrset=rrset_cache_lookup(env->rrset_cache, qname, qnamelen, + (rrset=rrset_cache_lookup(env->rrset_cache, qname, qnamelen, qtype, qclass, 0, now, 0))) { /* if the rrset is from the additional section, and the * signatures have fallen off, then do not synthesize a msg @@ -987,10 +987,10 @@ dns_cache_lookup(struct module_env* env, */ struct packed_rrset_data *d = (struct packed_rrset_data*) rrset->entry.data; - if(d->trust != rrset_trust_add_noAA && - d->trust != rrset_trust_add_AA && - (qtype == LDNS_RR_TYPE_DS || - (d->trust != rrset_trust_auth_noAA + if(d->trust != rrset_trust_add_noAA && + d->trust != rrset_trust_add_AA && + (qtype == LDNS_RR_TYPE_DS || + (d->trust != rrset_trust_auth_noAA && d->trust != rrset_trust_auth_AA) )) { struct dns_msg* msg = rrset_msg(rrset, region, now, &k); if(msg) { @@ -1073,7 +1073,7 @@ dns_cache_store(struct module_env* env, struct query_info* msgqinf, ref.id = rep->rrsets[i]->id; /*ignore ret: it was in the cache, ref updated */ /* no leeway for typeNS */ - (void)rrset_cache_update(env->rrset_cache, &ref, + (void)rrset_cache_update(env->rrset_cache, &ref, env->alloc, ((ntohs(ref.key->rk.type)==LDNS_RR_TYPE_NS && !pside) ? qstarttime:*env->now + leeway)); @@ -1092,21 +1092,21 @@ dns_cache_store(struct module_env* env, struct query_info* msgqinf, return 0; } /* fixup flags to be sensible for a reply based on the cache */ - /* this module means that RA is available. It is an answer QR. + /* this module means that RA is available. It is an answer QR. * Not AA from cache. Not CD in cache (depends on client bit). */ rep->flags |= (BIT_RA | BIT_QR); rep->flags &= ~(BIT_AA | BIT_CD); h = query_info_hash(&qinf, (uint16_t)flags); dns_cache_store_msg(env, &qinf, h, rep, leeway, pside, msgrep, flags, region, qstarttime); - /* qname is used inside query_info_entrysetup, and set to + /* qname is used inside query_info_entrysetup, and set to * NULL. If it has not been used, free it. free(0) is safe. */ free(qinf.qname); } return 1; } -int +int dns_cache_prefetch_adjust(struct module_env* env, struct query_info* qinfo, time_t adjust, uint16_t flags) { diff --git a/sbin/unwind/libunbound/services/cache/dns.h b/sbin/unwind/libunbound/services/cache/dns.h index 147f992cb..9b39aeb7f 100644 --- a/sbin/unwind/libunbound/services/cache/dns.h +++ b/sbin/unwind/libunbound/services/cache/dns.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -142,8 +142,8 @@ void dns_cache_store_msg(struct module_env* env, struct query_info* qinfo, * @param expiretoplen: length of expiretop dname. * @return new delegation or NULL on error or if not found in cache. */ -struct delegpt* dns_cache_find_delegation(struct module_env* env, - uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, +struct delegpt* dns_cache_find_delegation(struct module_env* env, + uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, struct regional* region, struct dns_msg** msg, time_t timenow, int noexpiredabove, uint8_t* expiretop, size_t expiretoplen); @@ -164,8 +164,8 @@ struct dns_msg* tomsg(struct module_env* env, struct query_info* q, struct reply_info* r, struct regional* region, time_t now, int allow_expired, struct regional* scratch); -/** - * Find cached message +/** + * Find cached message * @param env: module environment with the DNS cache. * @param qname: query name. * @param qnamelen: length of qname. @@ -187,15 +187,15 @@ struct dns_msg* dns_cache_lookup(struct module_env* env, uint16_t flags, struct regional* region, struct regional* scratch, int no_partial, uint8_t* dpname, size_t dpnamelen); -/** - * find and add A and AAAA records for missing nameservers in delegpt +/** + * find and add A and AAAA records for missing nameservers in delegpt * @param env: module environment with rrset cache * @param qclass: which class to look in. * @param region: where to store new dp info. * @param dp: delegation point to fill missing entries. * @return false on alloc failure. */ -int cache_fill_missing(struct module_env* env, uint16_t qclass, +int cache_fill_missing(struct module_env* env, uint16_t qclass, struct regional* region, struct delegpt* dp); /** @@ -209,7 +209,7 @@ int cache_fill_missing(struct module_env* env, uint16_t qclass, * @param capacity: number of rrsets space to create in the array. * @return new dns_msg struct or NULL on mem fail. */ -struct dns_msg* dns_msg_create(uint8_t* qname, size_t qnamelen, uint16_t qtype, +struct dns_msg* dns_msg_create(uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, struct regional* region, size_t capacity); /** @@ -221,7 +221,7 @@ struct dns_msg* dns_msg_create(uint8_t* qname, size_t qnamelen, uint16_t qtype, * @param now: now. * @return true if worked, false on fail */ -int dns_msg_authadd(struct dns_msg* msg, struct regional* region, +int dns_msg_authadd(struct dns_msg* msg, struct regional* region, struct ub_packed_rrset_key* rrset, time_t now); /** @@ -233,7 +233,7 @@ int dns_msg_authadd(struct dns_msg* msg, struct regional* region, * @param now: now. * @return true if worked, false on fail */ -int dns_msg_ansadd(struct dns_msg* msg, struct regional* region, +int dns_msg_ansadd(struct dns_msg* msg, struct regional* region, struct ub_packed_rrset_key* rrset, time_t now); /** diff --git a/sbin/unwind/libunbound/services/cache/infra.c b/sbin/unwind/libunbound/services/cache/infra.c index 31462d13a..6d66f2307 100644 --- a/sbin/unwind/libunbound/services/cache/infra.c +++ b/sbin/unwind/libunbound/services/cache/infra.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -72,7 +72,7 @@ int infra_ip_ratelimit = 0; * For clients with a valid DNS Cookie. */ int infra_ip_ratelimit_cookie = 0; -size_t +size_t infra_sizefunc(void* k, void* ATTR_UNUSED(d)) { struct infra_key* key = (struct infra_key*)k; @@ -80,7 +80,7 @@ infra_sizefunc(void* k, void* ATTR_UNUSED(d)) + lock_get_mem(&key->entry.lock); } -int +int infra_compfunc(void* key1, void* key2) { struct infra_key* k1 = (struct infra_key*)key1; @@ -96,7 +96,7 @@ infra_compfunc(void* key1, void* key2) return query_dname_compare(k1->zonename, k2->zonename); } -void +void infra_delkeyfunc(void* k, void* ATTR_UNUSED(arg)) { struct infra_key* key = (struct infra_key*)k; @@ -107,14 +107,14 @@ infra_delkeyfunc(void* k, void* ATTR_UNUSED(arg)) free(key); } -void +void infra_deldatafunc(void* d, void* ATTR_UNUSED(arg)) { struct infra_data* data = (struct infra_data*)d; free(data); } -size_t +size_t rate_sizefunc(void* k, void* ATTR_UNUSED(d)) { struct rate_key* key = (struct rate_key*)k; @@ -122,7 +122,7 @@ rate_sizefunc(void* k, void* ATTR_UNUSED(d)) + lock_get_mem(&key->entry.lock); } -int +int rate_compfunc(void* key1, void* key2) { struct rate_key* k1 = (struct rate_key*)key1; @@ -135,7 +135,7 @@ rate_compfunc(void* key1, void* key2) return query_dname_compare(k1->name, k2->name); } -void +void rate_delkeyfunc(void* k, void* ATTR_UNUSED(arg)) { struct rate_key* key = (struct rate_key*)k; @@ -146,7 +146,7 @@ rate_delkeyfunc(void* k, void* ATTR_UNUSED(arg)) free(key); } -void +void rate_deldatafunc(void* d, void* ATTR_UNUSED(arg)) { struct rate_data* data = (struct rate_data*)d; @@ -177,7 +177,7 @@ static struct domain_limit_data* domain_limit_findcreate( free(nm); return d; } - + /* create it */ d = (struct domain_limit_data*)calloc(1, sizeof(*d)); if(!d) { @@ -234,10 +234,10 @@ setup_domain_limits(struct infra_cache* infra, struct config_file* cfg) return 1; } -struct infra_cache* +struct infra_cache* infra_create(struct config_file* cfg) { - struct infra_cache* infra = (struct infra_cache*)calloc(1, + struct infra_cache* infra = (struct infra_cache*)calloc(1, sizeof(struct infra_cache)); size_t maxmem = cfg->infra_cache_numhosts * (sizeof(struct infra_key)+ sizeof(struct infra_data)+INFRA_BYTES_NAME); @@ -287,7 +287,7 @@ static void domain_limit_free(rbnode_type* n, void* ATTR_UNUSED(arg)) } } -void +void infra_delete(struct infra_cache* infra) { if(!infra) @@ -299,7 +299,7 @@ infra_delete(struct infra_cache* infra) free(infra); } -struct infra_cache* +struct infra_cache* infra_adjust(struct infra_cache* infra, struct config_file* cfg) { size_t maxmem; @@ -368,7 +368,7 @@ hash_infra(struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* name) } /** lookup version that does not check host ttl (you check it) */ -struct lruhash_entry* +struct lruhash_entry* infra_lookup_nottl(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* name, size_t namelen, int wr) { @@ -385,7 +385,7 @@ infra_lookup_nottl(struct infra_cache* infra, struct sockaddr_storage* addr, /** init the data elements */ static void -data_entry_init(struct infra_cache* infra, struct lruhash_entry* e, +data_entry_init(struct infra_cache* infra, struct lruhash_entry* e, time_t timenow) { struct infra_data* data = (struct infra_data*)e->data; @@ -403,8 +403,8 @@ data_entry_init(struct infra_cache* infra, struct lruhash_entry* e, data->timeout_other = 0; } -/** - * Create and init a new entry for a host +/** + * Create and init a new entry for a host * @param infra: infra structure with config parameters. * @param addr: host address. * @param addrlen: length of addr. @@ -414,7 +414,7 @@ data_entry_init(struct infra_cache* infra, struct lruhash_entry* e, * @return: the new entry or NULL on malloc failure. */ static struct lruhash_entry* -new_entry(struct infra_cache* infra, struct sockaddr_storage* addr, +new_entry(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* name, size_t namelen, time_t tm) { struct infra_data* data; @@ -443,7 +443,7 @@ new_entry(struct infra_cache* infra, struct sockaddr_storage* addr, return &key->entry; } -int +int infra_host(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* nm, size_t nmlen, time_t timenow, int* edns_vs, uint8_t* edns_lame_known, int* to) @@ -515,7 +515,7 @@ infra_host(struct infra_cache* infra, struct sockaddr_storage* addr, return 1; } -int +int infra_set_lame(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* nm, size_t nmlen, time_t timenow, int dnsseclame, int reclame, uint16_t qtype) @@ -553,7 +553,7 @@ infra_set_lame(struct infra_cache* infra, struct sockaddr_storage* addr, return 1; } -void +void infra_update_tcp_works(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* nm, size_t nmlen) @@ -571,7 +571,7 @@ infra_update_tcp_works(struct infra_cache* infra, lock_rw_unlock(&e->lock); } -int +int infra_rtt_update(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* nm, size_t nmlen, int qtype, int roundtrip, int orig_rtt, time_t timenow) @@ -659,7 +659,7 @@ long long infra_get_host_rto(struct infra_cache* infra, return ttl; } -int +int infra_edns_update(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* nm, size_t nmlen, int edns_version, time_t timenow) @@ -693,13 +693,13 @@ infra_edns_update(struct infra_cache* infra, struct sockaddr_storage* addr, int infra_get_lame_rtt(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, - uint8_t* name, size_t namelen, uint16_t qtype, + uint8_t* name, size_t namelen, uint16_t qtype, int* lame, int* dnsseclame, int* reclame, int* rtt, time_t timenow) { struct infra_data* host; struct lruhash_entry* e = infra_lookup_nottl(infra, addr, addrlen, name, namelen, 0); - if(!e) + if(!e) return 0; host = (struct infra_data*)e->data; *rtt = rtt_unclamped(&host->rtt); @@ -970,7 +970,7 @@ int infra_ratelimit_inc(struct infra_cache* infra, uint8_t* name, lim = infra_find_ratelimit(infra, name, namelen); if(!lim) return 1; /* disabled for this domain */ - + /* find or insert ratedata */ entry = infra_find_ratedata(infra, name, namelen, 1); if(entry) { @@ -1046,7 +1046,7 @@ int infra_ratelimit_exceeded(struct infra_cache* infra, uint8_t* name, return (max > lim); } -size_t +size_t infra_get_mem(struct infra_cache* infra) { size_t s = sizeof(*infra) + slabhash_get_mem(infra->hosts); diff --git a/sbin/unwind/libunbound/services/cache/infra.h b/sbin/unwind/libunbound/services/cache/infra.h index 525073bf3..0ad871226 100644 --- a/sbin/unwind/libunbound/services/cache/infra.h +++ b/sbin/unwind/libunbound/services/cache/infra.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -84,7 +84,7 @@ struct infra_data { /** edns version that the host supports, -1 means no EDNS */ int edns_version; /** if the EDNS lameness is already known or not. - * EDNS lame is when EDNS queries or replies are dropped, + * EDNS lame is when EDNS queries or replies are dropped, * and cause a timeout */ uint8_t edns_lame_known; @@ -107,7 +107,7 @@ struct infra_data { }; /** - * Infra cache + * Infra cache */ struct infra_cache { /** The hash table with hosts */ @@ -214,7 +214,7 @@ void infra_delete(struct infra_cache* infra); * @param cfg: config options. * @return the new infra cache pointer or NULL on error. */ -struct infra_cache* infra_adjust(struct infra_cache* infra, +struct infra_cache* infra_adjust(struct infra_cache* infra, struct config_file* cfg); /** @@ -233,7 +233,7 @@ struct lruhash_entry* infra_lookup_nottl(struct infra_cache* infra, /** * Find host information to send a packet. Creates new entry if not found. - * Lameness is empty. EDNS is 0 (try with first), and rtt is returned for + * Lameness is empty. EDNS is 0 (try with first), and rtt is returned for * the first message to it. * Use this to send a packet only, because it also locks out others when * probing is restricted. @@ -249,7 +249,7 @@ struct lruhash_entry* infra_lookup_nottl(struct infra_cache* infra, * @param to: timeout to use, is returned. * @return: 0 on error. */ -int infra_host(struct infra_cache* infra, struct sockaddr_storage* addr, +int infra_host(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* name, size_t namelen, time_t timenow, int* edns_vs, uint8_t* edns_lame_known, int* to); @@ -281,7 +281,7 @@ int infra_set_lame(struct infra_cache* infra, * @param name: zone name * @param namelen: zone name length * @param qtype: query type. - * @param roundtrip: estimate of roundtrip time in milliseconds or -1 for + * @param roundtrip: estimate of roundtrip time in milliseconds or -1 for * timeout. * @param orig_rtt: original rtt for the query that timed out (roundtrip==-1). * ignored if roundtrip != -1. @@ -339,8 +339,8 @@ int infra_edns_update(struct infra_cache* infra, * @return if found in cache, or false if not (or TTL bad). */ int infra_get_lame_rtt(struct infra_cache* infra, - struct sockaddr_storage* addr, socklen_t addrlen, - uint8_t* name, size_t namelen, uint16_t qtype, + struct sockaddr_storage* addr, socklen_t addrlen, + uint8_t* name, size_t namelen, uint16_t qtype, int* lame, int* dnsseclame, int* reclame, int* rtt, time_t timenow); /** diff --git a/sbin/unwind/libunbound/services/cache/rrset.c b/sbin/unwind/libunbound/services/cache/rrset.c index 4e3d08bda..a2330274a 100644 --- a/sbin/unwind/libunbound/services/cache/rrset.c +++ b/sbin/unwind/libunbound/services/cache/rrset.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -57,7 +57,7 @@ rrset_markdel(void* key) r->id = 0; } -struct rrset_cache* rrset_cache_create(struct config_file* cfg, +struct rrset_cache* rrset_cache_create(struct config_file* cfg, struct alloc_cache* alloc) { size_t slabs = (cfg?cfg->rrset_cache_slabs:HASH_DEFAULT_SLABS); @@ -73,13 +73,13 @@ struct rrset_cache* rrset_cache_create(struct config_file* cfg, void rrset_cache_delete(struct rrset_cache* r) { - if(!r) + if(!r) return; slabhash_delete(&r->table); /* slabhash delete also does free(r), since table is first in struct*/ } -struct rrset_cache* rrset_cache_adjust(struct rrset_cache *r, +struct rrset_cache* rrset_cache_adjust(struct rrset_cache *r, struct config_file* cfg, struct alloc_cache* alloc) { if(!r || !cfg || !slabhash_is_size(&r->table, cfg->rrset_cache_size, @@ -91,13 +91,13 @@ struct rrset_cache* rrset_cache_adjust(struct rrset_cache *r, return r; } -void +void rrset_cache_touch(struct rrset_cache* r, struct ub_packed_rrset_key* key, hashvalue_type hash, rrset_id_type id) { struct lruhash* table = slabhash_gettable(&r->table, hash); - /* - * This leads to locking problems, deadlocks, if the caller is + /* + * This leads to locking problems, deadlocks, if the caller is * holding any other rrset lock. * Because a lookup through the hashtable does: * tablelock -> entrylock (for that entry caller holds) @@ -127,20 +127,20 @@ need_to_update_rrset(void* nd, void* cd, time_t timenow, int equal, int ns) { struct packed_rrset_data* newd = (struct packed_rrset_data*)nd; struct packed_rrset_data* cached = (struct packed_rrset_data*)cd; - /* o store if rrset has been validated - * everything better than bogus data + /* o store if rrset has been validated + * everything better than bogus data * secure is preferred */ if( newd->security == sec_status_secure && cached->security != sec_status_secure) return 1; - if( cached->security == sec_status_bogus && + if( cached->security == sec_status_bogus && newd->security != sec_status_bogus && !equal) return 1; /* o if current RRset is more trustworthy - insert it */ if( newd->trust > cached->trust ) { /* if the cached rrset is bogus, and this one equal, * do not update the TTL - let it expire. */ - if(equal && cached->ttl >= timenow && + if(equal && cached->ttl >= timenow && cached->security == sec_status_bogus) return 0; return 1; @@ -182,7 +182,7 @@ rrset_update_id(struct rrset_ref* ref, struct alloc_cache* alloc) lock_rw_unlock(&ref->key->entry.lock); } -int +int rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref, struct alloc_cache* alloc, time_t timenow) { @@ -200,7 +200,7 @@ rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref, * the passed key in favor of the already stored key. * because of the small gap (see below) this key ptr and id * may prove later to be already deleted, which is no problem - * as it only makes a cache miss. + * as it only makes a cache miss. */ ref->key = (struct ub_packed_rrset_key*)e->key; ref->id = ref->key->id; @@ -226,10 +226,10 @@ rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref, log_assert(ref->key->id != 0); slabhash_insert(&r->table, h, &k->entry, k->entry.data, alloc); if(e) { - /* For NSEC, NSEC3, DNAME, when rdata is updated, update - * the ID number so that proofs in message cache are + /* For NSEC, NSEC3, DNAME, when rdata is updated, update + * the ID number so that proofs in message cache are * invalidated */ - if((rrset_type == LDNS_RR_TYPE_NSEC + if((rrset_type == LDNS_RR_TYPE_NSEC || rrset_type == LDNS_RR_TYPE_NSEC3 || rrset_type == LDNS_RR_TYPE_DNAME) && !equal) { rrset_update_id(ref, alloc); @@ -239,7 +239,7 @@ rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref, return 0; } -void rrset_cache_update_wildcard(struct rrset_cache* rrset_cache, +void rrset_cache_update_wildcard(struct rrset_cache* rrset_cache, struct ub_packed_rrset_key* rrset, uint8_t* ce, size_t ce_len, struct alloc_cache* alloc, time_t timenow) { @@ -272,14 +272,14 @@ void rrset_cache_update_wildcard(struct rrset_cache* rrset_cache, (void)rrset_cache_update(rrset_cache, &ref, alloc, timenow); } -struct ub_packed_rrset_key* -rrset_cache_lookup(struct rrset_cache* r, uint8_t* qname, size_t qnamelen, +struct ub_packed_rrset_key* +rrset_cache_lookup(struct rrset_cache* r, uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, uint32_t flags, time_t timenow, int wr) { struct lruhash_entry* e; struct ub_packed_rrset_key key; - + key.entry.key = &key; key.entry.data = NULL; key.rk.dname = qname; @@ -292,7 +292,7 @@ rrset_cache_lookup(struct rrset_cache* r, uint8_t* qname, size_t qnamelen, if((e = slabhash_lookup(&r->table, key.entry.hash, &key, wr))) { /* check TTL */ - struct packed_rrset_data* data = + struct packed_rrset_data* data = (struct packed_rrset_data*)e->data; if(timenow > data->ttl) { lock_rw_unlock(&e->lock); @@ -304,7 +304,7 @@ rrset_cache_lookup(struct rrset_cache* r, uint8_t* qname, size_t qnamelen, return NULL; } -int +int rrset_array_lock(struct rrset_ref* ref, size_t count, time_t timenow) { size_t i; @@ -323,7 +323,7 @@ rrset_array_lock(struct rrset_ref* ref, size_t count, time_t timenow) return 1; } -void +void rrset_array_unlock(struct rrset_ref* ref, size_t count) { size_t i; @@ -334,7 +334,7 @@ rrset_array_unlock(struct rrset_ref* ref, size_t count) } } -void +void rrset_array_unlock_touch(struct rrset_cache* r, struct regional* scratch, struct rrset_ref* ref, size_t count) { @@ -363,11 +363,11 @@ rrset_array_unlock_touch(struct rrset_cache* r, struct regional* scratch, } } -void -rrset_update_sec_status(struct rrset_cache* r, +void +rrset_update_sec_status(struct rrset_cache* r, struct ub_packed_rrset_key* rrset, time_t now) { - struct packed_rrset_data* updata = + struct packed_rrset_data* updata = (struct packed_rrset_data*)rrset->entry.data; struct lruhash_entry* e; struct packed_rrset_data* cachedata; @@ -403,11 +403,11 @@ rrset_update_sec_status(struct rrset_cache* r, lock_rw_unlock(&e->lock); } -void -rrset_check_sec_status(struct rrset_cache* r, +void +rrset_check_sec_status(struct rrset_cache* r, struct ub_packed_rrset_key* rrset, time_t now) { - struct packed_rrset_data* updata = + struct packed_rrset_data* updata = (struct packed_rrset_data*)rrset->entry.data; struct lruhash_entry* e; struct packed_rrset_data* cachedata; @@ -431,7 +431,7 @@ rrset_check_sec_status(struct rrset_cache* r, for(i=0; icount+cachedata->rrsig_count; i++) if(cachedata->rr_ttl[i] < now) updata->rr_ttl[i] = 0; - else updata->rr_ttl[i] = + else updata->rr_ttl[i] = cachedata->rr_ttl[i]-now; } if(cachedata->trust > updata->trust) diff --git a/sbin/unwind/libunbound/services/cache/rrset.h b/sbin/unwind/libunbound/services/cache/rrset.h index 7c36d4032..581445f08 100644 --- a/sbin/unwind/libunbound/services/cache/rrset.h +++ b/sbin/unwind/libunbound/services/cache/rrset.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -64,7 +64,7 @@ struct rrset_cache { * @param alloc: initial default rrset key allocation. * @return: NULL on error. */ -struct rrset_cache* rrset_cache_create(struct config_file* cfg, +struct rrset_cache* rrset_cache_create(struct config_file* cfg, struct alloc_cache* alloc); /** @@ -82,7 +82,7 @@ void rrset_cache_delete(struct rrset_cache* r); * @param alloc: initial default rrset key allocation. * @return 0 on error, or new rrset cache pointer on success. */ -struct rrset_cache* rrset_cache_adjust(struct rrset_cache* r, +struct rrset_cache* rrset_cache_adjust(struct rrset_cache* r, struct config_file* cfg, struct alloc_cache* alloc); /** @@ -91,7 +91,7 @@ struct rrset_cache* rrset_cache_adjust(struct rrset_cache* r, * * This routine is faster than a hashtable lookup: * o no bin_lock is acquired. - * o no walk through the bin-overflow-list. + * o no walk through the bin-overflow-list. * o no comparison of the entry key to find it. * * @param r: rrset cache. @@ -130,7 +130,7 @@ void rrset_cache_touch(struct rrset_cache* r, struct ub_packed_rrset_key* key, * 2: reference updated, item in cache is considered superior. * also the rdata is equal (but other parameters in cache are superior). */ -int rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref, +int rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref, struct alloc_cache* alloc, time_t timenow); /** @@ -140,14 +140,14 @@ int rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref, * necessary. * * @param rrset_cache: the rrset cache. - * @param rrset: which rrset to cache as wildcard. This rrset is left + * @param rrset: which rrset to cache as wildcard. This rrset is left * untouched. * @param ce: the closest encloser, will be uses to generate the wildcard dname. * @param ce_len: the closest encloser length. * @param alloc: how to allocate (and deallocate) the special rrset key. * @param timenow: current time (to see if ttl in cache is expired). */ -void rrset_cache_update_wildcard(struct rrset_cache* rrset_cache, +void rrset_cache_update_wildcard(struct rrset_cache* rrset_cache, struct ub_packed_rrset_key* rrset, uint8_t* ce, size_t ce_len, struct alloc_cache* alloc, time_t timenow); @@ -179,7 +179,7 @@ struct ub_packed_rrset_key* rrset_cache_lookup(struct rrset_cache* r, * @return true on success, false on a failure, which can be that some * RRsets have timed out, or that they do not exist any more, the * RRsets have been purged from the cache. - * If true, you hold readlocks on all the ref items. + * If true, you hold readlocks on all the ref items. */ int rrset_array_lock(struct rrset_ref* ref, size_t count, time_t timenow); @@ -211,24 +211,24 @@ void rrset_array_unlock_touch(struct rrset_cache* r, struct regional* scratch, * If found, checks if rdata is equal. * If so, it will update the security, trust and rrset-ttl values. * The values are only updated if security is increased (towards secure). - * @param r: the rrset cache. - * @param rrset: which rrset to attempt to update. This rrset is left + * @param r: the rrset cache. + * @param rrset: which rrset to attempt to update. This rrset is left * untouched. The rrset in the cache is updated in-place. * @param now: current time. */ -void rrset_update_sec_status(struct rrset_cache* r, +void rrset_update_sec_status(struct rrset_cache* r, struct ub_packed_rrset_key* rrset, time_t now); /** * Looks up security status of an rrset. Looks up the rrset. * If found, checks if rdata is equal, and entry did not expire. * If so, it will update the security, trust and rrset-ttl values. - * @param r: the rrset cache. + * @param r: the rrset cache. * @param rrset: This rrset may change security status due to the cache. * But its status will only improve, towards secure. * @param now: current time. */ -void rrset_check_sec_status(struct rrset_cache* r, +void rrset_check_sec_status(struct rrset_cache* r, struct ub_packed_rrset_key* rrset, time_t now); /** diff --git a/sbin/unwind/libunbound/services/listen_dnsport.h b/sbin/unwind/libunbound/services/listen_dnsport.h index 816d79aea..31ca8af85 100644 --- a/sbin/unwind/libunbound/services/listen_dnsport.h +++ b/sbin/unwind/libunbound/services/listen_dnsport.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -118,7 +118,7 @@ struct unbound_socket { }; /** - * Single linked list to store shared ports that have been + * Single linked list to store shared ports that have been * opened for use by all threads. */ struct listen_port { @@ -137,7 +137,7 @@ struct listen_port { /** * Create shared listening ports - * Getaddrinfo, create socket, bind and listen to zero or more + * Getaddrinfo, create socket, bind and listen to zero or more * interfaces for IP4 and/or IP6, for UDP and/or TCP. * On the given port number. It creates the sockets. * @param cfg: settings on what ports to open. @@ -176,7 +176,7 @@ int resolve_interface_names(char** ifs, int num_ifs, * for default all ifs. * @param ports: the list of shared ports. * @param bufsize: size of datagram buffer. - * @param tcp_accept_count: max number of simultaneous TCP connections + * @param tcp_accept_count: max number of simultaneous TCP connections * from clients. * @param tcp_idle_timeout: idle timeout for TCP connections in msec. * @param harden_large_queries: whether query size should be limited. @@ -249,7 +249,7 @@ void listen_start_accept(struct listen_dnsport* listen); IPv6 proto (family) is not available. * @param rcv: set size on rcvbuf with socket option, if 0 it is not set. * @param snd: set size on sndbuf with socket option, if 0 it is not set. - * @param listen: if true, this is a listening UDP port, eg port 53, and + * @param listen: if true, this is a listening UDP port, eg port 53, and * set SO_REUSEADDR on it. * @param reuseport: if nonNULL and true, try to set SO_REUSEPORT on * listening UDP port. Set to false on return if it failed to do so. @@ -259,7 +259,7 @@ void listen_start_accept(struct listen_dnsport* listen); * @param dscp: DSCP to use. * @return: the socket. -1 on error. */ -int create_udp_sock(int family, int socktype, struct sockaddr* addr, +int create_udp_sock(int family, int socktype, struct sockaddr* addr, socklen_t addrlen, int v6only, int* inuse, int* noproto, int rcv, int snd, int listen, int* reuseport, int transparent, int freebind, int use_systemd, int dscp); @@ -271,7 +271,7 @@ int create_udp_sock(int family, int socktype, struct sockaddr* addr, * @param reuseport: if nonNULL and true, try to set SO_REUSEPORT on * listening UDP port. Set to false on return if it failed to do so. * @param transparent: set IP_TRANSPARENT socket option. - * @param mss: maximum segment size of the socket. if zero, leaves the default. + * @param mss: maximum segment size of the socket. if zero, leaves the default. * @param nodelay: if true set TCP_NODELAY and TCP_QUICKACK socket options. * @param freebind: set IP_FREEBIND socket option. * @param use_systemd: if true, fetch sockets from systemd. @@ -414,7 +414,7 @@ int tcp_req_info_add_meshstate(struct tcp_req_info* req, void tcp_req_info_send_reply(struct tcp_req_info* req); /** the read channel has closed - * @param req: request. remaining queries are looked up and answered. + * @param req: request. remaining queries are looked up and answered. * @return zero if nothing to do, just close the tcp. */ int tcp_req_info_handle_read_close(struct tcp_req_info* req); @@ -428,7 +428,7 @@ size_t http2_get_query_buffer_size(void); size_t http2_get_response_buffer_size(void); #ifdef HAVE_NGHTTP2 -/** +/** * Create nghttp2 callbacks to handle HTTP2 requests. * @return malloc'ed struct, NULL on failure */ diff --git a/sbin/unwind/libunbound/services/localzone.c b/sbin/unwind/libunbound/services/localzone.c index 44da22d78..0ca003819 100644 --- a/sbin/unwind/libunbound/services/localzone.c +++ b/sbin/unwind/libunbound/services/localzone.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -94,10 +94,10 @@ void local_zones_print(struct local_zones* zones) lock_rw_unlock(&zones->lock); } -struct local_zones* +struct local_zones* local_zones_create(void) { - struct local_zones* zones = (struct local_zones*)calloc(1, + struct local_zones* zones = (struct local_zones*)calloc(1, sizeof(*zones)); if(!zones) return NULL; @@ -109,14 +109,14 @@ local_zones_create(void) } /** helper traverse to delete zones */ -static void +static void lzdel(rbnode_type* n, void* ATTR_UNUSED(arg)) { struct local_zone* z = (struct local_zone*)n->key; local_zone_delete(z); } -void +void local_zones_delete(struct local_zones* zones) { if(!zones) @@ -127,7 +127,7 @@ local_zones_delete(struct local_zones* zones) free(zones); } -void +void local_zone_delete(struct local_zone* z) { if(!z) @@ -139,7 +139,7 @@ local_zone_delete(struct local_zone* z) free(z); } -int +int local_zone_cmp(const void* z1, const void* z2) { /* first sort on class, so that hierarchy can be maintained within @@ -155,13 +155,13 @@ local_zone_cmp(const void* z1, const void* z2) return dname_lab_cmp(a->name, a->namelabs, b->name, b->namelabs, &m); } -int +int local_data_cmp(const void* d1, const void* d2) { struct local_data* a = (struct local_data*)d1; struct local_data* b = (struct local_data*)d2; int m; - return dname_canon_lab_cmp(a->name, a->namelabs, b->name, + return dname_canon_lab_cmp(a->name, a->namelabs, b->name, b->namelabs, &m); } @@ -181,7 +181,7 @@ parse_dname(const char* str, uint8_t** res, size_t* len, int* labs) /** create a new localzone */ static struct local_zone* -local_zone_create(uint8_t* nm, size_t len, int labs, +local_zone_create(uint8_t* nm, size_t len, int labs, enum localzone_type t, uint16_t dclass) { struct local_zone* z = (struct local_zone*)calloc(1, sizeof(*z)); @@ -208,7 +208,7 @@ local_zone_create(uint8_t* nm, size_t len, int labs, /** enter a new zone with allocated dname returns with WRlock */ static struct local_zone* -lz_enter_zone_dname(struct local_zones* zones, uint8_t* nm, size_t len, +lz_enter_zone_dname(struct local_zones* zones, uint8_t* nm, size_t len, int labs, enum localzone_type t, uint16_t c) { struct local_zone* z = local_zone_create(nm, len, labs, t, c); @@ -415,11 +415,11 @@ rrset_insert_rr(struct regional* region, struct packed_rrset_data* pd, return 0; } if(pd->count > 1) { - memcpy(pd->rr_len+1, oldlen, + memcpy(pd->rr_len+1, oldlen, sizeof(*pd->rr_len)*(pd->count-1)); - memcpy(pd->rr_ttl+1, oldttl, + memcpy(pd->rr_ttl+1, oldttl, sizeof(*pd->rr_ttl)*(pd->count-1)); - memcpy(pd->rr_data+1, olddata, + memcpy(pd->rr_data+1, olddata, sizeof(*pd->rr_data)*(pd->count-1)); } pd->rr_len[0] = rdata_len; @@ -454,7 +454,7 @@ local_rrset_remove_rr(struct packed_rrset_data* pd, size_t index) return 1; } -struct local_data* +struct local_data* local_zone_find_data(struct local_zone* z, uint8_t* nm, size_t nmlen, int nmlabs) { struct local_data key; @@ -467,7 +467,7 @@ local_zone_find_data(struct local_zone* z, uint8_t* nm, size_t nmlen, int nmlabs /** find a node, create it if not and all its empty nonterminal parents */ static int -lz_find_create_node(struct local_zone* z, uint8_t* nm, size_t nmlen, +lz_find_create_node(struct local_zone* z, uint8_t* nm, size_t nmlen, int nmlabs, struct local_data** res) { struct local_data* ld = local_zone_find_data(z, nm, nmlen, nmlabs); @@ -587,7 +587,7 @@ local_zone_enter_rr(struct local_zone* z, uint8_t* nm, size_t nmlen, rrstr)) return 0; } - } + } pd = (struct packed_rrset_data*)rrset->rrset->entry.data; log_assert(rrset && pd); @@ -595,7 +595,7 @@ local_zone_enter_rr(struct local_zone* z, uint8_t* nm, size_t nmlen, if(rr_is_duplicate(pd, rdata, rdata_len)) { verbose(VERB_ALGO, "ignoring duplicate RR: %s", rrstr); return 1; - } + } return rrset_insert_rr(z->region, pd, rdata, rdata_len, ttl, rrstr); } @@ -676,7 +676,7 @@ lz_enter_zone_tag(struct local_zones* zones, char* zname, uint8_t* list, return 0; } dname_labs = dname_count_labels(dname); - + lock_rw_rdlock(&zones->lock); z = local_zones_find(zones, dname, dname_len, dname_labs, rr_class); if(!z) { @@ -832,7 +832,7 @@ lz_nodefault(struct config_file* cfg, const char* name) for(p = cfg->local_zones_nodefault; p; p = p->next) { /* compare zone name, lowercase, compare without ending . */ - if(strncasecmp(p->str, name, len) == 0 && + if(strncasecmp(p->str, name, len) == 0 && (strlen(p->str) == len || (strlen(p->str)==len+1 && p->str[len] == '.'))) return 1; @@ -883,7 +883,7 @@ int local_zone_enter_defaults(struct local_zones* zones, struct config_file* cfg /* localhost. zone */ if(!lz_exists(zones, "localhost.") && !lz_nodefault(cfg, "localhost.")) { - if(!(z=lz_enter_zone(zones, "localhost.", "redirect", + if(!(z=lz_enter_zone(zones, "localhost.", "redirect", LDNS_RR_CLASS_IN)) || !lz_enter_rr_into_zone(z, "localhost. 10800 IN NS localhost.") || @@ -903,7 +903,7 @@ int local_zone_enter_defaults(struct local_zones* zones, struct config_file* cfg /* reverse ip4 zone */ if(!lz_exists(zones, "127.in-addr.arpa.") && !lz_nodefault(cfg, "127.in-addr.arpa.")) { - if(!(z=lz_enter_zone(zones, "127.in-addr.arpa.", "static", + if(!(z=lz_enter_zone(zones, "127.in-addr.arpa.", "static", LDNS_RR_CLASS_IN)) || !lz_enter_rr_into_zone(z, "127.in-addr.arpa. 10800 IN NS localhost.") || @@ -921,7 +921,7 @@ int local_zone_enter_defaults(struct local_zones* zones, struct config_file* cfg /* reverse ip6 zone */ if(!lz_exists(zones, "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa.") && !lz_nodefault(cfg, "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa.")) { - if(!(z=lz_enter_zone(zones, "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa.", "static", + if(!(z=lz_enter_zone(zones, "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa.", "static", LDNS_RR_CLASS_IN)) || !lz_enter_rr_into_zone(z, "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa. 10800 IN NS localhost.") || @@ -1097,7 +1097,7 @@ lz_setup_implicit(struct local_zones* zones, struct config_file* cfg) continue; } /* find smallest shared topdomain */ - (void)dname_lab_cmp(nm, nmlabs, + (void)dname_lab_cmp(nm, nmlabs, rr_name, labs, &m); free(rr_name); if(m < match) @@ -1120,7 +1120,7 @@ lz_setup_implicit(struct local_zones* zones, struct config_file* cfg) log_err("out of memory"); return 0; } - log_nametypeclass(VERB_ALGO, "implicit transparent local-zone", + log_nametypeclass(VERB_ALGO, "implicit transparent local-zone", n2, 0, dclass); if(!( #ifndef THREADS_DISABLED @@ -1132,7 +1132,7 @@ lz_setup_implicit(struct local_zones* zones, struct config_file* cfg) } lock_rw_unlock(&z->lock); } - if(have_other_classes) { + if(have_other_classes) { /* restart to setup other class */ return lz_setup_implicit(zones, cfg); } @@ -1154,7 +1154,7 @@ lz_enter_zone_tags(struct local_zones* zones, struct config_file* cfg) if(c) verbose(VERB_ALGO, "applied tags to %d local zones", c); return 1; } - + /** enter auth data */ static int lz_enter_data(struct local_zones* zones, struct config_file* cfg) @@ -1179,7 +1179,7 @@ lz_freeup_cfg(struct config_file* cfg) cfg->local_data = NULL; } -int +int local_zones_apply_cfg(struct local_zones* zones, struct config_file* cfg) { /* create zones from zone statements. */ @@ -1214,7 +1214,7 @@ local_zones_apply_cfg(struct local_zones* zones, struct config_file* cfg) return 1; } -struct local_zone* +struct local_zone* local_zones_lookup(struct local_zones* zones, uint8_t* name, size_t len, int labs, uint16_t dclass, uint16_t dtype) { @@ -1222,7 +1222,7 @@ local_zones_lookup(struct local_zones* zones, dclass, dtype, NULL, 0, 1); } -struct local_zone* +struct local_zone* local_zones_tags_lookup(struct local_zones* zones, uint8_t* name, size_t len, int labs, uint16_t dclass, uint16_t dtype, uint8_t* taglist, size_t taglen, int ignoretags) @@ -1252,7 +1252,7 @@ local_zones_tags_lookup(struct local_zones* zones, while(result) { /* go up until qname is zone or subdomain of zone */ if(result->namelabs <= m) if(ignoretags || !result->taglist || - taglist_intersect(result->taglist, + taglist_intersect(result->taglist, result->taglen, taglist, taglen)) break; result = result->parent; @@ -1260,7 +1260,7 @@ local_zones_tags_lookup(struct local_zones* zones, return result; } -struct local_zone* +struct local_zone* local_zones_find(struct local_zones* zones, uint8_t* name, size_t len, int labs, uint16_t dclass) { @@ -1379,7 +1379,7 @@ local_data_find_tag_datas(const struct query_info* qinfo, rdr_type = sldns_wirerr_get_type(rr, len, 1); if(rdr_type != qinfo->qtype && rdr_type != LDNS_RR_TYPE_CNAME) continue; - + /* do we have entries already? if not setup key */ if(r->rk.dname == NULL) { r->entry.key = r; @@ -1773,7 +1773,7 @@ lz_type(uint8_t *taglist, size_t taglen, uint8_t *taglist2, size_t taglen2, struct comm_reply* repinfo, struct rbtree_type* override_tree, int* tag, char** tagname, int num_tags) { - struct local_zone_override* lzo; + struct local_zone_override* lzo; if(repinfo && override_tree) { lzo = (struct local_zone_override*)addr_tree_lookup( override_tree, &repinfo->client_addr, @@ -1818,13 +1818,13 @@ local_data_find_tag_action(const uint8_t* taglist, size_t taglen, } return lzt; } - tagmatch >>= 1; + tagmatch >>= 1; } } return lzt; } -int +int local_zones_answer(struct local_zones* zones, struct module_env* env, struct query_info* qinfo, struct edns_data* edns, sldns_buffer* buf, struct regional* temp, struct comm_reply* repinfo, uint8_t* taglist, @@ -1833,7 +1833,7 @@ local_zones_answer(struct local_zones* zones, struct module_env* env, char** tagname, int num_tags, struct view* view) { /* see if query is covered by a zone, - * if so: - try to match (exact) local data + * if so: - try to match (exact) local data * - look at zone type for negative response. */ int labs = dname_count_labels(qinfo->qname); struct local_data* ld = NULL; @@ -1870,7 +1870,7 @@ local_zones_answer(struct local_zones* zones, struct module_env* env, if(z && verbosity >= VERB_ALGO) { char zname[255+1]; dname_str(z->name, zname); - verbose(VERB_ALGO, "using localzone %s %s from view %s", + verbose(VERB_ALGO, "using localzone %s %s from view %s", zname, local_zone_type2str(lzt), view->name); } lock_rw_unlock(&view->lock); @@ -1947,7 +1947,7 @@ const char* local_zone_type2str(enum localzone_type t) case local_zone_truncate: return "truncate"; case local_zone_invalid: return "invalid"; } - return "badtyped"; + return "badtyped"; } int local_zone_str2type(const char* type, enum localzone_type* t) @@ -1996,7 +1996,7 @@ int local_zone_str2type(const char* type, enum localzone_type* t) /** iterate over the kiddies of the given name and set their parent ptr */ static void -set_kiddo_parents(struct local_zone* z, struct local_zone* match, +set_kiddo_parents(struct local_zone* z, struct local_zone* match, struct local_zone* newp) { /* both zones and z are locked already */ @@ -2104,7 +2104,7 @@ static int is_terminal(struct local_data* d) { /* for empty nonterminals, the deeper domain names are sorted - * right after them, so simply check the next name in the tree + * right after them, so simply check the next name in the tree */ struct local_data* n = (struct local_data*)rbtree_next(&d->node); if(n == (struct local_data*)RBTREE_NULL) @@ -2115,8 +2115,8 @@ is_terminal(struct local_data* d) } /** delete empty terminals from tree when final data is deleted */ -static void -del_empty_term(struct local_zone* z, struct local_data* d, +static void +del_empty_term(struct local_zone* z, struct local_data* d, uint8_t* name, size_t len, int labs) { while(d && d->rrsets == NULL && is_terminal(d)) { @@ -2142,7 +2142,7 @@ del_local_rrset(struct local_data* d, uint16_t dtype) prev = p; p = p->next; } - if(!p) + if(!p) return; /* rrset type not found */ /* unlink it */ if(prev) prev->next = p->next; @@ -2150,7 +2150,7 @@ del_local_rrset(struct local_data* d, uint16_t dtype) /* no memory recycling for zone deletions ... */ } -void local_zones_del_data(struct local_zones* zones, +void local_zones_del_data(struct local_zones* zones, uint8_t* name, size_t len, int labs, uint16_t dclass) { /* find zone */ diff --git a/sbin/unwind/libunbound/services/localzone.h b/sbin/unwind/libunbound/services/localzone.h index 4456893ee..0c67b3fe5 100644 --- a/sbin/unwind/libunbound/services/localzone.h +++ b/sbin/unwind/libunbound/services/localzone.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -86,11 +86,11 @@ enum localzone_type { local_zone_inform_deny, /** log client address, and direct */ local_zone_inform_redirect, - /** resolve normally, even when there is local data */ + /** resolve normally, even when there is local data */ local_zone_always_transparent, /** resolve normally, even when there is local data but return NODATA for A queries */ local_zone_block_a, - /** answer with error, even when there is local data */ + /** answer with error, even when there is local data */ local_zone_always_refuse, /** answer with nxdomain, even when there is local data */ local_zone_always_nxdomain, @@ -134,7 +134,7 @@ struct local_zone { size_t namelen; /** number of labels in zone name */ int namelabs; - /** the class of this zone. + /** the class of this zone. * uses 'dclass' to not conflict with c++ keyword class. */ uint16_t dclass; @@ -218,7 +218,7 @@ struct local_zones* local_zones_create(void); void local_zones_delete(struct local_zones* zones); /** - * Apply config settings; setup the local authoritative data. + * Apply config settings; setup the local authoritative data. * Takes care of locking. * @param zones: is set up. * @param cfg: config data. @@ -264,7 +264,7 @@ void local_zone_delete(struct local_zone* z); * local-zone's tags. * @return closest local_zone or NULL if no covering zone is found. */ -struct local_zone* local_zones_tags_lookup(struct local_zones* zones, +struct local_zone* local_zones_tags_lookup(struct local_zones* zones, uint8_t* name, size_t len, int labs, uint16_t dclass, uint16_t dtype, uint8_t* taglist, size_t taglen, int ignoretags); @@ -280,11 +280,11 @@ struct local_zone* local_zones_tags_lookup(struct local_zones* zones, * pass 0 to just plain find a zone for a name. * @return closest local_zone or NULL if no covering zone is found. */ -struct local_zone* local_zones_lookup(struct local_zones* zones, +struct local_zone* local_zones_lookup(struct local_zones* zones, uint8_t* name, size_t len, int labs, uint16_t dclass, uint16_t dtype); /** - * Debug helper. Print all zones + * Debug helper. Print all zones * Takes care of locking. * @param zones: the zones tree */ @@ -309,8 +309,8 @@ void local_zones_print(struct local_zones* zones); * @param tagname: array of tag name strings (for debug output). * @param num_tags: number of items in tagname array. * @param view: answer using this view. May be NULL. - * @return true if answer is in buffer. false if query is not answered - * by authority data. If the reply should be dropped altogether, the return + * @return true if answer is in buffer. false if query is not answered + * by authority data. If the reply should be dropped altogether, the return * value is true, but the buffer is cleared (empty). * It can also return true if a non-exact alias answer is found. In this * case qinfo->local_alias points to the corresponding alias RRset but the @@ -328,7 +328,7 @@ int local_zones_answer(struct local_zones* zones, struct module_env* env, struct config_strlist** tag_datas, size_t tag_datas_size, char** tagname, int num_tags, struct view* view); -/** +/** * Answer using the local zone only (not local data used). * @param z: zone for query. * @param env: module environment. @@ -374,7 +374,7 @@ const char* local_zone_type2str(enum localzone_type t); * @param dclass: class to lookup. * @return the exact local_zone or NULL. */ -struct local_zone* local_zones_find(struct local_zones* zones, +struct local_zone* local_zones_find(struct local_zones* zones, uint8_t* name, size_t len, int labs, uint16_t dclass); /** @@ -405,8 +405,8 @@ local_zones_find_le(struct local_zones* zones, * @param tp: type. * @return local_zone or NULL on error, caller must printout memory error. */ -struct local_zone* local_zones_add_zone(struct local_zones* zones, - uint8_t* name, size_t len, int labs, uint16_t dclass, +struct local_zone* local_zones_add_zone(struct local_zones* zones, + uint8_t* name, size_t len, int labs, uint16_t dclass, enum localzone_type tp); /** @@ -436,12 +436,12 @@ int local_zones_add_RR(struct local_zones* zones, const char* rr); * @param labs: labelcount of name. * @param dclass: class to remove. */ -void local_zones_del_data(struct local_zones* zones, +void local_zones_del_data(struct local_zones* zones, uint8_t* name, size_t len, int labs, uint16_t dclass); -/** - * Form wireformat from text format domain name. +/** + * Form wireformat from text format domain name. * @param str: the domain name in text "www.example.com" * @param res: resulting wireformat is stored here with malloc. * @param len: length of resulting wireformat. @@ -639,6 +639,6 @@ local_zone_enter_rr(struct local_zone* z, uint8_t* nm, size_t nmlen, * @param nmlabs: labs of nm * @return local_data on exact match, NULL otherwise. */ -struct local_data* +struct local_data* local_zone_find_data(struct local_zone* z, uint8_t* nm, size_t nmlen, int nmlabs); #endif /* SERVICES_LOCALZONE_H */ diff --git a/sbin/unwind/libunbound/services/mesh.h b/sbin/unwind/libunbound/services/mesh.h index d926cfc9d..aa36312f6 100644 --- a/sbin/unwind/libunbound/services/mesh.h +++ b/sbin/unwind/libunbound/services/mesh.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -76,7 +76,7 @@ struct respip_client_info; */ #define MESH_MAX_SUBSUB 1024 -/** +/** * Mesh of query states */ struct mesh_area { @@ -92,7 +92,7 @@ struct mesh_area { /** count of the total number of mesh_reply entries */ size_t num_reply_addrs; - /** count of the number of mesh_states that have mesh_replies + /** count of the number of mesh_states that have mesh_replies * Because a state can send results to multiple reply addresses, * this number must be equal or lower than num_reply_addrs. */ size_t num_reply_states; @@ -171,14 +171,14 @@ struct mesh_state { rbnode_type node; /** node in mesh_area runnable tree, key is this struct */ rbnode_type run_node; - /** the query state. Note that the qinfo and query_flags + /** the query state. Note that the qinfo and query_flags * may not change. */ struct module_qstate s; /** the list of replies to clients for the results */ struct mesh_reply* reply_list; /** the list of callbacks for the results */ struct mesh_cb* cb_list; - /** set of superstates (that want this state's result) + /** set of superstates (that want this state's result) * contains struct mesh_state_ref* */ rbtree_type super_set; /** set of substates (that this state needs to continue) @@ -192,7 +192,7 @@ struct mesh_state { /** next in linked list for reply states */ struct mesh_state* next; /** if this state is in the forever list, jostle list, or neither */ - enum mesh_list_select { mesh_no_list, mesh_forever_list, + enum mesh_list_select { mesh_no_list, mesh_forever_list, mesh_jostle_list } list_select; /** pointer to this state for uniqueness or NULL */ struct mesh_state* unique; @@ -203,7 +203,7 @@ struct mesh_state { /** * Rbtree reference to a mesh_state. - * Used in super_set and sub_set. + * Used in super_set and sub_set. */ struct mesh_state_ref { /** node in rbtree for set, key is this structure */ @@ -236,7 +236,7 @@ struct mesh_reply { struct http2_stream* h2_stream; }; -/** +/** * Mesh result callback func. * called as func(cb_arg, rcode, buffer_with_reply, security, why_bogus, * was_ratelimited); @@ -274,7 +274,7 @@ struct mesh_cb { * @param env: environment for new queries. * @return mesh: the new mesh or NULL on error. */ -struct mesh_area* mesh_create(struct module_stack* stack, +struct mesh_area* mesh_create(struct module_stack* stack, struct module_env* env); /** @@ -308,7 +308,7 @@ void mesh_new_client(struct mesh_area* mesh, struct query_info* qinfo, /** * New query with callback. Create new query state if needed, and - * add mesh_cb to it. + * add mesh_cb to it. * Will run the mesh area queries to process if a new query state is created. * * @param mesh: the mesh. @@ -324,7 +324,7 @@ void mesh_new_client(struct mesh_area* mesh, struct query_info* qinfo, * @return 0 on error. */ int mesh_new_callback(struct mesh_area* mesh, struct query_info* qinfo, - uint16_t qflags, struct edns_data* edns, struct sldns_buffer* buf, + uint16_t qflags, struct edns_data* edns, struct sldns_buffer* buf, uint16_t qid, mesh_cb_func_type cb, void* cb_arg, int rpz_passthru); /** @@ -436,15 +436,15 @@ int mesh_add_sub(struct module_qstate* qstate, struct query_info* qinfo, * * @param mstate: mesh state that is done. return_rcode and return_msg * are used for replies. - * return_rcode: if not 0 (NOERROR) an error is sent back (and + * return_rcode: if not 0 (NOERROR) an error is sent back (and * return_msg is ignored). * return_msg: reply to encode and send back to clients. */ void mesh_query_done(struct mesh_state* mstate); /** - * Call inform_super for the super query states that are interested in the - * results from this query state. These can then be changed for error + * Call inform_super for the super query states that are interested in the + * results from this query state. These can then be changed for error * or results. * Called when a module is module_finished or returns module_error. * The super query states become runnable with event module_event_pass, @@ -488,7 +488,7 @@ struct mesh_state* mesh_state_create(struct module_env* env, void mesh_state_make_unique(struct mesh_state* mstate); /** - * Cleanup a mesh state and its query state. Does not do rbtree or + * Cleanup a mesh state and its query state. Does not do rbtree or * reference cleanup. * @param mstate: mesh state to cleanup. Its pointer may no longer be used * afterwards. Cleanup rbtrees before calling this function. @@ -567,7 +567,7 @@ int mesh_state_add_cb(struct mesh_state* s, struct edns_data* edns, * @param ev: event the mstate. Others get event_pass. * @param e: if a reply, its outbound entry. */ -void mesh_run(struct mesh_area* mesh, struct mesh_state* mstate, +void mesh_run(struct mesh_area* mesh, struct mesh_state* mstate, enum module_ev ev, struct outbound_entry* e); /** diff --git a/sbin/unwind/libunbound/services/modstack.c b/sbin/unwind/libunbound/services/modstack.c index a90d7178c..fc46286cd 100644 --- a/sbin/unwind/libunbound/services/modstack.c +++ b/sbin/unwind/libunbound/services/modstack.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -222,7 +222,7 @@ module_func_block* module_factory(const char** str) return NULL; } -int +int modstack_setup(struct module_stack* stack, const char* module_conf, struct module_env* env) { @@ -247,7 +247,7 @@ modstack_setup(struct module_stack* stack, const char* module_conf, return 1; } -void +void modstack_desetup(struct module_stack* stack, struct module_env* env) { int i; @@ -260,7 +260,7 @@ modstack_desetup(struct module_stack* stack, struct module_env* env) stack->mod = NULL; } -int +int modstack_find(struct module_stack* stack, const char* name) { int i; diff --git a/sbin/unwind/libunbound/services/modstack.h b/sbin/unwind/libunbound/services/modstack.h index 3ff01b54d..54c03d1e2 100644 --- a/sbin/unwind/libunbound/services/modstack.h +++ b/sbin/unwind/libunbound/services/modstack.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -62,7 +62,7 @@ void modstack_init(struct module_stack* stack); /** * Read config file module settings and set up the modfunc block - * @param stack: the stack of modules (empty before call). + * @param stack: the stack of modules (empty before call). * @param module_conf: string what modules to insert. * @return false on error */ diff --git a/sbin/unwind/libunbound/services/outbound_list.c b/sbin/unwind/libunbound/services/outbound_list.c index ad73380bc..3881258f1 100644 --- a/sbin/unwind/libunbound/services/outbound_list.c +++ b/sbin/unwind/libunbound/services/outbound_list.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -44,13 +44,13 @@ #include "services/outbound_list.h" #include "services/outside_network.h" -void +void outbound_list_init(struct outbound_list* list) { list->first = NULL; } -void +void outbound_list_clear(struct outbound_list* list) { struct outbound_entry *p, *np; @@ -64,7 +64,7 @@ outbound_list_clear(struct outbound_list* list) outbound_list_init(list); } -void +void outbound_list_insert(struct outbound_list* list, struct outbound_entry* e) { if(list->first) @@ -74,7 +74,7 @@ outbound_list_insert(struct outbound_list* list, struct outbound_entry* e) list->first = e; } -void +void outbound_list_remove(struct outbound_list* list, struct outbound_entry* e) { if(!e) diff --git a/sbin/unwind/libunbound/services/outbound_list.h b/sbin/unwind/libunbound/services/outbound_list.h index 73c137d50..7e26a11d2 100644 --- a/sbin/unwind/libunbound/services/outbound_list.h +++ b/sbin/unwind/libunbound/services/outbound_list.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -90,16 +90,16 @@ void outbound_list_clear(struct outbound_list* list); * @param e: entry to add, it is only half initialised at call start, fully * initialised at call end. */ -void outbound_list_insert(struct outbound_list* list, +void outbound_list_insert(struct outbound_list* list, struct outbound_entry* e); /** - * Remove an entry from the list, and deletes it. + * Remove an entry from the list, and deletes it. * Deletes serviced query in the entry. * @param list: the list to remove from. * @param e: the entry to remove. */ -void outbound_list_remove(struct outbound_list* list, +void outbound_list_remove(struct outbound_list* list, struct outbound_entry* e); #endif /* SERVICES_OUTBOUND_LIST_H */ diff --git a/sbin/unwind/libunbound/services/outside_network.c b/sbin/unwind/libunbound/services/outside_network.c index 2a219cbc6..9e50a2cb1 100644 --- a/sbin/unwind/libunbound/services/outside_network.c +++ b/sbin/unwind/libunbound/services/outside_network.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -100,7 +100,7 @@ static int serviced_tcp_send(struct serviced_query* sq, sldns_buffer* buff); static void serviced_callbacks(struct serviced_query* sq, int error, struct comm_point* c, struct comm_reply* rep); -int +int pending_cmp(const void* key1, const void* key2) { struct pending *p1 = (struct pending*)key1; @@ -113,7 +113,7 @@ pending_cmp(const void* key1, const void* key2) return sockaddr_cmp(&p1->addr, p1->addrlen, &p2->addr, p2->addrlen); } -int +int serviced_cmp(const void* key1, const void* key2) { struct serviced_query* q1 = (struct serviced_query*)key1; @@ -188,7 +188,7 @@ int reuse_id_cmp(const void* key1, const void* key2) return 0; } -/** delete waiting_tcp entry. Does not unlink from waiting list. +/** delete waiting_tcp entry. Does not unlink from waiting list. * @param w: to delete. */ static void @@ -200,7 +200,7 @@ waiting_tcp_delete(struct waiting_tcp* w) free(w); } -/** +/** * Pick random outgoing-interface of that family, and bind it. * port set to 0 so OS picks a port number for us. * if it is the ANY address, do not bind. @@ -659,7 +659,7 @@ outnet_tcp_take_into_use(struct waiting_tcp* w) fd_set_nonblock(s); #ifdef USE_OSX_MSG_FASTOPEN - /* API for fast open is different here. We use a connectx() function and + /* API for fast open is different here. We use a connectx() function and then writes can happen as normal even using SSL.*/ /* connectx requires that the len be set in the sockaddr struct*/ struct sockaddr_in *addr_in = (struct sockaddr_in *)&w->addr; @@ -670,7 +670,7 @@ outnet_tcp_take_into_use(struct waiting_tcp* w) endpoints.sae_srcaddrlen = 0; endpoints.sae_dstaddr = (struct sockaddr *)&w->addr; endpoints.sae_dstaddrlen = w->addrlen; - if (connectx(s, &endpoints, SAE_ASSOCID_ANY, + if (connectx(s, &endpoints, SAE_ASSOCID_ANY, CONNECT_DATA_IDEMPOTENT | CONNECT_RESUME_ON_READ_WRITE, NULL, 0, NULL, NULL) == -1) { /* if fails, failover to connect for OSX 10.10 */ @@ -684,7 +684,7 @@ outnet_tcp_take_into_use(struct waiting_tcp* w) #ifdef USE_MSG_FASTOPEN pend->c->tcp_do_fastopen = 1; /* Only do TFO for TCP in which case no connect() is required here. - Don't combine client TFO with SSL, since OpenSSL can't + Don't combine client TFO with SSL, since OpenSSL can't currently support doing a handshake on fd that already isn't connected*/ if (w->outnet->sslctx && w->ssl_upstream) { if(connect(s, (struct sockaddr*)&w->addr, w->addrlen) == -1) { @@ -1169,7 +1169,7 @@ void reuse_del_readwait(rbtree_type* tree_by_id) /** decommission a tcp buffer, closes commpoint and frees waiting_tcp entry */ static void -decommission_pending_tcp(struct outside_network* outnet, +decommission_pending_tcp(struct outside_network* outnet, struct pending_tcp* pend) { verbose(VERB_CLIENT, "decommission_pending_tcp"); @@ -1276,7 +1276,7 @@ reuse_tcp_setup_read_and_timeout(struct pending_tcp* pend_tcp, int tcp_reuse_tim comm_point_start_listening(pend_tcp->c, -1, tcp_reuse_timeout); } -int +int outnet_tcp_cb(struct comm_point* c, void* arg, int error, struct comm_reply *reply_info) { @@ -1340,7 +1340,7 @@ outnet_tcp_cb(struct comm_point* c, void* arg, int error, } else { /* check ID */ if(sldns_buffer_limit(c->buffer) < sizeof(uint16_t)) { - log_addr(VERB_QUERY, + log_addr(VERB_QUERY, "outnettcp: bad ID in reply, too short, from:", &pend->reuse.addr, pend->reuse.addrlen); error = NETEVENT_CLOSED; @@ -1451,7 +1451,7 @@ outnet_send_wait_udp(struct outside_network* outnet) /* callback error on pending */ if(pend->cb) { fptr_ok(fptr_whitelist_pending_udp(pend->cb)); - (void)(*pend->cb)(outnet->unused_fds->cp, pend->cb_arg, + (void)(*pend->cb)(outnet->unused_fds->cp, pend->cb_arg, NETEVENT_CLOSED, NULL); } pending_delete(outnet, pend); @@ -1461,7 +1461,7 @@ outnet_send_wait_udp(struct outside_network* outnet) } } -int +int outnet_udp_cb(struct comm_point* c, void* arg, int error, struct comm_reply *reply_info) { @@ -1485,7 +1485,7 @@ outnet_udp_cb(struct comm_point* c, void* arg, int error, memcpy(&key.addr, &reply_info->remote_addr, reply_info->remote_addrlen); key.addrlen = reply_info->remote_addrlen; verbose(VERB_ALGO, "Incoming reply id = %4.4x", key.id); - log_addr(VERB_ALGO, "Incoming reply addr =", + log_addr(VERB_ALGO, "Incoming reply addr =", &reply_info->remote_addr, reply_info->remote_addrlen); /* find it, see if this thing is a valid query response */ @@ -1495,7 +1495,7 @@ outnet_udp_cb(struct comm_point* c, void* arg, int error, verbose(VERB_QUERY, "received unwanted or unsolicited udp reply dropped."); log_buf(VERB_ALGO, "dropped message", c->buffer); outnet->unwanted_replies++; - if(outnet->unwanted_threshold && ++outnet->unwanted_total + if(outnet->unwanted_threshold && ++outnet->unwanted_total >= outnet->unwanted_threshold) { log_warn("unwanted reply total reached threshold (%u)" " you may be under attack." @@ -1515,7 +1515,7 @@ outnet_udp_cb(struct comm_point* c, void* arg, int error, verbose(VERB_QUERY, "received reply id,addr on wrong port. " "dropped."); outnet->unwanted_replies++; - if(outnet->unwanted_threshold && ++outnet->unwanted_total + if(outnet->unwanted_threshold && ++outnet->unwanted_total >= outnet->unwanted_threshold) { log_warn("unwanted reply total reached threshold (%u)" " you may be under attack." @@ -1543,8 +1543,8 @@ outnet_udp_cb(struct comm_point* c, void* arg, int error, } /** calculate number of ip4 and ip6 interfaces*/ -static void -calc_num46(char** ifs, int num_ifs, int do_ip4, int do_ip6, +static void +calc_num46(char** ifs, int num_ifs, int do_ip4, int do_ip6, int* num_ip4, int* num_ip6) { int i; @@ -1580,7 +1580,7 @@ pending_udp_timer_delay_cb(void* arg) outnet_send_wait_udp(outnet); } -void +void pending_udp_timer_cb(void *arg) { struct pending* p = (struct pending*)arg; @@ -1617,13 +1617,13 @@ create_pending_tcp(struct outside_network* outnet, size_t bufsize) outnet->num_tcp, sizeof(struct pending_tcp*)))) return 0; for(i=0; inum_tcp; i++) { - if(!(outnet->tcp_conns[i] = (struct pending_tcp*)calloc(1, + if(!(outnet->tcp_conns[i] = (struct pending_tcp*)calloc(1, sizeof(struct pending_tcp)))) return 0; outnet->tcp_conns[i]->next_free = outnet->tcp_free; outnet->tcp_free = outnet->tcp_conns[i]; outnet->tcp_conns[i]->c = comm_point_create_tcp_out( - outnet->base, bufsize, outnet_tcp_cb, + outnet->base, bufsize, outnet_tcp_cb, outnet->tcp_conns[i]); if(!outnet->tcp_conns[i]->c) return 0; @@ -1632,7 +1632,7 @@ create_pending_tcp(struct outside_network* outnet, size_t bufsize) } /** setup an outgoing interface, ready address */ -static int setup_if(struct port_if* pif, const char* addrstr, +static int setup_if(struct port_if* pif, const char* addrstr, int* avail, int numavail, size_t numfd) { #ifndef DISABLE_EXPLICIT_PORT_RANDOMISATION @@ -1647,18 +1647,18 @@ static int setup_if(struct port_if* pif, const char* addrstr, return 0; pif->maxout = (int)numfd; pif->inuse = 0; - pif->out = (struct port_comm**)calloc(numfd, + pif->out = (struct port_comm**)calloc(numfd, sizeof(struct port_comm*)); if(!pif->out) return 0; return 1; } -struct outside_network* -outside_network_create(struct comm_base *base, size_t bufsize, - size_t num_ports, char** ifs, int num_ifs, int do_ip4, +struct outside_network* +outside_network_create(struct comm_base *base, size_t bufsize, + size_t num_ports, char** ifs, int num_ifs, int do_ip4, int do_ip6, size_t num_tcp, int dscp, struct infra_cache* infra, - struct ub_randstate* rnd, int use_caps_for_id, int* availports, + struct ub_randstate* rnd, int use_caps_for_id, int* availports, int numavailports, size_t unwanted_threshold, int tcp_mss, void (*unwanted_action)(void*), void* unwanted_param, int do_udp, void* sslctx, int delayclose, int tls_use_sni, struct dt_env* dtenv, @@ -1716,7 +1716,7 @@ outside_network_create(struct comm_base *base, size_t bufsize, #ifndef INET6 do_ip6 = 0; #endif - calc_num46(ifs, num_ifs, do_ip4, do_ip6, + calc_num46(ifs, num_ifs, do_ip4, do_ip6, &outnet->num_ip4, &outnet->num_ip6); if(outnet->num_ip4 != 0) { if(!(outnet->ip4_ifs = (struct port_if*)calloc( @@ -1754,7 +1754,7 @@ outside_network_create(struct comm_base *base, size_t bufsize, outside_network_delete(outnet); return NULL; } - pc->cp = comm_point_create_udp(outnet->base, -1, + pc->cp = comm_point_create_udp(outnet->base, -1, outnet->udp_buff, 0, outnet_udp_cb, outnet, NULL); if(!pc->cp) { log_err("malloc failed"); @@ -1768,13 +1768,13 @@ outside_network_create(struct comm_base *base, size_t bufsize, /* allocate interfaces */ if(num_ifs == 0) { - if(do_ip4 && !setup_if(&outnet->ip4_ifs[0], "0.0.0.0", + if(do_ip4 && !setup_if(&outnet->ip4_ifs[0], "0.0.0.0", availports, numavailports, num_ports)) { log_err("malloc failed"); outside_network_delete(outnet); return NULL; } - if(do_ip6 && !setup_if(&outnet->ip6_ifs[0], "::", + if(do_ip6 && !setup_if(&outnet->ip6_ifs[0], "::", availports, numavailports, num_ports)) { log_err("malloc failed"); outside_network_delete(outnet); @@ -1827,16 +1827,16 @@ serviced_node_del(rbnode_type* node, void* ATTR_UNUSED(arg)) free(sq); } -void +void outside_network_quit_prepare(struct outside_network* outnet) { if(!outnet) return; /* prevent queued items from being sent */ - outnet->want_to_quit = 1; + outnet->want_to_quit = 1; } -void +void outside_network_delete(struct outside_network* outnet) { if(!outnet) @@ -1937,7 +1937,7 @@ outside_network_delete(struct outside_network* outnet) free(outnet); } -void +void pending_delete(struct outside_network* outnet, struct pending* p) { if(!p) @@ -2011,13 +2011,13 @@ udp_sockport(struct sockaddr_storage* addr, socklen_t addrlen, int pfxlen, freebind = 1; sai6_putrandom(&sa, pfxlen, rnd); } - fd = create_udp_sock(AF_INET6, SOCK_DGRAM, + fd = create_udp_sock(AF_INET6, SOCK_DGRAM, (struct sockaddr*)&sa, addrlen, 1, inuse, &noproto, 0, 0, 0, NULL, 0, freebind, 0, dscp); } else { struct sockaddr_in* sa = (struct sockaddr_in*)addr; sa->sin_port = (in_port_t)htons((uint16_t)port); - fd = create_udp_sock(AF_INET, SOCK_DGRAM, + fd = create_udp_sock(AF_INET, SOCK_DGRAM, (struct sockaddr*)addr, addrlen, 1, inuse, &noproto, 0, 0, 0, NULL, 0, 0, 0, dscp); } @@ -2135,7 +2135,7 @@ select_ifport(struct outside_network* outnet, struct pending* pend, return 0; } if(fd != -1) { - verbose(VERB_ALGO, "opened UDP if=%d port=%d", + verbose(VERB_ALGO, "opened UDP if=%d port=%d", my_if, portno); if(outnet->udp_connect) { /* connect() to the destination */ @@ -2198,11 +2198,11 @@ randomize_and_send_udp(struct pending* pend, sldns_buffer* packet, int timeout) /* select src_if, port */ if(addr_is_ip6(&pend->addr, pend->addrlen)) { - if(!select_ifport(outnet, pend, + if(!select_ifport(outnet, pend, outnet->num_ip6, outnet->ip6_ifs)) return 0; } else { - if(!select_ifport(outnet, pend, + if(!select_ifport(outnet, pend, outnet->num_ip4, outnet->ip4_ifs)) return 0; } @@ -2244,7 +2244,7 @@ randomize_and_send_udp(struct pending* pend, sldns_buffer* packet, int timeout) return 1; } -struct pending* +struct pending* pending_udp_query(struct serviced_query* sq, struct sldns_buffer* packet, int timeout, comm_point_callback_type* cb, void* cb_arg) { @@ -2279,7 +2279,7 @@ pending_udp_query(struct serviced_query* sq, struct sldns_buffer* packet, /* put at end of waiting list */ if(sq->outnet->udp_wait_last) sq->outnet->udp_wait_last->next_waiting = pend; - else + else sq->outnet->udp_wait_first = pend; sq->outnet->udp_wait_last = pend; return pend; @@ -2441,7 +2441,7 @@ pending_tcp_query(struct serviced_query* sq, sldns_buffer* packet, } /* allocate space to store query */ - w = (struct waiting_tcp*)malloc(sizeof(struct waiting_tcp) + w = (struct waiting_tcp*)malloc(sizeof(struct waiting_tcp) + sldns_buffer_limit(packet)); if(!w) { return NULL; @@ -2536,7 +2536,7 @@ pending_tcp_query(struct serviced_query* sq, sldns_buffer* packet, /** create query for serviced queries */ static void -serviced_gen_query(sldns_buffer* buff, uint8_t* qname, size_t qnamelen, +serviced_gen_query(sldns_buffer* buff, uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, uint16_t flags) { sldns_buffer_clear(buff); @@ -2796,7 +2796,7 @@ serviced_perturb_qname(struct ub_randstate* rnd, uint8_t* qbuf, size_t len) while(lablen--) { /* only perturb A-Z, a-z */ if(isalpha((unsigned char)*d)) { - /* get a random bit */ + /* get a random bit */ if(bits == 0) { random = ub_random(rnd); bits = 30; @@ -2895,8 +2895,8 @@ serviced_udp_send(struct serviced_query* sq, sldns_buffer* buff) if(sq->status == serviced_initial) { if(vs != -1) { sq->status = serviced_query_UDP_EDNS; - } else { - sq->status = serviced_query_UDP; + } else { + sq->status = serviced_query_UDP; } } serviced_encode(sq, buff, (sq->status == serviced_query_UDP_EDNS) || @@ -2980,7 +2980,7 @@ serviced_callbacks(struct serviced_query* sq, int error, struct comm_point* c, * queries that are identical to this one. */ rbtree_delete(sq->outnet->serviced, sq); log_assert(rem); /* should have been present */ - sq->to_be_deleted = 1; + sq->to_be_deleted = 1; verbose(VERB_ALGO, "svcd callbacks start"); if(sq->outnet->use_caps_for_id && error == NETEVENT_NOERROR && c && !sq->nocaps && sq->qtype != LDNS_RR_TYPE_PTR) { @@ -2990,30 +2990,30 @@ serviced_callbacks(struct serviced_query* sq, int error, struct comm_point* c, /* noerror and nxdomain must have a qname in reply */ if(sldns_buffer_read_u16_at(c->buffer, 4) == 0 && (LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer)) - == LDNS_RCODE_NOERROR || + == LDNS_RCODE_NOERROR || LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer)) == LDNS_RCODE_NXDOMAIN)) { verbose(VERB_DETAIL, "no qname in reply to check 0x20ID"); - log_addr(VERB_DETAIL, "from server", + log_addr(VERB_DETAIL, "from server", &sq->addr, sq->addrlen); log_buf(VERB_DETAIL, "for packet", c->buffer); error = NETEVENT_CLOSED; c = NULL; } else if(sldns_buffer_read_u16_at(c->buffer, 4) > 0 && - !serviced_check_qname(c->buffer, sq->qbuf, + !serviced_check_qname(c->buffer, sq->qbuf, sq->qbuflen)) { verbose(VERB_DETAIL, "wrong 0x20-ID in reply qname"); - log_addr(VERB_DETAIL, "from server", + log_addr(VERB_DETAIL, "from server", &sq->addr, sq->addrlen); log_buf(VERB_DETAIL, "for packet", c->buffer); error = NETEVENT_CAPSFAIL; /* and cleanup too */ - pkt_dname_tolower(c->buffer, + pkt_dname_tolower(c->buffer, sldns_buffer_at(c->buffer, 12)); } else { verbose(VERB_ALGO, "good 0x20-ID in reply qname"); /* cleanup caps, prettier cache contents. */ - pkt_dname_tolower(c->buffer, + pkt_dname_tolower(c->buffer, sldns_buffer_at(c->buffer, 12)); } } @@ -3051,7 +3051,7 @@ serviced_callbacks(struct serviced_query* sq, int error, struct comm_point* c, serviced_delete(sq); } -int +int serviced_tcp_callback(struct comm_point* c, void* arg, int error, struct comm_reply* rep) { @@ -3068,7 +3068,7 @@ serviced_tcp_callback(struct comm_point* c, void* arg, int error, #endif sq->pending = NULL; /* removed after this callback */ if(error != NETEVENT_NOERROR) - log_addr(VERB_QUERY, "tcp error for address", + log_addr(VERB_QUERY, "tcp error for address", &sq->addr, sq->addrlen); if(error==NETEVENT_NOERROR) infra_update_tcp_works(sq->outnet->infra, &sq->addr, @@ -3089,25 +3089,25 @@ serviced_tcp_callback(struct comm_point* c, void* arg, int error, } #endif if(error==NETEVENT_NOERROR && sq->status == serviced_query_TCP_EDNS && - (LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer)) == + (LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer)) == LDNS_RCODE_FORMERR || LDNS_RCODE_WIRE(sldns_buffer_begin( c->buffer)) == LDNS_RCODE_NOTIMPL) ) { /* attempt to fallback to nonEDNS */ sq->status = serviced_query_TCP_EDNS_fallback; serviced_tcp_initiate(sq, c->buffer); return 0; - } else if(error==NETEVENT_NOERROR && + } else if(error==NETEVENT_NOERROR && sq->status == serviced_query_TCP_EDNS_fallback && - (LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer)) == + (LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer)) == LDNS_RCODE_NOERROR || LDNS_RCODE_WIRE( - sldns_buffer_begin(c->buffer)) == LDNS_RCODE_NXDOMAIN - || LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer)) + sldns_buffer_begin(c->buffer)) == LDNS_RCODE_NXDOMAIN + || LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer)) == LDNS_RCODE_YXDOMAIN)) { /* the fallback produced a result that looks promising, note * that this server should be approached without EDNS */ /* only store noEDNS in cache if domain is noDNSSEC */ if(!sq->want_dnssec) - if(!infra_edns_update(sq->outnet->infra, &sq->addr, + if(!infra_edns_update(sq->outnet->infra, &sq->addr, sq->addrlen, sq->zone, sq->zonelen, -1, *sq->outnet->now_secs)) log_err("Out of memory caching no edns for host"); @@ -3153,7 +3153,7 @@ serviced_tcp_callback(struct comm_point* c, void* arg, int error, static void serviced_tcp_initiate(struct serviced_query* sq, sldns_buffer* buff) { - verbose(VERB_ALGO, "initiate TCP query %s", + verbose(VERB_ALGO, "initiate TCP query %s", sq->status==serviced_query_TCP_EDNS?"EDNS":""); serviced_encode(sq, buff, sq->status == serviced_query_TCP_EDNS); sq->last_sent_time = *sq->outnet->now_tv; @@ -3239,7 +3239,7 @@ packet_edns_malformed(struct sldns_buffer* buf, int qtype) return 0; } -int +int serviced_udp_callback(struct comm_point* c, void* arg, int error, struct comm_reply* rep) { @@ -3301,9 +3301,9 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error, sq->outnet->now_tv, c->buffer); } #endif - if( (sq->status == serviced_query_UDP_EDNS + if( (sq->status == serviced_query_UDP_EDNS ||sq->status == serviced_query_UDP_EDNS_FRAG) - && (LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer)) + && (LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer)) == LDNS_RCODE_FORMERR || LDNS_RCODE_WIRE( sldns_buffer_begin(c->buffer)) == LDNS_RCODE_NOTIMPL || packet_edns_malformed(c->buffer, sq->qtype) @@ -3316,20 +3316,20 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error, serviced_callbacks(sq, NETEVENT_CLOSED, c, rep); } return 0; - } else if(sq->status == serviced_query_UDP_EDNS && + } else if(sq->status == serviced_query_UDP_EDNS && !sq->edns_lame_known) { /* now we know that edns queries received answers store that */ log_addr(VERB_ALGO, "serviced query: EDNS works for", &sq->addr, sq->addrlen); - if(!infra_edns_update(outnet->infra, &sq->addr, sq->addrlen, + if(!infra_edns_update(outnet->infra, &sq->addr, sq->addrlen, sq->zone, sq->zonelen, 0, (time_t)now.tv_sec)) { log_err("Out of memory caching edns works"); } sq->edns_lame_known = 1; } else if(sq->status == serviced_query_UDP_EDNS_fallback && !sq->edns_lame_known && (LDNS_RCODE_WIRE( - sldns_buffer_begin(c->buffer)) == LDNS_RCODE_NOERROR || - LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer)) == + sldns_buffer_begin(c->buffer)) == LDNS_RCODE_NOERROR || + LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer)) == LDNS_RCODE_NXDOMAIN || LDNS_RCODE_WIRE(sldns_buffer_begin( c->buffer)) == LDNS_RCODE_YXDOMAIN)) { /* the fallback produced a result that looks promising, note @@ -3360,7 +3360,7 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error, /* in case the system hibernated, do not enter a huge value, * above this value gives trouble with server selection */ if(roundtime < 60000) { - if(!infra_rtt_update(outnet->infra, &sq->addr, sq->addrlen, + if(!infra_rtt_update(outnet->infra, &sq->addr, sq->addrlen, sq->zone, sq->zonelen, sq->qtype, roundtime, sq->last_rtt, (time_t)now.tv_sec)) log_err("out of memory noting rtt."); @@ -3385,7 +3385,7 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error, return 0; } -struct serviced_query* +struct serviced_query* outnet_serviced_query(struct outside_network* outnet, struct query_info* qinfo, uint16_t flags, int dnssec, int want_dnssec, int nocaps, int check_ratelimit, int tcp_upstream, int ssl_upstream, @@ -3597,7 +3597,7 @@ fd_for_dest(struct outside_network* outnet, struct sockaddr_storage* to_addr, } else { struct sockaddr_in* sa = (struct sockaddr_in*)addr; sa->sin_port = (in_port_t)htons((uint16_t)port); - fd = create_udp_sock(AF_INET, SOCK_DGRAM, + fd = create_udp_sock(AF_INET, SOCK_DGRAM, (struct sockaddr*)addr, addrlen, 1, &inuse, &noproto, 0, 0, 0, NULL, 0, freebind, 0, dscp); } @@ -3835,7 +3835,7 @@ if_get_mem(struct port_if* pif) #endif sizeof(struct port_comm*)*pif->maxout; for(i=0; iinuse; i++) - s += sizeof(*pif->out[i]) + + s += sizeof(*pif->out[i]) + comm_point_get_mem(pif->out[i]->cp); return s; } @@ -3858,8 +3858,8 @@ size_t outnet_get_mem(struct outside_network* outnet) struct serviced_query* sq; struct service_callback* sb; struct port_comm* pc; - size_t s = sizeof(*outnet) + sizeof(*outnet->base) + - sizeof(*outnet->udp_buff) + + size_t s = sizeof(*outnet) + sizeof(*outnet->base) + + sizeof(*outnet->udp_buff) + sldns_buffer_capacity(outnet->udp_buff); /* second buffer is not ours */ for(pc = outnet->unused_fds; pc; pc = pc->next) { @@ -3871,7 +3871,7 @@ size_t outnet_get_mem(struct outside_network* outnet) s += if_get_mem(&outnet->ip6_ifs[k]); for(u=outnet->udp_wait_first; u; u=u->next_waiting) s += waiting_udp_get_mem(u); - + s += sizeof(struct pending_tcp*)*outnet->num_tcp; for(i=0; inum_tcp; i++) { s += sizeof(struct pending_tcp); @@ -3882,7 +3882,7 @@ size_t outnet_get_mem(struct outside_network* outnet) for(w=outnet->tcp_wait_first; w; w = w->next_waiting) s += waiting_tcp_get_mem(w); s += sizeof(*outnet->pending); - s += (sizeof(struct pending) + comm_timer_get_mem(NULL)) * + s += (sizeof(struct pending) + comm_timer_get_mem(NULL)) * outnet->pending->count; s += sizeof(*outnet->serviced); s += outnet->svcd_overhead; @@ -3894,7 +3894,7 @@ size_t outnet_get_mem(struct outside_network* outnet) return s; } -size_t +size_t serviced_get_mem(struct serviced_query* sq) { struct service_callback* sb; diff --git a/sbin/unwind/libunbound/services/outside_network.h b/sbin/unwind/libunbound/services/outside_network.h index 467c81f60..11e4849ad 100644 --- a/sbin/unwind/libunbound/services/outside_network.h +++ b/sbin/unwind/libunbound/services/outside_network.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -155,7 +155,7 @@ struct outside_network { /** * Array of tcp pending used for outgoing TCP connections. * Each can be used to establish a TCP connection with a server. - * The file descriptors are -1 if they are free, and need to be + * The file descriptors are -1 if they are free, and need to be * opened for the tcp connection. Can be used for ip4 and ip6. */ struct pending_tcp **tcp_conns; @@ -214,7 +214,7 @@ struct port_if { int avail_total; #endif - /** array of the commpoints currently in use. + /** array of the commpoints currently in use. * allocated for max number of fds, first part in use. */ struct port_comm** out; /** max number of fds, size of out array */ @@ -367,7 +367,7 @@ struct pending_tcp { * Query waiting for TCP buffer. */ struct waiting_tcp { - /** + /** * next in waiting list. * if on_tcp_waiting_list==0, this points to the pending_tcp structure. */ @@ -396,7 +396,7 @@ struct waiting_tcp { struct sockaddr_storage addr; /** length of addr field in use. */ socklen_t addrlen; - /** + /** * The query itself, the query packet to send. * allocated after the waiting_tcp structure. */ @@ -495,8 +495,8 @@ struct serviced_query { serviced_query_TCP_EDNS_fallback, /** send UDP query with EDNS1480 (or 1280) */ serviced_query_UDP_EDNS_FRAG - } - /** variable with current status */ + } + /** variable with current status */ status; /** true if serviced_query is scheduled for deletion already */ int to_be_deleted; @@ -544,7 +544,7 @@ struct serviced_query { * @param infra: pointer to infra cached used for serviced queries. * @param rnd: stored to create random numbers for serviced queries. * @param use_caps_for_id: enable to use 0x20 bits to encode id randomness. - * @param availports: array of available ports. + * @param availports: array of available ports. * @param numavailports: number of available ports in array. * @param unwanted_threshold: when to take defensive action. * @param unwanted_action: the action to take. @@ -564,8 +564,8 @@ struct serviced_query { */ struct outside_network* outside_network_create(struct comm_base* base, size_t bufsize, size_t num_ports, char** ifs, int num_ifs, - int do_ip4, int do_ip6, size_t num_tcp, int dscp, struct infra_cache* infra, - struct ub_randstate* rnd, int use_caps_for_id, int* availports, + int do_ip4, int do_ip6, size_t num_tcp, int dscp, struct infra_cache* infra, + struct ub_randstate* rnd, int use_caps_for_id, int* availports, int numavailports, size_t unwanted_threshold, int tcp_mss, void (*unwanted_action)(void*), void* unwanted_param, int do_udp, void* sslctx, int delayclose, int tls_use_sni, struct dt_env *dtenv, @@ -599,7 +599,7 @@ struct pending* pending_udp_query(struct serviced_query* sq, void* callback_arg); /** - * Send TCP query. May wait for TCP buffer. Selects ID to be random, and + * Send TCP query. May wait for TCP buffer. Selects ID to be random, and * checks id. * @param sq: serviced query. * @param packet: wireformat query to send to destination. copied from. @@ -685,7 +685,7 @@ size_t outnet_get_mem(struct outside_network* outnet); * Get memory size in use by serviced query while it is servicing callbacks. * This takes into account the pre-deleted status of it; it will be deleted * when the callbacks are done. - * @param sq: serviced query. + * @param sq: serviced query. * @return size in bytes. */ size_t serviced_get_mem(struct serviced_query* sq); diff --git a/sbin/unwind/libunbound/services/rpz.c b/sbin/unwind/libunbound/services/rpz.c index 6ce83cb66..d903562e5 100644 --- a/sbin/unwind/libunbound/services/rpz.c +++ b/sbin/unwind/libunbound/services/rpz.c @@ -4,22 +4,22 @@ * Copyright (c) 2019, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -234,7 +234,7 @@ rpz_rr_to_action(uint16_t rr_type, uint8_t* rdatawl, size_t rdatalen) return RPZ_LOCAL_DATA_ACTION; } -static enum localzone_type +static enum localzone_type rpz_action_to_localzone_type(enum rpz_action a) { switch(a) { @@ -1273,7 +1273,7 @@ rpz_rrset_delete_rr(struct resp_addr* raddr, uint16_t rr_type, uint8_t* rdata, if(packed_rrset_find_rr(d, rdata, rdatalen, &index)) { if(d->count == 1) { /* regional alloc'd */ - raddr->data->entry.data = NULL; + raddr->data->entry.data = NULL; raddr->data = NULL; return 1; } @@ -1309,7 +1309,7 @@ rpz_remove_local_zones_trigger(struct local_zones* zones, uint8_t* dname, lock_rw_unlock(&zones->lock); return; } - lock_rw_unlock(&z->lock); + lock_rw_unlock(&z->lock); if(delete_zone) { local_zones_del_zone(zones, z); } @@ -1351,7 +1351,7 @@ rpz_remove_response_ip_trigger(struct rpz* r, uint8_t* dname, size_t dnamelen, lock_rw_wrlock(&node->lock); if(a == RPZ_LOCAL_DATA_ACTION) { /* remove RR, signal whether RR can be removed */ - delete_respip = rpz_rrset_delete_rr(node, rr_type, rdatawl, + delete_respip = rpz_rrset_delete_rr(node, rr_type, rdatawl, rdatalen); } lock_rw_unlock(&node->lock); diff --git a/sbin/unwind/libunbound/services/rpz.h b/sbin/unwind/libunbound/services/rpz.h index e6d8bf566..7e4ee7143 100644 --- a/sbin/unwind/libunbound/services/rpz.h +++ b/sbin/unwind/libunbound/services/rpz.h @@ -4,22 +4,22 @@ * Copyright (c) 2019, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR diff --git a/sbin/unwind/libunbound/services/view.c b/sbin/unwind/libunbound/services/view.c index 72f364318..86d314a2b 100644 --- a/sbin/unwind/libunbound/services/view.c +++ b/sbin/unwind/libunbound/services/view.c @@ -4,22 +4,22 @@ * Copyright (c) 2016, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -44,19 +44,19 @@ #include "services/localzone.h" #include "util/config_file.h" -int +int view_cmp(const void* v1, const void* v2) { struct view* a = (struct view*)v1; struct view* b = (struct view*)v2; - + return strcmp(a->name, b->name); } -struct views* +struct views* views_create(void) { - struct views* v = (struct views*)calloc(1, + struct views* v = (struct views*)calloc(1, sizeof(*v)); if(!v) return NULL; @@ -71,7 +71,7 @@ views_create(void) * unnecessary dependencies */ void respip_set_delete(struct respip_set *set); -void +void view_delete(struct view* v) { if(!v) @@ -90,7 +90,7 @@ delviewnode(rbnode_type* n, void* ATTR_UNUSED(arg)) view_delete(v); } -void +void views_delete(struct views* v) { if(!v) @@ -141,7 +141,7 @@ views_enter_view_name(struct views* vs, char* name) return v; } -int +int views_apply_cfg(struct views* vs, struct config_file* cfg) { struct config_view* cv; @@ -208,7 +208,7 @@ views_apply_cfg(struct views* vs, struct config_file* cfg) lock_rw_unlock(&v->lock); return 0; } - /* local_zones, local_zones_nodefault and local_data + /* local_zones, local_zones_nodefault and local_data * are free'd from config_view by local_zones_apply_cfg. * Set pointers to NULL. */ cv->local_zones = NULL; diff --git a/sbin/unwind/libunbound/services/view.h b/sbin/unwind/libunbound/services/view.h index 177781004..020e26b86 100644 --- a/sbin/unwind/libunbound/services/view.h +++ b/sbin/unwind/libunbound/services/view.h @@ -4,22 +4,22 @@ * Copyright (c) 2016, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -75,7 +75,7 @@ struct view { /** response-ip configuration data for this view */ struct respip_set* respip_set; /** Fallback to global local_zones when there is no match in the view - * specific tree. 1 for yes, 0 for no */ + * specific tree. 1 for yes, 0 for no */ int isfirst; /** lock on the data in the structure * For the node and name you need to also hold the views_tree lock to @@ -120,7 +120,7 @@ int view_cmp(const void* v1, const void* v2); void view_delete(struct view* v); /** - * Debug helper. Print all views + * Debug helper. Print all views * Takes care of locking. * @param v: the views tree */ @@ -130,7 +130,7 @@ void views_print(struct views* v); * @param vs: views * @param name: name of the view we are looking for * @param write: 1 for obtaining write lock on found view, 0 for read lock - * @return: locked view or NULL. + * @return: locked view or NULL. */ struct view* views_find_view(struct views* vs, const char* name, int write); diff --git a/sbin/unwind/libunbound/sldns/keyraw.c b/sbin/unwind/libunbound/sldns/keyraw.c index befe1f722..6ddbfaef2 100644 --- a/sbin/unwind/libunbound/sldns/keyraw.c +++ b/sbin/unwind/libunbound/sldns/keyraw.c @@ -44,11 +44,11 @@ sldns_rr_dnskey_key_size_raw(const unsigned char* keydata, { /* for DSA keys */ uint8_t t; - + /* for RSA keys */ uint16_t exp; uint16_t int16; - + switch ((sldns_algorithm)alg) { case LDNS_DSA: case LDNS_DSA_NSEC3: @@ -180,10 +180,10 @@ sldns_key_EVP_load_gost_id(void) /* Note: do not ENGINE_finish and ENGINE_free the acquired engine * on some platforms this frees up the meth and unloads gost stuff */ sldns_gost_engine = e; - + EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth); return gost_id; -} +} void sldns_key_EVP_unload_gost(void) { @@ -535,9 +535,9 @@ EVP_PKEY* sldns_gost2pkey_raw(unsigned char* key, size_t keylen) { /* prefix header for X509 encoding */ - uint8_t asn[37] = { 0x30, 0x63, 0x30, 0x1c, 0x06, 0x06, 0x2a, 0x85, - 0x03, 0x02, 0x02, 0x13, 0x30, 0x12, 0x06, 0x07, 0x2a, 0x85, - 0x03, 0x02, 0x02, 0x23, 0x01, 0x06, 0x07, 0x2a, 0x85, 0x03, + uint8_t asn[37] = { 0x30, 0x63, 0x30, 0x1c, 0x06, 0x06, 0x2a, 0x85, + 0x03, 0x02, 0x02, 0x13, 0x30, 0x12, 0x06, 0x07, 0x2a, 0x85, + 0x03, 0x02, 0x02, 0x23, 0x01, 0x06, 0x07, 0x2a, 0x85, 0x03, 0x02, 0x02, 0x1e, 0x01, 0x03, 0x43, 0x00, 0x04, 0x40}; unsigned char encoded[37+64]; const unsigned char* pp; diff --git a/sbin/unwind/libunbound/sldns/keyraw.h b/sbin/unwind/libunbound/sldns/keyraw.h index b1f19740c..3829fac79 100644 --- a/sbin/unwind/libunbound/sldns/keyraw.h +++ b/sbin/unwind/libunbound/sldns/keyraw.h @@ -14,9 +14,9 @@ * * Since those functions heavily rely op cryptographic operations, * this module is dependent on openssl. - * + * */ - + #ifndef LDNS_KEYRAW_H #define LDNS_KEYRAW_H @@ -47,7 +47,7 @@ size_t sldns_rr_dnskey_key_size_raw(const unsigned char *keydata, uint16_t sldns_calc_keytag_raw(uint8_t* key, size_t keysize); #if LDNS_BUILD_CONFIG_HAVE_SSL -/** +/** * Get the PKEY id for GOST, loads GOST into openssl as a side effect. * Only available if GOST is compiled into the library and openssl. * \return the gost id for EVP_CTX creation. @@ -138,7 +138,7 @@ EVP_PKEY* sldns_ed4482pkey_raw(const unsigned char* key, size_t len); * \param[in] md the message digest to use. * \return true if worked, false on failure. */ -int sldns_digest_evp(unsigned char* data, unsigned int len, +int sldns_digest_evp(unsigned char* data, unsigned int len, unsigned char* dest, const EVP_MD* md); #endif /* LDNS_BUILD_CONFIG_HAVE_SSL */ diff --git a/sbin/unwind/libunbound/sldns/parse.h b/sbin/unwind/libunbound/sldns/parse.h index fa8f51a92..6e756674e 100644 --- a/sbin/unwind/libunbound/sldns/parse.h +++ b/sbin/unwind/libunbound/sldns/parse.h @@ -1,5 +1,5 @@ /* - * parse.h + * parse.h * * a Net::DNS like library for C * LibDNS Team @ NLnet Labs @@ -29,7 +29,7 @@ extern "C" { * Contains some low-level parsing functions, mostly used in the _frm_str * family of functions. */ - + /** * different type of directives in zone files * We now deal with $TTL, $ORIGIN and $INCLUDE. @@ -43,7 +43,7 @@ enum sldns_enum_directive }; typedef enum sldns_enum_directive sldns_directive; -/** +/** * returns a token/char from the stream F. * This function deals with ( and ) in the stream, * and ignores them when encountered @@ -55,7 +55,7 @@ typedef enum sldns_enum_directive sldns_directive; */ ssize_t sldns_fget_token(FILE *f, char *token, const char *delim, size_t limit); -/** +/** * returns a token/char from the stream F. * This function deals with ( and ) in the stream, * and ignores when it finds them. @@ -81,7 +81,7 @@ ssize_t sldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit * to zero after last bget in string (for parse error). If you pass NULL, * the entire parenthesized string is read in. * \param[in] skipw string with whitespace to skip before the start of the - * token, like " ", or " \t", or NULL for none. + * token, like " ", or " \t", or NULL for none. * \returns 0 on error of EOF of b. Otherwise return the length of what is read */ ssize_t sldns_bget_token_par(struct sldns_buffer *b, char *token, const char *delim, size_t limit, int* par, const char* skipw); @@ -103,8 +103,8 @@ ssize_t sldns_bget_token(struct sldns_buffer *b, char *token, const char *delim, * after the keyword + k_del until we hit d_del * \param[in] f file pointer to read from * \param[in] keyword keyword to look for - * \param[in] k_del keyword delimiter - * \param[out] data the data found + * \param[in] k_del keyword delimiter + * \param[out] data the data found * \param[in] d_del the data delimiter * \param[in] data_limit maximum size the the data buffer * \return the number of character read @@ -116,8 +116,8 @@ ssize_t sldns_fget_keyword_data(FILE *f, const char *keyword, const char *k_del, * after the keyword + k_del until we hit d_del * \param[in] f file pointer to read from * \param[in] keyword keyword to look for - * \param[in] k_del keyword delimiter - * \param[out] data the data found + * \param[in] k_del keyword delimiter + * \param[out] data the data found * \param[in] d_del the data delimiter * \param[in] data_limit maximum size the the data buffer * \param[in] line_nr pointer to an integer containing the current line number (for @@ -131,8 +131,8 @@ ssize_t sldns_fget_keyword_data_l(FILE *f, const char *keyword, const char *k_de * after the keyword + k_del until we hit d_del * \param[in] b buffer pointer to read from * \param[in] keyword keyword to look for - * \param[in] k_del keyword delimiter - * \param[out] data the data found + * \param[in] k_del keyword delimiter + * \param[out] data the data found * \param[in] d_del the data delimiter * \param[in] data_limit maximum size the the data buffer * \return the number of character read diff --git a/sbin/unwind/libunbound/sldns/parseutil.c b/sbin/unwind/libunbound/sldns/parseutil.c index dd1f33484..c891b0b61 100644 --- a/sbin/unwind/libunbound/sldns/parseutil.c +++ b/sbin/unwind/libunbound/sldns/parseutil.c @@ -51,7 +51,7 @@ static const int mdays[] = { static int is_leap_year(int year) { - return LDNS_MOD(year, 4) == 0 && (LDNS_MOD(year, 100) != 0 + return LDNS_MOD(year, 4) == 0 && (LDNS_MOD(year, 100) != 0 || LDNS_MOD(year, 400) == 0); } @@ -60,7 +60,7 @@ leap_days(int y1, int y2) { --y1; --y2; - return (LDNS_DIV(y2, 4) - LDNS_DIV(y1, 4)) - + return (LDNS_DIV(y2, 4) - LDNS_DIV(y1, 4)) - (LDNS_DIV(y2, 100) - LDNS_DIV(y1, 100)) + (LDNS_DIV(y2, 400) - LDNS_DIV(y1, 400)); } @@ -120,7 +120,7 @@ static void sldns_mon_and_mday_from_year_and_yday(struct tm *result) { int idays = result->tm_yday; - const int *mon_lengths = is_leap_year(result->tm_year) ? + const int *mon_lengths = is_leap_year(result->tm_year) ? leap_year_mdays : mdays; result->tm_mon = 0; @@ -381,14 +381,14 @@ sldns_b32_ntop_base(const uint8_t* src, size_t src_sz, char* dst, size_t dst_sz, const char* b32 = extended_hex ? "0123456789abcdefghijklmnopqrstuv" : "abcdefghijklmnopqrstuvwxyz234567"; - size_t c = 0; /* c is used to carry partial base32 character over + size_t c = 0; /* c is used to carry partial base32 character over * byte boundaries for sizes with a remainder. * (i.e. src_sz % 5 != 0) */ ret_sz = add_padding ? sldns_b32_ntop_calculate_size(src_sz) : sldns_b32_ntop_calculate_size_no_padding(src_sz); - + /* Do we have enough space? */ if (dst_sz < ret_sz + 1) return -1; @@ -472,13 +472,13 @@ sldns_b32_ntop_base(const uint8_t* src, size_t src_sz, char* dst, size_t dst_sz, return (int)ret_sz; } -int +int sldns_b32_ntop(const uint8_t* src, size_t src_sz, char* dst, size_t dst_sz) { return sldns_b32_ntop_base(src, src_sz, dst, dst_sz, 0, 1); } -int +int sldns_b32_ntop_extended_hex(const uint8_t* src, size_t src_sz, char* dst, size_t dst_sz) { @@ -632,7 +632,7 @@ sldns_b32_pton(const char* src, size_t src_sz, uint8_t* dst, size_t dst_sz) } int -sldns_b32_pton_extended_hex(const char* src, size_t src_sz, +sldns_b32_pton_extended_hex(const char* src, size_t src_sz, uint8_t* dst, size_t dst_sz) { return sldns_b32_pton_base(src, src_sz, dst, dst_sz, 1, 1); diff --git a/sbin/unwind/libunbound/sldns/parseutil.h b/sbin/unwind/libunbound/sldns/parseutil.h index 683f34e23..e9c34cbb7 100644 --- a/sbin/unwind/libunbound/sldns/parseutil.h +++ b/sbin/unwind/libunbound/sldns/parseutil.h @@ -16,9 +16,9 @@ #define LDNS_PARSEUTIL_H struct tm; -/** +/** * A general purpose lookup table - * + * * Lookup tables are arrays of (id, name) pairs, * So you can for instance lookup the RCODE 3, which is "NXDOMAIN", * and vice versa. The lookup tables themselves are defined wherever needed, @@ -143,7 +143,7 @@ int sldns_b32_pton_extended_hex(const char* src_text, size_t src_text_length, */ int sldns_parse_escape(uint8_t *ch_p, const char** str_p); -/** +/** * Parse one character, with escape codes, * @param ch_p: the parsed character * @param str_p: the string. moved along for characters read. diff --git a/sbin/unwind/libunbound/sldns/pkthdr.h b/sbin/unwind/libunbound/sldns/pkthdr.h index c32e7d285..ff2829605 100644 --- a/sbin/unwind/libunbound/sldns/pkthdr.h +++ b/sbin/unwind/libunbound/sldns/pkthdr.h @@ -14,7 +14,7 @@ * Contains functions that translate dns data from the wire format (as sent * by servers and clients) to the internal structures for the packet header. */ - + #ifndef LDNS_PKTHDR_H #define LDNS_PKTHDR_H diff --git a/sbin/unwind/libunbound/sldns/rrdef.c b/sbin/unwind/libunbound/sldns/rrdef.c index e81ebb1fc..6f91494cb 100644 --- a/sbin/unwind/libunbound/sldns/rrdef.c +++ b/sbin/unwind/libunbound/sldns/rrdef.c @@ -35,7 +35,7 @@ static const sldns_rdf_type type_md_wireformat[] = { LDNS_RDF_TYPE_DNAME }; static const sldns_rdf_type type_mf_wireformat[] = { LDNS_RDF_TYPE_DNAME }; static const sldns_rdf_type type_cname_wireformat[] = { LDNS_RDF_TYPE_DNAME }; static const sldns_rdf_type type_soa_wireformat[] = { - LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_INT32, + LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_INT32, LDNS_RDF_TYPE_PERIOD, LDNS_RDF_TYPE_PERIOD, LDNS_RDF_TYPE_PERIOD, LDNS_RDF_TYPE_PERIOD }; diff --git a/sbin/unwind/libunbound/sldns/rrdef.h b/sbin/unwind/libunbound/sldns/rrdef.h index 1a5091d06..5f3efe25b 100644 --- a/sbin/unwind/libunbound/sldns/rrdef.h +++ b/sbin/unwind/libunbound/sldns/rrdef.h @@ -346,7 +346,7 @@ enum sldns_enum_rdf_type */ LDNS_RDF_TYPE_TAG, - /** A encoding of the value field as specified + /** A encoding of the value field as specified * [RFC1035], Section 5.1., encoded as remaining rdata. * For CAA, URI. */ diff --git a/sbin/unwind/libunbound/sldns/sbuffer.c b/sbin/unwind/libunbound/sldns/sbuffer.c index f0f1fbd91..030b2edb4 100644 --- a/sbin/unwind/libunbound/sldns/sbuffer.c +++ b/sbin/unwind/libunbound/sldns/sbuffer.c @@ -23,20 +23,20 @@ sldns_buffer_new(size_t capacity) if (!buffer) { return NULL; } - + buffer->_data = (uint8_t *) malloc(capacity); if (!buffer->_data) { free(buffer); return NULL; } - + buffer->_position = 0; buffer->_limit = buffer->_capacity = capacity; buffer->_fixed = 0; buffer->_status_err = 0; - + sldns_buffer_invariant(buffer); - + return buffer; } @@ -45,7 +45,7 @@ sldns_buffer_new_frm_data(sldns_buffer *buffer, void *data, size_t size) { assert(data != NULL); - buffer->_position = 0; + buffer->_position = 0; buffer->_limit = buffer->_capacity = size; buffer->_fixed = 0; if (!buffer->_fixed && buffer->_data) @@ -57,7 +57,7 @@ sldns_buffer_new_frm_data(sldns_buffer *buffer, void *data, size_t size) } memcpy(buffer->_data, data, size); buffer->_status_err = 0; - + sldns_buffer_invariant(buffer); } @@ -74,7 +74,7 @@ int sldns_buffer_set_capacity(sldns_buffer *buffer, size_t capacity) { void *data; - + sldns_buffer_invariant(buffer); assert(buffer->_position <= capacity && !buffer->_fixed); @@ -115,7 +115,7 @@ sldns_buffer_printf(sldns_buffer *buffer, const char *format, ...) va_list args; int written = 0; size_t remaining; - + if (sldns_buffer_status_ok(buffer)) { sldns_buffer_invariant(buffer); assert(buffer->_limit == buffer->_capacity); @@ -147,7 +147,7 @@ sldns_buffer_free(sldns_buffer *buffer) free(buffer); } -void +void sldns_buffer_copy(sldns_buffer* result, sldns_buffer* from) { size_t tocopy = sldns_buffer_limit(from); diff --git a/sbin/unwind/libunbound/sldns/sbuffer.h b/sbin/unwind/libunbound/sldns/sbuffer.h index 1b7fe370c..6d3a2e650 100644 --- a/sbin/unwind/libunbound/sldns/sbuffer.h +++ b/sbin/unwind/libunbound/sldns/sbuffer.h @@ -18,7 +18,7 @@ extern "C" { #endif #ifdef S_SPLINT_S -# define INLINE +# define INLINE #else # ifdef SWIG # define INLINE static @@ -106,7 +106,7 @@ sldns_write_uint48(void *dst, uint64_t data) * This file contains the definition of sldns_buffer, and functions to manipulate those. */ -/** +/** * implementation of buffers to ease operations * * sldns_buffers can contain arbitrary information, per octet. You can write @@ -115,7 +115,7 @@ sldns_write_uint48(void *dst, uint64_t data) */ struct sldns_buffer { - /** The current position used for reading/writing */ + /** The current position used for reading/writing */ size_t _position; /** The read/write limit */ @@ -735,7 +735,7 @@ int sldns_buffer_printf(sldns_buffer *buffer, const char *format, ...) void sldns_buffer_free(sldns_buffer *buffer); /** - * Copy contents of the from buffer to the result buffer and then flips + * Copy contents of the from buffer to the result buffer and then flips * the result buffer. Data will be silently truncated if the result buffer is * too small. * \param[out] *result resulting buffer which is copied to. diff --git a/sbin/unwind/libunbound/sldns/str2wire.c b/sbin/unwind/libunbound/sldns/str2wire.c index 45e247613..521d08a9f 100644 --- a/sbin/unwind/libunbound/sldns/str2wire.c +++ b/sbin/unwind/libunbound/sldns/str2wire.c @@ -1448,7 +1448,7 @@ sldns_str2wire_svcbparam_parse_next_unescaped_comma(const char *val) /* The source is already properly unescaped, this double unescaping is purely to allow for * comma's in comma separated alpn lists. - * + * * In draft-ietf-dnsop-svcb-https-06 Section 7: * To enable simpler parsing, this SvcParamValue MUST NOT contain escape sequences. */ diff --git a/sbin/unwind/libunbound/util/alloc.c b/sbin/unwind/libunbound/util/alloc.c index e9613b10d..8f02ecf46 100644 --- a/sbin/unwind/libunbound/util/alloc.c +++ b/sbin/unwind/libunbound/util/alloc.c @@ -1,25 +1,25 @@ /* - * util/alloc.c - memory allocation service. + * util/alloc.c - memory allocation service. * * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -59,7 +59,7 @@ alloc_setup_special(alloc_special_type* t) t->entry.key = t; } -/** prealloc some entries in the cache. To minimize contention. +/** prealloc some entries in the cache. To minimize contention. * Result is 1 lock per alloc_max newly created entries. * @param alloc: the structure to fill up. */ @@ -99,7 +99,7 @@ prealloc_blocks(struct alloc_cache* alloc, size_t num) } } -void +void alloc_init(struct alloc_cache* alloc, struct alloc_cache* super, int thread_num) { @@ -156,7 +156,7 @@ alloc_clear_special(struct alloc_cache* alloc) } } -void +void alloc_clear(struct alloc_cache* alloc) { alloc_special_type* p; @@ -201,7 +201,7 @@ alloc_get_id(struct alloc_cache* alloc) (*alloc->cleanup)(alloc->cleanup_arg); /* start back at first number */ /* like in alloc_init*/ - alloc->next_id = (uint64_t)alloc->thread_num; + alloc->next_id = (uint64_t)alloc->thread_num; alloc->next_id <<= THRNUM_SHIFT; /* in steps for comp. */ alloc->next_id += 1; /* portability. */ /* and generate new and safe id */ @@ -210,7 +210,7 @@ alloc_get_id(struct alloc_cache* alloc) return id; } -alloc_special_type* +alloc_special_type* alloc_special_obtain(struct alloc_cache* alloc) { alloc_special_type* p; @@ -250,13 +250,13 @@ alloc_special_obtain(struct alloc_cache* alloc) } /** push mem and some more items to the super */ -static void +static void pushintosuper(struct alloc_cache* alloc, alloc_special_type* mem) { int i; alloc_special_type *p = alloc->quar; log_assert(p); - log_assert(alloc && alloc->super && + log_assert(alloc && alloc->super && alloc->num_quar >= ALLOC_SPECIAL_MAX); /* push ALLOC_SPECIAL_MAX/2 after mem */ alloc_set_special_next(mem, alloc->quar); @@ -275,13 +275,13 @@ pushintosuper(struct alloc_cache* alloc, alloc_special_type* mem) /* so 1 lock per mem+alloc/2 deletes */ } -void +void alloc_special_release(struct alloc_cache* alloc, alloc_special_type* mem) { log_assert(alloc); if(!mem) return; - if(!alloc->super) { + if(!alloc->super) { lock_quick_lock(&alloc->lock); /* superalloc needs locking */ } @@ -300,7 +300,7 @@ alloc_special_release(struct alloc_cache* alloc, alloc_special_type* mem) } } -void +void alloc_stats(struct alloc_cache* alloc) { log_info("%salloc: %d in cache, %d blocks.", alloc->super?"":"sup", @@ -311,7 +311,7 @@ size_t alloc_get_mem(struct alloc_cache* alloc) { alloc_special_type* p; size_t s = sizeof(*alloc); - if(!alloc->super) { + if(!alloc->super) { lock_quick_lock(&alloc->lock); /* superalloc needs locking */ } s += sizeof(alloc_special_type) * alloc->num_quar; @@ -325,7 +325,7 @@ size_t alloc_get_mem(struct alloc_cache* alloc) return s; } -struct regional* +struct regional* alloc_reg_obtain(struct alloc_cache* alloc) { if(alloc->num_reg_blocks > 0) { @@ -338,7 +338,7 @@ alloc_reg_obtain(struct alloc_cache* alloc) return regional_create_custom(ALLOC_REG_SIZE); } -void +void alloc_reg_release(struct alloc_cache* alloc, struct regional* r) { if(alloc->num_reg_blocks >= alloc->max_reg_blocks) { @@ -353,7 +353,7 @@ alloc_reg_release(struct alloc_cache* alloc, struct regional* r) alloc->num_reg_blocks++; } -void +void alloc_set_id_cleanup(struct alloc_cache* alloc, void (*cleanup)(void*), void* arg) { @@ -479,7 +479,7 @@ void *unbound_stat_malloc_log(size_t size, const char* file, int line, void *unbound_stat_calloc_log(size_t nmemb, size_t size, const char* file, int line, const char* func) { - log_info("%s:%d %s calloc(%u, %u)", file, line, func, + log_info("%s:%d %s calloc(%u, %u)", file, line, func, (unsigned) nmemb, (unsigned)size); return unbound_stat_calloc(nmemb, size); } @@ -491,7 +491,7 @@ void unbound_stat_free_log(void *ptr, const char* file, int line, if(ptr && memcmp(ptr-8, &mem_special, sizeof(mem_special)) == 0) { size_t s; memcpy(&s, ptr-16, sizeof(s)); - log_info("%s:%d %s free(%p) size %u", + log_info("%s:%d %s free(%p) size %u", file, line, func, ptr, (unsigned)s); } else log_info("%s:%d %s unmatched free(%p)", file, line, func, ptr); @@ -502,7 +502,7 @@ void unbound_stat_free_log(void *ptr, const char* file, int line, void *unbound_stat_realloc_log(void *ptr, size_t size, const char* file, int line, const char* func) { - log_info("%s:%d %s realloc(%p, %u)", file, line, func, + log_info("%s:%d %s realloc(%p, %u)", file, line, func, ptr, (unsigned)size); return unbound_stat_realloc(ptr, size); } @@ -570,7 +570,7 @@ void unbound_stat_free_lite(void *ptr, const char* file, int line, if(memcmp(real+lite_pad+orig+sizeof(size_t), lite_post, lite_pad)!=0){ log_err("free(): suffix failed %s:%d %s", file, line, func); log_err("alloc size is %d", (int)orig); - log_hex("suffix here", real+lite_pad+orig+sizeof(size_t), + log_hex("suffix here", real+lite_pad+orig+sizeof(size_t), lite_pad); log_hex(" should be", lite_post, lite_pad); fatal_exit("alloc assertion failed"); @@ -606,7 +606,7 @@ void *unbound_stat_realloc_lite(void *ptr, size_t size, const char* file, if(memcmp(real+lite_pad+orig+sizeof(size_t), lite_post, lite_pad)!=0){ log_err("realloc(): suffix failed %s:%d %s", file, line, func); log_err("alloc size is %d", (int)orig); - log_hex("suffix here", real+lite_pad+orig+sizeof(size_t), + log_hex("suffix here", real+lite_pad+orig+sizeof(size_t), lite_pad); log_hex(" should be", lite_post, lite_pad); fatal_exit("alloc assertion failed"); @@ -623,7 +623,7 @@ void *unbound_stat_realloc_lite(void *ptr, size_t size, const char* file, return newa; } -char* unbound_strdup_lite(const char* s, const char* file, int line, +char* unbound_strdup_lite(const char* s, const char* file, int line, const char* func) { /* this routine is made to make sure strdup() uses the malloc_lite */ @@ -642,14 +642,14 @@ char* unbound_lite_wrapstr(char* s) } #undef sldns_pkt2wire -sldns_status unbound_lite_pkt2wire(uint8_t **dest, const sldns_pkt *p, +sldns_status unbound_lite_pkt2wire(uint8_t **dest, const sldns_pkt *p, size_t *size) { uint8_t* md = NULL; size_t ms = 0; sldns_status s = sldns_pkt2wire(&md, p, &ms); if(md) { - *dest = unbound_stat_malloc_lite(ms, __FILE__, __LINE__, + *dest = unbound_stat_malloc_lite(ms, __FILE__, __LINE__, __func__); *size = ms; if(!*dest) { free(md); return LDNS_STATUS_MEM_ERR; } @@ -668,7 +668,7 @@ int unbound_lite_i2d_DSA_SIG(DSA_SIG* dsasig, unsigned char** sig) unsigned char* n = NULL; int r= i2d_DSA_SIG(dsasig, &n); if(n) { - *sig = unbound_stat_malloc_lite((size_t)r, __FILE__, __LINE__, + *sig = unbound_stat_malloc_lite((size_t)r, __FILE__, __LINE__, __func__); if(!*sig) return -1; memcpy(*sig, n, (size_t)r); diff --git a/sbin/unwind/libunbound/util/alloc.h b/sbin/unwind/libunbound/util/alloc.h index ee03b074e..d65b0df0b 100644 --- a/sbin/unwind/libunbound/util/alloc.h +++ b/sbin/unwind/libunbound/util/alloc.h @@ -1,25 +1,25 @@ /* - * util/alloc.h - memory allocation service. + * util/alloc.h - memory allocation service. * * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -206,7 +206,7 @@ void *unbound_stat_realloc_lite(void *ptr, size_t size, const char* file, # undef strdup # endif # define strdup(s) unbound_strdup_lite(s, __FILE__, __LINE__, __func__) -char* unbound_strdup_lite(const char* s, const char* file, int line, +char* unbound_strdup_lite(const char* s, const char* file, int line, const char* func); char* unbound_lite_wrapstr(char* s); # define sldns_rr2str(rr) unbound_lite_wrapstr(sldns_rr2str(rr)) diff --git a/sbin/unwind/libunbound/util/as112.c b/sbin/unwind/libunbound/util/as112.c index 6ee694046..bf692a3ac 100644 --- a/sbin/unwind/libunbound/util/as112.c +++ b/sbin/unwind/libunbound/util/as112.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR diff --git a/sbin/unwind/libunbound/util/as112.h b/sbin/unwind/libunbound/util/as112.h index 7d0329e82..433799f46 100644 --- a/sbin/unwind/libunbound/util/as112.h +++ b/sbin/unwind/libunbound/util/as112.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -42,7 +42,7 @@ #ifndef UTIL_AS112_H #define UTIL_AS112_H -/** +/** * Array of text-format domain names of the AS112 zones. * The array ends with NULL. "AS112" is a service on the internet that * that this array is named after. The names in this list (or some of them) diff --git a/sbin/unwind/libunbound/util/configlexer.c b/sbin/unwind/libunbound/util/configlexer.c index 461789c98..82cfe9c1b 100644 --- a/sbin/unwind/libunbound/util/configlexer.c +++ b/sbin/unwind/libunbound/util/configlexer.c @@ -39,7 +39,7 @@ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. + * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 @@ -56,7 +56,7 @@ typedef uint32_t flex_uint32_t; typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; @@ -174,7 +174,7 @@ extern FILE *yyin, *yyout; #define YY_LESS_LINENO(n) #define YY_LINENO_REWIND_TO(ptr) - + /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ @@ -231,7 +231,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -3710,7 +3710,7 @@ YY_DECL yy_state_type yy_current_state; char *yy_cp, *yy_bp; int yy_act; - + if ( !(yy_init) ) { (yy_init) = 1; @@ -6127,7 +6127,7 @@ static int yy_get_next_buffer (void) { yy_state_type yy_current_state; char *yy_cp; - + yy_current_state = (yy_start); for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) @@ -6187,7 +6187,7 @@ static int yy_get_next_buffer (void) { int c; - + *(yy_c_buf_p) = (yy_hold_char); if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) @@ -6254,12 +6254,12 @@ static int yy_get_next_buffer (void) /** Immediately switch to a different input stream. * @param input_file A readable stream. - * + * * @note This function does not reset the start condition to @c INITIAL . */ void yyrestart (FILE * input_file ) { - + if ( ! YY_CURRENT_BUFFER ){ yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = @@ -6272,11 +6272,11 @@ static int yy_get_next_buffer (void) /** Switch to a different input buffer. * @param new_buffer The new input buffer. - * + * */ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) { - + /* TODO. We should be able to replace this entire function body * with * yypop_buffer_state(); @@ -6316,13 +6316,13 @@ static void yy_load_buffer_state (void) /** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * + * * @return the allocated buffer state. */ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) { YY_BUFFER_STATE b; - + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); @@ -6345,11 +6345,11 @@ static void yy_load_buffer_state (void) /** Destroy the buffer. * @param b a buffer created with yy_create_buffer() - * + * */ void yy_delete_buffer (YY_BUFFER_STATE b ) { - + if ( ! b ) return; @@ -6370,7 +6370,7 @@ static void yy_load_buffer_state (void) { int oerrno = errno; - + yy_flush_buffer(b ); b->yy_input_file = file; @@ -6386,13 +6386,13 @@ static void yy_load_buffer_state (void) } b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - + errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * + * */ void yy_flush_buffer (YY_BUFFER_STATE b ) { @@ -6421,7 +6421,7 @@ static void yy_load_buffer_state (void) * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. - * + * */ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) { @@ -6451,7 +6451,7 @@ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. - * + * */ void yypop_buffer_state (void) { @@ -6475,7 +6475,7 @@ void yypop_buffer_state (void) static void yyensure_buffer_stack (void) { yy_size_t num_to_alloc; - + if (!(yy_buffer_stack)) { /* First allocation is just for 2 elements, since we don't know if this @@ -6488,9 +6488,9 @@ static void yyensure_buffer_stack (void) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; @@ -6518,13 +6518,13 @@ static void yyensure_buffer_stack (void) /** Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. + * + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) { YY_BUFFER_STATE b; - + if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) @@ -6553,14 +6553,14 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) /** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan - * + * * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use * yy_scan_bytes() instead. */ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) { - + return yy_scan_bytes(yystr,strlen(yystr) ); } @@ -6568,7 +6568,7 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * + * * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) @@ -6577,7 +6577,7 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len char *buf; yy_size_t n; yy_size_t i; - + /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; buf = (char *) yyalloc(n ); @@ -6631,16 +6631,16 @@ static void yy_fatal_error (yyconst char* msg ) /* Accessor methods (get/set functions) to struct members. */ /** Get the current line number. - * + * */ int yyget_lineno (void) { - + return yylineno; } /** Get the input stream. - * + * */ FILE *yyget_in (void) { @@ -6648,7 +6648,7 @@ FILE *yyget_in (void) } /** Get the output stream. - * + * */ FILE *yyget_out (void) { @@ -6656,7 +6656,7 @@ FILE *yyget_out (void) } /** Get the length of the current token. - * + * */ yy_size_t yyget_leng (void) { @@ -6664,7 +6664,7 @@ yy_size_t yyget_leng (void) } /** Get the current token. - * + * */ char *yyget_text (void) @@ -6674,18 +6674,18 @@ char *yyget_text (void) /** Set the current line number. * @param line_number - * + * */ void yyset_lineno (int line_number ) { - + yylineno = line_number; } /** Set the input stream. This does not discard the current * input buffer. * @param in_str A readable stream. - * + * * @see yy_switch_to_buffer */ void yyset_in (FILE * in_str ) @@ -6739,7 +6739,7 @@ static int yy_init_globals (void) /* yylex_destroy is for both reentrant and non-reentrant scanners. */ int yylex_destroy (void) { - + /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ yy_delete_buffer(YY_CURRENT_BUFFER ); diff --git a/sbin/unwind/libunbound/util/data/dname.c b/sbin/unwind/libunbound/util/data/dname.c index 76b2ec7d6..6a0bb0cea 100644 --- a/sbin/unwind/libunbound/util/data/dname.c +++ b/sbin/unwind/libunbound/util/data/dname.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -70,7 +70,7 @@ query_dname_len(sldns_buffer* query) } } -size_t +size_t dname_valid(uint8_t* dname, size_t maxlen) { size_t len = 0; @@ -96,7 +96,7 @@ dname_valid(uint8_t* dname, size_t maxlen) } /** compare uncompressed, noncanonical, registers are hints for speed */ -int +int query_dname_compare(register uint8_t* d1, register uint8_t* d2) { register uint8_t lab1, lab2; @@ -115,7 +115,7 @@ query_dname_compare(register uint8_t* d1, register uint8_t* d2) /* compare lowercased labels. */ while(lab1--) { /* compare bytes first for speed */ - if(*d1 != *d2 && + if(*d1 != *d2 && tolower((unsigned char)*d1) != tolower((unsigned char)*d2)) { if(tolower((unsigned char)*d1) < tolower((unsigned char)*d2)) return -1; @@ -131,7 +131,7 @@ query_dname_compare(register uint8_t* d1, register uint8_t* d2) return 0; } -void +void query_dname_tolower(uint8_t* dname) { /* the dname is stored uncompressed */ @@ -147,7 +147,7 @@ query_dname_tolower(uint8_t* dname) } } -void +void pkt_dname_tolower(sldns_buffer* pkt, uint8_t* dname) { uint8_t lablen; @@ -157,7 +157,7 @@ pkt_dname_tolower(sldns_buffer* pkt, uint8_t* dname) lablen = *dname++; while(lablen) { if(LABEL_IS_PTR(lablen)) { - if((size_t)PTR_OFFSET(lablen, *dname) + if((size_t)PTR_OFFSET(lablen, *dname) >= sldns_buffer_limit(pkt)) return; dname = sldns_buffer_at(pkt, PTR_OFFSET(lablen, *dname)); @@ -229,7 +229,7 @@ pkt_dname_len(sldns_buffer* pkt) return len; } -int +int dname_pkt_compare(sldns_buffer* pkt, uint8_t* d1, uint8_t* d2) { uint8_t len1, len2; @@ -394,7 +394,7 @@ void dname_print(FILE* out, struct sldns_buffer* pkt, uint8_t* dname) if(!dname) return; lablen = *dname++; - if(!lablen) + if(!lablen) fputc('.', out); while(lablen) { if(LABEL_IS_PTR(lablen)) { @@ -427,7 +427,7 @@ void dname_print(FILE* out, struct sldns_buffer* pkt, uint8_t* dname) } } -int +int dname_count_labels(uint8_t* dname) { uint8_t lablen; @@ -442,9 +442,9 @@ dname_count_labels(uint8_t* dname) return labs; } -int +int dname_count_size_labels(uint8_t* dname, size_t* size) -{ +{ uint8_t lablen; int labs = 1; size_t sz = 1; @@ -482,7 +482,7 @@ memlowercmp(uint8_t* p1, uint8_t* p2, uint8_t len) return 0; } -int +int dname_lab_cmp(uint8_t* d1, int labs1, uint8_t* d2, int labs2, int* mlabs) { uint8_t len1, len2; @@ -524,13 +524,13 @@ dname_lab_cmp(uint8_t* d1, int labs1, uint8_t* d2, int labs2, int* mlabs) d2 += len2; } else { /* memlowercmp is inlined here; or just like - * if((c=memlowercmp(d1, d2, len1)) != 0) { + * if((c=memlowercmp(d1, d2, len1)) != 0) { * lastdiff = c; * lastmlabs = atlabel; } apart from d1++,d2++ */ while(len1) { - if(*d1 != *d2 && tolower((unsigned char)*d1) + if(*d1 != *d2 && tolower((unsigned char)*d1) != tolower((unsigned char)*d2)) { - if(tolower((unsigned char)*d1) < + if(tolower((unsigned char)*d1) < tolower((unsigned char)*d2)) { lastdiff = -1; lastmlabs = atlabel; @@ -616,7 +616,7 @@ dname_has_label(uint8_t* dname, size_t dnamelen, uint8_t* label) return 0; } -int +int dname_buffer_write(sldns_buffer* pkt, uint8_t* dname) { uint8_t lablen; @@ -660,8 +660,8 @@ void dname_str(uint8_t* dname, char* str) return; } while(lablen--) { - if(isalnum((unsigned char)*dname) - || *dname == '-' || *dname == '_' + if(isalnum((unsigned char)*dname) + || *dname == '-' || *dname == '_' || *dname == '*') *s++ = *(char*)dname++; else { @@ -675,12 +675,12 @@ void dname_str(uint8_t* dname, char* str) *s = 0; } -int +int dname_strict_subdomain(uint8_t* d1, int labs1, uint8_t* d2, int labs2) { int m; /* check subdomain: d1: www.example.com. and d2: example.com. */ - if(labs2 >= labs1) + if(labs2 >= labs1) return 0; if(dname_lab_cmp(d1, labs1, d2, labs2, &m) > 0) { /* subdomain if all labels match */ @@ -689,14 +689,14 @@ dname_strict_subdomain(uint8_t* d1, int labs1, uint8_t* d2, int labs2) return 0; } -int +int dname_strict_subdomain_c(uint8_t* d1, uint8_t* d2) { return dname_strict_subdomain(d1, dname_count_labels(d1), d2, dname_count_labels(d2)); } -int +int dname_subdomain_c(uint8_t* d1, uint8_t* d2) { int m; @@ -704,7 +704,7 @@ dname_subdomain_c(uint8_t* d1, uint8_t* d2) /* or d1: example.com. and d2: example.com. */ int labs1 = dname_count_labels(d1); int labs2 = dname_count_labels(d2); - if(labs2 > labs1) + if(labs2 > labs1) return 0; if(dname_lab_cmp(d1, labs1, d2, labs2, &m) < 0) { /* must have been example.com , www.example.com - wrong */ @@ -714,7 +714,7 @@ dname_subdomain_c(uint8_t* d1, uint8_t* d2) return (m == labs2); } -int +int dname_is_root(uint8_t* dname) { uint8_t len; @@ -724,7 +724,7 @@ dname_is_root(uint8_t* dname) return (len == 0); } -void +void dname_remove_label(uint8_t** dname, size_t* len) { size_t lablen; @@ -738,7 +738,7 @@ dname_remove_label(uint8_t** dname, size_t* len) *dname += lablen+1; } -void +void dname_remove_labels(uint8_t** dname, size_t* len, int n) { int i; @@ -746,7 +746,7 @@ dname_remove_labels(uint8_t** dname, size_t* len, int n) dname_remove_label(dname, len); } -int +int dname_signame_label_count(uint8_t* dname) { uint8_t lablen; @@ -765,7 +765,7 @@ dname_signame_label_count(uint8_t* dname) return count; } -int +int dname_is_wild(uint8_t* dname) { return (dname[0] == 1 && dname[1] == '*'); @@ -798,7 +798,7 @@ memcanoncmp(uint8_t* p1, uint8_t len1, uint8_t* p2, uint8_t len2) } -int +int dname_canon_lab_cmp(uint8_t* d1, int labs1, uint8_t* d2, int labs2, int* mlabs) { /* like dname_lab_cmp, but with different label comparison, diff --git a/sbin/unwind/libunbound/util/data/dname.h b/sbin/unwind/libunbound/util/data/dname.h index cb0f6735d..62770b0f2 100644 --- a/sbin/unwind/libunbound/util/data/dname.h +++ b/sbin/unwind/libunbound/util/data/dname.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -50,11 +50,11 @@ struct sldns_buffer; /** max number of compression ptrs to follow */ #define MAX_COMPRESS_PTRS 256 -/** - * Determine length of dname in buffer, no compression ptrs allowed, +/** + * Determine length of dname in buffer, no compression ptrs allowed, * @param query: the ldns buffer, current position at start of dname. * at end, position is at end of the dname. - * @return: 0 on parse failure, or length including ending 0 of dname. + * @return: 0 on parse failure, or length including ending 0 of dname. */ size_t query_dname_len(struct sldns_buffer* query); @@ -69,9 +69,9 @@ size_t dname_valid(uint8_t* dname, size_t len); /** lowercase query dname */ void query_dname_tolower(uint8_t* dname); -/** +/** * lowercase pkt dname (follows compression pointers) - * @param pkt: the packet, used to follow compression pointers. Position + * @param pkt: the packet, used to follow compression pointers. Position * is unchanged. * @param dname: start of dname in packet. */ @@ -87,7 +87,7 @@ void pkt_dname_tolower(struct sldns_buffer* pkt, uint8_t* dname); * that is smaller (possibly after lowercasing) makes an RR smaller, or the * shortest name makes an RR smaller. * - * This routine does not compute the canonical order needed for NSEC + * This routine does not compute the canonical order needed for NSEC * processing. * * Dnames have to be valid format. @@ -186,7 +186,7 @@ int dname_count_size_labels(uint8_t* dname, size_t* size); int dname_lab_cmp(uint8_t* d1, int labs1, uint8_t* d2, int labs2, int* mlabs); /** - * Check if labels starts with given prefix + * Check if labels starts with given prefix * @param label: dname label * @param prefix: the string to match label with, null terminated. * @param endptr: pointer to location in label after prefix, only if return @@ -207,7 +207,7 @@ int dname_has_label(uint8_t* dname, size_t dnamelen, uint8_t* label); /** * See if domain name d1 is a strict subdomain of d2. - * That is a subdomain, but not equal. + * That is a subdomain, but not equal. * @param d1: domain name, uncompressed wireformat * @param labs1: number of labels in d1, including root label. * @param d2: domain name, uncompressed wireformat @@ -217,7 +217,7 @@ int dname_has_label(uint8_t* dname, size_t dnamelen, uint8_t* label); int dname_strict_subdomain(uint8_t* d1, int labs1, uint8_t* d2, int labs2); /** - * Like dname_strict_subdomain but counts labels + * Like dname_strict_subdomain but counts labels * @param d1: domain name, uncompressed wireformat * @param d2: domain name, uncompressed wireformat * @return true if d1 is a subdomain of d2, but not equal to d2. @@ -232,15 +232,15 @@ int dname_strict_subdomain_c(uint8_t* d1, uint8_t* d2); */ int dname_subdomain_c(uint8_t* d1, uint8_t* d2); -/** - * Debug helper. Print wireformat dname to output. +/** + * Debug helper. Print wireformat dname to output. * @param out: like stdout or a file. * @param pkt: if not NULL, the packet for resolving compression ptrs. * @param dname: pointer to (start of) dname. */ void dname_print(FILE* out, struct sldns_buffer* pkt, uint8_t* dname); -/** +/** * Debug helper. Print dname to given string buffer (string buffer must * be at least 255 chars + 1 for the 0, in printable form. * This may lose information (? for nonprintable characters, or & if @@ -301,7 +301,7 @@ int dname_is_wild(uint8_t* dname); * @param mlabs: number of labels that matched exactly (the shared topdomain). * @return: 0 for equal, -1 smaller, or +1 d1 larger than d2. */ -int dname_canon_lab_cmp(uint8_t* d1, int labs1, uint8_t* d2, int labs2, +int dname_canon_lab_cmp(uint8_t* d1, int labs1, uint8_t* d2, int labs2, int* mlabs); /** diff --git a/sbin/unwind/libunbound/util/data/msgencode.c b/sbin/unwind/libunbound/util/data/msgencode.c index a170eb7b8..933f6dc65 100644 --- a/sbin/unwind/libunbound/util/data/msgencode.c +++ b/sbin/unwind/libunbound/util/data/msgencode.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -113,7 +113,7 @@ compress_tree_search(struct compress_tree_node** tree, uint8_t* dname, struct compress_tree_node* close = 0; struct compress_tree_node** prev = tree; while(p) { - if((c = dname_lab_cmp(dname, labs, p->dname, p->labs, &n)) + if((c = dname_lab_cmp(dname, labs, p->dname, p->labs, &n)) == 0) { *matchlabels = n; *match = p; @@ -175,7 +175,7 @@ compress_tree_lookup(struct compress_tree_node** tree, uint8_t* dname, * @return new node or 0 on malloc failure. */ static struct compress_tree_node* -compress_tree_newnode(uint8_t* dname, int labs, size_t offset, +compress_tree_newnode(uint8_t* dname, int labs, size_t offset, struct regional* region) { struct compress_tree_node* n = (struct compress_tree_node*) @@ -199,12 +199,12 @@ compress_tree_newnode(uint8_t* dname, int labs, size_t offset, * @param closest: match from previous lookup, used to compress dname. * may be NULL if no previous match. * if the tree has an ancestor of dname already, this must be it. - * @param insertpt: where to insert the dname in tree. + * @param insertpt: where to insert the dname in tree. * @return: 0 on memory error. */ static int -compress_tree_store(uint8_t* dname, int labs, size_t offset, - struct regional* region, struct compress_tree_node* closest, +compress_tree_store(uint8_t* dname, int labs, size_t offset, + struct regional* region, struct compress_tree_node* closest, struct compress_tree_node** insertpt) { uint8_t lablen; @@ -219,7 +219,7 @@ compress_tree_store(uint8_t* dname, int labs, size_t offset, /* insertion failed, drop vine */ return 1; /* compression pointer no longer useful */ } - if(!(newnode = compress_tree_newnode(dname, labs, offset, + if(!(newnode = compress_tree_newnode(dname, labs, offset, region))) { /* insertion failed, drop vine */ return 0; @@ -284,21 +284,21 @@ write_compressed_dname(sldns_buffer* pkt, uint8_t* dname, int labs, /** compress owner name of RR, return RETVAL_OUTMEM RETVAL_TRUNC */ static int -compress_owner(struct ub_packed_rrset_key* key, sldns_buffer* pkt, - struct regional* region, struct compress_tree_node** tree, +compress_owner(struct ub_packed_rrset_key* key, sldns_buffer* pkt, + struct regional* region, struct compress_tree_node** tree, size_t owner_pos, uint16_t* owner_ptr, int owner_labs) { struct compress_tree_node* p; struct compress_tree_node** insertpt = NULL; if(!*owner_ptr) { /* compress first time dname */ - if((p = compress_tree_lookup(tree, key->rk.dname, + if((p = compress_tree_lookup(tree, key->rk.dname, owner_labs, &insertpt))) { - if(p->labs == owner_labs) + if(p->labs == owner_labs) /* avoid ptr chains, since some software is * not capable of decoding ptr after a ptr. */ *owner_ptr = htons(PTR_CREATE(p->offset)); - if(!write_compressed_dname(pkt, key->rk.dname, + if(!write_compressed_dname(pkt, key->rk.dname, owner_labs, p)) return RETVAL_TRUNC; /* check if typeclass+4 ttl + rdatalen is available */ @@ -308,22 +308,22 @@ compress_owner(struct ub_packed_rrset_key* key, sldns_buffer* pkt, /* no compress */ if(sldns_buffer_remaining(pkt) < key->rk.dname_len+4+4+2) return RETVAL_TRUNC; - sldns_buffer_write(pkt, key->rk.dname, + sldns_buffer_write(pkt, key->rk.dname, key->rk.dname_len); if(owner_pos <= PTR_MAX_OFFSET) *owner_ptr = htons(PTR_CREATE(owner_pos)); } - if(!compress_tree_store(key->rk.dname, owner_labs, + if(!compress_tree_store(key->rk.dname, owner_labs, owner_pos, region, p, insertpt)) return RETVAL_OUTMEM; } else { /* always compress 2nd-further RRs in RRset */ if(owner_labs == 1) { - if(sldns_buffer_remaining(pkt) < 1+4+4+2) + if(sldns_buffer_remaining(pkt) < 1+4+4+2) return RETVAL_TRUNC; sldns_buffer_write_u8(pkt, 0); } else { - if(sldns_buffer_remaining(pkt) < 2+4+4+2) + if(sldns_buffer_remaining(pkt) < 2+4+4+2) return RETVAL_TRUNC; sldns_buffer_write(pkt, owner_ptr, 2); } @@ -333,7 +333,7 @@ compress_owner(struct ub_packed_rrset_key* key, sldns_buffer* pkt, /** compress any domain name to the packet, return RETVAL_* */ static int -compress_any_dname(uint8_t* dname, sldns_buffer* pkt, int labs, +compress_any_dname(uint8_t* dname, sldns_buffer* pkt, int labs, struct regional* region, struct compress_tree_node** tree) { struct compress_tree_node* p; @@ -356,7 +356,7 @@ static const sldns_rr_descriptor* type_rdata_compressable(struct ub_packed_rrset_key* key) { uint16_t t = ntohs(key->rk.type); - if(sldns_rr_descript(t) && + if(sldns_rr_descript(t) && sldns_rr_descript(t)->_compress == LDNS_RR_COMPRESS) return sldns_rr_descript(t); return 0; @@ -364,8 +364,8 @@ type_rdata_compressable(struct ub_packed_rrset_key* key) /** compress domain names in rdata, return RETVAL_* */ static int -compress_rdata(sldns_buffer* pkt, uint8_t* rdata, size_t todolen, - struct regional* region, struct compress_tree_node** tree, +compress_rdata(sldns_buffer* pkt, uint8_t* rdata, size_t todolen, + struct regional* region, struct compress_tree_node** tree, const sldns_rr_descriptor* desc) { int labs, r, rdf = 0; @@ -380,7 +380,7 @@ compress_rdata(sldns_buffer* pkt, uint8_t* rdata, size_t todolen, switch(desc->_wireformat[rdf]) { case LDNS_RDF_TYPE_DNAME: labs = dname_count_size_labels(rdata, &dname_len); - if((r=compress_any_dname(rdata, pkt, labs, region, + if((r=compress_any_dname(rdata, pkt, labs, region, tree)) != RETVAL_OK) return r; rdata += dname_len; @@ -418,7 +418,7 @@ compress_rdata(sldns_buffer* pkt, uint8_t* rdata, size_t todolen, /** Returns true if RR type should be included */ static int -rrset_belongs_in_reply(sldns_pkt_section s, uint16_t rrtype, uint16_t qtype, +rrset_belongs_in_reply(sldns_pkt_section s, uint16_t rrtype, uint16_t qtype, int dnssec) { if(dnssec) @@ -446,7 +446,7 @@ rrset_belongs_in_reply(sldns_pkt_section s, uint16_t rrtype, uint16_t qtype, /** store rrset in buffer in wireformat, return RETVAL_* */ static int -packed_rrset_encode(struct ub_packed_rrset_key* key, sldns_buffer* pkt, +packed_rrset_encode(struct ub_packed_rrset_key* key, sldns_buffer* pkt, uint16_t* num_rrs, time_t timenow, struct regional* region, int do_data, int do_sig, struct compress_tree_node** tree, sldns_pkt_section s, uint16_t qtype, int dnssec, size_t rr_offset) @@ -457,7 +457,7 @@ packed_rrset_encode(struct ub_packed_rrset_key* key, sldns_buffer* pkt, time_t adjust = 0; struct packed_rrset_data* data = (struct packed_rrset_data*) key->entry.data; - + /* does this RR type belong in the answer? */ if(!rrset_belongs_in_reply(s, ntohs(key->rk.type), qtype, dnssec)) return RETVAL_OK; @@ -477,7 +477,7 @@ packed_rrset_encode(struct ub_packed_rrset_key* key, sldns_buffer* pkt, for(i=0; icount; i++) { /* rrset roundrobin */ j = (i + rr_offset) % data->count; - if((r=compress_owner(key, pkt, region, tree, + if((r=compress_owner(key, pkt, region, tree, owner_pos, &owner_ptr, owner_labs)) != RETVAL_OK) return r; @@ -506,15 +506,15 @@ packed_rrset_encode(struct ub_packed_rrset_key* key, sldns_buffer* pkt, for(i=data->count; irr_len[i]) + 2+4+4+data->rr_len[i]) return RETVAL_TRUNC; sldns_buffer_write(pkt, &owner_ptr, 2); } else { - if((r=compress_any_dname(key->rk.dname, + if((r=compress_any_dname(key->rk.dname, pkt, owner_labs, region, tree)) != RETVAL_OK) return r; - if(sldns_buffer_remaining(pkt) < + if(sldns_buffer_remaining(pkt) < 4+4+data->rr_len[i]) return RETVAL_TRUNC; } @@ -542,7 +542,7 @@ packed_rrset_encode(struct ub_packed_rrset_key* key, sldns_buffer* pkt, /** store msg section in wireformat buffer, return RETVAL_* */ static int insert_section(struct reply_info* rep, size_t num_rrsets, uint16_t* num_rrs, - sldns_buffer* pkt, size_t rrsets_before, time_t timenow, + sldns_buffer* pkt, size_t rrsets_before, time_t timenow, struct regional* region, struct compress_tree_node** tree, sldns_pkt_section s, uint16_t qtype, int dnssec, size_t rr_offset) { @@ -558,7 +558,7 @@ insert_section(struct reply_info* rep, size_t num_rrsets, uint16_t* num_rrs, dnssec = 1; /* include all types in ANY answer */ for(i=0; irrsets[rrsets_before+i], + if((r=packed_rrset_encode(rep->rrsets[rrsets_before+i], pkt, num_rrs, timenow, region, 1, 1, tree, s, qtype, dnssec, rr_offset)) != RETVAL_OK) { @@ -571,7 +571,7 @@ insert_section(struct reply_info* rep, size_t num_rrsets, uint16_t* num_rrs, } else { for(i=0; irrsets[rrsets_before+i], + if((r=packed_rrset_encode(rep->rrsets[rrsets_before+i], pkt, num_rrs, timenow, region, 1, 0, tree, s, qtype, dnssec, rr_offset)) != RETVAL_OK) { @@ -582,7 +582,7 @@ insert_section(struct reply_info* rep, size_t num_rrsets, uint16_t* num_rrs, if(dnssec) for(i=0; irrsets[rrsets_before+i], + if((r=packed_rrset_encode(rep->rrsets[rrsets_before+i], pkt, num_rrs, timenow, region, 0, 1, tree, s, qtype, dnssec, rr_offset)) != RETVAL_OK) { @@ -596,14 +596,14 @@ insert_section(struct reply_info* rep, size_t num_rrsets, uint16_t* num_rrs, /** store query section in wireformat buffer, return RETVAL */ static int -insert_query(struct query_info* qinfo, struct compress_tree_node** tree, +insert_query(struct query_info* qinfo, struct compress_tree_node** tree, sldns_buffer* buffer, struct regional* region) { uint8_t* qname = qinfo->local_alias ? qinfo->local_alias->rrset->rk.dname : qinfo->qname; size_t qname_len = qinfo->local_alias ? qinfo->local_alias->rrset->rk.dname_len : qinfo->qname_len; - if(sldns_buffer_remaining(buffer) < + if(sldns_buffer_remaining(buffer) < qinfo->qname_len+sizeof(uint16_t)*2) return RETVAL_TRUNC; /* buffer too small */ /* the query is the first name inserted into the tree */ @@ -944,7 +944,7 @@ attach_edns_record_max_msg_sz(sldns_buffer* pkt, struct edns_data* edns, size_t msg_sz = ((pad_pos + 3) / edns->padding_block_size + 1) * edns->padding_block_size; size_t pad_sz; - + if (msg_sz > max_msg_sz) msg_sz = max_msg_sz; @@ -962,7 +962,7 @@ attach_edns_record_max_msg_sz(sldns_buffer* pkt, struct edns_data* edns, sldns_buffer_skip(pkt, pad_sz); } } - sldns_buffer_write_u16_at(pkt, rdatapos, + sldns_buffer_write_u16_at(pkt, rdatapos, sldns_buffer_position(pkt)-rdatapos-2); sldns_buffer_flip(pkt); } @@ -975,10 +975,10 @@ attach_edns_record(sldns_buffer* pkt, struct edns_data* edns) attach_edns_record_max_msg_sz(pkt, edns, edns->udp_size); } -int -reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep, +int +reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep, uint16_t id, uint16_t qflags, sldns_buffer* pkt, time_t timenow, - int cached, struct regional* region, uint16_t udpsize, + int cached, struct regional* region, uint16_t udpsize, struct edns_data* edns, int dnssec, int secure) { uint16_t flags; @@ -987,10 +987,10 @@ reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep, if(!cached || rep->authoritative) { /* original flags, copy RD and CD bits from query. */ - flags = rep->flags | (qflags & (BIT_RD|BIT_CD)); + flags = rep->flags | (qflags & (BIT_RD|BIT_CD)); } else { /* remove AA bit, copy RD and CD bits from query. */ - flags = (rep->flags & ~BIT_AA) | (qflags & (BIT_RD|BIT_CD)); + flags = (rep->flags & ~BIT_AA) | (qflags & (BIT_RD|BIT_CD)); } if(secure && (dnssec || (qflags&BIT_AD))) flags |= BIT_AD; @@ -1042,7 +1042,7 @@ reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep, return 1; } -void +void qinfo_query_encode(sldns_buffer* pkt, struct query_info* qinfo) { uint16_t flags = 0; /* QUERY, NOERROR */ diff --git a/sbin/unwind/libunbound/util/data/msgencode.h b/sbin/unwind/libunbound/util/data/msgencode.h index 6aff06099..dce4551ab 100644 --- a/sbin/unwind/libunbound/util/data/msgencode.h +++ b/sbin/unwind/libunbound/util/data/msgencode.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -48,7 +48,7 @@ struct reply_info; struct regional; struct edns_data; -/** +/** * Generate answer from reply_info. * @param qinf: query information that provides query section in packet. * @param rep: reply to fill in. @@ -66,9 +66,9 @@ struct edns_data; * @param secure: if 1, the AD bit is set in the reply. * @return: 0 on error (server failure). */ -int reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep, +int reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep, uint16_t id, uint16_t qflags, struct sldns_buffer* dest, time_t timenow, - int cached, struct regional* region, uint16_t udpsize, + int cached, struct regional* region, uint16_t udpsize, struct edns_data* edns, int dnssec, int secure); /** @@ -87,11 +87,11 @@ int reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep, * @param dnssec: if 0 DNSSEC records are omitted from the answer. * @param minimise: if true, the answer is a minimal response, with * authority and additional removed if possible. - * @return: nonzero is success, or + * @return: nonzero is success, or * 0 on error: malloc failure (no log_err has been done). */ -int reply_info_encode(struct query_info* qinfo, struct reply_info* rep, - uint16_t id, uint16_t flags, struct sldns_buffer* buffer, time_t timenow, +int reply_info_encode(struct query_info* qinfo, struct reply_info* rep, + uint16_t id, uint16_t flags, struct sldns_buffer* buffer, time_t timenow, struct regional* region, uint16_t udpsize, int dnssec, int minimise); /** diff --git a/sbin/unwind/libunbound/util/data/msgparse.c b/sbin/unwind/libunbound/util/data/msgparse.c index b5414c6d0..880cf89ae 100644 --- a/sbin/unwind/libunbound/util/data/msgparse.c +++ b/sbin/unwind/libunbound/util/data/msgparse.c @@ -1,25 +1,25 @@ -/* +/* * util/data/msgparse.c - parse wireformat DNS messages. - * + * * Copyright (c) 2007, NLnet Labs. All rights reserved. - * + * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -54,7 +54,7 @@ /** smart comparison of (compressed, valid) dnames from packet */ static int -smart_compare(sldns_buffer* pkt, uint8_t* dnow, +smart_compare(sldns_buffer* pkt, uint8_t* dnow, uint8_t* dprfirst, uint8_t* dprlast) { if(LABEL_IS_PTR(*dnow)) { @@ -77,10 +77,10 @@ smart_compare(sldns_buffer* pkt, uint8_t* dnow, /** * Allocate new rrset in region, fill with data. */ -static struct rrset_parse* -new_rrset(struct msg_parse* msg, uint8_t* dname, size_t dnamelen, - uint16_t type, uint16_t dclass, hashvalue_type hash, - uint32_t rrset_flags, sldns_pkt_section section, +static struct rrset_parse* +new_rrset(struct msg_parse* msg, uint8_t* dname, size_t dnamelen, + uint16_t type, uint16_t dclass, hashvalue_type hash, + uint32_t rrset_flags, sldns_pkt_section section, struct regional* region) { struct rrset_parse* p = regional_alloc(region, sizeof(*p)); @@ -168,7 +168,7 @@ pkt_rrset_flags(sldns_buffer* pkt, uint16_t type, sldns_pkt_section sec) } hashvalue_type -pkt_hash_rrset(sldns_buffer* pkt, uint8_t* dname, uint16_t type, +pkt_hash_rrset(sldns_buffer* pkt, uint8_t* dname, uint16_t type, uint16_t dclass, uint32_t rrset_flags) { /* note this MUST be identical to rrset_key_hash in packed_rrset.c */ @@ -195,7 +195,7 @@ pkt_hash_rrset_first(sldns_buffer* pkt, uint8_t* dname) /** create a rrset hash from a partial dname hash */ static hashvalue_type -pkt_hash_rrset_rest(hashvalue_type dname_h, uint16_t type, uint16_t dclass, +pkt_hash_rrset_rest(hashvalue_type dname_h, uint16_t type, uint16_t dclass, uint32_t rrset_flags) { /* works together with pkt_hash_rrset_first */ @@ -209,8 +209,8 @@ pkt_hash_rrset_rest(hashvalue_type dname_h, uint16_t type, uint16_t dclass, /** compare rrset_parse with data */ static int -rrset_parse_equals(struct rrset_parse* p, sldns_buffer* pkt, hashvalue_type h, - uint32_t rrset_flags, uint8_t* dname, size_t dnamelen, +rrset_parse_equals(struct rrset_parse* p, sldns_buffer* pkt, hashvalue_type h, + uint32_t rrset_flags, uint8_t* dname, size_t dnamelen, uint16_t type, uint16_t dclass) { if(p->hash == h && p->dname_len == dnamelen && p->type == type && @@ -222,7 +222,7 @@ rrset_parse_equals(struct rrset_parse* p, sldns_buffer* pkt, hashvalue_type h, struct rrset_parse* -msgparse_hashtable_lookup(struct msg_parse* msg, sldns_buffer* pkt, +msgparse_hashtable_lookup(struct msg_parse* msg, sldns_buffer* pkt, hashvalue_type h, uint32_t rrset_flags, uint8_t* dname, size_t dnamelen, uint16_t type, uint16_t dclass) { @@ -342,7 +342,7 @@ rrset_has_sigover(sldns_buffer* pkt, struct rrset_parse* rrset, uint16_t type, /** move rrsigs from sigset to dataset */ static int -moveover_rrsigs(sldns_buffer* pkt, struct regional* region, +moveover_rrsigs(sldns_buffer* pkt, struct regional* region, struct rrset_parse* sigset, struct rrset_parse* dataset, int duplicate) { struct rr_parse* sig = sigset->rr_first; @@ -351,7 +351,7 @@ moveover_rrsigs(sldns_buffer* pkt, struct regional* region, struct rr_parse* nextsig; while(sig) { nextsig = sig->next; - if(pkt_rrsig_covered_equals(pkt, sig->ttl_data, + if(pkt_rrsig_covered_equals(pkt, sig->ttl_data, dataset->type)) { if(duplicate) { /* new */ @@ -376,7 +376,7 @@ moveover_rrsigs(sldns_buffer* pkt, struct regional* region, /* add to dataset */ dataset->rrsig_count++; insert->next = 0; - if(dataset->rrsig_last) + if(dataset->rrsig_last) dataset->rrsig_last->next = insert; else dataset->rrsig_first = insert; dataset->rrsig_last = insert; @@ -391,21 +391,21 @@ moveover_rrsigs(sldns_buffer* pkt, struct regional* region, /** change an rrsig rrset for use as data rrset */ static struct rrset_parse* -change_rrsig_rrset(struct rrset_parse* sigset, struct msg_parse* msg, +change_rrsig_rrset(struct rrset_parse* sigset, struct msg_parse* msg, sldns_buffer* pkt, uint16_t datatype, uint32_t rrset_flags, int hasother, sldns_pkt_section section, struct regional* region) { struct rrset_parse* dataset = sigset; - hashvalue_type hash = pkt_hash_rrset(pkt, sigset->dname, datatype, + hashvalue_type hash = pkt_hash_rrset(pkt, sigset->dname, datatype, sigset->rrset_class, rrset_flags); log_assert( sigset->type == LDNS_RR_TYPE_RRSIG ); log_assert( datatype != LDNS_RR_TYPE_RRSIG ); if(hasother) { /* need to make new rrset to hold data type */ - dataset = new_rrset(msg, sigset->dname, sigset->dname_len, - datatype, sigset->rrset_class, hash, rrset_flags, + dataset = new_rrset(msg, sigset->dname, sigset->dname_len, + datatype, sigset->rrset_class, hash, rrset_flags, section, region); - if(!dataset) + if(!dataset) return NULL; switch(section) { case LDNS_SECTION_ANSWER: msg->an_rrsets++; break; @@ -413,7 +413,7 @@ change_rrsig_rrset(struct rrset_parse* sigset, struct msg_parse* msg, case LDNS_SECTION_ADDITIONAL: msg->ar_rrsets++; break; default: log_assert(0); } - if(!moveover_rrsigs(pkt, region, sigset, dataset, + if(!moveover_rrsigs(pkt, region, sigset, dataset, msg->qtype == LDNS_RR_TYPE_RRSIG || (msg->qtype == LDNS_RR_TYPE_ANY && section != LDNS_SECTION_ANSWER) )) @@ -462,8 +462,8 @@ change_rrsig_rrset(struct rrset_parse* sigset, struct msg_parse* msg, * @return 0 on out of memory. */ static int -find_rrset(struct msg_parse* msg, sldns_buffer* pkt, uint8_t* dname, - size_t dnamelen, uint16_t type, uint16_t dclass, hashvalue_type* hash, +find_rrset(struct msg_parse* msg, sldns_buffer* pkt, uint8_t* dname, + size_t dnamelen, uint16_t type, uint16_t dclass, hashvalue_type* hash, uint32_t* rrset_flags, uint8_t** prev_dname_first, uint8_t** prev_dname_last, size_t* prev_dnamelen, uint16_t* prev_type, @@ -476,7 +476,7 @@ find_rrset(struct msg_parse* msg, sldns_buffer* pkt, uint8_t* dname, /* check if equal to previous item */ if(type == *prev_type && dclass == *prev_dclass && dnamelen == *prev_dnamelen && - smart_compare(pkt, dname, *prev_dname_first, + smart_compare(pkt, dname, *prev_dname_first, *prev_dname_last) == 0 && type != LDNS_RR_TYPE_RRSIG) { /* same as previous */ @@ -496,21 +496,21 @@ find_rrset(struct msg_parse* msg, sldns_buffer* pkt, uint8_t* dname, } /* find by hashing and lookup in hashtable */ *rrset_flags = pkt_rrset_flags(pkt, type, section); - + /* if rrsig - try to lookup matching data set first */ - if(type == LDNS_RR_TYPE_RRSIG && pkt_rrsig_covered(pkt, + if(type == LDNS_RR_TYPE_RRSIG && pkt_rrsig_covered(pkt, sldns_buffer_current(pkt), &covtype)) { - *hash = pkt_hash_rrset_rest(dname_h, covtype, dclass, + *hash = pkt_hash_rrset_rest(dname_h, covtype, dclass, *rrset_flags); - *rrset_prev = msgparse_hashtable_lookup(msg, pkt, *hash, + *rrset_prev = msgparse_hashtable_lookup(msg, pkt, *hash, *rrset_flags, dname, dnamelen, covtype, dclass); if(!*rrset_prev && covtype == LDNS_RR_TYPE_NSEC) { /* if NSEC try with NSEC apex bit twiddled */ *rrset_flags ^= PACKED_RRSET_NSEC_AT_APEX; - *hash = pkt_hash_rrset_rest(dname_h, covtype, dclass, + *hash = pkt_hash_rrset_rest(dname_h, covtype, dclass, *rrset_flags); - *rrset_prev = msgparse_hashtable_lookup(msg, pkt, - *hash, *rrset_flags, dname, dnamelen, covtype, + *rrset_prev = msgparse_hashtable_lookup(msg, pkt, + *hash, *rrset_flags, dname, dnamelen, covtype, dclass); if(!*rrset_prev) /* untwiddle if not found */ *rrset_flags ^= PACKED_RRSET_NSEC_AT_APEX; @@ -518,10 +518,10 @@ find_rrset(struct msg_parse* msg, sldns_buffer* pkt, uint8_t* dname, if(!*rrset_prev && covtype == LDNS_RR_TYPE_SOA) { /* if SOA try with SOA neg flag twiddled */ *rrset_flags ^= PACKED_RRSET_SOA_NEG; - *hash = pkt_hash_rrset_rest(dname_h, covtype, dclass, + *hash = pkt_hash_rrset_rest(dname_h, covtype, dclass, *rrset_flags); - *rrset_prev = msgparse_hashtable_lookup(msg, pkt, - *hash, *rrset_flags, dname, dnamelen, covtype, + *rrset_prev = msgparse_hashtable_lookup(msg, pkt, + *hash, *rrset_flags, dname, dnamelen, covtype, dclass); if(!*rrset_prev) /* untwiddle if not found */ *rrset_flags ^= PACKED_RRSET_SOA_NEG; @@ -538,10 +538,10 @@ find_rrset(struct msg_parse* msg, sldns_buffer* pkt, uint8_t* dname, if(type != LDNS_RR_TYPE_RRSIG) { int hasother = 0; /* find matching rrsig */ - *hash = pkt_hash_rrset_rest(dname_h, LDNS_RR_TYPE_RRSIG, + *hash = pkt_hash_rrset_rest(dname_h, LDNS_RR_TYPE_RRSIG, dclass, 0); - *rrset_prev = msgparse_hashtable_lookup(msg, pkt, *hash, - 0, dname, dnamelen, LDNS_RR_TYPE_RRSIG, + *rrset_prev = msgparse_hashtable_lookup(msg, pkt, *hash, + 0, dname, dnamelen, LDNS_RR_TYPE_RRSIG, dclass); if(*rrset_prev && rrset_has_sigover(pkt, *rrset_prev, type, &hasother)) { @@ -551,8 +551,8 @@ find_rrset(struct msg_parse* msg, sldns_buffer* pkt, uint8_t* dname, *prev_dnamelen = dnamelen; *prev_type = type; *prev_dclass = dclass; - *rrset_prev = change_rrsig_rrset(*rrset_prev, msg, - pkt, type, *rrset_flags, hasother, section, + *rrset_prev = change_rrsig_rrset(*rrset_prev, msg, + pkt, type, *rrset_flags, hasother, section, region); if(!*rrset_prev) return 0; return 1; @@ -560,7 +560,7 @@ find_rrset(struct msg_parse* msg, sldns_buffer* pkt, uint8_t* dname, } *hash = pkt_hash_rrset_rest(dname_h, type, dclass, *rrset_flags); - *rrset_prev = msgparse_hashtable_lookup(msg, pkt, *hash, *rrset_flags, + *rrset_prev = msgparse_hashtable_lookup(msg, pkt, *hash, *rrset_flags, dname, dnamelen, type, dclass); if(*rrset_prev) *prev_dname_first = (*rrset_prev)->dname; @@ -573,7 +573,7 @@ find_rrset(struct msg_parse* msg, sldns_buffer* pkt, uint8_t* dname, } /** - * Parse query section. + * Parse query section. * @param pkt: packet, position at call must be at start of query section. * at end position is after query section. * @param msg: store results here. @@ -693,7 +693,7 @@ calc_size(sldns_buffer* pkt, uint16_t type, struct rr_parse* rr) /** skip rr ttl and rdata */ static int -skip_ttl_rdata(sldns_buffer* pkt) +skip_ttl_rdata(sldns_buffer* pkt) { uint16_t rdatalen; if(sldns_buffer_remaining(pkt) < 6) /* ttl + rdatalen */ @@ -713,7 +713,7 @@ sig_is_double(sldns_buffer* pkt, struct rrset_parse* rrset, uint8_t* ttldata) uint16_t rlen, siglen; size_t pos = sldns_buffer_position(pkt); struct rr_parse* sig; - if(sldns_buffer_remaining(pkt) < 6) + if(sldns_buffer_remaining(pkt) < 6) return 0; sldns_buffer_skip(pkt, 4); /* ttl */ rlen = sldns_buffer_read_u16(pkt); @@ -733,11 +733,11 @@ sig_is_double(sldns_buffer* pkt, struct rrset_parse* rrset, uint8_t* ttldata) * to have compressed dnames anyway. If it is compressed anyway * it will lead to duplicate rrs for qtype=RRSIG. (or ANY). * - * Cannot use sig->size because size of the other one is not + * Cannot use sig->size because size of the other one is not * calculated yet. */ if(siglen == rlen) { - if(siglen>0 && memcmp(sig->ttl_data+6, ttldata+6, + if(siglen>0 && memcmp(sig->ttl_data+6, ttldata+6, siglen) == 0) { /* same! */ return 1; @@ -750,8 +750,8 @@ sig_is_double(sldns_buffer* pkt, struct rrset_parse* rrset, uint8_t* ttldata) /** Add rr (from packet here) to rrset, skips rr */ static int -add_rr_to_rrset(struct rrset_parse* rrset, sldns_buffer* pkt, - struct msg_parse* msg, struct regional* region, +add_rr_to_rrset(struct rrset_parse* rrset, sldns_buffer* pkt, + struct msg_parse* msg, struct regional* region, sldns_pkt_section section, uint16_t type) { struct rr_parse* rr; @@ -759,8 +759,8 @@ add_rr_to_rrset(struct rrset_parse* rrset, sldns_buffer* pkt, if(rrset->section != section && type != LDNS_RR_TYPE_RRSIG && rrset->type != LDNS_RR_TYPE_RRSIG) { /* silently drop it - we drop the last part, since - * trust in rr data depends on the section it is in. - * the less trustworthy part is discarded. + * trust in rr data depends on the section it is in. + * the less trustworthy part is discarded. * also the last part is more likely to be incomplete. * RFC 2181: must put RRset only once in response. */ /* @@ -772,16 +772,16 @@ add_rr_to_rrset(struct rrset_parse* rrset, sldns_buffer* pkt, if(!skip_ttl_rdata(pkt)) return LDNS_RCODE_FORMERR; return 0; - } + } if( (msg->qtype == LDNS_RR_TYPE_RRSIG || - msg->qtype == LDNS_RR_TYPE_ANY) + msg->qtype == LDNS_RR_TYPE_ANY) && sig_is_double(pkt, rrset, sldns_buffer_current(pkt))) { if(!skip_ttl_rdata(pkt)) return LDNS_RCODE_FORMERR; return 0; } - + /* create rr */ if(!(rr = (struct rr_parse*)regional_alloc(region, sizeof(*rr)))) return LDNS_RCODE_SERVFAIL; @@ -789,7 +789,7 @@ add_rr_to_rrset(struct rrset_parse* rrset, sldns_buffer* pkt, rr->ttl_data = sldns_buffer_current(pkt); rr->next = 0; if(type == LDNS_RR_TYPE_RRSIG && rrset->type != LDNS_RR_TYPE_RRSIG) { - if(rrset->rrsig_last) + if(rrset->rrsig_last) rrset->rrsig_last->next = rr; else rrset->rrsig_first = rr; rrset->rrsig_last = rr; @@ -811,7 +811,7 @@ add_rr_to_rrset(struct rrset_parse* rrset, sldns_buffer* pkt, } /** - * Parse packet RR section, for answer, authority and additional sections. + * Parse packet RR section, for answer, authority and additional sections. * @param pkt: packet, position at call must be at start of section. * at end position is after section. * @param msg: store results here. @@ -822,8 +822,8 @@ add_rr_to_rrset(struct rrset_parse* rrset, sldns_buffer* pkt, * @return: 0 if OK, or rcode on error. */ static int -parse_section(sldns_buffer* pkt, struct msg_parse* msg, - struct regional* region, sldns_pkt_section section, +parse_section(sldns_buffer* pkt, struct msg_parse* msg, + struct regional* region, sldns_pkt_section section, uint16_t num_rrs, size_t* num_rrsets) { uint16_t i; @@ -853,7 +853,7 @@ parse_section(sldns_buffer* pkt, struct msg_parse* msg, if(0) { /* debug show what is being parsed. */ if(type == LDNS_RR_TYPE_RRSIG) { uint16_t t; - if(pkt_rrsig_covered(pkt, + if(pkt_rrsig_covered(pkt, sldns_buffer_current(pkt), &t)) fprintf(stderr, "parse of %s(%d) [%s(%d)]", sldns_rr_descript(type)? @@ -868,18 +868,18 @@ parse_section(sldns_buffer* pkt, struct msg_parse* msg, sldns_rr_descript(type)->_name: "??", (int)type); fprintf(stderr, " %s(%d) ", - sldns_lookup_by_id(sldns_rr_classes, + sldns_lookup_by_id(sldns_rr_classes, (int)ntohs(dclass))?sldns_lookup_by_id( - sldns_rr_classes, (int)ntohs(dclass))->name: + sldns_rr_classes, (int)ntohs(dclass))->name: "??", (int)ntohs(dclass)); dname_print(stderr, pkt, dname); fprintf(stderr, "\n"); } /* see if it is part of an existing RR set */ - if(!find_rrset(msg, pkt, dname, dnamelen, type, dclass, &hash, - &rrset_flags, &prev_dname_f, &prev_dname_l, - &prev_dnamelen, &prev_type, &prev_dclass, &rrset, + if(!find_rrset(msg, pkt, dname, dnamelen, type, dclass, &hash, + &rrset_flags, &prev_dname_f, &prev_dname_l, + &prev_dnamelen, &prev_type, &prev_dclass, &rrset, section, region)) return LDNS_RCODE_SERVFAIL; if(!rrset) { @@ -887,10 +887,10 @@ parse_section(sldns_buffer* pkt, struct msg_parse* msg, (*num_rrsets)++; rrset = new_rrset(msg, dname, dnamelen, type, dclass, hash, rrset_flags, section, region); - if(!rrset) + if(!rrset) return LDNS_RCODE_SERVFAIL; } - else if(0) { + else if(0) { fprintf(stderr, "is part of existing: "); dname_print(stderr, pkt, rrset->dname); fprintf(stderr, " type %s(%d)\n", @@ -899,7 +899,7 @@ parse_section(sldns_buffer* pkt, struct msg_parse* msg, (int)rrset->type); } /* add to rrset. */ - if((r=add_rr_to_rrset(rrset, pkt, msg, region, section, + if((r=add_rr_to_rrset(rrset, pkt, msg, region, section, type)) != 0) return r; } @@ -1001,7 +1001,7 @@ parse_edns_options_from_query(uint8_t* rdata_ptr, size_t rdata_len, * * This should be the first time the client sends this * option, so c->tcp_keepalive is not set. - * Besides adding the reply KEEPALIVE option, + * Besides adding the reply KEEPALIVE option, * c->tcp_keepalive will be set so that the * option will be added unsolicited in subsequent * responses (see the comment above the if-statement @@ -1120,7 +1120,7 @@ parse_edns_options_from_query(uint8_t* rdata_ptr, size_t rdata_len, return LDNS_RCODE_NOERROR; } -int +int parse_extract_edns_from_response_msg(struct msg_parse* msg, struct edns_data* edns, struct regional* region) { @@ -1151,13 +1151,13 @@ parse_extract_edns_from_response_msg(struct msg_parse* msg, /* check the found RRset */ /* most lenient check possible. ignore dname, use last opt */ if(found->section != LDNS_SECTION_ADDITIONAL) - return LDNS_RCODE_FORMERR; + return LDNS_RCODE_FORMERR; if(found->rr_count == 0) return LDNS_RCODE_FORMERR; if(0) { /* strict checking of dname and RRcount */ - if(found->dname_len != 1 || !found->dname - || found->dname[0] != 0) return LDNS_RCODE_FORMERR; - if(found->rr_count != 1) return LDNS_RCODE_FORMERR; + if(found->dname_len != 1 || !found->dname + || found->dname[0] != 0) return LDNS_RCODE_FORMERR; + if(found->rr_count != 1) return LDNS_RCODE_FORMERR; } log_assert(found->rr_first && found->rr_last); @@ -1169,7 +1169,7 @@ parse_extract_edns_from_response_msg(struct msg_parse* msg, msg->arcount --; msg->ar_rrsets --; msg->rrset_count --; - + /* take the data ! */ edns->edns_present = 1; edns->ext_rcode = found->rr_last->ttl_data[0]; @@ -1235,7 +1235,7 @@ skip_pkt_rrs(sldns_buffer* pkt, int num) return 1; } -int +int parse_edns_from_query_pkt(sldns_buffer* pkt, struct edns_data* edns, struct config_file* cfg, struct comm_point* c, struct comm_reply* repinfo, time_t now, struct regional* region) diff --git a/sbin/unwind/libunbound/util/data/msgparse.h b/sbin/unwind/libunbound/util/data/msgparse.h index b7dc235d6..1f2f825b2 100644 --- a/sbin/unwind/libunbound/util/data/msgparse.h +++ b/sbin/unwind/libunbound/util/data/msgparse.h @@ -1,25 +1,25 @@ /* * util/data/msgparse.h - parse wireformat DNS messages. - * + * * Copyright (c) 2007, NLnet Labs. All rights reserved. - * + * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -113,7 +113,7 @@ struct msg_parse { /** count of RRsets per section. */ size_t an_rrsets; /** count of RRsets per section. */ - size_t ns_rrsets; + size_t ns_rrsets; /** count of RRsets per section. */ size_t ar_rrsets; /** total number of rrsets found. */ @@ -133,7 +133,7 @@ struct msg_parse { * Based on name, type, class. Same hash value as in rrset cache. */ struct rrset_parse* hashtable[PARSE_TABLE_SIZE]; - + /** linked list of rrsets that have been found (in order). */ struct rrset_parse* rrset_first; /** last element of rrset list. */ @@ -184,7 +184,7 @@ struct rrset_parse { * Data stored for an RR during parsing. */ struct rr_parse { - /** + /** * Pointer to the RR. Points to start of TTL value in the packet. * Rdata length and rdata follow it. * its dname, type and class are the same and stored for the rrset. @@ -245,7 +245,7 @@ struct edns_data { unsigned int cookie_valid : 1; /** if the cookie holds only the client part */ unsigned int cookie_client : 1; -}; +}; /** * EDNS option @@ -277,7 +277,7 @@ size_t get_rdf_size(sldns_rdf_type rdf); * @param region: how to alloc results. * @return: 0 if OK, or rcode on error. */ -int parse_packet(struct sldns_buffer* pkt, struct msg_parse* msg, +int parse_packet(struct sldns_buffer* pkt, struct msg_parse* msg, struct regional* region); /** @@ -351,8 +351,8 @@ hashvalue_type pkt_hash_rrset(struct sldns_buffer* pkt, uint8_t* dname, * @param dclass: rrset class, network order. * @return NULL or the rrset_parse if found. */ -struct rrset_parse* msgparse_hashtable_lookup(struct msg_parse* msg, - struct sldns_buffer* pkt, hashvalue_type h, uint32_t rrset_flags, +struct rrset_parse* msgparse_hashtable_lookup(struct msg_parse* msg, + struct sldns_buffer* pkt, hashvalue_type h, uint32_t rrset_flags, uint8_t* dname, size_t dnamelen, uint16_t type, uint16_t dclass); /** diff --git a/sbin/unwind/libunbound/util/data/msgreply.c b/sbin/unwind/libunbound/util/data/msgreply.c index 920a0a939..bf7e96286 100644 --- a/sbin/unwind/libunbound/util/data/msgreply.c +++ b/sbin/unwind/libunbound/util/data/msgreply.c @@ -1,25 +1,25 @@ /* - * util/data/msgreply.c - store message and reply data. + * util/data/msgreply.c - store message and reply data. * * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -72,12 +72,12 @@ int SERVE_ORIGINAL_TTL = 0; /** allocate qinfo, return 0 on error */ static int -parse_create_qinfo(sldns_buffer* pkt, struct msg_parse* msg, +parse_create_qinfo(sldns_buffer* pkt, struct msg_parse* msg, struct query_info* qinf, struct regional* region) { if(msg->qname) { if(region) - qinf->qname = (uint8_t*)regional_alloc(region, + qinf->qname = (uint8_t*)regional_alloc(region, msg->qname_len); else qinf->qname = (uint8_t*)malloc(msg->qname_len); if(!qinf->qname) return 0; @@ -103,9 +103,9 @@ construct_reply_info_base(struct regional* region, uint16_t flags, size_t qd, if(total >= RR_COUNT_MAX) return NULL; /* sanity check on numRRS*/ if(region) rep = (struct reply_info*)regional_alloc(region, s); - else rep = (struct reply_info*)malloc(s + + else rep = (struct reply_info*)malloc(s + sizeof(struct rrset_ref) * (total)); - if(!rep) + if(!rep) return NULL; rep->flags = flags; rep->qdcount = qd; @@ -137,8 +137,8 @@ static int parse_create_repinfo(struct msg_parse* msg, struct reply_info** rep, struct regional* region) { - *rep = construct_reply_info_base(region, msg->flags, msg->qdcount, 0, - 0, 0, msg->an_rrsets, msg->ns_rrsets, msg->ar_rrsets, + *rep = construct_reply_info_base(region, msg->flags, msg->qdcount, 0, + 0, 0, msg->an_rrsets, msg->ns_rrsets, msg->ar_rrsets, msg->rrset_count, sec_status_unchecked, LDNS_EDE_NONE); if(!*rep) return 0; @@ -153,10 +153,10 @@ reply_info_alloc_rrset_keys(struct reply_info* rep, struct alloc_cache* alloc, for(i=0; irrset_count; i++) { if(region) { rep->rrsets[i] = (struct ub_packed_rrset_key*) - regional_alloc(region, + regional_alloc(region, sizeof(struct ub_packed_rrset_key)); if(rep->rrsets[i]) { - memset(rep->rrsets[i], 0, + memset(rep->rrsets[i], 0, sizeof(struct ub_packed_rrset_key)); rep->rrsets[i]->entry.key = rep->rrsets[i]; } @@ -209,7 +209,7 @@ soa_find_minttl(struct rr_parse* rr) /** do the rdata copy */ static int -rdata_copy(sldns_buffer* pkt, struct packed_rrset_data* data, uint8_t* to, +rdata_copy(sldns_buffer* pkt, struct packed_rrset_data* data, uint8_t* to, struct rr_parse* rr, time_t* rr_ttl, uint16_t type, sldns_pkt_section section) { @@ -267,7 +267,7 @@ rdata_copy(sldns_buffer* pkt, struct packed_rrset_data* data, uint8_t* to, switch(desc->_wireformat[rdf]) { case LDNS_RDF_TYPE_DNAME: oldpos = sldns_buffer_position(pkt); - dname_pkt_copy(pkt, to, + dname_pkt_copy(pkt, to, sldns_buffer_current(pkt)); to += pkt_dname_len(pkt); pkt_len -= sldns_buffer_position(pkt)-oldpos; @@ -294,13 +294,13 @@ rdata_copy(sldns_buffer* pkt, struct packed_rrset_data* data, uint8_t* to, /* copy remaining rdata */ if(pkt_len > 0) memmove(to, sldns_buffer_current(pkt), pkt_len); - + return 1; } /** copy over the data into packed rrset */ static int -parse_rr_copy(sldns_buffer* pkt, struct rrset_parse* pset, +parse_rr_copy(sldns_buffer* pkt, struct rrset_parse* pset, struct packed_rrset_data* data) { size_t i; @@ -313,7 +313,7 @@ parse_rr_copy(sldns_buffer* pkt, struct rrset_parse* pset, data->trust = rrset_trust_none; data->security = sec_status_unchecked; /* layout: struct - rr_len - rr_data - rr_ttl - rdata - rrsig */ - data->rr_len = (size_t*)((uint8_t*)data + + data->rr_len = (size_t*)((uint8_t*)data + sizeof(struct packed_rrset_data)); data->rr_data = (uint8_t**)&(data->rr_len[total]); data->rr_ttl = (time_t*)&(data->rr_data[total]); @@ -322,7 +322,7 @@ parse_rr_copy(sldns_buffer* pkt, struct rrset_parse* pset, data->rr_len[i] = rr->size; data->rr_data[i] = nextrdata; nextrdata += rr->size; - if(!rdata_copy(pkt, data, data->rr_data[i], rr, + if(!rdata_copy(pkt, data, data->rr_data[i], rr, &data->rr_ttl[i], pset->type, pset->section)) return 0; rr = rr->next; @@ -333,7 +333,7 @@ parse_rr_copy(sldns_buffer* pkt, struct rrset_parse* pset, data->rr_len[i] = rr->size; data->rr_data[i] = nextrdata; nextrdata += rr->size; - if(!rdata_copy(pkt, data, data->rr_data[i], rr, + if(!rdata_copy(pkt, data, data->rr_data[i], rr, &data->rr_ttl[i], LDNS_RR_TYPE_RRSIG, pset->section)) return 0; rr = rr->next; @@ -351,9 +351,9 @@ parse_create_rrset(sldns_buffer* pkt, struct rrset_parse* pset, if(pset->rr_count > RR_COUNT_MAX || pset->rrsig_count > RR_COUNT_MAX || pset->size > RR_COUNT_MAX) return 0; /* protect against integer overflow */ - s = sizeof(struct packed_rrset_data) + - (pset->rr_count + pset->rrsig_count) * - (sizeof(size_t)+sizeof(uint8_t*)+sizeof(time_t)) + + s = sizeof(struct packed_rrset_data) + + (pset->rr_count + pset->rrsig_count) * + (sizeof(size_t)+sizeof(uint8_t*)+sizeof(time_t)) + pset->size; if(region) *data = regional_alloc_zero(region, s); @@ -379,14 +379,14 @@ get_rrset_trust(struct msg_parse* msg, struct rrset_parse* rrset) if(rrset->section == LDNS_SECTION_ANSWER) { if(AA) { /* RFC2181 says remainder of CNAME chain is nonauth*/ - if(msg->rrset_first && + if(msg->rrset_first && msg->rrset_first->section==LDNS_SECTION_ANSWER && msg->rrset_first->type==LDNS_RR_TYPE_CNAME){ if(rrset == msg->rrset_first) return rrset_trust_ans_AA; else return rrset_trust_ans_noAA; } - if(msg->rrset_first && + if(msg->rrset_first && msg->rrset_first->section==LDNS_SECTION_ANSWER && msg->rrset_first->type==LDNS_RR_TYPE_DNAME){ if(rrset == msg->rrset_first || @@ -411,7 +411,7 @@ get_rrset_trust(struct msg_parse* msg, struct rrset_parse* rrset) int parse_copy_decompress_rrset(sldns_buffer* pkt, struct msg_parse* msg, - struct rrset_parse *pset, struct regional* region, + struct rrset_parse *pset, struct regional* region, struct ub_packed_rrset_key* pk) { struct packed_rrset_data* data; @@ -420,7 +420,7 @@ parse_copy_decompress_rrset(sldns_buffer* pkt, struct msg_parse* msg, if(region) pk->rk.dname = (uint8_t*)regional_alloc( region, pset->dname_len); - else pk->rk.dname = + else pk->rk.dname = (uint8_t*)malloc(pset->dname_len); if(!pk->rk.dname) return 0; @@ -444,7 +444,7 @@ parse_copy_decompress_rrset(sldns_buffer* pkt, struct msg_parse* msg, return 1; } -/** +/** * Copy and decompress rrs * @param pkt: the packet for compression pointer resolution. * @param msg: the parsed message @@ -480,9 +480,9 @@ parse_copy_decompress(sldns_buffer* pkt, struct msg_parse* msg, return 1; } -int +int parse_create_msg(sldns_buffer* pkt, struct msg_parse* msg, - struct alloc_cache* alloc, struct query_info* qinf, + struct alloc_cache* alloc, struct query_info* qinf, struct reply_info** rep, struct regional* region) { log_assert(pkt && msg); @@ -502,13 +502,13 @@ parse_create_msg(sldns_buffer* pkt, struct msg_parse* msg, } int reply_info_parse(sldns_buffer* pkt, struct alloc_cache* alloc, - struct query_info* qinf, struct reply_info** rep, + struct query_info* qinf, struct reply_info** rep, struct regional* region, struct edns_data* edns) { /* use scratch pad region-allocator during parsing. */ struct msg_parse* msg; int ret; - + qinf->qname = NULL; qinf->local_alias = NULL; *rep = NULL; @@ -516,7 +516,7 @@ int reply_info_parse(sldns_buffer* pkt, struct alloc_cache* alloc, return LDNS_RCODE_SERVFAIL; } memset(msg, 0, sizeof(*msg)); - + sldns_buffer_set_position(pkt, 0); if((ret = parse_packet(pkt, msg, region)) != 0) { return ret; @@ -545,14 +545,14 @@ reply_info_sortref_cmp(const void* a, const void* b) return 0; } -void +void reply_info_sortref(struct reply_info* rep) { qsort(&rep->ref[0], rep->rrset_count, sizeof(struct rrset_ref), reply_info_sortref_cmp); } -void +void reply_info_set_ttls(struct reply_info* rep, time_t timenow) { size_t i, j; @@ -572,11 +572,11 @@ reply_info_set_ttls(struct reply_info* rep, time_t timenow) } } -void +void reply_info_parsedelete(struct reply_info* rep, struct alloc_cache* alloc) { size_t i; - if(!rep) + if(!rep) return; /* no need to lock, since not shared in hashtables. */ for(i=0; irrset_count; i++) { @@ -589,7 +589,7 @@ reply_info_parsedelete(struct reply_info* rep, struct alloc_cache* alloc) free(rep); } -int +int query_info_parse(struct query_info* m, sldns_buffer* query) { uint8_t* q = sldns_buffer_begin(query); @@ -618,7 +618,7 @@ query_info_parse(struct query_info* m, sldns_buffer* query) else if( (x) > (y) ) return +1; \ log_assert( (x) == (y) ); -int +int query_info_compare(void* m1, void* m2) { struct query_info* msg1 = (struct query_info*)m1; @@ -634,14 +634,14 @@ query_info_compare(void* m1, void* m2) #undef COMPARE_IT } -void +void query_info_clear(struct query_info* m) { free(m->qname); m->qname = NULL; } -size_t +size_t msgreply_sizefunc(void* k, void* d) { struct msgreply_entry* q = (struct msgreply_entry*)k; @@ -654,7 +654,7 @@ msgreply_sizefunc(void* k, void* d) return s; } -void +void query_entry_delete(void *k, void* ATTR_UNUSED(arg)) { struct msgreply_entry* q = (struct msgreply_entry*)k; @@ -663,7 +663,7 @@ query_entry_delete(void *k, void* ATTR_UNUSED(arg)) free(q); } -void +void reply_info_delete(void* d, void* ATTR_UNUSED(arg)) { struct reply_info* r = (struct reply_info*)d; @@ -686,11 +686,11 @@ query_info_hash(struct query_info *q, uint16_t flags) return h; } -struct msgreply_entry* -query_info_entrysetup(struct query_info* q, struct reply_info* r, +struct msgreply_entry* +query_info_entrysetup(struct query_info* q, struct reply_info* r, hashvalue_type h) { - struct msgreply_entry* e = (struct msgreply_entry*)malloc( + struct msgreply_entry* e = (struct msgreply_entry*)malloc( sizeof(struct msgreply_entry)); if(!e) return NULL; memcpy(&e->key, q, sizeof(*q)); @@ -713,7 +713,7 @@ query_info_entrysetup(struct query_info* q, struct reply_info* r, /** copy rrsets from replyinfo to dest replyinfo */ static int -repinfo_copy_rrsets(struct reply_info* dest, struct reply_info* from, +repinfo_copy_rrsets(struct reply_info* dest, struct reply_info* from, struct regional* region) { size_t i, s; @@ -729,8 +729,8 @@ repinfo_copy_rrsets(struct reply_info* dest, struct reply_info* from, dk->id = fk->id; dk->rk.dname = (uint8_t*)regional_alloc_init(region, fk->rk.dname, fk->rk.dname_len); - } else - dk->rk.dname = (uint8_t*)memdup(fk->rk.dname, + } else + dk->rk.dname = (uint8_t*)memdup(fk->rk.dname, fk->rk.dname_len); if(!dk->rk.dname) return 0; @@ -739,7 +739,7 @@ repinfo_copy_rrsets(struct reply_info* dest, struct reply_info* from, dd = (struct packed_rrset_data*)regional_alloc_init( region, fd, s); else dd = (struct packed_rrset_data*)memdup(fd, s); - if(!dd) + if(!dd) return 0; packed_rrset_ptr_fixup(dd); dk->entry.data = (void*)dd; @@ -791,7 +791,7 @@ reply_info_copy(struct reply_info* rep, struct alloc_cache* alloc, return cp; } -uint8_t* +uint8_t* reply_find_final_cname_target(struct query_info* qinfo, struct reply_info* rep) { uint8_t* sname = qinfo->qname; @@ -800,8 +800,8 @@ reply_find_final_cname_target(struct query_info* qinfo, struct reply_info* rep) for(i=0; ian_numrrsets; i++) { struct ub_packed_rrset_key* s = rep->rrsets[i]; /* follow CNAME chain (if any) */ - if(ntohs(s->rk.type) == LDNS_RR_TYPE_CNAME && - ntohs(s->rk.rrset_class) == qinfo->qclass && + if(ntohs(s->rk.type) == LDNS_RR_TYPE_CNAME && + ntohs(s->rk.rrset_class) == qinfo->qclass && snamelen == s->rk.dname_len && query_dname_compare(sname, s->rk.dname) == 0) { get_cname_target(s, &sname, &snamelen); @@ -812,7 +812,7 @@ reply_find_final_cname_target(struct query_info* qinfo, struct reply_info* rep) return NULL; } -struct ub_packed_rrset_key* +struct ub_packed_rrset_key* reply_find_answer_rrset(struct query_info* qinfo, struct reply_info* rep) { uint8_t* sname = qinfo->qname; @@ -821,15 +821,15 @@ reply_find_answer_rrset(struct query_info* qinfo, struct reply_info* rep) for(i=0; ian_numrrsets; i++) { struct ub_packed_rrset_key* s = rep->rrsets[i]; /* first match type, for query of qtype cname */ - if(ntohs(s->rk.type) == qinfo->qtype && - ntohs(s->rk.rrset_class) == qinfo->qclass && + if(ntohs(s->rk.type) == qinfo->qtype && + ntohs(s->rk.rrset_class) == qinfo->qclass && snamelen == s->rk.dname_len && query_dname_compare(sname, s->rk.dname) == 0) { return s; } /* follow CNAME chain (if any) */ - if(ntohs(s->rk.type) == LDNS_RR_TYPE_CNAME && - ntohs(s->rk.rrset_class) == qinfo->qclass && + if(ntohs(s->rk.type) == LDNS_RR_TYPE_CNAME && + ntohs(s->rk.rrset_class) == qinfo->qclass && snamelen == s->rk.dname_len && query_dname_compare(sname, s->rk.dname) == 0) { get_cname_target(s, &sname, &snamelen); @@ -844,8 +844,8 @@ struct ub_packed_rrset_key* reply_find_rrset_section_an(struct reply_info* rep, size_t i; for(i=0; ian_numrrsets; i++) { struct ub_packed_rrset_key* s = rep->rrsets[i]; - if(ntohs(s->rk.type) == type && - ntohs(s->rk.rrset_class) == dclass && + if(ntohs(s->rk.type) == type && + ntohs(s->rk.rrset_class) == dclass && namelen == s->rk.dname_len && query_dname_compare(name, s->rk.dname) == 0) { return s; @@ -860,8 +860,8 @@ struct ub_packed_rrset_key* reply_find_rrset_section_ns(struct reply_info* rep, size_t i; for(i=rep->an_numrrsets; ian_numrrsets+rep->ns_numrrsets; i++) { struct ub_packed_rrset_key* s = rep->rrsets[i]; - if(ntohs(s->rk.type) == type && - ntohs(s->rk.rrset_class) == dclass && + if(ntohs(s->rk.type) == type && + ntohs(s->rk.rrset_class) == dclass && namelen == s->rk.dname_len && query_dname_compare(name, s->rk.dname) == 0) { return s; @@ -876,8 +876,8 @@ struct ub_packed_rrset_key* reply_find_rrset(struct reply_info* rep, size_t i; for(i=0; irrset_count; i++) { struct ub_packed_rrset_key* s = rep->rrsets[i]; - if(ntohs(s->rk.type) == type && - ntohs(s->rk.rrset_class) == dclass && + if(ntohs(s->rk.type) == type && + ntohs(s->rk.rrset_class) == dclass && namelen == s->rk.dname_len && query_dname_compare(name, s->rk.dname) == 0) { return s; @@ -886,7 +886,7 @@ struct ub_packed_rrset_key* reply_find_rrset(struct reply_info* rep, return NULL; } -void +void log_dns_msg(const char* str, struct query_info* qinfo, struct reply_info* rep) { /* not particularly fast but flexible, make wireformat and print */ @@ -956,14 +956,14 @@ log_reply_info(enum verbosity_value v, struct query_info *qinf, } void -log_query_info(enum verbosity_value v, const char* str, +log_query_info(enum verbosity_value v, const char* str, struct query_info* qinf) { log_nametypeclass(v, str, qinf->qname, qinf->qtype, qinf->qclass); } int -reply_check_cname_chain(struct query_info* qinfo, struct reply_info* rep) +reply_check_cname_chain(struct query_info* qinfo, struct reply_info* rep) { /* check only answer section rrs for matching cname chain. * the cache may return changed rdata, but owner names are untouched.*/ @@ -988,7 +988,7 @@ reply_check_cname_chain(struct query_info* qinfo, struct reply_info* rep) } int -reply_all_rrsets_secure(struct reply_info* rep) +reply_all_rrsets_secure(struct reply_info* rep) { size_t i; for(i=0; irrset_count; i++) { @@ -1206,7 +1206,7 @@ int inplace_cb_query_call(struct module_env* env, struct query_info* qinfo, return 1; } -int inplace_cb_edns_back_parsed_call(struct module_env* env, +int inplace_cb_edns_back_parsed_call(struct module_env* env, struct module_qstate* qstate) { struct inplace_cb* cb = diff --git a/sbin/unwind/libunbound/util/data/msgreply.h b/sbin/unwind/libunbound/util/data/msgreply.h index a9af3d7e6..ae5d43b41 100644 --- a/sbin/unwind/libunbound/util/data/msgreply.h +++ b/sbin/unwind/libunbound/util/data/msgreply.h @@ -1,25 +1,25 @@ /* - * util/data/msgreply.h - store message and reply data. + * util/data/msgreply.h - store message and reply data. * * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -68,8 +68,8 @@ struct dns_msg; * different. */ struct query_info { - /** - * Salient data on the query: qname, in wireformat. + /** + * Salient data on the query: qname, in wireformat. * can be allocated or a pointer to outside buffer. * User has to keep track on the status of this. */ @@ -112,7 +112,7 @@ struct rrset_ref { /** * Structure to store DNS query and the reply packet. * To use it, copy over the flags from reply and modify using flags from - * the query (RD,CD if not AA). prepend ID. + * the query (RD,CD if not AA). prepend ID. * * Memory layout is: * o struct @@ -128,8 +128,8 @@ struct reply_info { uint16_t flags; /** - * This flag informs unbound the answer is authoritative and - * the AA flag should be preserved. + * This flag informs unbound the answer is authoritative and + * the AA flag should be preserved. */ uint8_t authoritative; @@ -144,7 +144,7 @@ struct reply_info { /** 32 bit padding to pad struct member alignment to 64 bits. */ uint32_t padding; - /** + /** * TTL of the entire reply (for negative caching). * only for use when there are 0 RRsets in this message. * if there are RRsets, check those instead. @@ -157,7 +157,7 @@ struct reply_info { */ time_t prefetch_ttl; - /** + /** * Reply TTL extended with serve expired TTL, to limit time to serve * expired message. */ @@ -184,36 +184,36 @@ struct reply_info { /** * Number of RRsets in each section. * The answer section. Add up the RRs in every RRset to calculate - * the number of RRs, and the count for the dns packet. + * the number of RRs, and the count for the dns packet. * The number of RRs in RRsets can change due to RRset updates. */ size_t an_numrrsets; /** Count of authority section RRsets */ - size_t ns_numrrsets; + size_t ns_numrrsets; /** Count of additional section RRsets */ size_t ar_numrrsets; /** number of RRsets: an_numrrsets + ns_numrrsets + ar_numrrsets */ size_t rrset_count; - /** - * List of pointers (only) to the rrsets in the order in which - * they appear in the reply message. + /** + * List of pointers (only) to the rrsets in the order in which + * they appear in the reply message. * Number of elements is ancount+nscount+arcount RRsets. - * This is a pointer to that array. + * This is a pointer to that array. * Use the accessor function for access. */ struct ub_packed_rrset_key** rrsets; - /** + /** * Packed array of ids (see counts) and pointers to packed_rrset_key. - * The number equals ancount+nscount+arcount RRsets. + * The number equals ancount+nscount+arcount RRsets. * These are sorted in ascending pointer, the locking order. So - * this list can be locked (and id, ttl checked), to see if + * this list can be locked (and id, ttl checked), to see if * all the data is available and recent enough. * - * This is defined as an array of size 1, so that the compiler + * This is defined as an array of size 1, so that the compiler * associates the identifier with this position in the structure. * Array bound overflow on this array then gives access to the further * elements of the array, which are allocated after the main structure. @@ -258,8 +258,8 @@ construct_reply_info_base(struct regional* region, uint16_t flags, size_t qd, size_t ar, size_t total, enum sec_status sec, sldns_ede_code reason_bogus); -/** - * Parse wire query into a queryinfo structure, return 0 on parse error. +/** + * Parse wire query into a queryinfo structure, return 0 on parse error. * initialises the (prealloced) queryinfo structure as well. * This query structure contains a pointer back info the buffer! * This pointer avoids memory allocation. allocqname does memory allocation. @@ -286,7 +286,7 @@ int query_info_parse(struct query_info* m, struct sldns_buffer* query); * o SERVFAIL for memory allocation errors. */ int reply_info_parse(struct sldns_buffer* pkt, struct alloc_cache* alloc, - struct query_info* qinf, struct reply_info** rep, + struct query_info* qinf, struct reply_info** rep, struct regional* region, struct edns_data* edns); /** @@ -320,13 +320,13 @@ void reply_info_sortref(struct reply_info* rep); /** * Set TTLs inside the replyinfo to absolute values. - * @param rep: reply info. rrsets must be filled in. + * @param rep: reply info. rrsets must be filled in. * Also refs must be filled in. * @param timenow: the current time. */ void reply_info_set_ttls(struct reply_info* rep, time_t timenow); -/** +/** * Delete reply_info and packed_rrsets (while they are not yet added to the * hashtables.). Returns rrsets to the alloc cache. * @param rep: reply_info to delete. @@ -335,7 +335,7 @@ void reply_info_set_ttls(struct reply_info* rep, time_t timenow); void reply_info_parsedelete(struct reply_info* rep, struct alloc_cache* alloc); /** - * Compare two queryinfo structures, on query and type, class. + * Compare two queryinfo structures, on query and type, class. * It is _not_ sorted in canonical ordering. * @param m1: struct query_info* , void* here to ease use as function pointer. * @param m2: struct query_info* , void* here to ease use as function pointer. @@ -380,7 +380,7 @@ struct msgreply_entry* query_info_entrysetup(struct query_info* q, * and no rrset_ref array in the reply is built up. * @return new reply info or NULL on memory error. */ -struct reply_info* reply_info_copy(struct reply_info* rep, +struct reply_info* reply_info_copy(struct reply_info* rep, struct alloc_cache* alloc, struct regional* region); /** @@ -425,7 +425,7 @@ make_new_reply_info(const struct reply_info* rep, struct regional* region, * @return false on alloc failure. */ int parse_copy_decompress_rrset(struct sldns_buffer* pkt, struct msg_parse* msg, - struct rrset_parse *pset, struct regional* region, + struct rrset_parse *pset, struct regional* region, struct ub_packed_rrset_key* pk); /** @@ -531,7 +531,7 @@ void log_reply_info(enum verbosity_value v, struct query_info *qinf, * @param str: string of message. * @param qinf: query info structure with name, type and class. */ -void log_query_info(enum verbosity_value v, const char* str, +void log_query_info(enum verbosity_value v, const char* str, struct query_info* qinf); /** @@ -717,7 +717,7 @@ int inplace_cb_query_call(struct module_env* env, struct query_info* qinfo, * @param qstate: module qstate. * @return false on failure (a callback function returned an error). */ -int inplace_cb_edns_back_parsed_call(struct module_env* env, +int inplace_cb_edns_back_parsed_call(struct module_env* env, struct module_qstate* qstate); /** diff --git a/sbin/unwind/libunbound/util/data/packed_rrset.c b/sbin/unwind/libunbound/util/data/packed_rrset.c index e1a0833a2..5f5a07acf 100644 --- a/sbin/unwind/libunbound/util/data/packed_rrset.c +++ b/sbin/unwind/libunbound/util/data/packed_rrset.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -66,7 +66,7 @@ ub_packed_rrset_parsedelete(struct ub_packed_rrset_key* pkey, alloc_special_release(alloc, pkey); } -size_t +size_t ub_rrset_sizefunc(void* key, void* data) { struct ub_packed_rrset_key* k = (struct ub_packed_rrset_key*)key; @@ -76,22 +76,22 @@ ub_rrset_sizefunc(void* key, void* data) return s; } -size_t +size_t packed_rrset_sizeof(struct packed_rrset_data* d) { size_t s; if(d->rrsig_count > 0) { - s = ((uint8_t*)d->rr_data[d->count+d->rrsig_count-1] - + s = ((uint8_t*)d->rr_data[d->count+d->rrsig_count-1] - (uint8_t*)d) + d->rr_len[d->count+d->rrsig_count-1]; } else { log_assert(d->count > 0); - s = ((uint8_t*)d->rr_data[d->count-1] - (uint8_t*)d) + + s = ((uint8_t*)d->rr_data[d->count-1] - (uint8_t*)d) + d->rr_len[d->count-1]; } return s; } -int +int ub_rrset_compare(void* k1, void* k2) { struct ub_packed_rrset_key* key1 = (struct ub_packed_rrset_key*)k1; @@ -124,7 +124,7 @@ ub_rrset_compare(void* k1, void* k2) return 0; } -void +void ub_rrset_key_delete(void* key, void* userdata) { struct ub_packed_rrset_key* k = (struct ub_packed_rrset_key*)key; @@ -135,19 +135,19 @@ ub_rrset_key_delete(void* key, void* userdata) alloc_special_release(a, k); } -void +void rrset_data_delete(void* data, void* ATTR_UNUSED(userdata)) { struct packed_rrset_data* d = (struct packed_rrset_data*)data; free(d); } -int +int rrsetdata_equal(struct packed_rrset_data* d1, struct packed_rrset_data* d2) { size_t i; size_t total; - if(d1->count != d2->count || d1->rrsig_count != d2->rrsig_count) + if(d1->count != d2->count || d1->rrsig_count != d2->rrsig_count) return 0; total = d1->count + d1->rrsig_count; for(i=0; irk.type) != LDNS_RR_TYPE_CNAME && + if(ntohs(rrset->rk.type) != LDNS_RR_TYPE_CNAME && ntohs(rrset->rk.type) != LDNS_RR_TYPE_DNAME) return; d = (struct packed_rrset_data*)rrset->entry.data; @@ -215,7 +215,7 @@ get_cname_target(struct ub_packed_rrset_key* rrset, uint8_t** dname, *dname_len = len; } -void +void packed_rrset_ttl_add(struct packed_rrset_data* data, time_t add) { size_t i; @@ -226,7 +226,7 @@ packed_rrset_ttl_add(struct packed_rrset_data* data, time_t add) data->rr_ttl[i] += add; } -const char* +const char* rrset_trust_to_string(enum rrset_trust s) { switch(s) { @@ -247,7 +247,7 @@ rrset_trust_to_string(enum rrset_trust s) return "unknown_rrset_trust_value"; } -const char* +const char* sec_status_to_string(enum sec_status s) { switch(s) { @@ -261,7 +261,7 @@ sec_status_to_string(enum sec_status s) return "unknown_sec_status_value"; } -void log_rrset_key(enum verbosity_value v, const char* str, +void log_rrset_key(enum verbosity_value v, const char* str, struct ub_packed_rrset_key* rrset) { if(verbosity >= v) @@ -296,7 +296,7 @@ int packed_rr_to_string(struct ub_packed_rrset_key* rrset, size_t i, log_info("rrbuf failure %d %s", (int)d->rr_len[i], dest); dest[0] = 0; return 0; - } + } return 1; } @@ -318,7 +318,7 @@ void log_packed_rrset(enum verbosity_value v, const char* str, } } -time_t +time_t ub_packed_rrset_ttl(struct ub_packed_rrset_key* key) { struct packed_rrset_data* d = (struct packed_rrset_data*)key-> @@ -327,10 +327,10 @@ ub_packed_rrset_ttl(struct ub_packed_rrset_key* key) } struct ub_packed_rrset_key* -packed_rrset_copy_region(struct ub_packed_rrset_key* key, +packed_rrset_copy_region(struct ub_packed_rrset_key* key, struct regional* region, time_t now) { - struct ub_packed_rrset_key* ck = regional_alloc(region, + struct ub_packed_rrset_key* ck = regional_alloc(region, sizeof(struct ub_packed_rrset_key)); struct packed_rrset_data* d; struct packed_rrset_data* data = (struct packed_rrset_data*) @@ -344,7 +344,7 @@ packed_rrset_copy_region(struct ub_packed_rrset_key* key, ck->entry.hash = key->entry.hash; ck->entry.key = ck; ck->rk = key->rk; - ck->rk.dname = regional_alloc_init(region, key->rk.dname, + ck->rk.dname = regional_alloc_init(region, key->rk.dname, key->rk.dname_len); if(!ck->rk.dname) return NULL; @@ -368,8 +368,8 @@ packed_rrset_copy_region(struct ub_packed_rrset_key* key, return ck; } -struct ub_packed_rrset_key* -packed_rrset_copy_alloc(struct ub_packed_rrset_key* key, +struct ub_packed_rrset_key* +packed_rrset_copy_alloc(struct ub_packed_rrset_key* key, struct alloc_cache* alloc, time_t now) { struct packed_rrset_data* fd, *dd; diff --git a/sbin/unwind/libunbound/util/data/packed_rrset.h b/sbin/unwind/libunbound/util/data/packed_rrset.h index e1feb22bb..7d0f0a3cb 100644 --- a/sbin/unwind/libunbound/util/data/packed_rrset.h +++ b/sbin/unwind/libunbound/util/data/packed_rrset.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -85,8 +85,8 @@ struct packed_rrset_key { * This dname is not canonicalized. */ uint8_t* dname; - /** - * Length of the domain name, including last 0 root octet. + /** + * Length of the domain name, including last 0 root octet. */ size_t dname_len; /** @@ -113,14 +113,14 @@ struct packed_rrset_key { * structure can be recycled with a new id. */ struct ub_packed_rrset_key { - /** + /** * entry into hashtable. Note the lock is never destroyed, - * even when this key is retired to the cache. + * even when this key is retired to the cache. * the data pointer (if not null) points to a struct packed_rrset. */ struct lruhash_entry entry; - /** - * the ID of this rrset. unique, based on threadid + sequenceno. + /** + * the ID of this rrset. unique, based on threadid + sequenceno. * ids are not reused, except after flushing the cache. * zero is an unused entry, and never a valid id. * Check this value after getting entry.lock. @@ -172,7 +172,7 @@ enum rrset_trust { rrset_trust_prim_noglue, /** DNSSEC(rfc4034) validated with trusted keys */ rrset_trust_validated, - /** ultimately trusted, no more trust is possible; + /** ultimately trusted, no more trust is possible; * trusted keys from the unbound configuration setup. */ rrset_trust_ultimate }; @@ -187,19 +187,19 @@ enum sec_status { /** BOGUS means that the object (RRset or message) failed to validate * (according to local policy), but should have validated. */ sec_status_bogus, - /** INDETERMINATE means that the object is insecure, but not - * authoritatively so. Generally this means that the RRset is not + /** INDETERMINATE means that the object is insecure, but not + * authoritatively so. Generally this means that the RRset is not * below a configured trust anchor. */ sec_status_indeterminate, - /** INSECURE means that the object is authoritatively known to be - * insecure. Generally this means that this RRset is below a trust + /** INSECURE means that the object is authoritatively known to be + * insecure. Generally this means that this RRset is below a trust * anchor, but also below a verified, insecure delegation. */ sec_status_insecure, /** SECURE_SENTINEL_FAIL means that the object (RRset or message) * validated according to local policy but did not succeed in the root * KSK sentinel test (draft-ietf-dnsop-kskroll-sentinel). */ sec_status_secure_sentinel_fail, - /** SECURE means that the object (RRset or message) validated + /** SECURE means that the object (RRset or message) validated * according to local policy. */ sec_status_secure }; @@ -252,16 +252,16 @@ struct packed_rrset_data { /** number of rrsigs, if 0 no rrsigs */ size_t rrsig_count; /** the trustworthiness of the rrset data */ - enum rrset_trust trust; + enum rrset_trust trust; /** security status of the rrset data */ enum sec_status security; /** length of every rr's rdata, rr_len[i] is size of rr_data[i]. */ size_t* rr_len; /** ttl of every rr. rr_ttl[i] ttl of rr i. */ time_t *rr_ttl; - /** - * Array of pointers to every rr's rdata. - * The rr_data[i] rdata is stored in uncompressed wireformat. + /** + * Array of pointers to every rr's rdata. + * The rr_data[i] rdata is stored in uncompressed wireformat. * The first uint16_t of rr_data[i] is network format rdlength. * * rr_data[count] to rr_data[count+rrsig_count] contain the rrsig data. @@ -379,7 +379,7 @@ void packed_rrset_ttl_add(struct packed_rrset_data* data, time_t add); /** * Utility procedure to extract CNAME target name from its rdata. * Failsafes; it will change passed dname to a valid dname or do nothing. - * @param rrset: the rrset structure. Must be a CNAME. + * @param rrset: the rrset structure. Must be a CNAME. * Only first RR is used (multiple RRs are technically illegal anyway). * Also works on type DNAME. Returns target name. * @param dname: this pointer is updated to point into the cname rdata. @@ -387,18 +387,18 @@ void packed_rrset_ttl_add(struct packed_rrset_data* data, time_t add); * rdata was not a valid dname, not a CNAME, ...). * @param dname_len: length of dname is returned. */ -void get_cname_target(struct ub_packed_rrset_key* rrset, uint8_t** dname, +void get_cname_target(struct ub_packed_rrset_key* rrset, uint8_t** dname, size_t* dname_len); /** - * Get a printable string for a rrset trust value + * Get a printable string for a rrset trust value * @param s: rrset trust value * @return printable string. */ const char* rrset_trust_to_string(enum rrset_trust s); /** - * Get a printable string for a security status value + * Get a printable string for a security status value * @param s: security status * @return printable string. */ @@ -410,7 +410,7 @@ const char* sec_status_to_string(enum sec_status s); * @param str: string of message. * @param rrset: structure with name, type and class. */ -void log_rrset_key(enum verbosity_value v, const char* str, +void log_rrset_key(enum verbosity_value v, const char* str, struct ub_packed_rrset_key* rrset); /** @@ -434,8 +434,8 @@ int packed_rr_to_string(struct ub_packed_rrset_key* rrset, size_t i, void log_packed_rrset(enum verbosity_value v, const char* str, struct ub_packed_rrset_key* rrset); -/** - * Allocate rrset in region - no more locks needed +/** + * Allocate rrset in region - no more locks needed * @param key: a (just from rrset cache looked up) rrset key + valid, * packed data record. * @param region: where to alloc the copy @@ -443,10 +443,10 @@ void log_packed_rrset(enum verbosity_value v, const char* str, * @return new region-alloced rrset key or NULL on alloc failure. */ struct ub_packed_rrset_key* packed_rrset_copy_region( - struct ub_packed_rrset_key* key, struct regional* region, + struct ub_packed_rrset_key* key, struct regional* region, time_t now); -/** +/** * Allocate rrset with malloc (from region or you are holding the lock). * @param key: key with data entry. * @param alloc: alloc_cache to create rrset_keys @@ -454,7 +454,7 @@ struct ub_packed_rrset_key* packed_rrset_copy_region( * @return new region-alloced rrset key or NULL on alloc failure. */ struct ub_packed_rrset_key* packed_rrset_copy_alloc( - struct ub_packed_rrset_key* key, struct alloc_cache* alloc, + struct ub_packed_rrset_key* key, struct alloc_cache* alloc, time_t now); /** diff --git a/sbin/unwind/libunbound/util/fptr_wlist.c b/sbin/unwind/libunbound/util/fptr_wlist.c index 3b88da235..0ad3f6242 100644 --- a/sbin/unwind/libunbound/util/fptr_wlist.c +++ b/sbin/unwind/libunbound/util/fptr_wlist.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -38,7 +38,7 @@ * * This file contains functions that check function pointers. * The functions contain a whitelist of known good callback values. - * Any other values lead to an error. + * Any other values lead to an error. * * Due to the listing nature, this file violates all the modularization * boundaries in the program. @@ -100,7 +100,7 @@ #include "dnstap/dtstream.h" #endif -int +int fptr_whitelist_comm_point(comm_point_callback_type *fptr) { if(fptr == &worker_handle_request) return 1; @@ -113,7 +113,7 @@ fptr_whitelist_comm_point(comm_point_callback_type *fptr) return 0; } -int +int fptr_whitelist_comm_point_raw(comm_point_callback_type *fptr) { if(fptr == &tube_handle_listen) return 1; @@ -123,7 +123,7 @@ fptr_whitelist_comm_point_raw(comm_point_callback_type *fptr) return 0; } -int +int fptr_whitelist_comm_timer(void (*fptr)(void*)) { if(fptr == &pending_udp_timer_cb) return 1; @@ -145,7 +145,7 @@ fptr_whitelist_comm_timer(void (*fptr)(void*)) return 0; } -int +int fptr_whitelist_comm_signal(void (*fptr)(int, void*)) { if(fptr == &worker_sighandler) return 1; @@ -164,7 +164,7 @@ int fptr_whitelist_stop_accept(void (*fptr)(void*)) return 0; } -int +int fptr_whitelist_event(void (*fptr)(int, short, void *)) { if(fptr == &comm_point_udp_callback) return 1; @@ -193,21 +193,21 @@ fptr_whitelist_event(void (*fptr)(int, short, void *)) return 0; } -int +int fptr_whitelist_pending_udp(comm_point_callback_type *fptr) { if(fptr == &serviced_udp_callback) return 1; return 0; } -int +int fptr_whitelist_pending_tcp(comm_point_callback_type *fptr) { if(fptr == &serviced_tcp_callback) return 1; return 0; } -int +int fptr_whitelist_serviced_query(comm_point_callback_type *fptr) { if(fptr == &worker_handle_service_reply) return 1; @@ -215,7 +215,7 @@ fptr_whitelist_serviced_query(comm_point_callback_type *fptr) return 0; } -int +int fptr_whitelist_rbtree_cmp(int (*fptr) (const void *, const void *)) { if(fptr == &mesh_state_compare) return 1; @@ -248,7 +248,7 @@ fptr_whitelist_rbtree_cmp(int (*fptr) (const void *, const void *)) return 0; } -int +int fptr_whitelist_hash_sizefunc(lruhash_sizefunc_type fptr) { if(fptr == &msgreply_sizefunc) return 1; @@ -268,7 +268,7 @@ fptr_whitelist_hash_sizefunc(lruhash_sizefunc_type fptr) return 0; } -int +int fptr_whitelist_hash_compfunc(lruhash_compfunc_type fptr) { if(fptr == &query_info_compare) return 1; @@ -285,7 +285,7 @@ fptr_whitelist_hash_compfunc(lruhash_compfunc_type fptr) return 0; } -int +int fptr_whitelist_hash_delkeyfunc(lruhash_delkeyfunc_type fptr) { if(fptr == &query_entry_delete) return 1; @@ -302,7 +302,7 @@ fptr_whitelist_hash_delkeyfunc(lruhash_delkeyfunc_type fptr) return 0; } -int +int fptr_whitelist_hash_deldatafunc(lruhash_deldatafunc_type fptr) { if(fptr == &reply_info_delete) return 1; @@ -321,7 +321,7 @@ fptr_whitelist_hash_deldatafunc(lruhash_deldatafunc_type fptr) return 0; } -int +int fptr_whitelist_hash_markdelfunc(lruhash_markdelfunc_type fptr) { if(fptr == NULL) return 1; @@ -333,7 +333,7 @@ fptr_whitelist_hash_markdelfunc(lruhash_markdelfunc_type fptr) } /** whitelist env->send_query callbacks */ -int +int fptr_whitelist_modenv_send_query(struct outbound_entry* (*fptr)( struct query_info* qinfo, uint16_t flags, int dnssec, int want_dnssec, int nocaps, int check_ratelimit, struct sockaddr_storage* addr, @@ -346,7 +346,7 @@ fptr_whitelist_modenv_send_query(struct outbound_entry* (*fptr)( return 0; } -int +int fptr_whitelist_modenv_detach_subs(void (*fptr)( struct module_qstate* qstate)) { @@ -354,7 +354,7 @@ fptr_whitelist_modenv_detach_subs(void (*fptr)( return 0; } -int +int fptr_whitelist_modenv_attach_sub(int (*fptr)( struct module_qstate* qstate, struct query_info* qinfo, uint16_t qflags, int prime, int valrec, struct module_qstate** newq)) @@ -363,7 +363,7 @@ fptr_whitelist_modenv_attach_sub(int (*fptr)( return 0; } -int +int fptr_whitelist_modenv_add_sub(int (*fptr)( struct module_qstate* qstate, struct query_info* qinfo, uint16_t qflags, int prime, int valrec, struct module_qstate** newq, @@ -373,14 +373,14 @@ fptr_whitelist_modenv_add_sub(int (*fptr)( return 0; } -int +int fptr_whitelist_modenv_kill_sub(void (*fptr)(struct module_qstate* newq)) { if(fptr == &mesh_state_delete) return 1; return 0; } -int +int fptr_whitelist_modenv_detect_cycle(int (*fptr)( struct module_qstate* qstate, struct query_info* qinfo, uint16_t flags, int prime, int valrec)) @@ -389,7 +389,7 @@ fptr_whitelist_modenv_detect_cycle(int (*fptr)( return 0; } -int +int fptr_whitelist_mod_init(int (*fptr)(struct module_env* env, int id)) { if(fptr == &iter_init) return 1; @@ -417,7 +417,7 @@ fptr_whitelist_mod_init(int (*fptr)(struct module_env* env, int id)) return 0; } -int +int fptr_whitelist_mod_deinit(void (*fptr)(struct module_env* env, int id)) { if(fptr == &iter_deinit) return 1; @@ -445,7 +445,7 @@ fptr_whitelist_mod_deinit(void (*fptr)(struct module_env* env, int id)) return 0; } -int +int fptr_whitelist_mod_operate(void (*fptr)(struct module_qstate* qstate, enum module_ev event, int id, struct outbound_entry* outbound)) { @@ -474,7 +474,7 @@ fptr_whitelist_mod_operate(void (*fptr)(struct module_qstate* qstate, return 0; } -int +int fptr_whitelist_mod_inform_super(void (*fptr)( struct module_qstate* qstate, int id, struct module_qstate* super)) { @@ -503,7 +503,7 @@ fptr_whitelist_mod_inform_super(void (*fptr)( return 0; } -int +int fptr_whitelist_mod_clear(void (*fptr)(struct module_qstate* qstate, int id)) { @@ -532,7 +532,7 @@ fptr_whitelist_mod_clear(void (*fptr)(struct module_qstate* qstate, return 0; } -int +int fptr_whitelist_mod_get_mem(size_t (*fptr)(struct module_env* env, int id)) { if(fptr == &iter_get_mem) return 1; @@ -560,7 +560,7 @@ fptr_whitelist_mod_get_mem(size_t (*fptr)(struct module_env* env, int id)) return 0; } -int +int fptr_whitelist_alloc_cleanup(void (*fptr)(void*)) { if(fptr == &worker_alloc_cleanup) return 1; diff --git a/sbin/unwind/libunbound/util/fptr_wlist.h b/sbin/unwind/libunbound/util/fptr_wlist.h index a0d986755..7a01620b7 100644 --- a/sbin/unwind/libunbound/util/fptr_wlist.h +++ b/sbin/unwind/libunbound/util/fptr_wlist.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -38,10 +38,10 @@ * * This file contains functions that check function pointers. * The functions contain a whitelist of known good callback values. - * Any other values lead to an error. - * + * Any other values lead to an error. + * * This prevent heap overflow based exploits, where the callback pointer - * is overwritten by a buffer overflow (apart from this defense, buffer + * is overwritten by a buffer overflow (apart from this defense, buffer * overflows should be fixed of course). * * Function pointers are used in @@ -232,7 +232,7 @@ int fptr_whitelist_modenv_detach_subs(void (*fptr)( * @return false if not in whitelist. */ int fptr_whitelist_modenv_attach_sub(int (*fptr)( - struct module_qstate* qstate, struct query_info* qinfo, + struct module_qstate* qstate, struct query_info* qinfo, uint16_t qflags, int prime, int valrec, struct module_qstate** newq)); /** @@ -259,7 +259,7 @@ int fptr_whitelist_modenv_kill_sub(void (*fptr)(struct module_qstate* newq)); * @return false if not in whitelist. */ int fptr_whitelist_modenv_detect_cycle(int (*fptr)( - struct module_qstate* qstate, struct query_info* qinfo, + struct module_qstate* qstate, struct query_info* qinfo, uint16_t flags, int prime, int valrec)); /** @@ -284,7 +284,7 @@ int fptr_whitelist_mod_deinit(void (*fptr)(struct module_env* env, int id)); * @param fptr: function pointer to check. * @return false if not in whitelist. */ -int fptr_whitelist_mod_operate(void (*fptr)(struct module_qstate* qstate, +int fptr_whitelist_mod_operate(void (*fptr)(struct module_qstate* qstate, enum module_ev event, int id, struct outbound_entry* outbound)); /** @@ -302,7 +302,7 @@ int fptr_whitelist_mod_inform_super(void (*fptr)( * @param fptr: function pointer to check. * @return false if not in whitelist. */ -int fptr_whitelist_mod_clear(void (*fptr)(struct module_qstate* qstate, +int fptr_whitelist_mod_clear(void (*fptr)(struct module_qstate* qstate, int id)); /** @@ -387,16 +387,16 @@ int fptr_whitelist_serve_expired_lookup(serve_expired_lookup_func_type* fptr); /** Due to module breakage by fptr wlist, these test app declarations * are presented here */ -/** - * compare two order_ids from lock-verify test app +/** + * compare two order_ids from lock-verify test app * @param e1: first order_id * @param e2: second order_id * @return compare code -1, 0, +1 (like memcmp). */ int order_lock_cmp(const void* e1, const void* e2); -/** - * compare two codeline structs for rbtree from memstats test app +/** + * compare two codeline structs for rbtree from memstats test app * @param a: codeline * @param b: codeline * @return compare code -1, 0, +1 (like memcmp). diff --git a/sbin/unwind/libunbound/util/locks.c b/sbin/unwind/libunbound/util/locks.c index b65a02bdc..d68a47c3f 100644 --- a/sbin/unwind/libunbound/util/locks.c +++ b/sbin/unwind/libunbound/util/locks.c @@ -2,24 +2,24 @@ * util/locks.c - unbound locking primitives * * Copyright (c) 2007, NLnet Labs. All rights reserved. - * + * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -47,7 +47,7 @@ #endif /** block all signals, masks them away. */ -void +void ub_thread_blocksigs(void) { #if defined(HAVE_PTHREAD) || defined(HAVE_SOLARIS_THREADS) || defined(HAVE_SIGPROCMASK) @@ -63,7 +63,7 @@ ub_thread_blocksigs(void) # ifdef HAVE_SOLARIS_THREADS if((err=thr_sigsetmask(SIG_SETMASK, &sigset, NULL))) fatal_exit("thr_sigsetmask: %s", strerror(err)); -# else +# else /* have nothing, do single process signal mask */ if(sigprocmask(SIG_SETMASK, &sigset, NULL)) fatal_exit("sigprocmask: %s", strerror(errno)); @@ -89,7 +89,7 @@ void ub_thread_sig_unblock(int sig) # ifdef HAVE_SOLARIS_THREADS if((err=thr_sigsetmask(SIG_UNBLOCK, &sigset, NULL))) fatal_exit("thr_sigsetmask: %s", strerror(err)); -# else +# else /* have nothing, do single thread case */ if(sigprocmask(SIG_UNBLOCK, &sigset, NULL)) fatal_exit("sigprocmask: %s", strerror(errno)); @@ -109,7 +109,7 @@ void ub_thread_sig_unblock(int sig) * @param func: function body of the thread. Return value of func is lost. * @param arg: user argument to func. */ -void +void ub_thr_fork_create(ub_thread_type* thr, void* (*func)(void*), void* arg) { pid_t pid = fork(); @@ -156,8 +156,8 @@ void* ub_thread_key_get(ub_thread_key_type key) static void log_win_err(const char* str, DWORD err) { LPTSTR buf; - if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_ALLOCATE_BUFFER, + if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, err, 0, (LPTSTR)&buf, 0, NULL) == 0) { /* could not format error message */ log_err("%s, GetLastError=%d", str, (int)err); @@ -250,10 +250,10 @@ void ub_thread_join(ub_thread_type thr) { DWORD ret = WaitForSingleObject(thr, INFINITE); if(ret == WAIT_FAILED) { - log_win_err("WaitForSingleObject(Thread):WAIT_FAILED", + log_win_err("WaitForSingleObject(Thread):WAIT_FAILED", GetLastError()); } else if(ret == WAIT_TIMEOUT) { - log_win_err("WaitForSingleObject(Thread):WAIT_TIMEOUT", + log_win_err("WaitForSingleObject(Thread):WAIT_TIMEOUT", GetLastError()); } /* and close the handle to the thread */ diff --git a/sbin/unwind/libunbound/util/locks.h b/sbin/unwind/libunbound/util/locks.h index d86ee4923..d819d3c6b 100644 --- a/sbin/unwind/libunbound/util/locks.h +++ b/sbin/unwind/libunbound/util/locks.h @@ -2,24 +2,24 @@ * util/locks.h - unbound locking primitives * * Copyright (c) 2007, NLnet Labs. All rights reserved. - * + * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -51,7 +51,7 @@ * This lock is meant for non performance sensitive uses. * o lock_quick: speed lock. For performance sensitive locking of critical * sections. Could be implemented by a mutex or a spinlock. - * + * * Also thread creation and deletion functions are defined here. */ @@ -133,12 +133,12 @@ typedef pthread_mutex_t lock_quick_type; #else /* HAVE_PTHREAD_SPINLOCK_T */ /** use pthread spinlock for the quick lock */ typedef pthread_spinlock_t lock_quick_type; -/** +/** * allocate process private since this is available whether * Thread Process-Shared Synchronization is supported or not. * This means only threads inside this process may access the lock. * (not threads from another process that shares memory). - * spinlocks are not supported on all pthread platforms. + * spinlocks are not supported on all pthread platforms. */ #define lock_quick_init(lock) LOCKRET(pthread_spin_init(lock, PTHREAD_PROCESS_PRIVATE)) #define lock_quick_destroy(lock) LOCKRET(pthread_spin_destroy(lock)) diff --git a/sbin/unwind/libunbound/util/log.c b/sbin/unwind/libunbound/util/log.c index dfbb23349..1360df52f 100644 --- a/sbin/unwind/libunbound/util/log.c +++ b/sbin/unwind/libunbound/util/log.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -92,13 +92,13 @@ log_init(const char* filename, int use_syslog, const char* chrootdir) lock_basic_init(&log_lock); } lock_basic_lock(&log_lock); - if(logfile + if(logfile #if defined(HAVE_SYSLOG_H) || defined(UB_ON_WINDOWS) || logging_to_syslog #endif ) { lock_basic_unlock(&log_lock); /* verbose() needs the lock */ - verbose(VERB_QUERY, "switching log to %s", + verbose(VERB_QUERY, "switching log to %s", use_syslog?"syslog":(filename&&filename[0]?filename:"stderr")); lock_basic_lock(&log_lock); } @@ -140,12 +140,12 @@ log_init(const char* filename, int use_syslog, const char* chrootdir) } /* open the file for logging */ if(chrootdir && chrootdir[0] && strncmp(filename, chrootdir, - strlen(chrootdir)) == 0) + strlen(chrootdir)) == 0) filename += strlen(chrootdir); f = fopen(filename, "a"); if(!f) { lock_basic_unlock(&log_lock); - log_err("Could not open logfile %s: %s", filename, + log_err("Could not open logfile %s: %s", filename, strerror(errno)); return; } @@ -223,7 +223,7 @@ log_vmsg(int pri, const char* type, char message[MAXSYSLOGMSGLEN]; unsigned int* tid = (unsigned int*)ub_thread_key_get(logkey); time_t now; -#if defined(HAVE_STRFTIME) && defined(HAVE_LOCALTIME_R) +#if defined(HAVE_STRFTIME) && defined(HAVE_LOCALTIME_R) char tmbuf[32]; struct tm tm; #elif defined(UB_ON_WINDOWS) @@ -233,7 +233,7 @@ log_vmsg(int pri, const char* type, vsnprintf(message, sizeof(message), format, args); #ifdef HAVE_SYSLOG_H if(logging_to_syslog) { - syslog(pri, "[%d:%x] %s: %s", + syslog(pri, "[%d:%x] %s: %s", (int)getpid(), tid?*tid:0, type, message); return; } @@ -250,12 +250,12 @@ log_vmsg(int pri, const char* type, } else if(strcmp(type, "warning") == 0) { tp=MSG_GENERIC_WARN; wt=EVENTLOG_WARNING_TYPE; - } else if(strcmp(type, "notice") == 0 + } else if(strcmp(type, "notice") == 0 || strcmp(type, "debug") == 0) { tp=MSG_GENERIC_SUCCESS; wt=EVENTLOG_SUCCESS; } - snprintf(m, sizeof(m), "[%s:%x] %s: %s", + snprintf(m, sizeof(m), "[%s:%x] %s: %s", ident, tid?*tid:0, type, message); s = RegisterEventSource(NULL, SERVICE_NAME); if(!s) return; @@ -270,22 +270,22 @@ log_vmsg(int pri, const char* type, return; } now = (time_t)time(NULL); -#if defined(HAVE_STRFTIME) && defined(HAVE_LOCALTIME_R) +#if defined(HAVE_STRFTIME) && defined(HAVE_LOCALTIME_R) if(log_time_asc && strftime(tmbuf, sizeof(tmbuf), "%b %d %H:%M:%S", localtime_r(&now, &tm))%(sizeof(tmbuf)) != 0) { /* %sizeof buf!=0 because old strftime returned max on error */ - fprintf(logfile, "%s %s[%d:%x] %s: %s\n", tmbuf, + fprintf(logfile, "%s %s[%d:%x] %s: %s\n", tmbuf, ident, (int)getpid(), tid?*tid:0, type, message); } else #elif defined(UB_ON_WINDOWS) if(log_time_asc && GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, tmbuf, sizeof(tmbuf)) && GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, dtbuf, sizeof(dtbuf))) { - fprintf(logfile, "%s %s %s[%d:%x] %s: %s\n", dtbuf, tmbuf, + fprintf(logfile, "%s %s %s[%d:%x] %s: %s\n", dtbuf, tmbuf, ident, (int)getpid(), tid?*tid:0, type, message); } else #endif - fprintf(logfile, "[" ARG_LL "d] %s[%d:%x] %s: %s\n", (long long)now, + fprintf(logfile, "[" ARG_LL "d] %s[%d:%x] %s: %s\n", (long long)now, ident, (int)getpid(), tid?*tid:0, type, message); #ifdef UB_ON_WINDOWS /* line buffering does not work on windows */ @@ -368,7 +368,7 @@ verbose(enum verbosity_value level, const char* format, ...) } /** log hex data */ -static void +static void log_hex_f(enum verbosity_value v, const char* msg, void* data, size_t length) { size_t i, j; @@ -392,12 +392,12 @@ log_hex_f(enum verbosity_value v, const char* msg, void* data, size_t length) buf[j*2 + 1] = hexchar[ data8[i+j] & 0xF ]; } buf[len*2] = 0; - verbose(v, "%s[%u:%u] %.*s", msg, (unsigned)length, + verbose(v, "%s[%u:%u] %.*s", msg, (unsigned)length, (unsigned)i, (int)len*2, buf); } } -void +void log_hex(const char* msg, void* data, size_t length) { log_hex_f(verbosity, msg, data, length); diff --git a/sbin/unwind/libunbound/util/log.h b/sbin/unwind/libunbound/util/log.h index 29a1ba380..5276fcf89 100644 --- a/sbin/unwind/libunbound/util/log.h +++ b/sbin/unwind/libunbound/util/log.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -67,11 +67,11 @@ extern enum verbosity_value verbosity; /** * log a verbose message, pass the level for this message. * It has printf formatted arguments. No trailing newline is needed. - * @param level: verbosity level for this message, compared to global + * @param level: verbosity level for this message, compared to global * verbosity setting. * @param format: printf-style format string. Arguments follow. */ -void verbose(enum verbosity_value level, +void verbose(enum verbosity_value level, const char* format, ...) ATTR_FORMAT(printf, 2, 3); /** @@ -133,7 +133,7 @@ void log_ident_set_or_default(const char* identity); /** * Set if the time value is printed ascii or decimal in log entries. * @param use_asc: if true, ascii is printed, otherwise decimal. - * If the conversion fails or you have no time functions, + * If the conversion fails or you have no time functions, * decimal is printed. */ void log_set_time_asc(int use_asc); @@ -187,7 +187,7 @@ void log_reply(const char* format, ...) ATTR_FORMAT(printf, 1, 2); /** * Easy alternative for log_hex, takes a sldns_buffer. - * @param level: verbosity level for this message, compared to global + * @param level: verbosity level for this message, compared to global * verbosity setting. * @param msg: string desc to print * @param buf: the buffer. diff --git a/sbin/unwind/libunbound/util/mini_event.c b/sbin/unwind/libunbound/util/mini_event.c index c05dc668c..fd450d32f 100644 --- a/sbin/unwind/libunbound/util/mini_event.c +++ b/sbin/unwind/libunbound/util/mini_event.c @@ -2,24 +2,24 @@ * mini_event.c - implementation of part of libevent api, portably. * * Copyright (c) 2007, NLnet Labs. All rights reserved. - * + * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -31,7 +31,7 @@ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * */ /** @@ -108,7 +108,7 @@ void *event_init(time_t* time_secs, struct timeval* time_tv) if((int)FD_SETSIZE < base->capfd) base->capfd = (int)FD_SETSIZE; #endif - base->fds = (struct event**)calloc((size_t)base->capfd, + base->fds = (struct event**)calloc((size_t)base->capfd, sizeof(struct event*)); if(!base->fds) { event_base_free(base); @@ -139,7 +139,7 @@ const char *event_get_method(void) } /** call timeouts handlers, and return how long to wait for next one or -1 */ -static void handle_timeouts(struct event_base* base, struct timeval* now, +static void handle_timeouts(struct event_base* base, struct timeval* now, struct timeval* wait) { struct event* p; @@ -151,7 +151,7 @@ static void handle_timeouts(struct event_base* base, struct timeval* now, !=RBTREE_NULL) { #ifndef S_SPLINT_S if(p->ev_timeout.tv_sec > now->tv_sec || - (p->ev_timeout.tv_sec==now->tv_sec && + (p->ev_timeout.tv_sec==now->tv_sec && p->ev_timeout.tv_usec > now->tv_usec)) { /* there is a next larger timeout. wait for it */ wait->tv_sec = p->ev_timeout.tv_sec - now->tv_sec; @@ -160,7 +160,7 @@ static void handle_timeouts(struct event_base* base, struct timeval* now, wait->tv_usec = 1000000 - (now->tv_usec - p->ev_timeout.tv_usec); } else { - wait->tv_usec = p->ev_timeout.tv_usec + wait->tv_usec = p->ev_timeout.tv_usec - now->tv_usec; } return; @@ -199,7 +199,7 @@ static int handle_select(struct event_base* base, struct timeval* wait) } if(settime(base) < 0) return -1; - + for(i=0; imaxfd+1; i++) { short bits = 0; if(!base->fds[i] || !(FD_ISSET(i, &base->ready))) { @@ -217,7 +217,7 @@ static int handle_select(struct event_base* base, struct timeval* wait) if(bits) { fptr_ok(fptr_whitelist_event( base->fds[i]->ev_callback)); - (*base->fds[i]->ev_callback)(base->fds[i]->ev_fd, + (*base->fds[i]->ev_callback)(base->fds[i]->ev_fd, bits, base->fds[i]->ev_arg); if(ret==0) break; @@ -249,7 +249,7 @@ int event_base_dispatch(struct event_base* base) } /** exit that loop */ -int event_base_loopexit(struct event_base* base, +int event_base_loopexit(struct event_base* base, struct timeval* ATTR_UNUSED(tv)) { base->need_to_exit = 1; @@ -268,7 +268,7 @@ void event_base_free(struct event_base* base) } /** set content of event */ -void event_set(struct event* ev, int fd, short bits, +void event_set(struct event* ev, int fd, short bits, void (*cb)(int, short, void *), void* arg) { ev->node.key = ev; diff --git a/sbin/unwind/libunbound/util/mini_event.h b/sbin/unwind/libunbound/util/mini_event.h index fa71ca3d1..29ccd4a05 100644 --- a/sbin/unwind/libunbound/util/mini_event.h +++ b/sbin/unwind/libunbound/util/mini_event.h @@ -2,24 +2,24 @@ * mini-event.h - micro implementation of libevent api, using select() only. * * Copyright (c) 2007, NLnet Labs. All rights reserved. - * + * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -42,7 +42,7 @@ * * Although limited to select() and a max (1024) open fds, it * is efficient: - * o dispatch call caches fd_sets to use. + * o dispatch call caches fd_sets to use. * o handler calling takes time ~ to the number of fds. * o timeouts are stored in a redblack tree, sorted, so take log(n). * Timeouts are only accurate to the second (no subsecond accuracy). @@ -62,7 +62,7 @@ #ifndef HAVE_EVENT_BASE_FREE #define HAVE_EVENT_BASE_FREE -#endif +#endif /* redefine to use our own namespace so that on platforms where * linkers crosslink library-private symbols with other symbols, it works */ @@ -110,13 +110,13 @@ struct event_base /** capacity - size of the fds array */ int capfd; /* fdset for read write, for fds ready, and added */ - fd_set + fd_set /** fds for reading */ - reads, + reads, /** fds for writing */ - writes, + writes, /** fds determined ready for use */ - ready, + ready, /** ready plus newly added events. */ content; /** array of 0 - maxsig of ptr to event for it */ diff --git a/sbin/unwind/libunbound/util/module.c b/sbin/unwind/libunbound/util/module.c index 773dab853..86ab24a07 100644 --- a/sbin/unwind/libunbound/util/module.c +++ b/sbin/unwind/libunbound/util/module.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -45,7 +45,7 @@ #include "util/data/dname.h" #include "util/net_help.h" -const char* +const char* strextstate(enum module_ext_state s) { switch(s) { @@ -60,7 +60,7 @@ strextstate(enum module_ext_state s) return "bad_extstate_value"; } -const char* +const char* strmodulevent(enum module_ev e) { switch(e) { @@ -120,9 +120,9 @@ void errinf_origin(struct module_qstate* qstate, struct sock_list *origin) snprintf(buf, sizeof(buf), "from "); else snprintf(buf, sizeof(buf), "and "); if(p->len == 0) - snprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), + snprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), "cache"); - else + else addr_to_str(&p->addr, p->len, buf+strlen(buf), sizeof(buf)-strlen(buf)); errinf(qstate, buf); @@ -292,7 +292,7 @@ inplace_cb_register(void* cb, enum inplace_cb_list_type type, void* cbarg, callback->next = NULL; callback->cb = cb; callback->cb_arg = cbarg; - + prevp = (struct inplace_cb**) &env->inplace_cb_lists[type]; /* append at end of list */ while(*prevp != NULL) diff --git a/sbin/unwind/libunbound/util/module.h b/sbin/unwind/libunbound/util/module.h index 5b6fcc93c..f8e7e762b 100644 --- a/sbin/unwind/libunbound/util/module.h +++ b/sbin/unwind/libunbound/util/module.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -300,7 +300,7 @@ typedef int inplace_cb_query_func_type(struct query_info* qinfo, uint16_t flags, * id: module id. * cb_args: argument passed when registering callback. */ -typedef int inplace_cb_edns_back_parsed_func_type(struct module_qstate* qstate, +typedef int inplace_cb_edns_back_parsed_func_type(struct module_qstate* qstate, int id, void* cb_args); /** @@ -344,9 +344,9 @@ struct module_env { struct key_cache* key_cache; /* --- services --- */ - /** + /** * Send serviced DNS query to server. UDP/TCP and EDNS is handled. - * operate() should return with wait_reply. Later on a callback + * operate() should return with wait_reply. Later on a callback * will cause operate() to be called with event timeout or reply. * The time until a timeout is calculated from roundtrip timing, * several UDP retries are attempted. @@ -403,19 +403,19 @@ struct module_env { * o need to initialise the new state (module init; it is a new state). * so that the next run of the query with this module is successful. * o no init needed, attachment successful. - * - * @param qstate: the state to find mesh state, and that wants to + * + * @param qstate: the state to find mesh state, and that wants to * receive the results from the new subquery. * @param qinfo: what to query for (copied). * @param qflags: what flags to use (RD, CD flag or not). * @param prime: if it is a (stub) priming query. * @param valrec: validation lookup recursion, does not need validation - * @param newq: If the new subquery needs initialisation, it is + * @param newq: If the new subquery needs initialisation, it is * returned, otherwise NULL is returned. * @return: false on error, true if success (and init may be needed). - */ - int (*attach_sub)(struct module_qstate* qstate, - struct query_info* qinfo, uint16_t qflags, int prime, + */ + int (*attach_sub)(struct module_qstate* qstate, + struct query_info* qinfo, uint16_t qflags, int prime, int valrec, struct module_qstate** newq); /** @@ -444,13 +444,13 @@ struct module_env { * @param sub: The added mesh state, created if it did not exist already. * @return: false on error, true if success (and init may be needed). */ - int (*add_sub)(struct module_qstate* qstate, - struct query_info* qinfo, uint16_t qflags, int prime, + int (*add_sub)(struct module_qstate* qstate, + struct query_info* qinfo, uint16_t qflags, int prime, int valrec, struct module_qstate** newq, struct mesh_state** sub); /** - * Kill newly attached sub. If attach_sub returns newq for + * Kill newly attached sub. If attach_sub returns newq for * initialisation, but that fails, then this routine will cleanup and * delete the freshly created sub. * @param newq: the new subquery that is no longer needed. @@ -462,16 +462,16 @@ struct module_env { * Detect if adding a dependency for qstate on name,type,class will * create a dependency cycle. * @param qstate: given mesh querystate. - * @param qinfo: query info for dependency. + * @param qinfo: query info for dependency. * @param flags: query flags of dependency, RD/CD flags. * @param prime: if dependency is a priming query or not. * @param valrec: validation lookup recursion, does not need validation - * @return true if the name,type,class exists and the given - * qstate mesh exists as a dependency of that name. Thus - * if qstate becomes dependent on name,type,class then a + * @return true if the name,type,class exists and the given + * qstate mesh exists as a dependency of that name. Thus + * if qstate becomes dependent on name,type,class then a * cycle is created. */ - int (*detect_cycle)(struct module_qstate* qstate, + int (*detect_cycle)(struct module_qstate* qstate, struct query_info* qinfo, uint16_t flags, int prime, int valrec); @@ -513,12 +513,12 @@ struct module_env { /** Mapping of forwarding zones to targets. * iterator forwarder information. per-thread, created by worker */ struct iter_forwards* fwds; - /** + /** * iterator forwarder information. per-thread, created by worker. - * The hints -- these aren't stored in the cache because they don't - * expire. The hints are always used to "prime" the cache. Note - * that both root hints and stub zone "hints" are stored in this - * data structure. + * The hints -- these aren't stored in the cache because they don't + * expire. The hints are always used to "prime" the cache. Note + * that both root hints and stub zone "hints" are stored in this + * data structure. */ struct iter_hints* hints; /** module specific data. indexed by module id. */ @@ -542,7 +542,7 @@ struct module_env { }; /** - * External visible states of the module state machine + * External visible states of the module state machine * Modules may also have an internal state. * Modules are supposed to run to completion or until blocked. */ @@ -583,8 +583,8 @@ enum module_ev { module_event_error }; -/** - * Linked list of sockaddrs +/** + * Linked list of sockaddrs * May be allocated such that only 'len' bytes of addr exist for the structure. */ struct sock_list { @@ -696,14 +696,14 @@ struct module_qstate { int is_drop; }; -/** +/** * Module functionality block */ struct module_func_block { /** text string name of module */ const char* name; - /** + /** * init the module. Called once for the global state. * This is the place to apply settings from the config file. * @param env: module environment. @@ -722,14 +722,14 @@ struct module_func_block { /** * accept a new query, or work further on existing query. * Changes the qstate->ext_state to be correct on exit. - * @param ev: event that causes the module state machine to + * @param ev: event that causes the module state machine to * (re-)activate. - * @param qstate: the query state. + * @param qstate: the query state. * Note that this method is not allowed to change the * query state 'identity', that is query info, qflags, * and priming status. * Attach a subquery to get results to a different query. - * @param id: module id number that operate() is called on. + * @param id: module id number that operate() is called on. * @param outbound: if not NULL this event is due to the reply/timeout * or error on this outbound query. * @return: if at exit the ext_state is: @@ -739,7 +739,7 @@ struct module_func_block { * the service routine to make subrequest or send message * have been called. */ - void (*operate)(struct module_qstate* qstate, enum module_ev event, + void (*operate)(struct module_qstate* qstate, enum module_ev event, int id, struct outbound_entry* outbound); /** @@ -761,7 +761,7 @@ struct module_func_block { void (*clear)(struct module_qstate* qstate, int id); /** - * How much memory is the module specific data using. + * How much memory is the module specific data using. * @param env: module environment. * @param id: the module id. * @return the number of bytes that are alloced. @@ -769,15 +769,15 @@ struct module_func_block { size_t (*get_mem)(struct module_env* env, int id); }; -/** - * Debug utility: module external qstate to string +/** + * Debug utility: module external qstate to string * @param s: the state value. * @return descriptive string. */ const char* strextstate(enum module_ext_state s); -/** - * Debug utility: module event to string +/** + * Debug utility: module event to string * @param e: the module event value. * @return descriptive string. */ @@ -796,7 +796,7 @@ void errinf_ede(struct module_qstate* qstate, const char* str, /** * Append text to error info: from 1.2.3.4 * @param qstate: query state. - * @param origin: sock list with origin of trouble. + * @param origin: sock list with origin of trouble. * Every element added. * If NULL: nothing is added. * if 0len element: 'from cache' is added. @@ -816,7 +816,7 @@ void errinf_rrset(struct module_qstate* qstate, struct ub_packed_rrset_key *rr); * @param str: explanation string * @param dname: the dname. */ -void errinf_dname(struct module_qstate* qstate, const char* str, +void errinf_dname(struct module_qstate* qstate, const char* str, uint8_t* dname); /** diff --git a/sbin/unwind/libunbound/util/net_help.c b/sbin/unwind/libunbound/util/net_help.c index dec46da20..b0cb90464 100644 --- a/sbin/unwind/libunbound/util/net_help.c +++ b/sbin/unwind/libunbound/util/net_help.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -130,8 +130,8 @@ str_is_ip6(const char* str) else return 0; } -int -fd_set_nonblock(int s) +int +fd_set_nonblock(int s) { #ifdef HAVE_FCNTL int flag; @@ -147,15 +147,15 @@ fd_set_nonblock(int s) #elif defined(HAVE_IOCTLSOCKET) unsigned long on = 1; if(ioctlsocket(s, FIONBIO, &on) != 0) { - log_err("can't ioctlsocket FIONBIO on: %s", + log_err("can't ioctlsocket FIONBIO on: %s", wsa_strerror(WSAGetLastError())); } #endif return 1; } -int -fd_set_block(int s) +int +fd_set_block(int s) { #ifdef HAVE_FCNTL int flag; @@ -172,21 +172,21 @@ fd_set_block(int s) unsigned long off = 0; if(ioctlsocket(s, FIONBIO, &off) != 0) { if(WSAGetLastError() != WSAEINVAL || verbosity >= 4) - log_err("can't ioctlsocket FIONBIO off: %s", + log_err("can't ioctlsocket FIONBIO off: %s", wsa_strerror(WSAGetLastError())); } -#endif +#endif return 1; } -int +int is_pow2(size_t num) { if(num == 0) return 1; return (num & (num-1)) == 0; } -void* +void* memdup(void* data, size_t len) { void* d; @@ -199,7 +199,7 @@ memdup(void* data, size_t len) } void -log_addr(enum verbosity_value v, const char* str, +log_addr(enum verbosity_value v, const char* str, struct sockaddr_storage* addr, socklen_t addrlen) { uint16_t port; @@ -228,7 +228,7 @@ log_addr(enum verbosity_value v, const char* str, dest[sizeof(dest)-1] = 0; port = ntohs(((struct sockaddr_in*)addr)->sin_port); if(verbosity >= 4) - verbose(v, "%s %s %s port %d (len %d)", str, family, dest, + verbose(v, "%s %s %s port %d (len %d)", str, family, dest, (int)port, (int)addrlen); else verbose(v, "%s %s port %d", str, dest, (int)port); } @@ -254,7 +254,7 @@ extstrtoaddr(const char* str, struct sockaddr_storage* addr, return ipstrtoaddr(str, port, addr, addrlen); } -int +int ipstrtoaddr(const char* ip, int port, struct sockaddr_storage* addr, socklen_t* addrlen) { @@ -434,7 +434,7 @@ int netblockdnametoaddr(uint8_t* dname, size_t dnamelen, return 1; } -int authextstrtoaddr(char* str, struct sockaddr_storage* addr, +int authextstrtoaddr(char* str, struct sockaddr_storage* addr, socklen_t* addrlen, char** auth_name) { char* s; @@ -528,12 +528,12 @@ sockaddr_store_port(struct sockaddr_storage* addr, socklen_t addrlen, int port) } void -log_nametypeclass(enum verbosity_value v, const char* str, uint8_t* name, +log_nametypeclass(enum verbosity_value v, const char* str, uint8_t* name, uint16_t type, uint16_t dclass) { char buf[LDNS_MAX_DOMAINLEN+1]; char t[12], c[12]; - const char *ts, *cs; + const char *ts, *cs; if(verbosity < v) return; dname_str(name, buf); @@ -564,7 +564,7 @@ log_query_in(const char* str, uint8_t* name, uint16_t type, uint16_t dclass) { char buf[LDNS_MAX_DOMAINLEN+1]; char t[12], c[12]; - const char *ts, *cs; + const char *ts, *cs; dname_str(name, buf); if(type == LDNS_RR_TYPE_TSIG) ts = "TSIG"; else if(type == LDNS_RR_TYPE_IXFR) ts = "IXFR"; @@ -590,7 +590,7 @@ log_query_in(const char* str, uint8_t* name, uint16_t type, uint16_t dclass) else log_info("%s %s %s %s", str, buf, ts, cs); } -void log_name_addr(enum verbosity_value v, const char* str, uint8_t* zone, +void log_name_addr(enum verbosity_value v, const char* str, uint8_t* zone, struct sockaddr_storage* addr, socklen_t addrlen) { uint16_t port; @@ -643,7 +643,7 @@ void log_err_addr(const char* str, const char* err, } int -sockaddr_cmp(struct sockaddr_storage* addr1, socklen_t len1, +sockaddr_cmp(struct sockaddr_storage* addr1, socklen_t len1, struct sockaddr_storage* addr2, socklen_t len2) { struct sockaddr_in* p1_in = (struct sockaddr_in*)addr1; @@ -676,7 +676,7 @@ sockaddr_cmp(struct sockaddr_storage* addr1, socklen_t len1, if(p1_in6->sin6_port > p2_in6->sin6_port) return 1; log_assert(p1_in6->sin6_port == p2_in6->sin6_port); - return memcmp(&p1_in6->sin6_addr, &p2_in6->sin6_addr, + return memcmp(&p1_in6->sin6_addr, &p2_in6->sin6_addr, INET6_SIZE); } else { /* eek unknown type, perform this comparison for sanity. */ @@ -685,7 +685,7 @@ sockaddr_cmp(struct sockaddr_storage* addr1, socklen_t len1, } int -sockaddr_cmp_addr(struct sockaddr_storage* addr1, socklen_t len1, +sockaddr_cmp_addr(struct sockaddr_storage* addr1, socklen_t len1, struct sockaddr_storage* addr2, socklen_t len2) { struct sockaddr_in* p1_in = (struct sockaddr_in*)addr1; @@ -706,7 +706,7 @@ sockaddr_cmp_addr(struct sockaddr_storage* addr1, socklen_t len1, if( p1_in->sin_family == AF_INET ) { return memcmp(&p1_in->sin_addr, &p2_in->sin_addr, INET_SIZE); } else if (p1_in6->sin6_family == AF_INET6) { - return memcmp(&p1_in6->sin6_addr, &p2_in6->sin6_addr, + return memcmp(&p1_in6->sin6_addr, &p2_in6->sin6_addr, INET6_SIZE); } else { /* eek unknown type, perform this comparison for sanity. */ @@ -840,7 +840,7 @@ int addr_is_ip4mapped(struct sockaddr_storage* addr, socklen_t addrlen) { /* prefix for ipv4 into ipv6 mapping is ::ffff:x.x.x.x */ - const uint8_t map_prefix[16] = + const uint8_t map_prefix[16] = {0,0,0,0, 0,0,0,0, 0,0,0xff,0xff, 0,0,0,0}; uint8_t* s; if(!addr_is_ip6(addr, addrlen)) @@ -892,7 +892,7 @@ void sock_list_insert(struct sock_list** list, struct sockaddr_storage* addr, void sock_list_prepend(struct sock_list** list, struct sock_list* add) { struct sock_list* last = add; - if(!last) + if(!last) return; while(last->next) last = last->next; @@ -905,7 +905,7 @@ int sock_list_find(struct sock_list* list, struct sockaddr_storage* addr, { while(list) { if(len == list->len) { - if(len == 0 || sockaddr_cmp_addr(addr, len, + if(len == 0 || sockaddr_cmp_addr(addr, len, &list->addr, list->len) == 0) return 1; } @@ -1189,7 +1189,7 @@ add_WIN_cacerts_to_openssl_store(SSL_CTX* tls_ctx) CERT_STORE_PROV_SYSTEM, 0, 0, - /* NOTE: mingw does not have this const: replace with 1 << 16 from code + /* NOTE: mingw does not have this const: replace with 1 << 16 from code CERT_SYSTEM_STORE_CURRENT_USER, */ 1 << 16, L"root")) == 0) diff --git a/sbin/unwind/libunbound/util/net_help.h b/sbin/unwind/libunbound/util/net_help.h index a9de910d5..78f639da2 100644 --- a/sbin/unwind/libunbound/util/net_help.h +++ b/sbin/unwind/libunbound/util/net_help.h @@ -1,25 +1,25 @@ /* - * util/net_help.h - network help functions + * util/net_help.h - network help functions * * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -47,13 +47,13 @@ struct sock_list; struct regional; struct config_strlist; -/** DNS constants for uint16_t style flag manipulation. host byteorder. +/** DNS constants for uint16_t style flag manipulation. host byteorder. * 1 1 1 1 1 1 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ * |QR| Opcode |AA|TC|RD|RA| Z|AD|CD| RCODE | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ - */ + */ /** CD flag */ #define BIT_CD 0x0010 /** AD flag */ @@ -122,14 +122,14 @@ int str_is_ip6(const char* str); * @param s: file descriptor. * @return: 0 on error (error is printed to log). */ -int fd_set_nonblock(int s); +int fd_set_nonblock(int s); /** * Set fd (back to) blocking. * @param s: file descriptor. * @return: 0 on error (error is printed to log). */ -int fd_set_block(int s); +int fd_set_block(int s); /** * See if number is a power of 2. @@ -153,7 +153,7 @@ void* memdup(void* data, size_t len); * @param addr: the sockaddr to print. Can be ip4 or ip6. * @param addrlen: length of addr. */ -void log_addr(enum verbosity_value v, const char* str, +void log_addr(enum verbosity_value v, const char* str, struct sockaddr_storage* addr, socklen_t addrlen); /** @@ -164,7 +164,7 @@ void log_addr(enum verbosity_value v, const char* str, * @param addr: the sockaddr to print. Can be ip4 or ip6. * @param addrlen: length of addr. */ -void log_name_addr(enum verbosity_value v, const char* str, uint8_t* zone, +void log_name_addr(enum verbosity_value v, const char* str, uint8_t* zone, struct sockaddr_storage* addr, socklen_t addrlen); /** @@ -186,7 +186,7 @@ void log_err_addr(const char* str, const char* err, * @param port: default port. * @return 0 on error. */ -int extstrtoaddr(const char* str, struct sockaddr_storage* addr, +int extstrtoaddr(const char* str, struct sockaddr_storage* addr, socklen_t* addrlen, int port); /** @@ -257,7 +257,7 @@ void sockaddr_store_port(struct sockaddr_storage* addr, socklen_t addrlen, * @param type: host format RR type. * @param dclass: host format RR class. */ -void log_nametypeclass(enum verbosity_value v, const char* str, +void log_nametypeclass(enum verbosity_value v, const char* str, uint8_t* name, uint16_t type, uint16_t dclass); /** @@ -275,7 +275,7 @@ void log_query_in(const char* str, uint8_t* name, uint16_t type, * @param len2: lengths of addr2. * @return: 0 if addr1 == addr2. -1 if addr1 is smaller, +1 if larger. */ -int sockaddr_cmp(struct sockaddr_storage* addr1, socklen_t len1, +int sockaddr_cmp(struct sockaddr_storage* addr1, socklen_t len1, struct sockaddr_storage* addr2, socklen_t len2); /** @@ -286,7 +286,7 @@ int sockaddr_cmp(struct sockaddr_storage* addr1, socklen_t len1, * @param len2: lengths of addr2. * @return: 0 if addr1 == addr2. -1 if addr1 is smaller, +1 if larger. */ -int sockaddr_cmp_addr(struct sockaddr_storage* addr1, socklen_t len1, +int sockaddr_cmp_addr(struct sockaddr_storage* addr1, socklen_t len1, struct sockaddr_storage* addr2, socklen_t len2); /** @@ -450,7 +450,7 @@ int listen_sslctx_setup(void* ctxt); */ void listen_sslctx_setup_2(void* ctxt); -/** +/** * create SSL listen context * @param key: private key file. * @param pem: public key cert. diff --git a/sbin/unwind/libunbound/util/proxy_protocol.c b/sbin/unwind/libunbound/util/proxy_protocol.c index 757c5141d..13270ba40 100644 --- a/sbin/unwind/libunbound/util/proxy_protocol.c +++ b/sbin/unwind/libunbound/util/proxy_protocol.c @@ -4,22 +4,22 @@ * Copyright (c) 2022, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR diff --git a/sbin/unwind/libunbound/util/proxy_protocol.h b/sbin/unwind/libunbound/util/proxy_protocol.h index 13cab9d74..38addb290 100644 --- a/sbin/unwind/libunbound/util/proxy_protocol.h +++ b/sbin/unwind/libunbound/util/proxy_protocol.h @@ -4,22 +4,22 @@ * Copyright (c) 2022, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR diff --git a/sbin/unwind/libunbound/util/random.c b/sbin/unwind/libunbound/util/random.c index 6eb102c63..21315e857 100644 --- a/sbin/unwind/libunbound/util/random.c +++ b/sbin/unwind/libunbound/util/random.c @@ -1,25 +1,25 @@ /* * util/random.c - thread safe random generator, which is reasonably secure. - * + * * Copyright (c) 2007, NLnet Labs. All rights reserved. - * + * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -72,14 +72,14 @@ #include "yarrow.h" #endif -/** +/** * Max random value. Similar to RAND_MAX, but more portable * (mingw uses only 15 bits random). */ #define MAX_VALUE 0x7fffffff #if defined(HAVE_SSL) || defined(HAVE_LIBBSD) -struct ub_randstate* +struct ub_randstate* ub_initstate(struct ub_randstate* ATTR_UNUSED(from)) { struct ub_randstate* s = (struct ub_randstate*)malloc(1); @@ -90,7 +90,7 @@ ub_initstate(struct ub_randstate* ATTR_UNUSED(from)) return s; } -long int +long int ub_random(struct ub_randstate* ATTR_UNUSED(s)) { /* This relies on MAX_VALUE being 0x7fffffff. */ @@ -200,7 +200,7 @@ ub_random_max(struct ub_randstate* state, long int x) } #endif /* HAVE_NSS or HAVE_NETTLE and !HAVE_LIBBSD */ -void +void ub_randfree(struct ub_randstate* s) { free(s); diff --git a/sbin/unwind/libunbound/util/random.h b/sbin/unwind/libunbound/util/random.h index b257793a4..7bd94acc8 100644 --- a/sbin/unwind/libunbound/util/random.h +++ b/sbin/unwind/libunbound/util/random.h @@ -1,25 +1,25 @@ /* * util/random.h - thread safe random generator, which is reasonably secure. - * + * * Copyright (c) 2007, NLnet Labs. All rights reserved. - * + * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -48,7 +48,7 @@ struct ub_randstate; /** - * Initialize a random generator state for use + * Initialize a random generator state for use * @param from: if not NULL, the seed is taken from this random structure. * can be used to seed random states via a parent-random-state that * is itself seeded with entropy. diff --git a/sbin/unwind/libunbound/util/rbtree.c b/sbin/unwind/libunbound/util/rbtree.c index f031c9a13..9b20d8a1a 100644 --- a/sbin/unwind/libunbound/util/rbtree.c +++ b/sbin/unwind/libunbound/util/rbtree.c @@ -2,24 +2,24 @@ * rbtree.c -- generic red black tree * * Copyright (c) 2001-2007, NLnet Labs. All rights reserved. - * + * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -91,7 +91,7 @@ rbtree_create (int (*cmpf)(const void *, const void *)) return rbtree; } -void +void rbtree_init(rbtree_type *rbtree, int (*cmpf)(const void *, const void *)) { /* Initialize it */ @@ -290,15 +290,15 @@ rbtree_search (rbtree_type *rbtree, const void *key) } /** helpers for delete: swap node colours */ -static void swap_int8(uint8_t* x, uint8_t* y) -{ - uint8_t t = *x; *x = *y; *y = t; +static void swap_int8(uint8_t* x, uint8_t* y) +{ + uint8_t t = *x; *x = *y; *y = t; } /** helpers for delete: swap node pointers */ -static void swap_np(rbnode_type** x, rbnode_type** y) +static void swap_np(rbnode_type** x, rbnode_type** y) { - rbnode_type* t = *x; *x = *y; *y = t; + rbnode_type* t = *x; *x = *y; *y = t; } /** Update parent pointers of child trees of 'parent' */ @@ -325,7 +325,7 @@ static void change_child_ptr(rbnode_type* child, rbnode_type* old, if(child->parent == old) child->parent = new; } -rbnode_type* +rbnode_type* rbtree_delete(rbtree_type *rbtree, const void *key) { rbnode_type *to_delete; @@ -433,7 +433,7 @@ static void rbtree_delete_fixup(rbtree_type* rbtree, rbnode_type* child, else sibling = child_parent->right; } - if(child_parent->color == BLACK + if(child_parent->color == BLACK && sibling->color == BLACK && sibling->left->color == BLACK && sibling->right->color == BLACK) @@ -453,7 +453,7 @@ static void rbtree_delete_fixup(rbtree_type* rbtree, rbnode_type* child, if(child_parent->color == RED && sibling->color == BLACK && sibling->left->color == BLACK - && sibling->right->color == BLACK) + && sibling->right->color == BLACK) { /* move red to sibling to rebalance */ if(sibling != RBTREE_NULL) @@ -515,7 +515,7 @@ rbtree_find_less_equal(rbtree_type *rbtree, const void *key, rbnode_type *node; log_assert(result); - + /* We start at root... */ node = rbtree->root; @@ -529,7 +529,7 @@ rbtree_find_less_equal(rbtree_type *rbtree, const void *key, /* Exact match */ *result = node; return 1; - } + } if (r < 0) { node = node->left; } else { @@ -606,7 +606,7 @@ rbtree_previous(rbnode_type *node) } /** recursive descent traverse */ -static void +static void traverse_post(void (*func)(rbnode_type*, void*), void* arg, rbnode_type* node) { if(!node || node == RBTREE_NULL) @@ -618,7 +618,7 @@ traverse_post(void (*func)(rbnode_type*, void*), void* arg, rbnode_type* node) (*func)(node, arg); } -void +void traverse_postorder(rbtree_type* tree, void (*func)(rbnode_type*, void*), void* arg) { diff --git a/sbin/unwind/libunbound/util/rbtree.h b/sbin/unwind/libunbound/util/rbtree.h index dfcf09ac6..2fcdf5746 100644 --- a/sbin/unwind/libunbound/util/rbtree.h +++ b/sbin/unwind/libunbound/util/rbtree.h @@ -2,24 +2,24 @@ * rbtree.h -- generic red-black tree * * Copyright (c) 2001-2007, NLnet Labs. All rights reserved. - * + * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -80,32 +80,32 @@ struct rbtree_type { /** The number of the nodes in the tree */ size_t count; - /** - * Key compare function. <0,0,>0 like strcmp. - * Return 0 on two NULL ptrs. + /** + * Key compare function. <0,0,>0 like strcmp. + * Return 0 on two NULL ptrs. */ int (*cmp) (const void *, const void *); }; -/** - * Create new tree (malloced) with given key compare function. +/** + * Create new tree (malloced) with given key compare function. * @param cmpf: compare function (like strcmp) takes pointers to two keys. * @return: new tree, empty. */ rbtree_type *rbtree_create(int (*cmpf)(const void *, const void *)); -/** - * Init a new tree (malloced by caller) with given key compare function. +/** + * Init a new tree (malloced by caller) with given key compare function. * @param rbtree: uninitialised memory for new tree, returned empty. * @param cmpf: compare function (like strcmp) takes pointers to two keys. */ void rbtree_init(rbtree_type *rbtree, int (*cmpf)(const void *, const void *)); -/** - * Insert data into the tree. +/** + * Insert data into the tree. * @param rbtree: tree to insert to. - * @param data: element to insert. - * @return: data ptr or NULL if key already present. + * @param data: element to insert. + * @return: data ptr or NULL if key already present. */ rbnode_type *rbtree_insert(rbtree_type *rbtree, rbnode_type *data); @@ -113,8 +113,8 @@ rbnode_type *rbtree_insert(rbtree_type *rbtree, rbnode_type *data); * Delete element from tree. * @param rbtree: tree to delete from. * @param key: key of item to delete. - * @return: node that is now unlinked from the tree. User to delete it. - * returns 0 if node not present + * @return: node that is now unlinked from the tree. User to delete it. + * returns 0 if node not present */ rbnode_type *rbtree_delete(rbtree_type *rbtree, const void *key); @@ -133,9 +133,9 @@ rbnode_type *rbtree_search(rbtree_type *rbtree, const void *key); * @param result: set to the exact node if present, otherwise to element that * precedes the position of key in the tree. NULL if no smaller element. * @return: true if exact match in result. Else result points to <= element, - * or NULL if key is smaller than the smallest key. + * or NULL if key is smaller than the smallest key. */ -int rbtree_find_less_equal(rbtree_type *rbtree, const void *key, +int rbtree_find_less_equal(rbtree_type *rbtree, const void *key, rbnode_type **result); /** @@ -168,7 +168,7 @@ rbnode_type *rbtree_previous(rbnode_type *rbtree); /** * Call with node=variable of struct* with rbnode_type as first element. - * with type is the type of a pointer to that struct. + * with type is the type of a pointer to that struct. */ #define RBTREE_FOR(node, type, rbtree) \ for(node=(type)rbtree_first(rbtree); \ diff --git a/sbin/unwind/libunbound/util/regional.c b/sbin/unwind/libunbound/util/regional.c index 44aee68b2..fb0c6fc30 100644 --- a/sbin/unwind/libunbound/util/regional.c +++ b/sbin/unwind/libunbound/util/regional.c @@ -4,24 +4,24 @@ * Copyright (c) 2001-2006, NLnet Labs. All rights reserved. * * Copyright (c) 2007, NLnet Labs. All rights reserved. - * + * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -62,7 +62,7 @@ #define REGIONAL_LARGE_OBJECT_SIZE 2048 #endif -struct regional* +struct regional* regional_create(void) { return regional_create_custom(REGIONAL_CHUNK_SIZE); @@ -115,7 +115,7 @@ regional_create_nochunk(size_t size) return regional_create_custom_large_object(size, 0); } -void +void regional_free_all(struct regional *r) { char* p = r->next, *np; @@ -133,7 +133,7 @@ regional_free_all(struct regional *r) regional_init(r); } -void +void regional_destroy(struct regional *r) { if(!r) return; @@ -236,7 +236,7 @@ count_large(struct regional* r) return c; } -void +void regional_log_stats(struct regional *r) { /* some basic assertions put here (non time critical code) */ @@ -249,9 +249,9 @@ regional_log_stats(struct regional *r) (unsigned)count_chunks(r), (unsigned)count_large(r)); } -size_t +size_t regional_get_mem(struct regional* r) { - return r->first_size + (count_chunks(r)-1)*REGIONAL_CHUNK_SIZE + return r->first_size + (count_chunks(r)-1)*REGIONAL_CHUNK_SIZE + r->total_large; } diff --git a/sbin/unwind/libunbound/util/regional.h b/sbin/unwind/libunbound/util/regional.h index b439897d5..90ad7ed46 100644 --- a/sbin/unwind/libunbound/util/regional.h +++ b/sbin/unwind/libunbound/util/regional.h @@ -2,24 +2,24 @@ * regional.h -- region based memory allocator. * * Copyright (c) 2007, NLnet Labs. All rights reserved. - * + * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -51,16 +51,16 @@ #ifndef UTIL_REGIONAL_H_ #define UTIL_REGIONAL_H_ -/** +/** * the regional* is the first block*. * every block has a ptr to the next in first bytes. * and so does the regional struct, which is the first block. */ struct regional { - /** - * next chunk. NULL if first chunk is the only chunk. - * first inside that chunk is the char* next pointer. + /** + * next chunk. NULL if first chunk is the only chunk. + * first inside that chunk is the char* next pointer. * When regional_free_all() has been called this value is NULL. */ char* next; @@ -101,7 +101,7 @@ struct regional* regional_create_custom(size_t size); * @return: newly allocated regional. */ struct regional* regional_create_nochunk(size_t size); - + /** * Free all memory associated with regional. Only keeps the first block with * the regional inside it. diff --git a/sbin/unwind/libunbound/util/rtt.c b/sbin/unwind/libunbound/util/rtt.c index b64206eca..34f9a8a27 100644 --- a/sbin/unwind/libunbound/util/rtt.c +++ b/sbin/unwind/libunbound/util/rtt.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -61,7 +61,7 @@ calc_rto(const struct rtt_info* rtt) return rto; } -void +void rtt_init(struct rtt_info* rtt) { rtt->srtt = 0; @@ -71,13 +71,13 @@ rtt_init(struct rtt_info* rtt) /* first RTO is 0 + 4*0.094 = 0.376 seconds */ } -int +int rtt_timeout(const struct rtt_info* rtt) { return rtt->rto; } -int +int rtt_unclamped(const struct rtt_info* rtt) { if(calc_rto(rtt) != rtt->rto) { @@ -88,7 +88,7 @@ rtt_unclamped(const struct rtt_info* rtt) return rtt->srtt + 4*rtt->rttvar; } -void +void rtt_update(struct rtt_info* rtt, int ms) { int delta = ms - rtt->srtt; @@ -99,7 +99,7 @@ rtt_update(struct rtt_info* rtt, int ms) rtt->rto = calc_rto(rtt); } -void +void rtt_lost(struct rtt_info* rtt, int orig) { /* exponential backoff */ diff --git a/sbin/unwind/libunbound/util/rtt.h b/sbin/unwind/libunbound/util/rtt.h index 63ed8eadb..5e283833a 100644 --- a/sbin/unwind/libunbound/util/rtt.h +++ b/sbin/unwind/libunbound/util/rtt.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -66,18 +66,18 @@ extern int RTT_MAX_TIMEOUT; */ void rtt_init(struct rtt_info* rtt); -/** +/** * Get timeout to use for sending a UDP packet. * @param rtt: round trip statistics structure. * @return: timeout to use in milliseconds. Relative time value. */ int rtt_timeout(const struct rtt_info* rtt); -/** +/** * Get unclamped timeout to use for server selection. * Recent timeouts are reflected in the returned value. * @param rtt: round trip statistics structure. - * @return: value to use in milliseconds. + * @return: value to use in milliseconds. */ int rtt_unclamped(const struct rtt_info* rtt); diff --git a/sbin/unwind/libunbound/util/storage/dnstree.c b/sbin/unwind/libunbound/util/storage/dnstree.c index eef393f91..44f2357da 100644 --- a/sbin/unwind/libunbound/util/storage/dnstree.c +++ b/sbin/unwind/libunbound/util/storage/dnstree.c @@ -4,22 +4,22 @@ * Copyright (c) 2008, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -94,7 +94,7 @@ void addr_tree_addrport_init(rbtree_type* tree) rbtree_init(tree, &addr_tree_addrport_compare); } -int name_tree_insert(rbtree_type* tree, struct name_tree_node* node, +int name_tree_insert(rbtree_type* tree, struct name_tree_node* node, uint8_t* name, size_t len, int labs, uint16_t dclass) { node->node.key = node; @@ -176,7 +176,7 @@ void name_tree_init_parents(rbtree_type* tree) } } -struct name_tree_node* name_tree_find(rbtree_type* tree, uint8_t* name, +struct name_tree_node* name_tree_find(rbtree_type* tree, uint8_t* name, size_t len, int labs, uint16_t dclass) { struct name_tree_node key; @@ -220,7 +220,7 @@ struct name_tree_node* name_tree_lookup(rbtree_type* tree, uint8_t* name, return result; } -struct addr_tree_node* addr_tree_lookup(rbtree_type* tree, +struct addr_tree_node* addr_tree_lookup(rbtree_type* tree, struct sockaddr_storage* addr, socklen_t addrlen) { rbnode_type* res = NULL; diff --git a/sbin/unwind/libunbound/util/storage/dnstree.h b/sbin/unwind/libunbound/util/storage/dnstree.h index 8aaa94098..5d58f2ca5 100644 --- a/sbin/unwind/libunbound/util/storage/dnstree.h +++ b/sbin/unwind/libunbound/util/storage/dnstree.h @@ -4,22 +4,22 @@ * Copyright (c) 2008, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -105,7 +105,7 @@ void name_tree_init(rbtree_type* tree); * @param dclass: class of name * @return false on error (duplicate element). */ -int name_tree_insert(rbtree_type* tree, struct name_tree_node* node, +int name_tree_insert(rbtree_type* tree, struct name_tree_node* node, uint8_t* name, size_t len, int labs, uint16_t dclass); /** @@ -124,7 +124,7 @@ void name_tree_init_parents(rbtree_type* tree); * @param dclass: class of name * @return node or NULL if not found. */ -struct name_tree_node* name_tree_find(rbtree_type* tree, uint8_t* name, +struct name_tree_node* name_tree_find(rbtree_type* tree, uint8_t* name, size_t len, int labs, uint16_t dclass); /** @@ -136,7 +136,7 @@ struct name_tree_node* name_tree_find(rbtree_type* tree, uint8_t* name, * @param dclass: class of name * @return closest enclosing node (could be equal) or NULL if not found. */ -struct name_tree_node* name_tree_lookup(rbtree_type* tree, uint8_t* name, +struct name_tree_node* name_tree_lookup(rbtree_type* tree, uint8_t* name, size_t len, int labs, uint16_t dclass); /** @@ -167,10 +167,10 @@ void addr_tree_addrport_init(rbtree_type* tree); * has allocated). * @param addr: to insert (copied). * @param addrlen: length of addr - * @param net: size of subnet. + * @param net: size of subnet. * @return false on error (duplicate element). */ -int addr_tree_insert(rbtree_type* tree, struct addr_tree_node* node, +int addr_tree_insert(rbtree_type* tree, struct addr_tree_node* node, struct sockaddr_storage* addr, socklen_t addrlen, int net); /** @@ -194,7 +194,7 @@ void addr_tree_init_parents_node(struct addr_tree_node* node); * @param addrlen: length of addr * @return closest enclosing node (could be equal) or NULL if not found. */ -struct addr_tree_node* addr_tree_lookup(rbtree_type* tree, +struct addr_tree_node* addr_tree_lookup(rbtree_type* tree, struct sockaddr_storage* addr, socklen_t addrlen); /** @@ -205,7 +205,7 @@ struct addr_tree_node* addr_tree_lookup(rbtree_type* tree, * @param net: size of subnet * @return addr tree element, or NULL if not found. */ -struct addr_tree_node* addr_tree_find(rbtree_type* tree, +struct addr_tree_node* addr_tree_find(rbtree_type* tree, struct sockaddr_storage* addr, socklen_t addrlen, int net); /** compare name tree nodes */ diff --git a/sbin/unwind/libunbound/util/storage/lookup3.c b/sbin/unwind/libunbound/util/storage/lookup3.c index c4026626c..4f14d683c 100644 --- a/sbin/unwind/libunbound/util/storage/lookup3.c +++ b/sbin/unwind/libunbound/util/storage/lookup3.c @@ -16,8 +16,8 @@ lookup3.c, by Bob Jenkins, May 2006, Public Domain. These are functions for producing 32-bit hashes for hash table lookup. -hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final() -are externally useful functions. Routines to test the hash are included +hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final() +are externally useful functions. Routines to test the hash are included if SELF_TEST is defined. You can use this free for any purpose. It's in the public domain. It has no warranty. @@ -25,7 +25,7 @@ You probably want to use hashlittle(). hashlittle() and hashbig() hash byte arrays. hashlittle() is is faster than hashbig() on little-endian machines. Intel and AMD are little-endian machines. On second thought, you probably want hashlittle2(), which is identical to -hashlittle() except it returns two 32-bit hashes for the price of one. +hashlittle() except it returns two 32-bit hashes for the price of one. You could implement hashbig2() if you wanted but I haven't bothered here. If you want to find a hash of, say, exactly 7 integers, do @@ -38,9 +38,9 @@ If you want to find a hash of, say, exactly 7 integers, do then use c as the hash value. If you have a variable length array of 4-byte integers to hash, use hashword(). If you have a byte array (like a character string), use hashlittle(). If you have several byte arrays, or -a mix of things, see the comments above hashlittle(). +a mix of things, see the comments above hashlittle(). -Why is this so big? I read 12 bytes at a time into 3 4-byte integers, +Why is this so big? I read 12 bytes at a time into 3 4-byte integers, then mix those integers. This is fast (you can do a lot more thorough mixing with 12*3 instructions on 3 integers than you can with 3 instructions on 1 byte), but shoehorning those bytes into integers efficiently is messy. @@ -144,7 +144,7 @@ This was tested for: the output delta to a Gray code (a^(a>>1)) so a string of 1's (as is commonly produced by subtraction) look like a single 1-bit difference. -* the base values were pseudorandom, all zero but one bit set, or +* the base values were pseudorandom, all zero but one bit set, or all zero plus a counter that starts at zero. Some k values for my "a-=c; a^=rot(c,k); c+=b;" arrangement that @@ -154,7 +154,7 @@ satisfy this are 14 9 3 7 17 3 Well, "9 15 3 18 27 15" didn't quite get 32 bits diffing for "differ" defined as + with a one-bit base and a two-bit delta. I -used http://burtleburtle.net/bob/hash/avalanche.html to choose +used http://burtleburtle.net/bob/hash/avalanche.html to choose the operations, constants, and arrangements of the variables. This does not achieve avalanche. There are input bits of (a,b,c) @@ -193,7 +193,7 @@ produce values of c that look totally different. This was tested for the output delta to a Gray code (a^(a>>1)) so a string of 1's (as is commonly produced by subtraction) look like a single 1-bit difference. -* the base values were pseudorandom, all zero but one bit set, or +* the base values were pseudorandom, all zero but one bit set, or all zero plus a counter that starts at zero. These constants passed: @@ -252,7 +252,7 @@ uint32_t initval) /* the previous hash, or an arbitrary value */ /*------------------------------------------- handle the last 3 uint32_t's */ switch(length) /* all the case statements fall through */ - { + { case 3 : c+=k[2]; /* fallthrough */ case 2 : b+=k[1]; @@ -273,7 +273,7 @@ uint32_t initval) /* the previous hash, or an arbitrary value */ -------------------------------------------------------------------- hashword2() -- same as hashword(), but take two seeds and return two 32-bit values. pc and pb must both be nonnull, and *pc and *pb must -both be initialized with seeds. If you pass in (*pb)==0, the output +both be initialized with seeds. If you pass in (*pb)==0, the output (*pc) will be the same as the return value from hashword(). -------------------------------------------------------------------- */ @@ -302,7 +302,7 @@ uint32_t *pb) /* IN: more seed OUT: secondary hash value */ /*------------------------------------------- handle the last 3 uint32_t's */ switch(length) /* all the case statements fall through */ - { + { case 3 : c+=k[2]; case 2 : b+=k[1]; case 1 : a+=k[0]; @@ -370,7 +370,7 @@ uint32_t hashlittle( const void *key, size_t length, uint32_t initval) } /*----------------------------- handle the last (probably partial) block */ - /* + /* * "k[2]&0xffffff" actually reads beyond the end of the string, but * then masks off the part it's not allowed to read. Because the * string is aligned, the masked-off tail is in the same word as the @@ -537,7 +537,7 @@ uint32_t hashlittle( const void *key, size_t length, uint32_t initval) * the key. *pc is better mixed than *pb, so use *pc first. If you want * a 64-bit value do something like "*pc + (((uint64_t)*pb)<<32)". */ -void hashlittle2( +void hashlittle2( const void *key, /* the key to hash */ size_t length, /* length of the key */ uint32_t *pc, /* IN: primary initval, OUT: primary hash */ @@ -569,7 +569,7 @@ void hashlittle2( } /*----------------------------- handle the last (probably partial) block */ - /* + /* * "k[2]&0xffffff" actually reads beyond the end of the string, but * then masks off the part it's not allowed to read. Because the * string is aligned, the masked-off tail is in the same word as the @@ -721,7 +721,7 @@ void hashlittle2( * hashbig(): * This is the same as hashword() on big-endian machines. It is different * from hashlittle() on all machines. hashbig() takes advantage of - * big-endian byte ordering. + * big-endian byte ordering. */ uint32_t hashbig( const void *key, size_t length, uint32_t initval) { @@ -750,7 +750,7 @@ uint32_t hashbig( const void *key, size_t length, uint32_t initval) } /*----------------------------- handle the last (probably partial) block */ - /* + /* * "k[2]<<8" actually reads beyond the end of the string, but * then shifts out the part it's not allowed to read. Because the * string is aligned, the illegal read is in the same word as the @@ -861,7 +861,7 @@ void driver1(void) time(&a); for (i=0; i<256; ++i) buf[i] = 'x'; - for (i=0; i<1; ++i) + for (i=0; i<1; ++i) { h = hashlittle(&buf[0],1,h); } @@ -897,7 +897,7 @@ void driver2(void) /*---- check that every output bit is affected by that input bit */ for (k=0; kz) z=k; - if (k==MAXPAIR) + if (k==MAXPAIR) { printf("Some bit didn't change: "); printf("%.8x %.8x %.8x %.8x %.8x %.8x ", @@ -1008,7 +1008,7 @@ void driver3(void) i=47, j=0; hashword2(&len, 1, &i, &j); if (hashword(&len, 1, 47) != i) - printf("hashword2 and hashword mismatch %x %x\n", + printf("hashword2 and hashword mismatch %x %x\n", i, hashword(&len, 1, 47)); /* check hashlittle doesn't read before or after the ends of the string */ @@ -1025,7 +1025,7 @@ void driver3(void) *(b-1)=(uint8_t)~0; x = hashlittle(b, len, (uint32_t)1); y = hashlittle(b, len, (uint32_t)1); - if ((ref != x) || (ref != y)) + if ((ref != x) || (ref != y)) { printf("alignment error: %.8x %.8x %.8x %d %d\n",ref,x,y, h, i); diff --git a/sbin/unwind/libunbound/util/storage/lookup3.h b/sbin/unwind/libunbound/util/storage/lookup3.h index 59dad7c48..ab6d990b6 100644 --- a/sbin/unwind/libunbound/util/storage/lookup3.h +++ b/sbin/unwind/libunbound/util/storage/lookup3.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR diff --git a/sbin/unwind/libunbound/util/storage/lruhash.c b/sbin/unwind/libunbound/util/storage/lruhash.c index e17b180db..63922455c 100644 --- a/sbin/unwind/libunbound/util/storage/lruhash.c +++ b/sbin/unwind/libunbound/util/storage/lruhash.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -53,18 +53,18 @@ bin_init(struct lruhash_bin* array, size_t size) #endif for(i=0; iarray, table->size); lock_protect(&table->lock, table, sizeof(*table)); - lock_protect(&table->lock, table->array, + lock_protect(&table->lock, table->array, table->size*sizeof(struct lruhash_bin)); return table; } -void +void bin_delete(struct lruhash* table, struct lruhash_bin* bin) { struct lruhash_entry* p, *np; @@ -114,8 +114,8 @@ bin_delete(struct lruhash* table, struct lruhash_bin* bin) } } -void -bin_split(struct lruhash* table, struct lruhash_bin* newa, +void +bin_split(struct lruhash* table, struct lruhash_bin* newa, int newmask) { size_t i; @@ -150,7 +150,7 @@ bin_split(struct lruhash* table, struct lruhash_bin* newa, } } -void +void lruhash_delete(struct lruhash* table) { size_t i; @@ -164,7 +164,7 @@ lruhash_delete(struct lruhash* table) free(table); } -void +void bin_overflow_remove(struct lruhash_bin* bin, struct lruhash_entry* entry) { struct lruhash_entry* p = bin->overflow_list; @@ -179,7 +179,7 @@ bin_overflow_remove(struct lruhash_bin* bin, struct lruhash_entry* entry) } } -void +void reclaim_space(struct lruhash* table, struct lruhash_entry** list) { struct lruhash_entry* d; @@ -189,8 +189,8 @@ reclaim_space(struct lruhash* table, struct lruhash_entry** list) while(table->num > 1 && table->space_used > table->space_max) { /* notice that since we hold the hashtable lock, nobody can change the lru chain. So it cannot be deleted underneath - us. We still need the hashbin and entry write lock to make - sure we flush all users away from the entry. + us. We still need the hashbin and entry write lock to make + sure we flush all users away from the entry. which is unlikely, since it is LRU, if someone got a rdlock it would be moved to front, but to be sure. */ d = table->lru_end; @@ -215,8 +215,8 @@ reclaim_space(struct lruhash* table, struct lruhash_entry** list) } } -struct lruhash_entry* -bin_find_entry(struct lruhash* table, +struct lruhash_entry* +bin_find_entry(struct lruhash* table, struct lruhash_bin* bin, hashvalue_type hash, void* key, size_t* collisions) { size_t c = 0; @@ -232,7 +232,7 @@ bin_find_entry(struct lruhash* table, return p; } -void +void table_grow(struct lruhash* table) { struct lruhash_bin* newa; @@ -258,16 +258,16 @@ table_grow(struct lruhash* table) lock_quick_destroy(&table->array[i].lock); } free(table->array); - + table->size *= 2; table->size_mask = newmask; table->array = newa; - lock_protect(&table->lock, table->array, + lock_protect(&table->lock, table->array, table->size*sizeof(struct lruhash_bin)); return; } -void +void lru_front(struct lruhash* table, struct lruhash_entry* entry) { entry->lru_prev = NULL; @@ -278,7 +278,7 @@ lru_front(struct lruhash* table, struct lruhash_entry* entry) table->lru_start = entry; } -void +void lru_remove(struct lruhash* table, struct lruhash_entry* entry) { if(entry->lru_prev) @@ -289,7 +289,7 @@ lru_remove(struct lruhash* table, struct lruhash_entry* entry) else table->lru_end = entry->lru_prev; } -void +void lru_touch(struct lruhash* table, struct lruhash_entry* entry) { log_assert(table && entry); @@ -301,7 +301,7 @@ lru_touch(struct lruhash* table, struct lruhash_entry* entry) lru_front(table, entry); } -void +void lruhash_insert(struct lruhash* table, hashvalue_type hash, struct lruhash_entry* entry, void* data, void* cb_arg) { @@ -360,7 +360,7 @@ lruhash_insert(struct lruhash* table, hashvalue_type hash, } } -struct lruhash_entry* +struct lruhash_entry* lruhash_lookup(struct lruhash* table, hashvalue_type hash, void* key, int wr) { struct lruhash_entry* entry; @@ -382,7 +382,7 @@ lruhash_lookup(struct lruhash* table, hashvalue_type hash, void* key, int wr) return entry; } -void +void lruhash_remove(struct lruhash* table, hashvalue_type hash, void* key) { struct lruhash_entry* entry; @@ -406,7 +406,7 @@ lruhash_remove(struct lruhash* table, hashvalue_type hash, void* key) return; } table->num--; - table->space_used -= (*table->sizefunc)(entry->key, entry->data); + table->space_used -= (*table->sizefunc)(entry->key, entry->data); lock_rw_wrlock(&entry->lock); if(table->markdelfunc) (*table->markdelfunc)(entry->key); @@ -426,7 +426,7 @@ bin_clear(struct lruhash* table, struct lruhash_bin* bin) struct lruhash_entry* p, *np; void *d; lock_quick_lock(&bin->lock); - p = bin->overflow_list; + p = bin->overflow_list; while(p) { lock_rw_wrlock(&p->lock); np = p->overflow_next; @@ -463,7 +463,7 @@ lruhash_clear(struct lruhash* table) lock_quick_unlock(&table->lock); } -void +void lruhash_status(struct lruhash* table, const char* id, int extended) { lock_quick_lock(&table->lock); @@ -491,7 +491,7 @@ lruhash_status(struct lruhash* table, const char* id, int extended) if(here > max) max = here; if(here < min) min = here; } - log_info(" bin min %d, avg %.2lf, max %d", min, + log_info(" bin min %d, avg %.2lf, max %d", min, (double)table->num/(double)table->size, max); } lock_quick_unlock(&table->lock); @@ -507,12 +507,12 @@ lruhash_get_mem(struct lruhash* table) if(table->size != 0) { size_t i; for(i=0; isize; i++) - s += sizeof(struct lruhash_bin) + + s += sizeof(struct lruhash_bin) + lock_get_mem(&table->array[i].lock); } #else /* no THREAD_DEBUG */ if(table->size != 0) - s += (table->size)*(sizeof(struct lruhash_bin) + + s += (table->size)*(sizeof(struct lruhash_bin) + lock_get_mem(&table->array[0].lock)); #endif lock_quick_unlock(&table->lock); @@ -520,7 +520,7 @@ lruhash_get_mem(struct lruhash* table) return s; } -void +void lruhash_setmarkdel(struct lruhash* table, lruhash_markdelfunc_type md) { lock_quick_lock(&table->lock); @@ -528,8 +528,8 @@ lruhash_setmarkdel(struct lruhash* table, lruhash_markdelfunc_type md) lock_quick_unlock(&table->lock); } -void -lruhash_traverse(struct lruhash* h, int wr, +void +lruhash_traverse(struct lruhash* h, int wr, void (*func)(struct lruhash_entry*, void*), void* arg) { size_t i; diff --git a/sbin/unwind/libunbound/util/storage/lruhash.h b/sbin/unwind/libunbound/util/storage/lruhash.h index 2086e4dec..4457c4f81 100644 --- a/sbin/unwind/libunbound/util/storage/lruhash.h +++ b/sbin/unwind/libunbound/util/storage/lruhash.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -89,7 +89,7 @@ * the hashbinlock. The next thread that comes in and needs the same * hashbin will wait for the lock while holding the hashtable lock. * thus halting the entire system on hashtable. - * This is because of the delete protection. + * This is because of the delete protection. * Readlocks will be easier on the rwlock on entries. * While the writer is holding writelock, similar problems happen with * a reader or writer needing the same item. @@ -118,9 +118,9 @@ struct lruhash_entry; /** the type of a hash value */ typedef uint32_t hashvalue_type; -/** +/** * Type of function that calculates the size of an entry. - * Result must include the size of struct lruhash_entry. + * Result must include the size of struct lruhash_entry. * Keys that are identical must also calculate to the same size. * size = func(key, data). */ @@ -129,7 +129,7 @@ typedef size_t (*lruhash_sizefunc_type)(void*, void*); /** type of function that compares two keys. return 0 if equal. */ typedef int (*lruhash_compfunc_type)(void*, void*); -/** old keys are deleted. +/** old keys are deleted. * The RRset type has to revoke its ID number, markdel() is used first. * This function is called: func(key, userarg) */ typedef void (*lruhash_delkeyfunc_type)(void*, void*); @@ -137,7 +137,7 @@ typedef void (*lruhash_delkeyfunc_type)(void*, void*); /** old data is deleted. This function is called: func(data, userarg). */ typedef void (*lruhash_deldatafunc_type)(void*, void*); -/** mark a key as pending to be deleted (and not to be used by anyone). +/** mark a key as pending to be deleted (and not to be used by anyone). * called: func(key) */ typedef void (*lruhash_markdelfunc_type)(void*); @@ -186,7 +186,7 @@ struct lruhash { * A single bin with a linked list of entries in it. */ struct lruhash_bin { - /** + /** * Lock for exclusive access to the linked list * This lock makes deletion of items safe in this overflow list. */ @@ -203,7 +203,7 @@ struct lruhash_bin { * to get the surrounding structure. Data should be allocated on its own. */ struct lruhash_entry { - /** + /** * rwlock for access to the contents of the entry * Note that it does _not_ cover the lru_ and overflow_ ptrs. * Even with a writelock, you cannot change hash and key. @@ -233,7 +233,7 @@ struct lruhash_entry { * @param delkeyfunc: deletes key. * Calling both delkey and deldata will also free the struct lruhash_entry. * Make it part of the key structure and delete it in delkeyfunc. - * @param deldatafunc: deletes data. + * @param deldatafunc: deletes data. * @param arg: user argument that is passed to user function calls. * @return: new hash table or NULL on malloc failure. */ @@ -249,14 +249,14 @@ struct lruhash* lruhash_create(size_t start_size, size_t maxmem, void lruhash_delete(struct lruhash* table); /** - * Clear hash table. Entries are all deleted, while locking them before + * Clear hash table. Entries are all deleted, while locking them before * doing so. At end the table is empty. * @param table: to make empty. */ void lruhash_clear(struct lruhash* table); /** - * Insert a new element into the hashtable. + * Insert a new element into the hashtable. * If key is already present data pointer in that entry is updated. * The space calculation function is called with the key, data. * If necessary the least recently used entries are deleted to make space. @@ -271,7 +271,7 @@ void lruhash_clear(struct lruhash* table); * @param data: the data. * @param cb_override: if not null overrides the cb_arg for the deletefunc. */ -void lruhash_insert(struct lruhash* table, hashvalue_type hash, +void lruhash_insert(struct lruhash* table, hashvalue_type hash, struct lruhash_entry* entry, void* data, void* cb_override); /** @@ -319,7 +319,7 @@ void lru_demote(struct lruhash* table, struct lruhash_entry* entry); * element of it exits. * * If key is already present data pointer in that entry is kept. - * If it is not present, a new entry is created. In that case, + * If it is not present, a new entry is created. In that case, * the space calculation function is called with the key, data. * If necessary the least recently used entries are deleted to make space. * If necessary the hash array is grown up. @@ -343,7 +343,7 @@ struct lruhash_entry* lruhash_insert_or_retrieve(struct lruhash* table, hashvalu * Delfunc is called for the entry. * @param table: hash table. * @param hash: hash of key. - * @param key: what to look for. + * @param key: what to look for. */ void lruhash_remove(struct lruhash* table, hashvalue_type hash, void* key); @@ -353,7 +353,7 @@ void bin_init(struct lruhash_bin* array, size_t size); /** delete the hash bin and entries inside it */ void bin_delete(struct lruhash* table, struct lruhash_bin* bin); -/** +/** * Find entry in hash bin. You must have locked the bin. * @param table: hash table with function pointers. * @param bin: hash bin to look into. @@ -362,7 +362,7 @@ void bin_delete(struct lruhash* table, struct lruhash_bin* bin); * @param collisions: how many collisions were found during the search. * @return: the entry or NULL if not found. */ -struct lruhash_entry* bin_find_entry(struct lruhash* table, +struct lruhash_entry* bin_find_entry(struct lruhash* table, struct lruhash_bin* bin, hashvalue_type hash, void* key, size_t* collisions); /** @@ -371,7 +371,7 @@ struct lruhash_entry* bin_find_entry(struct lruhash* table, * @param bin: hash bin to look into. * @param entry: entry ptr that needs removal. */ -void bin_overflow_remove(struct lruhash_bin* bin, +void bin_overflow_remove(struct lruhash_bin* bin, struct lruhash_entry* entry); /** @@ -384,10 +384,10 @@ void bin_overflow_remove(struct lruhash_bin* bin, * @param newa: new increased array. * @param newmask: new lookup mask. */ -void bin_split(struct lruhash* table, struct lruhash_bin* newa, +void bin_split(struct lruhash* table, struct lruhash_bin* newa, int newmask); -/** +/** * Try to make space available by deleting old entries. * Assumes that the lock on the hashtable is being held by caller. * Caller must not hold bin locks. diff --git a/sbin/unwind/libunbound/util/storage/slabhash.c b/sbin/unwind/libunbound/util/storage/slabhash.c index 7d376c4d6..7c8e4e84e 100644 --- a/sbin/unwind/libunbound/util/storage/slabhash.c +++ b/sbin/unwind/libunbound/util/storage/slabhash.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -45,13 +45,13 @@ #include "config.h" #include "util/storage/slabhash.h" -struct slabhash* slabhash_create(size_t numtables, size_t start_size, - size_t maxmem, lruhash_sizefunc_type sizefunc, - lruhash_compfunc_type compfunc, lruhash_delkeyfunc_type delkeyfunc, +struct slabhash* slabhash_create(size_t numtables, size_t start_size, + size_t maxmem, lruhash_sizefunc_type sizefunc, + lruhash_compfunc_type compfunc, lruhash_delkeyfunc_type delkeyfunc, lruhash_deldatafunc_type deldatafunc, void* arg) { size_t i; - struct slabhash* sl = (struct slabhash*)calloc(1, + struct slabhash* sl = (struct slabhash*)calloc(1, sizeof(struct slabhash)); if(!sl) return NULL; sl->size = numtables; @@ -65,7 +65,7 @@ struct slabhash* slabhash_create(size_t numtables, size_t start_size, if(sl->mask == 0) { sl->shift = 0; } else { - log_assert( (sl->size & sl->mask) == 0 + log_assert( (sl->size & sl->mask) == 0 /* size must be power of 2 */ ); sl->shift = 0; while(!(sl->mask & 0x80000000)) { @@ -113,13 +113,13 @@ slab_idx(struct slabhash* sl, hashvalue_type hash) return ((hash & sl->mask) >> sl->shift); } -void slabhash_insert(struct slabhash* sl, hashvalue_type hash, +void slabhash_insert(struct slabhash* sl, hashvalue_type hash, struct lruhash_entry* entry, void* data, void* arg) { lruhash_insert(sl->array[slab_idx(sl, hash)], hash, entry, data, arg); } -struct lruhash_entry* slabhash_lookup(struct slabhash* sl, +struct lruhash_entry* slabhash_lookup(struct slabhash* sl, hashvalue_type hash, void* key, int wr) { return lruhash_lookup(sl->array[slab_idx(sl, hash)], hash, key, wr); @@ -134,7 +134,7 @@ void slabhash_status(struct slabhash* sl, const char* id, int extended) { size_t i; char num[17]; - log_info("Slabhash %s: %u tables mask=%x shift=%d", + log_info("Slabhash %s: %u tables mask=%x shift=%d", id, (unsigned)sl->size, (unsigned)sl->mask, sl->shift); for(i=0; isize; i++) { snprintf(num, sizeof(num), "table %u", (unsigned)i); @@ -167,7 +167,7 @@ int slabhash_is_size(struct slabhash* sl, size_t size, size_t slabs) } size_t slabhash_get_mem(struct slabhash* sl) -{ +{ size_t i, total = sizeof(*sl); total += sizeof(struct lruhash*)*sl->size; for(i=0; isize; i++) { @@ -190,7 +190,7 @@ static void deldata(struct slabhash_testdata* d) {free(d);} size_t test_slabhash_sizefunc(void* ATTR_UNUSED(key), void* ATTR_UNUSED(data)) { - return sizeof(struct slabhash_testkey) + + return sizeof(struct slabhash_testkey) + sizeof(struct slabhash_testdata); } diff --git a/sbin/unwind/libunbound/util/storage/slabhash.h b/sbin/unwind/libunbound/util/storage/slabhash.h index dc5fc3603..85872ab30 100644 --- a/sbin/unwind/libunbound/util/storage/slabhash.h +++ b/sbin/unwind/libunbound/util/storage/slabhash.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -49,7 +49,7 @@ #define HASH_DEFAULT_SLABS 4 /** - * Hash table formed from several smaller ones. + * Hash table formed from several smaller ones. * This results in a partitioned lruhash table, a 'slashtable'. * None of the data inside the slabhash may be altered. * Therefore, no locks are needed to access the structure. @@ -75,13 +75,13 @@ struct slabhash { * @param sizefunc: calculates memory usage of entries. * @param compfunc: compares entries, 0 on equality. * @param delkeyfunc: deletes key. - * @param deldatafunc: deletes data. + * @param deldatafunc: deletes data. * @param arg: user argument that is passed to user function calls. * @return: new hash table or NULL on malloc failure. */ -struct slabhash* slabhash_create(size_t numtables, size_t start_size, - size_t maxmem, lruhash_sizefunc_type sizefunc, - lruhash_compfunc_type compfunc, lruhash_delkeyfunc_type delkeyfunc, +struct slabhash* slabhash_create(size_t numtables, size_t start_size, + size_t maxmem, lruhash_sizefunc_type sizefunc, + lruhash_compfunc_type compfunc, lruhash_delkeyfunc_type delkeyfunc, lruhash_deldatafunc_type deldatafunc, void* arg); /** @@ -97,7 +97,7 @@ void slabhash_delete(struct slabhash* table); void slabhash_clear(struct slabhash* table); /** - * Insert a new element into the hashtable, uses lruhash_insert. + * Insert a new element into the hashtable, uses lruhash_insert. * If key is already present data pointer in that entry is updated. * * @param table: hash table. @@ -109,7 +109,7 @@ void slabhash_clear(struct slabhash* table); * @param data: the data. * @param cb_override: if not NULL overrides the cb_arg for deletefunc. */ -void slabhash_insert(struct slabhash* table, hashvalue_type hash, +void slabhash_insert(struct slabhash* table, hashvalue_type hash, struct lruhash_entry* entry, void* data, void* cb_override); /** @@ -125,7 +125,7 @@ void slabhash_insert(struct slabhash* table, hashvalue_type hash, * @return: pointer to the entry or NULL. The entry is locked. * The user must unlock the entry when done. */ -struct lruhash_entry* slabhash_lookup(struct slabhash* table, +struct lruhash_entry* slabhash_lookup(struct slabhash* table, hashvalue_type hash, void* key, int wr); /** @@ -133,7 +133,7 @@ struct lruhash_entry* slabhash_lookup(struct slabhash* table, * Delfunc is called for the entry. Uses lruhash_remove. * @param table: hash table. * @param hash: hash of key. - * @param key: what to look for. + * @param key: what to look for. */ void slabhash_remove(struct slabhash* table, hashvalue_type hash, void* key); diff --git a/sbin/unwind/libunbound/util/tcp_conn_limit.c b/sbin/unwind/libunbound/util/tcp_conn_limit.c index d7d86a540..d46aef572 100644 --- a/sbin/unwind/libunbound/util/tcp_conn_limit.c +++ b/sbin/unwind/libunbound/util/tcp_conn_limit.c @@ -4,22 +4,22 @@ * Copyright (c) 2018, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR diff --git a/sbin/unwind/libunbound/util/timehist.h b/sbin/unwind/libunbound/util/timehist.h index 5f88a38a9..084ea9c6f 100644 --- a/sbin/unwind/libunbound/util/timehist.h +++ b/sbin/unwind/libunbound/util/timehist.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -67,7 +67,7 @@ struct timehist { struct th_buck* buckets; }; -/** +/** * Setup a histogram, default * @return histogram or NULL on malloc failure. */ @@ -94,7 +94,7 @@ void timehist_insert(struct timehist* hist, struct timeval* tv); /** * Find time value for given quartile, such as 0.25, 0.50, 0.75. - * The looks up the value for the i-th element in the sorted list of time + * The looks up the value for the i-th element in the sorted list of time * values, as approximated using the histogram. * @param hist: histogram. Interpolated information is used from it. * @param q: quartile, 0.50 results in the median. Must be >0 and <1. diff --git a/sbin/unwind/libunbound/util/tube.c b/sbin/unwind/libunbound/util/tube.c index 7d98b93c3..68ef4b9db 100644 --- a/sbin/unwind/libunbound/util/tube.c +++ b/sbin/unwind/libunbound/util/tube.c @@ -4,22 +4,22 @@ * Copyright (c) 2008, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -54,7 +54,7 @@ #ifndef HAVE_SOCKETPAIR /** no socketpair() available, like on Minix 3.1.7, use pipe */ -#define socketpair(f, t, p, sv) pipe(sv) +#define socketpair(f, t, p, sv) pipe(sv) #endif /* HAVE_SOCKETPAIR */ struct tube* tube_create(void) @@ -165,7 +165,7 @@ tube_handle_listen(struct comm_point* c, void* arg, int error, /* error has happened or */ /* parent closed pipe, must have exited somehow */ fptr_ok(fptr_whitelist_tube_listen(tube->listen_cb)); - (*tube->listen_cb)(tube, NULL, 0, NETEVENT_CLOSED, + (*tube->listen_cb)(tube, NULL, 0, NETEVENT_CLOSED, tube->listen_arg); return 0; } @@ -195,7 +195,7 @@ tube_handle_listen(struct comm_point* c, void* arg, int error, /* error has happened or */ /* parent closed pipe, must have exited somehow */ fptr_ok(fptr_whitelist_tube_listen(tube->listen_cb)); - (*tube->listen_cb)(tube, NULL, 0, NETEVENT_CLOSED, + (*tube->listen_cb)(tube, NULL, 0, NETEVENT_CLOSED, tube->listen_arg); return 0; } @@ -214,7 +214,7 @@ tube_handle_listen(struct comm_point* c, void* arg, int error, tube->cmd_read = 0; fptr_ok(fptr_whitelist_tube_listen(tube->listen_cb)); - (*tube->listen_cb)(tube, tube->cmd_msg, tube->cmd_len, + (*tube->listen_cb)(tube, tube->cmd_msg, tube->cmd_len, NETEVENT_NOERROR, tube->listen_arg); /* also frees the buf */ tube->cmd_msg = NULL; @@ -285,7 +285,7 @@ tube_handle_write(struct comm_point* c, void* arg, int error, return 0; } -int tube_write_msg(struct tube* tube, uint8_t* buf, uint32_t len, +int tube_write_msg(struct tube* tube, uint8_t* buf, uint32_t len, int nonblock) { ssize_t r, d; @@ -331,7 +331,7 @@ int tube_write_msg(struct tube* tube, uint8_t* buf, uint32_t len, return 1; } -int tube_read_msg(struct tube* tube, uint8_t** buf, uint32_t* len, +int tube_read_msg(struct tube* tube, uint8_t** buf, uint32_t* len, int nonblock) { ssize_t r, d; @@ -470,7 +470,7 @@ int tube_setup_bg_listen(struct tube* tube, struct comm_base* base, { tube->listen_cb = cb; tube->listen_arg = arg; - if(!(tube->listen_com = comm_point_create_raw(base, tube->sr, + if(!(tube->listen_com = comm_point_create_raw(base, tube->sr, 0, tube_handle_listen, tube))) { int err = errno; log_err("tube_setup_bg_l: commpoint creation failed"); @@ -482,7 +482,7 @@ int tube_setup_bg_listen(struct tube* tube, struct comm_base* base, int tube_setup_bg_write(struct tube* tube, struct comm_base* base) { - if(!(tube->res_com = comm_point_create_raw(base, tube->sw, + if(!(tube->res_com = comm_point_create_raw(base, tube->sw, 1, tube_handle_write, tube))) { int err = errno; log_err("tube_setup_bg_w: commpoint creation failed"); @@ -517,7 +517,7 @@ int tube_queue_item(struct tube* tube, uint8_t* msg, size_t len) return 1; } -void tube_handle_signal(int ATTR_UNUSED(fd), short ATTR_UNUSED(events), +void tube_handle_signal(int ATTR_UNUSED(fd), short ATTR_UNUSED(events), void* ATTR_UNUSED(arg)) { log_assert(0); @@ -603,7 +603,7 @@ void tube_remove_bg_write(struct tube* tube) } } -int tube_write_msg(struct tube* tube, uint8_t* buf, uint32_t len, +int tube_write_msg(struct tube* tube, uint8_t* buf, uint32_t len, int ATTR_UNUSED(nonblock)) { uint8_t* a; @@ -617,7 +617,7 @@ int tube_write_msg(struct tube* tube, uint8_t* buf, uint32_t len, return tube_queue_item(tube, a, len); } -int tube_read_msg(struct tube* tube, uint8_t** buf, uint32_t* len, +int tube_read_msg(struct tube* tube, uint8_t** buf, uint32_t* len, int nonblock) { struct tube_res_list* item = NULL; @@ -640,7 +640,7 @@ int tube_read_msg(struct tube* tube, uint8_t** buf, uint32_t* len, tube->res_last = NULL; verbose(VERB_ALGO, "tube read_msg lastdata"); if(!WSAResetEvent(tube->event)) { - log_err("WSAResetEvent: %s", + log_err("WSAResetEvent: %s", wsa_strerror(WSAGetLastError())); } } @@ -670,9 +670,9 @@ int tube_wait(struct tube* tube) { /* block on eventhandle */ DWORD res = WSAWaitForMultipleEvents( - 1 /* one event in array */, - &tube->event /* the event to wait for, our pipe signal */, - 0 /* wait for all events is false */, + 1 /* one event in array */, + &tube->event /* the event to wait for, our pipe signal */, + 0 /* wait for all events is false */, WSA_INFINITE /* wait, no timeout */, 0 /* we are not alertable for IO completion routines */ ); @@ -713,7 +713,7 @@ int tube_read_fd(struct tube* ATTR_UNUSED(tube)) } int -tube_handle_listen(struct comm_point* ATTR_UNUSED(c), void* ATTR_UNUSED(arg), +tube_handle_listen(struct comm_point* ATTR_UNUSED(c), void* ATTR_UNUSED(arg), int ATTR_UNUSED(error), struct comm_reply* ATTR_UNUSED(reply_info)) { log_assert(0); @@ -721,7 +721,7 @@ tube_handle_listen(struct comm_point* ATTR_UNUSED(c), void* ATTR_UNUSED(arg), } int -tube_handle_write(struct comm_point* ATTR_UNUSED(c), void* ATTR_UNUSED(arg), +tube_handle_write(struct comm_point* ATTR_UNUSED(c), void* ATTR_UNUSED(arg), int ATTR_UNUSED(error), struct comm_reply* ATTR_UNUSED(reply_info)) { log_assert(0); @@ -740,7 +740,7 @@ int tube_setup_bg_listen(struct tube* tube, struct comm_base* base, return tube->ev_listen ? 1 : 0; } -int tube_setup_bg_write(struct tube* ATTR_UNUSED(tube), +int tube_setup_bg_write(struct tube* ATTR_UNUSED(tube), struct comm_base* ATTR_UNUSED(base)) { /* the queue item routine performs the signaling */ @@ -775,7 +775,7 @@ int tube_queue_item(struct tube* tube, uint8_t* msg, size_t len) return 1; } -void tube_handle_signal(int ATTR_UNUSED(fd), short ATTR_UNUSED(events), +void tube_handle_signal(int ATTR_UNUSED(fd), short ATTR_UNUSED(events), void* arg) { struct tube* tube = (struct tube*)arg; @@ -785,7 +785,7 @@ void tube_handle_signal(int ATTR_UNUSED(fd), short ATTR_UNUSED(events), while(tube_poll(tube)) { if(tube_read_msg(tube, &buf, &len, 1)) { fptr_ok(fptr_whitelist_tube_listen(tube->listen_cb)); - (*tube->listen_cb)(tube, buf, len, NETEVENT_NOERROR, + (*tube->listen_cb)(tube, buf, len, NETEVENT_NOERROR, tube->listen_arg); } } diff --git a/sbin/unwind/libunbound/util/tube.h b/sbin/unwind/libunbound/util/tube.h index 5e4fb8644..3abf18c43 100644 --- a/sbin/unwind/libunbound/util/tube.h +++ b/sbin/unwind/libunbound/util/tube.h @@ -4,22 +4,22 @@ * Copyright (c) 2008, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -150,7 +150,7 @@ void tube_delete(struct tube* tube); * unknown. * return 1 if all OK. */ -int tube_write_msg(struct tube* tube, uint8_t* buf, uint32_t len, +int tube_write_msg(struct tube* tube, uint8_t* buf, uint32_t len, int nonblock); /** @@ -166,11 +166,11 @@ int tube_write_msg(struct tube* tube, uint8_t* buf, uint32_t len, * If the first read fails the function returns -1. * If set false, the first read is blocking. * @return: all remainder reads are nonblocking. - * return 0 on error, in that case blocking/nonblocking of socket is + * return 0 on error, in that case blocking/nonblocking of socket is * unknown. On EOF 0 is returned. * return 1 if all OK. */ -int tube_read_msg(struct tube* tube, uint8_t** buf, uint32_t* len, +int tube_read_msg(struct tube* tube, uint8_t** buf, uint32_t* len, int nonblock); /** @@ -267,11 +267,11 @@ void tube_remove_bg_write(struct tube* tube); int tube_queue_item(struct tube* tube, uint8_t* msg, size_t len); /** for fptr wlist, callback function */ -int tube_handle_listen(struct comm_point* c, void* arg, int error, +int tube_handle_listen(struct comm_point* c, void* arg, int error, struct comm_reply* reply_info); /** for fptr wlist, callback function */ -int tube_handle_write(struct comm_point* c, void* arg, int error, +int tube_handle_write(struct comm_point* c, void* arg, int error, struct comm_reply* reply_info); /** for fptr wlist, winsock signal event callback function */ diff --git a/sbin/unwind/libunbound/util/ub_event.h b/sbin/unwind/libunbound/util/ub_event.h index b00a9bf6c..1313d9027 100644 --- a/sbin/unwind/libunbound/util/ub_event.h +++ b/sbin/unwind/libunbound/util/ub_event.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -60,14 +60,14 @@ struct event_base; #define UB_EV_PERSIST 0x10 /** Returns event-base type. Could be "mini-event", "winsock-event" for the - * daemon compile, and will be "pluggable-event" for + * daemon compile, and will be "pluggable-event" for * libunbound. */ const char* ub_event_get_version(void); /** Return the name, system and method for the pluggable event base */ void ub_get_event_sys(struct ub_event_base*, const char** n, const char** s, const char** m); -/** Return a default event base. In the daemon this will be the only event +/** Return a default event base. In the daemon this will be the only event * bases used. */ struct ub_event_base* ub_default_event_base(int, time_t*, struct timeval*); diff --git a/sbin/unwind/libunbound/util/ub_event_pluggable.c b/sbin/unwind/libunbound/util/ub_event_pluggable.c index 4280d4db1..74435a677 100644 --- a/sbin/unwind/libunbound/util/ub_event_pluggable.c +++ b/sbin/unwind/libunbound/util/ub_event_pluggable.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -252,7 +252,7 @@ my_event_base_free(struct ub_event_base* base) #ifdef USE_MINI_EVENT event_base_free(AS_MY_EVENT_BASE(base)->base); #elif defined(HAVE_EVENT_BASE_FREE) && defined(HAVE_EVENT_BASE_ONCE) - /* only libevent 1.2+ has it, but in 1.2 it is broken - + /* only libevent 1.2+ has it, but in 1.2 it is broken - assertion fails on signal handling ev that is not deleted in libevent 1.3c (event_base_once appears) this is fixed. */ event_base_free(AS_MY_EVENT_BASE(base)->base); diff --git a/sbin/unwind/libunbound/util/winsock_event.c b/sbin/unwind/libunbound/util/winsock_event.c index de6c28ecb..691cc23e3 100644 --- a/sbin/unwind/libunbound/util/winsock_event.c +++ b/sbin/unwind/libunbound/util/winsock_event.c @@ -1,25 +1,25 @@ /* - * util/winsock_event.c - implementation of the unbound winsock event handler. + * util/winsock_event.c - implementation of the unbound winsock event handler. * * Copyright (c) 2008, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -125,7 +125,7 @@ void *event_init(time_t* time_secs, struct timeval* time_tv) event_base_free(base); return NULL; } - base->items = (struct event**)calloc(WSK_MAX_ITEMS, + base->items = (struct event**)calloc(WSK_MAX_ITEMS, sizeof(struct event*)); if(!base->items) { event_base_free(base); @@ -229,7 +229,7 @@ static void handle_signal(struct event* ev) /** call select and callbacks for that */ static int handle_select(struct event_base* base, struct timeval* wait) { - DWORD timeout = 0; /* in milliseconds */ + DWORD timeout = 0; /* in milliseconds */ DWORD ret; struct event* eventlist[WSK_MAX_ITEMS]; WSANETWORKEVENTS netev; @@ -282,7 +282,7 @@ static int handle_select(struct event_base* base, struct timeval* wait) log_err("WSAWaitForMultipleEvents failed: WSA_WAIT_IO_COMPLETION"); return -1; } else if(ret == WSA_WAIT_FAILED) { - log_err("WSAWaitForMultipleEvents failed: %s", + log_err("WSAWaitForMultipleEvents failed: %s", wsa_strerror(WSAGetLastError())); return -1; } else if(ret == WSA_WAIT_TIMEOUT) { @@ -290,7 +290,7 @@ static int handle_select(struct event_base* base, struct timeval* wait) } else startidx = ret - WSA_WAIT_EVENT_0; } - verbose(VERB_CLIENT, "winsock_event wake was_timeout=%d startidx=%d", + verbose(VERB_CLIENT, "winsock_event wake was_timeout=%d startidx=%d", was_timeout, startidx); /* get new time after wait */ @@ -330,11 +330,11 @@ static int handle_select(struct event_base* base, struct timeval* wait) continue; /* not a network event at all */ eventlist[i]->just_checked = 0; - if(WSAEnumNetworkEvents(eventlist[i]->ev_fd, + if(WSAEnumNetworkEvents(eventlist[i]->ev_fd, base->waitfor[i], /* reset the event handle */ /*NULL,*/ /* do not reset the event handle */ &netev) != 0) { - log_err("WSAEnumNetworkEvents failed: %s", + log_err("WSAEnumNetworkEvents failed: %s", wsa_strerror(WSAGetLastError())); return -1; } @@ -402,11 +402,11 @@ static int handle_select(struct event_base* base, struct timeval* wait) (bits&EV_READ)?" EV_READ":"", (bits&EV_WRITE)?" EV_WRITE":"", (bits&EV_TIMEOUT)?" EV_TIMEOUT":""); - + fptr_ok(fptr_whitelist_event( eventlist[i]->ev_callback)); (*eventlist[i]->ev_callback)(eventlist[i]->ev_fd, - bits & eventlist[i]->ev_events, + bits & eventlist[i]->ev_events, eventlist[i]->ev_arg); } if(eventlist[i]->is_tcp && bits) @@ -447,7 +447,7 @@ int event_base_dispatch(struct event_base *base) return 0; } -int event_base_loopexit(struct event_base *base, +int event_base_loopexit(struct event_base *base, struct timeval * ATTR_UNUSED(tv)) { verbose(VERB_CLIENT, "winsock_event loopexit"); @@ -466,7 +466,7 @@ void event_base_free(struct event_base *base) free(base); } -void event_set(struct event *ev, int fd, short bits, +void event_set(struct event *ev, int fd, short bits, void (*cb)(int, short, void *), void *arg) { ev->node.key = ev; @@ -490,8 +490,8 @@ int event_base_set(struct event_base *base, struct event *ev) int event_add(struct event *ev, struct timeval *tv) { - verbose(VERB_ALGO, "event_add %p added=%d fd=%d tv=" ARG_LL "d %s%s%s", - ev, ev->added, ev->ev_fd, + verbose(VERB_ALGO, "event_add %p added=%d fd=%d tv=" ARG_LL "d %s%s%s", + ev, ev->added, ev->ev_fd, (tv?(long long)tv->tv_sec*1000+(long long)tv->tv_usec/1000:-1), (ev->ev_events&EV_READ)?" EV_READ":"", (ev->ev_events&EV_WRITE)?" EV_WRITE":"", @@ -546,7 +546,7 @@ int event_add(struct event *ev, struct timeval *tv) log_err("WSAEventSelect failed: %s", wsa_strerror(WSAGetLastError())); } - if(ev->is_tcp && ev->stick_events && + if(ev->is_tcp && ev->stick_events && (ev->ev_events & ev->old_events)) { /* go to processing the sticky event right away */ ev->ev_base->tcp_reinvigorated = 1; @@ -571,8 +571,8 @@ int event_add(struct event *ev, struct timeval *tv) int event_del(struct event *ev) { - verbose(VERB_ALGO, "event_del %p added=%d fd=%d tv=" ARG_LL "d %s%s%s", - ev, ev->added, ev->ev_fd, + verbose(VERB_ALGO, "event_del %p added=%d fd=%d tv=" ARG_LL "d %s%s%s", + ev, ev->added, ev->ev_fd, (ev->ev_events&EV_TIMEOUT)?(long long)ev->ev_timeout.tv_sec*1000+ (long long)ev->ev_timeout.tv_usec/1000:-1, (ev->ev_events&EV_READ)?" EV_READ":"", @@ -586,7 +586,7 @@ int event_del(struct event *ev) if((ev->ev_events&(EV_READ|EV_WRITE)) && ev->ev_fd != -1) { log_assert(ev->ev_base->max > 0); /* remove item and compact the list */ - ev->ev_base->items[ev->idx] = + ev->ev_base->items[ev->idx] = ev->ev_base->items[ev->ev_base->max-1]; ev->ev_base->items[ev->ev_base->max-1] = NULL; ev->ev_base->max--; @@ -645,14 +645,14 @@ int signal_del(struct event *ev) void winsock_tcp_wouldblock(struct event* ev, int eventbits) { - verbose(VERB_ALGO, "winsock: tcp wouldblock %s", + verbose(VERB_ALGO, "winsock: tcp wouldblock %s", eventbits==EV_READ?"EV_READ":"EV_WRITE"); ev->old_events &= (~eventbits); if(ev->old_events == 0) ev->stick_events = 0; /* in case this is the last sticky event, we could * possibly run an empty handler loop to reset the base - * tcp_stickies variable + * tcp_stickies variable */ } diff --git a/sbin/unwind/libunbound/util/winsock_event.h b/sbin/unwind/libunbound/util/winsock_event.h index d6dafac8c..029650ef4 100644 --- a/sbin/unwind/libunbound/util/winsock_event.h +++ b/sbin/unwind/libunbound/util/winsock_event.h @@ -4,22 +4,22 @@ * Copyright (c) 2008, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -41,17 +41,17 @@ * sockets. * * Note that windows can only wait for max 64 events at one time. - * + * * Also, file descriptors cannot be waited for. * * Named pipes are not easily available (and are not usable in select() ). * For interprocess communication, it is possible to wait for a hEvent to * be signaled by another thread. * - * When a socket becomes readable, then it will not be flagged as + * When a socket becomes readable, then it will not be flagged as * readable again until you have gotten WOULDBLOCK from a recv routine. * That means the event handler must store the readability (edge notify) - * and process the incoming data until it blocks. + * and process the incoming data until it blocks. * The function performing recv then has to inform the event handler that * the socket has blocked, and the event handler can mark it as such. * Thus, this file transforms the edge notify from windows to a level notify @@ -147,7 +147,7 @@ struct event_base time_t* time_secs; /** where to store time in microseconds */ struct timeval* time_tv; - /** + /** * TCP streams have sticky events to them, these are not * reported by the windows event system anymore, we have to * keep reporting those events as present until wouldblock() is @@ -196,11 +196,11 @@ struct event { int is_tcp; /** remembered EV_ values */ short old_events; - /** should remembered EV_ values be used for TCP streams. + /** should remembered EV_ values be used for TCP streams. * Reset after WOULDBLOCK is signaled using the function. */ int stick_events; - /** true if this event is a signaling WSAEvent by the user. + /** true if this event is a signaling WSAEvent by the user. * User created and user closed WSAEvent. Only signaled/unsignaled, * no read/write/distinctions needed. */ int is_signal; @@ -257,7 +257,7 @@ void winsock_tcp_wouldblock(struct event* ev, int eventbit); /** * Routine for windows only. where you pass a signal WSAEvent that * you wait for. When the event is signaled, the callback gets called. - * The callback has to WSAResetEvent to disable the signal. + * The callback has to WSAResetEvent to disable the signal. * @param base: the event base. * @param ev: the event structure for data storage * can be passed uninitialised. diff --git a/sbin/unwind/libunbound/validator/autotrust.c b/sbin/unwind/libunbound/validator/autotrust.c index 3011a0ace..62212c4a8 100644 --- a/sbin/unwind/libunbound/validator/autotrust.c +++ b/sbin/unwind/libunbound/validator/autotrust.c @@ -4,22 +4,22 @@ * Copyright (c) 2009, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -36,7 +36,7 @@ /** * \file * - * Contains autotrust implementation. The implementation was taken from + * Contains autotrust implementation. The implementation was taken from * the autotrust daemon (BSD licensed), written by Matthijs Mekking. * It was modified to fit into unbound. The state table process is the same. */ @@ -75,7 +75,7 @@ struct autr_global_data* autr_global_create(void) { struct autr_global_data* global; global = (struct autr_global_data*)malloc(sizeof(*global)); - if(!global) + if(!global) return NULL; rbtree_init(&global->probe, &probetree_cmp); return global; @@ -102,7 +102,7 @@ int probetree_cmp(const void* x, const void* y) return anchor_cmp(x, y); } -size_t +size_t autr_get_num_anchors(struct val_anchors* anchors) { size_t res = 0; @@ -127,18 +127,18 @@ position_in_string(char *str, const char* sub) /** Debug routine to print pretty key information */ static void -verbose_key(struct autr_ta* ta, enum verbosity_value level, +verbose_key(struct autr_ta* ta, enum verbosity_value level, const char* format, ...) ATTR_FORMAT(printf, 3, 4); -/** - * Implementation of debug pretty key print +/** + * Implementation of debug pretty key print * @param ta: trust anchor key with DNSKEY data. * @param level: verbosity level to print at. * @param format: printf style format string. */ static void -verbose_key(struct autr_ta* ta, enum verbosity_value level, - const char* format, ...) +verbose_key(struct autr_ta* ta, enum verbosity_value level, + const char* format, ...) { va_list args; va_start(args, format); @@ -156,8 +156,8 @@ verbose_key(struct autr_ta* ta, enum verbosity_value level, va_end(args); } -/** - * Parse comments +/** + * Parse comments * @param str: to parse * @param ta: trust key autotrust metadata * @return false on failure. @@ -429,7 +429,7 @@ find_add_tp(struct val_anchors* anchors, uint8_t* rr, size_t rr_len, } tp = autr_tp_create(anchors, rr, dname_len, sldns_wirerr_get_class(rr, rr_len, dname_len)); - if(!tp) + if(!tp) return NULL; lock_basic_lock(&tp->lock); return tp; @@ -441,7 +441,7 @@ add_trustanchor_frm_rr(struct val_anchors* anchors, uint8_t* rr, size_t rr_len, size_t dname_len, struct trust_anchor** tp) { struct autr_ta* ta = autr_ta_create(rr, rr_len, dname_len); - if(!ta) + if(!ta) return NULL; *tp = find_add_tp(anchors, rr, rr_len, dname_len); if(!*tp) { @@ -469,7 +469,7 @@ add_trustanchor_frm_rr(struct val_anchors* anchors, uint8_t* rr, size_t rr_len, * @return new key in trust point. */ static struct autr_ta* -add_trustanchor_frm_str(struct val_anchors* anchors, char* str, +add_trustanchor_frm_str(struct val_anchors* anchors, char* str, struct trust_anchor** tp, uint8_t* origin, size_t origin_len, uint8_t** prev, size_t* prev_len, int* skip) { @@ -509,8 +509,8 @@ add_trustanchor_frm_str(struct val_anchors* anchors, char* str, return add_trustanchor_frm_rr(anchors, drr, rr_len, dname_len, tp); } -/** - * Load single anchor +/** + * Load single anchor * @param anchors: all points. * @param str: comments line * @param fname: filename @@ -577,7 +577,7 @@ assemble_iterate_dnskey(struct autr_ta** list, uint8_t** rr, size_t* rr_len, while(*list) { if(sldns_wirerr_get_type((*list)->rr, (*list)->rr_len, (*list)->dname_len) != LDNS_RR_TYPE_DS && - ((*list)->s == AUTR_STATE_VALID || + ((*list)->s == AUTR_STATE_VALID || (*list)->s == AUTR_STATE_MISSING)) { *rr = (*list)->rr; *rr_len = (*list)->rr_len; @@ -622,7 +622,7 @@ assemble_iterate_count(int iter(struct autr_ta**, uint8_t**, size_t*, * @param list: the list. * @return key allocated or NULL on failure. */ -static struct ub_packed_rrset_key* +static struct ub_packed_rrset_key* ub_packed_rrset_heap_key(int iter(struct autr_ta**, uint8_t**, size_t*, size_t*), struct autr_ta* list) { @@ -651,7 +651,7 @@ ub_packed_rrset_heap_key(int iter(struct autr_ta**, uint8_t**, size_t*, * @param list: the list. * @return data allocated or NULL on failure. */ -static struct packed_rrset_data* +static struct packed_rrset_data* packed_rrset_heap_data(int iter(struct autr_ta**, uint8_t**, size_t*, size_t*), struct autr_ta* list) { @@ -678,7 +678,7 @@ packed_rrset_heap_data(int iter(struct autr_ta**, uint8_t**, size_t*, /* allocate */ total = count + rrsig_count; - len += sizeof(*data) + total*(sizeof(size_t) + sizeof(time_t) + + len += sizeof(*data) + total*(sizeof(size_t) + sizeof(time_t) + sizeof(uint8_t*)); data = (struct packed_rrset_data*)calloc(1, len); if(!data) @@ -738,7 +738,7 @@ packed_rrset_heap_data(int iter(struct autr_ta**, uint8_t**, size_t*, * @param tp: the trust point. Must be locked. * @return false on malloc failure. */ -static int +static int autr_assemble(struct trust_anchor* tp) { struct ub_packed_rrset_key* ubds=NULL, *ubdnskey=NULL; @@ -799,7 +799,7 @@ parse_int(char* line, int* ret) unsigned int x = (unsigned int)strtol(line, &e, 10); if(line == e) { *ret = -1; /* parse error */ - return 0; + return 0; } *ret = 1; /* matched */ return x; @@ -836,8 +836,8 @@ parse_id(struct val_anchors* anchors, char* line) return tp; } -/** - * Parse variable from trustanchor header +/** + * Parse variable from trustanchor header * @param line: to parse * @param anchors: the anchor is added to this, if "id:" is seen. * @param anchor: the anchor as result value or previously returned anchor @@ -846,7 +846,7 @@ parse_id(struct val_anchors* anchors, char* line) * +2 revoked trust anchor file. */ static int -parse_var_line(char* line, struct val_anchors* anchors, +parse_var_line(char* line, struct val_anchors* anchors, struct trust_anchor** anchor) { struct trust_anchor* tp = *anchor; @@ -954,9 +954,9 @@ read_multiline(char* buf, size_t len, FILE* in, int* linenr) } /* more lines expected, snip off comments and newline */ - if(poslen>0) + if(poslen>0) pos[poslen-1] = 0; /* strip newline */ - if(strchr(pos, ';')) + if(strchr(pos, ';')) strchr(pos, ';')[0] = 0; /* strip comments */ /* move to paste other lines behind this one */ @@ -998,7 +998,7 @@ int autr_read_file(struct val_anchors* anchors, const char* nm) size_t origin_len=0, prev_len=0; if (!(fd = fopen(nm, "r"))) { - log_err("unable to open %s for reading: %s", + log_err("unable to open %s for reading: %s", nm, strerror(errno)); return 0; } @@ -1132,17 +1132,17 @@ autr_write_contents(FILE* out, char* fn, struct trust_anchor* tp) if(!print_id(out, fn, tp->name, tp->namelen, tp->dclass)) { return 0; } - if(fprintf(out, ";;last_queried: %u ;;%s", - (unsigned int)tp->autr->last_queried, + if(fprintf(out, ";;last_queried: %u ;;%s", + (unsigned int)tp->autr->last_queried, autr_ctime_r(&(tp->autr->last_queried), tmi)) < 0 || - fprintf(out, ";;last_success: %u ;;%s", + fprintf(out, ";;last_success: %u ;;%s", (unsigned int)tp->autr->last_success, autr_ctime_r(&(tp->autr->last_success), tmi)) < 0 || - fprintf(out, ";;next_probe_time: %u ;;%s", + fprintf(out, ";;next_probe_time: %u ;;%s", (unsigned int)tp->autr->next_probe_time, autr_ctime_r(&(tp->autr->next_probe_time), tmi)) < 0 || fprintf(out, ";;query_failed: %d\n", (int)tp->autr->query_failed)<0 - || fprintf(out, ";;query_interval: %d\n", + || fprintf(out, ";;query_interval: %d\n", (int)tp->autr->query_interval) < 0 || fprintf(out, ";;retry_time: %d\n", (int)tp->autr->retry_time) < 0) { log_err("could not write to %s: %s", fn, strerror(errno)); @@ -1168,9 +1168,9 @@ autr_write_contents(FILE* out, char* fn, struct trust_anchor* tp) } str[strlen(str)-1] = 0; /* remove newline */ if(fprintf(out, "%s ;;state=%d [%s] ;;count=%d " - ";;lastchange=%u ;;%s", str, (int)ta->s, + ";;lastchange=%u ;;%s", str, (int)ta->s, trustanchor_state2str(ta->s), (int)ta->pending_count, - (unsigned int)ta->last_change, + (unsigned int)ta->last_change, autr_ctime_r(&(ta->last_change), tmi)) < 0) { log_err("could not write to %s: %s", fn, strerror(errno)); free(str); @@ -1244,8 +1244,8 @@ void autr_write_file(struct module_env* env, struct trust_anchor* tp) } } -/** - * Verify if dnskey works for trust point +/** + * Verify if dnskey works for trust point * @param env: environment (with time) for verification * @param ve: validator environment (with options) for verification. * @param tp: trust point to verify with @@ -1311,7 +1311,7 @@ rr_is_selfsigned_revoked(struct module_env* env, struct val_env* ve, (int)i); /* no algorithm downgrade protection necessary, if it is selfsigned * revoked it can be removed. */ - sec = dnskey_verify_rrset(env, ve, dnskey_rrset, dnskey_rrset, i, + sec = dnskey_verify_rrset(env, ve, dnskey_rrset, dnskey_rrset, i, &reason, NULL, LDNS_SECTION_ANSWER, qstate); return (sec == sec_status_secure); } @@ -1402,7 +1402,7 @@ ta_compare(struct autr_ta* a, uint16_t t, uint8_t* b, size_t b_len) return -1; } -/** +/** * Find key * @param tp: to search in * @param t: rr type of the rdata. @@ -1472,11 +1472,11 @@ key_ttl(struct ub_packed_rrset_key* k) /** update the time values for the trustpoint */ static void -set_tp_times(struct trust_anchor* tp, time_t rrsig_exp_interval, +set_tp_times(struct trust_anchor* tp, time_t rrsig_exp_interval, time_t origttl, int* changed) { time_t x, qi = tp->autr->query_interval, rt = tp->autr->retry_time; - + /* x = MIN(15days, ttl/2, expire/2) */ x = 15 * 24 * 3600; if(origttl/2 < x) @@ -1506,10 +1506,10 @@ set_tp_times(struct trust_anchor* tp, time_t rrsig_exp_interval, if(qi != tp->autr->query_interval || rt != tp->autr->retry_time) { *changed = 1; verbose(VERB_ALGO, "orig_ttl is %d", (int)origttl); - verbose(VERB_ALGO, "rrsig_exp_interval is %d", + verbose(VERB_ALGO, "rrsig_exp_interval is %d", (int)rrsig_exp_interval); verbose(VERB_ALGO, "query_interval: %d, retry_time: %d", - (int)tp->autr->query_interval, + (int)tp->autr->query_interval, (int)tp->autr->retry_time); } } @@ -1550,7 +1550,7 @@ check_contains_revoked(struct module_env* env, struct val_env* ve, continue; /* key not found */ if(rr_is_selfsigned_revoked(env, ve, dnskey_rrset, i, qstate)) { /* checked if there is an rrsig signed by this key. */ - /* same keytag, but stored can be revoked already, so + /* same keytag, but stored can be revoked already, so * compare keytags, with +0 or +128(REVOKE flag) */ log_assert(dnskey_calc_keytag(dnskey_rrset, i)-128 == sldns_calc_keytag_raw(sldns_wirerr_get_rdata( @@ -1563,7 +1563,7 @@ check_contains_revoked(struct module_env* env, struct val_env* ve, sldns_wirerr_get_rdatalen(ta->rr, ta->rr_len, ta->dname_len))); /* checks conversion*/ verbose_key(ta, VERB_ALGO, "is self-signed revoked"); - if(!ta->revoked) + if(!ta->revoked) *changed = 1; seen_revoked_trustanchor(ta, 1); do_revoked(env, ta, changed); @@ -1604,7 +1604,7 @@ key_matches_a_ds(struct module_env* env, struct val_env* ve, (void)ve; return 1; /* no need to check RRSIG, DS hash already matched with source - if(dnskey_verify_rrset(env, ve, dnskey_rrset, + if(dnskey_verify_rrset(env, ve, dnskey_rrset, dnskey_rrset, key_idx, &reason) == sec_status_secure) { return 1; } else { @@ -1618,8 +1618,8 @@ key_matches_a_ds(struct module_env* env, struct val_env* ve, /** Set update events */ static int -update_events(struct module_env* env, struct val_env* ve, - struct trust_anchor* tp, struct ub_packed_rrset_key* dnskey_rrset, +update_events(struct module_env* env, struct val_env* ve, + struct trust_anchor* tp, struct ub_packed_rrset_key* dnskey_rrset, int* changed) { struct packed_rrset_data* dd = (struct packed_rrset_data*) @@ -1644,7 +1644,7 @@ update_events(struct module_env* env, struct val_env* ve, !dnskey_size_is_supported(dnskey_rrset, i)) { /* skip unknown algorithm key, it is useless to us */ log_nametypeclass(VERB_DETAIL, "trust point has " - "unsupported algorithm at", + "unsupported algorithm at", tp->name, LDNS_RR_TYPE_DNSKEY, tp->dclass); continue; } @@ -1735,7 +1735,7 @@ do_newkey(struct module_env* env, struct autr_ta* anchor, int* c) static void do_addtime(struct module_env* env, struct autr_ta* anchor, int* c) { - /* This not according to RFC, this is 30 days, but the RFC demands + /* This not according to RFC, this is 30 days, but the RFC demands * MAX(30days, TTL expire time of first DNSKEY set with this key), * The value may be too small if a very large TTL was used. */ time_t exceeded = check_holddown(env, anchor, env->cfg->add_holddown); @@ -1864,7 +1864,7 @@ init_zsk_to_ksk(struct module_env* env, struct trust_anchor* tp, int* changed) /* last_change test makes sure it was manually configured */ if(sldns_wirerr_get_type(anchor->rr, anchor->rr_len, anchor->dname_len) == LDNS_RR_TYPE_DNSKEY && - anchor->last_change == 0 && + anchor->last_change == 0 && !ta_is_dnskey_sep(anchor) && anchor->s == AUTR_STATE_VALID) validzsk++; @@ -1872,11 +1872,11 @@ init_zsk_to_ksk(struct module_env* env, struct trust_anchor* tp, int* changed) if(validzsk == 0) return 0; for(anchor = tp->autr->keys; anchor; anchor = anchor->next) { - if (ta_is_dnskey_sep(anchor) && + if (ta_is_dnskey_sep(anchor) && anchor->s == AUTR_STATE_ADDPEND) { verbose_key(anchor, VERB_ALGO, "trust KSK from " "ZSK(config)"); - set_trustanchor_state(env, anchor, changed, + set_trustanchor_state(env, anchor, changed, AUTR_STATE_VALID); validksk++; } @@ -1912,7 +1912,7 @@ remove_missing_trustanchors(struct module_env* env, struct trust_anchor* tp, if(valid == 0) return; } - + for(anchor = tp->autr->keys; anchor; anchor = anchor->next) { /* ignore ZSKs if newly added */ if(anchor->s == AUTR_STATE_START) @@ -1922,7 +1922,7 @@ remove_missing_trustanchors(struct module_env* env, struct trust_anchor* tp, if(valid > 0) { verbose_key(anchor, VERB_ALGO, "remove ZSK " "[%d key(s) VALID]", valid); - set_trustanchor_state(env, anchor, changed, + set_trustanchor_state(env, anchor, changed, AUTR_STATE_REMOVED); } continue; @@ -1934,13 +1934,13 @@ remove_missing_trustanchors(struct module_env* env, struct trust_anchor* tp, continue; /* keep forever */ exceeded = check_holddown(env, anchor, env->cfg->keep_missing); - /* If keep_missing has exceeded and we still have more than + /* If keep_missing has exceeded and we still have more than * one valid KSK: remove missing trust anchor */ if (exceeded && valid > 0) { verbose_key(anchor, VERB_ALGO, "keep-missing time " "exceeded " ARG_LL "d seconds ago, [%d key(s) VALID]", (long long)exceeded, valid); - set_trustanchor_state(env, anchor, changed, + set_trustanchor_state(env, anchor, changed, AUTR_STATE_REMOVED); } } @@ -1967,7 +1967,7 @@ autr_holddown_exceed(struct module_env* env, struct trust_anchor* tp, int* c) { struct autr_ta* anchor; for(anchor = tp->autr->keys; anchor; anchor = anchor->next) { - if(ta_is_dnskey_sep(anchor) && + if(ta_is_dnskey_sep(anchor) && anchor->s == AUTR_STATE_ADDPEND) do_addtime(env, anchor, c); } @@ -2025,7 +2025,7 @@ static time_t wait_probe_time(struct val_anchors* anchors) { rbnode_type* t = rbtree_first(&anchors->autr->probe); - if(t != RBTREE_NULL) + if(t != RBTREE_NULL) return ((struct trust_anchor*)t->key)->autr->next_probe_time; return 0; } @@ -2078,13 +2078,13 @@ set_next_probe(struct module_env* env, struct trust_anchor* tp, /* schedule */ mold = wait_probe_time(env->anchors); (void)rbtree_delete(&env->anchors->autr->probe, tp); - tp->autr->next_probe_time = calc_next_probe(env, + tp->autr->next_probe_time = calc_next_probe(env, tp->autr->query_interval); (void)rbtree_insert(&env->anchors->autr->probe, &tp->autr->pnode); mnew = wait_probe_time(env->anchors); lock_basic_unlock(&env->anchors->lock); - verbose(VERB_ALGO, "next probe set in %d seconds", + verbose(VERB_ALGO, "next probe set in %d seconds", (int)tp->autr->next_probe_time - (int)*env->now); if(mold != mnew) { reset_worker_timer(env); @@ -2159,7 +2159,7 @@ int autr_process_prime(struct module_env* env, struct val_env* ve, * is busy deleting it. Just unlock and let the other do its job */ if(tp->autr->revoked) { log_nametypeclass(VERB_ALGO, "autotrust not processed, " - "trust point revoked", tp->name, + "trust point revoked", tp->name, LDNS_RR_TYPE_DNSKEY, tp->dclass); lock_basic_unlock(&tp->lock); return 0; /* it is revoked */ @@ -2255,12 +2255,12 @@ int autr_process_prime(struct module_env* env, struct val_env* ve, return 0; /* trust point removed */ } } else verbose(VERB_ALGO, "autotrust: no changes"); - + return 1; /* trust point exists */ } /** debug print a trust anchor key */ -static void +static void autr_debug_print_ta(struct autr_ta* ta) { char buf[32]; @@ -2279,7 +2279,7 @@ autr_debug_print_ta(struct autr_ta* ta) } /** debug print a trust point */ -static void +static void autr_debug_print_tp(struct trust_anchor* tp) { struct autr_ta* ta; @@ -2288,7 +2288,7 @@ autr_debug_print_tp(struct trust_anchor* tp) return; dname_str(tp->name, buf); log_info("trust point %s : %d", buf, (int)tp->dclass); - log_info("assembled %d DS and %d DNSKEYs", + log_info("assembled %d DS and %d DNSKEYs", (int)tp->numDS, (int)tp->numDNSKEY); if(tp->ds_rrset) { log_packed_rrset(NO_VERBOSE, "DS:", tp->ds_rrset); @@ -2310,13 +2310,13 @@ autr_debug_print_tp(struct trust_anchor* tp) log_info("query_interval: %u", (unsigned)tp->autr->query_interval); log_info("retry_time: %u", (unsigned)tp->autr->retry_time); log_info("query_failed: %u", (unsigned)tp->autr->query_failed); - + for(ta=tp->autr->keys; ta; ta=ta->next) { autr_debug_print_ta(ta); } } -void +void autr_debug_print(struct val_anchors* anchors) { struct trust_anchor* tp; @@ -2329,7 +2329,7 @@ autr_debug_print(struct val_anchors* anchors) lock_basic_unlock(&anchors->lock); } -void probe_answer_cb(void* arg, int ATTR_UNUSED(rcode), +void probe_answer_cb(void* arg, int ATTR_UNUSED(rcode), sldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(sec), char* ATTR_UNUSED(why_bogus), int ATTR_UNUSED(was_ratelimited)) { @@ -2337,7 +2337,7 @@ void probe_answer_cb(void* arg, int ATTR_UNUSED(rcode), * re-querytime is set when query succeeded, but that may not * have reset this timer because the query could have been * handled by another thread. In that case, this callback would - * get called after the original timeout is done. + * get called after the original timeout is done. * By not resetting the timer, it may probe more often, but not * less often. * Unless the new lookup resulted in smaller TTLs and thus smaller @@ -2366,7 +2366,7 @@ probe_anchor(struct module_env* env, struct trust_anchor* tp) qinfo.qclass = tp->dclass; qinfo.local_alias = NULL; log_query_info(VERB_ALGO, "autotrust probe", &qinfo); - verbose(VERB_ALGO, "retry probe set in %d seconds", + verbose(VERB_ALGO, "retry probe set in %d seconds", (int)tp->autr->next_probe_time - (int)*env->now); edns.edns_present = 1; edns.ext_rcode = 0; @@ -2390,10 +2390,10 @@ probe_anchor(struct module_env* env, struct trust_anchor* tp) * to recreate the key entry in a race condition. */ rrset_cache_remove(env->rrset_cache, qinfo.qname, qinfo.qname_len, qinfo.qtype, qinfo.qclass, 0); - key_cache_remove(env->key_cache, qinfo.qname, qinfo.qname_len, + key_cache_remove(env->key_cache, qinfo.qname, qinfo.qname_len, qinfo.qclass); - if(!mesh_new_callback(env->mesh, &qinfo, qflags, &edns, buf, 0, + if(!mesh_new_callback(env->mesh, &qinfo, qflags, &edns, buf, 0, &probe_answer_cb, env, 0)) { log_err("out of memory making 5011 probe"); } @@ -2435,7 +2435,7 @@ todo_probe(struct module_env* env, time_t* next) return tp; } -time_t +time_t autr_probe_timer(struct module_env* env) { struct trust_anchor* tp; diff --git a/sbin/unwind/libunbound/validator/autotrust.h b/sbin/unwind/libunbound/validator/autotrust.h index 057f2b68a..34104dea5 100644 --- a/sbin/unwind/libunbound/validator/autotrust.h +++ b/sbin/unwind/libunbound/validator/autotrust.h @@ -4,22 +4,22 @@ * Copyright (c) 2009, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -61,7 +61,7 @@ typedef enum { AUTR_STATE_REMOVED = 5 } autr_state_type; -/** +/** * Autotrust metadata for one trust anchor key. */ struct autr_ta { @@ -83,7 +83,7 @@ struct autr_ta { uint8_t revoked; }; -/** +/** * Autotrust metadata for a trust point. * This is part of the struct trust_anchor data. */ @@ -96,7 +96,7 @@ struct autr_point_data { /** the keys */ struct autr_ta* keys; - /** last queried DNSKEY set + /** last queried DNSKEY set * Not all failures are captured in this entry. * If the validator did not even start (e.g. timeout or localservfail), * then the last_queried and query_failed values are not updated. @@ -112,7 +112,7 @@ struct autr_point_data { /** when to retry if failed */ time_t retry_time; - /** + /** * How many times did it fail. diagnostic only (has no effect). * Only updated if there was a dnskey rrset that failed to verify. */ @@ -121,7 +121,7 @@ struct autr_point_data { uint8_t revoked; }; -/** +/** * Autotrust global metadata. */ struct autr_global_data { @@ -205,7 +205,7 @@ int autr_process_prime(struct module_env* env, struct val_env* ve, void autr_debug_print(struct val_anchors* anchors); /** callback for query answer to 5011 probe */ -void probe_answer_cb(void* arg, int rcode, struct sldns_buffer* buf, +void probe_answer_cb(void* arg, int rcode, struct sldns_buffer* buf, enum sec_status sec, char* errinf, int was_ratelimited); #endif /* VALIDATOR_AUTOTRUST_H */ diff --git a/sbin/unwind/libunbound/validator/val_anchor.c b/sbin/unwind/libunbound/validator/val_anchor.c index b1a54e1f0..006c129f0 100644 --- a/sbin/unwind/libunbound/validator/val_anchor.c +++ b/sbin/unwind/libunbound/validator/val_anchor.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -68,11 +68,11 @@ anchor_cmp(const void* k1, const void* k2) return -1; return 1; } - return dname_lab_cmp(n1->name, n1->namelabs, n2->name, n2->namelabs, + return dname_lab_cmp(n1->name, n1->namelabs, n2->name, n2->namelabs, &m); } -struct val_anchors* +struct val_anchors* anchors_create(void) { struct val_anchors* a = (struct val_anchors*)calloc(1, sizeof(*a)); @@ -136,7 +136,7 @@ anchors_delfunc(rbnode_type* elem, void* ATTR_UNUSED(arg)) } } -void +void anchors_delete(struct val_anchors* anchors) { if(!anchors) @@ -155,7 +155,7 @@ void anchors_init_parents_locked(struct val_anchors* anchors) { struct trust_anchor* node, *prev = NULL, *p; - int m; + int m; /* nobody else can grab locks because we hold the main lock. * Thus the previous items, after unlocked, are not deleted */ RBTREE_FOR(node, struct trust_anchor*, anchors->tree) { @@ -166,7 +166,7 @@ anchors_init_parents_locked(struct val_anchors* anchors) lock_basic_unlock(&node->lock); continue; } - (void)dname_lab_cmp(prev->name, prev->namelabs, node->name, + (void)dname_lab_cmp(prev->name, prev->namelabs, node->name, node->namelabs, &m); /* we know prev is smaller */ /* sort order like: . com. bla.com. zwb.com. net. */ /* find the previous, or parent-parent-parent */ @@ -268,7 +268,7 @@ anchor_find_key(struct trust_anchor* ta, uint8_t* rdata, size_t rdata_len, } return NULL; } - + /** create new trustanchor key */ static struct ta_key* anchor_new_ta_key(uint8_t* rdata, size_t rdata_len, uint16_t type) @@ -403,7 +403,7 @@ anchor_store_str(struct val_anchors* anchors, sldns_buffer* buffer, int status = sldns_str2wire_rr_buf(str, rr, &len, &dname_len, 0, NULL, 0, NULL, 0); if(status != 0) { - log_err("error parsing trust anchor %s: at %d: %s", + log_err("error parsing trust anchor %s: at %d: %s", str, LDNS_WIREPARSE_OFFSET(status), sldns_get_errorstr_parse(status)); return NULL; @@ -467,7 +467,7 @@ anchor_read_file(struct val_anchors* anchors, sldns_buffer* buffer, if(onlyone && ta && ta != tanew) { log_err("error at %s line %d: no multiple anchor " "domains allowed (you can have multiple " - "keys, but they must have the same name).", + "keys, but they must have the same name).", fname, pst.lineno); ok = 0; break; @@ -506,8 +506,8 @@ is_bind_special(int c) return 0; } -/** - * Read a keyword skipping bind comments; spaces, specials, restkeywords. +/** + * Read a keyword skipping bind comments; spaces, specials, restkeywords. * The file is split into the following tokens: * * special characters, on their own, rdlen=1, { } doublequote ; * * whitespace becomes a single ' ' or tab. Newlines become spaces. @@ -524,7 +524,7 @@ is_bind_special(int c) * if 1, comments are skipped entirely. * In BIND files, this is when reading quoted strings, for example * " base 64 text with / / in there " - * @return the number of character written to the buffer. + * @return the number of character written to the buffer. * 0 on end of file. */ static int @@ -538,7 +538,7 @@ readkeyword_bindfile(FILE* in, sldns_buffer* buf, int* line, int comments) (*line)++; continue; } else if(comments && c=='/' && numdone>0 && /* /_/ bla*/ - sldns_buffer_read_u8_at(buf, + sldns_buffer_read_u8_at(buf, sldns_buffer_position(buf)-1) == '/') { sldns_buffer_skip(buf, -1); numdone--; @@ -546,7 +546,7 @@ readkeyword_bindfile(FILE* in, sldns_buffer* buf, int* line, int comments) (*line)++; continue; } else if(comments && c=='*' && numdone>0 && /* /_* bla *_/ */ - sldns_buffer_read_u8_at(buf, + sldns_buffer_read_u8_at(buf, sldns_buffer_position(buf)-1) == '/') { sldns_buffer_skip(buf, -1); numdone--; @@ -602,8 +602,8 @@ readkeyword_bindfile(FILE* in, sldns_buffer* buf, int* line, int comments) } /** skip through file to { or ; */ -static int -skip_to_special(FILE* in, sldns_buffer* buf, int* line, int spec) +static int +skip_to_special(FILE* in, sldns_buffer* buf, int* line, int spec) { int rdlen; sldns_buffer_clear(buf); @@ -614,7 +614,7 @@ skip_to_special(FILE* in, sldns_buffer* buf, int* line, int spec) } if(rdlen != 1 || *sldns_buffer_begin(buf) != (uint8_t)spec) { sldns_buffer_write_u8(buf, 0); - log_err("trusted-keys, line %d, expected %c", + log_err("trusted-keys, line %d, expected %c", *line, spec); return 0; } @@ -624,7 +624,7 @@ skip_to_special(FILE* in, sldns_buffer* buf, int* line, int spec) return 0; } -/** +/** * read contents of trusted-keys{ ... ; clauses and insert keys into storage. * @param anchors: where to store keys * @param buf: buffer to use @@ -633,7 +633,7 @@ skip_to_special(FILE* in, sldns_buffer* buf, int* line, int spec) * @return 0 on error. */ static int -process_bind_contents(struct val_anchors* anchors, sldns_buffer* buf, +process_bind_contents(struct val_anchors* anchors, sldns_buffer* buf, int* line, FILE* in) { /* loop over contents, collate strings before ; */ @@ -703,7 +703,7 @@ process_bind_contents(struct val_anchors* anchors, sldns_buffer* buf, return 0; } return 1; - } else if(rdlen == 1 && + } else if(rdlen == 1 && isspace((unsigned char)sldns_buffer_current(buf)[-1])) { /* leave whitespace here */ } else { @@ -713,7 +713,7 @@ process_bind_contents(struct val_anchors* anchors, sldns_buffer* buf, if(sldns_buffer_remaining(buf) < 8+1) { log_err("line %d, too long", *line); return 0; - } + } sldns_buffer_write(buf, " DNSKEY ", 8); } } @@ -789,12 +789,12 @@ anchor_read_bind_file_wild(struct val_anchors* anchors, sldns_buffer* buffer, glob_t g; size_t i; int r, flags; - if(!strchr(pat, '*') && !strchr(pat, '?') && !strchr(pat, '[') && + if(!strchr(pat, '*') && !strchr(pat, '?') && !strchr(pat, '[') && !strchr(pat, '{') && !strchr(pat, '~')) { return anchor_read_bind_file(anchors, buffer, pat); } verbose(VERB_QUERY, "wildcard found, processing %s", pat); - flags = 0 + flags = 0 #ifdef GLOB_ERR | GLOB_ERR #endif @@ -827,7 +827,7 @@ anchor_read_bind_file_wild(struct val_anchors* anchors, sldns_buffer* buffer, "failed (%s)", pat, strerror(errno)); } /* ignore globs that yield no files */ - return 1; + return 1; } /* process files found, if any */ for(i=0; i<(size_t)g.gl_pathc; i++) { @@ -845,8 +845,8 @@ anchor_read_bind_file_wild(struct val_anchors* anchors, sldns_buffer* buffer, #endif /* HAVE_GLOB */ } -/** - * Assemble an rrset structure for the type +/** + * Assemble an rrset structure for the type * @param ta: trust anchor. * @param num: number of items to fetch from list. * @param type: fetch only items of this type. @@ -954,7 +954,7 @@ anchors_ds_unsupported(struct trust_anchor* ta) { size_t i, num = 0; for(i=0; inumDS; i++) { - if(!ds_digest_algo_is_supported(ta->ds_rrset, i) || + if(!ds_digest_algo_is_supported(ta->ds_rrset, i) || !ds_key_algo_is_supported(ta->ds_rrset, i)) num++; } @@ -1009,12 +1009,12 @@ anchors_assemble_rrsets(struct val_anchors* anchors) nokey = anchors_dnskey_unsupported(ta); if(nods) { log_nametypeclass(NO_VERBOSE, "warning: unsupported " - "algorithm for trust anchor", + "algorithm for trust anchor", ta->name, LDNS_RR_TYPE_DS, ta->dclass); } if(nokey) { log_nametypeclass(NO_VERBOSE, "warning: unsupported " - "algorithm for trust anchor", + "algorithm for trust anchor", ta->name, LDNS_RR_TYPE_DNSKEY, ta->dclass); } if(nods == ta->numDS && nokey == ta->numDNSKEY) { @@ -1042,7 +1042,7 @@ anchors_assemble_rrsets(struct val_anchors* anchors) return 1; } -int +int anchors_apply_cfg(struct val_anchors* anchors, struct config_file* cfg) { struct config_strlist* f; @@ -1116,7 +1116,7 @@ anchors_apply_cfg(struct val_anchors* anchors, struct config_file* cfg) cfg->chrootdir, strlen(cfg->chrootdir)) == 0) nm += strlen(cfg->chrootdir); if(!autr_read_file(anchors, nm)) { - log_err("error reading auto-trust-anchor-file: %s", + log_err("error reading auto-trust-anchor-file: %s", f->str); sldns_buffer_free(parsebuf); return 0; @@ -1130,7 +1130,7 @@ anchors_apply_cfg(struct val_anchors* anchors, struct config_file* cfg) return 1; } -struct trust_anchor* +struct trust_anchor* anchors_lookup(struct val_anchors* anchors, uint8_t* qname, size_t qname_len, uint16_t qclass) { @@ -1170,7 +1170,7 @@ anchors_lookup(struct val_anchors* anchors, return result; } -size_t +size_t anchors_get_mem(struct val_anchors* anchors) { struct trust_anchor *ta; diff --git a/sbin/unwind/libunbound/validator/val_anchor.h b/sbin/unwind/libunbound/validator/val_anchor.h index 1597a7d62..e37f451e0 100644 --- a/sbin/unwind/libunbound/validator/val_anchor.h +++ b/sbin/unwind/libunbound/validator/val_anchor.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -102,7 +102,7 @@ struct trust_anchor { int namelabs; /** the ancestor in the trustanchor tree */ struct trust_anchor* parent; - /** + /** * List of DS or DNSKEY rrs that form the trust anchor. */ struct ta_key* keylist; @@ -172,7 +172,7 @@ struct trust_anchor* anchors_lookup(struct val_anchors* anchors, * @param dclass: class of trust anchor * @return NULL if not found. The anchor is locked. */ -struct trust_anchor* anchor_find(struct val_anchors* anchors, +struct trust_anchor* anchor_find(struct val_anchors* anchors, uint8_t* name, int namelabs, size_t namelen, uint16_t dclass); /** @@ -182,7 +182,7 @@ struct trust_anchor* anchor_find(struct val_anchors* anchors, * @param str: string. * @return NULL on error. */ -struct trust_anchor* anchor_store_str(struct val_anchors* anchors, +struct trust_anchor* anchor_store_str(struct val_anchors* anchors, struct sldns_buffer* buffer, const char* str); /** diff --git a/sbin/unwind/libunbound/validator/val_kcache.c b/sbin/unwind/libunbound/validator/val_kcache.c index f5d49d24f..733639ade 100644 --- a/sbin/unwind/libunbound/validator/val_kcache.c +++ b/sbin/unwind/libunbound/validator/val_kcache.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -46,10 +46,10 @@ #include "util/data/dname.h" #include "util/module.h" -struct key_cache* +struct key_cache* key_cache_create(struct config_file* cfg) { - struct key_cache* kcache = (struct key_cache*)calloc(1, + struct key_cache* kcache = (struct key_cache*)calloc(1, sizeof(*kcache)); size_t numtables, start_size, maxmem; if(!kcache) { @@ -70,7 +70,7 @@ key_cache_create(struct config_file* cfg) return kcache; } -void +void key_cache_delete(struct key_cache* kcache) { if(!kcache) @@ -79,7 +79,7 @@ key_cache_delete(struct key_cache* kcache) free(kcache); } -void +void key_cache_insert(struct key_cache* kcache, struct key_entry_key* kkey, int copy_reason) { @@ -87,7 +87,7 @@ key_cache_insert(struct key_cache* kcache, struct key_entry_key* kkey, if(!k) return; key_entry_hash(k); - slabhash_insert(kcache->slab, k->entry.hash, &k->entry, + slabhash_insert(kcache->slab, k->entry.hash, &k->entry, k->entry.data, NULL); } @@ -103,7 +103,7 @@ key_cache_insert(struct key_cache* kcache, struct key_entry_key* kkey, * performed. */ static struct key_entry_key* -key_cache_search(struct key_cache* kcache, uint8_t* name, size_t namelen, +key_cache_search(struct key_cache* kcache, uint8_t* name, size_t namelen, uint16_t key_class, int wr) { struct lruhash_entry* e; @@ -114,18 +114,18 @@ key_cache_search(struct key_cache* kcache, uint8_t* name, size_t namelen, lookfor.key_class = key_class; key_entry_hash(&lookfor); e = slabhash_lookup(kcache->slab, lookfor.entry.hash, &lookfor, wr); - if(!e) + if(!e) return NULL; return (struct key_entry_key*)e->key; } -struct key_entry_key* -key_cache_obtain(struct key_cache* kcache, uint8_t* name, size_t namelen, +struct key_entry_key* +key_cache_obtain(struct key_cache* kcache, uint8_t* name, size_t namelen, uint16_t key_class, struct regional* region, time_t now) { /* keep looking until we find a nonexpired entry */ while(1) { - struct key_entry_key* k = key_cache_search(kcache, name, + struct key_entry_key* k = key_cache_search(kcache, name, namelen, key_class, 0); if(k) { /* see if TTL is OK */ @@ -148,7 +148,7 @@ key_cache_obtain(struct key_cache* kcache, uint8_t* name, size_t namelen, return NULL; } -size_t +size_t key_cache_get_mem(struct key_cache* kcache) { return sizeof(*kcache) + slabhash_get_mem(kcache->slab); diff --git a/sbin/unwind/libunbound/validator/val_kcache.h b/sbin/unwind/libunbound/validator/val_kcache.h index df8de0999..2eac3dc9a 100644 --- a/sbin/unwind/libunbound/validator/val_kcache.h +++ b/sbin/unwind/libunbound/validator/val_kcache.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -36,7 +36,7 @@ /** * \file * - * This file contains functions for caching validated key entries. + * This file contains functions for caching validated key entries. */ #ifndef VALIDATOR_VAL_KCACHE_H @@ -105,7 +105,7 @@ void key_cache_remove(struct key_cache* kcache, * Otherwise, NULL is returned. */ struct key_entry_key* key_cache_obtain(struct key_cache* kcache, - uint8_t* name, size_t namelen, uint16_t key_class, + uint8_t* name, size_t namelen, uint16_t key_class, struct regional* region, time_t now); /** diff --git a/sbin/unwind/libunbound/validator/val_kentry.c b/sbin/unwind/libunbound/validator/val_kentry.c index 85f026402..b99833502 100644 --- a/sbin/unwind/libunbound/validator/val_kentry.c +++ b/sbin/unwind/libunbound/validator/val_kentry.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -48,7 +48,7 @@ #include "sldns/rrdef.h" #include "sldns/keyraw.h" -size_t +size_t key_entry_sizefunc(void* key, void* data) { struct key_entry_key* kk = (struct key_entry_key*)key; @@ -64,7 +64,7 @@ key_entry_sizefunc(void* key, void* data) return s; } -int +int key_entry_compfunc(void* k1, void* k2) { struct key_entry_key* n1 = (struct key_entry_key*)k1; @@ -77,7 +77,7 @@ key_entry_compfunc(void* k1, void* k2) return query_dname_compare(n1->name, n2->name); } -void +void key_entry_delkeyfunc(void* key, void* ATTR_UNUSED(userarg)) { struct key_entry_key* kk = (struct key_entry_key*)key; @@ -88,7 +88,7 @@ key_entry_delkeyfunc(void* key, void* ATTR_UNUSED(userarg)) free(kk); } -void +void key_entry_deldatafunc(void* data, void* ATTR_UNUSED(userarg)) { struct key_entry_data* kd = (struct key_entry_data*)data; @@ -98,16 +98,16 @@ key_entry_deldatafunc(void* data, void* ATTR_UNUSED(userarg)) free(kd); } -void +void key_entry_hash(struct key_entry_key* kk) { kk->entry.hash = 0x654; - kk->entry.hash = hashlittle(&kk->key_class, sizeof(kk->key_class), + kk->entry.hash = hashlittle(&kk->key_class, sizeof(kk->key_class), kk->entry.hash); kk->entry.hash = dname_query_hash(kk->name, kk->entry.hash); } -struct key_entry_key* +struct key_entry_key* key_entry_copy_toregion(struct key_entry_key* kkey, struct regional* region) { struct key_entry_key* newk; @@ -129,7 +129,7 @@ key_entry_copy_toregion(struct key_entry_key* kkey, struct regional* region) /* copy rrset */ if(d->rrset_data) { newd->rrset_data = regional_alloc_init(region, - d->rrset_data, + d->rrset_data, packed_rrset_sizeof(d->rrset_data)); if(!newd->rrset_data) return NULL; @@ -151,7 +151,7 @@ key_entry_copy_toregion(struct key_entry_key* kkey, struct regional* region) return newk; } -struct key_entry_key* +struct key_entry_key* key_entry_copy(struct key_entry_key* kkey, int copy_reason) { struct key_entry_key* newk; @@ -180,7 +180,7 @@ key_entry_copy(struct key_entry_key* kkey, int copy_reason) } /* copy rrset */ if(d->rrset_data) { - newd->rrset_data = memdup(d->rrset_data, + newd->rrset_data = memdup(d->rrset_data, packed_rrset_sizeof(d->rrset_data)); if(!newd->rrset_data) { free(newd); @@ -218,21 +218,21 @@ key_entry_copy(struct key_entry_key* kkey, int copy_reason) return newk; } -int +int key_entry_isnull(struct key_entry_key* kkey) { struct key_entry_data* d = (struct key_entry_data*)kkey->entry.data; return (!d->isbad && d->rrset_data == NULL); } -int +int key_entry_isgood(struct key_entry_key* kkey) { struct key_entry_data* d = (struct key_entry_data*)kkey->entry.data; return (!d->isbad && d->rrset_data != NULL); } -int +int key_entry_isbad(struct key_entry_key* kkey) { struct key_entry_data* d = (struct key_entry_data*)kkey->entry.data; @@ -257,7 +257,7 @@ key_entry_get_reason_bogus(struct key_entry_key* kkey) /** setup key entry in region */ static int key_entry_setup(struct regional* region, - uint8_t* name, size_t namelen, uint16_t dclass, + uint8_t* name, size_t namelen, uint16_t dclass, struct key_entry_key** k, struct key_entry_data** d) { *k = regional_alloc(region, sizeof(**k)); @@ -277,7 +277,7 @@ key_entry_setup(struct regional* region, return 1; } -struct key_entry_key* +struct key_entry_key* key_entry_create_null(struct regional* region, uint8_t* name, size_t namelen, uint16_t dclass, time_t ttl, sldns_ede_code reason_bogus, const char* reason, @@ -299,7 +299,7 @@ key_entry_create_null(struct regional* region, return k; } -struct key_entry_key* +struct key_entry_key* key_entry_create_rrset(struct regional* region, uint8_t* name, size_t namelen, uint16_t dclass, struct ub_packed_rrset_key* rrset, uint8_t* sigalg, @@ -332,7 +332,7 @@ key_entry_create_rrset(struct regional* region, return k; } -struct key_entry_key* +struct key_entry_key* key_entry_create_bad(struct regional* region, uint8_t* name, size_t namelen, uint16_t dclass, time_t ttl, sldns_ede_code reason_bogus, const char* reason, @@ -354,7 +354,7 @@ key_entry_create_bad(struct regional* region, return k; } -struct ub_packed_rrset_key* +struct ub_packed_rrset_key* key_entry_get_rrset(struct key_entry_key* kkey, struct regional* region) { struct key_entry_data* d = (struct key_entry_data*)kkey->entry.data; @@ -373,7 +373,7 @@ key_entry_get_rrset(struct key_entry_key* kkey, struct regional* region) rrk->rk.type = htons(d->rrset_type); rrk->rk.rrset_class = htons(kkey->key_class); rrk->entry.key = rrk; - rrd = regional_alloc_init(region, d->rrset_data, + rrd = regional_alloc_init(region, d->rrset_data, packed_rrset_sizeof(d->rrset_data)); if(!rrd) return NULL; @@ -409,7 +409,7 @@ kd_get_flags(struct packed_rrset_data* data, size_t idx) return f; } -size_t +size_t key_entry_keysize(struct key_entry_key* kkey) { struct packed_rrset_data* d; diff --git a/sbin/unwind/libunbound/validator/val_kentry.h b/sbin/unwind/libunbound/validator/val_kentry.h index ca9f0dabc..836e90445 100644 --- a/sbin/unwind/libunbound/validator/val_kentry.h +++ b/sbin/unwind/libunbound/validator/val_kentry.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -103,7 +103,7 @@ void key_entry_delkeyfunc(void* key, void* userarg); /** function for lruhash operation */ void key_entry_deldatafunc(void* data, void* userarg); -/** calculate hash for key entry +/** calculate hash for key entry * @param kk: key entry. The lruhash entry.hash value is filled in. */ void key_entry_hash(struct key_entry_key* kk); @@ -114,7 +114,7 @@ void key_entry_hash(struct key_entry_key* kk); * @param region: where to allocate it * @return newly region-allocated entry or NULL on a failure to allocate. */ -struct key_entry_key* key_entry_copy_toregion(struct key_entry_key* kkey, +struct key_entry_key* key_entry_copy_toregion(struct key_entry_key* kkey, struct regional* region); /** diff --git a/sbin/unwind/libunbound/validator/val_neg.c b/sbin/unwind/libunbound/validator/val_neg.c index 52bc68387..6e3833bc3 100644 --- a/sbin/unwind/libunbound/validator/val_neg.c +++ b/sbin/unwind/libunbound/validator/val_neg.c @@ -4,22 +4,22 @@ * Copyright (c) 2008, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -85,7 +85,7 @@ int val_neg_zone_compare(const void* a, const void* b) struct val_neg_cache* val_neg_create(struct config_file* cfg, size_t maxiter) { - struct val_neg_cache* neg = (struct val_neg_cache*)calloc(1, + struct val_neg_cache* neg = (struct val_neg_cache*)calloc(1, sizeof(*neg)); if(!neg) { log_err("Could not create neg cache: out of memory"); @@ -144,7 +144,7 @@ void neg_cache_delete(struct val_neg_cache* neg) * @param neg: negative cache with LRU start and end. * @param data: this data is fronted. */ -static void neg_lru_front(struct val_neg_cache* neg, +static void neg_lru_front(struct val_neg_cache* neg, struct val_neg_data* data) { data->prev = NULL; @@ -160,7 +160,7 @@ static void neg_lru_front(struct val_neg_cache* neg, * @param neg: negative cache with LRU start and end. * @param data: this data is removed from the list. */ -static void neg_lru_remove(struct val_neg_cache* neg, +static void neg_lru_remove(struct val_neg_cache* neg, struct val_neg_data* data) { if(data->prev) @@ -176,7 +176,7 @@ static void neg_lru_remove(struct val_neg_cache* neg, * @param neg: negative cache with LRU start and end. * @param data: this data is used. */ -static void neg_lru_touch(struct val_neg_cache* neg, +static void neg_lru_touch(struct val_neg_cache* neg, struct val_neg_data* data) { if(data == neg->first) @@ -222,7 +222,7 @@ static void neg_delete_zone(struct val_neg_cache* neg, struct val_neg_zone* z) p = np; } } - + void neg_delete_data(struct val_neg_cache* neg, struct val_neg_data* el) { struct val_neg_zone* z; @@ -236,7 +236,7 @@ void neg_delete_data(struct val_neg_cache* neg, struct val_neg_data* el) /* remove it from the lru list */ neg_lru_remove(neg, el); log_assert(neg->first != el && neg->last != el); - + /* go up the tree and reduce counts */ p = el; while(p) { @@ -277,7 +277,7 @@ static void neg_make_space(struct val_neg_cache* neg, size_t need) } } -struct val_neg_zone* neg_find_zone(struct val_neg_cache* neg, +struct val_neg_zone* neg_find_zone(struct val_neg_cache* neg, uint8_t* nm, size_t len, uint16_t dclass) { struct val_neg_zone lookfor; @@ -301,7 +301,7 @@ struct val_neg_zone* neg_find_zone(struct val_neg_cache* neg, * @param labs: labels in nm * @return data or NULL if not found. */ -static struct val_neg_data* neg_find_data(struct val_neg_zone* zone, +static struct val_neg_data* neg_find_data(struct val_neg_zone* zone, uint8_t* nm, size_t len, int labs) { struct val_neg_data lookfor; @@ -449,7 +449,7 @@ static struct val_neg_data* neg_closest_data_parent( static struct val_neg_zone* neg_setup_zone_node( uint8_t* nm, size_t nm_len, int labs, uint16_t dclass) { - struct val_neg_zone* zone = + struct val_neg_zone* zone = (struct val_neg_zone*)calloc(1, sizeof(*zone)); if(!zone) { return NULL; @@ -513,7 +513,7 @@ static struct val_neg_zone* neg_zone_chain( dname_remove_label(&nm, &nm_len); } return first; -} +} void val_neg_zone_take_inuse(struct val_neg_zone* zone) { @@ -670,7 +670,7 @@ static struct val_neg_data* neg_data_chain( * @param el: element to start walking at. * @param nsec: the nsec record with the end point */ -static void wipeout(struct val_neg_cache* neg, struct val_neg_zone* zone, +static void wipeout(struct val_neg_cache* neg, struct val_neg_zone* zone, struct val_neg_data* el, struct ub_packed_rrset_key* nsec) { struct packed_rrset_data* d = (struct packed_rrset_data*)nsec-> @@ -697,7 +697,7 @@ static void wipeout(struct val_neg_cache* neg, struct val_neg_zone* zone, } /* sanity check, both owner and end must be below the zone apex */ - if(!dname_subdomain_c(el->name, zone->name) || + if(!dname_subdomain_c(el->name, zone->name) || !dname_subdomain_c(end, zone->name)) return; @@ -710,7 +710,7 @@ static void wipeout(struct val_neg_cache* neg, struct val_neg_zone* zone, while(walk && walk != RBTREE_NULL) { cur = (struct val_neg_data*)walk; /* sanity check: must be larger than start */ - if(dname_canon_lab_cmp(cur->name, cur->labs, + if(dname_canon_lab_cmp(cur->name, cur->labs, el->name, el->labs, &m) <= 0) { /* r == 0 skip original record. */ /* r < 0 too small! */ @@ -718,7 +718,7 @@ static void wipeout(struct val_neg_cache* neg, struct val_neg_zone* zone, continue; } /* stop at endpoint, also data at empty nonterminals must be - * removed (no NSECs there) so everything between + * removed (no NSECs there) so everything between * start and end */ if(end && dname_canon_lab_cmp(cur->name, cur->labs, end, end_labs, &m) >= 0) { @@ -734,7 +734,7 @@ static void wipeout(struct val_neg_cache* neg, struct val_neg_zone* zone, * But it may trigger delete of other data and the * entire zone. However, if that happens, this is done * by deleting the *parents* of the element for deletion, - * and maybe also the entire zone if it is empty. + * and maybe also the entire zone if it is empty. * But parents are smaller in canonical compare, thus, * if a larger element exists, then it is not a parent, * it cannot get deleted, the zone cannot get empty. @@ -745,7 +745,7 @@ static void wipeout(struct val_neg_cache* neg, struct val_neg_zone* zone, } } -void neg_insert_data(struct val_neg_cache* neg, +void neg_insert_data(struct val_neg_cache* neg, struct val_neg_zone* zone, struct ub_packed_rrset_key* nsec) { struct packed_rrset_data* d; @@ -759,8 +759,8 @@ void neg_insert_data(struct val_neg_cache* neg, if( !(d->security == sec_status_secure || (d->security == sec_status_unchecked && d->rrsig_count > 0))) return; - log_nametypeclass(VERB_ALGO, "negcache rr", - nsec->rk.dname, ntohs(nsec->rk.type), + log_nametypeclass(VERB_ALGO, "negcache rr", + nsec->rk.dname, ntohs(nsec->rk.type), ntohs(nsec->rk.rrset_class)); /* find closest enclosing parent data that (still) exists */ @@ -769,7 +769,7 @@ void neg_insert_data(struct val_neg_cache* neg, /* perfect match already exists */ log_assert(parent->count > 0); el = parent; - } else { + } else { struct val_neg_data* p, *np; /* create subtree for perfect match */ @@ -822,7 +822,7 @@ void neg_insert_data(struct val_neg_cache* neg, if(nsec3_get_params(nsec, 0, &h, &it, &s, &slen) && it <= neg->nsec3_max_iter && (h != zone->nsec3_hash || it != zone->nsec3_iter || - slen != zone->nsec3_saltlen || + slen != zone->nsec3_saltlen || memcmp(zone->nsec3_salt, s, slen) != 0)) { if(slen > 0) { @@ -893,7 +893,7 @@ void val_neg_addreply(struct val_neg_cache* neg, struct reply_info* rep) rrset_class = ntohs(soa->rk.rrset_class); } else { - /* No SOA in positive (wildcard) answer. Use signer from the + /* No SOA in positive (wildcard) answer. Use signer from the * validated answer RRsets' signature. */ if(!(dname = reply_nsec_signer(rep, &dname_len, &rrset_class))) return; @@ -901,9 +901,9 @@ void val_neg_addreply(struct val_neg_cache* neg, struct reply_info* rep) log_nametypeclass(VERB_ALGO, "negcache insert for zone", dname, LDNS_RR_TYPE_SOA, rrset_class); - + /* ask for enough space to store all of it */ - need = calc_data_need(rep) + + need = calc_data_need(rep) + calc_zone_need(dname, dname_len); lock_basic_lock(&neg->lock); neg_make_space(neg, need); @@ -924,7 +924,7 @@ void val_neg_addreply(struct val_neg_cache* neg, struct reply_info* rep) for(i=rep->an_numrrsets; i< rep->an_numrrsets+rep->ns_numrrsets; i++){ if(ntohs(rep->rrsets[i]->rk.type) != LDNS_RR_TYPE_NSEC) continue; - if(!dname_subdomain_c(rep->rrsets[i]->rk.dname, + if(!dname_subdomain_c(rep->rrsets[i]->rk.dname, zone->name)) continue; /* insert NSEC into this zone's tree */ neg_insert_data(neg, zone, rep->rrsets[i]); @@ -976,7 +976,7 @@ void val_neg_addreferral(struct val_neg_cache* neg, struct reply_info* rep, /* no SOA in this message, find RRSIG over NSEC's signer name. * note the NSEC records are maybe not validated yet */ signer = reply_nsec_signer(rep, &signer_len, &dclass); - if(!signer) + if(!signer) return; if(!dname_subdomain_c(signer, zone_name)) { /* the signer is not in the bailiwick, throw it out */ @@ -985,7 +985,7 @@ void val_neg_addreferral(struct val_neg_cache* neg, struct reply_info* rep, log_nametypeclass(VERB_ALGO, "negcache insert referral ", signer, LDNS_RR_TYPE_NS, dclass); - + /* ask for enough space to store all of it */ need = calc_data_need(rep) + calc_zone_need(signer, signer_len); lock_basic_lock(&neg->lock); @@ -994,7 +994,7 @@ void val_neg_addreferral(struct val_neg_cache* neg, struct reply_info* rep, /* find or create the zone entry */ zone = neg_find_zone(neg, signer, signer_len, dclass); if(!zone) { - if(!(zone = neg_create_zone(neg, signer, signer_len, + if(!(zone = neg_create_zone(neg, signer, signer_len, dclass))) { lock_basic_unlock(&neg->lock); log_err("out of memory adding negative zone"); @@ -1008,7 +1008,7 @@ void val_neg_addreferral(struct val_neg_cache* neg, struct reply_info* rep, if(ntohs(rep->rrsets[i]->rk.type) != LDNS_RR_TYPE_NSEC && ntohs(rep->rrsets[i]->rk.type) != LDNS_RR_TYPE_NSEC3) continue; - if(!dname_subdomain_c(rep->rrsets[i]->rk.dname, + if(!dname_subdomain_c(rep->rrsets[i]->rk.dname, zone->name)) continue; /* insert NSEC into this zone's tree */ neg_insert_data(neg, zone, rep->rrsets[i]); @@ -1057,8 +1057,8 @@ static int nsec3_no_type(struct ub_packed_rrset_key* k, uint16_t t) */ static struct ub_packed_rrset_key* grab_nsec(struct rrset_cache* rrset_cache, uint8_t* qname, size_t qname_len, - uint16_t qtype, uint16_t qclass, uint32_t flags, - struct regional* region, int checkbit, uint16_t checktype, + uint16_t qtype, uint16_t qclass, uint32_t flags, + struct regional* region, int checkbit, uint16_t checktype, time_t now) { struct ub_packed_rrset_key* r, *k = rrset_cache_lookup(rrset_cache, @@ -1172,8 +1172,8 @@ neg_find_nsec3_ce(struct val_neg_zone* zone, uint8_t* qname, size_t qname_len, *nclen = 0; while(qlabs > 0) { /* hash */ - if(!(celen=nsec3_get_hashed(buf, qname, qname_len, - zone->nsec3_hash, zone->nsec3_iter, zone->nsec3_salt, + if(!(celen=nsec3_get_hashed(buf, qname, qname_len, + zone->nsec3_hash, zone->nsec3_iter, zone->nsec3_salt, zone->nsec3_saltlen, hashce, sizeof(hashce)))) return NULL; if(!(b32len=nsec3_hash_to_b32(hashce, celen, zone->name, @@ -1212,7 +1212,7 @@ neg_params_ok(struct val_neg_zone* zone, struct ub_packed_rrset_key* rrset) /** get next closer for nsec3 proof */ static struct ub_packed_rrset_key* neg_nsec3_getnc(struct val_neg_zone* zone, uint8_t* hashnc, size_t nclen, - struct rrset_cache* rrset_cache, struct regional* region, + struct rrset_cache* rrset_cache, struct regional* region, time_t now, uint8_t* b32, size_t maxb32) { struct ub_packed_rrset_key* nc_rrset; @@ -1233,7 +1233,7 @@ neg_nsec3_getnc(struct val_neg_zone* zone, uint8_t* hashnc, size_t nclen, if(!data) return NULL; /* got a data element in tree, grab it */ - nc_rrset = grab_nsec(rrset_cache, data->name, data->len, + nc_rrset = grab_nsec(rrset_cache, data->name, data->len, LDNS_RR_TYPE_NSEC3, zone->dclass, 0, region, 0, 0, now); if(!nc_rrset) return NULL; @@ -1258,13 +1258,13 @@ neg_nsec3_proof_ds(struct val_neg_zone* zone, uint8_t* qname, size_t qname_len, /* for NSEC3 ; determine the closest encloser for which we * can find an exact match. Remember the hashed lower name, - * since that is the one we need a closest match for. + * since that is the one we need a closest match for. * If we find a match straight away, then it becomes NODATA. * Otherwise, NXDOMAIN or if OPTOUT, an insecure delegation. * Also check that parameters are the same on closest encloser * and on closest match. */ - if(!zone->nsec3_hash) + if(!zone->nsec3_hash) return NULL; /* not nsec3 zone */ if(!(data=neg_find_nsec3_ce(zone, qname, qname_len, qlabs, buf, @@ -1273,8 +1273,8 @@ neg_nsec3_proof_ds(struct val_neg_zone* zone, uint8_t* qname, size_t qname_len, } /* grab the ce rrset */ - ce_rrset = grab_nsec(rrset_cache, data->name, data->len, - LDNS_RR_TYPE_NSEC3, zone->dclass, 0, region, 1, + ce_rrset = grab_nsec(rrset_cache, data->name, data->len, + LDNS_RR_TYPE_NSEC3, zone->dclass, 0, region, 1, LDNS_RR_TYPE_DS, now); if(!ce_rrset) return NULL; @@ -1288,11 +1288,11 @@ neg_nsec3_proof_ds(struct val_neg_zone* zone, uint8_t* qname, size_t qname_len, nsec3_has_type(ce_rrset, 0, LDNS_RR_TYPE_DS) || !nsec3_has_type(ce_rrset, 0, LDNS_RR_TYPE_NS)) return NULL; - if(!(msg = dns_msg_create(qname, qname_len, - LDNS_RR_TYPE_DS, zone->dclass, region, 1))) + if(!(msg = dns_msg_create(qname, qname_len, + LDNS_RR_TYPE_DS, zone->dclass, region, 1))) return NULL; /* TTL reduced in grab_nsec */ - if(!dns_msg_authadd(msg, region, ce_rrset, 0)) + if(!dns_msg_authadd(msg, region, ce_rrset, 0)) return NULL; return msg; } @@ -1304,9 +1304,9 @@ neg_nsec3_proof_ds(struct val_neg_zone* zone, uint8_t* qname, size_t qname_len, /* if there is no exact match, it must be in an optout span * (an existing DS implies an NSEC3 must exist) */ - nc_rrset = neg_nsec3_getnc(zone, hashnc, nclen, rrset_cache, + nc_rrset = neg_nsec3_getnc(zone, hashnc, nclen, rrset_cache, region, now, nc_b32, sizeof(nc_b32)); - if(!nc_rrset) + if(!nc_rrset) return NULL; if(!neg_params_ok(zone, nc_rrset)) return NULL; @@ -1322,13 +1322,13 @@ neg_nsec3_proof_ds(struct val_neg_zone* zone, uint8_t* qname, size_t qname_len, * nc_rrset is optout. * No need to check wildcard for type DS */ /* capacity=3: ce + nc + soa(if needed) */ - if(!(msg = dns_msg_create(qname, qname_len, - LDNS_RR_TYPE_DS, zone->dclass, region, 3))) + if(!(msg = dns_msg_create(qname, qname_len, + LDNS_RR_TYPE_DS, zone->dclass, region, 3))) return NULL; /* now=0 because TTL was reduced in grab_nsec */ - if(!dns_msg_authadd(msg, region, ce_rrset, 0)) + if(!dns_msg_authadd(msg, region, ce_rrset, 0)) return NULL; - if(!dns_msg_authadd(msg, region, nc_rrset, 0)) + if(!dns_msg_authadd(msg, region, nc_rrset, 0)) return NULL; return msg; } @@ -1358,10 +1358,10 @@ static int add_soa(struct rrset_cache* rrset_cache, time_t now, } else { /* Assumes the signer is the zone SOA to add */ nm = reply_nsec_signer(msg->rep, &nmlen, &dclass); - if(!nm) + if(!nm) return 0; } - soa = rrset_cache_lookup(rrset_cache, nm, nmlen, LDNS_RR_TYPE_SOA, + soa = rrset_cache_lookup(rrset_cache, nm, nmlen, LDNS_RR_TYPE_SOA, dclass, PACKED_RRSET_SOA_NEG, now, 0); if(!soa) return 0; @@ -1373,9 +1373,9 @@ static int add_soa(struct rrset_cache* rrset_cache, time_t now, return 1; } -struct dns_msg* -val_neg_getmsg(struct val_neg_cache* neg, struct query_info* qinfo, - struct regional* region, struct rrset_cache* rrset_cache, +struct dns_msg* +val_neg_getmsg(struct val_neg_cache* neg, struct query_info* qinfo, + struct regional* region, struct rrset_cache* rrset_cache, sldns_buffer* buf, time_t now, int addsoa, uint8_t* topname, struct config_file* cfg) { @@ -1412,10 +1412,10 @@ val_neg_getmsg(struct val_neg_cache* neg, struct query_info* qinfo, * qtype ANY, in the else branch. */ if(qinfo->qtype == LDNS_RR_TYPE_ANY) return NULL; - if(!(msg = dns_msg_create(qinfo->qname, qinfo->qname_len, - qinfo->qtype, qinfo->qclass, region, 2))) + if(!(msg = dns_msg_create(qinfo->qname, qinfo->qname_len, + qinfo->qtype, qinfo->qclass, region, 2))) return NULL; - if(!dns_msg_authadd(msg, region, nsec, 0)) + if(!dns_msg_authadd(msg, region, nsec, 0)) return NULL; if(addsoa && !add_soa(rrset_cache, now, region, msg, NULL)) return NULL; @@ -1425,8 +1425,8 @@ val_neg_getmsg(struct val_neg_cache* neg, struct query_info* qinfo, lock_basic_unlock(&neg->lock); return msg; } else if(nsec && val_nsec_proves_name_error(nsec, qinfo->qname)) { - if(!(msg = dns_msg_create(qinfo->qname, qinfo->qname_len, - qinfo->qtype, qinfo->qclass, region, 3))) + if(!(msg = dns_msg_create(qinfo->qname, qinfo->qname_len, + qinfo->qtype, qinfo->qclass, region, 3))) return NULL; if(!(ce = nsec_closest_encloser(qinfo->qname, nsec))) return NULL; @@ -1528,7 +1528,7 @@ val_neg_getmsg(struct val_neg_cache* neg, struct query_info* qinfo, /* lookup closest zone */ lock_basic_lock(&neg->lock); - zone = neg_closest_zone_parent(neg, zname, zname_len, zname_labs, + zone = neg_closest_zone_parent(neg, zname, zname_len, zname_labs, qinfo->qclass); while(zone && !zone->in_use) zone = zone->parent; @@ -1543,7 +1543,7 @@ val_neg_getmsg(struct val_neg_cache* neg, struct query_info* qinfo, return NULL; } - msg = neg_nsec3_proof_ds(zone, qinfo->qname, qinfo->qname_len, + msg = neg_nsec3_proof_ds(zone, qinfo->qname, qinfo->qname_len, zname_labs+1, buf, rrset_cache, region, now, topname); if(msg && addsoa && !add_soa(rrset_cache, now, region, msg, zone)) { lock_basic_unlock(&neg->lock); diff --git a/sbin/unwind/libunbound/validator/val_neg.h b/sbin/unwind/libunbound/validator/val_neg.h index 5643ca331..5452f8cf7 100644 --- a/sbin/unwind/libunbound/validator/val_neg.h +++ b/sbin/unwind/libunbound/validator/val_neg.h @@ -4,22 +4,22 @@ * Copyright (c) 2008, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -57,15 +57,15 @@ struct dns_msg; struct ub_packed_rrset_key; /** - * The negative cache. It is shared between the threads, so locked. + * The negative cache. It is shared between the threads, so locked. * Kept as validator-environ-state. It refers back to the rrset cache for - * data elements. It can be out of date and contain conflicting data - * from zone content changes. + * data elements. It can be out of date and contain conflicting data + * from zone content changes. * It contains a tree of zones, every zone has a tree of data elements. * The data elements are part of one big LRU list, with one memory counter. */ struct val_neg_cache { - /** the big lock on the negative cache. Because we use a rbtree + /** the big lock on the negative cache. Because we use a rbtree * for the data (quick lookup), we need a big lock */ lock_basic_type lock; /** The zone rbtree. contents sorted canonical, type val_neg_zone */ @@ -105,7 +105,7 @@ struct val_neg_zone { struct val_neg_zone* parent; /** the number of elements, including this one and the ones whose - * parents (-parents) include this one, that are in_use + * parents (-parents) include this one, that are in_use * No elements have a count of zero, those are removed. */ int count; @@ -118,7 +118,7 @@ struct val_neg_zone { /** length of salt in bytes */ size_t nsec3_saltlen; - /** tree of NSEC data for this zone, sorted canonical + /** tree of NSEC data for this zone, sorted canonical * by NSEC owner name */ rbtree_type tree; @@ -153,7 +153,7 @@ struct val_neg_data { struct val_neg_data* parent; /** the number of elements, including this one and the ones whose - * parents (-parents) include this one, that are in use + * parents (-parents) include this one, that are in use * No elements have a count of zero, those are removed. */ int count; @@ -190,12 +190,12 @@ size_t val_neg_get_mem(struct val_neg_cache* neg); */ void neg_cache_delete(struct val_neg_cache* neg); -/** +/** * Comparison function for rbtree val neg data elements */ int val_neg_data_compare(const void* a, const void* b); -/** +/** * Comparison function for rbtree val neg zone elements */ int val_neg_zone_compare(const void* a, const void* b); @@ -229,7 +229,7 @@ void val_neg_addreferral(struct val_neg_cache* neg, struct reply_info* rep, * @param now: to check TTLs against. * @param addsoa: if true, produce result for external consumption. * if false, do not add SOA - for unbound-internal consumption. - * @param topname: do not look higher than this name, + * @param topname: do not look higher than this name, * so that the result cannot be taken from a zone above the current * trust anchor. Which could happen with multiple islands of trust. * if NULL, then no trust anchor is used, but also the algorithm becomes @@ -237,12 +237,12 @@ void val_neg_addreferral(struct val_neg_cache* neg, struct reply_info* rep, * may have a trust-anchor below the optout and thus the optout cannot * be used to create a proof from the negative cache. * @param cfg: config options. - * @return a reply message if something was found. + * @return a reply message if something was found. * This reply may still need validation. * NULL if nothing found (or out of memory). */ -struct dns_msg* val_neg_getmsg(struct val_neg_cache* neg, - struct query_info* qinfo, struct regional* region, +struct dns_msg* val_neg_getmsg(struct val_neg_cache* neg, + struct query_info* qinfo, struct regional* region, struct rrset_cache* rrset_cache, struct sldns_buffer* buf, time_t now, int addsoa, uint8_t* topname, struct config_file* cfg); diff --git a/sbin/unwind/libunbound/validator/val_nsec.c b/sbin/unwind/libunbound/validator/val_nsec.c index 17c90d83f..9fa760acc 100644 --- a/sbin/unwind/libunbound/validator/val_nsec.c +++ b/sbin/unwind/libunbound/validator/val_nsec.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -50,7 +50,7 @@ #include "services/cache/rrset.h" /** get ttl of rrset */ -static uint32_t +static uint32_t rrset_get_ttl(struct ub_packed_rrset_key* k) { struct packed_rrset_data* d = (struct packed_rrset_data*)k->entry.data; @@ -74,7 +74,7 @@ nsecbitmap_has_type_rdata(uint8_t* bitmap, size_t len, uint16_t type) win = *bitmap++; winlen = *bitmap++; len -= 2; - if(len < winlen || winlen < 1 || winlen > 32) + if(len < winlen || winlen < 1 || winlen > 32) return 0; /* bad window length */ if(win == type_window) { /* search window bitmap for the correct byte */ @@ -104,7 +104,7 @@ nsec_has_type(struct ub_packed_rrset_key* nsec, uint16_t type) len = dname_valid(d->rr_data[0]+2, d->rr_len[0]-2); if(!len) return 0; - return nsecbitmap_has_type_rdata(d->rr_data[0]+2+len, + return nsecbitmap_has_type_rdata(d->rr_data[0]+2+len, d->rr_len[0]-2-len, type); } @@ -116,7 +116,7 @@ nsec_has_type(struct ub_packed_rrset_key* nsec, uint16_t type) * @param ln: length of nm is returned. * @return false on a bad NSEC RR (too short, malformed dname). */ -static int +static int nsec_get_next(struct ub_packed_rrset_key* nsec, uint8_t** nm, size_t* ln) { struct packed_rrset_data* d = (struct packed_rrset_data*)nsec-> @@ -141,30 +141,30 @@ nsec_get_next(struct ub_packed_rrset_key* nsec, uint8_t** nm, size_t* ln) * * @param nsec: NSEC for proof, must be trusted. * @param qinfo: what is queried for. - * @return if secure the nsec proves that no DS is present, or + * @return if secure the nsec proves that no DS is present, or * insecure if it proves it is not a delegation point. * or bogus if something was wrong. */ -static enum sec_status -val_nsec_proves_no_ds(struct ub_packed_rrset_key* nsec, +static enum sec_status +val_nsec_proves_no_ds(struct ub_packed_rrset_key* nsec, struct query_info* qinfo) { log_assert(qinfo->qtype == LDNS_RR_TYPE_DS); log_assert(ntohs(nsec->rk.type) == LDNS_RR_TYPE_NSEC); if(nsec_has_type(nsec, LDNS_RR_TYPE_SOA) && qinfo->qname_len != 1) { - /* SOA present means that this is the NSEC from the child, + /* SOA present means that this is the NSEC from the child, * not the parent (so it is the wrong one). */ return sec_status_bogus; } if(nsec_has_type(nsec, LDNS_RR_TYPE_DS)) { - /* DS present means that there should have been a positive + /* DS present means that there should have been a positive * response to the DS query, so there is something wrong. */ return sec_status_bogus; } if(!nsec_has_type(nsec, LDNS_RR_TYPE_NS)) { - /* If there is no NS at this point at all, then this + /* If there is no NS at this point at all, then this * doesn't prove anything one way or the other. */ return sec_status_insecure; } @@ -196,14 +196,14 @@ nsec_verify_rrset(struct module_env* env, struct val_env* ve, return 0; } -enum sec_status -val_nsec_prove_nodata_dsreply(struct module_env* env, struct val_env* ve, - struct query_info* qinfo, struct reply_info* rep, +enum sec_status +val_nsec_prove_nodata_dsreply(struct module_env* env, struct val_env* ve, + struct query_info* qinfo, struct reply_info* rep, struct key_entry_key* kkey, time_t* proof_ttl, char** reason, sldns_ede_code* reason_bogus, struct module_qstate* qstate) { struct ub_packed_rrset_key* nsec = reply_find_rrset_section_ns( - rep, qinfo->qname, qinfo->qname_len, LDNS_RR_TYPE_NSEC, + rep, qinfo->qname, qinfo->qname_len, LDNS_RR_TYPE_NSEC, qinfo->qclass); enum sec_status sec; size_t i; @@ -211,7 +211,7 @@ val_nsec_prove_nodata_dsreply(struct module_env* env, struct val_env* ve, int valid_nsec = 0; struct ub_packed_rrset_key* wc_nsec = NULL; - /* If we have a NSEC at the same name, it must prove one + /* If we have a NSEC at the same name, it must prove one * of two things * -- * 1) this is a delegation point and there is no DS @@ -240,11 +240,11 @@ val_nsec_prove_nodata_dsreply(struct module_env* env, struct val_env* ve, /* if unchecked, fall through to next proof */ } - /* Otherwise, there is no NSEC at qname. This could be an ENT. + /* Otherwise, there is no NSEC at qname. This could be an ENT. * (ENT=empty non terminal). If not, this is broken. */ - + /* verify NSEC rrsets in auth section */ - for(i=rep->an_numrrsets; i < rep->an_numrrsets+rep->ns_numrrsets; + for(i=rep->an_numrrsets; i < rep->an_numrrsets+rep->ns_numrrsets; i++) { if(rep->rrsets[i]->rk.type != htons(LDNS_RR_TYPE_NSEC)) continue; @@ -260,12 +260,12 @@ val_nsec_prove_nodata_dsreply(struct module_env* env, struct val_env* ve, verbose(VERB_ALGO, "NSEC for empty non-terminal " "proved no DS."); *proof_ttl = rrset_get_ttl(rep->rrsets[i]); - if(wc && dname_is_wild(rep->rrsets[i]->rk.dname)) + if(wc && dname_is_wild(rep->rrsets[i]->rk.dname)) wc_nsec = rep->rrsets[i]; valid_nsec = 1; } if(val_nsec_proves_name_error(rep->rrsets[i], qinfo->qname)) { - ce = nsec_closest_encloser(qinfo->qname, + ce = nsec_closest_encloser(qinfo->qname, rep->rrsets[i]); } } @@ -273,7 +273,7 @@ val_nsec_prove_nodata_dsreply(struct module_env* env, struct val_env* ve, valid_nsec = 0; else if(wc && ce) { /* ce and wc must match */ - if(query_dname_compare(wc, ce) != 0) + if(query_dname_compare(wc, ce) != 0) valid_nsec = 0; else if(!wc_nsec) valid_nsec = 0; @@ -292,7 +292,7 @@ val_nsec_prove_nodata_dsreply(struct module_env* env, struct val_env* ve, return sec_status_unchecked; } -int nsec_proves_nodata(struct ub_packed_rrset_key* nsec, +int nsec_proves_nodata(struct ub_packed_rrset_key* nsec, struct query_info* qinfo, uint8_t** wc) { log_assert(wc); @@ -300,27 +300,27 @@ int nsec_proves_nodata(struct ub_packed_rrset_key* nsec, uint8_t* nm; size_t ln; - /* empty-non-terminal checking. + /* empty-non-terminal checking. * Done before wildcard, because this is an exact match, * and would prevent a wildcard from matching. */ - /* If the nsec is proving that qname is an ENT, the nsec owner - * will be less than qname, and the next name will be a child + /* If the nsec is proving that qname is an ENT, the nsec owner + * will be less than qname, and the next name will be a child * domain of the qname. */ if(!nsec_get_next(nsec, &nm, &ln)) return 0; /* bad nsec */ if(dname_strict_subdomain_c(nm, qinfo->qname) && - dname_canonical_compare(nsec->rk.dname, + dname_canonical_compare(nsec->rk.dname, qinfo->qname) < 0) { return 1; /* proves ENT */ } /* wildcard checking. */ - /* If this is a wildcard NSEC, make sure that a) it was - * possible to have generated qname from the wildcard and - * b) the type map does not contain qtype. Note that this - * does NOT prove that this wildcard was the applicable + /* If this is a wildcard NSEC, make sure that a) it was + * possible to have generated qname from the wildcard and + * b) the type map does not contain qtype. Note that this + * does NOT prove that this wildcard was the applicable * wildcard. */ if(dname_is_wild(nsec->rk.dname)) { /* the purported closest encloser. */ @@ -328,8 +328,8 @@ int nsec_proves_nodata(struct ub_packed_rrset_key* nsec, size_t ce_len = nsec->rk.dname_len; dname_remove_label(&ce, &ce_len); - /* The qname must be a strict subdomain of the - * closest encloser, for the wildcard to apply + /* The qname must be a strict subdomain of the + * closest encloser, for the wildcard to apply */ if(dname_strict_subdomain_c(qinfo->qname, ce)) { /* here we have a matching NSEC for the qname, @@ -338,7 +338,7 @@ int nsec_proves_nodata(struct ub_packed_rrset_key* nsec, /* should have gotten the wildcard CNAME */ return 0; } - if(nsec_has_type(nsec, LDNS_RR_TYPE_NS) && + if(nsec_has_type(nsec, LDNS_RR_TYPE_NS) && !nsec_has_type(nsec, LDNS_RR_TYPE_SOA)) { /* wrong parentside (wildcard) NSEC used */ return 0; @@ -373,7 +373,7 @@ int nsec_proves_nodata(struct ub_packed_rrset_key* nsec, } } - /* Otherwise, this NSEC does not prove ENT and is not a + /* Otherwise, this NSEC does not prove ENT and is not a * wildcard, so it does not prove NODATA. */ return 0; } @@ -388,13 +388,13 @@ int nsec_proves_nodata(struct ub_packed_rrset_key* nsec, return 0; } - /* If an NS set exists at this name, and NOT a SOA (so this is a - * zone cut, not a zone apex), then we should have gotten a - * referral (or we just got the wrong NSEC). + /* If an NS set exists at this name, and NOT a SOA (so this is a + * zone cut, not a zone apex), then we should have gotten a + * referral (or we just got the wrong NSEC). * The reverse of this check is used when qtype is DS, since that * must use the NSEC from above the zone cut. */ if(qinfo->qtype != LDNS_RR_TYPE_DS && - nsec_has_type(nsec, LDNS_RR_TYPE_NS) && + nsec_has_type(nsec, LDNS_RR_TYPE_NS) && !nsec_has_type(nsec, LDNS_RR_TYPE_SOA)) { return 0; } else if(qinfo->qtype == LDNS_RR_TYPE_DS && @@ -406,7 +406,7 @@ int nsec_proves_nodata(struct ub_packed_rrset_key* nsec, return 1; } -int +int val_nsec_proves_name_error(struct ub_packed_rrset_key* nsec, uint8_t* qname) { uint8_t* owner = nsec->rk.dname; @@ -421,11 +421,11 @@ val_nsec_proves_name_error(struct ub_packed_rrset_key* nsec, uint8_t* qname) } /* If NSEC is a parent of qname, we need to check the type map - * If the parent name has a DNAME or is a delegation point, then + * If the parent name has a DNAME or is a delegation point, then * this NSEC is being misused. */ - if(dname_subdomain_c(qname, owner) && + if(dname_subdomain_c(qname, owner) && (nsec_has_type(nsec, LDNS_RR_TYPE_DNAME) || - (nsec_has_type(nsec, LDNS_RR_TYPE_NS) + (nsec_has_type(nsec, LDNS_RR_TYPE_NS) && !nsec_has_type(nsec, LDNS_RR_TYPE_SOA)) )) { return 0; @@ -440,8 +440,8 @@ val_nsec_proves_name_error(struct ub_packed_rrset_key* nsec, uint8_t* qname) } else if(dname_canonical_compare(owner, next) > 0) { /* this is the last nsec, ....(bigger) NSEC zonename(smaller) */ - /* the names after the last (owner) name do not exist - * there are no names before the zone name in the zone + /* the names after the last (owner) name do not exist + * there are no names before the zone name in the zone * but the qname must be a subdomain of the zone name(next). */ if(dname_canonical_compare(owner, qname) < 0 && dname_strict_subdomain_c(qname, next)) @@ -456,7 +456,7 @@ val_nsec_proves_name_error(struct ub_packed_rrset_key* nsec, uint8_t* qname) return 0; } -int val_nsec_proves_insecuredelegation(struct ub_packed_rrset_key* nsec, +int val_nsec_proves_insecuredelegation(struct ub_packed_rrset_key* nsec, struct query_info* qinfo) { if(nsec_has_type(nsec, LDNS_RR_TYPE_NS) && @@ -477,7 +477,7 @@ int val_nsec_proves_insecuredelegation(struct ub_packed_rrset_key* nsec, return 0; } -uint8_t* +uint8_t* nsec_closest_encloser(uint8_t* qname, struct ub_packed_rrset_key* nsec) { uint8_t* next; @@ -493,11 +493,11 @@ nsec_closest_encloser(uint8_t* qname, struct ub_packed_rrset_key* nsec) return common2; } -int val_nsec_proves_positive_wildcard(struct ub_packed_rrset_key* nsec, +int val_nsec_proves_positive_wildcard(struct ub_packed_rrset_key* nsec, struct query_info* qinf, uint8_t* wc) { uint8_t* ce; - /* 1) prove that qname doesn't exist and + /* 1) prove that qname doesn't exist and * 2) that the correct wildcard was used * nsec has been verified already. */ if(!val_nsec_proves_name_error(nsec, qinf->qname)) @@ -512,11 +512,11 @@ int val_nsec_proves_positive_wildcard(struct ub_packed_rrset_key* nsec, return 1; } -int -val_nsec_proves_no_wc(struct ub_packed_rrset_key* nsec, uint8_t* qname, +int +val_nsec_proves_no_wc(struct ub_packed_rrset_key* nsec, uint8_t* qname, size_t qnamelen) { - /* Determine if a NSEC record proves the non-existence of a + /* Determine if a NSEC record proves the non-existence of a * wildcard that could have produced qname. */ int labs; uint8_t* ce = nsec_closest_encloser(qname, nsec); @@ -527,7 +527,7 @@ val_nsec_proves_no_wc(struct ub_packed_rrset_key* nsec, uint8_t* qname, return 0; /* we can subtract the closest encloser count - since that is the * largest shared topdomain with owner and next NSEC name, - * because the NSEC is no proof for names shorter than the owner + * because the NSEC is no proof for names shorter than the owner * and next names. */ labs = dname_count_labels(qname) - dname_count_labels(ce); diff --git a/sbin/unwind/libunbound/validator/val_nsec.h b/sbin/unwind/libunbound/validator/val_nsec.h index 81844c908..41f57c36e 100644 --- a/sbin/unwind/libunbound/validator/val_nsec.h +++ b/sbin/unwind/libunbound/validator/val_nsec.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -71,16 +71,16 @@ struct key_entry_key; * @return security status. * SECURE: proved absence of DS. * INSECURE: proved that this was not a delegation point. - * BOGUS: crypto bad, or no absence of DS proven. + * BOGUS: crypto bad, or no absence of DS proven. * UNCHECKED: there was no way to prove anything (no NSECs, unknown algo). */ enum sec_status val_nsec_prove_nodata_dsreply(struct module_env* env, - struct val_env* ve, struct query_info* qinfo, + struct val_env* ve, struct query_info* qinfo, struct reply_info* rep, struct key_entry_key* kkey, time_t* proof_ttl, char** reason, sldns_ede_code* reason_bogus, struct module_qstate* qstate); -/** +/** * nsec typemap check, takes an NSEC-type bitmap as argument, checks for type. * @param bitmap: pointer to the bitmap part of wireformat rdata. * @param len: length of the bitmap, in bytes. @@ -115,7 +115,7 @@ int nsec_has_type(struct ub_packed_rrset_key* nsec, uint16_t type); * nextcloser of qname. * @return true if NSEC proves this. */ -int nsec_proves_nodata(struct ub_packed_rrset_key* nsec, +int nsec_proves_nodata(struct ub_packed_rrset_key* nsec, struct query_info* qinfo, uint8_t** wc); /** @@ -126,7 +126,7 @@ int nsec_proves_nodata(struct ub_packed_rrset_key* nsec, * @param qname: what was queried. * @return true if proven. */ -int val_nsec_proves_name_error(struct ub_packed_rrset_key* nsec, +int val_nsec_proves_name_error(struct ub_packed_rrset_key* nsec, uint8_t* qname); /** @@ -136,18 +136,18 @@ int val_nsec_proves_name_error(struct ub_packed_rrset_key* nsec, * @param wc: wildcard (without *. label) * @return true if proven. */ -int val_nsec_proves_positive_wildcard(struct ub_packed_rrset_key* nsec, +int val_nsec_proves_positive_wildcard(struct ub_packed_rrset_key* nsec, struct query_info* qinf, uint8_t* wc); /** * Determine closest encloser of a query name and the NSEC that covers it - * (and thus disproved it). + * (and thus disproved it). * A name error must have been proven already, otherwise this will be invalid. * @param qname: the name queried for. * @param nsec: the nsec RRset. * @return closest encloser dname or NULL on error (bad nsec RRset). */ -uint8_t* nsec_closest_encloser(uint8_t* qname, +uint8_t* nsec_closest_encloser(uint8_t* qname, struct ub_packed_rrset_key* nsec); /** @@ -158,7 +158,7 @@ uint8_t* nsec_closest_encloser(uint8_t* qname, * @param qnamelen: length of qname. * @return true if proven. */ -int val_nsec_proves_no_wc(struct ub_packed_rrset_key* nsec, uint8_t* qname, +int val_nsec_proves_no_wc(struct ub_packed_rrset_key* nsec, uint8_t* qname, size_t qnamelen); /** diff --git a/sbin/unwind/libunbound/validator/val_nsec3.c b/sbin/unwind/libunbound/validator/val_nsec3.c index a2b3794f6..c5726c3c7 100644 --- a/sbin/unwind/libunbound/validator/val_nsec3.c +++ b/sbin/unwind/libunbound/validator/val_nsec3.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -58,17 +58,17 @@ #include "validator/val_nsec.h" #include "sldns/sbuffer.h" -/** - * This function we get from ldns-compat or from base system +/** + * This function we get from ldns-compat or from base system * it returns the number of data bytes stored at the target, or <0 on error. */ int sldns_b32_ntop_extended_hex(uint8_t const *src, size_t srclength, char *target, size_t targsize); -/** - * This function we get from ldns-compat or from base system +/** + * This function we get from ldns-compat or from base system * it returns the number of data bytes stored at the target, or <0 on error. */ -int sldns_b32_pton_extended_hex(char const *src, size_t hashed_owner_str_len, +int sldns_b32_pton_extended_hex(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize); /** @@ -255,7 +255,7 @@ size_t nsec3_hash_to_b32(uint8_t* hash, size_t hashlen, uint8_t* zone, if(max < hashlen*2+1) /* quick approx of b32, as if hexb16 */ return 0; ret = sldns_b32_ntop_extended_hex(hash, hashlen, (char*)buf+1, max-1); - if(ret < 1) + if(ret < 1) return 0; buf[0] = (uint8_t)ret; /* length of b32 label */ ret++; @@ -291,31 +291,31 @@ nsec3_has_type(struct ub_packed_rrset_key* rrset, int r, uint16_t type) /* skip salt */ if(d->rr_len[r] < skiplen+1) return 0; /* malformed, too short */ - skiplen += 1+(size_t)d->rr_data[r][skiplen]; + skiplen += 1+(size_t)d->rr_data[r][skiplen]; /* skip next hashed owner */ if(d->rr_len[r] < skiplen+1) return 0; /* malformed, too short */ - skiplen += 1+(size_t)d->rr_data[r][skiplen]; + skiplen += 1+(size_t)d->rr_data[r][skiplen]; if(d->rr_len[r] < skiplen) return 0; /* malformed, too short */ bitlen = d->rr_len[r] - skiplen; bitmap = d->rr_data[r]+skiplen; return nsecbitmap_has_type_rdata(bitmap, bitlen, type); } - -/** - * Iterate through NSEC3 list, per RR - * This routine gives the next RR in the list (or sets rrset null). + +/** + * Iterate through NSEC3 list, per RR + * This routine gives the next RR in the list (or sets rrset null). * Usage: * * size_t rrsetnum; * int rrnum; * struct ub_packed_rrset_key* rrset; - * for(rrset=filter_first(filter, &rrsetnum, &rrnum); rrset; + * for(rrset=filter_first(filter, &rrsetnum, &rrnum); rrset; * rrset=filter_next(filter, &rrsetnum, &rrnum)) * do_stuff; - * - * Also filters out + * + * Also filters out * o unknown flag NSEC3s * o unknown algorithm NSEC3s. * @param filter: nsec3 filter structure. @@ -335,8 +335,8 @@ filter_next(struct nsec3_filter* filter, size_t* rrsetnum, int* rrnum) for(i=*rrsetnum; inum; i++) { /* see if RRset qualifies */ if(ntohs(filter->list[i]->rk.type) != LDNS_RR_TYPE_NSEC3 || - ntohs(filter->list[i]->rk.rrset_class) != - filter->fclass) + ntohs(filter->list[i]->rk.rrset_class) != + filter->fclass) continue; /* check RRset zone */ nm = filter->list[i]->rk.dname; @@ -389,7 +389,7 @@ nsec3_rrset_has_known(struct ub_packed_rrset_key* s) return 0; } -/** +/** * Initialize the filter structure. * Finds the zone by looking at available NSEC3 records and best match. * (skips the unknown flag and unknown algo NSEC3s). @@ -397,7 +397,7 @@ nsec3_rrset_has_known(struct ub_packed_rrset_key* s) * @param filter: nsec3 filter structure. * @param list: list of rrsets, an array of them. * @param num: number of rrsets in list. - * @param qinfo: + * @param qinfo: * query name to match a zone for. * query type (if DS a higher zone must be chosen) * qclass, to filter NSEC3s with. @@ -417,7 +417,7 @@ filter_init(struct nsec3_filter* filter, struct ub_packed_rrset_key** list, for(i=0; irk.type) != LDNS_RR_TYPE_NSEC3 || - ntohs(list[i]->rk.rrset_class) != qinfo->qclass) + ntohs(list[i]->rk.rrset_class) != qinfo->qclass) continue; /* skip unknown flags, algo */ if(!nsec3_rrset_has_known(list[i])) @@ -433,7 +433,7 @@ filter_init(struct nsec3_filter* filter, struct ub_packed_rrset_key** list, if(dname_subdomain_c(qinfo->qname, nm) && (!filter->zone || dname_subdomain_c(nm, filter->zone))) { /* for a type DS do not accept a zone equal to qname*/ - if(qinfo->qtype == LDNS_RR_TYPE_DS && + if(qinfo->qtype == LDNS_RR_TYPE_DS && query_dname_compare(qinfo->qname, nm) == 0 && !dname_is_root(qinfo->qname)) continue; @@ -463,7 +463,7 @@ get_max_iter(struct val_env* ve, size_t bits) return ve->nsec3_maxiter[ve->nsec3_keyiter_count-1]; } -/** +/** * Determine if any of the NSEC3 rrs iteration count is too high, from key. * @param ve: validator environment with iteration count config settings. * @param filter: what NSEC3s to loop over. @@ -471,7 +471,7 @@ get_max_iter(struct val_env* ve, size_t bits) * @return 1 if some nsec3s are above the max iteration count. */ static int -nsec3_iteration_count_high(struct val_env* ve, struct nsec3_filter* filter, +nsec3_iteration_count_high(struct val_env* ve, struct nsec3_filter* filter, struct key_entry_key* kkey) { size_t rrsetnum; @@ -483,7 +483,7 @@ nsec3_iteration_count_high(struct val_env* ve, struct nsec3_filter* filter, verbose(VERB_ALGO, "nsec3: keysize %d bits, max iterations %d", (int)bits, (int)max_iter); - for(rrset=filter_first(filter, &rrsetnum, &rrnum); rrset; + for(rrset=filter_first(filter, &rrsetnum, &rrnum); rrset; rrset=filter_next(filter, &rrsetnum, &rrnum)) { if(nsec3_get_iter(rrset, rrnum) > max_iter) return 1; @@ -493,7 +493,7 @@ nsec3_iteration_count_high(struct val_env* ve, struct nsec3_filter* filter, /* nsec3_cache_compare for rbtree */ int -nsec3_hash_cmp(const void* c1, const void* c2) +nsec3_hash_cmp(const void* c1, const void* c2) { struct nsec3_cached_hash* h1 = (struct nsec3_cached_hash*)c1; struct nsec3_cached_hash* h2 = (struct nsec3_cached_hash*)c2; @@ -533,7 +533,7 @@ nsec3_hash_cmp(const void* c1, const void* c2) } size_t -nsec3_get_hashed(sldns_buffer* buf, uint8_t* nm, size_t nmlen, int algo, +nsec3_get_hashed(sldns_buffer* buf, uint8_t* nm, size_t nmlen, int algo, size_t iter, uint8_t* salt, size_t saltlen, uint8_t* res, size_t max) { size_t i, hash_len; @@ -568,7 +568,7 @@ nsec3_get_hashed(sldns_buffer* buf, uint8_t* nm, size_t nmlen, int algo, /** perform hash of name */ static int -nsec3_calc_hash(struct regional* region, sldns_buffer* buf, +nsec3_calc_hash(struct regional* region, sldns_buffer* buf, struct nsec3_cached_hash* c) { int algo = nsec3_get_algo(c->nsec3, c->rr); @@ -607,7 +607,7 @@ nsec3_calc_hash(struct regional* region, sldns_buffer* buf, /** perform b32 encoding of hash */ static int -nsec3_calc_b32(struct regional* region, sldns_buffer* buf, +nsec3_calc_b32(struct regional* region, sldns_buffer* buf, struct nsec3_cached_hash* c) { int r; @@ -619,7 +619,7 @@ nsec3_calc_b32(struct regional* region, sldns_buffer* buf, return 0; } c->b32_len = (size_t)r; - c->b32 = regional_alloc_init(region, sldns_buffer_begin(buf), + c->b32 = regional_alloc_init(region, sldns_buffer_begin(buf), c->b32_len); if(!c->b32) return 0; @@ -628,7 +628,7 @@ nsec3_calc_b32(struct regional* region, sldns_buffer* buf, int nsec3_hash_name(rbtree_type* table, struct regional* region, sldns_buffer* buf, - struct ub_packed_rrset_key* nsec3, int rr, uint8_t* dname, + struct ub_packed_rrset_key* nsec3, int rr, uint8_t* dname, size_t dname_len, struct nsec3_cached_hash** hash) { struct nsec3_cached_hash* c; @@ -700,15 +700,15 @@ label_compare_lower(uint8_t* lab1, uint8_t* lab2, size_t lablen) * @return true if matches exactly, false if not. */ static int -nsec3_hash_matches_owner(struct nsec3_filter* flt, +nsec3_hash_matches_owner(struct nsec3_filter* flt, struct nsec3_cached_hash* hash, struct ub_packed_rrset_key* s) { uint8_t* nm = s->rk.dname; /* compare, does hash of name based on params in this NSEC3 - * match the owner name of this NSEC3? - * name must be: base32 . zone name + * match the owner name of this NSEC3? + * name must be: base32 . zone name * so; first label must not be root label (not zero length), - * and match the b32 encoded hash length, + * and match the b32 encoded hash length, * and the label content match the b32 encoded hash * and the rest must be the zone name. */ @@ -734,7 +734,7 @@ nsec3_hash_matches_owner(struct nsec3_filter* flt, */ static int find_matching_nsec3(struct module_env* env, struct nsec3_filter* flt, - rbtree_type* ct, uint8_t* nm, size_t nmlen, + rbtree_type* ct, uint8_t* nm, size_t nmlen, struct ub_packed_rrset_key** rrset, int* rr) { size_t i_rs; @@ -744,7 +744,7 @@ find_matching_nsec3(struct module_env* env, struct nsec3_filter* flt, int r; /* this loop skips other-zone and unknown NSEC3s, also non-NSEC3 RRs */ - for(s=filter_first(flt, &i_rs, &i_rr); s; + for(s=filter_first(flt, &i_rs, &i_rr); s; s=filter_next(flt, &i_rs, &i_rr)) { /* get name hashed for this NSEC3 RR */ r = nsec3_hash_name(ct, env->scratch, env->scratch_buffer, @@ -776,32 +776,32 @@ nsec3_covers(uint8_t* zone, struct nsec3_cached_hash* hash, return 0; /* malformed RR proves nothing */ /* check the owner name is a hashed value . apex - * base32 encoded values must have equal length. + * base32 encoded values must have equal length. * hash_value and next hash value must have equal length. */ - if(nextlen != hash->hash_len || hash->hash_len==0||hash->b32_len==0|| + if(nextlen != hash->hash_len || hash->hash_len==0||hash->b32_len==0|| (size_t)*rrset->rk.dname != hash->b32_len || query_dname_compare(rrset->rk.dname+1+ (size_t)*rrset->rk.dname, zone) != 0) return 0; /* bad lengths or owner name */ /* This is the "normal case: owner < next and owner < hash < next */ - if(label_compare_lower(rrset->rk.dname+1, hash->b32, - hash->b32_len) < 0 && + if(label_compare_lower(rrset->rk.dname+1, hash->b32, + hash->b32_len) < 0 && memcmp(hash->hash, next, nextlen) < 0) return 1; /* convert owner name from text to binary */ sldns_buffer_clear(buf); owner = sldns_buffer_begin(buf); - len = sldns_b32_pton_extended_hex((char*)rrset->rk.dname+1, + len = sldns_b32_pton_extended_hex((char*)rrset->rk.dname+1, hash->b32_len, owner, sldns_buffer_limit(buf)); if(len<1) return 0; /* bad owner name in some way */ if((size_t)len != hash->hash_len || (size_t)len != nextlen) return 0; /* wrong length */ - /* this is the end of zone case: next <= owner && - * (hash > owner || hash < next) + /* this is the end of zone case: next <= owner && + * (hash > owner || hash < next) * this also covers the only-apex case of next==owner. */ if(memcmp(next, owner, nextlen) <= 0 && @@ -827,7 +827,7 @@ nsec3_covers(uint8_t* zone, struct nsec3_cached_hash* hash, */ static int find_covering_nsec3(struct module_env* env, struct nsec3_filter* flt, - rbtree_type* ct, uint8_t* nm, size_t nmlen, + rbtree_type* ct, uint8_t* nm, size_t nmlen, struct ub_packed_rrset_key** rrset, int* rr) { size_t i_rs; @@ -837,7 +837,7 @@ find_covering_nsec3(struct module_env* env, struct nsec3_filter* flt, int r; /* this loop skips other-zone and unknown NSEC3s, also non-NSEC3 RRs */ - for(s=filter_first(flt, &i_rs, &i_rr); s; + for(s=filter_first(flt, &i_rs, &i_rr); s; s=filter_next(flt, &i_rs, &i_rr)) { /* get name hashed for this NSEC3 RR */ r = nsec3_hash_name(ct, env->scratch, env->scratch_buffer, @@ -847,7 +847,7 @@ find_covering_nsec3(struct module_env* env, struct nsec3_filter* flt, break; /* alloc failure */ } else if(r != 1) continue; /* malformed NSEC3 */ - else if(nsec3_covers(flt->zone, hash, s, i_rr, + else if(nsec3_covers(flt->zone, hash, s, i_rr, env->scratch_buffer)) { *rrset = s; /* rrset with this name */ *rr = i_rr; /* covers hash with these parameters */ @@ -872,23 +872,23 @@ find_covering_nsec3(struct module_env* env, struct nsec3_filter* flt, * @return true if a closest encloser candidate is found, false if not. */ static int -nsec3_find_closest_encloser(struct module_env* env, struct nsec3_filter* flt, +nsec3_find_closest_encloser(struct module_env* env, struct nsec3_filter* flt, rbtree_type* ct, struct query_info* qinfo, struct ce_response* ce) { uint8_t* nm = qinfo->qname; size_t nmlen = qinfo->qname_len; - /* This scans from longest name to shortest, so the first match + /* This scans from longest name to shortest, so the first match * we find is the only viable candidate. */ - /* (David:) FIXME: modify so that the NSEC3 matching the zone apex need + /* (David:) FIXME: modify so that the NSEC3 matching the zone apex need * not be present. (Mark Andrews idea). * (Wouter:) But make sure you check for DNAME bit in zone apex, * if the NSEC3 you find is the only NSEC3 in the zone, then this * may be the case. */ while(dname_subdomain_c(nm, flt->zone)) { - if(find_matching_nsec3(env, flt, ct, nm, nmlen, + if(find_matching_nsec3(env, flt, ct, nm, nmlen, &ce->ce_rrset, &ce->ce_rr)) { ce->ce = nm; ce->ce_len = nmlen; @@ -911,7 +911,7 @@ nsec3_find_closest_encloser(struct module_env* env, struct nsec3_filter* flt, * @param nmlen: length of nm. */ static void -next_closer(uint8_t* qname, size_t qnamelen, uint8_t* ce, +next_closer(uint8_t* qname, size_t qnamelen, uint8_t* ce, uint8_t** nm, size_t* nmlen) { int strip = dname_count_labels(qname) - dname_count_labels(ce) -1; @@ -928,9 +928,9 @@ next_closer(uint8_t* qname, size_t qnamelen, uint8_t* ce, * @param flt: the NSEC3 RR filter, contains zone name and RRs. * @param ct: cached hashes table. * @param qinfo: query that is verified for. - * @param prove_does_not_exist: If true, then if the closest encloser + * @param prove_does_not_exist: If true, then if the closest encloser * turns out to be qname, then null is returned. - * If set true, and the return value is true, then you can be + * If set true, and the return value is true, then you can be * certain that the ce.nc_rrset and ce.nc_rr are set properly. * @param ce: closest encloser information is returned in here. * @return bogus if no closest encloser could be proven. @@ -939,7 +939,7 @@ next_closer(uint8_t* qname, size_t qnamelen, uint8_t* ce, * that an insecure delegation exists above the qname. */ static enum sec_status -nsec3_prove_closest_encloser(struct module_env* env, struct nsec3_filter* flt, +nsec3_prove_closest_encloser(struct module_env* env, struct nsec3_filter* flt, rbtree_type* ct, struct query_info* qinfo, int prove_does_not_exist, struct ce_response* ce) { @@ -961,13 +961,13 @@ nsec3_prove_closest_encloser(struct module_env* env, struct nsec3_filter* flt, "proved that qname existed, bad"); return sec_status_bogus; } - /* otherwise, we need to nothing else to prove that qname + /* otherwise, we need to nothing else to prove that qname * is its own closest encloser. */ return sec_status_secure; } - /* If the closest encloser is actually a delegation, then the - * response should have been a referral. If it is a DNAME, then + /* If the closest encloser is actually a delegation, then the + * response should have been a referral. If it is a DNAME, then * it should have been a DNAME response. */ if(nsec3_has_type(ce->ce_rrset, ce->ce_rr, LDNS_RR_TYPE_NS) && !nsec3_has_type(ce->ce_rrset, ce->ce_rr, LDNS_RR_TYPE_SOA)) { @@ -985,10 +985,10 @@ nsec3_prove_closest_encloser(struct module_env* env, struct nsec3_filter* flt, "encloser was a DNAME, bad"); return sec_status_bogus; } - + /* Otherwise, we need to show that the next closer name is covered. */ next_closer(qinfo->qname, qinfo->qname_len, ce->ce, &nc, &nc_len); - if(!find_covering_nsec3(env, flt, ct, nc, nc_len, + if(!find_covering_nsec3(env, flt, ct, nc, nc_len, &ce->nc_rrset, &ce->nc_rr)) { verbose(VERB_ALGO, "nsec3: Could not find proof that the " "candidate encloser was the closest encloser"); @@ -1019,7 +1019,7 @@ nsec3_ce_wildcard(struct regional* region, uint8_t* ce, size_t celen, /** Do the name error proof */ static enum sec_status -nsec3_do_prove_nameerror(struct module_env* env, struct nsec3_filter* flt, +nsec3_do_prove_nameerror(struct module_env* env, struct nsec3_filter* flt, rbtree_type* ct, struct query_info* qinfo) { struct ce_response ce; @@ -1029,8 +1029,8 @@ nsec3_do_prove_nameerror(struct module_env* env, struct nsec3_filter* flt, int wc_rr; enum sec_status sec; - /* First locate and prove the closest encloser to qname. We will - * use the variant that fails if the closest encloser turns out + /* First locate and prove the closest encloser to qname. We will + * use the variant that fails if the closest encloser turns out * to be qname. */ sec = nsec3_prove_closest_encloser(env, flt, ct, qinfo, 1, &ce); if(sec != sec_status_secure) { @@ -1043,11 +1043,11 @@ nsec3_do_prove_nameerror(struct module_env* env, struct nsec3_filter* flt, } log_nametypeclass(VERB_ALGO, "nsec3 nameerror: proven ce=", ce.ce,0,0); - /* At this point, we know that qname does not exist. Now we need + /* At this point, we know that qname does not exist. Now we need * to prove that the wildcard does not exist. */ log_assert(ce.ce); wc = nsec3_ce_wildcard(env->scratch, ce.ce, ce.ce_len, &wclen); - if(!wc || !find_covering_nsec3(env, flt, ct, wc, wclen, + if(!wc || !find_covering_nsec3(env, flt, ct, wc, wclen, &wc_rrset, &wc_rr)) { verbose(VERB_ALGO, "nsec3 nameerror proof: could not prove " "that the applicable wildcard did not exist."); @@ -1077,19 +1077,19 @@ nsec3_prove_nameerror(struct module_env* env, struct val_env* ve, return sec_status_bogus; /* no RRs */ if(nsec3_iteration_count_high(ve, &flt, kkey)) return sec_status_insecure; /* iteration count too high */ - log_nametypeclass(VERB_ALGO, "start nsec3 nameerror proof, zone", + log_nametypeclass(VERB_ALGO, "start nsec3 nameerror proof, zone", flt.zone, 0, 0); return nsec3_do_prove_nameerror(env, &flt, &ct, qinfo); } -/* - * No code to handle qtype=NSEC3 specially. +/* + * No code to handle qtype=NSEC3 specially. * This existed in early drafts, but was later (-05) removed. */ /** Do the nodata proof */ static enum sec_status -nsec3_do_prove_nodata(struct module_env* env, struct nsec3_filter* flt, +nsec3_do_prove_nodata(struct module_env* env, struct nsec3_filter* flt, rbtree_type* ct, struct query_info* qinfo) { struct ce_response ce; @@ -1099,7 +1099,7 @@ nsec3_do_prove_nodata(struct module_env* env, struct nsec3_filter* flt, int rr; enum sec_status sec; - if(find_matching_nsec3(env, flt, ct, qinfo->qname, qinfo->qname_len, + if(find_matching_nsec3(env, flt, ct, qinfo->qname, qinfo->qname_len, &rrset, &rr)) { /* cases 1 and 2 */ if(nsec3_has_type(rrset, rr, qinfo->qtype)) { @@ -1112,9 +1112,9 @@ nsec3_do_prove_nodata(struct module_env* env, struct nsec3_filter* flt, return sec_status_bogus; } - /* + /* * If type DS: filter_init zone find already found a parent - * zone, so this nsec3 is from a parent zone. + * zone, so this nsec3 is from a parent zone. * o can be not a delegation (unusual query for normal name, * no DS anyway, but we can verify that). * o can be a delegation (which is the usual DS check). @@ -1124,13 +1124,13 @@ nsec3_do_prove_nodata(struct module_env* env, struct nsec3_filter* flt, * * If not type DS: matching nsec3 must not be a delegation. */ - if(qinfo->qtype == LDNS_RR_TYPE_DS && qinfo->qname_len != 1 + if(qinfo->qtype == LDNS_RR_TYPE_DS && qinfo->qname_len != 1 && nsec3_has_type(rrset, rr, LDNS_RR_TYPE_SOA) && !dname_is_root(qinfo->qname)) { verbose(VERB_ALGO, "proveNodata: apex NSEC3 " "abused for no DS proof, bogus"); return sec_status_bogus; - } else if(qinfo->qtype != LDNS_RR_TYPE_DS && + } else if(qinfo->qtype != LDNS_RR_TYPE_DS && nsec3_has_type(rrset, rr, LDNS_RR_TYPE_NS) && !nsec3_has_type(rrset, rr, LDNS_RR_TYPE_SOA)) { if(!nsec3_has_type(rrset, rr, LDNS_RR_TYPE_DS)) { @@ -1145,8 +1145,8 @@ nsec3_do_prove_nodata(struct module_env* env, struct nsec3_filter* flt, return sec_status_secure; } - /* For cases 3 - 5, we need the proven closest encloser, and it - * can't match qname. Although, at this point, we know that it + /* For cases 3 - 5, we need the proven closest encloser, and it + * can't match qname. Although, at this point, we know that it * won't since we just checked that. */ sec = nsec3_prove_closest_encloser(env, flt, ct, qinfo, 1, &ce); if(sec == sec_status_bogus) { @@ -1175,12 +1175,12 @@ nsec3_do_prove_nodata(struct module_env* env, struct nsec3_filter* flt, "wildcard had a CNAME, bogus"); return sec_status_bogus; } - if(qinfo->qtype == LDNS_RR_TYPE_DS && qinfo->qname_len != 1 + if(qinfo->qtype == LDNS_RR_TYPE_DS && qinfo->qname_len != 1 && nsec3_has_type(rrset, rr, LDNS_RR_TYPE_SOA)) { verbose(VERB_ALGO, "nsec3 nodata proof: matching " "wildcard for no DS proof has a SOA, bogus"); return sec_status_bogus; - } else if(qinfo->qtype != LDNS_RR_TYPE_DS && + } else if(qinfo->qtype != LDNS_RR_TYPE_DS && nsec3_has_type(rrset, rr, LDNS_RR_TYPE_NS) && !nsec3_has_type(rrset, rr, LDNS_RR_TYPE_SOA)) { verbose(VERB_ALGO, "nsec3 nodata proof: matching " @@ -1261,8 +1261,8 @@ nsec3_prove_wildcard(struct module_env* env, struct val_env* ve, if(nsec3_iteration_count_high(ve, &flt, kkey)) return sec_status_insecure; /* iteration count too high */ - /* We know what the (purported) closest encloser is by just - * looking at the supposed generating wildcard. + /* We know what the (purported) closest encloser is by just + * looking at the supposed generating wildcard. * The *. has already been removed from the wc name. */ memset(&ce, 0, sizeof(ce)); @@ -1272,7 +1272,7 @@ nsec3_prove_wildcard(struct module_env* env, struct val_env* ve, /* Now we still need to prove that the original data did not exist. * Otherwise, we need to show that the next closer name is covered. */ next_closer(qinfo->qname, qinfo->qname_len, ce.ce, &nc, &nc_len); - if(!find_covering_nsec3(env, &flt, &ct, nc, nc_len, + if(!find_covering_nsec3(env, &flt, &ct, nc, nc_len, &ce.nc_rrset, &ce.nc_rr)) { verbose(VERB_ALGO, "proveWildcard: did not find a covering " "NSEC3 that covered the next closer name."); @@ -1287,7 +1287,7 @@ nsec3_prove_wildcard(struct module_env* env, struct val_env* ve, /** test if list is all secure */ static int -list_is_secure(struct module_env* env, struct val_env* ve, +list_is_secure(struct module_env* env, struct val_env* ve, struct ub_packed_rrset_key** list, size_t num, struct key_entry_key* kkey, char** reason, sldns_ede_code *reason_bogus, struct module_qstate* qstate) @@ -1344,14 +1344,14 @@ nsec3_prove_nods(struct module_env* env, struct val_env* ve, if(nsec3_iteration_count_high(ve, &flt, kkey)) return sec_status_insecure; /* iteration count too high */ - /* Look for a matching NSEC3 to qname -- this is the normal + /* Look for a matching NSEC3 to qname -- this is the normal * NODATA case. */ - if(find_matching_nsec3(env, &flt, &ct, qinfo->qname, qinfo->qname_len, + if(find_matching_nsec3(env, &flt, &ct, qinfo->qname, qinfo->qname_len, &rrset, &rr)) { - /* If the matching NSEC3 has the SOA bit set, it is from - * the wrong zone (the child instead of the parent). If + /* If the matching NSEC3 has the SOA bit set, it is from + * the wrong zone (the child instead of the parent). If * it has the DS bit set, then we were lied to. */ - if(nsec3_has_type(rrset, rr, LDNS_RR_TYPE_SOA) && + if(nsec3_has_type(rrset, rr, LDNS_RR_TYPE_SOA) && qinfo->qname_len != 1) { verbose(VERB_ALGO, "nsec3 provenods: NSEC3 is from" " child zone, bogus"); @@ -1363,7 +1363,7 @@ nsec3_prove_nods(struct module_env* env, struct val_env* ve, *reason = "NSEC3 has DS in bitmap"; return sec_status_bogus; } - /* If the NSEC3 RR doesn't have the NS bit set, then + /* If the NSEC3 RR doesn't have the NS bit set, then * this wasn't a delegation point. */ if(!nsec3_has_type(rrset, rr, LDNS_RR_TYPE_NS)) return sec_status_indeterminate; @@ -1407,7 +1407,7 @@ nsec3_prove_nods(struct module_env* env, struct val_env* ve, enum sec_status nsec3_prove_nxornodata(struct module_env* env, struct val_env* ve, - struct ub_packed_rrset_key** list, size_t num, + struct ub_packed_rrset_key** list, size_t num, struct query_info* qinfo, struct key_entry_key* kkey, int* nodata) { enum sec_status sec, secnx; diff --git a/sbin/unwind/libunbound/validator/val_nsec3.h b/sbin/unwind/libunbound/validator/val_nsec3.h index 7676fc8b2..f5c4141bf 100644 --- a/sbin/unwind/libunbound/validator/val_nsec3.h +++ b/sbin/unwind/libunbound/validator/val_nsec3.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -111,30 +111,30 @@ struct sldns_buffer; * @param qinfo: query that is verified for. * @param kkey: key entry that signed the NSEC3s. * @return: - * sec_status SECURE of the Name Error is proven by the NSEC3 RRs, + * sec_status SECURE of the Name Error is proven by the NSEC3 RRs, * BOGUS if not, INSECURE if all of the NSEC3s could be validly ignored. */ enum sec_status nsec3_prove_nameerror(struct module_env* env, struct val_env* ve, - struct ub_packed_rrset_key** list, size_t num, + struct ub_packed_rrset_key** list, size_t num, struct query_info* qinfo, struct key_entry_key* kkey); /** * Determine if the NSEC3s provided in a response prove the NOERROR/NODATA * status. There are a number of different variants to this: - * + * * 1) Normal NODATA -- qname is matched to an NSEC3 record, type is not * present. - * + * * 2) ENT NODATA -- because there must be NSEC3 record for * empty-non-terminals, this is the same as #1. - * + * * 3) NSEC3 ownername NODATA -- qname matched an existing, lone NSEC3 * ownername, but qtype was not NSEC3. NOTE: as of nsec-05, this case no * longer exists. - * + * * 4) Wildcard NODATA -- A wildcard matched the name, but not the type. - * + * * 5) Opt-In DS NODATA -- the qname is covered by an opt-in span and qtype == * DS. (or maybe some future record with the same parent-side-only property) * @@ -145,12 +145,12 @@ nsec3_prove_nameerror(struct module_env* env, struct val_env* ve, * @param qinfo: query that is verified for. * @param kkey: key entry that signed the NSEC3s. * @return: - * sec_status SECURE of the proposition is proven by the NSEC3 RRs, + * sec_status SECURE of the proposition is proven by the NSEC3 RRs, * BOGUS if not, INSECURE if all of the NSEC3s could be validly ignored. */ enum sec_status nsec3_prove_nodata(struct module_env* env, struct val_env* ve, - struct ub_packed_rrset_key** list, size_t num, + struct ub_packed_rrset_key** list, size_t num, struct query_info* qinfo, struct key_entry_key* kkey); @@ -167,12 +167,12 @@ nsec3_prove_nodata(struct module_env* env, struct val_env* ve, * @param wc: The purported wildcard that matched. This is the wildcard name * as *.wildcard.name., with the *. label already removed. * @return: - * sec_status SECURE of the proposition is proven by the NSEC3 RRs, + * sec_status SECURE of the proposition is proven by the NSEC3 RRs, * BOGUS if not, INSECURE if all of the NSEC3s could be validly ignored. */ enum sec_status nsec3_prove_wildcard(struct module_env* env, struct val_env* ve, - struct ub_packed_rrset_key** list, size_t num, + struct ub_packed_rrset_key** list, size_t num, struct query_info* qinfo, struct key_entry_key* kkey, uint8_t* wc); /** @@ -190,14 +190,14 @@ nsec3_prove_wildcard(struct module_env* env, struct val_env* ve, * @param reason_bogus: EDE (RFC8914) code paired with the reason of failure. * @param qstate: qstate with region. * @return: - * sec_status SECURE of the proposition is proven by the NSEC3 RRs, + * sec_status SECURE of the proposition is proven by the NSEC3 RRs, * BOGUS if not, INSECURE if all of the NSEC3s could be validly ignored. * or if there was no DS in an insecure (i.e., opt-in) way, * INDETERMINATE if it was clear that this wasn't a delegation point. */ enum sec_status nsec3_prove_nods(struct module_env* env, struct val_env* ve, - struct ub_packed_rrset_key** list, size_t num, + struct ub_packed_rrset_key** list, size_t num, struct query_info* qinfo, struct key_entry_key* kkey, char** reason, sldns_ede_code* reason_bogus, struct module_qstate* qstate); @@ -213,12 +213,12 @@ nsec3_prove_nods(struct module_env* env, struct val_env* ve, * @param nodata: if return value is secure, this indicates if nodata or * nxdomain was proven. * @return: - * sec_status SECURE of the proposition is proven by the NSEC3 RRs, + * sec_status SECURE of the proposition is proven by the NSEC3 RRs, * BOGUS if not, INSECURE if all of the NSEC3s could be validly ignored. */ enum sec_status nsec3_prove_nxornodata(struct module_env* env, struct val_env* ve, - struct ub_packed_rrset_key** list, size_t num, + struct ub_packed_rrset_key** list, size_t num, struct query_info* qinfo, struct key_entry_key* kkey, int* nodata); /** @@ -308,7 +308,7 @@ size_t nsec3_get_nextowner_b32(struct ub_packed_rrset_key* rrset, int r, size_t nsec3_hash_to_b32(uint8_t* hash, size_t hashlen, uint8_t* zone, size_t zonelen, uint8_t* buf, size_t max); -/** +/** * Get NSEC3 parameters out of rr. * @param rrset: the NSEC3 rrset. * @param r: the rr num of the nsec3 in the rrset. @@ -338,7 +338,7 @@ size_t nsec3_get_hashed(struct sldns_buffer* buf, uint8_t* nm, size_t nmlen, int algo, size_t iter, uint8_t* salt, size_t saltlen, uint8_t* res, size_t max); -/** +/** * see if NSEC3 RR contains given type * @param rrset: NSEC3 rrset * @param r: RR in rrset @@ -347,16 +347,16 @@ size_t nsec3_get_hashed(struct sldns_buffer* buf, uint8_t* nm, size_t nmlen, */ int nsec3_has_type(struct ub_packed_rrset_key* rrset, int r, uint16_t type); -/** - * return if nsec3 RR has the optout flag +/** + * return if nsec3 RR has the optout flag * @param rrset: NSEC3 rrset * @param r: RR in rrset * @return true if optout, false on error or not optout */ int nsec3_has_optout(struct ub_packed_rrset_key* rrset, int r); -/** - * Return nsec3 RR next hashed owner name +/** + * Return nsec3 RR next hashed owner name * @param rrset: NSEC3 rrset * @param r: RR in rrset * @param next: ptr into rdata to next owner hash diff --git a/sbin/unwind/libunbound/validator/val_secalgo.c b/sbin/unwind/libunbound/validator/val_secalgo.c index 786516749..d9c840d2e 100644 --- a/sbin/unwind/libunbound/validator/val_secalgo.c +++ b/sbin/unwind/libunbound/validator/val_secalgo.c @@ -4,22 +4,22 @@ * Copyright (c) 2012, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -268,7 +268,7 @@ static int do_gost94(unsigned char* data, size_t len, unsigned char* dest) { const EVP_MD* md = EVP_get_digestbyname("md_gost94"); - if(!md) + if(!md) return 0; return sldns_digest_evp(data, (unsigned int)len, dest, md); } @@ -318,8 +318,8 @@ secalgo_ds_digest(int algo, unsigned char* buf, size_t len, #endif return 1; #endif - default: - verbose(VERB_QUERY, "unknown DS digest algorithm %d", + default: + verbose(VERB_QUERY, "unknown DS digest algorithm %d", algo); break; } @@ -395,7 +395,7 @@ dnskey_algo_id_is_supported(int id) #ifdef USE_DSA /** - * Setup DSA key digest in DER encoding ... + * Setup DSA key digest in DER encoding ... * @param sig: input is signature output alloced ptr (unless failure). * caller must free alloced ptr if this routine returns true. * @param len: input is initial siglen, output is output len. @@ -542,7 +542,7 @@ void ecdsa_evp_workaround_init(void) * @return false on failure. */ static int -setup_key_digest(int algo, EVP_PKEY** evp_key, const EVP_MD** digest_type, +setup_key_digest(int algo, EVP_PKEY** evp_key, const EVP_MD** digest_type, unsigned char* key, size_t keylen) { switch(algo) { @@ -677,7 +677,7 @@ setup_key_digest(int algo, EVP_PKEY** evp_key, const EVP_MD** digest_type, break; #endif /* USE_ED448 */ default: - verbose(VERB_QUERY, "verify: unknown algorithm %d", + verbose(VERB_QUERY, "verify: unknown algorithm %d", algo); return 0; } @@ -746,7 +746,7 @@ verify_canonrrset(sldns_buffer* buf, int algo, unsigned char* sigblock, if(fake_sha1 && (algo == LDNS_DSA || algo == LDNS_DSA_NSEC3 || algo == LDNS_RSASHA1 || algo == LDNS_RSASHA1_NSEC3)) return sec_status_secure; #endif - + if(!setup_key_digest(algo, &evp_key, &digest_type, key, keylen)) { verbose(VERB_QUERY, "verify: failed to setup key"); *reason = "use of key for crypto failed"; @@ -755,7 +755,7 @@ verify_canonrrset(sldns_buffer* buf, int algo, unsigned char* sigblock, } #ifdef USE_DSA /* if it is a DSA signature in bind format, convert to DER format */ - if((algo == LDNS_DSA || algo == LDNS_DSA_NSEC3) && + if((algo == LDNS_DSA || algo == LDNS_DSA_NSEC3) && sigblock_len == 1+2*SHA_DIGEST_LENGTH) { if(!setup_dsa_sig(&sigblock, &sigblock_len)) { verbose(VERB_QUERY, "verify: failed to setup DSA sig"); @@ -767,7 +767,7 @@ verify_canonrrset(sldns_buffer* buf, int algo, unsigned char* sigblock, } #endif #if defined(USE_ECDSA) && defined(USE_DSA) - else + else #endif #ifdef USE_ECDSA if(algo == LDNS_ECDSAP256SHA256 || algo == LDNS_ECDSAP384SHA384) { @@ -804,7 +804,7 @@ verify_canonrrset(sldns_buffer* buf, int algo, unsigned char* sigblock, dofree, docrypto_free); return sec; } - if(EVP_DigestUpdate(ctx, (unsigned char*)sldns_buffer_begin(buf), + if(EVP_DigestUpdate(ctx, (unsigned char*)sldns_buffer_begin(buf), (unsigned int)sldns_buffer_limit(buf)) == 0) { log_crypto_verbose(VERB_QUERY, "verify: EVP_DigestUpdate failed", ERR_get_error()); @@ -989,8 +989,8 @@ secalgo_ds_digest(int algo, unsigned char* buf, size_t len, == SECSuccess; #endif case LDNS_HASH_GOST: - default: - verbose(VERB_QUERY, "unknown DS digest algorithm %d", + default: + verbose(VERB_QUERY, "unknown DS digest algorithm %d", algo); break; } @@ -1198,7 +1198,7 @@ static SECKEYPublicKey* nss_buf2rsa(unsigned char* key, size_t len) /* key length at least one */ if(len < (size_t)offset + exp + 1) return NULL; - + exponent.data = key+offset; exponent.len = exp; offset += exp; @@ -1250,7 +1250,7 @@ nss_setup_key_digest(int algo, SECKEYPublicKey** pubkey, HASH_HashType* htype, static unsigned char p_sha512[] = {0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40}; /* from RFC6234 */ - /* for future RSASHA384 .. + /* for future RSASHA384 .. static unsigned char p_sha384[] = {0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30}; */ @@ -1351,7 +1351,7 @@ nss_setup_key_digest(int algo, SECKEYPublicKey** pubkey, HASH_HashType* htype, #endif /* USE_ECDSA */ case LDNS_ECC_GOST: default: - verbose(VERB_QUERY, "verify: unknown algorithm %d", + verbose(VERB_QUERY, "verify: unknown algorithm %d", algo); return 0; } @@ -1372,7 +1372,7 @@ nss_setup_key_digest(int algo, SECKEYPublicKey** pubkey, HASH_HashType* htype, * unchecked on format errors and alloc failures. */ enum sec_status -verify_canonrrset(sldns_buffer* buf, int algo, unsigned char* sigblock, +verify_canonrrset(sldns_buffer* buf, int algo, unsigned char* sigblock, unsigned int sigblock_len, unsigned char* key, unsigned int keylen, char** reason) { diff --git a/sbin/unwind/libunbound/validator/val_secalgo.h b/sbin/unwind/libunbound/validator/val_secalgo.h index 8b6080dc2..5703ea7eb 100644 --- a/sbin/unwind/libunbound/validator/val_secalgo.h +++ b/sbin/unwind/libunbound/validator/val_secalgo.h @@ -4,22 +4,22 @@ * Copyright (c) 2012, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -113,7 +113,7 @@ void secalgo_hash_delete(struct secalgo_hash* hash); /** * Return size of DS digest according to its hash algorithm. * @param algo: DS digest algo. - * @return size in bytes of digest, or 0 if not supported. + * @return size in bytes of digest, or 0 if not supported. */ size_t ds_digest_size_supported(int algo); diff --git a/sbin/unwind/libunbound/validator/val_sigcrypt.c b/sbin/unwind/libunbound/validator/val_sigcrypt.c index 37730f179..596a315db 100644 --- a/sbin/unwind/libunbound/validator/val_sigcrypt.c +++ b/sbin/unwind/libunbound/validator/val_sigcrypt.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -105,7 +105,7 @@ rrset_get_sigcount(struct ub_packed_rrset_key* k) * @param sig_idx: signature index. * @return keytag or 0 if malformed rrsig. */ -static uint16_t +static uint16_t rrset_get_sig_keytag(struct ub_packed_rrset_key* k, size_t sig_idx) { uint16_t t; @@ -123,7 +123,7 @@ rrset_get_sig_keytag(struct ub_packed_rrset_key* k, size_t sig_idx) * @param sig_idx: signature index. * @return algo or 0 if malformed rrsig. */ -static int +static int rrset_get_sig_algo(struct ub_packed_rrset_key* k, size_t sig_idx) { struct packed_rrset_data* d = (struct packed_rrset_data*)k->entry.data; @@ -225,7 +225,7 @@ ds_get_digest_algo(struct ub_packed_rrset_key* k, size_t idx) return (int)rdata[2+3]; } -uint16_t +uint16_t ds_get_keytag(struct ub_packed_rrset_key* ds_rrset, size_t ds_idx) { uint16_t t; @@ -267,7 +267,7 @@ ds_get_sigdata(struct ub_packed_rrset_key* k, size_t idx, uint8_t** digest, * Return size of DS digest according to its hash algorithm. * @param k: DS rrset. * @param idx: which DS. - * @return size in bytes of digest, or 0 if not supported. + * @return size in bytes of digest, or 0 if not supported. */ static size_t ds_digest_size_algo(struct ub_packed_rrset_key* k, size_t idx) @@ -287,7 +287,7 @@ ds_digest_size_algo(struct ub_packed_rrset_key* k, size_t idx) * @return false on error. */ static int -ds_create_dnskey_digest(struct module_env* env, +ds_create_dnskey_digest(struct module_env* env, struct ub_packed_rrset_key* dnskey_rrset, size_t dnskey_idx, struct ub_packed_rrset_key* ds_rrset, size_t ds_idx, uint8_t* digest) @@ -297,16 +297,16 @@ ds_create_dnskey_digest(struct module_env* env, size_t dnskey_len; rrset_get_rdata(dnskey_rrset, dnskey_idx, &dnskey_rdata, &dnskey_len); - /* create digest source material in buffer + /* create digest source material in buffer * digest = digest_algorithm( DNSKEY owner name | DNSKEY RDATA); * DNSKEY RDATA = Flags | Protocol | Algorithm | Public Key. */ sldns_buffer_clear(b); - sldns_buffer_write(b, dnskey_rrset->rk.dname, + sldns_buffer_write(b, dnskey_rrset->rk.dname, dnskey_rrset->rk.dname_len); query_dname_tolower(sldns_buffer_begin(b)); sldns_buffer_write(b, dnskey_rdata+2, dnskey_len-2); /* skip rdatalen*/ sldns_buffer_flip(b); - + return secalgo_ds_digest(ds_get_digest_algo(ds_rrset, ds_idx), (unsigned char*)sldns_buffer_begin(b), sldns_buffer_limit(b), (unsigned char*)digest); @@ -330,7 +330,7 @@ int ds_digest_match_dnskey(struct module_env* env, if(fake_sha1 && ds_get_digest_algo(ds_rrset, ds_idx)==LDNS_SHA1) return 1; #endif - + /* check digest length in DS with length from hash function */ ds_get_sigdata(ds_rrset, ds_idx, &ds, &dslen); if(!ds || dslen != digestlen) { @@ -344,7 +344,7 @@ int ds_digest_match_dnskey(struct module_env* env, verbose(VERB_QUERY, "DS fail: out of memory"); return 0; /* mem error */ } - if(!ds_create_dnskey_digest(env, dnskey_rrset, dnskey_idx, ds_rrset, + if(!ds_create_dnskey_digest(env, dnskey_rrset, dnskey_idx, ds_rrset, ds_idx, digest)) { verbose(VERB_QUERY, "DS fail: could not calc key digest"); return 0; /* digest algo failed */ @@ -356,21 +356,21 @@ int ds_digest_match_dnskey(struct module_env* env, return 1; } -int -ds_digest_algo_is_supported(struct ub_packed_rrset_key* ds_rrset, +int +ds_digest_algo_is_supported(struct ub_packed_rrset_key* ds_rrset, size_t ds_idx) { return (ds_digest_size_algo(ds_rrset, ds_idx) != 0); } -int -ds_key_algo_is_supported(struct ub_packed_rrset_key* ds_rrset, +int +ds_key_algo_is_supported(struct ub_packed_rrset_key* ds_rrset, size_t ds_idx) { return dnskey_algo_id_is_supported(ds_get_key_algo(ds_rrset, ds_idx)); } -uint16_t +uint16_t dnskey_calc_keytag(struct ub_packed_rrset_key* dnskey_rrset, size_t dnskey_idx) { uint8_t* data; @@ -383,7 +383,7 @@ dnskey_calc_keytag(struct ub_packed_rrset_key* dnskey_rrset, size_t dnskey_idx) int dnskey_algo_is_supported(struct ub_packed_rrset_key* dnskey_rrset, size_t dnskey_idx) { - return dnskey_algo_id_is_supported(dnskey_get_algo(dnskey_rrset, + return dnskey_algo_id_is_supported(dnskey_get_algo(dnskey_rrset, dnskey_idx)); } @@ -483,7 +483,7 @@ void algo_needs_init_ds(struct algo_needs* n, struct ub_packed_rrset_key* ds, log_assert(algo != 0); /* we do not support 0 and is EOS */ if(n->needs[algo] == 0) { n->needs[algo] = 1; - sigalg[total] = algo; + sigalg[total] = algo; total++; } } @@ -605,7 +605,7 @@ dnskeyset_verify_rrset_sig(struct module_env* env, struct val_env* ve, return sec_status_bogus; } -enum sec_status +enum sec_status dnskeyset_verify_rrset(struct module_env* env, struct val_env* ve, struct ub_packed_rrset_key* rrset, struct ub_packed_rrset_key* dnskey, uint8_t* sigalg, char** reason, sldns_ede_code *reason_bogus, @@ -639,7 +639,7 @@ dnskeyset_verify_rrset(struct module_env* env, struct val_env* ve, } } for(i=0; inow, rrset, + sec = dnskeyset_verify_rrset_sig(env, ve, *env->now, rrset, dnskey, i, &sortree, reason, reason_bogus, section, qstate); /* see which algorithm has been fixed up */ @@ -708,7 +708,7 @@ dnskey_verify_rrset(struct module_env* env, struct val_env* ve, continue; buf_canon = 0; sec = dnskey_verify_rrset_sig(env->scratch, - env->scratch_buffer, ve, *env->now, rrset, + env->scratch_buffer, ve, *env->now, rrset, dnskey, dnskey_idx, i, &sortree, &buf_canon, reason, reason_bogus, section, qstate); if(sec == sec_status_secure) @@ -754,7 +754,7 @@ struct canon_rr { * @return comparison code. */ static int -canonical_compare_byfield(struct packed_rrset_data* d, +canonical_compare_byfield(struct packed_rrset_data* d, const sldns_rr_descriptor* desc, size_t i, size_t j) { /* sweep across rdata, keep track of some state: @@ -800,7 +800,7 @@ canonical_compare_byfield(struct packed_rrset_data* d, * The reason to first read the byte, then setup the rdf, * is that we are then sure the byte is available and short * rdata is handled gracefully (even if it is a formerr). */ - if(lablen_i == 0) { + if(lablen_i == 0) { if(dname_i) { /* scan this dname label */ /* capture length to lowercase */ @@ -817,9 +817,9 @@ canonical_compare_byfield(struct packed_rrset_data* d, } else { /* scan this rdata field */ wfi++; - if(desc->_wireformat[wfi] + if(desc->_wireformat[wfi] == LDNS_RDF_TYPE_DNAME) { - dname_i = 1; + dname_i = 1; lablen_i = (size_t)*di; if(lablen_i == 0) { dname_i = 0; @@ -827,7 +827,7 @@ canonical_compare_byfield(struct packed_rrset_data* d, if(dname_num_i == 0) lablen_i = ilen; } - } else if(desc->_wireformat[wfi] + } else if(desc->_wireformat[wfi] == LDNS_RDF_TYPE_STR) lablen_i = (size_t)*di; else lablen_i = get_rdf_size( @@ -836,7 +836,7 @@ canonical_compare_byfield(struct packed_rrset_data* d, } else lablen_i--; /* advance field j; same as for i */ - if(lablen_j == 0) { + if(lablen_j == 0) { if(dname_j) { lablen_j = (size_t)*dj; if(lablen_j == 0) { @@ -847,9 +847,9 @@ canonical_compare_byfield(struct packed_rrset_data* d, } } else { wfj++; - if(desc->_wireformat[wfj] + if(desc->_wireformat[wfj] == LDNS_RDF_TYPE_DNAME) { - dname_j = 1; + dname_j = 1; lablen_j = (size_t)*dj; if(lablen_j == 0) { dname_j = 0; @@ -857,7 +857,7 @@ canonical_compare_byfield(struct packed_rrset_data* d, if(dname_num_j == 0) lablen_j = jlen; } - } else if(desc->_wireformat[wfj] + } else if(desc->_wireformat[wfj] == LDNS_RDF_TYPE_STR) lablen_j = (size_t)*dj; else lablen_j = get_rdf_size( @@ -908,7 +908,7 @@ canonical_compare(struct ub_packed_rrset_key* rrset, size_t i, size_t j) return 0; switch(type) { - /* These RR types have only a name as RDATA. + /* These RR types have only a name as RDATA. * This name has to be canonicalized.*/ case LDNS_RR_TYPE_NS: case LDNS_RR_TYPE_MD: @@ -932,7 +932,7 @@ canonical_compare(struct ub_packed_rrset_key* rrset, size_t i, size_t j) * and after that a byte-for byte remainder can be compared. */ /* type starts with the name; remainder is binary compared */ - case LDNS_RR_TYPE_NXT: + case LDNS_RR_TYPE_NXT: /* use rdata field formats */ case LDNS_RR_TYPE_MINFO: case LDNS_RR_TYPE_RP: @@ -954,7 +954,7 @@ canonical_compare(struct ub_packed_rrset_key* rrset, size_t i, size_t j) return canonical_compare_byfield(d, desc, i, j); case LDNS_RR_TYPE_HINFO: /* no longer downcased */ - case LDNS_RR_TYPE_NSEC: + case LDNS_RR_TYPE_NSEC: default: /* For unknown RR types, or types not listed above, * no canonicalization is needed, do binary compare */ @@ -1041,7 +1041,7 @@ insert_can_owner(sldns_buffer* buf, struct ub_packed_rrset_key* k, size_t len = k->rk.dname_len; /* so skip fqdn_labels-rrsig_labels */ for(i=0; irk.type)) { - case LDNS_RR_TYPE_NXT: + case LDNS_RR_TYPE_NXT: case LDNS_RR_TYPE_NS: case LDNS_RR_TYPE_MD: case LDNS_RR_TYPE_MF: @@ -1080,7 +1080,7 @@ canonicalize_rdata(sldns_buffer* buf, struct ub_packed_rrset_key* rrset, case LDNS_RR_TYPE_SOA: /* two names after another */ query_dname_tolower(datstart); - query_dname_tolower(datstart + + query_dname_tolower(datstart + dname_valid(datstart, len-2)); return; case LDNS_RR_TYPE_RT: @@ -1104,11 +1104,11 @@ canonicalize_rdata(sldns_buffer* buf, struct ub_packed_rrset_key* rrset, return; case LDNS_RR_TYPE_PX: /* skip, then two names after another */ - if(len < 2+2+1) + if(len < 2+2+1) return; datstart += 2; query_dname_tolower(datstart); - query_dname_tolower(datstart + + query_dname_tolower(datstart + dname_valid(datstart, len-2-2)); return; case LDNS_RR_TYPE_NAPTR: @@ -1140,12 +1140,12 @@ canonicalize_rdata(sldns_buffer* buf, struct ub_packed_rrset_key* rrset, query_dname_tolower(datstart); return; - /* do not canonicalize NSEC rdata name, compat with + /* do not canonicalize NSEC rdata name, compat with * from bind 9.4 signer, where it does not do so */ case LDNS_RR_TYPE_NSEC: /* type starts with the name */ case LDNS_RR_TYPE_HINFO: /* not downcased */ /* A6 not supported */ - default: + default: /* nothing to do for unknown types */ return; } @@ -1231,7 +1231,7 @@ int rrset_canonical_equal(struct regional* region, * @return false on alloc error. */ static int -rrset_canonical(struct regional* region, sldns_buffer* buf, +rrset_canonical(struct regional* region, sldns_buffer* buf, struct ub_packed_rrset_key* k, uint8_t* sig, size_t siglen, struct rbtree_type** sortree, sldns_pkt_section section, struct module_qstate* qstate) @@ -1243,7 +1243,7 @@ rrset_canonical(struct regional* region, sldns_buffer* buf, struct canon_rr* rrs; if(!*sortree) { - *sortree = (struct rbtree_type*)regional_alloc(region, + *sortree = (struct rbtree_type*)regional_alloc(region, sizeof(rbtree_type)); if(!*sortree) return 0; @@ -1261,7 +1261,7 @@ rrset_canonical(struct regional* region, sldns_buffer* buf, sldns_buffer_clear(buf); sldns_buffer_write(buf, sig, siglen); /* canonicalize signer name */ - query_dname_tolower(sldns_buffer_begin(buf)+18); + query_dname_tolower(sldns_buffer_begin(buf)+18); RBTREE_FOR(walk, struct canon_rr*, (*sortree)) { /* see if there is enough space left in the buffer */ if(sldns_buffer_remaining(buf) < can_owner_len + 2 + 2 + 4 @@ -1273,12 +1273,12 @@ rrset_canonical(struct regional* region, sldns_buffer* buf, /* determine canonical owner name */ if(can_owner) sldns_buffer_write(buf, can_owner, can_owner_len); - else insert_can_owner(buf, k, sig, &can_owner, + else insert_can_owner(buf, k, sig, &can_owner, &can_owner_len); sldns_buffer_write(buf, &k->rk.type, 2); sldns_buffer_write(buf, &k->rk.rrset_class, 2); sldns_buffer_write(buf, sig+4, 4); - sldns_buffer_write(buf, d->rr_data[walk->rr_idx], + sldns_buffer_write(buf, d->rr_data[walk->rr_idx], d->rr_len[walk->rr_idx]); canonicalize_rdata(buf, k, d->rr_len[walk->rr_idx]); } @@ -1295,7 +1295,7 @@ rrset_canonical(struct regional* region, sldns_buffer* buf, return 0; k->rk.dname_len = can_owner_len; } - + return 1; } @@ -1372,10 +1372,10 @@ sigdate_error(const char* str, int32_t expi, int32_t incep, int32_t now) if(gmtime_r(&te, &tm) && strftime(expi_buf, 15, "%Y%m%d%H%M%S", &tm) &&gmtime_r(&ti, &tm) && strftime(incep_buf, 15, "%Y%m%d%H%M%S", &tm) &&gmtime_r(&tn, &tm) && strftime(now_buf, 15, "%Y%m%d%H%M%S", &tm)) { - log_info("%s expi=%s incep=%s now=%s", str, expi_buf, + log_info("%s expi=%s incep=%s now=%s", str, expi_buf, incep_buf, now_buf); } else - log_info("%s expi=%u incep=%u now=%u", str, (unsigned)expi, + log_info("%s expi=%u incep=%u now=%u", str, (unsigned)expi, (unsigned)incep, (unsigned)now); } @@ -1394,11 +1394,11 @@ check_dates(struct val_env* ve, uint32_t unow, uint8_t* expi_p, /* get current date */ if(ve->date_override) { if(ve->date_override == -1) { - verbose(VERB_ALGO, "date override: ignore date"); + verbose(VERB_ALGO, "date override: ignore date"); return 1; } now = ve->date_override; - verbose(VERB_ALGO, "date override option %d", (int)now); + verbose(VERB_ALGO, "date override option %d", (int)now); } else now = unow; /* check them */ @@ -1437,7 +1437,7 @@ check_dates(struct val_env* ve, uint32_t unow, uint8_t* expi_p, if(skew < (uint32_t)ve->skew_min) skew = ve->skew_min; if(skew > (uint32_t)ve->skew_max) skew = ve->skew_max; if(subtract_1982(expi, now) > skew) { - sigdate_error("verify: signature expired", expi, + sigdate_error("verify: signature expired", expi, incep, now); *reason = "signature expired"; if(reason_bogus) @@ -1452,11 +1452,11 @@ check_dates(struct val_env* ve, uint32_t unow, uint8_t* expi_p, /** adjust rrset TTL for verified rrset, compare to original TTL and expi */ static void -adjust_ttl(struct val_env* ve, uint32_t unow, - struct ub_packed_rrset_key* rrset, uint8_t* orig_p, +adjust_ttl(struct val_env* ve, uint32_t unow, + struct ub_packed_rrset_key* rrset, uint8_t* orig_p, uint8_t* expi_p, uint8_t* incep_p) { - struct packed_rrset_data* d = + struct packed_rrset_data* d = (struct packed_rrset_data*)rrset->entry.data; /* read out the dates */ int32_t origttl, expittl, expi, incep, now; @@ -1500,8 +1500,8 @@ adjust_ttl(struct val_env* ve, uint32_t unow, } } -enum sec_status -dnskey_verify_rrset_sig(struct regional* region, sldns_buffer* buf, +enum sec_status +dnskey_verify_rrset_sig(struct regional* region, sldns_buffer* buf, struct val_env* ve, time_t now, struct ub_packed_rrset_key* rrset, struct ub_packed_rrset_key* dnskey, size_t dnskey_idx, size_t sig_idx, @@ -1535,10 +1535,10 @@ dnskey_verify_rrset_sig(struct regional* region, sldns_buffer* buf, *reason = "dnskey without ZSK flag"; if(reason_bogus) *reason_bogus = LDNS_EDE_NO_ZONE_KEY_BIT_SET; - return sec_status_bogus; + return sec_status_bogus; } - if(dnskey_get_protocol(dnskey, dnskey_idx) != LDNS_DNSSEC_KEYPROTO) { + if(dnskey_get_protocol(dnskey, dnskey_idx) != LDNS_DNSSEC_KEYPROTO) { /* RFC 4034 says DNSKEY PROTOCOL MUST be 3 */ verbose(VERB_QUERY, "verify: dnskey has wrong key protocol"); *reason = "dnskey has wrong protocolnumber"; @@ -1577,9 +1577,9 @@ dnskey_verify_rrset_sig(struct regional* region, sldns_buffer* buf, /* verify key dname == sig signer name */ if(query_dname_compare(signer, dnskey->rk.dname) != 0) { verbose(VERB_QUERY, "verify: wrong key for rrsig"); - log_nametypeclass(VERB_QUERY, "RRSIG signername is", + log_nametypeclass(VERB_QUERY, "RRSIG signername is", signer, 0, 0); - log_nametypeclass(VERB_QUERY, "the key name is", + log_nametypeclass(VERB_QUERY, "the key name is", dnskey->rk.dname, 0, 0); *reason = "signer name mismatches key name"; if(reason_bogus) @@ -1625,9 +1625,9 @@ dnskey_verify_rrset_sig(struct regional* region, sldns_buffer* buf, /* original ttl, always ok */ if(!*buf_canon) { - /* create rrset canonical format in buffer, ready for + /* create rrset canonical format in buffer, ready for * signature */ - if(!rrset_canonical(region, buf, rrset, sig+2, + if(!rrset_canonical(region, buf, rrset, sig+2, 18 + signer_len, sortree, section, qstate)) { log_err("verify: failed due to alloc error"); return sec_status_unchecked; @@ -1645,12 +1645,12 @@ dnskey_verify_rrset_sig(struct regional* region, sldns_buffer* buf, /* verify */ sec = verify_canonrrset(buf, (int)sig[2+2], sigblock, sigblock_len, key, keylen, reason); - + if(sec == sec_status_secure) { /* check if TTL is too high - reduce if so */ adjust_ttl(ve, now, rrset, sig+2+4, sig+2+8, sig+2+12); - /* verify inception, expiration dates + /* verify inception, expiration dates * Do this last so that if you ignore expired-sigs the * rest is sure to be OK. */ if(!check_dates(ve, now, sig+2+8, sig+2+12, diff --git a/sbin/unwind/libunbound/validator/val_sigcrypt.h b/sbin/unwind/libunbound/validator/val_sigcrypt.h index 7f52b71e4..9baec52c0 100644 --- a/sbin/unwind/libunbound/validator/val_sigcrypt.h +++ b/sbin/unwind/libunbound/validator/val_sigcrypt.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -141,8 +141,8 @@ int algo_needs_missing(struct algo_needs* n); */ void algo_needs_reason(struct module_env* env, int alg, char** reason, char* s); -/** - * Check if dnskey matches a DS digest +/** + * Check if dnskey matches a DS digest * Does not check dnskey-keyid footprint, just the digest. * @param env: module environment. Uses scratch space. * @param dnskey_rrset: DNSKEY rrset. @@ -155,13 +155,13 @@ int ds_digest_match_dnskey(struct module_env* env, struct ub_packed_rrset_key* dnskey_rrset, size_t dnskey_idx, struct ub_packed_rrset_key* ds_rrset, size_t ds_idx); -/** +/** * Get dnskey keytag, footprint value * @param dnskey_rrset: DNSKEY rrset. * @param dnskey_idx: index of RR in rrset. * @return the keytag or 0 for badly formatted DNSKEYs. */ -uint16_t dnskey_calc_keytag(struct ub_packed_rrset_key* dnskey_rrset, +uint16_t dnskey_calc_keytag(struct ub_packed_rrset_key* dnskey_rrset, size_t dnskey_idx); /** @@ -169,16 +169,16 @@ uint16_t dnskey_calc_keytag(struct ub_packed_rrset_key* dnskey_rrset, * @param ds_rrset: DS rrset * @param ds_idx: index of RR in DS rrset. * @return the keytag or 0 for badly formatted DSs. - */ + */ uint16_t ds_get_keytag(struct ub_packed_rrset_key* ds_rrset, size_t ds_idx); -/** - * See if DNSKEY algorithm is supported +/** + * See if DNSKEY algorithm is supported * @param dnskey_rrset: DNSKEY rrset. * @param dnskey_idx: index of RR in rrset. * @return true if supported. */ -int dnskey_algo_is_supported(struct ub_packed_rrset_key* dnskey_rrset, +int dnskey_algo_is_supported(struct ub_packed_rrset_key* dnskey_rrset, size_t dnskey_idx); /** @@ -198,13 +198,13 @@ int dnskey_size_is_supported(struct ub_packed_rrset_key* dnskey_rrset, */ int dnskeyset_size_is_supported(struct ub_packed_rrset_key* dnskey_rrset); -/** - * See if DS digest algorithm is supported +/** + * See if DS digest algorithm is supported * @param ds_rrset: DS rrset * @param ds_idx: index of RR in DS rrset. * @return true if supported. */ -int ds_digest_algo_is_supported(struct ub_packed_rrset_key* ds_rrset, +int ds_digest_algo_is_supported(struct ub_packed_rrset_key* ds_rrset, size_t ds_idx); /** @@ -215,13 +215,13 @@ int ds_digest_algo_is_supported(struct ub_packed_rrset_key* ds_rrset, */ int ds_get_digest_algo(struct ub_packed_rrset_key* ds_rrset, size_t ds_idx); -/** - * See if DS key algorithm is supported +/** + * See if DS key algorithm is supported * @param ds_rrset: DS rrset * @param ds_idx: index of RR in DS rrset. * @return true if supported. */ -int ds_key_algo_is_supported(struct ub_packed_rrset_key* ds_rrset, +int ds_key_algo_is_supported(struct ub_packed_rrset_key* ds_rrset, size_t ds_idx); /** @@ -241,15 +241,15 @@ int ds_get_key_algo(struct ub_packed_rrset_key* k, size_t idx); int dnskey_get_algo(struct ub_packed_rrset_key* k, size_t idx); /** - * Get DNSKEY RR flags + * Get DNSKEY RR flags * @param k: DNSKEY rrset. * @param idx: which DNSKEY RR. * @return flags or 0 if DNSKEY too short. */ uint16_t dnskey_get_flags(struct ub_packed_rrset_key* k, size_t idx); -/** - * Verify rrset against dnskey rrset. +/** + * Verify rrset against dnskey rrset. * @param env: module environment, scratch space is used. * @param ve: validator environment, date settings. * @param rrset: to be validated. @@ -264,15 +264,15 @@ uint16_t dnskey_get_flags(struct ub_packed_rrset_key* k, size_t idx); * UNCHECKED on allocation errors, unsupported algorithms, malformed data, * and BOGUS on verification failures (no keys match any signatures). */ -enum sec_status dnskeyset_verify_rrset(struct module_env* env, - struct val_env* ve, struct ub_packed_rrset_key* rrset, +enum sec_status dnskeyset_verify_rrset(struct module_env* env, + struct val_env* ve, struct ub_packed_rrset_key* rrset, struct ub_packed_rrset_key* dnskey, uint8_t* sigalg, char** reason, sldns_ede_code *reason_bogus, sldns_pkt_section section, struct module_qstate* qstate); -/** - * verify rrset against one specific dnskey (from rrset) +/** + * verify rrset against one specific dnskey (from rrset) * @param env: module environment, scratch space is used. * @param ve: validator environment, date settings. * @param rrset: to be validated. @@ -290,8 +290,8 @@ enum sec_status dnskey_verify_rrset(struct module_env* env, struct val_env* ve, size_t dnskey_idx, char** reason, sldns_ede_code *reason_bogus, sldns_pkt_section section, struct module_qstate* qstate); -/** - * verify rrset, with specific dnskey(from set), for a specific rrsig +/** + * verify rrset, with specific dnskey(from set), for a specific rrsig * @param region: scratch region used for temporary allocation. * @param buf: scratch buffer used for canonicalized rrset data. * @param ve: validator environment, date settings. @@ -309,7 +309,7 @@ enum sec_status dnskey_verify_rrset(struct module_env* env, struct val_env* ve, * @param reason_bogus: EDE (8914) code paired with the reason of failure. * @param section: section of packet where this rrset comes from. * @param qstate: qstate with region. - * @return secure if this key signs this signature. unchecked on error or + * @return secure if this key signs this signature. unchecked on error or * bogus if it did not validate. */ enum sec_status dnskey_verify_rrset_sig(struct regional* region, diff --git a/sbin/unwind/libunbound/validator/val_utils.c b/sbin/unwind/libunbound/validator/val_utils.c index 8b388882b..ba7a66a22 100644 --- a/sbin/unwind/libunbound/validator/val_utils.c +++ b/sbin/unwind/libunbound/validator/val_utils.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -58,7 +58,7 @@ #include "sldns/wire2str.h" #include "sldns/parseutil.h" -enum val_classification +enum val_classification val_classify_response(uint16_t query_flags, struct query_info* origqinf, struct query_info* qinf, struct reply_info* rep, size_t skip) { @@ -74,7 +74,7 @@ val_classify_response(uint16_t query_flags, struct query_info* origqinf, if(!(query_flags&BIT_RD) && rep->an_numrrsets == 0 && rcode == LDNS_RCODE_NOERROR) { /* SOA record in auth indicates it is NODATA instead. - * All validation requiring NODATA messages have SOA in + * All validation requiring NODATA messages have SOA in * authority section. */ /* uses fact that answer section is empty */ int saw_ns = 0; @@ -92,7 +92,7 @@ val_classify_response(uint16_t query_flags, struct query_info* origqinf, if(!(query_flags&BIT_RD) && rep->ns_numrrsets == 0 && rep->an_numrrsets == 1 && rcode == LDNS_RCODE_NOERROR && ntohs(rep->rrsets[0]->rk.type) == LDNS_RR_TYPE_NS && - query_dname_compare(rep->rrsets[0]->rk.dname, + query_dname_compare(rep->rrsets[0]->rk.dname, origqinf->qname) != 0) return VAL_CLASS_REFERRAL; @@ -106,15 +106,15 @@ val_classify_response(uint16_t query_flags, struct query_info* origqinf, /* Next is NODATA */ if(rcode == LDNS_RCODE_NOERROR && rep->an_numrrsets == 0) return VAL_CLASS_NODATA; - + /* We distinguish between CNAME response and other positive/negative * responses because CNAME answers require extra processing. */ - /* We distinguish between ANY and CNAME or POSITIVE because + /* We distinguish between ANY and CNAME or POSITIVE because * ANY responses are validated differently. */ if(rcode == LDNS_RCODE_NOERROR && qinf->qtype == LDNS_RR_TYPE_ANY) return VAL_CLASS_ANY; - + /* Note that DNAMEs will be ignored here, unless qtype=DNAME. Unless * qtype=CNAME, this will yield a CNAME response. */ for(i=skip; ian_numrrsets; i++) { @@ -156,7 +156,7 @@ rrsig_get_signer(uint8_t* data, size_t len, uint8_t** sname, size_t* slen) *sname = data; } -void +void val_find_rrset_signer(struct ub_packed_rrset_key* rrset, uint8_t** sname, size_t* slen) { @@ -169,7 +169,7 @@ val_find_rrset_signer(struct ub_packed_rrset_key* rrset, uint8_t** sname, return; } /* get rrsig signer name out of the signature */ - rrsig_get_signer(d->rr_data[d->count], d->rr_len[d->count], + rrsig_get_signer(d->rr_data[d->count], d->rr_len[d->count], sname, slen); } @@ -183,8 +183,8 @@ val_find_rrset_signer(struct ub_packed_rrset_key* rrset, uint8_t** sname, * Updated if match is improved. */ static void -val_find_best_signer(struct ub_packed_rrset_key* rrset, - struct query_info* qinf, uint8_t** signer_name, size_t* signer_len, +val_find_best_signer(struct ub_packed_rrset_key* rrset, + struct query_info* qinf, uint8_t** signer_name, size_t* signer_len, int* matchcount) { struct packed_rrset_data* d = (struct packed_rrset_data*) @@ -200,8 +200,8 @@ val_find_best_signer(struct ub_packed_rrset_key* rrset, * improve the match if possible */ if(d->rr_len[i] > 2+19 && /* rdata, sig + root label*/ dname_subdomain_c(qinf->qname, sign)) { - (void)dname_lab_cmp(qinf->qname, - dname_count_labels(qinf->qname), + (void)dname_lab_cmp(qinf->qname, + dname_count_labels(qinf->qname), sign, dname_count_labels(sign), &m); if(m > *matchcount) { *matchcount = m; @@ -213,19 +213,19 @@ val_find_best_signer(struct ub_packed_rrset_key* rrset, } } -void -val_find_signer(enum val_classification subtype, struct query_info* qinf, - struct reply_info* rep, size_t skip, uint8_t** signer_name, +void +val_find_signer(enum val_classification subtype, struct query_info* qinf, + struct reply_info* rep, size_t skip, uint8_t** signer_name, size_t* signer_len) { size_t i; - + if(subtype == VAL_CLASS_POSITIVE) { /* check for the answer rrset */ for(i=skip; ian_numrrsets; i++) { - if(query_dname_compare(qinf->qname, + if(query_dname_compare(qinf->qname, rep->rrsets[i]->rk.dname) == 0) { - val_find_rrset_signer(rep->rrsets[i], + val_find_rrset_signer(rep->rrsets[i], signer_name, signer_len); return; } @@ -235,7 +235,7 @@ val_find_signer(enum val_classification subtype, struct query_info* qinf, } else if(subtype == VAL_CLASS_CNAME) { /* check for the first signed cname/dname rrset */ for(i=skip; ian_numrrsets; i++) { - val_find_rrset_signer(rep->rrsets[i], + val_find_rrset_signer(rep->rrsets[i], signer_name, signer_len); if(*signer_name) return; @@ -244,7 +244,7 @@ val_find_signer(enum val_classification subtype, struct query_info* qinf, } *signer_name = NULL; *signer_len = 0; - } else if(subtype == VAL_CLASS_NAMEERROR + } else if(subtype == VAL_CLASS_NAMEERROR || subtype == VAL_CLASS_NODATA) { /*Check to see if the AUTH section NSEC record(s) have rrsigs*/ for(i=rep->an_numrrsets; i< @@ -252,7 +252,7 @@ val_find_signer(enum val_classification subtype, struct query_info* qinf, if(ntohs(rep->rrsets[i]->rk.type) == LDNS_RR_TYPE_NSEC || ntohs(rep->rrsets[i]->rk.type) == LDNS_RR_TYPE_NSEC3) { - val_find_rrset_signer(rep->rrsets[i], + val_find_rrset_signer(rep->rrsets[i], signer_name, signer_len); return; } @@ -264,9 +264,9 @@ val_find_signer(enum val_classification subtype, struct query_info* qinf, *signer_name = NULL; *signer_len = 0; for(i=rep->an_numrrsets; ian_numrrsets+rep-> - ns_numrrsets; i++) { + ns_numrrsets; i++) { if(ntohs(rep->rrsets[i]->rk.type) == LDNS_RR_TYPE_NSEC - || ntohs(rep->rrsets[i]->rk.type) == + || ntohs(rep->rrsets[i]->rk.type) == LDNS_RR_TYPE_NSEC3) { val_find_best_signer(rep->rrsets[i], qinf, signer_name, signer_len, &matchcount); @@ -276,9 +276,9 @@ val_find_signer(enum val_classification subtype, struct query_info* qinf, /* check for one of the answer rrset that has signatures, * or potentially a DNAME is in use with a different qname */ for(i=skip; ian_numrrsets; i++) { - if(query_dname_compare(qinf->qname, + if(query_dname_compare(qinf->qname, rep->rrsets[i]->rk.dname) == 0) { - val_find_rrset_signer(rep->rrsets[i], + val_find_rrset_signer(rep->rrsets[i], signer_name, signer_len); if(*signer_name) return; @@ -288,7 +288,7 @@ val_find_signer(enum val_classification subtype, struct query_info* qinf, if(skip < rep->an_numrrsets && ntohs(rep->rrsets[skip]->rk.type) == LDNS_RR_TYPE_DNAME) { - val_find_rrset_signer(rep->rrsets[skip], + val_find_rrset_signer(rep->rrsets[skip], signer_name, signer_len); if(*signer_name) return; @@ -298,7 +298,7 @@ val_find_signer(enum val_classification subtype, struct query_info* qinf, } else if(subtype == VAL_CLASS_REFERRAL) { /* find keys for the item at skip */ if(skip < rep->rrset_count) { - val_find_rrset_signer(rep->rrsets[skip], + val_find_rrset_signer(rep->rrsets[skip], signer_name, signer_len); return; } @@ -332,7 +332,7 @@ rrset_get_ttl(struct ub_packed_rrset_key* rrset) return d->ttl; } -static enum sec_status +static enum sec_status val_verify_rrset(struct module_env* env, struct val_env* ve, struct ub_packed_rrset_key* rrset, struct ub_packed_rrset_key* keys, uint8_t* sigalg, char** reason, sldns_ede_code *reason_bogus, @@ -343,16 +343,16 @@ val_verify_rrset(struct module_env* env, struct val_env* ve, entry.data; if(d->security == sec_status_secure) { /* re-verify all other statuses, because keyset may change*/ - log_nametypeclass(VERB_ALGO, "verify rrset cached", - rrset->rk.dname, ntohs(rrset->rk.type), + log_nametypeclass(VERB_ALGO, "verify rrset cached", + rrset->rk.dname, ntohs(rrset->rk.type), ntohs(rrset->rk.rrset_class)); return d->security; } /* check in the cache if verification has already been done */ rrset_check_sec_status(env->rrset_cache, rrset, *env->now); if(d->security == sec_status_secure) { - log_nametypeclass(VERB_ALGO, "verify rrset from cache", - rrset->rk.dname, ntohs(rrset->rk.type), + log_nametypeclass(VERB_ALGO, "verify rrset from cache", + rrset->rk.dname, ntohs(rrset->rk.type), ntohs(rrset->rk.rrset_class)); return d->security; } @@ -363,8 +363,8 @@ val_verify_rrset(struct module_env* env, struct val_env* ve, verbose(VERB_ALGO, "verify result: %s", sec_status_to_string(sec)); regional_free_all(env->scratch); - /* update rrset security status - * only improves security status + /* update rrset security status + * only improves security status * and bogus is set only once, even if we rechecked the status */ if(sec > d->security) { d->security = sec; @@ -389,7 +389,7 @@ val_verify_rrset(struct module_env* env, struct val_env* ve, return sec; } -enum sec_status +enum sec_status val_verify_rrset_entry(struct module_env* env, struct val_env* ve, struct ub_packed_rrset_key* rrset, struct key_entry_key* kkey, char** reason, sldns_ede_code *reason_bogus, @@ -423,7 +423,7 @@ verify_dnskeys_with_ds_rr(struct module_env* env, struct val_env* ve, num = rrset_get_count(dnskey_rrset); for(i=0; irk.dname, ds_rrset->rk.dname_len, ntohs(ds_rrset->rk.rrset_class), dnskey_rrset, downprot?sigalg:NULL, LDNS_EDE_NONE, NULL, @@ -648,7 +648,7 @@ val_verify_DNSKEY_with_TA(struct module_env* env, struct val_env* ve, if(ta_ds) { num = rrset_get_count(ta_ds); for(i=0; irr_data[sig][2+3]; } -int +int val_rrset_wildcard(struct ub_packed_rrset_key* rrset, uint8_t** wc, size_t* wc_len) { @@ -826,7 +826,7 @@ val_rrset_wildcard(struct ub_packed_rrset_key* rrset, uint8_t** wc, } } /* OK the rrsigs check out */ - /* if the RRSIG label count is shorter than the number of actual + /* if the RRSIG label count is shorter than the number of actual * labels, then this rrset was synthesized from a wildcard. * Note that the RRSIG label count doesn't count the root label. */ wn = rrset->rk.dname; @@ -888,8 +888,8 @@ rrset_has_signer(struct ub_packed_rrset_key* rrset, uint8_t* name, size_t len) return 0; } -void -val_fill_reply(struct reply_info* chase, struct reply_info* orig, +void +val_fill_reply(struct reply_info* chase, struct reply_info* orig, size_t skip, uint8_t* name, size_t len, uint8_t* signer) { size_t i; @@ -901,28 +901,28 @@ val_fill_reply(struct reply_info* chase, struct reply_info* orig, /* ANSWER section */ for(i=skip; ian_numrrsets; i++) { if(!signer) { - if(query_dname_compare(name, + if(query_dname_compare(name, orig->rrsets[i]->rk.dname) == 0) - chase->rrsets[chase->an_numrrsets++] = + chase->rrsets[chase->an_numrrsets++] = orig->rrsets[i]; - } else if(seen_dname && ntohs(orig->rrsets[i]->rk.type) == + } else if(seen_dname && ntohs(orig->rrsets[i]->rk.type) == LDNS_RR_TYPE_CNAME) { chase->rrsets[chase->an_numrrsets++] = orig->rrsets[i]; seen_dname = 0; } else if(rrset_has_signer(orig->rrsets[i], name, len)) { chase->rrsets[chase->an_numrrsets++] = orig->rrsets[i]; - if(ntohs(orig->rrsets[i]->rk.type) == + if(ntohs(orig->rrsets[i]->rk.type) == LDNS_RR_TYPE_DNAME) { seen_dname = 1; } } - } + } /* AUTHORITY section */ for(i = (skip > orig->an_numrrsets)?skip:orig->an_numrrsets; - ian_numrrsets+orig->ns_numrrsets; + ian_numrrsets+orig->ns_numrrsets; i++) { if(!signer) { - if(query_dname_compare(name, + if(query_dname_compare(name, orig->rrsets[i]->rk.dname) == 0) chase->rrsets[chase->an_numrrsets+ chase->ns_numrrsets++] = orig->rrsets[i]; @@ -933,20 +933,20 @@ val_fill_reply(struct reply_info* chase, struct reply_info* orig, } /* ADDITIONAL section */ for(i= (skip>orig->an_numrrsets+orig->ns_numrrsets)? - skip:orig->an_numrrsets+orig->ns_numrrsets; + skip:orig->an_numrrsets+orig->ns_numrrsets; irrset_count; i++) { if(!signer) { - if(query_dname_compare(name, + if(query_dname_compare(name, orig->rrsets[i]->rk.dname) == 0) chase->rrsets[chase->an_numrrsets - +orig->ns_numrrsets+chase->ar_numrrsets++] + +orig->ns_numrrsets+chase->ar_numrrsets++] = orig->rrsets[i]; } else if(rrset_has_signer(orig->rrsets[i], name, len)) { chase->rrsets[chase->an_numrrsets+orig->ns_numrrsets+ chase->ar_numrrsets++] = orig->rrsets[i]; } } - chase->rrset_count = chase->an_numrrsets + chase->ns_numrrsets + + chase->rrset_count = chase->an_numrrsets + chase->ns_numrrsets + chase->ar_numrrsets; } @@ -963,7 +963,7 @@ void val_reply_remove_auth(struct reply_info* rep, size_t index) } void -val_check_nonsecure(struct module_env* env, struct reply_info* rep) +val_check_nonsecure(struct module_env* env, struct reply_info* rep) { size_t i; /* authority */ @@ -982,17 +982,17 @@ val_check_nonsecure(struct module_env* env, struct reply_info* rep) /* check if authority has an NS record * which is bad, and there is an answer section with - * data. In that case, delete NS and additional to + * data. In that case, delete NS and additional to * be lenient and make a minimal response */ if(rep->an_numrrsets != 0 && - ntohs(rep->rrsets[i]->rk.type) + ntohs(rep->rrsets[i]->rk.type) == LDNS_RR_TYPE_NS) { verbose(VERB_ALGO, "truncate to minimal"); rep->ar_numrrsets = 0; rep->rrset_count = rep->an_numrrsets + rep->ns_numrrsets; /* remove this unneeded authority rrset */ - memmove(rep->rrsets+i, rep->rrsets+i+1, + memmove(rep->rrsets+i, rep->rrsets+i+1, sizeof(struct ub_packed_rrset_key*)* (rep->rrset_count - i - 1)); rep->ns_numrrsets--; @@ -1003,7 +1003,7 @@ val_check_nonsecure(struct module_env* env, struct reply_info* rep) log_nametypeclass(VERB_QUERY, "message is bogus, " "non secure rrset", - rep->rrsets[i]->rk.dname, + rep->rrsets[i]->rk.dname, ntohs(rep->rrsets[i]->rk.type), ntohs(rep->rrsets[i]->rk.rrset_class)); rep->security = sec_status_bogus; @@ -1025,7 +1025,7 @@ val_check_nonsecure(struct module_env* env, struct reply_info* rep) * their authentication. */ /* remove this unneeded additional rrset */ - memmove(rep->rrsets+i, rep->rrsets+i+1, + memmove(rep->rrsets+i, rep->rrsets+i+1, sizeof(struct ub_packed_rrset_key*)* (rep->rrset_count - i - 1)); rep->ar_numrrsets--; @@ -1046,8 +1046,8 @@ check_no_anchor(struct val_anchors* anchors, uint8_t* nm, size_t l, uint16_t c) return !ta; } -void -val_mark_indeterminate(struct reply_info* rep, struct val_anchors* anchors, +void +val_mark_indeterminate(struct reply_info* rep, struct val_anchors* anchors, struct rrset_cache* r, struct module_env* env) { size_t i; @@ -1056,9 +1056,9 @@ val_mark_indeterminate(struct reply_info* rep, struct val_anchors* anchors, d = (struct packed_rrset_data*)rep->rrsets[i]->entry.data; if(d->security == sec_status_unchecked && check_no_anchor(anchors, rep->rrsets[i]->rk.dname, - rep->rrsets[i]->rk.dname_len, - ntohs(rep->rrsets[i]->rk.rrset_class))) - { + rep->rrsets[i]->rk.dname_len, + ntohs(rep->rrsets[i]->rk.rrset_class))) + { /* mark as indeterminate */ d->security = sec_status_indeterminate; rrset_update_sec_status(r, rep->rrsets[i], *env->now); @@ -1066,7 +1066,7 @@ val_mark_indeterminate(struct reply_info* rep, struct val_anchors* anchors, } } -void +void val_mark_insecure(struct reply_info* rep, uint8_t* kname, struct rrset_cache* r, struct module_env* env) { @@ -1083,7 +1083,7 @@ val_mark_insecure(struct reply_info* rep, uint8_t* kname, } } -size_t +size_t val_next_unchecked(struct reply_info* rep, size_t skip) { size_t i; @@ -1170,14 +1170,14 @@ int val_has_signed_nsecs(struct reply_info* rep, char** reason) return 0; } -struct dns_msg* -val_find_DS(struct module_env* env, uint8_t* nm, size_t nmlen, uint16_t c, +struct dns_msg* +val_find_DS(struct module_env* env, uint8_t* nm, size_t nmlen, uint16_t c, struct regional* region, uint8_t* topname) { struct dns_msg* msg; struct query_info qinfo; struct ub_packed_rrset_key *rrset = rrset_cache_lookup( - env->rrset_cache, nm, nmlen, LDNS_RR_TYPE_DS, c, 0, + env->rrset_cache, nm, nmlen, LDNS_RR_TYPE_DS, c, 0, *env->now, 0); if(rrset) { /* DS rrset exists. Return it to the validator immediately*/ diff --git a/sbin/unwind/libunbound/validator/val_utils.h b/sbin/unwind/libunbound/validator/val_utils.h index 83e3d0ad8..d6abf1235 100644 --- a/sbin/unwind/libunbound/validator/val_utils.h +++ b/sbin/unwind/libunbound/validator/val_utils.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -93,7 +93,7 @@ enum val_classification { * Then, another CNAME type, CNAME_NOANSWER or POSITIVE are possible. */ enum val_classification val_classify_response(uint16_t query_flags, - struct query_info* origqinf, struct query_info* qinf, + struct query_info* origqinf, struct query_info* qinf, struct reply_info* rep, size_t skip); /** @@ -106,11 +106,11 @@ enum val_classification val_classify_response(uint16_t query_flags, * @param rep: response to that, original response. * @param cname_skip: how many answer rrsets have been skipped due to CNAME * chains being chased around. - * @param signer_name: signer name, if the response is signed + * @param signer_name: signer name, if the response is signed * (even partially), or null if the response isn't signed. * @param signer_len: length of signer_name of 0 if signer_name is NULL. */ -void val_find_signer(enum val_classification subtype, +void val_find_signer(enum val_classification subtype, struct query_info* qinf, struct reply_info* rep, size_t cname_skip, uint8_t** signer_name, size_t* signer_len); @@ -126,8 +126,8 @@ void val_find_signer(enum val_classification subtype, * @param qstate: qstate with region. * @return security status of verification. */ -enum sec_status val_verify_rrset_entry(struct module_env* env, - struct val_env* ve, struct ub_packed_rrset_key* rrset, +enum sec_status val_verify_rrset_entry(struct module_env* env, + struct val_env* ve, struct ub_packed_rrset_key* rrset, struct key_entry_key* kkey, char** reason, sldns_ede_code *reason_bogus, sldns_pkt_section section, struct module_qstate* qstate); @@ -204,7 +204,7 @@ enum sec_status val_verify_DNSKEY_with_TA(struct module_env* env, */ struct key_entry_key* val_verify_new_DNSKEYs(struct regional* region, struct module_env* env, struct val_env* ve, - struct ub_packed_rrset_key* dnskey_rrset, + struct ub_packed_rrset_key* dnskey_rrset, struct ub_packed_rrset_key* ds_rrset, int downprot, char** reason, sldns_ede_code *reason_bogus, struct module_qstate* qstate); @@ -232,7 +232,7 @@ struct key_entry_key* val_verify_new_DNSKEYs(struct regional* region, * rrset. * if downprot is set, a key entry with an algo list is made. */ -struct key_entry_key* val_verify_new_DNSKEYs_with_ta(struct regional* region, +struct key_entry_key* val_verify_new_DNSKEYs_with_ta(struct regional* region, struct module_env* env, struct val_env* ve, struct ub_packed_rrset_key* dnskey_rrset, struct ub_packed_rrset_key* ta_ds_rrset, @@ -253,18 +253,18 @@ int val_dsset_isusable(struct ub_packed_rrset_key* ds_rrset); * Determine by looking at a signed RRset whether or not the RRset name was * the result of a wildcard expansion. If so, return the name of the * generating wildcard. - * + * * @param rrset The rrset to check. * @param wc: the wildcard name, if the rrset was synthesized from a wildcard. - * unchanged if not. The wildcard name, without "*." in front, is + * unchanged if not. The wildcard name, without "*." in front, is * returned. This is a pointer into the rrset owner name. * @param wc_len: the length of the returned wildcard name. - * @return false if the signatures are inconsistent in indicating the + * @return false if the signatures are inconsistent in indicating the * wildcard status; possible spoofing of wildcard response for other * responses is being tried. We lost the status which rrsig was verified * after the verification routine finished, so we simply check if * the signatures are consistent; inserting a fake signature is a denial - * of service; but in that you could also have removed the real + * of service; but in that you could also have removed the real * signature anyway. */ int val_rrset_wildcard(struct ub_packed_rrset_key* rrset, uint8_t** wc, @@ -295,7 +295,7 @@ int val_chase_cname(struct query_info* qchase, struct reply_info* rep, * @param signer: signer name or NULL if an unsigned RRset is considered. * If NULL, rrsets with the lookup name are copied over. */ -void val_fill_reply(struct reply_info* chase, struct reply_info* orig, +void val_fill_reply(struct reply_info* chase, struct reply_info* orig, size_t cname_skip, uint8_t* name, size_t len, uint8_t* signer); /** @@ -323,8 +323,8 @@ void val_check_nonsecure(struct module_env* env, struct reply_info* rep); * @param r: rrset cache to store updated security status into. * @param env: module environment */ -void val_mark_indeterminate(struct reply_info* rep, - struct val_anchors* anchors, struct rrset_cache* r, +void val_mark_indeterminate(struct reply_info* rep, + struct val_anchors* anchors, struct rrset_cache* r, struct module_env* env); /** diff --git a/sbin/unwind/libunbound/validator/validator.c b/sbin/unwind/libunbound/validator/validator.c index 9de9d54db..004846016 100644 --- a/sbin/unwind/libunbound/validator/validator.c +++ b/sbin/unwind/libunbound/validator/validator.c @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -65,8 +65,8 @@ #include "sldns/str2wire.h" /* forward decl for cache response and normal super inform calls of a DS */ -static void process_ds_response(struct module_qstate* qstate, - struct val_qstate* vq, int id, int rcode, struct dns_msg* msg, +static void process_ds_response(struct module_qstate* qstate, + struct val_qstate* vq, int id, int rcode, struct dns_msg* msg, struct query_info* qinfo, struct sock_list* origin); @@ -112,7 +112,7 @@ fill_nsec3_iter(struct val_env* ve, char* s, int c) s = e; if(i>0 && ve->nsec3_keysize[i-1] >= ve->nsec3_keysize[i]) { log_err("nsec3 key iterations not ascending: %d %d", - (int)ve->nsec3_keysize[i-1], + (int)ve->nsec3_keysize[i-1], (int)ve->nsec3_keysize[i]); return 0; } @@ -124,7 +124,7 @@ fill_nsec3_iter(struct val_env* ve, char* s, int c) /** apply config settings to validator */ static int -val_apply_cfg(struct module_env* env, struct val_env* val_env, +val_apply_cfg(struct module_env* env, struct val_env* val_env, struct config_file* cfg) { int c; @@ -250,8 +250,8 @@ val_new_getmsg(struct module_qstate* qstate, struct val_qstate* vq) } vq->qchase = qstate->qinfo; /* chase reply will be an edited (sub)set of the orig msg rrset ptrs */ - vq->chase_reply = regional_alloc_init(qstate->region, - vq->orig_msg->rep, + vq->chase_reply = regional_alloc_init(qstate->region, + vq->orig_msg->rep, sizeof(struct reply_info) - sizeof(struct rrset_ref)); if(!vq->chase_reply) return NULL; @@ -283,7 +283,7 @@ val_new(struct module_qstate* qstate, int id) /** * Exit validation with an error status - * + * * @param qstate: query state * @param id: validator id. * @return false, for use by caller to return to stop processing. @@ -296,10 +296,10 @@ val_error(struct module_qstate* qstate, int id) return 0; } -/** +/** * Check to see if a given response needs to go through the validation * process. Typical reasons for this routine to return false are: CD bit was - * on in the original request, or the response is a kind of message that + * on in the original request, or the response is a kind of message that * is unvalidatable (i.e., SERVFAIL, REFUSED, etc.) * * @param qstate: query state. @@ -309,7 +309,7 @@ val_error(struct module_qstate* qstate, int id) * mean we can actually validate this response). */ static int -needs_validation(struct module_qstate* qstate, int ret_rc, +needs_validation(struct module_qstate* qstate, int ret_rc, struct dns_msg* ret_msg) { int rcode; @@ -392,8 +392,8 @@ already_validated(struct dns_msg* ret_msg) * @return false on alloc failure. */ static int -generate_request(struct module_qstate* qstate, int id, uint8_t* name, - size_t namelen, uint16_t qtype, uint16_t qclass, uint16_t flags, +generate_request(struct module_qstate* qstate, int id, uint8_t* name, + size_t namelen, uint16_t qtype, uint16_t qclass, uint16_t flags, struct module_qstate** newq, int detached) { struct val_qstate* vq = (struct val_qstate*)qstate->minfo[id]; @@ -420,7 +420,7 @@ generate_request(struct module_qstate* qstate, int id, uint8_t* name, struct mesh_state* sub = NULL; fptr_ok(fptr_whitelist_modenv_add_sub( qstate->env->add_sub)); - if(!(*qstate->env->add_sub)(qstate, &ask, + if(!(*qstate->env->add_sub)(qstate, &ask, (uint16_t)(BIT_RD|flags), 0, valrec, newq, &sub)){ log_err("Could not generate request: out of memory"); return 0; @@ -429,7 +429,7 @@ generate_request(struct module_qstate* qstate, int id, uint8_t* name, else { fptr_ok(fptr_whitelist_modenv_attach_sub( qstate->env->attach_sub)); - if(!(*qstate->env->attach_sub)(qstate, &ask, + if(!(*qstate->env->attach_sub)(qstate, &ask, (uint16_t)(BIT_RD|flags), 0, valrec, newq)){ log_err("Could not generate request: out of memory"); return 0; @@ -562,7 +562,7 @@ prime_trust_anchor(struct module_qstate* qstate, struct val_qstate* vq, } /* ignore newq; validator does not need state created for that * query, and its a 'normal' for iterator as well */ - vq->wait_prime_ta = 1; /* to elicit PRIME_RESP_STATE processing + vq->wait_prime_ta = 1; /* to elicit PRIME_RESP_STATE processing from the validator inform_super() routine */ /* store trust anchor name for later lookup when prime returns */ vq->trust_anchor_name = regional_alloc_init(qstate->region, @@ -581,11 +581,11 @@ prime_trust_anchor(struct module_qstate* qstate, struct val_qstate* vq, * They must be validly signed with the given key. * Tries to validate ADDITIONAL rrsets as well, but only to check them. * Allows unsigned CNAME after a DNAME that expands the DNAME. - * + * * Note that by the time this method is called, the process of finding the * trusted DNSKEY rrset that signs this response must already have been * completed. - * + * * @param qstate: query state. * @param env: module env for verify. * @param ve: validator env for verify. @@ -593,7 +593,7 @@ prime_trust_anchor(struct module_qstate* qstate, struct val_qstate* vq, * @param chase_reply: answer to validate. * @param key_entry: the key entry, which is trusted, and which matches * the signer of the answer. The key entry isgood(). - * @return false if any of the rrsets in the an or ns sections of the message + * @return false if any of the rrsets in the an or ns sections of the message * fail to verify. The message is then set to bogus. */ static int @@ -613,8 +613,8 @@ validate_msg_signatures(struct module_qstate* qstate, struct module_env* env, for(i=0; ian_numrrsets; i++) { s = chase_reply->rrsets[i]; /* Skip the CNAME following a (validated) DNAME. - * Because of the normalization routines in the iterator, - * there will always be an unsigned CNAME following a DNAME + * Because of the normalization routines in the iterator, + * there will always be an unsigned CNAME following a DNAME * (unless qtype=DNAME). */ if(dname_seen && ntohs(s->rk.type) == LDNS_RR_TYPE_CNAME) { dname_seen = 0; @@ -630,7 +630,7 @@ validate_msg_signatures(struct module_qstate* qstate, struct module_env* env, /* Verify the answer rrset */ sec = val_verify_rrset_entry(env, ve, s, key_entry, &reason, &reason_bogus, LDNS_SECTION_ANSWER, qstate); - /* If the (answer) rrset failed to validate, then this + /* If the (answer) rrset failed to validate, then this * message is BAD. */ if(sec != sec_status_secure) { log_nametypeclass(VERB_QUERY, "validator: response " @@ -648,9 +648,9 @@ validate_msg_signatures(struct module_qstate* qstate, struct module_env* env, return 0; } - /* Notice a DNAME that should be followed by an unsigned + /* Notice a DNAME that should be followed by an unsigned * CNAME. */ - if(qchase->qtype != LDNS_RR_TYPE_DNAME && + if(qchase->qtype != LDNS_RR_TYPE_DNAME && ntohs(s->rk.type) == LDNS_RR_TYPE_DNAME) { dname_seen = 1; } @@ -662,7 +662,7 @@ validate_msg_signatures(struct module_qstate* qstate, struct module_env* env, s = chase_reply->rrsets[i]; sec = val_verify_rrset_entry(env, ve, s, key_entry, &reason, &reason_bogus, LDNS_SECTION_AUTHORITY, qstate); - /* If anything in the authority section fails to be secure, + /* If anything in the authority section fails to be secure, * we have a bad message. */ if(sec != sec_status_secure) { log_nametypeclass(VERB_QUERY, "validator: response " @@ -682,7 +682,7 @@ validate_msg_signatures(struct module_qstate* qstate, struct module_env* env, if(!env->cfg->val_clean_additional) return 1; /* attempt to validate the ADDITIONAL section rrsets */ - for(i=chase_reply->an_numrrsets+chase_reply->ns_numrrsets; + for(i=chase_reply->an_numrrsets+chase_reply->ns_numrrsets; irrset_count; i++) { s = chase_reply->rrsets[i]; /* only validate rrs that have signatures with the key */ @@ -692,7 +692,7 @@ validate_msg_signatures(struct module_qstate* qstate, struct module_env* env, if(sname && query_dname_compare(sname, key_entry->name)==0) (void)val_verify_rrset_entry(env, ve, s, key_entry, &reason, NULL, LDNS_SECTION_ADDITIONAL, qstate); - /* the additional section can fail to be secure, + /* the additional section can fail to be secure, * it is optional, check signature in case we need * to clean the additional section later. */ } @@ -788,10 +788,10 @@ remove_spurious_authority(struct reply_info* chase_reply, /** * Given a "positive" response -- a response that contains an answer to the - * question, and no CNAME chain, validate this response. + * question, and no CNAME chain, validate this response. * * The answer and authority RRsets must already be verified as secure. - * + * * @param env: module env for verify. * @param ve: validator env for verify. * @param qchase: query that was made. @@ -816,8 +816,8 @@ validate_positive_response(struct module_env* env, struct val_env* ve, for(i=0; ian_numrrsets; i++) { s = chase_reply->rrsets[i]; - /* Check to see if the rrset is the result of a wildcard - * expansion. If so, an additional check will need to be + /* Check to see if the rrset is the result of a wildcard + * expansion. If so, an additional check will need to be * made in the authority section. */ if(!val_rrset_wildcard(s, &wc, &wl)) { log_nametypeclass(VERB_QUERY, "Positive response has " @@ -835,15 +835,15 @@ validate_positive_response(struct module_env* env, struct val_env* ve, } - /* validate the AUTHORITY section as well - this will generally be + /* validate the AUTHORITY section as well - this will generally be * the NS rrset (which could be missing, no problem) */ for(i=chase_reply->an_numrrsets; ian_numrrsets+ chase_reply->ns_numrrsets; i++) { s = chase_reply->rrsets[i]; - /* If this is a positive wildcard response, and we have a - * (just verified) NSEC record, try to use it to 1) prove - * that qname doesn't exist and 2) that the correct wildcard + /* If this is a positive wildcard response, and we have a + * (just verified) NSEC record, try to use it to 1) prove + * that qname doesn't exist and 2) that the correct wildcard * was used. */ if(wc != NULL && ntohs(s->rk.type) == LDNS_RR_TYPE_NSEC) { if(val_nsec_proves_positive_wildcard(s, qchase, wc)) { @@ -852,7 +852,7 @@ validate_positive_response(struct module_env* env, struct val_env* ve, /* if not, continue looking for proof */ } - /* Otherwise, if this is a positive wildcard response and + /* Otherwise, if this is a positive wildcard response and * we have NSEC3 records */ if(wc != NULL && ntohs(s->rk.type) == LDNS_RR_TYPE_NSEC3) { nsec3s_seen = 1; @@ -863,7 +863,7 @@ validate_positive_response(struct module_env* env, struct val_env* ve, * proven, and we have NSEC3 records, try to prove it using the NSEC3 * records. */ if(wc != NULL && !wc_NSEC_ok && nsec3s_seen) { - enum sec_status sec = nsec3_prove_wildcard(env, ve, + enum sec_status sec = nsec3_prove_wildcard(env, ve, chase_reply->rrsets+chase_reply->an_numrrsets, chase_reply->ns_numrrsets, qchase, kkey, wc); if(sec == sec_status_insecure) { @@ -890,10 +890,10 @@ validate_positive_response(struct module_env* env, struct val_env* ve, chase_reply->security = sec_status_secure; } -/** +/** * Validate a NOERROR/NODATA signed response -- a response that has a - * NOERROR Rcode but no ANSWER section RRsets. This consists of making - * certain that the authority section NSEC/NSEC3s proves that the qname + * NOERROR Rcode but no ANSWER section RRsets. This consists of making + * certain that the authority section NSEC/NSEC3s proves that the qname * does exist and the qtype doesn't. * * The answer and authority RRsets must already be verified as secure. @@ -914,29 +914,29 @@ validate_nodata_response(struct module_env* env, struct val_env* ve, * validate. */ /* (Note: CNAME/DNAME responses will not directly get here -- * instead, they are chased down into individual CNAME validations, - * and at the end of the cname chain a POSITIVE, or CNAME_NOANSWER + * and at the end of the cname chain a POSITIVE, or CNAME_NOANSWER * validation.) */ - + /* validate the AUTHORITY section */ int has_valid_nsec = 0; /* If true, then the NODATA has been proven.*/ - uint8_t* ce = NULL; /* for wildcard nodata responses. This is the + uint8_t* ce = NULL; /* for wildcard nodata responses. This is the proven closest encloser. */ uint8_t* wc = NULL; /* for wildcard nodata responses. wildcard nsec */ int nsec3s_seen = 0; /* nsec3s seen */ - struct ub_packed_rrset_key* s; + struct ub_packed_rrset_key* s; size_t i; for(i=chase_reply->an_numrrsets; ian_numrrsets+ chase_reply->ns_numrrsets; i++) { s = chase_reply->rrsets[i]; - /* If we encounter an NSEC record, try to use it to prove + /* If we encounter an NSEC record, try to use it to prove * NODATA. * This needs to handle the ENT NODATA case. */ if(ntohs(s->rk.type) == LDNS_RR_TYPE_NSEC) { if(nsec_proves_nodata(s, qchase, &wc)) { has_valid_nsec = 1; /* sets wc-encloser if wildcard applicable */ - } + } if(val_nsec_proves_name_error(s, qchase->qname)) { ce = nsec_closest_encloser(qchase->qname, s); } @@ -952,8 +952,8 @@ validate_nodata_response(struct module_env* env, struct val_env* ve, /* check to see if we have a wildcard NODATA proof. */ - /* The wildcard NODATA is 1 NSEC proving that qname does not exist - * (and also proving what the closest encloser is), and 1 NSEC + /* The wildcard NODATA is 1 NSEC proving that qname does not exist + * (and also proving what the closest encloser is), and 1 NSEC * showing the matching wildcard, which must be *.closest_encloser. */ if(wc && !ce) has_valid_nsec = 0; @@ -962,9 +962,9 @@ validate_nodata_response(struct module_env* env, struct val_env* ve, has_valid_nsec = 0; } } - + if(!has_valid_nsec && nsec3s_seen) { - enum sec_status sec = nsec3_prove_nodata(env, ve, + enum sec_status sec = nsec3_prove_nodata(env, ve, chase_reply->rrsets+chase_reply->an_numrrsets, chase_reply->ns_numrrsets, qchase, kkey); if(sec == sec_status_insecure) { @@ -989,12 +989,12 @@ validate_nodata_response(struct module_env* env, struct val_env* ve, chase_reply->security = sec_status_secure; } -/** +/** * Validate a NAMEERROR signed response -- a response that has a NXDOMAIN - * Rcode. - * This consists of making certain that the authority section NSEC proves + * Rcode. + * This consists of making certain that the authority section NSEC proves * that the qname doesn't exist and the covering wildcard also doesn't exist.. - * + * * The answer and authority RRsets must have already been verified as secure. * * @param env: module env for verify. @@ -1013,7 +1013,7 @@ validate_nameerror_response(struct module_env* env, struct val_env* ve, int has_valid_nsec = 0; int has_valid_wnsec = 0; int nsec3s_seen = 0; - struct ub_packed_rrset_key* s; + struct ub_packed_rrset_key* s; size_t i; uint8_t* ce; int ce_labs = 0; @@ -1025,19 +1025,19 @@ validate_nameerror_response(struct module_env* env, struct val_env* ve, if(ntohs(s->rk.type) == LDNS_RR_TYPE_NSEC) { if(val_nsec_proves_name_error(s, qchase->qname)) has_valid_nsec = 1; - ce = nsec_closest_encloser(qchase->qname, s); - ce_labs = dname_count_labels(ce); + ce = nsec_closest_encloser(qchase->qname, s); + ce_labs = dname_count_labels(ce); /* Use longest closest encloser to prove wildcard. */ - if(ce_labs > prev_ce_labs || - (ce_labs == prev_ce_labs && - has_valid_wnsec == 0)) { - if(val_nsec_proves_no_wc(s, qchase->qname, - qchase->qname_len)) - has_valid_wnsec = 1; - else - has_valid_wnsec = 0; - } - prev_ce_labs = ce_labs; + if(ce_labs > prev_ce_labs || + (ce_labs == prev_ce_labs && + has_valid_wnsec == 0)) { + if(val_nsec_proves_no_wc(s, qchase->qname, + qchase->qname_len)) + has_valid_wnsec = 1; + else + has_valid_wnsec = 0; + } + prev_ce_labs = ce_labs; if(val_nsec_proves_insecuredelegation(s, qchase)) { verbose(VERB_ALGO, "delegation is insecure"); chase_reply->security = sec_status_insecure; @@ -1093,14 +1093,14 @@ validate_nameerror_response(struct module_env* env, struct val_env* ve, chase_reply->security = sec_status_secure; } -/** +/** * Given a referral response, validate rrsets and take least trusted rrset * as the current validation status. - * + * * Note that by the time this method is called, the process of finding the * trusted DNSKEY rrset that signs this response must already have been * completed. - * + * * @param chase_reply: answer to validate. */ static void @@ -1120,24 +1120,24 @@ validate_referral_response(struct reply_info* chase_reply) sec_status_to_string(chase_reply->security)); } -/** +/** * Given an "ANY" response -- a response that contains an answer to a - * qtype==ANY question, with answers. This does no checking that all + * qtype==ANY question, with answers. This does no checking that all * types are present. - * + * * NOTE: it may be possible to get parent-side delegation point records * here, which won't all be signed. Right now, this routine relies on the * upstream iterative resolver to not return these responses -- instead * treating them as referrals. - * + * * NOTE: RFC 4035 is silent on this issue, so this may change upon * clarification. Clarification draft -05 says to not check all types are * present. - * + * * Note that by the time this method is called, the process of finding the * trusted DNSKEY rrset that signs this response must already have been * completed. - * + * * @param env: module env for verify. * @param ve: validator env for verify. * @param qchase: query that was made. @@ -1171,13 +1171,13 @@ validate_any_response(struct module_env* env, struct val_env* ve, for(i=0; ian_numrrsets; i++) { s = chase_reply->rrsets[i]; - /* Check to see if the rrset is the result of a wildcard - * expansion. If so, an additional check will need to be + /* Check to see if the rrset is the result of a wildcard + * expansion. If so, an additional check will need to be * made in the authority section. */ if(!val_rrset_wildcard(s, &wc, &wl)) { log_nametypeclass(VERB_QUERY, "Positive ANY response" - " has inconsistent wildcard sigs:", - s->rk.dname, ntohs(s->rk.type), + " has inconsistent wildcard sigs:", + s->rk.dname, ntohs(s->rk.type), ntohs(s->rk.rrset_class)); chase_reply->security = sec_status_bogus; update_reason_bogus(chase_reply, LDNS_EDE_DNSSEC_BOGUS); @@ -1188,13 +1188,13 @@ validate_any_response(struct module_env* env, struct val_env* ve, /* if it was a wildcard, check for NSEC/NSEC3s in both answer * and authority sections (NSEC may be moved to the ANSWER section) */ if(wc != NULL) - for(i=0; ian_numrrsets+chase_reply->ns_numrrsets; + for(i=0; ian_numrrsets+chase_reply->ns_numrrsets; i++) { s = chase_reply->rrsets[i]; - /* If this is a positive wildcard response, and we have a - * (just verified) NSEC record, try to use it to 1) prove - * that qname doesn't exist and 2) that the correct wildcard + /* If this is a positive wildcard response, and we have a + * (just verified) NSEC record, try to use it to 1) prove + * that qname doesn't exist and 2) that the correct wildcard * was used. */ if(ntohs(s->rk.type) == LDNS_RR_TYPE_NSEC) { if(val_nsec_proves_positive_wildcard(s, qchase, wc)) { @@ -1203,7 +1203,7 @@ validate_any_response(struct module_env* env, struct val_env* ve, /* if not, continue looking for proof */ } - /* Otherwise, if this is a positive wildcard response and + /* Otherwise, if this is a positive wildcard response and * we have NSEC3 records */ if(ntohs(s->rk.type) == LDNS_RR_TYPE_NSEC3) { nsec3s_seen = 1; @@ -1215,9 +1215,9 @@ validate_any_response(struct module_env* env, struct val_env* ve, * records. */ if(wc != NULL && !wc_NSEC_ok && nsec3s_seen) { /* look both in answer and auth section for NSEC3s */ - enum sec_status sec = nsec3_prove_wildcard(env, ve, + enum sec_status sec = nsec3_prove_wildcard(env, ve, chase_reply->rrsets, - chase_reply->an_numrrsets+chase_reply->ns_numrrsets, + chase_reply->an_numrrsets+chase_reply->ns_numrrsets, qchase, kkey, wc); if(sec == sec_status_insecure) { verbose(VERB_ALGO, "Positive ANY wildcard response is " @@ -1245,13 +1245,13 @@ validate_any_response(struct module_env* env, struct val_env* ve, /** * Validate CNAME response, or DNAME+CNAME. - * This is just like a positive proof, except that this is about a + * This is just like a positive proof, except that this is about a * DNAME+CNAME. Possible wildcard proof. - * Difference with positive proof is that this routine refuses + * Difference with positive proof is that this routine refuses * wildcarded DNAMEs. - * + * * The answer and authority rrsets must already be verified as secure. - * + * * @param env: module env for verify. * @param ve: validator env for verify. * @param qchase: query that was made. @@ -1275,8 +1275,8 @@ validate_cname_response(struct module_env* env, struct val_env* ve, for(i=0; ian_numrrsets; i++) { s = chase_reply->rrsets[i]; - /* Check to see if the rrset is the result of a wildcard - * expansion. If so, an additional check will need to be + /* Check to see if the rrset is the result of a wildcard + * expansion. If so, an additional check will need to be * made in the authority section. */ if(!val_rrset_wildcard(s, &wc, &wl)) { log_nametypeclass(VERB_QUERY, "Cname response has " @@ -1286,14 +1286,14 @@ validate_cname_response(struct module_env* env, struct val_env* ve, update_reason_bogus(chase_reply, LDNS_EDE_DNSSEC_BOGUS); return; } - - /* Refuse wildcarded DNAMEs rfc 4597. - * Do not follow a wildcarded DNAME because + + /* Refuse wildcarded DNAMEs rfc 4597. + * Do not follow a wildcarded DNAME because * its synthesized CNAME expansion is underdefined */ - if(qchase->qtype != LDNS_RR_TYPE_DNAME && + if(qchase->qtype != LDNS_RR_TYPE_DNAME && ntohs(s->rk.type) == LDNS_RR_TYPE_DNAME && wc) { log_nametypeclass(VERB_QUERY, "cannot validate a " - "wildcarded DNAME:", s->rk.dname, + "wildcarded DNAME:", s->rk.dname, ntohs(s->rk.type), ntohs(s->rk.rrset_class)); chase_reply->security = sec_status_bogus; update_reason_bogus(chase_reply, LDNS_EDE_DNSSEC_BOGUS); @@ -1313,9 +1313,9 @@ validate_cname_response(struct module_env* env, struct val_env* ve, chase_reply->ns_numrrsets; i++) { s = chase_reply->rrsets[i]; - /* If this is a positive wildcard response, and we have a - * (just verified) NSEC record, try to use it to 1) prove - * that qname doesn't exist and 2) that the correct wildcard + /* If this is a positive wildcard response, and we have a + * (just verified) NSEC record, try to use it to 1) prove + * that qname doesn't exist and 2) that the correct wildcard * was used. */ if(wc != NULL && ntohs(s->rk.type) == LDNS_RR_TYPE_NSEC) { if(val_nsec_proves_positive_wildcard(s, qchase, wc)) { @@ -1324,7 +1324,7 @@ validate_cname_response(struct module_env* env, struct val_env* ve, /* if not, continue looking for proof */ } - /* Otherwise, if this is a positive wildcard response and + /* Otherwise, if this is a positive wildcard response and * we have NSEC3 records */ if(wc != NULL && ntohs(s->rk.type) == LDNS_RR_TYPE_NSEC3) { nsec3s_seen = 1; @@ -1335,7 +1335,7 @@ validate_cname_response(struct module_env* env, struct val_env* ve, * proven, and we have NSEC3 records, try to prove it using the NSEC3 * records. */ if(wc != NULL && !wc_NSEC_ok && nsec3s_seen) { - enum sec_status sec = nsec3_prove_wildcard(env, ve, + enum sec_status sec = nsec3_prove_wildcard(env, ve, chase_reply->rrsets+chase_reply->an_numrrsets, chase_reply->ns_numrrsets, qchase, kkey, wc); if(sec == sec_status_insecure) { @@ -1366,9 +1366,9 @@ validate_cname_response(struct module_env* env, struct val_env* ve, * Validate CNAME NOANSWER response, no more data after a CNAME chain. * This can be a NODATA or a NAME ERROR case, but not both at the same time. * We don't know because the rcode has been set to NOERROR by the CNAME. - * + * * The answer and authority rrsets must already be verified as secure. - * + * * @param env: module env for verify. * @param ve: validator env for verify. * @param qchase: query that was made. @@ -1382,13 +1382,13 @@ validate_cname_noanswer_response(struct module_env* env, struct val_env* ve, struct key_entry_key* kkey) { int nodata_valid_nsec = 0; /* If true, then NODATA has been proven.*/ - uint8_t* ce = NULL; /* for wildcard nodata responses. This is the + uint8_t* ce = NULL; /* for wildcard nodata responses. This is the proven closest encloser. */ uint8_t* wc = NULL; /* for wildcard nodata responses. wildcard nsec */ int nxdomain_valid_nsec = 0; /* if true, nameerror has been proven */ int nxdomain_valid_wnsec = 0; int nsec3s_seen = 0; /* nsec3s seen */ - struct ub_packed_rrset_key* s; + struct ub_packed_rrset_key* s; size_t i; uint8_t* nsec_ce; /* Used to find the NSEC with the longest ce */ int ce_labs = 0; @@ -1399,14 +1399,14 @@ validate_cname_noanswer_response(struct module_env* env, struct val_env* ve, chase_reply->ns_numrrsets; i++) { s = chase_reply->rrsets[i]; - /* If we encounter an NSEC record, try to use it to prove - * NODATA. This needs to handle the ENT NODATA case. + /* If we encounter an NSEC record, try to use it to prove + * NODATA. This needs to handle the ENT NODATA case. * Also try to prove NAMEERROR, and absence of a wildcard */ if(ntohs(s->rk.type) == LDNS_RR_TYPE_NSEC) { if(nsec_proves_nodata(s, qchase, &wc)) { nodata_valid_nsec = 1; /* set wc encloser if wildcard applicable */ - } + } if(val_nsec_proves_name_error(s, qchase->qname)) { ce = nsec_closest_encloser(qchase->qname, s); nxdomain_valid_nsec = 1; @@ -1436,8 +1436,8 @@ validate_cname_noanswer_response(struct module_env* env, struct val_env* ve, /* check to see if we have a wildcard NODATA proof. */ - /* The wildcard NODATA is 1 NSEC proving that qname does not exists - * (and also proving what the closest encloser is), and 1 NSEC + /* The wildcard NODATA is 1 NSEC proving that qname does not exists + * (and also proving what the closest encloser is), and 1 NSEC * showing the matching wildcard, which must be *.closest_encloser. */ if(wc && !ce) nodata_valid_nsec = 0; @@ -1450,7 +1450,7 @@ validate_cname_noanswer_response(struct module_env* env, struct val_env* ve, /* name error is missing wildcard denial proof */ nxdomain_valid_nsec = 0; } - + if(nodata_valid_nsec && nxdomain_valid_nsec) { verbose(VERB_QUERY, "CNAMEchain to noanswer proves that name " "exists and not exists, bogus"); @@ -1460,7 +1460,7 @@ validate_cname_noanswer_response(struct module_env* env, struct val_env* ve, } if(!nodata_valid_nsec && !nxdomain_valid_nsec && nsec3s_seen) { int nodata; - enum sec_status sec = nsec3_prove_nxornodata(env, ve, + enum sec_status sec = nsec3_prove_nxornodata(env, ve, chase_reply->rrsets+chase_reply->an_numrrsets, chase_reply->ns_numrrsets, qchase, kkey, &nodata); if(sec == sec_status_insecure) { @@ -1493,12 +1493,12 @@ validate_cname_noanswer_response(struct module_env* env, struct val_env* ve, chase_reply->security = sec_status_secure; } -/** +/** * Process init state for validator. * Process the INIT state. First tier responses start in the INIT state. * This is where they are vetted for validation suitability, and the initial * key search is done. - * + * * Currently, events the come through this routine will be either promoted * to FINISHED/CNAME_RESP (no validation needed), FINDKEY (next step to * validation), or will be (temporarily) retired and a new priming request @@ -1512,14 +1512,14 @@ validate_cname_noanswer_response(struct module_env* env, struct val_env* ve, * not. */ static int -processInit(struct module_qstate* qstate, struct val_qstate* vq, +processInit(struct module_qstate* qstate, struct val_qstate* vq, struct val_env* ve, int id) { uint8_t* lookup_name; size_t lookup_len; struct trust_anchor* anchor; enum val_classification subtype = val_classify_response( - qstate->query_flags, &qstate->qinfo, &vq->qchase, + qstate->query_flags, &qstate->qinfo, &vq->qchase, vq->orig_msg->rep, vq->rrset_skip); if(vq->restart_count > ve->max_restart) { verbose(VERB_ALGO, "restart count exceeded"); @@ -1529,9 +1529,9 @@ processInit(struct module_qstate* qstate, struct val_qstate* vq, /* correctly initialize reason_bogus */ update_reason_bogus(vq->chase_reply, LDNS_EDE_DNSSEC_BOGUS); - verbose(VERB_ALGO, "validator classification %s", + verbose(VERB_ALGO, "validator classification %s", val_classification_to_string(subtype)); - if(subtype == VAL_CLASS_REFERRAL && + if(subtype == VAL_CLASS_REFERRAL && vq->rrset_skip < vq->orig_msg->rep->rrset_count) { /* referral uses the rrset name as qchase, to find keys for * that rrset */ @@ -1549,7 +1549,7 @@ processInit(struct module_qstate* qstate, struct val_qstate* vq, /* for type DS look at the parent side for keys/trustanchor */ /* also for NSEC not at apex */ if(vq->qchase.qtype == LDNS_RR_TYPE_DS || - (vq->qchase.qtype == LDNS_RR_TYPE_NSEC && + (vq->qchase.qtype == LDNS_RR_TYPE_NSEC && vq->orig_msg->rep->rrset_count > vq->rrset_skip && ntohs(vq->orig_msg->rep->rrsets[vq->rrset_skip]->rk.type) == LDNS_RR_TYPE_NSEC && @@ -1558,16 +1558,16 @@ processInit(struct module_qstate* qstate, struct val_qstate* vq, dname_remove_label(&lookup_name, &lookup_len); } - val_mark_indeterminate(vq->chase_reply, qstate->env->anchors, + val_mark_indeterminate(vq->chase_reply, qstate->env->anchors, qstate->env->rrset_cache, qstate->env); vq->key_entry = NULL; vq->empty_DS_name = NULL; vq->ds_rrset = 0; - anchor = anchors_lookup(qstate->env->anchors, + anchor = anchors_lookup(qstate->env->anchors, lookup_name, lookup_len, vq->qchase.qclass); /* Determine the signer/lookup name */ - val_find_signer(subtype, &vq->qchase, vq->orig_msg->rep, + val_find_signer(subtype, &vq->qchase, vq->orig_msg->rep, vq->rrset_skip, &vq->signer_name, &vq->signer_len); if(vq->signer_name != NULL && !dname_subdomain_c(lookup_name, vq->signer_name)) { @@ -1588,7 +1588,7 @@ processInit(struct module_qstate* qstate, struct val_qstate* vq, if(subtype == VAL_CLASS_NAMEERROR && vq->signer_name && anchor && dname_strict_subdomain_c(anchor->name, lookup_name)){ lock_basic_unlock(&anchor->lock); - anchor = anchors_lookup(qstate->env->anchors, + anchor = anchors_lookup(qstate->env->anchors, lookup_name, lookup_len, vq->qchase.qclass); if(!anchor) { /* unsigned parent denies anchor*/ verbose(VERB_QUERY, "unsigned parent zone denies" @@ -1611,11 +1611,11 @@ processInit(struct module_qstate* qstate, struct val_qstate* vq, subtype == VAL_CLASS_REFERRAL) { /* extract this part of orig_msg into chase_reply for * the eventual VALIDATE stage */ - val_fill_reply(vq->chase_reply, vq->orig_msg->rep, - vq->rrset_skip, lookup_name, lookup_len, + val_fill_reply(vq->chase_reply, vq->orig_msg->rep, + vq->rrset_skip, lookup_name, lookup_len, vq->signer_name); if(verbosity >= VERB_ALGO) - log_dns_msg("chased extract", &vq->qchase, + log_dns_msg("chased extract", &vq->qchase, vq->chase_reply); } @@ -1638,7 +1638,7 @@ processInit(struct module_qstate* qstate, struct val_qstate* vq, /* trust anchor is an 'unsigned' trust anchor */ if(anchor && anchor->numDS == 0 && anchor->numDNSKEY == 0) { vq->chase_reply->security = sec_status_insecure; - val_mark_insecure(vq->chase_reply, anchor->name, + val_mark_insecure(vq->chase_reply, anchor->name, qstate->env->rrset_cache, qstate->env); lock_basic_unlock(&anchor->lock); /* go to finished state to cache this result */ @@ -1663,10 +1663,10 @@ processInit(struct module_qstate* qstate, struct val_qstate* vq, if(key_entry_isnull(vq->key_entry)) { /* response is under a null key, so we cannot validate - * However, we do set the status to INSECURE, since it is + * However, we do set the status to INSECURE, since it is * essentially proven insecure. */ vq->chase_reply->security = sec_status_insecure; - val_mark_insecure(vq->chase_reply, vq->key_entry->name, + val_mark_insecure(vq->chase_reply, vq->key_entry->name, qstate->env->rrset_cache, qstate->env); /* go to finished state to cache this result */ vq->state = VAL_FINISHED_STATE; @@ -1688,7 +1688,7 @@ processInit(struct module_qstate* qstate, struct val_qstate* vq, return 1; } - /* otherwise, we have our "closest" cached key -- continue + /* otherwise, we have our "closest" cached key -- continue * processing in the next state. */ vq->state = VAL_FINDKEY_STATE; return 1; @@ -1716,14 +1716,14 @@ processFindKey(struct module_qstate* qstate, struct val_qstate* vq, int id) log_query_info(VERB_ALGO, "validator: FindKey", &vq->qchase); /* We know that state.key_entry is not 0 or bad key -- if it were, - * then previous processing should have directed this event to - * a different state. + * then previous processing should have directed this event to + * a different state. * It could be an isnull key, which signals the DNSKEY failed * with retry and has to be looked up again. */ log_assert(vq->key_entry && !key_entry_isbad(vq->key_entry)); if(key_entry_isnull(vq->key_entry)) { - if(!generate_request(qstate, id, vq->ds_rrset->rk.dname, - vq->ds_rrset->rk.dname_len, LDNS_RR_TYPE_DNSKEY, + if(!generate_request(qstate, id, vq->ds_rrset->rk.dname, + vq->ds_rrset->rk.dname_len, LDNS_RR_TYPE_DNSKEY, vq->qchase.qclass, BIT_CD, &newq, 0)) { verbose(VERB_ALGO, "error generating DNSKEY request"); return val_error(qstate, id); @@ -1750,7 +1750,7 @@ processFindKey(struct module_qstate* qstate, struct val_qstate* vq, int id) /* if the last empty nonterminal/emptyDS name we detected is * below the current key, use that name to make progress * along the chain of trust */ - if(query_dname_compare(target_key_name, + if(query_dname_compare(target_key_name, vq->empty_DS_name) == 0) { /* do not query for empty_DS_name again */ verbose(VERB_ALGO, "Cannot retrieve DS for signature"); @@ -1776,18 +1776,18 @@ processFindKey(struct module_qstate* qstate, struct val_qstate* vq, int id) return 1; } /* so this value is >= -1 */ - strip_lab = dname_count_labels(target_key_name) - + strip_lab = dname_count_labels(target_key_name) - dname_count_labels(current_key_name) - 1; log_assert(strip_lab >= -1); verbose(VERB_ALGO, "striplab %d", strip_lab); if(strip_lab > 0) { - dname_remove_labels(&target_key_name, &target_key_len, + dname_remove_labels(&target_key_name, &target_key_len, strip_lab); } log_nametypeclass(VERB_ALGO, "next keyname", target_key_name, LDNS_RR_TYPE_DNSKEY, LDNS_RR_CLASS_IN); - /* The next step is either to query for the next DS, or to query + /* The next step is either to query for the next DS, or to query * for the next DNSKEY. */ if(vq->ds_rrset) log_nametypeclass(VERB_ALGO, "DS RRset", vq->ds_rrset->rk.dname, LDNS_RR_TYPE_DS, LDNS_RR_CLASS_IN); @@ -1795,8 +1795,8 @@ processFindKey(struct module_qstate* qstate, struct val_qstate* vq, int id) if(vq->ds_rrset && query_dname_compare(vq->ds_rrset->rk.dname, vq->key_entry->name) != 0) { - if(!generate_request(qstate, id, vq->ds_rrset->rk.dname, - vq->ds_rrset->rk.dname_len, LDNS_RR_TYPE_DNSKEY, + if(!generate_request(qstate, id, vq->ds_rrset->rk.dname, + vq->ds_rrset->rk.dname_len, LDNS_RR_TYPE_DNSKEY, vq->qchase.qclass, BIT_CD, &newq, 0)) { verbose(VERB_ALGO, "error generating DNSKEY request"); return val_error(qstate, id); @@ -1811,12 +1811,12 @@ processFindKey(struct module_qstate* qstate, struct val_qstate* vq, int id) * thus can disprove the secure delegation we seek. * We can then use that NSEC even in the absence of a SOA * record that would be required by the iterator to supply - * a completely protocol-correct response. + * a completely protocol-correct response. * Uses negative cache for NSEC3 lookup of DS responses. */ /* only if cache not blacklisted, of course */ struct dns_msg* msg; if(!qstate->blacklist && !vq->chain_blacklist && - (msg=val_find_DS(qstate->env, target_key_name, + (msg=val_find_DS(qstate->env, target_key_name, target_key_len, vq->qchase.qclass, qstate->region, vq->key_entry->name)) ) { verbose(VERB_ALGO, "Process cached DS response"); @@ -1824,7 +1824,7 @@ processFindKey(struct module_qstate* qstate, struct val_qstate* vq, int id) msg, &msg->qinfo, NULL); return 1; /* continue processing ds-response results */ } - if(!generate_request(qstate, id, target_key_name, + if(!generate_request(qstate, id, target_key_name, target_key_len, LDNS_RR_TYPE_DS, vq->qchase.qclass, BIT_CD, &newq, 0)) { verbose(VERB_ALGO, "error generating DS request"); @@ -1834,8 +1834,8 @@ processFindKey(struct module_qstate* qstate, struct val_qstate* vq, int id) } /* Otherwise, it is time to query for the DNSKEY */ - if(!generate_request(qstate, id, vq->ds_rrset->rk.dname, - vq->ds_rrset->rk.dname_len, LDNS_RR_TYPE_DNSKEY, + if(!generate_request(qstate, id, vq->ds_rrset->rk.dname, + vq->ds_rrset->rk.dname_len, LDNS_RR_TYPE_DNSKEY, vq->qchase.qclass, BIT_CD, &newq, 0)) { verbose(VERB_ALGO, "error generating DNSKEY request"); return val_error(qstate, id); @@ -1860,7 +1860,7 @@ processFindKey(struct module_qstate* qstate, struct val_qstate* vq, int id) * not. */ static int -processValidate(struct module_qstate* qstate, struct val_qstate* vq, +processValidate(struct module_qstate* qstate, struct val_qstate* vq, struct val_env* ve, int id) { enum val_classification subtype; @@ -1879,7 +1879,7 @@ processValidate(struct module_qstate* qstate, struct val_qstate* vq, verbose(VERB_DETAIL, "Verified that %sresponse is INSECURE", vq->signer_name?"":"unsigned "); vq->chase_reply->security = sec_status_insecure; - val_mark_insecure(vq->chase_reply, vq->key_entry->name, + val_mark_insecure(vq->chase_reply, vq->key_entry->name, qstate->env->rrset_cache, qstate->env); key_cache_insert(ve->kcache, vq->key_entry, qstate->env->cfg->val_log_level >= 2); @@ -1901,7 +1901,7 @@ processValidate(struct module_qstate* qstate, struct val_qstate* vq, return 1; } - /* signerName being null is the indicator that this response was + /* signerName being null is the indicator that this response was * unsigned */ if(vq->signer_name == NULL) { log_query_info(VERB_ALGO, "processValidate: state has no " @@ -1919,9 +1919,9 @@ processValidate(struct module_qstate* qstate, struct val_qstate* vq, if(subtype != VAL_CLASS_REFERRAL) remove_spurious_authority(vq->chase_reply, vq->orig_msg->rep); - /* check signatures in the message; + /* check signatures in the message; * answer and authority must be valid, additional is only checked. */ - if(!validate_msg_signatures(qstate, qstate->env, ve, &vq->qchase, + if(!validate_msg_signatures(qstate, qstate->env, ve, &vq->qchase, vq->chase_reply, vq->key_entry)) { /* workaround bad recursor out there that truncates (even * with EDNS4k) to 512 by removing RRSIG from auth section @@ -1932,11 +1932,11 @@ processValidate(struct module_qstate* qstate, struct val_qstate* vq, /* truncate the message some more */ vq->orig_msg->rep->ns_numrrsets = 0; vq->orig_msg->rep->ar_numrrsets = 0; - vq->orig_msg->rep->rrset_count = + vq->orig_msg->rep->rrset_count = vq->orig_msg->rep->an_numrrsets; vq->chase_reply->ns_numrrsets = 0; vq->chase_reply->ar_numrrsets = 0; - vq->chase_reply->rrset_count = + vq->chase_reply->rrset_count = vq->chase_reply->an_numrrsets; qstate->errinf = NULL; } @@ -1969,7 +1969,7 @@ processValidate(struct module_qstate* qstate, struct val_qstate* vq, case VAL_CLASS_NAMEERROR: rcode = (int)FLAGS_GET_RCODE(vq->orig_msg->rep->flags); verbose(VERB_ALGO, "Validating a nxdomain response"); - validate_nameerror_response(qstate->env, ve, + validate_nameerror_response(qstate->env, ve, &vq->qchase, vq->chase_reply, vq->key_entry, &rcode); verbose(VERB_DETAIL, "validate(nxdomain): %s", sec_status_to_string( @@ -2008,7 +2008,7 @@ processValidate(struct module_qstate* qstate, struct val_qstate* vq, case VAL_CLASS_ANY: verbose(VERB_ALGO, "Validating a positive ANY " "response"); - validate_any_response(qstate->env, ve, &vq->qchase, + validate_any_response(qstate->env, ve, &vq->qchase, vq->chase_reply, vq->key_entry); verbose(VERB_DETAIL, "validate(positive_any): %s", sec_status_to_string( @@ -2041,11 +2041,11 @@ processValidate(struct module_qstate* qstate, struct val_qstate* vq, * not. */ static int -processFinished(struct module_qstate* qstate, struct val_qstate* vq, +processFinished(struct module_qstate* qstate, struct val_qstate* vq, struct val_env* ve, int id) { enum val_classification subtype = val_classify_response( - qstate->query_flags, &qstate->qinfo, &vq->qchase, + qstate->query_flags, &qstate->qinfo, &vq->qchase, vq->orig_msg->rep, vq->rrset_skip); /* store overall validation result in orig_msg */ @@ -2053,13 +2053,13 @@ processFinished(struct module_qstate* qstate, struct val_qstate* vq, vq->orig_msg->rep->security = vq->chase_reply->security; update_reason_bogus(vq->orig_msg->rep, vq->chase_reply->reason_bogus); } else if(subtype != VAL_CLASS_REFERRAL || - vq->rrset_skip < vq->orig_msg->rep->an_numrrsets + + vq->rrset_skip < vq->orig_msg->rep->an_numrrsets + vq->orig_msg->rep->ns_numrrsets) { - /* ignore sec status of additional section if a referral + /* ignore sec status of additional section if a referral * type message skips there and * use the lowest security status as end result. */ if(vq->chase_reply->security < vq->orig_msg->rep->security) { - vq->orig_msg->rep->security = + vq->orig_msg->rep->security = vq->chase_reply->security; update_reason_bogus(vq->orig_msg->rep, vq->chase_reply->reason_bogus); } @@ -2067,7 +2067,7 @@ processFinished(struct module_qstate* qstate, struct val_qstate* vq, if(subtype == VAL_CLASS_REFERRAL) { /* for a referral, move to next unchecked rrset and check it*/ - vq->rrset_skip = val_next_unchecked(vq->orig_msg->rep, + vq->rrset_skip = val_next_unchecked(vq->orig_msg->rep, vq->rrset_skip); if(vq->rrset_skip < vq->orig_msg->rep->rrset_count) { /* and restart for this rrset */ @@ -2081,7 +2081,7 @@ processFinished(struct module_qstate* qstate, struct val_qstate* vq, if(vq->chase_reply->security != sec_status_bogus && subtype == VAL_CLASS_CNAME) { /* chase the CNAME; process next part of the message */ - if(!val_chase_cname(&vq->qchase, vq->orig_msg->rep, + if(!val_chase_cname(&vq->qchase, vq->orig_msg->rep, &vq->rrset_skip)) { verbose(VERB_ALGO, "validator: failed to chase CNAME"); vq->orig_msg->rep->security = sec_status_bogus; @@ -2104,7 +2104,7 @@ processFinished(struct module_qstate* qstate, struct val_qstate* vq, /* this may cause the msg to be marked bogus */ val_check_nonsecure(qstate->env, vq->orig_msg->rep); if(vq->orig_msg->rep->security == sec_status_secure) { - log_query_info(VERB_DETAIL, "validation success", + log_query_info(VERB_DETAIL, "validation success", &qstate->qinfo); if(!qstate->no_cache_store) { val_neg_addreply(qstate->env->neg_cache, @@ -2121,7 +2121,7 @@ processFinished(struct module_qstate* qstate, struct val_qstate* vq, int restart_count = vq->restart_count+1; verbose(VERB_ALGO, "validation failed, " "blacklist and retry to fetch data"); - val_blacklist(&qstate->blacklist, qstate->region, + val_blacklist(&qstate->blacklist, qstate->region, qstate->reply_origin, 0); qstate->reply_origin = NULL; qstate->errinf = NULL; @@ -2134,9 +2134,9 @@ processFinished(struct module_qstate* qstate, struct val_qstate* vq, } vq->orig_msg->rep->ttl = ve->bogus_ttl; - vq->orig_msg->rep->prefetch_ttl = + vq->orig_msg->rep->prefetch_ttl = PREFETCH_TTL_CALC(vq->orig_msg->rep->ttl); - vq->orig_msg->rep->serve_expired_ttl = + vq->orig_msg->rep->serve_expired_ttl = vq->orig_msg->rep->ttl + qstate->env->cfg->serve_expired_ttl; if((qstate->env->cfg->val_log_level >= 1 || qstate->env->cfg->log_servfail) && @@ -2229,7 +2229,7 @@ processFinished(struct module_qstate* qstate, struct val_qstate* vq, return 0; } -/** +/** * Handle validator state. * If a method returns true, the next state is started. If false, then * processing will stop. @@ -2239,7 +2239,7 @@ processFinished(struct module_qstate* qstate, struct val_qstate* vq, * @param id: module id. */ static void -val_handle(struct module_qstate* qstate, struct val_qstate* vq, +val_handle(struct module_qstate* qstate, struct val_qstate* vq, struct val_env* ve, int id) { int cont = 1; @@ -2250,13 +2250,13 @@ val_handle(struct module_qstate* qstate, struct val_qstate* vq, case VAL_INIT_STATE: cont = processInit(qstate, vq, ve, id); break; - case VAL_FINDKEY_STATE: + case VAL_FINDKEY_STATE: cont = processFindKey(qstate, vq, id); break; - case VAL_VALIDATE_STATE: + case VAL_VALIDATE_STATE: cont = processValidate(qstate, vq, ve, id); break; - case VAL_FINISHED_STATE: + case VAL_FINISHED_STATE: cont = processFinished(qstate, vq, ve, id); break; default: @@ -2275,15 +2275,15 @@ val_operate(struct module_qstate* qstate, enum module_ev event, int id, struct val_env* ve = (struct val_env*)qstate->env->modinfo[id]; struct val_qstate* vq = (struct val_qstate*)qstate->minfo[id]; verbose(VERB_QUERY, "validator[module %d] operate: extstate:%s " - "event:%s", id, strextstate(qstate->ext_state[id]), + "event:%s", id, strextstate(qstate->ext_state[id]), strmodulevent(event)); log_query_info(VERB_QUERY, "validator operate: query", &qstate->qinfo); - if(vq && qstate->qinfo.qname != vq->qchase.qname) + if(vq && qstate->qinfo.qname != vq->qchase.qname) log_query_info(VERB_QUERY, "validator operate: chased to", &vq->qchase); (void)outbound; - if(event == module_event_new || + if(event == module_event_new || (event == module_event_pass && vq == NULL)) { /* pass request to next module, to get it */ @@ -2295,7 +2295,7 @@ val_operate(struct module_qstate* qstate, enum module_ev event, int id, /* check if validation is needed */ verbose(VERB_ALGO, "validator: nextmodule returned"); - if(!needs_validation(qstate, qstate->return_rcode, + if(!needs_validation(qstate, qstate->return_rcode, qstate->return_msg)) { /* no need to validate this */ if(qstate->return_msg) @@ -2308,7 +2308,7 @@ val_operate(struct module_qstate* qstate, enum module_ev event, int id, qstate->ext_state[id] = module_finished; return; } - /* qclass ANY should have validation result from spawned + /* qclass ANY should have validation result from spawned * queries. If we get here, it is bogus or an internal error */ if(qstate->qinfo.qclass == LDNS_RR_CLASS_ANY) { verbose(VERB_ALGO, "cannot validate classANY: bogus"); @@ -2364,7 +2364,7 @@ val_operate(struct module_qstate* qstate, enum module_ev event, int id, * Bad key (validation failed). */ static struct key_entry_key* -primeResponseToKE(struct ub_packed_rrset_key* dnskey_rrset, +primeResponseToKE(struct ub_packed_rrset_key* dnskey_rrset, struct trust_anchor* ta, struct module_qstate* qstate, int id) { struct val_env* ve = (struct val_env*)qstate->env->modinfo[id]; @@ -2376,7 +2376,7 @@ primeResponseToKE(struct ub_packed_rrset_key* dnskey_rrset, if(!dnskey_rrset) { log_nametypeclass(VERB_OPS, "failed to prime trust anchor -- " - "could not fetch DNSKEY rrset", + "could not fetch DNSKEY rrset", ta->name, LDNS_RR_TYPE_DNSKEY, ta->dclass); reason_bogus = LDNS_EDE_DNSKEY_MISSING; reason = "no DNSKEY rrset"; @@ -2397,7 +2397,7 @@ primeResponseToKE(struct ub_packed_rrset_key* dnskey_rrset, return kkey; } /* attempt to verify with trust anchor DS and DNSKEY */ - kkey = val_verify_new_DNSKEYs_with_ta(qstate->region, qstate->env, ve, + kkey = val_verify_new_DNSKEYs_with_ta(qstate->region, qstate->env, ve, dnskey_rrset, ta->ds_rrset, ta->dnskey_rrset, downprot, &reason, &reason_bogus, qstate); if(!kkey) { @@ -2408,14 +2408,14 @@ primeResponseToKE(struct ub_packed_rrset_key* dnskey_rrset, sec = sec_status_secure; else sec = sec_status_bogus; - verbose(VERB_DETAIL, "validate keys with anchor(DS): %s", + verbose(VERB_DETAIL, "validate keys with anchor(DS): %s", sec_status_to_string(sec)); if(sec != sec_status_secure) { log_nametypeclass(VERB_OPS, "failed to prime trust anchor -- " - "DNSKEY rrset is not secure", + "DNSKEY rrset is not secure", ta->name, LDNS_RR_TYPE_DNSKEY, ta->dclass); - /* NOTE: in this case, we should probably reject the trust + /* NOTE: in this case, we should probably reject the trust * anchor for longer, perhaps forever. */ if(qstate->env->cfg->harden_dnssec_stripped) { errinf_ede(qstate, reason, reason_bogus); @@ -2434,7 +2434,7 @@ primeResponseToKE(struct ub_packed_rrset_key* dnskey_rrset, return kkey; } - log_nametypeclass(VERB_DETAIL, "Successfully primed trust anchor", + log_nametypeclass(VERB_DETAIL, "Successfully primed trust anchor", ta->name, LDNS_RR_TYPE_DNSKEY, ta->dclass); return kkey; } @@ -2483,7 +2483,7 @@ ds_response_to_ke(struct module_qstate* qstate, struct val_qstate* vq, struct ub_packed_rrset_key* ds; enum sec_status sec; ds = reply_find_answer_rrset(qinfo, msg->rep); - /* If there was no DS rrset, then we have mis-classified + /* If there was no DS rrset, then we have mis-classified * this message. */ if(!ds) { log_warn("internal error: POSITIVE DS response was " @@ -2492,7 +2492,7 @@ ds_response_to_ke(struct module_qstate* qstate, struct val_qstate* vq, errinf_ede(qstate, reason, reason_bogus); goto return_bogus; } - /* Verify only returns BOGUS or SECURE. If the rrset is + /* Verify only returns BOGUS or SECURE. If the rrset is * bogus, then we are done. */ sec = val_verify_rrset_entry(qstate->env, ve, ds, vq->key_entry, &reason, &reason_bogus, LDNS_SECTION_ANSWER, qstate); @@ -2503,10 +2503,10 @@ ds_response_to_ke(struct module_qstate* qstate, struct val_qstate* vq, goto return_bogus; } - /* If the DS rrset validates, we still have to make sure + /* If the DS rrset validates, we still have to make sure * that they are usable. */ if(!val_dsset_isusable(ds)) { - /* If they aren't usable, then we treat it like + /* If they aren't usable, then we treat it like * there was no DS. */ *ke = key_entry_create_null(qstate->region, qinfo->qname, qinfo->qname_len, qinfo->qclass, @@ -2522,9 +2522,9 @@ ds_response_to_ke(struct module_qstate* qstate, struct val_qstate* vq, qinfo->qname, qinfo->qname_len, qinfo->qclass, ds, NULL, LDNS_EDE_NONE, NULL, *qstate->env->now); return (*ke) != NULL; - } else if(subtype == VAL_CLASS_NODATA || + } else if(subtype == VAL_CLASS_NODATA || subtype == VAL_CLASS_NAMEERROR) { - /* NODATA means that the qname exists, but that there was + /* NODATA means that the qname exists, but that there was * no DS. This is a pretty normal case. */ time_t proof_ttl = 0; enum sec_status sec; @@ -2544,14 +2544,14 @@ ds_response_to_ke(struct module_qstate* qstate, struct val_qstate* vq, /* Try to prove absence of the DS with NSEC */ sec = val_nsec_prove_nodata_dsreply( - qstate->env, ve, qinfo, msg->rep, vq->key_entry, + qstate->env, ve, qinfo, msg->rep, vq->key_entry, &proof_ttl, &reason, &reason_bogus, qstate); switch(sec) { case sec_status_secure: verbose(VERB_DETAIL, "NSEC RRset for the " "referral proved no DS."); - *ke = key_entry_create_null(qstate->region, - qinfo->qname, qinfo->qname_len, + *ke = key_entry_create_null(qstate->region, + qinfo->qname, qinfo->qname_len, qinfo->qclass, proof_ttl, LDNS_EDE_NONE, NULL, *qstate->env->now); @@ -2572,7 +2572,7 @@ ds_response_to_ke(struct module_qstate* qstate, struct val_qstate* vq, break; } - sec = nsec3_prove_nods(qstate->env, ve, + sec = nsec3_prove_nods(qstate->env, ve, msg->rep->rrsets + msg->rep->an_numrrsets, msg->rep->ns_numrrsets, qinfo, vq->key_entry, &reason, &reason_bogus, qstate); @@ -2584,8 +2584,8 @@ ds_response_to_ke(struct module_qstate* qstate, struct val_qstate* vq, case sec_status_secure: verbose(VERB_DETAIL, "NSEC3s for the " "referral proved no DS."); - *ke = key_entry_create_null(qstate->region, - qinfo->qname, qinfo->qname_len, + *ke = key_entry_create_null(qstate->region, + qinfo->qname, qinfo->qname_len, qinfo->qclass, proof_ttl, LDNS_EDE_NONE, NULL, *qstate->env->now); @@ -2606,14 +2606,14 @@ ds_response_to_ke(struct module_qstate* qstate, struct val_qstate* vq, break; } - /* Apparently, no available NSEC/NSEC3 proved NODATA, so + /* Apparently, no available NSEC/NSEC3 proved NODATA, so * this is BOGUS. */ verbose(VERB_DETAIL, "DS %s ran out of options, so return " "bogus", val_classification_to_string(subtype)); reason = "no DS but also no proof of that"; errinf_ede(qstate, reason, reason_bogus); goto return_bogus; - } else if(subtype == VAL_CLASS_CNAME || + } else if(subtype == VAL_CLASS_CNAME || subtype == VAL_CLASS_CNAMENOANSWER) { /* if the CNAME matches the exact name we want and is signed * properly, then also, we are sure that no DS exists there, @@ -2727,7 +2727,7 @@ process_ds_response(struct module_qstate* qstate, struct val_qstate* vq, } vq->chain_blacklist = NULL; /* fresh blacklist for next part*/ /* Keep the forState.state on FINDKEY. */ - } else if(key_entry_isbad(dske) + } else if(key_entry_isbad(dske) && vq->restart_count < ve->max_restart) { vq->empty_DS_name = olds; val_blacklist(&vq->chain_blacklist, qstate->region, origin, 1); @@ -2738,8 +2738,8 @@ process_ds_response(struct module_qstate* qstate, struct val_qstate* vq, errinf_origin(qstate, origin); errinf_dname(qstate, "for DS", qinfo->qname); } - /* NOTE: the reason for the DS to be not good (that is, - * either bad or null) should have been logged by + /* NOTE: the reason for the DS to be not good (that is, + * either bad or null) should have been logged by * dsResponseToKE. */ vq->key_entry = dske; /* The FINDKEY phase has ended, so move on. */ @@ -2826,7 +2826,7 @@ process_dnskey_response(struct module_qstate* qstate, struct val_qstate* vq, if(!key_entry_isgood(vq->key_entry)) { if(key_entry_isbad(vq->key_entry)) { if(vq->restart_count < ve->max_restart) { - val_blacklist(&vq->chain_blacklist, + val_blacklist(&vq->chain_blacklist, qstate->region, origin, 1); qstate->errinf = NULL; vq->restart_count++; @@ -2871,7 +2871,7 @@ process_prime_response(struct module_qstate* qstate, struct val_qstate* vq, { struct val_env* ve = (struct val_env*)qstate->env->modinfo[id]; struct ub_packed_rrset_key* dnskey_rrset = NULL; - struct trust_anchor* ta = anchor_find(qstate->env->anchors, + struct trust_anchor* ta = anchor_find(qstate->env->anchors, vq->trust_anchor_name, vq->trust_anchor_labs, vq->trust_anchor_len, vq->qchase.qclass); if(!ta) { @@ -2882,7 +2882,7 @@ process_prime_response(struct module_qstate* qstate, struct val_qstate* vq, vq->trust_anchor_name = NULL; return; } - /* Fetch and validate the keyEntry that corresponds to the + /* Fetch and validate the keyEntry that corresponds to the * current trust anchor. */ if(rcode == LDNS_RCODE_NOERROR) { dnskey_rrset = reply_find_rrset_section_an(msg->rep, @@ -2902,16 +2902,16 @@ process_prime_response(struct module_qstate* qstate, struct val_qstate* vq, vq->key_entry = primeResponseToKE(dnskey_rrset, ta, qstate, id); lock_basic_unlock(&ta->lock); if(vq->key_entry) { - if(key_entry_isbad(vq->key_entry) + if(key_entry_isbad(vq->key_entry) && vq->restart_count < ve->max_restart) { - val_blacklist(&vq->chain_blacklist, qstate->region, + val_blacklist(&vq->chain_blacklist, qstate->region, origin, 1); qstate->errinf = NULL; vq->restart_count++; vq->key_entry = NULL; vq->state = VAL_INIT_STATE; return; - } + } vq->chain_blacklist = NULL; errinf_origin(qstate, origin); errinf_dname(qstate, "for trust anchor", ta->name); @@ -2928,9 +2928,9 @@ process_prime_response(struct module_qstate* qstate, struct val_qstate* vq, /* the qstate will be reactivated after inform_super is done */ } -/* +/* * inform validator super. - * + * * @param qstate: query state that finished. * @param id: module id. * @param super: the qstate to inform. @@ -2955,7 +2955,7 @@ val_inform_super(struct module_qstate* qstate, int id, } if(qstate->qinfo.qtype == LDNS_RR_TYPE_DS) { process_ds_response(super, vq, id, qstate->return_rcode, - qstate->return_msg, &qstate->qinfo, + qstate->return_msg, &qstate->qinfo, qstate->reply_origin); return; } else if(qstate->qinfo.qtype == LDNS_RR_TYPE_DNSKEY) { @@ -2976,19 +2976,19 @@ val_clear(struct module_qstate* qstate, int id) qstate->minfo[id] = NULL; } -size_t +size_t val_get_mem(struct module_env* env, int id) { struct val_env* ve = (struct val_env*)env->modinfo[id]; if(!ve) return 0; - return sizeof(*ve) + key_cache_get_mem(ve->kcache) + + return sizeof(*ve) + key_cache_get_mem(ve->kcache) + val_neg_get_mem(ve->neg_cache) + sizeof(size_t)*2*ve->nsec3_keyiter_count; } /** - * The validator function block + * The validator function block */ static struct module_func_block val_block = { "validator", @@ -2996,13 +2996,13 @@ static struct module_func_block val_block = { &val_get_mem }; -struct module_func_block* +struct module_func_block* val_get_funcblock(void) { return &val_block; } -const char* +const char* val_state_to_string(enum val_state state) { switch(state) { diff --git a/sbin/unwind/libunbound/validator/validator.h b/sbin/unwind/libunbound/validator/validator.h index 694e4c895..b620c1e98 100644 --- a/sbin/unwind/libunbound/validator/validator.h +++ b/sbin/unwind/libunbound/validator/validator.h @@ -4,22 +4,22 @@ * Copyright (c) 2007, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -72,7 +72,7 @@ struct config_strlist; #define SENTINEL_KEYTAG_LEN 5 /** - * Global state for the validator. + * Global state for the validator. */ struct val_env { /** key cache; these are validated keys. trusted keys only @@ -96,7 +96,7 @@ struct val_env { int max_restart; /** TTL for bogus data; used instead of untrusted TTL from data. - * Bogus data will not be verified more often than this interval. + * Bogus data will not be verified more often than this interval. * seconds. */ uint32_t bogus_ttl; @@ -143,7 +143,7 @@ enum val_state { * Per query state for the validator module. */ struct val_qstate { - /** + /** * State of the validator module. */ enum val_state state; @@ -169,14 +169,14 @@ struct val_qstate { * The chased reply, extract from original message. Can be: * o CNAME * o DNAME + CNAME - * o answer + * o answer * plus authority, additional (nsecs) that have same signature. */ struct reply_info* chase_reply; /** * The cname skip value; the number of rrsets that have been skipped - * due to chasing cnames. This is the offset into the + * due to chasing cnames. This is the offset into the * orig_msg->rep->rrsets array, into the answer section. * starts at 0 - for the full original message. * if it is >0 - qchase followed the cname, chase_reply setup to be @@ -240,9 +240,9 @@ void val_deinit(struct module_env* env, int id); void val_operate(struct module_qstate* qstate, enum module_ev event, int id, struct outbound_entry* outbound); -/** +/** * inform validator super. - * + * * @param qstate: query state that finished. * @param id: module id. * @param super: the qstate to inform. @@ -254,9 +254,9 @@ void val_inform_super(struct module_qstate* qstate, int id, void val_clear(struct module_qstate* qstate, int id); /** - * Debug helper routine that assists worker in determining memory in + * Debug helper routine that assists worker in determining memory in * use. - * @param env: module environment + * @param env: module environment * @param id: module id. * @return memory in use in bytes. */ diff --git a/sys/arch/arm64/dev/apldc.c b/sys/arch/arm64/dev/apldc.c index 8f755e8be..99d29ddb6 100644 --- a/sys/arch/arm64/dev/apldc.c +++ b/sys/arch/arm64/dev/apldc.c @@ -1067,7 +1067,7 @@ apldchidev_get_dimensions(struct apldchidev_softc *sc) sc->sc_y_max = dim.y_max; sc->sc_h_res = (100 * (dim.x_max - dim.x_min)) / dim.width; sc->sc_v_res = (100 * (dim.y_max - dim.y_min)) / dim.height; - } + } } void diff --git a/sys/dev/fdt/sncodec.c b/sys/dev/fdt/sncodec.c index 7f7efe09f..148c7d8fb 100644 --- a/sys/dev/fdt/sncodec.c +++ b/sys/dev/fdt/sncodec.c @@ -149,7 +149,7 @@ sncodec_attach(struct device *parent, struct device *self, void *aux) free(sdz_gpio, M_TEMP, sdz_gpiolen); delay(1000); } - + /* Set volume to a reasonable level. */ sc->sc_dvc = DVC_LVL_30DB; sc->sc_mute = MODE_CTRL_MODE_ACTIVE; diff --git a/sys/dev/ic/qwx.c b/sys/dev/ic/qwx.c index e9c4dbf2d..2cc510274 100644 --- a/sys/dev/ic/qwx.c +++ b/sys/dev/ic/qwx.c @@ -5057,7 +5057,7 @@ qwx_qmi_decode_datalen(struct qwx_softc *sc, size_t *used, uint32_t *datalen, printf("%s: bad datalen element size %u\n", sc->sc_dev.dv_xname, ei->elem_size); return -1; - + } *used = ei->elem_size; @@ -6610,7 +6610,7 @@ qwx_qmi_send_request(struct qwx_softc *sc, uint16_t msg_id, size_t msg_len, hdr.src_port_id = htole32(0x4000); /* TODO make human-readable */ hdr.dst_node_id = htole32(0x07); /* TODO make human-readable */ hdr.dst_port_id = htole32(0x01); /* TODO make human-readable */ - hdr.size = htole32(encoded_len); + hdr.size = htole32(encoded_len); err = m_copyback(m, 0, sizeof(hdr), &hdr, M_NOWAIT); if (err) @@ -6679,7 +6679,7 @@ qwx_qmi_fw_ind_register_send(struct qwx_softc *sc) return -1; } - sc->qmi_resp.result = QMI_RESULT_FAILURE_V01; + sc->qmi_resp.result = QMI_RESULT_FAILURE_V01; while (sc->qmi_resp.result != QMI_RESULT_SUCCESS_V01) { ret = tsleep_nsec(&sc->qmi_resp, 0, "qwxfwind", SEC_TO_NSEC(1)); @@ -6753,7 +6753,7 @@ qwx_qmi_host_cap_send(struct qwx_softc *sc) return -1; } - sc->qmi_resp.result = QMI_RESULT_FAILURE_V01; + sc->qmi_resp.result = QMI_RESULT_FAILURE_V01; while (sc->qmi_resp.result != QMI_RESULT_SUCCESS_V01) { ret = tsleep_nsec(&sc->qmi_resp, 0, "qwxfwhcap", SEC_TO_NSEC(1)); @@ -6823,7 +6823,7 @@ qwx_qmi_mem_seg_send(struct qwx_softc *sc) sc->sc_dev.dv_xname); mem_seg_len = 0; } else if (sc->fwmem == NULL || QWX_DMA_LEN(sc->fwmem) < total_size) { - if (sc->fwmem != NULL) + if (sc->fwmem != NULL) qwx_dmamem_free(sc->sc_dmat, sc->fwmem); sc->fwmem = qwx_dmamem_alloc(sc->sc_dmat, total_size, 65536); if (sc->fwmem == NULL) { @@ -6874,7 +6874,7 @@ qwx_qmi_mem_seg_send(struct qwx_softc *sc) sc->qmi_resp.result = QMI_RESULT_SUCCESS_V01; } else { expected_result = QMI_RESULT_SUCCESS_V01; - sc->qmi_resp.result = QMI_RESULT_FAILURE_V01; + sc->qmi_resp.result = QMI_RESULT_FAILURE_V01; } while (sc->qmi_resp.result != expected_result) { ret = tsleep_nsec(&sc->qmi_resp, 0, "qwxfwrespmem", @@ -6936,7 +6936,7 @@ qwx_qmi_request_target_cap(struct qwx_softc *sc) goto out; } - sc->qmi_resp.result = QMI_RESULT_FAILURE_V01; + sc->qmi_resp.result = QMI_RESULT_FAILURE_V01; while (sc->qmi_resp.result != QMI_RESULT_SUCCESS_V01) { ret = tsleep_nsec(&sc->qmi_resp, 0, "qwxfwcap", SEC_TO_NSEC(1)); @@ -7365,7 +7365,7 @@ qwx_qmi_load_file_target_mem(struct qwx_softc *sc, const u_char *data, goto err_iounmap; } - sc->qmi_resp.result = QMI_RESULT_FAILURE_V01; + sc->qmi_resp.result = QMI_RESULT_FAILURE_V01; while (sc->qmi_resp.result != QMI_RESULT_SUCCESS_V01) { ret = tsleep_nsec(&sc->qmi_resp, 0, "qwxbdf", SEC_TO_NSEC(1)); @@ -7602,7 +7602,7 @@ qwx_qmi_wlanfw_m3_info_send(struct qwx_softc *sc) return ret; } - sc->qmi_resp.result = QMI_RESULT_FAILURE_V01; + sc->qmi_resp.result = QMI_RESULT_FAILURE_V01; while (sc->qmi_resp.result != QMI_RESULT_SUCCESS_V01) { ret = tsleep_nsec(&sc->qmi_resp, 0, "qwxfwm3", SEC_TO_NSEC(1)); @@ -8449,7 +8449,7 @@ qwx_dp_shadow_timer_handler(void *arg) #endif s = splnet(); - /* + /* * Update HP if there were no TX operations during the timeout interval, * and stop the timer. Timer will be restarted if more TX happens. */ @@ -8928,7 +8928,7 @@ qwx_qmi_wlanfw_wlan_ini_send(struct qwx_softc *sc, int enable) return ret; } - sc->qmi_resp.result = QMI_RESULT_FAILURE_V01; + sc->qmi_resp.result = QMI_RESULT_FAILURE_V01; while (sc->qmi_resp.result != QMI_RESULT_SUCCESS_V01) { ret = tsleep_nsec(&sc->qmi_resp, 0, "qwxini", SEC_TO_NSEC(1)); @@ -9004,7 +9004,7 @@ qwx_qmi_wlanfw_wlan_cfg_send(struct qwx_softc *sc) goto out; } - sc->qmi_resp.result = QMI_RESULT_FAILURE_V01; + sc->qmi_resp.result = QMI_RESULT_FAILURE_V01; while (sc->qmi_resp.result != QMI_RESULT_SUCCESS_V01) { ret = tsleep_nsec(&sc->qmi_resp, 0, "qwxwlancfg", SEC_TO_NSEC(1)); @@ -9038,7 +9038,7 @@ qwx_qmi_wlanfw_mode_send(struct qwx_softc *sc, enum ath11k_firmware_mode mode) return ret; } - sc->qmi_resp.result = QMI_RESULT_FAILURE_V01; + sc->qmi_resp.result = QMI_RESULT_FAILURE_V01; while (sc->qmi_resp.result != QMI_RESULT_SUCCESS_V01) { ret = tsleep_nsec(&sc->qmi_resp, 0, "qwxfwmode", SEC_TO_NSEC(1)); @@ -12424,7 +12424,7 @@ qwx_dp_rxbufs_replenish(struct qwx_softc *sc, int mac_id, if (ret) goto fail_free_mbuf; } - + ret = bus_dmamap_load_mbuf(sc->sc_dmat, rx_data->map, m, BUS_DMA_READ | BUS_DMA_NOWAIT); if (ret) { @@ -14616,7 +14616,7 @@ qwx_core_stop(struct qwx_softc *sc) { if (!test_bit(ATH11K_FLAG_CRASH_FLUSH, sc->sc_flags)) qwx_qmi_firmware_stop(sc); - + sc->ops.stop(sc); qwx_wmi_detach(sc); qwx_dp_pdev_reo_cleanup(sc); @@ -16178,7 +16178,7 @@ qwx_ce_free_ring(struct qwx_softc *sc, struct qwx_ce_ring *ring) { bus_size_t dsize; size_t size; - + if (ring == NULL) return; @@ -17167,7 +17167,7 @@ qwx_reg_update_chan_list(struct qwx_softc *sc, uint8_t pdev_id) ch->cfreq1 = ch->mhz; ch->minpower = 0; ch->maxpower = 40; /* XXX from Linux debug trace */ - ch->maxregpower = ch->maxpower; + ch->maxregpower = ch->maxpower; ch->antennamax = 0; /* TODO: Use appropriate phymodes */ diff --git a/sys/dev/ic/qwxreg.h b/sys/dev/ic/qwxreg.h index fb7f57068..40b81cb2d 100644 --- a/sys/dev/ic/qwxreg.h +++ b/sys/dev/ic/qwxreg.h @@ -9868,7 +9868,7 @@ struct hal_reo_desc_thresh_reached_status { #define HAL_TX_ADDR_SEARCH_DEFAULT 0 #define HAL_TX_ADDR_SEARCH_INDEX 1 -/* +/* * Copy Engine */ diff --git a/sys/dev/ic/qwxvar.h b/sys/dev/ic/qwxvar.h index 15dbfe612..62773a2cf 100644 --- a/sys/dev/ic/qwxvar.h +++ b/sys/dev/ic/qwxvar.h @@ -746,7 +746,7 @@ struct qwx_ce_ring { uint32_t hal_ring_id; /* - * Per-transfer data. + * Per-transfer data. * Size and type of this data depends on how the ring is used. * * For transfers using DMA, the context contains pointers to diff --git a/sys/dev/pci/drm/i915/display/intel_hdcp.c b/sys/dev/pci/drm/i915/display/intel_hdcp.c index cafb966a9..e87a876fc 100644 --- a/sys/dev/pci/drm/i915/display/intel_hdcp.c +++ b/sys/dev/pci/drm/i915/display/intel_hdcp.c @@ -2224,7 +2224,7 @@ void intel_hdcp_component_init(struct drm_i915_private *i915) if (!is_hdcp2_supported(i915)) return; - + STUB(); #ifdef notyet mutex_lock(&i915->display.hdcp.hdcp_mutex); diff --git a/sys/dev/pci/drm/include/linux/device.h b/sys/dev/pci/drm/include/linux/device.h index 74ad8d020..3708d2139 100644 --- a/sys/dev/pci/drm/include/linux/device.h +++ b/sys/dev/pci/drm/include/linux/device.h @@ -92,7 +92,7 @@ devm_device_add_group(struct device *dev, const struct attribute_group *g) #define dev_err_once(dev, fmt, arg...) \ printf("drm:pid%d:%s *ERROR* " fmt, curproc->p_p->ps_pid, \ __func__ , ## arg) - + #define dev_err_probe(dev, err, fmt, arg...) \ printf("drm:pid%d:%s *ERROR* " fmt, curproc->p_p->ps_pid, \ __func__ , ## arg), err diff --git a/sys/dev/pci/drm/ttm/ttm_bo_util.c b/sys/dev/pci/drm/ttm/ttm_bo_util.c index d202b1ddf..db7dbb520 100644 --- a/sys/dev/pci/drm/ttm/ttm_bo_util.c +++ b/sys/dev/pci/drm/ttm/ttm_bo_util.c @@ -439,7 +439,7 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map) map->bo->resource->size); break; case ttm_bo_map_vmap: - vunmap(map->virtual, + vunmap(map->virtual, map->bo->resource->size); break; case ttm_bo_map_kmap: diff --git a/sys/dev/pci/if_iwm.c b/sys/dev/pci/if_iwm.c index 27ae25db4..f3c38ff25 100644 --- a/sys/dev/pci/if_iwm.c +++ b/sys/dev/pci/if_iwm.c @@ -9305,7 +9305,7 @@ iwm_set_rate_table_vht(struct iwm_node *in, struct iwm_lq_cmd *lqcmd) tab &= ~IWM_RATE_VHT_MCS_RATE_CODE_MSK; tab |= 8; } - + tab |= IWM_RATE_MCS_RTS_REQUIRED_MSK; if (i < 4) { if (ieee80211_ra_vht_use_sgi(ni)) diff --git a/sys/dev/pci/if_qwx_pci.c b/sys/dev/pci/if_qwx_pci.c index eb6776678..e11e6873b 100644 --- a/sys/dev/pci/if_qwx_pci.c +++ b/sys/dev/pci/if_qwx_pci.c @@ -1109,7 +1109,7 @@ qwx_pci_alloc_xfer_ring(struct qwx_softc *sc, struct qwx_pci_xfer_ring *ring, memset(ring->data, 0, sizeof(ring->data)); for (i = 0; i < ring->num_elements; i++) { struct qwx_xfer_data *xfer = &ring->data[i]; - + err = bus_dmamap_create(sc->sc_dmat, QWX_PCI_XFER_MAX_DATA_SIZE, 1, QWX_PCI_XFER_MAX_DATA_SIZE, 0, BUS_DMA_NOWAIT, &xfer->map); @@ -3026,7 +3026,7 @@ qwx_mhi_fw_load_bhi(struct qwx_pci_softc *psc, uint8_t *data, size_t len) qwx_pci_write(sc, psc->bhi_off + MHI_BHI_IMGADDR_LOW, paddr & 0xffffffff); qwx_pci_write(sc, psc->bhi_off + MHI_BHI_IMGSIZE, len); - + /* Set a random transaction sequence number. */ do { seq = arc4random_uniform(MHI_BHI_TXDB_SEQNUM_BMSK); diff --git a/sys/dev/usb/ugold.c b/sys/dev/usb/ugold.c index c761e5a9f..243188bb3 100644 --- a/sys/dev/usb/ugold.c +++ b/sys/dev/usb/ugold.c @@ -512,7 +512,7 @@ ugold_si700x_type(struct ugold_softc *sc) goto identified; } } - + printf("%s: unknown model \"%s\"\n", sc->sc_hdev.sc_dev.dv_xname, model); sc->sc_num_sensors = 0; diff --git a/sys/miscfs/fuse/fuse_device.c b/sys/miscfs/fuse/fuse_device.c index b81fcea9b..792489696 100644 --- a/sys/miscfs/fuse/fuse_device.c +++ b/sys/miscfs/fuse/fuse_device.c @@ -316,7 +316,7 @@ fuseioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) SIMPLEQ_REMOVE_AFTER(&fd->fd_fbufs_in, lastfbuf, fb_next); rw_exit_write(&fd->fd_lock); - + stat_fbufs_in--; /* Do not handle fbufs with bad len */ @@ -602,7 +602,7 @@ filt_fuse_process(struct knote *kn, struct kevent *kev) int active; rw_enter_write(&fd->fd_lock); - active = knote_process(kn, kev); + active = knote_process(kn, kev); rw_exit_write(&fd->fd_lock); return (active); diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c index 07d647e20..dfd65decd 100644 --- a/sys/uvm/uvm_map.c +++ b/sys/uvm/uvm_map.c @@ -4319,7 +4319,7 @@ uvm_map_immutable(struct vm_map *map, vaddr_t start, vaddr_t end, int imut) goto out; entry1 = RBT_NEXT(uvm_map_addr, entry1); } - + while (entry != NULL && entry->start < end) { UVM_MAP_CLIP_END(map, entry, end); if (imut) diff --git a/usr.sbin/httpd/css.h.in b/usr.sbin/httpd/css.h.in index 96ec89f2f..e57b0aebd 100644 --- a/usr.sbin/httpd/css.h.in +++ b/usr.sbin/httpd/css.h.in @@ -1,24 +1,24 @@ -static const char *css = +static const char *css = body { - background-color: white; - color: black; + background-color: white; + color: black; font-family: sans-serif; } table { - border-collapse: collapse; + border-collapse: collapse; border: 1px solid; } tr.sort th { - border-bottom: 1px solid; + border-bottom: 1px solid; font-weight: normal; text-decoration: underline; cursor: pointer; } tr.sort th.sorted { font-weight: bold; } tr.sort th::after { content: "\a0\2195"; } -tr.dir td:nth-child(2n+1) { - font-weight: bold; - font-style: italic; +tr.dir td:nth-child(2n+1) { + font-weight: bold; + font-style: italic; } td, th { padding: 2pt 2em; } td:first-child, th:first-child { padding-left: 5pt; } @@ -26,9 +26,9 @@ td:last-child, th:last-child { padding-right: 5pt; } td:nth-child(n+2) { text-align: end; } thead { text-align: left; } @media (prefers-color-scheme: dark) { - body { - background-color: #1E1F21; - color: #EEEFF1; + body { + background-color: #1E1F21; + color: #EEEFF1; } a { color: #BAD7FF; } } diff --git a/usr.sbin/httpd/js.h.in b/usr.sbin/httpd/js.h.in index a9b2332d0..e1c3e354b 100644 --- a/usr.sbin/httpd/js.h.in +++ b/usr.sbin/httpd/js.h.in @@ -1,8 +1,8 @@ -static const char *js = -const cellVal = (e) => e.getAttribute('title') || e.getAttribute('data-o') || +static const char *js = +const cellVal = (e) => e.getAttribute('title') || e.getAttribute('data-o') || e.innerText || e.textContent; const rowValue = (tr, idx) => cellVal(tr.children[idx]); -const compare = (idx, asc) => (a, b) => ((v1, v2) => +const compare = (idx, asc) => (a, b) => ((v1, v2) => v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2) )(rowValue(asc ? a : b, idx), rowValue(asc ? b : a, idx)); @@ -10,7 +10,7 @@ const compare = (idx, asc) => (a, b) => ((v1, v2) => document.querySelectorAll('tr.sort th').forEach(th => th.addEventListener('click', (() => { const table = th.closest('table'); // make the sorted column bold - table.querySelectorAll('tr.sort th').forEach(th2 => + table.querySelectorAll('tr.sort th').forEach(th2 => th2.className = th2 == th ? 'sorted' : 'unsorted'); const body = table.querySelector('tbody'); Array.from(body.querySelectorAll('tr')) diff --git a/usr.sbin/httpd/server_file.c b/usr.sbin/httpd/server_file.c index 8e76cc9b6..ad024fc95 100644 --- a/usr.sbin/httpd/server_file.c +++ b/usr.sbin/httpd/server_file.c @@ -471,7 +471,7 @@ server_partial_file_request(struct httpd *env, struct client *clt, char *path, } /* ignore hidden files starting with a dot */ -static int +static int select_visible(const struct dirent *dp) { if (dp->d_name[0] == '.' && @@ -548,7 +548,7 @@ server_file_index(struct httpd *env, struct client *clt) free(escapedpath); - if ((namesize = scandir(path, &namelist, select_visible, + if ((namesize = scandir(path, &namelist, select_visible, alphasort)) == -1) goto abort; @@ -588,7 +588,7 @@ server_file_index(struct httpd *env, struct client *clt) "%s/\n" " %s%s\n", strchr(escapeduri, ':') != NULL ? "./" : "", - escapeduri, escapedhtml, + escapeduri, escapedhtml, (long long)t, tmstr, "-") == -1) skip = 1; } else if (S_ISREG(subst.st_mode)) { @@ -599,7 +599,7 @@ server_file_index(struct httpd *env, struct client *clt) "%s\n", strchr(escapeduri, ':') != NULL ? "./" : "", escapeduri, escapedhtml, - (long long)t, tmstr, + (long long)t, tmstr, subst.st_size, human_size) == -1)) skip = 1; } diff --git a/usr.sbin/nsd/util/proxy_protocol.c b/usr.sbin/nsd/util/proxy_protocol.c index a18804974..08c4be7d7 100644 --- a/usr.sbin/nsd/util/proxy_protocol.c +++ b/usr.sbin/nsd/util/proxy_protocol.c @@ -4,22 +4,22 @@ * Copyright (c) 2022, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR diff --git a/usr.sbin/nsd/util/proxy_protocol.h b/usr.sbin/nsd/util/proxy_protocol.h index ca81065bf..e33ce20d4 100644 --- a/usr.sbin/nsd/util/proxy_protocol.h +++ b/usr.sbin/nsd/util/proxy_protocol.h @@ -4,22 +4,22 @@ * Copyright (c) 2022, NLnet Labs. All rights reserved. * * This software is open source. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR diff --git a/usr.sbin/pppd/chat/chat.c b/usr.sbin/pppd/chat/chat.c index 710b26186..fc95634aa 100644 --- a/usr.sbin/pppd/chat/chat.c +++ b/usr.sbin/pppd/chat/chat.c @@ -798,7 +798,7 @@ int sending; /* set to 1 when sending (putting) this string. */ fprintf(stderr, "clean(): guessed %d and used %d\n", new_length, s1-ret); #endif if (new_length < s1 - ret) - logmsg("clean(): new_length too short! %d < %d: \"%s\" -> \"%s\"", + logmsg("clean(): new_length too short! %d < %d: \"%s\" -> \"%s\"", new_length, s1 - ret, s, ret); return ret; diff --git a/usr.sbin/rdate/ntp.c b/usr.sbin/rdate/ntp.c index 4aed956d6..4606a0734 100644 --- a/usr.sbin/rdate/ntp.c +++ b/usr.sbin/rdate/ntp.c @@ -91,7 +91,7 @@ #define MILLION_L 1000000l /* For conversion to/from timeval */ #define MILLION_D 1.0e6 /* Must be equal to MILLION_L */ -/* +/* * The era we're in if we have no reason to assume otherwise. * If unpack_ntp() sees a small offset the era is is assumed to be * NTP_ERA + 1. diff --git a/usr.sbin/snmpd/application.c b/usr.sbin/snmpd/application.c index 849311482..ac06de8fa 100644 --- a/usr.sbin/snmpd/application.c +++ b/usr.sbin/snmpd/application.c @@ -1721,7 +1721,7 @@ appl_report(struct snmp_message *statereference, int32_t requestid, ureq->aru_vblist[0].avi_request_downstream = NULL; ureq->aru_vblist[0].avi_next = NULL; ureq->aru_vblist[0].avi_sub = NULL; - + appl_request_upstream_resolve(ureq); } diff --git a/usr.sbin/snmpd/parse.y b/usr.sbin/snmpd/parse.y index ab78c2bde..a40d88e90 100644 --- a/usr.sbin/snmpd/parse.y +++ b/usr.sbin/snmpd/parse.y @@ -884,7 +884,7 @@ objectvalue : INTEGER NUMBER { free($2); YYERROR; } - + } ;