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