10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51645Scomay * Common Development and Distribution License (the "License"). 61645Scomay * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 211645Scomay 220Sstevel@tonic-gate /* 2312582SGlenn.Faden@Sun.COM * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _ZONECFG_H 270Sstevel@tonic-gate #define _ZONECFG_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate /* 300Sstevel@tonic-gate * header file for zonecfg command 310Sstevel@tonic-gate */ 320Sstevel@tonic-gate 330Sstevel@tonic-gate #ifdef __cplusplus 340Sstevel@tonic-gate extern "C" { 350Sstevel@tonic-gate #endif 360Sstevel@tonic-gate 370Sstevel@tonic-gate #include <unistd.h> 380Sstevel@tonic-gate 390Sstevel@tonic-gate #define Z_ERR 1 400Sstevel@tonic-gate #define Z_USAGE 2 410Sstevel@tonic-gate #define Z_REPEAT 3 420Sstevel@tonic-gate 430Sstevel@tonic-gate #define CMD_ADD 0 440Sstevel@tonic-gate #define CMD_CANCEL 1 453247Sgjelinek #define CMD_CLEAR 2 463247Sgjelinek #define CMD_COMMIT 3 473247Sgjelinek #define CMD_CREATE 4 483247Sgjelinek #define CMD_DELETE 5 493247Sgjelinek #define CMD_END 6 503247Sgjelinek #define CMD_EXIT 7 513247Sgjelinek #define CMD_EXPORT 8 523247Sgjelinek #define CMD_HELP 9 533247Sgjelinek #define CMD_INFO 10 543247Sgjelinek #define CMD_REMOVE 11 553247Sgjelinek #define CMD_REVERT 12 563247Sgjelinek #define CMD_SELECT 13 573247Sgjelinek #define CMD_SET 14 583247Sgjelinek #define CMD_VERIFY 15 590Sstevel@tonic-gate 600Sstevel@tonic-gate #define CMD_MIN CMD_ADD 610Sstevel@tonic-gate #define CMD_MAX CMD_VERIFY 620Sstevel@tonic-gate 630Sstevel@tonic-gate /* resource types: increment RT_MAX when expanding this list */ 640Sstevel@tonic-gate #define RT_UNKNOWN 0 65565Sdp #define RT_ZONENAME 1 /* really a property, but for info ... */ 66565Sdp #define RT_ZONEPATH 2 /* really a property, but for info ... */ 67565Sdp #define RT_AUTOBOOT 3 /* really a property, but for info ... */ 68565Sdp #define RT_POOL 4 /* really a property, but for info ... */ 69565Sdp #define RT_FS 5 7012734Sgary.pennington@oracle.com #define RT_NET 6 7112734Sgary.pennington@oracle.com #define RT_DEVICE 7 7212734Sgary.pennington@oracle.com #define RT_RCTL 8 7312734Sgary.pennington@oracle.com #define RT_ATTR 9 7412734Sgary.pennington@oracle.com #define RT_DATASET 10 7512734Sgary.pennington@oracle.com #define RT_LIMITPRIV 11 /* really a property, but for info ... */ 7612734Sgary.pennington@oracle.com #define RT_BOOTARGS 12 /* really a property, but for info ... */ 7712734Sgary.pennington@oracle.com #define RT_BRAND 13 /* really a property, but for info ... */ 7812734Sgary.pennington@oracle.com #define RT_DCPU 14 7912734Sgary.pennington@oracle.com #define RT_MCAP 15 8012734Sgary.pennington@oracle.com #define RT_MAXLWPS 16 /* really a rctl alias property, but for info */ 8112734Sgary.pennington@oracle.com #define RT_MAXSHMMEM 17 /* really a rctl alias property, but for info */ 8212734Sgary.pennington@oracle.com #define RT_MAXSHMIDS 18 /* really a rctl alias property, but for info */ 8312734Sgary.pennington@oracle.com #define RT_MAXMSGIDS 19 /* really a rctl alias property, but for info */ 8412734Sgary.pennington@oracle.com #define RT_MAXSEMIDS 20 /* really a rctl alias property, but for info */ 8512734Sgary.pennington@oracle.com #define RT_SHARES 21 /* really a rctl alias property, but for info */ 8612734Sgary.pennington@oracle.com #define RT_SCHED 22 /* really a property, but for info ... */ 8712734Sgary.pennington@oracle.com #define RT_IPTYPE 23 /* really a property, but for info ... */ 8812734Sgary.pennington@oracle.com #define RT_PCAP 24 8912734Sgary.pennington@oracle.com #define RT_HOSTID 25 /* really a property, but for info ... */ 9012734Sgary.pennington@oracle.com #define RT_ADMIN 26 9112734Sgary.pennington@oracle.com #define RT_FS_ALLOWED 27 9212734Sgary.pennington@oracle.com #define RT_MAXPROCS 28 /* really a rctl alias property, but for info */ 930Sstevel@tonic-gate 940Sstevel@tonic-gate #define RT_MIN RT_UNKNOWN 9512725SMenno.Lageman@Sun.COM #define RT_MAX RT_MAXPROCS 960Sstevel@tonic-gate 970Sstevel@tonic-gate /* property types: increment PT_MAX when expanding this list */ 980Sstevel@tonic-gate #define PT_UNKNOWN 0 99565Sdp #define PT_ZONENAME 1 100565Sdp #define PT_ZONEPATH 2 101565Sdp #define PT_AUTOBOOT 3 102565Sdp #define PT_POOL 4 103565Sdp #define PT_DIR 5 104565Sdp #define PT_SPECIAL 6 105565Sdp #define PT_TYPE 7 106565Sdp #define PT_OPTIONS 8 107565Sdp #define PT_ADDRESS 9 108565Sdp #define PT_PHYSICAL 10 109565Sdp #define PT_NAME 11 110565Sdp #define PT_VALUE 12 111565Sdp #define PT_MATCH 13 112565Sdp #define PT_PRIV 14 113565Sdp #define PT_LIMIT 15 114565Sdp #define PT_ACTION 16 115565Sdp #define PT_RAW 17 1161645Scomay #define PT_LIMITPRIV 18 1172267Sdp #define PT_BOOTARGS 19 1182712Snn35248 #define PT_BRAND 20 1193247Sgjelinek #define PT_NCPUS 21 1203247Sgjelinek #define PT_IMPORTANCE 22 1213247Sgjelinek #define PT_SWAP 23 1223247Sgjelinek #define PT_LOCKED 24 1233247Sgjelinek #define PT_SHARES 25 1243247Sgjelinek #define PT_MAXLWPS 26 1253247Sgjelinek #define PT_MAXSHMMEM 27 1263247Sgjelinek #define PT_MAXSHMIDS 28 1273247Sgjelinek #define PT_MAXMSGIDS 29 1283247Sgjelinek #define PT_MAXSEMIDS 30 1293247Sgjelinek #define PT_MAXLOCKEDMEM 31 1303247Sgjelinek #define PT_MAXSWAP 32 1313247Sgjelinek #define PT_SCHED 33 1323448Sdh155122 #define PT_IPTYPE 34 1336076Sgfaden #define PT_DEFROUTER 35 1348662SJordan.Vaughan@Sun.com #define PT_HOSTID 36 13512578SGlenn.Faden@Sun.COM #define PT_USER 37 13612578SGlenn.Faden@Sun.COM #define PT_AUTHS 38 13712633Sjohn.levon@sun.com #define PT_FS_ALLOWED 39 13812725SMenno.Lageman@Sun.COM #define PT_MAXPROCS 40 13912748SSowmini.Varadhan@oracle.COM #define PT_ALLOWED_ADDRESS 41 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate #define PT_MIN PT_UNKNOWN 14212748SSowmini.Varadhan@oracle.COM #define PT_MAX PT_ALLOWED_ADDRESS 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate #define MAX_EQ_PROP_PAIRS 3 1450Sstevel@tonic-gate 1460Sstevel@tonic-gate #define PROP_VAL_SIMPLE 0 1470Sstevel@tonic-gate #define PROP_VAL_COMPLEX 1 1480Sstevel@tonic-gate #define PROP_VAL_LIST 2 1490Sstevel@tonic-gate 1500Sstevel@tonic-gate #define PROP_VAL_MIN PROP_VAL_SIMPLE 1510Sstevel@tonic-gate #define PROP_VAL_MAX PROP_VAL_LIST 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate /* 1540Sstevel@tonic-gate * If any subcommand is ever modified to take more than three arguments, 1550Sstevel@tonic-gate * this will need to be incremented. 1560Sstevel@tonic-gate */ 1570Sstevel@tonic-gate #define MAX_SUBCMD_ARGS 3 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate typedef struct complex_property { 1600Sstevel@tonic-gate int cp_type; /* from the PT_* list above */ 1610Sstevel@tonic-gate char *cp_value; 1620Sstevel@tonic-gate struct complex_property *cp_next; 1630Sstevel@tonic-gate } complex_property_t, *complex_property_ptr_t; 1640Sstevel@tonic-gate 1650Sstevel@tonic-gate typedef struct list_property { 1660Sstevel@tonic-gate char *lp_simple; 1670Sstevel@tonic-gate complex_property_ptr_t lp_complex; 1680Sstevel@tonic-gate struct list_property *lp_next; 1690Sstevel@tonic-gate } list_property_t, *list_property_ptr_t; 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate typedef struct property_value { 1720Sstevel@tonic-gate int pv_type; /* from the PROP_VAL_* list above */ 1730Sstevel@tonic-gate char *pv_simple; 1740Sstevel@tonic-gate complex_property_ptr_t pv_complex; 1750Sstevel@tonic-gate list_property_ptr_t pv_list; 1760Sstevel@tonic-gate } property_value_t, *property_value_ptr_t; 1770Sstevel@tonic-gate 1780Sstevel@tonic-gate typedef struct cmd { 1790Sstevel@tonic-gate char *cmd_name; 1800Sstevel@tonic-gate void (*cmd_handler)(struct cmd *); 1810Sstevel@tonic-gate int cmd_res_type; 1820Sstevel@tonic-gate int cmd_prop_nv_pairs; 1830Sstevel@tonic-gate int cmd_prop_name[MAX_EQ_PROP_PAIRS]; 1840Sstevel@tonic-gate property_value_ptr_t cmd_property_ptr[MAX_EQ_PROP_PAIRS]; 1850Sstevel@tonic-gate int cmd_argc; 1860Sstevel@tonic-gate char *cmd_argv[MAX_SUBCMD_ARGS + 1]; 1870Sstevel@tonic-gate } cmd_t; 1880Sstevel@tonic-gate 1890Sstevel@tonic-gate #define HELP_USAGE 0x01 1900Sstevel@tonic-gate #define HELP_SUBCMDS 0x02 1910Sstevel@tonic-gate #define HELP_SYNTAX 0x04 1920Sstevel@tonic-gate #define HELP_RESOURCES 0x08 1930Sstevel@tonic-gate #define HELP_PROPS 0x10 1940Sstevel@tonic-gate #define HELP_META 0x20 1950Sstevel@tonic-gate #define HELP_NETADDR 0x40 1960Sstevel@tonic-gate #define HELP_RES_SCOPE 0x80 1970Sstevel@tonic-gate 1980Sstevel@tonic-gate #define HELP_RES_PROPS (HELP_RESOURCES | HELP_PROPS) 1990Sstevel@tonic-gate 2000Sstevel@tonic-gate extern void add_func(cmd_t *); 2010Sstevel@tonic-gate extern void cancel_func(cmd_t *); 2020Sstevel@tonic-gate extern void commit_func(cmd_t *); 2030Sstevel@tonic-gate extern void create_func(cmd_t *); 2040Sstevel@tonic-gate extern void delete_func(cmd_t *); 2050Sstevel@tonic-gate extern void end_func(cmd_t *); 2060Sstevel@tonic-gate extern void exit_func(cmd_t *); 2070Sstevel@tonic-gate extern void export_func(cmd_t *); 2080Sstevel@tonic-gate extern void help_func(cmd_t *); 2090Sstevel@tonic-gate extern void info_func(cmd_t *); 2100Sstevel@tonic-gate extern void remove_func(cmd_t *); 2110Sstevel@tonic-gate extern void revert_func(cmd_t *); 2120Sstevel@tonic-gate extern void select_func(cmd_t *); 2130Sstevel@tonic-gate extern void set_func(cmd_t *); 2140Sstevel@tonic-gate extern void verify_func(cmd_t *); 2153247Sgjelinek extern void clear_func(cmd_t *); 2160Sstevel@tonic-gate 2170Sstevel@tonic-gate extern cmd_t *alloc_cmd(void); 2180Sstevel@tonic-gate extern complex_property_ptr_t alloc_complex(void); 2190Sstevel@tonic-gate extern list_property_ptr_t alloc_list(void); 2200Sstevel@tonic-gate extern void free_cmd(cmd_t *cmd); 2210Sstevel@tonic-gate extern void free_complex(complex_property_ptr_t complex); 2220Sstevel@tonic-gate extern void free_list(list_property_ptr_t list); 2230Sstevel@tonic-gate extern void free_outer_list(list_property_ptr_t list); 2240Sstevel@tonic-gate 2256215Sgjelinek extern void usage(boolean_t verbose, uint_t flags); 2260Sstevel@tonic-gate 2270Sstevel@tonic-gate extern FILE *yyin; 22811024SJordan.Vaughan@Sun.com extern char *res_types[]; 22911024SJordan.Vaughan@Sun.com extern char *prop_types[]; 2300Sstevel@tonic-gate 231*13140SJordan.Vaughan@Sun.com /* 232*13140SJordan.Vaughan@Sun.com * NOTE: Only Lex and YACC should use the following functions. 233*13140SJordan.Vaughan@Sun.com */ 234*13140SJordan.Vaughan@Sun.com extern void assert_no_unclaimed_tokens(void); 235*13140SJordan.Vaughan@Sun.com extern char *claim_token(char *); 236*13140SJordan.Vaughan@Sun.com 2370Sstevel@tonic-gate #ifdef __cplusplus 2380Sstevel@tonic-gate } 2390Sstevel@tonic-gate #endif 2400Sstevel@tonic-gate 2410Sstevel@tonic-gate #endif /* _ZONECFG_H */ 242