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