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