summaryrefslogtreecommitdiff
path: root/usr/src/lib/libdladm/common/libdllink.h
blob: a858e78aa3730e27465e6dc73ea19fb89bfc00c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
 * Copyright (c) 2011, Joyent Inc. All rights reserved.
 */

#ifndef _LIBDLLINK_H
#define	_LIBDLLINK_H

/*
 * This file includes structures, macros and routines used by general
 * link administration (i.e. not limited to one specific type of link).
 */

#include <stdio.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mac.h>
#include <sys/dld.h>
#include <libdladm.h>

#ifdef	__cplusplus
extern "C" {
#endif

typedef struct dladm_attr {
	uint_t			da_max_sdu;
} dladm_attr_t;

typedef struct dladm_phys_attr {
	char		dp_dev[MAXLINKNAMELEN];
	/*
	 * Whether this physical link supports vanity naming (links with media
	 * types not supported by GLDv3 don't have vanity naming support).
	 */
	boolean_t	dp_novanity;
} dladm_phys_attr_t;

typedef enum {
	DLADM_PROP_VAL_CURRENT = 1,
	DLADM_PROP_VAL_DEFAULT,
	DLADM_PROP_VAL_PERM,
	DLADM_PROP_VAL_MODIFIABLE,
	DLADM_PROP_VAL_PERSISTENT
} dladm_prop_type_t;

/*
 * Maximum size of secobj value. Note that it should not be greater than
 * DLD_SECOBJ_VAL_MAX.
 */
#define	DLADM_SECOBJ_VAL_MAX	256

/*
 * Maximum size of secobj name. Note that it should not be greater than
 * DLD_SECOBJ_NAME_MAX.
 */
#define	DLADM_SECOBJ_NAME_MAX	32

#define	DLADM_MAX_PROP_VALCNT	32
/*
 * Size of prop_val buffer passed to pd_get function must be at
 * least DLADM_PROP_VAL_MAX
 */
#define	DLADM_PROP_VAL_MAX	128

#define		DLADM_SECOBJ_CLASS_WEP	0
#define		DLADM_SECOBJ_CLASS_WPA	1
typedef int	dladm_secobj_class_t;

typedef int (dladm_walkcb_t)(const char *, void *);

/* possible flags for ma_flags below */
#define	DLADM_MACADDR_USED	0x1

typedef enum {
	DLADM_HWGRP_TYPE_RX = 0x1,
	DLADM_HWGRP_TYPE_TX
} dladm_hwgrp_type_t;

typedef struct dladm_hwgrp_attr {
	char		hg_link_name[MAXLINKNAMELEN];
	uint_t		hg_grp_num;
	dladm_hwgrp_type_t	hg_grp_type;
	uint_t		hg_n_rings;
	uint_t		hg_rings[MAX_RINGS_PER_GROUP];
	uint_t		hg_n_clnts;
	char		hg_client_names[MAXCLIENTNAMELEN];
} dladm_hwgrp_attr_t;

typedef struct dladm_macaddr_attr {
	uint_t		ma_slot;
	uint_t		ma_flags;
	uchar_t		ma_addr[MAXMACADDRLEN];
	uint_t		ma_addrlen;
	char		ma_client_name[MAXNAMELEN];
	datalink_id_t	ma_client_linkid;
} dladm_macaddr_attr_t;

extern dladm_status_t	dladm_walk(dladm_walkcb_t *, dladm_handle_t, void *,
			    datalink_class_t, datalink_media_t, uint32_t);
extern dladm_status_t	dladm_mac_walk(dladm_walkcb_t *, void *);
extern dladm_status_t	dladm_info(dladm_handle_t, datalink_id_t,
			    dladm_attr_t *);

extern dladm_status_t	dladm_rename_link(dladm_handle_t, const char *,
			    const char *, const char *);

extern dladm_status_t	dladm_set_linkprop(dladm_handle_t, datalink_id_t,
			    const char *, char **, uint_t, uint_t);
extern dladm_status_t	dladm_get_linkprop(dladm_handle_t, datalink_id_t,
			    dladm_prop_type_t, const char *, char **, uint_t *);
extern dladm_status_t	dladm_get_linkprop_values(dladm_handle_t, datalink_id_t,
			    dladm_prop_type_t, const char *, uint_t *,
			    uint_t *);
extern dladm_status_t	dladm_walk_linkprop(dladm_handle_t, datalink_id_t,
			    void *, int (*)(dladm_handle_t, datalink_id_t,
			    const char *, void *));
extern boolean_t	dladm_attr_is_linkprop(const char *name);
extern dladm_status_t	dladm_linkprop_is_set(dladm_handle_t, datalink_id_t,
			    dladm_prop_type_t, const char *, boolean_t *);

extern dladm_status_t	dladm_set_secobj(dladm_handle_t, const char *,
			    dladm_secobj_class_t, uint8_t *, uint_t, uint_t);
extern dladm_status_t	dladm_get_secobj(dladm_handle_t, const char *,
			    dladm_secobj_class_t *, uint8_t *, uint_t *,
			    uint_t);
extern dladm_status_t	dladm_unset_secobj(dladm_handle_t, const char *,
			    uint_t);
extern dladm_status_t	dladm_walk_secobj(dladm_handle_t, void *,
			    boolean_t (*)(dladm_handle_t, void *, const char *),
			    uint_t);

extern const char	*dladm_linkstate2str(link_state_t, char *);
extern const char	*dladm_linkduplex2str(link_duplex_t, char *);
extern const char	*dladm_secobjclass2str(dladm_secobj_class_t, char *);
extern dladm_status_t	dladm_str2secobjclass(const char *,
			    dladm_secobj_class_t *);

extern dladm_status_t	dladm_init_linkprop(dladm_handle_t, datalink_id_t,
			    boolean_t);
extern dladm_status_t	dladm_init_secobj(dladm_handle_t);
extern boolean_t	dladm_valid_secobj_name(const char *);

extern dladm_status_t	dladm_create_datalink_id(dladm_handle_t, const char *,
			    datalink_class_t, uint_t, uint32_t,
			    datalink_id_t *);
extern dladm_status_t	dladm_destroy_datalink_id(dladm_handle_t, datalink_id_t,
			    uint32_t);
extern dladm_status_t	dladm_remap_datalink_id(dladm_handle_t, datalink_id_t,
			    const char *);
extern dladm_status_t	dladm_up_datalink_id(dladm_handle_t, datalink_id_t);
extern dladm_status_t	dladm_name2info(dladm_handle_t, const char *,
			    datalink_id_t *, uint32_t *, datalink_class_t *,
			    uint32_t *);
extern dladm_status_t	dladm_zname2info(dladm_handle_t, const char *,
			    const char *, datalink_id_t *, uint32_t *,
			    datalink_class_t *, uint32_t *);
extern dladm_status_t	dladm_datalink_id2info(dladm_handle_t, datalink_id_t,
			    uint32_t *, datalink_class_t *, uint32_t *, char *,
			    size_t);
extern dladm_status_t	dladm_walk_datalink_id(int (*)(dladm_handle_t,
			    datalink_id_t, void *), dladm_handle_t, void *,
			    datalink_class_t, datalink_media_t, uint32_t);
extern dladm_status_t	dladm_create_conf(dladm_handle_t, const char *,
			    datalink_id_t, datalink_class_t, uint32_t,
			    dladm_conf_t *);
extern dladm_status_t	dladm_open_conf(dladm_handle_t, datalink_id_t,
			    dladm_conf_t *);
extern dladm_status_t	dladm_getsnap_conf(dladm_handle_t, datalink_id_t,
			    dladm_conf_t *);
extern dladm_status_t	dladm_write_conf(dladm_handle_t, dladm_conf_t);
extern dladm_status_t	dladm_remove_conf(dladm_handle_t, datalink_id_t);
extern void		dladm_destroy_conf(dladm_handle_t, dladm_conf_t);
extern dladm_status_t	dladm_get_conf_field(dladm_handle_t, dladm_conf_t,
			    const char *, void *, size_t);
extern dladm_status_t	dladm_getnext_conf_linkprop(dladm_handle_t,
			    dladm_conf_t, const char *, char *, void *,
			    size_t, size_t *);
extern dladm_status_t	dladm_set_conf_field(dladm_handle_t, dladm_conf_t,
			    const char *, dladm_datatype_t, const void *);
extern dladm_status_t	dladm_unset_conf_field(dladm_handle_t, dladm_conf_t,
			    const char *);

extern dladm_status_t	dladm_dev2linkid(dladm_handle_t, const char *,
			    datalink_id_t *);
extern dladm_status_t	dladm_linkid2legacyname(dladm_handle_t, datalink_id_t,
			    char *, size_t);
extern dladm_status_t	dladm_phys_delete(dladm_handle_t, datalink_id_t);

extern dladm_status_t	dladm_phys_info(dladm_handle_t, datalink_id_t,
			    dladm_phys_attr_t *, uint32_t);
extern dladm_status_t	dladm_parselink(const char *, char *, uint_t *);

extern int		dladm_walk_macaddr(dladm_handle_t, datalink_id_t,
			    void *,
			    boolean_t (*)(void *, dladm_macaddr_attr_t *));
extern int		dladm_walk_hwgrp(dladm_handle_t, datalink_id_t, void *,
			    boolean_t (*)(void *, dladm_hwgrp_attr_t *));

extern void		dladm_sort_index_list(uint_t [], uint_t);

extern dladm_status_t	dladm_link_get_proplist(dladm_handle_t, datalink_id_t,
			    dladm_arg_list_t **);

extern dladm_status_t	i_dladm_set_link_proplist_db(char *,
			    dladm_arg_list_t *);

#ifdef	__cplusplus
}
#endif

#endif	/* _LIBDLLINK_H */