]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Dump scan results in debug log if association command fails
authorJouni Malinen <j@w1.fi>
Mon, 25 Jan 2010 02:11:30 +0000 (18:11 -0800)
committerJouni Malinen <j@w1.fi>
Mon, 25 Jan 2010 02:11:30 +0000 (18:11 -0800)
This may help in debugging why cfg80211 refused the association
command since the scan results should include information about all
pending authentication and association states.

src/drivers/driver_nl80211.c

index 1f742ed0ca8ab58151f21cc7babdbdd81ee5cd71..1f04779fb1be0ebd3414b38f9509a8ab2595b4e3 100644 (file)
@@ -1654,15 +1654,9 @@ static void wpa_scan_results_free(struct wpa_scan_results *res)
 }
 
 
-/**
- * wpa_driver_nl80211_get_scan_results - Fetch the latest scan results
- * @priv: Pointer to private wext data from wpa_driver_nl80211_init()
- * Returns: Scan results on success, -1 on failure
- */
 static struct wpa_scan_results *
-wpa_driver_nl80211_get_scan_results(void *priv)
+nl80211_get_scan_results(struct wpa_driver_nl80211_data *drv)
 {
-       struct wpa_driver_nl80211_data *drv = priv;
        struct nl_msg *msg;
        struct wpa_scan_results *res;
        int ret;
@@ -1683,7 +1677,6 @@ wpa_driver_nl80211_get_scan_results(void *priv)
        if (ret == 0) {
                wpa_printf(MSG_DEBUG, "Received scan results (%lu BSSes)",
                           (unsigned long) res->num);
-               wpa_driver_nl80211_check_bss_status(drv, res);
                return res;
        }
        wpa_printf(MSG_DEBUG, "nl80211: Scan result fetch failed: ret=%d "
@@ -1695,6 +1688,48 @@ nla_put_failure:
 }
 
 
+/**
+ * wpa_driver_nl80211_get_scan_results - Fetch the latest scan results
+ * @priv: Pointer to private wext data from wpa_driver_nl80211_init()
+ * Returns: Scan results on success, -1 on failure
+ */
+static struct wpa_scan_results *
+wpa_driver_nl80211_get_scan_results(void *priv)
+{
+       struct wpa_driver_nl80211_data *drv = priv;
+       struct wpa_scan_results *res;
+
+       res = nl80211_get_scan_results(drv);
+       if (res)
+               wpa_driver_nl80211_check_bss_status(drv, res);
+       return res;
+}
+
+
+static void nl80211_dump_scan(struct wpa_driver_nl80211_data *drv)
+{
+       struct wpa_scan_results *res;
+       size_t i;
+
+       res = nl80211_get_scan_results(drv);
+       if (res == NULL) {
+               wpa_printf(MSG_DEBUG, "nl80211: Failed to get scan results");
+               return;
+       }
+
+       wpa_printf(MSG_DEBUG, "nl80211: Scan result dump");
+       for (i = 0; i < res->num; i++) {
+               struct wpa_scan_res *r = res->res[i];
+               wpa_printf(MSG_DEBUG, "nl80211: %d/%d " MACSTR "%s%s",
+                          (int) i, (int) res->num, MAC2STR(r->bssid),
+                          r->flags & WPA_SCAN_AUTHENTICATED ? " [auth]" : "",
+                          r->flags & WPA_SCAN_ASSOCIATED ? " [assoc]" : "");
+       }
+
+       wpa_scan_results_free(res);
+}
+
+
 static int wpa_driver_nl80211_set_key(const char *ifname, void *priv,
                                      enum wpa_alg alg, const u8 *addr,
                                      int key_idx, int set_tx,
@@ -3572,6 +3607,7 @@ static int wpa_driver_nl80211_associate(
        if (ret) {
                wpa_printf(MSG_DEBUG, "nl80211: MLME command failed: ret=%d "
                           "(%s)", ret, strerror(-ret));
+               nl80211_dump_scan(drv);
                goto nla_put_failure;
        }
        ret = 0;