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