summaryrefslogtreecommitdiffstats
path: root/usr.sbin/nsd
diff options
context:
space:
mode:
authorflorian <florian@openbsd.org>2017-02-17 20:04:45 +0000
committerflorian <florian@openbsd.org>2017-02-17 20:04:45 +0000
commitfe5fe5f6cfa8bb64bb38bafa85c14c1d131dfe6d (patch)
tree45b00c569386cd492431a724f9097b87e41209b3 /usr.sbin/nsd
parentFix up and use the device memory attribute for device mappings. Add (diff)
downloadwireguard-openbsd-fe5fe5f6cfa8bb64bb38bafa85c14c1d131dfe6d.tar.xz
wireguard-openbsd-fe5fe5f6cfa8bb64bb38bafa85c14c1d131dfe6d.zip
Update to 4.1.15.
This contains a local patch to query.c (missed _t conversion) that has been submitted upstream. OK sthen
Diffstat (limited to 'usr.sbin/nsd')
-rw-r--r--usr.sbin/nsd/axfr.c4
-rw-r--r--usr.sbin/nsd/configparser.y28
-rw-r--r--usr.sbin/nsd/configure.ac2
-rw-r--r--usr.sbin/nsd/dbaccess.c20
-rw-r--r--usr.sbin/nsd/dbcreate.c8
-rw-r--r--usr.sbin/nsd/difffile.c27
-rw-r--r--usr.sbin/nsd/difffile.h7
-rw-r--r--usr.sbin/nsd/ipc.c34
-rw-r--r--usr.sbin/nsd/mini_event.c2
-rw-r--r--usr.sbin/nsd/mini_event.h4
-rw-r--r--usr.sbin/nsd/namedb.c22
-rw-r--r--usr.sbin/nsd/namedb.h34
-rw-r--r--usr.sbin/nsd/nsd-checkconf.c54
-rw-r--r--usr.sbin/nsd/nsd-checkzone.c2
-rw-r--r--usr.sbin/nsd/nsd-control.c14
-rw-r--r--usr.sbin/nsd/nsd-mem.c12
-rw-r--r--usr.sbin/nsd/nsd.c4
-rw-r--r--usr.sbin/nsd/nsd.h18
-rw-r--r--usr.sbin/nsd/nsec3.c18
-rw-r--r--usr.sbin/nsd/options.c257
-rw-r--r--usr.sbin/nsd/options.h179
-rw-r--r--usr.sbin/nsd/query.c8
-rw-r--r--usr.sbin/nsd/radtree.c64
-rw-r--r--usr.sbin/nsd/radtree.h25
-rw-r--r--usr.sbin/nsd/rbtree.c94
-rw-r--r--usr.sbin/nsd/rbtree.h50
-rw-r--r--usr.sbin/nsd/remote.c195
-rw-r--r--usr.sbin/nsd/server.c9
-rw-r--r--usr.sbin/nsd/tsig.c4
-rw-r--r--usr.sbin/nsd/udbradtree.c83
-rw-r--r--usr.sbin/nsd/udbradtree.h12
-rw-r--r--usr.sbin/nsd/udbzone.h4
-rw-r--r--usr.sbin/nsd/util.c4
-rw-r--r--usr.sbin/nsd/xfrd-disk.c16
-rw-r--r--usr.sbin/nsd/xfrd-notify.c69
-rw-r--r--usr.sbin/nsd/xfrd-notify.h20
-rw-r--r--usr.sbin/nsd/xfrd-tcp.c80
-rw-r--r--usr.sbin/nsd/xfrd-tcp.h31
-rw-r--r--usr.sbin/nsd/xfrd.c168
-rw-r--r--usr.sbin/nsd/xfrd.h93
40 files changed, 912 insertions, 867 deletions
diff --git a/usr.sbin/nsd/axfr.c b/usr.sbin/nsd/axfr.c
index 92d4f2fc0c1..6f6b0957e99 100644
--- a/usr.sbin/nsd/axfr.c
+++ b/usr.sbin/nsd/axfr.c
@@ -164,12 +164,12 @@ return_answer:
query_state_type
answer_axfr_ixfr(struct nsd *nsd, struct query *q)
{
- acl_options_t *acl = NULL;
+ struct acl_options *acl = NULL;
/* Is it AXFR? */
switch (q->qtype) {
case TYPE_AXFR:
if (q->tcp) {
- zone_options_t* zone_opt;
+ struct zone_options* zone_opt;
zone_opt = zone_options_find(nsd->options, q->qname);
if(!zone_opt ||
acl_check_incoming(zone_opt->pattern->provide_xfr, q, &acl)==-1)
diff --git a/usr.sbin/nsd/configparser.y b/usr.sbin/nsd/configparser.y
index 204d236b653..bf20db12c72 100644
--- a/usr.sbin/nsd/configparser.y
+++ b/usr.sbin/nsd/configparser.y
@@ -30,7 +30,7 @@ extern "C"
#endif /* __cplusplus */
/* these need to be global, otherwise they cannot be used inside yacc */
-extern config_parser_state_t* cfg_parser;
+extern config_parser_state_type* cfg_parser;
#if 0
#define OUTYY(s) printf s /* used ONLY when debugging */
@@ -108,15 +108,15 @@ server_ip_address: VAR_IP_ADDRESS STRING
OUTYY(("P(server_ip_address:%s)\n", $2));
if(cfg_parser->current_ip_address_option) {
cfg_parser->current_ip_address_option->next =
- (ip_address_option_t*)region_alloc(
- cfg_parser->opt->region, sizeof(ip_address_option_t));
+ (ip_address_option_type*)region_alloc(
+ cfg_parser->opt->region, sizeof(ip_address_option_type));
cfg_parser->current_ip_address_option =
cfg_parser->current_ip_address_option->next;
cfg_parser->current_ip_address_option->next=0;
} else {
cfg_parser->current_ip_address_option =
- (ip_address_option_t*)region_alloc(
- cfg_parser->opt->region, sizeof(ip_address_option_t));
+ (ip_address_option_type*)region_alloc(
+ cfg_parser->opt->region, sizeof(ip_address_option_type));
cfg_parser->current_ip_address_option->next=0;
cfg_parser->opt->ip_addresses = cfg_parser->current_ip_address_option;
}
@@ -528,8 +528,8 @@ rc_control_port: VAR_CONTROL_PORT STRING
;
rc_control_interface: VAR_CONTROL_INTERFACE STRING
{
- ip_address_option_t* o = (ip_address_option_t*)region_alloc(
- cfg_parser->opt->region, sizeof(ip_address_option_t));
+ ip_address_option_type* o = (ip_address_option_type*)region_alloc(
+ cfg_parser->opt->region, sizeof(ip_address_option_type));
OUTYY(("P(control_interface:%s)\n", $2));
o->next = cfg_parser->opt->control_interface;
cfg_parser->opt->control_interface = o;
@@ -706,7 +706,7 @@ zone_zonestats: VAR_ZONESTATS STRING
;
zone_allow_notify: VAR_ALLOW_NOTIFY STRING STRING
{
- acl_options_t* acl = parse_acl_info(cfg_parser->opt->region, $2, $3);
+ acl_options_type* acl = parse_acl_info(cfg_parser->opt->region, $2, $3);
OUTYY(("P(allow_notify:%s %s)\n", $2, $3));
if(cfg_parser->current_allow_notify)
cfg_parser->current_allow_notify->next = acl;
@@ -729,7 +729,7 @@ zone_size_limit_xfr: VAR_SIZE_LIMIT_XFR STRING
;
zone_request_xfr_data: STRING STRING
{
- acl_options_t* acl = parse_acl_info(cfg_parser->opt->region, $1, $2);
+ acl_options_type* acl = parse_acl_info(cfg_parser->opt->region, $1, $2);
OUTYY(("P(request_xfr:%s %s)\n", $1, $2));
if(acl->blocked) c_error("blocked address used for request-xfr");
if(acl->rangetype!=acl_range_single) c_error("address range used for request-xfr");
@@ -741,7 +741,7 @@ zone_request_xfr_data: STRING STRING
}
| VAR_AXFR STRING STRING
{
- acl_options_t* acl = parse_acl_info(cfg_parser->opt->region, $2, $3);
+ acl_options_type* acl = parse_acl_info(cfg_parser->opt->region, $2, $3);
acl->use_axfr_only = 1;
OUTYY(("P(request_xfr:%s %s)\n", $2, $3));
if(acl->blocked) c_error("blocked address used for request-xfr");
@@ -754,7 +754,7 @@ zone_request_xfr_data: STRING STRING
}
| VAR_UDP STRING STRING
{
- acl_options_t* acl = parse_acl_info(cfg_parser->opt->region, $2, $3);
+ acl_options_type* acl = parse_acl_info(cfg_parser->opt->region, $2, $3);
acl->allow_udp = 1;
OUTYY(("P(request_xfr:%s %s)\n", $2, $3));
if(acl->blocked) c_error("blocked address used for request-xfr");
@@ -768,7 +768,7 @@ zone_request_xfr_data: STRING STRING
;
zone_notify: VAR_NOTIFY STRING STRING
{
- acl_options_t* acl = parse_acl_info(cfg_parser->opt->region, $2, $3);
+ acl_options_type* acl = parse_acl_info(cfg_parser->opt->region, $2, $3);
OUTYY(("P(notify:%s %s)\n", $2, $3));
if(acl->blocked) c_error("blocked address used for notify");
if(acl->rangetype!=acl_range_single) c_error("address range used for notify");
@@ -792,7 +792,7 @@ zone_notify_retry: VAR_NOTIFY_RETRY STRING
;
zone_provide_xfr: VAR_PROVIDE_XFR STRING STRING
{
- acl_options_t* acl = parse_acl_info(cfg_parser->opt->region, $2, $3);
+ acl_options_type* acl = parse_acl_info(cfg_parser->opt->region, $2, $3);
OUTYY(("P(provide_xfr:%s %s)\n", $2, $3));
if(cfg_parser->current_provide_xfr)
cfg_parser->current_provide_xfr->next = acl;
@@ -803,7 +803,7 @@ zone_provide_xfr: VAR_PROVIDE_XFR STRING STRING
;
zone_outgoing_interface: VAR_OUTGOING_INTERFACE STRING
{
- acl_options_t* acl = parse_acl_info(cfg_parser->opt->region, $2, "NOKEY");
+ acl_options_type* acl = parse_acl_info(cfg_parser->opt->region, $2, "NOKEY");
OUTYY(("P(outgoing_interface:%s)\n", $2));
if(acl->rangetype!=acl_range_single) c_error("address range used for outgoing interface");
if(cfg_parser->current_outgoing_interface)
diff --git a/usr.sbin/nsd/configure.ac b/usr.sbin/nsd/configure.ac
index 029193574f0..b984cac435a 100644
--- a/usr.sbin/nsd/configure.ac
+++ b/usr.sbin/nsd/configure.ac
@@ -4,7 +4,7 @@ dnl
sinclude(acx_nlnetlabs.m4)
-AC_INIT(NSD,4.1.14,nsd-bugs@nlnetlabs.nl)
+AC_INIT(NSD,4.1.15,nsd-bugs@nlnetlabs.nl)
AC_CONFIG_HEADER([config.h])
CFLAGS="$CFLAGS"
diff --git a/usr.sbin/nsd/dbaccess.c b/usr.sbin/nsd/dbaccess.c
index cc49a51a3e3..317273361b7 100644
--- a/usr.sbin/nsd/dbaccess.c
+++ b/usr.sbin/nsd/dbaccess.c
@@ -247,7 +247,7 @@ read_zone_data(udb_base* udb, namedb_type* db, region_type* dname_region,
/** create a zone */
zone_type*
namedb_zone_create(namedb_type* db, const dname_type* dname,
- zone_options_t* zo)
+ struct zone_options* zo)
{
zone_type* zone = (zone_type *) region_alloc(db->region,
sizeof(zone_type));
@@ -321,12 +321,12 @@ namedb_zone_delete(namedb_type* db, zone_type* zone)
#ifdef HAVE_MMAP
/** read a zone */
static void
-read_zone(udb_base* udb, namedb_type* db, nsd_options_t* opt,
+read_zone(udb_base* udb, namedb_type* db, struct nsd_options* opt,
region_type* dname_region, udb_ptr* z)
{
/* construct dname */
const dname_type* dname = dname_make(dname_region, ZONE(z)->name, 0);
- zone_options_t* zo = dname?zone_options_find(opt, dname):NULL;
+ struct zone_options* zo = dname?zone_options_find(opt, dname):NULL;
zone_type* zone;
if(!dname) return;
if(!zo) {
@@ -353,7 +353,7 @@ read_zone(udb_base* udb, namedb_type* db, nsd_options_t* opt,
#ifdef HAVE_MMAP
/** read zones from nsd.db */
static void
-read_zones(udb_base* udb, namedb_type* db, nsd_options_t* opt,
+read_zones(udb_base* udb, namedb_type* db, struct nsd_options* opt,
region_type* dname_region)
{
udb_ptr ztree, n, z;
@@ -378,7 +378,7 @@ read_zones(udb_base* udb, namedb_type* db, nsd_options_t* opt,
/** try to read the udb file or fail */
static int
try_read_udb(namedb_type* db, int fd, const char* filename,
- nsd_options_t* opt)
+ struct nsd_options* opt)
{
/*
* Temporary region used while loading domain names from the
@@ -414,7 +414,7 @@ try_read_udb(namedb_type* db, int fd, const char* filename,
#endif /* HAVE_MMAP */
struct namedb *
-namedb_open (const char* filename, nsd_options_t* opt)
+namedb_open (const char* filename, struct nsd_options* opt)
{
namedb_type* db;
@@ -653,7 +653,7 @@ namedb_read_zonefile(struct nsd* nsd, struct zone* zone, udb_base* taskudb,
}
void namedb_check_zonefile(struct nsd* nsd, udb_base* taskudb,
- udb_ptr* last_task, zone_options_t* zopt)
+ udb_ptr* last_task, struct zone_options* zopt)
{
zone_type* zone;
const dname_type* dname = (const dname_type*)zopt->node.key;
@@ -665,12 +665,12 @@ void namedb_check_zonefile(struct nsd* nsd, udb_base* taskudb,
namedb_read_zonefile(nsd, zone, taskudb, last_task);
}
-void namedb_check_zonefiles(struct nsd* nsd, nsd_options_t* opt,
+void namedb_check_zonefiles(struct nsd* nsd, struct nsd_options* opt,
udb_base* taskudb, udb_ptr* last_task)
{
- zone_options_t* zo;
+ struct zone_options* zo;
/* check all zones in opt, create if not exist in main db */
- RBTREE_FOR(zo, zone_options_t*, opt->zone_options) {
+ RBTREE_FOR(zo, struct zone_options*, opt->zone_options) {
namedb_check_zonefile(nsd, taskudb, last_task, zo);
if(nsd->signal_hint_shutdown) break;
}
diff --git a/usr.sbin/nsd/dbcreate.c b/usr.sbin/nsd/dbcreate.c
index ce2149138ed..d8d4608505b 100644
--- a/usr.sbin/nsd/dbcreate.c
+++ b/usr.sbin/nsd/dbcreate.c
@@ -326,7 +326,7 @@ create_path_components(const char* path, int* notexist)
}
void
-namedb_write_zonefile(struct nsd* nsd, zone_options_t* zopt)
+namedb_write_zonefile(struct nsd* nsd, struct zone_options* zopt)
{
const char* zfile;
int notexist = 0;
@@ -412,10 +412,10 @@ namedb_write_zonefile(struct nsd* nsd, zone_options_t* zopt)
}
void
-namedb_write_zonefiles(struct nsd* nsd, nsd_options_t* options)
+namedb_write_zonefiles(struct nsd* nsd, struct nsd_options* options)
{
- zone_options_t* zo;
- RBTREE_FOR(zo, zone_options_t*, options->zone_options) {
+ struct zone_options* zo;
+ RBTREE_FOR(zo, struct zone_options*, options->zone_options) {
namedb_write_zonefile(nsd, zo);
}
}
diff --git a/usr.sbin/nsd/difffile.c b/usr.sbin/nsd/difffile.c
index 6890a31db9d..720e3a5cc6e 100644
--- a/usr.sbin/nsd/difffile.c
+++ b/usr.sbin/nsd/difffile.c
@@ -858,10 +858,10 @@ add_RR(namedb_type* db, const dname_type* dname,
static zone_type*
find_or_create_zone(namedb_type* db, const dname_type* zone_name,
- nsd_options_t* opt, const char* zstr, const char* patname)
+ struct nsd_options* opt, const char* zstr, const char* patname)
{
zone_type* zone;
- zone_options_t* zopt;
+ struct zone_options* zopt;
zone = namedb_find_zone(db, zone_name);
if(zone) {
return zone;
@@ -958,7 +958,7 @@ delete_zone_rrs(namedb_type* db, zone_type* zone)
/* return value 0: syntaxerror,badIXFR, 1:OK, 2:done_and_skip_it */
static int
apply_ixfr(namedb_type* db, FILE *in, const char* zone, uint32_t serialno,
- nsd_options_t* opt, uint32_t seq_nr, uint32_t seq_total,
+ struct nsd_options* opt, uint32_t seq_nr, uint32_t seq_total,
int* is_axfr, int* delete_mode, int* rr_count,
udb_ptr* udbz, struct zone** zone_res, const char* patname, int* bytes,
int* softfail)
@@ -1256,7 +1256,7 @@ check_for_bad_serial(namedb_type* db, const char* zone_str, uint32_t old_serial)
static int
apply_ixfr_for_zone(nsd_type* nsd, zone_type* zonedb, FILE* in,
- nsd_options_t* opt, udb_base* taskudb, udb_ptr* last_task,
+ struct nsd_options* opt, udb_base* taskudb, udb_ptr* last_task,
uint32_t xfrfilenr)
{
char zone_buf[3072];
@@ -1617,7 +1617,7 @@ void* task_new_stat_info(udb_base* udb, udb_ptr* last, struct nsdst* stat,
udb_ptr e;
DEBUG(DEBUG_IPC,1, (LOG_INFO, "add task stat_info"));
if(!task_create_new_elem(udb, last, &e, sizeof(struct task_list_d)+
- sizeof(*stat) + sizeof(stc_t)*child_count, NULL)) {
+ sizeof(*stat) + sizeof(stc_type)*child_count, NULL)) {
log_msg(LOG_ERR, "tasklist: out of space, cannot add stati");
return NULL;
}
@@ -1665,7 +1665,7 @@ task_new_del_zone(udb_base* udb, udb_ptr* last, const dname_type* dname)
udb_ptr_unlink(&e, udb);
}
-void task_new_add_key(udb_base* udb, udb_ptr* last, key_options_t* key)
+void task_new_add_key(udb_base* udb, udb_ptr* last, struct key_options* key)
{
char* p;
udb_ptr e;
@@ -1703,7 +1703,8 @@ void task_new_del_key(udb_base* udb, udb_ptr* last, const char* name)
udb_ptr_unlink(&e, udb);
}
-void task_new_add_pattern(udb_base* udb, udb_ptr* last, pattern_options_t* p)
+void task_new_add_pattern(udb_base* udb, udb_ptr* last,
+ struct pattern_options* p)
{
region_type* temp;
buffer_type* buffer;
@@ -1743,7 +1744,7 @@ void task_new_del_pattern(udb_base* udb, udb_ptr* last, const char* name)
udb_ptr_unlink(&e, udb);
}
-void task_new_opt_change(udb_base* udb, udb_ptr* last, nsd_options_t* opt)
+void task_new_opt_change(udb_base* udb, udb_ptr* last, struct nsd_options* opt)
{
udb_ptr e;
DEBUG(DEBUG_IPC,1, (LOG_INFO, "add task opt_change"));
@@ -1837,7 +1838,7 @@ task_process_checkzones(struct nsd* nsd, udb_base* udb, udb_ptr* last_task,
/* on SIGHUP check if zone-text-files changed and if so,
* reread. When from xfrd-reload, no need to fstat the files */
if(task->yesno) {
- zone_options_t* zo = zone_options_find(nsd->options,
+ struct zone_options* zo = zone_options_find(nsd->options,
task->zname);
if(zo)
namedb_check_zonefile(nsd, udb, last_task, zo);
@@ -1851,7 +1852,7 @@ static void
task_process_writezones(struct nsd* nsd, struct task_list_d* task)
{
if(task->yesno) {
- zone_options_t* zo = zone_options_find(nsd->options,
+ struct zone_options* zo = zone_options_find(nsd->options,
task->zname);
if(zo)
namedb_write_zonefile(nsd, zo);
@@ -1893,7 +1894,7 @@ static void
task_process_del_zone(struct nsd* nsd, struct task_list_d* task)
{
zone_type* zone;
- zone_options_t* zopt;
+ struct zone_options* zopt;
DEBUG(DEBUG_IPC,1, (LOG_INFO, "delzone task %s", dname_to_string(
task->zname, NULL)));
zone = namedb_find_zone(nsd->db, task->zname);
@@ -1927,7 +1928,7 @@ task_process_del_zone(struct nsd* nsd, struct task_list_d* task)
static void
task_process_add_key(struct nsd* nsd, struct task_list_d* task)
{
- key_options_t key;
+ struct key_options key;
key.name = (char*)task->zname;
DEBUG(DEBUG_IPC,1, (LOG_INFO, "addkey task %s", key.name));
key.algorithm = key.name + strlen(key.name)+1;
@@ -1950,7 +1951,7 @@ task_process_add_pattern(struct nsd* nsd, struct task_list_d* task)
{
region_type* temp = region_create(xalloc, free);
buffer_type buffer;
- pattern_options_t *pat;
+ struct pattern_options *pat;
buffer_create_from(&buffer, task->zname, task->yesno);
pat = pattern_options_unmarshal(temp, &buffer);
DEBUG(DEBUG_IPC,1, (LOG_INFO, "addpattern task %s", pat->pname));
diff --git a/usr.sbin/nsd/difffile.h b/usr.sbin/nsd/difffile.h
index ae0dbff921a..f6db6e28234 100644
--- a/usr.sbin/nsd/difffile.h
+++ b/usr.sbin/nsd/difffile.h
@@ -119,11 +119,12 @@ void task_new_set_verbosity(udb_base* udb, udb_ptr* last, int v);
void task_new_add_zone(udb_base* udb, udb_ptr* last, const char* zone,
const char* pattern, unsigned zonestatid);
void task_new_del_zone(udb_base* udb, udb_ptr* last, const dname_type* dname);
-void task_new_add_key(udb_base* udb, udb_ptr* last, key_options_t* key);
+void task_new_add_key(udb_base* udb, udb_ptr* last, struct key_options* key);
void task_new_del_key(udb_base* udb, udb_ptr* last, const char* name);
-void task_new_add_pattern(udb_base* udb, udb_ptr* last, pattern_options_t* p);
+void task_new_add_pattern(udb_base* udb, udb_ptr* last,
+ struct pattern_options* p);
void task_new_del_pattern(udb_base* udb, udb_ptr* last, const char* name);
-void task_new_opt_change(udb_base* udb, udb_ptr* last, nsd_options_t* opt);
+void task_new_opt_change(udb_base* udb, udb_ptr* last, struct nsd_options* opt);
void task_new_zonestat_inc(udb_base* udb, udb_ptr* last, unsigned sz);
int task_new_apply_xfr(udb_base* udb, udb_ptr* last, const dname_type* zone,
uint32_t old_serial, uint32_t new_serial, uint64_t filenumber);
diff --git a/usr.sbin/nsd/ipc.c b/usr.sbin/nsd/ipc.c
index 8b5cba4bb88..5466239265a 100644
--- a/usr.sbin/nsd/ipc.c
+++ b/usr.sbin/nsd/ipc.c
@@ -24,11 +24,11 @@
/* attempt to send NSD_STATS command to child fd */
static void send_stat_to_child(struct main_ipc_handler_data* data, int fd);
/* send reload request over the IPC channel */
-static void xfrd_send_reload_req(xfrd_state_t* xfrd);
+static void xfrd_send_reload_req(xfrd_state_type* xfrd);
/* send quit request over the IPC channel */
-static void xfrd_send_quit_req(xfrd_state_t* xfrd);
+static void xfrd_send_quit_req(xfrd_state_type* xfrd);
/* perform read part of handle ipc for xfrd */
-static void xfrd_handle_ipc_read(struct event* handler, xfrd_state_t* xfrd);
+static void xfrd_handle_ipc_read(struct event* handler, xfrd_state_type* xfrd);
static void
ipc_child_quit(struct nsd* nsd)
@@ -254,17 +254,17 @@ void
stats_add(struct nsdst* total, struct nsdst* s)
{
unsigned i;
- for(i=0; i<sizeof(total->qtype)/sizeof(stc_t); i++)
+ for(i=0; i<sizeof(total->qtype)/sizeof(stc_type); i++)
total->qtype[i] += s->qtype[i];
- for(i=0; i<sizeof(total->qclass)/sizeof(stc_t); i++)
+ for(i=0; i<sizeof(total->qclass)/sizeof(stc_type); i++)
total->qclass[i] += s->qclass[i];
total->qudp += s->qudp;
total->qudp6 += s->qudp6;
total->ctcp += s->ctcp;
total->ctcp6 += s->ctcp6;
- for(i=0; i<sizeof(total->rcode)/sizeof(stc_t); i++)
+ for(i=0; i<sizeof(total->rcode)/sizeof(stc_type); i++)
total->rcode[i] += s->rcode[i];
- for(i=0; i<sizeof(total->opcode)/sizeof(stc_t); i++)
+ for(i=0; i<sizeof(total->opcode)/sizeof(stc_type); i++)
total->opcode[i] += s->opcode[i];
total->dropped += s->dropped;
total->truncated += s->truncated;
@@ -285,17 +285,17 @@ void
stats_subtract(struct nsdst* total, struct nsdst* s)
{
unsigned i;
- for(i=0; i<sizeof(total->qtype)/sizeof(stc_t); i++)
+ for(i=0; i<sizeof(total->qtype)/sizeof(stc_type); i++)
total->qtype[i] -= s->qtype[i];
- for(i=0; i<sizeof(total->qclass)/sizeof(stc_t); i++)
+ for(i=0; i<sizeof(total->qclass)/sizeof(stc_type); i++)
total->qclass[i] -= s->qclass[i];
total->qudp -= s->qudp;
total->qudp6 -= s->qudp6;
total->ctcp -= s->ctcp;
total->ctcp6 -= s->ctcp6;
- for(i=0; i<sizeof(total->rcode)/sizeof(stc_t); i++)
+ for(i=0; i<sizeof(total->rcode)/sizeof(stc_type); i++)
total->rcode[i] -= s->rcode[i];
- for(i=0; i<sizeof(total->opcode)/sizeof(stc_t); i++)
+ for(i=0; i<sizeof(total->opcode)/sizeof(stc_type); i++)
total->opcode[i] -= s->opcode[i];
total->dropped -= s->dropped;
total->truncated -= s->truncated;
@@ -553,7 +553,7 @@ parent_handle_reload_command(netio_type *ATTR_UNUSED(netio),
}
static void
-xfrd_send_reload_req(xfrd_state_t* xfrd)
+xfrd_send_reload_req(xfrd_state_type* xfrd)
{
sig_atomic_t req = NSD_RELOAD;
uint64_t p = xfrd->last_task->data;
@@ -598,7 +598,7 @@ ipc_xfrd_set_listening(struct xfrd_state* xfrd, short mode)
}
static void
-xfrd_send_shutdown_req(xfrd_state_t* xfrd)
+xfrd_send_shutdown_req(xfrd_state_type* xfrd)
{
sig_atomic_t cmd = NSD_SHUTDOWN;
xfrd->ipc_send_blocked = 1;
@@ -612,7 +612,7 @@ xfrd_send_shutdown_req(xfrd_state_t* xfrd)
}
static void
-xfrd_send_quit_req(xfrd_state_t* xfrd)
+xfrd_send_quit_req(xfrd_state_type* xfrd)
{
sig_atomic_t cmd = NSD_QUIT;
xfrd->ipc_send_blocked = 1;
@@ -626,7 +626,7 @@ xfrd_send_quit_req(xfrd_state_t* xfrd)
}
static void
-xfrd_send_stats(xfrd_state_t* xfrd)
+xfrd_send_stats(xfrd_state_type* xfrd)
{
sig_atomic_t cmd = NSD_STATS;
DEBUG(DEBUG_IPC,1, (LOG_INFO, "xfrd: ipc send stats"));
@@ -640,7 +640,7 @@ xfrd_send_stats(xfrd_state_t* xfrd)
void
xfrd_handle_ipc(int ATTR_UNUSED(fd), short event, void* arg)
{
- xfrd_state_t* xfrd = (xfrd_state_t*)arg;
+ xfrd_state_type* xfrd = (xfrd_state_type*)arg;
if ((event & EV_READ))
{
/* first attempt to read as a signal from main
@@ -674,7 +674,7 @@ xfrd_handle_ipc(int ATTR_UNUSED(fd), short event, void* arg)
}
static void
-xfrd_handle_ipc_read(struct event* handler, xfrd_state_t* xfrd)
+xfrd_handle_ipc_read(struct event* handler, xfrd_state_type* xfrd)
{
sig_atomic_t cmd;
int len;
diff --git a/usr.sbin/nsd/mini_event.c b/usr.sbin/nsd/mini_event.c
index c96dbbb1cef..a39d682cc51 100644
--- a/usr.sbin/nsd/mini_event.c
+++ b/usr.sbin/nsd/mini_event.c
@@ -166,7 +166,7 @@ handle_timeouts(struct event_base* base, struct timeval* now,
wait->tv_sec = (time_t)-1;
#endif
- while((rbnode_t*)(p = (struct event*)rbtree_first(base->times))
+ while((rbnode_type*)(p = (struct event*)rbtree_first(base->times))
!=RBTREE_NULL) {
#ifndef S_SPLINT_S
if(p->ev_timeout.tv_sec > now->tv_sec ||
diff --git a/usr.sbin/nsd/mini_event.h b/usr.sbin/nsd/mini_event.h
index 1b4a2f2dd3e..fbc56b15f24 100644
--- a/usr.sbin/nsd/mini_event.h
+++ b/usr.sbin/nsd/mini_event.h
@@ -82,7 +82,7 @@ struct region;
struct event_base
{
/** sorted by timeout (absolute), ptr */
- rbtree_t* times;
+ rbtree_type* times;
/** array of 0 - maxfd of ptr to event for it */
struct event** fds;
/** max fd in use */
@@ -116,7 +116,7 @@ struct event_base
*/
struct event {
/** node in timeout rbtree */
- rbnode_t node;
+ rbnode_type node;
/** is event already added */
int added;
diff --git a/usr.sbin/nsd/namedb.c b/usr.sbin/nsd/namedb.c
index fd381e98d32..f59f0b76fa3 100644
--- a/usr.sbin/nsd/namedb.c
+++ b/usr.sbin/nsd/namedb.c
@@ -164,7 +164,7 @@ int domain_is_prehash(domain_table_type* table, domain_type* domain)
/** remove domain node from NSEC3 tree in hash space */
void
-zone_del_domain_in_hash_tree(rbtree_t* tree, rbnode_t* node)
+zone_del_domain_in_hash_tree(rbtree_type* tree, rbnode_type* node)
{
if(!node->key)
return;
@@ -280,9 +280,9 @@ domain_table_deldomain(namedb_type* db, domain_type* domain)
/** clear hash tree */
void
-hash_tree_clear(rbtree_t* tree)
+hash_tree_clear(rbtree_type* tree)
{
- rbnode_t* n;
+ rbnode_type* n;
if(!tree) return;
/* note that elements are no longer in the tree */
@@ -293,19 +293,19 @@ hash_tree_clear(rbtree_t* tree)
tree->root = RBTREE_NULL;
}
-void hash_tree_delete(region_type* region, rbtree_t* tree)
+void hash_tree_delete(region_type* region, rbtree_type* tree)
{
- region_recycle(region, tree, sizeof(rbtree_t));
+ region_recycle(region, tree, sizeof(rbtree_type));
}
/** add domain nsec3 node to hashedspace tree */
-void zone_add_domain_in_hash_tree(region_type* region, rbtree_t** tree,
+void zone_add_domain_in_hash_tree(region_type* region, rbtree_type** tree,
int (*cmpf)(const void*, const void*),
- domain_type* domain, rbnode_t* node)
+ domain_type* domain, rbnode_type* node)
{
if(!*tree)
*tree = rbtree_create(region, cmpf);
- memset(node, 0, sizeof(rbnode_t));
+ memset(node, 0, sizeof(rbnode_type));
node->key = domain;
rbtree_insert(*tree, node);
}
@@ -351,7 +351,7 @@ domain_table_create(region_type* region)
#else
result->names_to_domains = rbtree_create(
region, (int (*)(const void *, const void *)) dname_compare);
- rbtree_insert(result->names_to_domains, (rbnode_t *) root);
+ rbtree_insert(result->names_to_domains, (rbnode_type *) root);
#endif
result->root = root;
@@ -382,7 +382,7 @@ domain_table_search(domain_table_type *table,
dname->name_size, (struct radnode**)closest_match);
*closest_match = (domain_type*)((*(struct radnode**)closest_match)->elem);
#else
- exact = rbtree_find_less_equal(table->names_to_domains, dname, (rbnode_t **) closest_match);
+ exact = rbtree_find_less_equal(table->names_to_domains, dname, (rbnode_type **) closest_match);
#endif
assert(*closest_match);
@@ -445,7 +445,7 @@ domain_table_insert(domain_table_type* table,
dname_name(result->dname),
result->dname->name_size, result);
#else
- rbtree_insert(table->names_to_domains, (rbnode_t *) result);
+ rbtree_insert(table->names_to_domains, (rbnode_type *) result);
#endif
/*
diff --git a/usr.sbin/nsd/namedb.h b/usr.sbin/nsd/namedb.h
index d8cefeb1af5..e2d84517854 100644
--- a/usr.sbin/nsd/namedb.h
+++ b/usr.sbin/nsd/namedb.h
@@ -40,7 +40,7 @@ struct domain_table
#ifdef USE_RADIX_TREE
struct radtree *nametree;
#else
- rbtree_t *names_to_domains;
+ rbtree_type *names_to_domains;
#endif
domain_type* root;
/* ptr to biggest domain.number and last in list.
@@ -63,13 +63,13 @@ struct nsec3_domain_data {
/* NSEC3 domains to prehash, prev and next on the list or cleared */
domain_type* prehash_prev, *prehash_next;
/* entry in the nsec3tree (for NSEC3s in the chain in use) */
- rbnode_t nsec3_node;
+ rbnode_type nsec3_node;
/* entry in the hashtree (for precompiled domains) */
- rbnode_t hash_node;
+ rbnode_type hash_node;
/* entry in the wchashtree (the wildcard precompile) */
- rbnode_t wchash_node;
+ rbnode_type wchash_node;
/* entry in the dshashtree (the parent ds precompile) */
- rbnode_t dshash_node;
+ rbnode_type dshash_node;
/* nsec3 hash */
uint8_t nsec3_hash[NSEC3_HASH_LEN];
@@ -94,7 +94,7 @@ struct domain
struct radnode* rnode;
const dname_type* dname;
#else
- rbnode_t node;
+ rbnode_type node;
#endif
domain_type* parent;
domain_type* wildcard_child_closest_match;
@@ -127,10 +127,10 @@ struct zone
rr_type* nsec3_param; /* NSEC3PARAM RR of chain in use or NULL */
domain_type* nsec3_last; /* last domain with nsec3, wraps */
/* in these trees, the root contains an elem ptr to the radtree* */
- rbtree_t* nsec3tree; /* tree with relevant NSEC3 domains */
- rbtree_t* hashtree; /* tree, hashed NSEC3precompiled domains */
- rbtree_t* wchashtree; /* tree, wildcard hashed domains */
- rbtree_t* dshashtree; /* tree, ds-parent-hash domains */
+ rbtree_type* nsec3tree; /* tree with relevant NSEC3 domains */
+ rbtree_type* hashtree; /* tree, hashed NSEC3precompiled domains */
+ rbtree_type* wchashtree; /* tree, wildcard hashed domains */
+ rbtree_type* dshashtree; /* tree, ds-parent-hash domains */
#endif
struct zone_options* opts;
char* filename; /* set if read from file, which file */
@@ -223,12 +223,12 @@ domain_type *domain_table_insert(domain_table_type *table,
const dname_type *dname);
/* put domain into nsec3 hash space tree */
-void zone_add_domain_in_hash_tree(region_type* region, rbtree_t** tree,
+void zone_add_domain_in_hash_tree(region_type* region, rbtree_type** tree,
int (*cmpf)(const void*, const void*), domain_type* domain,
- rbnode_t* node);
-void zone_del_domain_in_hash_tree(rbtree_t* tree, rbnode_t* node);
-void hash_tree_clear(rbtree_t* tree);
-void hash_tree_delete(region_type* region, rbtree_t* tree);
+ rbnode_type* node);
+void zone_del_domain_in_hash_tree(rbtree_type* tree, rbnode_type* node);
+void hash_tree_clear(rbtree_type* tree);
+void hash_tree_delete(region_type* region, rbtree_type* tree);
void prehash_clear(domain_table_type* table);
void prehash_add(domain_table_type* table, domain_type* domain);
void prehash_del(domain_table_type* table, domain_type* domain);
@@ -286,7 +286,7 @@ domain_previous(domain_type* domain)
struct radnode* prev = radix_prev(domain->rnode);
return prev == NULL ? NULL : (domain_type*)prev->elem;
#else
- rbnode_t *prev = rbtree_previous((rbnode_t *) domain);
+ rbnode_type *prev = rbtree_previous((rbnode_type *) domain);
return prev == RBTREE_NULL ? NULL : (domain_type *) prev;
#endif
}
@@ -298,7 +298,7 @@ domain_next(domain_type* domain)
struct radnode* next = radix_next(domain->rnode);
return next == NULL ? NULL : (domain_type*)next->elem;
#else
- rbnode_t *next = rbtree_next((rbnode_t *) domain);
+ rbnode_type *next = rbtree_next((rbnode_type *) domain);
return next == RBTREE_NULL ? NULL : (domain_type *) next;
#endif
}
diff --git a/usr.sbin/nsd/nsd-checkconf.c b/usr.sbin/nsd/nsd-checkconf.c
index 4559c3ac068..0f8b2c8e1cd 100644
--- a/usr.sbin/nsd/nsd-checkconf.c
+++ b/usr.sbin/nsd/nsd-checkconf.c
@@ -29,7 +29,7 @@ extern int optind;
#define ZONE_GET_OUTGOING(NAME, VAR, PATTERN) \
if (strcasecmp(#NAME, (VAR)) == 0) { \
- acl_options_t* acl; \
+ acl_options_type* acl; \
for(acl=PATTERN->NAME; acl; acl=acl->next) \
quote(acl->ip_address_spec); \
return; \
@@ -176,7 +176,7 @@ quote(const char *v)
}
static void
-quotepath(nsd_options_t* opt, int final, const char *f)
+quotepath(nsd_options_type* opt, int final, const char *f)
{
const char* chr = opt->chroot;
#ifdef CHROOTDIR
@@ -191,7 +191,7 @@ quotepath(nsd_options_t* opt, int final, const char *f)
}
static void
-quote_acl(acl_options_t* acl)
+quote_acl(acl_options_type* acl)
{
while(acl)
{
@@ -203,7 +203,7 @@ quote_acl(acl_options_t* acl)
}
static void
-print_acl(const char* varname, acl_options_t* acl)
+print_acl(const char* varname, acl_options_type* acl)
{
while(acl)
{
@@ -251,7 +251,7 @@ print_acl(const char* varname, acl_options_t* acl)
}
static void
-print_acl_ips(const char* varname, acl_options_t* acl)
+print_acl_ips(const char* varname, acl_options_type* acl)
{
while(acl)
{
@@ -261,14 +261,14 @@ print_acl_ips(const char* varname, acl_options_t* acl)
}
void
-config_print_zone(nsd_options_t* opt, const char* k, int s, const char *o,
+config_print_zone(nsd_options_type* opt, const char* k, int s, const char *o,
const char *z, const char* pat, int final)
{
- ip_address_option_t* ip;
+ ip_address_option_type* ip;
if (k) {
/* find key */
- key_options_t* key = key_options_find(opt, k);
+ key_options_type* key = key_options_find(opt, k);
if(key) {
if (s) {
quote(key->secret);
@@ -286,7 +286,7 @@ config_print_zone(nsd_options_t* opt, const char* k, int s, const char *o,
}
if (z) {
- zone_options_t* zone;
+ zone_options_type* zone;
const dname_type *dname = dname_parse(opt->region, z);
if(!dname) {
printf("Could not parse zone name %s\n", z);
@@ -324,7 +324,7 @@ config_print_zone(nsd_options_t* opt, const char* k, int s, const char *o,
printf("Zone option not handled: %s %s\n", z, o);
exit(1);
} else if(pat) {
- pattern_options_t* p = pattern_options_find(opt, pat);
+ pattern_options_type* p = pattern_options_find(opt, pat);
if(!p) {
printf("Pattern does not exist: %s\n", pat);
exit(1);
@@ -413,14 +413,14 @@ config_print_zone(nsd_options_t* opt, const char* k, int s, const char *o,
SERV_GET_STR(control_cert_file, o);
if(strcasecmp(o, "zones") == 0) {
- zone_options_t* zone;
- RBTREE_FOR(zone, zone_options_t*, opt->zone_options)
+ zone_options_type* zone;
+ RBTREE_FOR(zone, zone_options_type*, opt->zone_options)
quote(zone->name);
return;
}
if(strcasecmp(o, "patterns") == 0) {
- pattern_options_t* p;
- RBTREE_FOR(p, pattern_options_t*, opt->patterns)
+ pattern_options_type* p;
+ RBTREE_FOR(p, pattern_options_type*, opt->patterns)
quote(p->pname);
return;
}
@@ -430,7 +430,7 @@ config_print_zone(nsd_options_t* opt, const char* k, int s, const char *o,
}
/* print zone content items */
-static void print_zone_content_elems(pattern_options_t* pat)
+static void print_zone_content_elems(pattern_options_type* pat)
{
if(pat->zonefile)
print_string_var("zonefile:", pat->zonefile);
@@ -465,12 +465,12 @@ static void print_zone_content_elems(pattern_options_t* pat)
}
void
-config_test_print_server(nsd_options_t* opt)
+config_test_print_server(nsd_options_type* opt)
{
- ip_address_option_t* ip;
- key_options_t* key;
- zone_options_t* zone;
- pattern_options_t* pat;
+ ip_address_option_type* ip;
+ key_options_type* key;
+ zone_options_type* zone;
+ pattern_options_type* pat;
printf("# Config settings.\n");
printf("server:\n");
@@ -532,21 +532,21 @@ config_test_print_server(nsd_options_t* opt)
print_string_var("control-key-file:", opt->control_key_file);
print_string_var("control-cert-file:", opt->control_cert_file);
- RBTREE_FOR(key, key_options_t*, opt->keys)
+ RBTREE_FOR(key, key_options_type*, opt->keys)
{
printf("\nkey:\n");
print_string_var("name:", key->name);
print_string_var("algorithm:", key->algorithm);
print_string_var("secret:", key->secret);
}
- RBTREE_FOR(pat, pattern_options_t*, opt->patterns)
+ RBTREE_FOR(pat, pattern_options_type*, opt->patterns)
{
if(pat->implicit) continue;
printf("\npattern:\n");
print_string_var("name:", pat->pname);
print_zone_content_elems(pat);
}
- RBTREE_FOR(zone, zone_options_t*, opt->zone_options)
+ RBTREE_FOR(zone, zone_options_type*, opt->zone_options)
{
if(!zone->part_of_config)
continue;
@@ -578,12 +578,12 @@ file_inside_chroot(const char* fname, const char* chr)
}
static int
-additional_checks(nsd_options_t* opt, const char* filename)
+additional_checks(nsd_options_type* opt, const char* filename)
{
- zone_options_t* zone;
+ zone_options_type* zone;
int errors = 0;
- RBTREE_FOR(zone, zone_options_t*, opt->zone_options)
+ RBTREE_FOR(zone, zone_options_type*, opt->zone_options)
{
const dname_type* dname = dname_parse(opt->region, zone->name); /* memory leak. */
if(!dname) {
@@ -707,7 +707,7 @@ main(int argc, char* argv[])
const char * conf_key = NULL; /* what key is needed */
const char * conf_pat = NULL; /* what pattern is talked about */
const char* configfile;
- nsd_options_t *options;
+ nsd_options_type *options;
log_init("nsd-checkconf");
diff --git a/usr.sbin/nsd/nsd-checkzone.c b/usr.sbin/nsd/nsd-checkzone.c
index 95bb4e72836..c8366f99e14 100644
--- a/usr.sbin/nsd/nsd-checkzone.c
+++ b/usr.sbin/nsd/nsd-checkzone.c
@@ -55,7 +55,7 @@ static void
check_zone(struct nsd* nsd, const char* name, const char* fname)
{
const dname_type* dname;
- zone_options_t* zo;
+ zone_options_type* zo;
zone_type* zone;
unsigned errors;
diff --git a/usr.sbin/nsd/nsd-control.c b/usr.sbin/nsd/nsd-control.c
index 0b482839b47..da19f02abaa 100644
--- a/usr.sbin/nsd/nsd-control.c
+++ b/usr.sbin/nsd/nsd-control.c
@@ -106,7 +106,7 @@ static void ssl_err(const char* s)
/** setup SSL context */
static SSL_CTX*
-setup_ctx(nsd_options_t* cfg)
+setup_ctx(struct nsd_options* cfg)
{
char* s_cert, *c_key, *c_cert;
SSL_CTX* ctx;
@@ -144,7 +144,7 @@ setup_ctx(nsd_options_t* cfg)
/** contact the server with TCP connect */
static int
-contact_server(const char* svr, nsd_options_t* cfg, int statuscmd)
+contact_server(const char* svr, struct nsd_options* cfg, int statuscmd)
{
#ifdef INET6
struct sockaddr_storage addr;
@@ -156,9 +156,13 @@ contact_server(const char* svr, nsd_options_t* cfg, int statuscmd)
int port = cfg->control_port;
/* use svr or a config entry */
if(!svr) {
- if(cfg->control_interface)
+ if(cfg->control_interface) {
svr = cfg->control_interface->address;
- else svr = "127.0.0.1";
+ } else if(cfg->do_ip4) {
+ svr = "127.0.0.1";
+ } else {
+ svr = "::1";
+ }
/* config 0 addr (everything), means ask localhost */
if(strcmp(svr, "0.0.0.0") == 0)
svr = "127.0.0.1";
@@ -317,7 +321,7 @@ go_cmd(SSL* ssl, int argc, char* argv[])
static int
go(const char* cfgfile, char* svr, int argc, char* argv[])
{
- nsd_options_t* opt;
+ struct nsd_options* opt;
int fd, ret;
SSL_CTX* ctx;
SSL* ssl;
diff --git a/usr.sbin/nsd/nsd-mem.c b/usr.sbin/nsd/nsd-mem.c
index 105b88dad14..9383f84861a 100644
--- a/usr.sbin/nsd/nsd-mem.c
+++ b/usr.sbin/nsd/nsd-mem.c
@@ -139,7 +139,7 @@ print_zone_mem(struct zone_mem* z)
}
static void
-account_total(nsd_options_t* opt, struct tot_mem* t)
+account_total(struct nsd_options* opt, struct tot_mem* t)
{
t->opt_data = region_get_mem(opt->region);
t->opt_unused = region_get_mem_unused(opt->region);
@@ -192,8 +192,8 @@ add_mem(struct tot_mem* t, struct zone_mem* z)
}
static void
-check_zone_mem(const char* tf, const char* df, zone_options_t* zo,
- nsd_options_t* opt, struct tot_mem* totmem)
+check_zone_mem(const char* tf, const char* df, struct zone_options* zo,
+ struct nsd_options* opt, struct tot_mem* totmem)
{
struct nsd nsd;
struct namedb* db;
@@ -234,10 +234,10 @@ check_zone_mem(const char* tf, const char* df, zone_options_t* zo,
}
static void
-check_mem(nsd_options_t* opt)
+check_mem(struct nsd_options* opt)
{
struct tot_mem totmem;
- zone_options_t* zo;
+ struct zone_options* zo;
char tf[512];
char df[512];
memset(&totmem, 0, sizeof(totmem));
@@ -247,7 +247,7 @@ check_mem(nsd_options_t* opt)
else snprintf(df, sizeof(df), "./nsd-mem-db-%u.db", (unsigned)getpid());
/* read all zones and account memory */
- RBTREE_FOR(zo, zone_options_t*, opt->zone_options) {
+ RBTREE_FOR(zo, struct zone_options*, opt->zone_options) {
check_zone_mem(tf, df, zo, opt, &totmem);
}
diff --git a/usr.sbin/nsd/nsd.c b/usr.sbin/nsd/nsd.c
index f9643862a44..f2cf6ccf0cb 100644
--- a/usr.sbin/nsd/nsd.c
+++ b/usr.sbin/nsd/nsd.c
@@ -49,7 +49,7 @@
/* The server handler... */
struct nsd nsd;
static char hostname[MAXHOSTNAMELEN];
-extern config_parser_state_t* cfg_parser;
+extern config_parser_state_type* cfg_parser;
static void error(const char *format, ...) ATTR_FORMAT(printf, 1, 2);
@@ -630,7 +630,7 @@ main(int argc, char *argv[])
#endif /* INET6 */
if(nsd.options->ip_addresses)
{
- ip_address_option_t* ip = nsd.options->ip_addresses;
+ ip_address_option_type* ip = nsd.options->ip_addresses;
while(ip) {
add_interface(&nodes, &nsd, ip->address);
ip = ip->next;
diff --git a/usr.sbin/nsd/nsd.h b/usr.sbin/nsd/nsd.h
index 290b06552b3..0090100d00b 100644
--- a/usr.sbin/nsd/nsd.h
+++ b/usr.sbin/nsd/nsd.h
@@ -73,7 +73,7 @@ struct daemon_remote;
#ifdef BIND8_STATS
/* Counter for statistics */
-typedef unsigned long stc_t;
+typedef unsigned long stc_type;
#define LASTELEM(arr) (sizeof(arr) / sizeof(arr[0]) - 1)
@@ -146,7 +146,7 @@ struct nsd_child
struct netio_handler* handler;
#ifdef BIND8_STATS
- stc_t query_count;
+ stc_type query_count;
#endif
};
@@ -233,14 +233,14 @@ struct nsd
struct nsdst {
time_t boot;
int period; /* Produce statistics dump every st_period seconds */
- stc_t qtype[257]; /* Counters per qtype */
- stc_t qclass[4]; /* Class IN or Class CH or other */
- stc_t qudp, qudp6; /* Number of queries udp and udp6 */
- stc_t ctcp, ctcp6; /* Number of tcp and tcp6 connections */
- stc_t rcode[17], opcode[6]; /* Rcodes & opcodes */
+ stc_type qtype[257]; /* Counters per qtype */
+ stc_type qclass[4]; /* Class IN or Class CH or other */
+ stc_type qudp, qudp6; /* Number of queries udp and udp6 */
+ stc_type ctcp, ctcp6; /* Number of tcp and tcp6 connections */
+ stc_type rcode[17], opcode[6]; /* Rcodes & opcodes */
/* Dropped, truncated, queries for nonconfigured zone, tx errors */
- stc_t dropped, truncated, wrongzone, txerr, rxerr;
- stc_t edns, ednserr, raxfr, nona;
+ stc_type dropped, truncated, wrongzone, txerr, rxerr;
+ stc_type edns, ednserr, raxfr, nona;
uint64_t db_disk, db_mem;
} st;
/* per zone stats, each an array per zone-stat-idx, stats per zone is
diff --git a/usr.sbin/nsd/nsec3.c b/usr.sbin/nsd/nsec3.c
index 777b9f941e4..960e7216dad 100644
--- a/usr.sbin/nsd/nsec3.c
+++ b/usr.sbin/nsd/nsec3.c
@@ -346,7 +346,7 @@ nsec3_chain_find_prev(struct zone* zone, struct domain* domain)
{
if(domain->nsec3 && domain->nsec3->nsec3_node.key) {
/* see if there is a prev */
- rbnode_t* r = rbtree_previous(&domain->nsec3->nsec3_node);
+ rbnode_type* r = rbtree_previous(&domain->nsec3->nsec3_node);
if(r != RBTREE_NULL) {
/* found a previous, which is not the root-node in
* the prehash tree (and thus points to the tree) */
@@ -464,7 +464,7 @@ int
nsec3_find_cover(zone_type* zone, uint8_t* hash, size_t hashlen,
domain_type** result)
{
- rbnode_t* r = NULL;
+ rbnode_type* r = NULL;
int exact;
domain_type d;
uint8_t n[48];
@@ -656,7 +656,7 @@ init_lookup_key_ds_tree(domain_type* d, uint8_t* hash)
/* find first in the tree and true if the first to process it */
static int
-process_first(rbtree_t* tree, uint8_t* hash, rbnode_t** p,
+process_first(rbtree_type* tree, uint8_t* hash, rbnode_type** p,
void (*init)(domain_type*, uint8_t*))
{
domain_type d;
@@ -682,7 +682,7 @@ process_first(rbtree_t* tree, uint8_t* hash, rbnode_t** p,
/* set end pointer if possible */
static void
-process_end(rbtree_t* tree, uint8_t* hash, rbnode_t** p,
+process_end(rbtree_type* tree, uint8_t* hash, rbnode_type** p,
void (*init)(domain_type*, uint8_t*))
{
domain_type d;
@@ -716,8 +716,8 @@ process_range(zone_type* zone, domain_type* start,
{
/* start NULL means from first in tree */
/* end NULL means to last in tree */
- rbnode_t *p = RBTREE_NULL, *pwc = RBTREE_NULL, *pds = RBTREE_NULL;
- rbnode_t *p_end = RBTREE_NULL, *pwc_end = RBTREE_NULL, *pds_end = RBTREE_NULL;
+ rbnode_type *p = RBTREE_NULL, *pwc = RBTREE_NULL, *pds = RBTREE_NULL;
+ rbnode_type *p_end = RBTREE_NULL, *pwc_end = RBTREE_NULL, *pds_end = RBTREE_NULL;
/* because the nodes are on the prehashlist, the domain->nsec3 is
* already allocated, and we need not allocate it here */
/* set start */
@@ -783,7 +783,7 @@ process_prehash_domain(domain_type* domain, zone_type* zone)
* and set precompile pointers to point to this domain (or is_exact),
* the first domain can be is_exact. If it is the last NSEC3, also
* process the initial part (before the first) */
- rbnode_t* nx;
+ rbnode_type* nx;
/* this domain is part of the prehash list and therefore the
* domain->nsec3 is allocated and need not be allocated here */
@@ -855,8 +855,8 @@ nsec3_add_nonexist_proof(struct query* query, struct answer* answer,
{
/* exact match, hash collision */
/* the hashed name of the query corresponds to an existing name. */
- log_msg(LOG_ERR, "nsec3 hash collision for name=%s",
- dname_to_string(to_prove, NULL));
+ VERBOSITY(3, (LOG_ERR, "nsec3 hash collision for name=%s",
+ dname_to_string(to_prove, NULL)));
RCODE_SET(query->packet, RCODE_SERVFAIL);
return;
}
diff --git a/usr.sbin/nsd/options.c b/usr.sbin/nsd/options.c
index 8c1e58a3b90..883f154ed24 100644
--- a/usr.sbin/nsd/options.c
+++ b/usr.sbin/nsd/options.c
@@ -18,7 +18,7 @@
#include "configyyrename.h"
#include "configparser.h"
-config_parser_state_t* cfg_parser = 0;
+config_parser_state_type* cfg_parser = 0;
extern FILE* c_in, *c_out;
int c_parse(void);
int c_lex(void);
@@ -35,11 +35,12 @@ rbtree_strcmp(const void* p1, const void* p2)
return strcmp((const char*)p1, (const char*)p2);
}
-nsd_options_t*
+struct nsd_options*
nsd_options_create(region_type* region)
{
- nsd_options_t* opt;
- opt = (nsd_options_t*)region_alloc(region, sizeof(nsd_options_t));
+ struct nsd_options* opt;
+ opt = (struct nsd_options*)region_alloc(region, sizeof(
+ struct nsd_options));
opt->region = region;
opt->zone_options = rbtree_create(region,
(int (*)(const void *, const void *)) dname_compare);
@@ -110,40 +111,41 @@ nsd_options_create(region_type* region)
}
int
-nsd_options_insert_zone(nsd_options_t* opt, zone_options_t* zone)
+nsd_options_insert_zone(struct nsd_options* opt, struct zone_options* zone)
{
/* create dname for lookup */
const dname_type* dname = dname_parse(opt->region, zone->name);
if(!dname)
return 0;
zone->node.key = dname;
- if(!rbtree_insert(opt->zone_options, (rbnode_t*)zone))
+ if(!rbtree_insert(opt->zone_options, (rbnode_type*)zone))
return 0;
return 1;
}
int
-nsd_options_insert_pattern(nsd_options_t* opt, pattern_options_t* pat)
+nsd_options_insert_pattern(struct nsd_options* opt,
+ struct pattern_options* pat)
{
if(!pat->pname)
return 0;
pat->node.key = pat->pname;
- if(!rbtree_insert(opt->patterns, (rbnode_t*)pat))
+ if(!rbtree_insert(opt->patterns, (rbnode_type*)pat))
return 0;
return 1;
}
int
-parse_options_file(nsd_options_t* opt, const char* file,
+parse_options_file(struct nsd_options* opt, const char* file,
void (*err)(void*,const char*), void* err_arg)
{
FILE *in = 0;
- pattern_options_t* pat;
- acl_options_t* acl;
+ struct pattern_options* pat;
+ struct acl_options* acl;
if(!cfg_parser) {
- cfg_parser = (config_parser_state_t*)region_alloc(
- opt->region, sizeof(config_parser_state_t));
+ cfg_parser = (config_parser_state_type*)region_alloc(
+ opt->region, sizeof(config_parser_state_type));
cfg_parser->chroot = 0;
}
cfg_parser->err = err;
@@ -212,7 +214,7 @@ parse_options_file(nsd_options_t* opt, const char* file,
c_error("last key has no secret blob");
key_options_insert(opt, cfg_parser->current_key);
}
- RBTREE_FOR(pat, pattern_options_t*, opt->patterns)
+ RBTREE_FOR(pat, struct pattern_options*, opt->patterns)
{
/* lookup keys for acls */
for(acl=pat->allow_notify; acl; acl=acl->next)
@@ -271,9 +273,9 @@ parse_options_file(nsd_options_t* opt, const char* file,
return 1;
}
-void options_zonestatnames_create(nsd_options_t* opt)
+void options_zonestatnames_create(struct nsd_options* opt)
{
- zone_options_t* zopt;
+ struct zone_options* zopt;
/* allocate "" as zonestat 0, for zones without a zonestat */
if(!rbtree_search(opt->zonestatnames, "")) {
struct zonestatname* n;
@@ -285,9 +287,9 @@ void options_zonestatnames_create(nsd_options_t* opt)
exit(1);
}
n->id = (unsigned)(opt->zonestatnames->count);
- rbtree_insert(opt->zonestatnames, (rbnode_t*)n);
+ rbtree_insert(opt->zonestatnames, (rbnode_type*)n);
}
- RBTREE_FOR(zopt, zone_options_t*, opt->zone_options) {
+ RBTREE_FOR(zopt, struct zone_options*, opt->zone_options) {
/* insert into tree, so that when read in later id exists */
(void)getzonestatid(opt, zopt);
}
@@ -304,7 +306,7 @@ comp_zonebucket(const void* a, const void* b)
/* insert free entry into zonelist free buckets */
static void
-zone_list_free_insert(nsd_options_t* opt, int linesize, off_t off)
+zone_list_free_insert(struct nsd_options* opt, int linesize, off_t off)
{
struct zonelist_free* e;
struct zonelist_bucket* b = (struct zonelist_bucket*)rbtree_search(
@@ -323,12 +325,12 @@ zone_list_free_insert(nsd_options_t* opt, int linesize, off_t off)
opt->zonefree_number++;
}
-zone_options_t*
-zone_list_zone_insert(nsd_options_t* opt, const char* nm, const char* patnm,
- int linesize, off_t off)
+struct zone_options*
+zone_list_zone_insert(struct nsd_options* opt, const char* nm,
+ const char* patnm, int linesize, off_t off)
{
- pattern_options_t* pat = pattern_options_find(opt, patnm);
- zone_options_t* zone;
+ struct pattern_options* pat = pattern_options_find(opt, patnm);
+ struct zone_options* zone;
if(!pat) {
log_msg(LOG_ERR, "pattern does not exist for zone %s "
"pattern %s", nm, patnm);
@@ -351,7 +353,7 @@ zone_list_zone_insert(nsd_options_t* opt, const char* nm, const char* patnm,
}
int
-parse_zone_list_file(nsd_options_t* opt)
+parse_zone_list_file(struct nsd_options* opt)
{
/* zonelist looks like this:
# name pattern
@@ -432,7 +434,7 @@ parse_zone_list_file(nsd_options_t* opt)
}
void
-zone_options_delete(nsd_options_t* opt, zone_options_t* zone)
+zone_options_delete(struct nsd_options* opt, struct zone_options* zone)
{
rbtree_delete(opt->zone_options, zone->node.key);
region_recycle(opt->region, (void*)zone->node.key, dname_total_size(
@@ -441,15 +443,15 @@ zone_options_delete(nsd_options_t* opt, zone_options_t* zone)
}
/* add a new zone to the zonelist */
-zone_options_t*
-zone_list_add(nsd_options_t* opt, const char* zname, const char* pname)
+struct zone_options*
+zone_list_add(struct nsd_options* opt, const char* zname, const char* pname)
{
int r;
struct zonelist_free* e;
struct zonelist_bucket* b;
int linesize = 6 + strlen(zname) + strlen(pname);
/* create zone entry */
- zone_options_t* zone = zone_list_zone_insert(opt, zname, pname,
+ struct zone_options* zone = zone_list_zone_insert(opt, zname, pname,
linesize, 0);
if(!zone)
return NULL;
@@ -564,7 +566,7 @@ zone_list_add(nsd_options_t* opt, const char* zname, const char* pname)
/* remove a zone on the zonelist */
void
-zone_list_del(nsd_options_t* opt, zone_options_t* zone)
+zone_list_del(struct nsd_options* opt, struct zone_options* zone)
{
/* put its space onto the free entry */
if(fseeko(opt->zonelist, zone->off, SEEK_SET) == -1) {
@@ -574,7 +576,7 @@ zone_list_del(nsd_options_t* opt, zone_options_t* zone)
fprintf(opt->zonelist, "del");
zone_list_free_insert(opt, zone->linesize, zone->off);
- /* remove zone_options_t */
+ /* remove zone_options */
zone_options_delete(opt, zone);
/* see if we need to compact: it is going to halve the zonelist */
@@ -591,7 +593,7 @@ static void
delbucket(region_type* region, struct zonelist_bucket* b)
{
struct zonelist_free* e, *f;
- if(!b || (rbnode_t*)b==RBTREE_NULL)
+ if(!b || (rbnode_type*)b==RBTREE_NULL)
return;
delbucket(region, (struct zonelist_bucket*)b->node.left);
delbucket(region, (struct zonelist_bucket*)b->node.right);
@@ -606,11 +608,11 @@ delbucket(region_type* region, struct zonelist_bucket* b)
/* compact zonelist file */
void
-zone_list_compact(nsd_options_t* opt)
+zone_list_compact(struct nsd_options* opt)
{
char outname[1024];
FILE* out;
- zone_options_t* zone;
+ struct zone_options* zone;
off_t off;
int r;
snprintf(outname, sizeof(outname), "%s~", opt->zonelistfile);
@@ -639,7 +641,7 @@ zone_list_compact(nsd_options_t* opt)
fclose(out);
return;
}
- RBTREE_FOR(zone, zone_options_t*, opt->zone_options) {
+ RBTREE_FOR(zone, struct zone_options*, opt->zone_options) {
if(zone->part_of_config)
continue;
r = fprintf(out, "add %s %s\n", zone->name,
@@ -669,7 +671,7 @@ zone_list_compact(nsd_options_t* opt)
}
fclose(opt->zonelist);
/* set offsets */
- RBTREE_FOR(zone, zone_options_t*, opt->zone_options) {
+ RBTREE_FOR(zone, struct zone_options*, opt->zone_options) {
if(zone->part_of_config)
continue;
zone->off = off;
@@ -687,7 +689,7 @@ zone_list_compact(nsd_options_t* opt)
/* close zonelist file */
void
-zone_list_close(nsd_options_t* opt)
+zone_list_close(struct nsd_options* opt)
{
fclose(opt->zonelist);
opt->zonelist = NULL;
@@ -755,11 +757,12 @@ c_wrap()
return 1;
}
-zone_options_t*
+struct zone_options*
zone_options_create(region_type* region)
{
- zone_options_t* zone;
- zone = (zone_options_t*)region_alloc(region, sizeof(zone_options_t));
+ struct zone_options* zone;
+ zone = (struct zone_options*)region_alloc(region, sizeof(
+ struct zone_options));
zone->node = *RBTREE_NULL;
zone->name = 0;
zone->pattern = 0;
@@ -771,7 +774,7 @@ zone_options_create(region_type* region)
#define booleq(x,y) ( ((x) && (y)) || (!(x) && !(y)) )
int
-acl_equal(acl_options_t* p, acl_options_t* q)
+acl_equal(struct acl_options* p, struct acl_options* q)
{
if(!booleq(p->use_axfr_only, q->use_axfr_only)) return 0;
if(!booleq(p->allow_udp, q->allow_udp)) return 0;
@@ -788,7 +791,7 @@ acl_equal(acl_options_t* p, acl_options_t* q)
}
int
-acl_list_equal(acl_options_t* p, acl_options_t* q)
+acl_list_equal(struct acl_options* p, struct acl_options* q)
{
/* must be same and in same order */
while(p && q) {
@@ -802,11 +805,12 @@ acl_list_equal(acl_options_t* p, acl_options_t* q)
return 0;
}
-pattern_options_t*
+struct pattern_options*
pattern_options_create(region_type* region)
{
- pattern_options_t* p;
- p = (pattern_options_t*)region_alloc(region, sizeof(pattern_options_t));
+ struct pattern_options* p;
+ p = (struct pattern_options*)region_alloc(region, sizeof(
+ struct pattern_options));
p->node = *RBTREE_NULL;
p->pname = 0;
p->zonefile = 0;
@@ -839,7 +843,7 @@ pattern_options_create(region_type* region)
}
static void
-acl_delete(region_type* region, acl_options_t* acl)
+acl_delete(region_type* region, struct acl_options* acl)
{
if(acl->ip_address_spec)
region_recycle(region, (void*)acl->ip_address_spec,
@@ -852,9 +856,9 @@ acl_delete(region_type* region, acl_options_t* acl)
}
static void
-acl_list_delete(region_type* region, acl_options_t* list)
+acl_list_delete(region_type* region, struct acl_options* list)
{
- acl_options_t* n;
+ struct acl_options* n;
while(list) {
n = list->next;
acl_delete(region, list);
@@ -863,9 +867,9 @@ acl_list_delete(region_type* region, acl_options_t* list)
}
void
-pattern_options_remove(nsd_options_t* opt, const char* name)
+pattern_options_remove(struct nsd_options* opt, const char* name)
{
- pattern_options_t* p = (pattern_options_t*)rbtree_delete(
+ struct pattern_options* p = (struct pattern_options*)rbtree_delete(
opt->patterns, name);
/* delete p and its contents */
if (!p)
@@ -885,15 +889,15 @@ pattern_options_remove(nsd_options_t* opt, const char* name)
acl_list_delete(opt->region, p->provide_xfr);
acl_list_delete(opt->region, p->outgoing_interface);
- region_recycle(opt->region, p, sizeof(pattern_options_t));
+ region_recycle(opt->region, p, sizeof(struct pattern_options));
}
-static acl_options_t*
-copy_acl(region_type* region, acl_options_t* a)
+static struct acl_options*
+copy_acl(region_type* region, struct acl_options* a)
{
- acl_options_t* b;
+ struct acl_options* b;
if(!a) return NULL;
- b = (acl_options_t*)region_alloc(region, sizeof(*b));
+ b = (struct acl_options*)region_alloc(region, sizeof(*b));
/* copy the whole lot */
*b = *a;
/* fix the pointers */
@@ -906,10 +910,10 @@ copy_acl(region_type* region, acl_options_t* a)
return b;
}
-static acl_options_t*
-copy_acl_list(nsd_options_t* opt, acl_options_t* a)
+static struct acl_options*
+copy_acl_list(struct nsd_options* opt, struct acl_options* a)
{
- acl_options_t* b, *blast = NULL, *blist = NULL;
+ struct acl_options* b, *blast = NULL, *blist = NULL;
while(a) {
b = copy_acl(opt->region, a);
/* fixup key_options */
@@ -929,8 +933,8 @@ copy_acl_list(nsd_options_t* opt, acl_options_t* a)
}
static void
-copy_changed_acl(nsd_options_t* opt, acl_options_t** orig,
- acl_options_t* anew)
+copy_changed_acl(struct nsd_options* opt, struct acl_options** orig,
+ struct acl_options* anew)
{
if(!acl_list_equal(*orig, anew)) {
acl_list_delete(opt->region, *orig);
@@ -939,8 +943,8 @@ copy_changed_acl(nsd_options_t* opt, acl_options_t** orig,
}
static void
-copy_pat_fixed(region_type* region, pattern_options_t* orig,
- pattern_options_t* p)
+copy_pat_fixed(region_type* region, struct pattern_options* orig,
+ struct pattern_options* p)
{
orig->allow_axfr_fallback = p->allow_axfr_fallback;
orig->allow_axfr_fallback_is_default =
@@ -969,9 +973,9 @@ copy_pat_fixed(region_type* region, pattern_options_t* orig,
}
void
-pattern_options_add_modify(nsd_options_t* opt, pattern_options_t* p)
+pattern_options_add_modify(struct nsd_options* opt, struct pattern_options* p)
{
- pattern_options_t* orig = pattern_options_find(opt, p->pname);
+ struct pattern_options* orig = pattern_options_find(opt, p->pname);
if(!orig) {
/* needs to be copied to opt region */
orig = pattern_options_create(opt->region);
@@ -1003,14 +1007,14 @@ pattern_options_add_modify(nsd_options_t* opt, pattern_options_t* p)
}
}
-pattern_options_t*
-pattern_options_find(nsd_options_t* opt, const char* name)
+struct pattern_options*
+pattern_options_find(struct nsd_options* opt, const char* name)
{
- return (pattern_options_t*)rbtree_search(opt->patterns, name);
+ return (struct pattern_options*)rbtree_search(opt->patterns, name);
}
int
-pattern_options_equal(pattern_options_t* p, pattern_options_t* q)
+pattern_options_equal(struct pattern_options* p, struct pattern_options* q)
{
if(strcmp(p->pname, q->pname) != 0) return 0;
if(!p->zonefile && q->zonefile) return 0;
@@ -1137,7 +1141,7 @@ unmarshal_str(region_type* r, struct buffer* b)
}
static void
-marshal_acl(struct buffer* b, acl_options_t* acl)
+marshal_acl(struct buffer* b, struct acl_options* acl)
{
buffer_reserve(b, sizeof(*acl));
buffer_write(b, acl, sizeof(*acl));
@@ -1145,10 +1149,11 @@ marshal_acl(struct buffer* b, acl_options_t* acl)
marshal_str(b, acl->key_name);
}
-static acl_options_t*
+static struct acl_options*
unmarshal_acl(region_type* r, struct buffer* b)
{
- acl_options_t* acl = (acl_options_t*)region_alloc(r, sizeof(*acl));
+ struct acl_options* acl = (struct acl_options*)region_alloc(r,
+ sizeof(*acl));
buffer_read(b, acl, sizeof(*acl));
acl->next = NULL;
acl->key_options = NULL;
@@ -1158,7 +1163,7 @@ unmarshal_acl(region_type* r, struct buffer* b)
}
static void
-marshal_acl_list(struct buffer* b, acl_options_t* list)
+marshal_acl_list(struct buffer* b, struct acl_options* list)
{
while(list) {
marshal_u8(b, 1); /* is there a next one marker */
@@ -1168,10 +1173,10 @@ marshal_acl_list(struct buffer* b, acl_options_t* list)
marshal_u8(b, 0); /* end of list marker */
}
-static acl_options_t*
+static struct acl_options*
unmarshal_acl_list(region_type* r, struct buffer* b)
{
- acl_options_t* a, *last=NULL, *list=NULL;
+ struct acl_options* a, *last=NULL, *list=NULL;
while(unmarshal_u8(b)) {
a = unmarshal_acl(r, b);
/* link in */
@@ -1184,7 +1189,7 @@ unmarshal_acl_list(region_type* r, struct buffer* b)
}
void
-pattern_options_marshal(struct buffer* b, pattern_options_t* p)
+pattern_options_marshal(struct buffer* b, struct pattern_options* p)
{
marshal_str(b, p->pname);
marshal_str(b, p->zonefile);
@@ -1214,10 +1219,10 @@ pattern_options_marshal(struct buffer* b, pattern_options_t* p)
marshal_u8(b, p->multi_master_check);
}
-pattern_options_t*
+struct pattern_options*
pattern_options_unmarshal(region_type* r, struct buffer* b)
{
- pattern_options_t* p = pattern_options_create(r);
+ struct pattern_options* p = pattern_options_create(r);
p->pname = unmarshal_str(r, b);
p->zonefile = unmarshal_str(r, b);
p->zonestats = unmarshal_str(r, b);
@@ -1247,31 +1252,32 @@ pattern_options_unmarshal(region_type* r, struct buffer* b)
return p;
}
-key_options_t*
+struct key_options*
key_options_create(region_type* region)
{
- key_options_t* key;
- key = (key_options_t*)region_alloc_zero(region, sizeof(key_options_t));
+ struct key_options* key;
+ key = (struct key_options*)region_alloc_zero(region,
+ sizeof(struct key_options));
return key;
}
void
-key_options_insert(nsd_options_t* opt, key_options_t* key)
+key_options_insert(struct nsd_options* opt, struct key_options* key)
{
if(!key->name) return;
key->node.key = key->name;
(void)rbtree_insert(opt->keys, &key->node);
}
-key_options_t*
-key_options_find(nsd_options_t* opt, const char* name)
+struct key_options*
+key_options_find(struct nsd_options* opt, const char* name)
{
- return (key_options_t*)rbtree_search(opt->keys, name);
+ return (struct key_options*)rbtree_search(opt->keys, name);
}
/** remove tsig_key contents */
void
-key_options_desetup(region_type* region, key_options_t* key)
+key_options_desetup(region_type* region, struct key_options* key)
{
/* keep tsig_key pointer so that existing references keep valid */
if(!key->tsig_key)
@@ -1289,7 +1295,7 @@ key_options_desetup(region_type* region, key_options_t* key)
/** add tsig_key contents */
void
-key_options_setup(region_type* region, key_options_t* key)
+key_options_setup(region_type* region, struct key_options* key)
{
uint8_t data[16384]; /* 16KB */
int size;
@@ -1320,9 +1326,9 @@ key_options_setup(region_type* region, key_options_t* key)
}
void
-key_options_remove(nsd_options_t* opt, const char* name)
+key_options_remove(struct nsd_options* opt, const char* name)
{
- key_options_t* k = key_options_find(opt, name);
+ struct key_options* k = key_options_find(opt, name);
if(!k) return;
(void)rbtree_delete(opt->keys, name);
if(k->name)
@@ -1341,20 +1347,20 @@ key_options_remove(nsd_options_t* opt, const char* name)
key_options_desetup(opt->region, k);
region_recycle(opt->region, k->tsig_key, sizeof(tsig_key_type));
}
- region_recycle(opt->region, k, sizeof(key_options_t));
+ region_recycle(opt->region, k, sizeof(struct key_options));
}
int
-key_options_equal(key_options_t* p, key_options_t* q)
+key_options_equal(struct key_options* p, struct key_options* q)
{
return strcmp(p->name, q->name)==0 && strcmp(p->algorithm,
q->algorithm)==0 && strcmp(p->secret, q->secret)==0;
}
void
-key_options_add_modify(nsd_options_t* opt, key_options_t* key)
+key_options_add_modify(struct nsd_options* opt, struct key_options* key)
{
- key_options_t* orig = key_options_find(opt, key->name);
+ struct key_options* orig = key_options_find(opt, key->name);
if(!orig) {
/* needs to be copied to opt region */
orig = key_options_create(opt->region);
@@ -1378,8 +1384,8 @@ key_options_add_modify(nsd_options_t* opt, key_options_t* key)
}
int
-acl_check_incoming(acl_options_t* acl, struct query* q,
- acl_options_t** reason)
+acl_check_incoming(struct acl_options* acl, struct query* q,
+ struct acl_options** reason)
{
/* check each acl element.
if 1 blocked element matches - return -1.
@@ -1387,7 +1393,7 @@ acl_check_incoming(acl_options_t* acl, struct query* q,
else return -1. */
int found_match = -1;
int number = 0;
- acl_options_t* match = 0;
+ struct acl_options* match = 0;
if(reason)
*reason = NULL;
@@ -1420,7 +1426,7 @@ acl_check_incoming(acl_options_t* acl, struct query* q,
#ifdef INET6
int
-acl_addr_matches_ipv6host(acl_options_t* acl, struct sockaddr_storage* addr_storage, unsigned int port)
+acl_addr_matches_ipv6host(struct acl_options* acl, struct sockaddr_storage* addr_storage, unsigned int port)
{
struct sockaddr_in6* addr = (struct sockaddr_in6*)addr_storage;
if(acl->port != 0 && acl->port != port)
@@ -1449,7 +1455,7 @@ acl_addr_matches_ipv6host(acl_options_t* acl, struct sockaddr_storage* addr_stor
#endif
int
-acl_addr_matches_ipv4host(acl_options_t* acl, struct sockaddr_in* addr, unsigned int port)
+acl_addr_matches_ipv4host(struct acl_options* acl, struct sockaddr_in* addr, unsigned int port)
{
if(acl->port != 0 && acl->port != port)
return 0;
@@ -1476,7 +1482,7 @@ acl_addr_matches_ipv4host(acl_options_t* acl, struct sockaddr_in* addr, unsigned
}
int
-acl_addr_matches_host(acl_options_t* acl, acl_options_t* host)
+acl_addr_matches_host(struct acl_options* acl, struct acl_options* host)
{
if(acl->is_ipv6)
{
@@ -1499,7 +1505,7 @@ acl_addr_matches_host(acl_options_t* acl, acl_options_t* host)
}
int
-acl_addr_matches(acl_options_t* acl, struct query* q)
+acl_addr_matches(struct acl_options* acl, struct query* q)
{
if(acl->is_ipv6)
{
@@ -1571,7 +1577,7 @@ acl_addr_match_range(uint32_t* minval, uint32_t* x, uint32_t* maxval, size_t sz)
}
int
-acl_key_matches(acl_options_t* acl, struct query* q)
+acl_key_matches(struct acl_options* acl, struct query* q)
{
if(acl->blocked)
return 1;
@@ -1610,7 +1616,7 @@ acl_key_matches(acl_options_t* acl, struct query* q)
}
int
-acl_same_host(acl_options_t* a, acl_options_t* b)
+acl_same_host(struct acl_options* a, struct acl_options* b)
{
if(a->is_ipv6 && !b->is_ipv6)
return 0;
@@ -1646,10 +1652,10 @@ acl_same_host(acl_options_t* a, acl_options_t* b)
#if defined(HAVE_SSL)
void
-key_options_tsig_add(nsd_options_t* opt)
+key_options_tsig_add(struct nsd_options* opt)
{
- key_options_t* optkey;
- RBTREE_FOR(optkey, key_options_t*, opt->keys) {
+ struct key_options* optkey;
+ RBTREE_FOR(optkey, struct key_options*, opt->keys) {
key_options_setup(opt->region, optkey);
tsig_add_key(optkey->tsig_key);
}
@@ -1657,7 +1663,7 @@ key_options_tsig_add(nsd_options_t* opt)
#endif
int
-zone_is_slave(zone_options_t* opt)
+zone_is_slave(struct zone_options* opt)
{
return opt && opt->pattern && opt->pattern->request_xfr != 0;
}
@@ -1675,7 +1681,7 @@ get_char(const char* str, size_t i)
}
/* get end label of the zone name (or .) */
static const char*
-get_end_label(zone_options_t* zone, int i)
+get_end_label(struct zone_options* zone, int i)
{
const dname_type* d = (const dname_type*)zone->node.key;
if(i >= d->label_count) {
@@ -1706,7 +1712,7 @@ replace_str(char* str, size_t len, const char* one, const char* two)
}
const char*
-config_cook_string(zone_options_t* zone, const char* input)
+config_cook_string(struct zone_options* zone, const char* input)
{
static char f[1024];
/* if not a template, return as-is */
@@ -1732,7 +1738,7 @@ config_cook_string(zone_options_t* zone, const char* input)
}
const char*
-config_make_zonefile(zone_options_t* zone, struct nsd* nsd)
+config_make_zonefile(struct zone_options* zone, struct nsd* nsd)
{
static char f[1024];
/* if not a template, return as-is */
@@ -1768,14 +1774,14 @@ config_make_zonefile(zone_options_t* zone, struct nsd* nsd)
return f;
}
-zone_options_t*
-zone_options_find(nsd_options_t* opt, const struct dname* apex)
+struct zone_options*
+zone_options_find(struct nsd_options* opt, const struct dname* apex)
{
- return (zone_options_t*) rbtree_search(opt->zone_options, apex);
+ return (struct zone_options*) rbtree_search(opt->zone_options, apex);
}
-acl_options_t*
-acl_find_num(acl_options_t* acl, int num)
+struct acl_options*
+acl_find_num(struct acl_options* acl, int num)
{
int count = num;
if(num < 0)
@@ -1851,11 +1857,12 @@ parse_acl_range_subnet(char* p, void* addr, int maxbits)
}
}
-acl_options_t*
+struct acl_options*
parse_acl_info(region_type* region, char* ip, const char* key)
{
char* p;
- acl_options_t* acl = (acl_options_t*)region_alloc(region, sizeof(acl_options_t));
+ struct acl_options* acl = (struct acl_options*)region_alloc(region,
+ sizeof(struct acl_options));
acl->next = 0;
/* ip */
acl->ip_address_spec = region_strdup(region, ip);
@@ -1917,11 +1924,12 @@ parse_acl_info(region_type* region, char* ip, const char* key)
/* copy acl list at end of parser start, update current */
static
-void append_acl(acl_options_t** start, acl_options_t** cur,
- acl_options_t* list)
+void append_acl(struct acl_options** start, struct acl_options** cur,
+ struct acl_options* list)
{
while(list) {
- acl_options_t* acl = copy_acl(cfg_parser->opt->region, list);
+ struct acl_options* acl = copy_acl(cfg_parser->opt->region,
+ list);
acl->next = NULL;
if(*cur)
(*cur)->next = acl;
@@ -1935,8 +1943,9 @@ void
config_apply_pattern(const char* name)
{
/* find the pattern */
- pattern_options_t* pat = pattern_options_find(cfg_parser->opt, name);
- pattern_options_t* a = cfg_parser->current_pattern;
+ struct pattern_options* pat = pattern_options_find(cfg_parser->opt,
+ name);
+ struct pattern_options* a = cfg_parser->current_pattern;
if(!pat) {
c_error_msg("could not find pattern %s", name);
return;
@@ -1992,17 +2001,17 @@ config_apply_pattern(const char* name)
}
void
-nsd_options_destroy(nsd_options_t* opt)
+nsd_options_destroy(struct nsd_options* opt)
{
region_destroy(opt->region);
}
-unsigned getzonestatid(nsd_options_t* opt, zone_options_t* zopt)
+unsigned getzonestatid(struct nsd_options* opt, struct zone_options* zopt)
{
#ifdef USE_ZONE_STATS
const char* statname;
struct zonestatname* n;
- rbnode_t* res;
+ rbnode_type* res;
/* try to find the instantiated zonestat name */
if(!zopt->pattern->zonestats || zopt->pattern->zonestats[0]==0)
return 0; /* no zone stats */
@@ -2019,7 +2028,7 @@ unsigned getzonestatid(nsd_options_t* opt, zone_options_t* zopt)
exit(1);
}
n->id = (unsigned)(opt->zonestatnames->count);
- rbtree_insert(opt->zonestatnames, (rbnode_t*)n);
+ rbtree_insert(opt->zonestatnames, (rbnode_type*)n);
return n->id;
#else /* USE_ZONE_STATS */
(void)opt; (void)zopt;
diff --git a/usr.sbin/nsd/options.h b/usr.sbin/nsd/options.h
index d826c03fd7c..9e1d1efc3e1 100644
--- a/usr.sbin/nsd/options.h
+++ b/usr.sbin/nsd/options.h
@@ -20,26 +20,26 @@ struct tsig_key;
struct buffer;
struct nsd;
-typedef struct nsd_options nsd_options_t;
-typedef struct pattern_options pattern_options_t;
-typedef struct zone_options zone_options_t;
-typedef struct ipaddress_option ip_address_option_t;
-typedef struct acl_options acl_options_t;
-typedef struct key_options key_options_t;
-typedef struct config_parser_state config_parser_state_t;
+typedef struct nsd_options nsd_options_type;
+typedef struct pattern_options pattern_options_type;
+typedef struct zone_options zone_options_type;
+typedef struct ip_address_option ip_address_option_type;
+typedef struct acl_options acl_options_type;
+typedef struct key_options key_options_type;
+typedef struct config_parser_state config_parser_state_type;
/*
* Options global for nsd.
*/
struct nsd_options {
/* config file name */
char* configfile;
- /* options for zones, by apex, contains zone_options_t */
- rbtree_t* zone_options;
- /* patterns, by name, contains pattern_options_t */
- rbtree_t* patterns;
+ /* options for zones, by apex, contains zone_options */
+ rbtree_type* zone_options;
+ /* patterns, by name, contains pattern_options */
+ rbtree_type* patterns;
/* free space in zonelist file, contains zonelist_bucket */
- rbtree_t* zonefree;
+ rbtree_type* zonefree;
/* number of free space lines in zonelist file */
size_t zonefree_number;
/* zonelist file if open */
@@ -51,13 +51,13 @@ struct nsd_options {
* zonestatname with malloced key=stringname. The number of items
* is the max statnameid, no items are freed from this.
* kept correct in the xfrd process, and on startup. */
- rbtree_t* zonestatnames;
+ rbtree_type* zonestatnames;
/* rbtree of keys defined, by name */
- rbtree_t* keys;
+ rbtree_type* keys;
/* list of ip addresses to bind to (or NULL for all) */
- ip_address_option_t* ip_addresses;
+ struct ip_address_option* ip_addresses;
int ip_transparent;
int ip_freebind;
@@ -98,7 +98,7 @@ struct nsd_options {
/** remote control section. enable toggle. */
int control_enable;
/** the interfaces the remote control should listen on */
- ip_address_option_t* control_interface;
+ struct ip_address_option* control_interface;
/** port number for the control port */
int control_port;
/** private key file for server */
@@ -127,8 +127,8 @@ struct nsd_options {
region_type* region;
};
-struct ipaddress_option {
- ip_address_option_t* next;
+struct ip_address_option {
+ struct ip_address_option* next;
char* address;
};
@@ -136,14 +136,14 @@ struct ipaddress_option {
* Pattern of zone options, used to contain options for zone(s).
*/
struct pattern_options {
- rbnode_t node;
+ rbnode_type node;
const char* pname; /* name of the pattern, key of rbtree */
const char* zonefile;
- acl_options_t* allow_notify;
- acl_options_t* request_xfr;
- acl_options_t* notify;
- acl_options_t* provide_xfr;
- acl_options_t* outgoing_interface;
+ struct acl_options* allow_notify;
+ struct acl_options* request_xfr;
+ struct acl_options* notify;
+ struct acl_options* provide_xfr;
+ struct acl_options* outgoing_interface;
const char* zonestats;
#ifdef RATELIMIT
uint16_t rrl_whitelist; /* bitmap with rrl types */
@@ -173,7 +173,7 @@ struct pattern_options {
*/
struct zone_options {
/* key is dname of apex */
- rbnode_t node;
+ rbnode_type node;
/* is apex of the zone */
const char* name;
@@ -182,7 +182,7 @@ struct zone_options {
int linesize;
/* pattern for the zone options, if zone is part_of_config, this is
* a anonymous pattern created in-place */
- pattern_options_t* pattern;
+ struct pattern_options* pattern;
/* zone is fixed into the main config, not in zonelist, cannot delete */
uint8_t part_of_config;
};
@@ -200,7 +200,7 @@ union acl_addr_storage {
* Access control list element
*/
struct acl_options {
- acl_options_t* next;
+ struct acl_options* next;
/* options */
time_t ixfr_disabled;
@@ -225,14 +225,14 @@ struct acl_options {
uint8_t nokey;
uint8_t blocked;
const char* key_name;
- key_options_t* key_options;
+ struct key_options* key_options;
};
/*
* Key definition
*/
struct key_options {
- rbnode_t node; /* key of tree is name */
+ rbnode_type node; /* key of tree is name */
char* name;
char* algorithm;
char* secret;
@@ -246,7 +246,7 @@ struct zonelist_free {
};
/** zonelist free bucket for a particular line length */
struct zonelist_bucket {
- rbnode_t node; /* key is ptr to linesize */
+ rbnode_type node; /* key is ptr to linesize */
int linesize;
struct zonelist_free* list;
};
@@ -255,7 +255,7 @@ struct zonelist_bucket {
#define ZONEFILES_WRITE_INTERVAL 3600
struct zonestatname {
- rbnode_t node; /* key is malloced string with cooked zonestat name */
+ rbnode_type node; /* key is malloced string with cooked zonestat name */
unsigned id; /* index in nsd.zonestat array */
};
@@ -268,103 +268,107 @@ struct config_parser_state {
int line;
int errors;
int server_settings_seen;
- nsd_options_t* opt;
- pattern_options_t* current_pattern;
- zone_options_t* current_zone;
- key_options_t* current_key;
- ip_address_option_t* current_ip_address_option;
- acl_options_t* current_allow_notify;
- acl_options_t* current_request_xfr;
- acl_options_t* current_notify;
- acl_options_t* current_provide_xfr;
- acl_options_t* current_outgoing_interface;
+ struct nsd_options* opt;
+ struct pattern_options* current_pattern;
+ struct zone_options* current_zone;
+ struct key_options* current_key;
+ struct ip_address_option* current_ip_address_option;
+ struct acl_options* current_allow_notify;
+ struct acl_options* current_request_xfr;
+ struct acl_options* current_notify;
+ struct acl_options* current_provide_xfr;
+ struct acl_options* current_outgoing_interface;
void (*err)(void*,const char*);
void* err_arg;
};
-extern config_parser_state_t* cfg_parser;
+extern config_parser_state_type* cfg_parser;
/* region will be put in nsd_options struct. Returns empty options struct. */
-nsd_options_t* nsd_options_create(region_type* region);
+struct nsd_options* nsd_options_create(region_type* region);
/* the number of zones that are configured */
-static inline size_t nsd_options_num_zones(nsd_options_t* opt)
+static inline size_t nsd_options_num_zones(struct nsd_options* opt)
{ return opt->zone_options->count; }
/* insert a zone into the main options tree, returns 0 on error */
-int nsd_options_insert_zone(nsd_options_t* opt, zone_options_t* zone);
+int nsd_options_insert_zone(struct nsd_options* opt, struct zone_options* zone);
/* insert a pattern into the main options tree, returns 0 on error */
-int nsd_options_insert_pattern(nsd_options_t* opt, pattern_options_t* pat);
+int nsd_options_insert_pattern(struct nsd_options* opt,
+ struct pattern_options* pat);
/* parses options file. Returns false on failure. callback, if nonNULL,
* gets called with error strings, default prints. */
-int parse_options_file(nsd_options_t* opt, const char* file,
+int parse_options_file(struct nsd_options* opt, const char* file,
void (*err)(void*,const char*), void* err_arg);
-zone_options_t* zone_options_create(region_type* region);
-void zone_options_delete(nsd_options_t* opt, zone_options_t* zone);
+struct zone_options* zone_options_create(region_type* region);
+void zone_options_delete(struct nsd_options* opt, struct zone_options* zone);
/* find a zone by apex domain name, or NULL if not found. */
-zone_options_t* zone_options_find(nsd_options_t* opt, const struct dname* apex);
-pattern_options_t* pattern_options_create(region_type* region);
-pattern_options_t* pattern_options_find(nsd_options_t* opt, const char* name);
-int pattern_options_equal(pattern_options_t* p, pattern_options_t* q);
-void pattern_options_remove(nsd_options_t* opt, const char* name);
-void pattern_options_add_modify(nsd_options_t* opt, pattern_options_t* p);
-void pattern_options_marshal(struct buffer* buffer, pattern_options_t* p);
-pattern_options_t* pattern_options_unmarshal(region_type* r, struct buffer* b);
-key_options_t* key_options_create(region_type* region);
-void key_options_insert(nsd_options_t* opt, key_options_t* key);
-key_options_t* key_options_find(nsd_options_t* opt, const char* name);
-void key_options_remove(nsd_options_t* opt, const char* name);
-int key_options_equal(key_options_t* p, key_options_t* q);
-void key_options_add_modify(nsd_options_t* opt, key_options_t* key);
+struct zone_options* zone_options_find(struct nsd_options* opt,
+ const struct dname* apex);
+struct pattern_options* pattern_options_create(region_type* region);
+struct pattern_options* pattern_options_find(struct nsd_options* opt, const char* name);
+int pattern_options_equal(struct pattern_options* p, struct pattern_options* q);
+void pattern_options_remove(struct nsd_options* opt, const char* name);
+void pattern_options_add_modify(struct nsd_options* opt,
+ struct pattern_options* p);
+void pattern_options_marshal(struct buffer* buffer, struct pattern_options* p);
+struct pattern_options* pattern_options_unmarshal(region_type* r,
+ struct buffer* b);
+struct key_options* key_options_create(region_type* region);
+void key_options_insert(struct nsd_options* opt, struct key_options* key);
+struct key_options* key_options_find(struct nsd_options* opt, const char* name);
+void key_options_remove(struct nsd_options* opt, const char* name);
+int key_options_equal(struct key_options* p, struct key_options* q);
+void key_options_add_modify(struct nsd_options* opt, struct key_options* key);
/* read in zone list file. Returns false on failure */
-int parse_zone_list_file(nsd_options_t* opt);
+int parse_zone_list_file(struct nsd_options* opt);
/* create zone entry and add to the zonelist file */
-zone_options_t* zone_list_add(nsd_options_t* opt, const char* zname,
+struct zone_options* zone_list_add(struct nsd_options* opt, const char* zname,
const char* pname);
/* create zonelist entry, do not insert in file (called by _add) */
-zone_options_t* zone_list_zone_insert(nsd_options_t* opt, const char* nm,
- const char* patnm, int linesize, off_t off);
-void zone_list_del(nsd_options_t* opt, zone_options_t* zone);
-void zone_list_compact(nsd_options_t* opt);
-void zone_list_close(nsd_options_t* opt);
+struct zone_options* zone_list_zone_insert(struct nsd_options* opt,
+ const char* nm, const char* patnm, int linesize, off_t off);
+void zone_list_del(struct nsd_options* opt, struct zone_options* zone);
+void zone_list_compact(struct nsd_options* opt);
+void zone_list_close(struct nsd_options* opt);
/* create zonestat name tree , for initially created zones */
-void options_zonestatnames_create(nsd_options_t* opt);
+void options_zonestatnames_create(struct nsd_options* opt);
/* Get zonestat id for zone options, add new entry if necessary.
* instantiates the pattern's zonestat string */
-unsigned getzonestatid(nsd_options_t* opt, zone_options_t* zopt);
+unsigned getzonestatid(struct nsd_options* opt, struct zone_options* zopt);
/* create string, same options as zonefile but no chroot changes */
-const char* config_cook_string(zone_options_t* zone, const char* input);
+const char* config_cook_string(struct zone_options* zone, const char* input);
#if defined(HAVE_SSL)
/* tsig must be inited, adds all keys in options to tsig. */
-void key_options_tsig_add(nsd_options_t* opt);
+void key_options_tsig_add(struct nsd_options* opt);
#endif
/* check acl list, acl number that matches if passed(0..),
* or failure (-1) if dropped */
/* the reason why (the acl) is returned too (or NULL) */
-int acl_check_incoming(acl_options_t* acl, struct query* q,
- acl_options_t** reason);
-int acl_addr_matches_host(acl_options_t* acl, acl_options_t* host);
-int acl_addr_matches(acl_options_t* acl, struct query* q);
-int acl_key_matches(acl_options_t* acl, struct query* q);
+int acl_check_incoming(struct acl_options* acl, struct query* q,
+ struct acl_options** reason);
+int acl_addr_matches_host(struct acl_options* acl, struct acl_options* host);
+int acl_addr_matches(struct acl_options* acl, struct query* q);
+int acl_key_matches(struct acl_options* acl, struct query* q);
int acl_addr_match_mask(uint32_t* a, uint32_t* b, uint32_t* mask, size_t sz);
int acl_addr_match_range(uint32_t* minval, uint32_t* x, uint32_t* maxval, size_t sz);
/* returns true if acls are both from the same host */
-int acl_same_host(acl_options_t* a, acl_options_t* b);
+int acl_same_host(struct acl_options* a, struct acl_options* b);
/* find acl by number in the list */
-acl_options_t* acl_find_num(acl_options_t* acl, int num);
+struct acl_options* acl_find_num(struct acl_options* acl, int num);
/* see if two acl lists are the same (same elements in same order, or empty) */
-int acl_list_equal(acl_options_t* p, acl_options_t* q);
+int acl_list_equal(struct acl_options* p, struct acl_options* q);
/* see if two acl are the same */
-int acl_equal(acl_options_t* p, acl_options_t* q);
+int acl_equal(struct acl_options* p, struct acl_options* q);
/* see if a zone is a slave or a master zone */
-int zone_is_slave(zone_options_t* opt);
+int zone_is_slave(struct zone_options* opt);
/* create zonefile name, returns static pointer (perhaps to options data) */
-const char* config_make_zonefile(zone_options_t* zone, struct nsd* nsd);
+const char* config_make_zonefile(struct zone_options* zone, struct nsd* nsd);
#define ZONEC_PCT_TIME 5 /* seconds, then it starts to print pcts */
#define ZONEC_PCT_COUNT 100000 /* elements before pct check is done */
@@ -372,7 +376,8 @@ const char* config_make_zonefile(zone_options_t* zone, struct nsd* nsd);
/* parsing helpers */
void c_error(const char* msg);
void c_error_msg(const char* fmt, ...) ATTR_FORMAT(printf, 1, 2);
-acl_options_t* parse_acl_info(region_type* region, char* ip, const char* key);
+struct acl_options* parse_acl_info(region_type* region, char* ip,
+ const char* key);
/* true if ipv6 address, false if ipv4 */
int parse_acl_is_ipv6(const char* p);
/* returns range type. mask is the 2nd part of the range */
@@ -380,7 +385,7 @@ int parse_acl_range_type(char* ip, char** mask);
/* parses subnet mask, fills 0 mask as well */
void parse_acl_range_subnet(char* p, void* addr, int maxbits);
/* clean up options */
-void nsd_options_destroy(nsd_options_t* opt);
+void nsd_options_destroy(struct nsd_options* opt);
/* replace occurrences of one with two in buf, pass length of buffer */
void replace_str(char* buf, size_t len, const char* one, const char* two);
/* apply pattern to the existing pattern in the parser */
diff --git a/usr.sbin/nsd/query.c b/usr.sbin/nsd/query.c
index fc2d45e9b86..a9317d2c794 100644
--- a/usr.sbin/nsd/query.c
+++ b/usr.sbin/nsd/query.c
@@ -411,10 +411,10 @@ static query_state_type
answer_notify(struct nsd* nsd, struct query *query)
{
int acl_num, acl_num_xfr;
- acl_options_t *why;
+ struct acl_options *why;
nsd_rc_type rc;
- zone_options_t* zone_opt;
+ struct zone_options* zone_opt;
DEBUG(DEBUG_XFRD,1, (LOG_INFO, "got notify %s processing acl",
dname_to_string(query->qname, NULL)));
@@ -664,7 +664,7 @@ add_additional_rrsets(struct query *query, answer_type *answer,
temp->rnode = NULL;
temp->dname = additional->dname;
#else
- memcpy(&temp->node, &additional->node, sizeof(rbnode_t));
+ memcpy(&temp->node, &additional->node, sizeof(rbnode_type));
temp->node.parent = NULL;
#endif
temp->number = additional->number;
@@ -1113,7 +1113,7 @@ answer_authoritative(struct nsd *nsd,
match->rnode = NULL;
match->dname = wildcard_child->dname;
#else
- memcpy(&match->node, &wildcard_child->node, sizeof(rbnode_t));
+ memcpy(&match->node, &wildcard_child->node, sizeof(rbnode_type));
match->node.parent = NULL;
#endif
match->parent = closest_encloser;
diff --git a/usr.sbin/nsd/radtree.c b/usr.sbin/nsd/radtree.c
index fd003795a4a..c3ac8661a73 100644
--- a/usr.sbin/nsd/radtree.c
+++ b/usr.sbin/nsd/radtree.c
@@ -137,10 +137,10 @@ radnode_find_prev_from_idx(struct radnode* n, unsigned from)
* @return false if no prefix found, not even the root "" prefix.
*/
static int radix_find_prefix_node(struct radtree* rt, uint8_t* k,
- radstrlen_t len, struct radnode** result, radstrlen_t* respos)
+ radstrlen_type len, struct radnode** result, radstrlen_type* respos)
{
struct radnode* n = rt->root;
- radstrlen_t pos = 0;
+ radstrlen_type pos = 0;
uint8_t byte;
*respos = 0;
*result = n;
@@ -260,7 +260,7 @@ radnode_array_space(struct region* region, struct radnode* n, uint8_t byte)
/** create a prefix in the array strs */
static int
radsel_str_create(struct region* region, struct radsel* r, uint8_t* k,
- radstrlen_t pos, radstrlen_t len)
+ radstrlen_type pos, radstrlen_type len)
{
r->str = (uint8_t*)region_alloc(region, sizeof(uint8_t)*(len-pos));
if(!r->str)
@@ -272,7 +272,8 @@ radsel_str_create(struct region* region, struct radsel* r, uint8_t* k,
/** see if one byte string p is a prefix of another x (equality is true) */
static int
-bstr_is_prefix(uint8_t* p, radstrlen_t plen, uint8_t* x, radstrlen_t xlen)
+bstr_is_prefix(uint8_t* p, radstrlen_type plen, uint8_t* x,
+ radstrlen_type xlen)
{
/* if plen is zero, it is an (empty) prefix */
if(plen == 0)
@@ -284,8 +285,8 @@ bstr_is_prefix(uint8_t* p, radstrlen_t plen, uint8_t* x, radstrlen_t xlen)
}
/** number of bytes in common for the two strings */
-static radstrlen_t
-bstr_common(uint8_t* x, radstrlen_t xlen, uint8_t* y, radstrlen_t ylen)
+static radstrlen_type
+bstr_common(uint8_t* x, radstrlen_type xlen, uint8_t* y, radstrlen_type ylen)
{
unsigned i, max = ((xlen<ylen)?xlen:ylen);
for(i=0; i<max; i++) {
@@ -297,13 +298,15 @@ bstr_common(uint8_t* x, radstrlen_t xlen, uint8_t* y, radstrlen_t ylen)
int
-bstr_is_prefix_ext(uint8_t* p, radstrlen_t plen, uint8_t* x, radstrlen_t xlen)
+bstr_is_prefix_ext(uint8_t* p, radstrlen_type plen, uint8_t* x,
+ radstrlen_type xlen)
{
return bstr_is_prefix(p, plen, x, xlen);
}
-radstrlen_t
-bstr_common_ext(uint8_t* x, radstrlen_t xlen, uint8_t* y, radstrlen_t ylen)
+radstrlen_type
+bstr_common_ext(uint8_t* x, radstrlen_type xlen, uint8_t* y,
+ radstrlen_type ylen)
{
return bstr_common(x, xlen, y, ylen);
}
@@ -311,9 +314,9 @@ bstr_common_ext(uint8_t* x, radstrlen_t xlen, uint8_t* y, radstrlen_t ylen)
/** allocate remainder from prefixes for a split:
* plen: len prefix, l: longer bstring, llen: length of l. */
static int
-radsel_prefix_remainder(struct region* region, radstrlen_t plen,
- uint8_t* l, radstrlen_t llen,
- uint8_t** s, radstrlen_t* slen)
+radsel_prefix_remainder(struct region* region, radstrlen_type plen,
+ uint8_t* l, radstrlen_type llen,
+ uint8_t** s, radstrlen_type* slen)
{
*slen = llen - plen;
*s = (uint8_t*)region_alloc(region, (*slen)*sizeof(uint8_t));
@@ -334,13 +337,13 @@ radsel_prefix_remainder(struct region* region, radstrlen_t plen,
*/
static int
radsel_split(struct region* region, struct radsel* r, uint8_t* k,
- radstrlen_t pos, radstrlen_t len, struct radnode* add)
+ radstrlen_type pos, radstrlen_type len, struct radnode* add)
{
uint8_t* addstr = k+pos;
- radstrlen_t addlen = len-pos;
+ radstrlen_type addlen = len-pos;
if(bstr_is_prefix(addstr, addlen, r->str, r->len)) {
uint8_t* split_str=NULL, *dupstr=NULL;
- radstrlen_t split_len=0;
+ radstrlen_type split_len=0;
/* 'add' is a prefix of r.node */
/* also for empty addstr */
/* set it up so that the 'add' node has r.node as child */
@@ -384,7 +387,7 @@ radsel_split(struct region* region, struct radsel* r, uint8_t* k,
r->len = addlen;
} else if(bstr_is_prefix(r->str, r->len, addstr, addlen)) {
uint8_t* split_str = NULL;
- radstrlen_t split_len = 0;
+ radstrlen_type split_len = 0;
/* r.node is a prefix of 'add' */
/* set it up so that the 'r.node' has 'add' as child */
/* and basically, r.node is already completely fine,
@@ -414,7 +417,7 @@ radsel_split(struct region* region, struct radsel* r, uint8_t* k,
* key name. */
struct radnode* com;
uint8_t* common_str=NULL, *s1_str=NULL, *s2_str=NULL;
- radstrlen_t common_len, s1_len=0, s2_len=0;
+ radstrlen_type common_len, s1_len=0, s2_len=0;
common_len = bstr_common(r->str, r->len, addstr, addlen);
assert(common_len < r->len);
assert(common_len < addlen);
@@ -486,11 +489,11 @@ radsel_split(struct region* region, struct radsel* r, uint8_t* k,
return 1;
}
-struct radnode* radix_insert(struct radtree* rt, uint8_t* k, radstrlen_t len,
- void* elem)
+struct radnode* radix_insert(struct radtree* rt, uint8_t* k,
+ radstrlen_type len, void* elem)
{
struct radnode* n;
- radstrlen_t pos = 0;
+ radstrlen_type pos = 0;
/* create new element to add */
struct radnode* add = (struct radnode*)region_alloc_zero(rt->region,
sizeof(*add));
@@ -620,7 +623,7 @@ radnode_cleanup_onechild(struct region* region, struct radnode* n,
struct radnode* par)
{
uint8_t* join;
- radstrlen_t joinlen;
+ radstrlen_type joinlen;
uint8_t pidx = n->pidx;
struct radnode* child = n->array[0].node;
/* node had one child, merge them into the parent. */
@@ -813,10 +816,11 @@ void radix_delete(struct radtree* rt, struct radnode* n)
}
}
-struct radnode* radix_search(struct radtree* rt, uint8_t* k, radstrlen_t len)
+struct radnode* radix_search(struct radtree* rt, uint8_t* k,
+ radstrlen_type len)
{
struct radnode* n = rt->root;
- radstrlen_t pos = 0;
+ radstrlen_type pos = 0;
uint8_t byte;
while(n) {
if(pos == len)
@@ -851,11 +855,11 @@ static int ret_self_or_prev(struct radnode* n, struct radnode** result)
return 0;
}
-int radix_find_less_equal(struct radtree* rt, uint8_t* k, radstrlen_t len,
+int radix_find_less_equal(struct radtree* rt, uint8_t* k, radstrlen_type len,
struct radnode** result)
{
struct radnode* n = rt->root;
- radstrlen_t pos = 0;
+ radstrlen_type pos = 0;
uint8_t byte;
int r;
if(!n) {
@@ -1035,7 +1039,7 @@ static void cpy_r2d(uint8_t* to, uint8_t* from, uint8_t len)
}
/* radname code: domain to radix-bstring */
-void radname_d2r(uint8_t* k, radstrlen_t* len, const uint8_t* dname,
+void radname_d2r(uint8_t* k, radstrlen_type* len, const uint8_t* dname,
size_t dlen)
{
/* the domain name is converted as follows,
@@ -1107,7 +1111,7 @@ void radname_d2r(uint8_t* k, radstrlen_t* len, const uint8_t* dname,
}
/* radname code: radix-bstring to domain */
-void radname_r2d(uint8_t* k, radstrlen_t len, uint8_t* dname, size_t* dlen)
+void radname_r2d(uint8_t* k, radstrlen_type len, uint8_t* dname, size_t* dlen)
{
/* find labels and push on stack */
uint8_t* labstart[130];
@@ -1164,7 +1168,7 @@ radname_insert(struct radtree* rt, const uint8_t* d, size_t max, void* elem)
{
/* convert and insert */
uint8_t radname[300];
- radstrlen_t len = (radstrlen_t)sizeof(radname);
+ radstrlen_type len = (radstrlen_type)sizeof(radname);
if(max > sizeof(radname))
return NULL; /* too long */
radname_d2r(radname, &len, d, max);
@@ -1189,7 +1193,7 @@ struct radnode* radname_search(struct radtree* rt, const uint8_t* d,
unsigned int lab, dpos, lpos;
struct radnode* n = rt->root;
uint8_t byte;
- radstrlen_t i;
+ radstrlen_type i;
uint8_t b;
/* search for root? it is '' */
@@ -1274,7 +1278,7 @@ int radname_find_less_equal(struct radtree* rt, const uint8_t* d, size_t max,
unsigned int lab, dpos, lpos;
struct radnode* n = rt->root;
uint8_t byte;
- radstrlen_t i;
+ radstrlen_type i;
uint8_t b;
/* empty tree */
diff --git a/usr.sbin/nsd/radtree.h b/usr.sbin/nsd/radtree.h
index 6f54de01641..fdc58e7a903 100644
--- a/usr.sbin/nsd/radtree.h
+++ b/usr.sbin/nsd/radtree.h
@@ -10,7 +10,7 @@ struct radnode;
struct region;
/** length of the binary string */
-typedef uint16_t radstrlen_t;
+typedef uint16_t radstrlen_type;
/**
* The radix tree
@@ -58,7 +58,7 @@ struct radsel {
/** additional string after the selection-byte for this edge. */
uint8_t* str;
/** length of the additional string for this edge */
- radstrlen_t len;
+ radstrlen_type len;
/** node that deals with byte+str */
struct radnode* node;
};
@@ -99,8 +99,8 @@ void radix_tree_delete(struct radtree* rt);
* NULL on failure - duplicate entry.
* On success the new radix node for this element.
*/
-struct radnode* radix_insert(struct radtree* rt, uint8_t* k, radstrlen_t len,
- void* elem);
+struct radnode* radix_insert(struct radtree* rt, uint8_t* k,
+ radstrlen_type len, void* elem);
/**
* Delete element from radix tree.
@@ -117,7 +117,8 @@ void radix_delete(struct radtree* rt, struct radnode* n);
* @param len: length of key.
* @return the radix node or NULL if not found.
*/
-struct radnode* radix_search(struct radtree* rt, uint8_t* k, radstrlen_t len);
+struct radnode* radix_search(struct radtree* rt, uint8_t* k,
+ radstrlen_type len);
/**
* Find radix element in tree, and if not found, find the closest smaller or
@@ -129,7 +130,7 @@ struct radnode* radix_search(struct radtree* rt, uint8_t* k, radstrlen_t len);
* smaller than the smallest key in the tree).
* @return true if exact match, false if no match.
*/
-int radix_find_less_equal(struct radtree* rt, uint8_t* k, radstrlen_t len,
+int radix_find_less_equal(struct radtree* rt, uint8_t* k, radstrlen_type len,
struct radnode** result);
/**
@@ -174,7 +175,7 @@ struct radnode* radix_prev(struct radnode* n);
* @param dname: the domain name to convert, in wireformat.
* @param dlen: length of space for dname.
*/
-void radname_d2r(uint8_t* k, radstrlen_t* len, const uint8_t* dname,
+void radname_d2r(uint8_t* k, radstrlen_type* len, const uint8_t* dname,
size_t dlen);
/**
@@ -184,7 +185,7 @@ void radname_d2r(uint8_t* k, radstrlen_t* len, const uint8_t* dname,
* @param dname: buffer to store domain name into.
* @param dlen: length of dname (including root label).
*/
-void radname_r2d(uint8_t* k, radstrlen_t len, uint8_t* dname, size_t* dlen);
+void radname_r2d(uint8_t* k, radstrlen_type len, uint8_t* dname, size_t* dlen);
/**
* Search the radix tree using a domain name.
@@ -235,10 +236,10 @@ struct radnode* radname_insert(struct radtree* rt, const uint8_t* d,
void radname_delete(struct radtree* rt, const uint8_t* d, size_t max);
/** number of bytes in common in strings */
-radstrlen_t bstr_common_ext(uint8_t* x, radstrlen_t xlen, uint8_t* y,
- radstrlen_t ylen);
+radstrlen_type bstr_common_ext(uint8_t* x, radstrlen_type xlen, uint8_t* y,
+ radstrlen_type ylen);
/** true if one is prefix of the other */
-int bstr_is_prefix_ext(uint8_t* p, radstrlen_t plen, uint8_t* x,
- radstrlen_t xlen);
+int bstr_is_prefix_ext(uint8_t* p, radstrlen_type plen, uint8_t* x,
+ radstrlen_type xlen);
#endif /* RADTREE_H */
diff --git a/usr.sbin/nsd/rbtree.c b/usr.sbin/nsd/rbtree.c
index bc3840e2d6b..5d8cd4cd57a 100644
--- a/usr.sbin/nsd/rbtree.c
+++ b/usr.sbin/nsd/rbtree.c
@@ -17,7 +17,7 @@
#define BLACK 0
#define RED 1
-rbnode_t rbtree_null_node = {
+rbnode_type rbtree_null_node = {
RBTREE_NULL, /* Parent. */
RBTREE_NULL, /* Left. */
RBTREE_NULL, /* Right. */
@@ -25,10 +25,10 @@ rbnode_t rbtree_null_node = {
BLACK /* Color. */
};
-static void rbtree_rotate_left(rbtree_t *rbtree, rbnode_t *node);
-static void rbtree_rotate_right(rbtree_t *rbtree, rbnode_t *node);
-static void rbtree_insert_fixup(rbtree_t *rbtree, rbnode_t *node);
-static void rbtree_delete_fixup(rbtree_t* rbtree, rbnode_t* child, rbnode_t* child_parent);
+static void rbtree_rotate_left(rbtree_type *rbtree, rbnode_type *node);
+static void rbtree_rotate_right(rbtree_type *rbtree, rbnode_type *node);
+static void rbtree_insert_fixup(rbtree_type *rbtree, rbnode_type *node);
+static void rbtree_delete_fixup(rbtree_type* rbtree, rbnode_type* child, rbnode_type* child_parent);
/*
* Creates a new red black tree, initializes and returns a pointer to it.
@@ -36,13 +36,13 @@ static void rbtree_delete_fixup(rbtree_t* rbtree, rbnode_t* child, rbnode_t* chi
* Return NULL on failure.
*
*/
-rbtree_t *
+rbtree_type *
rbtree_create (region_type *region, int (*cmpf)(const void *, const void *))
{
- rbtree_t *rbtree;
+ rbtree_type *rbtree;
/* Allocate memory for it */
- rbtree = (rbtree_t *) region_alloc(region, sizeof(rbtree_t));
+ rbtree = (rbtree_type *) region_alloc(region, sizeof(rbtree_type));
if (!rbtree) {
return NULL;
}
@@ -61,9 +61,9 @@ rbtree_create (region_type *region, int (*cmpf)(const void *, const void *))
*
*/
static void
-rbtree_rotate_left(rbtree_t *rbtree, rbnode_t *node)
+rbtree_rotate_left(rbtree_type *rbtree, rbnode_type *node)
{
- rbnode_t *right = node->right;
+ rbnode_type *right = node->right;
node->right = right->left;
if (right->left != RBTREE_NULL)
right->left->parent = node;
@@ -88,9 +88,9 @@ rbtree_rotate_left(rbtree_t *rbtree, rbnode_t *node)
*
*/
static void
-rbtree_rotate_right(rbtree_t *rbtree, rbnode_t *node)
+rbtree_rotate_right(rbtree_type *rbtree, rbnode_type *node)
{
- rbnode_t *left = node->left;
+ rbnode_type *left = node->left;
node->left = left->right;
if (left->right != RBTREE_NULL)
left->right->parent = node;
@@ -111,9 +111,9 @@ rbtree_rotate_right(rbtree_t *rbtree, rbnode_t *node)
}
static void
-rbtree_insert_fixup(rbtree_t *rbtree, rbnode_t *node)
+rbtree_insert_fixup(rbtree_type *rbtree, rbnode_type *node)
{
- rbnode_t *uncle;
+ rbnode_type *uncle;
/* While not at the root and need fixing... */
while (node != rbtree->root && node->parent->color == RED) {
@@ -180,15 +180,15 @@ rbtree_insert_fixup(rbtree_t *rbtree, rbnode_t *node)
* Returns NULL on failure or the pointer to the newly added node
* otherwise.
*/
-rbnode_t *
-rbtree_insert (rbtree_t *rbtree, rbnode_t *data)
+rbnode_type *
+rbtree_insert (rbtree_type *rbtree, rbnode_type *data)
{
/* XXX Not necessary, but keeps compiler quiet... */
int r = 0;
/* We start at the root of the tree */
- rbnode_t *node = rbtree->root;
- rbnode_t *parent = RBTREE_NULL;
+ rbnode_type *node = rbtree->root;
+ rbnode_type *parent = RBTREE_NULL;
/* Lets find the new parent... */
while (node != RBTREE_NULL) {
@@ -232,10 +232,10 @@ rbtree_insert (rbtree_t *rbtree, rbnode_t *data)
* Searches the red black tree, returns the data if key is found or NULL otherwise.
*
*/
-rbnode_t *
-rbtree_search (rbtree_t *rbtree, const void *key)
+rbnode_type *
+rbtree_search (rbtree_type *rbtree, const void *key)
{
- rbnode_t *node;
+ rbnode_type *node;
if (rbtree_find_less_equal(rbtree, key, &node)) {
return node;
@@ -250,12 +250,12 @@ static void swap_int8(uint8_t* x, uint8_t* y)
uint8_t t = *x; *x = *y; *y = t;
}
-static void swap_np(rbnode_t** x, rbnode_t** y)
+static void swap_np(rbnode_type** x, rbnode_type** y)
{
- rbnode_t* t = *x; *x = *y; *y = t;
+ rbnode_type* t = *x; *x = *y; *y = t;
}
-static void change_parent_ptr(rbtree_t* rbtree, rbnode_t* parent, rbnode_t* old, rbnode_t* new)
+static void change_parent_ptr(rbtree_type* rbtree, rbnode_type* parent, rbnode_type* old, rbnode_type* new)
{
if(parent == RBTREE_NULL)
{
@@ -268,18 +268,18 @@ static void change_parent_ptr(rbtree_t* rbtree, rbnode_t* parent, rbnode_t* old,
if(parent->left == old) parent->left = new;
if(parent->right == old) parent->right = new;
}
-static void change_child_ptr(rbnode_t* child, rbnode_t* old, rbnode_t* new)
+static void change_child_ptr(rbnode_type* child, rbnode_type* old, rbnode_type* new)
{
if(child == RBTREE_NULL) return;
assert(child->parent == old || child->parent == new);
if(child->parent == old) child->parent = new;
}
-rbnode_t*
-rbtree_delete(rbtree_t *rbtree, const void *key)
+rbnode_type*
+rbtree_delete(rbtree_type *rbtree, const void *key)
{
- rbnode_t *to_delete;
- rbnode_t *child;
+ rbnode_type *to_delete;
+ rbnode_type *child;
if((to_delete = rbtree_search(rbtree, key)) == 0) return 0;
rbtree->count--;
@@ -287,11 +287,11 @@ rbtree_delete(rbtree_t *rbtree, const void *key)
if(to_delete->left != RBTREE_NULL && to_delete->right != RBTREE_NULL)
{
/* swap with smallest from right subtree (or largest from left) */
- rbnode_t *smright = to_delete->right;
+ rbnode_type *smright = to_delete->right;
while(smright->left != RBTREE_NULL)
smright = smright->left;
/* swap the smright and to_delete elements in the tree,
- * but the rbnode_t is first part of user data struct
+ * but the rbnode_type is first part of user data struct
* so cannot just swap the keys and data pointers. Instead
* readjust the pointers left,right,parent */
@@ -353,9 +353,9 @@ rbtree_delete(rbtree_t *rbtree, const void *key)
return to_delete;
}
-static void rbtree_delete_fixup(rbtree_t* rbtree, rbnode_t* child, rbnode_t* child_parent)
+static void rbtree_delete_fixup(rbtree_type* rbtree, rbnode_type* child, rbnode_type* child_parent)
{
- rbnode_t* sibling;
+ rbnode_type* sibling;
int go_up = 1;
/* determine sibling to the node that is one-black short */
@@ -457,10 +457,10 @@ static void rbtree_delete_fixup(rbtree_t* rbtree, rbnode_t* child, rbnode_t* chi
}
int
-rbtree_find_less_equal(rbtree_t *rbtree, const void *key, rbnode_t **result)
+rbtree_find_less_equal(rbtree_type *rbtree, const void *key, rbnode_type **result)
{
int r;
- rbnode_t *node;
+ rbnode_type *node;
assert(result);
@@ -492,19 +492,19 @@ rbtree_find_less_equal(rbtree_t *rbtree, const void *key, rbnode_t **result)
* Finds the first element in the red black tree
*
*/
-rbnode_t *
-rbtree_first (rbtree_t *rbtree)
+rbnode_type *
+rbtree_first (rbtree_type *rbtree)
{
- rbnode_t *node;
+ rbnode_type *node;
for (node = rbtree->root; node->left != RBTREE_NULL; node = node->left);
return node;
}
-rbnode_t *
-rbtree_last (rbtree_t *rbtree)
+rbnode_type *
+rbtree_last (rbtree_type *rbtree)
{
- rbnode_t *node;
+ rbnode_type *node;
for (node = rbtree->root; node->right != RBTREE_NULL; node = node->right);
return node;
@@ -514,10 +514,10 @@ rbtree_last (rbtree_t *rbtree)
* Returns the next node...
*
*/
-rbnode_t *
-rbtree_next (rbnode_t *node)
+rbnode_type *
+rbtree_next (rbnode_type *node)
{
- rbnode_t *parent;
+ rbnode_type *parent;
if (node->right != RBTREE_NULL) {
/* One right, then keep on going left... */
@@ -533,10 +533,10 @@ rbtree_next (rbnode_t *node)
return node;
}
-rbnode_t *
-rbtree_previous(rbnode_t *node)
+rbnode_type *
+rbtree_previous(rbnode_type *node)
{
- rbnode_t *parent;
+ rbnode_type *parent;
if (node->left != RBTREE_NULL) {
/* One left, then keep on going right... */
diff --git a/usr.sbin/nsd/rbtree.h b/usr.sbin/nsd/rbtree.h
index a381cf0788f..d6e54862a23 100644
--- a/usr.sbin/nsd/rbtree.h
+++ b/usr.sbin/nsd/rbtree.h
@@ -14,63 +14,63 @@
/*
* This structure must be the first member of the data structure in
- * the rbtree. This allows easy casting between an rbnode_t and the
+ * the rbtree. This allows easy casting between an rbnode_type and the
* user data (poor man's inheritance).
*/
-typedef struct rbnode_t rbnode_t;
-struct rbnode_t {
- rbnode_t *parent;
- rbnode_t *left;
- rbnode_t *right;
- const void *key;
- uint8_t color;
+typedef struct rbnode rbnode_type;
+struct rbnode {
+ rbnode_type *parent;
+ rbnode_type *left;
+ rbnode_type *right;
+ const void *key;
+ uint8_t color;
};
#define RBTREE_NULL &rbtree_null_node
-extern rbnode_t rbtree_null_node;
+extern rbnode_type rbtree_null_node;
-typedef struct rbtree_t rbtree_t;
-struct rbtree_t {
+typedef struct rbtree rbtree_type;
+struct rbtree {
region_type *region;
/* The root of the red-black tree */
- rbnode_t *root;
+ rbnode_type *root;
/* The number of the nodes in the tree */
size_t count;
/* Current node for walks... */
- rbnode_t *_node;
+ rbnode_type *_node;
/* Key compare function. <0,0,>0 like strcmp. Return 0 on two NULL ptrs. */
int (*cmp) (const void *, const void *);
};
/* rbtree.c */
-rbtree_t *rbtree_create(region_type *region, int (*cmpf)(const void *, const void *));
-rbnode_t *rbtree_insert(rbtree_t *rbtree, rbnode_t *data);
+rbtree_type *rbtree_create(region_type *region, int (*cmpf)(const void *, const void *));
+rbnode_type *rbtree_insert(rbtree_type *rbtree, rbnode_type *data);
/* returns node that is now unlinked from the tree. User to delete it.
* returns 0 if node not present */
-rbnode_t *rbtree_delete(rbtree_t *rbtree, const void *key);
-rbnode_t *rbtree_search(rbtree_t *rbtree, const void *key);
+rbnode_type *rbtree_delete(rbtree_type *rbtree, const void *key);
+rbnode_type *rbtree_search(rbtree_type *rbtree, const void *key);
/* returns true if exact match in result. Else result points to <= element,
or NULL if key is smaller than the smallest key. */
-int rbtree_find_less_equal(rbtree_t *rbtree, const void *key, rbnode_t **result);
-rbnode_t *rbtree_first(rbtree_t *rbtree);
-rbnode_t *rbtree_last(rbtree_t *rbtree);
-rbnode_t *rbtree_next(rbnode_t *rbtree);
-rbnode_t *rbtree_previous(rbnode_t *rbtree);
+int rbtree_find_less_equal(rbtree_type *rbtree, const void *key, rbnode_type **result);
+rbnode_type *rbtree_first(rbtree_type *rbtree);
+rbnode_type *rbtree_last(rbtree_type *rbtree);
+rbnode_type *rbtree_next(rbnode_type *rbtree);
+rbnode_type *rbtree_previous(rbnode_type *rbtree);
#define RBTREE_WALK(rbtree, k, d) \
for((rbtree)->_node = rbtree_first(rbtree);\
(rbtree)->_node != RBTREE_NULL && ((k) = (rbtree)->_node->key) && \
((d) = (void *) (rbtree)->_node); (rbtree)->_node = rbtree_next((rbtree)->_node))
-/* call with node=variable of struct* with rbnode_t as first element.
+/* call with node=variable of struct* with rbnode_type as first element.
with type is the type of a pointer to that struct. */
#define RBTREE_FOR(node, type, rbtree) \
for(node=(type)rbtree_first(rbtree); \
- (rbnode_t*)node != RBTREE_NULL; \
- node = (type)rbtree_next((rbnode_t*)node))
+ (rbnode_type*)node != RBTREE_NULL; \
+ node = (type)rbtree_next((rbnode_type*)node))
#endif /* _RBTREE_H_ */
diff --git a/usr.sbin/nsd/remote.c b/usr.sbin/nsd/remote.c
index baa9985389a..f7c88222b68 100644
--- a/usr.sbin/nsd/remote.c
+++ b/usr.sbin/nsd/remote.c
@@ -227,7 +227,7 @@ timeval_subtract(struct timeval* d, const struct timeval* end,
#endif /* BIND8_STATS */
struct daemon_remote*
-daemon_remote_create(nsd_options_t* cfg)
+daemon_remote_create(struct nsd_options* cfg)
{
char* s_cert;
char* s_key;
@@ -483,11 +483,11 @@ add_open(struct daemon_remote* rc, const char* ip, int nr, int noproto_is_err)
}
int
-daemon_remote_open_ports(struct daemon_remote* rc, nsd_options_t* cfg)
+daemon_remote_open_ports(struct daemon_remote* rc, struct nsd_options* cfg)
{
assert(cfg->control_enable && cfg->control_port);
if(cfg->control_interface) {
- ip_address_option_t* p;
+ ip_address_option_type* p;
for(p = cfg->control_interface; p; p = p->next) {
if(!add_open(rc, p->address, cfg->control_port, 1)) {
return 0;
@@ -764,8 +764,8 @@ send_ok(SSL* ssl)
/** get zone argument (if any) or NULL, false on error */
static int
-get_zone_arg(SSL* ssl, xfrd_state_t* xfrd, char* arg,
- zone_options_t** zo)
+get_zone_arg(SSL* ssl, xfrd_state_type* xfrd, char* arg,
+ struct zone_options** zo)
{
const dname_type* dname;
if(!arg[0]) {
@@ -790,7 +790,7 @@ get_zone_arg(SSL* ssl, xfrd_state_t* xfrd, char* arg,
/** do the stop command */
static void
-do_stop(SSL* ssl, xfrd_state_t* xfrd)
+do_stop(SSL* ssl, xfrd_state_type* xfrd)
{
xfrd->need_to_send_shutdown = 1;
@@ -803,7 +803,7 @@ do_stop(SSL* ssl, xfrd_state_t* xfrd)
/** do the log_reopen command, it only needs reload_now */
static void
-do_log_reopen(SSL* ssl, xfrd_state_t* xfrd)
+do_log_reopen(SSL* ssl, xfrd_state_type* xfrd)
{
xfrd_set_reload_now(xfrd);
send_ok(ssl);
@@ -811,9 +811,9 @@ do_log_reopen(SSL* ssl, xfrd_state_t* xfrd)
/** do the reload command */
static void
-do_reload(SSL* ssl, xfrd_state_t* xfrd, char* arg)
+do_reload(SSL* ssl, xfrd_state_type* xfrd, char* arg)
{
- zone_options_t* zo;
+ struct zone_options* zo;
if(!get_zone_arg(ssl, xfrd, arg, &zo))
return;
task_new_check_zonefiles(xfrd->nsd->task[xfrd->nsd->mytask],
@@ -824,9 +824,9 @@ do_reload(SSL* ssl, xfrd_state_t* xfrd, char* arg)
/** do the write command */
static void
-do_write(SSL* ssl, xfrd_state_t* xfrd, char* arg)
+do_write(SSL* ssl, xfrd_state_type* xfrd, char* arg)
{
- zone_options_t* zo;
+ struct zone_options* zo;
if(!get_zone_arg(ssl, xfrd, arg, &zo))
return;
task_new_write_zonefiles(xfrd->nsd->task[xfrd->nsd->mytask],
@@ -837,13 +837,13 @@ do_write(SSL* ssl, xfrd_state_t* xfrd, char* arg)
/** do the notify command */
static void
-do_notify(SSL* ssl, xfrd_state_t* xfrd, char* arg)
+do_notify(SSL* ssl, xfrd_state_type* xfrd, char* arg)
{
- zone_options_t* zo;
+ struct zone_options* zo;
if(!get_zone_arg(ssl, xfrd, arg, &zo))
return;
if(zo) {
- struct notify_zone_t* n = (struct notify_zone_t*)rbtree_search(
+ struct notify_zone* n = (struct notify_zone*)rbtree_search(
xfrd->notify_zones, (const dname_type*)zo->node.key);
if(n) {
xfrd_notify_start(n, xfrd);
@@ -852,8 +852,8 @@ do_notify(SSL* ssl, xfrd_state_t* xfrd, char* arg)
ssl_printf(ssl, "error zone does not have notify\n");
}
} else {
- struct notify_zone_t* n;
- RBTREE_FOR(n, struct notify_zone_t*, xfrd->notify_zones) {
+ struct notify_zone* n;
+ RBTREE_FOR(n, struct notify_zone*, xfrd->notify_zones) {
xfrd_notify_start(n, xfrd);
}
send_ok(ssl);
@@ -862,14 +862,14 @@ do_notify(SSL* ssl, xfrd_state_t* xfrd, char* arg)
/** do the transfer command */
static void
-do_transfer(SSL* ssl, xfrd_state_t* xfrd, char* arg)
+do_transfer(SSL* ssl, xfrd_state_type* xfrd, char* arg)
{
- zone_options_t* zo;
- xfrd_zone_t* zone;
+ struct zone_options* zo;
+ xfrd_zone_type* zone;
if(!get_zone_arg(ssl, xfrd, arg, &zo))
return;
if(zo) {
- zone = (xfrd_zone_t*)rbtree_search(xfrd->zones, (const
+ zone = (xfrd_zone_type*)rbtree_search(xfrd->zones, (const
dname_type*)zo->node.key);
if(zone) {
xfrd_handle_notify_and_start_xfr(zone, NULL);
@@ -878,7 +878,7 @@ do_transfer(SSL* ssl, xfrd_state_t* xfrd, char* arg)
ssl_printf(ssl, "error zone not slave\n");
}
} else {
- RBTREE_FOR(zone, xfrd_zone_t*, xfrd->zones) {
+ RBTREE_FOR(zone, xfrd_zone_type*, xfrd->zones) {
xfrd_handle_notify_and_start_xfr(zone, NULL);
}
ssl_printf(ssl, "ok, %u zones\n", (unsigned)xfrd->zones->count);
@@ -887,7 +887,7 @@ do_transfer(SSL* ssl, xfrd_state_t* xfrd, char* arg)
/** force transfer a zone */
static void
-force_transfer_zone(xfrd_zone_t* zone)
+force_transfer_zone(xfrd_zone_type* zone)
{
/* if in TCP transaction, stop it immediately. */
if(zone->tcp_conn != -1)
@@ -903,14 +903,14 @@ force_transfer_zone(xfrd_zone_t* zone)
/** do the force transfer command */
static void
-do_force_transfer(SSL* ssl, xfrd_state_t* xfrd, char* arg)
+do_force_transfer(SSL* ssl, xfrd_state_type* xfrd, char* arg)
{
- zone_options_t* zo;
- xfrd_zone_t* zone;
+ struct zone_options* zo;
+ xfrd_zone_type* zone;
if(!get_zone_arg(ssl, xfrd, arg, &zo))
return;
if(zo) {
- zone = (xfrd_zone_t*)rbtree_search(xfrd->zones, (const
+ zone = (xfrd_zone_type*)rbtree_search(xfrd->zones, (const
dname_type*)zo->node.key);
if(zone) {
force_transfer_zone(zone);
@@ -919,7 +919,7 @@ do_force_transfer(SSL* ssl, xfrd_state_t* xfrd, char* arg)
ssl_printf(ssl, "error zone not slave\n");
}
} else {
- RBTREE_FOR(zone, xfrd_zone_t*, xfrd->zones) {
+ RBTREE_FOR(zone, xfrd_zone_type*, xfrd->zones) {
force_transfer_zone(zone);
}
ssl_printf(ssl, "ok, %u zones\n", (unsigned)xfrd->zones->count);
@@ -927,7 +927,7 @@ do_force_transfer(SSL* ssl, xfrd_state_t* xfrd, char* arg)
}
static int
-print_soa_status(SSL* ssl, const char* str, xfrd_soa_t* soa, time_t acq)
+print_soa_status(SSL* ssl, const char* str, xfrd_soa_type* soa, time_t acq)
{
if(acq) {
if(!ssl_printf(ssl, " %s: \"%u since %s\"\n", str,
@@ -942,11 +942,11 @@ print_soa_status(SSL* ssl, const char* str, xfrd_soa_t* soa, time_t acq)
/** print zonestatus for one domain */
static int
-print_zonestatus(SSL* ssl, xfrd_state_t* xfrd, zone_options_t* zo)
+print_zonestatus(SSL* ssl, xfrd_state_type* xfrd, struct zone_options* zo)
{
- xfrd_zone_t* xz = (xfrd_zone_t*)rbtree_search(xfrd->zones,
+ xfrd_zone_type* xz = (xfrd_zone_type*)rbtree_search(xfrd->zones,
(const dname_type*)zo->node.key);
- struct notify_zone_t* nz = (struct notify_zone_t*)rbtree_search(
+ struct notify_zone* nz = (struct notify_zone*)rbtree_search(
xfrd->notify_zones, (const dname_type*)zo->node.key);
if(!ssl_printf(ssl, "zone: %s\n", zo->name))
return 0;
@@ -1012,14 +1012,14 @@ print_zonestatus(SSL* ssl, xfrd_state_t* xfrd, zone_options_t* zo)
/** do the zonestatus command */
static void
-do_zonestatus(SSL* ssl, xfrd_state_t* xfrd, char* arg)
+do_zonestatus(SSL* ssl, xfrd_state_type* xfrd, char* arg)
{
- zone_options_t* zo;
+ struct zone_options* zo;
if(!get_zone_arg(ssl, xfrd, arg, &zo))
return;
if(zo) (void)print_zonestatus(ssl, xfrd, zo);
else {
- RBTREE_FOR(zo, zone_options_t*,
+ RBTREE_FOR(zo, struct zone_options*,
xfrd->nsd->options->zone_options) {
if(!print_zonestatus(ssl, xfrd, zo))
return;
@@ -1067,7 +1067,7 @@ find_arg2(SSL* ssl, char* arg, char** arg2)
/** do the status command */
static void
-do_status(SSL* ssl, xfrd_state_t* xfrd)
+do_status(SSL* ssl, xfrd_state_type* xfrd)
{
if(!ssl_printf(ssl, "version: %s\n", PACKAGE_VERSION))
return;
@@ -1107,7 +1107,7 @@ do_stats(struct daemon_remote* rc, int peek, struct rc_state* rs)
/** see if we have more zonestatistics entries and it has to be incremented */
static void
-zonestat_inc_ifneeded(xfrd_state_t* xfrd)
+zonestat_inc_ifneeded(xfrd_state_type* xfrd)
{
#ifdef USE_ZONE_STATS
if(xfrd->nsd->options->zonestatnames->count != xfrd->zonestat_safe)
@@ -1121,10 +1121,10 @@ zonestat_inc_ifneeded(xfrd_state_t* xfrd)
/** perform the addzone command for one zone */
static int
-perform_addzone(SSL* ssl, xfrd_state_t* xfrd, char* arg)
+perform_addzone(SSL* ssl, xfrd_state_type* xfrd, char* arg)
{
const dname_type* dname;
- zone_options_t* zopt;
+ struct zone_options* zopt;
char* arg2 = NULL;
if(!find_arg2(ssl, arg, &arg2))
return 0;
@@ -1184,10 +1184,10 @@ perform_addzone(SSL* ssl, xfrd_state_t* xfrd, char* arg)
/** perform the delzone command for one zone */
static int
-perform_delzone(SSL* ssl, xfrd_state_t* xfrd, char* arg)
+perform_delzone(SSL* ssl, xfrd_state_type* xfrd, char* arg)
{
const dname_type* dname;
- zone_options_t* zopt;
+ struct zone_options* zopt;
dname = dname_parse(xfrd->region, arg);
if(!dname) {
@@ -1234,7 +1234,7 @@ perform_delzone(SSL* ssl, xfrd_state_t* xfrd, char* arg)
/** do the addzone command */
static void
-do_addzone(SSL* ssl, xfrd_state_t* xfrd, char* arg)
+do_addzone(SSL* ssl, xfrd_state_type* xfrd, char* arg)
{
if(!perform_addzone(ssl, xfrd, arg))
return;
@@ -1243,7 +1243,7 @@ do_addzone(SSL* ssl, xfrd_state_t* xfrd, char* arg)
/** do the delzone command */
static void
-do_delzone(SSL* ssl, xfrd_state_t* xfrd, char* arg)
+do_delzone(SSL* ssl, xfrd_state_type* xfrd, char* arg)
{
if(!perform_delzone(ssl, xfrd, arg))
return;
@@ -1252,7 +1252,7 @@ do_delzone(SSL* ssl, xfrd_state_t* xfrd, char* arg)
/** do the addzones command */
static void
-do_addzones(SSL* ssl, xfrd_state_t* xfrd)
+do_addzones(SSL* ssl, xfrd_state_type* xfrd)
{
char buf[2048];
int num = 0;
@@ -1274,7 +1274,7 @@ do_addzones(SSL* ssl, xfrd_state_t* xfrd)
/** do the delzones command */
static void
-do_delzones(SSL* ssl, xfrd_state_t* xfrd)
+do_delzones(SSL* ssl, xfrd_state_type* xfrd)
{
char buf[2048];
int num = 0;
@@ -1296,7 +1296,7 @@ do_delzones(SSL* ssl, xfrd_state_t* xfrd)
/** remove TSIG key from config and add task so that reload does too */
-static void remove_key(xfrd_state_t* xfrd, const char* kname)
+static void remove_key(xfrd_state_type* xfrd, const char* kname)
{
/* add task before deletion because the name string could be deleted */
task_new_del_key(xfrd->nsd->task[xfrd->nsd->mytask], xfrd->last_task,
@@ -1307,7 +1307,7 @@ static void remove_key(xfrd_state_t* xfrd, const char* kname)
}
/** add TSIG key to config and add task so that reload does too */
-static void add_key(xfrd_state_t* xfrd, key_options_t* k)
+static void add_key(xfrd_state_type* xfrd, struct key_options* k)
{
key_options_add_modify(xfrd->nsd->options, k);
task_new_add_key(xfrd->nsd->task[xfrd->nsd->mytask], xfrd->last_task,
@@ -1316,22 +1316,22 @@ static void add_key(xfrd_state_t* xfrd, key_options_t* k)
}
/** check if keys have changed */
-static void repat_keys(xfrd_state_t* xfrd, nsd_options_t* newopt)
+static void repat_keys(xfrd_state_type* xfrd, struct nsd_options* newopt)
{
- nsd_options_t* oldopt = xfrd->nsd->options;
- key_options_t* k;
+ struct nsd_options* oldopt = xfrd->nsd->options;
+ struct key_options* k;
/* find deleted keys */
- k = (key_options_t*)rbtree_first(oldopt->keys);
- while((rbnode_t*)k != RBTREE_NULL) {
- key_options_t* next = (key_options_t*)rbtree_next(
- (rbnode_t*)k);
+ k = (struct key_options*)rbtree_first(oldopt->keys);
+ while((rbnode_type*)k != RBTREE_NULL) {
+ struct key_options* next = (struct key_options*)rbtree_next(
+ (rbnode_type*)k);
if(!key_options_find(newopt, k->name))
remove_key(xfrd, k->name);
k = next;
}
/* find added or changed keys */
- RBTREE_FOR(k, key_options_t*, newopt->keys) {
- key_options_t* origk = key_options_find(oldopt, k->name);
+ RBTREE_FOR(k, struct key_options*, newopt->keys) {
+ struct key_options* origk = key_options_find(oldopt, k->name);
if(!origk)
add_key(xfrd, k);
else if(!key_options_equal(k, origk))
@@ -1341,7 +1341,7 @@ static void repat_keys(xfrd_state_t* xfrd, nsd_options_t* newopt)
/** find zone given the implicit pattern */
static const dname_type*
-parse_implicit_name(xfrd_state_t* xfrd,const char* pname)
+parse_implicit_name(xfrd_state_type* xfrd,const char* pname)
{
if(strncmp(pname, PATTERN_IMPLICIT_MARKER,
strlen(PATTERN_IMPLICIT_MARKER)) != 0)
@@ -1352,10 +1352,10 @@ parse_implicit_name(xfrd_state_t* xfrd,const char* pname)
/** remove cfgzone and add task so that reload does too */
static void
-remove_cfgzone(xfrd_state_t* xfrd, const char* pname)
+remove_cfgzone(xfrd_state_type* xfrd, const char* pname)
{
/* dname and find the zone for the implicit pattern */
- zone_options_t* zopt = NULL;
+ struct zone_options* zopt = NULL;
const dname_type* dname = parse_implicit_name(xfrd, pname);
if(!dname) {
/* should have a parseable name, but it did not */
@@ -1390,10 +1390,11 @@ remove_cfgzone(xfrd_state_t* xfrd, const char* pname)
/** add cfgzone and add task so that reload does too */
static void
-add_cfgzone(xfrd_state_t* xfrd, const char* pname)
+add_cfgzone(xfrd_state_type* xfrd, const char* pname)
{
/* add to our zonelist */
- zone_options_t* zopt = zone_options_create(xfrd->nsd->options->region);
+ struct zone_options* zopt = zone_options_create(
+ xfrd->nsd->options->region);
if(!zopt)
return;
zopt->part_of_config = 1;
@@ -1423,7 +1424,7 @@ add_cfgzone(xfrd_state_t* xfrd, const char* pname)
/** remove pattern and add task so that reload does too */
static void
-remove_pat(xfrd_state_t* xfrd, const char* name)
+remove_pat(xfrd_state_type* xfrd, const char* name)
{
/* add task before deletion, because name-string could be deleted */
task_new_del_pattern(xfrd->nsd->task[xfrd->nsd->mytask],
@@ -1434,7 +1435,7 @@ remove_pat(xfrd_state_t* xfrd, const char* name)
/** add pattern and add task so that reload does too */
static void
-add_pat(xfrd_state_t* xfrd, pattern_options_t* p)
+add_pat(xfrd_state_type* xfrd, struct pattern_options* p)
{
pattern_options_add_modify(xfrd->nsd->options, p);
task_new_add_pattern(xfrd->nsd->task[xfrd->nsd->mytask],
@@ -1444,17 +1445,17 @@ add_pat(xfrd_state_t* xfrd, pattern_options_t* p)
/** interrupt zones that are using changed or removed patterns */
static void
-repat_interrupt_zones(xfrd_state_t* xfrd, nsd_options_t* newopt)
+repat_interrupt_zones(xfrd_state_type* xfrd, struct nsd_options* newopt)
{
/* if masterlist changed:
* interrupt slave zone (UDP or TCP) transfers.
* slave zones reset master to start of list.
*/
- xfrd_zone_t* xz;
- struct notify_zone_t* nz;
- RBTREE_FOR(xz, xfrd_zone_t*, xfrd->zones) {
- pattern_options_t* oldp = xz->zone_options->pattern;
- pattern_options_t* newp = pattern_options_find(newopt,
+ xfrd_zone_type* xz;
+ struct notify_zone* nz;
+ RBTREE_FOR(xz, xfrd_zone_type*, xfrd->zones) {
+ struct pattern_options* oldp = xz->zone_options->pattern;
+ struct pattern_options* newp = pattern_options_find(newopt,
oldp->pname);
if(!newp || !acl_list_equal(oldp->request_xfr,
newp->request_xfr)) {
@@ -1476,9 +1477,9 @@ repat_interrupt_zones(xfrd_state_t* xfrd, nsd_options_t* newopt)
* interrupt notify that is busy.
* reset notify to start of list. (clear all other reset_notify)
*/
- RBTREE_FOR(nz, struct notify_zone_t*, xfrd->notify_zones) {
- pattern_options_t* oldp = nz->options->pattern;
- pattern_options_t* newp = pattern_options_find(newopt,
+ RBTREE_FOR(nz, struct notify_zone*, xfrd->notify_zones) {
+ struct pattern_options* oldp = nz->options->pattern;
+ struct pattern_options* newp = pattern_options_find(newopt,
oldp->pname);
if(!newp || !acl_list_equal(oldp->notify, newp->notify)) {
/* interrupt notify */
@@ -1498,10 +1499,10 @@ repat_interrupt_zones(xfrd_state_t* xfrd, nsd_options_t* newopt)
/** for notify, after the pattern changes, restart the affected notifies */
static void
-repat_interrupt_notify_start(xfrd_state_t* xfrd)
+repat_interrupt_notify_start(xfrd_state_type* xfrd)
{
- struct notify_zone_t* nz;
- RBTREE_FOR(nz, struct notify_zone_t*, xfrd->notify_zones) {
+ struct notify_zone* nz;
+ RBTREE_FOR(nz, struct notify_zone*, xfrd->notify_zones) {
if(nz->notify_restart) {
if(nz->notify_current)
nz->notify_current = nz->options->pattern->notify;
@@ -1515,7 +1516,7 @@ repat_interrupt_notify_start(xfrd_state_t* xfrd)
/** check if patterns have changed */
static void
-repat_patterns(xfrd_state_t* xfrd, nsd_options_t* newopt)
+repat_patterns(xfrd_state_type* xfrd, struct nsd_options* newopt)
{
/* zones that use changed patterns must have:
* - their AXFR/IXFR interrupted: try again, acl may have changed.
@@ -1523,16 +1524,16 @@ repat_patterns(xfrd_state_t* xfrd, nsd_options_t* newopt)
* keep going. Otherwise, stop xfer and reset TSIG.
* - send NOTIFY reset to start of NOTIFY list (and TSIG reset).
*/
- nsd_options_t* oldopt = xfrd->nsd->options;
- pattern_options_t* p;
+ struct nsd_options* oldopt = xfrd->nsd->options;
+ struct pattern_options* p;
int search_zones = 0;
repat_interrupt_zones(xfrd, newopt);
/* find deleted patterns */
- p = (pattern_options_t*)rbtree_first(oldopt->patterns);
- while((rbnode_t*)p != RBTREE_NULL) {
- pattern_options_t* next = (pattern_options_t*)rbtree_next(
- (rbnode_t*)p);
+ p = (struct pattern_options*)rbtree_first(oldopt->patterns);
+ while((rbnode_type*)p != RBTREE_NULL) {
+ struct pattern_options* next = (struct pattern_options*)
+ rbtree_next((rbnode_type*)p);
if(!pattern_options_find(newopt, p->pname)) {
if(p->implicit) {
/* first remove its zone */
@@ -1544,8 +1545,8 @@ repat_patterns(xfrd_state_t* xfrd, nsd_options_t* newopt)
p = next;
}
/* find added or changed patterns */
- RBTREE_FOR(p, pattern_options_t*, newopt->patterns) {
- pattern_options_t* origp = pattern_options_find(oldopt,
+ RBTREE_FOR(p, struct pattern_options*, newopt->patterns) {
+ struct pattern_options* origp = pattern_options_find(oldopt,
p->pname);
if(!origp) {
/* no zones can use it, no zone_interrupt needed */
@@ -1567,7 +1568,7 @@ repat_patterns(xfrd_state_t* xfrd, nsd_options_t* newopt)
parse_implicit_name(xfrd, p->pname);
if (dname) {
if (newstate == REPAT_SLAVE) {
- zone_options_t* zopt =
+ struct zone_options* zopt =
zone_options_find(
oldopt, dname);
if (zopt) {
@@ -1590,11 +1591,11 @@ repat_patterns(xfrd_state_t* xfrd, nsd_options_t* newopt)
}
}
if (search_zones) {
- zone_options_t* zone_opt;
+ struct zone_options* zone_opt;
/* search in oldopt because 1) it contains zonelist zones,
* and 2) you need oldopt(existing) to call xfrd_init */
- RBTREE_FOR(zone_opt, zone_options_t*, oldopt->zone_options) {
- pattern_options_t* oldp = zone_opt->pattern;
+ RBTREE_FOR(zone_opt, struct zone_options*, oldopt->zone_options) {
+ struct pattern_options* oldp = zone_opt->pattern;
if (!oldp->implicit) {
if (oldp->xfrd_flags == REPAT_SLAVE) {
/* xfrd needs stable reference so get
@@ -1614,7 +1615,7 @@ repat_patterns(xfrd_state_t* xfrd, nsd_options_t* newopt)
/** true if options are different that can be set via repat. */
static int
-repat_options_changed(xfrd_state_t* xfrd, nsd_options_t* newopt)
+repat_options_changed(xfrd_state_type* xfrd, struct nsd_options* newopt)
{
#ifdef RATELIMIT
if(xfrd->nsd->options->rrl_ratelimit != newopt->rrl_ratelimit)
@@ -1631,7 +1632,7 @@ repat_options_changed(xfrd_state_t* xfrd, nsd_options_t* newopt)
/** check if global options have changed */
static void
-repat_options(xfrd_state_t* xfrd, nsd_options_t* newopt)
+repat_options(xfrd_state_type* xfrd, struct nsd_options* newopt)
{
if(repat_options_changed(xfrd, newopt)) {
/* update our options */
@@ -1659,10 +1660,10 @@ print_ssl_cfg_err(void* arg, const char* str)
/** do the repattern command: reread config file and apply keys, patterns */
static void
-do_repattern(SSL* ssl, xfrd_state_t* xfrd)
+do_repattern(SSL* ssl, xfrd_state_type* xfrd)
{
region_type* region = region_create(xalloc, free);
- nsd_options_t* opt;
+ struct nsd_options* opt;
const char* cfgfile = xfrd->nsd->options->configfile;
/* check chroot and configfile, if possible to reread */
@@ -1699,7 +1700,7 @@ do_repattern(SSL* ssl, xfrd_state_t* xfrd)
/** do the serverpid command: printout pid of server process */
static void
-do_serverpid(SSL* ssl, xfrd_state_t* xfrd)
+do_serverpid(SSL* ssl, xfrd_state_type* xfrd)
{
(void)ssl_printf(ssl, "%u\n", (unsigned)xfrd->reload_pid);
}
@@ -2013,7 +2014,7 @@ print_stat_block(SSL* ssl, char* n, char* d, struct nsdst* st)
#ifdef USE_ZONE_STATS
static void
-resize_zonestat(xfrd_state_t* xfrd, size_t num)
+resize_zonestat(xfrd_state_type* xfrd, size_t num)
{
struct nsdst** a = xalloc_array_zero(num, sizeof(struct nsdst*));
if(xfrd->zonestat_clear_num != 0)
@@ -2025,7 +2026,7 @@ resize_zonestat(xfrd_state_t* xfrd, size_t num)
}
static void
-zonestat_print(SSL* ssl, xfrd_state_t* xfrd, int clear)
+zonestat_print(SSL* ssl, xfrd_state_type* xfrd, int clear)
{
struct zonestatname* n;
struct nsdst stat0, stat1;
@@ -2077,10 +2078,10 @@ zonestat_print(SSL* ssl, xfrd_state_t* xfrd, int clear)
#endif /* USE_ZONE_STATS */
static void
-print_stats(SSL* ssl, xfrd_state_t* xfrd, struct timeval* now, int clear)
+print_stats(SSL* ssl, xfrd_state_type* xfrd, struct timeval* now, int clear)
{
size_t i;
- stc_t total = 0;
+ stc_type total = 0;
struct timeval elapsed, uptime;
/* per CPU and total */
@@ -2132,7 +2133,7 @@ print_stats(SSL* ssl, xfrd_state_t* xfrd, struct timeval* now, int clear)
}
static void
-clear_stats(xfrd_state_t* xfrd)
+clear_stats(xfrd_state_type* xfrd)
{
size_t i;
uint64_t dbd = xfrd->nsd->st.db_disk;
diff --git a/usr.sbin/nsd/server.c b/usr.sbin/nsd/server.c
index ae27312fbfc..9018031cd74 100644
--- a/usr.sbin/nsd/server.c
+++ b/usr.sbin/nsd/server.c
@@ -1396,7 +1396,7 @@ parent_send_stats(struct nsd* nsd, int cmdfd)
}
for(i=0; i<nsd->child_count; i++)
if(!write_socket(cmdfd, &nsd->children[i].query_count,
- sizeof(stc_t))) {
+ sizeof(stc_type))) {
log_msg(LOG_ERR, "could not write stats to reload");
return;
}
@@ -1406,7 +1406,7 @@ static void
reload_do_stats(int cmdfd, struct nsd* nsd, udb_ptr* last)
{
struct nsdst s;
- stc_t* p;
+ stc_type* p;
size_t i;
if(block_read(nsd, cmdfd, &s, sizeof(s),
RELOAD_SYNC_TIMEOUT) != sizeof(s)) {
@@ -1415,11 +1415,12 @@ reload_do_stats(int cmdfd, struct nsd* nsd, udb_ptr* last)
}
s.db_disk = (nsd->db->udb?nsd->db->udb->base_size:0);
s.db_mem = region_get_mem(nsd->db->region);
- p = (stc_t*)task_new_stat_info(nsd->task[nsd->mytask], last, &s,
+ p = (stc_type*)task_new_stat_info(nsd->task[nsd->mytask], last, &s,
nsd->child_count);
if(!p) return;
for(i=0; i<nsd->child_count; i++) {
- if(block_read(nsd, cmdfd, p++, sizeof(stc_t), 1)!=sizeof(stc_t))
+ if(block_read(nsd, cmdfd, p++, sizeof(stc_type), 1)!=
+ sizeof(stc_type))
return;
}
}
diff --git a/usr.sbin/nsd/tsig.c b/usr.sbin/nsd/tsig.c
index b58191ce9b8..a7cc66ee184 100644
--- a/usr.sbin/nsd/tsig.c
+++ b/usr.sbin/nsd/tsig.c
@@ -23,11 +23,11 @@ static region_type *tsig_region;
struct tsig_key_table
{
- rbnode_t node; /* by dname */
+ rbnode_type node; /* by dname */
tsig_key_type *key;
};
typedef struct tsig_key_table tsig_key_table_type;
-static rbtree_t *tsig_key_table;
+static rbtree_type *tsig_key_table;
struct tsig_algorithm_table
{
diff --git a/usr.sbin/nsd/udbradtree.c b/usr.sbin/nsd/udbradtree.c
index d9be6b9c255..4452b6ddde1 100644
--- a/usr.sbin/nsd/udbradtree.c
+++ b/usr.sbin/nsd/udbradtree.c
@@ -46,7 +46,8 @@ size_t size_of_lookup_ext(udb_ptr* lookup)
}
/** size needed for a lookup array like this */
-static size_t size_of_lookup_needed(uint16_t capacity, udb_radstrlen_t str_cap)
+static size_t size_of_lookup_needed(uint16_t capacity,
+ udb_radstrlen_type str_cap)
{
return sizeof(struct udb_radarray_d)+ ((size_t)capacity)*(
sizeof(struct udb_radsel_d)+(size_t)str_cap);
@@ -61,7 +62,7 @@ static struct udb_radarray_d* lookup(udb_ptr* n)
}
/** get a length in the lookup array */
-static udb_radstrlen_t lookup_len(udb_ptr* n, unsigned i)
+static udb_radstrlen_type lookup_len(udb_ptr* n, unsigned i)
{
return lookup(n)->array[i].len;
}
@@ -158,9 +159,9 @@ void udb_radix_tree_delete(udb_base* udb, udb_ptr* rt)
* @return false if no prefix found, not even the root "" prefix.
*/
static int udb_radix_find_prefix_node(udb_base* udb, udb_ptr* rt, uint8_t* k,
- udb_radstrlen_t len, udb_ptr* result, udb_radstrlen_t* respos)
+ udb_radstrlen_type len, udb_ptr* result, udb_radstrlen_type* respos)
{
- udb_radstrlen_t pos = 0;
+ udb_radstrlen_type pos = 0;
uint8_t byte;
udb_ptr n;
udb_ptr_new(&n, udb, &RADTREE(rt)->root);
@@ -207,14 +208,15 @@ static int udb_radix_find_prefix_node(udb_base* udb, udb_ptr* rt, uint8_t* k,
}
/** grow the radnode stringcapacity, copy existing elements */
-static int udb_radnode_str_grow(udb_base* udb, udb_ptr* n, udb_radstrlen_t want)
+static int udb_radnode_str_grow(udb_base* udb, udb_ptr* n,
+ udb_radstrlen_type want)
{
unsigned ns = ((unsigned)lookup(n)->str_cap)*2;
unsigned i;
udb_ptr a;
if(want > ns)
ns = want;
- if(ns > 65535) ns = 65535; /* MAX of udb_radstrlen_t range */
+ if(ns > 65535) ns = 65535; /* MAX of udb_radstrlen_type range */
/* if this fails, the tree is still usable */
if(!udb_ptr_alloc_space(&a, udb, udb_chunk_type_radarray,
size_of_lookup_needed(lookup(n)->capacity, ns)))
@@ -280,7 +282,7 @@ static int udb_radnode_array_create(udb_base* udb, udb_ptr* n)
/* create array */
udb_ptr a;
uint16_t cap = 0;
- udb_radstrlen_t len = 0;
+ udb_radstrlen_type len = 0;
if(!udb_ptr_alloc_space(&a, udb, udb_chunk_type_radarray,
size_of_lookup_needed(cap, len)))
return 0;
@@ -297,7 +299,7 @@ static int udb_radnode_array_create(udb_base* udb, udb_ptr* n)
/** make space in radnode for another byte, or longer strings */
static int udb_radnode_array_space(udb_base* udb, udb_ptr* n, uint8_t byte,
- udb_radstrlen_t len)
+ udb_radstrlen_type len)
{
/* is there an array? */
if(RADNODE(n)->lookup.data == 0) {
@@ -389,7 +391,8 @@ static int udb_radnode_array_space(udb_base* udb, udb_ptr* n, uint8_t byte,
}
/** make space for string size */
-static int udb_radnode_str_space(udb_base* udb, udb_ptr* n, udb_radstrlen_t len)
+static int udb_radnode_str_space(udb_base* udb, udb_ptr* n,
+ udb_radstrlen_type len)
{
if(RADNODE(n)->lookup.data == 0) {
return udb_radnode_array_space(udb, n, 0, len);
@@ -404,9 +407,9 @@ static int udb_radnode_str_space(udb_base* udb, udb_ptr* n, udb_radstrlen_t len)
/** copy remainder from prefixes for a split:
* plen: len prefix, l: longer bstring, llen: length of l. */
-static void udb_radsel_prefix_remainder(udb_radstrlen_t plen,
- uint8_t* l, udb_radstrlen_t llen,
- uint8_t* s, udb_radstrlen_t* slen)
+static void udb_radsel_prefix_remainder(udb_radstrlen_type plen,
+ uint8_t* l, udb_radstrlen_type llen,
+ uint8_t* s, udb_radstrlen_type* slen)
{
*slen = llen - plen;
/* assert(*slen <= lookup(n)->str_cap); */
@@ -414,34 +417,34 @@ static void udb_radsel_prefix_remainder(udb_radstrlen_t plen,
}
/** create a prefix in the array strs */
-static void udb_radsel_str_create(uint8_t* s, udb_radstrlen_t* slen,
- uint8_t* k, udb_radstrlen_t pos, udb_radstrlen_t len)
+static void udb_radsel_str_create(uint8_t* s, udb_radstrlen_type* slen,
+ uint8_t* k, udb_radstrlen_type pos, udb_radstrlen_type len)
{
*slen = len-pos;
/* assert(*slen <= lookup(n)->str_cap); */
memmove(s, k+pos, len-pos);
}
-static udb_radstrlen_t
-udb_bstr_common(uint8_t* x, udb_radstrlen_t xlen,
- uint8_t* y, udb_radstrlen_t ylen)
+static udb_radstrlen_type
+udb_bstr_common(uint8_t* x, udb_radstrlen_type xlen,
+ uint8_t* y, udb_radstrlen_type ylen)
{
- assert(sizeof(radstrlen_t) == sizeof(udb_radstrlen_t));
+ assert(sizeof(radstrlen_type) == sizeof(udb_radstrlen_type));
return bstr_common_ext(x, xlen, y, ylen);
}
static int
-udb_bstr_is_prefix(uint8_t* p, udb_radstrlen_t plen,
- uint8_t* x, udb_radstrlen_t xlen)
+udb_bstr_is_prefix(uint8_t* p, udb_radstrlen_type plen,
+ uint8_t* x, udb_radstrlen_type xlen)
{
- assert(sizeof(radstrlen_t) == sizeof(udb_radstrlen_t));
+ assert(sizeof(radstrlen_type) == sizeof(udb_radstrlen_type));
return bstr_is_prefix_ext(p, plen, x, xlen);
}
/** grow array space for byte N after a string, (but if string shorter) */
static int
udb_radnode_array_space_strremain(udb_base* udb, udb_ptr* n,
- uint8_t* str, udb_radstrlen_t len, udb_radstrlen_t pos)
+ uint8_t* str, udb_radstrlen_type len, udb_radstrlen_type pos)
{
assert(pos < len);
/* shift by one char because it goes in lookup array */
@@ -461,13 +464,13 @@ udb_radnode_array_space_strremain(udb_base* udb, udb_ptr* n,
* @return false on alloc failure, no changes made.
*/
static int udb_radsel_split(udb_base* udb, udb_ptr* n, uint8_t idx, uint8_t* k,
- udb_radstrlen_t pos, udb_radstrlen_t len, udb_ptr* add)
+ udb_radstrlen_type pos, udb_radstrlen_type len, udb_ptr* add)
{
uint8_t* addstr = k+pos;
- udb_radstrlen_t addlen = len-pos;
+ udb_radstrlen_type addlen = len-pos;
if(udb_bstr_is_prefix(addstr, addlen, lookup_string(n, idx),
lookup_len(n, idx))) {
- udb_radstrlen_t split_len = 0;
+ udb_radstrlen_type split_len = 0;
/* 'add' is a prefix of r.node */
/* also for empty addstr */
/* set it up so that the 'add' node has r.node as child */
@@ -511,7 +514,7 @@ static int udb_radsel_split(udb_base* udb, udb_ptr* n, uint8_t idx, uint8_t* k,
}
} else if(udb_bstr_is_prefix(lookup_string(n, idx), lookup_len(n, idx),
addstr, addlen)) {
- udb_radstrlen_t split_len = 0;
+ udb_radstrlen_type split_len = 0;
udb_ptr rnode;
/* r.node is a prefix of 'add' */
/* set it up so that the 'r.node' has 'add' as child */
@@ -556,7 +559,7 @@ static int udb_radsel_split(udb_base* udb, udb_ptr* n, uint8_t idx, uint8_t* k,
* We do this so that r.node stays the same pointer for its
* key name. */
udb_ptr com, rnode;
- udb_radstrlen_t common_len = udb_bstr_common(
+ udb_radstrlen_type common_len = udb_bstr_common(
lookup_string(n, idx), lookup_len(n, idx),
addstr, addlen);
assert(common_len < lookup_len(n, idx));
@@ -633,11 +636,11 @@ static int udb_radsel_split(udb_base* udb, udb_ptr* n, uint8_t idx, uint8_t* k,
uint64_t* result_data = NULL;
udb_void udb_radix_insert(udb_base* udb, udb_ptr* rt, uint8_t* k,
- udb_radstrlen_t len, udb_ptr* elem, udb_ptr* result)
+ udb_radstrlen_type len, udb_ptr* elem, udb_ptr* result)
{
udb_void ret;
udb_ptr add, n; /* type udb_radnode_d */
- udb_radstrlen_t pos = 0;
+ udb_radstrlen_type pos = 0;
/* create new element to add */
if(!udb_ptr_alloc_space(&add, udb, udb_chunk_type_radnode,
sizeof(struct udb_radnode_d))) {
@@ -778,7 +781,7 @@ udb_radnode_cleanup_onechild(udb_base* udb, udb_ptr* n)
{
udb_ptr par, child;
uint8_t pidx = RADNODE(n)->pidx;
- radstrlen_t joinlen;
+ radstrlen_type joinlen;
udb_ptr_new(&par, udb, &RADNODE(n)->parent);
udb_ptr_new(&child, udb, &lookup(n)->array[0].node);
@@ -819,7 +822,7 @@ udb_radnode_cleanup_onechild(udb_base* udb, udb_ptr* n)
/** reduce the size of radarray, does a malloc */
static int
udb_radarray_reduce(udb_base* udb, udb_ptr* n, uint16_t cap,
- udb_radstrlen_t strcap)
+ udb_radstrlen_type strcap)
{
udb_ptr a;
unsigned i;
@@ -849,10 +852,10 @@ udb_radarray_reduce(udb_base* udb, udb_ptr* n, uint16_t cap,
}
/** find the max stringlength in the array */
-static udb_radstrlen_t udb_radarray_max_len(udb_ptr* n)
+static udb_radstrlen_type udb_radarray_max_len(udb_ptr* n)
{
unsigned i;
- udb_radstrlen_t maxlen = 0;
+ udb_radstrlen_type maxlen = 0;
for(i=0; i<lookup(n)->len; i++) {
if(lookup(n)->array[i].node.data &&
lookup(n)->array[i].len > maxlen)
@@ -865,7 +868,7 @@ static udb_radstrlen_t udb_radarray_max_len(udb_ptr* n)
static int
udb_radarray_reduce_if_needed(udb_base* udb, udb_ptr* n)
{
- udb_radstrlen_t maxlen = udb_radarray_max_len(n);
+ udb_radstrlen_type maxlen = udb_radarray_max_len(n);
if((lookup(n)->len <= lookup(n)->capacity/2 || lookup(n)->len == 0
|| maxlen <= lookup(n)->str_cap/2 || maxlen == 0) &&
(lookup(n)->len != lookup(n)->capacity ||
@@ -1053,12 +1056,12 @@ void udb_radix_delete(udb_base* udb, udb_ptr* rt, udb_ptr* n)
}
}
-udb_void udb_radix_search(udb_ptr* rt, uint8_t* k, udb_radstrlen_t len)
+udb_void udb_radix_search(udb_ptr* rt, uint8_t* k, udb_radstrlen_type len)
{
/* since we only perform reads, and no udb_mallocs or udb_frees
* we know the pointers stay the same */
struct udb_radnode_d* n;
- udb_radstrlen_t pos = 0;
+ udb_radstrlen_type pos = 0;
uint8_t byte;
void* base = *rt->base;
@@ -1206,10 +1209,10 @@ static int udb_ret_self_or_prev(udb_base* udb, udb_ptr* n, udb_ptr* result)
int udb_radix_find_less_equal(udb_base* udb, udb_ptr* rt, uint8_t* k,
- udb_radstrlen_t len, udb_ptr* result)
+ udb_radstrlen_type len, udb_ptr* result)
{
udb_ptr n;
- udb_radstrlen_t pos = 0;
+ udb_radstrlen_type pos = 0;
uint8_t byte;
int r;
/* set result to NULL */
@@ -1411,7 +1414,7 @@ udb_void udb_radname_insert(udb_base* udb, udb_ptr* rt, const uint8_t* dname,
size_t dlen, udb_ptr* elem, udb_ptr* result)
{
uint8_t k[300];
- radstrlen_t klen = (radstrlen_t)sizeof(k);
+ radstrlen_type klen = (radstrlen_type)sizeof(k);
radname_d2r(k, &klen, dname, dlen);
return udb_radix_insert(udb, rt, k, klen, elem, result);
}
@@ -1421,7 +1424,7 @@ int udb_radname_search(udb_base* udb, udb_ptr* rt, const uint8_t* dname,
{
udb_void r;
uint8_t k[300];
- radstrlen_t klen = (radstrlen_t)sizeof(k);
+ radstrlen_type klen = (radstrlen_type)sizeof(k);
radname_d2r(k, &klen, dname, dlen);
r = udb_radix_search(rt, k, klen);
udb_ptr_init(result, udb);
diff --git a/usr.sbin/nsd/udbradtree.h b/usr.sbin/nsd/udbradtree.h
index 2732e73d022..b8e6186ae8b 100644
--- a/usr.sbin/nsd/udbradtree.h
+++ b/usr.sbin/nsd/udbradtree.h
@@ -9,7 +9,7 @@
struct udb_radnode;
/** length of the binary string */
-typedef uint16_t udb_radstrlen_t;
+typedef uint16_t udb_radstrlen_type;
/**
* The radix tree
@@ -54,7 +54,7 @@ struct udb_radnode_d {
struct udb_radsel_d {
/** length of the additional string for this edge,
* additional string after the selection-byte for this edge.*/
- udb_radstrlen_t len;
+ udb_radstrlen_type len;
/** padding for non64bit compilers to 64bit boundaries, to make
* the udb file more portable, without this the file would work
* on the system it is created on (which is what we promise), but
@@ -78,7 +78,7 @@ struct udb_radarray_d {
/** capacity of the lookup array (can be larger than length) */
uint16_t capacity;
/** space capacity of for every string */
- udb_radstrlen_t str_cap;
+ udb_radstrlen_type str_cap;
/** padding to 64bit alignment, just in case compiler goes mad */
uint16_t padding;
/** the elements (allocated contiguously after this structure) */
@@ -123,7 +123,7 @@ void udb_radix_tree_delete(udb_base* udb, udb_ptr* rt);
* On success the new radix node for this element (udb_radnode_d).
*/
udb_void udb_radix_insert(udb_base* udb, udb_ptr* rt, uint8_t* k,
- udb_radstrlen_t len, udb_ptr* elem, udb_ptr* result);
+ udb_radstrlen_type len, udb_ptr* elem, udb_ptr* result);
/**
* Delete element from radix tree.
@@ -142,7 +142,7 @@ void udb_radix_delete(udb_base* udb, udb_ptr* rt, udb_ptr* n);
* @return the radix node or NULL if not found. type udb_radnode_d
*/
udb_void udb_radix_search(udb_ptr* rt, uint8_t* k,
- udb_radstrlen_t len);
+ udb_radstrlen_type len);
/**
* Find radix element in tree, and if not found, find the closest smaller or
@@ -157,7 +157,7 @@ udb_void udb_radix_search(udb_ptr* rt, uint8_t* k,
* @return true if exact match, false if no match.
*/
int udb_radix_find_less_equal(udb_base* udb, udb_ptr* rt, uint8_t* k,
- udb_radstrlen_t len, udb_ptr* result);
+ udb_radstrlen_type len, udb_ptr* result);
/**
* Return the first (smallest) element in the tree.
diff --git a/usr.sbin/nsd/udbzone.h b/usr.sbin/nsd/udbzone.h
index 8169857a795..8c5c5325581 100644
--- a/usr.sbin/nsd/udbzone.h
+++ b/usr.sbin/nsd/udbzone.h
@@ -46,7 +46,7 @@ struct zone_d {
/** number of RRs in the zone */
uint64_t rr_count;
/** the length of the zone name */
- udb_radstrlen_t namelen;
+ udb_radstrlen_type namelen;
/** if the zone is expired */
uint8_t expired;
/** if the zone has been changed by AXFR */
@@ -62,7 +62,7 @@ struct domain_d {
/** the list of rrsets for this name, single linked */
udb_rel_ptr rrsets;
/** length of the domain name */
- udb_radstrlen_t namelen;
+ udb_radstrlen_type namelen;
/** the domain (wire uncompressed) name in DNS format */
uint8_t name[0];
};
diff --git a/usr.sbin/nsd/util.c b/usr.sbin/nsd/util.c
index db3d7ceddce..458f0946643 100644
--- a/usr.sbin/nsd/util.c
+++ b/usr.sbin/nsd/util.c
@@ -487,6 +487,10 @@ strtoserial(const char* nptr, const char** endptr)
case '7':
case '8':
case '9':
+ if((i*10)/10 != i)
+ /* number too large, return i
+ * with *endptr != 0 as a failure*/
+ return i;
i *= 10;
i += (**endptr - '0');
break;
diff --git a/usr.sbin/nsd/xfrd-disk.c b/usr.sbin/nsd/xfrd-disk.c
index a86240d4a57..33f1dcac248 100644
--- a/usr.sbin/nsd/xfrd-disk.c
+++ b/usr.sbin/nsd/xfrd-disk.c
@@ -88,7 +88,7 @@ xfrd_read_check_str(FILE* in, const char* str)
static int
xfrd_read_state_soa(FILE* in, const char* id_acquired,
- const char* id, xfrd_soa_t* soa, time_t* soatime)
+ const char* id, xfrd_soa_type* soa, time_t* soatime)
{
char *p;
@@ -188,13 +188,13 @@ xfrd_read_state(struct xfrd_state* xfrd)
for(i=0; i<numzones; i++) {
char *p;
- xfrd_zone_t* zone;
+ xfrd_zone_type* zone;
const dname_type* dname;
uint32_t state, masnum, nextmas, round_num, timeout, backoff;
- xfrd_soa_t soa_nsd_read, soa_disk_read, soa_notified_read;
+ xfrd_soa_type soa_nsd_read, soa_disk_read, soa_notified_read;
time_t soa_nsd_acquired_read,
soa_disk_acquired_read, soa_notified_acquired_read;
- xfrd_soa_t incoming_soa;
+ xfrd_soa_type incoming_soa;
time_t incoming_acquired;
if(nsd.signal_hint_shutdown) {
@@ -237,7 +237,7 @@ xfrd_read_state(struct xfrd_state* xfrd)
return;
}
- zone = (xfrd_zone_t*)rbtree_search(xfrd->zones, dname);
+ zone = (xfrd_zone_type*)rbtree_search(xfrd->zones, dname);
if(!zone) {
DEBUG(DEBUG_XFRD,1, (LOG_INFO, "xfrd: state file has info for not configured zone %s", p));
continue;
@@ -407,7 +407,7 @@ static void xfrd_write_dname(FILE* out, uint8_t* dname)
static void
xfrd_write_state_soa(FILE* out, const char* id,
- xfrd_soa_t* soa, time_t soatime, const dname_type* ATTR_UNUSED(apex))
+ xfrd_soa_type* soa, time_t soatime, const dname_type* ATTR_UNUSED(apex))
{
fprintf(out, "\t%s_acquired: %d", id, (int)soatime);
if(!soatime) {
@@ -440,7 +440,7 @@ xfrd_write_state_soa(FILE* out, const char* id,
void
xfrd_write_state(struct xfrd_state* xfrd)
{
- rbnode_t* p;
+ rbnode_type* p;
const char* statefile = xfrd->nsd->options->xfrdfile;
FILE *out;
time_t now = xfrd_time();
@@ -477,7 +477,7 @@ xfrd_write_state(struct xfrd_state* xfrd)
fprintf(out, "\n");
for(p = rbtree_first(xfrd->zones); p && p!=RBTREE_NULL; p=rbtree_next(p))
{
- xfrd_zone_t* zone = (xfrd_zone_t*)p;
+ xfrd_zone_type* zone = (xfrd_zone_type*)p;
fprintf(out, "zone: \tname: %s\n", zone->apex_str);
fprintf(out, "\tstate: %d", (int)zone->state);
fprintf(out, " # %s", zone->state==xfrd_zone_ok?"OK":(
diff --git a/usr.sbin/nsd/xfrd-notify.c b/usr.sbin/nsd/xfrd-notify.c
index eb55c507d7d..918b32142c9 100644
--- a/usr.sbin/nsd/xfrd-notify.c
+++ b/usr.sbin/nsd/xfrd-notify.c
@@ -20,23 +20,23 @@
#define XFRD_NOTIFY_RETRY_TIMOUT 15 /* seconds between retries sending NOTIFY */
/* start sending notifies */
-static void notify_enable(struct notify_zone_t* zone,
+static void notify_enable(struct notify_zone* zone,
struct xfrd_soa* new_soa);
/* setup the notify active state */
-static void setup_notify_active(struct notify_zone_t* zone);
+static void setup_notify_active(struct notify_zone* zone);
/* returns if the notify send is done for the notify_current acl */
-static int xfrd_handle_notify_reply(struct notify_zone_t* zone, buffer_type* packet);
+static int xfrd_handle_notify_reply(struct notify_zone* zone, buffer_type* packet);
/* handle zone notify send */
static void xfrd_handle_notify_send(int fd, short event, void* arg);
-static void xfrd_notify_next(struct notify_zone_t* zone);
+static void xfrd_notify_next(struct notify_zone* zone);
-static void xfrd_notify_send_udp(struct notify_zone_t* zone, buffer_type* packet);
+static void xfrd_notify_send_udp(struct notify_zone* zone, buffer_type* packet);
static void
-notify_send_disable(struct notify_zone_t* zone)
+notify_send_disable(struct notify_zone* zone)
{
zone->notify_send_enable = 0;
event_del(&zone->notify_send_handler);
@@ -46,7 +46,7 @@ notify_send_disable(struct notify_zone_t* zone)
}
void
-notify_disable(struct notify_zone_t* zone)
+notify_disable(struct notify_zone* zone)
{
zone->notify_current = 0;
/* if added, then remove */
@@ -58,7 +58,7 @@ notify_disable(struct notify_zone_t* zone)
/* find next waiting and needy zone */
while(xfrd->notify_waiting_first) {
/* snip off */
- struct notify_zone_t* wz = xfrd->notify_waiting_first;
+ struct notify_zone* wz = xfrd->notify_waiting_first;
assert(wz->is_waiting);
wz->is_waiting = 0;
xfrd->notify_waiting_first = wz->waiting_next;
@@ -80,11 +80,12 @@ notify_disable(struct notify_zone_t* zone)
}
void
-init_notify_send(rbtree_t* tree, region_type* region, zone_options_t* options)
+init_notify_send(rbtree_type* tree, region_type* region,
+ struct zone_options* options)
{
- struct notify_zone_t* not = (struct notify_zone_t*)
- region_alloc(region, sizeof(struct notify_zone_t));
- memset(not, 0, sizeof(struct notify_zone_t));
+ struct notify_zone* not = (struct notify_zone*)
+ region_alloc(region, sizeof(struct notify_zone));
+ memset(not, 0, sizeof(struct notify_zone));
not->apex = options->node.key;
not->apex_str = options->name;
not->node.key = not->apex;
@@ -100,14 +101,14 @@ init_notify_send(rbtree_t* tree, region_type* region, zone_options_t* options)
not->notify_send_enable = 0;
tsig_create_record_custom(&not->notify_tsig, NULL, 0, 0, 4);
not->notify_current = 0;
- rbtree_insert(tree, (rbnode_t*)not);
+ rbtree_insert(tree, (rbnode_type*)not);
}
void
-xfrd_del_notify(xfrd_state_t* xfrd, const dname_type* dname)
+xfrd_del_notify(xfrd_state_type* xfrd, const dname_type* dname)
{
/* find it */
- struct notify_zone_t* not = (struct notify_zone_t*)rbtree_delete(
+ struct notify_zone* not = (struct notify_zone*)rbtree_delete(
xfrd->notify_zones, dname);
if(!not)
return;
@@ -132,13 +133,13 @@ xfrd_del_notify(xfrd_state_t* xfrd, const dname_type* dname)
tsig_delete_record(&not->notify_tsig, NULL);
/* free it */
- region_recycle(xfrd->region, not->current_soa, sizeof(xfrd_soa_t));
+ region_recycle(xfrd->region, not->current_soa, sizeof(xfrd_soa_type));
/* the apex is recycled when the zone_options.node.key is removed */
region_recycle(xfrd->region, not, sizeof(*not));
}
static int
-xfrd_handle_notify_reply(struct notify_zone_t* zone, buffer_type* packet)
+xfrd_handle_notify_reply(struct notify_zone* zone, buffer_type* packet)
{
if((OPCODE(packet) != OPCODE_NOTIFY) ||
(QR(packet) == 0)) {
@@ -167,7 +168,7 @@ xfrd_handle_notify_reply(struct notify_zone_t* zone, buffer_type* packet)
}
static void
-xfrd_notify_next(struct notify_zone_t* zone)
+xfrd_notify_next(struct notify_zone* zone)
{
/* advance to next in acl */
zone->notify_current = zone->notify_current->next;
@@ -182,7 +183,7 @@ xfrd_notify_next(struct notify_zone_t* zone)
}
static void
-xfrd_notify_send_udp(struct notify_zone_t* zone, buffer_type* packet)
+xfrd_notify_send_udp(struct notify_zone* zone, buffer_type* packet)
{
int fd;
if(zone->notify_send_enable) {
@@ -235,7 +236,7 @@ xfrd_notify_send_udp(struct notify_zone_t* zone, buffer_type* packet)
static void
xfrd_handle_notify_send(int fd, short event, void* arg)
{
- struct notify_zone_t* zone = (struct notify_zone_t*)arg;
+ struct notify_zone* zone = (struct notify_zone*)arg;
buffer_type* packet = xfrd_get_temp_buffer();
assert(zone->notify_current);
if(zone->is_waiting) {
@@ -272,7 +273,7 @@ xfrd_handle_notify_send(int fd, short event, void* arg)
}
static void
-setup_notify_active(struct notify_zone_t* zone)
+setup_notify_active(struct notify_zone* zone)
{
zone->notify_retry = 0;
zone->notify_current = zone->options->pattern->notify;
@@ -291,16 +292,16 @@ setup_notify_active(struct notify_zone_t* zone)
}
static void
-notify_enable(struct notify_zone_t* zone, struct xfrd_soa* new_soa)
+notify_enable(struct notify_zone* zone, struct xfrd_soa* new_soa)
{
if(!zone->options->pattern->notify) {
return; /* no notify acl, nothing to do */
}
if(new_soa == NULL)
- memset(zone->current_soa, 0, sizeof(xfrd_soa_t));
+ memset(zone->current_soa, 0, sizeof(xfrd_soa_type));
else
- memcpy(zone->current_soa, new_soa, sizeof(xfrd_soa_t));
+ memcpy(zone->current_soa, new_soa, sizeof(xfrd_soa_type));
if(zone->is_waiting)
return;
@@ -325,22 +326,22 @@ notify_enable(struct notify_zone_t* zone, struct xfrd_soa* new_soa)
}
void
-xfrd_notify_start(struct notify_zone_t* zone, struct xfrd_state* xfrd)
+xfrd_notify_start(struct notify_zone* zone, struct xfrd_state* xfrd)
{
- xfrd_zone_t* xz;
+ xfrd_zone_type* xz;
if(zone->is_waiting || zone->notify_send_enable)
return;
- xz = (xfrd_zone_t*)rbtree_search(xfrd->zones, zone->apex);
+ xz = (xfrd_zone_type*)rbtree_search(xfrd->zones, zone->apex);
if(xz && xz->soa_nsd_acquired)
notify_enable(zone, &xz->soa_nsd);
else notify_enable(zone, NULL);
}
void
-xfrd_send_notify(rbtree_t* tree, const dname_type* apex, struct xfrd_soa* new_soa)
+xfrd_send_notify(rbtree_type* tree, const dname_type* apex, struct xfrd_soa* new_soa)
{
/* lookup the zone */
- struct notify_zone_t* zone = (struct notify_zone_t*)
+ struct notify_zone* zone = (struct notify_zone*)
rbtree_search(tree, apex);
assert(zone);
if(zone->notify_send_enable)
@@ -350,11 +351,11 @@ xfrd_send_notify(rbtree_t* tree, const dname_type* apex, struct xfrd_soa* new_so
}
void
-notify_handle_master_zone_soainfo(rbtree_t* tree,
+notify_handle_master_zone_soainfo(rbtree_type* tree,
const dname_type* apex, struct xfrd_soa* new_soa)
{
/* lookup the zone */
- struct notify_zone_t* zone = (struct notify_zone_t*)
+ struct notify_zone* zone = (struct notify_zone*)
rbtree_search(tree, apex);
if(!zone) return; /* got SOAINFO but zone was deleted meanwhile */
@@ -368,10 +369,10 @@ notify_handle_master_zone_soainfo(rbtree_t* tree,
}
void
-close_notify_fds(rbtree_t* tree)
+close_notify_fds(rbtree_type* tree)
{
- struct notify_zone_t* zone;
- RBTREE_FOR(zone, struct notify_zone_t*, tree)
+ struct notify_zone* zone;
+ RBTREE_FOR(zone, struct notify_zone*, tree)
{
if(zone->notify_send_enable)
notify_send_disable(zone);
diff --git a/usr.sbin/nsd/xfrd-notify.h b/usr.sbin/nsd/xfrd-notify.h
index acda34308f3..153dca5129b 100644
--- a/usr.sbin/nsd/xfrd-notify.h
+++ b/usr.sbin/nsd/xfrd-notify.h
@@ -36,8 +36,8 @@ struct xfrd_state;
/**
* This struct keeps track of outbound notifies for a zone.
*/
-struct notify_zone_t {
- rbnode_t node;
+struct notify_zone {
+ rbnode_type node;
/* name of the zone */
const dname_type* apex;
const char* apex_str;
@@ -59,30 +59,30 @@ struct notify_zone_t {
/* is this notify waiting for a socket? */
uint8_t is_waiting;
/* the double linked waiting list for the udp sockets */
- struct notify_zone_t* waiting_next;
- struct notify_zone_t* waiting_prev;
+ struct notify_zone* waiting_next;
+ struct notify_zone* waiting_prev;
};
/* initialise outgoing notifies */
-void init_notify_send(rbtree_t* tree, region_type* region,
+void init_notify_send(rbtree_type* tree, region_type* region,
struct zone_options* options);
/* delete notify zone */
void xfrd_del_notify(struct xfrd_state* xfrd, const dname_type* dname);
/* send notifications to all in the notify list */
-void xfrd_send_notify(rbtree_t* tree, const struct dname* apex,
+void xfrd_send_notify(rbtree_type* tree, const struct dname* apex,
struct xfrd_soa* new_soa);
/* start notifications, if not started already (does not clobber SOA) */
-void xfrd_notify_start(struct notify_zone_t* zone, struct xfrd_state* xfrd);
+void xfrd_notify_start(struct notify_zone* zone, struct xfrd_state* xfrd);
/* handle soa update notify for a master zone. newsoa can be NULL.
Makes sure that the soa (serial) has changed. Or drops notify. */
-void notify_handle_master_zone_soainfo(rbtree_t* tree,
+void notify_handle_master_zone_soainfo(rbtree_type* tree,
const dname_type* apex, struct xfrd_soa* new_soa);
/* close fds in use for notification sending */
-void close_notify_fds(rbtree_t* tree);
+void close_notify_fds(rbtree_type* tree);
/* stop send of notify */
-void notify_disable(struct notify_zone_t* zone);
+void notify_disable(struct notify_zone* zone);
#endif /* XFRD_NOTIFY_H */
diff --git a/usr.sbin/nsd/xfrd-tcp.c b/usr.sbin/nsd/xfrd-tcp.c
index 506b2520589..70eef515b58 100644
--- a/usr.sbin/nsd/xfrd-tcp.c
+++ b/usr.sbin/nsd/xfrd-tcp.c
@@ -47,11 +47,12 @@ xfrd_pipe_cmp(const void* a, const void* b)
return (uintptr_t)x < (uintptr_t)y ? -1 : 1;
}
-xfrd_tcp_set_t* xfrd_tcp_set_create(struct region* region)
+struct xfrd_tcp_set* xfrd_tcp_set_create(struct region* region)
{
int i;
- xfrd_tcp_set_t* tcp_set = region_alloc(region, sizeof(xfrd_tcp_set_t));
- memset(tcp_set, 0, sizeof(xfrd_tcp_set_t));
+ struct xfrd_tcp_set* tcp_set = region_alloc(region,
+ sizeof(struct xfrd_tcp_set));
+ memset(tcp_set, 0, sizeof(struct xfrd_tcp_set));
tcp_set->tcp_count = 0;
tcp_set->tcp_waiting_first = 0;
tcp_set->tcp_waiting_last = 0;
@@ -99,10 +100,10 @@ xfrd_setup_packet(buffer_type* packet,
static socklen_t
#ifdef INET6
-xfrd_acl_sockaddr(acl_options_t* acl, unsigned int port,
+xfrd_acl_sockaddr(acl_options_type* acl, unsigned int port,
struct sockaddr_storage *sck)
#else
-xfrd_acl_sockaddr(acl_options_t* acl, unsigned int port,
+xfrd_acl_sockaddr(acl_options_type* acl, unsigned int port,
struct sockaddr_in *sck, const char* fromto)
#endif /* INET6 */
{
@@ -135,9 +136,9 @@ INET6.", fromto, acl->ip_address_spec);
socklen_t
#ifdef INET6
-xfrd_acl_sockaddr_to(acl_options_t* acl, struct sockaddr_storage *to)
+xfrd_acl_sockaddr_to(acl_options_type* acl, struct sockaddr_storage *to)
#else
-xfrd_acl_sockaddr_to(acl_options_t* acl, struct sockaddr_in *to)
+xfrd_acl_sockaddr_to(acl_options_type* acl, struct sockaddr_in *to)
#endif /* INET6 */
{
unsigned int port = acl->port?acl->port:(unsigned)atoi(TCP_PORT);
@@ -150,9 +151,9 @@ xfrd_acl_sockaddr_to(acl_options_t* acl, struct sockaddr_in *to)
socklen_t
#ifdef INET6
-xfrd_acl_sockaddr_frm(acl_options_t* acl, struct sockaddr_storage *frm)
+xfrd_acl_sockaddr_frm(acl_options_type* acl, struct sockaddr_storage *frm)
#else
-xfrd_acl_sockaddr_frm(acl_options_t* acl, struct sockaddr_in *frm)
+xfrd_acl_sockaddr_frm(acl_options_type* acl, struct sockaddr_in *frm)
#endif /* INET6 */
{
unsigned int port = acl->port?acl->port:0;
@@ -193,12 +194,12 @@ xfrd_write_soa_buffer(struct buffer* packet,
buffer_write_u16_at(packet, rdlength_pos, rdlength);
}
-xfrd_tcp_t*
+struct xfrd_tcp*
xfrd_tcp_create(region_type* region, size_t bufsize)
{
- xfrd_tcp_t* tcp_state = (xfrd_tcp_t*)region_alloc(
- region, sizeof(xfrd_tcp_t));
- memset(tcp_state, 0, sizeof(xfrd_tcp_t));
+ struct xfrd_tcp* tcp_state = (struct xfrd_tcp*)region_alloc(
+ region, sizeof(struct xfrd_tcp));
+ memset(tcp_state, 0, sizeof(struct xfrd_tcp));
tcp_state->packet = buffer_create(region, bufsize);
tcp_state->fd = -1;
@@ -206,9 +207,9 @@ xfrd_tcp_create(region_type* region, size_t bufsize)
}
static struct xfrd_tcp_pipeline*
-pipeline_find(xfrd_tcp_set_t* set, xfrd_zone_t* zone)
+pipeline_find(struct xfrd_tcp_set* set, xfrd_zone_type* zone)
{
- rbnode_t* sme = NULL;
+ rbnode_type* sme = NULL;
struct xfrd_tcp_pipeline* r;
/* smaller buf than a full pipeline with 64kb ID array, only need
* the front part with the key info, this front part contains the
@@ -243,7 +244,7 @@ pipeline_find(xfrd_tcp_set_t* set, xfrd_zone_t* zone)
/* remove zone from tcp waiting list */
static void
-tcp_zone_waiting_list_popfirst(xfrd_tcp_set_t* set, xfrd_zone_t* zone)
+tcp_zone_waiting_list_popfirst(struct xfrd_tcp_set* set, xfrd_zone_type* zone)
{
assert(zone->tcp_waiting);
set->tcp_waiting_first = zone->tcp_waiting_next;
@@ -256,7 +257,7 @@ tcp_zone_waiting_list_popfirst(xfrd_tcp_set_t* set, xfrd_zone_t* zone)
/* remove zone from tcp pipe write-wait list */
static void
-tcp_pipe_sendlist_remove(struct xfrd_tcp_pipeline* tp, xfrd_zone_t* zone)
+tcp_pipe_sendlist_remove(struct xfrd_tcp_pipeline* tp, xfrd_zone_type* zone)
{
if(zone->in_tcp_send) {
if(zone->tcp_send_prev)
@@ -271,7 +272,7 @@ tcp_pipe_sendlist_remove(struct xfrd_tcp_pipeline* tp, xfrd_zone_t* zone)
/* remove first from write-wait list */
static void
-tcp_pipe_sendlist_popfirst(struct xfrd_tcp_pipeline* tp, xfrd_zone_t* zone)
+tcp_pipe_sendlist_popfirst(struct xfrd_tcp_pipeline* tp, xfrd_zone_type* zone)
{
tp->tcp_send_first = zone->tcp_send_next;
if(tp->tcp_send_first)
@@ -282,7 +283,7 @@ tcp_pipe_sendlist_popfirst(struct xfrd_tcp_pipeline* tp, xfrd_zone_t* zone)
/* remove zone from tcp pipe ID map */
static void
-tcp_pipe_id_remove(struct xfrd_tcp_pipeline* tp, xfrd_zone_t* zone)
+tcp_pipe_id_remove(struct xfrd_tcp_pipeline* tp, xfrd_zone_type* zone)
{
assert(tp->num_unused < ID_PIPE_NUM && tp->num_unused >= 0);
assert(tp->id[zone->query_id] == zone);
@@ -305,7 +306,7 @@ xfrd_tcp_pipe_stop(struct xfrd_tcp_pipeline* tp)
/* these could use different lists and go to a different nextmaster*/
for(i=0; i<ID_PIPE_NUM; i++) {
if(tp->id[i] && tp->id[i] != TCP_NULL_SKIP) {
- xfrd_zone_t* zone = tp->id[i];
+ xfrd_zone_type* zone = tp->id[i];
conn = zone->tcp_conn;
zone->tcp_conn = -1;
zone->tcp_waiting = 0;
@@ -364,8 +365,8 @@ xfrd_handle_tcp_pipe(int ATTR_UNUSED(fd), short event, void* arg)
/* add a zone to the pipeline, it starts to want to write its query */
static void
-pipeline_setup_new_zone(xfrd_tcp_set_t* set, struct xfrd_tcp_pipeline* tp,
- xfrd_zone_t* zone)
+pipeline_setup_new_zone(struct xfrd_tcp_set* set, struct xfrd_tcp_pipeline* tp,
+ xfrd_zone_type* zone)
{
/* assign the ID */
int idx;
@@ -398,7 +399,7 @@ pipeline_setup_new_zone(xfrd_tcp_set_t* set, struct xfrd_tcp_pipeline* tp,
}
void
-xfrd_tcp_obtain(xfrd_tcp_set_t* set, xfrd_zone_t* zone)
+xfrd_tcp_obtain(struct xfrd_tcp_set* set, xfrd_zone_type* zone)
{
struct xfrd_tcp_pipeline* tp;
assert(zone->tcp_conn == -1);
@@ -484,8 +485,8 @@ xfrd_tcp_obtain(xfrd_tcp_set_t* set, xfrd_zone_t* zone)
}
int
-xfrd_tcp_open(xfrd_tcp_set_t* set, struct xfrd_tcp_pipeline* tp,
- xfrd_zone_t* zone)
+xfrd_tcp_open(struct xfrd_tcp_set* set, struct xfrd_tcp_pipeline* tp,
+ xfrd_zone_type* zone)
{
int fd, family, conn;
struct timeval tv;
@@ -521,7 +522,10 @@ xfrd_tcp_open(xfrd_tcp_set_t* set, struct xfrd_tcp_pipeline* tp,
}
fd = socket(family, SOCK_STREAM, IPPROTO_TCP);
if(fd == -1) {
- log_msg(LOG_ERR, "xfrd: %s cannot create tcp socket: %s",
+ /* squelch 'Address family not supported by protocol' at low
+ * verbosity levels */
+ if(errno != EAFNOSUPPORT || verbosity > 2)
+ log_msg(LOG_ERR, "xfrd: %s cannot create tcp socket: %s",
zone->master->ip_address_spec, strerror(errno));
xfrd_set_refresh_now(zone);
return 0;
@@ -583,9 +587,9 @@ xfrd_tcp_open(xfrd_tcp_set_t* set, struct xfrd_tcp_pipeline* tp,
}
void
-xfrd_tcp_setup_write_packet(struct xfrd_tcp_pipeline* tp, xfrd_zone_t* zone)
+xfrd_tcp_setup_write_packet(struct xfrd_tcp_pipeline* tp, xfrd_zone_type* zone)
{
- xfrd_tcp_t* tcp = tp->tcp_w;
+ struct xfrd_tcp* tcp = tp->tcp_w;
assert(zone->tcp_conn != -1);
assert(zone->tcp_waiting == 0);
/* start AXFR or IXFR for the zone */
@@ -625,14 +629,14 @@ xfrd_tcp_setup_write_packet(struct xfrd_tcp_pipeline* tp, xfrd_zone_t* zone)
}
static void
-tcp_conn_ready_for_reading(xfrd_tcp_t* tcp)
+tcp_conn_ready_for_reading(struct xfrd_tcp* tcp)
{
tcp->total_bytes = 0;
tcp->msglen = 0;
buffer_clear(tcp->packet);
}
-int conn_write(xfrd_tcp_t* tcp)
+int conn_write(struct xfrd_tcp* tcp)
{
ssize_t sent;
@@ -686,10 +690,10 @@ int conn_write(xfrd_tcp_t* tcp)
}
void
-xfrd_tcp_write(struct xfrd_tcp_pipeline* tp, xfrd_zone_t* zone)
+xfrd_tcp_write(struct xfrd_tcp_pipeline* tp, xfrd_zone_type* zone)
{
int ret;
- xfrd_tcp_t* tcp = tp->tcp_w;
+ struct xfrd_tcp* tcp = tp->tcp_w;
assert(zone->tcp_conn != -1);
assert(zone == tp->tcp_send_first);
/* see if for non-established connection, there is a connect error */
@@ -752,7 +756,7 @@ xfrd_tcp_write(struct xfrd_tcp_pipeline* tp, xfrd_zone_t* zone)
}
int
-conn_read(xfrd_tcp_t* tcp)
+conn_read(struct xfrd_tcp* tcp)
{
ssize_t received;
/* receive leading packet length bytes */
@@ -831,8 +835,8 @@ conn_read(xfrd_tcp_t* tcp)
void
xfrd_tcp_read(struct xfrd_tcp_pipeline* tp)
{
- xfrd_zone_t* zone;
- xfrd_tcp_t* tcp = tp->tcp_r;
+ xfrd_zone_type* zone;
+ struct xfrd_tcp* tcp = tp->tcp_r;
int ret;
enum xfrd_packet_result pkt_result;
@@ -906,7 +910,7 @@ xfrd_tcp_read(struct xfrd_tcp_pipeline* tp)
}
void
-xfrd_tcp_release(xfrd_tcp_set_t* set, xfrd_zone_t* zone)
+xfrd_tcp_release(struct xfrd_tcp_set* set, xfrd_zone_type* zone)
{
int conn = zone->tcp_conn;
struct xfrd_tcp_pipeline* tp = set->tcp_state[conn];
@@ -955,7 +959,7 @@ xfrd_tcp_release(xfrd_tcp_set_t* set, xfrd_zone_t* zone)
}
void
-xfrd_tcp_pipe_release(xfrd_tcp_set_t* set, struct xfrd_tcp_pipeline* tp,
+xfrd_tcp_pipe_release(struct xfrd_tcp_set* set, struct xfrd_tcp_pipeline* tp,
int conn)
{
DEBUG(DEBUG_XFRD,1, (LOG_INFO, "xfrd: tcp pipe released"));
@@ -980,7 +984,7 @@ xfrd_tcp_pipe_release(xfrd_tcp_set_t* set, struct xfrd_tcp_pipeline* tp,
int i;
/* pop first waiting process */
- xfrd_zone_t* zone = set->tcp_waiting_first;
+ xfrd_zone_type* zone = set->tcp_waiting_first;
/* start it */
assert(zone->tcp_conn == -1);
zone->tcp_conn = conn;
diff --git a/usr.sbin/nsd/xfrd-tcp.h b/usr.sbin/nsd/xfrd-tcp.h
index ac3f9dc5aab..fd6918768d9 100644
--- a/usr.sbin/nsd/xfrd-tcp.h
+++ b/usr.sbin/nsd/xfrd-tcp.h
@@ -21,8 +21,8 @@ struct dname;
struct acl_options;
struct xfrd_tcp_pipeline;
-typedef struct xfrd_tcp xfrd_tcp_t;
-typedef struct xfrd_tcp_set xfrd_tcp_set_t;
+typedef struct xfrd_tcp xfrd_tcp_type;
+typedef struct xfrd_tcp_set xfrd_tcp_set_type;
/*
* A set of xfrd tcp connections.
*/
@@ -34,7 +34,7 @@ struct xfrd_tcp_set {
/* TCP timeout. */
int tcp_timeout;
/* rbtree with pipelines sorted by master */
- rbtree_t* pipetree;
+ rbtree_type* pipetree;
/* double linked list of zones waiting for a TCP connection */
struct xfrd_zone *tcp_waiting_first, *tcp_waiting_last;
};
@@ -78,7 +78,7 @@ struct xfrd_tcp {
*/
struct xfrd_tcp_pipeline {
/* the rbtree node, sorted by IP and nr of unused queries */
- rbnode_t node;
+ rbnode_type node;
/* destination IP address */
#ifdef INET6
struct sockaddr_storage ip;
@@ -99,10 +99,10 @@ struct xfrd_tcp_pipeline {
struct event handler;
/* the tcp connection to use for reading */
- xfrd_tcp_t* tcp_r;
+ struct xfrd_tcp* tcp_r;
/* the tcp connection to use for writing, if it is done successfully,
* then the first zone from the sendlist can be removed. */
- xfrd_tcp_t* tcp_w;
+ struct xfrd_tcp* tcp_w;
/* once a byte has been written, handshake complete */
int connection_established;
@@ -125,22 +125,23 @@ struct xfrd_tcp_pipeline {
};
/* create set of tcp connections */
-xfrd_tcp_set_t* xfrd_tcp_set_create(struct region* region);
+struct xfrd_tcp_set* xfrd_tcp_set_create(struct region* region);
/* init tcp state */
-xfrd_tcp_t* xfrd_tcp_create(struct region* region, size_t bufsize);
+struct xfrd_tcp* xfrd_tcp_create(struct region* region, size_t bufsize);
/* obtain tcp connection for a zone (or wait) */
-void xfrd_tcp_obtain(xfrd_tcp_set_t* set, struct xfrd_zone* zone);
+void xfrd_tcp_obtain(struct xfrd_tcp_set* set, struct xfrd_zone* zone);
/* release tcp connection for a zone (starts waiting) */
-void xfrd_tcp_release(xfrd_tcp_set_t* set, struct xfrd_zone* zone);
+void xfrd_tcp_release(struct xfrd_tcp_set* set, struct xfrd_zone* zone);
/* release tcp pipe entirely (does not stop the zones inside it) */
-void xfrd_tcp_pipe_release(xfrd_tcp_set_t* set, struct xfrd_tcp_pipeline* tp,
- int conn);
+void xfrd_tcp_pipe_release(struct xfrd_tcp_set* set,
+ struct xfrd_tcp_pipeline* tp, int conn);
/* use tcp connection to start xfr */
void xfrd_tcp_setup_write_packet(struct xfrd_tcp_pipeline* tp,
struct xfrd_zone* zone);
/* initialize tcp_state for a zone. Opens the connection. true on success.*/
-int xfrd_tcp_open(xfrd_tcp_set_t* set, struct xfrd_tcp_pipeline* tp, struct xfrd_zone* zone);
+int xfrd_tcp_open(struct xfrd_tcp_set* set, struct xfrd_tcp_pipeline* tp,
+ struct xfrd_zone* zone);
/* read data from tcp, maybe partial read */
void xfrd_tcp_read(struct xfrd_tcp_pipeline* tp);
/* write data to tcp, maybe a partial write */
@@ -157,7 +158,7 @@ void xfrd_handle_tcp_pipe(int fd, short event, void* arg);
* On first call, make sure total_bytes = 0, msglen=0, buffer_clear().
* and the packet and fd need to be set.
*/
-int conn_read(xfrd_tcp_t* conn);
+int conn_read(struct xfrd_tcp* conn);
/*
* Write to a stream connection (size16)+packet.
* return value is
@@ -165,7 +166,7 @@ int conn_read(xfrd_tcp_t* conn);
* On first call, make sure total_bytes=0, msglen=buffer_limit(),
* buffer_flipped(). packet and fd need to be set.
*/
-int conn_write(xfrd_tcp_t* conn);
+int conn_write(struct xfrd_tcp* conn);
/* setup DNS packet for a query of this type */
void xfrd_setup_packet(struct buffer* packet,
diff --git a/usr.sbin/nsd/xfrd.c b/usr.sbin/nsd/xfrd.c
index 415602f014b..810ee3e2954 100644
--- a/usr.sbin/nsd/xfrd.c
+++ b/usr.sbin/nsd/xfrd.c
@@ -42,7 +42,7 @@
* was lost, and need waitpid to remove their process entry. */
/* the daemon state */
-xfrd_state_t* xfrd = 0;
+xfrd_state_type* xfrd = 0;
/* main xfrd loop */
static void xfrd_main(void);
@@ -56,16 +56,18 @@ static void xfrd_init_zones(void);
static void xfrd_receive_soa(int socket, int shortsoa);
/* handle incoming notification message. soa can be NULL. true if transfer needed. */
-static int xfrd_handle_incoming_notify(xfrd_zone_t* zone, xfrd_soa_t* soa);
+static int xfrd_handle_incoming_notify(xfrd_zone_type* zone,
+ xfrd_soa_type* soa);
/* call with buffer just after the soa dname. returns 0 on error. */
-static int xfrd_parse_soa_info(buffer_type* packet, xfrd_soa_t* soa);
+static int xfrd_parse_soa_info(buffer_type* packet, xfrd_soa_type* soa);
/* set the zone state to a new state (takes care of expiry messages) */
-static void xfrd_set_zone_state(xfrd_zone_t* zone, enum xfrd_zone_state new_zone_state);
+static void xfrd_set_zone_state(xfrd_zone_type* zone,
+ enum xfrd_zone_state new_zone_state);
/* set timer for retry amount (depends on zone_state) */
-static void xfrd_set_timer_retry(xfrd_zone_t* zone);
+static void xfrd_set_timer_retry(xfrd_zone_type* zone);
/* set timer for refresh timeout (depends on zone_state) */
-static void xfrd_set_timer_refresh(xfrd_zone_t* zone);
+static void xfrd_set_timer_refresh(xfrd_zone_type* zone);
/* set reload timeout */
static void xfrd_set_reload_timeout(void);
@@ -75,15 +77,15 @@ static void xfrd_handle_reload(int fd, short event, void* arg);
static void xfrd_handle_child_timer(int fd, short event, void* arg);
/* send ixfr request, returns fd of connection to read on */
-static int xfrd_send_ixfr_request_udp(xfrd_zone_t* zone);
+static int xfrd_send_ixfr_request_udp(xfrd_zone_type* zone);
/* obtain udp socket slot */
-static void xfrd_udp_obtain(xfrd_zone_t* zone);
+static void xfrd_udp_obtain(xfrd_zone_type* zone);
/* read data via udp */
-static void xfrd_udp_read(xfrd_zone_t* zone);
+static void xfrd_udp_read(xfrd_zone_type* zone);
/* find master by notify number */
-static int find_same_master_notify(xfrd_zone_t* zone, int acl_num_nfy);
+static int find_same_master_notify(xfrd_zone_type* zone, int acl_num_nfy);
/* set the write timer to activate */
static void xfrd_write_timer_set(void);
@@ -122,8 +124,8 @@ xfrd_init(int socket, struct nsd* nsd, int shortsoa, int reload_active,
region = region_create_custom(xalloc, free, DEFAULT_CHUNK_SIZE,
DEFAULT_LARGE_OBJECT_SIZE, DEFAULT_INITIAL_CLEANUP_SIZE, 1);
- xfrd = (xfrd_state_t*)region_alloc(region, sizeof(xfrd_state_t));
- memset(xfrd, 0, sizeof(xfrd_state_t));
+ xfrd = (xfrd_state_type*)region_alloc(region, sizeof(xfrd_state_type));
+ memset(xfrd, 0, sizeof(xfrd_state_type));
xfrd->region = region;
xfrd->xfrd_start_time = time(0);
xfrd->event_base = nsd_child_event_base();
@@ -221,7 +223,7 @@ xfrd_init(int socket, struct nsd* nsd, int shortsoa, int reload_active,
static void
xfrd_process_activated(void)
{
- xfrd_zone_t* zone;
+ xfrd_zone_type* zone;
while((zone = xfrd->activated_first)) {
DEBUG(DEBUG_XFRD,1, (LOG_INFO, "xfrd zone %s activation",
zone->apex_str));
@@ -314,7 +316,7 @@ xfrd_main(void)
static void
xfrd_shutdown()
{
- xfrd_zone_t* zone;
+ xfrd_zone_type* zone;
DEBUG(DEBUG_XFRD,1, (LOG_INFO, "xfrd shutdown"));
event_del(&xfrd->ipc_handler);
@@ -336,7 +338,7 @@ xfrd_shutdown()
daemon_remote_close(xfrd->nsd->rc); /* close sockets of rc */
#endif
/* close sockets */
- RBTREE_FOR(zone, xfrd_zone_t*, xfrd->zones)
+ RBTREE_FOR(zone, xfrd_zone_type*, xfrd->zones)
{
if(zone->event_added) {
event_del(&zone->zone_handler);
@@ -369,7 +371,7 @@ xfrd_shutdown()
* to clean them out */
/* unlink xfr files for running transfers */
- RBTREE_FOR(zone, xfrd_zone_t*, xfrd->zones)
+ RBTREE_FOR(zone, xfrd_zone_type*, xfrd->zones)
{
if(zone->msg_seq_nr)
xfrd_unlink_xfrfile(xfrd->nsd, zone->xfrfilenumber);
@@ -400,11 +402,12 @@ xfrd_clean_pending_tasks(struct nsd* nsd, udb_base* u)
}
void
-xfrd_init_slave_zone(xfrd_state_t* xfrd, zone_options_t* zone_opt)
+xfrd_init_slave_zone(xfrd_state_type* xfrd, struct zone_options* zone_opt)
{
- xfrd_zone_t *xzone;
- xzone = (xfrd_zone_t*)region_alloc(xfrd->region, sizeof(xfrd_zone_t));
- memset(xzone, 0, sizeof(xfrd_zone_t));
+ xfrd_zone_type *xzone;
+ xzone = (xfrd_zone_type*)region_alloc(xfrd->region,
+ sizeof(xfrd_zone_type));
+ memset(xzone, 0, sizeof(xfrd_zone_type));
xzone->apex = zone_opt->node.key;
xzone->apex_str = zone_opt->name;
xzone->state = xfrd_zone_refreshing;
@@ -443,13 +446,13 @@ xfrd_init_slave_zone(xfrd_state_t* xfrd, zone_options_t* zone_opt)
xfrd_set_refresh_now(xzone);
xzone->node.key = xzone->apex;
- rbtree_insert(xfrd->zones, (rbnode_t*)xzone);
+ rbtree_insert(xfrd->zones, (rbnode_type*)xzone);
}
static void
xfrd_init_zones()
{
- zone_options_t *zone_opt;
+ struct zone_options *zone_opt;
assert(xfrd->zones == 0);
xfrd->zones = rbtree_create(xfrd->region,
@@ -457,7 +460,7 @@ xfrd_init_zones()
xfrd->notify_zones = rbtree_create(xfrd->region,
(int (*)(const void *, const void *)) dname_compare);
- RBTREE_FOR(zone_opt, zone_options_t*, xfrd->nsd->options->zone_options)
+ RBTREE_FOR(zone_opt, struct zone_options*, xfrd->nsd->options->zone_options)
{
DEBUG(DEBUG_XFRD,1, (LOG_INFO, "xfrd: adding %s zone",
zone_opt->name));
@@ -478,12 +481,12 @@ xfrd_init_zones()
static void
xfrd_process_soa_info_task(struct task_list_d* task)
{
- xfrd_soa_t soa;
- xfrd_soa_t* soa_ptr = &soa;
- xfrd_zone_t* zone;
+ xfrd_soa_type soa;
+ xfrd_soa_type* soa_ptr = &soa;
+ xfrd_zone_type* zone;
DEBUG(DEBUG_IPC,1, (LOG_INFO, "xfrd: process SOAINFO %s",
dname_to_string(task->zname, 0)));
- zone = (xfrd_zone_t*)rbtree_search(xfrd->zones, task->zname);
+ zone = (xfrd_zone_type*)rbtree_search(xfrd->zones, task->zname);
if(task->size <= sizeof(struct task_list_d)+dname_total_size(
task->zname)+sizeof(uint32_t)*6 + sizeof(uint8_t)*2) {
/* NSD has zone without any info */
@@ -540,12 +543,12 @@ xfrd_receive_soa(int socket, int shortsoa)
sig_atomic_t cmd;
struct udb_base* xtask = xfrd->nsd->task[xfrd->nsd->mytask];
udb_ptr last_task, t;
- xfrd_zone_t* zone;
+ xfrd_zone_type* zone;
if(!shortsoa) {
/* put all expired zones into mytask */
udb_ptr_init(&last_task, xtask);
- RBTREE_FOR(zone, xfrd_zone_t*, xfrd->zones) {
+ RBTREE_FOR(zone, xfrd_zone_type*, xfrd->zones) {
if(zone->state == xfrd_zone_expired) {
task_new_expire(xtask, &last_task, zone->apex, 1);
}
@@ -605,7 +608,7 @@ xfrd_receive_soa(int socket, int shortsoa)
/* for shortsoa version, do expire later */
/* if expire notifications, put in my task and
* schedule a reload to make sure they are processed */
- RBTREE_FOR(zone, xfrd_zone_t*, xfrd->zones) {
+ RBTREE_FOR(zone, xfrd_zone_type*, xfrd->zones) {
if(zone->state == xfrd_zone_expired) {
xfrd_send_expire_notification(zone);
}
@@ -621,7 +624,7 @@ xfrd_reopen_logfile(void)
}
void
-xfrd_deactivate_zone(xfrd_zone_t* z)
+xfrd_deactivate_zone(xfrd_zone_type* z)
{
if(z->is_activated) {
/* delete from activated list */
@@ -635,9 +638,9 @@ xfrd_deactivate_zone(xfrd_zone_t* z)
}
void
-xfrd_del_slave_zone(xfrd_state_t* xfrd, const dname_type* dname)
+xfrd_del_slave_zone(xfrd_state_type* xfrd, const dname_type* dname)
{
- xfrd_zone_t* z = (xfrd_zone_t*)rbtree_delete(xfrd->zones, dname);
+ xfrd_zone_type* z = (xfrd_zone_type*)rbtree_delete(xfrd->zones, dname);
if(!z) return;
/* io */
@@ -691,7 +694,7 @@ xfrd_free_namedb(struct nsd* nsd)
}
static void
-xfrd_set_timer_refresh(xfrd_zone_t* zone)
+xfrd_set_timer_refresh(xfrd_zone_type* zone)
{
time_t set_refresh;
time_t set_expire;
@@ -722,7 +725,7 @@ xfrd_set_timer_refresh(xfrd_zone_t* zone)
}
static void
-xfrd_set_timer_retry(xfrd_zone_t* zone)
+xfrd_set_timer_retry(xfrd_zone_type* zone)
{
time_t set_retry;
int mult;
@@ -782,7 +785,7 @@ xfrd_set_timer_retry(xfrd_zone_t* zone)
void
xfrd_handle_zone(int ATTR_UNUSED(fd), short event, void* arg)
{
- xfrd_zone_t* zone = (xfrd_zone_t*)arg;
+ xfrd_zone_type* zone = (xfrd_zone_type*)arg;
if(zone->tcp_conn != -1) {
if(event == 0) /* activated, but already in TCP, nothing to do*/
@@ -846,7 +849,7 @@ xfrd_handle_zone(int ATTR_UNUSED(fd), short event, void* arg)
}
void
-xfrd_make_request(xfrd_zone_t* zone)
+xfrd_make_request(xfrd_zone_type* zone)
{
if(zone->next_master != -1) {
/* we are told to use this next master */
@@ -954,7 +957,7 @@ xfrd_make_request(xfrd_zone_t* zone)
}
static void
-xfrd_udp_obtain(xfrd_zone_t* zone)
+xfrd_udp_obtain(xfrd_zone_type* zone)
{
assert(zone->udp_waiting == 0);
if(zone->tcp_conn != -1) {
@@ -1005,7 +1008,7 @@ xfrd_time()
}
void
-xfrd_copy_soa(xfrd_soa_t* soa, rr_type* rr)
+xfrd_copy_soa(xfrd_soa_type* soa, rr_type* rr)
{
const uint8_t* rr_ns_wire = dname_name(domain_dname(rdata_atom_domain(rr->rdatas[0])));
uint8_t rr_ns_len = domain_dname(rdata_atom_domain(rr->rdatas[0]))->name_size;
@@ -1043,7 +1046,7 @@ xfrd_copy_soa(xfrd_soa_t* soa, rr_type* rr)
}
static void
-xfrd_set_zone_state(xfrd_zone_t* zone, enum xfrd_zone_state s)
+xfrd_set_zone_state(xfrd_zone_type* zone, enum xfrd_zone_state s)
{
if(s != zone->state) {
enum xfrd_zone_state old = zone->state;
@@ -1056,7 +1059,7 @@ xfrd_set_zone_state(xfrd_zone_t* zone, enum xfrd_zone_state s)
}
void
-xfrd_set_refresh_now(xfrd_zone_t* zone)
+xfrd_set_refresh_now(xfrd_zone_type* zone)
{
DEBUG(DEBUG_XFRD,1, (LOG_INFO, "xfrd zone %s is activated, state %d",
zone->apex_str, zone->state));
@@ -1072,7 +1075,7 @@ xfrd_set_refresh_now(xfrd_zone_t* zone)
}
void
-xfrd_unset_timer(xfrd_zone_t* zone)
+xfrd_unset_timer(xfrd_zone_type* zone)
{
assert(zone->zone_handler.ev_fd == -1);
if(zone->event_added)
@@ -1082,7 +1085,7 @@ xfrd_unset_timer(xfrd_zone_t* zone)
}
void
-xfrd_set_timer(xfrd_zone_t* zone, time_t t)
+xfrd_set_timer(xfrd_zone_type* zone, time_t t)
{
int fd = zone->zone_handler.ev_fd;
int fl = ((fd == -1)?EV_TIMEOUT:zone->zone_handler_flags);
@@ -1116,8 +1119,8 @@ xfrd_set_timer(xfrd_zone_t* zone, time_t t)
}
void
-xfrd_handle_incoming_soa(xfrd_zone_t* zone,
- xfrd_soa_t* soa, time_t acquired)
+xfrd_handle_incoming_soa(xfrd_zone_type* zone,
+ xfrd_soa_type* soa, time_t acquired)
{
if(soa == NULL) {
/* nsd no longer has a zone in memory */
@@ -1199,7 +1202,7 @@ xfrd_handle_incoming_soa(xfrd_zone_t* zone,
}
void
-xfrd_send_expire_notification(xfrd_zone_t* zone)
+xfrd_send_expire_notification(xfrd_zone_type* zone)
{
task_new_expire(xfrd->nsd->task[xfrd->nsd->mytask], xfrd->last_task,
zone->apex, zone->state == xfrd_zone_expired);
@@ -1225,7 +1228,7 @@ xfrd_udp_read_packet(buffer_type* packet, int fd)
}
void
-xfrd_udp_release(xfrd_zone_t* zone)
+xfrd_udp_release(xfrd_zone_type* zone)
{
assert(zone->udp_waiting == 0);
if(zone->event_added)
@@ -1241,7 +1244,7 @@ xfrd_udp_release(xfrd_zone_t* zone)
{
while(xfrd->udp_waiting_first) {
/* snip off waiting list */
- xfrd_zone_t* wz = xfrd->udp_waiting_first;
+ xfrd_zone_type* wz = xfrd->udp_waiting_first;
assert(wz->udp_waiting);
wz->udp_waiting = 0;
xfrd->udp_waiting_first = wz->udp_waiting_next;
@@ -1281,7 +1284,7 @@ xfrd_udp_release(xfrd_zone_t* zone)
/** disable ixfr for master */
void
-xfrd_disable_ixfr(xfrd_zone_t* zone)
+xfrd_disable_ixfr(xfrd_zone_type* zone)
{
if(!(zone->master->ixfr_disabled &&
(zone->master->ixfr_disabled + XFRD_NO_IXFR_CACHE) <= time(NULL))) {
@@ -1293,7 +1296,7 @@ xfrd_disable_ixfr(xfrd_zone_t* zone)
}
static void
-xfrd_udp_read(xfrd_zone_t* zone)
+xfrd_udp_read(xfrd_zone_type* zone)
{
DEBUG(DEBUG_XFRD,1, (LOG_INFO, "xfrd: zone %s read udp data", zone->apex_str));
if(!xfrd_udp_read_packet(xfrd->packet, zone->zone_handler.ev_fd)) {
@@ -1355,7 +1358,8 @@ xfrd_udp_read(xfrd_zone_t* zone)
}
int
-xfrd_send_udp(acl_options_t* acl, buffer_type* packet, acl_options_t* ifc)
+xfrd_send_udp(struct acl_options* acl, buffer_type* packet,
+ struct acl_options* ifc)
{
#ifdef INET6
struct sockaddr_storage to;
@@ -1409,8 +1413,8 @@ xfrd_send_udp(acl_options_t* acl, buffer_type* packet, acl_options_t* ifc)
}
int
-xfrd_bind_local_interface(int sockd, acl_options_t* ifc, acl_options_t* acl,
- int tcp)
+xfrd_bind_local_interface(int sockd, struct acl_options* ifc,
+ struct acl_options* acl, int tcp)
{
#ifdef SO_LINGER
struct linger linger = {1, 0};
@@ -1487,7 +1491,7 @@ xfrd_bind_local_interface(int sockd, acl_options_t* ifc, acl_options_t* acl,
void
xfrd_tsig_sign_request(buffer_type* packet, tsig_record_type* tsig,
- acl_options_t* acl)
+ struct acl_options* acl)
{
tsig_algorithm_type* algo;
assert(acl->key_options && acl->key_options->tsig_key);
@@ -1511,7 +1515,7 @@ xfrd_tsig_sign_request(buffer_type* packet, tsig_record_type* tsig,
}
static int
-xfrd_send_ixfr_request_udp(xfrd_zone_t* zone)
+xfrd_send_ixfr_request_udp(xfrd_zone_type* zone)
{
int fd;
@@ -1553,7 +1557,7 @@ xfrd_send_ixfr_request_udp(xfrd_zone_t* zone)
return fd;
}
-static int xfrd_parse_soa_info(buffer_type* packet, xfrd_soa_t* soa)
+static int xfrd_parse_soa_info(buffer_type* packet, xfrd_soa_type* soa)
{
if(!buffer_available(packet, 10))
return 0;
@@ -1590,8 +1594,8 @@ static int xfrd_parse_soa_info(buffer_type* packet, xfrd_soa_t* soa)
* (soa contents is modified by the routine)
*/
static int
-xfrd_xfr_check_rrs(xfrd_zone_t* zone, buffer_type* packet, size_t count,
- int *done, xfrd_soa_t* soa, region_type* temp)
+xfrd_xfr_check_rrs(xfrd_zone_type* zone, buffer_type* packet, size_t count,
+ int *done, xfrd_soa_type* soa, region_type* temp)
{
/* first RR has already been checked */
uint32_t tmp_serial = 0;
@@ -1697,7 +1701,7 @@ xfrd_xfr_check_rrs(xfrd_zone_t* zone, buffer_type* packet, size_t count,
}
static int
-xfrd_xfr_process_tsig(xfrd_zone_t* zone, buffer_type* packet)
+xfrd_xfr_process_tsig(xfrd_zone_type* zone, buffer_type* packet)
{
int have_tsig = 0;
assert(zone && zone->master && zone->master->key_options
@@ -1753,8 +1757,8 @@ xfrd_xfr_process_tsig(xfrd_zone_t* zone, buffer_type* packet)
/* parse the received packet. returns xfrd packet result code. */
static enum xfrd_packet_result
-xfrd_parse_received_xfr_packet(xfrd_zone_t* zone, buffer_type* packet,
- xfrd_soa_t* soa)
+xfrd_parse_received_xfr_packet(xfrd_zone_type* zone, buffer_type* packet,
+ xfrd_soa_type* soa)
{
size_t rr_count;
size_t qdcount = QDCOUNT(packet);
@@ -1981,9 +1985,9 @@ xfrd_pretty_time(time_t v)
}
enum xfrd_packet_result
-xfrd_handle_received_xfr_packet(xfrd_zone_t* zone, buffer_type* packet)
+xfrd_handle_received_xfr_packet(xfrd_zone_type* zone, buffer_type* packet)
{
- xfrd_soa_t soa;
+ xfrd_soa_type soa;
enum xfrd_packet_result res;
uint64_t xfrfile_size;
@@ -2168,7 +2172,7 @@ xfrd_handle_reload(int ATTR_UNUSED(fd), short event, void* ATTR_UNUSED(arg))
}
void
-xfrd_handle_notify_and_start_xfr(xfrd_zone_t* zone, xfrd_soa_t* soa)
+xfrd_handle_notify_and_start_xfr(xfrd_zone_type* zone, xfrd_soa_type* soa)
{
if(xfrd_handle_incoming_notify(zone, soa)) {
if(zone->zone_handler.ev_fd == -1 && zone->tcp_conn == -1 &&
@@ -2191,7 +2195,7 @@ xfrd_handle_passed_packet(buffer_type* packet,
uint16_t qtype, qclass;
const dname_type* dname;
region_type* tempregion = region_create(xalloc, free);
- xfrd_zone_t* zone;
+ xfrd_zone_type* zone;
buffer_skip(packet, QHEADERSZ);
if(!packet_read_query_section(packet, qnamebuf, &qtype, &qclass)) {
@@ -2204,7 +2208,7 @@ xfrd_handle_passed_packet(buffer_type* packet,
"%d", dname_to_string(dname,0), acl_num));
/* find the zone */
- zone = (xfrd_zone_t*)rbtree_search(xfrd->zones, dname);
+ zone = (xfrd_zone_type*)rbtree_search(xfrd->zones, dname);
if(!zone) {
/* this could be because the zone has been deleted meanwhile */
DEBUG(DEBUG_XFRD, 1, (LOG_INFO, "xfrd: incoming packet for "
@@ -2216,7 +2220,7 @@ xfrd_handle_passed_packet(buffer_type* packet,
/* handle */
if(OPCODE(packet) == OPCODE_NOTIFY) {
- xfrd_soa_t soa;
+ xfrd_soa_type soa;
int have_soa = 0;
int next;
/* get serial from a SOA */
@@ -2244,7 +2248,7 @@ xfrd_handle_passed_packet(buffer_type* packet,
}
static int
-xfrd_handle_incoming_notify(xfrd_zone_t* zone, xfrd_soa_t* soa)
+xfrd_handle_incoming_notify(xfrd_zone_type* zone, xfrd_soa_type* soa)
{
if(soa && zone->soa_disk_acquired && zone->state != xfrd_zone_expired &&
compare_serial(ntohl(soa->serial),ntohl(zone->soa_disk.serial)) <= 0)
@@ -2277,12 +2281,12 @@ xfrd_handle_incoming_notify(xfrd_zone_t* zone, xfrd_soa_t* soa)
}
static int
-find_same_master_notify(xfrd_zone_t* zone, int acl_num_nfy)
+find_same_master_notify(xfrd_zone_type* zone, int acl_num_nfy)
{
- acl_options_t* nfy_acl = acl_find_num(zone->zone_options->pattern->
+ struct acl_options* nfy_acl = acl_find_num(zone->zone_options->pattern->
allow_notify, acl_num_nfy);
int num = 0;
- acl_options_t* master = zone->zone_options->pattern->request_xfr;
+ struct acl_options* master = zone->zone_options->pattern->request_xfr;
if(!nfy_acl)
return -1;
while(master)
@@ -2299,8 +2303,8 @@ void
xfrd_check_failed_updates()
{
/* see if updates have not come through */
- xfrd_zone_t* zone;
- RBTREE_FOR(zone, xfrd_zone_t*, xfrd->zones)
+ xfrd_zone_type* zone;
+ RBTREE_FOR(zone, xfrd_zone_type*, xfrd->zones)
{
/* zone has a disk soa, and no nsd soa or a different nsd soa */
if(zone->soa_disk_acquired != 0 &&
@@ -2312,7 +2316,7 @@ xfrd_check_failed_updates()
{
/* this zone should have been loaded, since its disk
soa time is before the time of the reload cmd. */
- xfrd_soa_t dumped_soa = zone->soa_disk;
+ xfrd_soa_type dumped_soa = zone->soa_disk;
log_msg(LOG_ERR, "xfrd: zone %s: soa serial %u "
"update failed, restarting "
"transfer (notified zone)",
@@ -2351,8 +2355,8 @@ xfrd_check_failed_updates()
void
xfrd_prepare_zones_for_reload()
{
- xfrd_zone_t* zone;
- RBTREE_FOR(zone, xfrd_zone_t*, xfrd->zones)
+ xfrd_zone_type* zone;
+ RBTREE_FOR(zone, xfrd_zone_type*, xfrd->zones)
{
/* zone has a disk soa, and no nsd soa or a different nsd soa */
if(zone->soa_disk_acquired != 0 &&
@@ -2380,10 +2384,10 @@ xfrd_get_temp_buffer()
#ifdef BIND8_STATS
/** process stat info task */
static void
-xfrd_process_stat_info_task(xfrd_state_t* xfrd, struct task_list_d* task)
+xfrd_process_stat_info_task(xfrd_state_type* xfrd, struct task_list_d* task)
{
size_t i;
- stc_t* p = (void*)task->zname + sizeof(struct nsdst);
+ stc_type* p = (void*)task->zname + sizeof(struct nsdst);
stats_add(&xfrd->nsd->st, (struct nsdst*)task->zname);
for(i=0; i<xfrd->nsd->child_count; i++) {
xfrd->nsd->children[i].query_count += *p++;
@@ -2398,7 +2402,7 @@ xfrd_process_stat_info_task(xfrd_state_t* xfrd, struct task_list_d* task)
#ifdef USE_ZONE_STATS
/** process zonestat inc task */
static void
-xfrd_process_zonestat_inc_task(xfrd_state_t* xfrd, struct task_list_d* task)
+xfrd_process_zonestat_inc_task(xfrd_state_type* xfrd, struct task_list_d* task)
{
xfrd->zonestat_safe = (unsigned)task->oldserial;
zonestat_remap(xfrd->nsd, 0, xfrd->zonestat_safe*sizeof(struct nsdst));
@@ -2409,7 +2413,7 @@ xfrd_process_zonestat_inc_task(xfrd_state_t* xfrd, struct task_list_d* task)
#endif /* USE_ZONE_STATS */
static void
-xfrd_handle_taskresult(xfrd_state_t* xfrd, struct task_list_d* task)
+xfrd_handle_taskresult(xfrd_state_type* xfrd, struct task_list_d* task)
{
#ifndef BIND8_STATS
(void)xfrd;
@@ -2434,7 +2438,7 @@ xfrd_handle_taskresult(xfrd_state_t* xfrd, struct task_list_d* task)
}
}
-void xfrd_process_task_result(xfrd_state_t* xfrd, struct udb_base* taskudb)
+void xfrd_process_task_result(xfrd_state_type* xfrd, struct udb_base* taskudb)
{
udb_ptr t;
/* remap it for usage */
@@ -2452,7 +2456,7 @@ void xfrd_process_task_result(xfrd_state_t* xfrd, struct udb_base* taskudb)
task_clear(taskudb);
}
-void xfrd_set_reload_now(xfrd_state_t* xfrd)
+void xfrd_set_reload_now(xfrd_state_type* xfrd)
{
xfrd->need_to_send_reload = 1;
if(!(xfrd->ipc_handler_flags&EV_WRITE)) {
diff --git a/usr.sbin/nsd/xfrd.h b/usr.sbin/nsd/xfrd.h
index b601c2aae3e..44e7ba1795a 100644
--- a/usr.sbin/nsd/xfrd.h
+++ b/usr.sbin/nsd/xfrd.h
@@ -32,11 +32,11 @@ struct region;
struct buffer;
struct xfrd_tcp;
struct xfrd_tcp_set;
-struct notify_zone_t;
+struct notify_zone;
struct udb_ptr;
-typedef struct xfrd_state xfrd_state_t;
-typedef struct xfrd_zone xfrd_zone_t;
-typedef struct xfrd_soa xfrd_soa_t;
+typedef struct xfrd_state xfrd_state_type;
+typedef struct xfrd_zone xfrd_zone_type;
+typedef struct xfrd_soa xfrd_soa_type;
/*
* The global state for the xfrd daemon process.
* The time_t times are epochs in secs since 1970, absolute times.
@@ -105,15 +105,15 @@ struct xfrd_state {
/* xfrd shutdown flag */
uint8_t shutdown;
- /* tree of zones, by apex name, contains xfrd_zone_t*. Only secondary zones. */
- rbtree_t *zones;
+ /* tree of zones, by apex name, contains xfrd_zone_type*. Only secondary zones. */
+ rbtree_type *zones;
- /* tree of zones, by apex name, contains notify_zone_t*. All zones. */
- rbtree_t *notify_zones;
- /* number of notify_zone_t active using UDP socket */
+ /* tree of zones, by apex name, contains notify_zone*. All zones. */
+ rbtree_type *notify_zones;
+ /* number of notify_zone active using UDP socket */
int notify_udp_num;
- /* first and last notify_zone_t* entries waiting for a UDP socket */
- struct notify_zone_t *notify_waiting_first, *notify_waiting_last;
+ /* first and last notify_zone* entries waiting for a UDP socket */
+ struct notify_zone *notify_waiting_first, *notify_waiting_last;
};
/*
@@ -143,7 +143,7 @@ struct xfrd_soa {
* XFRD state for a single zone
*/
struct xfrd_zone {
- rbnode_t node;
+ rbnode_type node;
/* name of the zone */
const dname_type* apex;
@@ -156,11 +156,11 @@ struct xfrd_zone {
* And the time the soa was acquired (start time for timeouts).
* If the time==0, no SOA is available.
*/
- xfrd_soa_t soa_nsd;
+ xfrd_soa_type soa_nsd;
time_t soa_nsd_acquired;
- xfrd_soa_t soa_disk;
+ xfrd_soa_type soa_disk;
time_t soa_disk_acquired;
- xfrd_soa_t soa_notified;
+ xfrd_soa_type soa_notified;
time_t soa_notified_acquired;
enum xfrd_zone_state {
@@ -170,12 +170,12 @@ struct xfrd_zone {
} state;
/* master to try to transfer from, number for persistence */
- acl_options_t* master;
+ struct acl_options* master;
int master_num;
int next_master; /* -1 or set by notify where to try next */
/* round of xfrattempts, -1 is waiting for timeout */
int round_num;
- zone_options_t* zone_options;
+ struct zone_options* zone_options;
int fresh_xfr_timeout;
/* handler for timeouts */
@@ -189,23 +189,23 @@ struct xfrd_zone {
/* zone is waiting for a tcp connection */
uint8_t tcp_waiting;
/* next zone in waiting list */
- xfrd_zone_t* tcp_waiting_next;
- xfrd_zone_t* tcp_waiting_prev;
+ xfrd_zone_type* tcp_waiting_next;
+ xfrd_zone_type* tcp_waiting_prev;
/* zone is in its tcp send queue */
uint8_t in_tcp_send;
/* next zone in tcp send queue */
- xfrd_zone_t* tcp_send_next;
- xfrd_zone_t* tcp_send_prev;
+ xfrd_zone_type* tcp_send_next;
+ xfrd_zone_type* tcp_send_prev;
/* zone is waiting for a udp connection (tcp is preferred) */
uint8_t udp_waiting;
/* next zone in waiting list for UDP */
- xfrd_zone_t* udp_waiting_next;
- xfrd_zone_t* udp_waiting_prev;
+ xfrd_zone_type* udp_waiting_next;
+ xfrd_zone_type* udp_waiting_prev;
/* zone has been activated to run now (after the other events
* but before blocking in select again) */
uint8_t is_activated;
- xfrd_zone_t* activated_next;
- xfrd_zone_t* activated_prev;
+ xfrd_zone_type* activated_next;
+ xfrd_zone_type* activated_prev;
/* xfr message handling data */
/* query id */
@@ -247,20 +247,20 @@ enum xfrd_packet_result {
#define XFRD_TRANSFER_TIMEOUT_START 10 /* empty zone timeout is between x and 2*x seconds */
#define XFRD_TRANSFER_TIMEOUT_MAX 86400 /* empty zone timeout max expbackoff */
-extern xfrd_state_t* xfrd;
+extern xfrd_state_type* xfrd;
/* start xfrd, new start. Pass socket to server_main. */
void xfrd_init(int socket, struct nsd* nsd, int shortsoa, int reload_active,
pid_t nsd_pid);
/* add new slave zone, dname(from zone_opt) and given options */
-void xfrd_init_slave_zone(xfrd_state_t* xfrd, zone_options_t* zone_opt);
+void xfrd_init_slave_zone(xfrd_state_type* xfrd, struct zone_options* zone_opt);
/* delete slave zone */
-void xfrd_del_slave_zone(xfrd_state_t* xfrd, const dname_type* dname);
+void xfrd_del_slave_zone(xfrd_state_type* xfrd, const dname_type* dname);
/* disable ixfr for a while for zone->master */
-void xfrd_disable_ixfr(xfrd_zone_t* zone);
+void xfrd_disable_ixfr(xfrd_zone_type* zone);
/* get the current time epoch. Cached for speed. */
time_t xfrd_time(void);
@@ -270,16 +270,16 @@ time_t xfrd_time(void);
* returns enum of packet discovery results
*/
enum xfrd_packet_result xfrd_handle_received_xfr_packet(
- xfrd_zone_t* zone, buffer_type* packet);
+ xfrd_zone_type* zone, buffer_type* packet);
/* set timer to specific value */
-void xfrd_set_timer(xfrd_zone_t* zone, time_t t);
+void xfrd_set_timer(xfrd_zone_type* zone, time_t t);
/* set refresh timer of zone to refresh at time now */
-void xfrd_set_refresh_now(xfrd_zone_t* zone);
+void xfrd_set_refresh_now(xfrd_zone_type* zone);
/* unset the timer - no more timeouts, for when zone is queued */
-void xfrd_unset_timer(xfrd_zone_t* zone);
+void xfrd_unset_timer(xfrd_zone_type* zone);
/* remove the 'refresh now', remove it from the activated list */
-void xfrd_deactivate_zone(xfrd_zone_t* z);
+void xfrd_deactivate_zone(xfrd_zone_type* z);
/*
* Make a new request to next master server.
@@ -288,13 +288,14 @@ void xfrd_deactivate_zone(xfrd_zone_t* z);
* starts next round of requests if at last master.
* if too many rounds of requests, sets timer for next retry.
*/
-void xfrd_make_request(xfrd_zone_t* zone);
+void xfrd_make_request(xfrd_zone_type* zone);
/*
* send packet via udp (returns UDP fd source socket) to acl addr.
* returns -1 on failure.
*/
-int xfrd_send_udp(acl_options_t* acl, buffer_type* packet, acl_options_t* ifc);
+int xfrd_send_udp(struct acl_options* acl, buffer_type* packet,
+ struct acl_options* ifc);
/*
* read from udp port packet into buffer, returns 0 on failure
@@ -304,7 +305,7 @@ int xfrd_udp_read_packet(buffer_type* packet, int fd);
/*
* Release udp socket that a zone is using
*/
-void xfrd_udp_release(xfrd_zone_t* zone);
+void xfrd_udp_release(xfrd_zone_type* zone);
/*
* Get a static buffer for temporary use (to build a packet).
@@ -315,12 +316,12 @@ struct buffer* xfrd_get_temp_buffer(void);
* TSIG sign outgoing request. Call if acl has a key.
*/
void xfrd_tsig_sign_request(buffer_type* packet, struct tsig_record* tsig,
- acl_options_t* acl);
+ struct acl_options* acl);
/* handle incoming soa information (NSD is running it, time acquired=guess).
Pass soa=NULL,acquired=now if NSD has nothing loaded for the zone
(i.e. zonefile was deleted). */
-void xfrd_handle_incoming_soa(xfrd_zone_t* zone, xfrd_soa_t* soa,
+void xfrd_handle_incoming_soa(xfrd_zone_type* zone, xfrd_soa_type* soa,
time_t acquired);
/* handle a packet passed along ipc route. acl is the one that accepted
the packet. The packet is the network blob received. acl_xfr is
@@ -335,7 +336,7 @@ void xfrd_reopen_logfile(void);
void xfrd_free_namedb(struct nsd* nsd);
/* copy SOA info from rr to soa struct. */
-void xfrd_copy_soa(xfrd_soa_t* soa, rr_type* rr);
+void xfrd_copy_soa(xfrd_soa_type* soa, rr_type* rr);
/* check for failed updates - it is assumed that now the reload has
finished, and all zone SOAs have been sent. */
@@ -348,20 +349,20 @@ void xfrd_check_failed_updates(void);
void xfrd_prepare_zones_for_reload(void);
/* Bind a local interface to a socket descriptor, return 1 on success */
-int xfrd_bind_local_interface(int sockd, acl_options_t* ifc,
- acl_options_t* acl, int tcp);
+int xfrd_bind_local_interface(int sockd, struct acl_options* ifc,
+ struct acl_options* acl, int tcp);
/* process results and soa info from reload */
-void xfrd_process_task_result(xfrd_state_t* xfrd, struct udb_base* taskudb);
+void xfrd_process_task_result(xfrd_state_type* xfrd, struct udb_base* taskudb);
/* set to reload right away (for user controlled reload events) */
-void xfrd_set_reload_now(xfrd_state_t* xfrd);
+void xfrd_set_reload_now(xfrd_state_type* xfrd);
/* send expiry notifications to nsd */
-void xfrd_send_expire_notification(xfrd_zone_t* zone);
+void xfrd_send_expire_notification(xfrd_zone_type* zone);
/* handle incoming notify (soa or NULL) and start zone xfr if necessary */
-void xfrd_handle_notify_and_start_xfr(xfrd_zone_t* zone, xfrd_soa_t* soa);
+void xfrd_handle_notify_and_start_xfr(xfrd_zone_type* zone, xfrd_soa_type* soa);
/* handle zone timeout, event */
void xfrd_handle_zone(int fd, short event, void* arg);