xref: /titanic_52/usr/src/uts/common/net/wpa.h (revision bd0f52d78d701efcad2c460df61b45677d041c35)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * Macro and data structures defined for 802.11i.
28  */
29 
30 #ifndef	__WPA_H
31 #define	__WPA_H
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 #include <sys/types.h>
36 #include <inet/wifi_ioctl.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 #define	SERVICE_NAME			"network/wpa"
43 #define	WPA_DOOR 			"/var/run/wpa_door"
44 #define	SVC_METHOD			"/usr/lib/inet/wpad"
45 
46 #define	IEEE80211_ADDR_LEN		6
47 #define	IEEE80211_MAX_WPA_IE		40	/* IEEE802.11i */
48 #define	WPA_STRSIZE			256
49 /*
50  * Max size of optional information elements.  We artificially
51  * constrain this; it's limited only by the max frame size (and
52  * the max parameter size of the wireless extensions).
53  */
54 #define	IEEE80211_MAX_OPT_IE		256
55 
56 /*
57  * Parameters.
58  * WL_WPA_BASE + 0x1, 5, 6 reserved to be compatible with FreeBSD.
59  */
60 #define	WL_WPA_BASE			(WL_PARAMETERS_BASE + 0x500)
61 #define	WL_SETOPTIE			(WL_WPA_BASE + 0x0)
62 #define	WL_WPA				(WL_WPA_BASE + 0x2)
63 #define	WL_KEY				(WL_WPA_BASE + 0x3)
64 #define	WL_DELKEY			(WL_WPA_BASE + 0x4)
65 #define	WL_SCANRESULTS			(WL_WPA_BASE + 0x7)
66 #define	WL_MLME				(WL_WPA_BASE + 0x8)
67 #define	WL_CAPABILITY			(WL_WPA_BASE + 0x9)
68 
69 typedef struct wl_wpa_ie {
70     uint32_t	wpa_ie_len;
71     char 	wpa_ie[1];	/* it's the head of wpa_ie */
72 } wl_wpa_ie_t;
73 
74 typedef struct wl_wpa {
75     uint32_t	wpa_flag;
76 } wl_wpa_t;
77 
78 typedef struct wl_capability {
79     uint32_t	caps;
80 } wl_capability_t;
81 
82 #define	IEEE80211_KEYBUF_SIZE		16	/* 128-bit TKIP & CCMP key */
83 #define	IEEE80211_MICBUF_SIZE		(8+8)	/* 8 byte tx, 8 byte rx */
84 
85 /*
86  * NB: these values are ordered carefully; there are lots of
87  * of implications in any reordering.  In particular beware
88  * that 4 is not used to avoid conflicting with IEEE80211_F_PRIVACY.
89  */
90 #define	IEEE80211_CIPHER_WEP		0
91 #define	IEEE80211_CIPHER_TKIP		1
92 #define	IEEE80211_CIPHER_AES_OCB	2
93 #define	IEEE80211_CIPHER_AES_CCM	3
94 #define	IEEE80211_CIPHER_CKIP		4
95 #define	IEEE80211_CIPHER_NONE		5	/* pseudo value */
96 
97 #define	IEEE80211_CIPHER_MAX		(IEEE80211_CIPHER_NONE+1)
98 
99 /* Key Flags */
100 #define	IEEE80211_KEY_XMIT		0x01	/* key used for xmit */
101 #define	IEEE80211_KEY_RECV		0x02	/* key used for recv */
102 
103 #define	IEEE80211_KEY_DEFAULT		0x80	/* default xmit key */
104 
105 /*
106  * WPA/RSN get/set key request.  Specify the key/cipher
107  * type and whether the key is to be used for sending and/or
108  * receiving.  The key index should be set only when working
109  * with global keys (use IEEE80211_KEYIX_NONE for ``no index'').
110  * Otherwise a unicast/pairwise key is specified by the bssid
111  * (on a station) or mac address (on an ap).  They key length
112  * must include any MIC key data; otherwise it should be no
113  * more than IEEE80211_KEYBUF_SIZE.
114  */
115 #pragma pack(1)
116 typedef struct wl_key {
117 	uint8_t		ik_type;	/* key/cipher type */
118 	uint8_t		ik_pad;
119 
120 	uint16_t	ik_keyix;	/* key index */
121 	uint8_t		ik_keylen;	/* key length in bytes */
122 	uint8_t		ik_flags;
123 
124 	uint8_t		ik_macaddr[IEEE80211_ADDR_LEN];
125 	uint64_t	ik_keyrsc;	/* key receive sequence counter */
126 	uint64_t	ik_keytsc;	/* key transmit sequence counter */
127 
128 	uint8_t ik_keydata[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE];
129 } wl_key_t;
130 #pragma pack()
131 
132 struct wpa_ess {
133 	uint8_t		bssid[IEEE80211_ADDR_LEN];
134 	uint8_t		ssid[MAX_ESSID_LENGTH];
135 	uint32_t	ssid_len;
136 
137 	uint8_t		wpa_ie[IEEE80211_MAX_WPA_IE];
138 	uint32_t	wpa_ie_len;
139 	int		freq;
140 };
141 
142 typedef struct wl_del_key {
143 	uint8_t		idk_keyix;	/* key index */
144 	uint8_t		idk_macaddr[IEEE80211_ADDR_LEN];
145 }wl_del_key_t;
146 
147 typedef struct wl_countermeasures {
148 	uint32_t	cm_flag;
149 } wl_countermeasures_t;
150 
151 typedef struct wl_drop_unenc {
152 	uint32_t	drop_flag;
153 } wl_drop_unenc_t;
154 
155 typedef struct wl_wpa_ess {
156 	uint32_t	count;
157 	struct wpa_ess	ess[1];
158 } wl_wpa_ess_t;
159 
160 #define	IEEE80211_MLME_ASSOC		1	/* associate station */
161 #define	IEEE80211_MLME_DISASSOC		2	/* disassociate station */
162 #define	IEEE80211_MLME_DEAUTH		3	/* deauthenticate station */
163 #define	IEEE80211_MLME_AUTHORIZE	4	/* authorize station */
164 #define	IEEE80211_MLME_UNAUTHORIZE	5	/* unauthorize station */
165 
166 /*
167  *  * MLME state manipulation request.  IEEE80211_MLME_ASSOC
168  *   * only makes sense when operating as a station.  The other
169  *    * requests can be used when operating as a station or an
170  *     * ap (to effect a station).
171  */
172 typedef struct wl_mlme {
173 	uint8_t		im_op;		/* operation to perform */
174 	uint16_t	im_reason;	/* 802.11 reason code */
175 	uint8_t		im_macaddr[IEEE80211_ADDR_LEN];
176 } wl_mlme_t;
177 
178 /*
179  * State machine events
180  */
181 typedef enum {
182 	EVENT_ASSOC,
183 	EVENT_DISASSOC,
184 	EVENT_SCAN_RESULTS
185 } wpa_event_type;
186 
187 typedef struct  wl_events {
188 	wpa_event_type	event;
189 } wl_events_t;
190 
191 #ifdef __cplusplus
192 }
193 #endif
194 
195 #endif /* __WPA_H */
196