diff options
author | Stuart Henderson <sthen@cvs.openbsd.org> | 2013-11-26 12:50:31 +0000 |
---|---|---|
committer | Stuart Henderson <sthen@cvs.openbsd.org> | 2013-11-26 12:50:31 +0000 |
commit | b665eb4cb1ea56ccad7fee700f05c85dec76e702 (patch) | |
tree | 8453629bcc74596d1a3588c5a534658f6a7b3503 /usr.sbin/nsd/options.h | |
parent | 9f9bd245ba092cf635e0212513052b389360c9ba (diff) |
import NSD 4.0.0, tests from Dorian Büttner, Patrik Lundin, requested by brad@
Diffstat (limited to 'usr.sbin/nsd/options.h')
-rw-r--r-- | usr.sbin/nsd/options.h | 154 |
1 files changed, 132 insertions, 22 deletions
diff --git a/usr.sbin/nsd/options.h b/usr.sbin/nsd/options.h index cab7d5749cf..4cad972a683 100644 --- a/usr.sbin/nsd/options.h +++ b/usr.sbin/nsd/options.h @@ -1,7 +1,7 @@ /* * options.h -- nsd.conf options definitions and prototypes * - * Copyright (c) 2001-2011, NLnet Labs. All rights reserved. + * Copyright (c) 2001-2006, NLnet Labs. All rights reserved. * * See LICENSE for the license. * @@ -17,8 +17,10 @@ struct query; struct dname; struct tsig_key; +struct buffer; 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; @@ -28,12 +30,24 @@ typedef struct config_parser_state config_parser_state_t; * 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; - /* list of keys defined */ - key_options_t* keys; - size_t numkeys; + /* free space in zonelist file, contains zonelist_bucket */ + rbtree_t* zonefree; + /* number of free space lines in zonelist file */ + size_t zonefree_number; + /* zonelist file if open */ + FILE* zonelist; + /* last offset in file (or 0 if none) */ + off_t zonelist_off; + + /* rbtree of keys defined, by name */ + rbtree_t* keys; /* list of ip adresses to bind to (or NULL for all) */ ip_address_option_t* ip_addresses; @@ -42,8 +56,8 @@ struct nsd_options { int debug_mode; int verbosity; int hide_version; - int ip4_only; - int ip6_only; + int do_ip4; + int do_ip6; const char* database; const char* identity; const char* logfile; @@ -56,14 +70,30 @@ struct nsd_options { const char* pidfile; const char* port; int statistics; - const char* zonestatsfile; const char* chroot; const char* username; const char* zonesdir; - const char* difffile; const char* xfrdfile; + const char* xfrdir; + const char* zonelistfile; const char* nsid; int xfrd_reload_timeout; + int zonefiles_check; + + /** remote control section. enable toggle. */ + int control_enable; + /** the interfaces the remote control should listen on */ + ip_address_option_t* control_interface; + /** port number for the control port */ + int control_port; + /** private key file for server */ + char* server_key_file; + /** certificate file for server */ + char* server_cert_file; + /** private key file for nsd-control */ + char* control_key_file; + /** certificate file for nsd-control */ + char* control_cert_file; #ifdef RATELIMIT /** number of buckets in rrl hashtable */ @@ -88,14 +118,11 @@ struct ipaddress_option { }; /* - * Options for a zone + * Pattern of zone options, used to contain options for zone(s). */ -struct zone_options { - /* key is dname of apex */ +struct pattern_options { rbnode_t node; - - /* is apex of the zone */ - const char* name; + const char* pname; /* name of the pattern, key of rbtree */ const char* zonefile; acl_options_t* allow_notify; acl_options_t* request_xfr; @@ -106,7 +133,32 @@ struct zone_options { uint16_t rrl_whitelist; /* bitmap with rrl types */ #endif uint8_t allow_axfr_fallback; + uint8_t allow_axfr_fallback_is_default; uint8_t notify_retry; + uint8_t notify_retry_is_default; + uint8_t implicit; /* pattern is implicit, part_of_config zone used */ + uint8_t xfrd_flags; +}; + +#define PATTERN_IMPLICIT_MARKER "_implicit_" + +/* + * Options for a zone + */ +struct zone_options { + /* key is dname of apex */ + rbnode_t node; + + /* is apex of the zone */ + const char* name; + /* if not part of config, the offset and linesize of zonelist entry */ + off_t off; + 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; + /* zone is fixed into the main config, not in zonelist, cannot delete */ + uint8_t part_of_config; }; union acl_addr_storage { @@ -125,10 +177,10 @@ struct acl_options { acl_options_t* next; /* options */ - uint8_t use_axfr_only; - uint8_t allow_udp; time_t ixfr_disabled; int bad_xfr_count; + uint8_t use_axfr_only; + uint8_t allow_udp; /* ip address range */ const char* ip_address_spec; @@ -154,21 +206,36 @@ struct acl_options { * Key definition */ struct key_options { - key_options_t* next; - const char* name; - const char* algorithm; - const char* secret; + rbnode_t node; /* key of tree is name */ + char* name; + char* algorithm; + char* secret; struct tsig_key* tsig_key; }; +/** zone list free space */ +struct zonelist_free { + struct zonelist_free* next; + off_t off; +}; +/** zonelist free bucket for a particular line length */ +struct zonelist_bucket { + rbnode_t node; /* key is ptr to linesize */ + int linesize; + struct zonelist_free* list; +}; + /* * Used during options parsing */ struct config_parser_state { const char* filename; + const char* chroot; 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; @@ -177,6 +244,8 @@ struct config_parser_state { acl_options_t* current_notify; acl_options_t* current_provide_xfr; acl_options_t* current_outgoing_interface; + void (*err)(void*,const char*); + void* err_arg; }; extern config_parser_state_t* cfg_parser; @@ -188,14 +257,41 @@ static inline size_t nsd_options_num_zones(nsd_options_t* 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); +/* 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); -/* parses options file. Returns false on failure */ -int parse_options_file(nsd_options_t* opt, const char* file); +/* 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, + 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); /* 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); +/* read in zone list file. Returns false on failure */ +int parse_zone_list_file(nsd_options_t* opt); +/* create zone entry and add to the zonelist file */ +zone_options_t* zone_list_add(nsd_options_t* 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); #if defined(HAVE_SSL) /* tsig must be inited, adds all keys in options to tsig. */ @@ -218,8 +314,18 @@ int acl_same_host(acl_options_t* a, acl_options_t* b); /* find acl by number in the list */ acl_options_t* acl_find_num(acl_options_t* 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); +/* see if two acl are the same */ +int acl_equal(acl_options_t* p, acl_options_t* q); + /* see if a zone is a slave or a master zone */ int zone_is_slave(zone_options_t* opt); +/* create zonefile name, returns static pointer (perhaps to options data) */ +const char* config_make_zonefile(zone_options_t* zone); + +#define ZONEC_PCT_TIME 5 /* seconds, then it starts to print pcts */ +#define ZONEC_PCT_COUNT 100000 /* elements before pct check is done */ /* parsing helpers */ void c_error(const char* msg); @@ -233,5 +339,9 @@ int parse_acl_range_type(char* ip, char** mask); void parse_acl_range_subnet(char* p, void* addr, int maxbits); /* clean up options */ void nsd_options_destroy(nsd_options_t* 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 */ +void config_apply_pattern(const char* name); #endif /* OPTIONS_H */ |