1 /* $KAME: lexer.l,v 1.7 2000/11/08 02:40:53 itojun Exp $ */
4 * SPDX-License-Identifier: BSD-3-Clause
6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the project nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/param.h>
36 #include <sys/ioctl.h>
37 #include <sys/socket.h>
38 #include <sys/queue.h>
43 #include <netinet/in.h>
44 #include <netinet/in_var.h>
45 #include <netinet/icmp6.h>
47 #include <arpa/inet.h>
53 #define LINEBUF_SIZE 1000
54 char linebuf[LINEBUF_SIZE];
57 void yyerror(const char *);
78 usec {dot}{digit}{1,6}
82 hexpair {hexdigit}{hexdigit}
83 hexstring 0[xX]{hexdigit}+
84 octetstring {octet}({dot}{octet})+
85 ipv4addr {digit}{1,3}({dot}{digit}{1,3}){0,3}
86 ipv6addr {hexdigit}{0,4}({colon}{hexdigit}{0,4}){2,7}
87 ipaddrmask {slash}{digit}{1,3}
88 keyword {letter}{letter}+
89 name {letter}(({letter}|{digit}|{hyphen})*({letter}|{digit}))*
90 hostname {name}(({dot}{name})+{dot}?)?
98 mprefix match_prefix|match-prefix
99 uprefix use_prefix|use-prefix
102 /* rrenumd keywords */
116 yylval.num = RPM_PCO_ADD;
120 yylval.num = RPM_PCO_CHANGE;
124 yylval.num = RPM_PCO_SETGLOBAL;
128 return(MATCH_PREFIX_CMD);
137 return(USE_PREFIX_CMD);
150 return(RAF_ONLINK_CMD);
153 return(RAF_AUTO_CMD);
156 return(RAF_DECRVALID_CMD);
159 return(RAF_DECRPREFD_CMD);
163 yylval.num = atoi(yytext);
168 yylval.num = atoi(yytext);
173 yylval.num = atoi(yytext);
178 yylval.num = atoi(yytext);
209 yylval.cs.cp = yytext;
210 yylval.cs.len = yyleng;
214 yylval.cs.cp = yytext;
215 yylval.cs.len = yyleng;
219 yylval.cs.cp = yytext;
220 yylval.cs.len = yyleng;
224 memset(&yylval.addr4, 0, sizeof(struct in_addr));
225 if (inet_pton(AF_INET, yytext,
226 &yylval.addr4) == 1) {
233 memset(&yylval.addr6, 0, sizeof(struct in6_addr));
234 if (inet_pton(AF_INET6, yytext,
235 &yylval.addr6) == 1) {
243 yylval.num = atoi(yytext);
247 yylval.cs.cp = yytext;
248 yylval.cs.len = yyleng;
255 extern int yyparse(void);
267 yyerror(const char *s)
269 printf("%s: at %s in line %d\n", s, yytext, lineno);