#include "config.h"
#include "util/log.h"
#include "util/configyyrename.h"
#include "util/config_file.h"
#include "util/configparser.h"
#include "util/net_help.h"
#include "util/iana_ports.inc"
Defines | |
| #define | IS_NUMBER_OR_ZERO if(atoi(val) == 0 && strcmp(val, "0") != 0) return 0 |
| check that the value passed is >= 0 | |
| #define | IS_NONZERO_NUMBER if(atoi(val) == 0) return 0 |
| check that the value passed is > 0 | |
| #define | IS_POW2_NUMBER if(atoi(val) == 0 || !is_pow2((size_t)atoi(val))) return 0 |
| check that the value passed is not 0 and a power of 2 | |
| #define | IS_YES_OR_NO if(strcmp(val, "yes") != 0 && strcmp(val, "no") != 0) return 0 |
| check that the value passed is yes or no | |
Functions | |
| int | ub_c_parse (void) |
| the yacc lex generated parse function | |
| int | ub_c_lex (void) |
| the lexer function | |
| int | ub_c_wrap (void) |
| wrap function | |
| void | ub_c_error (const char *message) |
| print error with file and line number | |
| static void | init_outgoing_availports (int *array, int num) |
| init ports possible for use | |
| struct config_file * | config_create () |
| Create config file structure. | |
| struct config_file * | config_create_forlib () |
| Create config file structure for library use. | |
| int | config_set_option (struct config_file *cfg, const char *opt, const char *val) |
| Set the given keyword to the given value. | |
| static void | create_cfg_parser (struct config_file *cfg, char *filename) |
| initialize the global cfg_parser object | |
| int | config_read (struct config_file *cfg, char *filename) |
| Read the config file from the specified filename. | |
| void | config_delstrlist (struct config_strlist *p) |
| Delete items in config string list. | |
| void | config_deldblstrlist (struct config_str2list *p) |
| Delete items in config double string list. | |
| void | config_delstubs (struct config_stub *p) |
| Delete items in config stub list. | |
| void | config_delete (struct config_file *cfg) |
| Destroy the config file structure. | |
| int | cfg_mark_ports (const char *str, int allow, int *avail, int num) |
| Mark "number" or "low-high" as available or not in ports array. | |
| int | cfg_scan_ports (int *avail, int num) |
| Scan ports available. | |
| int | cfg_condense_ports (struct config_file *cfg, int **avail) |
| Get a condensed list of ports returned. | |
| void | ub_c_error_va_list (const char *fmt, va_list args) |
| print error with file and line number | |
| void | ub_c_error_msg (const char *fmt,...) |
| print error with file and line number | |
| int | cfg_strlist_insert (struct config_strlist **head, char *item) |
| Insert string into strlist. | |
| int | cfg_str2list_insert (struct config_str2list **head, char *item, char *i2) |
| Insert string into str2list. | |
| uint32_t | cfg_convert_timeval (const char *str) |
| Convert 14digit to time value. | |
| int | cfg_count_numbers (const char *s) |
| Count number of values in the string. | |
| static int | isalldigit (const char *str, size_t l) |
| all digit number | |
| int | cfg_parse_memsize (const char *str, size_t *res) |
| Convert a 'nice' memory or file size into a bytecount From '100k' to 102400. | |
| void | config_apply (struct config_file *config) |
| Apply config to global constants; this routine is called in single thread. | |
Variables | |
| struct config_parser_state * | cfg_parser = 0 |
| global config during parsing | |
| FILE * | ub_c_in |
| lex in file | |
| FILE * | ub_c_out |
| lex out file | |
| uint32_t | MAX_TTL |
| the MAX_TTL global | |
| struct config_file* config_create | ( | ) | [read] |
Create config file structure.
Filled with default values.
References config_file::acls, config_file::bogus_ttl, config_file::chrootdir, config_delete(), config_file::directory, config_file::do_daemonize, config_file::do_ip4, config_file::do_ip6, config_file::do_tcp, config_file::do_udp, config_file::donotquery_localhost, config_file::donotqueryaddrs, error_exit(), config_file::forwards, config_file::harden_dnssec_stripped, config_file::harden_glue, config_file::harden_large_queries, config_file::harden_short_bufsize, config_file::hide_identity, config_file::hide_version, config_file::host_ttl, config_file::identity, config_file::if_automatic, config_file::ifs, config_file::incoming_num_tcp, config_file::infra_cache_lame_size, config_file::infra_cache_numhosts, config_file::infra_cache_slabs, init_outgoing_availports(), config_file::key_cache_size, config_file::key_cache_slabs, config_file::lame_ttl, config_file::local_data, config_file::local_zones, config_file::local_zones_nodefault, config_file::logfile, config_file::max_ttl, config_file::module_conf, config_file::msg_buffer_size, config_file::msg_cache_size, config_file::msg_cache_slabs, config_file::num_ifs, config_file::num_out_ifs, config_file::num_queries_per_thread, config_file::num_threads, config_file::out_ifs, config_file::outgoing_avail_ports, config_file::outgoing_num_ports, config_file::outgoing_num_tcp, config_file::pidfile, config_file::port, config_file::root_hints, config_file::rrset_cache_size, config_file::rrset_cache_slabs, config_file::stat_cumulative, config_file::stat_interval, config_file::stubs, config_file::target_fetch_policy, config_file::trust_anchor_file_list, config_file::trust_anchor_list, config_file::trusted_keys_file_list, config_file::use_caps_bits_for_id, config_file::use_syslog, config_file::username, config_file::val_clean_additional, config_file::val_date_override, config_file::val_nsec3_key_iterations, config_file::val_permissive_mode, config_file::verbosity, and config_file::version.
Referenced by checkconf(), config_create_forlib(), infra_test(), and run_daemon().
| struct config_file* config_create_forlib | ( | ) | [read] |
Create config file structure for library use.
Filled with default values.
References config_file::chrootdir, config_create(), config_file::donotquery_localhost, config_file::infra_cache_slabs, config_file::key_cache_size, config_file::key_cache_slabs, config_file::msg_cache_size, config_file::msg_cache_slabs, config_file::outgoing_num_ports, config_file::outgoing_num_tcp, config_file::rrset_cache_size, config_file::rrset_cache_slabs, config_file::use_syslog, and config_file::verbosity.
Referenced by ub_ctx_create().
| int config_set_option | ( | struct config_file * | config, | |
| const char * | option, | |||
| const char * | value | |||
| ) |
Set the given keyword to the given value.
| config,: | where to store config | |
| option,: | option name, including the ':' character. | |
| value,: | value, this string is copied if needed, or parsed. The caller owns the value string. |
References config_file::bogus_ttl, cfg_convert_timeval(), cfg_mark_ports(), cfg_parse_memsize(), cfg_strlist_insert(), config_file::do_ip4, config_file::do_ip6, config_file::do_tcp, config_file::do_udp, config_file::donotquery_localhost, config_file::donotqueryaddrs, config_file::harden_dnssec_stripped, config_file::harden_glue, config_file::harden_large_queries, config_file::harden_short_bufsize, config_file::host_ttl, config_file::incoming_num_tcp, config_file::infra_cache_lame_size, config_file::infra_cache_numhosts, config_file::infra_cache_slabs, IS_NONZERO_NUMBER, IS_NUMBER_OR_ZERO, IS_POW2_NUMBER, IS_YES_OR_NO, config_file::key_cache_size, config_file::key_cache_slabs, config_file::lame_ttl, config_file::local_data, config_file::logfile, config_file::max_ttl, config_file::module_conf, config_file::msg_buffer_size, config_file::msg_cache_size, config_file::msg_cache_slabs, config_file::num_queries_per_thread, config_file::outgoing_avail_ports, config_file::outgoing_num_ports, config_file::outgoing_num_tcp, config_file::root_hints, config_file::rrset_cache_size, config_file::rrset_cache_slabs, config_file::stat_interval, config_file::target_fetch_policy, config_file::trust_anchor_file_list, config_file::trust_anchor_list, config_file::trusted_keys_file_list, config_file::use_syslog, config_file::val_clean_additional, config_file::val_date_override, config_file::val_nsec3_key_iterations, config_file::val_permissive_mode, and config_file::verbosity.
Referenced by ub_ctx_set_option().
| int config_read | ( | struct config_file * | config, | |
| char * | filename | |||
| ) |
Read the config file from the specified filename.
| config,: | where options are stored into, must be freshly created. | |
| filename,: | name of configfile. If NULL nothing is done. |
References create_cfg_parser(), config_parser_state::errors, config_parser_state::filename, log_err(), ub_c_in, and ub_c_parse().
Referenced by checkconf(), run_daemon(), and ub_ctx_config().
| void config_delstrlist | ( | struct config_strlist * | list | ) |
Delete items in config string list.
| list,: | list. |
References config_strlist::next, and config_strlist::str.
Referenced by config_delete(), config_delstubs(), and lz_freeup_cfg().
| void config_deldblstrlist | ( | struct config_str2list * | list | ) |
Delete items in config double string list.
| list,: | list. |
References config_str2list::next, config_str2list::str, and config_str2list::str2.
Referenced by config_delete(), and lz_freeup_cfg().
| void config_delstubs | ( | struct config_stub * | list | ) |
Delete items in config stub list.
| list,: | list. |
References config_stub::addrs, config_delstrlist(), config_stub::hosts, config_stub::name, and config_stub::next.
Referenced by config_delete(), and ub_ctx_set_fwd().
| void config_delete | ( | struct config_file * | config | ) |
Destroy the config file structure.
| config,: | to delete. |
References config_file::acls, config_file::chrootdir, config_deldblstrlist(), config_delstrlist(), config_delstubs(), config_file::directory, config_file::donotqueryaddrs, config_file::forwards, config_file::identity, config_file::ifs, config_file::local_data, config_file::local_zones, config_file::local_zones_nodefault, config_file::logfile, config_file::module_conf, config_file::num_ifs, config_file::num_out_ifs, config_file::out_ifs, config_file::outgoing_avail_ports, config_file::pidfile, config_file::root_hints, config_file::stubs, config_file::target_fetch_policy, config_file::trust_anchor_file_list, config_file::trust_anchor_list, config_file::trusted_keys_file_list, config_file::username, config_file::val_nsec3_key_iterations, and config_file::version.
Referenced by checkconf(), config_create(), infra_test(), run_daemon(), and ub_ctx_delete().
| int cfg_mark_ports | ( | const char * | str, | |
| int | allow, | |||
| int * | avail, | |||
| int | num | |||
| ) |
Mark "number" or "low-high" as available or not in ports array.
| str,: | string in input | |
| allow,: | give true if this range is permitted. | |
| avail,: | the array from cfg. | |
| num,: | size of the array (65536). |
References log_err().
Referenced by config_set_option().
| int cfg_scan_ports | ( | int * | avail, | |
| int | num | |||
| ) |
Scan ports available.
| avail,: | the array from cfg. | |
| num,: | size of the array (65536). |
Referenced by cfg_condense_ports().
| int cfg_condense_ports | ( | struct config_file * | cfg, | |
| int ** | avail | |||
| ) |
Get a condensed list of ports returned.
allocated.
| cfg,: | config file. | |
| avail,: | the available ports array is returned here. |
References cfg_scan_ports(), log_assert, and config_file::outgoing_avail_ports.
Referenced by libworker_setup().
| int cfg_strlist_insert | ( | struct config_strlist ** | head, | |
| char * | item | |||
| ) |
Insert string into strlist.
| head,: | pointer to strlist head variable. | |
| item,: | new item. malloced by caller. If NULL the insertion fails. |
References config_strlist::next, and config_strlist::str.
Referenced by config_set_option(), ub_ctx_add_ta(), ub_ctx_add_ta_file(), ub_ctx_hosts(), ub_ctx_set_fwd(), and ub_ctx_trustedkeys().
| int cfg_str2list_insert | ( | struct config_str2list ** | head, | |
| char * | item, | |||
| char * | i2 | |||
| ) |
Insert string into str2list.
| head,: | pointer to str2list head variable. | |
| item,: | new item. malloced by caller. If NULL the insertion fails. | |
| i2,: | 2nd string, malloced by caller. If NULL the insertion fails. |
References config_str2list::next, config_str2list::str, and config_str2list::str2.
| uint32_t cfg_convert_timeval | ( | const char * | str | ) |
Convert 14digit to time value.
| str,: | string of 14 digits |
Referenced by config_set_option(), parse_cmdline(), and verifytest_file().
| int cfg_count_numbers | ( | const char * | str | ) |
Count number of values in the string.
format ::= (sp num)+ sp num ::= [-](0-9)+ sp ::= (space|tab)*
| str,: | string |
Referenced by read_fetch_policy(), and val_apply_cfg().
| int cfg_parse_memsize | ( | const char * | str, | |
| size_t * | res | |||
| ) |
Convert a 'nice' memory or file size into a bytecount From '100k' to 102400.
and so on. Understands kKmMgG. k=1024, m=1024*1024, g=1024*1024*1024.
| str,: | string | |
| res,: | result is stored here, size in bytes. |
References isalldigit(), and log_err().
Referenced by config_memsize_test(), config_set_option(), and main().
| void config_apply | ( | struct config_file * | config | ) |
Apply config to global constants; this routine is called in single thread.
| config,: | to apply. Side effect: global constants change. |
References config_file::max_ttl, and MAX_TTL.
Referenced by apply_settings(), and context_finalize().
| struct config_parser_state* cfg_parser = 0 |
global config during parsing
global config parser object used during config parsing
1.5.6