summaryrefslogtreecommitdiff
path: root/usr/src/lib/libwladm/common/libwladm.h
blob: 0a5d24df9e0fb2971cca294c828ca03e01b47cc8 (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
/*
 * 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 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _LIBWLADM_H
#define	_LIBWLADM_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#include <sys/types.h>

/*
 * General libwladm definitions and functions.
 *
 * These interfaces are ON consolidation-private.
 * For documentation, refer to PSARC/2006/623.
 */

#ifdef	__cplusplus
extern "C" {
#endif

#define	WLADM_MAX_ESSID_LEN		32	/* per 802.11 spec */
#define	WLADM_BSSID_LEN			6	/* per 802.11 spec */
#define	WLADM_STRSIZE			256

#define	WLADM_CONNECT_TIMEOUT_DEFAULT	10
#define	WLADM_OPT_CREATEIBSS		0x00000001
#define	WLADM_OPT_NOSCAN		0x00000002

typedef struct wladm_essid {
	char	we_bytes[WLADM_MAX_ESSID_LEN];
} wladm_essid_t;

typedef struct wladm_bssid {
	uint8_t	wb_bytes[WLADM_BSSID_LEN];
} wladm_bssid_t;

typedef enum {
	WLADM_SECMODE_NONE = 1,
	WLADM_SECMODE_WEP
} wladm_secmode_t;

typedef enum {
	WLADM_STRENGTH_VERY_WEAK = 1,
	WLADM_STRENGTH_WEAK,
	WLADM_STRENGTH_GOOD,
	WLADM_STRENGTH_VERY_GOOD,
	WLADM_STRENGTH_EXCELLENT
} wladm_strength_t;

typedef enum {
	WLADM_MODE_NONE = 0,
	WLADM_MODE_80211A,
	WLADM_MODE_80211B,
	WLADM_MODE_80211G
} wladm_mode_t;

typedef enum {
	WLADM_AUTH_OPEN = 1,
	WLADM_AUTH_SHARED
} wladm_auth_t;

typedef enum {
	WLADM_BSSTYPE_BSS = 1,
	WLADM_BSSTYPE_IBSS,
	WLADM_BSSTYPE_ANY
} wladm_bsstype_t;

typedef enum {
	WLADM_LINK_STATUS_DISCONNECTED = 1,
	WLADM_LINK_STATUS_CONNECTED
} wladm_linkstatus_t;

typedef enum {
	WLADM_STATUS_OK = 0,
	WLADM_STATUS_BADARG,
	WLADM_STATUS_FAILED,
	WLADM_STATUS_NOTSUP,
	WLADM_STATUS_ISCONN,
	WLADM_STATUS_NOTCONN,
	WLADM_STATUS_NOTFOUND,
	WLADM_STATUS_BADVAL,
	WLADM_STATUS_LINKINVAL,
	WLADM_STATUS_NOMEM,
	WLADM_STATUS_TIMEDOUT,
	WLADM_STATUS_PROPRDONLY,
	WLADM_STATUS_TOOSMALL,
	WLADM_STATUS_BADVALCNT
} wladm_status_t;

typedef uint32_t wladm_speed_t;
typedef	uint32_t wladm_channel_t;

enum {
	WLADM_WLAN_ATTR_ESSID	= 0x00000001,
	WLADM_WLAN_ATTR_BSSID	= 0x00000002,
	WLADM_WLAN_ATTR_SECMODE	= 0x00000004,
	WLADM_WLAN_ATTR_STRENGTH = 0x00000008,
	WLADM_WLAN_ATTR_MODE	= 0x00000010,
	WLADM_WLAN_ATTR_SPEED	= 0x00000020,
	WLADM_WLAN_ATTR_AUTH	= 0x00000040,
	WLADM_WLAN_ATTR_BSSTYPE	= 0x00000080,
	WLADM_WLAN_ATTR_CHANNEL	= 0x00000100
};
typedef struct wladm_wlan_attr {
	uint_t			wa_valid;
	wladm_essid_t		wa_essid;
	wladm_bssid_t		wa_bssid;
	wladm_secmode_t		wa_secmode;
	wladm_strength_t	wa_strength;
	wladm_mode_t		wa_mode;
	wladm_speed_t		wa_speed;
	wladm_auth_t		wa_auth;
	wladm_bsstype_t		wa_bsstype;
	wladm_channel_t		wa_channel;
} wladm_wlan_attr_t;

enum {
	WLADM_LINK_ATTR_STATUS	= 0x00000001,
	WLADM_LINK_ATTR_WLAN	= 0x00000002
};
typedef struct wladm_link_attr {
	uint_t			la_valid;
	wladm_linkstatus_t	la_status;
	wladm_wlan_attr_t	la_wlan_attr;
} wladm_link_attr_t;

#define	WLADM_WEPKEY64_LEN		5 	/* per WEP spec */
#define	WLADM_WEPKEY128_LEN		13 	/* per WEP spec */
#define	WLADM_MAX_WEPKEY_LEN		13	/* per WEP spec */
#define	WLADM_MAX_WEPKEYS		4 	/* MAX_NWEPKEYS */
#define	WLADM_MAX_WEPKEYNAME_LEN	64
typedef struct wladm_wep_key {
	uint_t		wk_idx;
	uint_t		wk_len;
	uint8_t		wk_val[WLADM_MAX_WEPKEY_LEN];
	char		wk_name[WLADM_MAX_WEPKEYNAME_LEN];
} wladm_wep_key_t;

typedef enum {
	WLADM_PROP_VAL_CURRENT = 1,
	WLADM_PROP_VAL_DEFAULT,
	WLADM_PROP_VAL_MODIFIABLE
} wladm_prop_type_t;

extern wladm_status_t	wladm_scan(const char *, void *,
			    boolean_t (*)(void *, wladm_wlan_attr_t *));
extern wladm_status_t	wladm_connect(const char *, wladm_wlan_attr_t *,
			    int, void *, uint_t, uint_t);
extern wladm_status_t	wladm_disconnect(const char *);
extern wladm_status_t	wladm_get_link_attr(const char *, wladm_link_attr_t *);
extern wladm_status_t	wladm_walk(void *, boolean_t (*)(void *, const char *));
extern boolean_t	wladm_is_valid(const char *);
extern wladm_status_t	wladm_set_prop(const char *, const char *, char **,
			    uint_t);
extern wladm_status_t	wladm_walk_prop(const char *, void *,
			    boolean_t (*)(void *, const char *));
extern wladm_status_t	wladm_get_prop(const char *, wladm_prop_type_t,
			    const char *, char **, uint_t *);

extern const char	*wladm_essid2str(wladm_essid_t *, char *);
extern const char	*wladm_bssid2str(wladm_bssid_t *, char *);
extern const char	*wladm_secmode2str(wladm_secmode_t *, char *);
extern const char	*wladm_strength2str(wladm_strength_t *, char *);
extern const char	*wladm_mode2str(wladm_mode_t *, char *);
extern const char	*wladm_speed2str(wladm_speed_t *, char *);
extern const char	*wladm_auth2str(wladm_auth_t *, char *);
extern const char	*wladm_bsstype2str(wladm_bsstype_t *, char *);
extern const char	*wladm_linkstatus2str(wladm_linkstatus_t *, char *);
extern const char	*wladm_status2str(wladm_status_t, char *);

extern wladm_status_t	wladm_str2essid(const char *, wladm_essid_t *);
extern wladm_status_t	wladm_str2bssid(const char *, wladm_bssid_t *);
extern wladm_status_t	wladm_str2secmode(const char *, wladm_secmode_t *);
extern wladm_status_t	wladm_str2strength(const char *, wladm_strength_t *);
extern wladm_status_t	wladm_str2mode(const char *, wladm_mode_t *);
extern wladm_status_t	wladm_str2speed(const char *, wladm_speed_t *);
extern wladm_status_t	wladm_str2auth(const char *, wladm_auth_t *);
extern wladm_status_t	wladm_str2bsstype(const char *, wladm_bsstype_t *);
extern wladm_status_t	wladm_str2linkstatus(const char *,
			    wladm_linkstatus_t *);

#ifdef	__cplusplus
}
#endif

#endif	/* _LIBWLADM_H */