blob: e1bbd5092b2e69651aa5a08ec77ad8c4f06f9090 [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001/*
2 * WPA Supplicant - Common definitions
3 * Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
4 *
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 Shmidt8d520ff2011-05-09 14:06:53 -070053
54static inline int wpa_key_mgmt_wpa_ieee8021x(int akm)
55{
56 return !!(akm & (WPA_KEY_MGMT_IEEE8021X |
57 WPA_KEY_MGMT_FT_IEEE8021X |
Dmitry Shmidtd5e49232012-12-03 15:08:10 -080058 WPA_KEY_MGMT_CCKM |
Dmitry Shmidtf21452a2014-02-26 10:55:25 -080059 WPA_KEY_MGMT_OSEN |
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080060 WPA_KEY_MGMT_IEEE8021X_SHA256 |
61 WPA_KEY_MGMT_IEEE8021X_SUITE_B));
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070062}
63
64static inline int wpa_key_mgmt_wpa_psk(int akm)
65{
66 return !!(akm & (WPA_KEY_MGMT_PSK |
67 WPA_KEY_MGMT_FT_PSK |
Dmitry Shmidtd5e49232012-12-03 15:08:10 -080068 WPA_KEY_MGMT_PSK_SHA256 |
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -080069 WPA_KEY_MGMT_SAE |
70 WPA_KEY_MGMT_FT_SAE));
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070071}
72
73static inline int wpa_key_mgmt_ft(int akm)
74{
75 return !!(akm & (WPA_KEY_MGMT_FT_PSK |
Dmitry Shmidtd5e49232012-12-03 15:08:10 -080076 WPA_KEY_MGMT_FT_IEEE8021X |
77 WPA_KEY_MGMT_FT_SAE));
78}
79
80static inline int wpa_key_mgmt_sae(int akm)
81{
82 return !!(akm & (WPA_KEY_MGMT_SAE |
83 WPA_KEY_MGMT_FT_SAE));
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070084}
85
86static inline int wpa_key_mgmt_sha256(int akm)
87{
88 return !!(akm & (WPA_KEY_MGMT_PSK_SHA256 |
Dmitry Shmidtf21452a2014-02-26 10:55:25 -080089 WPA_KEY_MGMT_IEEE8021X_SHA256 |
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080090 WPA_KEY_MGMT_OSEN |
91 WPA_KEY_MGMT_IEEE8021X_SUITE_B));
92}
93
94static inline int wpa_key_mgmt_suite_b(int akm)
95{
96 return !!(akm & WPA_KEY_MGMT_IEEE8021X_SUITE_B);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070097}
98
99static inline int wpa_key_mgmt_wpa(int akm)
100{
101 return wpa_key_mgmt_wpa_ieee8021x(akm) ||
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800102 wpa_key_mgmt_wpa_psk(akm) ||
103 wpa_key_mgmt_sae(akm);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700104}
105
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800106static inline int wpa_key_mgmt_wpa_any(int akm)
107{
108 return wpa_key_mgmt_wpa(akm) || (akm & WPA_KEY_MGMT_WPA_NONE);
109}
110
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800111static inline int wpa_key_mgmt_cckm(int akm)
112{
113 return akm == WPA_KEY_MGMT_CCKM;
114}
115
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700116
117#define WPA_PROTO_WPA BIT(0)
118#define WPA_PROTO_RSN BIT(1)
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800119#define WPA_PROTO_WAPI BIT(2)
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800120#define WPA_PROTO_OSEN BIT(3)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700121
122#define WPA_AUTH_ALG_OPEN BIT(0)
123#define WPA_AUTH_ALG_SHARED BIT(1)
124#define WPA_AUTH_ALG_LEAP BIT(2)
125#define WPA_AUTH_ALG_FT BIT(3)
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800126#define WPA_AUTH_ALG_SAE BIT(4)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700127
128
129enum wpa_alg {
130 WPA_ALG_NONE,
131 WPA_ALG_WEP,
132 WPA_ALG_TKIP,
133 WPA_ALG_CCMP,
134 WPA_ALG_IGTK,
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700135 WPA_ALG_PMK,
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800136 WPA_ALG_GCMP,
137 WPA_ALG_SMS4,
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800138 WPA_ALG_KRK,
139 WPA_ALG_GCMP_256,
140 WPA_ALG_CCMP_256,
141 WPA_ALG_BIP_GMAC_128,
142 WPA_ALG_BIP_GMAC_256,
143 WPA_ALG_BIP_CMAC_256
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700144};
145
146/**
147 * enum wpa_states - wpa_supplicant state
148 *
149 * These enumeration values are used to indicate the current wpa_supplicant
150 * state (wpa_s->wpa_state). The current state can be retrieved with
151 * wpa_supplicant_get_state() function and the state can be changed by calling
152 * wpa_supplicant_set_state(). In WPA state machine (wpa.c and preauth.c), the
153 * wrapper functions wpa_sm_get_state() and wpa_sm_set_state() should be used
154 * to access the state variable.
155 */
156enum wpa_states {
157 /**
158 * WPA_DISCONNECTED - Disconnected state
159 *
160 * This state indicates that client is not associated, but is likely to
161 * start looking for an access point. This state is entered when a
162 * connection is lost.
163 */
164 WPA_DISCONNECTED,
165
166 /**
167 * WPA_INTERFACE_DISABLED - Interface disabled
168 *
169 * This stat eis entered if the network interface is disabled, e.g.,
170 * due to rfkill. wpa_supplicant refuses any new operations that would
171 * use the radio until the interface has been enabled.
172 */
173 WPA_INTERFACE_DISABLED,
174
175 /**
176 * WPA_INACTIVE - Inactive state (wpa_supplicant disabled)
177 *
178 * This state is entered if there are no enabled networks in the
179 * configuration. wpa_supplicant is not trying to associate with a new
180 * network and external interaction (e.g., ctrl_iface call to add or
181 * enable a network) is needed to start association.
182 */
183 WPA_INACTIVE,
184
185 /**
186 * WPA_SCANNING - Scanning for a network
187 *
188 * This state is entered when wpa_supplicant starts scanning for a
189 * network.
190 */
191 WPA_SCANNING,
192
193 /**
194 * WPA_AUTHENTICATING - Trying to authenticate with a BSS/SSID
195 *
196 * This state is entered when wpa_supplicant has found a suitable BSS
197 * to authenticate with and the driver is configured to try to
198 * authenticate with this BSS. This state is used only with drivers
199 * that use wpa_supplicant as the SME.
200 */
201 WPA_AUTHENTICATING,
202
203 /**
204 * WPA_ASSOCIATING - Trying to associate with a BSS/SSID
205 *
206 * This state is entered when wpa_supplicant has found a suitable BSS
207 * to associate with and the driver is configured to try to associate
208 * with this BSS in ap_scan=1 mode. When using ap_scan=2 mode, this
209 * state is entered when the driver is configured to try to associate
210 * with a network using the configured SSID and security policy.
211 */
212 WPA_ASSOCIATING,
213
214 /**
215 * WPA_ASSOCIATED - Association completed
216 *
217 * This state is entered when the driver reports that association has
218 * been successfully completed with an AP. If IEEE 802.1X is used
219 * (with or without WPA/WPA2), wpa_supplicant remains in this state
220 * until the IEEE 802.1X/EAPOL authentication has been completed.
221 */
222 WPA_ASSOCIATED,
223
224 /**
225 * WPA_4WAY_HANDSHAKE - WPA 4-Way Key Handshake in progress
226 *
227 * This state is entered when WPA/WPA2 4-Way Handshake is started. In
228 * case of WPA-PSK, this happens when receiving the first EAPOL-Key
229 * frame after association. In case of WPA-EAP, this state is entered
230 * when the IEEE 802.1X/EAPOL authentication has been completed.
231 */
232 WPA_4WAY_HANDSHAKE,
233
234 /**
235 * WPA_GROUP_HANDSHAKE - WPA Group Key Handshake in progress
236 *
237 * This state is entered when 4-Way Key Handshake has been completed
238 * (i.e., when the supplicant sends out message 4/4) and when Group
239 * Key rekeying is started by the AP (i.e., when supplicant receives
240 * message 1/2).
241 */
242 WPA_GROUP_HANDSHAKE,
243
244 /**
245 * WPA_COMPLETED - All authentication completed
246 *
247 * This state is entered when the full authentication process is
248 * completed. In case of WPA2, this happens when the 4-Way Handshake is
249 * successfully completed. With WPA, this state is entered after the
250 * Group Key Handshake; with IEEE 802.1X (non-WPA) connection is
251 * completed after dynamic keys are received (or if not used, after
252 * the EAP authentication has been completed). With static WEP keys and
253 * plaintext connections, this state is entered when an association
254 * has been completed.
255 *
256 * This state indicates that the supplicant has completed its
257 * processing for the association phase and that data connection is
258 * fully configured.
259 */
260 WPA_COMPLETED
261};
262
263#define MLME_SETPROTECTION_PROTECT_TYPE_NONE 0
264#define MLME_SETPROTECTION_PROTECT_TYPE_RX 1
265#define MLME_SETPROTECTION_PROTECT_TYPE_TX 2
266#define MLME_SETPROTECTION_PROTECT_TYPE_RX_TX 3
267
268#define MLME_SETPROTECTION_KEY_TYPE_GROUP 0
269#define MLME_SETPROTECTION_KEY_TYPE_PAIRWISE 1
270
271
272/**
273 * enum mfp_options - Management frame protection (IEEE 802.11w) options
274 */
275enum mfp_options {
276 NO_MGMT_FRAME_PROTECTION = 0,
277 MGMT_FRAME_PROTECTION_OPTIONAL = 1,
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800278 MGMT_FRAME_PROTECTION_REQUIRED = 2,
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700279};
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800280#define MGMT_FRAME_PROTECTION_DEFAULT 3
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700281
282/**
283 * enum hostapd_hw_mode - Hardware mode
284 */
285enum hostapd_hw_mode {
286 HOSTAPD_MODE_IEEE80211B,
287 HOSTAPD_MODE_IEEE80211G,
288 HOSTAPD_MODE_IEEE80211A,
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -0800289 HOSTAPD_MODE_IEEE80211AD,
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700290 NUM_HOSTAPD_MODES
291};
292
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800293/**
294 * enum wpa_ctrl_req_type - Control interface request types
295 */
296enum wpa_ctrl_req_type {
297 WPA_CTRL_REQ_UNKNOWN,
298 WPA_CTRL_REQ_EAP_IDENTITY,
299 WPA_CTRL_REQ_EAP_PASSWORD,
300 WPA_CTRL_REQ_EAP_NEW_PASSWORD,
301 WPA_CTRL_REQ_EAP_PIN,
302 WPA_CTRL_REQ_EAP_OTP,
303 WPA_CTRL_REQ_EAP_PASSPHRASE,
Dmitry Shmidt051af732013-10-22 13:52:46 -0700304 WPA_CTRL_REQ_SIM,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800305 NUM_WPA_CTRL_REQS
306};
307
308/* Maximum number of EAP methods to store for EAP server user information */
309#define EAP_MAX_METHODS 8
310
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800311/**
312 * enum ht_mode - channel width and offset
313 */
314enum ht_mode {
315 CHAN_UNDEFINED = 0,
316 CHAN_NO_HT,
317 CHAN_HT20,
318 CHAN_HT40PLUS,
319 CHAN_HT40MINUS,
320};
321
322enum mesh_plink_state {
323 PLINK_LISTEN = 1,
324 PLINK_OPEN_SENT,
325 PLINK_OPEN_RCVD,
326 PLINK_CNF_RCVD,
327 PLINK_ESTAB,
328 PLINK_HOLDING,
329 PLINK_BLOCKED,
330};
331
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700332#endif /* DEFS_H */