xref: /titanic_51/usr/src/cmd/zonecfg/zonecfg.h (revision f4b3ec61df05330d25f55a36b975b4d7519fdeb1)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _ZONECFG_H
28 #define	_ZONECFG_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * header file for zonecfg command
34  */
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #include <unistd.h>
41 
42 #define	FALSE	0
43 #define	TRUE	1
44 
45 typedef int bool;
46 
47 #define	Z_ERR		1
48 #define	Z_USAGE		2
49 #define	Z_REPEAT	3
50 
51 #define	CMD_ADD		0
52 #define	CMD_CANCEL	1
53 #define	CMD_CLEAR	2
54 #define	CMD_COMMIT	3
55 #define	CMD_CREATE	4
56 #define	CMD_DELETE	5
57 #define	CMD_END		6
58 #define	CMD_EXIT	7
59 #define	CMD_EXPORT	8
60 #define	CMD_HELP	9
61 #define	CMD_INFO	10
62 #define	CMD_REMOVE	11
63 #define	CMD_REVERT	12
64 #define	CMD_SELECT	13
65 #define	CMD_SET		14
66 #define	CMD_VERIFY	15
67 
68 #define	CMD_MIN		CMD_ADD
69 #define	CMD_MAX		CMD_VERIFY
70 
71 /* resource types: increment RT_MAX when expanding this list */
72 #define	RT_UNKNOWN	0
73 #define	RT_ZONENAME	1	/* really a property, but for info ... */
74 #define	RT_ZONEPATH	2	/* really a property, but for info ... */
75 #define	RT_AUTOBOOT	3	/* really a property, but for info ... */
76 #define	RT_POOL		4	/* really a property, but for info ... */
77 #define	RT_FS		5
78 #define	RT_IPD		6
79 #define	RT_NET		7
80 #define	RT_DEVICE	8
81 #define	RT_RCTL		9
82 #define	RT_ATTR		10
83 #define	RT_DATASET	11
84 #define	RT_LIMITPRIV	12	/* really a property, but for info ... */
85 #define	RT_BOOTARGS	13	/* really a property, but for info ... */
86 #define	RT_BRAND	14	/* really a property, but for info ... */
87 #define	RT_DCPU		15
88 #define	RT_MCAP		16
89 #define	RT_MAXLWPS	17	/* really a rctl alias property, but for info */
90 #define	RT_MAXSHMMEM	18	/* really a rctl alias property, but for info */
91 #define	RT_MAXSHMIDS	19	/* really a rctl alias property, but for info */
92 #define	RT_MAXMSGIDS	20	/* really a rctl alias property, but for info */
93 #define	RT_MAXSEMIDS	21	/* really a rctl alias property, but for info */
94 #define	RT_SHARES	22	/* really a rctl alias property, but for info */
95 #define	RT_SCHED	23	/* really a property, but for info ... */
96 #define	RT_IPTYPE	24	/* really a property, but for info ... */
97 
98 #define	RT_MIN		RT_UNKNOWN
99 #define	RT_MAX		RT_IPTYPE
100 
101 /* property types: increment PT_MAX when expanding this list */
102 #define	PT_UNKNOWN	0
103 #define	PT_ZONENAME	1
104 #define	PT_ZONEPATH	2
105 #define	PT_AUTOBOOT	3
106 #define	PT_POOL		4
107 #define	PT_DIR		5
108 #define	PT_SPECIAL	6
109 #define	PT_TYPE		7
110 #define	PT_OPTIONS	8
111 #define	PT_ADDRESS	9
112 #define	PT_PHYSICAL	10
113 #define	PT_NAME		11
114 #define	PT_VALUE	12
115 #define	PT_MATCH	13
116 #define	PT_PRIV		14
117 #define	PT_LIMIT	15
118 #define	PT_ACTION	16
119 #define	PT_RAW		17
120 #define	PT_LIMITPRIV	18
121 #define	PT_BOOTARGS	19
122 #define	PT_BRAND	20
123 #define	PT_NCPUS	21
124 #define	PT_IMPORTANCE	22
125 #define	PT_SWAP		23
126 #define	PT_LOCKED	24
127 #define	PT_SHARES	25
128 #define	PT_MAXLWPS	26
129 #define	PT_MAXSHMMEM	27
130 #define	PT_MAXSHMIDS	28
131 #define	PT_MAXMSGIDS	29
132 #define	PT_MAXSEMIDS	30
133 #define	PT_MAXLOCKEDMEM	31
134 #define	PT_MAXSWAP	32
135 #define	PT_SCHED	33
136 #define	PT_IPTYPE	34
137 
138 #define	PT_MIN		PT_UNKNOWN
139 #define	PT_MAX		PT_IPTYPE
140 
141 #define	MAX_EQ_PROP_PAIRS	3
142 
143 #define	PROP_VAL_SIMPLE		0
144 #define	PROP_VAL_COMPLEX	1
145 #define	PROP_VAL_LIST		2
146 
147 #define	PROP_VAL_MIN		PROP_VAL_SIMPLE
148 #define	PROP_VAL_MAX		PROP_VAL_LIST
149 
150 /*
151  * If any subcommand is ever modified to take more than three arguments,
152  * this will need to be incremented.
153  */
154 #define	MAX_SUBCMD_ARGS		3
155 
156 typedef struct complex_property {
157 	int	cp_type;	/* from the PT_* list above */
158 	char	*cp_value;
159 	struct complex_property *cp_next;
160 } complex_property_t, *complex_property_ptr_t;
161 
162 typedef struct list_property {
163 	char	*lp_simple;
164 	complex_property_ptr_t	lp_complex;
165 	struct list_property	*lp_next;
166 } list_property_t, *list_property_ptr_t;
167 
168 typedef struct property_value {
169 	int	pv_type;	/* from the PROP_VAL_* list above */
170 	char	*pv_simple;
171 	complex_property_ptr_t	pv_complex;
172 	list_property_ptr_t	pv_list;
173 } property_value_t, *property_value_ptr_t;
174 
175 typedef struct cmd {
176 	char	*cmd_name;
177 	void	(*cmd_handler)(struct cmd *);
178 	int	cmd_res_type;
179 	int	cmd_prop_nv_pairs;
180 	int	cmd_prop_name[MAX_EQ_PROP_PAIRS];
181 	property_value_ptr_t	cmd_property_ptr[MAX_EQ_PROP_PAIRS];
182 	int	cmd_argc;
183 	char	*cmd_argv[MAX_SUBCMD_ARGS + 1];
184 } cmd_t;
185 
186 #define	HELP_USAGE	0x01
187 #define	HELP_SUBCMDS	0x02
188 #define	HELP_SYNTAX	0x04
189 #define	HELP_RESOURCES	0x08
190 #define	HELP_PROPS	0x10
191 #define	HELP_META	0x20
192 #define	HELP_NETADDR	0x40
193 #define	HELP_RES_SCOPE	0x80
194 
195 #define	HELP_RES_PROPS	(HELP_RESOURCES | HELP_PROPS)
196 
197 extern void add_func(cmd_t *);
198 extern void cancel_func(cmd_t *);
199 extern void commit_func(cmd_t *);
200 extern void create_func(cmd_t *);
201 extern void delete_func(cmd_t *);
202 extern void end_func(cmd_t *);
203 extern void exit_func(cmd_t *);
204 extern void export_func(cmd_t *);
205 extern void help_func(cmd_t *);
206 extern void info_func(cmd_t *);
207 extern void remove_func(cmd_t *);
208 extern void revert_func(cmd_t *);
209 extern void select_func(cmd_t *);
210 extern void set_func(cmd_t *);
211 extern void verify_func(cmd_t *);
212 extern void clear_func(cmd_t *);
213 
214 extern cmd_t *alloc_cmd(void);
215 extern complex_property_ptr_t alloc_complex(void);
216 extern list_property_ptr_t alloc_list(void);
217 extern void free_cmd(cmd_t *cmd);
218 extern void free_complex(complex_property_ptr_t complex);
219 extern void free_list(list_property_ptr_t list);
220 extern void free_outer_list(list_property_ptr_t list);
221 
222 extern void usage(bool verbose, uint_t flags);
223 
224 extern FILE *yyin;
225 
226 #ifdef __cplusplus
227 }
228 #endif
229 
230 #endif	/* _ZONECFG_H */
231