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