x86_64: Fix a warning.
[dragonfly.git] / usr.sbin / atm / scspd / scsp_config_parse.y
blob049892788a21e600fe5fc26c34fa3915cf85eae8
1 %{
2 /*
4 * ===================================
5 * HARP | Host ATM Research Platform
6 * ===================================
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.
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.
22 * Copyright 1994-1998 Network Computing Services, Inc.
24 * Copies of this Software may be made, however, the above copyright
25 * notice must be reproduced on all copies.
27 * @(#) $FreeBSD: src/usr.sbin/atm/scspd/scsp_config_parse.y,v 1.3 1999/08/28 01:15:32 peter Exp $
28 * @(#) $DragonFly: src/usr.sbin/atm/scspd/scsp_config_parse.y,v 1.4 2008/11/12 21:44:59 swildner Exp $
33 * Server Cache Synchronization Protocol (SCSP) Support
34 * ----------------------------------------------------
36 * YACC input for configuration file processing
40 #include <sys/types.h>
41 #include <sys/param.h>
42 #include <sys/socket.h>
43 #include <net/if.h>
44 #include <netinet/in.h>
45 #include <netatm/port.h>
46 #include <netatm/queue.h>
47 #include <netatm/atm.h>
48 #include <netatm/atm_if.h>
49 #include <netatm/atm_sap.h>
50 #include <netatm/atm_sys.h>
51 #include <netatm/atm_ioctl.h>
53 #include <libatm.h>
54 #if __STDC__
55 #include <stdarg.h>
56 #else
57 #include <varargs.h>
58 #endif
59 #include <stdio.h>
60 #include <stdlib.h>
61 #include <string.h>
62 #include <syslog.h>
64 #include "scsp_msg.h"
65 #include "scsp_if.h"
66 #include "scsp_var.h"
68 void yyerror(char *);
73 * Token value definition
75 %union {
76 char *tv_alpha;
77 int tv_int;
78 char *tv_hex;
83 * Token types returned by scanner
85 %token <tv_alpha> TOK_NAME
86 %token <tv_int> TOK_INTEGER
87 %token <tv_hex> TOK_HEX
90 * Reserved words
92 %token TOK_ATMARP
93 %token TOK_DCS
94 %token TOK_DCS_ADDR
95 %token TOK_DCS_CA_REXMIT_INT
96 %token TOK_DCS_CSUS_REXMIT_INT
97 %token TOK_DCS_CSU_REXMIT_INT
98 %token TOK_DCS_CSU_REXMIT_MAX
99 %token TOK_DCS_HELLO_DF
100 %token TOK_DCS_HELLO_INT
101 %token TOK_DCS_HOP_CNT
102 %token TOK_DCS_ID
103 %token TOK_DHCP
104 %token TOK_FAMILY
105 %token TOK_LFN
106 %token TOK_LNNI
107 %token TOK_LOG
108 %token TOK_MARS
109 %token TOK_NETIF
110 %token TOK_NHRP
111 %token TOK_PROTOCOL
112 %token TOK_SERVER
113 %token TOK_SRVGRP
114 %token TOK_SYSLOG
118 cfg_file: /* Empty */
119 | stmt_seq
121 stmt_seq: stmt
122 | stmt_seq stmt
125 stmt: server_stmt ';'
126 | log_stmt ';'
130 * SCSP server definition statements
132 server_stmt: TOK_SERVER TOK_NAME
134 int rc;
136 rc = start_server($2);
137 UM_FREE($2);
138 if (rc)
139 return(rc);
141 '{' server_def '}'
143 int rc;
145 rc = finish_server();
146 if (rc)
147 return(rc);
151 server_def: server_spec ';'
152 | server_def server_spec ';'
155 server_spec: /* Nothing */
156 | dcs_stmt
157 | TOK_NETIF TOK_NAME
159 int rc;
162 * Configure the network interface
164 rc = set_intf($2);
165 UM_FREE($2);
166 if (rc)
167 return(rc);
169 | TOK_PROTOCOL TOK_ATMARP
171 int rc;
174 * Configure the protocol
176 rc = set_protocol(SCSP_PROTO_ATMARP);
177 if (rc)
178 return(rc);
180 | TOK_PROTOCOL TOK_DHCP | TOK_LNNI | TOK_MARS | TOK_NHRP
182 yyerror("Protocol not implemented");
183 return(1);
185 | TOK_SRVGRP TOK_INTEGER
187 int rc;
190 * Configure the SCSP server group ID
192 rc = set_server_group($2);
193 if (rc)
194 return(rc);
199 * SCSP DCS definition statements
201 dcs_stmt: TOK_DCS
203 int rc;
205 rc = start_dcs();
206 if (rc)
207 return(rc);
209 '{' dcs_def '}'
211 int rc;
213 rc = finish_dcs();
214 if (rc)
215 return(rc);
219 dcs_def: dcs_spec ';'
220 | dcs_def dcs_spec ';'
223 dcs_spec: /* Nothing */
224 | TOK_DCS_ADDR TOK_HEX
226 int rc;
229 * Set DCS address
231 rc = set_dcs_addr($2, NULL);
232 UM_FREE($2);
233 if (rc)
234 return(rc);
236 | TOK_DCS_ADDR TOK_HEX TOK_HEX
238 int rc;
241 * Set DCS address and subaddress
243 rc = set_dcs_addr($2, $3);
244 UM_FREE($2);
245 UM_FREE($3);
246 if (rc)
247 return(rc);
249 | TOK_DCS_CA_REXMIT_INT TOK_INTEGER
251 int rc;
254 * Configure the CA retransmit interval
256 rc = set_dcs_ca_rexmit($2);
257 if (rc)
258 return(rc);
260 | TOK_DCS_CSUS_REXMIT_INT TOK_INTEGER
262 int rc;
265 * Configure the CSUS retransmit interval
267 rc = set_dcs_csus_rexmit($2);
268 if (rc)
269 return(rc);
271 | TOK_DCS_CSU_REXMIT_INT TOK_INTEGER
273 int rc;
276 * Configure the CSU retransmit interval
278 rc = set_dcs_csu_rexmit($2);
279 if (rc)
280 return(rc);
282 | TOK_DCS_CSU_REXMIT_MAX TOK_INTEGER
284 int rc;
287 * Configure the CSU retransmit limit
289 rc = set_dcs_csu_rexmit_max($2);
290 if (rc)
291 return(rc);
293 | TOK_DCS_HELLO_DF TOK_INTEGER
295 int rc;
298 * Configure the Hello dead factor
300 rc = set_dcs_hello_df($2);
301 if (rc)
302 return(rc);
304 | TOK_DCS_HELLO_INT TOK_INTEGER
306 int rc;
309 * Configure the Hello interval
311 rc = set_dcs_hello_int($2);
312 if (rc)
313 return(rc);
315 | TOK_DCS_HOP_CNT TOK_INTEGER
317 int rc;
320 * Configure the hop count
322 rc = set_dcs_hops($2);
323 if (rc)
324 return(rc);
326 | TOK_DCS_ID TOK_NAME
328 int rc;
331 * Configure the DCS ID
333 rc = set_dcs_id($2);
334 UM_FREE($2);
335 if (rc)
336 return(rc);
342 * Logging option statements
344 log_stmt: TOK_LOG
345 '{' log_spec '}'
348 log_spec: /* Nothing */
349 | TOK_LFN TOK_NAME ';'
352 * Configure the log file name
354 int rc;
356 rc = set_log_file($2);
357 UM_FREE($2);
358 if (rc)
359 return(rc);
362 | TOK_SYSLOG ';'
365 * Configure logging to syslog
367 scsp_log_syslog = 1;
373 void
374 #if __STDC__
375 parse_error(const char *fmt, ...)
376 #else
377 parse_error(fmt, va_alist)
378 char *fmt;
379 va_dcl
380 #endif
382 va_list ap;
383 char buff[256];
385 #if __STDC__
386 va_start(ap, fmt);
387 #else
388 va_start(ap);
389 #endif
391 vsprintf(buff, fmt, ap);
392 scsp_log(LOG_ERR, "%s: Config file error at line %d: %s\n",
393 prog, parse_line, buff);
394 #ifdef NOTDEF
395 fprintf(stderr, "%s: Config file error at line %d: %s\n",
396 prog, parse_line, buff);
397 #endif
398 va_end(ap);
402 void
403 yyerror(char *s)
405 parse_error(s);