blob: d4091e31004edf61ce3b28c95d79df78f4224df3 [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 Shmidt8d520ff2011-05-09 14:06:53 -070052
53static inline int wpa_key_mgmt_wpa_ieee8021x(int akm)
54{
55 return !!(akm & (WPA_KEY_MGMT_IEEE8021X |
56 WPA_KEY_MGMT_FT_IEEE8021X |
Dmitry Shmidtd5e49232012-12-03 15:08:10 -080057 WPA_KEY_MGMT_CCKM |
Dmitry Shmidtf21452a2014-02-26 10:55:25 -080058 WPA_KEY_MGMT_OSEN |
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070059 WPA_KEY_MGMT_IEEE8021X_SHA256));
60}
61
62static inline int wpa_key_mgmt_wpa_psk(int akm)
63{
64 return !!(akm & (WPA_KEY_MGMT_PSK |
65 WPA_KEY_MGMT_FT_PSK |
Dmitry Shmidtd5e49232012-12-03 15:08:10 -080066 WPA_KEY_MGMT_PSK_SHA256 |
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -080067 WPA_KEY_MGMT_SAE |
68 WPA_KEY_MGMT_FT_SAE));
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070069}
70
71static inline int wpa_key_mgmt_ft(int akm)
72{
73 return !!(akm & (WPA_KEY_MGMT_FT_PSK |
Dmitry Shmidtd5e49232012-12-03 15:08:10 -080074 WPA_KEY_MGMT_FT_IEEE8021X |
75 WPA_KEY_MGMT_FT_SAE));
76}
77
78static inline int wpa_key_mgmt_sae(int akm)
79{
80 return !!(akm & (WPA_KEY_MGMT_SAE |
81 WPA_KEY_MGMT_FT_SAE));
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070082}
83
84static inline int wpa_key_mgmt_sha256(int akm)
85{
86 return !!(akm & (WPA_KEY_MGMT_PSK_SHA256 |
Dmitry Shmidtf21452a2014-02-26 10:55:25 -080087 WPA_KEY_MGMT_IEEE8021X_SHA256 |
88 WPA_KEY_MGMT_OSEN));
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070089}
90
91static inline int wpa_key_mgmt_wpa(int akm)
92{
93 return wpa_key_mgmt_wpa_ieee8021x(akm) ||
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -080094 wpa_key_mgmt_wpa_psk(akm) ||
95 wpa_key_mgmt_sae(akm);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070096}
97
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080098static inline int wpa_key_mgmt_wpa_any(int akm)
99{
100 return wpa_key_mgmt_wpa(akm) || (akm & WPA_KEY_MGMT_WPA_NONE);
101}
102
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800103static inline int wpa_key_mgmt_cckm(int akm)
104{
105 return akm == WPA_KEY_MGMT_CCKM;
106}
107
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700108
109#define WPA_PROTO_WPA BIT(0)
110#define WPA_PROTO_RSN BIT(1)
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800111#define WPA_PROTO_WAPI BIT(2)
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800112#define WPA_PROTO_OSEN BIT(3)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700113
114#define WPA_AUTH_ALG_OPEN BIT(0)
115#define WPA_AUTH_ALG_SHARED BIT(1)
116#define WPA_AUTH_ALG_LEAP BIT(2)
117#define WPA_AUTH_ALG_FT BIT(3)
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800118#define WPA_AUTH_ALG_SAE BIT(4)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700119
120
121enum wpa_alg {
122 WPA_ALG_NONE,
123 WPA_ALG_WEP,
124 WPA_ALG_TKIP,
125 WPA_ALG_CCMP,
126 WPA_ALG_IGTK,
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700127 WPA_ALG_PMK,
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800128 WPA_ALG_GCMP,
129 WPA_ALG_SMS4,
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800130 WPA_ALG_KRK,
131 WPA_ALG_GCMP_256,
132 WPA_ALG_CCMP_256,
133 WPA_ALG_BIP_GMAC_128,
134 WPA_ALG_BIP_GMAC_256,
135 WPA_ALG_BIP_CMAC_256
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700136};
137
138/**
139 * enum wpa_states - wpa_supplicant state
140 *
141 * These enumeration values are used to indicate the current wpa_supplicant
142 * state (wpa_s->wpa_state). The current state can be retrieved with
143 * wpa_supplicant_get_state() function and the state can be changed by calling
144 * wpa_supplicant_set_state(). In WPA state machine (wpa.c and preauth.c), the
145 * wrapper functions wpa_sm_get_state() and wpa_sm_set_state() should be used
146 * to access the state variable.
147 */
148enum wpa_states {
149 /**
150 * WPA_DISCONNECTED - Disconnected state
151 *
152 * This state indicates that client is not associated, but is likely to
153 * start looking for an access point. This state is entered when a
154 * connection is lost.
155 */
156 WPA_DISCONNECTED,
157
158 /**
159 * WPA_INTERFACE_DISABLED - Interface disabled
160 *
161 * This stat eis entered if the network interface is disabled, e.g.,
162 * due to rfkill. wpa_supplicant refuses any new operations that would
163 * use the radio until the interface has been enabled.
164 */
165 WPA_INTERFACE_DISABLED,
166
167 /**
168 * WPA_INACTIVE - Inactive state (wpa_supplicant disabled)
169 *
170 * This state is entered if there are no enabled networks in the
171 * configuration. wpa_supplicant is not trying to associate with a new
172 * network and external interaction (e.g., ctrl_iface call to add or
173 * enable a network) is needed to start association.
174 */
175 WPA_INACTIVE,
176
177 /**
178 * WPA_SCANNING - Scanning for a network
179 *
180 * This state is entered when wpa_supplicant starts scanning for a
181 * network.
182 */
183 WPA_SCANNING,
184
185 /**
186 * WPA_AUTHENTICATING - Trying to authenticate with a BSS/SSID
187 *
188 * This state is entered when wpa_supplicant has found a suitable BSS
189 * to authenticate with and the driver is configured to try to
190 * authenticate with this BSS. This state is used only with drivers
191 * that use wpa_supplicant as the SME.
192 */
193 WPA_AUTHENTICATING,
194
195 /**
196 * WPA_ASSOCIATING - Trying to associate with a BSS/SSID
197 *
198 * This state is entered when wpa_supplicant has found a suitable BSS
199 * to associate with and the driver is configured to try to associate
200 * with this BSS in ap_scan=1 mode. When using ap_scan=2 mode, this
201 * state is entered when the driver is configured to try to associate
202 * with a network using the configured SSID and security policy.
203 */
204 WPA_ASSOCIATING,
205
206 /**
207 * WPA_ASSOCIATED - Association completed
208 *
209 * This state is entered when the driver reports that association has
210 * been successfully completed with an AP. If IEEE 802.1X is used
211 * (with or without WPA/WPA2), wpa_supplicant remains in this state
212 * until the IEEE 802.1X/EAPOL authentication has been completed.
213 */
214 WPA_ASSOCIATED,
215
216 /**
217 * WPA_4WAY_HANDSHAKE - WPA 4-Way Key Handshake in progress
218 *
219 * This state is entered when WPA/WPA2 4-Way Handshake is started. In
220 * case of WPA-PSK, this happens when receiving the first EAPOL-Key
221 * frame after association. In case of WPA-EAP, this state is entered
222 * when the IEEE 802.1X/EAPOL authentication has been completed.
223 */
224 WPA_4WAY_HANDSHAKE,
225
226 /**
227 * WPA_GROUP_HANDSHAKE - WPA Group Key Handshake in progress
228 *
229 * This state is entered when 4-Way Key Handshake has been completed
230 * (i.e., when the supplicant sends out message 4/4) and when Group
231 * Key rekeying is started by the AP (i.e., when supplicant receives
232 * message 1/2).
233 */
234 WPA_GROUP_HANDSHAKE,
235
236 /**
237 * WPA_COMPLETED - All authentication completed
238 *
239 * This state is entered when the full authentication process is
240 * completed. In case of WPA2, this happens when the 4-Way Handshake is
241 * successfully completed. With WPA, this state is entered after the
242 * Group Key Handshake; with IEEE 802.1X (non-WPA) connection is
243 * completed after dynamic keys are received (or if not used, after
244 * the EAP authentication has been completed). With static WEP keys and
245 * plaintext connections, this state is entered when an association
246 * has been completed.
247 *
248 * This state indicates that the supplicant has completed its
249 * processing for the association phase and that data connection is
250 * fully configured.
251 */
252 WPA_COMPLETED
253};
254
255#define MLME_SETPROTECTION_PROTECT_TYPE_NONE 0
256#define MLME_SETPROTECTION_PROTECT_TYPE_RX 1
257#define MLME_SETPROTECTION_PROTECT_TYPE_TX 2
258#define MLME_SETPROTECTION_PROTECT_TYPE_RX_TX 3
259
260#define MLME_SETPROTECTION_KEY_TYPE_GROUP 0
261#define MLME_SETPROTECTION_KEY_TYPE_PAIRWISE 1
262
263
264/**
265 * enum mfp_options - Management frame protection (IEEE 802.11w) options
266 */
267enum mfp_options {
268 NO_MGMT_FRAME_PROTECTION = 0,
269 MGMT_FRAME_PROTECTION_OPTIONAL = 1,
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800270 MGMT_FRAME_PROTECTION_REQUIRED = 2,
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700271};
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800272#define MGMT_FRAME_PROTECTION_DEFAULT 3
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700273
274/**
275 * enum hostapd_hw_mode - Hardware mode
276 */
277enum hostapd_hw_mode {
278 HOSTAPD_MODE_IEEE80211B,
279 HOSTAPD_MODE_IEEE80211G,
280 HOSTAPD_MODE_IEEE80211A,
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -0800281 HOSTAPD_MODE_IEEE80211AD,
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700282 NUM_HOSTAPD_MODES
283};
284
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800285/**
286 * enum wpa_ctrl_req_type - Control interface request types
287 */
288enum wpa_ctrl_req_type {
289 WPA_CTRL_REQ_UNKNOWN,
290 WPA_CTRL_REQ_EAP_IDENTITY,
291 WPA_CTRL_REQ_EAP_PASSWORD,
292 WPA_CTRL_REQ_EAP_NEW_PASSWORD,
293 WPA_CTRL_REQ_EAP_PIN,
294 WPA_CTRL_REQ_EAP_OTP,
295 WPA_CTRL_REQ_EAP_PASSPHRASE,
Dmitry Shmidt051af732013-10-22 13:52:46 -0700296 WPA_CTRL_REQ_SIM,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800297 NUM_WPA_CTRL_REQS
298};
299
300/* Maximum number of EAP methods to store for EAP server user information */
301#define EAP_MAX_METHODS 8
302
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700303#endif /* DEFS_H */