parser.y (62638) | parser.y (78064) |
---|---|
1/* $KAME$ */ | 1/* $KAME: parser.y,v 1.8 2000/11/08 03:03:34 jinmei Exp $ */ |
2 3/* 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: --- 13 unchanged lines hidden (view full) --- 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * | 2 3/* 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: --- 13 unchanged lines hidden (view full) --- 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * |
31 * $FreeBSD: head/usr.sbin/rrenumd/parser.y 62638 2000-07-05 11:12:53Z kris $ | 31 * $FreeBSD: head/usr.sbin/rrenumd/parser.y 78064 2001-06-11 12:39:29Z ume $ |
32 */ 33 34%{ 35#include <sys/param.h> 36#include <sys/ioctl.h> 37#include <sys/socket.h> 38#include <sys/uio.h> | 32 */ 33 34%{ 35#include <sys/param.h> 36#include <sys/ioctl.h> 37#include <sys/socket.h> 38#include <sys/uio.h> |
39#include <sys/queue.h> |
|
39 40#include <net/if.h> 41#if defined(__FreeBSD__) && __FreeBSD__ >= 3 42#include <net/if_var.h> 43#endif /* __FreeBSD__ >= 3 */ 44 45#include <netinet/in.h> 46#include <netinet/in_var.h> 47#include <netinet/icmp6.h> 48 49#include <netdb.h> 50#include <string.h> | 40 41#include <net/if.h> 42#if defined(__FreeBSD__) && __FreeBSD__ >= 3 43#include <net/if_var.h> 44#endif /* __FreeBSD__ >= 3 */ 45 46#include <netinet/in.h> 47#include <netinet/in_var.h> 48#include <netinet/icmp6.h> 49 50#include <netdb.h> 51#include <string.h> |
52#include <stdio.h> |
|
51 52#include "rrenumd.h" 53 54struct config_is_set { 55 u_short cis_dest : 1; 56} cis; 57 58struct dst_list *dl_head; 59struct payload_list *pl_head, ple_cur; 60u_int retry; 61char errbuf[LINE_MAX]; 62 63extern int lineno; 64extern void yyerror __P((const char *s)); | 53 54#include "rrenumd.h" 55 56struct config_is_set { 57 u_short cis_dest : 1; 58} cis; 59 60struct dst_list *dl_head; 61struct payload_list *pl_head, ple_cur; 62u_int retry; 63char errbuf[LINE_MAX]; 64 65extern int lineno; 66extern void yyerror __P((const char *s)); |
67extern int yylex __P((void)); |
|
65static struct payload_list * pllist_lookup __P((int seqnum)); 66static void pllist_enqueue __P((struct payload_list *pl_entry)); 67 68#define MAX_RETRYNUM 10 /* upper limit of retry in this rrenumd program */ 69#define MAX_SEQNUM 256 /* upper limit of seqnum in this rrenumd program */ 70#define NOSPEC -1 71 72%} --- 114 unchanged lines hidden (view full) --- 187 188 memset(&hints, 0, sizeof(hints)); 189 hints.ai_flags = AI_CANONNAME; 190 hints.ai_family = AF_UNSPEC; 191 hints.ai_socktype = SOCK_RAW; 192 hints.ai_protocol = 0; 193 error = getaddrinfo($1.cp, 0, &hints, &res); 194 if (error) { | 68static struct payload_list * pllist_lookup __P((int seqnum)); 69static void pllist_enqueue __P((struct payload_list *pl_entry)); 70 71#define MAX_RETRYNUM 10 /* upper limit of retry in this rrenumd program */ 72#define MAX_SEQNUM 256 /* upper limit of seqnum in this rrenumd program */ 73#define NOSPEC -1 74 75%} --- 114 unchanged lines hidden (view full) --- 190 191 memset(&hints, 0, sizeof(hints)); 192 hints.ai_flags = AI_CANONNAME; 193 hints.ai_family = AF_UNSPEC; 194 hints.ai_socktype = SOCK_RAW; 195 hints.ai_protocol = 0; 196 error = getaddrinfo($1.cp, 0, &hints, &res); 197 if (error) { |
195 sprintf(errbuf, "name resolution failed for %s" 196 ":%s", $1, gai_strerror(error)); | 198 snprintf(errbuf, sizeof(errbuf), 199 "name resolution failed for %s:%s", 200 $1.cp, gai_strerror(error)); |
197 yyerror(errbuf); 198 } 199 ss = (struct sockaddr_storage *)malloc(sizeof(*ss)); 200 memset(ss, 0, sizeof(*ss)); 201 memcpy(ss, res->ai_addr, res->ai_addr->sa_len); 202 freeaddrinfo(res); 203 204 $$ = (struct dst_list *) --- 64 unchanged lines hidden (view full) --- 269 $$ = $2; 270 } 271 ; 272 273rrenum_statement_with_seqnum: 274 SEQNUM_CMD seqnum 275 { 276 if (pllist_lookup($2)) { | 201 yyerror(errbuf); 202 } 203 ss = (struct sockaddr_storage *)malloc(sizeof(*ss)); 204 memset(ss, 0, sizeof(*ss)); 205 memcpy(ss, res->ai_addr, res->ai_addr->sa_len); 206 freeaddrinfo(res); 207 208 $$ = (struct dst_list *) --- 64 unchanged lines hidden (view full) --- 273 $$ = $2; 274 } 275 ; 276 277rrenum_statement_with_seqnum: 278 SEQNUM_CMD seqnum 279 { 280 if (pllist_lookup($2)) { |
277 sprintf(errbuf, "duplicate seqnum %d specified" 278 " at %d", $2, lineno); | 281 snprintf(errbuf, sizeof(errbuf), 282 "duplicate seqnum %ld specified at %d", 283 $2, lineno); |
279 yyerror(errbuf); 280 } 281 } 282 BCL rrenum_statement EOS ECL EOS 283 { 284 $5->pl_irr.rr_seqnum = $2; 285 pllist_enqueue($5); 286 } 287 ; 288 289seqnum: 290 /* empty */ 291 { 292 $$ = 0; 293 } 294 | decstring 295 { 296 if ($1 > MAX_SEQNUM) { | 284 yyerror(errbuf); 285 } 286 } 287 BCL rrenum_statement EOS ECL EOS 288 { 289 $5->pl_irr.rr_seqnum = $2; 290 pllist_enqueue($5); 291 } 292 ; 293 294seqnum: 295 /* empty */ 296 { 297 $$ = 0; 298 } 299 | decstring 300 { 301 if ($1 > MAX_SEQNUM) { |
297 sprintf(errbuf, "seqnum %d is illegal for this" 298 " program. should be between 0 and %d", 299 $1, MAX_SEQNUM); | 302 snprintf(errbuf, sizeof(errbuf), 303 "seqnum %ld is illegal for this program. " 304 "should be between 0 and %d", 305 $1, MAX_SEQNUM); |
300 yyerror(errbuf); 301 } 302 $$ = $1; 303 } 304 ; 305 306rrenum_statement_without_seqnum: 307 rrenum_statement EOS 308 { 309 if (pllist_lookup(0)) { | 306 yyerror(errbuf); 307 } 308 $$ = $1; 309 } 310 ; 311 312rrenum_statement_without_seqnum: 313 rrenum_statement EOS 314 { 315 if (pllist_lookup(0)) { |
310 sprintf(errbuf, "duplicate seqnum %d specified" 311 " at %d", 0, lineno); | 316 snprintf(errbuf, sizeof(errbuf), 317 "duplicate seqnum %d specified at %d", 318 0, lineno); |
312 yyerror(errbuf); 313 } 314 $1->pl_irr.rr_seqnum = 0; 315 pllist_enqueue($1); 316 } 317 ; 318 319rrenum_statement: --- 110 unchanged lines hidden (view full) --- 430 struct rr_pco_match *rpm; 431 struct rr_pco_use *rpu; 432 433 irr = (struct icmp6_router_renum *)&ple_cur.pl_irr; 434 rpm = (struct rr_pco_match *)(irr + 1); 435 rpu = (struct rr_pco_use *)(rpm + 1); 436 memset(rpu, 0, sizeof(*rpu)); 437 | 319 yyerror(errbuf); 320 } 321 $1->pl_irr.rr_seqnum = 0; 322 pllist_enqueue($1); 323 } 324 ; 325 326rrenum_statement: --- 110 unchanged lines hidden (view full) --- 437 struct rr_pco_match *rpm; 438 struct rr_pco_use *rpu; 439 440 irr = (struct icmp6_router_renum *)&ple_cur.pl_irr; 441 rpm = (struct rr_pco_match *)(irr + 1); 442 rpu = (struct rr_pco_use *)(rpm + 1); 443 memset(rpu, 0, sizeof(*rpu)); 444 |
438 rpu->rpu_vltime = DEF_VLTIME; 439 rpu->rpu_pltime = DEF_PLTIME; | 445 rpu->rpu_vltime = htonl(DEF_VLTIME); 446 rpu->rpu_pltime = htonl(DEF_PLTIME); |
440 rpu->rpu_ramask = 0; 441 rpu->rpu_flags = 0; 442 } 443 | BCL vltime pltime raf_onlink raf_auto raf_decrvalid raf_decrprefd ECL 444 { 445 struct icmp6_router_renum *irr; 446 struct rr_pco_match *rpm; 447 struct rr_pco_use *rpu; --- 57 unchanged lines hidden (view full) --- 505 $$ = $2; 506 } 507 ; 508 509 510vltime: 511 /* empty */ 512 { | 447 rpu->rpu_ramask = 0; 448 rpu->rpu_flags = 0; 449 } 450 | BCL vltime pltime raf_onlink raf_auto raf_decrvalid raf_decrprefd ECL 451 { 452 struct icmp6_router_renum *irr; 453 struct rr_pco_match *rpm; 454 struct rr_pco_use *rpu; --- 57 unchanged lines hidden (view full) --- 512 $$ = $2; 513 } 514 ; 515 516 517vltime: 518 /* empty */ 519 { |
513 $$ = DEF_VLTIME; | 520 $$ = htonl(DEF_VLTIME); |
514 } 515 | VLTIME_CMD lifetime 516 { 517 $$ = htonl($2); 518 } 519 ; 520 521pltime: 522 /* empty */ 523 { | 521 } 522 | VLTIME_CMD lifetime 523 { 524 $$ = htonl($2); 525 } 526 ; 527 528pltime: 529 /* empty */ 530 { |
524 $$ = DEF_PLTIME; | 531 $$ = htonl(DEF_PLTIME); |
525 } 526 | PLTIME_CMD lifetime 527 { 528 $$ = htonl($2); 529 } 530 531raf_onlink: 532 /* empty */ --- 35 unchanged lines hidden (view full) --- 568 } 569 | RAF_DECRPREFD_CMD flag 570 { 571 $$ = $2; 572 } 573 ; 574 575flag: | 532 } 533 | PLTIME_CMD lifetime 534 { 535 $$ = htonl($2); 536 } 537 538raf_onlink: 539 /* empty */ --- 35 unchanged lines hidden (view full) --- 575 } 576 | RAF_DECRPREFD_CMD flag 577 { 578 $$ = $2; 579 } 580 ; 581 582flag: |
576 ON 577 | OFF | 583 ON { $$ = ON; } 584 | OFF { $$ = OFF; } |
578 ; 579 580lifetime: 581 decstring 582 | INFINITY 583 { 584 $$ = 0xffffffff; 585 } --- 62 unchanged lines hidden (view full) --- 648 continue; 649 return (pl); 650} 651 652static void 653pllist_enqueue(struct payload_list *pl_entry) 654{ 655 struct payload_list *pl, *pl_last; | 585 ; 586 587lifetime: 588 decstring 589 | INFINITY 590 { 591 $$ = 0xffffffff; 592 } --- 62 unchanged lines hidden (view full) --- 655 continue; 656 return (pl); 657} 658 659static void 660pllist_enqueue(struct payload_list *pl_entry) 661{ 662 struct payload_list *pl, *pl_last; |
656 if (pl_head == NULL) { 657 pl_head = pl_entry; 658 return; 659 } | 663 664 pl_last = NULL; |
660 for (pl = pl_head; 661 pl && pl->pl_irr.rr_seqnum < pl_entry->pl_irr.rr_seqnum; 662 pl_last = pl, pl = pl->pl_next) 663 continue; | 665 for (pl = pl_head; 666 pl && pl->pl_irr.rr_seqnum < pl_entry->pl_irr.rr_seqnum; 667 pl_last = pl, pl = pl->pl_next) 668 continue; |
664 pl_last->pl_next = pl_entry; | 669 if (pl_last) 670 pl_last->pl_next = pl_entry; 671 else 672 pl_head = pl_entry; |
665 666 return; 667} | 673 674 return; 675} |