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