blob: 4dd5690cb6e6ca9fdea9cf9b6223a56ae2fb1f15 [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001/*
2 * WPA Supplicant - Common definitions
Dmitry Shmidt807291d2015-01-27 13:40:23 -08003 * Copyright (c) 2004-2015, Jouni Malinen <j@w1.fi>
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07004 *
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -08005 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07007 */
8
9#ifndef DEFS_H
10#define DEFS_H
11
12#ifdef FALSE
13#undef FALSE
14#endif
15#ifdef TRUE
16#undef TRUE
17#endif
18typedef enum { FALSE = 0, TRUE = 1 } Boolean;
19
20
21#define WPA_CIPHER_NONE BIT(0)
22#define WPA_CIPHER_WEP40 BIT(1)
23#define WPA_CIPHER_WEP104 BIT(2)
24#define WPA_CIPHER_TKIP BIT(3)
25#define WPA_CIPHER_CCMP BIT(4)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070026#define WPA_CIPHER_AES_128_CMAC BIT(5)
Dmitry Shmidt61d9df32012-08-29 16:22:06 -070027#define WPA_CIPHER_GCMP BIT(6)
Dmitry Shmidtd5e49232012-12-03 15:08:10 -080028#define WPA_CIPHER_SMS4 BIT(7)
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -080029#define WPA_CIPHER_GCMP_256 BIT(8)
30#define WPA_CIPHER_CCMP_256 BIT(9)
31#define WPA_CIPHER_BIP_GMAC_128 BIT(11)
32#define WPA_CIPHER_BIP_GMAC_256 BIT(12)
33#define WPA_CIPHER_BIP_CMAC_256 BIT(13)
34#define WPA_CIPHER_GTK_NOT_USED BIT(14)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070035
36#define WPA_KEY_MGMT_IEEE8021X BIT(0)
37#define WPA_KEY_MGMT_PSK BIT(1)
38#define WPA_KEY_MGMT_NONE BIT(2)
39#define WPA_KEY_MGMT_IEEE8021X_NO_WPA BIT(3)
40#define WPA_KEY_MGMT_WPA_NONE BIT(4)
41#define WPA_KEY_MGMT_FT_IEEE8021X BIT(5)
42#define WPA_KEY_MGMT_FT_PSK BIT(6)
43#define WPA_KEY_MGMT_IEEE8021X_SHA256 BIT(7)
44#define WPA_KEY_MGMT_PSK_SHA256 BIT(8)
45#define WPA_KEY_MGMT_WPS BIT(9)
Dmitry Shmidtd5e49232012-12-03 15:08:10 -080046#define WPA_KEY_MGMT_SAE BIT(10)
47#define WPA_KEY_MGMT_FT_SAE BIT(11)
48#define WPA_KEY_MGMT_WAPI_PSK BIT(12)
49#define WPA_KEY_MGMT_WAPI_CERT BIT(13)
50#define WPA_KEY_MGMT_CCKM BIT(14)
Dmitry Shmidtf21452a2014-02-26 10:55:25 -080051#define WPA_KEY_MGMT_OSEN BIT(15)
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080052#define WPA_KEY_MGMT_IEEE8021X_SUITE_B BIT(16)
Dmitry Shmidt807291d2015-01-27 13:40:23 -080053#define WPA_KEY_MGMT_IEEE8021X_SUITE_B_192 BIT(17)
Dmitry Shmidt9839ecd2016-11-07 11:05:47 -080054#define WPA_KEY_MGMT_FILS_SHA256 BIT(18)
55#define WPA_KEY_MGMT_FILS_SHA384 BIT(19)
56#define WPA_KEY_MGMT_FT_FILS_SHA256 BIT(20)
57#define WPA_KEY_MGMT_FT_FILS_SHA384 BIT(21)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070058
59static inline int wpa_key_mgmt_wpa_ieee8021x(int akm)
60{
61 return !!(akm & (WPA_KEY_MGMT_IEEE8021X |
62 WPA_KEY_MGMT_FT_IEEE8021X |
Dmitry Shmidtd5e49232012-12-03 15:08:10 -080063 WPA_KEY_MGMT_CCKM |
Dmitry Shmidtf21452a2014-02-26 10:55:25 -080064 WPA_KEY_MGMT_OSEN |
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080065 WPA_KEY_MGMT_IEEE8021X_SHA256 |
Dmitry Shmidt807291d2015-01-27 13:40:23 -080066 WPA_KEY_MGMT_IEEE8021X_SUITE_B |
Dmitry Shmidt9839ecd2016-11-07 11:05:47 -080067 WPA_KEY_MGMT_IEEE8021X_SUITE_B_192 |
68 WPA_KEY_MGMT_FILS_SHA256 |
69 WPA_KEY_MGMT_FILS_SHA384 |
70 WPA_KEY_MGMT_FT_FILS_SHA256 |
71 WPA_KEY_MGMT_FT_FILS_SHA384));
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070072}
73
74static inline int wpa_key_mgmt_wpa_psk(int akm)
75{
76 return !!(akm & (WPA_KEY_MGMT_PSK |
77 WPA_KEY_MGMT_FT_PSK |
Dmitry Shmidtd5e49232012-12-03 15:08:10 -080078 WPA_KEY_MGMT_PSK_SHA256 |
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -080079 WPA_KEY_MGMT_SAE |
80 WPA_KEY_MGMT_FT_SAE));
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070081}
82
83static inline int wpa_key_mgmt_ft(int akm)
84{
85 return !!(akm & (WPA_KEY_MGMT_FT_PSK |
Dmitry Shmidtd5e49232012-12-03 15:08:10 -080086 WPA_KEY_MGMT_FT_IEEE8021X |
Dmitry Shmidt9839ecd2016-11-07 11:05:47 -080087 WPA_KEY_MGMT_FT_SAE |
88 WPA_KEY_MGMT_FT_FILS_SHA256 |
89 WPA_KEY_MGMT_FT_FILS_SHA384));
90}
91
92static inline int wpa_key_mgmt_ft_psk(int akm)
93{
94 return !!(akm & WPA_KEY_MGMT_FT_PSK);
Dmitry Shmidtd5e49232012-12-03 15:08:10 -080095}
96
97static inline int wpa_key_mgmt_sae(int akm)
98{
99 return !!(akm & (WPA_KEY_MGMT_SAE |
100 WPA_KEY_MGMT_FT_SAE));
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700101}
102
Dmitry Shmidt9839ecd2016-11-07 11:05:47 -0800103static inline int wpa_key_mgmt_fils(int akm)
104{
105 return !!(akm & (WPA_KEY_MGMT_FILS_SHA256 |
106 WPA_KEY_MGMT_FILS_SHA384 |
107 WPA_KEY_MGMT_FT_FILS_SHA256 |
108 WPA_KEY_MGMT_FT_FILS_SHA384));
109}
110
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700111static inline int wpa_key_mgmt_sha256(int akm)
112{
113 return !!(akm & (WPA_KEY_MGMT_PSK_SHA256 |
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800114 WPA_KEY_MGMT_IEEE8021X_SHA256 |
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800115 WPA_KEY_MGMT_OSEN |
Dmitry Shmidt9839ecd2016-11-07 11:05:47 -0800116 WPA_KEY_MGMT_IEEE8021X_SUITE_B |
117 WPA_KEY_MGMT_FILS_SHA256 |
118 WPA_KEY_MGMT_FT_FILS_SHA256));
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800119}
120
Dmitry Shmidt807291d2015-01-27 13:40:23 -0800121static inline int wpa_key_mgmt_sha384(int akm)
122{
Dmitry Shmidt9839ecd2016-11-07 11:05:47 -0800123 return !!(akm & (WPA_KEY_MGMT_IEEE8021X_SUITE_B_192 |
124 WPA_KEY_MGMT_FILS_SHA384 |
125 WPA_KEY_MGMT_FT_FILS_SHA384));
Dmitry Shmidt807291d2015-01-27 13:40:23 -0800126}
127
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800128static inline int wpa_key_mgmt_suite_b(int akm)
129{
Dmitry Shmidt807291d2015-01-27 13:40:23 -0800130 return !!(akm & (WPA_KEY_MGMT_IEEE8021X_SUITE_B |
131 WPA_KEY_MGMT_IEEE8021X_SUITE_B_192));
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700132}
133
134static inline int wpa_key_mgmt_wpa(int akm)
135{
136 return wpa_key_mgmt_wpa_ieee8021x(akm) ||
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800137 wpa_key_mgmt_wpa_psk(akm) ||
Dmitry Shmidt9839ecd2016-11-07 11:05:47 -0800138 wpa_key_mgmt_fils(akm) ||
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800139 wpa_key_mgmt_sae(akm);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700140}
141
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800142static inline int wpa_key_mgmt_wpa_any(int akm)
143{
144 return wpa_key_mgmt_wpa(akm) || (akm & WPA_KEY_MGMT_WPA_NONE);
145}
146
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800147static inline int wpa_key_mgmt_cckm(int akm)
148{
149 return akm == WPA_KEY_MGMT_CCKM;
150}
151
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700152
153#define WPA_PROTO_WPA BIT(0)
154#define WPA_PROTO_RSN BIT(1)
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800155#define WPA_PROTO_WAPI BIT(2)
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800156#define WPA_PROTO_OSEN BIT(3)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700157
158#define WPA_AUTH_ALG_OPEN BIT(0)
159#define WPA_AUTH_ALG_SHARED BIT(1)
160#define WPA_AUTH_ALG_LEAP BIT(2)
161#define WPA_AUTH_ALG_FT BIT(3)
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800162#define WPA_AUTH_ALG_SAE BIT(4)
Dmitry Shmidt9839ecd2016-11-07 11:05:47 -0800163#define WPA_AUTH_ALG_FILS BIT(5)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700164
165
166enum wpa_alg {
167 WPA_ALG_NONE,
168 WPA_ALG_WEP,
169 WPA_ALG_TKIP,
170 WPA_ALG_CCMP,
171 WPA_ALG_IGTK,
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700172 WPA_ALG_PMK,
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800173 WPA_ALG_GCMP,
174 WPA_ALG_SMS4,
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800175 WPA_ALG_KRK,
176 WPA_ALG_GCMP_256,
177 WPA_ALG_CCMP_256,
178 WPA_ALG_BIP_GMAC_128,
179 WPA_ALG_BIP_GMAC_256,
180 WPA_ALG_BIP_CMAC_256
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700181};
182
183/**
184 * enum wpa_states - wpa_supplicant state
185 *
186 * These enumeration values are used to indicate the current wpa_supplicant
187 * state (wpa_s->wpa_state). The current state can be retrieved with
188 * wpa_supplicant_get_state() function and the state can be changed by calling
189 * wpa_supplicant_set_state(). In WPA state machine (wpa.c and preauth.c), the
190 * wrapper functions wpa_sm_get_state() and wpa_sm_set_state() should be used
191 * to access the state variable.
192 */
193enum wpa_states {
194 /**
195 * WPA_DISCONNECTED - Disconnected state
196 *
197 * This state indicates that client is not associated, but is likely to
198 * start looking for an access point. This state is entered when a
199 * connection is lost.
200 */
201 WPA_DISCONNECTED,
202
203 /**
204 * WPA_INTERFACE_DISABLED - Interface disabled
205 *
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800206 * This state is entered if the network interface is disabled, e.g.,
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700207 * due to rfkill. wpa_supplicant refuses any new operations that would
208 * use the radio until the interface has been enabled.
209 */
210 WPA_INTERFACE_DISABLED,
211
212 /**
213 * WPA_INACTIVE - Inactive state (wpa_supplicant disabled)
214 *
215 * This state is entered if there are no enabled networks in the
216 * configuration. wpa_supplicant is not trying to associate with a new
217 * network and external interaction (e.g., ctrl_iface call to add or
218 * enable a network) is needed to start association.
219 */
220 WPA_INACTIVE,
221
222 /**
223 * WPA_SCANNING - Scanning for a network
224 *
225 * This state is entered when wpa_supplicant starts scanning for a
226 * network.
227 */
228 WPA_SCANNING,
229
230 /**
231 * WPA_AUTHENTICATING - Trying to authenticate with a BSS/SSID
232 *
233 * This state is entered when wpa_supplicant has found a suitable BSS
234 * to authenticate with and the driver is configured to try to
235 * authenticate with this BSS. This state is used only with drivers
236 * that use wpa_supplicant as the SME.
237 */
238 WPA_AUTHENTICATING,
239
240 /**
241 * WPA_ASSOCIATING - Trying to associate with a BSS/SSID
242 *
243 * This state is entered when wpa_supplicant has found a suitable BSS
244 * to associate with and the driver is configured to try to associate
245 * with this BSS in ap_scan=1 mode. When using ap_scan=2 mode, this
246 * state is entered when the driver is configured to try to associate
247 * with a network using the configured SSID and security policy.
248 */
249 WPA_ASSOCIATING,
250
251 /**
252 * WPA_ASSOCIATED - Association completed
253 *
254 * This state is entered when the driver reports that association has
255 * been successfully completed with an AP. If IEEE 802.1X is used
256 * (with or without WPA/WPA2), wpa_supplicant remains in this state
257 * until the IEEE 802.1X/EAPOL authentication has been completed.
258 */
259 WPA_ASSOCIATED,
260
261 /**
262 * WPA_4WAY_HANDSHAKE - WPA 4-Way Key Handshake in progress
263 *
264 * This state is entered when WPA/WPA2 4-Way Handshake is started. In
265 * case of WPA-PSK, this happens when receiving the first EAPOL-Key
266 * frame after association. In case of WPA-EAP, this state is entered
267 * when the IEEE 802.1X/EAPOL authentication has been completed.
268 */
269 WPA_4WAY_HANDSHAKE,
270
271 /**
272 * WPA_GROUP_HANDSHAKE - WPA Group Key Handshake in progress
273 *
274 * This state is entered when 4-Way Key Handshake has been completed
275 * (i.e., when the supplicant sends out message 4/4) and when Group
276 * Key rekeying is started by the AP (i.e., when supplicant receives
277 * message 1/2).
278 */
279 WPA_GROUP_HANDSHAKE,
280
281 /**
282 * WPA_COMPLETED - All authentication completed
283 *
284 * This state is entered when the full authentication process is
285 * completed. In case of WPA2, this happens when the 4-Way Handshake is
286 * successfully completed. With WPA, this state is entered after the
287 * Group Key Handshake; with IEEE 802.1X (non-WPA) connection is
288 * completed after dynamic keys are received (or if not used, after
289 * the EAP authentication has been completed). With static WEP keys and
290 * plaintext connections, this state is entered when an association
291 * has been completed.
292 *
293 * This state indicates that the supplicant has completed its
294 * processing for the association phase and that data connection is
295 * fully configured.
296 */
297 WPA_COMPLETED
298};
299
300#define MLME_SETPROTECTION_PROTECT_TYPE_NONE 0
301#define MLME_SETPROTECTION_PROTECT_TYPE_RX 1
302#define MLME_SETPROTECTION_PROTECT_TYPE_TX 2
303#define MLME_SETPROTECTION_PROTECT_TYPE_RX_TX 3
304
305#define MLME_SETPROTECTION_KEY_TYPE_GROUP 0
306#define MLME_SETPROTECTION_KEY_TYPE_PAIRWISE 1
307
308
309/**
310 * enum mfp_options - Management frame protection (IEEE 802.11w) options
311 */
312enum mfp_options {
313 NO_MGMT_FRAME_PROTECTION = 0,
314 MGMT_FRAME_PROTECTION_OPTIONAL = 1,
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800315 MGMT_FRAME_PROTECTION_REQUIRED = 2,
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700316};
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800317#define MGMT_FRAME_PROTECTION_DEFAULT 3
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700318
319/**
320 * enum hostapd_hw_mode - Hardware mode
321 */
322enum hostapd_hw_mode {
323 HOSTAPD_MODE_IEEE80211B,
324 HOSTAPD_MODE_IEEE80211G,
325 HOSTAPD_MODE_IEEE80211A,
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -0800326 HOSTAPD_MODE_IEEE80211AD,
Dmitry Shmidtb1e52102015-05-29 12:36:29 -0700327 HOSTAPD_MODE_IEEE80211ANY,
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700328 NUM_HOSTAPD_MODES
329};
330
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800331/**
332 * enum wpa_ctrl_req_type - Control interface request types
333 */
334enum wpa_ctrl_req_type {
335 WPA_CTRL_REQ_UNKNOWN,
336 WPA_CTRL_REQ_EAP_IDENTITY,
337 WPA_CTRL_REQ_EAP_PASSWORD,
338 WPA_CTRL_REQ_EAP_NEW_PASSWORD,
339 WPA_CTRL_REQ_EAP_PIN,
340 WPA_CTRL_REQ_EAP_OTP,
341 WPA_CTRL_REQ_EAP_PASSPHRASE,
Dmitry Shmidt051af732013-10-22 13:52:46 -0700342 WPA_CTRL_REQ_SIM,
Dmitry Shmidt912c6ec2015-03-30 13:16:51 -0700343 WPA_CTRL_REQ_PSK_PASSPHRASE,
Dmitry Shmidt55840ad2015-12-14 12:45:46 -0800344 WPA_CTRL_REQ_EXT_CERT_CHECK,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800345 NUM_WPA_CTRL_REQS
346};
347
348/* Maximum number of EAP methods to store for EAP server user information */
349#define EAP_MAX_METHODS 8
350
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800351enum mesh_plink_state {
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700352 PLINK_IDLE = 1,
353 PLINK_OPN_SNT,
354 PLINK_OPN_RCVD,
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800355 PLINK_CNF_RCVD,
356 PLINK_ESTAB,
357 PLINK_HOLDING,
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700358 PLINK_BLOCKED, /* not defined in the IEEE 802.11 standard */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800359};
360
Ravi Joshie6ccb162015-07-16 17:45:41 -0700361enum set_band {
362 WPA_SETBAND_AUTO,
363 WPA_SETBAND_5G,
364 WPA_SETBAND_2G
365};
366
Dmitry Shmidt9c175262016-03-03 10:20:07 -0800367enum wpa_radio_work_band {
368 BAND_2_4_GHZ = BIT(0),
369 BAND_5_GHZ = BIT(1),
370 BAND_60_GHZ = BIT(2),
371};
372
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700373#endif /* DEFS_H */