xref: /titanic_52/usr/src/cmd/zonecfg/zonecfg.h (revision 9acbbeaf2a1ffe5c14b244867d427714fab43c5c)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5ffbafc53Scomay  * Common Development and Distribution License (the "License").
6ffbafc53Scomay  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21ffbafc53Scomay 
227c478bd9Sstevel@tonic-gate /*
23ffbafc53Scomay  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef _ZONECFG_H
287c478bd9Sstevel@tonic-gate #define	_ZONECFG_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate /*
337c478bd9Sstevel@tonic-gate  * header file for zonecfg command
347c478bd9Sstevel@tonic-gate  */
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #ifdef __cplusplus
377c478bd9Sstevel@tonic-gate extern "C" {
387c478bd9Sstevel@tonic-gate #endif
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #include <unistd.h>
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #define	FALSE	0
437c478bd9Sstevel@tonic-gate #define	TRUE	1
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate typedef int bool;
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate #define	Z_ERR		1
487c478bd9Sstevel@tonic-gate #define	Z_USAGE		2
497c478bd9Sstevel@tonic-gate #define	Z_REPEAT	3
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate #define	CMD_ADD		0
527c478bd9Sstevel@tonic-gate #define	CMD_CANCEL	1
537c478bd9Sstevel@tonic-gate #define	CMD_COMMIT	2
547c478bd9Sstevel@tonic-gate #define	CMD_CREATE	3
557c478bd9Sstevel@tonic-gate #define	CMD_DELETE	4
567c478bd9Sstevel@tonic-gate #define	CMD_END		5
577c478bd9Sstevel@tonic-gate #define	CMD_EXIT	6
587c478bd9Sstevel@tonic-gate #define	CMD_EXPORT	7
597c478bd9Sstevel@tonic-gate #define	CMD_HELP	8
607c478bd9Sstevel@tonic-gate #define	CMD_INFO	9
617c478bd9Sstevel@tonic-gate #define	CMD_REMOVE	10
627c478bd9Sstevel@tonic-gate #define	CMD_REVERT	11
637c478bd9Sstevel@tonic-gate #define	CMD_SELECT	12
647c478bd9Sstevel@tonic-gate #define	CMD_SET		13
657c478bd9Sstevel@tonic-gate #define	CMD_VERIFY	14
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate #define	CMD_MIN		CMD_ADD
687c478bd9Sstevel@tonic-gate #define	CMD_MAX		CMD_VERIFY
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /* resource types: increment RT_MAX when expanding this list */
717c478bd9Sstevel@tonic-gate #define	RT_UNKNOWN	0
72087719fdSdp #define	RT_ZONENAME	1	/* really a property, but for info ... */
73087719fdSdp #define	RT_ZONEPATH	2	/* really a property, but for info ... */
74087719fdSdp #define	RT_AUTOBOOT	3	/* really a property, but for info ... */
75087719fdSdp #define	RT_POOL		4	/* really a property, but for info ... */
76087719fdSdp #define	RT_FS		5
77087719fdSdp #define	RT_IPD		6
78087719fdSdp #define	RT_NET		7
79087719fdSdp #define	RT_DEVICE	8
80087719fdSdp #define	RT_RCTL		9
81087719fdSdp #define	RT_ATTR		10
82fa9e4066Sahrens #define	RT_DATASET	11
83ffbafc53Scomay #define	RT_LIMITPRIV	12	/* really a property, but for info ... */
843f2f09c1Sdp #define	RT_BOOTARGS	13	/* really a property, but for info ... */
85*9acbbeafSnn35248 #define	RT_BRAND	14	/* really a property, but for info ... */
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate #define	RT_MIN		RT_UNKNOWN
88*9acbbeafSnn35248 #define	RT_MAX		RT_BRAND
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate /* property types: increment PT_MAX when expanding this list */
917c478bd9Sstevel@tonic-gate #define	PT_UNKNOWN	0
92087719fdSdp #define	PT_ZONENAME	1
93087719fdSdp #define	PT_ZONEPATH	2
94087719fdSdp #define	PT_AUTOBOOT	3
95087719fdSdp #define	PT_POOL		4
96087719fdSdp #define	PT_DIR		5
97087719fdSdp #define	PT_SPECIAL	6
98087719fdSdp #define	PT_TYPE		7
99087719fdSdp #define	PT_OPTIONS	8
100087719fdSdp #define	PT_ADDRESS	9
101087719fdSdp #define	PT_PHYSICAL	10
102087719fdSdp #define	PT_NAME		11
103087719fdSdp #define	PT_VALUE	12
104087719fdSdp #define	PT_MATCH	13
105087719fdSdp #define	PT_PRIV		14
106087719fdSdp #define	PT_LIMIT	15
107087719fdSdp #define	PT_ACTION	16
108087719fdSdp #define	PT_RAW		17
109ffbafc53Scomay #define	PT_LIMITPRIV	18
1103f2f09c1Sdp #define	PT_BOOTARGS	19
111*9acbbeafSnn35248 #define	PT_BRAND	20
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate #define	PT_MIN		PT_UNKNOWN
114*9acbbeafSnn35248 #define	PT_MAX		PT_BRAND
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate #define	MAX_EQ_PROP_PAIRS	3
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate #define	PROP_VAL_SIMPLE		0
1197c478bd9Sstevel@tonic-gate #define	PROP_VAL_COMPLEX	1
1207c478bd9Sstevel@tonic-gate #define	PROP_VAL_LIST		2
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate #define	PROP_VAL_MIN		PROP_VAL_SIMPLE
1237c478bd9Sstevel@tonic-gate #define	PROP_VAL_MAX		PROP_VAL_LIST
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate /*
1267c478bd9Sstevel@tonic-gate  * If any subcommand is ever modified to take more than three arguments,
1277c478bd9Sstevel@tonic-gate  * this will need to be incremented.
1287c478bd9Sstevel@tonic-gate  */
1297c478bd9Sstevel@tonic-gate #define	MAX_SUBCMD_ARGS		3
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate typedef struct complex_property {
1327c478bd9Sstevel@tonic-gate 	int	cp_type;	/* from the PT_* list above */
1337c478bd9Sstevel@tonic-gate 	char	*cp_value;
1347c478bd9Sstevel@tonic-gate 	struct complex_property *cp_next;
1357c478bd9Sstevel@tonic-gate } complex_property_t, *complex_property_ptr_t;
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate typedef struct list_property {
1387c478bd9Sstevel@tonic-gate 	char	*lp_simple;
1397c478bd9Sstevel@tonic-gate 	complex_property_ptr_t	lp_complex;
1407c478bd9Sstevel@tonic-gate 	struct list_property	*lp_next;
1417c478bd9Sstevel@tonic-gate } list_property_t, *list_property_ptr_t;
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate typedef struct property_value {
1447c478bd9Sstevel@tonic-gate 	int	pv_type;	/* from the PROP_VAL_* list above */
1457c478bd9Sstevel@tonic-gate 	char	*pv_simple;
1467c478bd9Sstevel@tonic-gate 	complex_property_ptr_t	pv_complex;
1477c478bd9Sstevel@tonic-gate 	list_property_ptr_t	pv_list;
1487c478bd9Sstevel@tonic-gate } property_value_t, *property_value_ptr_t;
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate typedef struct cmd {
1517c478bd9Sstevel@tonic-gate 	char	*cmd_name;
1527c478bd9Sstevel@tonic-gate 	void	(*cmd_handler)(struct cmd *);
1537c478bd9Sstevel@tonic-gate 	int	cmd_res_type;
1547c478bd9Sstevel@tonic-gate 	int	cmd_prop_nv_pairs;
1557c478bd9Sstevel@tonic-gate 	int	cmd_prop_name[MAX_EQ_PROP_PAIRS];
1567c478bd9Sstevel@tonic-gate 	property_value_ptr_t	cmd_property_ptr[MAX_EQ_PROP_PAIRS];
1577c478bd9Sstevel@tonic-gate 	int	cmd_argc;
1587c478bd9Sstevel@tonic-gate 	char	*cmd_argv[MAX_SUBCMD_ARGS + 1];
1597c478bd9Sstevel@tonic-gate } cmd_t;
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate #define	HELP_USAGE	0x01
1627c478bd9Sstevel@tonic-gate #define	HELP_SUBCMDS	0x02
1637c478bd9Sstevel@tonic-gate #define	HELP_SYNTAX	0x04
1647c478bd9Sstevel@tonic-gate #define	HELP_RESOURCES	0x08
1657c478bd9Sstevel@tonic-gate #define	HELP_PROPS	0x10
1667c478bd9Sstevel@tonic-gate #define	HELP_META	0x20
1677c478bd9Sstevel@tonic-gate #define	HELP_NETADDR	0x40
1687c478bd9Sstevel@tonic-gate #define	HELP_RES_SCOPE	0x80
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate #define	HELP_RES_PROPS	(HELP_RESOURCES | HELP_PROPS)
1717c478bd9Sstevel@tonic-gate 
1727c478bd9Sstevel@tonic-gate extern void add_func(cmd_t *);
1737c478bd9Sstevel@tonic-gate extern void cancel_func(cmd_t *);
1747c478bd9Sstevel@tonic-gate extern void commit_func(cmd_t *);
1757c478bd9Sstevel@tonic-gate extern void create_func(cmd_t *);
1767c478bd9Sstevel@tonic-gate extern void delete_func(cmd_t *);
1777c478bd9Sstevel@tonic-gate extern void end_func(cmd_t *);
1787c478bd9Sstevel@tonic-gate extern void exit_func(cmd_t *);
1797c478bd9Sstevel@tonic-gate extern void export_func(cmd_t *);
1807c478bd9Sstevel@tonic-gate extern void help_func(cmd_t *);
1817c478bd9Sstevel@tonic-gate extern void info_func(cmd_t *);
1827c478bd9Sstevel@tonic-gate extern void remove_func(cmd_t *);
1837c478bd9Sstevel@tonic-gate extern void revert_func(cmd_t *);
1847c478bd9Sstevel@tonic-gate extern void select_func(cmd_t *);
1857c478bd9Sstevel@tonic-gate extern void set_func(cmd_t *);
1867c478bd9Sstevel@tonic-gate extern void verify_func(cmd_t *);
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate extern cmd_t *alloc_cmd(void);
1897c478bd9Sstevel@tonic-gate extern complex_property_ptr_t alloc_complex(void);
1907c478bd9Sstevel@tonic-gate extern list_property_ptr_t alloc_list(void);
1917c478bd9Sstevel@tonic-gate extern void free_cmd(cmd_t *cmd);
1927c478bd9Sstevel@tonic-gate extern void free_complex(complex_property_ptr_t complex);
1937c478bd9Sstevel@tonic-gate extern void free_list(list_property_ptr_t list);
1947c478bd9Sstevel@tonic-gate extern void free_outer_list(list_property_ptr_t list);
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate extern void usage(bool verbose, uint_t flags);
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate extern FILE *yyin;
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate #ifdef __cplusplus
2017c478bd9Sstevel@tonic-gate }
2027c478bd9Sstevel@tonic-gate #endif
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate #endif	/* _ZONECFG_H */
205