1 /* $KAME: lexer.l,v 1.7 2000/11/08 02:40:53 itojun Exp $ */
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
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
37 #include <sys/param.h>
38 #include <sys/ioctl.h>
39 #include <sys/socket.h>
40 #include <sys/queue.h>
45 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
46 #include <net/if_var.h>
47 #endif /* __FreeBSD__ >= 3 */
49 #include <netinet/in.h>
50 #include <netinet/in_var.h>
51 #include <netinet/icmp6.h>
53 #include <arpa/inet.h>
59 #define LINEBUF_SIZE 1000
60 char linebuf[LINEBUF_SIZE];
63 void yyerror(const char *);
81 usec {dot}{digit}{1,6}
85 hexpair {hexdigit}{hexdigit}
86 hexstring 0[xX]{hexdigit}+
87 octetstring {octet}({dot}{octet})+
88 ipv4addr {digit}{1,3}({dot}{digit}{1,3}){0,3}
89 ipv6addr {hexdigit}{0,4}({colon}{hexdigit}{0,4}){2,7}
90 ipaddrmask {slash}{digit}{1,3}
91 keyword {letter}{letter}+
92 name {letter}(({letter}|{digit}|{hyphen})*({letter}|{digit}))*
93 hostname {name}(({dot}{name})+{dot}?)?
101 mprefix match_prefix|match-prefix
102 uprefix use_prefix|use-prefix
105 /* rrenumd keywords */
119 yylval.num = RPM_PCO_ADD;
123 yylval.num = RPM_PCO_CHANGE;
127 yylval.num = RPM_PCO_SETGLOBAL;
131 return(MATCH_PREFIX_CMD);
140 return(USE_PREFIX_CMD);
153 return(RAF_ONLINK_CMD);
156 return(RAF_AUTO_CMD);
159 return(RAF_DECRVALID_CMD);
162 return(RAF_DECRPREFD_CMD);
166 yylval.num = atoi(yytext);
171 yylval.num = atoi(yytext);
176 yylval.num = atoi(yytext);
181 yylval.num = atoi(yytext);
212 yylval.cs.cp = yytext;
213 yylval.cs.len = yyleng;
217 yylval.cs.cp = yytext;
218 yylval.cs.len = yyleng;
222 yylval.cs.cp = yytext;
223 yylval.cs.len = yyleng;
227 memset(&yylval.addr4, 0, sizeof(struct in_addr));
228 if (inet_pton(AF_INET, yytext,
229 &yylval.addr4) == 1) {
236 memset(&yylval.addr6, 0, sizeof(struct in6_addr));
237 if (inet_pton(AF_INET6, yytext,
238 &yylval.addr6) == 1) {
246 yylval.num = atoi(yytext);
250 yylval.cs.cp = yytext;
251 yylval.cs.len = yyleng;
258 extern int yyparse(void);
270 yyerror(const char *s)
272 printf("%s: at %s in line %d\n", s, yytext, lineno);