This repository has been archived by the owner on Aug 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscanner.l
154 lines (122 loc) · 4.1 KB
/
scanner.l
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
*
* Authors:
* Pedro Roque <[email protected]>
* Lars Fenneberg <[email protected]>
*
* This software is Copyright 1996-2000 by the above mentioned author(s),
* All Rights Reserved.
*
* The license which is distributed with this software in the file COPYRIGHT
* applies to this software. If your distribution is missing this file, you
* may request it from <[email protected]>.
*
*/
%option nounput noinput noyywrap
%{
#include "config.h"
#include "includes.h"
#include "log.h"
#include "gram.h"
extern char *conf_file;
int num_lines = 1;
%}
digit [0-9]
number ({digit})+
snum -?({digit})+
decimal ({number}"."{number})
hexdigit ([a-f]|[A-F]|[0-9])
addr1 {hexdigit}{1,4}":"({hexdigit}{1,4}":")*(":"{hexdigit}{1,4})+
addr2 {hexdigit}{1,4}(":"{hexdigit}{1,4})*"::"
addr3 ({hexdigit}{1,4}":"){7}{hexdigit}{1,4}
addr ({addr1}|{addr2}|{addr3}|"::")
whitespace ([ \t])+
string [a-zA-Z0-9`~!@#$%\^&*()_\-+=:\[\]<>,\.?\\]+
%%
#.*$ {/* ignore comments */}
\n {num_lines++;}
{whitespace} {}
interface { return T_INTERFACE; }
prefix { return T_PREFIX; }
route { return T_ROUTE; }
RDNSS { return T_RDNSS; }
DNSSL { return T_DNSSL; }
clients { return T_CLIENTS; }
IgnoreIfMissing { return T_IgnoreIfMissing; }
AdvSendAdvert { return T_AdvSendAdvert; }
MaxRtrAdvInterval { return T_MaxRtrAdvInterval; }
MinRtrAdvInterval { return T_MinRtrAdvInterval; }
AdvManagedFlag { return T_AdvManagedFlag; }
AdvOtherConfigFlag { return T_AdvOtherConfigFlag; }
AdvLinkMTU { return T_AdvLinkMTU; }
AdvReachableTime { return T_AdvReachableTime; }
AdvRetransTimer { return T_AdvRetransTimer; }
AdvCurHopLimit { return T_AdvCurHopLimit; }
AdvDefaultLifetime { return T_AdvDefaultLifetime; }
AdvDefaultPreference { return T_AdvDefaultPreference; }
AdvSourceLLAddress { return T_AdvSourceLLAddress; }
AdvOnLink { return T_AdvOnLink; }
AdvAutonomous { return T_AdvAutonomous; }
AdvValidLifetime { return T_AdvValidLifetime; }
AdvPreferredLifetime { return T_AdvPreferredLifetime; }
DeprecatePrefix { return T_DeprecatePrefix; }
DecrementLifetimes { return T_DecrementLifetimes; }
AdvRouterAddr { return T_AdvRouterAddr; }
AdvHomeAgentFlag { return T_AdvHomeAgentFlag; }
AdvIntervalOpt { return T_AdvIntervalOpt; }
AdvHomeAgentInfo { return T_AdvHomeAgentInfo; }
UnicastOnly { return T_UnicastOnly; }
Base6Interface { return T_Base6Interface; }
Base6to4Interface { return T_Base6to4Interface; }
HomeAgentPreference { return T_HomeAgentPreference; }
HomeAgentLifetime { return T_HomeAgentLifetime; }
AdvRoutePreference { return T_AdvRoutePreference; }
AdvRouteLifetime { return T_AdvRouteLifetime; }
RemoveRoute { return T_RemoveRoute; }
AdvRDNSSPreference { return T_AdvRDNSSPreference; }
AdvRDNSSOpen { return T_AdvRDNSSOpenFlag; }
AdvRDNSSLifetime { return T_AdvRDNSSLifetime; }
FlushRDNSS { return T_FlushRDNSS; }
AdvDNSSLLifetime { return T_AdvDNSSLLifetime; }
FlushDNSSL { return T_FlushDNSSL; }
MinDelayBetweenRAs { return T_MinDelayBetweenRAs; }
AdvMobRtrSupportFlag { return T_AdvMobRtrSupportFlag; }
{addr} {
static struct in6_addr addr;
if (inet_pton(AF_INET6, yytext, &addr) < 1) {
flog(LOG_ERR, "invalid address in %s, line %d", conf_file,
num_lines);
return T_BAD_TOKEN;
}
yylval.addr = &addr;
return IPV6ADDR;
}
{number} {
unsigned long lnum;
char *endp;
lnum = strtoul(yytext, &endp, 10);
if (*yytext == '\0' || *endp != '\0')
return T_BAD_TOKEN;
if (lnum > 0xFFFFFFFFUL)
return T_BAD_TOKEN; /* XXX */
yylval.num = lnum;
return NUMBER;
}
{snum} { yylval.snum = atoi(yytext); return SIGNEDNUMBER; }
{decimal} { yylval.dec = atof(yytext); return DECIMAL; }
infinity { return INFINITY; }
on { yylval.num = 1; return SWITCH; }
off { yylval.num = 0; return SWITCH; }
low { yylval.snum = -1; return SIGNEDNUMBER; }
medium { yylval.snum = 0; return SIGNEDNUMBER; }
high { yylval.snum = 1; return SIGNEDNUMBER; }
{string} {
static char string[256];
strncpy(string, yytext, sizeof(string));
string[sizeof(string)-1] = '\0';
yylval.str = string;
return STRING;
}
"{"|"}"|";"|"/" { return *yytext; }
. { return T_BAD_TOKEN; }
%%