1*8275SEric Cheng /* 2*8275SEric Cheng * CDDL HEADER START 3*8275SEric Cheng * 4*8275SEric Cheng * The contents of this file are subject to the terms of the 5*8275SEric Cheng * Common Development and Distribution License (the "License"). 6*8275SEric Cheng * You may not use this file except in compliance with the License. 7*8275SEric Cheng * 8*8275SEric Cheng * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*8275SEric Cheng * or http://www.opensolaris.org/os/licensing. 10*8275SEric Cheng * See the License for the specific language governing permissions 11*8275SEric Cheng * and limitations under the License. 12*8275SEric Cheng * 13*8275SEric Cheng * When distributing Covered Code, include this CDDL HEADER in each 14*8275SEric Cheng * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*8275SEric Cheng * If applicable, add the following below this CDDL HEADER, with the 16*8275SEric Cheng * fields enclosed by brackets "[]" replaced with your own identifying 17*8275SEric Cheng * information: Portions Copyright [yyyy] [name of copyright owner] 18*8275SEric Cheng * 19*8275SEric Cheng * CDDL HEADER END 20*8275SEric Cheng */ 21*8275SEric Cheng /* 22*8275SEric Cheng * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23*8275SEric Cheng * Use is subject to license terms. 24*8275SEric Cheng */ 25*8275SEric Cheng 26*8275SEric Cheng #ifndef _LIBDLFLOW_IMPL_H 27*8275SEric Cheng #define _LIBDLFLOW_IMPL_H 28*8275SEric Cheng 29*8275SEric Cheng #include <sys/types.h> 30*8275SEric Cheng #include <sys/param.h> 31*8275SEric Cheng #include <sys/mac.h> 32*8275SEric Cheng #include <libdladm.h> 33*8275SEric Cheng 34*8275SEric Cheng #ifdef __cplusplus 35*8275SEric Cheng extern "C" { 36*8275SEric Cheng #endif 37*8275SEric Cheng 38*8275SEric Cheng struct fprop_desc; 39*8275SEric Cheng struct fattr_desc; 40*8275SEric Cheng 41*8275SEric Cheng typedef dladm_status_t fpd_getf_t(const char *, char **, uint_t *); 42*8275SEric Cheng typedef dladm_status_t fpd_setf_t(const char *, val_desc_t *, uint_t); 43*8275SEric Cheng typedef dladm_status_t fpd_checkf_t(struct fprop_desc *, char **, 44*8275SEric Cheng uint_t, val_desc_t **); 45*8275SEric Cheng 46*8275SEric Cheng typedef struct fprop_desc { 47*8275SEric Cheng char *pd_name; 48*8275SEric Cheng val_desc_t pd_defval; 49*8275SEric Cheng val_desc_t *pd_modval; 50*8275SEric Cheng uint_t pd_nmodval; 51*8275SEric Cheng boolean_t pd_temponly; 52*8275SEric Cheng fpd_setf_t *pd_set; 53*8275SEric Cheng fpd_getf_t *pd_getmod; 54*8275SEric Cheng fpd_getf_t *pd_get; 55*8275SEric Cheng fpd_checkf_t *pd_check; 56*8275SEric Cheng } fprop_desc_t; 57*8275SEric Cheng 58*8275SEric Cheng typedef struct prop_table { 59*8275SEric Cheng fprop_desc_t *pt_table; 60*8275SEric Cheng uint_t pt_size; 61*8275SEric Cheng } prop_table_t; 62*8275SEric Cheng 63*8275SEric Cheng typedef enum { 64*8275SEric Cheng DLADM_PROP_VAL_CURRENT = 1, 65*8275SEric Cheng DLADM_PROP_VAL_DEFAULT, 66*8275SEric Cheng DLADM_PROP_VAL_MODIFIABLE, 67*8275SEric Cheng DLADM_PROP_VAL_PERSISTENT 68*8275SEric Cheng } prop_type_t; 69*8275SEric Cheng 70*8275SEric Cheng typedef dladm_status_t fad_checkf_t(char *, flow_desc_t *); 71*8275SEric Cheng 72*8275SEric Cheng extern dladm_status_t do_check_ip_addr(char *, boolean_t, flow_desc_t *); 73*8275SEric Cheng extern dladm_status_t do_check_dsfield(char *, flow_desc_t *); 74*8275SEric Cheng 75*8275SEric Cheng typedef struct fattr_desc { 76*8275SEric Cheng const char *ad_name; 77*8275SEric Cheng fad_checkf_t *ad_check; 78*8275SEric Cheng } fattr_desc_t; 79*8275SEric Cheng 80*8275SEric Cheng extern dladm_status_t i_dladm_get_prop_temp(const char *, prop_type_t, 81*8275SEric Cheng const char *, char **, uint_t *, prop_table_t *); 82*8275SEric Cheng extern dladm_status_t i_dladm_set_prop_temp(const char *, const char *, 83*8275SEric Cheng char **, uint_t, uint_t, char **, prop_table_t *); 84*8275SEric Cheng extern boolean_t i_dladm_is_prop_temponly(const char *prop_name, 85*8275SEric Cheng char **, prop_table_t *); 86*8275SEric Cheng /* 87*8275SEric Cheng * Data structures used for implementing persistent properties 88*8275SEric Cheng */ 89*8275SEric Cheng typedef struct prop_val { 90*8275SEric Cheng const char *lv_name; 91*8275SEric Cheng struct prop_val *lv_nextval; 92*8275SEric Cheng } prop_val_t; 93*8275SEric Cheng 94*8275SEric Cheng typedef struct prop_db_info { 95*8275SEric Cheng const char *li_name; 96*8275SEric Cheng struct prop_db_info *li_nextprop; 97*8275SEric Cheng struct prop_val *li_val; 98*8275SEric Cheng } prop_db_info_t; 99*8275SEric Cheng 100*8275SEric Cheng typedef struct prop_db_state prop_db_state_t; 101*8275SEric Cheng 102*8275SEric Cheng typedef boolean_t (*prop_db_op_t)(prop_db_state_t *, 103*8275SEric Cheng char *, prop_db_info_t *, dladm_status_t *); 104*8275SEric Cheng 105*8275SEric Cheng typedef dladm_status_t (*prop_db_initop_t)(const char *, const char *, 106*8275SEric Cheng char **, uint_t, uint_t, char **); 107*8275SEric Cheng 108*8275SEric Cheng struct prop_db_state { 109*8275SEric Cheng prop_db_op_t ls_op; 110*8275SEric Cheng const char *ls_name; 111*8275SEric Cheng const char *ls_propname; 112*8275SEric Cheng char **ls_propval; 113*8275SEric Cheng uint_t *ls_valcntp; 114*8275SEric Cheng prop_db_initop_t ls_initop; 115*8275SEric Cheng }; 116*8275SEric Cheng 117*8275SEric Cheng extern boolean_t process_prop_set(prop_db_state_t *lsp, char *buf, 118*8275SEric Cheng prop_db_info_t *listp, dladm_status_t *statusp); 119*8275SEric Cheng extern boolean_t process_prop_get(prop_db_state_t *lsp, char *buf, 120*8275SEric Cheng prop_db_info_t *listp, dladm_status_t *statusp); 121*8275SEric Cheng extern boolean_t process_prop_init(prop_db_state_t *lsp, char *buf, 122*8275SEric Cheng prop_db_info_t *listp, dladm_status_t *statusp); 123*8275SEric Cheng extern dladm_status_t process_prop_db(void *arg, FILE *fp, FILE *nfp); 124*8275SEric Cheng 125*8275SEric Cheng extern dladm_status_t i_dladm_init_flowprop_db(void); 126*8275SEric Cheng extern dladm_status_t i_dladm_set_flow_proplist_db(char *, 127*8275SEric Cheng dladm_arg_list_t *); 128*8275SEric Cheng extern dladm_status_t i_dladm_flow_check_restriction(datalink_id_t, 129*8275SEric Cheng flow_desc_t *, mac_resource_props_t *, boolean_t); 130*8275SEric Cheng 131*8275SEric Cheng extern dladm_status_t dladm_flow_attrlist_extract(dladm_arg_list_t *, 132*8275SEric Cheng flow_desc_t *); 133*8275SEric Cheng 134*8275SEric Cheng #ifdef __cplusplus 135*8275SEric Cheng } 136*8275SEric Cheng #endif 137*8275SEric Cheng 138*8275SEric Cheng #endif /* _LIBDLFLOW_IMPL_H */ 139