xref: /netbsd-src/external/bsd/ntp/dist/ntpd/ntp_parser.y (revision eabc0478de71e4e011a5b4e0392741e01d491794)
1*eabc0478Schristos /*	$NetBSD: ntp_parser.y,v 1.20 2024/08/18 20:47:17 christos Exp $	*/
2abb0f93cSkardel 
3abb0f93cSkardel /* ntp_parser.y
4abb0f93cSkardel  *
5abb0f93cSkardel  * The parser for the NTP configuration file.
6abb0f93cSkardel  *
7abb0f93cSkardel  * Written By:	Sachin Kamboj
8abb0f93cSkardel  *		University of Delaware
9abb0f93cSkardel  *		Newark, DE 19711
10abb0f93cSkardel  * Copyright (c) 2006
11abb0f93cSkardel  */
12abb0f93cSkardel 
13abb0f93cSkardel %{
14abb0f93cSkardel   #ifdef HAVE_CONFIG_H
15abb0f93cSkardel   # include <config.h>
16abb0f93cSkardel   #endif
17abb0f93cSkardel 
183123f114Skardel   #include "ntp.h"
19abb0f93cSkardel   #include "ntpd.h"
20abb0f93cSkardel   #include "ntp_machine.h"
21abb0f93cSkardel   #include "ntp_stdlib.h"
22abb0f93cSkardel   #include "ntp_filegen.h"
23abb0f93cSkardel   #include "ntp_scanner.h"
24abb0f93cSkardel   #include "ntp_config.h"
25abb0f93cSkardel   #include "ntp_crypto.h"
2679045f13Schristos   #include "ntp_calendar.h"
27abb0f93cSkardel 
28abb0f93cSkardel   #include "ntpsim.h"		/* HMS: Do we really want this all the time? */
29abb0f93cSkardel 				/* SK: It might be a good idea to always
30abb0f93cSkardel 				   include the simulator code. That way
31abb0f93cSkardel 				   someone can use the same configuration file
32abb0f93cSkardel 				   for both the simulator and the daemon
33abb0f93cSkardel 				*/
34abb0f93cSkardel 
35abb0f93cSkardel   #define YYMALLOC	emalloc
36abb0f93cSkardel   #define YYFREE	free
37abb0f93cSkardel   #define YYERROR_VERBOSE
38abb0f93cSkardel   #define YYMAXDEPTH	1000	/* stop the madness sooner */
395d681e99Schristos   void yyerror(const char *msg);
40ea66d795Schristos 
41ea66d795Schristos   #ifdef SIM
42ea66d795Schristos   #  define ONLY_SIM(a)	(a)
43ea66d795Schristos   #else
44ea66d795Schristos   #  define ONLY_SIM(a)	NULL
45ea66d795Schristos   #endif
46abb0f93cSkardel %}
47abb0f93cSkardel 
48abb0f93cSkardel /*
49abb0f93cSkardel  * Enable generation of token names array even without YYDEBUG.
50abb0f93cSkardel  * We access via token_name() defined below.
51abb0f93cSkardel  */
52abb0f93cSkardel %token-table
53abb0f93cSkardel 
54abb0f93cSkardel %union {
55abb0f93cSkardel 	char *			String;
56abb0f93cSkardel 	double			Double;
57abb0f93cSkardel 	int			Integer;
582950cc38Schristos 	unsigned		U_int;
592950cc38Schristos 	gen_fifo *		Generic_fifo;
602950cc38Schristos 	attr_val *		Attr_val;
612950cc38Schristos 	attr_val_fifo *		Attr_val_fifo;
622950cc38Schristos 	int_fifo *		Int_fifo;
632950cc38Schristos 	string_fifo *		String_fifo;
642950cc38Schristos 	address_node *		Address_node;
652950cc38Schristos 	address_fifo *		Address_fifo;
662950cc38Schristos 	setvar_node *		Set_var;
67abb0f93cSkardel 	server_info *		Sim_server;
682950cc38Schristos 	server_info_fifo *	Sim_server_fifo;
69abb0f93cSkardel 	script_info *		Sim_script;
702950cc38Schristos 	script_info_fifo *	Sim_script_fifo;
71abb0f93cSkardel }
72abb0f93cSkardel 
73abb0f93cSkardel /* TERMINALS (do not appear left of colon) */
742950cc38Schristos %token	<Integer>	T_Abbrev
75abb0f93cSkardel %token	<Integer>	T_Age
76abb0f93cSkardel %token	<Integer>	T_All
77abb0f93cSkardel %token	<Integer>	T_Allan
782950cc38Schristos %token	<Integer>	T_Allpeers
79abb0f93cSkardel %token	<Integer>	T_Auth
80abb0f93cSkardel %token	<Integer>	T_Autokey
81abb0f93cSkardel %token	<Integer>	T_Automax
82abb0f93cSkardel %token	<Integer>	T_Average
834eea345dSchristos %token	<Integer>	T_Basedate
84abb0f93cSkardel %token	<Integer>	T_Bclient
8503cfe0ffSchristos %token	<Integer>	T_Bcpollbstep
86abb0f93cSkardel %token	<Integer>	T_Beacon
87abb0f93cSkardel %token	<Integer>	T_Broadcast
88abb0f93cSkardel %token	<Integer>	T_Broadcastclient
89abb0f93cSkardel %token	<Integer>	T_Broadcastdelay
90abb0f93cSkardel %token	<Integer>	T_Burst
91abb0f93cSkardel %token	<Integer>	T_Calibrate
92abb0f93cSkardel %token	<Integer>	T_Ceiling
93cdfa2a7eSchristos %token	<Integer>	T_Checkhash
94abb0f93cSkardel %token	<Integer>	T_Clockstats
95abb0f93cSkardel %token	<Integer>	T_Cohort
96abb0f93cSkardel %token	<Integer>	T_ControlKey
97abb0f93cSkardel %token	<Integer>	T_Crypto
98abb0f93cSkardel %token	<Integer>	T_Cryptostats
992950cc38Schristos %token	<Integer>	T_Ctl
100abb0f93cSkardel %token	<Integer>	T_Day
101abb0f93cSkardel %token	<Integer>	T_Default
102*eabc0478Schristos %token	<Integer>	T_Delrestrict
103*eabc0478Schristos %token	<Integer>	T_Device
104abb0f93cSkardel %token	<Integer>	T_Digest
105abb0f93cSkardel %token	<Integer>	T_Disable
106abb0f93cSkardel %token	<Integer>	T_Discard
107abb0f93cSkardel %token	<Integer>	T_Dispersion
1082950cc38Schristos %token	<Double>	T_Double		/* not a token */
109abb0f93cSkardel %token	<Integer>	T_Driftfile
110abb0f93cSkardel %token	<Integer>	T_Drop
1115d681e99Schristos %token	<Integer>	T_Dscp
1123123f114Skardel %token	<Integer>	T_Ellipsis	/* "..." not "ellipsis" */
113abb0f93cSkardel %token	<Integer>	T_Enable
114abb0f93cSkardel %token	<Integer>	T_End
1154eea345dSchristos %token	<Integer>	T_Epeer
116abb0f93cSkardel %token	<Integer>	T_False
117abb0f93cSkardel %token	<Integer>	T_File
118abb0f93cSkardel %token	<Integer>	T_Filegen
1192950cc38Schristos %token	<Integer>	T_Filenum
120abb0f93cSkardel %token	<Integer>	T_Flag1
121abb0f93cSkardel %token	<Integer>	T_Flag2
122abb0f93cSkardel %token	<Integer>	T_Flag3
123abb0f93cSkardel %token	<Integer>	T_Flag4
124abb0f93cSkardel %token	<Integer>	T_Flake
125abb0f93cSkardel %token	<Integer>	T_Floor
126abb0f93cSkardel %token	<Integer>	T_Freq
127abb0f93cSkardel %token	<Integer>	T_Fudge
128cdfa2a7eSchristos %token	<Integer>	T_Fuzz
129abb0f93cSkardel %token	<Integer>	T_Host
130abb0f93cSkardel %token	<Integer>	T_Huffpuff
131abb0f93cSkardel %token	<Integer>	T_Iburst
132abb0f93cSkardel %token	<Integer>	T_Ident
133abb0f93cSkardel %token	<Integer>	T_Ignore
134cdfa2a7eSchristos %token	<Integer>	T_Ignorehash
1352950cc38Schristos %token	<Integer>	T_Incalloc
1362950cc38Schristos %token	<Integer>	T_Incmem
1372950cc38Schristos %token	<Integer>	T_Initalloc
1382950cc38Schristos %token	<Integer>	T_Initmem
139abb0f93cSkardel %token	<Integer>	T_Includefile
1402950cc38Schristos %token	<Integer>	T_Integer		/* not a token */
141abb0f93cSkardel %token	<Integer>	T_Interface
1422950cc38Schristos %token	<Integer>	T_Intrange		/* not a token */
1432950cc38Schristos %token	<Integer>	T_Io
1444eea345dSchristos %token	<Integer>	T_Ippeerlimit
145abb0f93cSkardel %token	<Integer>	T_Ipv4
146abb0f93cSkardel %token	<Integer>	T_Ipv4_flag
147abb0f93cSkardel %token	<Integer>	T_Ipv6
148abb0f93cSkardel %token	<Integer>	T_Ipv6_flag
149abb0f93cSkardel %token	<Integer>	T_Kernel
150abb0f93cSkardel %token	<Integer>	T_Key
151abb0f93cSkardel %token	<Integer>	T_Keys
152abb0f93cSkardel %token	<Integer>	T_Keysdir
153abb0f93cSkardel %token	<Integer>	T_Kod
154abb0f93cSkardel %token	<Integer>	T_Leapfile
1555d681e99Schristos %token	<Integer>	T_Leapsmearinterval
156abb0f93cSkardel %token	<Integer>	T_Limited
157abb0f93cSkardel %token	<Integer>	T_Link
158abb0f93cSkardel %token	<Integer>	T_Listen
159abb0f93cSkardel %token	<Integer>	T_Logconfig
160abb0f93cSkardel %token	<Integer>	T_Logfile
161abb0f93cSkardel %token	<Integer>	T_Loopstats
162abb0f93cSkardel %token	<Integer>	T_Lowpriotrap
163abb0f93cSkardel %token	<Integer>	T_Manycastclient
164abb0f93cSkardel %token	<Integer>	T_Manycastserver
165abb0f93cSkardel %token	<Integer>	T_Mask
1662950cc38Schristos %token	<Integer>	T_Maxage
167abb0f93cSkardel %token	<Integer>	T_Maxclock
1682950cc38Schristos %token	<Integer>	T_Maxdepth
169abb0f93cSkardel %token	<Integer>	T_Maxdist
1702950cc38Schristos %token	<Integer>	T_Maxmem
171abb0f93cSkardel %token	<Integer>	T_Maxpoll
172a04a202dSchristos %token	<Integer>	T_Mdnstries
1732950cc38Schristos %token	<Integer>	T_Mem
1742950cc38Schristos %token	<Integer>	T_Memlock
175abb0f93cSkardel %token	<Integer>	T_Minclock
1762950cc38Schristos %token	<Integer>	T_Mindepth
177abb0f93cSkardel %token	<Integer>	T_Mindist
178abb0f93cSkardel %token	<Integer>	T_Minimum
179cdfa2a7eSchristos %token	<Integer>	T_Minjitter
180abb0f93cSkardel %token	<Integer>	T_Minpoll
181abb0f93cSkardel %token	<Integer>	T_Minsane
182abb0f93cSkardel %token	<Integer>	T_Mode
1832950cc38Schristos %token	<Integer>	T_Mode7
184abb0f93cSkardel %token	<Integer>	T_Monitor
185abb0f93cSkardel %token	<Integer>	T_Month
1862950cc38Schristos %token	<Integer>	T_Mru
187cdfa2a7eSchristos %token	<Integer>	T_Mssntp
188abb0f93cSkardel %token	<Integer>	T_Multicastclient
189abb0f93cSkardel %token	<Integer>	T_Nic
190abb0f93cSkardel %token	<Integer>	T_Nolink
191abb0f93cSkardel %token	<Integer>	T_Nomodify
1922950cc38Schristos %token	<Integer>	T_Nomrulist
193abb0f93cSkardel %token	<Integer>	T_None
1942950cc38Schristos %token	<Integer>	T_Nonvolatile
1954eea345dSchristos %token	<Integer>	T_Noepeer
196abb0f93cSkardel %token	<Integer>	T_Nopeer
197abb0f93cSkardel %token	<Integer>	T_Noquery
198abb0f93cSkardel %token	<Integer>	T_Noselect
199abb0f93cSkardel %token	<Integer>	T_Noserve
200abb0f93cSkardel %token	<Integer>	T_Notrap
201abb0f93cSkardel %token	<Integer>	T_Notrust
202abb0f93cSkardel %token	<Integer>	T_Ntp
203abb0f93cSkardel %token	<Integer>	T_Ntpport
204abb0f93cSkardel %token	<Integer>	T_NtpSignDsocket
205abb0f93cSkardel %token	<Integer>	T_Orphan
2062950cc38Schristos %token	<Integer>	T_Orphanwait
207717847f5Schristos %token	<Integer>	T_PCEdigest
208abb0f93cSkardel %token	<Integer>	T_Panic
209abb0f93cSkardel %token	<Integer>	T_Peer
210abb0f93cSkardel %token	<Integer>	T_Peerstats
211abb0f93cSkardel %token	<Integer>	T_Phone
212abb0f93cSkardel %token	<Integer>	T_Pid
213abb0f93cSkardel %token	<Integer>	T_Pidfile
214cdfa2a7eSchristos %token	<Integer>	T_Poll
215cdfa2a7eSchristos %token	<Integer>	T_PollSkewList
216abb0f93cSkardel %token	<Integer>	T_Pool
217abb0f93cSkardel %token	<Integer>	T_Port
218*eabc0478Schristos %token	<Integer>	T_PpsData
219abb0f93cSkardel %token	<Integer>	T_Preempt
220abb0f93cSkardel %token	<Integer>	T_Prefer
221abb0f93cSkardel %token	<Integer>	T_Protostats
222abb0f93cSkardel %token	<Integer>	T_Pw
223abb0f93cSkardel %token	<Integer>	T_Randfile
224abb0f93cSkardel %token	<Integer>	T_Rawstats
225abb0f93cSkardel %token	<Integer>	T_Refid
226abb0f93cSkardel %token	<Integer>	T_Requestkey
2272950cc38Schristos %token	<Integer>	T_Reset
228abb0f93cSkardel %token	<Integer>	T_Restrict
229abb0f93cSkardel %token	<Integer>	T_Revoke
2302950cc38Schristos %token	<Integer>	T_Rlimit
231abb0f93cSkardel %token	<Integer>	T_Saveconfigdir
232abb0f93cSkardel %token	<Integer>	T_Server
233cdfa2a7eSchristos %token	<Integer>	T_Serverresponse
234cdfa2a7eSchristos %token	<Integer>	T_ServerresponseFuzz	/* Not a token */
235abb0f93cSkardel %token	<Integer>	T_Setvar
2362950cc38Schristos %token	<Integer>	T_Source
2372950cc38Schristos %token	<Integer>	T_Stacksize
238abb0f93cSkardel %token	<Integer>	T_Statistics
239abb0f93cSkardel %token	<Integer>	T_Stats
240abb0f93cSkardel %token	<Integer>	T_Statsdir
241abb0f93cSkardel %token	<Integer>	T_Step
2427476e6e4Schristos %token	<Integer>	T_Stepback
2437476e6e4Schristos %token	<Integer>	T_Stepfwd
244abb0f93cSkardel %token	<Integer>	T_Stepout
245abb0f93cSkardel %token	<Integer>	T_Stratum
2462950cc38Schristos %token	<String>	T_String		/* not a token */
2472950cc38Schristos %token	<Integer>	T_Sys
248abb0f93cSkardel %token	<Integer>	T_Sysstats
249abb0f93cSkardel %token	<Integer>	T_Tick
250abb0f93cSkardel %token	<Integer>	T_Time1
251abb0f93cSkardel %token	<Integer>	T_Time2
252*eabc0478Schristos %token	<Integer>	T_TimeData
2532950cc38Schristos %token	<Integer>	T_Timer
254abb0f93cSkardel %token	<Integer>	T_Timingstats
255abb0f93cSkardel %token	<Integer>	T_Tinker
256abb0f93cSkardel %token	<Integer>	T_Tos
257abb0f93cSkardel %token	<Integer>	T_Trap
258abb0f93cSkardel %token	<Integer>	T_True
259abb0f93cSkardel %token	<Integer>	T_Trustedkey
260abb0f93cSkardel %token	<Integer>	T_Ttl
261abb0f93cSkardel %token	<Integer>	T_Type
2622950cc38Schristos %token	<Integer>	T_U_int			/* Not a token */
26368dbbb44Schristos %token	<Integer>	T_UEcrypto
26468dbbb44Schristos %token	<Integer>	T_UEcryptonak
26568dbbb44Schristos %token	<Integer>	T_UEdigest
266abb0f93cSkardel %token	<Integer>	T_Unconfig
267abb0f93cSkardel %token	<Integer>	T_Unpeer
268abb0f93cSkardel %token	<Integer>	T_Version
269abb0f93cSkardel %token	<Integer>	T_WanderThreshold	/* Not a token */
270abb0f93cSkardel %token	<Integer>	T_Week
271abb0f93cSkardel %token	<Integer>	T_Wildcard
272abb0f93cSkardel %token	<Integer>	T_Xleave
273cdfa2a7eSchristos %token	<Integer>	T_Xmtnonce
274abb0f93cSkardel %token	<Integer>	T_Year
2752950cc38Schristos %token	<Integer>	T_Flag			/* Not a token */
276abb0f93cSkardel %token	<Integer>	T_EOC
277abb0f93cSkardel 
278abb0f93cSkardel 
279abb0f93cSkardel /* NTP Simulator Tokens */
280abb0f93cSkardel %token	<Integer>	T_Simulate
281abb0f93cSkardel %token	<Integer>	T_Beep_Delay
282abb0f93cSkardel %token	<Integer>	T_Sim_Duration
283abb0f93cSkardel %token	<Integer>	T_Server_Offset
284abb0f93cSkardel %token	<Integer>	T_Duration
285abb0f93cSkardel %token	<Integer>	T_Freq_Offset
286abb0f93cSkardel %token	<Integer>	T_Wander
287abb0f93cSkardel %token	<Integer>	T_Jitter
288abb0f93cSkardel %token	<Integer>	T_Prop_Delay
289abb0f93cSkardel %token	<Integer>	T_Proc_Delay
290abb0f93cSkardel 
291abb0f93cSkardel 
292abb0f93cSkardel 
293abb0f93cSkardel /*** NON-TERMINALS ***/
294abb0f93cSkardel %type	<Integer>	access_control_flag
295cdfa2a7eSchristos %type	<Attr_val_fifo>	ac_flag_list
296abb0f93cSkardel %type	<Address_node>	address
2973123f114Skardel %type	<Integer>	address_fam
2982950cc38Schristos %type	<Address_fifo>	address_list
2994eea345dSchristos %type	<Integer>	basedate
300abb0f93cSkardel %type	<Integer>	boolean
301abb0f93cSkardel %type	<Integer>	client_type
3022950cc38Schristos %type	<Integer>	counter_set_keyword
3032950cc38Schristos %type	<Int_fifo>	counter_set_list
304abb0f93cSkardel %type	<Attr_val>	crypto_command
3052950cc38Schristos %type	<Attr_val_fifo>	crypto_command_list
3063123f114Skardel %type	<Integer>	crypto_str_keyword
307*eabc0478Schristos %type	<Attr_val>	device_item
308*eabc0478Schristos %type	<Integer>	device_item_path_keyword
309*eabc0478Schristos %type	<Attr_val_fifo>	device_item_list
310abb0f93cSkardel %type	<Attr_val>	discard_option
3113123f114Skardel %type	<Integer>	discard_option_keyword
3122950cc38Schristos %type	<Attr_val_fifo>	discard_option_list
3133123f114Skardel %type	<Integer>	enable_disable
314abb0f93cSkardel %type	<Attr_val>	filegen_option
3152950cc38Schristos %type	<Attr_val_fifo>	filegen_option_list
316abb0f93cSkardel %type	<Integer>	filegen_type
317abb0f93cSkardel %type	<Attr_val>	fudge_factor
3183123f114Skardel %type	<Integer>	fudge_factor_bool_keyword
3193123f114Skardel %type	<Integer>	fudge_factor_dbl_keyword
3202950cc38Schristos %type	<Attr_val_fifo>	fudge_factor_list
3212950cc38Schristos %type	<Attr_val_fifo>	integer_list
3222950cc38Schristos %type	<Attr_val_fifo>	integer_list_range
3233123f114Skardel %type	<Attr_val>	integer_list_range_elt
3243123f114Skardel %type	<Attr_val>	integer_range
325abb0f93cSkardel %type	<Integer>	nic_rule_action
3263123f114Skardel %type	<Integer>	interface_command
327abb0f93cSkardel %type	<Integer>	interface_nic
328abb0f93cSkardel %type	<Address_node>	ip_address
3294eea345dSchristos %type	<Integer>	res_ippeerlimit
3303123f114Skardel %type	<Integer>	link_nolink
331abb0f93cSkardel %type	<Attr_val>	log_config_command
3322950cc38Schristos %type	<Attr_val_fifo>	log_config_list
3333123f114Skardel %type	<Integer>	misc_cmd_dbl_keyword
3345d681e99Schristos %type	<Integer>	misc_cmd_int_keyword
3353123f114Skardel %type	<Integer>	misc_cmd_str_keyword
3363123f114Skardel %type	<Integer>	misc_cmd_str_lcl_keyword
3372950cc38Schristos %type	<Attr_val>	mru_option
3382950cc38Schristos %type	<Integer>	mru_option_keyword
3392950cc38Schristos %type	<Attr_val_fifo>	mru_option_list
340abb0f93cSkardel %type	<Integer>	nic_rule_class
341abb0f93cSkardel %type	<Double>	number
342cdfa2a7eSchristos %type	<Integer>	opt_hash_check
343abb0f93cSkardel %type	<Attr_val>	option
3443123f114Skardel %type	<Attr_val>	option_flag
3453123f114Skardel %type	<Integer>	option_flag_keyword
3462950cc38Schristos %type	<Attr_val_fifo>	option_list
3473123f114Skardel %type	<Attr_val>	option_int
3483123f114Skardel %type	<Integer>	option_int_keyword
3492950cc38Schristos %type	<Attr_val>	option_str
3502950cc38Schristos %type	<Integer>	option_str_keyword
351cdfa2a7eSchristos %type	<Attr_val_fifo>	pollskew_list
352cdfa2a7eSchristos %type	<Attr_val>	pollskew_cycle
353cdfa2a7eSchristos %type	<Attr_val>	pollskew_spec
3542950cc38Schristos %type	<Integer>	reset_command
355*eabc0478Schristos %type	<Address_node>	restrict_mask
3562950cc38Schristos %type	<Integer>	rlimit_option_keyword
3572950cc38Schristos %type	<Attr_val>	rlimit_option
3582950cc38Schristos %type	<Attr_val_fifo>	rlimit_option_list
359abb0f93cSkardel %type	<Integer>	stat
3602950cc38Schristos %type	<Int_fifo>	stats_list
3612950cc38Schristos %type	<String_fifo>	string_list
362abb0f93cSkardel %type	<Attr_val>	system_option
3633123f114Skardel %type	<Integer>	system_option_flag_keyword
3642950cc38Schristos %type	<Integer>	system_option_local_flag_keyword
3652950cc38Schristos %type	<Attr_val_fifo>	system_option_list
3663123f114Skardel %type	<Integer>	t_default_or_zero
3673123f114Skardel %type	<Integer>	tinker_option_keyword
368abb0f93cSkardel %type	<Attr_val>	tinker_option
3692950cc38Schristos %type	<Attr_val_fifo>	tinker_option_list
370abb0f93cSkardel %type	<Attr_val>	tos_option
3713123f114Skardel %type	<Integer>	tos_option_dbl_keyword
3723123f114Skardel %type	<Integer>	tos_option_int_keyword
3732950cc38Schristos %type	<Attr_val_fifo>	tos_option_list
374abb0f93cSkardel %type	<Attr_val>	trap_option
3752950cc38Schristos %type	<Attr_val_fifo>	trap_option_list
376abb0f93cSkardel %type	<Integer>	unpeer_keyword
377abb0f93cSkardel %type	<Set_var>	variable_assign
378abb0f93cSkardel 
379abb0f93cSkardel /* NTP Simulator non-terminals */
380abb0f93cSkardel %type	<Attr_val>		sim_init_statement
3812950cc38Schristos %type	<Attr_val_fifo>		sim_init_statement_list
3822950cc38Schristos %type	<Integer>		sim_init_keyword
3832950cc38Schristos %type	<Sim_server_fifo>	sim_server_list
384abb0f93cSkardel %type	<Sim_server>		sim_server
385abb0f93cSkardel %type	<Double>		sim_server_offset
386abb0f93cSkardel %type	<Address_node>		sim_server_name
387abb0f93cSkardel %type	<Sim_script>		sim_act
3882950cc38Schristos %type	<Sim_script_fifo>	sim_act_list
3892950cc38Schristos %type	<Integer>		sim_act_keyword
3902950cc38Schristos %type	<Attr_val_fifo>		sim_act_stmt_list
391abb0f93cSkardel %type	<Attr_val>		sim_act_stmt
392abb0f93cSkardel 
393abb0f93cSkardel %%
394abb0f93cSkardel 
395abb0f93cSkardel /* ntp.conf
396abb0f93cSkardel  * Configuration File Grammar
397abb0f93cSkardel  * --------------------------
398abb0f93cSkardel  */
399abb0f93cSkardel 
400abb0f93cSkardel configuration
401abb0f93cSkardel 	:	command_list
402abb0f93cSkardel 	;
403abb0f93cSkardel 
404abb0f93cSkardel command_list
405abb0f93cSkardel 	:	command_list command T_EOC
406abb0f93cSkardel 	|	command T_EOC
407abb0f93cSkardel 	|	error T_EOC
408abb0f93cSkardel 		{
409abb0f93cSkardel 			/* I will need to incorporate much more fine grained
410abb0f93cSkardel 			 * error messages. The following should suffice for
411abb0f93cSkardel 			 * the time being.
412abb0f93cSkardel 			 */
4135d681e99Schristos 			struct FILE_INFO * ip_ctx = lex_current();
414abb0f93cSkardel 			msyslog(LOG_ERR,
415abb0f93cSkardel 				"syntax error in %s line %d, column %d",
4165d681e99Schristos 				ip_ctx->fname,
4175d681e99Schristos 				ip_ctx->errpos.nline,
4185d681e99Schristos 				ip_ctx->errpos.ncol);
419abb0f93cSkardel 		}
420abb0f93cSkardel 	;
421abb0f93cSkardel 
422abb0f93cSkardel command :	/* NULL STATEMENT */
423abb0f93cSkardel 	|	server_command
424abb0f93cSkardel 	|	unpeer_command
425abb0f93cSkardel 	|	other_mode_command
426abb0f93cSkardel 	|	authentication_command
427abb0f93cSkardel 	|	monitoring_command
428abb0f93cSkardel 	|	access_control_command
429abb0f93cSkardel 	|	orphan_mode_command
430abb0f93cSkardel 	|	fudge_command
4312950cc38Schristos 	|	rlimit_command
432abb0f93cSkardel 	|	system_option_command
433abb0f93cSkardel 	|	tinker_command
434abb0f93cSkardel 	|	miscellaneous_command
435abb0f93cSkardel 	|	simulate_command
436*eabc0478Schristos 	|	device_command
437abb0f93cSkardel 	;
438abb0f93cSkardel 
439abb0f93cSkardel /* Server Commands
440abb0f93cSkardel  * ---------------
441abb0f93cSkardel  */
442abb0f93cSkardel 
443abb0f93cSkardel server_command
444abb0f93cSkardel 	:	client_type address option_list
445abb0f93cSkardel 		{
4462950cc38Schristos 			peer_node *my_node;
4472950cc38Schristos 
4482950cc38Schristos 			my_node = create_peer_node($1, $2, $3);
4492950cc38Schristos 			APPEND_G_FIFO(cfgt.peers, my_node);
450abb0f93cSkardel 		}
451abb0f93cSkardel 	;
452abb0f93cSkardel 
453abb0f93cSkardel client_type
454abb0f93cSkardel 	:	T_Server
455abb0f93cSkardel 	|	T_Pool
456abb0f93cSkardel 	|	T_Peer
457abb0f93cSkardel 	|	T_Broadcast
458abb0f93cSkardel 	|	T_Manycastclient
459abb0f93cSkardel 	;
460abb0f93cSkardel 
461abb0f93cSkardel address
462abb0f93cSkardel 	:	ip_address
4633123f114Skardel 	|	address_fam T_String
4643123f114Skardel 			{ $$ = create_address_node($2, $1); }
465abb0f93cSkardel 	;
466abb0f93cSkardel 
467abb0f93cSkardel ip_address
4683123f114Skardel 	:	T_String
4692950cc38Schristos 			{ $$ = create_address_node($1, AF_UNSPEC); }
4703123f114Skardel 	;
4713123f114Skardel 
4723123f114Skardel address_fam
4733123f114Skardel 	:	T_Ipv4_flag
4743123f114Skardel 			{ $$ = AF_INET; }
4753123f114Skardel 	|	T_Ipv6_flag
4763123f114Skardel 			{ $$ = AF_INET6; }
477abb0f93cSkardel 	;
478abb0f93cSkardel 
479abb0f93cSkardel option_list
4802950cc38Schristos 	:	/* empty list */
4812950cc38Schristos 			{ $$ = NULL; }
4822950cc38Schristos 	|	option_list option
4832950cc38Schristos 		{
4842950cc38Schristos 			$$ = $1;
4852950cc38Schristos 			APPEND_G_FIFO($$, $2);
4862950cc38Schristos 		}
487abb0f93cSkardel 	;
488abb0f93cSkardel 
489abb0f93cSkardel option
4903123f114Skardel 	:	option_flag
4913123f114Skardel 	|	option_int
4922950cc38Schristos 	|	option_str
493abb0f93cSkardel 	;
494abb0f93cSkardel 
4953123f114Skardel option_flag
4963123f114Skardel 	:	option_flag_keyword
4973123f114Skardel 			{ $$ = create_attr_ival(T_Flag, $1); }
4983123f114Skardel 	;
4993123f114Skardel 
5003123f114Skardel option_flag_keyword
5013123f114Skardel 	:	T_Autokey
5023123f114Skardel 	|	T_Burst
5033123f114Skardel 	|	T_Iburst
5043123f114Skardel 	|	T_Noselect
5053123f114Skardel 	|	T_Preempt
5063123f114Skardel 	|	T_Prefer
5073123f114Skardel 	|	T_True
5083123f114Skardel 	|	T_Xleave
509cdfa2a7eSchristos 	|	T_Xmtnonce
5103123f114Skardel 	;
5113123f114Skardel 
5123123f114Skardel option_int
5133123f114Skardel 	:	option_int_keyword T_Integer
5143123f114Skardel 			{ $$ = create_attr_ival($1, $2); }
5152950cc38Schristos 	|	option_int_keyword T_U_int
5162950cc38Schristos 			{ $$ = create_attr_uval($1, $2); }
5173123f114Skardel 	;
5183123f114Skardel 
5193123f114Skardel option_int_keyword
5203123f114Skardel 	:	T_Key
5213123f114Skardel 	|	T_Minpoll
5223123f114Skardel 	|	T_Maxpoll
5233123f114Skardel 	|	T_Ttl
5243123f114Skardel 	|	T_Mode
5253123f114Skardel 	|	T_Version
5263123f114Skardel 	;
5273123f114Skardel 
5282950cc38Schristos option_str
5292950cc38Schristos 	:	option_str_keyword T_String
5302950cc38Schristos 			{ $$ = create_attr_sval($1, $2); }
5312950cc38Schristos 	;
5322950cc38Schristos 
5332950cc38Schristos option_str_keyword
5342950cc38Schristos 	:	T_Ident
5352950cc38Schristos 	;
5363123f114Skardel 
537abb0f93cSkardel 
538abb0f93cSkardel /* unpeer commands
539abb0f93cSkardel  * ---------------
540abb0f93cSkardel  */
541abb0f93cSkardel 
542abb0f93cSkardel unpeer_command
543abb0f93cSkardel 	:	unpeer_keyword address
544abb0f93cSkardel 		{
5452950cc38Schristos 			unpeer_node *my_node;
5462950cc38Schristos 
5472950cc38Schristos 			my_node = create_unpeer_node($2);
548abb0f93cSkardel 			if (my_node)
5492950cc38Schristos 				APPEND_G_FIFO(cfgt.unpeers, my_node);
550abb0f93cSkardel 		}
551abb0f93cSkardel 	;
552abb0f93cSkardel unpeer_keyword
553abb0f93cSkardel 	:	T_Unconfig
554abb0f93cSkardel 	|	T_Unpeer
555abb0f93cSkardel 	;
556abb0f93cSkardel 
557abb0f93cSkardel 
558abb0f93cSkardel /* Other Modes
559abb0f93cSkardel  * (broadcastclient manycastserver multicastclient)
560abb0f93cSkardel  * ------------------------------------------------
561abb0f93cSkardel  */
562abb0f93cSkardel 
563abb0f93cSkardel other_mode_command
564abb0f93cSkardel 	:	T_Broadcastclient
565abb0f93cSkardel 			{ cfgt.broadcastclient = 1; }
566abb0f93cSkardel 	|	T_Manycastserver address_list
5672950cc38Schristos 			{ CONCAT_G_FIFOS(cfgt.manycastserver, $2); }
568abb0f93cSkardel 	|	T_Multicastclient address_list
5692950cc38Schristos 			{ CONCAT_G_FIFOS(cfgt.multicastclient, $2); }
570a04a202dSchristos 	|	T_Mdnstries T_Integer
571a04a202dSchristos 			{ cfgt.mdnstries = $2; }
572abb0f93cSkardel 	;
573abb0f93cSkardel 
574abb0f93cSkardel 
575abb0f93cSkardel 
576abb0f93cSkardel /* Authentication Commands
577abb0f93cSkardel  * -----------------------
578abb0f93cSkardel  */
579abb0f93cSkardel 
580abb0f93cSkardel authentication_command
581abb0f93cSkardel 	:	T_Automax T_Integer
5822950cc38Schristos 		{
5832950cc38Schristos 			attr_val *atrv;
5842950cc38Schristos 
5852950cc38Schristos 			atrv = create_attr_ival($1, $2);
5862950cc38Schristos 			APPEND_G_FIFO(cfgt.vars, atrv);
5872950cc38Schristos 		}
588abb0f93cSkardel 	|	T_ControlKey T_Integer
589abb0f93cSkardel 			{ cfgt.auth.control_key = $2; }
5903123f114Skardel 	|	T_Crypto crypto_command_list
591abb0f93cSkardel 		{
592abb0f93cSkardel 			cfgt.auth.cryptosw++;
5932950cc38Schristos 			CONCAT_G_FIFOS(cfgt.auth.crypto_cmd_list, $2);
594abb0f93cSkardel 		}
595abb0f93cSkardel 	|	T_Keys T_String
596abb0f93cSkardel 			{ cfgt.auth.keys = $2; }
597abb0f93cSkardel 	|	T_Keysdir T_String
598abb0f93cSkardel 			{ cfgt.auth.keysdir = $2; }
599abb0f93cSkardel 	|	T_Requestkey T_Integer
600abb0f93cSkardel 			{ cfgt.auth.request_key = $2; }
601abb0f93cSkardel 	|	T_Revoke T_Integer
602abb0f93cSkardel 			{ cfgt.auth.revoke = $2; }
6033123f114Skardel 	|	T_Trustedkey integer_list_range
6042950cc38Schristos 		{
6054eea345dSchristos 			/* [Bug 948] leaves it open if appending or
6064eea345dSchristos 			 * replacing the trusted key list is the right
6074eea345dSchristos 			 * way. In any case, either alternative should
6084eea345dSchristos 			 * be coded correctly!
6094eea345dSchristos 			 */
6104eea345dSchristos 			DESTROY_G_FIFO(cfgt.auth.trusted_key_list, destroy_attr_val); /* remove for append */
6114eea345dSchristos 			CONCAT_G_FIFOS(cfgt.auth.trusted_key_list, $2);
6122950cc38Schristos 		}
613abb0f93cSkardel 	|	T_NtpSignDsocket T_String
614abb0f93cSkardel 			{ cfgt.auth.ntp_signd_socket = $2; }
615abb0f93cSkardel 	;
616abb0f93cSkardel 
617abb0f93cSkardel crypto_command_list
6183123f114Skardel 	:	/* empty list */
6192950cc38Schristos 			{ $$ = NULL; }
6203123f114Skardel 	|	crypto_command_list crypto_command
621abb0f93cSkardel 		{
622abb0f93cSkardel 			$$ = $1;
6232950cc38Schristos 			APPEND_G_FIFO($$, $2);
624abb0f93cSkardel 		}
625abb0f93cSkardel 	;
626abb0f93cSkardel 
627abb0f93cSkardel crypto_command
6283123f114Skardel 	:	crypto_str_keyword T_String
629abb0f93cSkardel 			{ $$ = create_attr_sval($1, $2); }
630abb0f93cSkardel 	|	T_Revoke T_Integer
631abb0f93cSkardel 		{
632abb0f93cSkardel 			$$ = NULL;
633abb0f93cSkardel 			cfgt.auth.revoke = $2;
634abb0f93cSkardel 			msyslog(LOG_WARNING,
635abb0f93cSkardel 				"'crypto revoke %d' is deprecated, "
636abb0f93cSkardel 				"please use 'revoke %d' instead.",
637abb0f93cSkardel 				cfgt.auth.revoke, cfgt.auth.revoke);
638abb0f93cSkardel 		}
639abb0f93cSkardel 	;
640abb0f93cSkardel 
6413123f114Skardel crypto_str_keyword
6423123f114Skardel 	:	T_Host
6433123f114Skardel 	|	T_Ident
6443123f114Skardel 	|	T_Pw
6453123f114Skardel 	|	T_Randfile
6463123f114Skardel 	|	T_Digest
6473123f114Skardel 	;
6483123f114Skardel 
649abb0f93cSkardel 
650abb0f93cSkardel /* Orphan Mode Commands
651abb0f93cSkardel  * --------------------
652abb0f93cSkardel  */
653abb0f93cSkardel 
654abb0f93cSkardel orphan_mode_command
655abb0f93cSkardel 	:	T_Tos tos_option_list
6562950cc38Schristos 			{ CONCAT_G_FIFOS(cfgt.orphan_cmds, $2); }
657abb0f93cSkardel 	;
658abb0f93cSkardel 
659abb0f93cSkardel tos_option_list
6602950cc38Schristos 	:	tos_option_list tos_option
6612950cc38Schristos 		{
6622950cc38Schristos 			$$ = $1;
6632950cc38Schristos 			APPEND_G_FIFO($$, $2);
6642950cc38Schristos 		}
6652950cc38Schristos 	|	tos_option
6662950cc38Schristos 		{
6672950cc38Schristos 			$$ = NULL;
6682950cc38Schristos 			APPEND_G_FIFO($$, $1);
6692950cc38Schristos 		}
670abb0f93cSkardel 	;
671abb0f93cSkardel 
672abb0f93cSkardel tos_option
6733123f114Skardel 	:	tos_option_int_keyword T_Integer
674abb0f93cSkardel 			{ $$ = create_attr_dval($1, (double)$2); }
6753123f114Skardel 	|	tos_option_dbl_keyword number
6763123f114Skardel 			{ $$ = create_attr_dval($1, $2); }
677abb0f93cSkardel 	|	T_Cohort boolean
678abb0f93cSkardel 			{ $$ = create_attr_dval($1, (double)$2); }
6794eea345dSchristos 	|	basedate
6804eea345dSchristos 			{ $$ = create_attr_ival(T_Basedate, $1); }
6813123f114Skardel 	;
6823123f114Skardel 
6833123f114Skardel tos_option_int_keyword
68403cfe0ffSchristos 	:	T_Bcpollbstep
685ccc794f0Schristos 	|	T_Beacon
68603cfe0ffSchristos 	|	T_Ceiling
6873123f114Skardel 	|	T_Floor
688ccc794f0Schristos 	|	T_Maxclock
689ccc794f0Schristos 	|	T_Minclock
690ccc794f0Schristos 	|	T_Minsane
6913123f114Skardel 	|	T_Orphan
6922950cc38Schristos 	|	T_Orphanwait
6933123f114Skardel 	;
6943123f114Skardel 
6953123f114Skardel tos_option_dbl_keyword
6963123f114Skardel 	:	T_Mindist
6973123f114Skardel 	|	T_Maxdist
698abb0f93cSkardel 	;
699abb0f93cSkardel 
700abb0f93cSkardel 
701abb0f93cSkardel /* Monitoring Commands
702abb0f93cSkardel  * -------------------
703abb0f93cSkardel  */
704abb0f93cSkardel 
705abb0f93cSkardel monitoring_command
706abb0f93cSkardel 	:	T_Statistics stats_list
7072950cc38Schristos 			{ CONCAT_G_FIFOS(cfgt.stats_list, $2); }
708abb0f93cSkardel 	|	T_Statsdir T_String
709abb0f93cSkardel 		{
7105d681e99Schristos 			if (lex_from_file()) {
711abb0f93cSkardel 				cfgt.stats_dir = $2;
7123123f114Skardel 			} else {
7133123f114Skardel 				YYFREE($2);
7145d681e99Schristos 				yyerror("statsdir remote configuration ignored");
715abb0f93cSkardel 			}
716abb0f93cSkardel 		}
717abb0f93cSkardel 	|	T_Filegen stat filegen_option_list
718abb0f93cSkardel 		{
7192950cc38Schristos 			filegen_node *fgn;
7202950cc38Schristos 
7212950cc38Schristos 			fgn = create_filegen_node($2, $3);
7222950cc38Schristos 			APPEND_G_FIFO(cfgt.filegen_opts, fgn);
723abb0f93cSkardel 		}
724abb0f93cSkardel 	;
725abb0f93cSkardel 
726abb0f93cSkardel stats_list
7272950cc38Schristos 	:	stats_list stat
7282950cc38Schristos 		{
7292950cc38Schristos 			$$ = $1;
7302950cc38Schristos 			APPEND_G_FIFO($$, create_int_node($2));
7312950cc38Schristos 		}
7322950cc38Schristos 	|	stat
7332950cc38Schristos 		{
7342950cc38Schristos 			$$ = NULL;
7352950cc38Schristos 			APPEND_G_FIFO($$, create_int_node($1));
7362950cc38Schristos 		}
737abb0f93cSkardel 	;
738abb0f93cSkardel 
739abb0f93cSkardel stat
740abb0f93cSkardel 	:	T_Clockstats
741abb0f93cSkardel 	|	T_Cryptostats
742abb0f93cSkardel 	|	T_Loopstats
743abb0f93cSkardel 	|	T_Peerstats
744abb0f93cSkardel 	|	T_Rawstats
745abb0f93cSkardel 	|	T_Sysstats
746abb0f93cSkardel 	|	T_Timingstats
747abb0f93cSkardel 	|	T_Protostats
748abb0f93cSkardel 	;
749abb0f93cSkardel 
750abb0f93cSkardel filegen_option_list
7513123f114Skardel 	:	/* empty list */
7522950cc38Schristos 			{ $$ = NULL; }
7533123f114Skardel 	|	filegen_option_list filegen_option
754abb0f93cSkardel 		{
755abb0f93cSkardel 			$$ = $1;
7562950cc38Schristos 			APPEND_G_FIFO($$, $2);
757abb0f93cSkardel 		}
758abb0f93cSkardel 	;
759abb0f93cSkardel 
760abb0f93cSkardel filegen_option
761abb0f93cSkardel 	:	T_File T_String
762abb0f93cSkardel 		{
7635d681e99Schristos 			if (lex_from_file()) {
764abb0f93cSkardel 				$$ = create_attr_sval($1, $2);
7653123f114Skardel 			} else {
766abb0f93cSkardel 				$$ = NULL;
7673123f114Skardel 				YYFREE($2);
7685d681e99Schristos 				yyerror("filegen file remote config ignored");
769abb0f93cSkardel 			}
770abb0f93cSkardel 		}
771abb0f93cSkardel 	|	T_Type filegen_type
772abb0f93cSkardel 		{
7735d681e99Schristos 			if (lex_from_file()) {
774abb0f93cSkardel 				$$ = create_attr_ival($1, $2);
7753123f114Skardel 			} else {
776abb0f93cSkardel 				$$ = NULL;
7775d681e99Schristos 				yyerror("filegen type remote config ignored");
778abb0f93cSkardel 			}
779abb0f93cSkardel 		}
7803123f114Skardel 	|	link_nolink
781abb0f93cSkardel 		{
7823123f114Skardel 			const char *err;
7833123f114Skardel 
7845d681e99Schristos 			if (lex_from_file()) {
785abb0f93cSkardel 				$$ = create_attr_ival(T_Flag, $1);
7863123f114Skardel 			} else {
787abb0f93cSkardel 				$$ = NULL;
7883123f114Skardel 				if (T_Link == $1)
7893123f114Skardel 					err = "filegen link remote config ignored";
7903123f114Skardel 				else
7913123f114Skardel 					err = "filegen nolink remote config ignored";
7925d681e99Schristos 				yyerror(err);
793abb0f93cSkardel 			}
794abb0f93cSkardel 		}
7953123f114Skardel 	|	enable_disable
7963123f114Skardel 			{ $$ = create_attr_ival(T_Flag, $1); }
7973123f114Skardel 	;
7983123f114Skardel 
7993123f114Skardel link_nolink
8003123f114Skardel 	:	T_Link
801abb0f93cSkardel 	|	T_Nolink
8023123f114Skardel 	;
8033123f114Skardel 
8043123f114Skardel enable_disable
8053123f114Skardel 	:	T_Enable
8063123f114Skardel 	|	T_Disable
807abb0f93cSkardel 	;
808abb0f93cSkardel 
809abb0f93cSkardel filegen_type
810abb0f93cSkardel 	:	T_None
811abb0f93cSkardel 	|	T_Pid
812abb0f93cSkardel 	|	T_Day
813abb0f93cSkardel 	|	T_Week
814abb0f93cSkardel 	|	T_Month
815abb0f93cSkardel 	|	T_Year
816abb0f93cSkardel 	|	T_Age
817abb0f93cSkardel 	;
818abb0f93cSkardel 
819abb0f93cSkardel 
820abb0f93cSkardel /* Access Control Commands
821abb0f93cSkardel  * -----------------------
822abb0f93cSkardel  */
823abb0f93cSkardel 
824abb0f93cSkardel access_control_command
825abb0f93cSkardel 	:	T_Discard discard_option_list
826abb0f93cSkardel 		{
8272950cc38Schristos 			CONCAT_G_FIFOS(cfgt.discard_opts, $2);
8282950cc38Schristos 		}
8292950cc38Schristos 	|	T_Mru mru_option_list
8302950cc38Schristos 		{
8312950cc38Schristos 			CONCAT_G_FIFOS(cfgt.mru_opts, $2);
832abb0f93cSkardel 		}
833*eabc0478Schristos 	|	T_Restrict address restrict_mask res_ippeerlimit ac_flag_list
834abb0f93cSkardel 		{
8352950cc38Schristos 			restrict_node *rn;
8362950cc38Schristos 
837*eabc0478Schristos 			rn = create_restrict_node($2, $3, $4, $5, FALSE,
838*eabc0478Schristos 						  lex_current()->curpos.nline,
839*eabc0478Schristos 						  lex_current()->curpos.ncol);
8402950cc38Schristos 			APPEND_G_FIFO(cfgt.restrict_opts, rn);
8412950cc38Schristos 		}
8424eea345dSchristos 	|	T_Restrict T_Default res_ippeerlimit ac_flag_list
8432950cc38Schristos 		{
8442950cc38Schristos 			restrict_node *rn;
8452950cc38Schristos 
846*eabc0478Schristos 			rn = create_restrict_node(NULL, NULL, $3, $4, FALSE,
847*eabc0478Schristos 						  lex_current()->curpos.nline,
848*eabc0478Schristos 						  lex_current()->curpos.ncol);
8492950cc38Schristos 			APPEND_G_FIFO(cfgt.restrict_opts, rn);
8502950cc38Schristos 		}
8514eea345dSchristos 	|	T_Restrict T_Ipv4_flag T_Default res_ippeerlimit ac_flag_list
8522950cc38Schristos 		{
8532950cc38Schristos 			restrict_node *rn;
8542950cc38Schristos 
8552950cc38Schristos 			rn = create_restrict_node(
8562950cc38Schristos 				create_address_node(
8572950cc38Schristos 					estrdup("0.0.0.0"),
8582950cc38Schristos 					AF_INET),
8592950cc38Schristos 				create_address_node(
8602950cc38Schristos 					estrdup("0.0.0.0"),
8612950cc38Schristos 					AF_INET),
862*eabc0478Schristos 				$4, $5, FALSE,
863*eabc0478Schristos 				lex_current()->curpos.nline,
864*eabc0478Schristos 				lex_current()->curpos.ncol);
8652950cc38Schristos 			APPEND_G_FIFO(cfgt.restrict_opts, rn);
8662950cc38Schristos 		}
8674eea345dSchristos 	|	T_Restrict T_Ipv6_flag T_Default res_ippeerlimit ac_flag_list
8682950cc38Schristos 		{
8692950cc38Schristos 			restrict_node *rn;
8702950cc38Schristos 
8712950cc38Schristos 			rn = create_restrict_node(
8722950cc38Schristos 				create_address_node(
8732950cc38Schristos 					estrdup("::"),
8742950cc38Schristos 					AF_INET6),
8752950cc38Schristos 				create_address_node(
8762950cc38Schristos 					estrdup("::"),
8772950cc38Schristos 					AF_INET6),
878*eabc0478Schristos 				$4, $5, FALSE,
879*eabc0478Schristos 				lex_current()->curpos.nline,
880*eabc0478Schristos 				lex_current()->curpos.ncol);
8812950cc38Schristos 			APPEND_G_FIFO(cfgt.restrict_opts, rn);
8822950cc38Schristos 		}
8834eea345dSchristos 	|	T_Restrict T_Source res_ippeerlimit ac_flag_list
8842950cc38Schristos 		{
8852950cc38Schristos 			restrict_node *	rn;
8862950cc38Schristos 
887cdfa2a7eSchristos 			APPEND_G_FIFO($4, create_attr_ival($2, 1));
888*eabc0478Schristos 			rn = create_restrict_node(NULL, NULL, $3, $4, FALSE,
889*eabc0478Schristos 						  lex_current()->curpos.nline,
890*eabc0478Schristos 						  lex_current()->curpos.ncol);
8912950cc38Schristos 			APPEND_G_FIFO(cfgt.restrict_opts, rn);
892abb0f93cSkardel 		}
893*eabc0478Schristos 	|	T_Delrestrict ip_address restrict_mask
894*eabc0478Schristos 		{
895*eabc0478Schristos 			restrict_node *	rn;
896*eabc0478Schristos 
897*eabc0478Schristos 			rn = create_restrict_node($2, $3, -1, NULL, TRUE,
898*eabc0478Schristos 						  lex_current()->curpos.nline,
899*eabc0478Schristos 						  lex_current()->curpos.ncol);
900*eabc0478Schristos 			APPEND_G_FIFO(cfgt.restrict_opts, rn);
901*eabc0478Schristos 		}
902*eabc0478Schristos 	|	T_Delrestrict T_Source ip_address
903*eabc0478Schristos 		{
904*eabc0478Schristos 			restrict_node *	rn;
905*eabc0478Schristos 			attr_val_fifo * avf;
906*eabc0478Schristos 
907*eabc0478Schristos 			avf = NULL;
908*eabc0478Schristos 			APPEND_G_FIFO(avf, create_attr_ival($2, 1));
909*eabc0478Schristos 			rn = create_restrict_node($3, NULL, -1, avf, TRUE,
910*eabc0478Schristos 						  lex_current()->curpos.nline,
911*eabc0478Schristos 						  lex_current()->curpos.ncol);
912*eabc0478Schristos 			APPEND_G_FIFO(cfgt.restrict_opts, rn);
913*eabc0478Schristos 		}
914*eabc0478Schristos 	;
915*eabc0478Schristos 
916*eabc0478Schristos restrict_mask
917*eabc0478Schristos 	:	/* no mask is allowed */
918*eabc0478Schristos 			{ $$ = NULL; }
919*eabc0478Schristos 	|	T_Mask ip_address
920*eabc0478Schristos 		{
921*eabc0478Schristos 			$$ = $2;
922*eabc0478Schristos 		}
923abb0f93cSkardel 	;
924abb0f93cSkardel 
9254eea345dSchristos res_ippeerlimit
9264eea345dSchristos 	:	/* empty ippeerlimit defaults to -1 (unlimited) */
9274eea345dSchristos 			{ $$ = -1; }
9284eea345dSchristos 	|	T_Ippeerlimit  T_Integer
9294eea345dSchristos 		{
9304eea345dSchristos 			if (($2 < -1) || ($2 > 100)) {
9314eea345dSchristos 				struct FILE_INFO * ip_ctx;
9324eea345dSchristos 
9334eea345dSchristos 				ip_ctx = lex_current();
9344eea345dSchristos 				msyslog(LOG_ERR,
9354eea345dSchristos 					"Unreasonable ippeerlimit value (%d) in %s line %d, column %d.  Using 0.",
9364eea345dSchristos 					$2,
9374eea345dSchristos 					ip_ctx->fname,
938*eabc0478Schristos 					ip_ctx->curpos.nline,
939*eabc0478Schristos 					ip_ctx->curpos.ncol);
9404eea345dSchristos 				$2 = 0;
9414eea345dSchristos 			}
9424eea345dSchristos 			$$ = $2;
9434eea345dSchristos 		}
9444eea345dSchristos 	;
9454eea345dSchristos 
946abb0f93cSkardel ac_flag_list
9473123f114Skardel 	:	/* empty list is allowed */
9482950cc38Schristos 			{ $$ = NULL; }
949abb0f93cSkardel 	|	ac_flag_list access_control_flag
9502950cc38Schristos 		{
951cdfa2a7eSchristos 			attr_val *av;
952cdfa2a7eSchristos 
9532950cc38Schristos 			$$ = $1;
954cdfa2a7eSchristos 			av = create_attr_ival($2, 1);
955cdfa2a7eSchristos 			APPEND_G_FIFO($$, av);
956cdfa2a7eSchristos 		}
957cdfa2a7eSchristos 	|	ac_flag_list T_Serverresponse T_Fuzz
958cdfa2a7eSchristos 		{
959cdfa2a7eSchristos 			attr_val *av;
960cdfa2a7eSchristos 
961cdfa2a7eSchristos 			$$ = $1;
962cdfa2a7eSchristos 			av = create_attr_ival(T_ServerresponseFuzz, 1);
963cdfa2a7eSchristos 			APPEND_G_FIFO($$, av);
9642950cc38Schristos 		}
965abb0f93cSkardel 	;
966abb0f93cSkardel 
967abb0f93cSkardel access_control_flag
9684eea345dSchristos 	:	T_Epeer
9694eea345dSchristos 	|	T_Flake
970abb0f93cSkardel 	|	T_Ignore
971abb0f93cSkardel 	|	T_Kod
972abb0f93cSkardel 	|	T_Limited
973abb0f93cSkardel 	|	T_Lowpriotrap
974cdfa2a7eSchristos 	|	T_Mssntp
9754eea345dSchristos 	|	T_Noepeer
976abb0f93cSkardel 	|	T_Nomodify
9772950cc38Schristos 	|	T_Nomrulist
978abb0f93cSkardel 	|	T_Nopeer
979abb0f93cSkardel 	|	T_Noquery
980abb0f93cSkardel 	|	T_Noserve
981abb0f93cSkardel 	|	T_Notrap
982abb0f93cSkardel 	|	T_Notrust
983abb0f93cSkardel 	|	T_Ntpport
984abb0f93cSkardel 	|	T_Version
985abb0f93cSkardel 	;
986abb0f93cSkardel 
987abb0f93cSkardel discard_option_list
988abb0f93cSkardel 	:	discard_option_list discard_option
9892950cc38Schristos 		{
9902950cc38Schristos 			$$ = $1;
9912950cc38Schristos 			APPEND_G_FIFO($$, $2);
9922950cc38Schristos 		}
993abb0f93cSkardel 	|	discard_option
9942950cc38Schristos 		{
9952950cc38Schristos 			$$ = NULL;
9962950cc38Schristos 			APPEND_G_FIFO($$, $1);
9972950cc38Schristos 		}
998abb0f93cSkardel 	;
999abb0f93cSkardel 
1000abb0f93cSkardel discard_option
10013123f114Skardel 	:	discard_option_keyword T_Integer
10023123f114Skardel 			{ $$ = create_attr_ival($1, $2); }
1003abb0f93cSkardel 	;
1004abb0f93cSkardel 
10053123f114Skardel discard_option_keyword
10063123f114Skardel 	:	T_Average
10073123f114Skardel 	|	T_Minimum
10083123f114Skardel 	|	T_Monitor
10093123f114Skardel 	;
10103123f114Skardel 
10112950cc38Schristos mru_option_list
10122950cc38Schristos 	:	mru_option_list mru_option
10132950cc38Schristos 		{
10142950cc38Schristos 			$$ = $1;
10152950cc38Schristos 			APPEND_G_FIFO($$, $2);
10162950cc38Schristos 		}
10172950cc38Schristos 	|	mru_option
10182950cc38Schristos 		{
10192950cc38Schristos 			$$ = NULL;
10202950cc38Schristos 			APPEND_G_FIFO($$, $1);
10212950cc38Schristos 		}
10222950cc38Schristos 	;
10232950cc38Schristos 
10242950cc38Schristos mru_option
10252950cc38Schristos 	:	mru_option_keyword T_Integer
10262950cc38Schristos 			{ $$ = create_attr_ival($1, $2); }
10272950cc38Schristos 	;
10282950cc38Schristos 
10292950cc38Schristos mru_option_keyword
10302950cc38Schristos 	:	T_Incalloc
10312950cc38Schristos 	|	T_Incmem
10322950cc38Schristos 	|	T_Initalloc
10332950cc38Schristos 	|	T_Initmem
10342950cc38Schristos 	|	T_Maxage
10352950cc38Schristos 	|	T_Maxdepth
10362950cc38Schristos 	|	T_Maxmem
10372950cc38Schristos 	|	T_Mindepth
10382950cc38Schristos 	;
10393123f114Skardel 
1040abb0f93cSkardel /* Fudge Commands
1041abb0f93cSkardel  * --------------
1042abb0f93cSkardel  */
1043abb0f93cSkardel 
1044abb0f93cSkardel fudge_command
1045abb0f93cSkardel 	:	T_Fudge address fudge_factor_list
10462950cc38Schristos 		{
10472950cc38Schristos 			addr_opts_node *aon;
10482950cc38Schristos 
10492950cc38Schristos 			aon = create_addr_opts_node($2, $3);
10502950cc38Schristos 			APPEND_G_FIFO(cfgt.fudge, aon);
10512950cc38Schristos 		}
1052abb0f93cSkardel 	;
1053abb0f93cSkardel 
1054abb0f93cSkardel fudge_factor_list
1055abb0f93cSkardel 	:	fudge_factor_list fudge_factor
10562950cc38Schristos 		{
10572950cc38Schristos 			$$ = $1;
10582950cc38Schristos 			APPEND_G_FIFO($$, $2);
10592950cc38Schristos 		}
1060abb0f93cSkardel 	|	fudge_factor
10612950cc38Schristos 		{
10622950cc38Schristos 			$$ = NULL;
10632950cc38Schristos 			APPEND_G_FIFO($$, $1);
10642950cc38Schristos 		}
1065abb0f93cSkardel 	;
1066abb0f93cSkardel 
1067abb0f93cSkardel fudge_factor
10683123f114Skardel 	:	fudge_factor_dbl_keyword number
10693123f114Skardel 			{ $$ = create_attr_dval($1, $2); }
10703123f114Skardel 	|	fudge_factor_bool_keyword boolean
10713123f114Skardel 			{ $$ = create_attr_ival($1, $2); }
10723123f114Skardel 	|	T_Stratum T_Integer
10738b8da087Schristos 		{
10748b8da087Schristos 			if ($2 >= 0 && $2 <= 16) {
10758b8da087Schristos 				$$ = create_attr_ival($1, $2);
10768b8da087Schristos 			} else {
10778b8da087Schristos 				$$ = NULL;
10788b8da087Schristos 				yyerror("fudge factor: stratum value not in [0..16], ignored");
10798b8da087Schristos 			}
10808b8da087Schristos 		}
10812950cc38Schristos 	|	T_Abbrev T_String
10822950cc38Schristos 			{ $$ = create_attr_sval($1, $2); }
10833123f114Skardel 	|	T_Refid T_String
10843123f114Skardel 			{ $$ = create_attr_sval($1, $2); }
1085abb0f93cSkardel 	;
1086abb0f93cSkardel 
10873123f114Skardel fudge_factor_dbl_keyword
10883123f114Skardel 	:	T_Time1
10893123f114Skardel 	|	T_Time2
1090cdfa2a7eSchristos 	|	T_Minjitter
10913123f114Skardel 	;
10923123f114Skardel 
10933123f114Skardel fudge_factor_bool_keyword
10943123f114Skardel 	:	T_Flag1
10953123f114Skardel 	|	T_Flag2
10963123f114Skardel 	|	T_Flag3
10973123f114Skardel 	|	T_Flag4
10983123f114Skardel 	;
10993123f114Skardel 
1100*eabc0478Schristos /* Device Commands
1101*eabc0478Schristos  * --------------
1102*eabc0478Schristos  */
1103*eabc0478Schristos 
1104*eabc0478Schristos device_command
1105*eabc0478Schristos 	:	T_Device address device_item_list
1106*eabc0478Schristos 		{
1107*eabc0478Schristos 			addr_opts_node *aon;
1108*eabc0478Schristos 
1109*eabc0478Schristos 			aon = create_addr_opts_node($2, $3);
1110*eabc0478Schristos 			APPEND_G_FIFO(cfgt.device, aon);
1111*eabc0478Schristos 		}
1112*eabc0478Schristos 	;
1113*eabc0478Schristos 
1114*eabc0478Schristos device_item_list
1115*eabc0478Schristos 	:	device_item_list device_item
1116*eabc0478Schristos 		{
1117*eabc0478Schristos 			$$ = $1;
1118*eabc0478Schristos 			APPEND_G_FIFO($$, $2);
1119*eabc0478Schristos 		}
1120*eabc0478Schristos 	|	device_item
1121*eabc0478Schristos 		{
1122*eabc0478Schristos 			$$ = NULL;
1123*eabc0478Schristos 			APPEND_G_FIFO($$, $1);
1124*eabc0478Schristos 		}
1125*eabc0478Schristos 	;
1126*eabc0478Schristos 
1127*eabc0478Schristos device_item
1128*eabc0478Schristos 	:	device_item_path_keyword T_String
1129*eabc0478Schristos 			{ $$ = create_attr_sval($1, $2); }
1130*eabc0478Schristos 	;
1131*eabc0478Schristos 
1132*eabc0478Schristos device_item_path_keyword
1133*eabc0478Schristos 	:	T_TimeData
1134*eabc0478Schristos 	|	T_PpsData
1135*eabc0478Schristos 	;
1136*eabc0478Schristos 
11372950cc38Schristos /* rlimit Commands
11382950cc38Schristos  * ---------------
11392950cc38Schristos  */
11402950cc38Schristos 
11412950cc38Schristos rlimit_command
11422950cc38Schristos 	:	T_Rlimit rlimit_option_list
11432950cc38Schristos 			{ CONCAT_G_FIFOS(cfgt.rlimit, $2); }
11442950cc38Schristos 	;
11452950cc38Schristos 
11462950cc38Schristos rlimit_option_list
11472950cc38Schristos 	:	rlimit_option_list rlimit_option
11482950cc38Schristos 		{
11492950cc38Schristos 			$$ = $1;
11502950cc38Schristos 			APPEND_G_FIFO($$, $2);
11512950cc38Schristos 		}
11522950cc38Schristos 	|	rlimit_option
11532950cc38Schristos 		{
11542950cc38Schristos 			$$ = NULL;
11552950cc38Schristos 			APPEND_G_FIFO($$, $1);
11562950cc38Schristos 		}
11572950cc38Schristos 	;
11582950cc38Schristos 
11592950cc38Schristos rlimit_option
11602950cc38Schristos 	:	rlimit_option_keyword T_Integer
11612950cc38Schristos 			{ $$ = create_attr_ival($1, $2); }
11622950cc38Schristos 	;
11632950cc38Schristos 
11642950cc38Schristos rlimit_option_keyword
11652950cc38Schristos 	:	T_Memlock
11662950cc38Schristos 	|	T_Stacksize
11672950cc38Schristos 	|	T_Filenum
11682950cc38Schristos 	;
11692950cc38Schristos 
11703123f114Skardel 
1171abb0f93cSkardel /* Command for System Options
1172abb0f93cSkardel  * --------------------------
1173abb0f93cSkardel  */
1174abb0f93cSkardel 
1175abb0f93cSkardel system_option_command
1176abb0f93cSkardel 	:	T_Enable system_option_list
11772950cc38Schristos 			{ CONCAT_G_FIFOS(cfgt.enable_opts, $2); }
1178abb0f93cSkardel 	|	T_Disable system_option_list
11792950cc38Schristos 			{ CONCAT_G_FIFOS(cfgt.disable_opts, $2); }
1180abb0f93cSkardel 	;
1181abb0f93cSkardel 
1182abb0f93cSkardel system_option_list
1183abb0f93cSkardel 	:	system_option_list system_option
1184abb0f93cSkardel 		{
1185abb0f93cSkardel 			$$ = $1;
11862950cc38Schristos 			APPEND_G_FIFO($$, $2);
1187abb0f93cSkardel 		}
1188abb0f93cSkardel 	|	system_option
1189abb0f93cSkardel 		{
11902950cc38Schristos 			$$ = NULL;
11912950cc38Schristos 			APPEND_G_FIFO($$, $1);
1192abb0f93cSkardel 		}
1193abb0f93cSkardel 	;
1194abb0f93cSkardel 
1195abb0f93cSkardel system_option
11963123f114Skardel 	:	system_option_flag_keyword
11973123f114Skardel 			{ $$ = create_attr_ival(T_Flag, $1); }
11982950cc38Schristos 	|	system_option_local_flag_keyword
1199abb0f93cSkardel 		{
12005d681e99Schristos 			if (lex_from_file()) {
1201abb0f93cSkardel 				$$ = create_attr_ival(T_Flag, $1);
12023123f114Skardel 			} else {
12032950cc38Schristos 				char err_str[128];
12042950cc38Schristos 
1205abb0f93cSkardel 				$$ = NULL;
12062950cc38Schristos 				snprintf(err_str, sizeof(err_str),
12072950cc38Schristos 					 "enable/disable %s remote configuration ignored",
12082950cc38Schristos 					 keyword($1));
12095d681e99Schristos 				yyerror(err_str);
1210abb0f93cSkardel 			}
1211abb0f93cSkardel 		}
1212abb0f93cSkardel 	;
1213abb0f93cSkardel 
12143123f114Skardel system_option_flag_keyword
12153123f114Skardel 	:	T_Auth
12163123f114Skardel 	|	T_Bclient
12173123f114Skardel 	|	T_Calibrate
12183123f114Skardel 	|	T_Kernel
12193123f114Skardel 	|	T_Monitor
12203123f114Skardel 	|	T_Ntp
12213123f114Skardel 	;
12223123f114Skardel 
12232950cc38Schristos system_option_local_flag_keyword
12242950cc38Schristos 	:	T_Mode7
1225717847f5Schristos 	|	T_PCEdigest
12262950cc38Schristos 	|	T_Stats
122768dbbb44Schristos 	|	T_UEcrypto
122868dbbb44Schristos 	|	T_UEcryptonak
122968dbbb44Schristos 	|	T_UEdigest
12302950cc38Schristos 	;
12313123f114Skardel 
1232abb0f93cSkardel /* Tinker Commands
1233abb0f93cSkardel  * ---------------
1234abb0f93cSkardel  */
1235abb0f93cSkardel 
1236abb0f93cSkardel tinker_command
12372950cc38Schristos 	:	T_Tinker tinker_option_list
12382950cc38Schristos 			{ CONCAT_G_FIFOS(cfgt.tinker, $2); }
1239abb0f93cSkardel 	;
1240abb0f93cSkardel 
1241abb0f93cSkardel tinker_option_list
12422950cc38Schristos 	:	tinker_option_list tinker_option
12432950cc38Schristos 		{
12442950cc38Schristos 			$$ = $1;
12452950cc38Schristos 			APPEND_G_FIFO($$, $2);
12462950cc38Schristos 		}
12472950cc38Schristos 	|	tinker_option
12482950cc38Schristos 		{
12492950cc38Schristos 			$$ = NULL;
12502950cc38Schristos 			APPEND_G_FIFO($$, $1);
12512950cc38Schristos 		}
1252abb0f93cSkardel 	;
1253abb0f93cSkardel 
1254abb0f93cSkardel tinker_option
12553123f114Skardel 	:	tinker_option_keyword number
12563123f114Skardel 			{ $$ = create_attr_dval($1, $2); }
12573123f114Skardel 	;
12583123f114Skardel 
12593123f114Skardel tinker_option_keyword
12603123f114Skardel 	:	T_Allan
12613123f114Skardel 	|	T_Dispersion
12623123f114Skardel 	|	T_Freq
12633123f114Skardel 	|	T_Huffpuff
12643123f114Skardel 	|	T_Panic
12653123f114Skardel 	|	T_Step
12667476e6e4Schristos 	|	T_Stepback
12677476e6e4Schristos 	|	T_Stepfwd
12683123f114Skardel 	|	T_Stepout
12692950cc38Schristos 	|	T_Tick
1270abb0f93cSkardel 	;
1271abb0f93cSkardel 
1272abb0f93cSkardel 
1273abb0f93cSkardel /* Miscellaneous Commands
1274abb0f93cSkardel  * ----------------------
1275abb0f93cSkardel  */
1276abb0f93cSkardel 
1277abb0f93cSkardel miscellaneous_command
1278abb0f93cSkardel 	:	interface_command
12792950cc38Schristos 	|	reset_command
12803123f114Skardel 	|	misc_cmd_dbl_keyword number
12813123f114Skardel 		{
12822950cc38Schristos 			attr_val *av;
12833123f114Skardel 
12843123f114Skardel 			av = create_attr_dval($1, $2);
12852950cc38Schristos 			APPEND_G_FIFO(cfgt.vars, av);
12863123f114Skardel 		}
12875d681e99Schristos 	|	misc_cmd_int_keyword T_Integer
12885d681e99Schristos 		{
12895d681e99Schristos 			attr_val *av;
12905d681e99Schristos 
12915d681e99Schristos 			av = create_attr_ival($1, $2);
12925d681e99Schristos 			APPEND_G_FIFO(cfgt.vars, av);
12935d681e99Schristos 		}
12943123f114Skardel 	|	misc_cmd_str_keyword T_String
12953123f114Skardel 		{
12962950cc38Schristos 			attr_val *av;
12973123f114Skardel 
12983123f114Skardel 			av = create_attr_sval($1, $2);
12992950cc38Schristos 			APPEND_G_FIFO(cfgt.vars, av);
13003123f114Skardel 		}
13013123f114Skardel 	|	misc_cmd_str_lcl_keyword T_String
13023123f114Skardel 		{
13033123f114Skardel 			char error_text[64];
13042950cc38Schristos 			attr_val *av;
13053123f114Skardel 
13065d681e99Schristos 			if (lex_from_file()) {
13073123f114Skardel 				av = create_attr_sval($1, $2);
13082950cc38Schristos 				APPEND_G_FIFO(cfgt.vars, av);
13093123f114Skardel 			} else {
13103123f114Skardel 				YYFREE($2);
13113123f114Skardel 				snprintf(error_text, sizeof(error_text),
13123123f114Skardel 					 "%s remote config ignored",
13133123f114Skardel 					 keyword($1));
13145d681e99Schristos 				yyerror(error_text);
13153123f114Skardel 			}
13163123f114Skardel 		}
1317abb0f93cSkardel 	|	T_Includefile T_String command
1318abb0f93cSkardel 		{
13195d681e99Schristos 			if (!lex_from_file()) {
13205d681e99Schristos 				YYFREE($2); /* avoid leak */
13215d681e99Schristos 				yyerror("remote includefile ignored");
13223123f114Skardel 				break;
13233123f114Skardel 			}
13245d681e99Schristos 			if (lex_level() > MAXINCLUDELEVEL) {
1325abb0f93cSkardel 				fprintf(stderr, "getconfig: Maximum include file level exceeded.\n");
13262950cc38Schristos 				msyslog(LOG_ERR, "getconfig: Maximum include file level exceeded.");
13273123f114Skardel 			} else {
13285d681e99Schristos 				const char * path = FindConfig($2); /* might return $2! */
13295d681e99Schristos 				if (!lex_push_file(path, "r")) {
13305d681e99Schristos 					fprintf(stderr, "getconfig: Couldn't open <%s>\n", path);
13315d681e99Schristos 					msyslog(LOG_ERR, "getconfig: Couldn't open <%s>", path);
1332abb0f93cSkardel 				}
1333abb0f93cSkardel 			}
13345d681e99Schristos 			YYFREE($2); /* avoid leak */
13353123f114Skardel 		}
1336cdfa2a7eSchristos 	|	T_Leapfile T_String opt_hash_check
1337cdfa2a7eSchristos 		{
1338cdfa2a7eSchristos 			attr_val *av;
1339cdfa2a7eSchristos 
1340cdfa2a7eSchristos 			av = create_attr_sval($1, $2);
1341cdfa2a7eSchristos 			av->flag = $3;
1342cdfa2a7eSchristos 			APPEND_G_FIFO(cfgt.vars, av);
1343cdfa2a7eSchristos 		}
1344abb0f93cSkardel 	|	T_End
13455d681e99Schristos 			{ lex_flush_stack(); }
1346abb0f93cSkardel 	|	T_Driftfile drift_parm
13472950cc38Schristos 			{ /* see drift_parm below for actions */ }
1348abb0f93cSkardel 	|	T_Logconfig log_config_list
13492950cc38Schristos 			{ CONCAT_G_FIFOS(cfgt.logconfig, $2); }
1350abb0f93cSkardel 	|	T_Phone string_list
13512950cc38Schristos 			{ CONCAT_G_FIFOS(cfgt.phone, $2); }
1352cdfa2a7eSchristos 	|	T_PollSkewList pollskew_list
1353cdfa2a7eSchristos 			{ CONCAT_G_FIFOS(cfgt.pollskewlist, $2); }
1354abb0f93cSkardel 	|	T_Setvar variable_assign
13552950cc38Schristos 			{ APPEND_G_FIFO(cfgt.setvar, $2); }
1356abb0f93cSkardel 	|	T_Trap ip_address trap_option_list
13572950cc38Schristos 		{
13582950cc38Schristos 			addr_opts_node *aon;
13592950cc38Schristos 
13602950cc38Schristos 			aon = create_addr_opts_node($2, $3);
13612950cc38Schristos 			APPEND_G_FIFO(cfgt.trap, aon);
13622950cc38Schristos 		}
1363abb0f93cSkardel 	|	T_Ttl integer_list
13642950cc38Schristos 			{ CONCAT_G_FIFOS(cfgt.ttl, $2); }
13653123f114Skardel 	;
13663123f114Skardel 
13673123f114Skardel misc_cmd_dbl_keyword
13683123f114Skardel 	:	T_Broadcastdelay
13692950cc38Schristos 	|	T_Nonvolatile
13703123f114Skardel 	|	T_Tick
13713123f114Skardel 	;
13723123f114Skardel 
13735d681e99Schristos misc_cmd_int_keyword
13745d681e99Schristos 	:	T_Dscp
13755d681e99Schristos 	;
13765d681e99Schristos 
13775d681e99Schristos misc_cmd_int_keyword
13785d681e99Schristos 	:	T_Leapsmearinterval
13795d681e99Schristos 		{
13805d681e99Schristos #ifndef LEAP_SMEAR
13815d681e99Schristos 			yyerror("Built without LEAP_SMEAR support.");
13825d681e99Schristos #endif
13835d681e99Schristos 		}
13845d681e99Schristos 	;
13855d681e99Schristos 
1386cdfa2a7eSchristos opt_hash_check
1387cdfa2a7eSchristos 	:	T_Ignorehash
1388cdfa2a7eSchristos 			{ $$ = FALSE; }
1389cdfa2a7eSchristos 	|	T_Checkhash
1390cdfa2a7eSchristos 			{ $$ = TRUE; }
1391cdfa2a7eSchristos 	|	/*EMPTY*/
1392cdfa2a7eSchristos 			{  $$ = TRUE; }
1393cdfa2a7eSchristos 	;
1394cdfa2a7eSchristos 
13953123f114Skardel misc_cmd_str_keyword
13962950cc38Schristos 	:	T_Ident
13973123f114Skardel 	;
13983123f114Skardel 
13993123f114Skardel misc_cmd_str_lcl_keyword
14003123f114Skardel 	:	T_Logfile
1401af12ab5eSchristos 	|	T_Pidfile
14023123f114Skardel 	|	T_Saveconfigdir
1403abb0f93cSkardel 	;
1404abb0f93cSkardel 
1405abb0f93cSkardel drift_parm
1406abb0f93cSkardel 	:	T_String
14072950cc38Schristos 		{
1408af12ab5eSchristos 			if (lex_from_file()) {
14092950cc38Schristos 				attr_val *av;
14102950cc38Schristos 				av = create_attr_sval(T_Driftfile, $1);
14112950cc38Schristos 				APPEND_G_FIFO(cfgt.vars, av);
1412af12ab5eSchristos 			} else {
1413af12ab5eSchristos 				YYFREE($1);
1414af12ab5eSchristos 				yyerror("driftfile remote configuration ignored");
1415af12ab5eSchristos 			}
14162950cc38Schristos 		}
1417abb0f93cSkardel 	|	T_String T_Double
14182950cc38Schristos 		{
1419af12ab5eSchristos 			if (lex_from_file()) {
14202950cc38Schristos 				attr_val *av;
14212950cc38Schristos 				av = create_attr_sval(T_Driftfile, $1);
14222950cc38Schristos 				APPEND_G_FIFO(cfgt.vars, av);
14232950cc38Schristos 				av = create_attr_dval(T_WanderThreshold, $2);
14242950cc38Schristos 				APPEND_G_FIFO(cfgt.vars, av);
14254eea345dSchristos 			msyslog(LOG_WARNING,
14264eea345dSchristos 				"'driftfile FILENAME WanderValue' is deprecated, "
14274eea345dSchristos 				"please use separate 'driftfile FILENAME' and "
14284eea345dSchristos 				"'nonvolatile WanderValue' lines instead.");
1429af12ab5eSchristos 			} else {
1430af12ab5eSchristos 				YYFREE($1);
1431af12ab5eSchristos 				yyerror("driftfile remote configuration ignored");
1432af12ab5eSchristos 			}
14332950cc38Schristos 		}
14342950cc38Schristos 	|	/* Null driftfile,  indicated by empty string "" */
14352950cc38Schristos 		{
1436af12ab5eSchristos 			if (lex_from_file()) {
14372950cc38Schristos 				attr_val *av;
1438af12ab5eSchristos 				av = create_attr_sval(T_Driftfile, estrdup(""));
14392950cc38Schristos 				APPEND_G_FIFO(cfgt.vars, av);
1440af12ab5eSchristos 			} else {
1441af12ab5eSchristos 				yyerror("driftfile remote configuration ignored");
1442af12ab5eSchristos 			}
14432950cc38Schristos 		}
1444abb0f93cSkardel 	;
1445abb0f93cSkardel 
1446cdfa2a7eSchristos pollskew_list
1447cdfa2a7eSchristos 	:	/* empty */
1448cdfa2a7eSchristos 			{ $$ = NULL; }
1449cdfa2a7eSchristos 	|	pollskew_list pollskew_spec
1450cdfa2a7eSchristos 			{ $$ = append_gen_fifo($1, $2); }
1451cdfa2a7eSchristos 	;
1452cdfa2a7eSchristos 
1453cdfa2a7eSchristos pollskew_spec
1454cdfa2a7eSchristos 	:	pollskew_cycle T_Integer '|' T_Integer
1455cdfa2a7eSchristos 		{
1456cdfa2a7eSchristos 			if ($2 < 0 || $4 < 0) {
1457cdfa2a7eSchristos 				/* bad numbers */
1458cdfa2a7eSchristos 				yyerror("pollskewlist: skew values must be >=0");
1459cdfa2a7eSchristos 				destroy_attr_val($1);
1460cdfa2a7eSchristos 				$1 = NULL;
1461cdfa2a7eSchristos 			} else if ($1 == NULL) {
1462cdfa2a7eSchristos 				yyerror("pollskewlist: poll value must be 3-17, inclusive");
1463cdfa2a7eSchristos 			} else if ($1->attr <= 0) {
1464cdfa2a7eSchristos 				/* process default range */
1465cdfa2a7eSchristos 				$1->value.r.first = $2;
1466cdfa2a7eSchristos 				$1->value.r.last  = $4;
1467cdfa2a7eSchristos 			} else if ($2 < (1 << ($1->attr - 1)) && $4 < (1 << ($1->attr - 1))) {
1468cdfa2a7eSchristos 				$1->value.r.first = $2;
1469cdfa2a7eSchristos 				$1->value.r.last  = $4;
1470cdfa2a7eSchristos 			} else {
1471cdfa2a7eSchristos 				yyerror("pollskewlist: randomization limit must be <= half the poll interval");
1472cdfa2a7eSchristos 				destroy_attr_val($1);
1473cdfa2a7eSchristos 				$1 = NULL;
1474cdfa2a7eSchristos 			}
1475cdfa2a7eSchristos 			$$ = $1;
1476cdfa2a7eSchristos 		}
1477cdfa2a7eSchristos 	;
1478cdfa2a7eSchristos 
1479cdfa2a7eSchristos pollskew_cycle
1480*eabc0478Schristos 	:	T_Integer
1481*eabc0478Schristos 		{
1482*eabc0478Schristos 			$$ = ($1 >= NTP_MINPOLL && $1 <= NTP_MAXPOLL)
1483*eabc0478Schristos 				? create_attr_rval($1, 0, 0)
1484*eabc0478Schristos 				: NULL;
1485*eabc0478Schristos 		}
1486cdfa2a7eSchristos 	|	T_Default { $$ = create_attr_rval(-1, 0, 0); }
1487cdfa2a7eSchristos 	;
1488cdfa2a7eSchristos 
1489cdfa2a7eSchristos 
1490abb0f93cSkardel variable_assign
14913123f114Skardel 	:	T_String '=' T_String t_default_or_zero
1492abb0f93cSkardel 			{ $$ = create_setvar_node($1, $3, $4); }
14933123f114Skardel 	;
14943123f114Skardel 
14953123f114Skardel t_default_or_zero
14963123f114Skardel 	:	T_Default
14973123f114Skardel 	|	/* empty, no "default" modifier */
14983123f114Skardel 			{ $$ = 0; }
1499abb0f93cSkardel 	;
1500abb0f93cSkardel 
1501abb0f93cSkardel trap_option_list
15022950cc38Schristos 	:	/* empty list */
15032950cc38Schristos 			{ $$ = NULL; }
15042950cc38Schristos 	|	trap_option_list trap_option
15052950cc38Schristos 		{
15062950cc38Schristos 			$$ = $1;
15072950cc38Schristos 			APPEND_G_FIFO($$, $2);
15082950cc38Schristos 		}
1509abb0f93cSkardel 	;
1510abb0f93cSkardel 
1511abb0f93cSkardel trap_option
15122950cc38Schristos 	:	T_Port T_Integer
15132950cc38Schristos 			{ $$ = create_attr_ival($1, $2); }
15142950cc38Schristos 	|	T_Interface ip_address
15152950cc38Schristos 		{
15162950cc38Schristos 			$$ = create_attr_sval($1, estrdup($2->address));
15172950cc38Schristos 			destroy_address_node($2);
15182950cc38Schristos 		}
1519abb0f93cSkardel 	;
1520abb0f93cSkardel 
1521abb0f93cSkardel log_config_list
15222950cc38Schristos 	:	log_config_list log_config_command
15232950cc38Schristos 		{
15242950cc38Schristos 			$$ = $1;
15252950cc38Schristos 			APPEND_G_FIFO($$, $2);
15262950cc38Schristos 		}
15272950cc38Schristos 	|	log_config_command
15282950cc38Schristos 		{
15292950cc38Schristos 			$$ = NULL;
15302950cc38Schristos 			APPEND_G_FIFO($$, $1);
15312950cc38Schristos 		}
1532abb0f93cSkardel 	;
1533abb0f93cSkardel 
1534abb0f93cSkardel log_config_command
1535abb0f93cSkardel 	:	T_String
1536abb0f93cSkardel 		{
15372950cc38Schristos 			char	prefix;
15382950cc38Schristos 			char *	type;
1539abb0f93cSkardel 
15402950cc38Schristos 			switch ($1[0]) {
15412950cc38Schristos 
15422950cc38Schristos 			case '+':
15432950cc38Schristos 			case '-':
15442950cc38Schristos 			case '=':
15452950cc38Schristos 				prefix = $1[0];
15462950cc38Schristos 				type = $1 + 1;
15472950cc38Schristos 				break;
15482950cc38Schristos 
15492950cc38Schristos 			default:
15502950cc38Schristos 				prefix = '=';
15512950cc38Schristos 				type = $1;
1552abb0f93cSkardel 			}
15532950cc38Schristos 
1554abb0f93cSkardel 			$$ = create_attr_sval(prefix, estrdup(type));
1555abb0f93cSkardel 			YYFREE($1);
1556abb0f93cSkardel 		}
1557abb0f93cSkardel 	;
1558abb0f93cSkardel 
1559abb0f93cSkardel interface_command
1560abb0f93cSkardel 	:	interface_nic nic_rule_action nic_rule_class
1561abb0f93cSkardel 		{
15622950cc38Schristos 			nic_rule_node *nrn;
15632950cc38Schristos 
15642950cc38Schristos 			nrn = create_nic_rule_node($3, NULL, $2);
15652950cc38Schristos 			APPEND_G_FIFO(cfgt.nic_rules, nrn);
1566abb0f93cSkardel 		}
1567abb0f93cSkardel 	|	interface_nic nic_rule_action T_String
1568abb0f93cSkardel 		{
15692950cc38Schristos 			nic_rule_node *nrn;
15702950cc38Schristos 
15712950cc38Schristos 			nrn = create_nic_rule_node(0, $3, $2);
15722950cc38Schristos 			APPEND_G_FIFO(cfgt.nic_rules, nrn);
1573abb0f93cSkardel 		}
1574abb0f93cSkardel 	;
1575abb0f93cSkardel 
1576abb0f93cSkardel interface_nic
1577abb0f93cSkardel 	:	T_Interface
1578abb0f93cSkardel 	|	T_Nic
1579abb0f93cSkardel 	;
1580abb0f93cSkardel 
1581abb0f93cSkardel nic_rule_class
1582abb0f93cSkardel 	:	T_All
1583abb0f93cSkardel 	|	T_Ipv4
1584abb0f93cSkardel 	|	T_Ipv6
1585abb0f93cSkardel 	|	T_Wildcard
1586abb0f93cSkardel 	;
1587abb0f93cSkardel 
1588abb0f93cSkardel nic_rule_action
1589abb0f93cSkardel 	:	T_Listen
1590abb0f93cSkardel 	|	T_Ignore
1591abb0f93cSkardel 	|	T_Drop
1592abb0f93cSkardel 	;
1593abb0f93cSkardel 
15942950cc38Schristos reset_command
15952950cc38Schristos 	:	T_Reset counter_set_list
15962950cc38Schristos 			{ CONCAT_G_FIFOS(cfgt.reset_counters, $2); }
15972950cc38Schristos 	;
15982950cc38Schristos 
15992950cc38Schristos counter_set_list
16002950cc38Schristos 	:	counter_set_list counter_set_keyword
16012950cc38Schristos 		{
16022950cc38Schristos 			$$ = $1;
16032950cc38Schristos 			APPEND_G_FIFO($$, create_int_node($2));
16042950cc38Schristos 		}
16052950cc38Schristos 	|	counter_set_keyword
16062950cc38Schristos 		{
16072950cc38Schristos 			$$ = NULL;
16082950cc38Schristos 			APPEND_G_FIFO($$, create_int_node($1));
16092950cc38Schristos 		}
16102950cc38Schristos 	;
16112950cc38Schristos 
16122950cc38Schristos counter_set_keyword
16132950cc38Schristos 	:	T_Allpeers
16142950cc38Schristos 	|	T_Auth
16152950cc38Schristos 	|	T_Ctl
16162950cc38Schristos 	|	T_Io
16172950cc38Schristos 	|	T_Mem
16182950cc38Schristos 	|	T_Sys
16192950cc38Schristos 	|	T_Timer
16202950cc38Schristos 	;
16212950cc38Schristos 
1622abb0f93cSkardel 
1623abb0f93cSkardel 
1624abb0f93cSkardel /* Miscellaneous Rules
1625abb0f93cSkardel  * -------------------
1626abb0f93cSkardel  */
1627abb0f93cSkardel 
1628abb0f93cSkardel integer_list
16292950cc38Schristos 	:	integer_list T_Integer
16302950cc38Schristos 		{
16312950cc38Schristos 			$$ = $1;
16322950cc38Schristos 			APPEND_G_FIFO($$, create_int_node($2));
16332950cc38Schristos 		}
16342950cc38Schristos 	|	T_Integer
16352950cc38Schristos 		{
16362950cc38Schristos 			$$ = NULL;
16372950cc38Schristos 			APPEND_G_FIFO($$, create_int_node($1));
16382950cc38Schristos 		}
1639abb0f93cSkardel 	;
1640abb0f93cSkardel 
16413123f114Skardel integer_list_range
16423123f114Skardel 	:	integer_list_range integer_list_range_elt
16432950cc38Schristos 		{
16442950cc38Schristos 			$$ = $1;
16452950cc38Schristos 			APPEND_G_FIFO($$, $2);
16462950cc38Schristos 		}
16473123f114Skardel 	|	integer_list_range_elt
16482950cc38Schristos 		{
16492950cc38Schristos 			$$ = NULL;
16502950cc38Schristos 			APPEND_G_FIFO($$, $1);
16512950cc38Schristos 		}
16523123f114Skardel 	;
16533123f114Skardel 
16543123f114Skardel integer_list_range_elt
16553123f114Skardel 	:	T_Integer
16563123f114Skardel 			{ $$ = create_attr_ival('i', $1); }
16572950cc38Schristos 	|	integer_range
16583123f114Skardel 	;
16593123f114Skardel 
16602950cc38Schristos integer_range
16613123f114Skardel 	:	'(' T_Integer T_Ellipsis T_Integer ')'
1662cdfa2a7eSchristos 			{ $$ = create_attr_rval('-', $2, $4); }
16633123f114Skardel 	;
16643123f114Skardel 
1665abb0f93cSkardel string_list
16662950cc38Schristos 	:	string_list T_String
16672950cc38Schristos 		{
16682950cc38Schristos 			$$ = $1;
16692950cc38Schristos 			APPEND_G_FIFO($$, create_string_node($2));
16702950cc38Schristos 		}
16712950cc38Schristos 	|	T_String
16722950cc38Schristos 		{
16732950cc38Schristos 			$$ = NULL;
16742950cc38Schristos 			APPEND_G_FIFO($$, create_string_node($1));
16752950cc38Schristos 		}
1676abb0f93cSkardel 	;
1677abb0f93cSkardel 
1678abb0f93cSkardel address_list
16792950cc38Schristos 	:	address_list address
16802950cc38Schristos 		{
16812950cc38Schristos 			$$ = $1;
16822950cc38Schristos 			APPEND_G_FIFO($$, $2);
16832950cc38Schristos 		}
16842950cc38Schristos 	|	address
16852950cc38Schristos 		{
16862950cc38Schristos 			$$ = NULL;
16872950cc38Schristos 			APPEND_G_FIFO($$, $1);
16882950cc38Schristos 		}
1689abb0f93cSkardel 	;
1690abb0f93cSkardel 
1691abb0f93cSkardel boolean
1692abb0f93cSkardel 	:	T_Integer
1693abb0f93cSkardel 		{
1694abb0f93cSkardel 			if ($1 != 0 && $1 != 1) {
16955d681e99Schristos 				yyerror("Integer value is not boolean (0 or 1). Assuming 1");
1696abb0f93cSkardel 				$$ = 1;
16973123f114Skardel 			} else {
1698abb0f93cSkardel 				$$ = $1;
1699abb0f93cSkardel 			}
17003123f114Skardel 		}
1701abb0f93cSkardel 	|	T_True	{ $$ = 1; }
1702abb0f93cSkardel 	|	T_False	{ $$ = 0; }
1703abb0f93cSkardel 	;
1704abb0f93cSkardel 
1705abb0f93cSkardel number
1706abb0f93cSkardel 	:	T_Integer	{ $$ = (double)$1; }
1707abb0f93cSkardel 	|	T_Double
1708abb0f93cSkardel 	;
1709abb0f93cSkardel 
17104eea345dSchristos basedate
17114eea345dSchristos 	:	T_Basedate T_String
17124eea345dSchristos 			{ $$ = basedate_eval_string($2); YYFREE($2); }
1713abb0f93cSkardel 
1714abb0f93cSkardel /* Simulator Configuration Commands
1715abb0f93cSkardel  * --------------------------------
1716abb0f93cSkardel  */
1717abb0f93cSkardel 
1718abb0f93cSkardel simulate_command
1719abb0f93cSkardel 	:	sim_conf_start '{' sim_init_statement_list sim_server_list '}'
1720abb0f93cSkardel 		{
17212950cc38Schristos 			sim_node *sn;
1722abb0f93cSkardel 
17232950cc38Schristos 			sn =  create_sim_node($3, $4);
17242950cc38Schristos 			APPEND_G_FIFO(cfgt.sim_details, sn);
17252950cc38Schristos 
17262950cc38Schristos 			/* Revert from ; to \n for end-of-command */
1727abb0f93cSkardel 			old_config_style = 1;
1728abb0f93cSkardel 		}
1729abb0f93cSkardel 	;
1730abb0f93cSkardel 
1731abb0f93cSkardel /* The following is a terrible hack to get the configuration file to
1732abb0f93cSkardel  * treat newlines as whitespace characters within the simulation.
1733abb0f93cSkardel  * This is needed because newlines are significant in the rest of the
1734abb0f93cSkardel  * configuration file.
1735abb0f93cSkardel  */
1736abb0f93cSkardel sim_conf_start
1737abb0f93cSkardel 	:	T_Simulate { old_config_style = 0; }
1738abb0f93cSkardel 	;
1739abb0f93cSkardel 
1740abb0f93cSkardel sim_init_statement_list
17412950cc38Schristos 	:	sim_init_statement_list sim_init_statement T_EOC
17422950cc38Schristos 		{
17432950cc38Schristos 			$$ = $1;
17442950cc38Schristos 			APPEND_G_FIFO($$, $2);
17452950cc38Schristos 		}
17462950cc38Schristos 	|	sim_init_statement T_EOC
17472950cc38Schristos 		{
17482950cc38Schristos 			$$ = NULL;
17492950cc38Schristos 			APPEND_G_FIFO($$, $1);
17502950cc38Schristos 		}
1751abb0f93cSkardel 	;
1752abb0f93cSkardel 
1753abb0f93cSkardel sim_init_statement
17542950cc38Schristos 	:	sim_init_keyword '=' number
17552950cc38Schristos 			{ $$ = create_attr_dval($1, $3); }
17562950cc38Schristos 	;
17572950cc38Schristos 
17582950cc38Schristos sim_init_keyword
17592950cc38Schristos 	:	T_Beep_Delay
17602950cc38Schristos 	|	T_Sim_Duration
1761abb0f93cSkardel 	;
1762abb0f93cSkardel 
1763abb0f93cSkardel sim_server_list
17642950cc38Schristos 	:	sim_server_list sim_server
17652950cc38Schristos 		{
17662950cc38Schristos 			$$ = $1;
17672950cc38Schristos 			APPEND_G_FIFO($$, $2);
17682950cc38Schristos 		}
17692950cc38Schristos 	|	sim_server
17702950cc38Schristos 		{
17712950cc38Schristos 			$$ = NULL;
17722950cc38Schristos 			APPEND_G_FIFO($$, $1);
17732950cc38Schristos 		}
1774abb0f93cSkardel 	;
1775abb0f93cSkardel 
1776abb0f93cSkardel sim_server
1777abb0f93cSkardel 	:	sim_server_name '{' sim_server_offset sim_act_list '}'
1778ea66d795Schristos 			{ $$ = ONLY_SIM(create_sim_server($1, $3, $4)); }
1779abb0f93cSkardel 	;
1780abb0f93cSkardel 
1781abb0f93cSkardel sim_server_offset
17822950cc38Schristos 	:	T_Server_Offset '=' number T_EOC
17832950cc38Schristos 			{ $$ = $3; }
1784abb0f93cSkardel 	;
1785abb0f93cSkardel 
1786abb0f93cSkardel sim_server_name
17872950cc38Schristos 	:	T_Server '=' address
17882950cc38Schristos 			{ $$ = $3; }
1789abb0f93cSkardel 	;
1790abb0f93cSkardel 
1791abb0f93cSkardel sim_act_list
17922950cc38Schristos 	:	sim_act_list sim_act
17932950cc38Schristos 		{
17942950cc38Schristos 			$$ = $1;
17952950cc38Schristos 			APPEND_G_FIFO($$, $2);
17962950cc38Schristos 		}
17972950cc38Schristos 	|	sim_act
17982950cc38Schristos 		{
17992950cc38Schristos 			$$ = NULL;
18002950cc38Schristos 			APPEND_G_FIFO($$, $1);
18012950cc38Schristos 		}
1802abb0f93cSkardel 	;
1803abb0f93cSkardel 
1804abb0f93cSkardel sim_act
1805abb0f93cSkardel 	:	T_Duration '=' number '{' sim_act_stmt_list '}'
1806ea66d795Schristos 			{ $$ = ONLY_SIM(create_sim_script_info($3, $5)); }
1807abb0f93cSkardel 	;
1808abb0f93cSkardel 
1809abb0f93cSkardel sim_act_stmt_list
18102950cc38Schristos 	:	sim_act_stmt_list sim_act_stmt T_EOC
18112950cc38Schristos 		{
18122950cc38Schristos 			$$ = $1;
18132950cc38Schristos 			APPEND_G_FIFO($$, $2);
18142950cc38Schristos 		}
18152950cc38Schristos 	|	sim_act_stmt T_EOC
18162950cc38Schristos 		{
18172950cc38Schristos 			$$ = NULL;
18182950cc38Schristos 			APPEND_G_FIFO($$, $1);
18192950cc38Schristos 		}
1820abb0f93cSkardel 	;
1821abb0f93cSkardel 
1822abb0f93cSkardel sim_act_stmt
18232950cc38Schristos 	:	sim_act_keyword '=' number
1824abb0f93cSkardel 			{ $$ = create_attr_dval($1, $3); }
1825abb0f93cSkardel 	;
1826abb0f93cSkardel 
18272950cc38Schristos sim_act_keyword
18282950cc38Schristos 	:	T_Freq_Offset
18292950cc38Schristos 	|	T_Wander
18302950cc38Schristos 	|	T_Jitter
18312950cc38Schristos 	|	T_Prop_Delay
18322950cc38Schristos 	|	T_Proc_Delay
18332950cc38Schristos 	;
1834abb0f93cSkardel 
1835abb0f93cSkardel %%
1836abb0f93cSkardel 
18373123f114Skardel void
18383123f114Skardel yyerror(
18393123f114Skardel 	const char *msg
18403123f114Skardel 	)
1841abb0f93cSkardel {
1842abb0f93cSkardel 	int retval;
18435d681e99Schristos 	struct FILE_INFO * ip_ctx;
1844abb0f93cSkardel 
18455d681e99Schristos 	ip_ctx = lex_current();
18465d681e99Schristos 	ip_ctx->errpos = ip_ctx->tokpos;
1847abb0f93cSkardel 
18485d681e99Schristos 	msyslog(LOG_ERR, "line %d column %d %s",
18495d681e99Schristos 		ip_ctx->errpos.nline, ip_ctx->errpos.ncol, msg);
18505d681e99Schristos 	if (!lex_from_file()) {
1851abb0f93cSkardel 		/* Save the error message in the correct buffer */
1852abb0f93cSkardel 		retval = snprintf(remote_config.err_msg + remote_config.err_pos,
1853*eabc0478Schristos 				  sizeof remote_config.err_msg - remote_config.err_pos,
1854abb0f93cSkardel 				  "column %d %s",
18555d681e99Schristos 				  ip_ctx->errpos.ncol, msg);
1856abb0f93cSkardel 
1857abb0f93cSkardel 		/* Increment the value of err_pos */
1858abb0f93cSkardel 		if (retval > 0)
1859abb0f93cSkardel 			remote_config.err_pos += retval;
1860abb0f93cSkardel 
1861abb0f93cSkardel 		/* Increment the number of errors */
1862abb0f93cSkardel 		++remote_config.no_errors;
1863abb0f93cSkardel 	}
1864abb0f93cSkardel }
1865abb0f93cSkardel 
1866abb0f93cSkardel 
1867abb0f93cSkardel /*
18682950cc38Schristos  * token_name - convert T_ token integers to text
18692950cc38Schristos  *		example: token_name(T_Server) returns "T_Server"
1870abb0f93cSkardel  */
1871abb0f93cSkardel const char *
1872abb0f93cSkardel token_name(
1873abb0f93cSkardel 	int token
1874abb0f93cSkardel 	)
1875abb0f93cSkardel {
1876abb0f93cSkardel 	return yytname[YYTRANSLATE(token)];
1877abb0f93cSkardel }
1878abb0f93cSkardel 
1879abb0f93cSkardel 
18802950cc38Schristos /* Initial Testing function -- ignore */
18812950cc38Schristos #if 0
1882abb0f93cSkardel int main(int argc, char *argv[])
1883abb0f93cSkardel {
1884abb0f93cSkardel 	ip_file = FOPEN(argv[1], "r");
18852950cc38Schristos 	if (!ip_file)
1886abb0f93cSkardel 		fprintf(stderr, "ERROR!! Could not open file: %s\n", argv[1]);
1887abb0f93cSkardel 	yyparse();
1888abb0f93cSkardel 	return 0;
1889abb0f93cSkardel }
18902950cc38Schristos #endif
1891abb0f93cSkardel 
1892