2 * util/config_file.h - reads and stores the config file for unbound.
4 * Copyright (c) 2007, NLnet Labs. All rights reserved.
6 * This software is open source.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
19 * Neither the name of the NLNET LABS nor the names of its contributors may
20 * be used to endorse or promote products derived from this software without
21 * specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 * This file contains functions for the config file.
42 #ifndef UTIL_CONFIG_FILE_H
43 #define UTIL_CONFIG_FILE_H
45 struct config_strlist;
46 struct config_str2list;
47 struct config_str3list;
48 struct config_strbytelist;
51 struct ub_packed_rrset_key;
55 * The configuration options.
56 * Strings are malloced.
59 /** verbosity level as specified in the config file */
62 /** statistics interval (in seconds) */
64 /** if false, statistics values are reset after printing them */
66 /** if true, the statistics are kept in greater detail */
69 /** number of threads to create */
72 /** port on which queries are answered. */
74 /** do ip4 query support. */
76 /** do ip6 query support. */
78 /** prefer ip6 upstream queries. */
80 /** do udp query support. */
82 /** do tcp query support. */
84 /** tcp upstream queries (no UDP upstream queries) */
86 /** maximum segment size of tcp socket which queries are answered */
88 /** maximum segment size of tcp socket for outgoing queries */
91 /** private key file for dnstcp-ssl service (enabled if not NULL) */
92 char* ssl_service_key;
93 /** public key file for dnstcp-ssl service */
94 char* ssl_service_pem;
95 /** port on which to provide ssl service */
97 /** if outgoing tcp connections use SSL */
100 /** outgoing port range number of ports (per thread) */
101 int outgoing_num_ports;
102 /** number of outgoing tcp buffers per (per thread) */
103 size_t outgoing_num_tcp;
104 /** number of incoming tcp buffers per (per thread) */
105 size_t incoming_num_tcp;
106 /** allowed udp port numbers, array with 0 if not allowed */
107 int* outgoing_avail_ports;
109 /** EDNS buffer size to use */
110 size_t edns_buffer_size;
111 /** number of bytes buffer size for DNS messages */
112 size_t msg_buffer_size;
113 /** size of the message cache */
114 size_t msg_cache_size;
115 /** slabs in the message cache. */
116 size_t msg_cache_slabs;
117 /** number of queries every thread can service */
118 size_t num_queries_per_thread;
119 /** number of msec to wait before items can be jostled out */
121 /** size of the rrset cache */
122 size_t rrset_cache_size;
123 /** slabs in the rrset cache */
124 size_t rrset_cache_slabs;
125 /** host cache ttl in seconds */
127 /** number of slabs in the infra host cache */
128 size_t infra_cache_slabs;
129 /** max number of hosts in the infra cache */
130 size_t infra_cache_numhosts;
131 /** min value for infra cache rtt */
132 int infra_cache_min_rtt;
133 /** delay close of udp-timeouted ports, if 0 no delayclose. in msec */
136 /** the target fetch policy for the iterator */
137 char* target_fetch_policy;
139 /** automatic interface for incoming messages. Uses ipv6 remapping,
140 * and recvmsg/sendmsg ancillary data to detect interfaces, boolean */
142 /** SO_RCVBUF size to set on port 53 UDP socket */
144 /** SO_SNDBUF size to set on port 53 UDP socket */
146 /** SO_REUSEPORT requested on port 53 sockets */
148 /** IP_TRANSPARENT socket option requested on port 53 sockets */
150 /** IP_FREEBIND socket option request on port 53 sockets */
153 /** number of interfaces to open. If 0 default all interfaces. */
155 /** interface description strings (IP addresses) */
158 /** number of outgoing interfaces to open.
159 * If 0 default all interfaces. */
161 /** outgoing interface description strings (IP addresses) */
164 /** the root hints */
165 struct config_strlist* root_hints;
166 /** the stub definitions, linked list */
167 struct config_stub* stubs;
168 /** the forward zone definitions, linked list */
169 struct config_stub* forwards;
170 /** list of donotquery addresses, linked list */
171 struct config_strlist* donotqueryaddrs;
172 /** list of access control entries, linked list */
173 struct config_str2list* acls;
174 /** use default localhost donotqueryaddr entries */
175 int donotquery_localhost;
177 /** harden against very small edns buffer sizes */
178 int harden_short_bufsize;
179 /** harden against very large query sizes */
180 int harden_large_queries;
181 /** harden against spoofed glue (out of zone data) */
183 /** harden against receiving no DNSSEC data for trust anchor */
184 int harden_dnssec_stripped;
185 /** harden against queries that fall under known nxdomain names */
186 int harden_below_nxdomain;
187 /** harden the referral path, query for NS,A,AAAA and validate */
188 int harden_referral_path;
189 /** harden against algorithm downgrade */
190 int harden_algo_downgrade;
191 /** use 0x20 bits in query as random ID bits */
192 int use_caps_bits_for_id;
193 /** 0x20 whitelist, domains that do not use capsforid */
194 struct config_strlist* caps_whitelist;
195 /** strip away these private addrs from answers, no DNS Rebinding */
196 struct config_strlist* private_address;
197 /** allow domain (and subdomains) to use private address space */
198 struct config_strlist* private_domain;
199 /** what threshold for unwanted action. */
200 size_t unwanted_threshold;
201 /** the number of seconds maximal TTL used for RRsets and messages */
203 /** the number of seconds minimum TTL used for RRsets and messages */
205 /** the number of seconds maximal negative TTL for SOA in auth */
206 int max_negative_ttl;
207 /** if prefetching of messages should be performed. */
209 /** if prefetching of DNSKEYs should be performed. */
212 /** chrootdir, if not "" or chroot will be done */
214 /** username to change to, if not "". */
216 /** working directory */
218 /** filename to log to. */
220 /** pidfile to write pid to. */
223 /** should log messages be sent to syslogd */
225 /** log timestamp in ascii UTC */
227 /** log queries with one line per query */
230 /** do not report identity (id.server, hostname.bind) */
232 /** do not report version (version.server, version.bind) */
234 /** identity, hostname is returned if "". */
236 /** version, package version returned if "". */
239 /** the module configuration string */
242 /** files with trusted DS and DNSKEYs in zonefile format, list */
243 struct config_strlist* trust_anchor_file_list;
244 /** list of trustanchor keys, linked list */
245 struct config_strlist* trust_anchor_list;
246 /** files with 5011 autotrust tracked keys */
247 struct config_strlist* auto_trust_anchor_file_list;
248 /** files with trusted DNSKEYs in named.conf format, list */
249 struct config_strlist* trusted_keys_file_list;
250 /** DLV anchor file */
251 char* dlv_anchor_file;
252 /** DLV anchor inline */
253 struct config_strlist* dlv_anchor_list;
254 /** insecure domain list */
255 struct config_strlist* domain_insecure;
257 /** if not 0, this value is the validation date for RRSIGs */
258 int32_t val_date_override;
259 /** the minimum for signature clock skew */
260 int32_t val_sig_skew_min;
261 /** the maximum for signature clock skew */
262 int32_t val_sig_skew_max;
263 /** this value sets the number of seconds before revalidating bogus */
265 /** should validator clean additional section for secure msgs */
266 int val_clean_additional;
267 /** log bogus messages by the validator */
269 /** squelch val_log_level to log - this is library goes to callback */
271 /** should validator allow bogus messages to go through */
272 int val_permissive_mode;
273 /** ignore the CD flag in incoming queries and refuse them bogus data */
275 /** nsec3 maximum iterations per key size, string */
276 char* val_nsec3_key_iterations;
277 /** autotrust add holddown time, in seconds */
278 unsigned int add_holddown;
279 /** autotrust del holddown time, in seconds */
280 unsigned int del_holddown;
281 /** autotrust keep_missing time, in seconds. 0 is forever. */
282 unsigned int keep_missing;
283 /** permit small holddown values, allowing 5011 rollover very fast */
284 int permit_small_holddown;
286 /** size of the key cache */
287 size_t key_cache_size;
288 /** slabs in the key cache. */
289 size_t key_cache_slabs;
290 /** size of the neg cache */
291 size_t neg_cache_size;
293 /** local zones config */
294 struct config_str2list* local_zones;
295 /** local zones nodefault list */
296 struct config_strlist* local_zones_nodefault;
297 /** local data RRs configured */
298 struct config_strlist* local_data;
299 /** local zone override types per netblock */
300 struct config_str3list* local_zone_overrides;
301 /** unblock lan zones (reverse lookups for AS112 zones) */
302 int unblock_lan_zones;
303 /** insecure lan zones (don't validate AS112 zones) */
304 int insecure_lan_zones;
305 /** list of zonename, tagbitlist */
306 struct config_strbytelist* local_zone_tags;
307 /** list of aclname, tagbitlist */
308 struct config_strbytelist* acl_tags;
309 /** list of aclname, tagname, localzonetype */
310 struct config_str3list* acl_tag_actions;
311 /** list of aclname, tagname, redirectdata */
312 struct config_str3list* acl_tag_datas;
313 /** tag list, array with tagname[i] is malloced string */
315 /** number of items in the taglist */
318 /** remote control section. enable toggle. */
319 int remote_control_enable;
320 /** the interfaces the remote control should listen on */
321 struct config_strlist* control_ifs;
322 /** port number for the control port */
324 /** use certificates for remote control */
325 int remote_control_use_cert;
326 /** private key file for server */
327 char* server_key_file;
328 /** certificate file for server */
329 char* server_cert_file;
330 /** private key file for unbound-control */
331 char* control_key_file;
332 /** certificate file for unbound-control */
333 char* control_cert_file;
335 /** Python script file */
338 /** daemonize, i.e. fork into the background. */
341 /* minimal response when positive answer */
342 int minimal_responses;
344 /* RRSet roundrobin */
345 int rrset_roundrobin;
347 /* maximum UDP response size */
353 /* Synthetize all AAAA record despite the presence of an authoritative one */
356 /** true to enable dnstap support */
358 /** dnstap socket path */
359 char* dnstap_socket_path;
360 /** true to send "identity" via dnstap */
361 int dnstap_send_identity;
362 /** true to send "version" via dnstap */
363 int dnstap_send_version;
364 /** dnstap "identity", hostname is used if "". */
365 char* dnstap_identity;
366 /** dnstap "version", package version is used if "". */
367 char* dnstap_version;
369 /** true to log dnstap RESOLVER_QUERY message events */
370 int dnstap_log_resolver_query_messages;
371 /** true to log dnstap RESOLVER_RESPONSE message events */
372 int dnstap_log_resolver_response_messages;
373 /** true to log dnstap CLIENT_QUERY message events */
374 int dnstap_log_client_query_messages;
375 /** true to log dnstap CLIENT_RESPONSE message events */
376 int dnstap_log_client_response_messages;
377 /** true to log dnstap FORWARDER_QUERY message events */
378 int dnstap_log_forwarder_query_messages;
379 /** true to log dnstap FORWARDER_RESPONSE message events */
380 int dnstap_log_forwarder_response_messages;
382 /** true to disable DNSSEC lameness check in iterator */
383 int disable_dnssec_lame_check;
385 /** ratelimit 0 is off, otherwise qps (unless overridden) */
387 /** number of slabs for ratelimit cache */
388 size_t ratelimit_slabs;
389 /** memory size in bytes for ratelimit cache */
390 size_t ratelimit_size;
391 /** ratelimits for domain (exact match) */
392 struct config_str2list* ratelimit_for_domain;
393 /** ratelimits below domain */
394 struct config_str2list* ratelimit_below_domain;
395 /** ratelimit factor, 0 blocks all, 10 allows 1/10 of traffic */
396 int ratelimit_factor;
397 /** minimise outgoing QNAME and hide original QTYPE if possible */
398 int qname_minimisation;
401 /** from cfg username, after daemonise setup performed */
402 extern uid_t cfg_uid;
403 /** from cfg username, after daemonise setup performed */
404 extern gid_t cfg_gid;
405 /** debug and enable small timeouts */
406 extern int autr_permit_small_holddown;
409 * Stub config options
413 struct config_stub* next;
414 /** domain name (in text) of the stub apex domain */
416 /** list of stub nameserver hosts (domain name) */
417 struct config_strlist* hosts;
418 /** list of stub nameserver addresses (IP address) */
419 struct config_strlist* addrs;
420 /** if stub-prime is set */
422 /** if forward-first is set (failover to without if fails) */
427 * List of strings for config options
429 struct config_strlist {
430 /** next item in list */
431 struct config_strlist* next;
432 /** config option string */
437 * List of two strings for config options
439 struct config_str2list {
440 /** next item in list */
441 struct config_str2list* next;
449 * List of three strings for config options
451 struct config_str3list {
452 /** next item in list */
453 struct config_str3list* next;
464 * List of string, bytestring for config options
466 struct config_strbytelist {
467 /** next item in list */
468 struct config_strbytelist* next;
471 /** second bytestring */
476 /** List head for strlist processing, used for append operation. */
477 struct config_strlist_head {
478 /** first in list of text items */
479 struct config_strlist* first;
480 /** last in list of text items */
481 struct config_strlist* last;
485 * Create config file structure. Filled with default values.
486 * @return: the new structure or NULL on memory error.
488 struct config_file* config_create(void);
491 * Create config file structure for library use. Filled with default values.
492 * @return: the new structure or NULL on memory error.
494 struct config_file* config_create_forlib(void);
497 * Read the config file from the specified filename.
498 * @param config: where options are stored into, must be freshly created.
499 * @param filename: name of configfile. If NULL nothing is done.
500 * @param chroot: if not NULL, the chroot dir currently in use (for include).
501 * @return: false on error. In that case errno is set, ENOENT means
504 int config_read(struct config_file* config, const char* filename,
508 * Destroy the config file structure.
509 * @param config: to delete.
511 void config_delete(struct config_file* config);
514 * Apply config to global constants; this routine is called in single thread.
515 * @param config: to apply. Side effect: global constants change.
517 void config_apply(struct config_file* config);
520 * Find username, sets cfg_uid and cfg_gid.
521 * @param config: the config structure.
523 void config_lookup_uid(struct config_file* config);
526 * Set the given keyword to the given value.
527 * @param config: where to store config
528 * @param option: option name, including the ':' character.
529 * @param value: value, this string is copied if needed, or parsed.
530 * The caller owns the value string.
531 * @return 0 on error (malloc or syntax error).
533 int config_set_option(struct config_file* config, const char* option,
537 * Call print routine for the given option.
538 * @param cfg: config.
539 * @param opt: option name without trailing :.
540 * This is different from config_set_option.
541 * @param func: print func, called as (str, arg) for every data element.
542 * @param arg: user argument for print func.
543 * @return false if the option name is not supported (syntax error).
545 int config_get_option(struct config_file* cfg, const char* opt,
546 void (*func)(char*,void*), void* arg);
549 * Get an option and return strlist
550 * @param cfg: config file
551 * @param opt: option name.
552 * @param list: list is returned here. malloced, caller must free it.
553 * @return 0=OK, 1=syntax error, 2=malloc failed.
555 int config_get_option_list(struct config_file* cfg, const char* opt,
556 struct config_strlist** list);
559 * Get an option and collate results into string
560 * @param cfg: config file
561 * @param opt: option name.
562 * @param str: string. malloced, caller must free it.
563 * @return 0=OK, 1=syntax error, 2=malloc failed.
565 int config_get_option_collate(struct config_file* cfg, const char* opt,
569 * function to print to a file, use as func with config_get_option.
570 * @param line: text to print. \n appended.
571 * @param arg: pass a FILE*, like stdout.
573 void config_print_func(char* line, void* arg);
576 * function to collate the text strings into a strlist_head.
577 * @param line: text to append.
578 * @param arg: pass a strlist_head structure. zeroed on start.
580 void config_collate_func(char* line, void* arg);
583 * take a strlist_head list and return a malloc string. separated with newline.
584 * @param list: strlist first to collate. zeroes return "".
585 * @return NULL on malloc failure. Or if malloc failure happened in strlist.
587 char* config_collate_cat(struct config_strlist* list);
590 * Append text at end of list.
591 * @param list: list head. zeroed at start.
592 * @param item: new item. malloced by caller. if NULL the insertion fails.
593 * @return true on success.
595 int cfg_strlist_append(struct config_strlist_head* list, char* item);
598 * Insert string into strlist.
599 * @param head: pointer to strlist head variable.
600 * @param item: new item. malloced by caller. If NULL the insertion fails.
601 * @return: true on success.
603 int cfg_strlist_insert(struct config_strlist** head, char* item);
605 /** insert with region for allocation. */
606 int cfg_region_strlist_insert(struct regional* region,
607 struct config_strlist** head, char* item);
610 * Insert string into str2list.
611 * @param head: pointer to str2list head variable.
612 * @param item: new item. malloced by caller. If NULL the insertion fails.
613 * @param i2: 2nd string, malloced by caller. If NULL the insertion fails.
614 * @return: true on success.
616 int cfg_str2list_insert(struct config_str2list** head, char* item, char* i2);
619 * Insert string into str3list.
620 * @param head: pointer to str3list head variable.
621 * @param item: new item. malloced by caller. If NULL the insertion fails.
622 * @param i2: 2nd string, malloced by caller. If NULL the insertion fails.
623 * @param i3: 3rd string, malloced by caller. If NULL the insertion fails.
624 * @return: true on success.
626 int cfg_str3list_insert(struct config_str3list** head, char* item, char* i2,
630 * Insert string into strbytelist.
631 * @param head: pointer to strbytelist head variable.
632 * @param item: new item. malloced by caller. If NULL the insertion fails.
633 * @param i2: 2nd string, malloced by caller. If NULL the insertion fails.
634 * @param i2len: length of the i2 bytestring.
635 * @return: true on success.
637 int cfg_strbytelist_insert(struct config_strbytelist** head, char* item,
638 uint8_t* i2, size_t i2len);
641 * Find stub in config list, also returns prevptr (for deletion).
642 * @param pp: call routine with pointer to a pointer to the start of the list,
643 * if the stub is found, on exit, the value contains a pointer to the
644 * next pointer that points to the found element (or to the list start
645 * pointer if it is the first element).
646 * @param nm: name of stub to find.
647 * @return: pointer to config_stub if found, or NULL if not found.
649 struct config_stub* cfg_stub_find(struct config_stub*** pp, const char* nm);
652 * Delete items in config string list.
655 void config_delstrlist(struct config_strlist* list);
658 * Delete items in config double string list.
661 void config_deldblstrlist(struct config_str2list* list);
664 * Delete items in config triple string list.
667 void config_deltrplstrlist(struct config_str3list* list);
669 /** delete stringbytelist */
670 void config_del_strbytelist(struct config_strbytelist* list);
674 * @param p: stub item
676 void config_delstub(struct config_stub* p);
679 * Delete items in config stub list.
682 void config_delstubs(struct config_stub* list);
685 * Convert 14digit to time value
686 * @param str: string of 14 digits
687 * @return time value or 0 for error.
689 time_t cfg_convert_timeval(const char* str);
692 * Count number of values in the string.
693 * format ::= (sp num)+ sp
695 * sp ::= (space|tab)*
698 * @return: 0 on parse error, or empty string, else
699 * number of integer values in the string.
701 int cfg_count_numbers(const char* str);
704 * Convert a 'nice' memory or file size into a bytecount
705 * From '100k' to 102400. and so on. Understands kKmMgG.
706 * k=1024, m=1024*1024, g=1024*1024*1024.
708 * @param res: result is stored here, size in bytes.
709 * @return: true if parsed correctly, or 0 on a parse error (and an error
712 int cfg_parse_memsize(const char* str, size_t* res);
715 * Add a tag name to the config. It is added at the end with a new ID value.
716 * @param cfg: the config structure.
717 * @param tag: string (which is copied) with the name.
718 * @return: false on alloc failure.
720 int config_add_tag(struct config_file* cfg, const char* tag);
723 * Find tag ID in the tag list.
724 * @param cfg: the config structure.
725 * @param tag: string with tag name to search for.
726 * @return: 0..(num_tags-1) with tag ID, or -1 if tagname is not found.
728 int find_tag_id(struct config_file* cfg, const char* tag);
731 * parse taglist from string into bytestring with bitlist.
732 * @param cfg: the config structure (with tagnames)
733 * @param str: the string to parse. Parse puts 0 bytes in string.
734 * @param listlen: returns length of in bytes.
735 * @return malloced bytes with a bitlist of the tags. or NULL on parse error
738 uint8_t* config_parse_taglist(struct config_file* cfg, char* str,
742 * convert tag bitlist to a malloced string with tag names. For debug output.
743 * @param cfg: the config structure (with tagnames)
744 * @param taglist: the tag bitlist.
745 * @param len: length of the tag bitlist.
746 * @return malloced string or NULL.
748 char* config_taglist2str(struct config_file* cfg, uint8_t* taglist,
752 * see if two taglists intersect (have tags in common).
753 * @param list1: first tag bitlist.
754 * @param list1len: length in bytes of first list.
755 * @param list2: second tag bitlist.
756 * @param list2len: length in bytes of second list.
757 * @return true if there are tags in common, 0 if not.
759 int taglist_intersect(uint8_t* list1, size_t list1len, uint8_t* list2,
763 * Parse local-zone directive into two strings and register it in the config.
764 * @param cfg: to put it in.
765 * @param val: argument strings to local-zone, "example.com nodefault".
766 * @return: false on failure
768 int cfg_parse_local_zone(struct config_file* cfg, const char* val);
771 * Mark "number" or "low-high" as available or not in ports array.
772 * @param str: string in input
773 * @param allow: give true if this range is permitted.
774 * @param avail: the array from cfg.
775 * @param num: size of the array (65536).
776 * @return: true if parsed correctly, or 0 on a parse error (and an error
779 int cfg_mark_ports(const char* str, int allow, int* avail, int num);
782 * Get a condensed list of ports returned. allocated.
783 * @param cfg: config file.
784 * @param avail: the available ports array is returned here.
785 * @return: number of ports in array or 0 on error.
787 int cfg_condense_ports(struct config_file* cfg, int** avail);
790 * Scan ports available
791 * @param avail: the array from cfg.
792 * @param num: size of the array (65536).
793 * @return the number of ports available for use.
795 int cfg_scan_ports(int* avail, int num);
798 * Convert a filename to full pathname in original filesys
799 * @param fname: the path name to convert.
800 * Must not be null or empty.
801 * @param cfg: config struct for chroot and chdir (if set).
802 * @param use_chdir: if false, only chroot is applied.
803 * @return pointer to malloced buffer which is: [chroot][chdir]fname
804 * or NULL on malloc failure.
806 char* fname_after_chroot(const char* fname, struct config_file* cfg,
810 * Convert a ptr shorthand into a full reverse-notation PTR record.
811 * @param str: input string, "IP name"
812 * @return: malloced string "reversed-ip-name PTR name"
814 char* cfg_ptr_reverse(char* str);
817 * Append text to the error info for validation.
818 * @param qstate: query state.
819 * @param str: copied into query region and appended.
820 * Failures to allocate are logged.
822 void errinf(struct module_qstate* qstate, const char* str);
825 * Append text to error info: from 1.2.3.4
826 * @param qstate: query state.
827 * @param origin: sock list with origin of trouble.
828 * Every element added.
829 * If NULL: nothing is added.
830 * if 0len element: 'from cache' is added.
832 void errinf_origin(struct module_qstate* qstate, struct sock_list *origin);
835 * Append text to error info: for RRset name type class
836 * @param qstate: query state.
837 * @param rr: rrset_key.
839 void errinf_rrset(struct module_qstate* qstate, struct ub_packed_rrset_key *rr);
842 * Append text to error info: str dname
843 * @param qstate: query state.
844 * @param str: explanation string
845 * @param dname: the dname.
847 void errinf_dname(struct module_qstate* qstate, const char* str,
851 * Create error info in string
852 * @param qstate: query state.
853 * @return string or NULL on malloc failure (already logged).
854 * This string is malloced and has to be freed by caller.
856 char* errinf_to_str(struct module_qstate* qstate);
859 * Used during options parsing
861 struct config_parser_state {
862 /** name of file being parser */
864 /** line number in the file, starts at 1 */
866 /** number of errors encountered */
868 /** the result of parsing is stored here. */
869 struct config_file* cfg;
870 /** the current chroot dir (or NULL if none) */
874 /** global config parser object used during config parsing */
875 extern struct config_parser_state* cfg_parser;
876 /** init lex state */
877 void init_cfg_parse(void);
879 extern FILE* ub_c_in;
881 extern FILE* ub_c_out;
882 /** the yacc lex generated parse function */
883 int ub_c_parse(void);
884 /** the lexer function */
888 /** parsing helpers: print error with file and line numbers */
889 void ub_c_error(const char* msg);
890 /** parsing helpers: print error with file and line numbers */
891 void ub_c_error_msg(const char* fmt, ...) ATTR_FORMAT(printf, 1, 2);
895 * Obtain registry string (if it exists).
896 * @param key: key string
897 * @param name: name of value to fetch.
898 * @return malloced string with the result or NULL if it did not
899 * exist on an error (logged with log_err) was encountered.
901 char* w_lookup_reg_str(const char* key, const char* name);
903 /** Modify directory in options for module file name */
904 void w_config_adjust_directory(struct config_file* cfg);
905 #endif /* UB_ON_WINDOWS */
907 #endif /* UTIL_CONFIG_FILE_H */