1 /* $FreeBSD: src/lib/libipsec/policy_token.l,v 1.2.2.2 2001/07/03 11:01:15 ume Exp $ */
2 /* $KAME: policy_token.l,v 1.11 2000/12/01 10:08:29 sakane Exp $ */
5 * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the project nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include <sys/types.h>
35 #include <sys/param.h>
36 #include <sys/socket.h>
37 #include <net/route.h>
38 #include <net/pfkeyv2.h>
39 #include <netinet/in.h>
40 #include <netinet6/ipsec.h>
51 #include "policy_parse.h"
53 #define yylval __libipsecyylval /* XXX */
55 int yylex __P((void));
78 usec {dot}{digit}{1,6}
81 bracketstring \<[^>]*\>
82 quotedstring \"[^"]*\"
84 hexpair {hexdigit}{hexdigit}
85 hexstring 0[xX]{hexdigit}+
86 octetstring {octet}({dot}{octet})+
87 ipaddress [a-zA-Z0-9:\._][a-zA-Z0-9:\._]*(%[a-zA-Z0-9]+)?
91 in { yylval.num = IPSEC_DIR_INBOUND; return(DIR); }
92 out { yylval.num = IPSEC_DIR_OUTBOUND; return(DIR); }
94 discard { yylval.num = IPSEC_POLICY_DISCARD; return(ACTION); }
95 none { yylval.num = IPSEC_POLICY_NONE; return(ACTION); }
96 ipsec { yylval.num = IPSEC_POLICY_IPSEC; return(ACTION); }
97 bypass { yylval.num = IPSEC_POLICY_BYPASS; return(ACTION); }
98 entrust { yylval.num = IPSEC_POLICY_ENTRUST; return(ACTION); }
100 esp { yylval.num = IPPROTO_ESP; return(PROTOCOL); }
101 ah { yylval.num = IPPROTO_AH; return(PROTOCOL); }
102 ipcomp { yylval.num = IPPROTO_IPCOMP; return(PROTOCOL); }
104 transport { yylval.num = IPSEC_MODE_TRANSPORT; return(MODE); }
105 tunnel { yylval.num = IPSEC_MODE_TUNNEL; return(MODE); }
110 default { yylval.num = IPSEC_LEVEL_DEFAULT; return(LEVEL); }
111 use { yylval.num = IPSEC_LEVEL_USE; return(LEVEL); }
112 require { yylval.num = IPSEC_LEVEL_REQUIRE; return(LEVEL); }
113 unique{colon}{decstring} {
114 yylval.val.len = strlen(yytext + 7);
115 yylval.val.buf = yytext + 7;
116 return(LEVEL_SPECIFY);
118 unique { yylval.num = IPSEC_LEVEL_UNIQUE; return(LEVEL); }
119 {slash} { return(SLASH); }
122 yylval.val.len = strlen(yytext);
123 yylval.val.buf = yytext;
127 {hyphen} { return(HYPHEN); }
134 void __policy__strbuffer__init__ __P((char *));
137 __policy__strbuffer__init__(msg)
142 if (yy_current_buffer)
143 yy_delete_buffer(yy_current_buffer);
144 yyb = (YY_BUFFER_STATE)yy_scan_string(msg);
145 yy_switch_to_buffer(yyb);