2 * hostapd / IEEE 802.11 Management
3 * Copyright (c) 2002-2006, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
18 /* IEEE 802.11 defines */
20 #define WLAN_FC_PVER (BIT(1) | BIT(0))
21 #define WLAN_FC_TODS BIT(8)
22 #define WLAN_FC_FROMDS BIT(9)
23 #define WLAN_FC_MOREFRAG BIT(10)
24 #define WLAN_FC_RETRY BIT(11)
25 #define WLAN_FC_PWRMGT BIT(12)
26 #define WLAN_FC_MOREDATA BIT(13)
27 #define WLAN_FC_ISWEP BIT(14)
28 #define WLAN_FC_ORDER BIT(15)
30 #define WLAN_FC_GET_TYPE(fc) (((fc) & (BIT(3) | BIT(2))) >> 2)
31 #define WLAN_FC_GET_STYPE(fc) \
32 (((fc) & (BIT(7) | BIT(6) | BIT(5) | BIT(4))) >> 4)
34 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & (BIT(3) | BIT(2) | BIT(1) | BIT(0)))
35 #define WLAN_GET_SEQ_SEQ(seq) \
36 (((seq) & (~(BIT(3) | BIT(2) | BIT(1) | BIT(0)))) >> 4)
38 #define WLAN_FC_TYPE_MGMT 0
39 #define WLAN_FC_TYPE_CTRL 1
40 #define WLAN_FC_TYPE_DATA 2
43 #define WLAN_FC_STYPE_ASSOC_REQ 0
44 #define WLAN_FC_STYPE_ASSOC_RESP 1
45 #define WLAN_FC_STYPE_REASSOC_REQ 2
46 #define WLAN_FC_STYPE_REASSOC_RESP 3
47 #define WLAN_FC_STYPE_PROBE_REQ 4
48 #define WLAN_FC_STYPE_PROBE_RESP 5
49 #define WLAN_FC_STYPE_BEACON 8
50 #define WLAN_FC_STYPE_ATIM 9
51 #define WLAN_FC_STYPE_DISASSOC 10
52 #define WLAN_FC_STYPE_AUTH 11
53 #define WLAN_FC_STYPE_DEAUTH 12
54 #define WLAN_FC_STYPE_ACTION 13
57 #define WLAN_FC_STYPE_PSPOLL 10
58 #define WLAN_FC_STYPE_RTS 11
59 #define WLAN_FC_STYPE_CTS 12
60 #define WLAN_FC_STYPE_ACK 13
61 #define WLAN_FC_STYPE_CFEND 14
62 #define WLAN_FC_STYPE_CFENDACK 15
65 #define WLAN_FC_STYPE_DATA 0
66 #define WLAN_FC_STYPE_DATA_CFACK 1
67 #define WLAN_FC_STYPE_DATA_CFPOLL 2
68 #define WLAN_FC_STYPE_DATA_CFACKPOLL 3
69 #define WLAN_FC_STYPE_NULLFUNC 4
70 #define WLAN_FC_STYPE_CFACK 5
71 #define WLAN_FC_STYPE_CFPOLL 6
72 #define WLAN_FC_STYPE_CFACKPOLL 7
73 #define WLAN_FC_STYPE_QOS_DATA 8
75 /* Authentication algorithms */
76 #define WLAN_AUTH_OPEN 0
77 #define WLAN_AUTH_SHARED_KEY 1
79 #define WLAN_AUTH_CHALLENGE_LEN 128
81 #define WLAN_CAPABILITY_ESS BIT(0)
82 #define WLAN_CAPABILITY_IBSS BIT(1)
83 #define WLAN_CAPABILITY_CF_POLLABLE BIT(2)
84 #define WLAN_CAPABILITY_CF_POLL_REQUEST BIT(3)
85 #define WLAN_CAPABILITY_PRIVACY BIT(4)
86 #define WLAN_CAPABILITY_SHORT_PREAMBLE BIT(5)
87 #define WLAN_CAPABILITY_PBCC BIT(6)
88 #define WLAN_CAPABILITY_CHANNEL_AGILITY BIT(7)
89 #define WLAN_CAPABILITY_SPECTRUM_MGMT BIT(8)
90 #define WLAN_CAPABILITY_SHORT_SLOT_TIME BIT(10)
91 #define WLAN_CAPABILITY_DSSS_OFDM BIT(13)
94 #define WLAN_STATUS_SUCCESS 0
95 #define WLAN_STATUS_UNSPECIFIED_FAILURE 1
96 #define WLAN_STATUS_CAPS_UNSUPPORTED 10
97 #define WLAN_STATUS_REASSOC_NO_ASSOC 11
98 #define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
99 #define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
100 #define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
101 #define WLAN_STATUS_CHALLENGE_FAIL 15
102 #define WLAN_STATUS_AUTH_TIMEOUT 16
103 #define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
104 #define WLAN_STATUS_ASSOC_DENIED_RATES 18
106 #define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
107 #define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
108 #define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
110 #define WLAN_STATUS_SPEC_MGMT_REQUIRED 22
111 #define WLAN_STATUS_PWR_CAPABILITY_NOT_VALID 23
112 #define WLAN_STATUS_SUPPORTED_CHANNEL_NOT_VALID 24
114 #define WLAN_STATUS_INVALID_IE 40
115 #define WLAN_STATUS_GROUP_CIPHER_NOT_VALID 41
116 #define WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID 42
117 #define WLAN_STATUS_AKMP_NOT_VALID 43
118 #define WLAN_STATUS_UNSUPPORTED_RSN_IE_VERSION 44
119 #define WLAN_STATUS_INVALID_RSN_IE_CAPAB 45
120 #define WLAN_STATUS_CIPHER_REJECTED_PER_POLICY 46
123 #define WLAN_REASON_UNSPECIFIED 1
124 #define WLAN_REASON_PREV_AUTH_NOT_VALID 2
125 #define WLAN_REASON_DEAUTH_LEAVING 3
126 #define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
127 #define WLAN_REASON_DISASSOC_AP_BUSY 5
128 #define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
129 #define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
130 #define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
131 #define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
133 #define WLAN_REASON_INVALID_IE 13
134 #define WLAN_REASON_MICHAEL_MIC_FAILURE 14
135 #define WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT 15
136 #define WLAN_REASON_GROUP_KEY_UPDATE_TIMEOUT 16
137 #define WLAN_REASON_IE_IN_4WAY_DIFFERS 17
138 #define WLAN_REASON_GROUP_CIPHER_NOT_VALID 18
139 #define WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID 19
140 #define WLAN_REASON_AKMP_NOT_VALID 20
141 #define WLAN_REASON_UNSUPPORTED_RSN_IE_VERSION 21
142 #define WLAN_REASON_INVALID_RSN_IE_CAPAB 22
143 #define WLAN_REASON_IEEE_802_1X_AUTH_FAILED 23
144 #define WLAN_REASON_CIPHER_SUITE_REJECTED 24
147 /* Information Element IDs */
148 #define WLAN_EID_SSID 0
149 #define WLAN_EID_SUPP_RATES 1
150 #define WLAN_EID_FH_PARAMS 2
151 #define WLAN_EID_DS_PARAMS 3
152 #define WLAN_EID_CF_PARAMS 4
153 #define WLAN_EID_TIM 5
154 #define WLAN_EID_IBSS_PARAMS 6
155 #define WLAN_EID_COUNTRY 7
156 #define WLAN_EID_CHALLENGE 16
157 /* EIDs defined by IEEE 802.11h - START */
158 #define WLAN_EID_PWR_CONSTRAINT 32
159 #define WLAN_EID_PWR_CAPABILITY 33
160 #define WLAN_EID_TPC_REQUEST 34
161 #define WLAN_EID_TPC_REPORT 35
162 #define WLAN_EID_SUPPORTED_CHANNELS 36
163 #define WLAN_EID_CHANNEL_SWITCH 37
164 #define WLAN_EID_MEASURE_REQUEST 38
165 #define WLAN_EID_MEASURE_REPORT 39
166 #define WLAN_EID_QUITE 40
167 #define WLAN_EID_IBSS_DFS 41
168 /* EIDs defined by IEEE 802.11h - END */
169 #define WLAN_EID_ERP_INFO 42
170 #define WLAN_EID_RSN 48
171 #define WLAN_EID_EXT_SUPP_RATES 50
172 #define WLAN_EID_GENERIC 221
173 #define WLAN_EID_VENDOR_SPECIFIC 221
176 struct ieee80211_mgmt
{
186 u16 auth_transaction
;
188 /* possibly followed by Challenge text */
190 } __attribute__ ((packed
)) auth
;
193 } __attribute__ ((packed
)) deauth
;
197 /* followed by SSID and Supported rates */
199 } __attribute__ ((packed
)) assoc_req
;
204 /* followed by Supported rates */
206 } __attribute__ ((packed
)) assoc_resp
, reassoc_resp
;
211 /* followed by SSID and Supported rates */
213 } __attribute__ ((packed
)) reassoc_req
;
216 } __attribute__ ((packed
)) disassoc
;
218 /* only variable items: SSID, Supported rates */
220 } __attribute__ ((packed
)) probe_req
;
225 /* followed by some of SSID, Supported rates,
226 * FH Params, DS Params, CF Params, IBSS Params */
228 } __attribute__ ((packed
)) probe_resp
;
233 /* followed by some of SSID, Supported rates,
234 * FH Params, DS Params, CF Params, IBSS Params, TIM */
236 } __attribute__ ((packed
)) beacon
;
245 } __attribute__ ((packed
)) wme_action
;
253 } __attribute__ ((packed
)) chan_switch
;
255 } __attribute__ ((packed
)) action
;
257 } __attribute__ ((packed
));
260 #define ERP_INFO_NON_ERP_PRESENT BIT(0)
261 #define ERP_INFO_USE_PROTECTION BIT(1)
262 #define ERP_INFO_BARKER_PREAMBLE_MODE BIT(2)
264 /* Parsed Information Elements */
265 struct ieee802_11_elems
{
285 u8 ext_supp_rates_len
;
297 u8 supp_channels_len
;
300 typedef enum { ParseOK
= 0, ParseUnknown
= 1, ParseFailed
= -1 } ParseRes
;
303 struct hostapd_frame_info
{
309 unsigned int passive_scan
:1;
313 void ieee802_11_send_deauth(struct hostapd_data
*hapd
, u8
*addr
, u16 reason
);
314 void ieee802_11_mgmt(struct hostapd_data
*hapd
, u8
*buf
, size_t len
,
315 u16 stype
, struct hostapd_frame_info
*fi
);
316 void ieee802_11_mgmt_cb(struct hostapd_data
*hapd
, u8
*buf
, size_t len
,
318 ParseRes
ieee802_11_parse_elems(struct hostapd_data
*hapd
, u8
*start
,
320 struct ieee802_11_elems
*elems
,
322 void ieee802_11_print_ssid(const u8
*ssid
, u8 len
);
323 void ieee80211_michael_mic_failure(struct hostapd_data
*hapd
, const u8
*addr
,
325 int ieee802_11_get_mib(struct hostapd_data
*hapd
, char *buf
, size_t buflen
);
326 int ieee802_11_get_mib_sta(struct hostapd_data
*hapd
, struct sta_info
*sta
,
327 char *buf
, size_t buflen
);
328 u16
hostapd_own_capab_info(struct hostapd_data
*hapd
, struct sta_info
*sta
,
330 u8
* hostapd_eid_supp_rates(struct hostapd_data
*hapd
, u8
*eid
);
331 u8
* hostapd_eid_ext_supp_rates(struct hostapd_data
*hapd
, u8
*eid
);
333 #endif /* IEEE802_11_H */