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
31 * $FreeBSD: src/usr.sbin/rrenumd/lexer.l,v 1.1.2.2 2001/07/03 11:02:10 ume Exp $
32 * $DragonFly: src/usr.sbin/rrenumd/lexer.l,v 1.4 2004/02/10 02:59:43 rob Exp $
39 #include <sys/param.h>
40 #include <sys/ioctl.h>
41 #include <sys/socket.h>
42 #include <sys/queue.h>
47 #if defined(__DragonFly__)
48 #include <net/if_var.h>
49 #endif /* __DragonFly__ */
51 #include <netinet/in.h>
52 #include <netinet/in_var.h>
53 #include <netinet/icmp6.h>
55 #include <arpa/inet.h>
61 #define LINEBUF_SIZE 1000
62 char linebuf[LINEBUF_SIZE];
65 void yyerror(const char *);
83 usec {dot}{digit}{1,6}
87 hexpair {hexdigit}{hexdigit}
88 hexstring 0[xX]{hexdigit}+
89 octetstring {octet}({dot}{octet})+
90 ipv4addr {digit}{1,3}({dot}{digit}{1,3}){0,3}
91 ipv6addr {hexdigit}{0,4}({colon}{hexdigit}{0,4}){2,7}
92 ipaddrmask {slash}{digit}{1,3}
93 keyword {letter}{letter}+
94 name {letter}(({letter}|{digit}|{hyphen})*({letter}|{digit}))*
95 hostname {name}(({dot}{name})+{dot}?)?
103 mprefix match_prefix|match-prefix
104 uprefix use_prefix|use-prefix
107 /* rrenumd keywords */
121 yylval.num = RPM_PCO_ADD;
125 yylval.num = RPM_PCO_CHANGE;
129 yylval.num = RPM_PCO_SETGLOBAL;
133 return(MATCH_PREFIX_CMD);
142 return(USE_PREFIX_CMD);
155 return(RAF_ONLINK_CMD);
158 return(RAF_AUTO_CMD);
161 return(RAF_DECRVALID_CMD);
164 return(RAF_DECRPREFD_CMD);
168 yylval.num = atoi(yytext);
173 yylval.num = atoi(yytext);
178 yylval.num = atoi(yytext);
183 yylval.num = atoi(yytext);
214 yylval.cs.cp = yytext;
215 yylval.cs.len = yyleng;
219 yylval.cs.cp = yytext;
220 yylval.cs.len = yyleng;
224 yylval.cs.cp = yytext;
225 yylval.cs.len = yyleng;
229 memset(&yylval.addr4, 0, sizeof(struct in_addr));
230 if (inet_pton(AF_INET, yytext,
231 &yylval.addr4) == 1) {
238 memset(&yylval.addr6, 0, sizeof(struct in6_addr));
239 if (inet_pton(AF_INET6, yytext,
240 &yylval.addr6) == 1) {
248 yylval.num = atoi(yytext);
252 yylval.cs.cp = yytext;
253 yylval.cs.len = yyleng;
260 extern int yyparse(void);
272 yyerror(const char *s)
274 printf("%s: at %s in line %d\n", s, yytext, lineno);