5 * The contents of this file are subject to the terms of the
6 * Common Development and Distribution License (the "License").
7 * You may not use this file except in compliance with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
24 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
30 #include <sys/types.h>
32 #include "nwamcfg_grammar.tab.h"
34 int lex_lineno = 1; /* line number for error reporting */
35 static int state = INITIAL;
36 extern boolean_t cmd_file_mode;
38 extern void yyerror(char *s);
39 char *safe_strdup(char *s);
50 * The state below are for tokens.
56 <INITIAL>"#"[^\n]* { }
155 <TSTATE>[Ll][Oo][Cc] { return LOC; }
156 <TSTATE>[Nn][Cc][Pp] { return NCP; }
157 <TSTATE>[Ee][Nn][Mm] { return ENM; }
158 <TSTATE>[Ww][Ll][Aa][Nn] { return WLAN; }
160 <TSTATE>[Nn][Cc][Uu] { return NCU; }
162 <TSTATE>[Pp][Hh][Yy][Ss] { return PHYS; }
163 <TSTATE>[Ii][Pp] { return IP; }
165 <TSTATE>unknown { return UNKNOWN; }
166 <TSTATE>activation-mode { return ACTIVATION_MODE; }
167 <TSTATE>conditions { return CONDITIONS; }
168 <TSTATE>enabled { return ENABLED; }
170 <TSTATE>type { return TYPE; }
171 <TSTATE>class { return CLASS; }
172 <TSTATE>parent { return PARENT; }
173 <TSTATE>priority-group { return PRIORITY_GROUP; }
174 <TSTATE>priority-mode { return PRIORITY_MODE; }
175 <TSTATE>link-mac-addr { return LINK_MACADDR; }
176 <TSTATE>link-autopush { return LINK_AUTOPUSH; }
177 <TSTATE>link-mtu { return LINK_MTU; }
178 <TSTATE>ip-version { return IP_VERSION; }
179 <TSTATE>ipv4-addrsrc { return IPV4_ADDRSRC; }
180 <TSTATE>ipv4-addr { return IPV4_ADDR; }
181 <TSTATE>ipv4-default-route { return IPV4_DEFAULT_ROUTE; }
182 <TSTATE>ipv6-addrsrc { return IPV6_ADDRSRC; }
183 <TSTATE>ipv6-addr { return IPV6_ADDR; }
184 <TSTATE>ipv6-default-route { return IPV6_DEFAULT_ROUTE; }
186 <TSTATE>state { return ENM_STATE; }
187 <TSTATE>fmri { return ENM_FMRI; }
188 <TSTATE>start { return ENM_START; }
189 <TSTATE>stop { return ENM_STOP; }
191 <TSTATE>nameservices { return LOC_NAMESERVICES; }
192 <TSTATE>nameservices-config-file { return LOC_NAMESERVICES_CONFIG; }
193 <TSTATE>dns-nameservice-configsrc { return LOC_DNS_CONFIGSRC; }
194 <TSTATE>dns-nameservice-domain { return LOC_DNS_DOMAIN; }
195 <TSTATE>dns-nameservice-servers { return LOC_DNS_SERVERS; }
196 <TSTATE>dns-nameservice-search { return LOC_DNS_SEARCH; }
197 <TSTATE>nis-nameservice-configsrc { return LOC_NIS_CONFIGSRC; }
198 <TSTATE>nis-nameservice-servers { return LOC_NIS_SERVERS; }
199 <TSTATE>ldap-nameservice-configsrc { return LOC_LDAP_CONFIGSRC; }
200 <TSTATE>ldap-nameservice-servers { return LOC_LDAP_SERVERS; }
201 <TSTATE>default-domain { return LOC_DEFAULT_DOMAIN; }
202 <TSTATE>nfsv4-domain { return LOC_NFSV4_DOMAIN; }
203 <TSTATE>ipfilter-config-file { return LOC_IPF_CONFIG; }
204 <TSTATE>ipfilter-v6-config-file { return LOC_IPF_V6_CONFIG; }
205 <TSTATE>ipnat-config-file { return LOC_IPNAT_CONFIG; }
206 <TSTATE>ippool-config-file { return LOC_IPPOOL_CONFIG; }
207 <TSTATE>ike-config-file { return LOC_IKE_CONFIG; }
208 <TSTATE>ipsecpolicy-config-file { return LOC_IPSECPOL_CONFIG; }
210 <TSTATE>bssids { return WLAN_BSSIDS; }
211 <TSTATE>priority { return WLAN_PRIORITY; }
212 <TSTATE>keyname { return WLAN_KEYNAME; }
213 <TSTATE>keyslot { return WLAN_KEYSLOT; }
214 <TSTATE>security-mode { return WLAN_SECURITY_MODE; }
216 <TSTATE>= { return EQUAL; }
218 <TSTATE>\-[adftV] { /* matches options */
219 yylval.strval = safe_strdup(yytext);
223 <TSTATE>[^ \t\n\";=\[\]\(\)]+ { /* matches non-quoted values */
224 yylval.strval = safe_strdup(yytext);
228 <TSTATE>\"[^\"\n]*[\"\n] { /* matches string with quotes */
229 yylval.strval = safe_strdup(yytext);
233 <TSTATE>\".*\"\,\".*\" { /* matches string list of the form "a","b",.. */
234 yylval.strval = safe_strdup(yytext);
249 [ \t] ; /* ignore white space */
251 . { /* matches all single otherwise unmatched characters */
262 if ((result = strdup(s)) == NULL) {
263 yyerror("Out of memory");
272 /* feof(yyin) is not an error; anything else is, so we set saw_error */
273 if (yytext[0] == '\0') {
276 (void) fprintf(stderr, gettext("%s, token expected\n"),
284 (void) fprintf(stderr, gettext("%s on line %d at '%s'\n"), s,
285 lex_lineno, (yytext[0] == '\n') ? "\\n" : yytext);
287 (void) fprintf(stderr, gettext("%s at '%s'\n\n"), s,
288 (yytext[0] == '\n') ? "\\n" : yytext);