18275SEric Cheng /*
28275SEric Cheng  * CDDL HEADER START
38275SEric Cheng  *
48275SEric Cheng  * The contents of this file are subject to the terms of the
58275SEric Cheng  * Common Development and Distribution License (the "License").
68275SEric Cheng  * You may not use this file except in compliance with the License.
78275SEric Cheng  *
88275SEric Cheng  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
98275SEric Cheng  * or http://www.opensolaris.org/os/licensing.
108275SEric Cheng  * See the License for the specific language governing permissions
118275SEric Cheng  * and limitations under the License.
128275SEric Cheng  *
138275SEric Cheng  * When distributing Covered Code, include this CDDL HEADER in each
148275SEric Cheng  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
158275SEric Cheng  * If applicable, add the following below this CDDL HEADER, with the
168275SEric Cheng  * fields enclosed by brackets "[]" replaced with your own identifying
178275SEric Cheng  * information: Portions Copyright [yyyy] [name of copyright owner]
188275SEric Cheng  *
198275SEric Cheng  * CDDL HEADER END
208275SEric Cheng  */
218275SEric Cheng /*
228275SEric Cheng  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
238275SEric Cheng  * Use is subject to license terms.
248275SEric Cheng  */
258275SEric Cheng 
268275SEric Cheng #ifndef _LIBDLFLOW_IMPL_H
278275SEric Cheng #define	_LIBDLFLOW_IMPL_H
288275SEric Cheng 
298275SEric Cheng #include <sys/types.h>
308275SEric Cheng #include <sys/param.h>
318275SEric Cheng #include <sys/mac.h>
328275SEric Cheng #include <libdladm.h>
338275SEric Cheng 
348275SEric Cheng #ifdef	__cplusplus
358275SEric Cheng extern "C" {
368275SEric Cheng #endif
378275SEric Cheng 
388275SEric Cheng struct fprop_desc;
398275SEric Cheng struct fattr_desc;
408275SEric Cheng 
41*8453SAnurag.Maskey@Sun.COM typedef	dladm_status_t	fpd_getf_t(dladm_handle_t, const char *, char **,
42*8453SAnurag.Maskey@Sun.COM 			    uint_t *);
43*8453SAnurag.Maskey@Sun.COM typedef	dladm_status_t	fpd_setf_t(dladm_handle_t, const char *, val_desc_t *,
44*8453SAnurag.Maskey@Sun.COM 			    uint_t);
45*8453SAnurag.Maskey@Sun.COM typedef	dladm_status_t	fpd_checkf_t(struct fprop_desc *, char **, uint_t,
46*8453SAnurag.Maskey@Sun.COM 			    val_desc_t **);
478275SEric Cheng 
488275SEric Cheng typedef struct fprop_desc {
498275SEric Cheng 	char		*pd_name;
508275SEric Cheng 	val_desc_t	pd_defval;
518275SEric Cheng 	val_desc_t	*pd_modval;
528275SEric Cheng 	uint_t		pd_nmodval;
538275SEric Cheng 	boolean_t	pd_temponly;
548275SEric Cheng 	fpd_setf_t	*pd_set;
558275SEric Cheng 	fpd_getf_t	*pd_getmod;
568275SEric Cheng 	fpd_getf_t	*pd_get;
578275SEric Cheng 	fpd_checkf_t	*pd_check;
588275SEric Cheng } fprop_desc_t;
598275SEric Cheng 
608275SEric Cheng typedef struct prop_table {
618275SEric Cheng 	fprop_desc_t	*pt_table;
628275SEric Cheng 	uint_t		pt_size;
638275SEric Cheng } prop_table_t;
648275SEric Cheng 
658275SEric Cheng typedef enum {
668275SEric Cheng 	DLADM_PROP_VAL_CURRENT = 1,
678275SEric Cheng 	DLADM_PROP_VAL_DEFAULT,
688275SEric Cheng 	DLADM_PROP_VAL_MODIFIABLE,
698275SEric Cheng 	DLADM_PROP_VAL_PERSISTENT
708275SEric Cheng } prop_type_t;
718275SEric Cheng 
728275SEric Cheng typedef	dladm_status_t	fad_checkf_t(char *, flow_desc_t *);
738275SEric Cheng 
748275SEric Cheng extern dladm_status_t	do_check_ip_addr(char *, boolean_t, flow_desc_t *);
758275SEric Cheng extern dladm_status_t	do_check_dsfield(char *, flow_desc_t *);
768275SEric Cheng 
778275SEric Cheng typedef struct fattr_desc {
788275SEric Cheng 	const char	*ad_name;
798275SEric Cheng 	fad_checkf_t	*ad_check;
808275SEric Cheng } fattr_desc_t;
818275SEric Cheng 
82*8453SAnurag.Maskey@Sun.COM extern dladm_status_t	i_dladm_get_prop_temp(dladm_handle_t, const char *,
83*8453SAnurag.Maskey@Sun.COM 			    prop_type_t, const char *, char **, uint_t *,
84*8453SAnurag.Maskey@Sun.COM 			    prop_table_t *);
85*8453SAnurag.Maskey@Sun.COM extern dladm_status_t	i_dladm_set_prop_temp(dladm_handle_t, const char *,
86*8453SAnurag.Maskey@Sun.COM 			    const char *, char **, uint_t, uint_t, char **,
87*8453SAnurag.Maskey@Sun.COM 			    prop_table_t *);
888275SEric Cheng extern boolean_t	i_dladm_is_prop_temponly(const char *prop_name,
898275SEric Cheng 			    char **, prop_table_t *);
908275SEric Cheng /*
918275SEric Cheng  * Data structures used for implementing persistent properties
928275SEric Cheng  */
938275SEric Cheng typedef struct prop_val {
948275SEric Cheng 	const char		*lv_name;
958275SEric Cheng 	struct prop_val		*lv_nextval;
968275SEric Cheng } prop_val_t;
978275SEric Cheng 
988275SEric Cheng typedef struct prop_db_info {
998275SEric Cheng 	const char		*li_name;
1008275SEric Cheng 	struct prop_db_info	*li_nextprop;
1018275SEric Cheng 	struct prop_val		*li_val;
1028275SEric Cheng } prop_db_info_t;
1038275SEric Cheng 
1048275SEric Cheng typedef struct prop_db_state	prop_db_state_t;
1058275SEric Cheng 
106*8453SAnurag.Maskey@Sun.COM typedef boolean_t (*prop_db_op_t)(dladm_handle_t, prop_db_state_t *,
1078275SEric Cheng     char *, prop_db_info_t *, dladm_status_t *);
1088275SEric Cheng 
109*8453SAnurag.Maskey@Sun.COM typedef dladm_status_t (*prop_db_initop_t)(dladm_handle_t, const char *,
110*8453SAnurag.Maskey@Sun.COM     const char *, char **, uint_t, uint_t, char **);
1118275SEric Cheng 
1128275SEric Cheng struct prop_db_state {
1138275SEric Cheng 	prop_db_op_t		ls_op;
1148275SEric Cheng 	const char		*ls_name;
1158275SEric Cheng 	const char		*ls_propname;
1168275SEric Cheng 	char			**ls_propval;
1178275SEric Cheng 	uint_t			*ls_valcntp;
1188275SEric Cheng 	prop_db_initop_t	ls_initop;
1198275SEric Cheng };
1208275SEric Cheng 
121*8453SAnurag.Maskey@Sun.COM extern boolean_t	process_prop_set(dladm_handle_t, prop_db_state_t *lsp,
122*8453SAnurag.Maskey@Sun.COM 			    char *buf, prop_db_info_t *listp,
123*8453SAnurag.Maskey@Sun.COM 			    dladm_status_t *statusp);
124*8453SAnurag.Maskey@Sun.COM extern boolean_t	process_prop_get(dladm_handle_t, prop_db_state_t *lsp,
125*8453SAnurag.Maskey@Sun.COM 			    char *buf, prop_db_info_t *listp,
126*8453SAnurag.Maskey@Sun.COM 			    dladm_status_t *statusp);
127*8453SAnurag.Maskey@Sun.COM extern boolean_t	process_prop_init(dladm_handle_t, prop_db_state_t *lsp,
128*8453SAnurag.Maskey@Sun.COM 			    char *buf, prop_db_info_t *listp,
129*8453SAnurag.Maskey@Sun.COM 			    dladm_status_t *statusp);
130*8453SAnurag.Maskey@Sun.COM extern dladm_status_t	process_prop_db(dladm_handle_t, void *arg, FILE *fp,
131*8453SAnurag.Maskey@Sun.COM 			    FILE *nfp);
1328275SEric Cheng 
133*8453SAnurag.Maskey@Sun.COM extern dladm_status_t	i_dladm_init_flowprop_db(dladm_handle_t);
134*8453SAnurag.Maskey@Sun.COM extern dladm_status_t	i_dladm_set_flow_proplist_db(dladm_handle_t, char *,
135*8453SAnurag.Maskey@Sun.COM 			    dladm_arg_list_t *);
1368275SEric Cheng extern dladm_status_t	i_dladm_flow_check_restriction(datalink_id_t,
137*8453SAnurag.Maskey@Sun.COM 			    flow_desc_t *, mac_resource_props_t *, boolean_t);
1388275SEric Cheng 
1398275SEric Cheng extern dladm_status_t	dladm_flow_attrlist_extract(dladm_arg_list_t *,
140*8453SAnurag.Maskey@Sun.COM 			    flow_desc_t *);
1418275SEric Cheng 
1428275SEric Cheng #ifdef	__cplusplus
1438275SEric Cheng }
1448275SEric Cheng #endif
1458275SEric Cheng 
1468275SEric Cheng #endif	/* _LIBDLFLOW_IMPL_H */
147