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