xref: /titanic_53/usr/src/cmd/zonecfg/zonecfg.h (revision fa9e4066f08beec538e775443c5be79dd423fcab)
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
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23087719fdSdp  * Copyright 2005 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
537c478bd9Sstevel@tonic-gate #define	CMD_COMMIT	2
547c478bd9Sstevel@tonic-gate #define	CMD_CREATE	3
557c478bd9Sstevel@tonic-gate #define	CMD_DELETE	4
567c478bd9Sstevel@tonic-gate #define	CMD_END		5
577c478bd9Sstevel@tonic-gate #define	CMD_EXIT	6
587c478bd9Sstevel@tonic-gate #define	CMD_EXPORT	7
597c478bd9Sstevel@tonic-gate #define	CMD_HELP	8
607c478bd9Sstevel@tonic-gate #define	CMD_INFO	9
617c478bd9Sstevel@tonic-gate #define	CMD_REMOVE	10
627c478bd9Sstevel@tonic-gate #define	CMD_REVERT	11
637c478bd9Sstevel@tonic-gate #define	CMD_SELECT	12
647c478bd9Sstevel@tonic-gate #define	CMD_SET		13
657c478bd9Sstevel@tonic-gate #define	CMD_VERIFY	14
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate #define	CMD_MIN		CMD_ADD
687c478bd9Sstevel@tonic-gate #define	CMD_MAX		CMD_VERIFY
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /* resource types: increment RT_MAX when expanding this list */
717c478bd9Sstevel@tonic-gate #define	RT_UNKNOWN	0
72087719fdSdp #define	RT_ZONENAME	1	/* really a property, but for info ... */
73087719fdSdp #define	RT_ZONEPATH	2	/* really a property, but for info ... */
74087719fdSdp #define	RT_AUTOBOOT	3	/* really a property, but for info ... */
75087719fdSdp #define	RT_POOL		4	/* really a property, but for info ... */
76087719fdSdp #define	RT_FS		5
77087719fdSdp #define	RT_IPD		6
78087719fdSdp #define	RT_NET		7
79087719fdSdp #define	RT_DEVICE	8
80087719fdSdp #define	RT_RCTL		9
81087719fdSdp #define	RT_ATTR		10
82*fa9e4066Sahrens #define	RT_DATASET	11
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate #define	RT_MIN		RT_UNKNOWN
85*fa9e4066Sahrens #define	RT_MAX		RT_DATASET
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate /* property types: increment PT_MAX when expanding this list */
887c478bd9Sstevel@tonic-gate #define	PT_UNKNOWN	0
89087719fdSdp #define	PT_ZONENAME	1
90087719fdSdp #define	PT_ZONEPATH	2
91087719fdSdp #define	PT_AUTOBOOT	3
92087719fdSdp #define	PT_POOL		4
93087719fdSdp #define	PT_DIR		5
94087719fdSdp #define	PT_SPECIAL	6
95087719fdSdp #define	PT_TYPE		7
96087719fdSdp #define	PT_OPTIONS	8
97087719fdSdp #define	PT_ADDRESS	9
98087719fdSdp #define	PT_PHYSICAL	10
99087719fdSdp #define	PT_NAME		11
100087719fdSdp #define	PT_VALUE	12
101087719fdSdp #define	PT_MATCH	13
102087719fdSdp #define	PT_PRIV		14
103087719fdSdp #define	PT_LIMIT	15
104087719fdSdp #define	PT_ACTION	16
105087719fdSdp #define	PT_RAW		17
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate #define	PT_MIN		PT_UNKNOWN
1087c478bd9Sstevel@tonic-gate #define	PT_MAX		PT_RAW
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate #define	MAX_EQ_PROP_PAIRS	3
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate #define	PROP_VAL_SIMPLE		0
1137c478bd9Sstevel@tonic-gate #define	PROP_VAL_COMPLEX	1
1147c478bd9Sstevel@tonic-gate #define	PROP_VAL_LIST		2
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate #define	PROP_VAL_MIN		PROP_VAL_SIMPLE
1177c478bd9Sstevel@tonic-gate #define	PROP_VAL_MAX		PROP_VAL_LIST
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate /*
1207c478bd9Sstevel@tonic-gate  * If any subcommand is ever modified to take more than three arguments,
1217c478bd9Sstevel@tonic-gate  * this will need to be incremented.
1227c478bd9Sstevel@tonic-gate  */
1237c478bd9Sstevel@tonic-gate #define	MAX_SUBCMD_ARGS		3
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate typedef struct complex_property {
1267c478bd9Sstevel@tonic-gate 	int	cp_type;	/* from the PT_* list above */
1277c478bd9Sstevel@tonic-gate 	char	*cp_value;
1287c478bd9Sstevel@tonic-gate 	struct complex_property *cp_next;
1297c478bd9Sstevel@tonic-gate } complex_property_t, *complex_property_ptr_t;
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate typedef struct list_property {
1327c478bd9Sstevel@tonic-gate 	char	*lp_simple;
1337c478bd9Sstevel@tonic-gate 	complex_property_ptr_t	lp_complex;
1347c478bd9Sstevel@tonic-gate 	struct list_property	*lp_next;
1357c478bd9Sstevel@tonic-gate } list_property_t, *list_property_ptr_t;
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate typedef struct property_value {
1387c478bd9Sstevel@tonic-gate 	int	pv_type;	/* from the PROP_VAL_* list above */
1397c478bd9Sstevel@tonic-gate 	char	*pv_simple;
1407c478bd9Sstevel@tonic-gate 	complex_property_ptr_t	pv_complex;
1417c478bd9Sstevel@tonic-gate 	list_property_ptr_t	pv_list;
1427c478bd9Sstevel@tonic-gate } property_value_t, *property_value_ptr_t;
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate typedef struct cmd {
1457c478bd9Sstevel@tonic-gate 	char	*cmd_name;
1467c478bd9Sstevel@tonic-gate 	void	(*cmd_handler)(struct cmd *);
1477c478bd9Sstevel@tonic-gate 	int	cmd_res_type;
1487c478bd9Sstevel@tonic-gate 	int	cmd_prop_nv_pairs;
1497c478bd9Sstevel@tonic-gate 	int	cmd_prop_name[MAX_EQ_PROP_PAIRS];
1507c478bd9Sstevel@tonic-gate 	property_value_ptr_t	cmd_property_ptr[MAX_EQ_PROP_PAIRS];
1517c478bd9Sstevel@tonic-gate 	int	cmd_argc;
1527c478bd9Sstevel@tonic-gate 	char	*cmd_argv[MAX_SUBCMD_ARGS + 1];
1537c478bd9Sstevel@tonic-gate } cmd_t;
1547c478bd9Sstevel@tonic-gate 
1557c478bd9Sstevel@tonic-gate #define	HELP_USAGE	0x01
1567c478bd9Sstevel@tonic-gate #define	HELP_SUBCMDS	0x02
1577c478bd9Sstevel@tonic-gate #define	HELP_SYNTAX	0x04
1587c478bd9Sstevel@tonic-gate #define	HELP_RESOURCES	0x08
1597c478bd9Sstevel@tonic-gate #define	HELP_PROPS	0x10
1607c478bd9Sstevel@tonic-gate #define	HELP_META	0x20
1617c478bd9Sstevel@tonic-gate #define	HELP_NETADDR	0x40
1627c478bd9Sstevel@tonic-gate #define	HELP_RES_SCOPE	0x80
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate #define	HELP_RES_PROPS	(HELP_RESOURCES | HELP_PROPS)
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate extern void add_func(cmd_t *);
1677c478bd9Sstevel@tonic-gate extern void cancel_func(cmd_t *);
1687c478bd9Sstevel@tonic-gate extern void commit_func(cmd_t *);
1697c478bd9Sstevel@tonic-gate extern void create_func(cmd_t *);
1707c478bd9Sstevel@tonic-gate extern void delete_func(cmd_t *);
1717c478bd9Sstevel@tonic-gate extern void end_func(cmd_t *);
1727c478bd9Sstevel@tonic-gate extern void exit_func(cmd_t *);
1737c478bd9Sstevel@tonic-gate extern void export_func(cmd_t *);
1747c478bd9Sstevel@tonic-gate extern void help_func(cmd_t *);
1757c478bd9Sstevel@tonic-gate extern void info_func(cmd_t *);
1767c478bd9Sstevel@tonic-gate extern void remove_func(cmd_t *);
1777c478bd9Sstevel@tonic-gate extern void revert_func(cmd_t *);
1787c478bd9Sstevel@tonic-gate extern void select_func(cmd_t *);
1797c478bd9Sstevel@tonic-gate extern void set_func(cmd_t *);
1807c478bd9Sstevel@tonic-gate extern void verify_func(cmd_t *);
1817c478bd9Sstevel@tonic-gate 
1827c478bd9Sstevel@tonic-gate extern cmd_t *alloc_cmd(void);
1837c478bd9Sstevel@tonic-gate extern complex_property_ptr_t alloc_complex(void);
1847c478bd9Sstevel@tonic-gate extern list_property_ptr_t alloc_list(void);
1857c478bd9Sstevel@tonic-gate extern void free_cmd(cmd_t *cmd);
1867c478bd9Sstevel@tonic-gate extern void free_complex(complex_property_ptr_t complex);
1877c478bd9Sstevel@tonic-gate extern void free_list(list_property_ptr_t list);
1887c478bd9Sstevel@tonic-gate extern void free_outer_list(list_property_ptr_t list);
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate extern void usage(bool verbose, uint_t flags);
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate extern FILE *yyin;
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1957c478bd9Sstevel@tonic-gate }
1967c478bd9Sstevel@tonic-gate #endif
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate #endif	/* _ZONECFG_H */
199