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