Standardize on a single definition of auth_alg bitfield values
authorJouni Malinen <j@w1.fi>
Sun, 3 Jan 2010 19:14:40 +0000 (21:14 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 3 Jan 2010 19:14:40 +0000 (21:14 +0200)
14 files changed:
src/common/defs.h
src/drivers/driver.h
src/drivers/driver_bsd.c
src/drivers/driver_hostap.c
src/drivers/driver_ipw.c
src/drivers/driver_madwifi.c
src/drivers/driver_ndis.c
src/drivers/driver_nl80211.c
src/drivers/driver_ralink.c
src/drivers/driver_wext.c
wpa_supplicant/mlme.c
wpa_supplicant/sme.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index c8aee31..1483ae3 100644 (file)
@@ -77,6 +77,7 @@ static inline int wpa_key_mgmt_sha256(int akm)
 #define WPA_AUTH_ALG_OPEN BIT(0)
 #define WPA_AUTH_ALG_SHARED BIT(1)
 #define WPA_AUTH_ALG_LEAP BIT(2)
+#define WPA_AUTH_ALG_FT BIT(2)
 
 
 enum wpa_alg {
index d5f3bbf..a8e9b76 100644 (file)
@@ -103,11 +103,6 @@ struct hostapd_hw_modes {
 };
 
 
-#define AUTH_ALG_OPEN_SYSTEM   0x01
-#define AUTH_ALG_SHARED_KEY    0x02
-#define AUTH_ALG_LEAP          0x04
-#define AUTH_ALG_FT            0x08
-
 #define IEEE80211_MODE_INFRA   0
 #define IEEE80211_MODE_IBSS    1
 #define IEEE80211_MODE_AP      2
@@ -329,7 +324,7 @@ struct wpa_driver_associate_params {
 
        /**
         * auth_alg - Allowed authentication algorithms
-        * Bit field of AUTH_ALG_*
+        * Bit field of WPA_AUTH_ALG_*
         */
        int auth_alg;
 
index 276588c..317238b 100644 (file)
@@ -1148,10 +1148,10 @@ wpa_driver_bsd_set_auth_alg(void *priv, int auth_alg)
        struct wpa_driver_bsd_data *drv = priv;
        int authmode;
 
-       if ((auth_alg & AUTH_ALG_OPEN_SYSTEM) &&
-           (auth_alg & AUTH_ALG_SHARED_KEY))
+       if ((auth_alg & WPA_AUTH_ALG_OPEN) &&
+           (auth_alg & WPA_AUTH_ALG_SHARED))
                authmode = IEEE80211_AUTH_AUTO;
-       else if (auth_alg & AUTH_ALG_SHARED_KEY)
+       else if (auth_alg & WPA_AUTH_ALG_SHARED)
                authmode = IEEE80211_AUTH_SHARED;
        else
                authmode = IEEE80211_AUTH_OPEN;
index 4faec83..6b731f6 100644 (file)
@@ -1533,11 +1533,11 @@ static int wpa_driver_hostap_set_auth_alg(void *priv, int auth_alg)
        struct wpa_driver_hostap_data *drv = priv;
        int algs = 0;
 
-       if (auth_alg & AUTH_ALG_OPEN_SYSTEM)
+       if (auth_alg & WPA_AUTH_ALG_OPEN)
                algs |= 1;
-       if (auth_alg & AUTH_ALG_SHARED_KEY)
+       if (auth_alg & WPA_AUTH_ALG_SHARED)
                algs |= 2;
-       if (auth_alg & AUTH_ALG_LEAP)
+       if (auth_alg & WPA_AUTH_ALG_LEAP)
                algs |= 4;
        if (algs == 0)
                algs = 1; /* at least one algorithm should be set */
index beda6d0..77984f9 100644 (file)
@@ -355,11 +355,11 @@ static int wpa_driver_ipw_set_auth_alg(void *priv, int auth_alg)
        struct wpa_driver_ipw_data *drv = priv;
        int algs = 0;
 
-       if (auth_alg & AUTH_ALG_OPEN_SYSTEM)
+       if (auth_alg & WPA_AUTH_ALG_OPEN)
                algs |= 1;
-       if (auth_alg & AUTH_ALG_SHARED_KEY)
+       if (auth_alg & WPA_AUTH_ALG_SHARED)
                algs |= 2;
-       if (auth_alg & AUTH_ALG_LEAP)
+       if (auth_alg & WPA_AUTH_ALG_LEAP)
                algs |= 4;
        if (algs == 0)
                algs = 1; /* at least one algorithm should be set */
index 31b32b5..f16b012 100644 (file)
@@ -1662,10 +1662,10 @@ wpa_driver_madwifi_set_auth_alg(void *priv, int auth_alg)
        struct wpa_driver_madwifi_data *drv = priv;
        int authmode;
 
-       if ((auth_alg & AUTH_ALG_OPEN_SYSTEM) &&
-           (auth_alg & AUTH_ALG_SHARED_KEY))
+       if ((auth_alg & WPA_AUTH_ALG_OPEN) &&
+           (auth_alg & WPA_AUTH_ALG_SHARED))
                authmode = IEEE80211_AUTH_AUTO;
-       else if (auth_alg & AUTH_ALG_SHARED_KEY)
+       else if (auth_alg & WPA_AUTH_ALG_SHARED)
                authmode = IEEE80211_AUTH_SHARED;
        else
                authmode = IEEE80211_AUTH_OPEN;
index 8d5fe36..999f43e 100644 (file)
@@ -1107,8 +1107,8 @@ wpa_driver_ndis_associate(void *priv,
        }
 
        if (params->wpa_ie == NULL || params->wpa_ie_len == 0) {
-               if (params->auth_alg & AUTH_ALG_SHARED_KEY) {
-                       if (params->auth_alg & AUTH_ALG_OPEN_SYSTEM)
+               if (params->auth_alg & WPA_AUTH_ALG_SHARED) {
+                       if (params->auth_alg & WPA_AUTH_ALG_OPEN)
                                auth_mode = Ndis802_11AuthModeAutoSwitch;
                        else
                                auth_mode = Ndis802_11AuthModeShared;
index 89acdae..15700e4 100644 (file)
@@ -2089,13 +2089,13 @@ retry:
         * TODO: if multiple auth_alg options enabled, try them one by one if
         * the AP rejects authentication due to unknown auth alg
         */
-       if (params->auth_alg & AUTH_ALG_OPEN_SYSTEM)
+       if (params->auth_alg & WPA_AUTH_ALG_OPEN)
                type = NL80211_AUTHTYPE_OPEN_SYSTEM;
-       else if (params->auth_alg & AUTH_ALG_SHARED_KEY)
+       else if (params->auth_alg & WPA_AUTH_ALG_SHARED)
                type = NL80211_AUTHTYPE_SHARED_KEY;
-       else if (params->auth_alg & AUTH_ALG_LEAP)
+       else if (params->auth_alg & WPA_AUTH_ALG_LEAP)
                type = NL80211_AUTHTYPE_NETWORK_EAP;
-       else if (params->auth_alg & AUTH_ALG_FT)
+       else if (params->auth_alg & WPA_AUTH_ALG_FT)
                type = NL80211_AUTHTYPE_FT;
        else
                goto nla_put_failure;
@@ -3427,13 +3427,13 @@ static int wpa_driver_nl80211_connect(
                NLA_PUT(msg, NL80211_ATTR_IE, params->wpa_ie_len,
                        params->wpa_ie);
 
-       if (params->auth_alg & AUTH_ALG_OPEN_SYSTEM)
+       if (params->auth_alg & WPA_AUTH_ALG_OPEN)
                type = NL80211_AUTHTYPE_OPEN_SYSTEM;
-       else if (params->auth_alg & AUTH_ALG_SHARED_KEY)
+       else if (params->auth_alg & WPA_AUTH_ALG_SHARED)
                type = NL80211_AUTHTYPE_SHARED_KEY;
-       else if (params->auth_alg & AUTH_ALG_LEAP)
+       else if (params->auth_alg & WPA_AUTH_ALG_LEAP)
                type = NL80211_AUTHTYPE_NETWORK_EAP;
-       else if (params->auth_alg & AUTH_ALG_FT)
+       else if (params->auth_alg & WPA_AUTH_ALG_FT)
                type = NL80211_AUTHTYPE_FT;
        else
                goto nla_put_failure;
index 6eebdd6..7b46772 100644 (file)
@@ -1406,8 +1406,8 @@ wpa_driver_ralink_associate(void *priv,
 #endif /* CONFIG_WPS */
 
                if (params->wpa_ie == NULL || params->wpa_ie_len == 0) {
-                       if (params->auth_alg & AUTH_ALG_SHARED_KEY) {
-                               if (params->auth_alg & AUTH_ALG_OPEN_SYSTEM)
+                       if (params->auth_alg & WPA_AUTH_ALG_SHARED) {
+                               if (params->auth_alg & WPA_AUTH_ALG_OPEN)
                                        auth_mode = Ndis802_11AuthModeAutoSwitch;
                                else
                                        auth_mode = Ndis802_11AuthModeShared;
index 210e29b..0fc1c54 100644 (file)
@@ -1907,9 +1907,9 @@ wpa_driver_wext_auth_alg_fallback(struct wpa_driver_wext_data *drv,
        if (!drv->use_crypt) {
                iwr.u.encoding.flags |= IW_ENCODE_DISABLED;
        } else {
-               if (params->auth_alg & AUTH_ALG_OPEN_SYSTEM)
+               if (params->auth_alg & WPA_AUTH_ALG_OPEN)
                        iwr.u.encoding.flags |= IW_ENCODE_OPEN;
-               if (params->auth_alg & AUTH_ALG_SHARED_KEY)
+               if (params->auth_alg & WPA_AUTH_ALG_SHARED)
                        iwr.u.encoding.flags |= IW_ENCODE_RESTRICTED;
        }
 
@@ -2034,11 +2034,11 @@ static int wpa_driver_wext_set_auth_alg(void *priv, int auth_alg)
        struct wpa_driver_wext_data *drv = priv;
        int algs = 0, res;
 
-       if (auth_alg & AUTH_ALG_OPEN_SYSTEM)
+       if (auth_alg & WPA_AUTH_ALG_OPEN)
                algs |= IW_AUTH_ALG_OPEN_SYSTEM;
-       if (auth_alg & AUTH_ALG_SHARED_KEY)
+       if (auth_alg & WPA_AUTH_ALG_SHARED)
                algs |= IW_AUTH_ALG_SHARED_KEY;
-       if (auth_alg & AUTH_ALG_LEAP)
+       if (auth_alg & WPA_AUTH_ALG_LEAP)
                algs |= IW_AUTH_ALG_LEAP;
        if (algs == 0) {
                /* at least one algorithm should be set */
index e1cf415..51db9ef 100644 (file)
@@ -827,12 +827,11 @@ static void ieee80211_rx_mgmt_auth(struct wpa_supplicant *wpa_s,
                        u8 algs[num_algs];
                        int i, pos;
                        algs[0] = algs[1] = algs[2] = 0xff;
-                       if (wpa_s->mlme.auth_algs & IEEE80211_AUTH_ALG_OPEN)
+                       if (wpa_s->mlme.auth_algs & WPA_AUTH_ALG_OPEN)
                                algs[0] = WLAN_AUTH_OPEN;
-                       if (wpa_s->mlme.auth_algs &
-                           IEEE80211_AUTH_ALG_SHARED_KEY)
+                       if (wpa_s->mlme.auth_algs & WPA_AUTH_ALG_SHARED)
                                algs[1] = WLAN_AUTH_SHARED_KEY;
-                       if (wpa_s->mlme.auth_algs & IEEE80211_AUTH_ALG_LEAP)
+                       if (wpa_s->mlme.auth_algs & WPA_AUTH_ALG_LEAP)
                                algs[2] = WLAN_AUTH_LEAP;
                        if (wpa_s->mlme.auth_alg == WLAN_AUTH_OPEN)
                                pos = 0;
@@ -2206,11 +2205,11 @@ static void ieee80211_sta_new_auth(struct wpa_supplicant *wpa_s)
        wpa_s->mlme.wmm_last_param_set = -1; /* allow any WMM update */
 
 
-       if (wpa_s->mlme.auth_algs & IEEE80211_AUTH_ALG_OPEN)
+       if (wpa_s->mlme.auth_algs & WPA_AUTH_ALG_OPEN)
                wpa_s->mlme.auth_alg = WLAN_AUTH_OPEN;
-       else if (wpa_s->mlme.auth_algs & IEEE80211_AUTH_ALG_SHARED_KEY)
+       else if (wpa_s->mlme.auth_algs & WPA_AUTH_ALG_SHARED)
                wpa_s->mlme.auth_alg = WLAN_AUTH_SHARED_KEY;
-       else if (wpa_s->mlme.auth_algs & IEEE80211_AUTH_ALG_LEAP)
+       else if (wpa_s->mlme.auth_algs & WPA_AUTH_ALG_LEAP)
                wpa_s->mlme.auth_alg = WLAN_AUTH_LEAP;
        else
                wpa_s->mlme.auth_alg = WLAN_AUTH_OPEN;
index 8339ad5..24f94a5 100644 (file)
@@ -68,27 +68,21 @@ void sme_authenticate(struct wpa_supplicant *wpa_s,
        os_memcpy(wpa_s->sme.ssid, params.ssid, params.ssid_len);
        wpa_s->sme.ssid_len = params.ssid_len;
 
-       params.auth_alg = AUTH_ALG_OPEN_SYSTEM;
+       params.auth_alg = WPA_AUTH_ALG_OPEN;
 #ifdef IEEE8021X_EAPOL
        if (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
                if (ssid->leap) {
                        if (ssid->non_leap == 0)
-                               params.auth_alg = AUTH_ALG_LEAP;
+                               params.auth_alg = WPA_AUTH_ALG_LEAP;
                        else
-                               params.auth_alg |= AUTH_ALG_LEAP;
+                               params.auth_alg |= WPA_AUTH_ALG_LEAP;
                }
        }
 #endif /* IEEE8021X_EAPOL */
        wpa_printf(MSG_DEBUG, "Automatic auth_alg selection: 0x%x",
                   params.auth_alg);
        if (ssid->auth_alg) {
-               params.auth_alg = 0;
-               if (ssid->auth_alg & WPA_AUTH_ALG_OPEN)
-                       params.auth_alg |= AUTH_ALG_OPEN_SYSTEM;
-               if (ssid->auth_alg & WPA_AUTH_ALG_SHARED)
-                       params.auth_alg |= AUTH_ALG_SHARED_KEY;
-               if (ssid->auth_alg & WPA_AUTH_ALG_LEAP)
-                       params.auth_alg |= AUTH_ALG_LEAP;
+               params.auth_alg = ssid->auth_alg;
                wpa_printf(MSG_DEBUG, "Overriding auth_alg selection: 0x%x",
                           params.auth_alg);
        }
@@ -191,7 +185,7 @@ void sme_authenticate(struct wpa_supplicant *wpa_s,
                    os_memcmp(md, wpa_s->sme.mobility_domain, 2) == 0) {
                        wpa_printf(MSG_DEBUG, "SME: Trying to use FT "
                                   "over-the-air");
-                       params.auth_alg = AUTH_ALG_FT;
+                       params.auth_alg = WPA_AUTH_ALG_FT;
                        params.ie = wpa_s->sme.ft_ies;
                        params.ie_len = wpa_s->sme.ft_ies_len;
                }
index ae640a9..dff8a10 100644 (file)
@@ -983,7 +983,7 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
        u8 wpa_ie[80];
        size_t wpa_ie_len;
        int use_crypt, ret, i, bssid_changed;
-       int algs = AUTH_ALG_OPEN_SYSTEM;
+       int algs = WPA_AUTH_ALG_OPEN;
        enum wpa_cipher cipher_pairwise, cipher_group;
        struct wpa_driver_associate_params params;
        int wep_keys_set = 0;
@@ -1062,21 +1062,15 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
        if (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
                if (ssid->leap) {
                        if (ssid->non_leap == 0)
-                               algs = AUTH_ALG_LEAP;
+                               algs = WPA_AUTH_ALG_LEAP;
                        else
-                               algs |= AUTH_ALG_LEAP;
+                               algs |= WPA_AUTH_ALG_LEAP;
                }
        }
 #endif /* IEEE8021X_EAPOL */
        wpa_printf(MSG_DEBUG, "Automatic auth_alg selection: 0x%x", algs);
        if (ssid->auth_alg) {
-               algs = 0;
-               if (ssid->auth_alg & WPA_AUTH_ALG_OPEN)
-                       algs |= AUTH_ALG_OPEN_SYSTEM;
-               if (ssid->auth_alg & WPA_AUTH_ALG_SHARED)
-                       algs |= AUTH_ALG_SHARED_KEY;
-               if (ssid->auth_alg & WPA_AUTH_ALG_LEAP)
-                       algs |= AUTH_ALG_LEAP;
+               algs = ssid->auth_alg;
                wpa_printf(MSG_DEBUG, "Overriding auth_alg selection: 0x%x",
                           algs);
        }
index 936684c..c96fd3b 100644 (file)
@@ -234,10 +234,8 @@ struct wpa_client_mlme {
 
        struct os_time last_probe;
 
-#define IEEE80211_AUTH_ALG_OPEN BIT(0)
-#define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
-#define IEEE80211_AUTH_ALG_LEAP BIT(2)
-       unsigned int auth_algs; /* bitfield of allowed auth algs */
+       unsigned int auth_algs; /* bitfield of allowed auth algs
+                                * (WPA_AUTH_ALG_*) */
        int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
        int auth_transaction;