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