From: Jouni Malinen Date: Mon, 25 Jan 2010 02:11:30 +0000 (-0800) Subject: nl80211: Dump scan results in debug log if association command fails X-Git-Tag: hostap_0_7_2~218 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8856462d61d48f98a13f5c17b0eb6c85e4f1c020;p=thirdparty%2Fhostap.git nl80211: Dump scan results in debug log if association command fails 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. --- diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 1f742ed0c..1f04779fb 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -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;