parser.y (9a4365d0e0833374e893c519639bde71756aa104) parser.y (434d523b2d63281f9daf43fddcb5f009ac54800c)
1/* $KAME$ */
2
1/*
2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31
32%{
33#include <sys/param.h>
34#include <sys/ioctl.h>
35#include <sys/socket.h>
36#include <sys/uio.h>
37
38#include <net/if.h>
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:
10 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

33
34%{
35#include <sys/param.h>
36#include <sys/ioctl.h>
37#include <sys/socket.h>
38#include <sys/uio.h>
39
40#include <net/if.h>
41#if defined(__FreeBSD__) && __FreeBSD__ >= 3
39#include <net/if_var.h>
42#include <net/if_var.h>
43#endif /* __FreeBSD__ >= 3 */
40
41#include <netinet/in.h>
42#include <netinet/in_var.h>
43#include <netinet/icmp6.h>
44
45#include <netdb.h>
46#include <string.h>
47
48#include "rrenumd.h"
49
50struct config_is_set {
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>
51
52#include "rrenumd.h"
53
54struct config_is_set {
51 u_short cis_dest : 1;
55 u_short cis_dest : 1;
52} cis;
53
56} cis;
57
54struct dst_list *dl_head;
55struct payload_list *pl_head, ple_cur;
56u_int retry;
57char errbuf[LINE_MAX];
58struct dst_list *dl_head;
59struct payload_list *pl_head, ple_cur;
60u_int retry;
61char errbuf[LINE_MAX];
58
62
59extern int lineno;
60extern void yyerror __P((const char *s));
61static struct payload_list * pllist_lookup __P((int seqnum));
62static void pllist_enqueue __P((struct payload_list *pl_entry));
63extern int lineno;
64extern void yyerror __P((const char *s));
65static struct payload_list * pllist_lookup __P((int seqnum));
66static void pllist_enqueue __P((struct payload_list *pl_entry));
63
67
64#define MAX_RETRYNUM 10 /* upper limit of retry in this rrenumd program */
65#define MAX_SEQNUM 256 /* upper limit of seqnum in this rrenumd program */
66#define NOSPEC -1
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
67
68%}
69
70%union {
71
72%}
73
74%union {
71 u_long num;
75 u_long num;
72 struct {
76 struct {
73 char *cp;
74 int len;
77 char *cp;
78 int len;
75 } cs;
79 } cs;
76 struct in_addr addr4;
77 struct in6_addr addr6;
80 struct in_addr addr4;
81 struct in6_addr addr6;
78 struct {
82 struct {
79 struct in6_addr addr;
80 u_char plen;
83 struct in6_addr addr;
84 u_char plen;
81 } prefix;
85 } prefix;
82 struct dst_list *dl;
83 struct payload_list *pl;
84 struct sockaddr *sa;
86 struct dst_list *dl;
87 struct payload_list *pl;
88 struct sockaddr *sa;
85}
86
87%token <num> ADD CHANGE SETGLOBAL
88%token DEBUG_CMD DEST_CMD RETRY_CMD SEQNUM_CMD
89%token MATCH_PREFIX_CMD MAXLEN_CMD MINLEN_CMD
90%token USE_PREFIX_CMD KEEPLEN_CMD
91%token VLTIME_CMD PLTIME_CMD
92%token RAF_ONLINK_CMD RAF_AUTO_CMD RAF_DECRVALID_CMD RAF_DECRPREFD_CMD

--- 5 unchanged lines hidden (view full) ---

98%token <addr6> IPV6ADDR
99%token <num> PREFIXLEN
100
101%type <num> retrynum seqnum rrenum_cmd
102%type <num> prefixlen maxlen minlen keeplen vltime pltime
103%type <num> lifetime days hours minutes seconds
104%type <num> decstring
105%type <num> raf_onlink raf_auto raf_decrvalid raf_decrprefd flag
89}
90
91%token <num> ADD CHANGE SETGLOBAL
92%token DEBUG_CMD DEST_CMD RETRY_CMD SEQNUM_CMD
93%token MATCH_PREFIX_CMD MAXLEN_CMD MINLEN_CMD
94%token USE_PREFIX_CMD KEEPLEN_CMD
95%token VLTIME_CMD PLTIME_CMD
96%token RAF_ONLINK_CMD RAF_AUTO_CMD RAF_DECRVALID_CMD RAF_DECRPREFD_CMD

--- 5 unchanged lines hidden (view full) ---

102%token <addr6> IPV6ADDR
103%token <num> PREFIXLEN
104
105%type <num> retrynum seqnum rrenum_cmd
106%type <num> prefixlen maxlen minlen keeplen vltime pltime
107%type <num> lifetime days hours minutes seconds
108%type <num> decstring
109%type <num> raf_onlink raf_auto raf_decrvalid raf_decrprefd flag
106%type <dl> dest_addrs dest_addr sin6
110%type <dl> dest_addrs dest_addr sin sin6
107%type <pl> rrenum_statement
108%type <cs> ifname
109%type <prefix> prefixval
110
111%%
112config:
113 /* empty */
114 | statements

--- 38 unchanged lines hidden (view full) ---

153 | dest_addrs dest_addr
154 {
155 $2->dl_next = $1;
156 $$ = $2;
157 }
158 ;
159
160dest_addr :
111%type <pl> rrenum_statement
112%type <cs> ifname
113%type <prefix> prefixval
114
115%%
116config:
117 /* empty */
118 | statements

--- 38 unchanged lines hidden (view full) ---

157 | dest_addrs dest_addr
158 {
159 $2->dl_next = $1;
160 $$ = $2;
161 }
162 ;
163
164dest_addr :
161 sin6
165 sin
162 {
166 {
167 with_v4dest = 1;
168 }
169 | sin6
170 {
163 with_v6dest = 1;
164 }
165 | sin6 ifname
166 {
167 struct sockaddr_in6 *sin6;
168
169 sin6 = (struct sockaddr_in6 *)$1->dl_dst;
170 sin6->sin6_scope_id = if_nametoindex($2.cp);
171 with_v6dest = 1;
172 $$ = $1;
173 }
174 | HOSTNAME
175 {
176 struct sockaddr_storage *ss;
177 struct addrinfo hints, *res;
178 int error;
179
180 memset(&hints, 0, sizeof(hints));
181 hints.ai_flags = AI_CANONNAME;
171 with_v6dest = 1;
172 }
173 | sin6 ifname
174 {
175 struct sockaddr_in6 *sin6;
176
177 sin6 = (struct sockaddr_in6 *)$1->dl_dst;
178 sin6->sin6_scope_id = if_nametoindex($2.cp);
179 with_v6dest = 1;
180 $$ = $1;
181 }
182 | HOSTNAME
183 {
184 struct sockaddr_storage *ss;
185 struct addrinfo hints, *res;
186 int error;
187
188 memset(&hints, 0, sizeof(hints));
189 hints.ai_flags = AI_CANONNAME;
182 hints.ai_family = AF_INET6;
190 hints.ai_family = AF_UNSPEC;
183 hints.ai_socktype = SOCK_RAW;
184 hints.ai_protocol = 0;
185 error = getaddrinfo($1.cp, 0, &hints, &res);
186 if (error) {
187 sprintf(errbuf, "name resolution failed for %s"
188 ":%s", $1, gai_strerror(error));
189 yyerror(errbuf);
190 }

--- 4 unchanged lines hidden (view full) ---

195
196 $$ = (struct dst_list *)
197 malloc(sizeof(struct dst_list));
198 memset($$, 0, sizeof(struct dst_list));
199 $$->dl_dst = (struct sockaddr *)ss;
200 }
201 ;
202
191 hints.ai_socktype = SOCK_RAW;
192 hints.ai_protocol = 0;
193 error = getaddrinfo($1.cp, 0, &hints, &res);
194 if (error) {
195 sprintf(errbuf, "name resolution failed for %s"
196 ":%s", $1, gai_strerror(error));
197 yyerror(errbuf);
198 }

--- 4 unchanged lines hidden (view full) ---

203
204 $$ = (struct dst_list *)
205 malloc(sizeof(struct dst_list));
206 memset($$, 0, sizeof(struct dst_list));
207 $$->dl_dst = (struct sockaddr *)ss;
208 }
209 ;
210
211sin:
212 IPV4ADDR
213 {
214 struct sockaddr_in *sin;
215
216 sin = (struct sockaddr_in *)malloc(sizeof(*sin));
217 memset(sin, 0, sizeof(*sin));
218 sin->sin_len = sizeof(*sin);
219 sin->sin_family = AF_INET;
220 sin->sin_addr = $1;
221
222 $$ = (struct dst_list *)
223 malloc(sizeof(struct dst_list));
224 memset($$, 0, sizeof(struct dst_list));
225 $$->dl_dst = (struct sockaddr *)sin;
226 }
227 ;
228
203sin6:
204 IPV6ADDR
205 {
206 struct sockaddr_in6 *sin6;
207
208 sin6 = (struct sockaddr_in6 *)malloc(sizeof(*sin6));
209 memset(sin6, 0, sizeof(*sin6));
210 sin6->sin6_len = sizeof(*sin6);

--- 211 unchanged lines hidden (view full) ---

422
423 irr = (struct icmp6_router_renum *)&ple_cur.pl_irr;
424 rpm = (struct rr_pco_match *)(irr + 1);
425 rpu = (struct rr_pco_use *)(rpm + 1);
426 memset(rpu, 0, sizeof(*rpu));
427
428 rpu->rpu_vltime = $2;
429 rpu->rpu_pltime = $3;
229sin6:
230 IPV6ADDR
231 {
232 struct sockaddr_in6 *sin6;
233
234 sin6 = (struct sockaddr_in6 *)malloc(sizeof(*sin6));
235 memset(sin6, 0, sizeof(*sin6));
236 sin6->sin6_len = sizeof(*sin6);

--- 211 unchanged lines hidden (view full) ---

448
449 irr = (struct icmp6_router_renum *)&ple_cur.pl_irr;
450 rpm = (struct rr_pco_match *)(irr + 1);
451 rpu = (struct rr_pco_use *)(rpm + 1);
452 memset(rpu, 0, sizeof(*rpu));
453
454 rpu->rpu_vltime = $2;
455 rpu->rpu_pltime = $3;
430 if ($4 == NOSPEC)
456 if ($4 == NOSPEC) {
431 rpu->rpu_ramask &=
457 rpu->rpu_ramask &=
432 ~ICMP6_RR_PCOUSE_RAFLAGS_ONLINK;
433 else {
458 ~ICMP6_RR_PCOUSE_RAFLAGS_ONLINK;
459 } else {
434 rpu->rpu_ramask |=
460 rpu->rpu_ramask |=
435 ICMP6_RR_PCOUSE_RAFLAGS_ONLINK;
436 if ($4 == ON)
461 ICMP6_RR_PCOUSE_RAFLAGS_ONLINK;
462 if ($4 == ON) {
437 rpu->rpu_raflags |=
463 rpu->rpu_raflags |=
438 ICMP6_RR_PCOUSE_RAFLAGS_ONLINK;
439 else
464 ICMP6_RR_PCOUSE_RAFLAGS_ONLINK;
465 } else {
440 rpu->rpu_raflags &=
466 rpu->rpu_raflags &=
441 ~ICMP6_RR_PCOUSE_RAFLAGS_ONLINK;
467 ~ICMP6_RR_PCOUSE_RAFLAGS_ONLINK;
468 }
442 }
469 }
443 if ($5 == NOSPEC)
470 if ($5 == NOSPEC) {
444 rpu->rpu_ramask &=
471 rpu->rpu_ramask &=
445 ICMP6_RR_PCOUSE_RAFLAGS_AUTO;
446 else {
472 ICMP6_RR_PCOUSE_RAFLAGS_AUTO;
473 } else {
447 rpu->rpu_ramask |=
474 rpu->rpu_ramask |=
448 ICMP6_RR_PCOUSE_RAFLAGS_AUTO;
449 if ($5 == ON)
475 ICMP6_RR_PCOUSE_RAFLAGS_AUTO;
476 if ($5 == ON) {
450 rpu->rpu_raflags |=
477 rpu->rpu_raflags |=
451 ICMP6_RR_PCOUSE_RAFLAGS_AUTO;
452 else
478 ICMP6_RR_PCOUSE_RAFLAGS_AUTO;
479 } else {
453 rpu->rpu_raflags &=
480 rpu->rpu_raflags &=
454 ~ICMP6_RR_PCOUSE_RAFLAGS_AUTO;
481 ~ICMP6_RR_PCOUSE_RAFLAGS_AUTO;
482 }
455 }
456 rpu->rpu_flags = 0;
483 }
484 rpu->rpu_flags = 0;
457 if ($6 == ON)
485 if ($6 == ON) {
458 rpu->rpu_flags |=
486 rpu->rpu_flags |=
459 ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME;
460 if ($7 == ON)
487 ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME;
488 }
489 if ($7 == ON) {
461 rpu->rpu_flags |=
490 rpu->rpu_flags |=
462 ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME;
491 ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME;
492 }
463 }
464 ;
465
466keeplen:
467 /* empty */
468 {
469 $$ = 0;
470 }

--- 167 unchanged lines hidden ---
493 }
494 ;
495
496keeplen:
497 /* empty */
498 {
499 $$ = 0;
500 }

--- 167 unchanged lines hidden ---