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