OSDN Git Service

Add MS7619SE
[uclinux-h8/uClinux-dist.git] / user / radvd / scanner.l
1 /*
2  *   $Id: scanner.l,v 1.6 2002/07/11 21:26:16 lutchann 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 <lutchann@litech.org>.
14  *
15  */
16 %{
17 #include <config.h>
18 #include <includes.h>
19 #include <radvd.h>
20 #include <gram.h>
21
22 extern char *conf_file;
23
24 int num_lines = 1;
25 %}
26
27 digit           [0-9]
28 number          ({digit})+
29 snum            -?({digit})+
30 decimal         ({number}"."{number})
31 hexdigit        ([a-f]|[A-F]|[0-9])
32 addr1           {hexdigit}{1,4}":"({hexdigit}{1,4}":")*(":"{hexdigit}{1,4})+
33 addr2           {hexdigit}{1,4}(":"{hexdigit}{1,4})*"::"
34 addr3           ({hexdigit}{1,4}":"){7}{hexdigit}{1,4}
35 addr            ({addr1}|{addr2}|{addr3}|"::")
36 whitespace      ([ \t])+
37 string          [a-z]([a-z]|{digit})*([:.]{digit}+)?
38 filepath        \"[^"\n]+\"
39 %%
40
41 #.*$                    {/* ignore comments */}
42 \n                      {num_lines++;}
43 {whitespace}            {}
44
45 interface               { return T_INTERFACE; }
46 prefix                  { return T_PREFIX; }
47
48 AdvSendAdvert           { return T_AdvSendAdvert; }
49 MaxRtrAdvInterval       { return T_MaxRtrAdvInterval; }
50 MinRtrAdvInterval       { return T_MinRtrAdvInterval; }
51 AdvManagedFlag          { return T_AdvManagedFlag; }
52 AdvOtherConfigFlag      { return T_AdvOtherConfigFlag; }
53 AdvLinkMTU              { return T_AdvLinkMTU; }
54 AdvReachableTime        { return T_AdvReachableTime; }
55 AdvRetransTimer         { return T_AdvRetransTimer; }
56 AdvCurHopLimit          { return T_AdvCurHopLimit; }
57 AdvDefaultLifetime      { return T_AdvDefaultLifetime; }
58 AdvSourceLLAddress      { return T_AdvSourceLLAddress; }
59
60 AdvOnLink               { return T_AdvOnLink; }
61 AdvAutonomous           { return T_AdvAutonomous; }
62 AdvValidLifetime        { return T_AdvValidLifetime; }
63 AdvPreferredLifetime    { return T_AdvPreferredLifetime; }
64
65 AdvRouterAddr           { return T_AdvRouterAddr; }
66 AdvHomeAgentFlag        { return T_AdvHomeAgentFlag; }
67 AdvIntervalOpt          { return T_AdvIntervalOpt; }
68 AdvHomeAgentInfo        { return T_AdvHomeAgentInfo; }
69 UnicastOnly             { return T_UnicastOnly; }
70
71 Base6to4Interface       { return T_Base6to4Interface; }
72
73 HomeAgentPreference     { return T_HomeAgentPreference; }
74 HomeAgentLifetime       { return T_HomeAgentLifetime; }
75
76 {addr}          {
77                         static struct in6_addr addr;
78                         int i;
79                                 
80                         i = inet_pton(AF_INET6, yytext, &addr);
81
82                         dlog(LOG_DEBUG, 4, "inet_pton returned %d", i);
83
84                         /* BSD API draft and NRL's code don't aggree on
85                          * this. the draft specifies a return value of 1 on 
86                          * success, NRL's code returns the address length in 
87                          * bytes on success (16 for an IPv6 address)
88                          */
89                         if (i < 1) {
90                                 log(LOG_ERR, "invalid address in %s, line %d", conf_file,
91                                         num_lines);
92                                 return T_BAD_TOKEN;
93                         }
94
95                         yylval.addr = &addr;
96                         return IPV6ADDR;
97                 }
98
99 {number}        { yylval.num = atoi(yytext); return NUMBER; }
100
101 {snum}          { yylval.snum = atoi(yytext); return SIGNEDNUMBER; }
102
103 {decimal}       { yylval.dec = atof(yytext); return DECIMAL; }
104
105 infinity        { return INFINITY; }
106
107 on                      { yylval.bool = 1; return SWITCH; }
108
109 off                     { yylval.bool = 0; return SWITCH; }
110
111 {string}        {
112                         static char name[IFNAMSIZ];
113                                 
114                         strncpy(name, yytext, IFNAMSIZ-1);
115                         name[IFNAMSIZ-1] = '\0';
116                         yylval.str = name;
117                         return STRING;
118                 }
119
120 {filepath}      {
121                         static char filepath[MAXPATHLEN];
122                         int len;
123
124                         len = yyleng-2;
125                         if (len < 0)
126                                 len = 0;
127                         if (len >= MAXPATHLEN)
128                                 len = MAXPATHLEN-1;
129                         strncpy(filepath, yytext+1, len);
130                         filepath[len] = '\0';
131                         yylval.str = filepath;
132                         return FILEPATH;
133                 }
134
135 "{"|"}"|";"|"/" { return *yytext; }
136
137 .               { return T_BAD_TOKEN; }
138 %%