xref: /titanic_52/usr/src/cmd/zonecfg/zonecfg.h (revision cb8a054b1ab30d5caa746e6c44f29d4c9d3071c1)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5ffbafc53Scomay  * Common Development and Distribution License (the "License").
6ffbafc53Scomay  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21ffbafc53Scomay 
227c478bd9Sstevel@tonic-gate /*
23*cb8a054bSGlenn Faden  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _ZONECFG_H
277c478bd9Sstevel@tonic-gate #define	_ZONECFG_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * header file for zonecfg command
317c478bd9Sstevel@tonic-gate  */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifdef __cplusplus
347c478bd9Sstevel@tonic-gate extern "C" {
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #include <unistd.h>
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #define	Z_ERR		1
407c478bd9Sstevel@tonic-gate #define	Z_USAGE		2
417c478bd9Sstevel@tonic-gate #define	Z_REPEAT	3
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #define	CMD_ADD		0
447c478bd9Sstevel@tonic-gate #define	CMD_CANCEL	1
450209230bSgjelinek #define	CMD_CLEAR	2
460209230bSgjelinek #define	CMD_COMMIT	3
470209230bSgjelinek #define	CMD_CREATE	4
480209230bSgjelinek #define	CMD_DELETE	5
490209230bSgjelinek #define	CMD_END		6
500209230bSgjelinek #define	CMD_EXIT	7
510209230bSgjelinek #define	CMD_EXPORT	8
520209230bSgjelinek #define	CMD_HELP	9
530209230bSgjelinek #define	CMD_INFO	10
540209230bSgjelinek #define	CMD_REMOVE	11
550209230bSgjelinek #define	CMD_REVERT	12
560209230bSgjelinek #define	CMD_SELECT	13
570209230bSgjelinek #define	CMD_SET		14
580209230bSgjelinek #define	CMD_VERIFY	15
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate #define	CMD_MIN		CMD_ADD
617c478bd9Sstevel@tonic-gate #define	CMD_MAX		CMD_VERIFY
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate /* resource types: increment RT_MAX when expanding this list */
647c478bd9Sstevel@tonic-gate #define	RT_UNKNOWN	0
65087719fdSdp #define	RT_ZONENAME	1	/* really a property, but for info ... */
66087719fdSdp #define	RT_ZONEPATH	2	/* really a property, but for info ... */
67087719fdSdp #define	RT_AUTOBOOT	3	/* really a property, but for info ... */
68087719fdSdp #define	RT_POOL		4	/* really a property, but for info ... */
69087719fdSdp #define	RT_FS		5
70087719fdSdp #define	RT_IPD		6
71087719fdSdp #define	RT_NET		7
72087719fdSdp #define	RT_DEVICE	8
73087719fdSdp #define	RT_RCTL		9
74087719fdSdp #define	RT_ATTR		10
75fa9e4066Sahrens #define	RT_DATASET	11
76ffbafc53Scomay #define	RT_LIMITPRIV	12	/* really a property, but for info ... */
773f2f09c1Sdp #define	RT_BOOTARGS	13	/* really a property, but for info ... */
789acbbeafSnn35248 #define	RT_BRAND	14	/* really a property, but for info ... */
790209230bSgjelinek #define	RT_DCPU		15
800209230bSgjelinek #define	RT_MCAP		16
810209230bSgjelinek #define	RT_MAXLWPS	17	/* really a rctl alias property, but for info */
820209230bSgjelinek #define	RT_MAXSHMMEM	18	/* really a rctl alias property, but for info */
830209230bSgjelinek #define	RT_MAXSHMIDS	19	/* really a rctl alias property, but for info */
840209230bSgjelinek #define	RT_MAXMSGIDS	20	/* really a rctl alias property, but for info */
850209230bSgjelinek #define	RT_MAXSEMIDS	21	/* really a rctl alias property, but for info */
860209230bSgjelinek #define	RT_SHARES	22	/* really a rctl alias property, but for info */
870209230bSgjelinek #define	RT_SCHED	23	/* really a property, but for info ... */
88f4b3ec61Sdh155122 #define	RT_IPTYPE	24	/* really a property, but for info ... */
89c97ad5cdSakolb #define	RT_PCAP		25
905679c89fSjv227347 #define	RT_HOSTID	26	/* really a property, but for info ... */
91*cb8a054bSGlenn Faden #define	RT_ADMIN	27
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate #define	RT_MIN		RT_UNKNOWN
94*cb8a054bSGlenn Faden #define	RT_MAX		RT_ADMIN
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate /* property types: increment PT_MAX when expanding this list */
977c478bd9Sstevel@tonic-gate #define	PT_UNKNOWN	0
98087719fdSdp #define	PT_ZONENAME	1
99087719fdSdp #define	PT_ZONEPATH	2
100087719fdSdp #define	PT_AUTOBOOT	3
101087719fdSdp #define	PT_POOL		4
102087719fdSdp #define	PT_DIR		5
103087719fdSdp #define	PT_SPECIAL	6
104087719fdSdp #define	PT_TYPE		7
105087719fdSdp #define	PT_OPTIONS	8
106087719fdSdp #define	PT_ADDRESS	9
107087719fdSdp #define	PT_PHYSICAL	10
108087719fdSdp #define	PT_NAME		11
109087719fdSdp #define	PT_VALUE	12
110087719fdSdp #define	PT_MATCH	13
111087719fdSdp #define	PT_PRIV		14
112087719fdSdp #define	PT_LIMIT	15
113087719fdSdp #define	PT_ACTION	16
114087719fdSdp #define	PT_RAW		17
115ffbafc53Scomay #define	PT_LIMITPRIV	18
1163f2f09c1Sdp #define	PT_BOOTARGS	19
1179acbbeafSnn35248 #define	PT_BRAND	20
1180209230bSgjelinek #define	PT_NCPUS	21
1190209230bSgjelinek #define	PT_IMPORTANCE	22
1200209230bSgjelinek #define	PT_SWAP		23
1210209230bSgjelinek #define	PT_LOCKED	24
1220209230bSgjelinek #define	PT_SHARES	25
1230209230bSgjelinek #define	PT_MAXLWPS	26
1240209230bSgjelinek #define	PT_MAXSHMMEM	27
1250209230bSgjelinek #define	PT_MAXSHMIDS	28
1260209230bSgjelinek #define	PT_MAXMSGIDS	29
1270209230bSgjelinek #define	PT_MAXSEMIDS	30
1280209230bSgjelinek #define	PT_MAXLOCKEDMEM	31
1290209230bSgjelinek #define	PT_MAXSWAP	32
1300209230bSgjelinek #define	PT_SCHED	33
131f4b3ec61Sdh155122 #define	PT_IPTYPE	34
132de860bd9Sgfaden #define	PT_DEFROUTER	35
1335679c89fSjv227347 #define	PT_HOSTID	36
134*cb8a054bSGlenn Faden #define	PT_USER		37
135*cb8a054bSGlenn Faden #define	PT_AUTHS	38
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate #define	PT_MIN		PT_UNKNOWN
138*cb8a054bSGlenn Faden #define	PT_MAX		PT_AUTHS
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate #define	MAX_EQ_PROP_PAIRS	3
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate #define	PROP_VAL_SIMPLE		0
1437c478bd9Sstevel@tonic-gate #define	PROP_VAL_COMPLEX	1
1447c478bd9Sstevel@tonic-gate #define	PROP_VAL_LIST		2
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate #define	PROP_VAL_MIN		PROP_VAL_SIMPLE
1477c478bd9Sstevel@tonic-gate #define	PROP_VAL_MAX		PROP_VAL_LIST
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate /*
1507c478bd9Sstevel@tonic-gate  * If any subcommand is ever modified to take more than three arguments,
1517c478bd9Sstevel@tonic-gate  * this will need to be incremented.
1527c478bd9Sstevel@tonic-gate  */
1537c478bd9Sstevel@tonic-gate #define	MAX_SUBCMD_ARGS		3
1547c478bd9Sstevel@tonic-gate 
1557c478bd9Sstevel@tonic-gate typedef struct complex_property {
1567c478bd9Sstevel@tonic-gate 	int	cp_type;	/* from the PT_* list above */
1577c478bd9Sstevel@tonic-gate 	char	*cp_value;
1587c478bd9Sstevel@tonic-gate 	struct complex_property *cp_next;
1597c478bd9Sstevel@tonic-gate } complex_property_t, *complex_property_ptr_t;
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate typedef struct list_property {
1627c478bd9Sstevel@tonic-gate 	char	*lp_simple;
1637c478bd9Sstevel@tonic-gate 	complex_property_ptr_t	lp_complex;
1647c478bd9Sstevel@tonic-gate 	struct list_property	*lp_next;
1657c478bd9Sstevel@tonic-gate } list_property_t, *list_property_ptr_t;
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate typedef struct property_value {
1687c478bd9Sstevel@tonic-gate 	int	pv_type;	/* from the PROP_VAL_* list above */
1697c478bd9Sstevel@tonic-gate 	char	*pv_simple;
1707c478bd9Sstevel@tonic-gate 	complex_property_ptr_t	pv_complex;
1717c478bd9Sstevel@tonic-gate 	list_property_ptr_t	pv_list;
1727c478bd9Sstevel@tonic-gate } property_value_t, *property_value_ptr_t;
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate typedef struct cmd {
1757c478bd9Sstevel@tonic-gate 	char	*cmd_name;
1767c478bd9Sstevel@tonic-gate 	void	(*cmd_handler)(struct cmd *);
1777c478bd9Sstevel@tonic-gate 	int	cmd_res_type;
1787c478bd9Sstevel@tonic-gate 	int	cmd_prop_nv_pairs;
1797c478bd9Sstevel@tonic-gate 	int	cmd_prop_name[MAX_EQ_PROP_PAIRS];
1807c478bd9Sstevel@tonic-gate 	property_value_ptr_t	cmd_property_ptr[MAX_EQ_PROP_PAIRS];
1817c478bd9Sstevel@tonic-gate 	int	cmd_argc;
1827c478bd9Sstevel@tonic-gate 	char	*cmd_argv[MAX_SUBCMD_ARGS + 1];
1837c478bd9Sstevel@tonic-gate } cmd_t;
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate #define	HELP_USAGE	0x01
1867c478bd9Sstevel@tonic-gate #define	HELP_SUBCMDS	0x02
1877c478bd9Sstevel@tonic-gate #define	HELP_SYNTAX	0x04
1887c478bd9Sstevel@tonic-gate #define	HELP_RESOURCES	0x08
1897c478bd9Sstevel@tonic-gate #define	HELP_PROPS	0x10
1907c478bd9Sstevel@tonic-gate #define	HELP_META	0x20
1917c478bd9Sstevel@tonic-gate #define	HELP_NETADDR	0x40
1927c478bd9Sstevel@tonic-gate #define	HELP_RES_SCOPE	0x80
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate #define	HELP_RES_PROPS	(HELP_RESOURCES | HELP_PROPS)
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate extern void add_func(cmd_t *);
1977c478bd9Sstevel@tonic-gate extern void cancel_func(cmd_t *);
1987c478bd9Sstevel@tonic-gate extern void commit_func(cmd_t *);
1997c478bd9Sstevel@tonic-gate extern void create_func(cmd_t *);
2007c478bd9Sstevel@tonic-gate extern void delete_func(cmd_t *);
2017c478bd9Sstevel@tonic-gate extern void end_func(cmd_t *);
2027c478bd9Sstevel@tonic-gate extern void exit_func(cmd_t *);
2037c478bd9Sstevel@tonic-gate extern void export_func(cmd_t *);
2047c478bd9Sstevel@tonic-gate extern void help_func(cmd_t *);
2057c478bd9Sstevel@tonic-gate extern void info_func(cmd_t *);
2067c478bd9Sstevel@tonic-gate extern void remove_func(cmd_t *);
2077c478bd9Sstevel@tonic-gate extern void revert_func(cmd_t *);
2087c478bd9Sstevel@tonic-gate extern void select_func(cmd_t *);
2097c478bd9Sstevel@tonic-gate extern void set_func(cmd_t *);
2107c478bd9Sstevel@tonic-gate extern void verify_func(cmd_t *);
2110209230bSgjelinek extern void clear_func(cmd_t *);
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate extern cmd_t *alloc_cmd(void);
2147c478bd9Sstevel@tonic-gate extern complex_property_ptr_t alloc_complex(void);
2157c478bd9Sstevel@tonic-gate extern list_property_ptr_t alloc_list(void);
2167c478bd9Sstevel@tonic-gate extern void free_cmd(cmd_t *cmd);
2177c478bd9Sstevel@tonic-gate extern void free_complex(complex_property_ptr_t complex);
2187c478bd9Sstevel@tonic-gate extern void free_list(list_property_ptr_t list);
2197c478bd9Sstevel@tonic-gate extern void free_outer_list(list_property_ptr_t list);
2207c478bd9Sstevel@tonic-gate 
221bbec428eSgjelinek extern void usage(boolean_t verbose, uint_t flags);
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate extern FILE *yyin;
224c94c1ef0Sjv227347 extern char *res_types[];
225c94c1ef0Sjv227347 extern char *prop_types[];
2267c478bd9Sstevel@tonic-gate 
2277c478bd9Sstevel@tonic-gate #ifdef __cplusplus
2287c478bd9Sstevel@tonic-gate }
2297c478bd9Sstevel@tonic-gate #endif
2307c478bd9Sstevel@tonic-gate 
2317c478bd9Sstevel@tonic-gate #endif	/* _ZONECFG_H */
232