]> err.no Git - linux-2.6/blobdiff - net/ieee80211/softmac/ieee80211softmac_assoc.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/pci-2.6
[linux-2.6] / net / ieee80211 / softmac / ieee80211softmac_assoc.c
index 01f21334767cc950f7c488b79813f9ef911c635e..5e9a90651d04f5433225357dad60ac5c396218d2 100644 (file)
@@ -96,6 +96,7 @@ ieee80211softmac_disassoc(struct ieee80211softmac_device *mac)
        mac->associated = 0;
        mac->associnfo.bssvalid = 0;
        mac->associnfo.associating = 0;
+       ieee80211softmac_init_txrates(mac);
        ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_DISASSOCIATED, NULL);
        spin_unlock_irqrestore(&mac->lock, flags);
 }
@@ -118,24 +119,15 @@ ieee80211softmac_send_disassoc_req(struct ieee80211softmac_device *mac, u16 reas
 static inline int
 we_support_all_basic_rates(struct ieee80211softmac_device *mac, u8 *from, u8 from_len)
 {
-       int idx, search, found;
-       u8 rate, search_rate;
+       int idx;
+       u8 rate;
 
        for (idx = 0; idx < (from_len); idx++) {
                rate = (from)[idx];
                if (!(rate & IEEE80211_BASIC_RATE_MASK))
                        continue;
-               found = 0;
                rate &= ~IEEE80211_BASIC_RATE_MASK;
-               for (search = 0; search < mac->ratesinfo.count; search++) {
-                       search_rate = mac->ratesinfo.rates[search];
-                       search_rate &= ~IEEE80211_BASIC_RATE_MASK;
-                       if (rate == search_rate) {
-                               found = 1;
-                               break;
-                       }
-               }
-               if (!found)
+               if (!ieee80211softmac_ratesinfo_rate_supported(&mac->ratesinfo, rate))
                        return 0;
        }
        return 1;
@@ -172,12 +164,28 @@ network_matches_request(struct ieee80211softmac_device *mac, struct ieee80211_ne
 }
 
 static void
-ieee80211softmac_assoc_notify(struct net_device *dev, void *context)
+ieee80211softmac_assoc_notify_scan(struct net_device *dev, int event_type, void *context)
 {
        struct ieee80211softmac_device *mac = ieee80211_priv(dev);
        ieee80211softmac_assoc_work((void*)mac);
 }
 
+static void
+ieee80211softmac_assoc_notify_auth(struct net_device *dev, int event_type, void *context)
+{
+       struct ieee80211softmac_device *mac = ieee80211_priv(dev);
+
+       switch (event_type) {
+       case IEEE80211SOFTMAC_EVENT_AUTHENTICATED:
+               ieee80211softmac_assoc_work((void*)mac);
+               break;
+       case IEEE80211SOFTMAC_EVENT_AUTH_FAILED:
+       case IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT:
+               ieee80211softmac_disassoc(mac);
+               break;
+       }
+}
+
 /* This function is called to handle userspace requests (asynchronously) */
 void
 ieee80211softmac_assoc_work(void *d)
@@ -257,7 +265,7 @@ ieee80211softmac_assoc_work(void *d)
                         * Maybe we can hope to have more memory after scanning finishes ;)
                         */
                        dprintk(KERN_INFO PFX "Associate: Scanning for networks first.\n");
-                       ieee80211softmac_notify(mac->dev, IEEE80211SOFTMAC_EVENT_SCAN_FINISHED, ieee80211softmac_assoc_notify, NULL);
+                       ieee80211softmac_notify(mac->dev, IEEE80211SOFTMAC_EVENT_SCAN_FINISHED, ieee80211softmac_assoc_notify_scan, NULL);
                        if (ieee80211softmac_start_scan(mac))
                                dprintk(KERN_INFO PFX "Associate: failed to initiate scan. Is device up?\n");
                        return;
@@ -292,7 +300,7 @@ ieee80211softmac_assoc_work(void *d)
                 * otherwise adding the notification would be racy. */
                if (!ieee80211softmac_auth_req(mac, found)) {
                        dprintk(KERN_INFO PFX "cannot associate without being authenticated, requested authentication\n");
-                       ieee80211softmac_notify_internal(mac, IEEE80211SOFTMAC_EVENT_ANY, found, ieee80211softmac_assoc_notify, NULL, GFP_KERNEL);
+                       ieee80211softmac_notify_internal(mac, IEEE80211SOFTMAC_EVENT_ANY, found, ieee80211softmac_assoc_notify_auth, NULL, GFP_KERNEL);
                } else {
                        printkl(KERN_WARNING PFX "Not authenticated, but requesting authentication failed. Giving up to associate\n");
                        ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, found);
@@ -310,6 +318,9 @@ ieee80211softmac_associated(struct ieee80211softmac_device *mac,
        struct ieee80211softmac_network *net)
 {
        mac->associnfo.associating = 0;
+       mac->associnfo.supported_rates = net->supported_rates;
+       ieee80211softmac_recalc_txrates(mac);
+
        mac->associated = 1;
        if (mac->set_bssid_filter)
                mac->set_bssid_filter(mac->dev, net->bssid);