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