3 * The parser for the NTP configuration file.
5 * Written By: Sachin Kamboj
6 * University of Delaware
18 #include "ntp_machine.h"
19 #include "ntp_stdlib.h"
20 #include "ntp_filegen.h"
21 #include "ntp_scanner.h"
22 #include "ntp_config.h"
23 #include "ntp_crypto.h"
25 #include "ntpsim.h" /* HMS: Do we really want this all the time? */
26 /* SK: It might be a good idea to always
27 include the simulator code. That way
28 someone can use the same configuration file
29 for both the simulator and the daemon
32 #define YYMALLOC emalloc
34 #define YYERROR_VERBOSE
35 #define YYMAXDEPTH 1000 /* stop the madness sooner */
36 void yyerror(const char *msg);
39 # define ONLY_SIM(a) (a)
41 # define ONLY_SIM(a) NULL
46 * Enable generation of token names array even without YYDEBUG.
47 * We access via token_name() defined below.
56 gen_fifo * Generic_fifo;
58 attr_val_fifo * Attr_val_fifo;
60 string_fifo * String_fifo;
61 address_node * Address_node;
62 address_fifo * Address_fifo;
63 setvar_node * Set_var;
64 server_info * Sim_server;
65 server_info_fifo * Sim_server_fifo;
66 script_info * Sim_script;
67 script_info_fifo * Sim_script_fifo;
70 /* TERMINALS (do not appear left of colon) */
71 %token <Integer> T_Abbrev
72 %token <Integer> T_Age
73 %token <Integer> T_All
74 %token <Integer> T_Allan
75 %token <Integer> T_Allpeers
76 %token <Integer> T_Auth
77 %token <Integer> T_Autokey
78 %token <Integer> T_Automax
79 %token <Integer> T_Average
80 %token <Integer> T_Bclient
81 %token <Integer> T_Beacon
82 %token <Integer> T_Broadcast
83 %token <Integer> T_Broadcastclient
84 %token <Integer> T_Broadcastdelay
85 %token <Integer> T_Burst
86 %token <Integer> T_Calibrate
87 %token <Integer> T_Ceiling
88 %token <Integer> T_Clockstats
89 %token <Integer> T_Cohort
90 %token <Integer> T_ControlKey
91 %token <Integer> T_Crypto
92 %token <Integer> T_Cryptostats
93 %token <Integer> T_Ctl
94 %token <Integer> T_Day
95 %token <Integer> T_Default
96 %token <Integer> T_Digest
97 %token <Integer> T_Disable
98 %token <Integer> T_Discard
99 %token <Integer> T_Dispersion
100 %token <Double> T_Double /* not a token */
101 %token <Integer> T_Driftfile
102 %token <Integer> T_Drop
103 %token <Integer> T_Dscp
104 %token <Integer> T_Ellipsis /* "..." not "ellipsis" */
105 %token <Integer> T_Enable
106 %token <Integer> T_End
107 %token <Integer> T_False
108 %token <Integer> T_File
109 %token <Integer> T_Filegen
110 %token <Integer> T_Filenum
111 %token <Integer> T_Flag1
112 %token <Integer> T_Flag2
113 %token <Integer> T_Flag3
114 %token <Integer> T_Flag4
115 %token <Integer> T_Flake
116 %token <Integer> T_Floor
117 %token <Integer> T_Freq
118 %token <Integer> T_Fudge
119 %token <Integer> T_Host
120 %token <Integer> T_Huffpuff
121 %token <Integer> T_Iburst
122 %token <Integer> T_Ident
123 %token <Integer> T_Ignore
124 %token <Integer> T_Incalloc
125 %token <Integer> T_Incmem
126 %token <Integer> T_Initalloc
127 %token <Integer> T_Initmem
128 %token <Integer> T_Includefile
129 %token <Integer> T_Integer /* not a token */
130 %token <Integer> T_Interface
131 %token <Integer> T_Intrange /* not a token */
132 %token <Integer> T_Io
133 %token <Integer> T_Ipv4
134 %token <Integer> T_Ipv4_flag
135 %token <Integer> T_Ipv6
136 %token <Integer> T_Ipv6_flag
137 %token <Integer> T_Kernel
138 %token <Integer> T_Key
139 %token <Integer> T_Keys
140 %token <Integer> T_Keysdir
141 %token <Integer> T_Kod
142 %token <Integer> T_Mssntp
143 %token <Integer> T_Leapfile
144 %token <Integer> T_Leapsmearinterval
145 %token <Integer> T_Limited
146 %token <Integer> T_Link
147 %token <Integer> T_Listen
148 %token <Integer> T_Logconfig
149 %token <Integer> T_Logfile
150 %token <Integer> T_Loopstats
151 %token <Integer> T_Lowpriotrap
152 %token <Integer> T_Manycastclient
153 %token <Integer> T_Manycastserver
154 %token <Integer> T_Mask
155 %token <Integer> T_Maxage
156 %token <Integer> T_Maxclock
157 %token <Integer> T_Maxdepth
158 %token <Integer> T_Maxdist
159 %token <Integer> T_Maxmem
160 %token <Integer> T_Maxpoll
161 %token <Integer> T_Mdnstries
162 %token <Integer> T_Mem
163 %token <Integer> T_Memlock
164 %token <Integer> T_Minclock
165 %token <Integer> T_Mindepth
166 %token <Integer> T_Mindist
167 %token <Integer> T_Minimum
168 %token <Integer> T_Minpoll
169 %token <Integer> T_Minsane
170 %token <Integer> T_Mode
171 %token <Integer> T_Mode7
172 %token <Integer> T_Monitor
173 %token <Integer> T_Month
174 %token <Integer> T_Mru
175 %token <Integer> T_Multicastclient
176 %token <Integer> T_Nic
177 %token <Integer> T_Nolink
178 %token <Integer> T_Nomodify
179 %token <Integer> T_Nomrulist
180 %token <Integer> T_None
181 %token <Integer> T_Nonvolatile
182 %token <Integer> T_Nopeer
183 %token <Integer> T_Noquery
184 %token <Integer> T_Noselect
185 %token <Integer> T_Noserve
186 %token <Integer> T_Notrap
187 %token <Integer> T_Notrust
188 %token <Integer> T_Ntp
189 %token <Integer> T_Ntpport
190 %token <Integer> T_NtpSignDsocket
191 %token <Integer> T_Orphan
192 %token <Integer> T_Orphanwait
193 %token <Integer> T_PCEdigest
194 %token <Integer> T_Panic
195 %token <Integer> T_Peer
196 %token <Integer> T_Peerstats
197 %token <Integer> T_Phone
198 %token <Integer> T_Pid
199 %token <Integer> T_Pidfile
200 %token <Integer> T_Pool
201 %token <Integer> T_Port
202 %token <Integer> T_Preempt
203 %token <Integer> T_Prefer
204 %token <Integer> T_Protostats
205 %token <Integer> T_Pw
206 %token <Integer> T_Randfile
207 %token <Integer> T_Rawstats
208 %token <Integer> T_Refid
209 %token <Integer> T_Requestkey
210 %token <Integer> T_Reset
211 %token <Integer> T_Restrict
212 %token <Integer> T_Revoke
213 %token <Integer> T_Rlimit
214 %token <Integer> T_Saveconfigdir
215 %token <Integer> T_Server
216 %token <Integer> T_Setvar
217 %token <Integer> T_Source
218 %token <Integer> T_Stacksize
219 %token <Integer> T_Statistics
220 %token <Integer> T_Stats
221 %token <Integer> T_Statsdir
222 %token <Integer> T_Step
223 %token <Integer> T_Stepback
224 %token <Integer> T_Stepfwd
225 %token <Integer> T_Stepout
226 %token <Integer> T_Stratum
227 %token <String> T_String /* not a token */
228 %token <Integer> T_Sys
229 %token <Integer> T_Sysstats
230 %token <Integer> T_Tick
231 %token <Integer> T_Time1
232 %token <Integer> T_Time2
233 %token <Integer> T_Timer
234 %token <Integer> T_Timingstats
235 %token <Integer> T_Tinker
236 %token <Integer> T_Tos
237 %token <Integer> T_Trap
238 %token <Integer> T_True
239 %token <Integer> T_Trustedkey
240 %token <Integer> T_Ttl
241 %token <Integer> T_Type
242 %token <Integer> T_U_int /* Not a token */
243 %token <Integer> T_UEcrypto
244 %token <Integer> T_UEcryptonak
245 %token <Integer> T_UEdigest
246 %token <Integer> T_Unconfig
247 %token <Integer> T_Unpeer
248 %token <Integer> T_Version
249 %token <Integer> T_WanderThreshold /* Not a token */
250 %token <Integer> T_Week
251 %token <Integer> T_Wildcard
252 %token <Integer> T_Xleave
253 %token <Integer> T_Year
254 %token <Integer> T_Flag /* Not a token */
255 %token <Integer> T_EOC
258 /* NTP Simulator Tokens */
259 %token <Integer> T_Simulate
260 %token <Integer> T_Beep_Delay
261 %token <Integer> T_Sim_Duration
262 %token <Integer> T_Server_Offset
263 %token <Integer> T_Duration
264 %token <Integer> T_Freq_Offset
265 %token <Integer> T_Wander
266 %token <Integer> T_Jitter
267 %token <Integer> T_Prop_Delay
268 %token <Integer> T_Proc_Delay
272 /*** NON-TERMINALS ***/
273 %type <Integer> access_control_flag
274 %type <Int_fifo> ac_flag_list
275 %type <Address_node> address
276 %type <Integer> address_fam
277 %type <Address_fifo> address_list
278 %type <Integer> boolean
279 %type <Integer> client_type
280 %type <Integer> counter_set_keyword
281 %type <Int_fifo> counter_set_list
282 %type <Attr_val> crypto_command
283 %type <Attr_val_fifo> crypto_command_list
284 %type <Integer> crypto_str_keyword
285 %type <Attr_val> discard_option
286 %type <Integer> discard_option_keyword
287 %type <Attr_val_fifo> discard_option_list
288 %type <Integer> enable_disable
289 %type <Attr_val> filegen_option
290 %type <Attr_val_fifo> filegen_option_list
291 %type <Integer> filegen_type
292 %type <Attr_val> fudge_factor
293 %type <Integer> fudge_factor_bool_keyword
294 %type <Integer> fudge_factor_dbl_keyword
295 %type <Attr_val_fifo> fudge_factor_list
296 %type <Attr_val_fifo> integer_list
297 %type <Attr_val_fifo> integer_list_range
298 %type <Attr_val> integer_list_range_elt
299 %type <Attr_val> integer_range
300 %type <Integer> nic_rule_action
301 %type <Integer> interface_command
302 %type <Integer> interface_nic
303 %type <Address_node> ip_address
304 %type <Integer> link_nolink
305 %type <Attr_val> log_config_command
306 %type <Attr_val_fifo> log_config_list
307 %type <Integer> misc_cmd_dbl_keyword
308 %type <Integer> misc_cmd_int_keyword
309 %type <Integer> misc_cmd_str_keyword
310 %type <Integer> misc_cmd_str_lcl_keyword
311 %type <Attr_val> mru_option
312 %type <Integer> mru_option_keyword
313 %type <Attr_val_fifo> mru_option_list
314 %type <Integer> nic_rule_class
315 %type <Double> number
316 %type <Attr_val> option
317 %type <Attr_val> option_flag
318 %type <Integer> option_flag_keyword
319 %type <Attr_val_fifo> option_list
320 %type <Attr_val> option_int
321 %type <Integer> option_int_keyword
322 %type <Attr_val> option_str
323 %type <Integer> option_str_keyword
324 %type <Integer> reset_command
325 %type <Integer> rlimit_option_keyword
326 %type <Attr_val> rlimit_option
327 %type <Attr_val_fifo> rlimit_option_list
329 %type <Int_fifo> stats_list
330 %type <String_fifo> string_list
331 %type <Attr_val> system_option
332 %type <Integer> system_option_flag_keyword
333 %type <Integer> system_option_local_flag_keyword
334 %type <Attr_val_fifo> system_option_list
335 %type <Integer> t_default_or_zero
336 %type <Integer> tinker_option_keyword
337 %type <Attr_val> tinker_option
338 %type <Attr_val_fifo> tinker_option_list
339 %type <Attr_val> tos_option
340 %type <Integer> tos_option_dbl_keyword
341 %type <Integer> tos_option_int_keyword
342 %type <Attr_val_fifo> tos_option_list
343 %type <Attr_val> trap_option
344 %type <Attr_val_fifo> trap_option_list
345 %type <Integer> unpeer_keyword
346 %type <Set_var> variable_assign
348 /* NTP Simulator non-terminals */
349 %type <Attr_val> sim_init_statement
350 %type <Attr_val_fifo> sim_init_statement_list
351 %type <Integer> sim_init_keyword
352 %type <Sim_server_fifo> sim_server_list
353 %type <Sim_server> sim_server
354 %type <Double> sim_server_offset
355 %type <Address_node> sim_server_name
356 %type <Sim_script> sim_act
357 %type <Sim_script_fifo> sim_act_list
358 %type <Integer> sim_act_keyword
359 %type <Attr_val_fifo> sim_act_stmt_list
360 %type <Attr_val> sim_act_stmt
365 * Configuration File Grammar
366 * --------------------------
374 : command_list command T_EOC
378 /* I will need to incorporate much more fine grained
379 * error messages. The following should suffice for
382 struct FILE_INFO * ip_ctx = lex_current();
384 "syntax error in %s line %d, column %d",
386 ip_ctx->errpos.nline,
387 ip_ctx->errpos.ncol);
391 command : /* NULL STATEMENT */
395 | authentication_command
397 | access_control_command
398 | orphan_mode_command
401 | system_option_command
403 | miscellaneous_command
412 : client_type address option_list
416 my_node = create_peer_node($1, $2, $3);
417 APPEND_G_FIFO(cfgt.peers, my_node);
431 | address_fam T_String
432 { $$ = create_address_node($2, $1); }
437 { $$ = create_address_node($1, AF_UNSPEC); }
453 APPEND_G_FIFO($$, $2);
464 : option_flag_keyword
465 { $$ = create_attr_ival(T_Flag, $1); }
480 : option_int_keyword T_Integer
481 { $$ = create_attr_ival($1, $2); }
482 | option_int_keyword T_U_int
483 { $$ = create_attr_uval($1, $2); }
496 : option_str_keyword T_String
497 { $$ = create_attr_sval($1, $2); }
510 : unpeer_keyword address
512 unpeer_node *my_node;
514 my_node = create_unpeer_node($2);
516 APPEND_G_FIFO(cfgt.unpeers, my_node);
526 * (broadcastclient manycastserver multicastclient)
527 * ------------------------------------------------
532 { cfgt.broadcastclient = 1; }
533 | T_Manycastserver address_list
534 { CONCAT_G_FIFOS(cfgt.manycastserver, $2); }
535 | T_Multicastclient address_list
536 { CONCAT_G_FIFOS(cfgt.multicastclient, $2); }
537 | T_Mdnstries T_Integer
538 { cfgt.mdnstries = $2; }
543 /* Authentication Commands
544 * -----------------------
547 authentication_command
548 : T_Automax T_Integer
552 atrv = create_attr_ival($1, $2);
553 APPEND_G_FIFO(cfgt.vars, atrv);
555 | T_ControlKey T_Integer
556 { cfgt.auth.control_key = $2; }
557 | T_Crypto crypto_command_list
559 cfgt.auth.cryptosw++;
560 CONCAT_G_FIFOS(cfgt.auth.crypto_cmd_list, $2);
563 { cfgt.auth.keys = $2; }
565 { cfgt.auth.keysdir = $2; }
566 | T_Requestkey T_Integer
567 { cfgt.auth.request_key = $2; }
569 { cfgt.auth.revoke = $2; }
570 | T_Trustedkey integer_list_range
572 cfgt.auth.trusted_key_list = $2;
574 // if (!cfgt.auth.trusted_key_list)
575 // cfgt.auth.trusted_key_list = $2;
577 // LINK_SLIST(cfgt.auth.trusted_key_list, $2, link);
579 | T_NtpSignDsocket T_String
580 { cfgt.auth.ntp_signd_socket = $2; }
586 | crypto_command_list crypto_command
589 APPEND_G_FIFO($$, $2);
594 : crypto_str_keyword T_String
595 { $$ = create_attr_sval($1, $2); }
599 cfgt.auth.revoke = $2;
601 "'crypto revoke %d' is deprecated, "
602 "please use 'revoke %d' instead.",
603 cfgt.auth.revoke, cfgt.auth.revoke);
616 /* Orphan Mode Commands
617 * --------------------
621 : T_Tos tos_option_list
622 { CONCAT_G_FIFOS(cfgt.orphan_cmds, $2); }
626 : tos_option_list tos_option
629 APPEND_G_FIFO($$, $2);
634 APPEND_G_FIFO($$, $1);
639 : tos_option_int_keyword T_Integer
640 { $$ = create_attr_dval($1, (double)$2); }
641 | tos_option_dbl_keyword number
642 { $$ = create_attr_dval($1, $2); }
644 { $$ = create_attr_dval($1, (double)$2); }
647 tos_option_int_keyword
656 tos_option_dbl_keyword
664 /* Monitoring Commands
665 * -------------------
669 : T_Statistics stats_list
670 { CONCAT_G_FIFOS(cfgt.stats_list, $2); }
671 | T_Statsdir T_String
673 if (lex_from_file()) {
677 yyerror("statsdir remote configuration ignored");
680 | T_Filegen stat filegen_option_list
684 fgn = create_filegen_node($2, $3);
685 APPEND_G_FIFO(cfgt.filegen_opts, fgn);
693 APPEND_G_FIFO($$, create_int_node($2));
698 APPEND_G_FIFO($$, create_int_node($1));
716 | filegen_option_list filegen_option
719 APPEND_G_FIFO($$, $2);
726 if (lex_from_file()) {
727 $$ = create_attr_sval($1, $2);
731 yyerror("filegen file remote config ignored");
734 | T_Type filegen_type
736 if (lex_from_file()) {
737 $$ = create_attr_ival($1, $2);
740 yyerror("filegen type remote config ignored");
747 if (lex_from_file()) {
748 $$ = create_attr_ival(T_Flag, $1);
752 err = "filegen link remote config ignored";
754 err = "filegen nolink remote config ignored";
759 { $$ = create_attr_ival(T_Flag, $1); }
783 /* Access Control Commands
784 * -----------------------
787 access_control_command
788 : T_Discard discard_option_list
790 CONCAT_G_FIFOS(cfgt.discard_opts, $2);
792 | T_Mru mru_option_list
794 CONCAT_G_FIFOS(cfgt.mru_opts, $2);
796 | T_Restrict address ac_flag_list
800 rn = create_restrict_node($2, NULL, $3,
801 lex_current()->curpos.nline);
802 APPEND_G_FIFO(cfgt.restrict_opts, rn);
804 | T_Restrict ip_address T_Mask ip_address ac_flag_list
808 rn = create_restrict_node($2, $4, $5,
809 lex_current()->curpos.nline);
810 APPEND_G_FIFO(cfgt.restrict_opts, rn);
812 | T_Restrict T_Default ac_flag_list
816 rn = create_restrict_node(NULL, NULL, $3,
817 lex_current()->curpos.nline);
818 APPEND_G_FIFO(cfgt.restrict_opts, rn);
820 | T_Restrict T_Ipv4_flag T_Default ac_flag_list
824 rn = create_restrict_node(
832 lex_current()->curpos.nline);
833 APPEND_G_FIFO(cfgt.restrict_opts, rn);
835 | T_Restrict T_Ipv6_flag T_Default ac_flag_list
839 rn = create_restrict_node(
847 lex_current()->curpos.nline);
848 APPEND_G_FIFO(cfgt.restrict_opts, rn);
850 | T_Restrict T_Source ac_flag_list
854 APPEND_G_FIFO($3, create_int_node($2));
855 rn = create_restrict_node(
856 NULL, NULL, $3, lex_current()->curpos.nline);
857 APPEND_G_FIFO(cfgt.restrict_opts, rn);
862 : /* empty list is allowed */
864 | ac_flag_list access_control_flag
867 APPEND_G_FIFO($$, create_int_node($2));
890 : discard_option_list discard_option
893 APPEND_G_FIFO($$, $2);
898 APPEND_G_FIFO($$, $1);
903 : discard_option_keyword T_Integer
904 { $$ = create_attr_ival($1, $2); }
907 discard_option_keyword
914 : mru_option_list mru_option
917 APPEND_G_FIFO($$, $2);
922 APPEND_G_FIFO($$, $1);
927 : mru_option_keyword T_Integer
928 { $$ = create_attr_ival($1, $2); }
947 : T_Fudge address fudge_factor_list
951 aon = create_addr_opts_node($2, $3);
952 APPEND_G_FIFO(cfgt.fudge, aon);
957 : fudge_factor_list fudge_factor
960 APPEND_G_FIFO($$, $2);
965 APPEND_G_FIFO($$, $1);
970 : fudge_factor_dbl_keyword number
971 { $$ = create_attr_dval($1, $2); }
972 | fudge_factor_bool_keyword boolean
973 { $$ = create_attr_ival($1, $2); }
974 | T_Stratum T_Integer
976 if ($2 >= 0 && $2 <= 16) {
977 $$ = create_attr_ival($1, $2);
980 yyerror("fudge factor: stratum value not in [0..16], ignored");
984 { $$ = create_attr_sval($1, $2); }
986 { $$ = create_attr_sval($1, $2); }
989 fudge_factor_dbl_keyword
994 fudge_factor_bool_keyword
1006 : T_Rlimit rlimit_option_list
1007 { CONCAT_G_FIFOS(cfgt.rlimit, $2); }
1011 : rlimit_option_list rlimit_option
1014 APPEND_G_FIFO($$, $2);
1019 APPEND_G_FIFO($$, $1);
1024 : rlimit_option_keyword T_Integer
1025 { $$ = create_attr_ival($1, $2); }
1028 rlimit_option_keyword
1035 /* Command for System Options
1036 * --------------------------
1039 system_option_command
1040 : T_Enable system_option_list
1041 { CONCAT_G_FIFOS(cfgt.enable_opts, $2); }
1042 | T_Disable system_option_list
1043 { CONCAT_G_FIFOS(cfgt.disable_opts, $2); }
1047 : system_option_list system_option
1050 APPEND_G_FIFO($$, $2);
1055 APPEND_G_FIFO($$, $1);
1060 : system_option_flag_keyword
1061 { $$ = create_attr_ival(T_Flag, $1); }
1062 | system_option_local_flag_keyword
1064 if (lex_from_file()) {
1065 $$ = create_attr_ival(T_Flag, $1);
1070 snprintf(err_str, sizeof(err_str),
1071 "enable/disable %s remote configuration ignored",
1078 system_option_flag_keyword
1087 system_option_local_flag_keyword
1101 : T_Tinker tinker_option_list
1102 { CONCAT_G_FIFOS(cfgt.tinker, $2); }
1106 : tinker_option_list tinker_option
1109 APPEND_G_FIFO($$, $2);
1114 APPEND_G_FIFO($$, $1);
1119 : tinker_option_keyword number
1120 { $$ = create_attr_dval($1, $2); }
1123 tinker_option_keyword
1137 /* Miscellaneous Commands
1138 * ----------------------
1141 miscellaneous_command
1144 | misc_cmd_dbl_keyword number
1148 av = create_attr_dval($1, $2);
1149 APPEND_G_FIFO(cfgt.vars, av);
1151 | misc_cmd_int_keyword T_Integer
1155 av = create_attr_ival($1, $2);
1156 APPEND_G_FIFO(cfgt.vars, av);
1158 | misc_cmd_str_keyword T_String
1162 av = create_attr_sval($1, $2);
1163 APPEND_G_FIFO(cfgt.vars, av);
1165 | misc_cmd_str_lcl_keyword T_String
1167 char error_text[64];
1170 if (lex_from_file()) {
1171 av = create_attr_sval($1, $2);
1172 APPEND_G_FIFO(cfgt.vars, av);
1175 snprintf(error_text, sizeof(error_text),
1176 "%s remote config ignored",
1178 yyerror(error_text);
1181 | T_Includefile T_String command
1183 if (!lex_from_file()) {
1184 YYFREE($2); /* avoid leak */
1185 yyerror("remote includefile ignored");
1188 if (lex_level() > MAXINCLUDELEVEL) {
1189 fprintf(stderr, "getconfig: Maximum include file level exceeded.\n");
1190 msyslog(LOG_ERR, "getconfig: Maximum include file level exceeded.");
1192 const char * path = FindConfig($2); /* might return $2! */
1193 if (!lex_push_file(path, "r")) {
1194 fprintf(stderr, "getconfig: Couldn't open <%s>\n", path);
1195 msyslog(LOG_ERR, "getconfig: Couldn't open <%s>", path);
1198 YYFREE($2); /* avoid leak */
1201 { lex_flush_stack(); }
1202 | T_Driftfile drift_parm
1203 { /* see drift_parm below for actions */ }
1204 | T_Logconfig log_config_list
1205 { CONCAT_G_FIFOS(cfgt.logconfig, $2); }
1206 | T_Phone string_list
1207 { CONCAT_G_FIFOS(cfgt.phone, $2); }
1208 | T_Setvar variable_assign
1209 { APPEND_G_FIFO(cfgt.setvar, $2); }
1210 | T_Trap ip_address trap_option_list
1212 addr_opts_node *aon;
1214 aon = create_addr_opts_node($2, $3);
1215 APPEND_G_FIFO(cfgt.trap, aon);
1217 | T_Ttl integer_list
1218 { CONCAT_G_FIFOS(cfgt.ttl, $2); }
1221 misc_cmd_dbl_keyword
1227 misc_cmd_int_keyword
1231 misc_cmd_int_keyword
1232 : T_Leapsmearinterval
1235 yyerror("Built without LEAP_SMEAR support.");
1240 misc_cmd_str_keyword
1245 misc_cmd_str_lcl_keyword
1254 if (lex_from_file()) {
1256 av = create_attr_sval(T_Driftfile, $1);
1257 APPEND_G_FIFO(cfgt.vars, av);
1260 yyerror("driftfile remote configuration ignored");
1265 if (lex_from_file()) {
1267 av = create_attr_sval(T_Driftfile, $1);
1268 APPEND_G_FIFO(cfgt.vars, av);
1269 av = create_attr_dval(T_WanderThreshold, $2);
1270 APPEND_G_FIFO(cfgt.vars, av);
1273 yyerror("driftfile remote configuration ignored");
1276 | /* Null driftfile, indicated by empty string "" */
1278 if (lex_from_file()) {
1280 av = create_attr_sval(T_Driftfile, estrdup(""));
1281 APPEND_G_FIFO(cfgt.vars, av);
1283 yyerror("driftfile remote configuration ignored");
1289 : T_String '=' T_String t_default_or_zero
1290 { $$ = create_setvar_node($1, $3, $4); }
1295 | /* empty, no "default" modifier */
1302 | trap_option_list trap_option
1305 APPEND_G_FIFO($$, $2);
1311 { $$ = create_attr_ival($1, $2); }
1312 | T_Interface ip_address
1314 $$ = create_attr_sval($1, estrdup($2->address));
1315 destroy_address_node($2);
1320 : log_config_list log_config_command
1323 APPEND_G_FIFO($$, $2);
1325 | log_config_command
1328 APPEND_G_FIFO($$, $1);
1352 $$ = create_attr_sval(prefix, estrdup(type));
1358 : interface_nic nic_rule_action nic_rule_class
1362 nrn = create_nic_rule_node($3, NULL, $2);
1363 APPEND_G_FIFO(cfgt.nic_rules, nrn);
1365 | interface_nic nic_rule_action T_String
1369 nrn = create_nic_rule_node(0, $3, $2);
1370 APPEND_G_FIFO(cfgt.nic_rules, nrn);
1393 : T_Reset counter_set_list
1394 { CONCAT_G_FIFOS(cfgt.reset_counters, $2); }
1398 : counter_set_list counter_set_keyword
1401 APPEND_G_FIFO($$, create_int_node($2));
1403 | counter_set_keyword
1406 APPEND_G_FIFO($$, create_int_node($1));
1422 /* Miscellaneous Rules
1423 * -------------------
1427 : integer_list T_Integer
1430 APPEND_G_FIFO($$, create_int_node($2));
1435 APPEND_G_FIFO($$, create_int_node($1));
1440 : integer_list_range integer_list_range_elt
1443 APPEND_G_FIFO($$, $2);
1445 | integer_list_range_elt
1448 APPEND_G_FIFO($$, $1);
1452 integer_list_range_elt
1454 { $$ = create_attr_ival('i', $1); }
1459 : '(' T_Integer T_Ellipsis T_Integer ')'
1460 { $$ = create_attr_rangeval('-', $2, $4); }
1464 : string_list T_String
1467 APPEND_G_FIFO($$, create_string_node($2));
1472 APPEND_G_FIFO($$, create_string_node($1));
1477 : address_list address
1480 APPEND_G_FIFO($$, $2);
1485 APPEND_G_FIFO($$, $1);
1492 if ($1 != 0 && $1 != 1) {
1493 yyerror("Integer value is not boolean (0 or 1). Assuming 1");
1499 | T_True { $$ = 1; }
1500 | T_False { $$ = 0; }
1504 : T_Integer { $$ = (double)$1; }
1509 /* Simulator Configuration Commands
1510 * --------------------------------
1514 : sim_conf_start '{' sim_init_statement_list sim_server_list '}'
1518 sn = create_sim_node($3, $4);
1519 APPEND_G_FIFO(cfgt.sim_details, sn);
1521 /* Revert from ; to \n for end-of-command */
1522 old_config_style = 1;
1526 /* The following is a terrible hack to get the configuration file to
1527 * treat newlines as whitespace characters within the simulation.
1528 * This is needed because newlines are significant in the rest of the
1529 * configuration file.
1532 : T_Simulate { old_config_style = 0; }
1535 sim_init_statement_list
1536 : sim_init_statement_list sim_init_statement T_EOC
1539 APPEND_G_FIFO($$, $2);
1541 | sim_init_statement T_EOC
1544 APPEND_G_FIFO($$, $1);
1549 : sim_init_keyword '=' number
1550 { $$ = create_attr_dval($1, $3); }
1559 : sim_server_list sim_server
1562 APPEND_G_FIFO($$, $2);
1567 APPEND_G_FIFO($$, $1);
1572 : sim_server_name '{' sim_server_offset sim_act_list '}'
1573 { $$ = ONLY_SIM(create_sim_server($1, $3, $4)); }
1577 : T_Server_Offset '=' number T_EOC
1582 : T_Server '=' address
1587 : sim_act_list sim_act
1590 APPEND_G_FIFO($$, $2);
1595 APPEND_G_FIFO($$, $1);
1600 : T_Duration '=' number '{' sim_act_stmt_list '}'
1601 { $$ = ONLY_SIM(create_sim_script_info($3, $5)); }
1605 : sim_act_stmt_list sim_act_stmt T_EOC
1608 APPEND_G_FIFO($$, $2);
1610 | sim_act_stmt T_EOC
1613 APPEND_G_FIFO($$, $1);
1618 : sim_act_keyword '=' number
1619 { $$ = create_attr_dval($1, $3); }
1638 struct FILE_INFO * ip_ctx;
1640 ip_ctx = lex_current();
1641 ip_ctx->errpos = ip_ctx->tokpos;
1643 msyslog(LOG_ERR, "line %d column %d %s",
1644 ip_ctx->errpos.nline, ip_ctx->errpos.ncol, msg);
1645 if (!lex_from_file()) {
1646 /* Save the error message in the correct buffer */
1647 retval = snprintf(remote_config.err_msg + remote_config.err_pos,
1648 MAXLINE - remote_config.err_pos,
1650 ip_ctx->errpos.ncol, msg);
1652 /* Increment the value of err_pos */
1654 remote_config.err_pos += retval;
1656 /* Increment the number of errors */
1657 ++remote_config.no_errors;
1663 * token_name - convert T_ token integers to text
1664 * example: token_name(T_Server) returns "T_Server"
1671 return yytname[YYTRANSLATE(token)];
1675 /* Initial Testing function -- ignore */
1677 int main(int argc, char *argv[])
1679 ip_file = FOPEN(argv[1], "r");
1681 fprintf(stderr, "ERROR!! Could not open file: %s\n", argv[1]);