xref: /freebsd/contrib/unbound/util/configparser.y (revision 5fa84c6ec176d186ddad25d31f8760e50f48157f)
1 /*
2  * configparser.y -- yacc grammar for unbound configuration files
3  *
4  * Copyright (c) 2001-2006, NLnet Labs. All rights reserved.
5  *
6  * Copyright (c) 2007, NLnet Labs. All rights reserved.
7  *
8  * This software is open source.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * Redistributions of source code must retain the above copyright notice,
15  * this list of conditions and the following disclaimer.
16  *
17  * Redistributions in binary form must reproduce the above copyright notice,
18  * this list of conditions and the following disclaimer in the documentation
19  * and/or other materials provided with the distribution.
20  *
21  * Neither the name of the NLNET LABS nor the names of its contributors may
22  * be used to endorse or promote products derived from this software without
23  * specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
31  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 %{
39 #include "config.h"
40 
41 #include <stdarg.h>
42 #include <stdio.h>
43 #include <string.h>
44 #include <stdlib.h>
45 #include <assert.h>
46 
47 #include "util/configyyrename.h"
48 #include "util/config_file.h"
49 #include "util/net_help.h"
50 #include "sldns/str2wire.h"
51 
52 int ub_c_lex(void);
53 void ub_c_error(const char *message);
54 
55 static void validate_respip_action(const char* action);
56 static void validate_acl_action(const char* action);
57 
58 /* these need to be global, otherwise they cannot be used inside yacc */
59 extern struct config_parser_state* cfg_parser;
60 
61 #if 0
62 #define OUTYY(s)  printf s /* used ONLY when debugging */
63 #else
64 #define OUTYY(s)
65 #endif
66 
67 %}
68 %union {
69 	char*	str;
70 };
71 
72 %token SPACE LETTER NEWLINE COMMENT COLON ANY ZONESTR
73 %token <str> STRING_ARG
74 %token VAR_FORCE_TOPLEVEL
75 %token VAR_SERVER VAR_VERBOSITY VAR_NUM_THREADS VAR_PORT
76 %token VAR_OUTGOING_RANGE VAR_INTERFACE VAR_PREFER_IP4
77 %token VAR_DO_IP4 VAR_DO_IP6 VAR_DO_NAT64 VAR_PREFER_IP6 VAR_DO_UDP VAR_DO_TCP
78 %token VAR_TCP_MSS VAR_OUTGOING_TCP_MSS VAR_TCP_IDLE_TIMEOUT
79 %token VAR_EDNS_TCP_KEEPALIVE VAR_EDNS_TCP_KEEPALIVE_TIMEOUT
80 %token VAR_SOCK_QUEUE_TIMEOUT
81 %token VAR_CHROOT VAR_USERNAME VAR_DIRECTORY VAR_LOGFILE VAR_PIDFILE
82 %token VAR_MSG_CACHE_SIZE VAR_MSG_CACHE_SLABS VAR_NUM_QUERIES_PER_THREAD
83 %token VAR_RRSET_CACHE_SIZE VAR_RRSET_CACHE_SLABS VAR_OUTGOING_NUM_TCP
84 %token VAR_INFRA_HOST_TTL VAR_INFRA_LAME_TTL VAR_INFRA_CACHE_SLABS
85 %token VAR_INFRA_CACHE_NUMHOSTS VAR_INFRA_CACHE_LAME_SIZE VAR_NAME
86 %token VAR_STUB_ZONE VAR_STUB_HOST VAR_STUB_ADDR VAR_TARGET_FETCH_POLICY
87 %token VAR_HARDEN_SHORT_BUFSIZE VAR_HARDEN_LARGE_QUERIES
88 %token VAR_FORWARD_ZONE VAR_FORWARD_HOST VAR_FORWARD_ADDR
89 %token VAR_DO_NOT_QUERY_ADDRESS VAR_HIDE_IDENTITY VAR_HIDE_VERSION
90 %token VAR_IDENTITY VAR_VERSION VAR_HARDEN_GLUE VAR_MODULE_CONF
91 %token VAR_TRUST_ANCHOR_FILE VAR_TRUST_ANCHOR VAR_VAL_OVERRIDE_DATE
92 %token VAR_BOGUS_TTL VAR_VAL_CLEAN_ADDITIONAL VAR_VAL_PERMISSIVE_MODE
93 %token VAR_INCOMING_NUM_TCP VAR_MSG_BUFFER_SIZE VAR_KEY_CACHE_SIZE
94 %token VAR_KEY_CACHE_SLABS VAR_TRUSTED_KEYS_FILE
95 %token VAR_VAL_NSEC3_KEYSIZE_ITERATIONS VAR_USE_SYSLOG
96 %token VAR_OUTGOING_INTERFACE VAR_ROOT_HINTS VAR_DO_NOT_QUERY_LOCALHOST
97 %token VAR_CACHE_MAX_TTL VAR_HARDEN_DNSSEC_STRIPPED VAR_ACCESS_CONTROL
98 %token VAR_LOCAL_ZONE VAR_LOCAL_DATA VAR_INTERFACE_AUTOMATIC
99 %token VAR_STATISTICS_INTERVAL VAR_DO_DAEMONIZE VAR_USE_CAPS_FOR_ID
100 %token VAR_STATISTICS_CUMULATIVE VAR_OUTGOING_PORT_PERMIT
101 %token VAR_OUTGOING_PORT_AVOID VAR_DLV_ANCHOR_FILE VAR_DLV_ANCHOR
102 %token VAR_NEG_CACHE_SIZE VAR_HARDEN_REFERRAL_PATH VAR_PRIVATE_ADDRESS
103 %token VAR_PRIVATE_DOMAIN VAR_REMOTE_CONTROL VAR_CONTROL_ENABLE
104 %token VAR_CONTROL_INTERFACE VAR_CONTROL_PORT VAR_SERVER_KEY_FILE
105 %token VAR_SERVER_CERT_FILE VAR_CONTROL_KEY_FILE VAR_CONTROL_CERT_FILE
106 %token VAR_CONTROL_USE_CERT VAR_TCP_REUSE_TIMEOUT VAR_MAX_REUSE_TCP_QUERIES
107 %token VAR_EXTENDED_STATISTICS VAR_LOCAL_DATA_PTR VAR_JOSTLE_TIMEOUT
108 %token VAR_STUB_PRIME VAR_UNWANTED_REPLY_THRESHOLD VAR_LOG_TIME_ASCII
109 %token VAR_DOMAIN_INSECURE VAR_PYTHON VAR_PYTHON_SCRIPT VAR_VAL_SIG_SKEW_MIN
110 %token VAR_VAL_SIG_SKEW_MAX VAR_VAL_MAX_RESTART VAR_CACHE_MIN_TTL
111 %token VAR_VAL_LOG_LEVEL VAR_AUTO_TRUST_ANCHOR_FILE VAR_KEEP_MISSING
112 %token VAR_ADD_HOLDDOWN VAR_DEL_HOLDDOWN VAR_SO_RCVBUF VAR_EDNS_BUFFER_SIZE
113 %token VAR_PREFETCH VAR_PREFETCH_KEY VAR_SO_SNDBUF VAR_SO_REUSEPORT
114 %token VAR_HARDEN_BELOW_NXDOMAIN VAR_IGNORE_CD_FLAG VAR_LOG_QUERIES
115 %token VAR_LOG_REPLIES VAR_LOG_LOCAL_ACTIONS VAR_TCP_UPSTREAM
116 %token VAR_SSL_UPSTREAM VAR_TCP_AUTH_QUERY_TIMEOUT VAR_SSL_SERVICE_KEY
117 %token VAR_SSL_SERVICE_PEM VAR_SSL_PORT VAR_FORWARD_FIRST
118 %token VAR_STUB_SSL_UPSTREAM VAR_FORWARD_SSL_UPSTREAM VAR_TLS_CERT_BUNDLE
119 %token VAR_STUB_TCP_UPSTREAM VAR_FORWARD_TCP_UPSTREAM
120 %token VAR_HTTPS_PORT VAR_HTTP_ENDPOINT VAR_HTTP_MAX_STREAMS
121 %token VAR_HTTP_QUERY_BUFFER_SIZE VAR_HTTP_RESPONSE_BUFFER_SIZE
122 %token VAR_HTTP_NODELAY VAR_HTTP_NOTLS_DOWNSTREAM
123 %token VAR_STUB_FIRST VAR_MINIMAL_RESPONSES VAR_RRSET_ROUNDROBIN
124 %token VAR_MAX_UDP_SIZE VAR_DELAY_CLOSE VAR_UDP_CONNECT
125 %token VAR_UNBLOCK_LAN_ZONES VAR_INSECURE_LAN_ZONES
126 %token VAR_INFRA_CACHE_MIN_RTT VAR_INFRA_CACHE_MAX_RTT VAR_INFRA_KEEP_PROBING
127 %token VAR_DNS64_PREFIX VAR_DNS64_SYNTHALL VAR_DNS64_IGNORE_AAAA
128 %token VAR_NAT64_PREFIX
129 %token VAR_DNSTAP VAR_DNSTAP_ENABLE VAR_DNSTAP_SOCKET_PATH VAR_DNSTAP_IP
130 %token VAR_DNSTAP_TLS VAR_DNSTAP_TLS_SERVER_NAME VAR_DNSTAP_TLS_CERT_BUNDLE
131 %token VAR_DNSTAP_TLS_CLIENT_KEY_FILE VAR_DNSTAP_TLS_CLIENT_CERT_FILE
132 %token VAR_DNSTAP_SEND_IDENTITY VAR_DNSTAP_SEND_VERSION VAR_DNSTAP_BIDIRECTIONAL
133 %token VAR_DNSTAP_IDENTITY VAR_DNSTAP_VERSION
134 %token VAR_DNSTAP_LOG_RESOLVER_QUERY_MESSAGES
135 %token VAR_DNSTAP_LOG_RESOLVER_RESPONSE_MESSAGES
136 %token VAR_DNSTAP_LOG_CLIENT_QUERY_MESSAGES
137 %token VAR_DNSTAP_LOG_CLIENT_RESPONSE_MESSAGES
138 %token VAR_DNSTAP_LOG_FORWARDER_QUERY_MESSAGES
139 %token VAR_DNSTAP_LOG_FORWARDER_RESPONSE_MESSAGES
140 %token VAR_DNSTAP_SAMPLE_RATE
141 %token VAR_RESPONSE_IP_TAG VAR_RESPONSE_IP VAR_RESPONSE_IP_DATA
142 %token VAR_HARDEN_ALGO_DOWNGRADE VAR_IP_TRANSPARENT
143 %token VAR_IP_DSCP
144 %token VAR_DISABLE_DNSSEC_LAME_CHECK
145 %token VAR_IP_RATELIMIT VAR_IP_RATELIMIT_SLABS VAR_IP_RATELIMIT_SIZE
146 %token VAR_RATELIMIT VAR_RATELIMIT_SLABS VAR_RATELIMIT_SIZE
147 %token VAR_OUTBOUND_MSG_RETRY VAR_MAX_SENT_COUNT VAR_MAX_QUERY_RESTARTS
148 %token VAR_RATELIMIT_FOR_DOMAIN VAR_RATELIMIT_BELOW_DOMAIN
149 %token VAR_IP_RATELIMIT_FACTOR VAR_RATELIMIT_FACTOR
150 %token VAR_IP_RATELIMIT_BACKOFF VAR_RATELIMIT_BACKOFF
151 %token VAR_SEND_CLIENT_SUBNET VAR_CLIENT_SUBNET_ZONE
152 %token VAR_CLIENT_SUBNET_ALWAYS_FORWARD VAR_CLIENT_SUBNET_OPCODE
153 %token VAR_MAX_CLIENT_SUBNET_IPV4 VAR_MAX_CLIENT_SUBNET_IPV6
154 %token VAR_MIN_CLIENT_SUBNET_IPV4 VAR_MIN_CLIENT_SUBNET_IPV6
155 %token VAR_MAX_ECS_TREE_SIZE_IPV4 VAR_MAX_ECS_TREE_SIZE_IPV6
156 %token VAR_CAPS_WHITELIST VAR_CACHE_MAX_NEGATIVE_TTL VAR_PERMIT_SMALL_HOLDDOWN
157 %token VAR_CACHE_MIN_NEGATIVE_TTL
158 %token VAR_QNAME_MINIMISATION VAR_QNAME_MINIMISATION_STRICT VAR_IP_FREEBIND
159 %token VAR_DEFINE_TAG VAR_LOCAL_ZONE_TAG VAR_ACCESS_CONTROL_TAG
160 %token VAR_LOCAL_ZONE_OVERRIDE VAR_ACCESS_CONTROL_TAG_ACTION
161 %token VAR_ACCESS_CONTROL_TAG_DATA VAR_VIEW VAR_ACCESS_CONTROL_VIEW
162 %token VAR_VIEW_FIRST VAR_SERVE_EXPIRED VAR_SERVE_EXPIRED_TTL
163 %token VAR_SERVE_EXPIRED_TTL_RESET VAR_SERVE_EXPIRED_REPLY_TTL
164 %token VAR_SERVE_EXPIRED_CLIENT_TIMEOUT VAR_EDE_SERVE_EXPIRED
165 %token VAR_SERVE_ORIGINAL_TTL VAR_FAKE_DSA
166 %token VAR_FAKE_SHA1 VAR_LOG_IDENTITY VAR_HIDE_TRUSTANCHOR
167 %token VAR_HIDE_HTTP_USER_AGENT VAR_HTTP_USER_AGENT
168 %token VAR_TRUST_ANCHOR_SIGNALING VAR_AGGRESSIVE_NSEC VAR_USE_SYSTEMD
169 %token VAR_SHM_ENABLE VAR_SHM_KEY VAR_ROOT_KEY_SENTINEL
170 %token VAR_DNSCRYPT VAR_DNSCRYPT_ENABLE VAR_DNSCRYPT_PORT VAR_DNSCRYPT_PROVIDER
171 %token VAR_DNSCRYPT_SECRET_KEY VAR_DNSCRYPT_PROVIDER_CERT
172 %token VAR_DNSCRYPT_PROVIDER_CERT_ROTATED
173 %token VAR_DNSCRYPT_SHARED_SECRET_CACHE_SIZE
174 %token VAR_DNSCRYPT_SHARED_SECRET_CACHE_SLABS
175 %token VAR_DNSCRYPT_NONCE_CACHE_SIZE
176 %token VAR_DNSCRYPT_NONCE_CACHE_SLABS
177 %token VAR_PAD_RESPONSES VAR_PAD_RESPONSES_BLOCK_SIZE
178 %token VAR_PAD_QUERIES VAR_PAD_QUERIES_BLOCK_SIZE
179 %token VAR_IPSECMOD_ENABLED VAR_IPSECMOD_HOOK VAR_IPSECMOD_IGNORE_BOGUS
180 %token VAR_IPSECMOD_MAX_TTL VAR_IPSECMOD_WHITELIST VAR_IPSECMOD_STRICT
181 %token VAR_CACHEDB VAR_CACHEDB_BACKEND VAR_CACHEDB_SECRETSEED
182 %token VAR_CACHEDB_REDISHOST VAR_CACHEDB_REDISREPLICAHOST
183 %token VAR_CACHEDB_REDISPORT VAR_CACHEDB_REDISREPLICAPORT
184 %token VAR_CACHEDB_REDISTIMEOUT VAR_CACHEDB_REDISREPLICATIMEOUT
185 %token VAR_CACHEDB_REDISEXPIRERECORDS
186 %token VAR_CACHEDB_REDISPATH VAR_CACHEDB_REDISREPLICAPATH
187 %token VAR_CACHEDB_REDISPASSWORD VAR_CACHEDB_REDISREPLICAPASSWORD
188 %token VAR_CACHEDB_REDISLOGICALDB VAR_CACHEDB_REDISREPLICALOGICALDB
189 %token VAR_CACHEDB_REDISCOMMANDTIMEOUT VAR_CACHEDB_REDISREPLICACOMMANDTIMEOUT
190 %token VAR_CACHEDB_REDISCONNECTTIMEOUT VAR_CACHEDB_REDISREPLICACONNECTTIMEOUT
191 %token VAR_UDP_UPSTREAM_WITHOUT_DOWNSTREAM VAR_FOR_UPSTREAM
192 %token VAR_AUTH_ZONE VAR_ZONEFILE VAR_MASTER VAR_URL VAR_FOR_DOWNSTREAM
193 %token VAR_FALLBACK_ENABLED VAR_TLS_ADDITIONAL_PORT VAR_LOW_RTT VAR_LOW_RTT_PERMIL
194 %token VAR_FAST_SERVER_PERMIL VAR_FAST_SERVER_NUM
195 %token VAR_ALLOW_NOTIFY VAR_TLS_WIN_CERT VAR_TCP_CONNECTION_LIMIT
196 %token VAR_ANSWER_COOKIE VAR_COOKIE_SECRET VAR_IP_RATELIMIT_COOKIE
197 %token VAR_FORWARD_NO_CACHE VAR_STUB_NO_CACHE VAR_LOG_SERVFAIL VAR_DENY_ANY
198 %token VAR_UNKNOWN_SERVER_TIME_LIMIT VAR_LOG_TAG_QUERYREPLY
199 %token VAR_DISCARD_TIMEOUT VAR_WAIT_LIMIT VAR_WAIT_LIMIT_COOKIE
200 %token VAR_WAIT_LIMIT_NETBLOCK VAR_WAIT_LIMIT_COOKIE_NETBLOCK
201 %token VAR_STREAM_WAIT_SIZE VAR_TLS_CIPHERS VAR_TLS_CIPHERSUITES VAR_TLS_USE_SNI
202 %token VAR_TLS_PROTOCOLS
203 %token VAR_IPSET VAR_IPSET_NAME_V4 VAR_IPSET_NAME_V6
204 %token VAR_TLS_SESSION_TICKET_KEYS VAR_RPZ VAR_TAGS VAR_RPZ_ACTION_OVERRIDE
205 %token VAR_RPZ_CNAME_OVERRIDE VAR_RPZ_LOG VAR_RPZ_LOG_NAME
206 %token VAR_DYNLIB VAR_DYNLIB_FILE VAR_EDNS_CLIENT_STRING
207 %token VAR_EDNS_CLIENT_STRING_OPCODE VAR_NSID
208 %token VAR_ZONEMD_PERMISSIVE_MODE VAR_ZONEMD_CHECK VAR_ZONEMD_REJECT_ABSENCE
209 %token VAR_RPZ_SIGNAL_NXDOMAIN_RA VAR_INTERFACE_AUTOMATIC_PORTS VAR_EDE
210 %token VAR_DNS_ERROR_REPORTING
211 %token VAR_INTERFACE_ACTION VAR_INTERFACE_VIEW VAR_INTERFACE_TAG
212 %token VAR_INTERFACE_TAG_ACTION VAR_INTERFACE_TAG_DATA
213 %token VAR_QUIC_PORT VAR_QUIC_SIZE
214 %token VAR_PROXY_PROTOCOL_PORT VAR_STATISTICS_INHIBIT_ZERO
215 %token VAR_HARDEN_UNKNOWN_ADDITIONAL VAR_DISABLE_EDNS_DO VAR_CACHEDB_NO_STORE
216 %token VAR_LOG_DESTADDR VAR_CACHEDB_CHECK_WHEN_SERVE_EXPIRED
217 %token VAR_COOKIE_SECRET_FILE VAR_ITER_SCRUB_NS VAR_ITER_SCRUB_CNAME
218 %token VAR_ITER_SCRUB_RRSIG
219 %token VAR_MAX_GLOBAL_QUOTA VAR_HARDEN_UNVERIFIED_GLUE VAR_LOG_TIME_ISO
220 %token VAR_ITER_SCRUB_PROMISCUOUS VAR_LOG_THREAD_ID
221 
222 %%
223 toplevelvars: /* empty */ | toplevelvars toplevelvar ;
224 toplevelvar: serverstart contents_server | stub_clause |
225 	forward_clause | pythonstart contents_py |
226 	rcstart contents_rc | dtstart contents_dt | view_clause |
227 	dnscstart contents_dnsc | cachedbstart contents_cachedb |
228 	ipsetstart contents_ipset | authstart contents_auth |
229 	rpzstart contents_rpz | dynlibstart contents_dl |
230 	force_toplevel
231 	;
232 force_toplevel: VAR_FORCE_TOPLEVEL
233 	{
234 		OUTYY(("\nP(force-toplevel)\n"));
235 		cfg_parser->started_toplevel = 0;
236 	}
237 	;
238 /* server: declaration */
239 serverstart: VAR_SERVER
240 	{
241 		OUTYY(("\nP(server:)\n"));
242 		cfg_parser->started_toplevel = 1;
243 	}
244 	;
245 contents_server: contents_server content_server
246 	| ;
247 content_server: server_num_threads | server_verbosity | server_port |
248 	server_outgoing_range | server_do_ip4 |
249 	server_do_ip6 | server_do_nat64 | server_prefer_ip4 |
250 	server_prefer_ip6 | server_do_udp | server_do_tcp |
251 	server_tcp_mss | server_outgoing_tcp_mss | server_tcp_idle_timeout |
252 	server_tcp_keepalive | server_tcp_keepalive_timeout |
253 	server_sock_queue_timeout |
254 	server_interface | server_chroot | server_username |
255 	server_directory | server_logfile | server_pidfile |
256 	server_msg_cache_size | server_msg_cache_slabs |
257 	server_num_queries_per_thread | server_rrset_cache_size |
258 	server_rrset_cache_slabs | server_outgoing_num_tcp |
259 	server_infra_host_ttl | server_infra_lame_ttl |
260 	server_infra_cache_slabs | server_infra_cache_numhosts |
261 	server_infra_cache_lame_size | server_target_fetch_policy |
262 	server_harden_short_bufsize | server_harden_large_queries |
263 	server_do_not_query_address | server_hide_identity |
264 	server_hide_version | server_identity | server_version |
265 	server_hide_http_user_agent | server_http_user_agent |
266 	server_harden_glue | server_module_conf | server_trust_anchor_file |
267 	server_trust_anchor | server_val_override_date | server_bogus_ttl |
268 	server_val_clean_additional | server_val_permissive_mode |
269 	server_incoming_num_tcp | server_msg_buffer_size |
270 	server_key_cache_size | server_key_cache_slabs |
271 	server_trusted_keys_file | server_val_nsec3_keysize_iterations |
272 	server_use_syslog | server_outgoing_interface | server_root_hints |
273 	server_do_not_query_localhost | server_cache_max_ttl |
274 	server_harden_dnssec_stripped | server_access_control |
275 	server_local_zone | server_local_data | server_interface_automatic |
276 	server_statistics_interval | server_do_daemonize |
277 	server_use_caps_for_id | server_statistics_cumulative |
278 	server_outgoing_port_permit | server_outgoing_port_avoid |
279 	server_dlv_anchor_file | server_dlv_anchor | server_neg_cache_size |
280 	server_harden_referral_path | server_private_address |
281 	server_private_domain | server_extended_statistics |
282 	server_local_data_ptr | server_jostle_timeout |
283 	server_unwanted_reply_threshold | server_log_time_ascii |
284 	server_domain_insecure | server_val_sig_skew_min |
285 	server_val_sig_skew_max | server_val_max_restart |
286 	server_cache_min_ttl | server_val_log_level |
287 	server_auto_trust_anchor_file |	server_add_holddown |
288 	server_del_holddown | server_keep_missing | server_so_rcvbuf |
289 	server_edns_buffer_size | server_prefetch | server_prefetch_key |
290 	server_so_sndbuf | server_harden_below_nxdomain | server_ignore_cd_flag |
291 	server_log_queries | server_log_replies | server_tcp_upstream | server_ssl_upstream |
292 	server_log_local_actions | server_log_thread_id |
293 	server_ssl_service_key | server_ssl_service_pem | server_ssl_port |
294 	server_https_port | server_http_endpoint | server_http_max_streams |
295 	server_http_query_buffer_size | server_http_response_buffer_size |
296 	server_http_nodelay | server_http_notls_downstream |
297 	server_minimal_responses | server_rrset_roundrobin | server_max_udp_size |
298 	server_so_reuseport | server_delay_close | server_udp_connect |
299 	server_unblock_lan_zones | server_insecure_lan_zones |
300 	server_dns64_prefix | server_dns64_synthall | server_dns64_ignore_aaaa |
301 	server_nat64_prefix |
302 	server_infra_cache_min_rtt | server_infra_cache_max_rtt | server_harden_algo_downgrade |
303 	server_ip_transparent | server_ip_ratelimit | server_ratelimit |
304 	server_ip_dscp | server_infra_keep_probing |
305 	server_ip_ratelimit_slabs | server_ratelimit_slabs |
306 	server_ip_ratelimit_size | server_ratelimit_size |
307 	server_ratelimit_for_domain |
308 	server_ratelimit_below_domain | server_ratelimit_factor |
309 	server_ip_ratelimit_factor | server_ratelimit_backoff |
310 	server_ip_ratelimit_backoff | server_outbound_msg_retry |
311 	server_max_sent_count | server_max_query_restarts |
312 	server_send_client_subnet | server_client_subnet_zone |
313 	server_client_subnet_always_forward | server_client_subnet_opcode |
314 	server_max_client_subnet_ipv4 | server_max_client_subnet_ipv6 |
315 	server_min_client_subnet_ipv4 | server_min_client_subnet_ipv6 |
316 	server_max_ecs_tree_size_ipv4 | server_max_ecs_tree_size_ipv6 |
317 	server_caps_whitelist | server_cache_max_negative_ttl |
318 	server_cache_min_negative_ttl |
319 	server_permit_small_holddown | server_qname_minimisation |
320 	server_ip_freebind | server_define_tag | server_local_zone_tag |
321 	server_disable_dnssec_lame_check | server_access_control_tag |
322 	server_local_zone_override | server_access_control_tag_action |
323 	server_access_control_tag_data | server_access_control_view |
324 	server_interface_action | server_interface_view | server_interface_tag |
325 	server_interface_tag_action | server_interface_tag_data |
326 	server_qname_minimisation_strict |
327 	server_pad_responses | server_pad_responses_block_size |
328 	server_pad_queries | server_pad_queries_block_size |
329 	server_serve_expired |
330 	server_serve_expired_ttl | server_serve_expired_ttl_reset |
331 	server_serve_expired_reply_ttl | server_serve_expired_client_timeout |
332 	server_ede_serve_expired | server_serve_original_ttl | server_fake_dsa |
333 	server_log_identity | server_use_systemd |
334 	server_response_ip_tag | server_response_ip | server_response_ip_data |
335 	server_shm_enable | server_shm_key | server_fake_sha1 |
336 	server_hide_trustanchor | server_trust_anchor_signaling |
337 	server_root_key_sentinel |
338 	server_ipsecmod_enabled | server_ipsecmod_hook |
339 	server_ipsecmod_ignore_bogus | server_ipsecmod_max_ttl |
340 	server_ipsecmod_whitelist | server_ipsecmod_strict |
341 	server_udp_upstream_without_downstream | server_aggressive_nsec |
342 	server_tls_cert_bundle | server_tls_additional_port | server_low_rtt |
343 	server_fast_server_permil | server_fast_server_num  | server_tls_win_cert |
344 	server_tcp_connection_limit | server_log_servfail | server_deny_any |
345 	server_unknown_server_time_limit | server_log_tag_queryreply |
346 	server_discard_timeout | server_wait_limit | server_wait_limit_cookie |
347 	server_wait_limit_netblock | server_wait_limit_cookie_netblock |
348 	server_stream_wait_size | server_tls_ciphers |
349 	server_tls_ciphersuites | server_tls_session_ticket_keys |
350 	server_answer_cookie | server_cookie_secret | server_ip_ratelimit_cookie |
351 	server_tls_use_sni | server_edns_client_string | server_tls_protocols |
352 	server_edns_client_string_opcode | server_nsid |
353 	server_zonemd_permissive_mode | server_max_reuse_tcp_queries |
354 	server_tcp_reuse_timeout | server_tcp_auth_query_timeout |
355 	server_quic_port | server_quic_size |
356 	server_interface_automatic_ports | server_ede |
357 	server_dns_error_reporting |
358 	server_proxy_protocol_port | server_statistics_inhibit_zero |
359 	server_harden_unknown_additional | server_disable_edns_do |
360 	server_log_destaddr | server_cookie_secret_file |
361 	server_iter_scrub_ns | server_iter_scrub_cname | server_max_global_quota |
362 	server_iter_scrub_rrsig |
363 	server_harden_unverified_glue | server_log_time_iso | server_iter_scrub_promiscuous
364 	;
365 stub_clause: stubstart contents_stub
366 	{
367 		/* stub end */
368 		if(cfg_parser->cfg->stubs &&
369 			!cfg_parser->cfg->stubs->name)
370 			yyerror("stub-zone without name");
371 	}
372 	;
373 stubstart: VAR_STUB_ZONE
374 	{
375 		struct config_stub* s;
376 		OUTYY(("\nP(stub_zone:)\n"));
377 		cfg_parser->started_toplevel = 1;
378 		s = (struct config_stub*)calloc(1, sizeof(struct config_stub));
379 		if(s) {
380 			s->next = cfg_parser->cfg->stubs;
381 			cfg_parser->cfg->stubs = s;
382 		} else {
383 			yyerror("out of memory");
384 		}
385 	}
386 	;
387 contents_stub: contents_stub content_stub
388 	| ;
389 content_stub: stub_name | stub_host | stub_addr | stub_prime | stub_first |
390 	stub_no_cache | stub_ssl_upstream | stub_tcp_upstream
391 	;
392 forward_clause: forwardstart contents_forward
393 	{
394 		/* forward end */
395 		if(cfg_parser->cfg->forwards &&
396 			!cfg_parser->cfg->forwards->name)
397 			yyerror("forward-zone without name");
398 	}
399 	;
400 forwardstart: VAR_FORWARD_ZONE
401 	{
402 		struct config_stub* s;
403 		OUTYY(("\nP(forward_zone:)\n"));
404 		cfg_parser->started_toplevel = 1;
405 		s = (struct config_stub*)calloc(1, sizeof(struct config_stub));
406 		if(s) {
407 			s->next = cfg_parser->cfg->forwards;
408 			cfg_parser->cfg->forwards = s;
409 		} else {
410 			yyerror("out of memory");
411 		}
412 	}
413 	;
414 contents_forward: contents_forward content_forward
415 	| ;
416 content_forward: forward_name | forward_host | forward_addr | forward_first |
417 	forward_no_cache | forward_ssl_upstream | forward_tcp_upstream
418 	;
419 view_clause: viewstart contents_view
420 	{
421 		/* view end */
422 		if(cfg_parser->cfg->views &&
423 			!cfg_parser->cfg->views->name)
424 			yyerror("view without name");
425 	}
426 	;
427 viewstart: VAR_VIEW
428 	{
429 		struct config_view* s;
430 		OUTYY(("\nP(view:)\n"));
431 		cfg_parser->started_toplevel = 1;
432 		s = (struct config_view*)calloc(1, sizeof(struct config_view));
433 		if(s) {
434 			s->next = cfg_parser->cfg->views;
435 			cfg_parser->cfg->views = s;
436 		} else {
437 			yyerror("out of memory");
438 		}
439 	}
440 	;
441 contents_view: contents_view content_view
442 	| ;
443 content_view: view_name | view_local_zone | view_local_data | view_first |
444 		view_response_ip | view_response_ip_data | view_local_data_ptr
445 	;
446 authstart: VAR_AUTH_ZONE
447 	{
448 		struct config_auth* s;
449 		OUTYY(("\nP(auth_zone:)\n"));
450 		cfg_parser->started_toplevel = 1;
451 		s = (struct config_auth*)calloc(1, sizeof(struct config_auth));
452 		if(s) {
453 			s->next = cfg_parser->cfg->auths;
454 			cfg_parser->cfg->auths = s;
455 			/* defaults for auth zone */
456 			s->for_downstream = 1;
457 			s->for_upstream = 1;
458 			s->fallback_enabled = 0;
459 			s->zonemd_check = 0;
460 			s->zonemd_reject_absence = 0;
461 			s->isrpz = 0;
462 		} else {
463 			yyerror("out of memory");
464 		}
465 	}
466 	;
467 contents_auth: contents_auth content_auth
468 	| ;
469 content_auth: auth_name | auth_zonefile | auth_master | auth_url |
470 	auth_for_downstream | auth_for_upstream | auth_fallback_enabled |
471 	auth_allow_notify | auth_zonemd_check | auth_zonemd_reject_absence
472 	;
473 
474 rpz_tag: VAR_TAGS STRING_ARG
475 	{
476 		uint8_t* bitlist;
477 		size_t len = 0;
478 		OUTYY(("P(server_local_zone_tag:%s)\n", $2));
479 		bitlist = config_parse_taglist(cfg_parser->cfg, $2,
480 			&len);
481 		free($2);
482 		if(!bitlist) {
483 			yyerror("could not parse tags, (define-tag them first)");
484 		}
485 		if(bitlist) {
486 			cfg_parser->cfg->auths->rpz_taglist = bitlist;
487 			cfg_parser->cfg->auths->rpz_taglistlen = len;
488 
489 		}
490 	}
491 	;
492 
493 rpz_action_override: VAR_RPZ_ACTION_OVERRIDE STRING_ARG
494 	{
495 		OUTYY(("P(rpz_action_override:%s)\n", $2));
496 		if(strcmp($2, "nxdomain")!=0 && strcmp($2, "nodata")!=0 &&
497 		   strcmp($2, "passthru")!=0 && strcmp($2, "drop")!=0 &&
498 		   strcmp($2, "cname")!=0 && strcmp($2, "disabled")!=0) {
499 			yyerror("rpz-action-override action: expected nxdomain, "
500 				"nodata, passthru, drop, cname or disabled");
501 			free($2);
502 			cfg_parser->cfg->auths->rpz_action_override = NULL;
503 		}
504 		else {
505 			cfg_parser->cfg->auths->rpz_action_override = $2;
506 		}
507 	}
508 	;
509 
510 rpz_cname_override: VAR_RPZ_CNAME_OVERRIDE STRING_ARG
511 	{
512 		OUTYY(("P(rpz_cname_override:%s)\n", $2));
513 		free(cfg_parser->cfg->auths->rpz_cname);
514 		cfg_parser->cfg->auths->rpz_cname = $2;
515 	}
516 	;
517 
518 rpz_log: VAR_RPZ_LOG STRING_ARG
519 	{
520 		OUTYY(("P(rpz_log:%s)\n", $2));
521 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
522 			yyerror("expected yes or no.");
523 		else cfg_parser->cfg->auths->rpz_log = (strcmp($2, "yes")==0);
524 		free($2);
525 	}
526 	;
527 
528 rpz_log_name: VAR_RPZ_LOG_NAME STRING_ARG
529 	{
530 		OUTYY(("P(rpz_log_name:%s)\n", $2));
531 		free(cfg_parser->cfg->auths->rpz_log_name);
532 		cfg_parser->cfg->auths->rpz_log_name = $2;
533 	}
534 	;
535 rpz_signal_nxdomain_ra: VAR_RPZ_SIGNAL_NXDOMAIN_RA STRING_ARG
536 	{
537 		OUTYY(("P(rpz_signal_nxdomain_ra:%s)\n", $2));
538 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
539 			yyerror("expected yes or no.");
540 		else cfg_parser->cfg->auths->rpz_signal_nxdomain_ra = (strcmp($2, "yes")==0);
541 		free($2);
542 	}
543 	;
544 
545 rpzstart: VAR_RPZ
546 	{
547 		struct config_auth* s;
548 		OUTYY(("\nP(rpz:)\n"));
549 		cfg_parser->started_toplevel = 1;
550 		s = (struct config_auth*)calloc(1, sizeof(struct config_auth));
551 		if(s) {
552 			s->next = cfg_parser->cfg->auths;
553 			cfg_parser->cfg->auths = s;
554 			/* defaults for RPZ auth zone */
555 			s->for_downstream = 0;
556 			s->for_upstream = 0;
557 			s->fallback_enabled = 0;
558 			s->isrpz = 1;
559 		} else {
560 			yyerror("out of memory");
561 		}
562 	}
563 	;
564 contents_rpz: contents_rpz content_rpz
565 	| ;
566 content_rpz: auth_name | auth_zonefile | rpz_tag | auth_master | auth_url |
567 	   auth_allow_notify | rpz_action_override | rpz_cname_override |
568 	   rpz_log | rpz_log_name | rpz_signal_nxdomain_ra | auth_for_downstream
569 	;
570 server_num_threads: VAR_NUM_THREADS STRING_ARG
571 	{
572 		OUTYY(("P(server_num_threads:%s)\n", $2));
573 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
574 			yyerror("number expected");
575 		else cfg_parser->cfg->num_threads = atoi($2);
576 		free($2);
577 	}
578 	;
579 server_verbosity: VAR_VERBOSITY STRING_ARG
580 	{
581 		OUTYY(("P(server_verbosity:%s)\n", $2));
582 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
583 			yyerror("number expected");
584 		else cfg_parser->cfg->verbosity = atoi($2);
585 		free($2);
586 	}
587 	;
588 server_statistics_interval: VAR_STATISTICS_INTERVAL STRING_ARG
589 	{
590 		OUTYY(("P(server_statistics_interval:%s)\n", $2));
591 		if(strcmp($2, "") == 0 || strcmp($2, "0") == 0)
592 			cfg_parser->cfg->stat_interval = 0;
593 		else if(atoi($2) == 0)
594 			yyerror("number expected");
595 		else cfg_parser->cfg->stat_interval = atoi($2);
596 		free($2);
597 	}
598 	;
599 server_statistics_cumulative: VAR_STATISTICS_CUMULATIVE STRING_ARG
600 	{
601 		OUTYY(("P(server_statistics_cumulative:%s)\n", $2));
602 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
603 			yyerror("expected yes or no.");
604 		else cfg_parser->cfg->stat_cumulative = (strcmp($2, "yes")==0);
605 		free($2);
606 	}
607 	;
608 server_extended_statistics: VAR_EXTENDED_STATISTICS STRING_ARG
609 	{
610 		OUTYY(("P(server_extended_statistics:%s)\n", $2));
611 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
612 			yyerror("expected yes or no.");
613 		else cfg_parser->cfg->stat_extended = (strcmp($2, "yes")==0);
614 		free($2);
615 	}
616 	;
617 server_statistics_inhibit_zero: VAR_STATISTICS_INHIBIT_ZERO STRING_ARG
618 	{
619 		OUTYY(("P(server_statistics_inhibit_zero:%s)\n", $2));
620 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
621 			yyerror("expected yes or no.");
622 		else cfg_parser->cfg->stat_inhibit_zero = (strcmp($2, "yes")==0);
623 		free($2);
624 	}
625 	;
626 server_shm_enable: VAR_SHM_ENABLE STRING_ARG
627 	{
628 		OUTYY(("P(server_shm_enable:%s)\n", $2));
629 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
630 			yyerror("expected yes or no.");
631 		else cfg_parser->cfg->shm_enable = (strcmp($2, "yes")==0);
632 		free($2);
633 	}
634 	;
635 server_shm_key: VAR_SHM_KEY STRING_ARG
636 	{
637 		OUTYY(("P(server_shm_key:%s)\n", $2));
638 		if(strcmp($2, "") == 0 || strcmp($2, "0") == 0)
639 			cfg_parser->cfg->shm_key = 0;
640 		else if(atoi($2) == 0)
641 			yyerror("number expected");
642 		else cfg_parser->cfg->shm_key = atoi($2);
643 		free($2);
644 	}
645 	;
646 server_port: VAR_PORT STRING_ARG
647 	{
648 		OUTYY(("P(server_port:%s)\n", $2));
649 		if(atoi($2) == 0)
650 			yyerror("port number expected");
651 		else cfg_parser->cfg->port = atoi($2);
652 		free($2);
653 	}
654 	;
655 server_send_client_subnet: VAR_SEND_CLIENT_SUBNET STRING_ARG
656 	{
657 	#ifdef CLIENT_SUBNET
658 		OUTYY(("P(server_send_client_subnet:%s)\n", $2));
659 		if(!cfg_strlist_insert(&cfg_parser->cfg->client_subnet, $2))
660 			fatal_exit("out of memory adding client-subnet");
661 	#else
662 		OUTYY(("P(Compiled without edns subnet option, ignoring)\n"));
663 		free($2);
664 	#endif
665 	}
666 	;
667 server_client_subnet_zone: VAR_CLIENT_SUBNET_ZONE STRING_ARG
668 	{
669 	#ifdef CLIENT_SUBNET
670 		OUTYY(("P(server_client_subnet_zone:%s)\n", $2));
671 		if(!cfg_strlist_insert(&cfg_parser->cfg->client_subnet_zone,
672 			$2))
673 			fatal_exit("out of memory adding client-subnet-zone");
674 	#else
675 		OUTYY(("P(Compiled without edns subnet option, ignoring)\n"));
676 		free($2);
677 	#endif
678 	}
679 	;
680 server_client_subnet_always_forward:
681 	VAR_CLIENT_SUBNET_ALWAYS_FORWARD STRING_ARG
682 	{
683 	#ifdef CLIENT_SUBNET
684 		OUTYY(("P(server_client_subnet_always_forward:%s)\n", $2));
685 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
686 			yyerror("expected yes or no.");
687 		else
688 			cfg_parser->cfg->client_subnet_always_forward =
689 				(strcmp($2, "yes")==0);
690 	#else
691 		OUTYY(("P(Compiled without edns subnet option, ignoring)\n"));
692 	#endif
693 		free($2);
694 	}
695 	;
696 server_client_subnet_opcode: VAR_CLIENT_SUBNET_OPCODE STRING_ARG
697 	{
698 	#ifdef CLIENT_SUBNET
699 		OUTYY(("P(client_subnet_opcode:%s)\n", $2));
700 		OUTYY(("P(Deprecated option, ignoring)\n"));
701 	#else
702 		OUTYY(("P(Compiled without edns subnet option, ignoring)\n"));
703 	#endif
704 		free($2);
705 	}
706 	;
707 server_max_client_subnet_ipv4: VAR_MAX_CLIENT_SUBNET_IPV4 STRING_ARG
708 	{
709 	#ifdef CLIENT_SUBNET
710 		OUTYY(("P(max_client_subnet_ipv4:%s)\n", $2));
711 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
712 			yyerror("IPv4 subnet length expected");
713 		else if (atoi($2) > 32)
714 			cfg_parser->cfg->max_client_subnet_ipv4 = 32;
715 		else if (atoi($2) < 0)
716 			cfg_parser->cfg->max_client_subnet_ipv4 = 0;
717 		else cfg_parser->cfg->max_client_subnet_ipv4 = (uint8_t)atoi($2);
718 	#else
719 		OUTYY(("P(Compiled without edns subnet option, ignoring)\n"));
720 	#endif
721 		free($2);
722 	}
723 	;
724 server_max_client_subnet_ipv6: VAR_MAX_CLIENT_SUBNET_IPV6 STRING_ARG
725 	{
726 	#ifdef CLIENT_SUBNET
727 		OUTYY(("P(max_client_subnet_ipv6:%s)\n", $2));
728 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
729 			yyerror("Ipv6 subnet length expected");
730 		else if (atoi($2) > 128)
731 			cfg_parser->cfg->max_client_subnet_ipv6 = 128;
732 		else if (atoi($2) < 0)
733 			cfg_parser->cfg->max_client_subnet_ipv6 = 0;
734 		else cfg_parser->cfg->max_client_subnet_ipv6 = (uint8_t)atoi($2);
735 	#else
736 		OUTYY(("P(Compiled without edns subnet option, ignoring)\n"));
737 	#endif
738 		free($2);
739 	}
740 	;
741 server_min_client_subnet_ipv4: VAR_MIN_CLIENT_SUBNET_IPV4 STRING_ARG
742 	{
743 	#ifdef CLIENT_SUBNET
744 		OUTYY(("P(min_client_subnet_ipv4:%s)\n", $2));
745 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
746 			yyerror("IPv4 subnet length expected");
747 		else if (atoi($2) > 32)
748 			cfg_parser->cfg->min_client_subnet_ipv4 = 32;
749 		else if (atoi($2) < 0)
750 			cfg_parser->cfg->min_client_subnet_ipv4 = 0;
751 		else cfg_parser->cfg->min_client_subnet_ipv4 = (uint8_t)atoi($2);
752 	#else
753 		OUTYY(("P(Compiled without edns subnet option, ignoring)\n"));
754 	#endif
755 		free($2);
756 	}
757 	;
758 server_min_client_subnet_ipv6: VAR_MIN_CLIENT_SUBNET_IPV6 STRING_ARG
759 	{
760 	#ifdef CLIENT_SUBNET
761 		OUTYY(("P(min_client_subnet_ipv6:%s)\n", $2));
762 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
763 			yyerror("Ipv6 subnet length expected");
764 		else if (atoi($2) > 128)
765 			cfg_parser->cfg->min_client_subnet_ipv6 = 128;
766 		else if (atoi($2) < 0)
767 			cfg_parser->cfg->min_client_subnet_ipv6 = 0;
768 		else cfg_parser->cfg->min_client_subnet_ipv6 = (uint8_t)atoi($2);
769 	#else
770 		OUTYY(("P(Compiled without edns subnet option, ignoring)\n"));
771 	#endif
772 		free($2);
773 	}
774 	;
775 server_max_ecs_tree_size_ipv4: VAR_MAX_ECS_TREE_SIZE_IPV4 STRING_ARG
776 	{
777 	#ifdef CLIENT_SUBNET
778 		OUTYY(("P(max_ecs_tree_size_ipv4:%s)\n", $2));
779 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
780 			yyerror("IPv4 ECS tree size expected");
781 		else if (atoi($2) < 0)
782 			cfg_parser->cfg->max_ecs_tree_size_ipv4 = 0;
783 		else cfg_parser->cfg->max_ecs_tree_size_ipv4 = (uint32_t)atoi($2);
784 	#else
785 		OUTYY(("P(Compiled without edns subnet option, ignoring)\n"));
786 	#endif
787 		free($2);
788 	}
789 	;
790 server_max_ecs_tree_size_ipv6: VAR_MAX_ECS_TREE_SIZE_IPV6 STRING_ARG
791 	{
792 	#ifdef CLIENT_SUBNET
793 		OUTYY(("P(max_ecs_tree_size_ipv6:%s)\n", $2));
794 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
795 			yyerror("IPv6 ECS tree size expected");
796 		else if (atoi($2) < 0)
797 			cfg_parser->cfg->max_ecs_tree_size_ipv6 = 0;
798 		else cfg_parser->cfg->max_ecs_tree_size_ipv6 = (uint32_t)atoi($2);
799 	#else
800 		OUTYY(("P(Compiled without edns subnet option, ignoring)\n"));
801 	#endif
802 		free($2);
803 	}
804 	;
805 server_interface: VAR_INTERFACE STRING_ARG
806 	{
807 		OUTYY(("P(server_interface:%s)\n", $2));
808 		if(cfg_parser->cfg->num_ifs == 0)
809 			cfg_parser->cfg->ifs = calloc(1, sizeof(char*));
810 		else cfg_parser->cfg->ifs = realloc(cfg_parser->cfg->ifs,
811 				(cfg_parser->cfg->num_ifs+1)*sizeof(char*));
812 		if(!cfg_parser->cfg->ifs)
813 			yyerror("out of memory");
814 		else
815 			cfg_parser->cfg->ifs[cfg_parser->cfg->num_ifs++] = $2;
816 	}
817 	;
818 server_outgoing_interface: VAR_OUTGOING_INTERFACE STRING_ARG
819 	{
820 		OUTYY(("P(server_outgoing_interface:%s)\n", $2));
821 		if(cfg_parser->cfg->num_out_ifs == 0)
822 			cfg_parser->cfg->out_ifs = calloc(1, sizeof(char*));
823 		else cfg_parser->cfg->out_ifs = realloc(
824 			cfg_parser->cfg->out_ifs,
825 			(cfg_parser->cfg->num_out_ifs+1)*sizeof(char*));
826 		if(!cfg_parser->cfg->out_ifs)
827 			yyerror("out of memory");
828 		else
829 			cfg_parser->cfg->out_ifs[
830 				cfg_parser->cfg->num_out_ifs++] = $2;
831 	}
832 	;
833 server_outgoing_range: VAR_OUTGOING_RANGE STRING_ARG
834 	{
835 		OUTYY(("P(server_outgoing_range:%s)\n", $2));
836 		if(atoi($2) == 0)
837 			yyerror("number expected");
838 		else cfg_parser->cfg->outgoing_num_ports = atoi($2);
839 		free($2);
840 	}
841 	;
842 server_outgoing_port_permit: VAR_OUTGOING_PORT_PERMIT STRING_ARG
843 	{
844 		OUTYY(("P(server_outgoing_port_permit:%s)\n", $2));
845 		if(!cfg_mark_ports($2, 1,
846 			cfg_parser->cfg->outgoing_avail_ports, 65536))
847 			yyerror("port number or range (\"low-high\") expected");
848 		free($2);
849 	}
850 	;
851 server_outgoing_port_avoid: VAR_OUTGOING_PORT_AVOID STRING_ARG
852 	{
853 		OUTYY(("P(server_outgoing_port_avoid:%s)\n", $2));
854 		if(!cfg_mark_ports($2, 0,
855 			cfg_parser->cfg->outgoing_avail_ports, 65536))
856 			yyerror("port number or range (\"low-high\") expected");
857 		free($2);
858 	}
859 	;
860 server_outgoing_num_tcp: VAR_OUTGOING_NUM_TCP STRING_ARG
861 	{
862 		OUTYY(("P(server_outgoing_num_tcp:%s)\n", $2));
863 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
864 			yyerror("number expected");
865 		else cfg_parser->cfg->outgoing_num_tcp = atoi($2);
866 		free($2);
867 	}
868 	;
869 server_incoming_num_tcp: VAR_INCOMING_NUM_TCP STRING_ARG
870 	{
871 		OUTYY(("P(server_incoming_num_tcp:%s)\n", $2));
872 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
873 			yyerror("number expected");
874 		else cfg_parser->cfg->incoming_num_tcp = atoi($2);
875 		free($2);
876 	}
877 	;
878 server_interface_automatic: VAR_INTERFACE_AUTOMATIC STRING_ARG
879 	{
880 		OUTYY(("P(server_interface_automatic:%s)\n", $2));
881 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
882 			yyerror("expected yes or no.");
883 		else cfg_parser->cfg->if_automatic = (strcmp($2, "yes")==0);
884 		free($2);
885 	}
886 	;
887 server_interface_automatic_ports: VAR_INTERFACE_AUTOMATIC_PORTS STRING_ARG
888 	{
889 		OUTYY(("P(server_interface_automatic_ports:%s)\n", $2));
890 		free(cfg_parser->cfg->if_automatic_ports);
891 		cfg_parser->cfg->if_automatic_ports = $2;
892 	}
893 	;
894 server_do_ip4: VAR_DO_IP4 STRING_ARG
895 	{
896 		OUTYY(("P(server_do_ip4:%s)\n", $2));
897 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
898 			yyerror("expected yes or no.");
899 		else cfg_parser->cfg->do_ip4 = (strcmp($2, "yes")==0);
900 		free($2);
901 	}
902 	;
903 server_do_ip6: VAR_DO_IP6 STRING_ARG
904 	{
905 		OUTYY(("P(server_do_ip6:%s)\n", $2));
906 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
907 			yyerror("expected yes or no.");
908 		else cfg_parser->cfg->do_ip6 = (strcmp($2, "yes")==0);
909 		free($2);
910 	}
911 	;
912 server_do_nat64: VAR_DO_NAT64 STRING_ARG
913 	{
914 		OUTYY(("P(server_do_nat64:%s)\n", $2));
915 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
916 			yyerror("expected yes or no.");
917 		else cfg_parser->cfg->do_nat64 = (strcmp($2, "yes")==0);
918 		free($2);
919 	}
920 	;
921 server_do_udp: VAR_DO_UDP STRING_ARG
922 	{
923 		OUTYY(("P(server_do_udp:%s)\n", $2));
924 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
925 			yyerror("expected yes or no.");
926 		else cfg_parser->cfg->do_udp = (strcmp($2, "yes")==0);
927 		free($2);
928 	}
929 	;
930 server_do_tcp: VAR_DO_TCP STRING_ARG
931 	{
932 		OUTYY(("P(server_do_tcp:%s)\n", $2));
933 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
934 			yyerror("expected yes or no.");
935 		else cfg_parser->cfg->do_tcp = (strcmp($2, "yes")==0);
936 		free($2);
937 	}
938 	;
939 server_prefer_ip4: VAR_PREFER_IP4 STRING_ARG
940 	{
941 		OUTYY(("P(server_prefer_ip4:%s)\n", $2));
942 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
943 			yyerror("expected yes or no.");
944 		else cfg_parser->cfg->prefer_ip4 = (strcmp($2, "yes")==0);
945 		free($2);
946 	}
947 	;
948 server_prefer_ip6: VAR_PREFER_IP6 STRING_ARG
949 	{
950 		OUTYY(("P(server_prefer_ip6:%s)\n", $2));
951 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
952 			yyerror("expected yes or no.");
953 		else cfg_parser->cfg->prefer_ip6 = (strcmp($2, "yes")==0);
954 		free($2);
955 	}
956 	;
957 server_tcp_mss: VAR_TCP_MSS STRING_ARG
958 	{
959 		OUTYY(("P(server_tcp_mss:%s)\n", $2));
960 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
961 			yyerror("number expected");
962 		else cfg_parser->cfg->tcp_mss = atoi($2);
963 		free($2);
964 	}
965 	;
966 server_outgoing_tcp_mss: VAR_OUTGOING_TCP_MSS STRING_ARG
967 	{
968 		OUTYY(("P(server_outgoing_tcp_mss:%s)\n", $2));
969 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
970 			yyerror("number expected");
971 		else cfg_parser->cfg->outgoing_tcp_mss = atoi($2);
972 		free($2);
973 	}
974 	;
975 server_tcp_idle_timeout: VAR_TCP_IDLE_TIMEOUT STRING_ARG
976 	{
977 		OUTYY(("P(server_tcp_idle_timeout:%s)\n", $2));
978 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
979 			yyerror("number expected");
980 		else if (atoi($2) > 120000)
981 			cfg_parser->cfg->tcp_idle_timeout = 120000;
982 		else if (atoi($2) < 1)
983 			cfg_parser->cfg->tcp_idle_timeout = 1;
984 		else cfg_parser->cfg->tcp_idle_timeout = atoi($2);
985 		free($2);
986 	}
987 	;
988 server_max_reuse_tcp_queries: VAR_MAX_REUSE_TCP_QUERIES STRING_ARG
989 	{
990 		OUTYY(("P(server_max_reuse_tcp_queries:%s)\n", $2));
991 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
992 			yyerror("number expected");
993 		else if (atoi($2) < 1)
994 			cfg_parser->cfg->max_reuse_tcp_queries = 0;
995 		else cfg_parser->cfg->max_reuse_tcp_queries = atoi($2);
996 		free($2);
997 	}
998 	;
999 server_tcp_reuse_timeout: VAR_TCP_REUSE_TIMEOUT STRING_ARG
1000 	{
1001 		OUTYY(("P(server_tcp_reuse_timeout:%s)\n", $2));
1002 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
1003 			yyerror("number expected");
1004 		else if (atoi($2) < 1)
1005 			cfg_parser->cfg->tcp_reuse_timeout = 0;
1006 		else cfg_parser->cfg->tcp_reuse_timeout = atoi($2);
1007 		free($2);
1008 	}
1009 	;
1010 server_tcp_auth_query_timeout: VAR_TCP_AUTH_QUERY_TIMEOUT STRING_ARG
1011 	{
1012 		OUTYY(("P(server_tcp_auth_query_timeout:%s)\n", $2));
1013 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
1014 			yyerror("number expected");
1015 		else if (atoi($2) < 1)
1016 			cfg_parser->cfg->tcp_auth_query_timeout = 0;
1017 		else cfg_parser->cfg->tcp_auth_query_timeout = atoi($2);
1018 		free($2);
1019 	}
1020 	;
1021 server_tcp_keepalive: VAR_EDNS_TCP_KEEPALIVE STRING_ARG
1022 	{
1023 		OUTYY(("P(server_tcp_keepalive:%s)\n", $2));
1024 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1025 			yyerror("expected yes or no.");
1026 		else cfg_parser->cfg->do_tcp_keepalive = (strcmp($2, "yes")==0);
1027 		free($2);
1028 	}
1029 	;
1030 server_tcp_keepalive_timeout: VAR_EDNS_TCP_KEEPALIVE_TIMEOUT STRING_ARG
1031 	{
1032 		OUTYY(("P(server_tcp_keepalive_timeout:%s)\n", $2));
1033 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
1034 			yyerror("number expected");
1035 		else if (atoi($2) > 6553500)
1036 			cfg_parser->cfg->tcp_keepalive_timeout = 6553500;
1037 		else if (atoi($2) < 1)
1038 			cfg_parser->cfg->tcp_keepalive_timeout = 0;
1039 		else cfg_parser->cfg->tcp_keepalive_timeout = atoi($2);
1040 		free($2);
1041 	}
1042 	;
1043 server_sock_queue_timeout: VAR_SOCK_QUEUE_TIMEOUT STRING_ARG
1044 	{
1045 		OUTYY(("P(server_sock_queue_timeout:%s)\n", $2));
1046 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
1047 			yyerror("number expected");
1048 		else if (atoi($2) > 6553500)
1049 			cfg_parser->cfg->sock_queue_timeout = 6553500;
1050 		else if (atoi($2) < 1)
1051 			cfg_parser->cfg->sock_queue_timeout = 0;
1052 		else cfg_parser->cfg->sock_queue_timeout = atoi($2);
1053 		free($2);
1054 	}
1055 	;
1056 server_tcp_upstream: VAR_TCP_UPSTREAM STRING_ARG
1057 	{
1058 		OUTYY(("P(server_tcp_upstream:%s)\n", $2));
1059 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1060 			yyerror("expected yes or no.");
1061 		else cfg_parser->cfg->tcp_upstream = (strcmp($2, "yes")==0);
1062 		free($2);
1063 	}
1064 	;
1065 server_udp_upstream_without_downstream: VAR_UDP_UPSTREAM_WITHOUT_DOWNSTREAM STRING_ARG
1066 	{
1067 		OUTYY(("P(server_udp_upstream_without_downstream:%s)\n", $2));
1068 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1069 			yyerror("expected yes or no.");
1070 		else cfg_parser->cfg->udp_upstream_without_downstream = (strcmp($2, "yes")==0);
1071 		free($2);
1072 	}
1073 	;
1074 server_ssl_upstream: VAR_SSL_UPSTREAM STRING_ARG
1075 	{
1076 		OUTYY(("P(server_ssl_upstream:%s)\n", $2));
1077 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1078 			yyerror("expected yes or no.");
1079 		else cfg_parser->cfg->ssl_upstream = (strcmp($2, "yes")==0);
1080 		free($2);
1081 	}
1082 	;
1083 server_ssl_service_key: VAR_SSL_SERVICE_KEY STRING_ARG
1084 	{
1085 		OUTYY(("P(server_ssl_service_key:%s)\n", $2));
1086 		free(cfg_parser->cfg->ssl_service_key);
1087 		cfg_parser->cfg->ssl_service_key = $2;
1088 	}
1089 	;
1090 server_ssl_service_pem: VAR_SSL_SERVICE_PEM STRING_ARG
1091 	{
1092 		OUTYY(("P(server_ssl_service_pem:%s)\n", $2));
1093 		free(cfg_parser->cfg->ssl_service_pem);
1094 		cfg_parser->cfg->ssl_service_pem = $2;
1095 	}
1096 	;
1097 server_ssl_port: VAR_SSL_PORT STRING_ARG
1098 	{
1099 		OUTYY(("P(server_ssl_port:%s)\n", $2));
1100 		if(atoi($2) == 0)
1101 			yyerror("port number expected");
1102 		else cfg_parser->cfg->ssl_port = atoi($2);
1103 		free($2);
1104 	}
1105 	;
1106 server_tls_cert_bundle: VAR_TLS_CERT_BUNDLE STRING_ARG
1107 	{
1108 		OUTYY(("P(server_tls_cert_bundle:%s)\n", $2));
1109 		free(cfg_parser->cfg->tls_cert_bundle);
1110 		cfg_parser->cfg->tls_cert_bundle = $2;
1111 	}
1112 	;
1113 server_tls_win_cert: VAR_TLS_WIN_CERT STRING_ARG
1114 	{
1115 		OUTYY(("P(server_tls_win_cert:%s)\n", $2));
1116 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1117 			yyerror("expected yes or no.");
1118 		else cfg_parser->cfg->tls_win_cert = (strcmp($2, "yes")==0);
1119 		free($2);
1120 	}
1121 	;
1122 server_tls_additional_port: VAR_TLS_ADDITIONAL_PORT STRING_ARG
1123 	{
1124 		OUTYY(("P(server_tls_additional_port:%s)\n", $2));
1125 		if(!cfg_strlist_insert(&cfg_parser->cfg->tls_additional_port,
1126 			$2))
1127 			yyerror("out of memory");
1128 	}
1129 	;
1130 server_tls_ciphers: VAR_TLS_CIPHERS STRING_ARG
1131 	{
1132 		OUTYY(("P(server_tls_ciphers:%s)\n", $2));
1133 		free(cfg_parser->cfg->tls_ciphers);
1134 		cfg_parser->cfg->tls_ciphers = $2;
1135 	}
1136 	;
1137 server_tls_ciphersuites: VAR_TLS_CIPHERSUITES STRING_ARG
1138 	{
1139 		OUTYY(("P(server_tls_ciphersuites:%s)\n", $2));
1140 		free(cfg_parser->cfg->tls_ciphersuites);
1141 		cfg_parser->cfg->tls_ciphersuites = $2;
1142 	}
1143 	;
1144 server_tls_session_ticket_keys: VAR_TLS_SESSION_TICKET_KEYS STRING_ARG
1145 	{
1146 		OUTYY(("P(server_tls_session_ticket_keys:%s)\n", $2));
1147 		if(!cfg_strlist_append(&cfg_parser->cfg->tls_session_ticket_keys,
1148 			$2))
1149 			yyerror("out of memory");
1150 	}
1151 	;
1152 server_tls_use_sni: VAR_TLS_USE_SNI STRING_ARG
1153 	{
1154 		OUTYY(("P(server_tls_use_sni:%s)\n", $2));
1155 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1156 			yyerror("expected yes or no.");
1157 		else cfg_parser->cfg->tls_use_sni = (strcmp($2, "yes")==0);
1158 		free($2);
1159 	}
1160 	;
1161 server_tls_protocols: VAR_TLS_PROTOCOLS STRING_ARG
1162 	{
1163 		OUTYY(("P(server_tls_protocols:%s)\n", $2));
1164 		if(!cfg_tls_protocols_is_valid($2))
1165 			yyerror("tls-protocols: valid values are 'TLSv1.2' and 'TLSv1.3'.");
1166 		free(cfg_parser->cfg->tls_protocols);
1167 		cfg_parser->cfg->tls_protocols = $2;
1168 	}
1169 	;
1170 server_https_port: VAR_HTTPS_PORT STRING_ARG
1171 	{
1172 		OUTYY(("P(server_https_port:%s)\n", $2));
1173 		if(atoi($2) == 0)
1174 			yyerror("port number expected");
1175 		else cfg_parser->cfg->https_port = atoi($2);
1176 		free($2);
1177 	};
1178 server_http_endpoint: VAR_HTTP_ENDPOINT STRING_ARG
1179 	{
1180 		OUTYY(("P(server_http_endpoint:%s)\n", $2));
1181 		free(cfg_parser->cfg->http_endpoint);
1182 		if($2 && $2[0] != '/') {
1183 			cfg_parser->cfg->http_endpoint = malloc(strlen($2)+2);
1184 			if(cfg_parser->cfg->http_endpoint) {
1185 				cfg_parser->cfg->http_endpoint[0] = '/';
1186 				memmove(cfg_parser->cfg->http_endpoint+1, $2,
1187 					strlen($2)+1);
1188 			} else {
1189 				yyerror("out of memory");
1190 			}
1191 			free($2);
1192 		} else {
1193 			cfg_parser->cfg->http_endpoint = $2;
1194 		}
1195 	};
1196 server_http_max_streams: VAR_HTTP_MAX_STREAMS STRING_ARG
1197 	{
1198 		OUTYY(("P(server_http_max_streams:%s)\n", $2));
1199 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
1200 			yyerror("number expected");
1201 		else cfg_parser->cfg->http_max_streams = atoi($2);
1202 		free($2);
1203 	};
1204 server_http_query_buffer_size: VAR_HTTP_QUERY_BUFFER_SIZE STRING_ARG
1205 	{
1206 		OUTYY(("P(server_http_query_buffer_size:%s)\n", $2));
1207 		if(!cfg_parse_memsize($2,
1208 			&cfg_parser->cfg->http_query_buffer_size))
1209 			yyerror("memory size expected");
1210 		free($2);
1211 	};
1212 server_http_response_buffer_size: VAR_HTTP_RESPONSE_BUFFER_SIZE STRING_ARG
1213 	{
1214 		OUTYY(("P(server_http_response_buffer_size:%s)\n", $2));
1215 		if(!cfg_parse_memsize($2,
1216 			&cfg_parser->cfg->http_response_buffer_size))
1217 			yyerror("memory size expected");
1218 		free($2);
1219 	};
1220 server_http_nodelay: VAR_HTTP_NODELAY STRING_ARG
1221 	{
1222 		OUTYY(("P(server_http_nodelay:%s)\n", $2));
1223 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1224 			yyerror("expected yes or no.");
1225 		else cfg_parser->cfg->http_nodelay = (strcmp($2, "yes")==0);
1226 		free($2);
1227 	};
1228 server_http_notls_downstream: VAR_HTTP_NOTLS_DOWNSTREAM STRING_ARG
1229 	{
1230 		OUTYY(("P(server_http_notls_downstream:%s)\n", $2));
1231 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1232 			yyerror("expected yes or no.");
1233 		else cfg_parser->cfg->http_notls_downstream = (strcmp($2, "yes")==0);
1234 		free($2);
1235 	};
1236 server_quic_port: VAR_QUIC_PORT STRING_ARG
1237 	{
1238 		OUTYY(("P(server_quic_port:%s)\n", $2));
1239 		if(atoi($2) == 0 && strcmp($2,"0")!=0)
1240 			yyerror("port number expected");
1241 		else {
1242 			cfg_parser->cfg->quic_port = atoi($2);
1243 #ifndef HAVE_NGTCP2
1244 			if (cfg_parser->cfg->quic_port != 0)
1245 				log_warn("%s:%d: Unbound is not compiled with "
1246 					"ngtcp2. This is required to use DNS "
1247 					"over QUIC.", cfg_parser->filename, cfg_parser->line);
1248 #endif
1249 		}
1250 		free($2);
1251 	};
1252 server_quic_size: VAR_QUIC_SIZE STRING_ARG
1253 	{
1254 		OUTYY(("P(server_quic_size:%s)\n", $2));
1255 		if(!cfg_parse_memsize($2, &cfg_parser->cfg->quic_size))
1256 			yyerror("memory size expected");
1257 		free($2);
1258 	};
1259 server_use_systemd: VAR_USE_SYSTEMD STRING_ARG
1260 	{
1261 		OUTYY(("P(server_use_systemd:%s)\n", $2));
1262 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1263 			yyerror("expected yes or no.");
1264 		else cfg_parser->cfg->use_systemd = (strcmp($2, "yes")==0);
1265 		free($2);
1266 	}
1267 	;
1268 server_do_daemonize: VAR_DO_DAEMONIZE STRING_ARG
1269 	{
1270 		OUTYY(("P(server_do_daemonize:%s)\n", $2));
1271 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1272 			yyerror("expected yes or no.");
1273 		else cfg_parser->cfg->do_daemonize = (strcmp($2, "yes")==0);
1274 		free($2);
1275 	}
1276 	;
1277 server_use_syslog: VAR_USE_SYSLOG STRING_ARG
1278 	{
1279 		OUTYY(("P(server_use_syslog:%s)\n", $2));
1280 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1281 			yyerror("expected yes or no.");
1282 		else cfg_parser->cfg->use_syslog = (strcmp($2, "yes")==0);
1283 #if !defined(HAVE_SYSLOG_H) && !defined(UB_ON_WINDOWS)
1284 		if(strcmp($2, "yes") == 0)
1285 			yyerror("no syslog services are available. "
1286 				"(reconfigure and compile to add)");
1287 #endif
1288 		free($2);
1289 	}
1290 	;
1291 server_log_time_ascii: VAR_LOG_TIME_ASCII STRING_ARG
1292 	{
1293 		OUTYY(("P(server_log_time_ascii:%s)\n", $2));
1294 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1295 			yyerror("expected yes or no.");
1296 		else cfg_parser->cfg->log_time_ascii = (strcmp($2, "yes")==0);
1297 		free($2);
1298 	}
1299 	;
1300 server_log_time_iso: VAR_LOG_TIME_ISO STRING_ARG
1301 	{
1302 		OUTYY(("P(server_log_time_iso:%s)\n", $2));
1303 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1304 			yyerror("expected yes or no.");
1305 		else cfg_parser->cfg->log_time_iso = (strcmp($2, "yes")==0);
1306 		free($2);
1307 	}
1308 	;
1309 server_log_queries: VAR_LOG_QUERIES STRING_ARG
1310 	{
1311 		OUTYY(("P(server_log_queries:%s)\n", $2));
1312 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1313 			yyerror("expected yes or no.");
1314 		else cfg_parser->cfg->log_queries = (strcmp($2, "yes")==0);
1315 		free($2);
1316 	}
1317 	;
1318 server_log_replies: VAR_LOG_REPLIES STRING_ARG
1319 	{
1320 		OUTYY(("P(server_log_replies:%s)\n", $2));
1321 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1322 			yyerror("expected yes or no.");
1323 		else cfg_parser->cfg->log_replies = (strcmp($2, "yes")==0);
1324 		free($2);
1325 	}
1326 	;
1327 server_log_tag_queryreply: VAR_LOG_TAG_QUERYREPLY STRING_ARG
1328 	{
1329 		OUTYY(("P(server_log_tag_queryreply:%s)\n", $2));
1330 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1331 			yyerror("expected yes or no.");
1332 		else cfg_parser->cfg->log_tag_queryreply = (strcmp($2, "yes")==0);
1333 		free($2);
1334 	}
1335 	;
1336 server_log_servfail: VAR_LOG_SERVFAIL STRING_ARG
1337 	{
1338 		OUTYY(("P(server_log_servfail:%s)\n", $2));
1339 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1340 			yyerror("expected yes or no.");
1341 		else cfg_parser->cfg->log_servfail = (strcmp($2, "yes")==0);
1342 		free($2);
1343 	}
1344 	;
1345 server_log_destaddr: VAR_LOG_DESTADDR STRING_ARG
1346 	{
1347 		OUTYY(("P(server_log_destaddr:%s)\n", $2));
1348 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1349 			yyerror("expected yes or no.");
1350 		else cfg_parser->cfg->log_destaddr = (strcmp($2, "yes")==0);
1351 		free($2);
1352 	}
1353 	;
1354 server_log_thread_id: VAR_LOG_THREAD_ID STRING_ARG
1355 	{
1356 		OUTYY(("P(server_log_thread_id:%s)\n", $2));
1357 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1358 			yyerror("expected yes or no.");
1359 		else cfg_parser->cfg->log_thread_id = (strcmp($2, "yes")==0);
1360 		free($2);
1361 	}
1362 	;
1363 server_log_local_actions: VAR_LOG_LOCAL_ACTIONS STRING_ARG
1364 	{
1365 		OUTYY(("P(server_log_local_actions:%s)\n", $2));
1366 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1367 			yyerror("expected yes or no.");
1368 		else cfg_parser->cfg->log_local_actions = (strcmp($2, "yes")==0);
1369 		free($2);
1370 	}
1371 	;
1372 server_chroot: VAR_CHROOT STRING_ARG
1373 	{
1374 		OUTYY(("P(server_chroot:%s)\n", $2));
1375 		free(cfg_parser->cfg->chrootdir);
1376 		cfg_parser->cfg->chrootdir = $2;
1377 	}
1378 	;
1379 server_username: VAR_USERNAME STRING_ARG
1380 	{
1381 		OUTYY(("P(server_username:%s)\n", $2));
1382 		free(cfg_parser->cfg->username);
1383 		cfg_parser->cfg->username = $2;
1384 	}
1385 	;
1386 server_directory: VAR_DIRECTORY STRING_ARG
1387 	{
1388 		OUTYY(("P(server_directory:%s)\n", $2));
1389 		free(cfg_parser->cfg->directory);
1390 		cfg_parser->cfg->directory = $2;
1391 		/* change there right away for includes relative to this */
1392 		if($2[0]) {
1393 			char* d;
1394 #ifdef UB_ON_WINDOWS
1395 			w_config_adjust_directory(cfg_parser->cfg);
1396 #endif
1397 			d = cfg_parser->cfg->directory;
1398 			/* adjust directory if we have already chroot,
1399 			 * like, we reread after sighup */
1400 			if(cfg_parser->chroot && cfg_parser->chroot[0] &&
1401 				strncmp(d, cfg_parser->chroot, strlen(
1402 				cfg_parser->chroot)) == 0)
1403 				d += strlen(cfg_parser->chroot);
1404 			if(d[0]) {
1405 				if(chdir(d))
1406 				log_err("cannot chdir to directory: %s (%s)",
1407 					d, strerror(errno));
1408 			}
1409 		}
1410 	}
1411 	;
1412 server_logfile: VAR_LOGFILE STRING_ARG
1413 	{
1414 		OUTYY(("P(server_logfile:%s)\n", $2));
1415 		free(cfg_parser->cfg->logfile);
1416 		cfg_parser->cfg->logfile = $2;
1417 		cfg_parser->cfg->use_syslog = 0;
1418 	}
1419 	;
1420 server_pidfile: VAR_PIDFILE STRING_ARG
1421 	{
1422 		OUTYY(("P(server_pidfile:%s)\n", $2));
1423 		free(cfg_parser->cfg->pidfile);
1424 		cfg_parser->cfg->pidfile = $2;
1425 	}
1426 	;
1427 server_root_hints: VAR_ROOT_HINTS STRING_ARG
1428 	{
1429 		OUTYY(("P(server_root_hints:%s)\n", $2));
1430 		if(!cfg_strlist_insert(&cfg_parser->cfg->root_hints, $2))
1431 			yyerror("out of memory");
1432 	}
1433 	;
1434 server_dlv_anchor_file: VAR_DLV_ANCHOR_FILE STRING_ARG
1435 	{
1436 		OUTYY(("P(server_dlv_anchor_file:%s)\n", $2));
1437 		log_warn("option dlv-anchor-file ignored: DLV is decommissioned");
1438 		free($2);
1439 	}
1440 	;
1441 server_dlv_anchor: VAR_DLV_ANCHOR STRING_ARG
1442 	{
1443 		OUTYY(("P(server_dlv_anchor:%s)\n", $2));
1444 		log_warn("option dlv-anchor ignored: DLV is decommissioned");
1445 		free($2);
1446 	}
1447 	;
1448 server_auto_trust_anchor_file: VAR_AUTO_TRUST_ANCHOR_FILE STRING_ARG
1449 	{
1450 		OUTYY(("P(server_auto_trust_anchor_file:%s)\n", $2));
1451 		if(!cfg_strlist_insert(&cfg_parser->cfg->
1452 			auto_trust_anchor_file_list, $2))
1453 			yyerror("out of memory");
1454 	}
1455 	;
1456 server_trust_anchor_file: VAR_TRUST_ANCHOR_FILE STRING_ARG
1457 	{
1458 		OUTYY(("P(server_trust_anchor_file:%s)\n", $2));
1459 		if(!cfg_strlist_insert(&cfg_parser->cfg->
1460 			trust_anchor_file_list, $2))
1461 			yyerror("out of memory");
1462 	}
1463 	;
1464 server_trusted_keys_file: VAR_TRUSTED_KEYS_FILE STRING_ARG
1465 	{
1466 		OUTYY(("P(server_trusted_keys_file:%s)\n", $2));
1467 		if(!cfg_strlist_insert(&cfg_parser->cfg->
1468 			trusted_keys_file_list, $2))
1469 			yyerror("out of memory");
1470 	}
1471 	;
1472 server_trust_anchor: VAR_TRUST_ANCHOR STRING_ARG
1473 	{
1474 		OUTYY(("P(server_trust_anchor:%s)\n", $2));
1475 		if(!cfg_strlist_insert(&cfg_parser->cfg->trust_anchor_list, $2))
1476 			yyerror("out of memory");
1477 	}
1478 	;
1479 server_trust_anchor_signaling: VAR_TRUST_ANCHOR_SIGNALING STRING_ARG
1480 	{
1481 		OUTYY(("P(server_trust_anchor_signaling:%s)\n", $2));
1482 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1483 			yyerror("expected yes or no.");
1484 		else
1485 			cfg_parser->cfg->trust_anchor_signaling =
1486 				(strcmp($2, "yes")==0);
1487 		free($2);
1488 	}
1489 	;
1490 server_root_key_sentinel: VAR_ROOT_KEY_SENTINEL STRING_ARG
1491 	{
1492 		OUTYY(("P(server_root_key_sentinel:%s)\n", $2));
1493 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1494 			yyerror("expected yes or no.");
1495 		else
1496 			cfg_parser->cfg->root_key_sentinel =
1497 				(strcmp($2, "yes")==0);
1498 		free($2);
1499 	}
1500 	;
1501 server_domain_insecure: VAR_DOMAIN_INSECURE STRING_ARG
1502 	{
1503 		OUTYY(("P(server_domain_insecure:%s)\n", $2));
1504 		if(!cfg_strlist_insert(&cfg_parser->cfg->domain_insecure, $2))
1505 			yyerror("out of memory");
1506 	}
1507 	;
1508 server_hide_identity: VAR_HIDE_IDENTITY STRING_ARG
1509 	{
1510 		OUTYY(("P(server_hide_identity:%s)\n", $2));
1511 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1512 			yyerror("expected yes or no.");
1513 		else cfg_parser->cfg->hide_identity = (strcmp($2, "yes")==0);
1514 		free($2);
1515 	}
1516 	;
1517 server_hide_version: VAR_HIDE_VERSION STRING_ARG
1518 	{
1519 		OUTYY(("P(server_hide_version:%s)\n", $2));
1520 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1521 			yyerror("expected yes or no.");
1522 		else cfg_parser->cfg->hide_version = (strcmp($2, "yes")==0);
1523 		free($2);
1524 	}
1525 	;
1526 server_hide_trustanchor: VAR_HIDE_TRUSTANCHOR STRING_ARG
1527 	{
1528 		OUTYY(("P(server_hide_trustanchor:%s)\n", $2));
1529 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1530 			yyerror("expected yes or no.");
1531 		else cfg_parser->cfg->hide_trustanchor = (strcmp($2, "yes")==0);
1532 		free($2);
1533 	}
1534 	;
1535 server_hide_http_user_agent: VAR_HIDE_HTTP_USER_AGENT STRING_ARG
1536 	{
1537 		OUTYY(("P(server_hide_user_agent:%s)\n", $2));
1538 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1539 			yyerror("expected yes or no.");
1540 		else cfg_parser->cfg->hide_http_user_agent = (strcmp($2, "yes")==0);
1541 		free($2);
1542 	}
1543 	;
1544 server_identity: VAR_IDENTITY STRING_ARG
1545 	{
1546 		OUTYY(("P(server_identity:%s)\n", $2));
1547 		free(cfg_parser->cfg->identity);
1548 		cfg_parser->cfg->identity = $2;
1549 	}
1550 	;
1551 server_version: VAR_VERSION STRING_ARG
1552 	{
1553 		OUTYY(("P(server_version:%s)\n", $2));
1554 		free(cfg_parser->cfg->version);
1555 		cfg_parser->cfg->version = $2;
1556 	}
1557 	;
1558 server_http_user_agent: VAR_HTTP_USER_AGENT STRING_ARG
1559 	{
1560 		OUTYY(("P(server_http_user_agent:%s)\n", $2));
1561 		free(cfg_parser->cfg->http_user_agent);
1562 		cfg_parser->cfg->http_user_agent = $2;
1563 	}
1564 	;
1565 server_nsid: VAR_NSID STRING_ARG
1566 	{
1567 		OUTYY(("P(server_nsid:%s)\n", $2));
1568 		free(cfg_parser->cfg->nsid_cfg_str);
1569 		cfg_parser->cfg->nsid_cfg_str = $2;
1570 		free(cfg_parser->cfg->nsid);
1571 		cfg_parser->cfg->nsid = NULL;
1572 		cfg_parser->cfg->nsid_len = 0;
1573 		if (*$2 == 0)
1574 			; /* pass; empty string is not setting nsid */
1575 		else if (!(cfg_parser->cfg->nsid = cfg_parse_nsid(
1576 					$2, &cfg_parser->cfg->nsid_len)))
1577 			yyerror("the NSID must be either a hex string or an "
1578 			    "ascii character string prepended with ascii_.");
1579 	}
1580 	;
1581 server_so_rcvbuf: VAR_SO_RCVBUF STRING_ARG
1582 	{
1583 		OUTYY(("P(server_so_rcvbuf:%s)\n", $2));
1584 		if(!cfg_parse_memsize($2, &cfg_parser->cfg->so_rcvbuf))
1585 			yyerror("buffer size expected");
1586 		free($2);
1587 	}
1588 	;
1589 server_so_sndbuf: VAR_SO_SNDBUF STRING_ARG
1590 	{
1591 		OUTYY(("P(server_so_sndbuf:%s)\n", $2));
1592 		if(!cfg_parse_memsize($2, &cfg_parser->cfg->so_sndbuf))
1593 			yyerror("buffer size expected");
1594 		free($2);
1595 	}
1596 	;
1597 server_so_reuseport: VAR_SO_REUSEPORT STRING_ARG
1598 	{
1599 		OUTYY(("P(server_so_reuseport:%s)\n", $2));
1600 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1601 			yyerror("expected yes or no.");
1602 		else cfg_parser->cfg->so_reuseport =
1603 			(strcmp($2, "yes")==0);
1604 		free($2);
1605 	}
1606 	;
1607 server_ip_transparent: VAR_IP_TRANSPARENT STRING_ARG
1608 	{
1609 		OUTYY(("P(server_ip_transparent:%s)\n", $2));
1610 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1611 			yyerror("expected yes or no.");
1612 		else cfg_parser->cfg->ip_transparent =
1613 			(strcmp($2, "yes")==0);
1614 		free($2);
1615 	}
1616 	;
1617 server_ip_freebind: VAR_IP_FREEBIND STRING_ARG
1618 	{
1619 		OUTYY(("P(server_ip_freebind:%s)\n", $2));
1620 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1621 			yyerror("expected yes or no.");
1622 		else cfg_parser->cfg->ip_freebind =
1623 			(strcmp($2, "yes")==0);
1624 		free($2);
1625 	}
1626 	;
1627 server_ip_dscp: VAR_IP_DSCP STRING_ARG
1628 	{
1629 		OUTYY(("P(server_ip_dscp:%s)\n", $2));
1630 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
1631 			yyerror("number expected");
1632 		else if (atoi($2) > 63)
1633 			yyerror("value too large (max 63)");
1634 		else if (atoi($2) < 0)
1635 			yyerror("value too small (min 0)");
1636 		else
1637 			cfg_parser->cfg->ip_dscp = atoi($2);
1638 		free($2);
1639 	}
1640 	;
1641 server_stream_wait_size: VAR_STREAM_WAIT_SIZE STRING_ARG
1642 	{
1643 		OUTYY(("P(server_stream_wait_size:%s)\n", $2));
1644 		if(!cfg_parse_memsize($2, &cfg_parser->cfg->stream_wait_size))
1645 			yyerror("memory size expected");
1646 		free($2);
1647 	}
1648 	;
1649 server_edns_buffer_size: VAR_EDNS_BUFFER_SIZE STRING_ARG
1650 	{
1651 		OUTYY(("P(server_edns_buffer_size:%s)\n", $2));
1652 		if(atoi($2) == 0)
1653 			yyerror("number expected");
1654 		else if (atoi($2) < 12)
1655 			yyerror("edns buffer size too small");
1656 		else if (atoi($2) > 65535)
1657 			cfg_parser->cfg->edns_buffer_size = 65535;
1658 		else cfg_parser->cfg->edns_buffer_size = atoi($2);
1659 		free($2);
1660 	}
1661 	;
1662 server_msg_buffer_size: VAR_MSG_BUFFER_SIZE STRING_ARG
1663 	{
1664 		OUTYY(("P(server_msg_buffer_size:%s)\n", $2));
1665 		if(atoi($2) == 0)
1666 			yyerror("number expected");
1667 		else if (atoi($2) < 4096)
1668 			yyerror("message buffer size too small (use 4096)");
1669 		else cfg_parser->cfg->msg_buffer_size = atoi($2);
1670 		free($2);
1671 	}
1672 	;
1673 server_msg_cache_size: VAR_MSG_CACHE_SIZE STRING_ARG
1674 	{
1675 		OUTYY(("P(server_msg_cache_size:%s)\n", $2));
1676 		if(!cfg_parse_memsize($2, &cfg_parser->cfg->msg_cache_size))
1677 			yyerror("memory size expected");
1678 		free($2);
1679 	}
1680 	;
1681 server_msg_cache_slabs: VAR_MSG_CACHE_SLABS STRING_ARG
1682 	{
1683 		OUTYY(("P(server_msg_cache_slabs:%s)\n", $2));
1684 		if(atoi($2) == 0) {
1685 			yyerror("number expected");
1686 		} else {
1687 			cfg_parser->cfg->msg_cache_slabs = atoi($2);
1688 			if(!is_pow2(cfg_parser->cfg->msg_cache_slabs))
1689 				yyerror("must be a power of 2");
1690 		}
1691 		free($2);
1692 	}
1693 	;
1694 server_num_queries_per_thread: VAR_NUM_QUERIES_PER_THREAD STRING_ARG
1695 	{
1696 		OUTYY(("P(server_num_queries_per_thread:%s)\n", $2));
1697 		if(atoi($2) == 0)
1698 			yyerror("number expected");
1699 		else cfg_parser->cfg->num_queries_per_thread = atoi($2);
1700 		free($2);
1701 	}
1702 	;
1703 server_jostle_timeout: VAR_JOSTLE_TIMEOUT STRING_ARG
1704 	{
1705 		OUTYY(("P(server_jostle_timeout:%s)\n", $2));
1706 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
1707 			yyerror("number expected");
1708 		else cfg_parser->cfg->jostle_time = atoi($2);
1709 		free($2);
1710 	}
1711 	;
1712 server_delay_close: VAR_DELAY_CLOSE STRING_ARG
1713 	{
1714 		OUTYY(("P(server_delay_close:%s)\n", $2));
1715 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
1716 			yyerror("number expected");
1717 		else cfg_parser->cfg->delay_close = atoi($2);
1718 		free($2);
1719 	}
1720 	;
1721 server_udp_connect: VAR_UDP_CONNECT STRING_ARG
1722 	{
1723 		OUTYY(("P(server_udp_connect:%s)\n", $2));
1724 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1725 			yyerror("expected yes or no.");
1726 		else cfg_parser->cfg->udp_connect = (strcmp($2, "yes")==0);
1727 		free($2);
1728 	}
1729 	;
1730 server_unblock_lan_zones: VAR_UNBLOCK_LAN_ZONES STRING_ARG
1731 	{
1732 		OUTYY(("P(server_unblock_lan_zones:%s)\n", $2));
1733 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1734 			yyerror("expected yes or no.");
1735 		else cfg_parser->cfg->unblock_lan_zones =
1736 			(strcmp($2, "yes")==0);
1737 		free($2);
1738 	}
1739 	;
1740 server_insecure_lan_zones: VAR_INSECURE_LAN_ZONES STRING_ARG
1741 	{
1742 		OUTYY(("P(server_insecure_lan_zones:%s)\n", $2));
1743 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1744 			yyerror("expected yes or no.");
1745 		else cfg_parser->cfg->insecure_lan_zones =
1746 			(strcmp($2, "yes")==0);
1747 		free($2);
1748 	}
1749 	;
1750 server_rrset_cache_size: VAR_RRSET_CACHE_SIZE STRING_ARG
1751 	{
1752 		OUTYY(("P(server_rrset_cache_size:%s)\n", $2));
1753 		if(!cfg_parse_memsize($2, &cfg_parser->cfg->rrset_cache_size))
1754 			yyerror("memory size expected");
1755 		free($2);
1756 	}
1757 	;
1758 server_rrset_cache_slabs: VAR_RRSET_CACHE_SLABS STRING_ARG
1759 	{
1760 		OUTYY(("P(server_rrset_cache_slabs:%s)\n", $2));
1761 		if(atoi($2) == 0) {
1762 			yyerror("number expected");
1763 		} else {
1764 			cfg_parser->cfg->rrset_cache_slabs = atoi($2);
1765 			if(!is_pow2(cfg_parser->cfg->rrset_cache_slabs))
1766 				yyerror("must be a power of 2");
1767 		}
1768 		free($2);
1769 	}
1770 	;
1771 server_infra_host_ttl: VAR_INFRA_HOST_TTL STRING_ARG
1772 	{
1773 		OUTYY(("P(server_infra_host_ttl:%s)\n", $2));
1774 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
1775 			yyerror("number expected");
1776 		else cfg_parser->cfg->host_ttl = atoi($2);
1777 		free($2);
1778 	}
1779 	;
1780 server_infra_lame_ttl: VAR_INFRA_LAME_TTL STRING_ARG
1781 	{
1782 		OUTYY(("P(server_infra_lame_ttl:%s)\n", $2));
1783 		verbose(VERB_DETAIL, "ignored infra-lame-ttl: %s (option "
1784 			"removed, use infra-host-ttl)", $2);
1785 		free($2);
1786 	}
1787 	;
1788 server_infra_cache_numhosts: VAR_INFRA_CACHE_NUMHOSTS STRING_ARG
1789 	{
1790 		OUTYY(("P(server_infra_cache_numhosts:%s)\n", $2));
1791 		if(atoi($2) == 0)
1792 			yyerror("number expected");
1793 		else cfg_parser->cfg->infra_cache_numhosts = atoi($2);
1794 		free($2);
1795 	}
1796 	;
1797 server_infra_cache_lame_size: VAR_INFRA_CACHE_LAME_SIZE STRING_ARG
1798 	{
1799 		OUTYY(("P(server_infra_cache_lame_size:%s)\n", $2));
1800 		verbose(VERB_DETAIL, "ignored infra-cache-lame-size: %s "
1801 			"(option removed, use infra-cache-numhosts)", $2);
1802 		free($2);
1803 	}
1804 	;
1805 server_infra_cache_slabs: VAR_INFRA_CACHE_SLABS STRING_ARG
1806 	{
1807 		OUTYY(("P(server_infra_cache_slabs:%s)\n", $2));
1808 		if(atoi($2) == 0) {
1809 			yyerror("number expected");
1810 		} else {
1811 			cfg_parser->cfg->infra_cache_slabs = atoi($2);
1812 			if(!is_pow2(cfg_parser->cfg->infra_cache_slabs))
1813 				yyerror("must be a power of 2");
1814 		}
1815 		free($2);
1816 	}
1817 	;
1818 server_infra_cache_min_rtt: VAR_INFRA_CACHE_MIN_RTT STRING_ARG
1819 	{
1820 		OUTYY(("P(server_infra_cache_min_rtt:%s)\n", $2));
1821 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
1822 			yyerror("number expected");
1823 		else cfg_parser->cfg->infra_cache_min_rtt = atoi($2);
1824 		free($2);
1825 	}
1826 	;
1827 server_infra_cache_max_rtt: VAR_INFRA_CACHE_MAX_RTT STRING_ARG
1828 	{
1829 		OUTYY(("P(server_infra_cache_max_rtt:%s)\n", $2));
1830 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
1831 			yyerror("number expected");
1832 		else cfg_parser->cfg->infra_cache_max_rtt = atoi($2);
1833 		free($2);
1834 	}
1835 	;
1836 server_infra_keep_probing: VAR_INFRA_KEEP_PROBING STRING_ARG
1837 	{
1838 		OUTYY(("P(server_infra_keep_probing:%s)\n", $2));
1839 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1840 			yyerror("expected yes or no.");
1841 		else cfg_parser->cfg->infra_keep_probing =
1842 			(strcmp($2, "yes")==0);
1843 		free($2);
1844 	}
1845 	;
1846 server_target_fetch_policy: VAR_TARGET_FETCH_POLICY STRING_ARG
1847 	{
1848 		OUTYY(("P(server_target_fetch_policy:%s)\n", $2));
1849 		free(cfg_parser->cfg->target_fetch_policy);
1850 		cfg_parser->cfg->target_fetch_policy = $2;
1851 	}
1852 	;
1853 server_harden_short_bufsize: VAR_HARDEN_SHORT_BUFSIZE STRING_ARG
1854 	{
1855 		OUTYY(("P(server_harden_short_bufsize:%s)\n", $2));
1856 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1857 			yyerror("expected yes or no.");
1858 		else cfg_parser->cfg->harden_short_bufsize =
1859 			(strcmp($2, "yes")==0);
1860 		free($2);
1861 	}
1862 	;
1863 server_harden_large_queries: VAR_HARDEN_LARGE_QUERIES STRING_ARG
1864 	{
1865 		OUTYY(("P(server_harden_large_queries:%s)\n", $2));
1866 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1867 			yyerror("expected yes or no.");
1868 		else cfg_parser->cfg->harden_large_queries =
1869 			(strcmp($2, "yes")==0);
1870 		free($2);
1871 	}
1872 	;
1873 server_harden_glue: VAR_HARDEN_GLUE STRING_ARG
1874 	{
1875 		OUTYY(("P(server_harden_glue:%s)\n", $2));
1876 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1877 			yyerror("expected yes or no.");
1878 		else cfg_parser->cfg->harden_glue =
1879 			(strcmp($2, "yes")==0);
1880 		free($2);
1881 	}
1882 	;
1883 server_harden_unverified_glue: VAR_HARDEN_UNVERIFIED_GLUE STRING_ARG
1884        {
1885                OUTYY(("P(server_harden_unverified_glue:%s)\n", $2));
1886                if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1887                        yyerror("expected yes or no.");
1888                else cfg_parser->cfg->harden_unverified_glue =
1889                        (strcmp($2, "yes")==0);
1890                free($2);
1891        }
1892        ;
1893 server_harden_dnssec_stripped: VAR_HARDEN_DNSSEC_STRIPPED STRING_ARG
1894 	{
1895 		OUTYY(("P(server_harden_dnssec_stripped:%s)\n", $2));
1896 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1897 			yyerror("expected yes or no.");
1898 		else cfg_parser->cfg->harden_dnssec_stripped =
1899 			(strcmp($2, "yes")==0);
1900 		free($2);
1901 	}
1902 	;
1903 server_harden_below_nxdomain: VAR_HARDEN_BELOW_NXDOMAIN STRING_ARG
1904 	{
1905 		OUTYY(("P(server_harden_below_nxdomain:%s)\n", $2));
1906 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1907 			yyerror("expected yes or no.");
1908 		else cfg_parser->cfg->harden_below_nxdomain =
1909 			(strcmp($2, "yes")==0);
1910 		free($2);
1911 	}
1912 	;
1913 server_harden_referral_path: VAR_HARDEN_REFERRAL_PATH STRING_ARG
1914 	{
1915 		OUTYY(("P(server_harden_referral_path:%s)\n", $2));
1916 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1917 			yyerror("expected yes or no.");
1918 		else cfg_parser->cfg->harden_referral_path =
1919 			(strcmp($2, "yes")==0);
1920 		free($2);
1921 	}
1922 	;
1923 server_harden_algo_downgrade: VAR_HARDEN_ALGO_DOWNGRADE STRING_ARG
1924 	{
1925 		OUTYY(("P(server_harden_algo_downgrade:%s)\n", $2));
1926 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1927 			yyerror("expected yes or no.");
1928 		else cfg_parser->cfg->harden_algo_downgrade =
1929 			(strcmp($2, "yes")==0);
1930 		free($2);
1931 	}
1932 	;
1933 server_harden_unknown_additional: VAR_HARDEN_UNKNOWN_ADDITIONAL STRING_ARG
1934 	{
1935 		OUTYY(("P(server_harden_unknown_additional:%s)\n", $2));
1936 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1937 			yyerror("expected yes or no.");
1938 		else cfg_parser->cfg->harden_unknown_additional =
1939 			(strcmp($2, "yes")==0);
1940 		free($2);
1941 	}
1942 	;
1943 server_use_caps_for_id: VAR_USE_CAPS_FOR_ID STRING_ARG
1944 	{
1945 		OUTYY(("P(server_use_caps_for_id:%s)\n", $2));
1946 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1947 			yyerror("expected yes or no.");
1948 		else cfg_parser->cfg->use_caps_bits_for_id =
1949 			(strcmp($2, "yes")==0);
1950 		free($2);
1951 	}
1952 	;
1953 server_caps_whitelist: VAR_CAPS_WHITELIST STRING_ARG
1954 	{
1955 		OUTYY(("P(server_caps_whitelist:%s)\n", $2));
1956 		if(!cfg_strlist_insert(&cfg_parser->cfg->caps_whitelist, $2))
1957 			yyerror("out of memory");
1958 	}
1959 	;
1960 server_private_address: VAR_PRIVATE_ADDRESS STRING_ARG
1961 	{
1962 		OUTYY(("P(server_private_address:%s)\n", $2));
1963 		if(!cfg_strlist_insert(&cfg_parser->cfg->private_address, $2))
1964 			yyerror("out of memory");
1965 	}
1966 	;
1967 server_private_domain: VAR_PRIVATE_DOMAIN STRING_ARG
1968 	{
1969 		OUTYY(("P(server_private_domain:%s)\n", $2));
1970 		if(!cfg_strlist_insert(&cfg_parser->cfg->private_domain, $2))
1971 			yyerror("out of memory");
1972 	}
1973 	;
1974 server_prefetch: VAR_PREFETCH STRING_ARG
1975 	{
1976 		OUTYY(("P(server_prefetch:%s)\n", $2));
1977 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1978 			yyerror("expected yes or no.");
1979 		else cfg_parser->cfg->prefetch = (strcmp($2, "yes")==0);
1980 		free($2);
1981 	}
1982 	;
1983 server_prefetch_key: VAR_PREFETCH_KEY STRING_ARG
1984 	{
1985 		OUTYY(("P(server_prefetch_key:%s)\n", $2));
1986 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1987 			yyerror("expected yes or no.");
1988 		else cfg_parser->cfg->prefetch_key = (strcmp($2, "yes")==0);
1989 		free($2);
1990 	}
1991 	;
1992 server_deny_any: VAR_DENY_ANY STRING_ARG
1993 	{
1994 		OUTYY(("P(server_deny_any:%s)\n", $2));
1995 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1996 			yyerror("expected yes or no.");
1997 		else cfg_parser->cfg->deny_any = (strcmp($2, "yes")==0);
1998 		free($2);
1999 	}
2000 	;
2001 server_unwanted_reply_threshold: VAR_UNWANTED_REPLY_THRESHOLD STRING_ARG
2002 	{
2003 		OUTYY(("P(server_unwanted_reply_threshold:%s)\n", $2));
2004 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2005 			yyerror("number expected");
2006 		else cfg_parser->cfg->unwanted_threshold = atoi($2);
2007 		free($2);
2008 	}
2009 	;
2010 server_do_not_query_address: VAR_DO_NOT_QUERY_ADDRESS STRING_ARG
2011 	{
2012 		OUTYY(("P(server_do_not_query_address:%s)\n", $2));
2013 		if(!cfg_strlist_insert(&cfg_parser->cfg->donotqueryaddrs, $2))
2014 			yyerror("out of memory");
2015 	}
2016 	;
2017 server_do_not_query_localhost: VAR_DO_NOT_QUERY_LOCALHOST STRING_ARG
2018 	{
2019 		OUTYY(("P(server_do_not_query_localhost:%s)\n", $2));
2020 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2021 			yyerror("expected yes or no.");
2022 		else cfg_parser->cfg->donotquery_localhost =
2023 			(strcmp($2, "yes")==0);
2024 		free($2);
2025 	}
2026 	;
2027 server_access_control: VAR_ACCESS_CONTROL STRING_ARG STRING_ARG
2028 	{
2029 		OUTYY(("P(server_access_control:%s %s)\n", $2, $3));
2030 		validate_acl_action($3);
2031 		if(!cfg_str2list_insert(&cfg_parser->cfg->acls, $2, $3))
2032 			fatal_exit("out of memory adding acl");
2033 	}
2034 	;
2035 server_interface_action: VAR_INTERFACE_ACTION STRING_ARG STRING_ARG
2036 	{
2037 		OUTYY(("P(server_interface_action:%s %s)\n", $2, $3));
2038 		validate_acl_action($3);
2039 		if(!cfg_str2list_insert(
2040 			&cfg_parser->cfg->interface_actions, $2, $3))
2041 			fatal_exit("out of memory adding acl");
2042 	}
2043 	;
2044 server_module_conf: VAR_MODULE_CONF STRING_ARG
2045 	{
2046 		OUTYY(("P(server_module_conf:%s)\n", $2));
2047 		free(cfg_parser->cfg->module_conf);
2048 		cfg_parser->cfg->module_conf = $2;
2049 	}
2050 	;
2051 server_val_override_date: VAR_VAL_OVERRIDE_DATE STRING_ARG
2052 	{
2053 		OUTYY(("P(server_val_override_date:%s)\n", $2));
2054 		if(*$2 == '\0' || strcmp($2, "0") == 0) {
2055 			cfg_parser->cfg->val_date_override = 0;
2056 		} else if(strlen($2) == 14) {
2057 			cfg_parser->cfg->val_date_override =
2058 				cfg_convert_timeval($2);
2059 			if(!cfg_parser->cfg->val_date_override)
2060 				yyerror("bad date/time specification");
2061 		} else {
2062 			if(atoi($2) == 0)
2063 				yyerror("number expected");
2064 			cfg_parser->cfg->val_date_override = atoi($2);
2065 		}
2066 		free($2);
2067 	}
2068 	;
2069 server_val_sig_skew_min: VAR_VAL_SIG_SKEW_MIN STRING_ARG
2070 	{
2071 		OUTYY(("P(server_val_sig_skew_min:%s)\n", $2));
2072 		if(*$2 == '\0' || strcmp($2, "0") == 0) {
2073 			cfg_parser->cfg->val_sig_skew_min = 0;
2074 		} else {
2075 			cfg_parser->cfg->val_sig_skew_min = atoi($2);
2076 			if(!cfg_parser->cfg->val_sig_skew_min)
2077 				yyerror("number expected");
2078 		}
2079 		free($2);
2080 	}
2081 	;
2082 server_val_sig_skew_max: VAR_VAL_SIG_SKEW_MAX STRING_ARG
2083 	{
2084 		OUTYY(("P(server_val_sig_skew_max:%s)\n", $2));
2085 		if(*$2 == '\0' || strcmp($2, "0") == 0) {
2086 			cfg_parser->cfg->val_sig_skew_max = 0;
2087 		} else {
2088 			cfg_parser->cfg->val_sig_skew_max = atoi($2);
2089 			if(!cfg_parser->cfg->val_sig_skew_max)
2090 				yyerror("number expected");
2091 		}
2092 		free($2);
2093 	}
2094 	;
2095 server_val_max_restart: VAR_VAL_MAX_RESTART STRING_ARG
2096 	{
2097 		OUTYY(("P(server_val_max_restart:%s)\n", $2));
2098 		if(*$2 == '\0' || strcmp($2, "0") == 0) {
2099 			cfg_parser->cfg->val_max_restart = 0;
2100 		} else {
2101 			cfg_parser->cfg->val_max_restart = atoi($2);
2102 			if(!cfg_parser->cfg->val_max_restart)
2103 				yyerror("number expected");
2104 		}
2105 		free($2);
2106 	}
2107 	;
2108 server_cache_max_ttl: VAR_CACHE_MAX_TTL STRING_ARG
2109 	{
2110 		OUTYY(("P(server_cache_max_ttl:%s)\n", $2));
2111 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2112 			yyerror("number expected");
2113 		else cfg_parser->cfg->max_ttl = atoi($2);
2114 		free($2);
2115 	}
2116 	;
2117 server_cache_max_negative_ttl: VAR_CACHE_MAX_NEGATIVE_TTL STRING_ARG
2118 	{
2119 		OUTYY(("P(server_cache_max_negative_ttl:%s)\n", $2));
2120 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2121 			yyerror("number expected");
2122 		else cfg_parser->cfg->max_negative_ttl = atoi($2);
2123 		free($2);
2124 	}
2125 	;
2126 server_cache_min_negative_ttl: VAR_CACHE_MIN_NEGATIVE_TTL STRING_ARG
2127 	{
2128 		OUTYY(("P(server_cache_min_negative_ttl:%s)\n", $2));
2129 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2130 			yyerror("number expected");
2131 		else cfg_parser->cfg->min_negative_ttl = atoi($2);
2132 		free($2);
2133 	}
2134 	;
2135 server_cache_min_ttl: VAR_CACHE_MIN_TTL STRING_ARG
2136 	{
2137 		OUTYY(("P(server_cache_min_ttl:%s)\n", $2));
2138 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2139 			yyerror("number expected");
2140 		else cfg_parser->cfg->min_ttl = atoi($2);
2141 		free($2);
2142 	}
2143 	;
2144 server_bogus_ttl: VAR_BOGUS_TTL STRING_ARG
2145 	{
2146 		OUTYY(("P(server_bogus_ttl:%s)\n", $2));
2147 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2148 			yyerror("number expected");
2149 		else cfg_parser->cfg->bogus_ttl = atoi($2);
2150 		free($2);
2151 	}
2152 	;
2153 server_val_clean_additional: VAR_VAL_CLEAN_ADDITIONAL STRING_ARG
2154 	{
2155 		OUTYY(("P(server_val_clean_additional:%s)\n", $2));
2156 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2157 			yyerror("expected yes or no.");
2158 		else cfg_parser->cfg->val_clean_additional =
2159 			(strcmp($2, "yes")==0);
2160 		free($2);
2161 	}
2162 	;
2163 server_val_permissive_mode: VAR_VAL_PERMISSIVE_MODE STRING_ARG
2164 	{
2165 		OUTYY(("P(server_val_permissive_mode:%s)\n", $2));
2166 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2167 			yyerror("expected yes or no.");
2168 		else cfg_parser->cfg->val_permissive_mode =
2169 			(strcmp($2, "yes")==0);
2170 		free($2);
2171 	}
2172 	;
2173 server_aggressive_nsec: VAR_AGGRESSIVE_NSEC STRING_ARG
2174 	{
2175 		OUTYY(("P(server_aggressive_nsec:%s)\n", $2));
2176 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2177 			yyerror("expected yes or no.");
2178 		else
2179 			cfg_parser->cfg->aggressive_nsec =
2180 				(strcmp($2, "yes")==0);
2181 		free($2);
2182 	}
2183 	;
2184 server_ignore_cd_flag: VAR_IGNORE_CD_FLAG STRING_ARG
2185 	{
2186 		OUTYY(("P(server_ignore_cd_flag:%s)\n", $2));
2187 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2188 			yyerror("expected yes or no.");
2189 		else cfg_parser->cfg->ignore_cd = (strcmp($2, "yes")==0);
2190 		free($2);
2191 	}
2192 	;
2193 server_disable_edns_do: VAR_DISABLE_EDNS_DO STRING_ARG
2194 	{
2195 		OUTYY(("P(server_disable_edns_do:%s)\n", $2));
2196 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2197 			yyerror("expected yes or no.");
2198 		else cfg_parser->cfg->disable_edns_do = (strcmp($2, "yes")==0);
2199 		free($2);
2200 	}
2201 	;
2202 server_serve_expired: VAR_SERVE_EXPIRED STRING_ARG
2203 	{
2204 		OUTYY(("P(server_serve_expired:%s)\n", $2));
2205 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2206 			yyerror("expected yes or no.");
2207 		else cfg_parser->cfg->serve_expired = (strcmp($2, "yes")==0);
2208 		free($2);
2209 	}
2210 	;
2211 server_serve_expired_ttl: VAR_SERVE_EXPIRED_TTL STRING_ARG
2212 	{
2213 		OUTYY(("P(server_serve_expired_ttl:%s)\n", $2));
2214 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2215 			yyerror("number expected");
2216 		else cfg_parser->cfg->serve_expired_ttl = atoi($2);
2217 		free($2);
2218 	}
2219 	;
2220 server_serve_expired_ttl_reset: VAR_SERVE_EXPIRED_TTL_RESET STRING_ARG
2221 	{
2222 		OUTYY(("P(server_serve_expired_ttl_reset:%s)\n", $2));
2223 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2224 			yyerror("expected yes or no.");
2225 		else cfg_parser->cfg->serve_expired_ttl_reset = (strcmp($2, "yes")==0);
2226 		free($2);
2227 	}
2228 	;
2229 server_serve_expired_reply_ttl: VAR_SERVE_EXPIRED_REPLY_TTL STRING_ARG
2230 	{
2231 		OUTYY(("P(server_serve_expired_reply_ttl:%s)\n", $2));
2232 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2233 			yyerror("number expected");
2234 		else cfg_parser->cfg->serve_expired_reply_ttl = atoi($2);
2235 		free($2);
2236 	}
2237 	;
2238 server_serve_expired_client_timeout: VAR_SERVE_EXPIRED_CLIENT_TIMEOUT STRING_ARG
2239 	{
2240 		OUTYY(("P(server_serve_expired_client_timeout:%s)\n", $2));
2241 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2242 			yyerror("number expected");
2243 		else cfg_parser->cfg->serve_expired_client_timeout = atoi($2);
2244 		free($2);
2245 	}
2246 	;
2247 server_ede_serve_expired: VAR_EDE_SERVE_EXPIRED STRING_ARG
2248 	{
2249 		OUTYY(("P(server_ede_serve_expired:%s)\n", $2));
2250 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2251 			yyerror("expected yes or no.");
2252 		else cfg_parser->cfg->ede_serve_expired = (strcmp($2, "yes")==0);
2253 		free($2);
2254 	}
2255 	;
2256 server_serve_original_ttl: VAR_SERVE_ORIGINAL_TTL STRING_ARG
2257 	{
2258 		OUTYY(("P(server_serve_original_ttl:%s)\n", $2));
2259 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2260 			yyerror("expected yes or no.");
2261 		else cfg_parser->cfg->serve_original_ttl = (strcmp($2, "yes")==0);
2262 		free($2);
2263 	}
2264 	;
2265 server_fake_dsa: VAR_FAKE_DSA STRING_ARG
2266 	{
2267 		OUTYY(("P(server_fake_dsa:%s)\n", $2));
2268 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2269 			yyerror("expected yes or no.");
2270 #if defined(HAVE_SSL) || defined(HAVE_NETTLE)
2271 		else fake_dsa = (strcmp($2, "yes")==0);
2272 		if(fake_dsa)
2273 			log_warn("test option fake_dsa is enabled");
2274 #endif
2275 		free($2);
2276 	}
2277 	;
2278 server_fake_sha1: VAR_FAKE_SHA1 STRING_ARG
2279 	{
2280 		OUTYY(("P(server_fake_sha1:%s)\n", $2));
2281 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2282 			yyerror("expected yes or no.");
2283 #if defined(HAVE_SSL) || defined(HAVE_NETTLE)
2284 		else fake_sha1 = (strcmp($2, "yes")==0);
2285 		if(fake_sha1)
2286 			log_warn("test option fake_sha1 is enabled");
2287 #endif
2288 		free($2);
2289 	}
2290 	;
2291 server_val_log_level: VAR_VAL_LOG_LEVEL STRING_ARG
2292 	{
2293 		OUTYY(("P(server_val_log_level:%s)\n", $2));
2294 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2295 			yyerror("number expected");
2296 		else cfg_parser->cfg->val_log_level = atoi($2);
2297 		free($2);
2298 	}
2299 	;
2300 server_val_nsec3_keysize_iterations: VAR_VAL_NSEC3_KEYSIZE_ITERATIONS STRING_ARG
2301 	{
2302 		OUTYY(("P(server_val_nsec3_keysize_iterations:%s)\n", $2));
2303 		free(cfg_parser->cfg->val_nsec3_key_iterations);
2304 		cfg_parser->cfg->val_nsec3_key_iterations = $2;
2305 	}
2306 	;
2307 server_zonemd_permissive_mode: VAR_ZONEMD_PERMISSIVE_MODE STRING_ARG
2308 	{
2309 		OUTYY(("P(server_zonemd_permissive_mode:%s)\n", $2));
2310 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2311 			yyerror("expected yes or no.");
2312 		else	cfg_parser->cfg->zonemd_permissive_mode = (strcmp($2, "yes")==0);
2313 		free($2);
2314 	}
2315 	;
2316 server_add_holddown: VAR_ADD_HOLDDOWN STRING_ARG
2317 	{
2318 		OUTYY(("P(server_add_holddown:%s)\n", $2));
2319 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2320 			yyerror("number expected");
2321 		else cfg_parser->cfg->add_holddown = atoi($2);
2322 		free($2);
2323 	}
2324 	;
2325 server_del_holddown: VAR_DEL_HOLDDOWN STRING_ARG
2326 	{
2327 		OUTYY(("P(server_del_holddown:%s)\n", $2));
2328 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2329 			yyerror("number expected");
2330 		else cfg_parser->cfg->del_holddown = atoi($2);
2331 		free($2);
2332 	}
2333 	;
2334 server_keep_missing: VAR_KEEP_MISSING STRING_ARG
2335 	{
2336 		OUTYY(("P(server_keep_missing:%s)\n", $2));
2337 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2338 			yyerror("number expected");
2339 		else cfg_parser->cfg->keep_missing = atoi($2);
2340 		free($2);
2341 	}
2342 	;
2343 server_permit_small_holddown: VAR_PERMIT_SMALL_HOLDDOWN STRING_ARG
2344 	{
2345 		OUTYY(("P(server_permit_small_holddown:%s)\n", $2));
2346 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2347 			yyerror("expected yes or no.");
2348 		else cfg_parser->cfg->permit_small_holddown =
2349 			(strcmp($2, "yes")==0);
2350 		free($2);
2351 	}
2352 	;
2353 server_key_cache_size: VAR_KEY_CACHE_SIZE STRING_ARG
2354 	{
2355 		OUTYY(("P(server_key_cache_size:%s)\n", $2));
2356 		if(!cfg_parse_memsize($2, &cfg_parser->cfg->key_cache_size))
2357 			yyerror("memory size expected");
2358 		free($2);
2359 	}
2360 	;
2361 server_key_cache_slabs: VAR_KEY_CACHE_SLABS STRING_ARG
2362 	{
2363 		OUTYY(("P(server_key_cache_slabs:%s)\n", $2));
2364 		if(atoi($2) == 0) {
2365 			yyerror("number expected");
2366 		} else {
2367 			cfg_parser->cfg->key_cache_slabs = atoi($2);
2368 			if(!is_pow2(cfg_parser->cfg->key_cache_slabs))
2369 				yyerror("must be a power of 2");
2370 		}
2371 		free($2);
2372 	}
2373 	;
2374 server_neg_cache_size: VAR_NEG_CACHE_SIZE STRING_ARG
2375 	{
2376 		OUTYY(("P(server_neg_cache_size:%s)\n", $2));
2377 		if(!cfg_parse_memsize($2, &cfg_parser->cfg->neg_cache_size))
2378 			yyerror("memory size expected");
2379 		free($2);
2380 	}
2381 	;
2382 server_local_zone: VAR_LOCAL_ZONE STRING_ARG STRING_ARG
2383 	{
2384 		OUTYY(("P(server_local_zone:%s %s)\n", $2, $3));
2385 		if(strcmp($3, "static")!=0 && strcmp($3, "deny")!=0 &&
2386 		   strcmp($3, "refuse")!=0 && strcmp($3, "redirect")!=0 &&
2387 		   strcmp($3, "transparent")!=0 && strcmp($3, "nodefault")!=0
2388 		   && strcmp($3, "typetransparent")!=0
2389 		   && strcmp($3, "always_transparent")!=0
2390 		   && strcmp($3, "block_a")!=0
2391 		   && strcmp($3, "always_refuse")!=0
2392 		   && strcmp($3, "always_nxdomain")!=0
2393 		   && strcmp($3, "always_nodata")!=0
2394 		   && strcmp($3, "always_deny")!=0
2395 		   && strcmp($3, "always_null")!=0
2396 		   && strcmp($3, "noview")!=0
2397 		   && strcmp($3, "inform")!=0 && strcmp($3, "inform_deny")!=0
2398 		   && strcmp($3, "inform_redirect") != 0
2399 		   && strcmp($3, "ipset") != 0) {
2400 			yyerror("local-zone type: expected static, deny, "
2401 				"refuse, redirect, transparent, "
2402 				"typetransparent, inform, inform_deny, "
2403 				"inform_redirect, always_transparent, block_a, "
2404 				"always_refuse, always_nxdomain, "
2405 				"always_nodata, always_deny, always_null, "
2406 				"noview, nodefault or ipset");
2407 			free($2);
2408 			free($3);
2409 		} else if(strcmp($3, "nodefault")==0) {
2410 			if(!cfg_strlist_insert(&cfg_parser->cfg->
2411 				local_zones_nodefault, $2))
2412 				fatal_exit("out of memory adding local-zone");
2413 			free($3);
2414 #ifdef USE_IPSET
2415 		} else if(strcmp($3, "ipset")==0) {
2416 			size_t len = strlen($2);
2417 			/* Make sure to add the trailing dot.
2418 			 * These are str compared to domain names. */
2419 			if($2[len-1] != '.') {
2420 				if(!($2 = realloc($2, len+2))) {
2421 					fatal_exit("out of memory adding local-zone");
2422 				}
2423 				$2[len] = '.';
2424 				$2[len+1] = 0;
2425 			}
2426 			if(!cfg_strlist_insert(&cfg_parser->cfg->
2427 				local_zones_ipset, $2))
2428 				fatal_exit("out of memory adding local-zone");
2429 			free($3);
2430 #endif
2431 		} else {
2432 			if(!cfg_str2list_insert(&cfg_parser->cfg->local_zones,
2433 				$2, $3))
2434 				fatal_exit("out of memory adding local-zone");
2435 		}
2436 	}
2437 	;
2438 server_local_data: VAR_LOCAL_DATA STRING_ARG
2439 	{
2440 		OUTYY(("P(server_local_data:%s)\n", $2));
2441 		if(!cfg_strlist_insert(&cfg_parser->cfg->local_data, $2))
2442 			fatal_exit("out of memory adding local-data");
2443 	}
2444 	;
2445 server_local_data_ptr: VAR_LOCAL_DATA_PTR STRING_ARG
2446 	{
2447 		char* ptr;
2448 		OUTYY(("P(server_local_data_ptr:%s)\n", $2));
2449 		ptr = cfg_ptr_reverse($2);
2450 		free($2);
2451 		if(ptr) {
2452 			if(!cfg_strlist_insert(&cfg_parser->cfg->
2453 				local_data, ptr))
2454 				fatal_exit("out of memory adding local-data");
2455 		} else {
2456 			yyerror("local-data-ptr could not be reversed");
2457 		}
2458 	}
2459 	;
2460 server_minimal_responses: VAR_MINIMAL_RESPONSES STRING_ARG
2461 	{
2462 		OUTYY(("P(server_minimal_responses:%s)\n", $2));
2463 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2464 			yyerror("expected yes or no.");
2465 		else cfg_parser->cfg->minimal_responses =
2466 			(strcmp($2, "yes")==0);
2467 		free($2);
2468 	}
2469 	;
2470 server_rrset_roundrobin: VAR_RRSET_ROUNDROBIN STRING_ARG
2471 	{
2472 		OUTYY(("P(server_rrset_roundrobin:%s)\n", $2));
2473 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2474 			yyerror("expected yes or no.");
2475 		else cfg_parser->cfg->rrset_roundrobin =
2476 			(strcmp($2, "yes")==0);
2477 		free($2);
2478 	}
2479 	;
2480 server_unknown_server_time_limit: VAR_UNKNOWN_SERVER_TIME_LIMIT STRING_ARG
2481 	{
2482 		OUTYY(("P(server_unknown_server_time_limit:%s)\n", $2));
2483 		cfg_parser->cfg->unknown_server_time_limit = atoi($2);
2484 		free($2);
2485 	}
2486 	;
2487 server_discard_timeout: VAR_DISCARD_TIMEOUT STRING_ARG
2488 	{
2489 		OUTYY(("P(server_discard_timeout:%s)\n", $2));
2490 		cfg_parser->cfg->discard_timeout = atoi($2);
2491 		free($2);
2492 	}
2493 	;
2494 server_wait_limit: VAR_WAIT_LIMIT STRING_ARG
2495 	{
2496 		OUTYY(("P(server_wait_limit:%s)\n", $2));
2497 		cfg_parser->cfg->wait_limit = atoi($2);
2498 		free($2);
2499 	}
2500 	;
2501 server_wait_limit_cookie: VAR_WAIT_LIMIT_COOKIE STRING_ARG
2502 	{
2503 		OUTYY(("P(server_wait_limit_cookie:%s)\n", $2));
2504 		cfg_parser->cfg->wait_limit_cookie = atoi($2);
2505 		free($2);
2506 	}
2507 	;
2508 server_wait_limit_netblock: VAR_WAIT_LIMIT_NETBLOCK STRING_ARG STRING_ARG
2509 	{
2510 		OUTYY(("P(server_wait_limit_netblock:%s %s)\n", $2, $3));
2511 		if(atoi($3) == 0 && strcmp($3, "0") != 0) {
2512 			yyerror("number expected");
2513 			free($2);
2514 			free($3);
2515 		} else {
2516 			if(!cfg_str2list_insert(&cfg_parser->cfg->
2517 				wait_limit_netblock, $2, $3))
2518 				fatal_exit("out of memory adding "
2519 					"wait-limit-netblock");
2520 		}
2521 	}
2522 	;
2523 server_wait_limit_cookie_netblock: VAR_WAIT_LIMIT_COOKIE_NETBLOCK STRING_ARG STRING_ARG
2524 	{
2525 		OUTYY(("P(server_wait_limit_cookie_netblock:%s %s)\n", $2, $3));
2526 		if(atoi($3) == 0 && strcmp($3, "0") != 0) {
2527 			yyerror("number expected");
2528 			free($2);
2529 			free($3);
2530 		} else {
2531 			if(!cfg_str2list_insert(&cfg_parser->cfg->
2532 				wait_limit_cookie_netblock, $2, $3))
2533 				fatal_exit("out of memory adding "
2534 					"wait-limit-cookie-netblock");
2535 		}
2536 	}
2537 	;
2538 server_max_udp_size: VAR_MAX_UDP_SIZE STRING_ARG
2539 	{
2540 		OUTYY(("P(server_max_udp_size:%s)\n", $2));
2541 		cfg_parser->cfg->max_udp_size = atoi($2);
2542 		free($2);
2543 	}
2544 	;
2545 server_dns64_prefix: VAR_DNS64_PREFIX STRING_ARG
2546 	{
2547 		OUTYY(("P(dns64_prefix:%s)\n", $2));
2548 		free(cfg_parser->cfg->dns64_prefix);
2549 		cfg_parser->cfg->dns64_prefix = $2;
2550 	}
2551 	;
2552 server_dns64_synthall: VAR_DNS64_SYNTHALL STRING_ARG
2553 	{
2554 		OUTYY(("P(server_dns64_synthall:%s)\n", $2));
2555 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2556 			yyerror("expected yes or no.");
2557 		else cfg_parser->cfg->dns64_synthall = (strcmp($2, "yes")==0);
2558 		free($2);
2559 	}
2560 	;
2561 server_dns64_ignore_aaaa: VAR_DNS64_IGNORE_AAAA STRING_ARG
2562 	{
2563 		OUTYY(("P(dns64_ignore_aaaa:%s)\n", $2));
2564 		if(!cfg_strlist_insert(&cfg_parser->cfg->dns64_ignore_aaaa,
2565 			$2))
2566 			fatal_exit("out of memory adding dns64-ignore-aaaa");
2567 	}
2568 	;
2569 server_nat64_prefix: VAR_NAT64_PREFIX STRING_ARG
2570 	{
2571 		OUTYY(("P(nat64_prefix:%s)\n", $2));
2572 		free(cfg_parser->cfg->nat64_prefix);
2573 		cfg_parser->cfg->nat64_prefix = $2;
2574 	}
2575 	;
2576 server_define_tag: VAR_DEFINE_TAG STRING_ARG
2577 	{
2578 		char* p, *s = $2;
2579 		OUTYY(("P(server_define_tag:%s)\n", $2));
2580 		while((p=strsep(&s, " \t\n")) != NULL) {
2581 			if(*p) {
2582 				if(!config_add_tag(cfg_parser->cfg, p))
2583 					yyerror("could not define-tag, "
2584 						"out of memory");
2585 			}
2586 		}
2587 		free($2);
2588 	}
2589 	;
2590 server_local_zone_tag: VAR_LOCAL_ZONE_TAG STRING_ARG STRING_ARG
2591 	{
2592 		size_t len = 0;
2593 		uint8_t* bitlist = config_parse_taglist(cfg_parser->cfg, $3,
2594 			&len);
2595 		free($3);
2596 		OUTYY(("P(server_local_zone_tag:%s)\n", $2));
2597 		if(!bitlist) {
2598 			yyerror("could not parse tags, (define-tag them first)");
2599 			free($2);
2600 		}
2601 		if(bitlist) {
2602 			if(!cfg_strbytelist_insert(
2603 				&cfg_parser->cfg->local_zone_tags,
2604 				$2, bitlist, len)) {
2605 				yyerror("out of memory");
2606 				free($2);
2607 			}
2608 		}
2609 	}
2610 	;
2611 server_access_control_tag: VAR_ACCESS_CONTROL_TAG STRING_ARG STRING_ARG
2612 	{
2613 		size_t len = 0;
2614 		uint8_t* bitlist = config_parse_taglist(cfg_parser->cfg, $3,
2615 			&len);
2616 		free($3);
2617 		OUTYY(("P(server_access_control_tag:%s)\n", $2));
2618 		if(!bitlist) {
2619 			yyerror("could not parse tags, (define-tag them first)");
2620 			free($2);
2621 		}
2622 		if(bitlist) {
2623 			if(!cfg_strbytelist_insert(
2624 				&cfg_parser->cfg->acl_tags,
2625 				$2, bitlist, len)) {
2626 				yyerror("out of memory");
2627 				free($2);
2628 			}
2629 		}
2630 	}
2631 	;
2632 server_access_control_tag_action: VAR_ACCESS_CONTROL_TAG_ACTION STRING_ARG STRING_ARG STRING_ARG
2633 	{
2634 		OUTYY(("P(server_access_control_tag_action:%s %s %s)\n", $2, $3, $4));
2635 		if(!cfg_str3list_insert(&cfg_parser->cfg->acl_tag_actions,
2636 			$2, $3, $4)) {
2637 			yyerror("out of memory");
2638 			free($2);
2639 			free($3);
2640 			free($4);
2641 		}
2642 	}
2643 	;
2644 server_access_control_tag_data: VAR_ACCESS_CONTROL_TAG_DATA STRING_ARG STRING_ARG STRING_ARG
2645 	{
2646 		OUTYY(("P(server_access_control_tag_data:%s %s %s)\n", $2, $3, $4));
2647 		if(!cfg_str3list_insert(&cfg_parser->cfg->acl_tag_datas,
2648 			$2, $3, $4)) {
2649 			yyerror("out of memory");
2650 			free($2);
2651 			free($3);
2652 			free($4);
2653 		}
2654 	}
2655 	;
2656 server_local_zone_override: VAR_LOCAL_ZONE_OVERRIDE STRING_ARG STRING_ARG STRING_ARG
2657 	{
2658 		OUTYY(("P(server_local_zone_override:%s %s %s)\n", $2, $3, $4));
2659 		if(!cfg_str3list_insert(&cfg_parser->cfg->local_zone_overrides,
2660 			$2, $3, $4)) {
2661 			yyerror("out of memory");
2662 			free($2);
2663 			free($3);
2664 			free($4);
2665 		}
2666 	}
2667 	;
2668 server_access_control_view: VAR_ACCESS_CONTROL_VIEW STRING_ARG STRING_ARG
2669 	{
2670 		OUTYY(("P(server_access_control_view:%s %s)\n", $2, $3));
2671 		if(!cfg_str2list_insert(&cfg_parser->cfg->acl_view,
2672 			$2, $3)) {
2673 			yyerror("out of memory");
2674 		}
2675 	}
2676 	;
2677 server_interface_tag: VAR_INTERFACE_TAG STRING_ARG STRING_ARG
2678 	{
2679 		size_t len = 0;
2680 		uint8_t* bitlist = config_parse_taglist(cfg_parser->cfg, $3,
2681 			&len);
2682 		free($3);
2683 		OUTYY(("P(server_interface_tag:%s)\n", $2));
2684 		if(!bitlist) {
2685 			yyerror("could not parse tags, (define-tag them first)");
2686 			free($2);
2687 		}
2688 		if(bitlist) {
2689 			if(!cfg_strbytelist_insert(
2690 				&cfg_parser->cfg->interface_tags,
2691 				$2, bitlist, len)) {
2692 				yyerror("out of memory");
2693 				free($2);
2694 			}
2695 		}
2696 	}
2697 	;
2698 server_interface_tag_action: VAR_INTERFACE_TAG_ACTION STRING_ARG STRING_ARG STRING_ARG
2699 	{
2700 		OUTYY(("P(server_interface_tag_action:%s %s %s)\n", $2, $3, $4));
2701 		if(!cfg_str3list_insert(&cfg_parser->cfg->interface_tag_actions,
2702 			$2, $3, $4)) {
2703 			yyerror("out of memory");
2704 			free($2);
2705 			free($3);
2706 			free($4);
2707 		}
2708 	}
2709 	;
2710 server_interface_tag_data: VAR_INTERFACE_TAG_DATA STRING_ARG STRING_ARG STRING_ARG
2711 	{
2712 		OUTYY(("P(server_interface_tag_data:%s %s %s)\n", $2, $3, $4));
2713 		if(!cfg_str3list_insert(&cfg_parser->cfg->interface_tag_datas,
2714 			$2, $3, $4)) {
2715 			yyerror("out of memory");
2716 			free($2);
2717 			free($3);
2718 			free($4);
2719 		}
2720 	}
2721 	;
2722 server_interface_view: VAR_INTERFACE_VIEW STRING_ARG STRING_ARG
2723 	{
2724 		OUTYY(("P(server_interface_view:%s %s)\n", $2, $3));
2725 		if(!cfg_str2list_insert(&cfg_parser->cfg->interface_view,
2726 			$2, $3)) {
2727 			yyerror("out of memory");
2728 		}
2729 	}
2730 	;
2731 server_response_ip_tag: VAR_RESPONSE_IP_TAG STRING_ARG STRING_ARG
2732 	{
2733 		size_t len = 0;
2734 		uint8_t* bitlist = config_parse_taglist(cfg_parser->cfg, $3,
2735 			&len);
2736 		free($3);
2737 		OUTYY(("P(response_ip_tag:%s)\n", $2));
2738 		if(!bitlist) {
2739 			yyerror("could not parse tags, (define-tag them first)");
2740 			free($2);
2741 		}
2742 		if(bitlist) {
2743 			if(!cfg_strbytelist_insert(
2744 				&cfg_parser->cfg->respip_tags,
2745 				$2, bitlist, len)) {
2746 				yyerror("out of memory");
2747 				free($2);
2748 			}
2749 		}
2750 	}
2751 	;
2752 server_ip_ratelimit: VAR_IP_RATELIMIT STRING_ARG
2753 	{
2754 		OUTYY(("P(server_ip_ratelimit:%s)\n", $2));
2755 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2756 			yyerror("number expected");
2757 		else cfg_parser->cfg->ip_ratelimit = atoi($2);
2758 		free($2);
2759 	}
2760 	;
2761 server_ip_ratelimit_cookie: VAR_IP_RATELIMIT_COOKIE STRING_ARG
2762 	{
2763 		OUTYY(("P(server_ip_ratelimit_cookie:%s)\n", $2));
2764 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2765 			yyerror("number expected");
2766 		else cfg_parser->cfg->ip_ratelimit_cookie = atoi($2);
2767 		free($2);
2768 	}
2769 	;
2770 server_ratelimit: VAR_RATELIMIT STRING_ARG
2771 	{
2772 		OUTYY(("P(server_ratelimit:%s)\n", $2));
2773 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2774 			yyerror("number expected");
2775 		else cfg_parser->cfg->ratelimit = atoi($2);
2776 		free($2);
2777 	}
2778 	;
2779 server_ip_ratelimit_size: VAR_IP_RATELIMIT_SIZE STRING_ARG
2780 	{
2781 		OUTYY(("P(server_ip_ratelimit_size:%s)\n", $2));
2782 		if(!cfg_parse_memsize($2, &cfg_parser->cfg->ip_ratelimit_size))
2783 			yyerror("memory size expected");
2784 		free($2);
2785 	}
2786 	;
2787 server_ratelimit_size: VAR_RATELIMIT_SIZE STRING_ARG
2788 	{
2789 		OUTYY(("P(server_ratelimit_size:%s)\n", $2));
2790 		if(!cfg_parse_memsize($2, &cfg_parser->cfg->ratelimit_size))
2791 			yyerror("memory size expected");
2792 		free($2);
2793 	}
2794 	;
2795 server_ip_ratelimit_slabs: VAR_IP_RATELIMIT_SLABS STRING_ARG
2796 	{
2797 		OUTYY(("P(server_ip_ratelimit_slabs:%s)\n", $2));
2798 		if(atoi($2) == 0) {
2799 			yyerror("number expected");
2800 		} else {
2801 			cfg_parser->cfg->ip_ratelimit_slabs = atoi($2);
2802 			if(!is_pow2(cfg_parser->cfg->ip_ratelimit_slabs))
2803 				yyerror("must be a power of 2");
2804 		}
2805 		free($2);
2806 	}
2807 	;
2808 server_ratelimit_slabs: VAR_RATELIMIT_SLABS STRING_ARG
2809 	{
2810 		OUTYY(("P(server_ratelimit_slabs:%s)\n", $2));
2811 		if(atoi($2) == 0) {
2812 			yyerror("number expected");
2813 		} else {
2814 			cfg_parser->cfg->ratelimit_slabs = atoi($2);
2815 			if(!is_pow2(cfg_parser->cfg->ratelimit_slabs))
2816 				yyerror("must be a power of 2");
2817 		}
2818 		free($2);
2819 	}
2820 	;
2821 server_ratelimit_for_domain: VAR_RATELIMIT_FOR_DOMAIN STRING_ARG STRING_ARG
2822 	{
2823 		OUTYY(("P(server_ratelimit_for_domain:%s %s)\n", $2, $3));
2824 		if(atoi($3) == 0 && strcmp($3, "0") != 0) {
2825 			yyerror("number expected");
2826 			free($2);
2827 			free($3);
2828 		} else {
2829 			if(!cfg_str2list_insert(&cfg_parser->cfg->
2830 				ratelimit_for_domain, $2, $3))
2831 				fatal_exit("out of memory adding "
2832 					"ratelimit-for-domain");
2833 		}
2834 	}
2835 	;
2836 server_ratelimit_below_domain: VAR_RATELIMIT_BELOW_DOMAIN STRING_ARG STRING_ARG
2837 	{
2838 		OUTYY(("P(server_ratelimit_below_domain:%s %s)\n", $2, $3));
2839 		if(atoi($3) == 0 && strcmp($3, "0") != 0) {
2840 			yyerror("number expected");
2841 			free($2);
2842 			free($3);
2843 		} else {
2844 			if(!cfg_str2list_insert(&cfg_parser->cfg->
2845 				ratelimit_below_domain, $2, $3))
2846 				fatal_exit("out of memory adding "
2847 					"ratelimit-below-domain");
2848 		}
2849 	}
2850 	;
2851 server_ip_ratelimit_factor: VAR_IP_RATELIMIT_FACTOR STRING_ARG
2852 	{
2853 		OUTYY(("P(server_ip_ratelimit_factor:%s)\n", $2));
2854 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2855 			yyerror("number expected");
2856 		else cfg_parser->cfg->ip_ratelimit_factor = atoi($2);
2857 		free($2);
2858 	}
2859 	;
2860 server_ratelimit_factor: VAR_RATELIMIT_FACTOR STRING_ARG
2861 	{
2862 		OUTYY(("P(server_ratelimit_factor:%s)\n", $2));
2863 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2864 			yyerror("number expected");
2865 		else cfg_parser->cfg->ratelimit_factor = atoi($2);
2866 		free($2);
2867 	}
2868 	;
2869 server_ip_ratelimit_backoff: VAR_IP_RATELIMIT_BACKOFF STRING_ARG
2870 	{
2871 		OUTYY(("P(server_ip_ratelimit_backoff:%s)\n", $2));
2872 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2873 			yyerror("expected yes or no.");
2874 		else cfg_parser->cfg->ip_ratelimit_backoff =
2875 			(strcmp($2, "yes")==0);
2876 		free($2);
2877 	}
2878 	;
2879 server_ratelimit_backoff: VAR_RATELIMIT_BACKOFF STRING_ARG
2880 	{
2881 		OUTYY(("P(server_ratelimit_backoff:%s)\n", $2));
2882 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2883 			yyerror("expected yes or no.");
2884 		else cfg_parser->cfg->ratelimit_backoff =
2885 			(strcmp($2, "yes")==0);
2886 		free($2);
2887 	}
2888 	;
2889 server_outbound_msg_retry: VAR_OUTBOUND_MSG_RETRY STRING_ARG
2890 	{
2891 		OUTYY(("P(server_outbound_msg_retry:%s)\n", $2));
2892 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2893 			yyerror("number expected");
2894 		else cfg_parser->cfg->outbound_msg_retry = atoi($2);
2895 		free($2);
2896 	}
2897 	;
2898 server_max_sent_count: VAR_MAX_SENT_COUNT STRING_ARG
2899 	{
2900 		OUTYY(("P(server_max_sent_count:%s)\n", $2));
2901 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2902 			yyerror("number expected");
2903 		else cfg_parser->cfg->max_sent_count = atoi($2);
2904 		free($2);
2905 	}
2906 	;
2907 server_max_query_restarts: VAR_MAX_QUERY_RESTARTS STRING_ARG
2908 	{
2909 		OUTYY(("P(server_max_query_restarts:%s)\n", $2));
2910 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2911 			yyerror("number expected");
2912 		else cfg_parser->cfg->max_query_restarts = atoi($2);
2913 		free($2);
2914 	}
2915 	;
2916 server_low_rtt: VAR_LOW_RTT STRING_ARG
2917 	{
2918 		OUTYY(("P(low-rtt option is deprecated, use fast-server-num instead)\n"));
2919 		free($2);
2920 	}
2921 	;
2922 server_fast_server_num: VAR_FAST_SERVER_NUM STRING_ARG
2923 	{
2924 		OUTYY(("P(server_fast_server_num:%s)\n", $2));
2925 		if(atoi($2) <= 0)
2926 			yyerror("number expected");
2927 		else cfg_parser->cfg->fast_server_num = atoi($2);
2928 		free($2);
2929 	}
2930 	;
2931 server_fast_server_permil: VAR_FAST_SERVER_PERMIL STRING_ARG
2932 	{
2933 		OUTYY(("P(server_fast_server_permil:%s)\n", $2));
2934 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
2935 			yyerror("number expected");
2936 		else cfg_parser->cfg->fast_server_permil = atoi($2);
2937 		free($2);
2938 	}
2939 	;
2940 server_qname_minimisation: VAR_QNAME_MINIMISATION STRING_ARG
2941 	{
2942 		OUTYY(("P(server_qname_minimisation:%s)\n", $2));
2943 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2944 			yyerror("expected yes or no.");
2945 		else cfg_parser->cfg->qname_minimisation =
2946 			(strcmp($2, "yes")==0);
2947 		free($2);
2948 	}
2949 	;
2950 server_qname_minimisation_strict: VAR_QNAME_MINIMISATION_STRICT STRING_ARG
2951 	{
2952 		OUTYY(("P(server_qname_minimisation_strict:%s)\n", $2));
2953 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2954 			yyerror("expected yes or no.");
2955 		else cfg_parser->cfg->qname_minimisation_strict =
2956 			(strcmp($2, "yes")==0);
2957 		free($2);
2958 	}
2959 	;
2960 server_pad_responses: VAR_PAD_RESPONSES STRING_ARG
2961 	{
2962 		OUTYY(("P(server_pad_responses:%s)\n", $2));
2963 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2964 			yyerror("expected yes or no.");
2965 		else cfg_parser->cfg->pad_responses =
2966 			(strcmp($2, "yes")==0);
2967 		free($2);
2968 	}
2969 	;
2970 server_pad_responses_block_size: VAR_PAD_RESPONSES_BLOCK_SIZE STRING_ARG
2971 	{
2972 		OUTYY(("P(server_pad_responses_block_size:%s)\n", $2));
2973 		if(atoi($2) == 0)
2974 			yyerror("number expected");
2975 		else cfg_parser->cfg->pad_responses_block_size = atoi($2);
2976 		free($2);
2977 	}
2978 	;
2979 server_pad_queries: VAR_PAD_QUERIES STRING_ARG
2980 	{
2981 		OUTYY(("P(server_pad_queries:%s)\n", $2));
2982 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
2983 			yyerror("expected yes or no.");
2984 		else cfg_parser->cfg->pad_queries =
2985 			(strcmp($2, "yes")==0);
2986 		free($2);
2987 	}
2988 	;
2989 server_pad_queries_block_size: VAR_PAD_QUERIES_BLOCK_SIZE STRING_ARG
2990 	{
2991 		OUTYY(("P(server_pad_queries_block_size:%s)\n", $2));
2992 		if(atoi($2) == 0)
2993 			yyerror("number expected");
2994 		else cfg_parser->cfg->pad_queries_block_size = atoi($2);
2995 		free($2);
2996 	}
2997 	;
2998 server_ipsecmod_enabled: VAR_IPSECMOD_ENABLED STRING_ARG
2999 	{
3000 	#ifdef USE_IPSECMOD
3001 		OUTYY(("P(server_ipsecmod_enabled:%s)\n", $2));
3002 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3003 			yyerror("expected yes or no.");
3004 		else cfg_parser->cfg->ipsecmod_enabled = (strcmp($2, "yes")==0);
3005 	#else
3006 		OUTYY(("P(Compiled without IPsec module, ignoring)\n"));
3007 	#endif
3008 		free($2);
3009 	}
3010 	;
3011 server_ipsecmod_ignore_bogus: VAR_IPSECMOD_IGNORE_BOGUS STRING_ARG
3012 	{
3013 	#ifdef USE_IPSECMOD
3014 		OUTYY(("P(server_ipsecmod_ignore_bogus:%s)\n", $2));
3015 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3016 			yyerror("expected yes or no.");
3017 		else cfg_parser->cfg->ipsecmod_ignore_bogus = (strcmp($2, "yes")==0);
3018 	#else
3019 		OUTYY(("P(Compiled without IPsec module, ignoring)\n"));
3020 	#endif
3021 		free($2);
3022 	}
3023 	;
3024 server_ipsecmod_hook: VAR_IPSECMOD_HOOK STRING_ARG
3025 	{
3026 	#ifdef USE_IPSECMOD
3027 		OUTYY(("P(server_ipsecmod_hook:%s)\n", $2));
3028 		free(cfg_parser->cfg->ipsecmod_hook);
3029 		cfg_parser->cfg->ipsecmod_hook = $2;
3030 	#else
3031 		OUTYY(("P(Compiled without IPsec module, ignoring)\n"));
3032 		free($2);
3033 	#endif
3034 	}
3035 	;
3036 server_ipsecmod_max_ttl: VAR_IPSECMOD_MAX_TTL STRING_ARG
3037 	{
3038 	#ifdef USE_IPSECMOD
3039 		OUTYY(("P(server_ipsecmod_max_ttl:%s)\n", $2));
3040 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
3041 			yyerror("number expected");
3042 		else cfg_parser->cfg->ipsecmod_max_ttl = atoi($2);
3043 		free($2);
3044 	#else
3045 		OUTYY(("P(Compiled without IPsec module, ignoring)\n"));
3046 		free($2);
3047 	#endif
3048 	}
3049 	;
3050 server_ipsecmod_whitelist: VAR_IPSECMOD_WHITELIST STRING_ARG
3051 	{
3052 	#ifdef USE_IPSECMOD
3053 		OUTYY(("P(server_ipsecmod_whitelist:%s)\n", $2));
3054 		if(!cfg_strlist_insert(&cfg_parser->cfg->ipsecmod_whitelist, $2))
3055 			yyerror("out of memory");
3056 	#else
3057 		OUTYY(("P(Compiled without IPsec module, ignoring)\n"));
3058 		free($2);
3059 	#endif
3060 	}
3061 	;
3062 server_ipsecmod_strict: VAR_IPSECMOD_STRICT STRING_ARG
3063 	{
3064 	#ifdef USE_IPSECMOD
3065 		OUTYY(("P(server_ipsecmod_strict:%s)\n", $2));
3066 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3067 			yyerror("expected yes or no.");
3068 		else cfg_parser->cfg->ipsecmod_strict = (strcmp($2, "yes")==0);
3069 		free($2);
3070 	#else
3071 		OUTYY(("P(Compiled without IPsec module, ignoring)\n"));
3072 		free($2);
3073 	#endif
3074 	}
3075 	;
3076 server_edns_client_string: VAR_EDNS_CLIENT_STRING STRING_ARG STRING_ARG
3077 	{
3078 		OUTYY(("P(server_edns_client_string:%s %s)\n", $2, $3));
3079 		if(!cfg_str2list_insert(
3080 			&cfg_parser->cfg->edns_client_strings, $2, $3))
3081 			fatal_exit("out of memory adding "
3082 				"edns-client-string");
3083 	}
3084 	;
3085 server_edns_client_string_opcode: VAR_EDNS_CLIENT_STRING_OPCODE STRING_ARG
3086 	{
3087 		OUTYY(("P(edns_client_string_opcode:%s)\n", $2));
3088 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
3089 			yyerror("option code expected");
3090 		else if(atoi($2) > 65535 || atoi($2) < 0)
3091 			yyerror("option code must be in interval [0, 65535]");
3092 		else cfg_parser->cfg->edns_client_string_opcode = atoi($2);
3093 		free($2);
3094 	}
3095 	;
3096 server_ede: VAR_EDE STRING_ARG
3097 	{
3098 		OUTYY(("P(server_ede:%s)\n", $2));
3099 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3100 			yyerror("expected yes or no.");
3101 		else cfg_parser->cfg->ede = (strcmp($2, "yes")==0);
3102 		free($2);
3103 	}
3104 	;
3105 server_dns_error_reporting: VAR_DNS_ERROR_REPORTING STRING_ARG
3106 	{
3107 		OUTYY(("P(server_dns_error_reporting:%s)\n", $2));
3108 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3109 			yyerror("expected yes or no.");
3110 		else cfg_parser->cfg->dns_error_reporting = (strcmp($2, "yes")==0);
3111 		free($2);
3112 	}
3113 	;
3114 server_proxy_protocol_port: VAR_PROXY_PROTOCOL_PORT STRING_ARG
3115 	{
3116 		OUTYY(("P(server_proxy_protocol_port:%s)\n", $2));
3117 		if(!cfg_strlist_insert(&cfg_parser->cfg->proxy_protocol_port, $2))
3118 			yyerror("out of memory");
3119 	}
3120 	;
3121 stub_name: VAR_NAME STRING_ARG
3122 	{
3123 		OUTYY(("P(name:%s)\n", $2));
3124 		if(cfg_parser->cfg->stubs->name)
3125 			yyerror("stub name override, there must be one name "
3126 				"for one stub-zone");
3127 		free(cfg_parser->cfg->stubs->name);
3128 		cfg_parser->cfg->stubs->name = $2;
3129 	}
3130 	;
3131 stub_host: VAR_STUB_HOST STRING_ARG
3132 	{
3133 		OUTYY(("P(stub-host:%s)\n", $2));
3134 		if(!cfg_strlist_insert(&cfg_parser->cfg->stubs->hosts, $2))
3135 			yyerror("out of memory");
3136 	}
3137 	;
3138 stub_addr: VAR_STUB_ADDR STRING_ARG
3139 	{
3140 		OUTYY(("P(stub-addr:%s)\n", $2));
3141 		if(!cfg_strlist_insert(&cfg_parser->cfg->stubs->addrs, $2))
3142 			yyerror("out of memory");
3143 	}
3144 	;
3145 stub_first: VAR_STUB_FIRST STRING_ARG
3146 	{
3147 		OUTYY(("P(stub-first:%s)\n", $2));
3148 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3149 			yyerror("expected yes or no.");
3150 		else cfg_parser->cfg->stubs->isfirst=(strcmp($2, "yes")==0);
3151 		free($2);
3152 	}
3153 	;
3154 stub_no_cache: VAR_STUB_NO_CACHE STRING_ARG
3155 	{
3156 		OUTYY(("P(stub-no-cache:%s)\n", $2));
3157 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3158 			yyerror("expected yes or no.");
3159 		else cfg_parser->cfg->stubs->no_cache=(strcmp($2, "yes")==0);
3160 		free($2);
3161 	}
3162 	;
3163 stub_ssl_upstream: VAR_STUB_SSL_UPSTREAM STRING_ARG
3164 	{
3165 		OUTYY(("P(stub-ssl-upstream:%s)\n", $2));
3166 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3167 			yyerror("expected yes or no.");
3168 		else cfg_parser->cfg->stubs->ssl_upstream =
3169 			(strcmp($2, "yes")==0);
3170 		free($2);
3171 	}
3172 	;
3173 stub_tcp_upstream: VAR_STUB_TCP_UPSTREAM STRING_ARG
3174         {
3175                 OUTYY(("P(stub-tcp-upstream:%s)\n", $2));
3176                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3177                         yyerror("expected yes or no.");
3178                 else cfg_parser->cfg->stubs->tcp_upstream =
3179                         (strcmp($2, "yes")==0);
3180                 free($2);
3181         }
3182         ;
3183 stub_prime: VAR_STUB_PRIME STRING_ARG
3184 	{
3185 		OUTYY(("P(stub-prime:%s)\n", $2));
3186 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3187 			yyerror("expected yes or no.");
3188 		else cfg_parser->cfg->stubs->isprime =
3189 			(strcmp($2, "yes")==0);
3190 		free($2);
3191 	}
3192 	;
3193 forward_name: VAR_NAME STRING_ARG
3194 	{
3195 		OUTYY(("P(name:%s)\n", $2));
3196 		if(cfg_parser->cfg->forwards->name)
3197 			yyerror("forward name override, there must be one "
3198 				"name for one forward-zone");
3199 		free(cfg_parser->cfg->forwards->name);
3200 		cfg_parser->cfg->forwards->name = $2;
3201 	}
3202 	;
3203 forward_host: VAR_FORWARD_HOST STRING_ARG
3204 	{
3205 		OUTYY(("P(forward-host:%s)\n", $2));
3206 		if(!cfg_strlist_insert(&cfg_parser->cfg->forwards->hosts, $2))
3207 			yyerror("out of memory");
3208 	}
3209 	;
3210 forward_addr: VAR_FORWARD_ADDR STRING_ARG
3211 	{
3212 		OUTYY(("P(forward-addr:%s)\n", $2));
3213 		if(!cfg_strlist_insert(&cfg_parser->cfg->forwards->addrs, $2))
3214 			yyerror("out of memory");
3215 	}
3216 	;
3217 forward_first: VAR_FORWARD_FIRST STRING_ARG
3218 	{
3219 		OUTYY(("P(forward-first:%s)\n", $2));
3220 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3221 			yyerror("expected yes or no.");
3222 		else cfg_parser->cfg->forwards->isfirst=(strcmp($2, "yes")==0);
3223 		free($2);
3224 	}
3225 	;
3226 forward_no_cache: VAR_FORWARD_NO_CACHE STRING_ARG
3227 	{
3228 		OUTYY(("P(forward-no-cache:%s)\n", $2));
3229 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3230 			yyerror("expected yes or no.");
3231 		else cfg_parser->cfg->forwards->no_cache=(strcmp($2, "yes")==0);
3232 		free($2);
3233 	}
3234 	;
3235 forward_ssl_upstream: VAR_FORWARD_SSL_UPSTREAM STRING_ARG
3236 	{
3237 		OUTYY(("P(forward-ssl-upstream:%s)\n", $2));
3238 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3239 			yyerror("expected yes or no.");
3240 		else cfg_parser->cfg->forwards->ssl_upstream =
3241 			(strcmp($2, "yes")==0);
3242 		free($2);
3243 	}
3244 	;
3245 forward_tcp_upstream: VAR_FORWARD_TCP_UPSTREAM STRING_ARG
3246         {
3247                 OUTYY(("P(forward-tcp-upstream:%s)\n", $2));
3248                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3249                         yyerror("expected yes or no.");
3250                 else cfg_parser->cfg->forwards->tcp_upstream =
3251                         (strcmp($2, "yes")==0);
3252                 free($2);
3253         }
3254         ;
3255 auth_name: VAR_NAME STRING_ARG
3256 	{
3257 		OUTYY(("P(name:%s)\n", $2));
3258 		if(cfg_parser->cfg->auths->name)
3259 			yyerror("auth name override, there must be one name "
3260 				"for one auth-zone");
3261 		free(cfg_parser->cfg->auths->name);
3262 		cfg_parser->cfg->auths->name = $2;
3263 	}
3264 	;
3265 auth_zonefile: VAR_ZONEFILE STRING_ARG
3266 	{
3267 		OUTYY(("P(zonefile:%s)\n", $2));
3268 		free(cfg_parser->cfg->auths->zonefile);
3269 		cfg_parser->cfg->auths->zonefile = $2;
3270 	}
3271 	;
3272 auth_master: VAR_MASTER STRING_ARG
3273 	{
3274 		OUTYY(("P(master:%s)\n", $2));
3275 		if(!cfg_strlist_insert(&cfg_parser->cfg->auths->masters, $2))
3276 			yyerror("out of memory");
3277 	}
3278 	;
3279 auth_url: VAR_URL STRING_ARG
3280 	{
3281 		OUTYY(("P(url:%s)\n", $2));
3282 		if(!cfg_strlist_insert(&cfg_parser->cfg->auths->urls, $2))
3283 			yyerror("out of memory");
3284 	}
3285 	;
3286 auth_allow_notify: VAR_ALLOW_NOTIFY STRING_ARG
3287 	{
3288 		OUTYY(("P(allow-notify:%s)\n", $2));
3289 		if(!cfg_strlist_insert(&cfg_parser->cfg->auths->allow_notify,
3290 			$2))
3291 			yyerror("out of memory");
3292 	}
3293 	;
3294 auth_zonemd_check: VAR_ZONEMD_CHECK STRING_ARG
3295 	{
3296 		OUTYY(("P(zonemd-check:%s)\n", $2));
3297 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3298 			yyerror("expected yes or no.");
3299 		else cfg_parser->cfg->auths->zonemd_check =
3300 			(strcmp($2, "yes")==0);
3301 		free($2);
3302 	}
3303 	;
3304 auth_zonemd_reject_absence: VAR_ZONEMD_REJECT_ABSENCE STRING_ARG
3305 	{
3306 		OUTYY(("P(zonemd-reject-absence:%s)\n", $2));
3307 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3308 			yyerror("expected yes or no.");
3309 		else cfg_parser->cfg->auths->zonemd_reject_absence =
3310 			(strcmp($2, "yes")==0);
3311 		free($2);
3312 	}
3313 	;
3314 auth_for_downstream: VAR_FOR_DOWNSTREAM STRING_ARG
3315 	{
3316 		OUTYY(("P(for-downstream:%s)\n", $2));
3317 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3318 			yyerror("expected yes or no.");
3319 		else cfg_parser->cfg->auths->for_downstream =
3320 			(strcmp($2, "yes")==0);
3321 		free($2);
3322 	}
3323 	;
3324 auth_for_upstream: VAR_FOR_UPSTREAM STRING_ARG
3325 	{
3326 		OUTYY(("P(for-upstream:%s)\n", $2));
3327 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3328 			yyerror("expected yes or no.");
3329 		else cfg_parser->cfg->auths->for_upstream =
3330 			(strcmp($2, "yes")==0);
3331 		free($2);
3332 	}
3333 	;
3334 auth_fallback_enabled: VAR_FALLBACK_ENABLED STRING_ARG
3335 	{
3336 		OUTYY(("P(fallback-enabled:%s)\n", $2));
3337 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3338 			yyerror("expected yes or no.");
3339 		else cfg_parser->cfg->auths->fallback_enabled =
3340 			(strcmp($2, "yes")==0);
3341 		free($2);
3342 	}
3343 	;
3344 view_name: VAR_NAME STRING_ARG
3345 	{
3346 		OUTYY(("P(name:%s)\n", $2));
3347 		if(cfg_parser->cfg->views->name)
3348 			yyerror("view name override, there must be one "
3349 				"name for one view");
3350 		free(cfg_parser->cfg->views->name);
3351 		cfg_parser->cfg->views->name = $2;
3352 	}
3353 	;
3354 view_local_zone: VAR_LOCAL_ZONE STRING_ARG STRING_ARG
3355 	{
3356 		OUTYY(("P(view_local_zone:%s %s)\n", $2, $3));
3357 		if(strcmp($3, "static")!=0 && strcmp($3, "deny")!=0 &&
3358 		   strcmp($3, "refuse")!=0 && strcmp($3, "redirect")!=0 &&
3359 		   strcmp($3, "transparent")!=0 && strcmp($3, "nodefault")!=0
3360 		   && strcmp($3, "typetransparent")!=0
3361 		   && strcmp($3, "always_transparent")!=0
3362 		   && strcmp($3, "always_refuse")!=0
3363 		   && strcmp($3, "always_nxdomain")!=0
3364 		   && strcmp($3, "always_nodata")!=0
3365 		   && strcmp($3, "always_deny")!=0
3366 		   && strcmp($3, "always_null")!=0
3367 		   && strcmp($3, "noview")!=0
3368 		   && strcmp($3, "inform")!=0 && strcmp($3, "inform_deny")!=0
3369 		   && strcmp($3, "inform_redirect") != 0
3370 		   && strcmp($3, "ipset") != 0) {
3371 			yyerror("local-zone type: expected static, deny, "
3372 				"refuse, redirect, transparent, "
3373 				"typetransparent, inform, inform_deny, "
3374 				"inform_redirect, always_transparent, "
3375 				"always_refuse, always_nxdomain, "
3376 				"always_nodata, always_deny, always_null, "
3377 				"noview, nodefault or ipset");
3378 			free($2);
3379 			free($3);
3380 		} else if(strcmp($3, "nodefault")==0) {
3381 			if(!cfg_strlist_insert(&cfg_parser->cfg->views->
3382 				local_zones_nodefault, $2))
3383 				fatal_exit("out of memory adding local-zone");
3384 			free($3);
3385 #ifdef USE_IPSET
3386 		} else if(strcmp($3, "ipset")==0) {
3387 			size_t len = strlen($2);
3388 			/* Make sure to add the trailing dot.
3389 			 * These are str compared to domain names. */
3390 			if($2[len-1] != '.') {
3391 				if(!($2 = realloc($2, len+2))) {
3392 					fatal_exit("out of memory adding local-zone");
3393 				}
3394 				$2[len] = '.';
3395 				$2[len+1] = 0;
3396 			}
3397 			if(!cfg_strlist_insert(&cfg_parser->cfg->views->
3398 				local_zones_ipset, $2))
3399 				fatal_exit("out of memory adding local-zone");
3400 			free($3);
3401 #endif
3402 		} else {
3403 			if(!cfg_str2list_insert(
3404 				&cfg_parser->cfg->views->local_zones,
3405 				$2, $3))
3406 				fatal_exit("out of memory adding local-zone");
3407 		}
3408 	}
3409 	;
3410 view_response_ip: VAR_RESPONSE_IP STRING_ARG STRING_ARG
3411 	{
3412 		OUTYY(("P(view_response_ip:%s %s)\n", $2, $3));
3413 		validate_respip_action($3);
3414 		if(!cfg_str2list_insert(
3415 			&cfg_parser->cfg->views->respip_actions, $2, $3))
3416 			fatal_exit("out of memory adding per-view "
3417 				"response-ip action");
3418 	}
3419 	;
3420 view_response_ip_data: VAR_RESPONSE_IP_DATA STRING_ARG STRING_ARG
3421 	{
3422 		OUTYY(("P(view_response_ip_data:%s)\n", $2));
3423 		if(!cfg_str2list_insert(
3424 			&cfg_parser->cfg->views->respip_data, $2, $3))
3425 			fatal_exit("out of memory adding response-ip-data");
3426 	}
3427 	;
3428 view_local_data: VAR_LOCAL_DATA STRING_ARG
3429 	{
3430 		OUTYY(("P(view_local_data:%s)\n", $2));
3431 		if(!cfg_strlist_insert(&cfg_parser->cfg->views->local_data, $2)) {
3432 			fatal_exit("out of memory adding local-data");
3433 		}
3434 	}
3435 	;
3436 view_local_data_ptr: VAR_LOCAL_DATA_PTR STRING_ARG
3437 	{
3438 		char* ptr;
3439 		OUTYY(("P(view_local_data_ptr:%s)\n", $2));
3440 		ptr = cfg_ptr_reverse($2);
3441 		free($2);
3442 		if(ptr) {
3443 			if(!cfg_strlist_insert(&cfg_parser->cfg->views->
3444 				local_data, ptr))
3445 				fatal_exit("out of memory adding local-data");
3446 		} else {
3447 			yyerror("local-data-ptr could not be reversed");
3448 		}
3449 	}
3450 	;
3451 view_first: VAR_VIEW_FIRST STRING_ARG
3452 	{
3453 		OUTYY(("P(view-first:%s)\n", $2));
3454 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3455 			yyerror("expected yes or no.");
3456 		else cfg_parser->cfg->views->isfirst=(strcmp($2, "yes")==0);
3457 		free($2);
3458 	}
3459 	;
3460 rcstart: VAR_REMOTE_CONTROL
3461 	{
3462 		OUTYY(("\nP(remote-control:)\n"));
3463 		cfg_parser->started_toplevel = 1;
3464 	}
3465 	;
3466 contents_rc: contents_rc content_rc
3467 	| ;
3468 content_rc: rc_control_enable | rc_control_interface | rc_control_port |
3469 	rc_server_key_file | rc_server_cert_file | rc_control_key_file |
3470 	rc_control_cert_file | rc_control_use_cert
3471 	;
3472 rc_control_enable: VAR_CONTROL_ENABLE STRING_ARG
3473 	{
3474 		OUTYY(("P(control_enable:%s)\n", $2));
3475 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3476 			yyerror("expected yes or no.");
3477 		else cfg_parser->cfg->remote_control_enable =
3478 			(strcmp($2, "yes")==0);
3479 		free($2);
3480 	}
3481 	;
3482 rc_control_port: VAR_CONTROL_PORT STRING_ARG
3483 	{
3484 		OUTYY(("P(control_port:%s)\n", $2));
3485 		if(atoi($2) == 0)
3486 			yyerror("control port number expected");
3487 		else cfg_parser->cfg->control_port = atoi($2);
3488 		free($2);
3489 	}
3490 	;
3491 rc_control_interface: VAR_CONTROL_INTERFACE STRING_ARG
3492 	{
3493 		OUTYY(("P(control_interface:%s)\n", $2));
3494 		if(!cfg_strlist_append(&cfg_parser->cfg->control_ifs, $2))
3495 			yyerror("out of memory");
3496 	}
3497 	;
3498 rc_control_use_cert: VAR_CONTROL_USE_CERT STRING_ARG
3499 	{
3500 		OUTYY(("P(control_use_cert:%s)\n", $2));
3501 		cfg_parser->cfg->control_use_cert = (strcmp($2, "yes")==0);
3502 		free($2);
3503 	}
3504 	;
3505 rc_server_key_file: VAR_SERVER_KEY_FILE STRING_ARG
3506 	{
3507 		OUTYY(("P(rc_server_key_file:%s)\n", $2));
3508 		free(cfg_parser->cfg->server_key_file);
3509 		cfg_parser->cfg->server_key_file = $2;
3510 	}
3511 	;
3512 rc_server_cert_file: VAR_SERVER_CERT_FILE STRING_ARG
3513 	{
3514 		OUTYY(("P(rc_server_cert_file:%s)\n", $2));
3515 		free(cfg_parser->cfg->server_cert_file);
3516 		cfg_parser->cfg->server_cert_file = $2;
3517 	}
3518 	;
3519 rc_control_key_file: VAR_CONTROL_KEY_FILE STRING_ARG
3520 	{
3521 		OUTYY(("P(rc_control_key_file:%s)\n", $2));
3522 		free(cfg_parser->cfg->control_key_file);
3523 		cfg_parser->cfg->control_key_file = $2;
3524 	}
3525 	;
3526 rc_control_cert_file: VAR_CONTROL_CERT_FILE STRING_ARG
3527 	{
3528 		OUTYY(("P(rc_control_cert_file:%s)\n", $2));
3529 		free(cfg_parser->cfg->control_cert_file);
3530 		cfg_parser->cfg->control_cert_file = $2;
3531 	}
3532 	;
3533 dtstart: VAR_DNSTAP
3534 	{
3535 		OUTYY(("\nP(dnstap:)\n"));
3536 		cfg_parser->started_toplevel = 1;
3537 	}
3538 	;
3539 contents_dt: contents_dt content_dt
3540 	| ;
3541 content_dt: dt_dnstap_enable | dt_dnstap_socket_path | dt_dnstap_bidirectional |
3542 	dt_dnstap_ip | dt_dnstap_tls | dt_dnstap_tls_server_name |
3543 	dt_dnstap_tls_cert_bundle |
3544 	dt_dnstap_tls_client_key_file | dt_dnstap_tls_client_cert_file |
3545 	dt_dnstap_send_identity | dt_dnstap_send_version |
3546 	dt_dnstap_identity | dt_dnstap_version |
3547 	dt_dnstap_log_resolver_query_messages |
3548 	dt_dnstap_log_resolver_response_messages |
3549 	dt_dnstap_log_client_query_messages |
3550 	dt_dnstap_log_client_response_messages |
3551 	dt_dnstap_log_forwarder_query_messages |
3552 	dt_dnstap_log_forwarder_response_messages |
3553 	dt_dnstap_sample_rate
3554 	;
3555 dt_dnstap_enable: VAR_DNSTAP_ENABLE STRING_ARG
3556 	{
3557 		OUTYY(("P(dt_dnstap_enable:%s)\n", $2));
3558 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3559 			yyerror("expected yes or no.");
3560 		else cfg_parser->cfg->dnstap = (strcmp($2, "yes")==0);
3561 		free($2);
3562 	}
3563 	;
3564 dt_dnstap_bidirectional: VAR_DNSTAP_BIDIRECTIONAL STRING_ARG
3565 	{
3566 		OUTYY(("P(dt_dnstap_bidirectional:%s)\n", $2));
3567 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3568 			yyerror("expected yes or no.");
3569 		else cfg_parser->cfg->dnstap_bidirectional =
3570 			(strcmp($2, "yes")==0);
3571 		free($2);
3572 	}
3573 	;
3574 dt_dnstap_socket_path: VAR_DNSTAP_SOCKET_PATH STRING_ARG
3575 	{
3576 		OUTYY(("P(dt_dnstap_socket_path:%s)\n", $2));
3577 		free(cfg_parser->cfg->dnstap_socket_path);
3578 		cfg_parser->cfg->dnstap_socket_path = $2;
3579 	}
3580 	;
3581 dt_dnstap_ip: VAR_DNSTAP_IP STRING_ARG
3582 	{
3583 		OUTYY(("P(dt_dnstap_ip:%s)\n", $2));
3584 		free(cfg_parser->cfg->dnstap_ip);
3585 		cfg_parser->cfg->dnstap_ip = $2;
3586 	}
3587 	;
3588 dt_dnstap_tls: VAR_DNSTAP_TLS STRING_ARG
3589 	{
3590 		OUTYY(("P(dt_dnstap_tls:%s)\n", $2));
3591 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3592 			yyerror("expected yes or no.");
3593 		else cfg_parser->cfg->dnstap_tls = (strcmp($2, "yes")==0);
3594 		free($2);
3595 	}
3596 	;
3597 dt_dnstap_tls_server_name: VAR_DNSTAP_TLS_SERVER_NAME STRING_ARG
3598 	{
3599 		OUTYY(("P(dt_dnstap_tls_server_name:%s)\n", $2));
3600 		free(cfg_parser->cfg->dnstap_tls_server_name);
3601 		cfg_parser->cfg->dnstap_tls_server_name = $2;
3602 	}
3603 	;
3604 dt_dnstap_tls_cert_bundle: VAR_DNSTAP_TLS_CERT_BUNDLE STRING_ARG
3605 	{
3606 		OUTYY(("P(dt_dnstap_tls_cert_bundle:%s)\n", $2));
3607 		free(cfg_parser->cfg->dnstap_tls_cert_bundle);
3608 		cfg_parser->cfg->dnstap_tls_cert_bundle = $2;
3609 	}
3610 	;
3611 dt_dnstap_tls_client_key_file: VAR_DNSTAP_TLS_CLIENT_KEY_FILE STRING_ARG
3612 	{
3613 		OUTYY(("P(dt_dnstap_tls_client_key_file:%s)\n", $2));
3614 		free(cfg_parser->cfg->dnstap_tls_client_key_file);
3615 		cfg_parser->cfg->dnstap_tls_client_key_file = $2;
3616 	}
3617 	;
3618 dt_dnstap_tls_client_cert_file: VAR_DNSTAP_TLS_CLIENT_CERT_FILE STRING_ARG
3619 	{
3620 		OUTYY(("P(dt_dnstap_tls_client_cert_file:%s)\n", $2));
3621 		free(cfg_parser->cfg->dnstap_tls_client_cert_file);
3622 		cfg_parser->cfg->dnstap_tls_client_cert_file = $2;
3623 	}
3624 	;
3625 dt_dnstap_send_identity: VAR_DNSTAP_SEND_IDENTITY STRING_ARG
3626 	{
3627 		OUTYY(("P(dt_dnstap_send_identity:%s)\n", $2));
3628 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3629 			yyerror("expected yes or no.");
3630 		else cfg_parser->cfg->dnstap_send_identity = (strcmp($2, "yes")==0);
3631 		free($2);
3632 	}
3633 	;
3634 dt_dnstap_send_version: VAR_DNSTAP_SEND_VERSION STRING_ARG
3635 	{
3636 		OUTYY(("P(dt_dnstap_send_version:%s)\n", $2));
3637 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3638 			yyerror("expected yes or no.");
3639 		else cfg_parser->cfg->dnstap_send_version = (strcmp($2, "yes")==0);
3640 		free($2);
3641 	}
3642 	;
3643 dt_dnstap_identity: VAR_DNSTAP_IDENTITY STRING_ARG
3644 	{
3645 		OUTYY(("P(dt_dnstap_identity:%s)\n", $2));
3646 		free(cfg_parser->cfg->dnstap_identity);
3647 		cfg_parser->cfg->dnstap_identity = $2;
3648 	}
3649 	;
3650 dt_dnstap_version: VAR_DNSTAP_VERSION STRING_ARG
3651 	{
3652 		OUTYY(("P(dt_dnstap_version:%s)\n", $2));
3653 		free(cfg_parser->cfg->dnstap_version);
3654 		cfg_parser->cfg->dnstap_version = $2;
3655 	}
3656 	;
3657 dt_dnstap_log_resolver_query_messages: VAR_DNSTAP_LOG_RESOLVER_QUERY_MESSAGES STRING_ARG
3658 	{
3659 		OUTYY(("P(dt_dnstap_log_resolver_query_messages:%s)\n", $2));
3660 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3661 			yyerror("expected yes or no.");
3662 		else cfg_parser->cfg->dnstap_log_resolver_query_messages =
3663 			(strcmp($2, "yes")==0);
3664 		free($2);
3665 	}
3666 	;
3667 dt_dnstap_log_resolver_response_messages: VAR_DNSTAP_LOG_RESOLVER_RESPONSE_MESSAGES STRING_ARG
3668 	{
3669 		OUTYY(("P(dt_dnstap_log_resolver_response_messages:%s)\n", $2));
3670 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3671 			yyerror("expected yes or no.");
3672 		else cfg_parser->cfg->dnstap_log_resolver_response_messages =
3673 			(strcmp($2, "yes")==0);
3674 		free($2);
3675 	}
3676 	;
3677 dt_dnstap_log_client_query_messages: VAR_DNSTAP_LOG_CLIENT_QUERY_MESSAGES STRING_ARG
3678 	{
3679 		OUTYY(("P(dt_dnstap_log_client_query_messages:%s)\n", $2));
3680 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3681 			yyerror("expected yes or no.");
3682 		else cfg_parser->cfg->dnstap_log_client_query_messages =
3683 			(strcmp($2, "yes")==0);
3684 		free($2);
3685 	}
3686 	;
3687 dt_dnstap_log_client_response_messages: VAR_DNSTAP_LOG_CLIENT_RESPONSE_MESSAGES STRING_ARG
3688 	{
3689 		OUTYY(("P(dt_dnstap_log_client_response_messages:%s)\n", $2));
3690 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3691 			yyerror("expected yes or no.");
3692 		else cfg_parser->cfg->dnstap_log_client_response_messages =
3693 			(strcmp($2, "yes")==0);
3694 		free($2);
3695 	}
3696 	;
3697 dt_dnstap_log_forwarder_query_messages: VAR_DNSTAP_LOG_FORWARDER_QUERY_MESSAGES STRING_ARG
3698 	{
3699 		OUTYY(("P(dt_dnstap_log_forwarder_query_messages:%s)\n", $2));
3700 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3701 			yyerror("expected yes or no.");
3702 		else cfg_parser->cfg->dnstap_log_forwarder_query_messages =
3703 			(strcmp($2, "yes")==0);
3704 		free($2);
3705 	}
3706 	;
3707 dt_dnstap_log_forwarder_response_messages: VAR_DNSTAP_LOG_FORWARDER_RESPONSE_MESSAGES STRING_ARG
3708 	{
3709 		OUTYY(("P(dt_dnstap_log_forwarder_response_messages:%s)\n", $2));
3710 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3711 			yyerror("expected yes or no.");
3712 		else cfg_parser->cfg->dnstap_log_forwarder_response_messages =
3713 			(strcmp($2, "yes")==0);
3714 		free($2);
3715 	}
3716 	;
3717 dt_dnstap_sample_rate: VAR_DNSTAP_SAMPLE_RATE STRING_ARG
3718 	{
3719 		OUTYY(("P(dt_dnstap_sample_rate:%s)\n", $2));
3720 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
3721 			yyerror("number expected");
3722 		else if(atoi($2) < 0)
3723 			yyerror("dnstap sample rate too small");
3724 		else	cfg_parser->cfg->dnstap_sample_rate = atoi($2);
3725 		free($2);
3726 	}
3727 	;
3728 pythonstart: VAR_PYTHON
3729 	{
3730 		OUTYY(("\nP(python:)\n"));
3731 		cfg_parser->started_toplevel = 1;
3732 	}
3733 	;
3734 contents_py: contents_py content_py
3735 	| ;
3736 content_py: py_script
3737 	;
3738 py_script: VAR_PYTHON_SCRIPT STRING_ARG
3739 	{
3740 		OUTYY(("P(python-script:%s)\n", $2));
3741 		if(!cfg_strlist_append_ex(&cfg_parser->cfg->python_script, $2))
3742 			yyerror("out of memory");
3743 	}
3744 	;
3745 dynlibstart: VAR_DYNLIB
3746 	{
3747 		OUTYY(("\nP(dynlib:)\n"));
3748 		cfg_parser->started_toplevel = 1;
3749 	}
3750 	;
3751 contents_dl: contents_dl content_dl
3752 	| ;
3753 content_dl: dl_file
3754 	;
3755 dl_file: VAR_DYNLIB_FILE STRING_ARG
3756 	{
3757 		OUTYY(("P(dynlib-file:%s)\n", $2));
3758 		if(!cfg_strlist_append_ex(&cfg_parser->cfg->dynlib_file, $2))
3759 			yyerror("out of memory");
3760 	}
3761 	;
3762 server_disable_dnssec_lame_check: VAR_DISABLE_DNSSEC_LAME_CHECK STRING_ARG
3763 	{
3764 		OUTYY(("P(disable_dnssec_lame_check:%s)\n", $2));
3765 		if (strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3766 			yyerror("expected yes or no.");
3767 		else cfg_parser->cfg->disable_dnssec_lame_check =
3768 			(strcmp($2, "yes")==0);
3769 		free($2);
3770 	}
3771 	;
3772 server_log_identity: VAR_LOG_IDENTITY STRING_ARG
3773 	{
3774 		OUTYY(("P(server_log_identity:%s)\n", $2));
3775 		free(cfg_parser->cfg->log_identity);
3776 		cfg_parser->cfg->log_identity = $2;
3777 	}
3778 	;
3779 server_response_ip: VAR_RESPONSE_IP STRING_ARG STRING_ARG
3780 	{
3781 		OUTYY(("P(server_response_ip:%s %s)\n", $2, $3));
3782 		validate_respip_action($3);
3783 		if(!cfg_str2list_insert(&cfg_parser->cfg->respip_actions,
3784 			$2, $3))
3785 			fatal_exit("out of memory adding response-ip");
3786 	}
3787 	;
3788 server_response_ip_data: VAR_RESPONSE_IP_DATA STRING_ARG STRING_ARG
3789 	{
3790 		OUTYY(("P(server_response_ip_data:%s)\n", $2));
3791 		if(!cfg_str2list_insert(&cfg_parser->cfg->respip_data,
3792 			$2, $3))
3793 			fatal_exit("out of memory adding response-ip-data");
3794 	}
3795 	;
3796 dnscstart: VAR_DNSCRYPT
3797 	{
3798 		OUTYY(("\nP(dnscrypt:)\n"));
3799 		cfg_parser->started_toplevel = 1;
3800 	}
3801 	;
3802 contents_dnsc: contents_dnsc content_dnsc
3803 	| ;
3804 content_dnsc:
3805 	dnsc_dnscrypt_enable | dnsc_dnscrypt_port | dnsc_dnscrypt_provider |
3806 	dnsc_dnscrypt_secret_key | dnsc_dnscrypt_provider_cert |
3807 	dnsc_dnscrypt_provider_cert_rotated |
3808 	dnsc_dnscrypt_shared_secret_cache_size |
3809 	dnsc_dnscrypt_shared_secret_cache_slabs |
3810 	dnsc_dnscrypt_nonce_cache_size |
3811 	dnsc_dnscrypt_nonce_cache_slabs
3812 	;
3813 dnsc_dnscrypt_enable: VAR_DNSCRYPT_ENABLE STRING_ARG
3814 	{
3815 		OUTYY(("P(dnsc_dnscrypt_enable:%s)\n", $2));
3816 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3817 			yyerror("expected yes or no.");
3818 		else cfg_parser->cfg->dnscrypt = (strcmp($2, "yes")==0);
3819 		free($2);
3820 	}
3821 	;
3822 dnsc_dnscrypt_port: VAR_DNSCRYPT_PORT STRING_ARG
3823 	{
3824 		OUTYY(("P(dnsc_dnscrypt_port:%s)\n", $2));
3825 		if(atoi($2) == 0)
3826 			yyerror("port number expected");
3827 		else cfg_parser->cfg->dnscrypt_port = atoi($2);
3828 		free($2);
3829 	}
3830 	;
3831 dnsc_dnscrypt_provider: VAR_DNSCRYPT_PROVIDER STRING_ARG
3832 	{
3833 		OUTYY(("P(dnsc_dnscrypt_provider:%s)\n", $2));
3834 		free(cfg_parser->cfg->dnscrypt_provider);
3835 		cfg_parser->cfg->dnscrypt_provider = $2;
3836 	}
3837 	;
3838 dnsc_dnscrypt_provider_cert: VAR_DNSCRYPT_PROVIDER_CERT STRING_ARG
3839 	{
3840 		OUTYY(("P(dnsc_dnscrypt_provider_cert:%s)\n", $2));
3841 		if(cfg_strlist_find(cfg_parser->cfg->dnscrypt_provider_cert, $2))
3842 			log_warn("dnscrypt-provider-cert %s is a duplicate", $2);
3843 		if(!cfg_strlist_insert(&cfg_parser->cfg->dnscrypt_provider_cert, $2))
3844 			fatal_exit("out of memory adding dnscrypt-provider-cert");
3845 	}
3846 	;
3847 dnsc_dnscrypt_provider_cert_rotated: VAR_DNSCRYPT_PROVIDER_CERT_ROTATED STRING_ARG
3848 	{
3849 		OUTYY(("P(dnsc_dnscrypt_provider_cert_rotated:%s)\n", $2));
3850 		if(!cfg_strlist_insert(&cfg_parser->cfg->dnscrypt_provider_cert_rotated, $2))
3851 			fatal_exit("out of memory adding dnscrypt-provider-cert-rotated");
3852 	}
3853 	;
3854 dnsc_dnscrypt_secret_key: VAR_DNSCRYPT_SECRET_KEY STRING_ARG
3855 	{
3856 		OUTYY(("P(dnsc_dnscrypt_secret_key:%s)\n", $2));
3857 		if(cfg_strlist_find(cfg_parser->cfg->dnscrypt_secret_key, $2))
3858 			log_warn("dnscrypt-secret-key: %s is a duplicate", $2);
3859 		if(!cfg_strlist_insert(&cfg_parser->cfg->dnscrypt_secret_key, $2))
3860 			fatal_exit("out of memory adding dnscrypt-secret-key");
3861 	}
3862 	;
3863 dnsc_dnscrypt_shared_secret_cache_size: VAR_DNSCRYPT_SHARED_SECRET_CACHE_SIZE STRING_ARG
3864   {
3865 	OUTYY(("P(dnscrypt_shared_secret_cache_size:%s)\n", $2));
3866 	if(!cfg_parse_memsize($2, &cfg_parser->cfg->dnscrypt_shared_secret_cache_size))
3867 		yyerror("memory size expected");
3868 	free($2);
3869   }
3870   ;
3871 dnsc_dnscrypt_shared_secret_cache_slabs: VAR_DNSCRYPT_SHARED_SECRET_CACHE_SLABS STRING_ARG
3872   {
3873 	OUTYY(("P(dnscrypt_shared_secret_cache_slabs:%s)\n", $2));
3874 	if(atoi($2) == 0) {
3875 		yyerror("number expected");
3876 	} else {
3877 		cfg_parser->cfg->dnscrypt_shared_secret_cache_slabs = atoi($2);
3878 		if(!is_pow2(cfg_parser->cfg->dnscrypt_shared_secret_cache_slabs))
3879 			yyerror("must be a power of 2");
3880 	}
3881 	free($2);
3882   }
3883   ;
3884 dnsc_dnscrypt_nonce_cache_size: VAR_DNSCRYPT_NONCE_CACHE_SIZE STRING_ARG
3885   {
3886 	OUTYY(("P(dnscrypt_nonce_cache_size:%s)\n", $2));
3887 	if(!cfg_parse_memsize($2, &cfg_parser->cfg->dnscrypt_nonce_cache_size))
3888 		yyerror("memory size expected");
3889 	free($2);
3890   }
3891   ;
3892 dnsc_dnscrypt_nonce_cache_slabs: VAR_DNSCRYPT_NONCE_CACHE_SLABS STRING_ARG
3893   {
3894 	OUTYY(("P(dnscrypt_nonce_cache_slabs:%s)\n", $2));
3895 	if(atoi($2) == 0) {
3896 		yyerror("number expected");
3897 	} else {
3898 		cfg_parser->cfg->dnscrypt_nonce_cache_slabs = atoi($2);
3899 		if(!is_pow2(cfg_parser->cfg->dnscrypt_nonce_cache_slabs))
3900 			yyerror("must be a power of 2");
3901 	}
3902 	free($2);
3903   }
3904   ;
3905 cachedbstart: VAR_CACHEDB
3906 	{
3907 		OUTYY(("\nP(cachedb:)\n"));
3908 		cfg_parser->started_toplevel = 1;
3909 	}
3910 	;
3911 contents_cachedb: contents_cachedb content_cachedb
3912 	| ;
3913 content_cachedb: cachedb_backend_name | cachedb_secret_seed |
3914 	redis_server_host | redis_replica_server_host |
3915 	redis_server_port | redis_replica_server_port |
3916 	redis_timeout | redis_replica_timeout |
3917 	redis_command_timeout | redis_replica_command_timeout |
3918 	redis_connect_timeout | redis_replica_connect_timeout |
3919 	redis_server_path | redis_replica_server_path |
3920 	redis_server_password | redis_replica_server_password |
3921 	redis_logical_db | redis_replica_logical_db |
3922 	cachedb_no_store | redis_expire_records |
3923 	cachedb_check_when_serve_expired
3924 	;
3925 cachedb_backend_name: VAR_CACHEDB_BACKEND STRING_ARG
3926 	{
3927 	#ifdef USE_CACHEDB
3928 		OUTYY(("P(backend:%s)\n", $2));
3929 		free(cfg_parser->cfg->cachedb_backend);
3930 		cfg_parser->cfg->cachedb_backend = $2;
3931 	#else
3932 		OUTYY(("P(Compiled without cachedb, ignoring)\n"));
3933 		free($2);
3934 	#endif
3935 	}
3936 	;
3937 cachedb_secret_seed: VAR_CACHEDB_SECRETSEED STRING_ARG
3938 	{
3939 	#ifdef USE_CACHEDB
3940 		OUTYY(("P(secret-seed:%s)\n", $2));
3941 		free(cfg_parser->cfg->cachedb_secret);
3942 		cfg_parser->cfg->cachedb_secret = $2;
3943 	#else
3944 		OUTYY(("P(Compiled without cachedb, ignoring)\n"));
3945 		free($2);
3946 	#endif
3947 	}
3948 	;
3949 cachedb_no_store: VAR_CACHEDB_NO_STORE STRING_ARG
3950 	{
3951 	#ifdef USE_CACHEDB
3952 		OUTYY(("P(cachedb_no_store:%s)\n", $2));
3953 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3954 			yyerror("expected yes or no.");
3955 		else cfg_parser->cfg->cachedb_no_store = (strcmp($2, "yes")==0);
3956 	#else
3957 		OUTYY(("P(Compiled without cachedb, ignoring)\n"));
3958 	#endif
3959 		free($2);
3960 	}
3961 	;
3962 cachedb_check_when_serve_expired: VAR_CACHEDB_CHECK_WHEN_SERVE_EXPIRED STRING_ARG
3963 	{
3964 	#ifdef USE_CACHEDB
3965 		OUTYY(("P(cachedb_check_when_serve_expired:%s)\n", $2));
3966 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
3967 			yyerror("expected yes or no.");
3968 		else cfg_parser->cfg->cachedb_check_when_serve_expired = (strcmp($2, "yes")==0);
3969 	#else
3970 		OUTYY(("P(Compiled without cachedb, ignoring)\n"));
3971 	#endif
3972 		free($2);
3973 	}
3974 	;
3975 redis_server_host: VAR_CACHEDB_REDISHOST STRING_ARG
3976 	{
3977 	#if defined(USE_CACHEDB) && defined(USE_REDIS)
3978 		OUTYY(("P(redis_server_host:%s)\n", $2));
3979 		free(cfg_parser->cfg->redis_server_host);
3980 		cfg_parser->cfg->redis_server_host = $2;
3981 	#else
3982 		OUTYY(("P(Compiled without cachedb or redis, ignoring)\n"));
3983 		free($2);
3984 	#endif
3985 	}
3986 	;
3987 redis_replica_server_host: VAR_CACHEDB_REDISREPLICAHOST STRING_ARG
3988 	{
3989 	#if defined(USE_CACHEDB) && defined(USE_REDIS)
3990 		OUTYY(("P(redis_replica_server_host:%s)\n", $2));
3991 		free(cfg_parser->cfg->redis_replica_server_host);
3992 		cfg_parser->cfg->redis_replica_server_host = $2;
3993 	#else
3994 		OUTYY(("P(Compiled without cachedb or redis, ignoring)\n"));
3995 		free($2);
3996 	#endif
3997 	}
3998 	;
3999 redis_server_port: VAR_CACHEDB_REDISPORT STRING_ARG
4000 	{
4001 	#if defined(USE_CACHEDB) && defined(USE_REDIS)
4002 		int port;
4003 		OUTYY(("P(redis_server_port:%s)\n", $2));
4004 		port = atoi($2);
4005 		if(port == 0 || port < 0 || port > 65535)
4006 			yyerror("valid redis server port number expected");
4007 		else cfg_parser->cfg->redis_server_port = port;
4008 	#else
4009 		OUTYY(("P(Compiled without cachedb or redis, ignoring)\n"));
4010 	#endif
4011 		free($2);
4012 	}
4013 	;
4014 redis_replica_server_port: VAR_CACHEDB_REDISREPLICAPORT STRING_ARG
4015 	{
4016 	#if defined(USE_CACHEDB) && defined(USE_REDIS)
4017 		int port;
4018 		OUTYY(("P(redis_replica_server_port:%s)\n", $2));
4019 		port = atoi($2);
4020 		if(port == 0 || port < 0 || port > 65535)
4021 			yyerror("valid redis server port number expected");
4022 		else cfg_parser->cfg->redis_replica_server_port = port;
4023 	#else
4024 		OUTYY(("P(Compiled without cachedb or redis, ignoring)\n"));
4025 	#endif
4026 		free($2);
4027 	}
4028 	;
4029 redis_server_path: VAR_CACHEDB_REDISPATH STRING_ARG
4030 	{
4031 	#if defined(USE_CACHEDB) && defined(USE_REDIS)
4032 		OUTYY(("P(redis_server_path:%s)\n", $2));
4033 		free(cfg_parser->cfg->redis_server_path);
4034 		cfg_parser->cfg->redis_server_path = $2;
4035 	#else
4036 		OUTYY(("P(Compiled without cachedb or redis, ignoring)\n"));
4037 		free($2);
4038 	#endif
4039 	}
4040 	;
4041 redis_replica_server_path: VAR_CACHEDB_REDISREPLICAPATH STRING_ARG
4042 	{
4043 	#if defined(USE_CACHEDB) && defined(USE_REDIS)
4044 		OUTYY(("P(redis_replica_server_path:%s)\n", $2));
4045 		free(cfg_parser->cfg->redis_replica_server_path);
4046 		cfg_parser->cfg->redis_replica_server_path = $2;
4047 	#else
4048 		OUTYY(("P(Compiled without cachedb or redis, ignoring)\n"));
4049 		free($2);
4050 	#endif
4051 	}
4052 	;
4053 redis_server_password: VAR_CACHEDB_REDISPASSWORD STRING_ARG
4054 	{
4055 	#if defined(USE_CACHEDB) && defined(USE_REDIS)
4056 		OUTYY(("P(redis_server_password:%s)\n", $2));
4057 		free(cfg_parser->cfg->redis_server_password);
4058 		cfg_parser->cfg->redis_server_password = $2;
4059 	#else
4060 		OUTYY(("P(Compiled without cachedb or redis, ignoring)\n"));
4061 		free($2);
4062 	#endif
4063 	}
4064 	;
4065 redis_replica_server_password: VAR_CACHEDB_REDISREPLICAPASSWORD STRING_ARG
4066 	{
4067 	#if defined(USE_CACHEDB) && defined(USE_REDIS)
4068 		OUTYY(("P(redis_replica_server_password:%s)\n", $2));
4069 		free(cfg_parser->cfg->redis_replica_server_password);
4070 		cfg_parser->cfg->redis_replica_server_password = $2;
4071 	#else
4072 		OUTYY(("P(Compiled without cachedb or redis, ignoring)\n"));
4073 		free($2);
4074 	#endif
4075 	}
4076 	;
4077 redis_timeout: VAR_CACHEDB_REDISTIMEOUT STRING_ARG
4078 	{
4079 	#if defined(USE_CACHEDB) && defined(USE_REDIS)
4080 		OUTYY(("P(redis_timeout:%s)\n", $2));
4081 		if(atoi($2) == 0)
4082 			yyerror("redis timeout value expected");
4083 		else cfg_parser->cfg->redis_timeout = atoi($2);
4084 	#else
4085 		OUTYY(("P(Compiled without cachedb or redis, ignoring)\n"));
4086 	#endif
4087 		free($2);
4088 	}
4089 	;
4090 redis_replica_timeout: VAR_CACHEDB_REDISREPLICATIMEOUT STRING_ARG
4091 	{
4092 	#if defined(USE_CACHEDB) && defined(USE_REDIS)
4093 		OUTYY(("P(redis_replica_timeout:%s)\n", $2));
4094 		if(atoi($2) == 0)
4095 			yyerror("redis timeout value expected");
4096 		else cfg_parser->cfg->redis_replica_timeout = atoi($2);
4097 	#else
4098 		OUTYY(("P(Compiled without cachedb or redis, ignoring)\n"));
4099 	#endif
4100 		free($2);
4101 	}
4102 	;
4103 redis_command_timeout: VAR_CACHEDB_REDISCOMMANDTIMEOUT STRING_ARG
4104 	{
4105 	#if defined(USE_CACHEDB) && defined(USE_REDIS)
4106 		OUTYY(("P(redis_command_timeout:%s)\n", $2));
4107 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
4108 			yyerror("redis command timeout value expected");
4109 		else cfg_parser->cfg->redis_command_timeout = atoi($2);
4110 	#else
4111 		OUTYY(("P(Compiled without cachedb or redis, ignoring)\n"));
4112 	#endif
4113 		free($2);
4114 	}
4115 	;
4116 redis_replica_command_timeout: VAR_CACHEDB_REDISREPLICACOMMANDTIMEOUT STRING_ARG
4117 	{
4118 	#if defined(USE_CACHEDB) && defined(USE_REDIS)
4119 		OUTYY(("P(redis_replica_command_timeout:%s)\n", $2));
4120 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
4121 			yyerror("redis command timeout value expected");
4122 		else cfg_parser->cfg->redis_replica_command_timeout = atoi($2);
4123 	#else
4124 		OUTYY(("P(Compiled without cachedb or redis, ignoring)\n"));
4125 	#endif
4126 		free($2);
4127 	}
4128 	;
4129 redis_connect_timeout: VAR_CACHEDB_REDISCONNECTTIMEOUT STRING_ARG
4130 	{
4131 	#if defined(USE_CACHEDB) && defined(USE_REDIS)
4132 		OUTYY(("P(redis_connect_timeout:%s)\n", $2));
4133 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
4134 			yyerror("redis connect timeout value expected");
4135 		else cfg_parser->cfg->redis_connect_timeout = atoi($2);
4136 	#else
4137 		OUTYY(("P(Compiled without cachedb or redis, ignoring)\n"));
4138 	#endif
4139 		free($2);
4140 	}
4141 	;
4142 redis_replica_connect_timeout: VAR_CACHEDB_REDISREPLICACONNECTTIMEOUT STRING_ARG
4143 	{
4144 	#if defined(USE_CACHEDB) && defined(USE_REDIS)
4145 		OUTYY(("P(redis_replica_connect_timeout:%s)\n", $2));
4146 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
4147 			yyerror("redis connect timeout value expected");
4148 		else cfg_parser->cfg->redis_replica_connect_timeout = atoi($2);
4149 	#else
4150 		OUTYY(("P(Compiled without cachedb or redis, ignoring)\n"));
4151 	#endif
4152 		free($2);
4153 	}
4154 	;
4155 redis_expire_records: VAR_CACHEDB_REDISEXPIRERECORDS STRING_ARG
4156 	{
4157 	#if defined(USE_CACHEDB) && defined(USE_REDIS)
4158 		OUTYY(("P(redis_expire_records:%s)\n", $2));
4159 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
4160 			yyerror("expected yes or no.");
4161 		else cfg_parser->cfg->redis_expire_records = (strcmp($2, "yes")==0);
4162 	#else
4163 		OUTYY(("P(Compiled without cachedb or redis, ignoring)\n"));
4164 	#endif
4165 		free($2);
4166 	}
4167 	;
4168 redis_logical_db: VAR_CACHEDB_REDISLOGICALDB STRING_ARG
4169 	{
4170 	#if defined(USE_CACHEDB) && defined(USE_REDIS)
4171 		int db;
4172 		OUTYY(("P(redis_logical_db:%s)\n", $2));
4173 		db = atoi($2);
4174 		if((db == 0 && strcmp($2, "0") != 0) || db < 0)
4175 			yyerror("valid redis logical database index expected");
4176 		else cfg_parser->cfg->redis_logical_db = db;
4177 	#else
4178 		OUTYY(("P(Compiled without cachedb or redis, ignoring)\n"));
4179 	#endif
4180 		free($2);
4181 	}
4182 	;
4183 redis_replica_logical_db: VAR_CACHEDB_REDISREPLICALOGICALDB STRING_ARG
4184 	{
4185 	#if defined(USE_CACHEDB) && defined(USE_REDIS)
4186 		int db;
4187 		OUTYY(("P(redis_replica_logical_db:%s)\n", $2));
4188 		db = atoi($2);
4189 		if((db == 0 && strcmp($2, "0") != 0) || db < 0)
4190 			yyerror("valid redis logical database index expected");
4191 		else cfg_parser->cfg->redis_replica_logical_db = db;
4192 	#else
4193 		OUTYY(("P(Compiled without cachedb or redis, ignoring)\n"));
4194 	#endif
4195 		free($2);
4196 	}
4197 	;
4198 server_tcp_connection_limit: VAR_TCP_CONNECTION_LIMIT STRING_ARG STRING_ARG
4199 	{
4200 		OUTYY(("P(server_tcp_connection_limit:%s %s)\n", $2, $3));
4201 		if (atoi($3) < 0)
4202 			yyerror("positive number expected");
4203 		else {
4204 			if(!cfg_str2list_insert(&cfg_parser->cfg->tcp_connection_limits, $2, $3))
4205 				fatal_exit("out of memory adding tcp connection limit");
4206 		}
4207 	}
4208 	;
4209 server_answer_cookie: VAR_ANSWER_COOKIE STRING_ARG
4210 	{
4211 		OUTYY(("P(server_answer_cookie:%s)\n", $2));
4212 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
4213 			yyerror("expected yes or no.");
4214 		else cfg_parser->cfg->do_answer_cookie = (strcmp($2, "yes")==0);
4215 		free($2);
4216 	}
4217 	;
4218 server_cookie_secret: VAR_COOKIE_SECRET STRING_ARG
4219 	{
4220 		uint8_t secret[32];
4221 		size_t secret_len = sizeof(secret);
4222 
4223 		OUTYY(("P(server_cookie_secret:%s)\n", $2));
4224 		if(sldns_str2wire_hex_buf($2, secret, &secret_len)
4225 		|| (secret_len != 16))
4226 			yyerror("expected 128 bit hex string");
4227 		else {
4228 			cfg_parser->cfg->cookie_secret_len = secret_len;
4229 			memcpy(cfg_parser->cfg->cookie_secret, secret, sizeof(secret));
4230 		}
4231 		free($2);
4232 	}
4233 	;
4234 server_cookie_secret_file: VAR_COOKIE_SECRET_FILE STRING_ARG
4235 	{
4236 		OUTYY(("P(cookie_secret_file:%s)\n", $2));
4237 		free(cfg_parser->cfg->cookie_secret_file);
4238 		cfg_parser->cfg->cookie_secret_file = $2;
4239 	}
4240 	;
4241 server_iter_scrub_ns: VAR_ITER_SCRUB_NS STRING_ARG
4242 	{
4243 		OUTYY(("P(server_iter_scrub_ns:%s)\n", $2));
4244 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
4245 			yyerror("number expected");
4246 		else cfg_parser->cfg->iter_scrub_ns = atoi($2);
4247 		free($2);
4248 	}
4249 	;
4250 server_iter_scrub_cname: VAR_ITER_SCRUB_CNAME STRING_ARG
4251 	{
4252 		OUTYY(("P(server_iter_scrub_cname:%s)\n", $2));
4253 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
4254 			yyerror("number expected");
4255 		else cfg_parser->cfg->iter_scrub_cname = atoi($2);
4256 		free($2);
4257 	}
4258 	;
4259 server_iter_scrub_rrsig: VAR_ITER_SCRUB_RRSIG STRING_ARG
4260 	{
4261 		OUTYY(("P(server_iter_scrub_rrsig:%s)\n", $2));
4262 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
4263 			yyerror("number expected");
4264 		else cfg_parser->cfg->iter_scrub_rrsig = atoi($2);
4265 		free($2);
4266 	}
4267 	;
4268 server_max_global_quota: VAR_MAX_GLOBAL_QUOTA STRING_ARG
4269 	{
4270 		OUTYY(("P(server_max_global_quota:%s)\n", $2));
4271 		if(atoi($2) == 0 && strcmp($2, "0") != 0)
4272 			yyerror("number expected");
4273 		else cfg_parser->cfg->max_global_quota = atoi($2);
4274 		free($2);
4275 	}
4276 	;
4277 server_iter_scrub_promiscuous: VAR_ITER_SCRUB_PROMISCUOUS STRING_ARG
4278 	{
4279 		OUTYY(("P(server_iter_scrub_promiscuous:%s)\n", $2));
4280 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
4281 			yyerror("expected yes or no.");
4282 		else cfg_parser->cfg->iter_scrub_promiscuous =
4283 			(strcmp($2, "yes")==0);
4284 		free($2);
4285 	}
4286 	;
4287 ipsetstart: VAR_IPSET
4288 	{
4289 		OUTYY(("\nP(ipset:)\n"));
4290 		cfg_parser->started_toplevel = 1;
4291 	}
4292 	;
4293 contents_ipset: contents_ipset content_ipset
4294 	| ;
4295 content_ipset: ipset_name_v4 | ipset_name_v6
4296 	;
4297 ipset_name_v4: VAR_IPSET_NAME_V4 STRING_ARG
4298 	{
4299 	#ifdef USE_IPSET
4300 		OUTYY(("P(name-v4:%s)\n", $2));
4301 		if(cfg_parser->cfg->ipset_name_v4)
4302 			yyerror("ipset name v4 override, there must be one "
4303 				"name for ip v4");
4304 		free(cfg_parser->cfg->ipset_name_v4);
4305 		cfg_parser->cfg->ipset_name_v4 = $2;
4306 	#else
4307 		OUTYY(("P(Compiled without ipset, ignoring)\n"));
4308 		free($2);
4309 	#endif
4310 	}
4311 	;
4312 ipset_name_v6: VAR_IPSET_NAME_V6 STRING_ARG
4313 	{
4314 	#ifdef USE_IPSET
4315 		OUTYY(("P(name-v6:%s)\n", $2));
4316 		if(cfg_parser->cfg->ipset_name_v6)
4317 			yyerror("ipset name v6 override, there must be one "
4318 				"name for ip v6");
4319 		free(cfg_parser->cfg->ipset_name_v6);
4320 		cfg_parser->cfg->ipset_name_v6 = $2;
4321 	#else
4322 		OUTYY(("P(Compiled without ipset, ignoring)\n"));
4323 		free($2);
4324 	#endif
4325 	}
4326 	;
4327 %%
4328 
4329 /* parse helper routines could be here */
4330 static void
4331 validate_respip_action(const char* action)
4332 {
4333 	if(strcmp(action, "deny")!=0 &&
4334 		strcmp(action, "redirect")!=0 &&
4335 		strcmp(action, "inform")!=0 &&
4336 		strcmp(action, "inform_deny")!=0 &&
4337 		strcmp(action, "always_transparent")!=0 &&
4338 		strcmp(action, "always_refuse")!=0 &&
4339 		strcmp(action, "always_nxdomain")!=0)
4340 	{
4341 		yyerror("response-ip action: expected deny, redirect, "
4342 			"inform, inform_deny, always_transparent, "
4343 			"always_refuse or always_nxdomain");
4344 	}
4345 }
4346 
4347 static void
validate_acl_action(const char * action)4348 validate_acl_action(const char* action)
4349 {
4350 	if(strcmp(action, "deny")!=0 &&
4351 		strcmp(action, "refuse")!=0 &&
4352 		strcmp(action, "deny_non_local")!=0 &&
4353 		strcmp(action, "refuse_non_local")!=0 &&
4354 		strcmp(action, "allow_setrd")!=0 &&
4355 		strcmp(action, "allow")!=0 &&
4356 		strcmp(action, "allow_snoop")!=0 &&
4357 		strcmp(action, "allow_cookie")!=0)
4358 	{
4359 		yyerror("expected deny, refuse, deny_non_local, "
4360 			"refuse_non_local, allow, allow_setrd, "
4361 			"allow_snoop or allow_cookie as access control action");
4362 	}
4363 }
4364