]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
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 c8aee31bafd030ce62a7c7cda8098c3d0c709ca2..1483ae3ee15e4e9de47c0529c8d37b3b2dc51913 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 d5f3bbfede3ea4cd55edbc47d531c639b3f83b27..a8e9b769db27546ffe57952984bc04cd1cfe4fb2 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 276588cc9f3cf881c4e6d19270578b314048397f..317238b153da8c63a26888d3cf20ab34a5207f36 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 4faec83ceaaa7d224e0091d6d28dacdfb5313e1f..6b731f6735c6aecfb65362107b7167beed909030 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 beda6d0d6d6691e8b6e6e6c03893f91540ac8081..77984f9e5c4cc6bca62b8661b0d3345a5298dbe6 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 31b32b5da3dd0aae949620a641dda2e03ec7eaf1..f16b0121533dfec57a63406bdcb8a6571fdfc11b 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 8d5fe36333a6273a57aa18c026cc3ec0c03cdd0e..999f43e950b04062119abe4709b0f455bf667b14 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 89acdaeadaed104654da20eaa570a4fd9c438308..15700e4fde14ec85149274f1a2e27bdf82d1e88f 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 6eebdd667817868faaeece81a0bcc7c5206e6559..7b46772478e04446f3ea61211215bee9bd0ee22f 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 210e29bcf180b0852155e99cb22f12769c2319c7..0fc1c549235a82d45777209de48ee3dc38642616 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 e1cf415025ac4006d1d08a79efe7d500d7a14b7b..51db9ef6b818d9367fa56da68b92d4000a4454a6 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 8339ad54628b6c6662061eb5bd22abd98b23551a..24f94a56edddd35caddc7b7ae19a45b96f0759b6 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 ae640a9e8c43b2ab4bfc1349aab5d10154f36677..dff8a10b012efce6d45790e1fdf7a563dea1b1fa 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 936684c43c390261e5152c4ead5df804e50daca1..c96fd3b7020b181006297207b3255bad3b271116 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;