source: rtems-libbsd/freebsd-userspace/lib/libipsec/policy_token.l @ 0551981

4.1155-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since 0551981 was 0551981, checked in by Jennifer Averett <jennifer.averett@…>, on 10/11/12 at 14:03:25

Added files to get netshell to link when using ping.

  • Property mode set to 100644
File size: 4.5 KB
Line 
1/*      $FreeBSD$       */
2/*      $KAME: policy_token.l,v 1.13 2003/05/09 05:19:55 sakane Exp $   */
3
4/*
5 * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
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.
19 *
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
30 * SUCH DAMAGE.
31 */
32
33%{
34#include <sys/types.h>
35#include <sys/param.h>
36#include <sys/socket.h>
37#include <net/route.h>
38#ifdef __rtems__
39#include <freebsd/net/pfkeyv2.h>
40#include <freebsd/netipsec/keydb.h>
41#include <freebsd/netinet/in.h>
42#include <freebsd/netipsec/ipsec.h>
43#else
44#include <net/pfkeyv2.h>
45#include <netipsec/keydb.h>
46#include <netinet/in.h>
47#include <netipsec/ipsec.h>
48#endif
49
50#include <stdlib.h>
51#include <limits.h>
52#include <string.h>
53#include <unistd.h>
54#include <errno.h>
55
56#ifdef __rtems__
57#include "../../y.tab.h"
58/* XXX - Jennifer doesn't know where to get this from */
59YY_BUFFER_STATE yy_current_buffer;
60#else
61#include "y.tab.h"
62#endif
63
64#define yylval __libipsecyylval /* XXX */
65
66int yylex(void);
67%}
68
69%option noyywrap
70%option nounput
71
72/* common section */
73nl              \n
74ws              [ \t]+
75digit           [0-9]
76hexdigit        [0-9A-Fa-f]
77special         [()+\|\?\*,]
78dot             \.
79comma           \,
80hyphen          \-
81colon           \:
82slash           \/
83bcl             \{
84ecl             \}
85blcl            \[
86elcl            \]
87percent         \%
88semi            \;
89usec            {dot}{digit}{1,6}
90comment         \#.*
91ccomment        "/*"
92bracketstring   \<[^>]*\>
93quotedstring    \"[^"]*\"
94decstring       {digit}+
95hexpair         {hexdigit}{hexdigit}
96hexstring       0[xX]{hexdigit}+
97octetstring     {octet}({dot}{octet})+
98ipaddress       [a-zA-Z0-9:\._][a-zA-Z0-9:\._]*(%[a-zA-Z0-9]+)?
99
100%%
101
102in              { yylval.num = IPSEC_DIR_INBOUND; return(DIR); }
103out             { yylval.num = IPSEC_DIR_OUTBOUND; return(DIR); }
104
105discard         { yylval.num = IPSEC_POLICY_DISCARD; return(ACTION); }
106none            { yylval.num = IPSEC_POLICY_NONE; return(ACTION); }
107ipsec           { yylval.num = IPSEC_POLICY_IPSEC; return(ACTION); }
108bypass          { yylval.num = IPSEC_POLICY_BYPASS; return(ACTION); }
109entrust         { yylval.num = IPSEC_POLICY_ENTRUST; return(ACTION); }
110
111esp             { yylval.num = IPPROTO_ESP; return(PROTOCOL); }
112ah              { yylval.num = IPPROTO_AH; return(PROTOCOL); }
113ipcomp          { yylval.num = IPPROTO_IPCOMP; return(PROTOCOL); }
114tcp             { yylval.num = IPPROTO_TCP; return(PROTOCOL); }
115
116transport       { yylval.num = IPSEC_MODE_TRANSPORT; return(MODE); }
117tunnel          { yylval.num = IPSEC_MODE_TUNNEL; return(MODE); }
118
119me              { return(ME); }
120any             { return(ANY); }
121
122default         { yylval.num = IPSEC_LEVEL_DEFAULT; return(LEVEL); }
123use             { yylval.num = IPSEC_LEVEL_USE; return(LEVEL); }
124require         { yylval.num = IPSEC_LEVEL_REQUIRE; return(LEVEL); }
125unique{colon}{decstring} {
126                        yylval.val.len = strlen(yytext + 7);
127                        yylval.val.buf = yytext + 7;
128                        return(LEVEL_SPECIFY);
129                }
130unique          { yylval.num = IPSEC_LEVEL_UNIQUE; return(LEVEL); }
131{slash}         { return(SLASH); }
132
133{ipaddress}     {
134                        yylval.val.len = strlen(yytext);
135                        yylval.val.buf = yytext;
136                        return(IPADDRESS);
137                }
138
139{hyphen}        { return(HYPHEN); }
140
141{ws}            { ; }
142{nl}            { ; }
143
144%%
145
146void __policy__strbuffer__init__(char *);
147void __policy__strbuffer__free__(void);
148
149static YY_BUFFER_STATE strbuffer;
150
151void
152__policy__strbuffer__init__(msg)
153        char *msg;
154{
155        if (yy_current_buffer)
156                yy_delete_buffer(yy_current_buffer);
157        strbuffer = (YY_BUFFER_STATE)yy_scan_string(msg);
158        yy_switch_to_buffer(strbuffer);
159
160        return;
161}
162
163void
164__policy__strbuffer__free__()
165{
166        yy_delete_buffer(strbuffer);
167
168        return;
169}
Note: See TracBrowser for help on using the repository browser.