xref: /titanic_51/usr/src/lib/libdladm/common/libdllink.h (revision 07d06da50d310a325b457d6330165aebab1e0064)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _LIBDLLINK_H
27 #define	_LIBDLLINK_H
28 
29 /*
30  * This file includes structures, macros and routines used by general
31  * link administration (i.e. not limited to one specific type of link).
32  */
33 
34 #include <stdio.h>
35 #include <sys/types.h>
36 #include <sys/param.h>
37 #include <sys/mac.h>
38 #include <sys/dld.h>
39 #include <libdladm.h>
40 
41 #ifdef	__cplusplus
42 extern "C" {
43 #endif
44 
45 typedef struct dladm_attr {
46 	uint_t			da_max_sdu;
47 } dladm_attr_t;
48 
49 typedef struct dladm_phys_attr {
50 	char		dp_dev[MAXLINKNAMELEN];
51 	/*
52 	 * Whether this physical link supports vanity naming (links with media
53 	 * types not supported by GLDv3 don't have vanity naming support).
54 	 */
55 	boolean_t	dp_novanity;
56 } dladm_phys_attr_t;
57 
58 typedef enum {
59 	DLADM_PROP_VAL_CURRENT = 1,
60 	DLADM_PROP_VAL_DEFAULT,
61 	DLADM_PROP_VAL_PERM,
62 	DLADM_PROP_VAL_MODIFIABLE,
63 	DLADM_PROP_VAL_PERSISTENT
64 } dladm_prop_type_t;
65 
66 /*
67  * Maximum size of secobj value. Note that it should not be greater than
68  * DLD_SECOBJ_VAL_MAX.
69  */
70 #define	DLADM_SECOBJ_VAL_MAX	256
71 
72 /*
73  * Maximum size of secobj name. Note that it should not be greater than
74  * DLD_SECOBJ_NAME_MAX.
75  */
76 #define	DLADM_SECOBJ_NAME_MAX	32
77 
78 #define	DLADM_MAX_PROP_VALCNT	32
79 /*
80  * Size of prop_val buffer passed to pd_get function must be at
81  * least DLADM_PROP_VAL_MAX
82  */
83 #define	DLADM_PROP_VAL_MAX	128
84 
85 #define		DLADM_SECOBJ_CLASS_WEP	0
86 #define		DLADM_SECOBJ_CLASS_WPA	1
87 typedef int	dladm_secobj_class_t;
88 
89 typedef int (dladm_walkcb_t)(const char *, void *);
90 
91 /* possible flags for ma_flags below */
92 #define	DLADM_MACADDR_USED	0x1
93 
94 typedef enum {
95 	DLADM_HWGRP_TYPE_RX = 0x1,
96 	DLADM_HWGRP_TYPE_TX
97 } dladm_hwgrp_type_t;
98 
99 typedef struct dladm_hwgrp_attr {
100 	char		hg_link_name[MAXLINKNAMELEN];
101 	uint_t		hg_grp_num;
102 	dladm_hwgrp_type_t	hg_grp_type;
103 	uint_t		hg_n_rings;
104 	uint_t		hg_n_clnts;
105 	char		hg_client_names[MAXCLIENTNAMELEN];
106 } dladm_hwgrp_attr_t;
107 
108 typedef struct dladm_macaddr_attr {
109 	uint_t		ma_slot;
110 	uint_t		ma_flags;
111 	uchar_t		ma_addr[MAXMACADDRLEN];
112 	uint_t		ma_addrlen;
113 	char		ma_client_name[MAXNAMELEN];
114 	datalink_id_t	ma_client_linkid;
115 } dladm_macaddr_attr_t;
116 
117 extern dladm_status_t	dladm_walk(dladm_walkcb_t *, dladm_handle_t, void *,
118 			    datalink_class_t, datalink_media_t, uint32_t);
119 extern dladm_status_t	dladm_mac_walk(dladm_walkcb_t *, void *);
120 extern dladm_status_t	dladm_info(dladm_handle_t, datalink_id_t,
121 			    dladm_attr_t *);
122 
123 extern dladm_status_t	dladm_rename_link(dladm_handle_t, const char *,
124 			    const char *);
125 
126 extern dladm_status_t	dladm_set_linkprop(dladm_handle_t, datalink_id_t,
127 			    const char *, char **, uint_t, uint_t);
128 extern dladm_status_t	dladm_get_linkprop(dladm_handle_t, datalink_id_t,
129 			    dladm_prop_type_t, const char *, char **, uint_t *);
130 extern dladm_status_t	dladm_get_linkprop_values(dladm_handle_t, datalink_id_t,
131 			    dladm_prop_type_t, const char *, uint_t *,
132 			    uint_t *);
133 extern dladm_status_t	dladm_walk_linkprop(dladm_handle_t, datalink_id_t,
134 			    void *, int (*)(dladm_handle_t, datalink_id_t,
135 			    const char *, void *));
136 extern boolean_t	dladm_attr_is_linkprop(const char *name);
137 
138 extern dladm_status_t	dladm_set_secobj(dladm_handle_t, const char *,
139 			    dladm_secobj_class_t, uint8_t *, uint_t, uint_t);
140 extern dladm_status_t	dladm_get_secobj(dladm_handle_t, const char *,
141 			    dladm_secobj_class_t *, uint8_t *, uint_t *,
142 			    uint_t);
143 extern dladm_status_t	dladm_unset_secobj(dladm_handle_t, const char *,
144 			    uint_t);
145 extern dladm_status_t	dladm_walk_secobj(dladm_handle_t, void *,
146 			    boolean_t (*)(dladm_handle_t, void *, const char *),
147 			    uint_t);
148 
149 extern const char	*dladm_linkstate2str(link_state_t, char *);
150 extern const char	*dladm_linkduplex2str(link_duplex_t, char *);
151 extern const char	*dladm_secobjclass2str(dladm_secobj_class_t, char *);
152 extern dladm_status_t	dladm_str2secobjclass(const char *,
153 			    dladm_secobj_class_t *);
154 
155 extern dladm_status_t	dladm_init_linkprop(dladm_handle_t, datalink_id_t,
156 			    boolean_t);
157 extern dladm_status_t	dladm_init_secobj(dladm_handle_t);
158 extern boolean_t	dladm_valid_secobj_name(const char *);
159 
160 extern dladm_status_t	dladm_create_datalink_id(dladm_handle_t, const char *,
161 			    datalink_class_t, uint_t, uint32_t,
162 			    datalink_id_t *);
163 extern dladm_status_t	dladm_destroy_datalink_id(dladm_handle_t, datalink_id_t,
164 			    uint32_t);
165 extern dladm_status_t	dladm_remap_datalink_id(dladm_handle_t, datalink_id_t,
166 			    const char *);
167 extern dladm_status_t	dladm_up_datalink_id(dladm_handle_t, datalink_id_t);
168 extern dladm_status_t	dladm_name2info(dladm_handle_t, const char *,
169 			    datalink_id_t *, uint32_t *, datalink_class_t *,
170 			    uint32_t *);
171 extern dladm_status_t	dladm_datalink_id2info(dladm_handle_t, datalink_id_t,
172 			    uint32_t *, datalink_class_t *, uint32_t *, char *,
173 			    size_t);
174 extern dladm_status_t	dladm_walk_datalink_id(int (*)(dladm_handle_t,
175 			    datalink_id_t, void *), dladm_handle_t, void *,
176 			    datalink_class_t, datalink_media_t, uint32_t);
177 extern dladm_status_t	dladm_create_conf(dladm_handle_t, const char *,
178 			    datalink_id_t, datalink_class_t, uint32_t,
179 			    dladm_conf_t *);
180 extern dladm_status_t	dladm_read_conf(dladm_handle_t, datalink_id_t,
181 			    dladm_conf_t *);
182 extern dladm_status_t	dladm_write_conf(dladm_handle_t, dladm_conf_t);
183 extern dladm_status_t	dladm_remove_conf(dladm_handle_t, datalink_id_t);
184 extern void		dladm_destroy_conf(dladm_handle_t, dladm_conf_t);
185 extern dladm_status_t	dladm_get_conf_field(dladm_handle_t, dladm_conf_t,
186 			    const char *, void *, size_t);
187 extern dladm_status_t	dladm_getnext_conf_linkprop(dladm_handle_t,
188 			    dladm_conf_t, const char *, char *, void *,
189 			    size_t, size_t *);
190 extern dladm_status_t	dladm_set_conf_field(dladm_handle_t, dladm_conf_t,
191 			    const char *, dladm_datatype_t, const void *);
192 extern dladm_status_t	dladm_unset_conf_field(dladm_handle_t, dladm_conf_t,
193 			    const char *);
194 
195 extern dladm_status_t	dladm_dev2linkid(dladm_handle_t, const char *,
196 			    datalink_id_t *);
197 extern dladm_status_t	dladm_linkid2legacyname(dladm_handle_t, datalink_id_t,
198 			    char *, size_t);
199 extern dladm_status_t	dladm_phys_delete(dladm_handle_t, datalink_id_t);
200 
201 extern dladm_status_t	dladm_phys_info(dladm_handle_t, datalink_id_t,
202 			    dladm_phys_attr_t *, uint32_t);
203 extern dladm_status_t	dladm_parselink(const char *, char *, uint_t *);
204 
205 extern int		dladm_walk_macaddr(dladm_handle_t, datalink_id_t,
206 			    void *,
207 			    boolean_t (*)(void *, dladm_macaddr_attr_t *));
208 extern int		dladm_walk_hwgrp(dladm_handle_t, datalink_id_t, void *,
209 			    boolean_t (*)(void *, dladm_hwgrp_attr_t *));
210 
211 extern dladm_status_t	dladm_link_get_proplist(dladm_handle_t, datalink_id_t,
212 			    dladm_arg_list_t **);
213 
214 extern dladm_status_t	i_dladm_set_link_proplist_db(char *,
215 			    dladm_arg_list_t *);
216 
217 #ifdef	__cplusplus
218 }
219 #endif
220 
221 #endif	/* _LIBDLLINK_H */
222