diff options
Diffstat (limited to 'usr.sbin/nsd/options.h')
-rw-r--r-- | usr.sbin/nsd/options.h | 179 |
1 files changed, 92 insertions, 87 deletions
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 */ |