xref: /titanic_53/usr/src/cmd/zonecfg/zonecfg.h (revision c97ad5cdc75eb73e3cc38542ca3ba783574b0a7a)
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 /*
23f4b3ec61Sdh155122  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef _ZONECFG_H
287c478bd9Sstevel@tonic-gate #define	_ZONECFG_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate /*
337c478bd9Sstevel@tonic-gate  * header file for zonecfg command
347c478bd9Sstevel@tonic-gate  */
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #ifdef __cplusplus
377c478bd9Sstevel@tonic-gate extern "C" {
387c478bd9Sstevel@tonic-gate #endif
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #include <unistd.h>
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #define	FALSE	0
437c478bd9Sstevel@tonic-gate #define	TRUE	1
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate typedef int bool;
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate #define	Z_ERR		1
487c478bd9Sstevel@tonic-gate #define	Z_USAGE		2
497c478bd9Sstevel@tonic-gate #define	Z_REPEAT	3
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate #define	CMD_ADD		0
527c478bd9Sstevel@tonic-gate #define	CMD_CANCEL	1
530209230bSgjelinek #define	CMD_CLEAR	2
540209230bSgjelinek #define	CMD_COMMIT	3
550209230bSgjelinek #define	CMD_CREATE	4
560209230bSgjelinek #define	CMD_DELETE	5
570209230bSgjelinek #define	CMD_END		6
580209230bSgjelinek #define	CMD_EXIT	7
590209230bSgjelinek #define	CMD_EXPORT	8
600209230bSgjelinek #define	CMD_HELP	9
610209230bSgjelinek #define	CMD_INFO	10
620209230bSgjelinek #define	CMD_REMOVE	11
630209230bSgjelinek #define	CMD_REVERT	12
640209230bSgjelinek #define	CMD_SELECT	13
650209230bSgjelinek #define	CMD_SET		14
660209230bSgjelinek #define	CMD_VERIFY	15
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate #define	CMD_MIN		CMD_ADD
697c478bd9Sstevel@tonic-gate #define	CMD_MAX		CMD_VERIFY
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate /* resource types: increment RT_MAX when expanding this list */
727c478bd9Sstevel@tonic-gate #define	RT_UNKNOWN	0
73087719fdSdp #define	RT_ZONENAME	1	/* really a property, but for info ... */
74087719fdSdp #define	RT_ZONEPATH	2	/* really a property, but for info ... */
75087719fdSdp #define	RT_AUTOBOOT	3	/* really a property, but for info ... */
76087719fdSdp #define	RT_POOL		4	/* really a property, but for info ... */
77087719fdSdp #define	RT_FS		5
78087719fdSdp #define	RT_IPD		6
79087719fdSdp #define	RT_NET		7
80087719fdSdp #define	RT_DEVICE	8
81087719fdSdp #define	RT_RCTL		9
82087719fdSdp #define	RT_ATTR		10
83fa9e4066Sahrens #define	RT_DATASET	11
84ffbafc53Scomay #define	RT_LIMITPRIV	12	/* really a property, but for info ... */
853f2f09c1Sdp #define	RT_BOOTARGS	13	/* really a property, but for info ... */
869acbbeafSnn35248 #define	RT_BRAND	14	/* really a property, but for info ... */
870209230bSgjelinek #define	RT_DCPU		15
880209230bSgjelinek #define	RT_MCAP		16
890209230bSgjelinek #define	RT_MAXLWPS	17	/* really a rctl alias property, but for info */
900209230bSgjelinek #define	RT_MAXSHMMEM	18	/* really a rctl alias property, but for info */
910209230bSgjelinek #define	RT_MAXSHMIDS	19	/* really a rctl alias property, but for info */
920209230bSgjelinek #define	RT_MAXMSGIDS	20	/* really a rctl alias property, but for info */
930209230bSgjelinek #define	RT_MAXSEMIDS	21	/* really a rctl alias property, but for info */
940209230bSgjelinek #define	RT_SHARES	22	/* really a rctl alias property, but for info */
950209230bSgjelinek #define	RT_SCHED	23	/* really a property, but for info ... */
96f4b3ec61Sdh155122 #define	RT_IPTYPE	24	/* really a property, but for info ... */
97*c97ad5cdSakolb #define	RT_PCAP		25
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate #define	RT_MIN		RT_UNKNOWN
100*c97ad5cdSakolb #define	RT_MAX		RT_PCAP
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate /* property types: increment PT_MAX when expanding this list */
1037c478bd9Sstevel@tonic-gate #define	PT_UNKNOWN	0
104087719fdSdp #define	PT_ZONENAME	1
105087719fdSdp #define	PT_ZONEPATH	2
106087719fdSdp #define	PT_AUTOBOOT	3
107087719fdSdp #define	PT_POOL		4
108087719fdSdp #define	PT_DIR		5
109087719fdSdp #define	PT_SPECIAL	6
110087719fdSdp #define	PT_TYPE		7
111087719fdSdp #define	PT_OPTIONS	8
112087719fdSdp #define	PT_ADDRESS	9
113087719fdSdp #define	PT_PHYSICAL	10
114087719fdSdp #define	PT_NAME		11
115087719fdSdp #define	PT_VALUE	12
116087719fdSdp #define	PT_MATCH	13
117087719fdSdp #define	PT_PRIV		14
118087719fdSdp #define	PT_LIMIT	15
119087719fdSdp #define	PT_ACTION	16
120087719fdSdp #define	PT_RAW		17
121ffbafc53Scomay #define	PT_LIMITPRIV	18
1223f2f09c1Sdp #define	PT_BOOTARGS	19
1239acbbeafSnn35248 #define	PT_BRAND	20
1240209230bSgjelinek #define	PT_NCPUS	21
1250209230bSgjelinek #define	PT_IMPORTANCE	22
1260209230bSgjelinek #define	PT_SWAP		23
1270209230bSgjelinek #define	PT_LOCKED	24
1280209230bSgjelinek #define	PT_SHARES	25
1290209230bSgjelinek #define	PT_MAXLWPS	26
1300209230bSgjelinek #define	PT_MAXSHMMEM	27
1310209230bSgjelinek #define	PT_MAXSHMIDS	28
1320209230bSgjelinek #define	PT_MAXMSGIDS	29
1330209230bSgjelinek #define	PT_MAXSEMIDS	30
1340209230bSgjelinek #define	PT_MAXLOCKEDMEM	31
1350209230bSgjelinek #define	PT_MAXSWAP	32
1360209230bSgjelinek #define	PT_SCHED	33
137f4b3ec61Sdh155122 #define	PT_IPTYPE	34
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate #define	PT_MIN		PT_UNKNOWN
140f4b3ec61Sdh155122 #define	PT_MAX		PT_IPTYPE
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate #define	MAX_EQ_PROP_PAIRS	3
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate #define	PROP_VAL_SIMPLE		0
1457c478bd9Sstevel@tonic-gate #define	PROP_VAL_COMPLEX	1
1467c478bd9Sstevel@tonic-gate #define	PROP_VAL_LIST		2
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate #define	PROP_VAL_MIN		PROP_VAL_SIMPLE
1497c478bd9Sstevel@tonic-gate #define	PROP_VAL_MAX		PROP_VAL_LIST
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate /*
1527c478bd9Sstevel@tonic-gate  * If any subcommand is ever modified to take more than three arguments,
1537c478bd9Sstevel@tonic-gate  * this will need to be incremented.
1547c478bd9Sstevel@tonic-gate  */
1557c478bd9Sstevel@tonic-gate #define	MAX_SUBCMD_ARGS		3
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate typedef struct complex_property {
1587c478bd9Sstevel@tonic-gate 	int	cp_type;	/* from the PT_* list above */
1597c478bd9Sstevel@tonic-gate 	char	*cp_value;
1607c478bd9Sstevel@tonic-gate 	struct complex_property *cp_next;
1617c478bd9Sstevel@tonic-gate } complex_property_t, *complex_property_ptr_t;
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate typedef struct list_property {
1647c478bd9Sstevel@tonic-gate 	char	*lp_simple;
1657c478bd9Sstevel@tonic-gate 	complex_property_ptr_t	lp_complex;
1667c478bd9Sstevel@tonic-gate 	struct list_property	*lp_next;
1677c478bd9Sstevel@tonic-gate } list_property_t, *list_property_ptr_t;
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate typedef struct property_value {
1707c478bd9Sstevel@tonic-gate 	int	pv_type;	/* from the PROP_VAL_* list above */
1717c478bd9Sstevel@tonic-gate 	char	*pv_simple;
1727c478bd9Sstevel@tonic-gate 	complex_property_ptr_t	pv_complex;
1737c478bd9Sstevel@tonic-gate 	list_property_ptr_t	pv_list;
1747c478bd9Sstevel@tonic-gate } property_value_t, *property_value_ptr_t;
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate typedef struct cmd {
1777c478bd9Sstevel@tonic-gate 	char	*cmd_name;
1787c478bd9Sstevel@tonic-gate 	void	(*cmd_handler)(struct cmd *);
1797c478bd9Sstevel@tonic-gate 	int	cmd_res_type;
1807c478bd9Sstevel@tonic-gate 	int	cmd_prop_nv_pairs;
1817c478bd9Sstevel@tonic-gate 	int	cmd_prop_name[MAX_EQ_PROP_PAIRS];
1827c478bd9Sstevel@tonic-gate 	property_value_ptr_t	cmd_property_ptr[MAX_EQ_PROP_PAIRS];
1837c478bd9Sstevel@tonic-gate 	int	cmd_argc;
1847c478bd9Sstevel@tonic-gate 	char	*cmd_argv[MAX_SUBCMD_ARGS + 1];
1857c478bd9Sstevel@tonic-gate } cmd_t;
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate #define	HELP_USAGE	0x01
1887c478bd9Sstevel@tonic-gate #define	HELP_SUBCMDS	0x02
1897c478bd9Sstevel@tonic-gate #define	HELP_SYNTAX	0x04
1907c478bd9Sstevel@tonic-gate #define	HELP_RESOURCES	0x08
1917c478bd9Sstevel@tonic-gate #define	HELP_PROPS	0x10
1927c478bd9Sstevel@tonic-gate #define	HELP_META	0x20
1937c478bd9Sstevel@tonic-gate #define	HELP_NETADDR	0x40
1947c478bd9Sstevel@tonic-gate #define	HELP_RES_SCOPE	0x80
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate #define	HELP_RES_PROPS	(HELP_RESOURCES | HELP_PROPS)
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate extern void add_func(cmd_t *);
1997c478bd9Sstevel@tonic-gate extern void cancel_func(cmd_t *);
2007c478bd9Sstevel@tonic-gate extern void commit_func(cmd_t *);
2017c478bd9Sstevel@tonic-gate extern void create_func(cmd_t *);
2027c478bd9Sstevel@tonic-gate extern void delete_func(cmd_t *);
2037c478bd9Sstevel@tonic-gate extern void end_func(cmd_t *);
2047c478bd9Sstevel@tonic-gate extern void exit_func(cmd_t *);
2057c478bd9Sstevel@tonic-gate extern void export_func(cmd_t *);
2067c478bd9Sstevel@tonic-gate extern void help_func(cmd_t *);
2077c478bd9Sstevel@tonic-gate extern void info_func(cmd_t *);
2087c478bd9Sstevel@tonic-gate extern void remove_func(cmd_t *);
2097c478bd9Sstevel@tonic-gate extern void revert_func(cmd_t *);
2107c478bd9Sstevel@tonic-gate extern void select_func(cmd_t *);
2117c478bd9Sstevel@tonic-gate extern void set_func(cmd_t *);
2127c478bd9Sstevel@tonic-gate extern void verify_func(cmd_t *);
2130209230bSgjelinek extern void clear_func(cmd_t *);
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate extern cmd_t *alloc_cmd(void);
2167c478bd9Sstevel@tonic-gate extern complex_property_ptr_t alloc_complex(void);
2177c478bd9Sstevel@tonic-gate extern list_property_ptr_t alloc_list(void);
2187c478bd9Sstevel@tonic-gate extern void free_cmd(cmd_t *cmd);
2197c478bd9Sstevel@tonic-gate extern void free_complex(complex_property_ptr_t complex);
2207c478bd9Sstevel@tonic-gate extern void free_list(list_property_ptr_t list);
2217c478bd9Sstevel@tonic-gate extern void free_outer_list(list_property_ptr_t list);
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate extern void usage(bool verbose, uint_t flags);
2247c478bd9Sstevel@tonic-gate 
2257c478bd9Sstevel@tonic-gate extern FILE *yyin;
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