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