xref: /titanic_51/usr/src/cmd/cfgadm/cfgadm.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1998-1999 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_CFGADM_H
28*7c478bd9Sstevel@tonic-gate #define	_CFGADM_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
33*7c478bd9Sstevel@tonic-gate extern "C" {
34*7c478bd9Sstevel@tonic-gate #endif
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate /*
37*7c478bd9Sstevel@tonic-gate  * Command line options
38*7c478bd9Sstevel@tonic-gate  */
39*7c478bd9Sstevel@tonic-gate #define	OPTIONS		"ac:fhlno:s:tx:vy"
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate /*
42*7c478bd9Sstevel@tonic-gate  * Configuration operations
43*7c478bd9Sstevel@tonic-gate  */
44*7c478bd9Sstevel@tonic-gate typedef enum {
45*7c478bd9Sstevel@tonic-gate 	CFGA_OP_NONE = 0,
46*7c478bd9Sstevel@tonic-gate 	CFGA_OP_CHANGE_STATE,
47*7c478bd9Sstevel@tonic-gate 	CFGA_OP_TEST,
48*7c478bd9Sstevel@tonic-gate 	CFGA_OP_LIST,
49*7c478bd9Sstevel@tonic-gate 	CFGA_OP_PRIVATE,
50*7c478bd9Sstevel@tonic-gate 	CFGA_OP_HELP
51*7c478bd9Sstevel@tonic-gate } cfga_op_t;
52*7c478bd9Sstevel@tonic-gate 
53*7c478bd9Sstevel@tonic-gate /*
54*7c478bd9Sstevel@tonic-gate  * Names for -c functions
55*7c478bd9Sstevel@tonic-gate  */
56*7c478bd9Sstevel@tonic-gate static char *state_opts[] = {
57*7c478bd9Sstevel@tonic-gate 	"",
58*7c478bd9Sstevel@tonic-gate 	"insert",
59*7c478bd9Sstevel@tonic-gate 	"remove",
60*7c478bd9Sstevel@tonic-gate 	"connect",
61*7c478bd9Sstevel@tonic-gate 	"disconnect",
62*7c478bd9Sstevel@tonic-gate 	"configure",
63*7c478bd9Sstevel@tonic-gate 	"unconfigure",
64*7c478bd9Sstevel@tonic-gate 	NULL
65*7c478bd9Sstevel@tonic-gate };
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate /*
68*7c478bd9Sstevel@tonic-gate  * Attachment point specifier types.
69*7c478bd9Sstevel@tonic-gate  */
70*7c478bd9Sstevel@tonic-gate typedef enum {
71*7c478bd9Sstevel@tonic-gate 	UNKNOWN_AP,
72*7c478bd9Sstevel@tonic-gate 	LOGICAL_AP_ID,
73*7c478bd9Sstevel@tonic-gate 	PHYSICAL_AP_ID,
74*7c478bd9Sstevel@tonic-gate 	AP_TYPE
75*7c478bd9Sstevel@tonic-gate } cfga_ap_types_t;
76*7c478bd9Sstevel@tonic-gate 
77*7c478bd9Sstevel@tonic-gate /*
78*7c478bd9Sstevel@tonic-gate  * Confirm values.
79*7c478bd9Sstevel@tonic-gate  */
80*7c478bd9Sstevel@tonic-gate enum confirm { CONFIRM_DEFAULT, CONFIRM_NO, CONFIRM_YES };
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate /* Limit size of sysinfo return */
83*7c478bd9Sstevel@tonic-gate #define	SYSINFO_LENGTH	256
84*7c478bd9Sstevel@tonic-gate #define	YESNO_STR_MAX	127
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate /* exit codes */
87*7c478bd9Sstevel@tonic-gate #define	EXIT_OK		0
88*7c478bd9Sstevel@tonic-gate #define	EXIT_OPFAILED	1
89*7c478bd9Sstevel@tonic-gate #define	EXIT_NOTSUPP	2
90*7c478bd9Sstevel@tonic-gate #define	EXIT_ARGERROR	3
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate /* Macro to figure size of cfga_list_data items */
93*7c478bd9Sstevel@tonic-gate #define	SZ_EL(EL)	(sizeof ((struct cfga_list_data *)NULL)->EL)
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate /* Maximum number of fields in cfgadm output */
96*7c478bd9Sstevel@tonic-gate #define	N_FIELDS	(sizeof (all_fields)/sizeof (all_fields[0]))
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate /* printing format controls */
99*7c478bd9Sstevel@tonic-gate #define	DEF_SORT_FIELDS		"ap_id"
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate #define	DEF_COLS		"ap_id:type:r_state:o_state:condition"
102*7c478bd9Sstevel@tonic-gate #define	DEF_COLS2		NULL
103*7c478bd9Sstevel@tonic-gate #define	DEF_COLS_VERBOSE	"ap_id:r_state:o_state:condition:info"
104*7c478bd9Sstevel@tonic-gate #define	DEF_COLS2_VERBOSE	"status_time:type:busy:physid"
105*7c478bd9Sstevel@tonic-gate #define	DEF_DELIM		" "
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate /* listing field delimiter */
108*7c478bd9Sstevel@tonic-gate #define	FDELIM		':'
109*7c478bd9Sstevel@tonic-gate #define	ARG_DELIM	' '
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate /* listing lengths for various fields */
112*7c478bd9Sstevel@tonic-gate #define	STATE_WIDTH	12	/* longest - "disconnected" */
113*7c478bd9Sstevel@tonic-gate #define	COND_WIDTH	10	/* longest is the heading - "condition" */
114*7c478bd9Sstevel@tonic-gate #define	TIME_WIDTH	12
115*7c478bd9Sstevel@tonic-gate #define	TIME_P_WIDTH	14	/* YYYYMMDDhhmmss */
116*7c478bd9Sstevel@tonic-gate /*	Date and time	formats	*/
117*7c478bd9Sstevel@tonic-gate /*
118*7c478bd9Sstevel@tonic-gate  * b --- abbreviated month name
119*7c478bd9Sstevel@tonic-gate  * e --- day number
120*7c478bd9Sstevel@tonic-gate  * Y --- year in the form ccyy
121*7c478bd9Sstevel@tonic-gate  * H --- hour(24-hour version)
122*7c478bd9Sstevel@tonic-gate  * M --- minute
123*7c478bd9Sstevel@tonic-gate  */
124*7c478bd9Sstevel@tonic-gate #define	FORMAT1	 "%b %e  %Y"
125*7c478bd9Sstevel@tonic-gate #define	FORMAT2  "%b %e %H:%M"
126*7c478bd9Sstevel@tonic-gate 
127*7c478bd9Sstevel@tonic-gate /* listing control data */
128*7c478bd9Sstevel@tonic-gate struct sort_el {
129*7c478bd9Sstevel@tonic-gate 	int reverse;
130*7c478bd9Sstevel@tonic-gate 	struct field_info *fld;
131*7c478bd9Sstevel@tonic-gate };
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate struct print_col {
134*7c478bd9Sstevel@tonic-gate 	int width;
135*7c478bd9Sstevel@tonic-gate 	struct field_info *line1;
136*7c478bd9Sstevel@tonic-gate 	struct field_info *line2;
137*7c478bd9Sstevel@tonic-gate };
138*7c478bd9Sstevel@tonic-gate 
139*7c478bd9Sstevel@tonic-gate /*
140*7c478bd9Sstevel@tonic-gate  * The first three types are used for filtering and the last for sorting.
141*7c478bd9Sstevel@tonic-gate  */
142*7c478bd9Sstevel@tonic-gate typedef enum {
143*7c478bd9Sstevel@tonic-gate 	CFGA_MATCH_PARTIAL,	/* pass if a partial match */
144*7c478bd9Sstevel@tonic-gate 	CFGA_MATCH_EXACT,	/* pass only if an exact match */
145*7c478bd9Sstevel@tonic-gate 	CFGA_MATCH_NOFILTER,	/* pass all. Not valid user input */
146*7c478bd9Sstevel@tonic-gate 	CFGA_MATCH_ORDER	/* compare and return relative order */
147*7c478bd9Sstevel@tonic-gate } match_type_t;
148*7c478bd9Sstevel@tonic-gate 
149*7c478bd9Sstevel@tonic-gate struct field_info {
150*7c478bd9Sstevel@tonic-gate 	char *name;
151*7c478bd9Sstevel@tonic-gate 	char *heading;
152*7c478bd9Sstevel@tonic-gate 	int width;
153*7c478bd9Sstevel@tonic-gate 	int (*compare)(struct cfga_list_data *, struct cfga_list_data *,
154*7c478bd9Sstevel@tonic-gate 	    match_type_t);
155*7c478bd9Sstevel@tonic-gate 	void (*printfn)(struct cfga_list_data *, int, char *);
156*7c478bd9Sstevel@tonic-gate 	cfga_err_t (*set_filter)(struct cfga_list_data *, const char *);
157*7c478bd9Sstevel@tonic-gate };
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate /* list option strings */
160*7c478bd9Sstevel@tonic-gate static char *list_options[] = {
161*7c478bd9Sstevel@tonic-gate #define	LIST_SORT	0
162*7c478bd9Sstevel@tonic-gate 	"sort",
163*7c478bd9Sstevel@tonic-gate #define	LIST_COLS	1
164*7c478bd9Sstevel@tonic-gate 	"cols",
165*7c478bd9Sstevel@tonic-gate #define	LIST_COLS2	2
166*7c478bd9Sstevel@tonic-gate 	"cols2",
167*7c478bd9Sstevel@tonic-gate #define	LIST_DELIM	3
168*7c478bd9Sstevel@tonic-gate 	"delim",
169*7c478bd9Sstevel@tonic-gate #define	LIST_NOHEADINGS	4
170*7c478bd9Sstevel@tonic-gate 	"noheadings",
171*7c478bd9Sstevel@tonic-gate #define	LIST_SELECT	5
172*7c478bd9Sstevel@tonic-gate 	"select",
173*7c478bd9Sstevel@tonic-gate #define	LIST_MATCH	6
174*7c478bd9Sstevel@tonic-gate 	"match",
175*7c478bd9Sstevel@tonic-gate 	NULL
176*7c478bd9Sstevel@tonic-gate };
177*7c478bd9Sstevel@tonic-gate 
178*7c478bd9Sstevel@tonic-gate /* Selection related */
179*7c478bd9Sstevel@tonic-gate typedef struct {
180*7c478bd9Sstevel@tonic-gate 	char *arg;
181*7c478bd9Sstevel@tonic-gate 	int resp; /* If set, this cmd arg received a response */
182*7c478bd9Sstevel@tonic-gate } ap_arg_t;
183*7c478bd9Sstevel@tonic-gate 
184*7c478bd9Sstevel@tonic-gate typedef struct {
185*7c478bd9Sstevel@tonic-gate 	cfga_list_data_t *ldatap;
186*7c478bd9Sstevel@tonic-gate 	int req; /* If set, this list_data was requested by user */
187*7c478bd9Sstevel@tonic-gate } ap_out_t;
188*7c478bd9Sstevel@tonic-gate 
189*7c478bd9Sstevel@tonic-gate /* Filtering related */
190*7c478bd9Sstevel@tonic-gate #define	CFGA_DEFAULT_MATCH	CFGA_MATCH_EXACT
191*7c478bd9Sstevel@tonic-gate #define	LEFT_PAREN	'('
192*7c478bd9Sstevel@tonic-gate #define	RIGHT_PAREN	')'
193*7c478bd9Sstevel@tonic-gate #define	CFGA_DEV_DIR	"/dev/cfg"
194*7c478bd9Sstevel@tonic-gate #define	SLASH		"/"
195*7c478bd9Sstevel@tonic-gate #define	EQUALS		"="
196*7c478bd9Sstevel@tonic-gate 
197*7c478bd9Sstevel@tonic-gate typedef enum {
198*7c478bd9Sstevel@tonic-gate 	CFGA_PSTATE_INIT,
199*7c478bd9Sstevel@tonic-gate 	CFGA_PSTATE_ATTR_DONE,
200*7c478bd9Sstevel@tonic-gate 	CFGA_PSTATE_VAL_DONE,
201*7c478bd9Sstevel@tonic-gate 	CFGA_PSTATE_ERR
202*7c478bd9Sstevel@tonic-gate } parse_state_t;
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate typedef struct match_cvt {
205*7c478bd9Sstevel@tonic-gate 	char *str;
206*7c478bd9Sstevel@tonic-gate 	match_type_t type;
207*7c478bd9Sstevel@tonic-gate } match_cvt_t;
208*7c478bd9Sstevel@tonic-gate 
209*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
210*7c478bd9Sstevel@tonic-gate }
211*7c478bd9Sstevel@tonic-gate #endif
212*7c478bd9Sstevel@tonic-gate 
213*7c478bd9Sstevel@tonic-gate #endif	/* _CFGADM_H */
214