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