remove whitespace and tab

This commit is contained in:
purplerain 2024-01-25 01:55:28 +00:00
parent 8b912e5823
commit 029e4bda60
Signed by: purplerain
GPG Key ID: F42C07F07E2E35B7
161 changed files with 3363 additions and 3363 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -27,7 +27,7 @@
#include <keynote.h>
char policy_assertions[] =
char policy_assertions[] =
"Authorizer: \"POLICY\"\n" \
"Licensees: \"rsa-hex:3048024100d15d08ce7d2103d93ef21a87330361\\\n" \
" ff123096b14330f9f0936e8f2064ef815ffdaabbb7d3ba47b\\\n" \

View File

@ -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

View File

@ -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;

View File

@ -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; i<msg->rep->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);
}

View File

@ -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.

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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;
}

View File

@ -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);
/**

View File

@ -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; i<msg->rep->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; i<msg->rep->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

View File

@ -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 */

View File

@ -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) &&

View File

@ -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);

View File

@ -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.

File diff suppressed because it is too large Load Diff

View File

@ -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 */

View File

@ -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));

View File

@ -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 */

View File

@ -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);

View File

@ -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);
}

View File

@ -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,

View File

@ -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);

View File

@ -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 */

View File

@ -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))) {

View File

@ -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.

View File

@ -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; i<d->count+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) {

View File

@ -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.

View File

@ -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)
{

View File

@ -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);
/**

View File

@ -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);

View File

@ -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);
/**

View File

@ -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; i<cachedata->count+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)

View File

@ -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);
/**

View File

@ -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
*/

View File

@ -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 */

View File

@ -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 */

View File

@ -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);
/**

View File

@ -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;

View File

@ -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
*/

View File

@ -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)

View File

@ -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 */

View File

@ -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; i<outnet->num_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; i<pif->inuse; 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; i<outnet->num_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;

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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 */

View File

@ -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

View File

@ -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);

View File

@ -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.

View File

@ -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

View File

@ -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
};

View File

@ -346,7 +346,7 @@ enum sldns_enum_rdf_type
*/
LDNS_RDF_TYPE_TAG,
/** A <character-string> encoding of the value field as specified
/** A <character-string> encoding of the value field as specified
* [RFC1035], Section 5.1., encoded as remaining rdata.
* For CAA, URI.
*/

View File

@ -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);

View File

@ -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.

View File

@ -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.
*/

View File

@ -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);

View File

@ -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))

View File

@ -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

View File

@ -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)

View File

@ -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 );

View File

@ -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,

View File

@ -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);
/**

View File

@ -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; i<data->count; 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; i<total; i++) {
if(owner_ptr && owner_labs != 1) {
if(sldns_buffer_remaining(pkt) <
2+4+4+data->rr_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; i<num_rrsets; i++) {
setstart = sldns_buffer_position(pkt);
if((r=packed_rrset_encode(rep->rrsets[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; i<num_rrsets; i++) {
setstart = sldns_buffer_position(pkt);
if((r=packed_rrset_encode(rep->rrsets[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; i<num_rrsets; i++) {
setstart = sldns_buffer_position(pkt);
if((r=packed_rrset_encode(rep->rrsets[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 */

View File

@ -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);
/**

View File

@ -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)

View File

@ -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);
/**

View File

@ -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; i<rep->rrset_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; i<rep->rrset_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; i<rep->an_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; i<rep->an_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; i<rep->an_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; i<rep->an_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; i<rep->rrset_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; i<rep->rrset_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 =

View File

@ -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);
/**

View File

@ -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; i<total; i++) {
@ -174,7 +174,7 @@ rrset_key_hash(struct packed_rrset_key* key)
return h;
}
void
void
packed_rrset_ptr_fixup(struct packed_rrset_data* data)
{
size_t i;
@ -192,13 +192,13 @@ packed_rrset_ptr_fixup(struct packed_rrset_data* data)
}
}
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)
{
struct packed_rrset_data* d;
size_t len;
if(ntohs(rrset->rk.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;

View File

@ -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);
/**

View File

@ -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;

View File

@ -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).

View File

@ -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 */

View File

@ -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))

View File

@ -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);

View File

@ -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.

View File

@ -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; i<base->maxfd+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;

View File

@ -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 */

View File

@ -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)

View File

@ -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);
/**

View File

@ -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)

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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.

View File

@ -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)
{

View File

@ -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); \

View File

@ -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;
}

View File

@ -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.

View File

@ -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 */

Some files were not shown because too many files have changed in this diff Show More