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