Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6.git] / drivers / net / wireless / libertas / assoc.c
index 12a2ef9..aa06070 100644 (file)
@@ -32,6 +32,9 @@ u8 lbs_bg_rates[MAX_RATES] =
 0x00, 0x00 };
 
 
+static int assoc_helper_wep_keys(struct lbs_private *priv,
+               struct assoc_request *assoc_req);
+
 /**
  *  @brief This function finds common rates between rates and card rates.
  *
@@ -611,7 +614,7 @@ static int lbs_assoc_post(struct lbs_private *priv,
 
        if (status_code) {
                lbs_mac_event_disconnected(priv);
-               ret = -1;
+               ret = status_code;
                goto done;
        }
 
@@ -814,7 +817,24 @@ static int lbs_try_associate(struct lbs_private *priv,
                goto out;
 
        ret = lbs_associate(priv, assoc_req, CMD_802_11_ASSOCIATE);
+       /* If the association fails with current auth mode, let's
+        * try by changing the auth mode
+        */
+       if ((priv->authtype_auto) &&
+                       (ret == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) &&
+                       (assoc_req->secinfo.wep_enabled) &&
+                       (priv->connect_status != LBS_CONNECTED)) {
+               if (priv->secinfo.auth_mode == IW_AUTH_ALG_OPEN_SYSTEM)
+                       priv->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
+               else
+                       priv->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
+               if (!assoc_helper_wep_keys(priv, assoc_req))
+                       ret = lbs_associate(priv, assoc_req,
+                                               CMD_802_11_ASSOCIATE);
+       }
 
+       if (ret)
+               ret = -1;
 out:
        lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
        return ret;