1 /*
2 * WPA Supplicant - Common definitions
3 * Copyright (c) 2004-2015, Jouni Malinen <j@w1.fi>
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
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
18 typedef enum { FALSE = 0, TRUE = 1 } Boolean;
19
20 #define WPA_CIPHER_NONE BIT(0)
21 #define WPA_CIPHER_WEP40 BIT(7)
22 #define WPA_CIPHER_WEP104 BIT(8)
23 #define WPA_CIPHER_TKIP BIT(1)
24 #define WPA_CIPHER_CCMP BIT(3)
25 #define WPA_CIPHER_AES_128_CMAC BIT(5)
26 #define WPA_CIPHER_SMS4 BIT(10)
27 #define WPA_CIPHER_GCMP BIT(11)
28 #define WPA_CIPHER_GCMP_256 BIT(12)
29 #define WPA_CIPHER_BIP_GMAC_128 BIT(13)
30 #define WPA_CIPHER_BIP_GMAC_256 BIT(14)
31
32 #define WPA_KEY_MGMT_IEEE8021X BIT(0)
33 #define WPA_KEY_MGMT_PSK BIT(1)
34 #define WPA_KEY_MGMT_NONE BIT(2)
35 #define WPA_KEY_MGMT_IEEE8021X_NO_WPA BIT(3)
36 #define WPA_KEY_MGMT_WPA_NONE BIT(4)
37 #define WPA_KEY_MGMT_FT_IEEE8021X BIT(5)
38 #define WPA_KEY_MGMT_FT_PSK BIT(6)
39 #define WPA_KEY_MGMT_IEEE8021X_SHA256 BIT(7)
40 #define WPA_KEY_MGMT_PSK_SHA256 BIT(8)
41 #define WPA_KEY_MGMT_WPS BIT(9)
42 #define WPA_KEY_MGMT_SAE BIT(10)
43 #define WPA_KEY_MGMT_FT_SAE BIT(11)
44 #define WPA_KEY_MGMT_WAPI_PSK BIT(12)
45 #define WPA_KEY_MGMT_WAPI_CERT BIT(13)
46 #define WPA_KEY_MGMT_CCKM BIT(14)
47 #define WPA_KEY_MGMT_OSEN BIT(15)
48 #define WPA_KEY_MGMT_IEEE8021X_SUITE_B BIT(16)
49 #define WPA_KEY_MGMT_IEEE8021X_SUITE_B_192 BIT(17)
50
wpa_key_mgmt_wpa_ieee8021x(int akm)51 static inline int wpa_key_mgmt_wpa_ieee8021x(int akm)
52 {
53 return !!(akm & (WPA_KEY_MGMT_IEEE8021X |
54 WPA_KEY_MGMT_FT_IEEE8021X |
55 WPA_KEY_MGMT_CCKM |
56 WPA_KEY_MGMT_OSEN |
57 WPA_KEY_MGMT_IEEE8021X_SHA256 |
58 WPA_KEY_MGMT_IEEE8021X_SUITE_B |
59 WPA_KEY_MGMT_IEEE8021X_SUITE_B_192));
60 }
61
wpa_key_mgmt_wpa_psk(int akm)62 static inline int wpa_key_mgmt_wpa_psk(int akm)
63 {
64 return !!(akm & (WPA_KEY_MGMT_PSK |
65 WPA_KEY_MGMT_FT_PSK |
66 WPA_KEY_MGMT_PSK_SHA256 |
67 WPA_KEY_MGMT_SAE |
68 WPA_KEY_MGMT_FT_SAE));
69 }
70
wpa_key_mgmt_ft(int akm)71 static inline int wpa_key_mgmt_ft(int akm)
72 {
73 return !!(akm & (WPA_KEY_MGMT_FT_PSK |
74 WPA_KEY_MGMT_FT_IEEE8021X |
75 WPA_KEY_MGMT_FT_SAE));
76 }
77
wpa_key_mgmt_sae(int akm)78 static inline int wpa_key_mgmt_sae(int akm)
79 {
80 return !!(akm & (WPA_KEY_MGMT_SAE |
81 WPA_KEY_MGMT_FT_SAE));
82 }
83
wpa_key_mgmt_sha256(int akm)84 static inline int wpa_key_mgmt_sha256(int akm)
85 {
86 return !!(akm & (WPA_KEY_MGMT_PSK_SHA256 |
87 WPA_KEY_MGMT_IEEE8021X_SHA256 |
88 WPA_KEY_MGMT_OSEN |
89 WPA_KEY_MGMT_SAE |
90 WPA_KEY_MGMT_IEEE8021X_SUITE_B));
91 }
92
wpa_key_mgmt_sha384(int akm)93 static inline int wpa_key_mgmt_sha384(int akm)
94 {
95 return !!(akm & WPA_KEY_MGMT_IEEE8021X_SUITE_B_192);
96 }
97
wpa_key_mgmt_suite_b(int akm)98 static inline int wpa_key_mgmt_suite_b(int akm)
99 {
100 return !!(akm & (WPA_KEY_MGMT_IEEE8021X_SUITE_B |
101 WPA_KEY_MGMT_IEEE8021X_SUITE_B_192));
102 }
103
wpa_key_mgmt_wpa(int akm)104 static inline int wpa_key_mgmt_wpa(int akm)
105 {
106 return wpa_key_mgmt_wpa_ieee8021x(akm) ||
107 wpa_key_mgmt_wpa_psk(akm) ||
108 wpa_key_mgmt_sae(akm);
109 }
110
wpa_key_mgmt_wpa_any(int akm)111 static inline int wpa_key_mgmt_wpa_any(int akm)
112 {
113 return wpa_key_mgmt_wpa(akm) || (akm & WPA_KEY_MGMT_WPA_NONE);
114 }
115
wpa_key_mgmt_cckm(int akm)116 static inline int wpa_key_mgmt_cckm(int akm)
117 {
118 return akm == WPA_KEY_MGMT_CCKM;
119 }
120
121
122 #define WPA_PROTO_WPA BIT(0)
123 #define WPA_PROTO_RSN BIT(1)
124 #define WPA_PROTO_WAPI BIT(2)
125 #define WPA_PROTO_OSEN BIT(3)
126
127 #define WPA_AUTH_ALG_OPEN BIT(0)
128 #define WPA_AUTH_ALG_SHARED BIT(1)
129 #define WPA_AUTH_ALG_LEAP BIT(2)
130 #define WPA_AUTH_ALG_FT BIT(3)
131 #define WPA_AUTH_ALG_SAE BIT(4)
132
133
134 enum wifi_key_alg {
135 ALG_WEP,
136 ALG_TKIP,
137 ALG_CCMP,
138 ALG_AES_CMAC,
139 };
140
141 /**
142 * enum wpa_cipher - Cipher suites
143 */
144 enum wpa_cipher {
145 CIPHER_NONE,
146 CIPHER_WEP40,
147 CIPHER_TKIP,
148 CIPHER_CCMP,
149 CIPHER_WEP104,
150 CIPHER_SMS4,
151 CIPHER_GCMP_256,
152 };
153
154 /**
155 * enum wpa_key_mgmt - Key management suites
156 */
157 enum wpa_key_mgmt {
158 KEY_MGMT_802_1X,
159 KEY_MGMT_PSK,
160 KEY_MGMT_NONE,
161 KEY_MGMT_802_1X_NO_WPA,
162 KEY_MGMT_WPA_NONE,
163 KEY_MGMT_FT_802_1X,
164 KEY_MGMT_FT_PSK,
165 KEY_MGMT_802_1X_SHA256,
166 KEY_MGMT_PSK_SHA256,
167 KEY_MGMT_WPS
168 };
169
170 /**
171 * enum wpa_states - wpa_supplicant state
172 *
173 * These enumeration values are used to indicate the current wpa_supplicant
174 * state (wpa_s->wpa_state). The current state can be retrieved with
175 * wpa_supplicant_get_state() function and the state can be changed by calling
176 * wpa_supplicant_set_state(). In WPA state machine (wpa.c and preauth.c), the
177 * wrapper functions wpa_sm_get_state() and wpa_sm_set_state() should be used
178 * to access the state variable.
179 */
180 enum wpa_states {
181 /**
182 * WPA_DISCONNECTED - Disconnected state
183 *
184 * This state indicates that client is not associated, but is likely to
185 * start looking for an access point. This state is entered when a
186 * connection is lost.
187 */
188 WPA_DISCONNECTED,
189
190 /**
191 * WPA_INTERFACE_DISABLED - Interface disabled
192 *
193 * This state is entered if the network interface is disabled, e.g.,
194 * due to rfkill. wpa_supplicant refuses any new operations that would
195 * use the radio until the interface has been enabled.
196 */
197 WPA_INTERFACE_DISABLED,
198
199 /**
200 * WPA_INACTIVE - Inactive state (wpa_supplicant disabled)
201 *
202 * This state is entered if there are no enabled networks in the
203 * configuration. wpa_supplicant is not trying to associate with a new
204 * network and external interaction (e.g., ctrl_iface call to add or
205 * enable a network) is needed to start association.
206 */
207 WPA_INACTIVE,
208
209 /**
210 * WPA_SCANNING - Scanning for a network
211 *
212 * This state is entered when wpa_supplicant starts scanning for a
213 * network.
214 */
215 WPA_SCANNING,
216
217 /**
218 * WPA_AUTHENTICATING - Trying to authenticate with a BSS/SSID
219 *
220 * This state is entered when wpa_supplicant has found a suitable BSS
221 * to authenticate with and the driver is configured to try to
222 * authenticate with this BSS. This state is used only with drivers
223 * that use wpa_supplicant as the SME.
224 */
225 WPA_AUTHENTICATING,
226
227 /**
228 * WPA_ASSOCIATING - Trying to associate with a BSS/SSID
229 *
230 * This state is entered when wpa_supplicant has found a suitable BSS
231 * to associate with and the driver is configured to try to associate
232 * with this BSS in ap_scan=1 mode. When using ap_scan=2 mode, this
233 * state is entered when the driver is configured to try to associate
234 * with a network using the configured SSID and security policy.
235 */
236 WPA_ASSOCIATING,
237
238 /**
239 * WPA_ASSOCIATED - Association completed
240 *
241 * This state is entered when the driver reports that association has
242 * been successfully completed with an AP. If IEEE 802.1X is used
243 * (with or without WPA/WPA2), wpa_supplicant remains in this state
244 * until the IEEE 802.1X/EAPOL authentication has been completed.
245 */
246 WPA_ASSOCIATED,
247
248 /**
249 * WPA_4WAY_HANDSHAKE - WPA 4-Way Key Handshake in progress
250 *
251 * This state is entered when WPA/WPA2 4-Way Handshake is started. In
252 * case of WPA-PSK, this happens when receiving the first EAPOL-Key
253 * frame after association. In case of WPA-EAP, this state is entered
254 * when the IEEE 802.1X/EAPOL authentication has been completed.
255 */
256 WPA_FIRST_HALF_4WAY_HANDSHAKE,
257
258 WPA_LAST_HALF_4WAY_HANDSHAKE,
259
260 /**
261 * WPA_GROUP_HANDSHAKE - WPA Group Key Handshake in progress
262 *
263 * This state is entered when 4-Way Key Handshake has been completed
264 * (i.e., when the supplicant sends out message 4/4) and when Group
265 * Key rekeying is started by the AP (i.e., when supplicant receives
266 * message 1/2).
267 */
268 WPA_GROUP_HANDSHAKE,
269
270 /**
271 * WPA_COMPLETED - All authentication completed
272 *
273 * This state is entered when the full authentication process is
274 * completed. In case of WPA2, this happens when the 4-Way Handshake is
275 * successfully completed. With WPA, this state is entered after the
276 * Group Key Handshake; with IEEE 802.1X (non-WPA) connection is
277 * completed after dynamic keys are received (or if not used, after
278 * the EAP authentication has been completed). With static WEP keys and
279 * plaintext connections, this state is entered when an association
280 * has been completed.
281 *
282 * This state indicates that the supplicant has completed its
283 * processing for the association phase and that data connection is
284 * fully configured.
285 */
286 WPA_COMPLETED,
287
288 WPA_MIC_FAILURE, // first mic_error event occur
289
290 WPA_TKIP_COUNTERMEASURES //in countermeasure period that stop connect with ap in 60 sec
291 };
292
293 #define MLME_SETPROTECTION_PROTECT_TYPE_NONE 0
294 #define MLME_SETPROTECTION_PROTECT_TYPE_RX 1
295 #define MLME_SETPROTECTION_PROTECT_TYPE_TX 2
296 #define MLME_SETPROTECTION_PROTECT_TYPE_RX_TX 3
297
298 #define MLME_SETPROTECTION_KEY_TYPE_GROUP 0
299 #define MLME_SETPROTECTION_KEY_TYPE_PAIRWISE 1
300
301 /**
302 * enum mfp_options - Management frame protection (IEEE 802.11w) options
303 */
304 enum mfp_options {
305 NO_MGMT_FRAME_PROTECTION = 0,
306 MGMT_FRAME_PROTECTION_OPTIONAL = 1,
307 MGMT_FRAME_PROTECTION_REQUIRED = 2,
308 };
309 #define MGMT_FRAME_PROTECTION_DEFAULT 3
310
311 /**
312 * enum hostapd_hw_mode - Hardware mode
313 */
314 enum hostapd_hw_mode {
315 HOSTAPD_MODE_IEEE80211B,
316 HOSTAPD_MODE_IEEE80211G,
317 HOSTAPD_MODE_IEEE80211A,
318 HOSTAPD_MODE_IEEE80211AD,
319 HOSTAPD_MODE_IEEE80211ANY,
320 NUM_HOSTAPD_MODES
321 };
322
323 /**
324 * enum wpa_ctrl_req_type - Control interface request types
325 */
326 enum wpa_ctrl_req_type {
327 WPA_CTRL_REQ_UNKNOWN,
328 WPA_CTRL_REQ_EAP_IDENTITY,
329 WPA_CTRL_REQ_EAP_PASSWORD,
330 WPA_CTRL_REQ_EAP_NEW_PASSWORD,
331 WPA_CTRL_REQ_EAP_PIN,
332 WPA_CTRL_REQ_EAP_OTP,
333 WPA_CTRL_REQ_EAP_PASSPHRASE,
334 WPA_CTRL_REQ_SIM,
335 WPA_CTRL_REQ_PSK_PASSPHRASE,
336 NUM_WPA_CTRL_REQS
337 };
338
339 /* Maximum number of EAP methods to store for EAP server user information */
340 #define EAP_MAX_METHODS 8
341
342 enum mesh_plink_state {
343 PLINK_LISTEN = 1,
344 PLINK_OPEN_SENT,
345 PLINK_OPEN_RCVD,
346 PLINK_CNF_RCVD,
347 PLINK_ESTAB,
348 PLINK_HOLDING,
349 PLINK_BLOCKED,
350 };
351
352 enum set_band {
353 WPA_SETBAND_AUTO,
354 WPA_SETBAND_5G,
355 WPA_SETBAND_2G
356 };
357
358 #endif /* DEFS_H */
359