kernel: Sync ACPICA with Intel's version 20140424.
[dragonfly.git] / usr.sbin / atm / scspd / scsp_config_parse.y
1 %{
2 /*
3  *
4  * ===================================
5  * HARP  |  Host ATM Research Platform
6  * ===================================
7  *
8  *
9  * This Host ATM Research Platform ("HARP") file (the "Software") is
10  * made available by Network Computing Services, Inc. ("NetworkCS")
11  * "AS IS".  NetworkCS does not provide maintenance, improvements or
12  * support of any kind.
13  *
14  * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
15  * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
16  * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
17  * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
18  * In no event shall NetworkCS be responsible for any damages, including
19  * but not limited to consequential damages, arising from or relating to
20  * any use of the Software or related support.
21  *
22  * Copyright 1994-1998 Network Computing Services, Inc.
23  *
24  * Copies of this Software may be made, however, the above copyright
25  * notice must be reproduced on all copies.
26  *
27  *      @(#) $FreeBSD: src/usr.sbin/atm/scspd/scsp_config_parse.y,v 1.3 1999/08/28 01:15:32 peter Exp $
28  */
29
30
31 /*
32  * Server Cache Synchronization Protocol (SCSP) Support
33  * ----------------------------------------------------
34  *
35  * YACC input for configuration file processing
36  *
37  */
38
39 #include <sys/types.h>
40 #include <sys/param.h>
41 #include <sys/socket.h>
42 #include <net/if.h>
43 #include <netinet/in.h>
44 #include <netatm/port.h> 
45 #include <netatm/queue.h> 
46 #include <netatm/atm.h>
47 #include <netatm/atm_if.h>
48 #include <netatm/atm_sap.h>
49 #include <netatm/atm_sys.h>
50 #include <netatm/atm_ioctl.h>
51
52 #include <libatm.h>
53 #if __STDC__
54 #include <stdarg.h>
55 #else
56 #include <varargs.h>
57 #endif
58 #include <stdio.h>
59 #include <stdlib.h>
60 #include <string.h>
61 #include <syslog.h>
62
63 #include "scsp_msg.h"
64 #include "scsp_if.h"
65 #include "scsp_var.h"
66
67 void    yyerror(char *);
68 %}
69
70
71 /*
72  * Token value definition
73  */
74 %union {
75         char            *tv_alpha;
76         int             tv_int;
77         char            *tv_hex;
78 }
79
80
81 /*
82  * Token types returned by scanner
83  */
84 %token  <tv_alpha>      TOK_NAME
85 %token  <tv_int>        TOK_INTEGER
86 %token  <tv_hex>        TOK_HEX
87
88 /*
89  * Reserved words
90  */
91 %token                  TOK_ATMARP
92 %token                  TOK_DCS
93 %token                  TOK_DCS_ADDR
94 %token                  TOK_DCS_CA_REXMIT_INT
95 %token                  TOK_DCS_CSUS_REXMIT_INT
96 %token                  TOK_DCS_CSU_REXMIT_INT
97 %token                  TOK_DCS_CSU_REXMIT_MAX
98 %token                  TOK_DCS_HELLO_DF
99 %token                  TOK_DCS_HELLO_INT
100 %token                  TOK_DCS_HOP_CNT
101 %token                  TOK_DCS_ID
102 %token                  TOK_DHCP
103 %token                  TOK_FAMILY
104 %token                  TOK_LFN
105 %token                  TOK_LNNI
106 %token                  TOK_LOG
107 %token                  TOK_MARS
108 %token                  TOK_NETIF
109 %token                  TOK_NHRP
110 %token                  TOK_PROTOCOL
111 %token                  TOK_SERVER
112 %token                  TOK_SRVGRP
113 %token                  TOK_SYSLOG
114
115
116 %%
117 cfg_file: /* Empty */
118         | stmt_seq
119
120 stmt_seq: stmt
121         | stmt_seq stmt
122         ;
123
124 stmt:   server_stmt ';'
125         | log_stmt ';'
126         ;
127
128 /*
129  * SCSP server definition statements
130  */
131 server_stmt: TOK_SERVER TOK_NAME
132         {
133                 int     rc;
134
135                 rc = start_server($2);
136                 UM_FREE($2);
137                 if (rc)
138                         return(rc);
139         }
140         '{' server_def '}'
141         {
142                 int     rc;
143
144                 rc = finish_server();
145                 if (rc)
146                         return(rc);
147         }
148         ;
149
150 server_def: server_spec ';'
151         | server_def server_spec ';'
152         ;
153
154 server_spec: /* Nothing */
155         | dcs_stmt
156         | TOK_NETIF TOK_NAME
157         {
158                 int     rc;
159
160                 /*
161                  * Configure the network interface
162                  */
163                 rc = set_intf($2);
164                 UM_FREE($2);
165                 if (rc)
166                         return(rc);
167         }
168         | TOK_PROTOCOL TOK_ATMARP
169         {
170                 int     rc;
171
172                 /*
173                  * Configure the protocol
174                  */
175                 rc = set_protocol(SCSP_PROTO_ATMARP);
176                 if (rc)
177                         return(rc);
178         }
179         | TOK_PROTOCOL TOK_DHCP | TOK_LNNI | TOK_MARS | TOK_NHRP
180         {
181                 yyerror("Protocol not implemented");
182                 return(1);
183         }
184         | TOK_SRVGRP TOK_INTEGER
185         {
186                 int     rc;
187
188                 /*
189                  * Configure the SCSP server group ID
190                  */
191                 rc = set_server_group($2);
192                 if (rc)
193                         return(rc);
194         }
195         ;
196
197 /*
198  * SCSP DCS definition statements
199  */
200 dcs_stmt: TOK_DCS 
201         {
202                 int     rc;
203
204                 rc = start_dcs();
205                 if (rc)
206                         return(rc);
207         }
208         '{' dcs_def '}'
209         {
210                 int     rc;
211
212                 rc = finish_dcs();
213                 if (rc)
214                         return(rc);
215         }
216         ;
217
218 dcs_def: dcs_spec ';'
219         | dcs_def dcs_spec ';'
220         ;
221
222 dcs_spec: /* Nothing */
223         | TOK_DCS_ADDR TOK_HEX
224         {
225                 int     rc;
226
227                 /*
228                  * Set DCS address
229                  */
230                 rc = set_dcs_addr($2, NULL);
231                 UM_FREE($2);
232                 if (rc)
233                         return(rc);
234         }
235         | TOK_DCS_ADDR TOK_HEX TOK_HEX
236         {
237                 int     rc;
238
239                 /*
240                  * Set DCS address and subaddress
241                  */
242                 rc = set_dcs_addr($2, $3);
243                 UM_FREE($2);
244                 UM_FREE($3);
245                 if (rc)
246                         return(rc);
247         }
248         | TOK_DCS_CA_REXMIT_INT TOK_INTEGER
249         {
250                 int     rc;
251
252                 /*
253                  * Configure the CA retransmit interval
254                  */
255                 rc = set_dcs_ca_rexmit($2);
256                 if (rc)
257                         return(rc);
258         }
259         | TOK_DCS_CSUS_REXMIT_INT TOK_INTEGER
260         {
261                 int     rc;
262
263                 /*
264                  * Configure the CSUS retransmit interval
265                  */
266                 rc = set_dcs_csus_rexmit($2);
267                 if (rc)
268                         return(rc);
269         }
270         | TOK_DCS_CSU_REXMIT_INT TOK_INTEGER
271         {
272                 int     rc;
273
274                 /*
275                  * Configure the CSU retransmit interval
276                  */
277                 rc = set_dcs_csu_rexmit($2);
278                 if (rc)
279                         return(rc);
280         }
281         | TOK_DCS_CSU_REXMIT_MAX TOK_INTEGER
282         {
283                 int     rc;
284
285                 /*
286                  * Configure the CSU retransmit limit
287                  */
288                 rc = set_dcs_csu_rexmit_max($2);
289                 if (rc)
290                         return(rc);
291         }
292         | TOK_DCS_HELLO_DF TOK_INTEGER
293         {
294                 int     rc;
295
296                 /*
297                  * Configure the Hello dead factor
298                  */
299                 rc = set_dcs_hello_df($2);
300                 if (rc)
301                         return(rc);
302         }
303         | TOK_DCS_HELLO_INT TOK_INTEGER
304         {
305                 int     rc;
306
307                 /*
308                  * Configure the Hello interval
309                  */
310                 rc = set_dcs_hello_int($2);
311                 if (rc)
312                         return(rc);
313         }
314         | TOK_DCS_HOP_CNT TOK_INTEGER
315         {
316                 int     rc;
317
318                 /*
319                  * Configure the hop count
320                  */
321                 rc = set_dcs_hops($2);
322                 if (rc)
323                         return(rc);
324         }
325         | TOK_DCS_ID TOK_NAME
326         {
327                 int     rc;
328
329                 /*
330                  * Configure the DCS ID
331                  */
332                 rc = set_dcs_id($2);
333                 UM_FREE($2);
334                 if (rc)
335                         return(rc);
336         }
337         ;
338
339
340 /*
341  * Logging option statements
342  */
343 log_stmt: TOK_LOG
344         '{' log_spec '}'
345         ;
346
347 log_spec: /* Nothing */
348         | TOK_LFN TOK_NAME ';'
349         {
350                 /*
351                  * Configure the log file name
352                  */
353                 int     rc;
354
355                 rc = set_log_file($2);
356                 UM_FREE($2);
357                 if (rc)
358                         return(rc);
359         }
360         ;
361         | TOK_SYSLOG ';'
362         {
363                 /*
364                  * Configure logging to syslog
365                  */
366                 scsp_log_syslog = 1;
367         }
368         ;
369
370 %%
371
372 void
373 parse_error(const char *fmt, ...)
374 {
375         va_list ap;
376         char    buff[256];
377
378         va_start(ap, fmt);
379
380         vsprintf(buff, fmt, ap);
381         scsp_log(LOG_ERR, "%s: Config file error at line %d: %s\n",
382                         prog, parse_line, buff);
383 #ifdef NOTDEF
384         fprintf(stderr, "%s: Config file error at line %d: %s\n",
385                         prog, parse_line, buff);
386 #endif
387         va_end(ap);
388 }
389
390
391 void
392 yyerror(char *s)
393 {
394         parse_error("%s", s);
395 }