xref: /illumos-gate/usr/src/cmd/cmd-inet/usr.sbin/nwamcfg/nwamcfg_grammar.y (revision 132157d7fb25c120ae1deca2a65fa7c78e8fcfd0)
1 %{
2 /*
3  * CDDL HEADER START
4  *
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.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #include <stdio.h>
29 #include <sys/types.h>
30 
31 #include "nwamcfg.h"
32 
33 static cmd_t *cmd = NULL;		/* Command being processed */
34 
35 /* yacc externals */
36 extern int yydebug;
37 extern void yyerror(char *s);
38 
39 extern boolean_t newline_terminated;
40 
41 %}
42 
43 %union {
44 	int ival;
45 	char *strval;
46 	cmd_t *cmd;
47 }
48 
49 %start commands
50 
51 %token CANCEL CLEAR COMMIT CREATE DESTROY END EXIT EXPORT GET HELP
52 %token LIST REVERT SELECT SET VERIFY WALKPROP
53 %token LOC NCP NCU ENM WLAN
54 %token PHYS IP
55 %token TOKEN EQUAL OPTION
56 %token UNKNOWN ACTIVATION_MODE CONDITIONS ENABLED
57 %token TYPE CLASS PARENT PRIORITY_GROUP PRIORITY_MODE
58 %token LINK_MACADDR LINK_AUTOPUSH LINK_MTU
59 %token IP_VERSION IPV4_ADDRSRC IPV4_ADDR IPV4_DEFAULT_ROUTE
60 %token IPV6_ADDRSRC IPV6_ADDR IPV6_DEFAULT_ROUTE
61 %token ENM_STATE ENM_FMRI ENM_START ENM_STOP
62 %token LOC_NAMESERVICES LOC_NAMESERVICES_CONFIG
63 %token LOC_DNS_CONFIGSRC LOC_DNS_DOMAIN LOC_DNS_SERVERS LOC_DNS_SEARCH
64 %token LOC_NIS_CONFIGSRC LOC_NIS_SERVERS
65 %token LOC_LDAP_CONFIGSRC LOC_LDAP_SERVERS
66 %token LOC_DEFAULT_DOMAIN LOC_NFSV4_DOMAIN
67 %token LOC_IPF_CONFIG LOC_IPF_V6_CONFIG
68 %token LOC_IPNAT_CONFIG LOC_IPPOOL_CONFIG LOC_IKE_CONFIG LOC_IPSECPOL_CONFIG
69 %token WLAN_BSSIDS WLAN_PRIORITY WLAN_KEYNAME WLAN_KEYSLOT WLAN_SECURITY_MODE
70 
71 %type <strval> TOKEN EQUAL OPTION
72 %type <ival> resource1_type LOC NCP ENM WLAN
73 %type <ival> resource2_type NCU
74 %type <ival> ncu_class_type PHYS IP
75 %type <ival> property_type UNKNOWN ACTIVATION_MODE CONDITIONS ENABLED
76     TYPE CLASS PARENT PRIORITY_GROUP PRIORITY_MODE
77     LINK_MACADDR LINK_AUTOPUSH LINK_MTU
78     IP_VERSION IPV4_ADDRSRC IPV4_ADDR IPV4_DEFAULT_ROUTE
79     IPV6_ADDRSRC IPV6_ADDR IPV6_DEFAULT_ROUTE
80     ENM_STATE ENM_FMRI ENM_START ENM_STOP
81     LOC_NAMESERVICES LOC_NAMESERVICES_CONFIG
82     LOC_DNS_CONFIGSRC LOC_DNS_DOMAIN LOC_DNS_SERVERS LOC_DNS_SEARCH
83     LOC_NIS_CONFIGSRC LOC_NIS_SERVERS
84     LOC_LDAP_CONFIGSRC LOC_LDAP_SERVERS
85     LOC_DEFAULT_DOMAIN LOC_NFSV4_DOMAIN
86     LOC_IPF_CONFIG LOC_IPF_V6_CONFIG
87     LOC_IPNAT_CONFIG LOC_IPPOOL_CONFIG LOC_IKE_CONFIG LOC_IPSECPOL_CONFIG
88     WLAN_BSSIDS WLAN_PRIORITY WLAN_KEYNAME WLAN_KEYSLOT WLAN_SECURITY_MODE
89 %type <cmd> command
90 %type <cmd> cancel_command CANCEL
91 %type <cmd> clear_command CLEAR
92 %type <cmd> commit_command COMMIT
93 %type <cmd> create_command CREATE
94 %type <cmd> destroy_command DESTROY
95 %type <cmd> end_command END
96 %type <cmd> exit_command EXIT
97 %type <cmd> export_command EXPORT
98 %type <cmd> get_command GET
99 %type <cmd> help_command HELP
100 %type <cmd> list_command LIST
101 %type <cmd> revert_command REVERT
102 %type <cmd> select_command SELECT
103 %type <cmd> set_command SET
104 %type <cmd> verify_command VERIFY
105 %type <cmd> walkprop_command WALKPROP
106 %type <cmd> terminator
107 
108 %%
109 
110 commands: command terminator
111 	{
112 		if ($1 != NULL) {
113 			if ($1->cmd_handler != NULL)
114 				if (check_scope($1->cmd_num))
115 					$1->cmd_handler($1);
116 			free_cmd($1);
117 		}
118 		return (0);
119 	}
120 	| command error terminator
121 	{
122 		if ($1 != NULL)
123 			free_cmd($1);
124 		if (YYRECOVERING())
125 			YYABORT;
126 		yyclearin;
127 		yyerrok;
128 	}
129 	| error terminator
130 	{
131 		if (YYRECOVERING())
132 			YYABORT;
133 		yyclearin;
134 		yyerrok;
135 	}
136 	| terminator
137 	{
138 		return (0);
139 	}
140 
141 command: cancel_command
142 	| clear_command
143 	| commit_command
144 	| create_command
145 	| destroy_command
146 	| end_command
147 	| exit_command
148 	| export_command
149 	| get_command
150 	| help_command
151 	| list_command
152 	| revert_command
153 	| select_command
154 	| set_command
155 	| verify_command
156 	| walkprop_command
157 
158 terminator:	'\n'	{ newline_terminated = B_TRUE; }
159 	|	';'	{ newline_terminated = B_FALSE; }
160 
161 cancel_command: CANCEL
162 	{
163 		if (($$ = alloc_cmd()) == NULL)
164 			YYERROR;
165 		cmd = $$;
166 		$$->cmd_num = CMD_CANCEL;
167 		$$->cmd_handler = &cancel_func;
168 		$$->cmd_argc = 0;
169 		$$->cmd_argv[0] = NULL;
170 	}
171 
172 clear_command: CLEAR
173 	{
174 		command_usage(CMD_CLEAR);
175 		YYERROR;
176 	}
177 	|	CLEAR TOKEN
178 	{
179 		properr($2);
180 		YYERROR;
181 	}
182 	|	CLEAR property_type
183 	{
184 		/* clear prop */
185 		if (($$ = alloc_cmd()) == NULL)
186 			YYERROR;
187 		cmd = $$;
188 		$$->cmd_num = CMD_CLEAR;
189 		$$->cmd_handler = &clear_func;
190 		$$->cmd_prop_type = $2;
191 		$$->cmd_argc = 0;
192 		$$->cmd_argv[0] = NULL;
193 	}
194 
195 commit_command: COMMIT
196 	{
197 		if (($$ = alloc_cmd()) == NULL)
198 			YYERROR;
199 		cmd = $$;
200 		$$->cmd_num = CMD_COMMIT;
201 		$$->cmd_handler = &commit_func;
202 		$$->cmd_argc = 0;
203 		$$->cmd_argv[0] = NULL;
204 	}
205 
206 create_command: CREATE
207 	{
208 		command_usage(CMD_CREATE);
209 		YYERROR;
210 	}
211 	|	CREATE TOKEN
212 	{
213 		command_usage(CMD_CREATE);
214 		YYERROR;
215 	}
216 	|	CREATE resource1_type
217 	{
218 		command_usage(CMD_CREATE);
219 		YYERROR;
220 	}
221 	|	CREATE resource2_type
222 	{
223 		command_usage(CMD_CREATE);
224 		YYERROR;
225 	}
226 	|	CREATE resource1_type TOKEN
227 	{
228 		/* create enm/loc/ncp test */
229 		if (($$ = alloc_cmd()) == NULL)
230 			YYERROR;
231 		cmd = $$;
232 		$$->cmd_num = CMD_CREATE;
233 		$$->cmd_handler = &create_func;
234 		$$->cmd_res1_type = $2;
235 		$$->cmd_argc = 1;
236 		$$->cmd_argv[0] = $3;
237 		$$->cmd_argv[1] = NULL;
238 	}
239 	|	CREATE resource2_type ncu_class_type TOKEN
240 	{
241 		/* create ncu ip/phys test */
242 		if (($$ = alloc_cmd()) == NULL)
243 			YYERROR;
244 		cmd = $$;
245 		$$->cmd_num = CMD_CREATE;
246 		$$->cmd_handler = &create_func;
247 		$$->cmd_res1_type = RT1_NCP;
248 		$$->cmd_res2_type = $2;
249 		$$->cmd_ncu_class_type = $3;
250 		$$->cmd_argc = 1;
251 		$$->cmd_argv[0] = $4;
252 		$$->cmd_argv[1] = NULL;
253 	}
254 	|	CREATE OPTION TOKEN resource1_type TOKEN
255 	{
256 		/* create -t old enm/loc/ncp test */
257 		if (($$ = alloc_cmd()) == NULL)
258 			YYERROR;
259 		cmd = $$;
260 		$$->cmd_num = CMD_CREATE;
261 		$$->cmd_handler = &create_func;
262 		$$->cmd_res1_type = $4;
263 		$$->cmd_argc = 3;
264 		$$->cmd_argv[0] = $2;
265 		$$->cmd_argv[1] = $3;
266 		$$->cmd_argv[2] = $5;
267 		$$->cmd_argv[3] = NULL;
268 	}
269 	|	CREATE OPTION TOKEN resource2_type ncu_class_type TOKEN
270 	{
271 		/* create -t old ncu ip/phys test */
272 		if (($$ = alloc_cmd()) == NULL)
273 			YYERROR;
274 		cmd = $$;
275 		$$->cmd_num = CMD_CREATE;
276 		$$->cmd_handler = &create_func;
277 		$$->cmd_res1_type = RT1_NCP;
278 		$$->cmd_res2_type = $4;
279 		$$->cmd_ncu_class_type = $5;
280 		$$->cmd_argc = 3;
281 		$$->cmd_argv[0] = $2;
282 		$$->cmd_argv[1] = $3;
283 		$$->cmd_argv[2] = $6;
284 		$$->cmd_argv[3] = NULL;
285 	}
286 
287 destroy_command: DESTROY
288 	{
289 		command_usage(CMD_DESTROY);
290 		YYERROR;
291 	}
292 	|	DESTROY OPTION
293 	{
294 		/* destroy -a */
295 		if (($$ = alloc_cmd()) == NULL)
296 			YYERROR;
297 		cmd = $$;
298 		$$->cmd_num = CMD_DESTROY;
299 		$$->cmd_handler = &destroy_func;
300 		$$->cmd_res1_type = -1; /* special value */
301 		$$->cmd_argc = 1;
302 		$$->cmd_argv[0] = $2;
303 		$$->cmd_argv[1] = NULL;
304 	}
305 	|	DESTROY resource1_type
306 	{
307 		command_usage(CMD_DESTROY);
308 		YYERROR;
309 	}
310 	|	DESTROY resource2_type
311 	{
312 		command_usage(CMD_DESTROY);
313 		YYERROR;
314 	}
315 	|	DESTROY resource1_type TOKEN
316 	{
317 		/* destroy enm/loc/ncp test */
318 		if (($$ = alloc_cmd()) == NULL)
319 			YYERROR;
320 		cmd = $$;
321 		$$->cmd_num = CMD_DESTROY;
322 		$$->cmd_handler = &destroy_func;
323 		$$->cmd_res1_type = $2;
324 		$$->cmd_argc = 1;
325 		$$->cmd_argv[0] = $3;
326 		$$->cmd_argv[1] = NULL;
327 	}
328 	|	DESTROY resource2_type TOKEN
329 	{
330 		/* destroy ncu test (class inferred) */
331 		if (($$ = alloc_cmd()) == NULL)
332 			YYERROR;
333 		cmd = $$;
334 		$$->cmd_num = CMD_DESTROY;
335 		$$->cmd_handler = &destroy_func;
336 		$$->cmd_res1_type = RT1_NCP;
337 		$$->cmd_res2_type = $2;
338 		$$->cmd_ncu_class_type = NCU_CLASS_ANY;
339 		$$->cmd_argc = 1;
340 		$$->cmd_argv[0] = $3;
341 		$$->cmd_argv[1] = NULL;
342 	}
343 	|	DESTROY resource2_type ncu_class_type TOKEN
344 	{
345 		/* destroy ncu ip/phys test */
346 		if (($$ = alloc_cmd()) == NULL)
347 			YYERROR;
348 		cmd = $$;
349 		$$->cmd_num = CMD_DESTROY;
350 		$$->cmd_handler = &destroy_func;
351 		$$->cmd_res1_type = RT1_NCP;
352 		$$->cmd_res2_type = $2;
353 		$$->cmd_ncu_class_type = $3;
354 		$$->cmd_argc = 1;
355 		$$->cmd_argv[0] = $4;
356 		$$->cmd_argv[1] = NULL;
357 	}
358 
359 end_command:	END
360 	{
361 		if (($$ = alloc_cmd()) == NULL)
362 			YYERROR;
363 		cmd = $$;
364 		$$->cmd_num = CMD_END;
365 		$$->cmd_handler = &end_func;
366 		$$->cmd_argc = 0;
367 		$$->cmd_argv[0] = NULL;
368 	}
369 
370 exit_command:	EXIT
371 	{
372 		if (($$ = alloc_cmd()) == NULL)
373 			YYERROR;
374 		cmd = $$;
375 		$$->cmd_num = CMD_EXIT;
376 		$$->cmd_handler = &exit_func;
377 		$$->cmd_argc = 0;
378 		$$->cmd_argv[0] = NULL;
379 	}
380 
381 export_command:	EXPORT
382 	{
383 		if (($$ = alloc_cmd()) == NULL)
384 			YYERROR;
385 		cmd = $$;
386 		$$->cmd_num = CMD_EXPORT;
387 		$$->cmd_handler = &export_func;
388 		$$->cmd_argc = 0;
389 		$$->cmd_argv[0] = NULL;
390 	}
391 	|	EXPORT TOKEN
392 	{
393 		command_usage(CMD_EXPORT);
394 		YYERROR;
395 	}
396  	|	EXPORT OPTION
397 	{
398 		/* export -d */
399 		if (($$ = alloc_cmd()) == NULL)
400 			YYERROR;
401 		cmd = $$;
402 		$$->cmd_num = CMD_EXPORT;
403 		$$->cmd_handler = &export_func;
404 		$$->cmd_argc = 1;
405 		$$->cmd_argv[0] = $2;
406 		$$->cmd_argv[1] = NULL;
407 	}
408 	|	EXPORT OPTION TOKEN
409 	{
410 		/* export -f file */
411 		if (($$ = alloc_cmd()) == NULL)
412 			YYERROR;
413 		cmd = $$;
414 		$$->cmd_num = CMD_EXPORT;
415 		$$->cmd_handler = &export_func;
416 		$$->cmd_argc = 2;
417 		$$->cmd_argv[0] = $2;
418 		$$->cmd_argv[1] = $3;
419 		$$->cmd_argv[2] = NULL;
420 	}
421 	|	EXPORT OPTION OPTION TOKEN
422 	{
423 		/* export -d -f file */
424 		if (($$ = alloc_cmd()) == NULL)
425 			YYERROR;
426 		cmd = $$;
427 		$$->cmd_num = CMD_EXPORT;
428 		$$->cmd_handler = &export_func;
429 		$$->cmd_argc = 3;
430 		$$->cmd_argv[0] = $2;
431 		$$->cmd_argv[1] = $3;
432 		$$->cmd_argv[2] = $4;
433 		$$->cmd_argv[3] = NULL;
434 	}
435 	|	EXPORT resource1_type TOKEN
436 	{
437 		/* export enm/loc/ncp test */
438 		if (($$ = alloc_cmd()) == NULL)
439 			YYERROR;
440 		cmd = $$;
441 		$$->cmd_num = CMD_EXPORT;
442 		$$->cmd_handler = &export_func;
443 		$$->cmd_res1_type = $2;
444 		$$->cmd_argc = 1;
445 		$$->cmd_argv[0] = $3;
446 		$$->cmd_argv[1] = NULL;
447 	}
448 	|	EXPORT resource2_type TOKEN
449 	{
450 		/* export ncu test (all ncu's named test) */
451 		if (($$ = alloc_cmd()) == NULL)
452 			YYERROR;
453 		cmd = $$;
454 		$$->cmd_num = CMD_EXPORT;
455 		$$->cmd_handler = &export_func;
456 		$$->cmd_res1_type = RT1_NCP;
457 		$$->cmd_res2_type = $2;
458 		$$->cmd_ncu_class_type = NCU_CLASS_ANY;
459 		$$->cmd_argc = 1;
460 		$$->cmd_argv[0] = $3;
461 		$$->cmd_argv[1] = NULL;
462 	}
463 	|	EXPORT resource2_type ncu_class_type TOKEN
464 	{
465 		/* export ncu ip/phys test */
466 		if (($$ = alloc_cmd()) == NULL)
467 			YYERROR;
468 		cmd = $$;
469 		$$->cmd_num = CMD_EXPORT;
470 		$$->cmd_handler = &export_func;
471 		$$->cmd_res1_type = RT1_NCP;
472 		$$->cmd_res2_type = $2;
473 		$$->cmd_ncu_class_type = $3;
474 		$$->cmd_argc = 1;
475 		$$->cmd_argv[0] = $4;
476 		$$->cmd_argv[1] = NULL;
477 	}
478 	|	EXPORT OPTION TOKEN resource1_type TOKEN
479 	{
480 		/* export -f file enm/loc/ncp test */
481 		if (($$ = alloc_cmd()) == NULL)
482 			YYERROR;
483 		cmd = $$;
484 		$$->cmd_num = CMD_EXPORT;
485 		$$->cmd_handler = &export_func;
486 		$$->cmd_res1_type = $4;
487 		$$->cmd_argc = 3;
488 		$$->cmd_argv[0] = $2;
489 		$$->cmd_argv[1] = $3;
490 		$$->cmd_argv[2] = $5;
491 		$$->cmd_argv[3] = NULL;
492 	}
493 	|	EXPORT OPTION TOKEN resource2_type TOKEN
494 	{
495 		/* export -f file ncu test (all ncu's named test) */
496 		if (($$ = alloc_cmd()) == NULL)
497 			YYERROR;
498 		cmd = $$;
499 		$$->cmd_num = CMD_EXPORT;
500 		$$->cmd_handler = &export_func;
501 		$$->cmd_res1_type = RT1_NCP;
502 		$$->cmd_res2_type = $4;
503 		$$->cmd_ncu_class_type = NCU_CLASS_ANY;
504 		$$->cmd_argc = 3;
505 		$$->cmd_argv[0] = $2;
506 		$$->cmd_argv[1] = $3;
507 		$$->cmd_argv[2] = $5;
508 		$$->cmd_argv[3] = NULL;
509 	}
510 	|	EXPORT OPTION TOKEN resource2_type ncu_class_type TOKEN
511 	{
512 		/* export -f file ncu ip/phys test */
513 		if (($$ = alloc_cmd()) == NULL)
514 			YYERROR;
515 		cmd = $$;
516 		$$->cmd_num = CMD_EXPORT;
517 		$$->cmd_handler = &export_func;
518 		$$->cmd_res1_type = RT1_NCP;
519 		$$->cmd_res2_type = $4;
520 		$$->cmd_ncu_class_type = $5;
521 		$$->cmd_argc = 3;
522 		$$->cmd_argv[0] = $2;
523 		$$->cmd_argv[1] = $3;
524 		$$->cmd_argv[2] = $6;
525 		$$->cmd_argv[3] = NULL;
526 	}
527 
528 get_command: GET
529 	{
530 		command_usage(CMD_GET);
531 		YYERROR;
532 	}
533 	|	GET TOKEN
534 	{
535 		properr($2);
536 		YYERROR;
537 	}
538 	|	GET property_type
539 	{
540 		/* get prop */
541 		if (($$ = alloc_cmd()) == NULL)
542 			YYERROR;
543 		cmd = $$;
544 		$$->cmd_num = CMD_GET;
545 		$$->cmd_handler = &get_func;
546 		$$->cmd_prop_type = $2;
547 		$$->cmd_argc = 0;
548 		$$->cmd_argv[0] = NULL;
549 	}
550 	|	GET OPTION property_type
551 	{
552 		/* get -V prop */
553 		if (($$ = alloc_cmd()) == NULL)
554 			YYERROR;
555 		cmd = $$;
556 		$$->cmd_num = CMD_GET;
557 		$$->cmd_handler = &get_func;
558 		$$->cmd_prop_type = $3;
559 		$$->cmd_argc = 1;
560 		$$->cmd_argv[0] = $2;
561 		$$->cmd_argv[1] = NULL;
562 	}
563 
564 help_command:	HELP
565 	{
566 		if (($$ = alloc_cmd()) == NULL)
567 			YYERROR;
568 		cmd = $$;
569 		$$->cmd_num = CMD_HELP;
570 		$$->cmd_handler = &help_func;
571 		$$->cmd_argc = 0;
572 		$$->cmd_argv[0] = NULL;
573 	}
574 	|	HELP TOKEN
575 	{
576 		/* help command */
577 		if (($$ = alloc_cmd()) == NULL)
578 			YYERROR;
579 		cmd = $$;
580 		$$->cmd_num = CMD_HELP;
581 		$$->cmd_handler = &help_func;
582 		$$->cmd_argc = 1;
583 		$$->cmd_argv[0] = $2;
584 		$$->cmd_argv[1] = NULL;
585 	}
586 
587 list_command:	LIST
588 	{
589 		if (($$ = alloc_cmd()) == NULL)
590 			YYERROR;
591 		cmd = $$;
592 		$$->cmd_num = CMD_LIST;
593 		$$->cmd_handler = &list_func;
594 		$$->cmd_argc = 0;
595 		$$->cmd_argv[0] = NULL;
596 	}
597 	|	LIST TOKEN
598 	{
599 		command_usage(CMD_LIST);
600 		YYERROR;
601 	}
602 	|	LIST OPTION
603 	{
604 		/* list -a */
605 		if (($$ = alloc_cmd()) == NULL)
606 			YYERROR;
607 		cmd = $$;
608 		$$->cmd_num = CMD_LIST;
609 		$$->cmd_handler = &list_func;
610 		$$->cmd_res1_type = -1; /* special value */
611 		$$->cmd_argc = 1;
612 		$$->cmd_argv[0] = $2;
613 		$$->cmd_argv[1] = NULL;
614 	}
615 	|	LIST resource1_type
616 	{
617 		command_usage(CMD_LIST);
618 		YYERROR;
619 	}
620 	|	LIST resource2_type
621 	{
622 		command_usage(CMD_LIST);
623 		YYERROR;
624 	}
625 	|	LIST resource1_type TOKEN
626 	{
627 		/* list enm/loc/ncp test */
628 		if (($$ = alloc_cmd()) == NULL)
629 			YYERROR;
630 		cmd = $$;
631 		$$->cmd_num = CMD_LIST;
632 		$$->cmd_handler = &list_func;
633 		$$->cmd_res1_type = $2;
634 		$$->cmd_argc = 1;
635 		$$->cmd_argv[0] = $3;
636 		$$->cmd_argv[1] = NULL;
637 	}
638 	|	LIST resource2_type TOKEN
639 	{
640 		/* list ncu test (all ncu's named test) */
641 		if (($$ = alloc_cmd()) == NULL)
642 			YYERROR;
643 		cmd = $$;
644 		$$->cmd_num = CMD_LIST;
645 		$$->cmd_handler = &list_func;
646 		$$->cmd_res1_type = RT1_NCP;
647 		$$->cmd_res2_type = $2;
648 		$$->cmd_ncu_class_type = NCU_CLASS_ANY;
649 		$$->cmd_argc = 1;
650 		$$->cmd_argv[0] = $3;
651 		$$->cmd_argv[1] = NULL;
652 	}
653 	|	LIST resource2_type ncu_class_type TOKEN
654 	{
655 		/* list ncu ip/phys test */
656 		if (($$ = alloc_cmd()) == NULL)
657 			YYERROR;
658 		cmd = $$;
659 		$$->cmd_num = CMD_LIST;
660 		$$->cmd_handler = &list_func;
661 		$$->cmd_res1_type = RT1_NCP;
662 		$$->cmd_res2_type = $2;
663 		$$->cmd_ncu_class_type = $3;
664 		$$->cmd_argc = 1;
665 		$$->cmd_argv[0] = $4;
666 		$$->cmd_argv[1] = NULL;
667 	}
668 	|	LIST OPTION resource1_type TOKEN
669 	{
670 		/* list -a enm/loc/ncp test */
671 		if (($$ = alloc_cmd()) == NULL)
672 			YYERROR;
673 		cmd = $$;
674 		$$->cmd_num = CMD_LIST;
675 		$$->cmd_handler = &list_func;
676 		$$->cmd_res1_type = $3;
677 		$$->cmd_argc = 2;
678 		$$->cmd_argv[0] = $4;
679 		$$->cmd_argv[1] = $2;
680 		$$->cmd_argv[2] = NULL;
681 	}
682 	|	LIST OPTION resource2_type TOKEN
683 	{
684 		/* list -a ncu test (all ncu's named test) */
685 		if (($$ = alloc_cmd()) == NULL)
686 			YYERROR;
687 		cmd = $$;
688 		$$->cmd_num = CMD_LIST;
689 		$$->cmd_handler = &list_func;
690 		$$->cmd_res1_type = RT1_NCP;
691 		$$->cmd_res2_type = $3;
692 		$$->cmd_ncu_class_type = NCU_CLASS_ANY;
693 		$$->cmd_argc = 2;
694 		$$->cmd_argv[0] = $4;
695 		$$->cmd_argv[1] = $2;
696 		$$->cmd_argv[2] = NULL;
697 	}
698 	|	LIST OPTION resource2_type ncu_class_type TOKEN
699 	{
700 		/* list -a ncu ip/phys test */
701 		if (($$ = alloc_cmd()) == NULL)
702 			YYERROR;
703 		cmd = $$;
704 		$$->cmd_num = CMD_LIST;
705 		$$->cmd_handler = &list_func;
706 		$$->cmd_res1_type = RT1_NCP;
707 		$$->cmd_res2_type = $3;
708 		$$->cmd_ncu_class_type = $4;
709 		$$->cmd_argc = 2;
710 		$$->cmd_argv[0] = $5;
711 		$$->cmd_argv[1] = $2;
712 		$$->cmd_argv[2] = NULL;
713 	}
714 
715 revert_command: REVERT
716 	{
717 		if (($$ = alloc_cmd()) == NULL)
718 			YYERROR;
719 		cmd = $$;
720 		$$->cmd_num = CMD_REVERT;
721 		$$->cmd_handler = &revert_func;
722 		$$->cmd_argc = 0;
723 		$$->cmd_argv[0] = NULL;
724 	}
725 
726 select_command:	SELECT
727 	{
728 		command_usage(CMD_SELECT);
729 		YYERROR;
730 	}
731 	|	SELECT TOKEN
732 	{
733 		command_usage(CMD_SELECT);
734 		YYERROR;
735 	}
736 	|	SELECT resource1_type
737 	{
738 		command_usage(CMD_SELECT);
739 		YYERROR;
740 	}
741 	|	SELECT resource2_type
742 	{
743 		command_usage(CMD_SELECT);
744 		YYERROR;
745 	}
746 	|	SELECT resource1_type TOKEN
747 	{
748 		/* select enm/loc/ncp test */
749 		if (($$ = alloc_cmd()) == NULL)
750 			YYERROR;
751 		cmd = $$;
752 		$$->cmd_num = CMD_SELECT;
753 		$$->cmd_handler = &select_func;
754 		$$->cmd_res1_type = $2;
755 		$$->cmd_argc = 1;
756 		$$->cmd_argv[0] = $3;
757 		$$->cmd_argv[1] = NULL;
758 	}
759 	|	SELECT resource2_type TOKEN
760 	{
761 		/* select ncu test (class inferred) */
762 		if (($$ = alloc_cmd()) == NULL)
763 			YYERROR;
764 		cmd = $$;
765 		$$->cmd_num = CMD_SELECT;
766 		$$->cmd_handler = &select_func;
767 		$$->cmd_res1_type = RT1_NCP;
768 		$$->cmd_res2_type = $2;
769 		$$->cmd_ncu_class_type = NCU_CLASS_ANY;
770 		$$->cmd_argc = 1;
771 		$$->cmd_argv[0] = $3;
772 		$$->cmd_argv[1] = NULL;
773 	}
774 	|	SELECT resource2_type ncu_class_type TOKEN
775 	{
776 		/* select ncu ip/phys test */
777 		if (($$ = alloc_cmd()) == NULL)
778 			YYERROR;
779 		cmd = $$;
780 		$$->cmd_num = CMD_SELECT;
781 		$$->cmd_handler = &select_func;
782 		$$->cmd_res1_type = RT1_NCP;
783 		$$->cmd_res2_type = $2;
784 		$$->cmd_ncu_class_type = $3;
785 		$$->cmd_argc = 1;
786 		$$->cmd_argv[0] = $4;
787 		$$->cmd_argv[1] = NULL;
788 	}
789 
790 set_command:	SET
791 	{
792 		command_usage(CMD_SET);
793 		YYERROR;
794 	}
795 	|	SET TOKEN
796 	{
797 		properr($2);
798 		YYERROR;
799 	}
800 	|	SET property_type EQUAL TOKEN
801 	{
802 		/* set prop=value */
803 		if (($$ = alloc_cmd()) == NULL)
804 			YYERROR;
805 		cmd = $$;
806 		$$->cmd_num = CMD_SET;
807 		$$->cmd_handler = &set_func;
808 		$$->cmd_prop_type = $2;
809 		$$->cmd_argc = 1;
810 		$$->cmd_argv[0] = $4;
811 		$$->cmd_argv[1] = NULL;
812 	}
813 
814 verify_command: VERIFY
815 	{
816 		if (($$ = alloc_cmd()) == NULL)
817 			YYERROR;
818 		cmd = $$;
819 		$$->cmd_num = CMD_VERIFY;
820 		$$->cmd_handler = &verify_func;
821 		$$->cmd_argc = 0;
822 		$$->cmd_argv[0] = NULL;
823 	}
824 
825 walkprop_command: WALKPROP
826 	{
827 		if (($$ = alloc_cmd()) == NULL)
828 			YYERROR;
829 		cmd = $$;
830 		$$->cmd_num = CMD_WALKPROP;
831 		$$->cmd_handler = &walkprop_func;
832 		$$->cmd_argc = 0;
833 		$$->cmd_argv[0] = NULL;
834 	}
835 	|	WALKPROP OPTION
836 	{
837 		/* walkprop -a */
838 		if (($$ = alloc_cmd()) == NULL)
839 			YYERROR;
840 		cmd = $$;
841 		$$->cmd_num = CMD_WALKPROP;
842 		$$->cmd_handler = &walkprop_func;
843 		$$->cmd_argc = 1;
844 		$$->cmd_argv[0] = $2;
845 		$$->cmd_argv[1] = NULL;
846 	}
847 
848 resource1_type: LOC	{ $$ = RT1_LOC; }
849 	|	NCP	{ $$ = RT1_NCP; }
850 	|	ENM	{ $$ = RT1_ENM; }
851 	|	WLAN	{ $$ = RT1_WLAN; }
852 
853 resource2_type: NCU	{ $$ = RT2_NCU; }
854 
855 ncu_class_type:	PHYS		{ $$ = NCU_CLASS_PHYS; }
856 	|	IP		{ $$ = NCU_CLASS_IP; }
857 
858 property_type:	UNKNOWN			{ $$ = PT_UNKNOWN; }
859 	|	ACTIVATION_MODE		{ $$ = PT_ACTIVATION_MODE; }
860 	|	CONDITIONS		{ $$ = PT_CONDITIONS; }
861 	|	ENABLED			{ $$ = PT_ENABLED; }
862 	|	TYPE			{ $$ = PT_TYPE; }
863 	|	CLASS			{ $$ = PT_CLASS; }
864 	|	PARENT			{ $$ = PT_PARENT; }
865 	|	PRIORITY_GROUP		{ $$ = PT_PRIORITY_GROUP; }
866 	|	PRIORITY_MODE		{ $$ = PT_PRIORITY_MODE; }
867 	|	LINK_MACADDR		{ $$ = PT_LINK_MACADDR; }
868 	|	LINK_AUTOPUSH		{ $$ = PT_LINK_AUTOPUSH; }
869 	|	LINK_MTU		{ $$ = PT_LINK_MTU; }
870 	|	IP_VERSION		{ $$ = PT_IP_VERSION; }
871 	|	IPV4_ADDRSRC		{ $$ = PT_IPV4_ADDRSRC; }
872 	|	IPV4_ADDR		{ $$ = PT_IPV4_ADDR; }
873 	|	IPV4_DEFAULT_ROUTE	{ $$ = PT_IPV4_DEFAULT_ROUTE; }
874 	|	IPV6_ADDRSRC		{ $$ = PT_IPV6_ADDRSRC; }
875 	|	IPV6_ADDR		{ $$ = PT_IPV6_ADDR; }
876 	|	IPV6_DEFAULT_ROUTE	{ $$ = PT_IPV6_DEFAULT_ROUTE; }
877 	|	ENM_FMRI		{ $$ = PT_ENM_FMRI; }
878 	|	ENM_START		{ $$ = PT_ENM_START; }
879 	|	ENM_STOP		{ $$ = PT_ENM_STOP; }
880 	|	LOC_NAMESERVICES	{ $$ = PT_LOC_NAMESERVICES; }
881 	|	LOC_NAMESERVICES_CONFIG	{ $$ = PT_LOC_NAMESERVICES_CONFIG; }
882 	|	LOC_DNS_CONFIGSRC	{ $$ = PT_LOC_DNS_CONFIGSRC; }
883 	|	LOC_DNS_DOMAIN		{ $$ = PT_LOC_DNS_DOMAIN; }
884 	|	LOC_DNS_SERVERS		{ $$ = PT_LOC_DNS_SERVERS; }
885 	|	LOC_DNS_SEARCH		{ $$ = PT_LOC_DNS_SEARCH; }
886 	|	LOC_NIS_CONFIGSRC	{ $$ = PT_LOC_NIS_CONFIGSRC; }
887 	|	LOC_NIS_SERVERS		{ $$ = PT_LOC_NIS_SERVERS; }
888 	|	LOC_LDAP_CONFIGSRC	{ $$ = PT_LOC_LDAP_CONFIGSRC; }
889 	|	LOC_LDAP_SERVERS	{ $$ = PT_LOC_LDAP_SERVERS; }
890 	|	LOC_DEFAULT_DOMAIN	{ $$ = PT_LOC_DEFAULT_DOMAIN; }
891 	|	LOC_NFSV4_DOMAIN	{ $$ = PT_LOC_NFSV4_DOMAIN; }
892 	|	LOC_IPF_CONFIG		{ $$ = PT_LOC_IPF_CONFIG; }
893 	|	LOC_IPF_V6_CONFIG	{ $$ = PT_LOC_IPF_V6_CONFIG; }
894 	|	LOC_IPNAT_CONFIG	{ $$ = PT_LOC_IPNAT_CONFIG; }
895 	|	LOC_IPPOOL_CONFIG	{ $$ = PT_LOC_IPPOOL_CONFIG; }
896 	|	LOC_IKE_CONFIG		{ $$ = PT_LOC_IKE_CONFIG; }
897 	|	LOC_IPSECPOL_CONFIG	{ $$ = PT_LOC_IPSECPOL_CONFIG; }
898 	|	WLAN_BSSIDS		{ $$ = PT_WLAN_BSSIDS; }
899 	|	WLAN_PRIORITY		{ $$ = PT_WLAN_PRIORITY; }
900 	|	WLAN_KEYNAME		{ $$ = PT_WLAN_KEYNAME; }
901 	|	WLAN_KEYSLOT		{ $$ = PT_WLAN_KEYSLOT; }
902 	|	WLAN_SECURITY_MODE	{ $$ = PT_WLAN_SECURITY_MODE; }
903 
904 %%
905