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