Changeset 12:418d2ce80dc8 in freeDiameter for freeDiameter/fdd.y
- Timestamp:
- Sep 28, 2009, 5:29:25 PM (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
freeDiameter/fdd.y
r10 r12 70 70 } 71 71 72 int got_peer_noip = 0; 73 int got_peer_noipv6 = 0; 74 int got_peer_notcp = 0; 75 int got_peer_nosctp = 0; 76 77 struct peer_info fddpi; 78 72 79 %} 73 80 74 81 /* Values returned by lex for token */ 75 82 %union { 76 char *string; /* The string is allocated by strdup in lex.*/77 int integer; /* Store integer values */83 char *string; /* The string is allocated by strdup in lex.*/ 84 int integer; /* Store integer values */ 78 85 } 79 86 … … 84 91 %token <integer> INTEGER 85 92 86 %type <string> extconf87 88 %token LOCALIDENTITY89 %token LOCALREALM90 %token LOCALPORT91 %token LOCALSECPORT93 %type <string> extconf 94 95 %token IDENTITY 96 %token REALM 97 %token PORT 98 %token SECPORT 92 99 %token NOIP 93 100 %token NOIP6 … … 96 103 %token PREFERTCP 97 104 %token OLDTLS 105 %token NOTLS 98 106 %token SCTPSTREAMS 99 107 %token LISTENON … … 102 110 %token NORELAY 103 111 %token LOADEXT 112 %token CONNPEER 113 %token CONNTO 104 114 105 115 … … 109 119 /* The grammar definition - Sections blocs. */ 110 120 conffile: /* Empty is OK */ 111 | conffile localidentity112 | conffile localrealm121 | conffile identity 122 | conffile realm 113 123 | conffile tctimer 114 124 | conffile twtimer 115 | conffile localport116 | conffile localsecport125 | conffile port 126 | conffile secport 117 127 | conffile sctpstreams 118 128 | conffile listenon … … 125 135 | conffile oldtls 126 136 | conffile loadext 127 ; 128 129 localidentity: LOCALIDENTITY '=' QSTRING ';' 137 | conffile connpeer 138 | conffile errors 139 { 140 yyerror(&yylloc, conf, "An error occurred while parsing the configuration file"); 141 return EINVAL; 142 } 143 ; 144 145 /* Lexical or syntax error */ 146 errors: LEX_ERROR 147 | error 148 ; 149 150 identity: IDENTITY '=' QSTRING ';' 130 151 { 131 152 conf->cnf_diamid = $3; … … 133 154 ; 134 155 135 localrealm: LOCALREALM '=' QSTRING ';'156 realm: REALM '=' QSTRING ';' 136 157 { 137 158 conf->cnf_diamrlm = $3; … … 155 176 ; 156 177 157 localport: LOCALPORT '=' INTEGER ';'178 port: PORT '=' INTEGER ';' 158 179 { 159 180 CHECK_PARAMS_DO( ($3 > 0) && ($3 < 1<<16), … … 163 184 ; 164 185 165 localsecport: LOCALSECPORT '=' INTEGER ';'186 secport: SECPORT '=' INTEGER ';' 166 187 { 167 188 CHECK_PARAMS_DO( ($3 > 0) && ($3 < 1<<16), … … 210 231 noip: NOIP ';' 211 232 { 233 if (got_peer_noipv6) { 234 yyerror (&yylloc, conf, "No_IP conflicts with a ConnectPeer directive No_IPv6."); 235 YYERROR; 236 } 212 237 conf->cnf_flags.no_ip4 = 1; 213 238 } … … 216 241 noip6: NOIP6 ';' 217 242 { 243 if (got_peer_noip) { 244 yyerror (&yylloc, conf, "No_IP conflicts with a ConnectPeer directive No_IP."); 245 YYERROR; 246 } 218 247 conf->cnf_flags.no_ip6 = 1; 219 248 } … … 222 251 notcp: NOTCP ';' 223 252 { 253 #ifdef DISABLE_SCTP 254 yyerror (&yylloc, conf, "No_TCP cannot be specified for daemon compiled with DISABLE_SCTP option."); 255 YYERROR; 256 #endif 257 if (conf->cnf_flags.no_sctp) 258 { 259 yyerror (&yylloc, conf, "No_TCP conflicts with No_SCTP directive." ); 260 YYERROR; 261 } 262 if (got_peer_nosctp) { 263 yyerror (&yylloc, conf, "No_TCP conflicts with a ConnectPeer directive No_SCTP."); 264 YYERROR; 265 } 224 266 conf->cnf_flags.no_tcp = 1; 225 267 } … … 228 270 nosctp: NOSCTP ';' 229 271 { 272 if (conf->cnf_flags.no_tcp) 273 { 274 yyerror (&yylloc, conf, "No_SCTP conflicts with No_TCP directive." ); 275 YYERROR; 276 } 277 if (got_peer_notcp) { 278 yyerror (&yylloc, conf, "No_SCTP conflicts with a ConnectPeer directive No_TCP."); 279 YYERROR; 280 } 230 281 conf->cnf_flags.no_sctp = 1; 231 282 } … … 260 311 } 261 312 ; 313 314 connpeer: { 315 memset(&fddpi, 0, sizeof(fddpi)); 316 } 317 CONNPEER '=' QSTRING peerinfo ';' 318 { 319 fddpi.pi_diamid = $4; 320 CHECK_FCT_DO( fd_peer_add ( &fddpi, conf->cnf_file, NULL, NULL ), 321 { yyerror (&yylloc, conf, "Error adding ConnectPeer information"); YYERROR; } ); 322 323 /* Now destroy any content in the structure */ 324 free(fddpi.pi_diamid); 325 while (!FD_IS_LIST_EMPTY(&fddpi.pi_endpoints)) { 326 struct fd_list * li = fddpi.pi_endpoints.next; 327 fd_list_unlink(li); 328 free(li); 329 } 330 } 331 ; 332 333 peerinfo: /* empty */ 334 | '{' peerparams '}' 335 ; 336 337 peerparams: /* empty */ 338 | peerparams NOIP ';' 339 { 340 if ((conf->cnf_flags.no_ip6) || (fddpi.pi_flags.pro3 == PI_P3_IP)) { 341 yyerror (&yylloc, conf, "No_IP conflicts with a No_IPv6 directive."); 342 YYERROR; 343 } 344 got_peer_noip++; 345 fddpi.pi_flags.pro3 = PI_P3_IPv6; 346 } 347 | peerparams NOIP6 ';' 348 { 349 if ((conf->cnf_flags.no_ip4) || (fddpi.pi_flags.pro3 == PI_P3_IPv6)) { 350 yyerror (&yylloc, conf, "No_IPv6 conflicts with a No_IP directive."); 351 YYERROR; 352 } 353 got_peer_noipv6++; 354 fddpi.pi_flags.pro3 = PI_P3_IP; 355 } 356 | peerparams NOTCP ';' 357 { 358 #ifdef DISABLE_SCTP 359 yyerror (&yylloc, conf, "No_TCP cannot be specified in daemon compiled with DISABLE_SCTP option."); 360 YYERROR; 361 #endif 362 if ((conf->cnf_flags.no_sctp) || (fddpi.pi_flags.pro4 == PI_P4_TCP)) { 363 yyerror (&yylloc, conf, "No_TCP conflicts with a No_SCTP directive."); 364 YYERROR; 365 } 366 got_peer_notcp++; 367 fddpi.pi_flags.pro4 = PI_P4_SCTP; 368 } 369 | peerparams NOSCTP ';' 370 { 371 if ((conf->cnf_flags.no_tcp) || (fddpi.pi_flags.pro4 == PI_P4_SCTP)) { 372 yyerror (&yylloc, conf, "No_SCTP conflicts with a No_TCP directive."); 373 YYERROR; 374 } 375 got_peer_nosctp++; 376 fddpi.pi_flags.pro4 = PI_P4_TCP; 377 } 378 | peerparams PREFERTCP ';' 379 { 380 fddpi.pi_flags.alg = PI_ALGPREF_TCP; 381 } 382 | peerparams OLDTLS ';' 383 { 384 if (fddpi.pi_flags.sec == PI_SEC_NONE) { 385 yyerror (&yylloc, conf, "ConnectPeer: TLS_old_method conflicts with No_TLS."); 386 YYERROR; 387 } 388 fddpi.pi_flags.sec = PI_SEC_TLS_OLD; 389 } 390 | peerparams NOTLS ';' 391 { 392 if (fddpi.pi_flags.sec == PI_SEC_TLS_OLD) { 393 yyerror (&yylloc, conf, "ConnectPeer: No_TLS conflicts with TLS_old_method."); 394 YYERROR; 395 } 396 fddpi.pi_flags.sec = PI_SEC_NONE; 397 } 398 | peerparams PORT '=' INTEGER ';' 399 { 400 CHECK_PARAMS_DO( ($4 > 0) && ($4 < 1<<16), 401 { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } ); 402 fddpi.pi_port = (uint16_t)$4; 403 } 404 | peerparams SCTPSTREAMS '=' INTEGER ';' 405 { 406 CHECK_PARAMS_DO( ($4 > 0) && ($4 < 1<<16), 407 { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } ); 408 fddpi.pi_streams = (uint16_t)$4; 409 } 410 | peerparams TCTIMER '=' INTEGER ';' 411 { 412 fddpi.pi_tctimer = $4; 413 } 414 | peerparams TWTIMER '=' INTEGER ';' 415 { 416 fddpi.pi_twtimer = $4; 417 } 418 | peerparams CONNTO '=' QSTRING ';' 419 { 420 struct fd_endpoint * ep; 421 struct addrinfo hints, *ai; 422 int ret; 423 424 CHECK_MALLOC_DO( ep = malloc(sizeof(struct fd_endpoint)), 425 { yyerror (&yylloc, conf, "Out of memory"); YYERROR; } ); 426 memset(ep, 0, sizeof(struct fd_endpoint)); 427 fd_list_init(&ep->chain, NULL); 428 429 memset(&hints, 0, sizeof(hints)); 430 hints.ai_flags = AI_ADDRCONFIG; 431 ret = getaddrinfo($4, NULL, &hints, &ai); 432 if (ret) { yyerror (&yylloc, conf, gai_strerror(ret)); YYERROR; } 433 434 memcpy(&ep->ss, ai->ai_addr, ai->ai_addrlen); 435 free($4); 436 freeaddrinfo(ai); 437 fd_list_insert_before(&fddpi.pi_endpoints, &ep->chain); 438 } 439 ;
Note: See TracChangeset
for help on using the changeset viewer.