Merge branch 'tomato-ND-USBmod' into tomato-RT
[tomato.git] / release / src / router / radvd / scanner.l
blob35ec8bbf7bdee6ef91e36cf730a815be3322f3d4
1 /*
2  *   $Id: scanner.l,v 1.29 2011/05/07 02:09:40 reubenhwk Exp $
3  *
4  *   Authors:
5  *    Pedro Roque               <roque@di.fc.ul.pt>
6  *    Lars Fenneberg            <lf@elemental.net>
7  *
8  *   This software is Copyright 1996-2000 by the above mentioned author(s),
9  *   All Rights Reserved.
10  *
11  *   The license which is distributed with this software in the file COPYRIGHT
12  *   applies to this software. If your distribution is missing this file, you
13  *   may request it from <pekkas@netcore.fi>.
14  *
15  */
17 %option nounput noinput noyywrap
20 #include <string.h>
21 #include "config.h"
22 #include "includes.h"
23 #include "log.h"
24 #include "gram.h"
26 extern char *conf_file;
28 int num_lines = 1;
30 #define YY_NO_INPUT
33 digit           [0-9]
34 number          ({digit})+
35 snum            -?({digit})+
36 decimal         ({number}"."{number})
37 hexdigit        ([a-f]|[A-F]|[0-9])
38 addr1           {hexdigit}{1,4}":"({hexdigit}{1,4}":")*(":"{hexdigit}{1,4})+
39 addr2           {hexdigit}{1,4}(":"{hexdigit}{1,4})*"::"
40 addr3           ({hexdigit}{1,4}":"){7}{hexdigit}{1,4}
41 addr            ({addr1}|{addr2}|{addr3}|"::")
42 whitespace      ([ \t])+
43 string          [a-zA-Z0-9`~!@#$%\^&*()_\-+=:\[\]<>,\.?\\]+
46 #.*$                    {/* ignore comments */}
47 \n                      {num_lines++;}
48 {whitespace}            {}
50 interface               { return T_INTERFACE; }
51 prefix                  { return T_PREFIX; }
52 route                   { return T_ROUTE; }
53 RDNSS                   { return T_RDNSS; }
54 DNSSL                   { return T_DNSSL; }
55 clients                 { return T_CLIENTS; }
57 IgnoreIfMissing         { return T_IgnoreIfMissing; }
58 AdvSendAdvert           { return T_AdvSendAdvert; }
59 MaxRtrAdvInterval       { return T_MaxRtrAdvInterval; }
60 MinRtrAdvInterval       { return T_MinRtrAdvInterval; }
61 AdvManagedFlag          { return T_AdvManagedFlag; }
62 AdvOtherConfigFlag      { return T_AdvOtherConfigFlag; }
63 AdvLinkMTU              { return T_AdvLinkMTU; }
64 AdvReachableTime        { return T_AdvReachableTime; }
65 AdvRetransTimer         { return T_AdvRetransTimer; }
66 AdvCurHopLimit          { return T_AdvCurHopLimit; }
67 AdvDefaultLifetime      { return T_AdvDefaultLifetime; }
68 AdvDefaultPreference    { return T_AdvDefaultPreference; }
69 AdvSourceLLAddress      { return T_AdvSourceLLAddress; }
71 AdvOnLink               { return T_AdvOnLink; }
72 AdvAutonomous           { return T_AdvAutonomous; }
73 AdvValidLifetime        { return T_AdvValidLifetime; }
74 AdvPreferredLifetime    { return T_AdvPreferredLifetime; }
75 DeprecatePrefix         { return T_DeprecatePrefix; }
76 DecrementLifetimes      { return T_DecrementLifetimes; }
78 AdvRouterAddr           { return T_AdvRouterAddr; }
79 AdvHomeAgentFlag        { return T_AdvHomeAgentFlag; }
80 AdvIntervalOpt          { return T_AdvIntervalOpt; }
81 AdvHomeAgentInfo        { return T_AdvHomeAgentInfo; }
82 UnicastOnly             { return T_UnicastOnly; }
84 Base6Interface          { return T_Base6Interface; }
85 Base6to4Interface       { return T_Base6to4Interface; }
87 HomeAgentPreference     { return T_HomeAgentPreference; }
88 HomeAgentLifetime       { return T_HomeAgentLifetime; }
90 AdvRoutePreference      { return T_AdvRoutePreference; }
91 AdvRouteLifetime        { return T_AdvRouteLifetime; }
92 RemoveRoute             { return T_RemoveRoute; }
94 AdvRDNSSPreference      { return T_AdvRDNSSPreference; }
95 AdvRDNSSOpen            { return T_AdvRDNSSOpenFlag; }
96 AdvRDNSSLifetime        { return T_AdvRDNSSLifetime; }
97 FlushRDNSS              { return T_FlushRDNSS; }
99 AdvDNSSLLifetime        { return T_AdvDNSSLLifetime; }
100 FlushDNSSL              { return T_FlushDNSSL; }
102 MinDelayBetweenRAs      { return T_MinDelayBetweenRAs; }
104 AdvMobRtrSupportFlag    { return T_AdvMobRtrSupportFlag; }
106 {addr}          {
107                         static struct in6_addr addr;
108                         if (inet_pton(AF_INET6, yytext, &addr) < 1) {
109                                 flog(LOG_ERR, "invalid address in %s, line %d", conf_file,
110                                         num_lines);
111                                 return T_BAD_TOKEN;
112                         }
114                         yylval.addr = &addr;
115                         return IPV6ADDR;
116                 }
118 {number}        {
119                         unsigned long lnum;
120                         char *endp;
121                         lnum = strtoul(yytext, &endp, 10);
122                         if (*yytext == '\0' || *endp != '\0')
123                                 return T_BAD_TOKEN;
124                         if (lnum > 0xFFFFFFFFUL)
125                                 return T_BAD_TOKEN;     /* XXX */
126                         yylval.num = lnum;
127                         return NUMBER;
128                 }
130 {snum}          { yylval.snum = atoi(yytext); return SIGNEDNUMBER; }
132 {decimal}       { yylval.dec = atof(yytext); return DECIMAL; }
134 infinity        { return INFINITY; }
136 on                      { yylval.num = 1; return SWITCH; }
138 off                     { yylval.num = 0; return SWITCH; }
140 low             { yylval.snum = -1; return SIGNEDNUMBER; }
142 medium          { yylval.snum = 0; return SIGNEDNUMBER; }
144 high            { yylval.snum = 1; return SIGNEDNUMBER; }
146 {string}        {
147                         static char string[256];
149                         strncpy(string, yytext, sizeof(string));
150                         string[sizeof(string)-1] = '\0';
151                         yylval.str = string;
152                         return STRING;
153                 }
155 "{"|"}"|";"|"/" { return *yytext; }
157 .               { return T_BAD_TOKEN; }