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