xref: /titanic_44/usr/src/cmd/zonecfg/zonecfg.h (revision b7f45089ccbe01bab3d7c7377b49d80d2ae18a69)
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 2004 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_ZONEPATH	1	/* really a property, but for info ... */
73 #define	RT_AUTOBOOT	2	/* really a property, but for info ... */
74 #define	RT_POOL		3	/* really a property, but for info ... */
75 #define	RT_FS		4
76 #define	RT_IPD		5
77 #define	RT_NET		6
78 #define	RT_DEVICE	7
79 #define	RT_RCTL		8
80 #define	RT_ATTR		9
81 
82 #define	RT_MIN		RT_UNKNOWN
83 #define	RT_MAX		RT_ATTR
84 
85 /* property types: increment PT_MAX when expanding this list */
86 #define	PT_UNKNOWN	0
87 #define	PT_ZONEPATH	1
88 #define	PT_AUTOBOOT	2
89 #define	PT_POOL		3
90 #define	PT_DIR		4
91 #define	PT_SPECIAL	5
92 #define	PT_TYPE		6
93 #define	PT_OPTIONS	7
94 #define	PT_ADDRESS	8
95 #define	PT_PHYSICAL	9
96 #define	PT_NAME		10
97 #define	PT_VALUE	11
98 #define	PT_MATCH	12
99 #define	PT_PRIV		13
100 #define	PT_LIMIT	14
101 #define	PT_ACTION	15
102 #define	PT_RAW		16
103 
104 #define	PT_MIN		PT_UNKNOWN
105 #define	PT_MAX		PT_RAW
106 
107 #define	MAX_EQ_PROP_PAIRS	3
108 
109 #define	PROP_VAL_SIMPLE		0
110 #define	PROP_VAL_COMPLEX	1
111 #define	PROP_VAL_LIST		2
112 
113 #define	PROP_VAL_MIN		PROP_VAL_SIMPLE
114 #define	PROP_VAL_MAX		PROP_VAL_LIST
115 
116 /*
117  * If any subcommand is ever modified to take more than three arguments,
118  * this will need to be incremented.
119  */
120 #define	MAX_SUBCMD_ARGS		3
121 
122 typedef struct complex_property {
123 	int	cp_type;	/* from the PT_* list above */
124 	char	*cp_value;
125 	struct complex_property *cp_next;
126 } complex_property_t, *complex_property_ptr_t;
127 
128 typedef struct list_property {
129 	char	*lp_simple;
130 	complex_property_ptr_t	lp_complex;
131 	struct list_property	*lp_next;
132 } list_property_t, *list_property_ptr_t;
133 
134 typedef struct property_value {
135 	int	pv_type;	/* from the PROP_VAL_* list above */
136 	char	*pv_simple;
137 	complex_property_ptr_t	pv_complex;
138 	list_property_ptr_t	pv_list;
139 } property_value_t, *property_value_ptr_t;
140 
141 typedef struct cmd {
142 	char	*cmd_name;
143 	void	(*cmd_handler)(struct cmd *);
144 	int	cmd_res_type;
145 	int	cmd_prop_nv_pairs;
146 	int	cmd_prop_name[MAX_EQ_PROP_PAIRS];
147 	property_value_ptr_t	cmd_property_ptr[MAX_EQ_PROP_PAIRS];
148 	int	cmd_argc;
149 	char	*cmd_argv[MAX_SUBCMD_ARGS + 1];
150 } cmd_t;
151 
152 #define	HELP_USAGE	0x01
153 #define	HELP_SUBCMDS	0x02
154 #define	HELP_SYNTAX	0x04
155 #define	HELP_RESOURCES	0x08
156 #define	HELP_PROPS	0x10
157 #define	HELP_META	0x20
158 #define	HELP_NETADDR	0x40
159 #define	HELP_RES_SCOPE	0x80
160 
161 #define	HELP_RES_PROPS	(HELP_RESOURCES | HELP_PROPS)
162 
163 extern void add_func(cmd_t *);
164 extern void cancel_func(cmd_t *);
165 extern void commit_func(cmd_t *);
166 extern void create_func(cmd_t *);
167 extern void delete_func(cmd_t *);
168 extern void end_func(cmd_t *);
169 extern void exit_func(cmd_t *);
170 extern void export_func(cmd_t *);
171 extern void help_func(cmd_t *);
172 extern void info_func(cmd_t *);
173 extern void remove_func(cmd_t *);
174 extern void revert_func(cmd_t *);
175 extern void select_func(cmd_t *);
176 extern void set_func(cmd_t *);
177 extern void verify_func(cmd_t *);
178 
179 extern cmd_t *alloc_cmd(void);
180 extern complex_property_ptr_t alloc_complex(void);
181 extern list_property_ptr_t alloc_list(void);
182 extern void free_cmd(cmd_t *cmd);
183 extern void free_complex(complex_property_ptr_t complex);
184 extern void free_list(list_property_ptr_t list);
185 extern void free_outer_list(list_property_ptr_t list);
186 
187 extern void usage(bool verbose, uint_t flags);
188 
189 extern FILE *yyin;
190 
191 #ifdef __cplusplus
192 }
193 #endif
194 
195 #endif	/* _ZONECFG_H */
196