cfg80211: send events for userspace SME
authorJohannes Berg <johannes@sipsolutions.net>
Thu, 2 Jul 2009 07:58:04 +0000 (09:58 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 10 Jul 2009 19:01:53 +0000 (15:01 -0400)
When the userspace SME is in control, we are currently not sending
events, but this means that any userspace applications using wext
or nl80211 to receive events will not know what's going on unless
they can also interpret the nl80211 assoc event. Since we have all
the required code, let the SME follow events from the userspace
SME, this even means that you will be refused to connect() while
the userspace SME is in control and connected.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/wireless/sme.c

index f272ebf94303bf9e2174faed9d96d79ae24a05ed..d4e0b4065cbc4d76f534d984b87db7601061a2eb 100644 (file)
@@ -287,6 +287,44 @@ static void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
        if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION))
                return;
 
+       if (wdev->sme_state == CFG80211_SME_CONNECTED)
+               nl80211_send_roamed(wiphy_to_dev(wdev->wiphy), dev,
+                                   bssid, req_ie, req_ie_len,
+                                   resp_ie, resp_ie_len, gfp);
+       else
+               nl80211_send_connect_result(wiphy_to_dev(wdev->wiphy), dev,
+                                           bssid, req_ie, req_ie_len,
+                                           resp_ie, resp_ie_len,
+                                           status, gfp);
+
+#ifdef CONFIG_WIRELESS_EXT
+       if (wextev) {
+               if (req_ie && status == WLAN_STATUS_SUCCESS) {
+                       memset(&wrqu, 0, sizeof(wrqu));
+                       wrqu.data.length = req_ie_len;
+                       wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, req_ie);
+               }
+
+               if (resp_ie && status == WLAN_STATUS_SUCCESS) {
+                       memset(&wrqu, 0, sizeof(wrqu));
+                       wrqu.data.length = resp_ie_len;
+                       wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, resp_ie);
+               }
+
+               memset(&wrqu, 0, sizeof(wrqu));
+               wrqu.ap_addr.sa_family = ARPHRD_ETHER;
+               if (bssid && status == WLAN_STATUS_SUCCESS)
+                       memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN);
+               wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL);
+       }
+#endif
+
+       if (status == WLAN_STATUS_SUCCESS &&
+           wdev->sme_state == CFG80211_SME_IDLE) {
+               wdev->sme_state = CFG80211_SME_CONNECTED;
+               return;
+       }
+
        if (wdev->sme_state != CFG80211_SME_CONNECTING)
                return;
 
@@ -315,32 +353,6 @@ static void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
 
        if (wdev->conn)
                wdev->conn->state = CFG80211_CONN_IDLE;
-
-       nl80211_send_connect_result(wiphy_to_dev(wdev->wiphy), dev, bssid,
-                                   req_ie, req_ie_len, resp_ie, resp_ie_len,
-                                   status, gfp);
-
-#ifdef CONFIG_WIRELESS_EXT
-       if (wextev) {
-               if (req_ie && status == WLAN_STATUS_SUCCESS) {
-                       memset(&wrqu, 0, sizeof(wrqu));
-                       wrqu.data.length = req_ie_len;
-                       wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, req_ie);
-               }
-
-               if (resp_ie && status == WLAN_STATUS_SUCCESS) {
-                       memset(&wrqu, 0, sizeof(wrqu));
-                       wrqu.data.length = resp_ie_len;
-                       wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, resp_ie);
-               }
-
-               memset(&wrqu, 0, sizeof(wrqu));
-               wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-               if (bssid && status == WLAN_STATUS_SUCCESS)
-                       memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN);
-               wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL);
-       }
-#endif
 }
 
 void cfg80211_connect_result(struct net_device *dev, const u8 *bssid,