]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Allow driver wrappers to indicate whether result codes are sane
authorJouni Malinen <jouni.malinen@atheros.com>
Fri, 26 Nov 2010 15:41:21 +0000 (17:41 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 26 Nov 2010 15:41:21 +0000 (17:41 +0200)
Some drivers are not providing exactly reliable error codes (e.g.,
with WEXT), but others may actually indicate reliable information.
Allow driver wrappers to indicate if that is the case and use
optimizations if so. For now, this improves nl80211 with
NL80211_CMD_CONNECT for a case where connection request fails.

src/drivers/driver.h
src/drivers/driver_nl80211.c
wpa_supplicant/wpa_supplicant.c

index d936895867996ce188f1e73c6a2e2472cc23fdc2..eaaef00a366ffac07b8ba7d3d8bfab4fafd2e21d 100644 (file)
@@ -553,6 +553,12 @@ struct wpa_driver_capa {
  * P2P group operations.
  */
 #define WPA_DRIVER_FLAGS_P2P_MGMT_AND_NON_P2P          0x00002000
+/*
+ * Driver is known to use sane error codes, i.e., when it indicates that
+ * something (e.g., association) fails, there was indeed a failure and the
+ * operation does not end up getting completed successfully later.
+ */
+#define WPA_DRIVER_FLAGS_SANE_ERROR_CODES              0x00004000
        unsigned int flags;
 
        int max_scan_ssids;
index 71640fc88d7164ebe74045120f3d22ab05f708b2..f69cc712d5849456cee290ef0ed93c7057c10955 100644 (file)
@@ -1489,6 +1489,7 @@ static int wpa_driver_nl80211_capa(struct wpa_driver_nl80211_data *drv)
                return -1;
        }
 
+       drv->capa.flags |= WPA_DRIVER_FLAGS_SANE_ERROR_CODES;
        drv->capa.flags |= WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE;
        drv->capa.flags |= WPA_DRIVER_FLAGS_P2P_CAPABLE;
        drv->capa.max_remain_on_chan = 5000;
index 350ad9a71bd7ced4e25894a46ac23abde9ebe9f6..68d171fbfb7765d38f5ea0c72e60e13c1f2cc186 100644 (file)
@@ -1304,6 +1304,16 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
        if (ret < 0) {
                wpa_msg(wpa_s, MSG_INFO, "Association request to the driver "
                        "failed");
+               if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SANE_ERROR_CODES) {
+                       /*
+                        * The driver is known to mean what is saying, so we
+                        * can stop right here; the association will not
+                        * succeed.
+                        */
+                       wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
+                       os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
+                       return;
+               }
                /* try to continue anyway; new association will be tried again
                 * after timeout */
                assoc_failed = 1;