LCOV - code coverage report
Current view: top level - src/common - defs.h (source / functions) Hit Total Coverage
Test: hostapd hwsim test run 1388338050 Lines: 10 10 100.0 %
Date: 2013-12-29 Functions: 5 5 100.0 %
Branches: 0 0 -

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

Generated by: LCOV version 1.9