File: | src/usr.sbin/dvmrpd/obj/parse.c |
Warning: | line 932, column 12 Use of zero-allocated memory |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | #include <stdlib.h> | |||
2 | #include <string.h> | |||
3 | #define YYBYACC1 1 | |||
4 | #define YYMAJOR1 1 | |||
5 | #define YYMINOR9 9 | |||
6 | #define YYLEXyylex() yylex() | |||
7 | #define YYEMPTY-1 -1 | |||
8 | #define yyclearin(yychar=(-1)) (yychar=(YYEMPTY-1)) | |||
9 | #define yyerrok(yyerrflag=0) (yyerrflag=0) | |||
10 | #define YYRECOVERING()(yyerrflag!=0) (yyerrflag!=0) | |||
11 | #define YYPREFIX"yy" "yy" | |||
12 | #line 25 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
13 | #include <sys/types.h> | |||
14 | #include <sys/time.h> | |||
15 | #include <sys/stat.h> | |||
16 | #include <sys/socket.h> | |||
17 | #include <netinet/in.h> | |||
18 | #include <arpa/inet.h> | |||
19 | #include <net/if.h> | |||
20 | #include <ctype.h> | |||
21 | #include <err.h> | |||
22 | #include <limits.h> | |||
23 | #include <unistd.h> | |||
24 | #include <errno(*__errno()).h> | |||
25 | #include <stdarg.h> | |||
26 | #include <stdio.h> | |||
27 | #include <string.h> | |||
28 | #include <syslog.h> | |||
29 | ||||
30 | #include "igmp.h" | |||
31 | #include "dvmrp.h" | |||
32 | #include "dvmrpd.h" | |||
33 | #include "dvmrpe.h" | |||
34 | #include "log.h" | |||
35 | ||||
36 | TAILQ_HEAD(files, file)struct files { struct file *tqh_first; struct file **tqh_last ; } files = TAILQ_HEAD_INITIALIZER(files){ ((void *)0), &(files).tqh_first }; | |||
37 | static struct file { | |||
38 | TAILQ_ENTRY(file)struct { struct file *tqe_next; struct file **tqe_prev; } entry; | |||
39 | FILE *stream; | |||
40 | char *name; | |||
41 | int lineno; | |||
42 | int errors; | |||
43 | } *file, *topfile; | |||
44 | struct file *pushfile(const char *, int); | |||
45 | int popfile(void); | |||
46 | int check_file_secrecy(int, const char *); | |||
47 | int yyparse(void); | |||
48 | int yylex(void); | |||
49 | int yyerror(const char *, ...) | |||
50 | __attribute__((__format__ (printf, 1, 2))) | |||
51 | __attribute__((__nonnull__ (1))); | |||
52 | int kw_cmp(const void *, const void *); | |||
53 | int lookup(char *); | |||
54 | int lgetc(int); | |||
55 | int lungetc(int); | |||
56 | int findeol(void); | |||
57 | ||||
58 | TAILQ_HEAD(symhead, sym)struct symhead { struct sym *tqh_first; struct sym **tqh_last ; } symhead = TAILQ_HEAD_INITIALIZER(symhead){ ((void *)0), &(symhead).tqh_first }; | |||
59 | struct sym { | |||
60 | TAILQ_ENTRY(sym)struct { struct sym *tqe_next; struct sym **tqe_prev; } entry; | |||
61 | int used; | |||
62 | int persist; | |||
63 | char *nam; | |||
64 | char *val; | |||
65 | }; | |||
66 | int symset(const char *, const char *, int); | |||
67 | char *symget(const char *); | |||
68 | ||||
69 | static struct dvmrpd_conf *conf; | |||
70 | char *start_state; | |||
71 | struct iface *iface = NULL((void *)0); | |||
72 | ||||
73 | static struct { | |||
74 | u_int32_t probe_interval; | |||
75 | u_int32_t query_interval; | |||
76 | u_int32_t query_resp_interval; | |||
77 | u_int32_t startup_query_interval; | |||
78 | u_int32_t startup_query_cnt; | |||
79 | u_int32_t last_member_query_interval; | |||
80 | u_int32_t last_member_query_cnt; | |||
81 | u_int32_t dead_interval; | |||
82 | u_int16_t metric; | |||
83 | u_int8_t robustness; | |||
84 | u_int8_t igmp_version; | |||
85 | } *defs, *grdefs, globaldefs, groupdefs, ifacedefs; | |||
86 | ||||
87 | void clear_config(struct dvmrpd_conf *xconf); | |||
88 | struct iface *conf_get_if(struct kif *); | |||
89 | struct iface *new_group(void); | |||
90 | ||||
91 | typedef struct { | |||
92 | union { | |||
93 | int64_t number; | |||
94 | char *string; | |||
95 | } v; | |||
96 | int lineno; | |||
97 | } YYSTYPE; | |||
98 | ||||
99 | #line 100 "parse.c" | |||
100 | #define INTERFACE257 257 | |||
101 | #define FIBUPDATE258 258 | |||
102 | #define GROUP259 259 | |||
103 | #define METRIC260 260 | |||
104 | #define PASSIVE261 261 | |||
105 | #define ROBUSTNESS262 262 | |||
106 | #define QUERYINTERVAL263 263 | |||
107 | #define QUERYRESPINTERVAL264 264 | |||
108 | #define STARTUPQUERYINTERVAL265 265 | |||
109 | #define STARTUPQUERYCNT266 266 | |||
110 | #define LASTMEMBERQUERYINTERVAL267 267 | |||
111 | #define LASTMEMBERQUERYCNT268 268 | |||
112 | #define IGMPVERSION269 269 | |||
113 | #define ERROR270 270 | |||
114 | #define STRING271 271 | |||
115 | #define NUMBER272 272 | |||
116 | #define YYERRCODE256 256 | |||
117 | const short yylhs[] = | |||
118 | { -1, | |||
119 | 0, 0, 0, 0, 0, 0, 0, 2, 2, 1, | |||
120 | 4, 3, 3, 7, 7, 7, 7, 7, 7, 7, | |||
121 | 7, 7, 8, 8, 9, 11, 5, 10, 10, 10, | |||
122 | 12, 12, 13, 13, 15, 6, 14, 14, 16, 16, | |||
123 | 16, | |||
124 | }; | |||
125 | const short yylen[] = | |||
126 | { 2, | |||
127 | 0, 2, 3, 3, 3, 3, 3, 2, 1, 1, | |||
128 | 3, 2, 1, 2, 2, 2, 2, 2, 2, 2, | |||
129 | 2, 2, 2, 0, 2, 0, 4, 4, 3, 0, | |||
130 | 2, 1, 2, 2, 0, 7, 2, 1, 2, 2, | |||
131 | 2, | |||
132 | }; | |||
133 | const short yydefred[] = | |||
134 | { 1, | |||
135 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
136 | 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, | |||
137 | 13, 7, 26, 10, 12, 0, 0, 16, 19, 17, | |||
138 | 18, 21, 20, 15, 14, 22, 0, 3, 4, 5, | |||
139 | 6, 0, 23, 0, 9, 0, 0, 27, 35, 8, | |||
140 | 0, 0, 0, 29, 0, 0, 32, 0, 0, 0, | |||
141 | 0, 38, 0, 33, 34, 28, 31, 41, 39, 40, | |||
142 | 36, 37, 25, | |||
143 | }; | |||
144 | const short yydgoto[] = | |||
145 | { 1, | |||
146 | 25, 46, 17, 18, 59, 20, 55, 27, 64, 48, | |||
147 | 42, 56, 57, 61, 52, 62, | |||
148 | }; | |||
149 | const short yysindex[] = | |||
150 | { 0, | |||
151 | -10, -4, -261, -260, 2, -259, -258, -257, -256, -254, | |||
152 | -253, -252, -251, -250, -37, 0, 15, 17, 18, 19, | |||
153 | 0, 0, 0, 0, 0, 2, -93, 0, 0, 0, | |||
154 | 0, 0, 0, 0, 0, 0, -239, 0, 0, 0, | |||
155 | 0, -90, 0, 2, 0, -237, 2, 0, 0, 0, | |||
156 | -84, -197, 25, 0, 25, -74, 0, 25, 25, 25, | |||
157 | -94, 0, 2, 0, 0, 0, 0, 0, 0, 0, | |||
158 | 0, 0, 0,}; | |||
159 | const short yyrindex[] = | |||
160 | { 0, | |||
161 | 0, 0, 0, 0, -87, 0, 0, 0, 0, 0, | |||
162 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
163 | 0, 0, 0, 0, 0, -122, 0, 0, 0, 0, | |||
164 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
165 | 0, 27, 0, -183, 0, 28, -64, 0, 0, 0, | |||
166 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
167 | 0, 0, -108, 0, 0, 0, 0, 0, 0, 0, | |||
168 | 0, 0, 0,}; | |||
169 | const short yygindex[] = | |||
170 | { 0, | |||
171 | 0, 0, 0, 0, 38, 0, 1, -21, -51, 0, | |||
172 | 0, 0, -16, 0, 0, -18, | |||
173 | }; | |||
174 | #define YYTABLESIZE261 261 | |||
175 | const short yytable[] = | |||
176 | { 16, | |||
177 | 24, 21, 24, 65, 43, 22, 68, 69, 70, 23, | |||
178 | 24, 26, 28, 29, 30, 31, 24, 32, 33, 34, | |||
179 | 35, 36, 49, 37, 38, 51, 39, 40, 41, 44, | |||
180 | 71, 45, 47, 50, 63, 24, 30, 11, 19, 67, | |||
181 | 54, 73, 72, 0, 0, 0, 0, 0, 0, 0, | |||
182 | 66, 0, 60, 0, 0, 0, 0, 0, 58, 3, | |||
183 | 24, 60, 6, 0, 7, 8, 9, 10, 11, 12, | |||
184 | 13, 14, 24, 24, 0, 0, 24, 0, 24, 24, | |||
185 | 24, 24, 24, 24, 24, 24, 0, 0, 0, 0, | |||
186 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
187 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
188 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
189 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
190 | 0, 0, 0, 24, 24, 0, 0, 24, 24, 24, | |||
191 | 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, | |||
192 | 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, | |||
193 | 24, 58, 3, 0, 0, 6, 0, 7, 8, 9, | |||
194 | 10, 11, 12, 13, 14, 6, 53, 7, 8, 9, | |||
195 | 10, 11, 12, 13, 14, 6, 53, 7, 8, 9, | |||
196 | 10, 11, 12, 13, 14, 24, 24, 24, 24, 24, | |||
197 | 24, 24, 24, 24, 24, 0, 0, 0, 0, 0, | |||
198 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
199 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
200 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
201 | 0, 0, 0, 0, 0, 2, 3, 4, 5, 6, | |||
202 | 0, 7, 8, 9, 10, 11, 12, 13, 14, 0, | |||
203 | 15, | |||
204 | }; | |||
205 | const short yycheck[] = | |||
206 | { 10, | |||
207 | 123, 1, 125, 55, 26, 10, 58, 59, 60, 271, | |||
208 | 271, 10, 272, 272, 272, 272, 125, 272, 272, 272, | |||
209 | 272, 272, 44, 61, 10, 47, 10, 10, 10, 123, | |||
210 | 125, 271, 123, 271, 10, 123, 10, 10, 1, 56, | |||
211 | 125, 63, 61, -1, -1, -1, -1, -1, -1, -1, | |||
212 | 125, -1, 52, -1, -1, -1, -1, -1, 256, 257, | |||
213 | 125, 61, 260, -1, 262, 263, 264, 265, 266, 267, | |||
214 | 268, 269, 256, 257, -1, -1, 260, -1, 262, 263, | |||
215 | 264, 265, 266, 267, 268, 269, -1, -1, -1, -1, | |||
216 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
217 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
218 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
219 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
220 | -1, -1, -1, 256, 257, -1, -1, 260, 261, 262, | |||
221 | 263, 264, 265, 266, 267, 268, 269, 256, 257, -1, | |||
222 | -1, 260, 261, 262, 263, 264, 265, 266, 267, 268, | |||
223 | 269, 256, 257, -1, -1, 260, -1, 262, 263, 264, | |||
224 | 265, 266, 267, 268, 269, 260, 261, 262, 263, 264, | |||
225 | 265, 266, 267, 268, 269, 260, 261, 262, 263, 264, | |||
226 | 265, 266, 267, 268, 269, 260, 261, 262, 263, 264, | |||
227 | 265, 266, 267, 268, 269, -1, -1, -1, -1, -1, | |||
228 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
229 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
230 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
231 | -1, -1, -1, -1, -1, 256, 257, 258, 259, 260, | |||
232 | -1, 262, 263, 264, 265, 266, 267, 268, 269, -1, | |||
233 | 271, | |||
234 | }; | |||
235 | #define YYFINAL1 1 | |||
236 | #ifndef YYDEBUG0 | |||
237 | #define YYDEBUG0 0 | |||
238 | #endif | |||
239 | #define YYMAXTOKEN272 272 | |||
240 | #if YYDEBUG0 | |||
241 | const char * const yyname[] = | |||
242 | { | |||
243 | "end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
244 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'='",0,0,0,0,0,0,0, | |||
245 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
246 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
247 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
248 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
249 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"INTERFACE", | |||
250 | "FIBUPDATE","GROUP","METRIC","PASSIVE","ROBUSTNESS","QUERYINTERVAL", | |||
251 | "QUERYRESPINTERVAL","STARTUPQUERYINTERVAL","STARTUPQUERYCNT", | |||
252 | "LASTMEMBERQUERYINTERVAL","LASTMEMBERQUERYCNT","IGMPVERSION","ERROR","STRING", | |||
253 | "NUMBER", | |||
254 | }; | |||
255 | const char * const yyrule[] = | |||
256 | {"$accept : grammar", | |||
257 | "grammar :", | |||
258 | "grammar : grammar '\\n'", | |||
259 | "grammar : grammar conf_main '\\n'", | |||
260 | "grammar : grammar varset '\\n'", | |||
261 | "grammar : grammar interface '\\n'", | |||
262 | "grammar : grammar group '\\n'", | |||
263 | "grammar : grammar error '\\n'", | |||
264 | "string : string STRING", | |||
265 | "string : STRING", | |||
266 | "yesno : STRING", | |||
267 | "varset : STRING '=' string", | |||
268 | "conf_main : FIBUPDATE yesno", | |||
269 | "conf_main : defaults", | |||
270 | "defaults : LASTMEMBERQUERYCNT NUMBER", | |||
271 | "defaults : LASTMEMBERQUERYINTERVAL NUMBER", | |||
272 | "defaults : METRIC NUMBER", | |||
273 | "defaults : QUERYINTERVAL NUMBER", | |||
274 | "defaults : QUERYRESPINTERVAL NUMBER", | |||
275 | "defaults : ROBUSTNESS NUMBER", | |||
276 | "defaults : STARTUPQUERYCNT NUMBER", | |||
277 | "defaults : STARTUPQUERYINTERVAL NUMBER", | |||
278 | "defaults : IGMPVERSION NUMBER", | |||
279 | "optnl : '\\n' optnl", | |||
280 | "optnl :", | |||
281 | "nl : '\\n' optnl", | |||
282 | "$$1 :", | |||
283 | "interface : INTERFACE STRING $$1 interface_block", | |||
284 | "interface_block : '{' optnl interfaceopts_l '}'", | |||
285 | "interface_block : '{' optnl '}'", | |||
286 | "interface_block :", | |||
287 | "interfaceopts_l : interfaceopts_l interfaceoptsl", | |||
288 | "interfaceopts_l : interfaceoptsl", | |||
289 | "interfaceoptsl : PASSIVE nl", | |||
290 | "interfaceoptsl : defaults nl", | |||
291 | "$$2 :", | |||
292 | "group : GROUP optnl '{' optnl $$2 groupopts_l '}'", | |||
293 | "groupopts_l : groupopts_l groupoptsl", | |||
294 | "groupopts_l : groupoptsl", | |||
295 | "groupoptsl : interface nl", | |||
296 | "groupoptsl : defaults nl", | |||
297 | "groupoptsl : error nl", | |||
298 | }; | |||
299 | #endif | |||
300 | #ifdef YYSTACKSIZE10000 | |||
301 | #undef YYMAXDEPTH10000 | |||
302 | #define YYMAXDEPTH10000 YYSTACKSIZE10000 | |||
303 | #else | |||
304 | #ifdef YYMAXDEPTH10000 | |||
305 | #define YYSTACKSIZE10000 YYMAXDEPTH10000 | |||
306 | #else | |||
307 | #define YYSTACKSIZE10000 10000 | |||
308 | #define YYMAXDEPTH10000 10000 | |||
309 | #endif | |||
310 | #endif | |||
311 | #define YYINITSTACKSIZE200 200 | |||
312 | /* LINTUSED */ | |||
313 | int yydebug; | |||
314 | int yynerrs; | |||
315 | int yyerrflag; | |||
316 | int yychar; | |||
317 | short *yyssp; | |||
318 | YYSTYPE *yyvsp; | |||
319 | YYSTYPE yyval; | |||
320 | YYSTYPE yylval; | |||
321 | short *yyss; | |||
322 | short *yysslim; | |||
323 | YYSTYPE *yyvs; | |||
324 | unsigned int yystacksize; | |||
325 | int yyparse(void); | |||
326 | #line 364 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
327 | ||||
328 | struct keywords { | |||
329 | const char *k_name; | |||
330 | int k_val; | |||
331 | }; | |||
332 | ||||
333 | int | |||
334 | yyerror(const char *fmt, ...) | |||
335 | { | |||
336 | va_list ap; | |||
337 | char *msg; | |||
338 | ||||
339 | file->errors++; | |||
340 | va_start(ap, fmt)__builtin_va_start(ap, fmt); | |||
341 | if (vasprintf(&msg, fmt, ap) == -1) | |||
342 | fatalx("yyerror vasprintf"); | |||
343 | va_end(ap)__builtin_va_end(ap); | |||
344 | logit(LOG_CRIT2, "%s:%d: %s", file->name, yylval.lineno, msg); | |||
345 | free(msg); | |||
346 | return (0); | |||
347 | } | |||
348 | ||||
349 | int | |||
350 | kw_cmp(const void *k, const void *e) | |||
351 | { | |||
352 | return (strcmp(k, ((const struct keywords *)e)->k_name)); | |||
353 | } | |||
354 | ||||
355 | int | |||
356 | lookup(char *s) | |||
357 | { | |||
358 | /* this has to be sorted always */ | |||
359 | static const struct keywords keywords[] = { | |||
360 | {"fib-update", FIBUPDATE258}, | |||
361 | {"group", GROUP259}, | |||
362 | {"igmp-version", IGMPVERSION269}, | |||
363 | {"interface", INTERFACE257}, | |||
364 | {"last-member-query-count", LASTMEMBERQUERYCNT268}, | |||
365 | {"last-member-query-interval", LASTMEMBERQUERYINTERVAL267}, | |||
366 | {"metric", METRIC260}, | |||
367 | {"passive", PASSIVE261}, | |||
368 | {"query-interval", QUERYINTERVAL263}, | |||
369 | {"query-response-interval", QUERYRESPINTERVAL264}, | |||
370 | {"robustness", ROBUSTNESS262}, | |||
371 | {"startup-query-count", STARTUPQUERYCNT266}, | |||
372 | {"startup-query-interval", STARTUPQUERYINTERVAL265} | |||
373 | }; | |||
374 | const struct keywords *p; | |||
375 | ||||
376 | p = bsearch(s, keywords, sizeof(keywords)/sizeof(keywords[0]), | |||
377 | sizeof(keywords[0]), kw_cmp); | |||
378 | ||||
379 | if (p) | |||
380 | return (p->k_val); | |||
381 | else | |||
382 | return (STRING271); | |||
383 | } | |||
384 | ||||
385 | #define MAXPUSHBACK128 128 | |||
386 | ||||
387 | char *parsebuf; | |||
388 | int parseindex; | |||
389 | char pushback_buffer[MAXPUSHBACK128]; | |||
390 | int pushback_index = 0; | |||
391 | ||||
392 | int | |||
393 | lgetc(int quotec) | |||
394 | { | |||
395 | int c, next; | |||
396 | ||||
397 | if (parsebuf) { | |||
398 | /* Read character from the parsebuffer instead of input. */ | |||
399 | if (parseindex >= 0) { | |||
400 | c = (unsigned char)parsebuf[parseindex++]; | |||
401 | if (c != '\0') | |||
402 | return (c); | |||
403 | parsebuf = NULL((void *)0); | |||
404 | } else | |||
405 | parseindex++; | |||
406 | } | |||
407 | ||||
408 | if (pushback_index) | |||
409 | return ((unsigned char)pushback_buffer[--pushback_index]); | |||
410 | ||||
411 | if (quotec) { | |||
412 | if ((c = getc(file->stream)(!__isthreaded ? (--(file->stream)->_r < 0 ? __srget (file->stream) : (int)(*(file->stream)->_p++)) : (getc )(file->stream))) == EOF(-1)) { | |||
413 | yyerror("reached end of file while parsing " | |||
414 | "quoted string"); | |||
415 | if (file == topfile || popfile() == EOF(-1)) | |||
416 | return (EOF(-1)); | |||
417 | return (quotec); | |||
418 | } | |||
419 | return (c); | |||
420 | } | |||
421 | ||||
422 | while ((c = getc(file->stream)(!__isthreaded ? (--(file->stream)->_r < 0 ? __srget (file->stream) : (int)(*(file->stream)->_p++)) : (getc )(file->stream))) == '\\') { | |||
423 | next = getc(file->stream)(!__isthreaded ? (--(file->stream)->_r < 0 ? __srget (file->stream) : (int)(*(file->stream)->_p++)) : (getc )(file->stream)); | |||
424 | if (next != '\n') { | |||
425 | c = next; | |||
426 | break; | |||
427 | } | |||
428 | yylval.lineno = file->lineno; | |||
429 | file->lineno++; | |||
430 | } | |||
431 | ||||
432 | while (c == EOF(-1)) { | |||
433 | if (file == topfile || popfile() == EOF(-1)) | |||
434 | return (EOF(-1)); | |||
435 | c = getc(file->stream)(!__isthreaded ? (--(file->stream)->_r < 0 ? __srget (file->stream) : (int)(*(file->stream)->_p++)) : (getc )(file->stream)); | |||
436 | } | |||
437 | return (c); | |||
438 | } | |||
439 | ||||
440 | int | |||
441 | lungetc(int c) | |||
442 | { | |||
443 | if (c == EOF(-1)) | |||
444 | return (EOF(-1)); | |||
445 | if (parsebuf) { | |||
446 | parseindex--; | |||
447 | if (parseindex >= 0) | |||
448 | return (c); | |||
449 | } | |||
450 | if (pushback_index + 1 >= MAXPUSHBACK128) | |||
451 | return (EOF(-1)); | |||
452 | pushback_buffer[pushback_index++] = c; | |||
453 | return (c); | |||
454 | } | |||
455 | ||||
456 | int | |||
457 | findeol(void) | |||
458 | { | |||
459 | int c; | |||
460 | ||||
461 | parsebuf = NULL((void *)0); | |||
462 | ||||
463 | /* skip to either EOF or the first real EOL */ | |||
464 | while (1) { | |||
465 | if (pushback_index) | |||
466 | c = (unsigned char)pushback_buffer[--pushback_index]; | |||
467 | else | |||
468 | c = lgetc(0); | |||
469 | if (c == '\n') { | |||
470 | file->lineno++; | |||
471 | break; | |||
472 | } | |||
473 | if (c == EOF(-1)) | |||
474 | break; | |||
475 | } | |||
476 | return (ERROR270); | |||
477 | } | |||
478 | ||||
479 | int | |||
480 | yylex(void) | |||
481 | { | |||
482 | char buf[8096]; | |||
483 | char *p, *val; | |||
484 | int quotec, next, c; | |||
485 | int token; | |||
486 | ||||
487 | top: | |||
488 | p = buf; | |||
489 | while ((c = lgetc(0)) == ' ' || c == '\t') | |||
490 | ; /* nothing */ | |||
491 | ||||
492 | yylval.lineno = file->lineno; | |||
493 | if (c == '#') | |||
494 | while ((c = lgetc(0)) != '\n' && c != EOF(-1)) | |||
495 | ; /* nothing */ | |||
496 | if (c == '$' && parsebuf == NULL((void *)0)) { | |||
497 | while (1) { | |||
498 | if ((c = lgetc(0)) == EOF(-1)) | |||
499 | return (0); | |||
500 | ||||
501 | if (p + 1 >= buf + sizeof(buf) - 1) { | |||
502 | yyerror("string too long"); | |||
503 | return (findeol()); | |||
504 | } | |||
505 | if (isalnum(c) || c == '_') { | |||
506 | *p++ = c; | |||
507 | continue; | |||
508 | } | |||
509 | *p = '\0'; | |||
510 | lungetc(c); | |||
511 | break; | |||
512 | } | |||
513 | val = symget(buf); | |||
514 | if (val == NULL((void *)0)) { | |||
515 | yyerror("macro '%s' not defined", buf); | |||
516 | return (findeol()); | |||
517 | } | |||
518 | parsebuf = val; | |||
519 | parseindex = 0; | |||
520 | goto top; | |||
521 | } | |||
522 | ||||
523 | switch (c) { | |||
524 | case '\'': | |||
525 | case '"': | |||
526 | quotec = c; | |||
527 | while (1) { | |||
528 | if ((c = lgetc(quotec)) == EOF(-1)) | |||
529 | return (0); | |||
530 | if (c == '\n') { | |||
531 | file->lineno++; | |||
532 | continue; | |||
533 | } else if (c == '\\') { | |||
534 | if ((next = lgetc(quotec)) == EOF(-1)) | |||
535 | return (0); | |||
536 | if (next == quotec || next == ' ' || | |||
537 | next == '\t') | |||
538 | c = next; | |||
539 | else if (next == '\n') { | |||
540 | file->lineno++; | |||
541 | continue; | |||
542 | } else | |||
543 | lungetc(next); | |||
544 | } else if (c == quotec) { | |||
545 | *p = '\0'; | |||
546 | break; | |||
547 | } else if (c == '\0') { | |||
548 | yyerror("syntax error"); | |||
549 | return (findeol()); | |||
550 | } | |||
551 | if (p + 1 >= buf + sizeof(buf) - 1) { | |||
552 | yyerror("string too long"); | |||
553 | return (findeol()); | |||
554 | } | |||
555 | *p++ = c; | |||
556 | } | |||
557 | yylval.v.string = strdup(buf); | |||
558 | if (yylval.v.string == NULL((void *)0)) | |||
559 | err(1, "%s", __func__); | |||
560 | return (STRING271); | |||
561 | } | |||
562 | ||||
563 | #define allowed_to_end_number(x)(isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=') \ | |||
564 | (isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=') | |||
565 | ||||
566 | if (c == '-' || isdigit(c)) { | |||
567 | do { | |||
568 | *p++ = c; | |||
569 | if ((size_t)(p-buf) >= sizeof(buf)) { | |||
570 | yyerror("string too long"); | |||
571 | return (findeol()); | |||
572 | } | |||
573 | } while ((c = lgetc(0)) != EOF(-1) && isdigit(c)); | |||
574 | lungetc(c); | |||
575 | if (p == buf + 1 && buf[0] == '-') | |||
576 | goto nodigits; | |||
577 | if (c == EOF(-1) || allowed_to_end_number(c)(isspace(c) || c == ')' || c ==',' || c == '/' || c == '}' || c == '=')) { | |||
578 | const char *errstr = NULL((void *)0); | |||
579 | ||||
580 | *p = '\0'; | |||
581 | yylval.v.number = strtonum(buf, LLONG_MIN(-9223372036854775807LL -1LL), | |||
582 | LLONG_MAX9223372036854775807LL, &errstr); | |||
583 | if (errstr) { | |||
584 | yyerror("\"%s\" invalid number: %s", | |||
585 | buf, errstr); | |||
586 | return (findeol()); | |||
587 | } | |||
588 | return (NUMBER272); | |||
589 | } else { | |||
590 | nodigits: | |||
591 | while (p > buf + 1) | |||
592 | lungetc((unsigned char)*--p); | |||
593 | c = (unsigned char)*--p; | |||
594 | if (c == '-') | |||
595 | return (c); | |||
596 | } | |||
597 | } | |||
598 | ||||
599 | #define allowed_in_string(x)(isalnum(x) || (ispunct(x) && x != '(' && x != ')' && x != '{' && x != '}' && x != '!' && x != '=' && x != '#' && x != ',') ) \ | |||
600 | (isalnum(x) || (ispunct(x) && x != '(' && x != ')' && \ | |||
601 | x != '{' && x != '}' && \ | |||
602 | x != '!' && x != '=' && x != '#' && \ | |||
603 | x != ',')) | |||
604 | ||||
605 | if (isalnum(c) || c == ':' || c == '_') { | |||
606 | do { | |||
607 | *p++ = c; | |||
608 | if ((size_t)(p-buf) >= sizeof(buf)) { | |||
609 | yyerror("string too long"); | |||
610 | return (findeol()); | |||
611 | } | |||
612 | } while ((c = lgetc(0)) != EOF(-1) && (allowed_in_string(c)(isalnum(c) || (ispunct(c) && c != '(' && c != ')' && c != '{' && c != '}' && c != '!' && c != '=' && c != '#' && c != ',') ))); | |||
613 | lungetc(c); | |||
614 | *p = '\0'; | |||
615 | if ((token = lookup(buf)) == STRING271) | |||
616 | if ((yylval.v.string = strdup(buf)) == NULL((void *)0)) | |||
617 | err(1, "%s", __func__); | |||
618 | return (token); | |||
619 | } | |||
620 | if (c == '\n') { | |||
621 | yylval.lineno = file->lineno; | |||
622 | file->lineno++; | |||
623 | } | |||
624 | if (c == EOF(-1)) | |||
625 | return (0); | |||
626 | return (c); | |||
627 | } | |||
628 | ||||
629 | int | |||
630 | check_file_secrecy(int fd, const char *fname) | |||
631 | { | |||
632 | struct stat st; | |||
633 | ||||
634 | if (fstat(fd, &st)) { | |||
635 | log_warn("cannot stat %s", fname); | |||
636 | return (-1); | |||
637 | } | |||
638 | if (st.st_uid != 0 && st.st_uid != getuid()) { | |||
639 | log_warnx("%s: owner not root or current user", fname); | |||
640 | return (-1); | |||
641 | } | |||
642 | if (st.st_mode & (S_IWGRP0000020 | S_IXGRP0000010 | S_IRWXO0000007)) { | |||
643 | log_warnx("%s: group writable or world read/writable", fname); | |||
644 | return (-1); | |||
645 | } | |||
646 | return (0); | |||
647 | } | |||
648 | ||||
649 | struct file * | |||
650 | pushfile(const char *name, int secret) | |||
651 | { | |||
652 | struct file *nfile; | |||
653 | ||||
654 | if ((nfile = calloc(1, sizeof(struct file))) == NULL((void *)0)) { | |||
655 | log_warn("%s", __func__); | |||
656 | return (NULL((void *)0)); | |||
657 | } | |||
658 | if ((nfile->name = strdup(name)) == NULL((void *)0)) { | |||
659 | log_warn("%s", __func__); | |||
660 | free(nfile); | |||
661 | return (NULL((void *)0)); | |||
662 | } | |||
663 | if ((nfile->stream = fopen(nfile->name, "r")) == NULL((void *)0)) { | |||
664 | log_warn("%s: %s", __func__, nfile->name); | |||
665 | free(nfile->name); | |||
666 | free(nfile); | |||
667 | return (NULL((void *)0)); | |||
668 | } else if (secret && | |||
669 | check_file_secrecy(fileno(nfile->stream)(!__isthreaded ? ((nfile->stream)->_file) : (fileno)(nfile ->stream)), nfile->name)) { | |||
670 | fclose(nfile->stream); | |||
671 | free(nfile->name); | |||
672 | free(nfile); | |||
673 | return (NULL((void *)0)); | |||
674 | } | |||
675 | nfile->lineno = 1; | |||
676 | TAILQ_INSERT_TAIL(&files, nfile, entry)do { (nfile)->entry.tqe_next = ((void *)0); (nfile)->entry .tqe_prev = (&files)->tqh_last; *(&files)->tqh_last = (nfile); (&files)->tqh_last = &(nfile)->entry .tqe_next; } while (0); | |||
677 | return (nfile); | |||
678 | } | |||
679 | ||||
680 | int | |||
681 | popfile(void) | |||
682 | { | |||
683 | struct file *prev; | |||
684 | ||||
685 | if ((prev = TAILQ_PREV(file, files, entry)(*(((struct files *)((file)->entry.tqe_prev))->tqh_last ))) != NULL((void *)0)) | |||
686 | prev->errors += file->errors; | |||
687 | ||||
688 | TAILQ_REMOVE(&files, file, entry)do { if (((file)->entry.tqe_next) != ((void *)0)) (file)-> entry.tqe_next->entry.tqe_prev = (file)->entry.tqe_prev ; else (&files)->tqh_last = (file)->entry.tqe_prev; *(file)->entry.tqe_prev = (file)->entry.tqe_next; ; ; } while (0); | |||
689 | fclose(file->stream); | |||
690 | free(file->name); | |||
691 | free(file); | |||
692 | file = prev; | |||
693 | return (file ? 0 : EOF(-1)); | |||
694 | } | |||
695 | ||||
696 | struct dvmrpd_conf * | |||
697 | parse_config(char *filename, int opts) | |||
698 | { | |||
699 | int errors = 0; | |||
700 | struct sym *sym, *next; | |||
701 | struct timeval now; | |||
702 | ||||
703 | if ((conf = calloc(1, sizeof(struct dvmrpd_conf))) == NULL((void *)0)) { | |||
704 | errx(1, "parse_config calloc"); | |||
705 | return (NULL((void *)0)); | |||
706 | } | |||
707 | ||||
708 | defs = &globaldefs; | |||
709 | defs->probe_interval = DEFAULT_PROBE_INTERVAL10; | |||
710 | defs->last_member_query_cnt = DEFAULT_LAST_MEMBER_QUERY_CNT2; | |||
711 | defs->last_member_query_interval = DEFAULT_LAST_MEMBER_QUERY_INTERVAL10; | |||
712 | defs->metric = DEFAULT_METRIC1; | |||
713 | defs->query_interval = DEFAULT_QUERY_INTERVAL125; | |||
714 | defs->query_resp_interval = DEFAULT_QUERY_RESP_INTERVAL100; | |||
715 | defs->robustness = DEFAULT_ROBUSTNESS2; | |||
716 | defs->startup_query_cnt = DEFAULT_STARTUP_QUERY_CNT2; | |||
717 | defs->startup_query_interval = DEFAULT_STARTUP_QUERY_INTERVAL125 / 4; | |||
718 | defs->igmp_version = DEFAULT_IGMP_VERSION2; | |||
719 | defs->dead_interval = NBR_TMOUT35; | |||
720 | ||||
721 | if ((file = pushfile(filename, 1)) == NULL((void *)0)) { | |||
722 | free(conf); | |||
723 | return (NULL((void *)0)); | |||
724 | } | |||
725 | topfile = file; | |||
726 | ||||
727 | gettimeofday(&now, NULL((void *)0)); | |||
728 | conf->gen_id = (u_int32_t)now.tv_sec; /* for a while after 2038 */ | |||
729 | conf->opts = opts; | |||
730 | ||||
731 | yyparse(); | |||
732 | errors = file->errors; | |||
733 | popfile(); | |||
734 | ||||
735 | /* Free macros and check which have not been used. */ | |||
736 | TAILQ_FOREACH_SAFE(sym, &symhead, entry, next)for ((sym) = ((&symhead)->tqh_first); (sym) != ((void * )0) && ((next) = ((sym)->entry.tqe_next), 1); (sym ) = (next)) { | |||
737 | if ((conf->opts & DVMRPD_OPT_VERBOSE20x00000002) && !sym->used) | |||
738 | fprintf(stderr(&__sF[2]), "warning: macro '%s' not " | |||
739 | "used\n", sym->nam); | |||
740 | if (!sym->persist) { | |||
741 | free(sym->nam); | |||
742 | free(sym->val); | |||
743 | TAILQ_REMOVE(&symhead, sym, entry)do { if (((sym)->entry.tqe_next) != ((void *)0)) (sym)-> entry.tqe_next->entry.tqe_prev = (sym)->entry.tqe_prev; else (&symhead)->tqh_last = (sym)->entry.tqe_prev; *(sym)->entry.tqe_prev = (sym)->entry.tqe_next; ; ; } while (0); | |||
744 | free(sym); | |||
745 | } | |||
746 | } | |||
747 | ||||
748 | if (errors) { | |||
749 | clear_config(conf); | |||
750 | return (NULL((void *)0)); | |||
751 | } | |||
752 | ||||
753 | return (conf); | |||
754 | } | |||
755 | ||||
756 | int | |||
757 | symset(const char *nam, const char *val, int persist) | |||
758 | { | |||
759 | struct sym *sym; | |||
760 | ||||
761 | TAILQ_FOREACH(sym, &symhead, entry)for((sym) = ((&symhead)->tqh_first); (sym) != ((void * )0); (sym) = ((sym)->entry.tqe_next)) { | |||
762 | if (strcmp(nam, sym->nam) == 0) | |||
763 | break; | |||
764 | } | |||
765 | ||||
766 | if (sym != NULL((void *)0)) { | |||
767 | if (sym->persist == 1) | |||
768 | return (0); | |||
769 | else { | |||
770 | free(sym->nam); | |||
771 | free(sym->val); | |||
772 | TAILQ_REMOVE(&symhead, sym, entry)do { if (((sym)->entry.tqe_next) != ((void *)0)) (sym)-> entry.tqe_next->entry.tqe_prev = (sym)->entry.tqe_prev; else (&symhead)->tqh_last = (sym)->entry.tqe_prev; *(sym)->entry.tqe_prev = (sym)->entry.tqe_next; ; ; } while (0); | |||
773 | free(sym); | |||
774 | } | |||
775 | } | |||
776 | if ((sym = calloc(1, sizeof(*sym))) == NULL((void *)0)) | |||
777 | return (-1); | |||
778 | ||||
779 | sym->nam = strdup(nam); | |||
780 | if (sym->nam == NULL((void *)0)) { | |||
781 | free(sym); | |||
782 | return (-1); | |||
783 | } | |||
784 | sym->val = strdup(val); | |||
785 | if (sym->val == NULL((void *)0)) { | |||
786 | free(sym->nam); | |||
787 | free(sym); | |||
788 | return (-1); | |||
789 | } | |||
790 | sym->used = 0; | |||
791 | sym->persist = persist; | |||
792 | TAILQ_INSERT_TAIL(&symhead, sym, entry)do { (sym)->entry.tqe_next = ((void *)0); (sym)->entry. tqe_prev = (&symhead)->tqh_last; *(&symhead)->tqh_last = (sym); (&symhead)->tqh_last = &(sym)->entry. tqe_next; } while (0); | |||
793 | return (0); | |||
794 | } | |||
795 | ||||
796 | int | |||
797 | cmdline_symset(char *s) | |||
798 | { | |||
799 | char *sym, *val; | |||
800 | int ret; | |||
801 | ||||
802 | if ((val = strrchr(s, '=')) == NULL((void *)0)) | |||
803 | return (-1); | |||
804 | sym = strndup(s, val - s); | |||
805 | if (sym == NULL((void *)0)) | |||
806 | errx(1, "%s: strndup", __func__); | |||
807 | ret = symset(sym, val + 1, 1); | |||
808 | free(sym); | |||
809 | ||||
810 | return (ret); | |||
811 | } | |||
812 | ||||
813 | char * | |||
814 | symget(const char *nam) | |||
815 | { | |||
816 | struct sym *sym; | |||
817 | ||||
818 | TAILQ_FOREACH(sym, &symhead, entry)for((sym) = ((&symhead)->tqh_first); (sym) != ((void * )0); (sym) = ((sym)->entry.tqe_next)) { | |||
819 | if (strcmp(nam, sym->nam) == 0) { | |||
820 | sym->used = 1; | |||
821 | return (sym->val); | |||
822 | } | |||
823 | } | |||
824 | return (NULL((void *)0)); | |||
825 | } | |||
826 | ||||
827 | struct iface * | |||
828 | conf_get_if(struct kif *kif) | |||
829 | { | |||
830 | struct iface *i; | |||
831 | ||||
832 | if (kif->ifindex >= MAXVIFS32) { | |||
833 | yyerror("interface %s index too large", kif->ifname); | |||
834 | return (NULL((void *)0)); | |||
835 | } | |||
836 | ||||
837 | LIST_FOREACH(i, &conf->iface_list, entry)for((i) = ((&conf->iface_list)->lh_first); (i)!= (( void *)0); (i) = ((i)->entry.le_next)) | |||
838 | if (i->ifindex == kif->ifindex) { | |||
839 | yyerror("interface %s already configured", | |||
840 | kif->ifname); | |||
841 | return (NULL((void *)0)); | |||
842 | } | |||
843 | ||||
844 | i = if_new(kif); | |||
845 | i->passive = 0; | |||
846 | i->recv_query_resp_interval = DEFAULT_QUERY_RESP_INTERVAL100; | |||
847 | ||||
848 | return (i); | |||
849 | } | |||
850 | ||||
851 | void | |||
852 | clear_config(struct dvmrpd_conf *xconf) | |||
853 | { | |||
854 | /* XXX clear conf */ | |||
855 | /* ... */ | |||
856 | } | |||
857 | #line 850 "parse.c" | |||
858 | /* allocate initial stack or double stack size, up to YYMAXDEPTH */ | |||
859 | static int yygrowstack(void) | |||
860 | { | |||
861 | unsigned int newsize; | |||
862 | long sslen; | |||
863 | short *newss; | |||
864 | YYSTYPE *newvs; | |||
865 | ||||
866 | if ((newsize = yystacksize) == 0) | |||
867 | newsize = YYINITSTACKSIZE200; | |||
868 | else if (newsize >= YYMAXDEPTH10000) | |||
869 | return -1; | |||
870 | else if ((newsize *= 2) > YYMAXDEPTH10000) | |||
871 | newsize = YYMAXDEPTH10000; | |||
872 | sslen = yyssp - yyss; | |||
873 | #ifdef SIZE_MAX0xffffffffffffffffUL | |||
874 | #define YY_SIZE_MAX0xffffffffffffffffUL SIZE_MAX0xffffffffffffffffUL | |||
875 | #else | |||
876 | #define YY_SIZE_MAX0xffffffffffffffffUL 0xffffffffU | |||
877 | #endif | |||
878 | if (newsize && YY_SIZE_MAX0xffffffffffffffffUL / newsize < sizeof *newss) | |||
879 | goto bail; | |||
880 | newss = (short *)realloc(yyss, newsize * sizeof *newss); | |||
881 | if (newss == NULL((void *)0)) | |||
882 | goto bail; | |||
883 | yyss = newss; | |||
884 | yyssp = newss + sslen; | |||
885 | if (newsize
| |||
886 | goto bail; | |||
887 | newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs); | |||
888 | if (newvs == NULL((void *)0)) | |||
889 | goto bail; | |||
890 | yyvs = newvs; | |||
891 | yyvsp = newvs + sslen; | |||
892 | yystacksize = newsize; | |||
893 | yysslim = yyss + newsize - 1; | |||
894 | return 0; | |||
895 | bail: | |||
896 | if (yyss) | |||
897 | free(yyss); | |||
898 | if (yyvs) | |||
899 | free(yyvs); | |||
900 | yyss = yyssp = NULL((void *)0); | |||
901 | yyvs = yyvsp = NULL((void *)0); | |||
902 | yystacksize = 0; | |||
903 | return -1; | |||
904 | } | |||
905 | ||||
906 | #define YYABORTgoto yyabort goto yyabort | |||
907 | #define YYREJECTgoto yyabort goto yyabort | |||
908 | #define YYACCEPTgoto yyaccept goto yyaccept | |||
909 | #define YYERRORgoto yyerrlab goto yyerrlab | |||
910 | int | |||
911 | yyparse(void) | |||
912 | { | |||
913 | int yym, yyn, yystate; | |||
914 | #if YYDEBUG0 | |||
915 | const char *yys; | |||
916 | ||||
917 | if ((yys = getenv("YYDEBUG"))) | |||
918 | { | |||
919 | yyn = *yys; | |||
920 | if (yyn >= '0' && yyn <= '9') | |||
921 | yydebug = yyn - '0'; | |||
922 | } | |||
923 | #endif /* YYDEBUG */ | |||
924 | ||||
925 | yynerrs = 0; | |||
926 | yyerrflag = 0; | |||
927 | yychar = (-1); | |||
928 | ||||
929 | if (yyss == NULL((void *)0) && yygrowstack()) goto yyoverflow; | |||
| ||||
930 | yyssp = yyss; | |||
931 | yyvsp = yyvs; | |||
932 | *yyssp = yystate = 0; | |||
| ||||
933 | ||||
934 | yyloop: | |||
935 | if ((yyn = yydefred[yystate]) != 0) goto yyreduce; | |||
936 | if (yychar < 0) | |||
937 | { | |||
938 | if ((yychar = yylex()) < 0) yychar = 0; | |||
939 | #if YYDEBUG0 | |||
940 | if (yydebug) | |||
941 | { | |||
942 | yys = 0; | |||
943 | if (yychar <= YYMAXTOKEN272) yys = yyname[yychar]; | |||
944 | if (!yys) yys = "illegal-symbol"; | |||
945 | printf("%sdebug: state %d, reading %d (%s)\n", | |||
946 | YYPREFIX"yy", yystate, yychar, yys); | |||
947 | } | |||
948 | #endif | |||
949 | } | |||
950 | if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && | |||
951 | yyn <= YYTABLESIZE261 && yycheck[yyn] == yychar) | |||
952 | { | |||
953 | #if YYDEBUG0 | |||
954 | if (yydebug) | |||
955 | printf("%sdebug: state %d, shifting to state %d\n", | |||
956 | YYPREFIX"yy", yystate, yytable[yyn]); | |||
957 | #endif | |||
958 | if (yyssp >= yysslim && yygrowstack()) | |||
959 | { | |||
960 | goto yyoverflow; | |||
961 | } | |||
962 | *++yyssp = yystate = yytable[yyn]; | |||
963 | *++yyvsp = yylval; | |||
964 | yychar = (-1); | |||
965 | if (yyerrflag > 0) --yyerrflag; | |||
966 | goto yyloop; | |||
967 | } | |||
968 | if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && | |||
969 | yyn <= YYTABLESIZE261 && yycheck[yyn] == yychar) | |||
970 | { | |||
971 | yyn = yytable[yyn]; | |||
972 | goto yyreduce; | |||
973 | } | |||
974 | if (yyerrflag) goto yyinrecovery; | |||
975 | #if defined(__GNUC__4) | |||
976 | goto yynewerror; | |||
977 | #endif | |||
978 | yynewerror: | |||
979 | yyerror("syntax error"); | |||
980 | #if defined(__GNUC__4) | |||
981 | goto yyerrlab; | |||
982 | #endif | |||
983 | yyerrlab: | |||
984 | ++yynerrs; | |||
985 | yyinrecovery: | |||
986 | if (yyerrflag < 3) | |||
987 | { | |||
988 | yyerrflag = 3; | |||
989 | for (;;) | |||
990 | { | |||
991 | if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE256) >= 0 && | |||
992 | yyn <= YYTABLESIZE261 && yycheck[yyn] == YYERRCODE256) | |||
993 | { | |||
994 | #if YYDEBUG0 | |||
995 | if (yydebug) | |||
996 | printf("%sdebug: state %d, error recovery shifting\ | |||
997 | to state %d\n", YYPREFIX"yy", *yyssp, yytable[yyn]); | |||
998 | #endif | |||
999 | if (yyssp >= yysslim && yygrowstack()) | |||
1000 | { | |||
1001 | goto yyoverflow; | |||
1002 | } | |||
1003 | *++yyssp = yystate = yytable[yyn]; | |||
1004 | *++yyvsp = yylval; | |||
1005 | goto yyloop; | |||
1006 | } | |||
1007 | else | |||
1008 | { | |||
1009 | #if YYDEBUG0 | |||
1010 | if (yydebug) | |||
1011 | printf("%sdebug: error recovery discarding state %d\n", | |||
1012 | YYPREFIX"yy", *yyssp); | |||
1013 | #endif | |||
1014 | if (yyssp <= yyss) goto yyabort; | |||
1015 | --yyssp; | |||
1016 | --yyvsp; | |||
1017 | } | |||
1018 | } | |||
1019 | } | |||
1020 | else | |||
1021 | { | |||
1022 | if (yychar == 0) goto yyabort; | |||
1023 | #if YYDEBUG0 | |||
1024 | if (yydebug) | |||
1025 | { | |||
1026 | yys = 0; | |||
1027 | if (yychar <= YYMAXTOKEN272) yys = yyname[yychar]; | |||
1028 | if (!yys) yys = "illegal-symbol"; | |||
1029 | printf("%sdebug: state %d, error recovery discards token %d (%s)\n", | |||
1030 | YYPREFIX"yy", yystate, yychar, yys); | |||
1031 | } | |||
1032 | #endif | |||
1033 | yychar = (-1); | |||
1034 | goto yyloop; | |||
1035 | } | |||
1036 | yyreduce: | |||
1037 | #if YYDEBUG0 | |||
1038 | if (yydebug) | |||
1039 | printf("%sdebug: state %d, reducing by rule %d (%s)\n", | |||
1040 | YYPREFIX"yy", yystate, yyn, yyrule[yyn]); | |||
1041 | #endif | |||
1042 | yym = yylen[yyn]; | |||
1043 | if (yym) | |||
1044 | yyval = yyvsp[1-yym]; | |||
1045 | else | |||
1046 | memset(&yyval, 0, sizeof yyval); | |||
1047 | switch (yyn) | |||
1048 | { | |||
1049 | case 7: | |||
1050 | #line 134 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1051 | { file->errors++; } | |||
1052 | break; | |||
1053 | case 8: | |||
1054 | #line 137 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1055 | { | |||
1056 | if (asprintf(&yyval.v.string, "%s %s", yyvsp[-1].v.string, yyvsp[0].v.string) == -1) { | |||
1057 | free(yyvsp[-1].v.string); | |||
1058 | free(yyvsp[0].v.string); | |||
1059 | yyerror("string: asprintf"); | |||
1060 | YYERRORgoto yyerrlab; | |||
1061 | } | |||
1062 | free(yyvsp[-1].v.string); | |||
1063 | free(yyvsp[0].v.string); | |||
1064 | } | |||
1065 | break; | |||
1066 | case 10: | |||
1067 | #line 150 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1068 | { | |||
1069 | if (!strcmp(yyvsp[0].v.string, "yes")) | |||
1070 | yyval.v.number = 1; | |||
1071 | else if (!strcmp(yyvsp[0].v.string, "no")) | |||
1072 | yyval.v.number = 0; | |||
1073 | else { | |||
1074 | yyerror("syntax error, " | |||
1075 | "either yes or no expected"); | |||
1076 | free(yyvsp[0].v.string); | |||
1077 | YYERRORgoto yyerrlab; | |||
1078 | } | |||
1079 | free(yyvsp[0].v.string); | |||
1080 | } | |||
1081 | break; | |||
1082 | case 11: | |||
1083 | #line 165 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1084 | { | |||
1085 | char *s = yyvsp[-2].v.string; | |||
1086 | if (conf->opts & DVMRPD_OPT_VERBOSE0x00000001) | |||
1087 | printf("%s = \"%s\"\n", yyvsp[-2].v.string, yyvsp[0].v.string); | |||
1088 | while (*s++) { | |||
1089 | if (isspace((unsigned char)*s)) { | |||
1090 | yyerror("macro name cannot contain " | |||
1091 | "whitespace"); | |||
1092 | free(yyvsp[-2].v.string); | |||
1093 | free(yyvsp[0].v.string); | |||
1094 | YYERRORgoto yyerrlab; | |||
1095 | } | |||
1096 | } | |||
1097 | if (symset(yyvsp[-2].v.string, yyvsp[0].v.string, 0) == -1) | |||
1098 | fatal("cannot store variable"); | |||
1099 | free(yyvsp[-2].v.string); | |||
1100 | free(yyvsp[0].v.string); | |||
1101 | } | |||
1102 | break; | |||
1103 | case 12: | |||
1104 | #line 185 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1105 | { | |||
1106 | if (yyvsp[0].v.number == 0) | |||
1107 | conf->flags |= DVMRPD_FLAG_NO_FIB_UPDATE0x0001; | |||
1108 | else | |||
1109 | conf->flags &= ~DVMRPD_FLAG_NO_FIB_UPDATE0x0001; | |||
1110 | } | |||
1111 | break; | |||
1112 | case 14: | |||
1113 | #line 194 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1114 | { | |||
1115 | if (yyvsp[0].v.number < MIN_LAST_MEMBER_QUERY_CNT1 || | |||
1116 | yyvsp[0].v.number > MAX_LAST_MEMBER_QUERY_CNT255) { | |||
1117 | yyerror("last-member-query-count out of " | |||
1118 | "range (%d-%d)", | |||
1119 | MIN_LAST_MEMBER_QUERY_CNT1, | |||
1120 | MAX_LAST_MEMBER_QUERY_CNT255); | |||
1121 | YYERRORgoto yyerrlab; | |||
1122 | } | |||
1123 | defs->last_member_query_cnt = yyvsp[0].v.number; | |||
1124 | } | |||
1125 | break; | |||
1126 | case 15: | |||
1127 | #line 205 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1128 | { | |||
1129 | if (yyvsp[0].v.number < MIN_LAST_MEMBER_QUERY_INTERVAL1 || | |||
1130 | yyvsp[0].v.number > MAX_LAST_MEMBER_QUERY_INTERVAL65535) { | |||
1131 | yyerror("last-member-query-interval out of " | |||
1132 | "range (%d-%d)", | |||
1133 | MIN_LAST_MEMBER_QUERY_INTERVAL1, | |||
1134 | MAX_LAST_MEMBER_QUERY_INTERVAL65535); | |||
1135 | YYERRORgoto yyerrlab; | |||
1136 | } | |||
1137 | defs->last_member_query_interval = yyvsp[0].v.number; | |||
1138 | } | |||
1139 | break; | |||
1140 | case 16: | |||
1141 | #line 216 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1142 | { | |||
1143 | if (yyvsp[0].v.number < MIN_METRIC1 || yyvsp[0].v.number > MAX_METRIC31) { | |||
1144 | yyerror("metric out of range (%d-%d)", | |||
1145 | MIN_METRIC1, MAX_METRIC31); | |||
1146 | YYERRORgoto yyerrlab; | |||
1147 | } | |||
1148 | defs->metric = yyvsp[0].v.number; | |||
1149 | } | |||
1150 | break; | |||
1151 | case 17: | |||
1152 | #line 224 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1153 | { | |||
1154 | if (yyvsp[0].v.number < MIN_QUERY_INTERVAL1 || | |||
1155 | yyvsp[0].v.number > MAX_QUERY_INTERVAL65535) { | |||
1156 | yyerror("query-interval out of range (%d-%d)", | |||
1157 | MIN_QUERY_INTERVAL1, MAX_QUERY_INTERVAL65535); | |||
1158 | YYERRORgoto yyerrlab; | |||
1159 | } | |||
1160 | defs->query_interval = yyvsp[0].v.number; | |||
1161 | } | |||
1162 | break; | |||
1163 | case 18: | |||
1164 | #line 233 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1165 | { | |||
1166 | if (yyvsp[0].v.number < MIN_QUERY_RESP_INTERVAL1 || | |||
1167 | yyvsp[0].v.number > MAX_QUERY_RESP_INTERVAL65535) { | |||
1168 | yyerror("query-response-interval out of " | |||
1169 | "range (%d-%d)", | |||
1170 | MIN_QUERY_RESP_INTERVAL1, | |||
1171 | MAX_QUERY_RESP_INTERVAL65535); | |||
1172 | YYERRORgoto yyerrlab; | |||
1173 | } | |||
1174 | defs->query_resp_interval = yyvsp[0].v.number; | |||
1175 | } | |||
1176 | break; | |||
1177 | case 19: | |||
1178 | #line 244 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1179 | { | |||
1180 | if (yyvsp[0].v.number < MIN_ROBUSTNESS1 || yyvsp[0].v.number > MAX_ROBUSTNESS4) { | |||
1181 | yyerror("robustness out of range (%d-%d)", | |||
1182 | MIN_ROBUSTNESS1, MAX_ROBUSTNESS4); | |||
1183 | YYERRORgoto yyerrlab; | |||
1184 | } | |||
1185 | defs->robustness = yyvsp[0].v.number; | |||
1186 | } | |||
1187 | break; | |||
1188 | case 20: | |||
1189 | #line 252 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1190 | { | |||
1191 | if (yyvsp[0].v.number < MIN_STARTUP_QUERY_CNT1 || | |||
1192 | yyvsp[0].v.number > MAX_STARTUP_QUERY_CNT4) { | |||
1193 | yyerror("startup-query-count out of " | |||
1194 | "range (%d-%d)", | |||
1195 | MIN_STARTUP_QUERY_CNT1, | |||
1196 | MAX_STARTUP_QUERY_CNT4); | |||
1197 | YYERRORgoto yyerrlab; | |||
1198 | } | |||
1199 | defs->startup_query_cnt = yyvsp[0].v.number; | |||
1200 | } | |||
1201 | break; | |||
1202 | case 21: | |||
1203 | #line 263 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1204 | { | |||
1205 | if (yyvsp[0].v.number < MIN_STARTUP_QUERY_INTERVAL1 || | |||
1206 | yyvsp[0].v.number > MAX_STARTUP_QUERY_INTERVAL65535) { | |||
1207 | yyerror("startup-query-interval out of " | |||
1208 | "range (%d-%d)", | |||
1209 | MIN_STARTUP_QUERY_INTERVAL1, | |||
1210 | MAX_STARTUP_QUERY_INTERVAL65535); | |||
1211 | YYERRORgoto yyerrlab; | |||
1212 | } | |||
1213 | defs->startup_query_interval = yyvsp[0].v.number; | |||
1214 | } | |||
1215 | break; | |||
1216 | case 22: | |||
1217 | #line 274 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1218 | { | |||
1219 | if (yyvsp[0].v.number < MIN_IGMP_VERSION1 || | |||
1220 | yyvsp[0].v.number > MAX_IGMP_VERSION2) { | |||
1221 | yyerror("igmp-version out of range (%d-%d)", | |||
1222 | MIN_IGMP_VERSION1, MAX_IGMP_VERSION2); | |||
1223 | YYERRORgoto yyerrlab; | |||
1224 | } | |||
1225 | defs->igmp_version = yyvsp[0].v.number; | |||
1226 | } | |||
1227 | break; | |||
1228 | case 26: | |||
1229 | #line 292 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1230 | { | |||
1231 | struct kif *kif; | |||
1232 | ||||
1233 | if ((kif = kif_findname(yyvsp[0].v.string)) == NULL((void *)0)) { | |||
1234 | yyerror("unknown interface %s", yyvsp[0].v.string); | |||
1235 | free(yyvsp[0].v.string); | |||
1236 | YYERRORgoto yyerrlab; | |||
1237 | } | |||
1238 | free(yyvsp[0].v.string); | |||
1239 | iface = conf_get_if(kif); | |||
1240 | if (iface == NULL((void *)0)) | |||
1241 | YYERRORgoto yyerrlab; | |||
1242 | LIST_INSERT_HEAD(&conf->iface_list, iface, entry)do { if (((iface)->entry.le_next = (&conf->iface_list )->lh_first) != ((void *)0)) (&conf->iface_list)-> lh_first->entry.le_prev = &(iface)->entry.le_next; ( &conf->iface_list)->lh_first = (iface); (iface)-> entry.le_prev = &(&conf->iface_list)->lh_first; } while (0); | |||
1243 | ||||
1244 | memcpy(&ifacedefs, defs, sizeof(ifacedefs)); | |||
1245 | defs = &ifacedefs; | |||
1246 | } | |||
1247 | break; | |||
1248 | case 27: | |||
1249 | #line 308 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1250 | { | |||
1251 | iface->probe_interval = defs->probe_interval; | |||
1252 | iface->query_interval = defs->query_interval; | |||
1253 | iface->query_resp_interval = defs->query_resp_interval; | |||
1254 | iface->startup_query_interval = | |||
1255 | defs->startup_query_interval; | |||
1256 | iface->startup_query_cnt = defs->startup_query_cnt; | |||
1257 | iface->last_member_query_interval = | |||
1258 | defs->last_member_query_interval; | |||
1259 | iface->last_member_query_cnt = | |||
1260 | defs->last_member_query_cnt; | |||
1261 | iface->dead_interval = defs->dead_interval; | |||
1262 | iface->metric = defs->metric; | |||
1263 | iface->robustness = defs->robustness; | |||
1264 | iface->igmp_version = defs->igmp_version; | |||
1265 | if (grdefs) | |||
1266 | defs = grdefs; | |||
1267 | else | |||
1268 | defs = &globaldefs; | |||
1269 | iface = NULL((void *)0); | |||
1270 | } | |||
1271 | break; | |||
1272 | case 33: | |||
1273 | #line 340 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1274 | { iface->passive = 1; } | |||
1275 | break; | |||
1276 | case 35: | |||
1277 | #line 344 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1278 | { | |||
1279 | memcpy(&groupdefs, defs, sizeof(groupdefs)); | |||
1280 | grdefs = defs = &groupdefs; | |||
1281 | } | |||
1282 | break; | |||
1283 | case 36: | |||
1284 | #line 348 "/usr/src/usr.sbin/dvmrpd/parse.y" | |||
1285 | { | |||
1286 | grdefs = NULL((void *)0); | |||
1287 | defs = &globaldefs; | |||
1288 | } | |||
1289 | break; | |||
1290 | #line 1283 "parse.c" | |||
1291 | } | |||
1292 | yyssp -= yym; | |||
1293 | yystate = *yyssp; | |||
1294 | yyvsp -= yym; | |||
1295 | yym = yylhs[yyn]; | |||
1296 | if (yystate == 0 && yym == 0) | |||
1297 | { | |||
1298 | #if YYDEBUG0 | |||
1299 | if (yydebug) | |||
1300 | printf("%sdebug: after reduction, shifting from state 0 to\ | |||
1301 | state %d\n", YYPREFIX"yy", YYFINAL1); | |||
1302 | #endif | |||
1303 | yystate = YYFINAL1; | |||
1304 | *++yyssp = YYFINAL1; | |||
1305 | *++yyvsp = yyval; | |||
1306 | if (yychar < 0) | |||
1307 | { | |||
1308 | if ((yychar = yylex()) < 0) yychar = 0; | |||
1309 | #if YYDEBUG0 | |||
1310 | if (yydebug) | |||
1311 | { | |||
1312 | yys = 0; | |||
1313 | if (yychar <= YYMAXTOKEN272) yys = yyname[yychar]; | |||
1314 | if (!yys) yys = "illegal-symbol"; | |||
1315 | printf("%sdebug: state %d, reading %d (%s)\n", | |||
1316 | YYPREFIX"yy", YYFINAL1, yychar, yys); | |||
1317 | } | |||
1318 | #endif | |||
1319 | } | |||
1320 | if (yychar == 0) goto yyaccept; | |||
1321 | goto yyloop; | |||
1322 | } | |||
1323 | if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && | |||
1324 | yyn <= YYTABLESIZE261 && yycheck[yyn] == yystate) | |||
1325 | yystate = yytable[yyn]; | |||
1326 | else | |||
1327 | yystate = yydgoto[yym]; | |||
1328 | #if YYDEBUG0 | |||
1329 | if (yydebug) | |||
1330 | printf("%sdebug: after reduction, shifting from state %d \ | |||
1331 | to state %d\n", YYPREFIX"yy", *yyssp, yystate); | |||
1332 | #endif | |||
1333 | if (yyssp >= yysslim && yygrowstack()) | |||
1334 | { | |||
1335 | goto yyoverflow; | |||
1336 | } | |||
1337 | *++yyssp = yystate; | |||
1338 | *++yyvsp = yyval; | |||
1339 | goto yyloop; | |||
1340 | yyoverflow: | |||
1341 | yyerror("yacc stack overflow"); | |||
1342 | yyabort: | |||
1343 | if (yyss) | |||
1344 | free(yyss); | |||
1345 | if (yyvs) | |||
1346 | free(yyvs); | |||
1347 | yyss = yyssp = NULL((void *)0); | |||
1348 | yyvs = yyvsp = NULL((void *)0); | |||
1349 | yystacksize = 0; | |||
1350 | return (1); | |||
1351 | yyaccept: | |||
1352 | if (yyss) | |||
1353 | free(yyss); | |||
1354 | if (yyvs) | |||
1355 | free(yyvs); | |||
1356 | yyss = yyssp = NULL((void *)0); | |||
1357 | yyvs = yyvsp = NULL((void *)0); | |||
1358 | yystacksize = 0; | |||
1359 | return (0); | |||
1360 | } |