| 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 | * @(#) $DragonFly: src/usr.sbin/atm/scspd/scsp_config_parse.y,v 1.3 2003/11/03 19:31:35 eirikn Exp $ |
| 29 | */ |
| 30 | |
| 31 | |
| 32 | /* |
| 33 | * Server Cache Synchronization Protocol (SCSP) Support |
| 34 | * ---------------------------------------------------- |
| 35 | * |
| 36 | * YACC input for configuration file processing |
| 37 | * |
| 38 | */ |
| 39 | |
| 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> |
| 52 | |
| 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> |
| 63 | |
| 64 | #include "scsp_msg.h" |
| 65 | #include "scsp_if.h" |
| 66 | #include "scsp_var.h" |
| 67 | |
| 68 | void yyerror(char *); |
| 69 | %} |
| 70 | |
| 71 | |
| 72 | /* |
| 73 | * Token value definition |
| 74 | */ |
| 75 | %union { |
| 76 | char *tv_alpha; |
| 77 | int tv_int; |
| 78 | char *tv_hex; |
| 79 | } |
| 80 | |
| 81 | |
| 82 | /* |
| 83 | * Token types returned by scanner |
| 84 | */ |
| 85 | %token <tv_alpha> TOK_NAME |
| 86 | %token <tv_int> TOK_INTEGER |
| 87 | %token <tv_hex> TOK_HEX |
| 88 | |
| 89 | /* |
| 90 | * Reserved words |
| 91 | */ |
| 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 |
| 115 | |
| 116 | |
| 117 | %% |
| 118 | cfg_file: /* Empty */ |
| 119 | | stmt_seq |
| 120 | |
| 121 | stmt_seq: stmt |
| 122 | | stmt_seq stmt |
| 123 | ; |
| 124 | |
| 125 | stmt: server_stmt ';' |
| 126 | | log_stmt ';' |
| 127 | ; |
| 128 | |
| 129 | /* |
| 130 | * SCSP server definition statements |
| 131 | */ |
| 132 | server_stmt: TOK_SERVER TOK_NAME |
| 133 | { |
| 134 | int rc; |
| 135 | |
| 136 | rc = start_server($2); |
| 137 | UM_FREE($2); |
| 138 | if (rc) |
| 139 | return(rc); |
| 140 | } |
| 141 | '{' server_def '}' |
| 142 | { |
| 143 | int rc; |
| 144 | |
| 145 | rc = finish_server(); |
| 146 | if (rc) |
| 147 | return(rc); |
| 148 | } |
| 149 | ; |
| 150 | |
| 151 | server_def: server_spec ';' |
| 152 | | server_def server_spec ';' |
| 153 | ; |
| 154 | |
| 155 | server_spec: /* Nothing */ |
| 156 | | dcs_stmt |
| 157 | | TOK_NETIF TOK_NAME |
| 158 | { |
| 159 | int rc; |
| 160 | |
| 161 | /* |
| 162 | * Configure the network interface |
| 163 | */ |
| 164 | rc = set_intf($2); |
| 165 | UM_FREE($2); |
| 166 | if (rc) |
| 167 | return(rc); |
| 168 | } |
| 169 | | TOK_PROTOCOL TOK_ATMARP |
| 170 | { |
| 171 | int rc; |
| 172 | |
| 173 | /* |
| 174 | * Configure the protocol |
| 175 | */ |
| 176 | rc = set_protocol(SCSP_PROTO_ATMARP); |
| 177 | if (rc) |
| 178 | return(rc); |
| 179 | } |
| 180 | | TOK_PROTOCOL TOK_DHCP | TOK_LNNI | TOK_MARS | TOK_NHRP |
| 181 | { |
| 182 | yyerror("Protocol not implemented"); |
| 183 | return(1); |
| 184 | } |
| 185 | | TOK_SRVGRP TOK_INTEGER |
| 186 | { |
| 187 | int rc; |
| 188 | |
| 189 | /* |
| 190 | * Configure the SCSP server group ID |
| 191 | */ |
| 192 | rc = set_server_group($2); |
| 193 | if (rc) |
| 194 | return(rc); |
| 195 | } |
| 196 | ; |
| 197 | |
| 198 | /* |
| 199 | * SCSP DCS definition statements |
| 200 | */ |
| 201 | dcs_stmt: TOK_DCS |
| 202 | { |
| 203 | int rc; |
| 204 | |
| 205 | rc = start_dcs(); |
| 206 | if (rc) |
| 207 | return(rc); |
| 208 | } |
| 209 | '{' dcs_def '}' |
| 210 | { |
| 211 | int rc; |
| 212 | |
| 213 | rc = finish_dcs(); |
| 214 | if (rc) |
| 215 | return(rc); |
| 216 | } |
| 217 | ; |
| 218 | |
| 219 | dcs_def: dcs_spec ';' |
| 220 | | dcs_def dcs_spec ';' |
| 221 | ; |
| 222 | |
| 223 | dcs_spec: /* Nothing */ |
| 224 | | TOK_DCS_ADDR TOK_HEX |
| 225 | { |
| 226 | int rc; |
| 227 | |
| 228 | /* |
| 229 | * Set DCS address |
| 230 | */ |
| 231 | rc = set_dcs_addr($2, (char *)0); |
| 232 | UM_FREE($2); |
| 233 | if (rc) |
| 234 | return(rc); |
| 235 | } |
| 236 | | TOK_DCS_ADDR TOK_HEX TOK_HEX |
| 237 | { |
| 238 | int rc; |
| 239 | |
| 240 | /* |
| 241 | * Set DCS address and subaddress |
| 242 | */ |
| 243 | rc = set_dcs_addr($2, $3); |
| 244 | UM_FREE($2); |
| 245 | UM_FREE($3); |
| 246 | if (rc) |
| 247 | return(rc); |
| 248 | } |
| 249 | | TOK_DCS_CA_REXMIT_INT TOK_INTEGER |
| 250 | { |
| 251 | int rc; |
| 252 | |
| 253 | /* |
| 254 | * Configure the CA retransmit interval |
| 255 | */ |
| 256 | rc = set_dcs_ca_rexmit($2); |
| 257 | if (rc) |
| 258 | return(rc); |
| 259 | } |
| 260 | | TOK_DCS_CSUS_REXMIT_INT TOK_INTEGER |
| 261 | { |
| 262 | int rc; |
| 263 | |
| 264 | /* |
| 265 | * Configure the CSUS retransmit interval |
| 266 | */ |
| 267 | rc = set_dcs_csus_rexmit($2); |
| 268 | if (rc) |
| 269 | return(rc); |
| 270 | } |
| 271 | | TOK_DCS_CSU_REXMIT_INT TOK_INTEGER |
| 272 | { |
| 273 | int rc; |
| 274 | |
| 275 | /* |
| 276 | * Configure the CSU retransmit interval |
| 277 | */ |
| 278 | rc = set_dcs_csu_rexmit($2); |
| 279 | if (rc) |
| 280 | return(rc); |
| 281 | } |
| 282 | | TOK_DCS_CSU_REXMIT_MAX TOK_INTEGER |
| 283 | { |
| 284 | int rc; |
| 285 | |
| 286 | /* |
| 287 | * Configure the CSU retransmit limit |
| 288 | */ |
| 289 | rc = set_dcs_csu_rexmit_max($2); |
| 290 | if (rc) |
| 291 | return(rc); |
| 292 | } |
| 293 | | TOK_DCS_HELLO_DF TOK_INTEGER |
| 294 | { |
| 295 | int rc; |
| 296 | |
| 297 | /* |
| 298 | * Configure the Hello dead factor |
| 299 | */ |
| 300 | rc = set_dcs_hello_df($2); |
| 301 | if (rc) |
| 302 | return(rc); |
| 303 | } |
| 304 | | TOK_DCS_HELLO_INT TOK_INTEGER |
| 305 | { |
| 306 | int rc; |
| 307 | |
| 308 | /* |
| 309 | * Configure the Hello interval |
| 310 | */ |
| 311 | rc = set_dcs_hello_int($2); |
| 312 | if (rc) |
| 313 | return(rc); |
| 314 | } |
| 315 | | TOK_DCS_HOP_CNT TOK_INTEGER |
| 316 | { |
| 317 | int rc; |
| 318 | |
| 319 | /* |
| 320 | * Configure the hop count |
| 321 | */ |
| 322 | rc = set_dcs_hops($2); |
| 323 | if (rc) |
| 324 | return(rc); |
| 325 | } |
| 326 | | TOK_DCS_ID TOK_NAME |
| 327 | { |
| 328 | int rc; |
| 329 | |
| 330 | /* |
| 331 | * Configure the DCS ID |
| 332 | */ |
| 333 | rc = set_dcs_id($2); |
| 334 | UM_FREE($2); |
| 335 | if (rc) |
| 336 | return(rc); |
| 337 | } |
| 338 | ; |
| 339 | |
| 340 | |
| 341 | /* |
| 342 | * Logging option statements |
| 343 | */ |
| 344 | log_stmt: TOK_LOG |
| 345 | '{' log_spec '}' |
| 346 | ; |
| 347 | |
| 348 | log_spec: /* Nothing */ |
| 349 | | TOK_LFN TOK_NAME ';' |
| 350 | { |
| 351 | /* |
| 352 | * Configure the log file name |
| 353 | */ |
| 354 | int rc; |
| 355 | |
| 356 | rc = set_log_file($2); |
| 357 | UM_FREE($2); |
| 358 | if (rc) |
| 359 | return(rc); |
| 360 | } |
| 361 | ; |
| 362 | | TOK_SYSLOG ';' |
| 363 | { |
| 364 | /* |
| 365 | * Configure logging to syslog |
| 366 | */ |
| 367 | scsp_log_syslog = 1; |
| 368 | } |
| 369 | ; |
| 370 | |
| 371 | %% |
| 372 | |
| 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 |
| 381 | { |
| 382 | va_list ap; |
| 383 | char buff[256]; |
| 384 | |
| 385 | #if __STDC__ |
| 386 | va_start(ap, fmt); |
| 387 | #else |
| 388 | va_start(ap); |
| 389 | #endif |
| 390 | |
| 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); |
| 399 | } |
| 400 | |
| 401 | |
| 402 | void |
| 403 | yyerror(s) |
| 404 | char *s; |
| 405 | { |
| 406 | parse_error(s); |
| 407 | } |