[PATCH] libertas: honor specific channel requests during association
authorDan Williams <dcbw@redhat.com>
Sat, 26 May 2007 02:30:48 +0000 (22:30 -0400)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 11 Jun 2007 18:28:43 +0000 (14:28 -0400)
Previously if a fixed channel was specified along with an SSID,
the channel request would be ignored during the association
process.  Instead, when searching for an adhoc or infrastructure
network to join, allow filtering results based on channel so
that the driver doesn't pick a BSS on a different channel than
requested.

Signed-off-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/libertas/assoc.c
drivers/net/wireless/libertas/scan.c
drivers/net/wireless/libertas/scan.h

index afce327..4fcc6a6 100644 (file)
@@ -70,6 +70,7 @@ static int assoc_helper_essid(wlan_private *priv,
        wlan_adapter *adapter = priv->adapter;
        int ret = 0;
        struct bss_descriptor * bss;
+       int channel = -1;
 
        lbs_deb_enter(LBS_DEB_ASSOC);
 
@@ -77,6 +78,9 @@ static int assoc_helper_essid(wlan_private *priv,
         * is set.
         */
 
+       if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags))
+               channel = assoc_req->channel;
+
        lbs_deb_assoc("New SSID requested: %s\n", assoc_req->ssid.ssid);
        if (assoc_req->mode == IW_MODE_INFRA) {
                if (adapter->prescan) {
@@ -84,7 +88,7 @@ static int assoc_helper_essid(wlan_private *priv,
                }
 
                bss = libertas_find_SSID_in_list(adapter, &assoc_req->ssid,
-                               NULL, IW_MODE_INFRA);
+                               NULL, IW_MODE_INFRA, channel);
                if (bss != NULL) {
                        lbs_deb_assoc("SSID found in scan list, associating\n");
                        memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor));
@@ -101,7 +105,7 @@ static int assoc_helper_essid(wlan_private *priv,
 
                /* Search for the requested SSID in the scan table */
                bss = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, NULL,
-                               IW_MODE_ADHOC);
+                               IW_MODE_ADHOC, channel);
                if (bss != NULL) {
                        lbs_deb_assoc("SSID found joining\n");
                        memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor));
index 8aaac5f..83b1612 100644 (file)
@@ -1268,7 +1268,8 @@ struct bss_descriptor * libertas_find_BSSID_in_list(wlan_adapter * adapter,
  *  @return         index in BSSID list
  */
 struct bss_descriptor * libertas_find_SSID_in_list(wlan_adapter * adapter,
-                  struct WLAN_802_11_SSID *ssid, u8 * bssid, u8 mode)
+                  struct WLAN_802_11_SSID *ssid, u8 * bssid, u8 mode,
+                  int channel)
 {
        u8 bestrssi = 0;
        struct bss_descriptor * iter_bss = NULL;
@@ -1286,6 +1287,8 @@ struct bss_descriptor * libertas_find_SSID_in_list(wlan_adapter * adapter,
                        continue; /* ssid doesn't match */
                if (bssid && compare_ether_addr(iter_bss->bssid, bssid) != 0)
                        continue; /* bssid doesn't match */
+               if ((channel > 0) && (iter_bss->channel != channel))
+                       continue; /* channel doesn't match */
 
                switch (mode) {
                case IW_MODE_INFRA:
@@ -1661,7 +1664,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info,
                wlan_scan_networks(priv, NULL, 0);
 
        /* Update RSSI if current BSS is a locally created ad-hoc BSS */
-       if ((adapter->inframode == wlan802_11ibss) && adapter->adhoccreate) {
+       if ((adapter->mode == IW_MODE_ADHOC) && adapter->adhoccreate) {
                libertas_prepare_and_send_command(priv, cmd_802_11_rssi, 0,
                                        cmd_option_waitforrsp, 0, NULL);
        }
index 4ad130f..df7481c 100644 (file)
@@ -178,7 +178,8 @@ extern int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1,
                        struct WLAN_802_11_SSID *ssid2);
 
 struct bss_descriptor * libertas_find_SSID_in_list(wlan_adapter * adapter,
-                       struct WLAN_802_11_SSID *ssid, u8 * bssid, u8 mode);
+                       struct WLAN_802_11_SSID *ssid, u8 * bssid, u8 mode,
+                       int channel);
 
 struct bss_descriptor * libertas_find_best_SSID_in_list(wlan_adapter * adapter,
                        u8 mode);