1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _IPQOS_CONF_H 28*0Sstevel@tonic-gate #define _IPQOS_CONF_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #include <sys/stat.h> 33*0Sstevel@tonic-gate #include <sys/types.h> 34*0Sstevel@tonic-gate #include <sys/nvpair.h> 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #ifdef __cplusplus 37*0Sstevel@tonic-gate extern "C" { 38*0Sstevel@tonic-gate #endif 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate /* debug level bits */ 41*0Sstevel@tonic-gate #define L0 0x01 42*0Sstevel@tonic-gate #define L1 0x02 43*0Sstevel@tonic-gate #define L2 0x04 44*0Sstevel@tonic-gate #define DIFF 0x08 45*0Sstevel@tonic-gate #define KRET 0x10 46*0Sstevel@tonic-gate #define APPLY 0x20 47*0Sstevel@tonic-gate #define MHME 0x40 48*0Sstevel@tonic-gate #define RBK 0x80 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gate /* directory for types files */ 51*0Sstevel@tonic-gate #define TYPES_FILE_DIR "/usr/lib/ipqosconf/" 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate /* location of lock file */ 54*0Sstevel@tonic-gate #define IPQOS_CONF_LOCK_FILE "/var/run/ipqosconf.lock" 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate /* location of startup config file */ 57*0Sstevel@tonic-gate #define IPQOS_CONF_INIT_PATH "/etc/inet/ipqosinit.conf" 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate /* ipqosconf commands */ 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gate #define IPQOS_CONF_APPLY 1 62*0Sstevel@tonic-gate #define IPQOS_CONF_VIEW 2 63*0Sstevel@tonic-gate #define IPQOS_CONF_COMMIT 3 64*0Sstevel@tonic-gate #define IPQOS_CONF_FLUSH 4 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate /* print ntabs to stream fp */ 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate #define PRINT_TABS(fp, ntabs)\ 69*0Sstevel@tonic-gate {\ 70*0Sstevel@tonic-gate int x;\ 71*0Sstevel@tonic-gate for (x = 0; x < ntabs; x++)\ 72*0Sstevel@tonic-gate (void) fprintf(fp, "\t");\ 73*0Sstevel@tonic-gate } 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate /* having to define this as ip6.h version in _KERNEL guard */ 76*0Sstevel@tonic-gate #ifndef V4_PART_OF_V6 77*0Sstevel@tonic-gate #define V4_PART_OF_V6(v6) v6._S6_un._S6_u32[3] 78*0Sstevel@tonic-gate #endif 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate /* 81*0Sstevel@tonic-gate * given pointer cp advance it to the first non-space character. 82*0Sstevel@tonic-gate */ 83*0Sstevel@tonic-gate #define SKIPWS(cp) while (isspace(*cp) && (*cp != '\0')) cp++ 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate /* extract the v4 and v6 bits of the ip_version enumeration from the filter */ 86*0Sstevel@tonic-gate #define VERSION_IS_V4(flt) ((flt)->ip_versions & 0x01) 87*0Sstevel@tonic-gate #define VERSION_IS_V6(flt) ((flt)->ip_versions & 0x02) 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate /* retrieve short name from a module.name nvpair name */ 90*0Sstevel@tonic-gate #define SHORT_NAME(longnme) (strchr(longnme, '.') + 1) 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate /* latest version of cfg file supported (1.0) */ 93*0Sstevel@tonic-gate #define IPQOS_CUR_FMT_MAJOR_VER 1 94*0Sstevel@tonic-gate #define IPQOS_CUR_FMT_MINOR_VER 0 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate /* length of string buffer used for storing an integer as a string */ 97*0Sstevel@tonic-gate #define IPQOS_INT_STR_LEN 15 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gate /* length of line buffer used to read types file */ 100*0Sstevel@tonic-gate #define IPQOS_CONF_TYPE_LINE_LEN 1024 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate /* length of buffer used to store name of type when reading types file */ 103*0Sstevel@tonic-gate #define IPQOS_CONF_TYPE_LEN 24 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate /* max length of value string in types file */ 106*0Sstevel@tonic-gate #define IPQOS_VALST_MAXLEN 100 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gate /* initial size of line buffer used by readtoken */ 109*0Sstevel@tonic-gate #define IPQOS_CONF_LINEBUF_SZ 150 110*0Sstevel@tonic-gate 111*0Sstevel@tonic-gate /* length of class/filter/action names */ 112*0Sstevel@tonic-gate #define IPQOS_CONF_NAME_LEN 24 113*0Sstevel@tonic-gate 114*0Sstevel@tonic-gate /* length of module names */ 115*0Sstevel@tonic-gate #define IPQOS_CONF_MOD_NAME_LEN 10 116*0Sstevel@tonic-gate 117*0Sstevel@tonic-gate /* IPQOS_CONF_NAME_LEN + IPQOS_CONF_MOD_NAME_LEN */ 118*0Sstevel@tonic-gate /* must be a numeric literal for use in scanf() format string */ 119*0Sstevel@tonic-gate #define IPQOS_CONF_PNAME_LEN 34 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gate /* length of buffer used to construct msgs for printing */ 122*0Sstevel@tonic-gate #define IPQOS_MSG_BUF_SZ 200 123*0Sstevel@tonic-gate /* 124*0Sstevel@tonic-gate * Define CURL here so that while you are reading 125*0Sstevel@tonic-gate * the code, it does not affect "vi" in pattern 126*0Sstevel@tonic-gate * matching. 127*0Sstevel@tonic-gate */ 128*0Sstevel@tonic-gate #define CURL_BEGIN '{' 129*0Sstevel@tonic-gate #define CURL_END '}' 130*0Sstevel@tonic-gate 131*0Sstevel@tonic-gate /* internal return codes */ 132*0Sstevel@tonic-gate #define IPQOS_CONF_SUCCESS 0 133*0Sstevel@tonic-gate #define IPQOS_CONF_ERR 1 134*0Sstevel@tonic-gate #define IPQOS_CONF_RECOVER_ERR 2 135*0Sstevel@tonic-gate #define IPQOS_CONF_CURL_END 3 136*0Sstevel@tonic-gate #define IPQOS_CONF_CURL_BEGIN 4 137*0Sstevel@tonic-gate #define IPQOS_CONF_EOF 5 138*0Sstevel@tonic-gate #define IPQOS_CONF_NO_VER_STR 6 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gate /* special tokens in config file */ 141*0Sstevel@tonic-gate #define IPQOS_CONF_IP_VERSION_STR "ip_version" 142*0Sstevel@tonic-gate #define IPQOS_CONF_NEXT_ACTION_STR "next_action" 143*0Sstevel@tonic-gate #define IPQOS_CONF_NAME_STR "name" 144*0Sstevel@tonic-gate #define IPQOS_CONF_MODULE_STR "module" 145*0Sstevel@tonic-gate #define IPQOS_CONF_FILTER_STR "filter" 146*0Sstevel@tonic-gate #define IPQOS_CONF_ACTION_STR "action" 147*0Sstevel@tonic-gate #define IPQOS_CONF_CLASS_STR "class" 148*0Sstevel@tonic-gate #define IPQOS_CONF_PARAMS_STR "params" 149*0Sstevel@tonic-gate #define IPQOS_CONF_NEXT_STR "next" 150*0Sstevel@tonic-gate #define IPQOS_CONF_STATS_ENABLE_STR "enable_stats" 151*0Sstevel@tonic-gate #define IPQOS_CONF_GLOBAL_STATS_STR "global_stats" 152*0Sstevel@tonic-gate #define IPQOS_CONF_DROP_STR "drop" 153*0Sstevel@tonic-gate #define IPQOS_CONF_CONT_STR "continue" 154*0Sstevel@tonic-gate #define IPQOS_CONF_DEFER_STR "defer" 155*0Sstevel@tonic-gate #define IPQOS_CONF_TRUE_STR "true" 156*0Sstevel@tonic-gate #define IPQOS_CONF_FALSE_STR "false" 157*0Sstevel@tonic-gate #define IPQOS_FMT_VERSION_STR "fmt_version" 158*0Sstevel@tonic-gate #define IPQOS_IFNAME_STR "if_name" 159*0Sstevel@tonic-gate #define IPQOS_PLACE_PRM_STR IPQOS_CONF_PARAMS_STR 160*0Sstevel@tonic-gate #define IPQOS_PLACE_FILTER_STR IPQOS_CONF_FILTER_STR 161*0Sstevel@tonic-gate #define IPQOS_PLACE_MAP_STR "map" 162*0Sstevel@tonic-gate 163*0Sstevel@tonic-gate /* special tokens in types file */ 164*0Sstevel@tonic-gate #define IPQOS_CONF_PERM_FILTER_MK "#PERM_FILTER" 165*0Sstevel@tonic-gate #define IPQOS_CONF_PERM_CLASS_MK "#PERM_CLASS" 166*0Sstevel@tonic-gate #define IPQOS_FMT_STR "fmt_version" 167*0Sstevel@tonic-gate #define IPQOS_MOD_STR "mod_version" 168*0Sstevel@tonic-gate 169*0Sstevel@tonic-gate 170*0Sstevel@tonic-gate /* nvlist parameters */ 171*0Sstevel@tonic-gate #define IPQOS_CONF_IP_VERSION "ipgpc.ip_version" 172*0Sstevel@tonic-gate 173*0Sstevel@tonic-gate /* name lookup errors returned from domultihome() */ 174*0Sstevel@tonic-gate #define IPQOS_LOOKUP_RETRY 1 175*0Sstevel@tonic-gate #define IPQOS_LOOKUP_FAIL 2 176*0Sstevel@tonic-gate 177*0Sstevel@tonic-gate /* 178*0Sstevel@tonic-gate * used in calls to ipp_action_info() to encapuslate both an action and 179*0Sstevel@tonic-gate * an ipqosconf internal return code. 180*0Sstevel@tonic-gate */ 181*0Sstevel@tonic-gate typedef struct ipqos_actinfo_prm_s { 182*0Sstevel@tonic-gate struct ipqos_conf_action_s *action; 183*0Sstevel@tonic-gate int intl_ret; 184*0Sstevel@tonic-gate } ipqos_actinfo_prm_t; 185*0Sstevel@tonic-gate 186*0Sstevel@tonic-gate /* 187*0Sstevel@tonic-gate * skeletal list element struct used in manipulating lists of more complex 188*0Sstevel@tonic-gate * structures. 189*0Sstevel@tonic-gate */ 190*0Sstevel@tonic-gate typedef struct ipqos_list_el_s { 191*0Sstevel@tonic-gate struct ipqos_list_el_s *next; 192*0Sstevel@tonic-gate } ipqos_list_el_t; 193*0Sstevel@tonic-gate 194*0Sstevel@tonic-gate typedef struct str_str { 195*0Sstevel@tonic-gate char *s1; 196*0Sstevel@tonic-gate char *s2; 197*0Sstevel@tonic-gate } str_str_t; 198*0Sstevel@tonic-gate 199*0Sstevel@tonic-gate typedef struct str_val { 200*0Sstevel@tonic-gate char *string; 201*0Sstevel@tonic-gate int value; 202*0Sstevel@tonic-gate } str_val_t; 203*0Sstevel@tonic-gate 204*0Sstevel@tonic-gate typedef struct str_val_nd { 205*0Sstevel@tonic-gate struct str_val sv; 206*0Sstevel@tonic-gate struct str_val_nd *next; 207*0Sstevel@tonic-gate } str_val_nd_t; 208*0Sstevel@tonic-gate 209*0Sstevel@tonic-gate /* type of msg to be printed by ipqos_msg */ 210*0Sstevel@tonic-gate enum msg_type { MT_ERROR, MT_WARNING, MT_LOG, MT_ENOSTR }; 211*0Sstevel@tonic-gate 212*0Sstevel@tonic-gate /* enum for allowable parameter types */ 213*0Sstevel@tonic-gate 214*0Sstevel@tonic-gate typedef enum ipqos_nvtype_e { 215*0Sstevel@tonic-gate IPQOS_DATA_TYPE_UINT8, 216*0Sstevel@tonic-gate IPQOS_DATA_TYPE_INT16, 217*0Sstevel@tonic-gate IPQOS_DATA_TYPE_UINT16, 218*0Sstevel@tonic-gate IPQOS_DATA_TYPE_INT32, 219*0Sstevel@tonic-gate IPQOS_DATA_TYPE_UINT32, 220*0Sstevel@tonic-gate IPQOS_DATA_TYPE_BOOLEAN, 221*0Sstevel@tonic-gate IPQOS_DATA_TYPE_STRING, 222*0Sstevel@tonic-gate IPQOS_DATA_TYPE_ACTION, 223*0Sstevel@tonic-gate IPQOS_DATA_TYPE_ADDRESS, 224*0Sstevel@tonic-gate IPQOS_DATA_TYPE_PORT, 225*0Sstevel@tonic-gate IPQOS_DATA_TYPE_PROTO, 226*0Sstevel@tonic-gate IPQOS_DATA_TYPE_ENUM, 227*0Sstevel@tonic-gate IPQOS_DATA_TYPE_IFNAME, 228*0Sstevel@tonic-gate IPQOS_DATA_TYPE_M_INDEX, 229*0Sstevel@tonic-gate IPQOS_DATA_TYPE_INT_ARRAY, 230*0Sstevel@tonic-gate IPQOS_DATA_TYPE_USER, 231*0Sstevel@tonic-gate IPQOS_DATA_TYPE_ADDRESS_MASK, 232*0Sstevel@tonic-gate IPQOS_DATA_TYPE_IFINDEX 233*0Sstevel@tonic-gate } ipqos_nvtype_t; 234*0Sstevel@tonic-gate 235*0Sstevel@tonic-gate /* 236*0Sstevel@tonic-gate * passed to readnvpair to indicate which special meanings for nv names 237*0Sstevel@tonic-gate * to use. 238*0Sstevel@tonic-gate */ 239*0Sstevel@tonic-gate typedef enum place_e { 240*0Sstevel@tonic-gate PL_ACTION, PL_FILTER, PL_CLASS, PL_PARAMS, PL_MAP, PL_ANY} place_t; 241*0Sstevel@tonic-gate 242*0Sstevel@tonic-gate 243*0Sstevel@tonic-gate /* classifier filter representation */ 244*0Sstevel@tonic-gate 245*0Sstevel@tonic-gate typedef struct ipqos_conf_filter_s { 246*0Sstevel@tonic-gate struct ipqos_conf_filter_s *next; 247*0Sstevel@tonic-gate char name[IPQOS_CONF_NAME_LEN]; 248*0Sstevel@tonic-gate char class_name[IPQOS_CONF_NAME_LEN]; 249*0Sstevel@tonic-gate nvlist_t *nvlist; 250*0Sstevel@tonic-gate boolean_t new; 251*0Sstevel@tonic-gate boolean_t modified; 252*0Sstevel@tonic-gate boolean_t cr_mod; 253*0Sstevel@tonic-gate boolean_t todel; 254*0Sstevel@tonic-gate boolean_t deleted; 255*0Sstevel@tonic-gate uint32_t originator; 256*0Sstevel@tonic-gate char *src_nd_name; 257*0Sstevel@tonic-gate char *dst_nd_name; 258*0Sstevel@tonic-gate int instance; 259*0Sstevel@tonic-gate uint32_t lineno; 260*0Sstevel@tonic-gate uint32_t ip_versions; 261*0Sstevel@tonic-gate int nlerr; 262*0Sstevel@tonic-gate } ipqos_conf_filter_t; 263*0Sstevel@tonic-gate 264*0Sstevel@tonic-gate 265*0Sstevel@tonic-gate /* 266*0Sstevel@tonic-gate * action reference - used to store information and reference an action struct. 267*0Sstevel@tonic-gate */ 268*0Sstevel@tonic-gate 269*0Sstevel@tonic-gate typedef struct ipqos_conf_act_ref_s { 270*0Sstevel@tonic-gate struct ipqos_conf_act_ref_s *next; 271*0Sstevel@tonic-gate struct ipqos_conf_act_ref_s *prev; 272*0Sstevel@tonic-gate char name[IPQOS_CONF_NAME_LEN]; 273*0Sstevel@tonic-gate char field[IPQOS_CONF_PNAME_LEN]; 274*0Sstevel@tonic-gate struct ipqos_conf_action_s *action; 275*0Sstevel@tonic-gate nvlist_t *nvlist; 276*0Sstevel@tonic-gate } ipqos_conf_act_ref_t; 277*0Sstevel@tonic-gate 278*0Sstevel@tonic-gate 279*0Sstevel@tonic-gate /* classifier class representation */ 280*0Sstevel@tonic-gate 281*0Sstevel@tonic-gate typedef struct ipqos_conf_class_s { 282*0Sstevel@tonic-gate struct ipqos_conf_class_s *next; 283*0Sstevel@tonic-gate char name[IPQOS_CONF_NAME_LEN]; 284*0Sstevel@tonic-gate nvlist_t *nvlist; 285*0Sstevel@tonic-gate ipqos_conf_act_ref_t *alist; 286*0Sstevel@tonic-gate boolean_t modified; 287*0Sstevel@tonic-gate boolean_t new; 288*0Sstevel@tonic-gate boolean_t cr_mod; 289*0Sstevel@tonic-gate boolean_t todel; 290*0Sstevel@tonic-gate boolean_t deleted; 291*0Sstevel@tonic-gate boolean_t stats_enable; 292*0Sstevel@tonic-gate uint32_t originator; 293*0Sstevel@tonic-gate uint32_t lineno; 294*0Sstevel@tonic-gate } ipqos_conf_class_t; 295*0Sstevel@tonic-gate 296*0Sstevel@tonic-gate /* action parameters representation */ 297*0Sstevel@tonic-gate 298*0Sstevel@tonic-gate typedef struct ipqos_conf_params_s { 299*0Sstevel@tonic-gate struct ipqos_conf_params_s *next; 300*0Sstevel@tonic-gate ipqos_conf_act_ref_t *actions; 301*0Sstevel@tonic-gate nvlist_t *nvlist; 302*0Sstevel@tonic-gate boolean_t modified; 303*0Sstevel@tonic-gate boolean_t stats_enable; 304*0Sstevel@tonic-gate uint32_t originator; 305*0Sstevel@tonic-gate uint32_t lineno; 306*0Sstevel@tonic-gate boolean_t cr_mod; 307*0Sstevel@tonic-gate } ipqos_conf_params_t; 308*0Sstevel@tonic-gate 309*0Sstevel@tonic-gate 310*0Sstevel@tonic-gate /* signifys which stage of configuration application has just past */ 311*0Sstevel@tonic-gate enum visit {ADD_VISITED = 1, MOD_VISITED, REM_VISITED, INCYCLE_VISITED}; 312*0Sstevel@tonic-gate 313*0Sstevel@tonic-gate /* 314*0Sstevel@tonic-gate * action representation, with parameters, and lists of filters and classes 315*0Sstevel@tonic-gate * if classifier action. 316*0Sstevel@tonic-gate */ 317*0Sstevel@tonic-gate typedef struct ipqos_conf_action_s { 318*0Sstevel@tonic-gate struct ipqos_conf_action_s *next; 319*0Sstevel@tonic-gate char name[IPQOS_CONF_NAME_LEN]; 320*0Sstevel@tonic-gate char module[IPQOS_CONF_NAME_LEN]; 321*0Sstevel@tonic-gate ipqos_conf_filter_t *filters; 322*0Sstevel@tonic-gate ipqos_conf_class_t *classes; 323*0Sstevel@tonic-gate ipqos_conf_params_t *params; 324*0Sstevel@tonic-gate nvlist_t *nvlist; 325*0Sstevel@tonic-gate boolean_t todel; 326*0Sstevel@tonic-gate boolean_t deleted; 327*0Sstevel@tonic-gate boolean_t new; 328*0Sstevel@tonic-gate boolean_t modified; 329*0Sstevel@tonic-gate boolean_t cr_mod; 330*0Sstevel@tonic-gate ipqos_conf_act_ref_t *dependencies; 331*0Sstevel@tonic-gate enum visit visited; 332*0Sstevel@tonic-gate uint32_t lineno; 333*0Sstevel@tonic-gate ipqos_conf_filter_t *retry_filters; 334*0Sstevel@tonic-gate char **perm_classes; 335*0Sstevel@tonic-gate int num_perm_classes; 336*0Sstevel@tonic-gate int module_version; 337*0Sstevel@tonic-gate } ipqos_conf_action_t; 338*0Sstevel@tonic-gate 339*0Sstevel@tonic-gate 340*0Sstevel@tonic-gate #ifdef __cplusplus 341*0Sstevel@tonic-gate } 342*0Sstevel@tonic-gate #endif 343*0Sstevel@tonic-gate 344*0Sstevel@tonic-gate #endif /* _IPQOS_CONF_H */ 345