xref: /titanic_53/usr/src/cmd/zonecfg/zonecfg.h (revision 0209230bf1261579beab4f55226bb509e6b850cb)
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
53*0209230bSgjelinek #define	CMD_CLEAR	2
54*0209230bSgjelinek #define	CMD_COMMIT	3
55*0209230bSgjelinek #define	CMD_CREATE	4
56*0209230bSgjelinek #define	CMD_DELETE	5
57*0209230bSgjelinek #define	CMD_END		6
58*0209230bSgjelinek #define	CMD_EXIT	7
59*0209230bSgjelinek #define	CMD_EXPORT	8
60*0209230bSgjelinek #define	CMD_HELP	9
61*0209230bSgjelinek #define	CMD_INFO	10
62*0209230bSgjelinek #define	CMD_REMOVE	11
63*0209230bSgjelinek #define	CMD_REVERT	12
64*0209230bSgjelinek #define	CMD_SELECT	13
65*0209230bSgjelinek #define	CMD_SET		14
66*0209230bSgjelinek #define	CMD_VERIFY	15
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate #define	CMD_MIN		CMD_ADD
697c478bd9Sstevel@tonic-gate #define	CMD_MAX		CMD_VERIFY
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate /* resource types: increment RT_MAX when expanding this list */
727c478bd9Sstevel@tonic-gate #define	RT_UNKNOWN	0
73087719fdSdp #define	RT_ZONENAME	1	/* really a property, but for info ... */
74087719fdSdp #define	RT_ZONEPATH	2	/* really a property, but for info ... */
75087719fdSdp #define	RT_AUTOBOOT	3	/* really a property, but for info ... */
76087719fdSdp #define	RT_POOL		4	/* really a property, but for info ... */
77087719fdSdp #define	RT_FS		5
78087719fdSdp #define	RT_IPD		6
79087719fdSdp #define	RT_NET		7
80087719fdSdp #define	RT_DEVICE	8
81087719fdSdp #define	RT_RCTL		9
82087719fdSdp #define	RT_ATTR		10
83fa9e4066Sahrens #define	RT_DATASET	11
84ffbafc53Scomay #define	RT_LIMITPRIV	12	/* really a property, but for info ... */
853f2f09c1Sdp #define	RT_BOOTARGS	13	/* really a property, but for info ... */
869acbbeafSnn35248 #define	RT_BRAND	14	/* really a property, but for info ... */
87*0209230bSgjelinek #define	RT_DCPU		15
88*0209230bSgjelinek #define	RT_MCAP		16
89*0209230bSgjelinek #define	RT_MAXLWPS	17	/* really a rctl alias property, but for info */
90*0209230bSgjelinek #define	RT_MAXSHMMEM	18	/* really a rctl alias property, but for info */
91*0209230bSgjelinek #define	RT_MAXSHMIDS	19	/* really a rctl alias property, but for info */
92*0209230bSgjelinek #define	RT_MAXMSGIDS	20	/* really a rctl alias property, but for info */
93*0209230bSgjelinek #define	RT_MAXSEMIDS	21	/* really a rctl alias property, but for info */
94*0209230bSgjelinek #define	RT_SHARES	22	/* really a rctl alias property, but for info */
95*0209230bSgjelinek #define	RT_SCHED	23	/* really a property, but for info ... */
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate #define	RT_MIN		RT_UNKNOWN
98*0209230bSgjelinek #define	RT_MAX		RT_SCHED
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate /* property types: increment PT_MAX when expanding this list */
1017c478bd9Sstevel@tonic-gate #define	PT_UNKNOWN	0
102087719fdSdp #define	PT_ZONENAME	1
103087719fdSdp #define	PT_ZONEPATH	2
104087719fdSdp #define	PT_AUTOBOOT	3
105087719fdSdp #define	PT_POOL		4
106087719fdSdp #define	PT_DIR		5
107087719fdSdp #define	PT_SPECIAL	6
108087719fdSdp #define	PT_TYPE		7
109087719fdSdp #define	PT_OPTIONS	8
110087719fdSdp #define	PT_ADDRESS	9
111087719fdSdp #define	PT_PHYSICAL	10
112087719fdSdp #define	PT_NAME		11
113087719fdSdp #define	PT_VALUE	12
114087719fdSdp #define	PT_MATCH	13
115087719fdSdp #define	PT_PRIV		14
116087719fdSdp #define	PT_LIMIT	15
117087719fdSdp #define	PT_ACTION	16
118087719fdSdp #define	PT_RAW		17
119ffbafc53Scomay #define	PT_LIMITPRIV	18
1203f2f09c1Sdp #define	PT_BOOTARGS	19
1219acbbeafSnn35248 #define	PT_BRAND	20
122*0209230bSgjelinek #define	PT_NCPUS	21
123*0209230bSgjelinek #define	PT_IMPORTANCE	22
124*0209230bSgjelinek #define	PT_SWAP		23
125*0209230bSgjelinek #define	PT_LOCKED	24
126*0209230bSgjelinek #define	PT_SHARES	25
127*0209230bSgjelinek #define	PT_MAXLWPS	26
128*0209230bSgjelinek #define	PT_MAXSHMMEM	27
129*0209230bSgjelinek #define	PT_MAXSHMIDS	28
130*0209230bSgjelinek #define	PT_MAXMSGIDS	29
131*0209230bSgjelinek #define	PT_MAXSEMIDS	30
132*0209230bSgjelinek #define	PT_MAXLOCKEDMEM	31
133*0209230bSgjelinek #define	PT_MAXSWAP	32
134*0209230bSgjelinek #define	PT_SCHED	33
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate #define	PT_MIN		PT_UNKNOWN
137*0209230bSgjelinek #define	PT_MAX		PT_SCHED
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate #define	MAX_EQ_PROP_PAIRS	3
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate #define	PROP_VAL_SIMPLE		0
1427c478bd9Sstevel@tonic-gate #define	PROP_VAL_COMPLEX	1
1437c478bd9Sstevel@tonic-gate #define	PROP_VAL_LIST		2
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate #define	PROP_VAL_MIN		PROP_VAL_SIMPLE
1467c478bd9Sstevel@tonic-gate #define	PROP_VAL_MAX		PROP_VAL_LIST
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate /*
1497c478bd9Sstevel@tonic-gate  * If any subcommand is ever modified to take more than three arguments,
1507c478bd9Sstevel@tonic-gate  * this will need to be incremented.
1517c478bd9Sstevel@tonic-gate  */
1527c478bd9Sstevel@tonic-gate #define	MAX_SUBCMD_ARGS		3
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate typedef struct complex_property {
1557c478bd9Sstevel@tonic-gate 	int	cp_type;	/* from the PT_* list above */
1567c478bd9Sstevel@tonic-gate 	char	*cp_value;
1577c478bd9Sstevel@tonic-gate 	struct complex_property *cp_next;
1587c478bd9Sstevel@tonic-gate } complex_property_t, *complex_property_ptr_t;
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate typedef struct list_property {
1617c478bd9Sstevel@tonic-gate 	char	*lp_simple;
1627c478bd9Sstevel@tonic-gate 	complex_property_ptr_t	lp_complex;
1637c478bd9Sstevel@tonic-gate 	struct list_property	*lp_next;
1647c478bd9Sstevel@tonic-gate } list_property_t, *list_property_ptr_t;
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate typedef struct property_value {
1677c478bd9Sstevel@tonic-gate 	int	pv_type;	/* from the PROP_VAL_* list above */
1687c478bd9Sstevel@tonic-gate 	char	*pv_simple;
1697c478bd9Sstevel@tonic-gate 	complex_property_ptr_t	pv_complex;
1707c478bd9Sstevel@tonic-gate 	list_property_ptr_t	pv_list;
1717c478bd9Sstevel@tonic-gate } property_value_t, *property_value_ptr_t;
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate typedef struct cmd {
1747c478bd9Sstevel@tonic-gate 	char	*cmd_name;
1757c478bd9Sstevel@tonic-gate 	void	(*cmd_handler)(struct cmd *);
1767c478bd9Sstevel@tonic-gate 	int	cmd_res_type;
1777c478bd9Sstevel@tonic-gate 	int	cmd_prop_nv_pairs;
1787c478bd9Sstevel@tonic-gate 	int	cmd_prop_name[MAX_EQ_PROP_PAIRS];
1797c478bd9Sstevel@tonic-gate 	property_value_ptr_t	cmd_property_ptr[MAX_EQ_PROP_PAIRS];
1807c478bd9Sstevel@tonic-gate 	int	cmd_argc;
1817c478bd9Sstevel@tonic-gate 	char	*cmd_argv[MAX_SUBCMD_ARGS + 1];
1827c478bd9Sstevel@tonic-gate } cmd_t;
1837c478bd9Sstevel@tonic-gate 
1847c478bd9Sstevel@tonic-gate #define	HELP_USAGE	0x01
1857c478bd9Sstevel@tonic-gate #define	HELP_SUBCMDS	0x02
1867c478bd9Sstevel@tonic-gate #define	HELP_SYNTAX	0x04
1877c478bd9Sstevel@tonic-gate #define	HELP_RESOURCES	0x08
1887c478bd9Sstevel@tonic-gate #define	HELP_PROPS	0x10
1897c478bd9Sstevel@tonic-gate #define	HELP_META	0x20
1907c478bd9Sstevel@tonic-gate #define	HELP_NETADDR	0x40
1917c478bd9Sstevel@tonic-gate #define	HELP_RES_SCOPE	0x80
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate #define	HELP_RES_PROPS	(HELP_RESOURCES | HELP_PROPS)
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate extern void add_func(cmd_t *);
1967c478bd9Sstevel@tonic-gate extern void cancel_func(cmd_t *);
1977c478bd9Sstevel@tonic-gate extern void commit_func(cmd_t *);
1987c478bd9Sstevel@tonic-gate extern void create_func(cmd_t *);
1997c478bd9Sstevel@tonic-gate extern void delete_func(cmd_t *);
2007c478bd9Sstevel@tonic-gate extern void end_func(cmd_t *);
2017c478bd9Sstevel@tonic-gate extern void exit_func(cmd_t *);
2027c478bd9Sstevel@tonic-gate extern void export_func(cmd_t *);
2037c478bd9Sstevel@tonic-gate extern void help_func(cmd_t *);
2047c478bd9Sstevel@tonic-gate extern void info_func(cmd_t *);
2057c478bd9Sstevel@tonic-gate extern void remove_func(cmd_t *);
2067c478bd9Sstevel@tonic-gate extern void revert_func(cmd_t *);
2077c478bd9Sstevel@tonic-gate extern void select_func(cmd_t *);
2087c478bd9Sstevel@tonic-gate extern void set_func(cmd_t *);
2097c478bd9Sstevel@tonic-gate extern void verify_func(cmd_t *);
210*0209230bSgjelinek extern void clear_func(cmd_t *);
2117c478bd9Sstevel@tonic-gate 
2127c478bd9Sstevel@tonic-gate extern cmd_t *alloc_cmd(void);
2137c478bd9Sstevel@tonic-gate extern complex_property_ptr_t alloc_complex(void);
2147c478bd9Sstevel@tonic-gate extern list_property_ptr_t alloc_list(void);
2157c478bd9Sstevel@tonic-gate extern void free_cmd(cmd_t *cmd);
2167c478bd9Sstevel@tonic-gate extern void free_complex(complex_property_ptr_t complex);
2177c478bd9Sstevel@tonic-gate extern void free_list(list_property_ptr_t list);
2187c478bd9Sstevel@tonic-gate extern void free_outer_list(list_property_ptr_t list);
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate extern void usage(bool verbose, uint_t flags);
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate extern FILE *yyin;
2237c478bd9Sstevel@tonic-gate 
2247c478bd9Sstevel@tonic-gate #ifdef __cplusplus
2257c478bd9Sstevel@tonic-gate }
2267c478bd9Sstevel@tonic-gate #endif
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate #endif	/* _ZONECFG_H */
229