From 31cbe002c9f818ff616938855cf3744ab2c4590d Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 5 Nov 2008 23:44:26 +0200 Subject: [PATCH] driver_ndis: Added a workaround for a driver that removes SSID IE in scan A driver was found to remove SSID IE from NDIS_WLAN_BSSID_EX IEs, but the correct SSID is included in NDIS_802_11_SSID structure inside the BSSID data. If this is seen in scan results, create a matching SSID IE and add it to the end of IEs to fix scan result parsing. --- src/drivers/driver_ndis.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/drivers/driver_ndis.c b/src/drivers/driver_ndis.c index 074f950ce..e245b3070 100644 --- a/src/drivers/driver_ndis.c +++ b/src/drivers/driver_ndis.c @@ -731,6 +731,32 @@ static int wpa_driver_ndis_scan(void *priv, const u8 *ssid, size_t ssid_len) } +static struct wpa_scan_res * wpa_driver_ndis_add_scan_ssid( + struct wpa_scan_res *r, NDIS_802_11_SSID *ssid) +{ + struct wpa_scan_res *nr; + u8 *pos; + + if (wpa_scan_get_ie(r, WLAN_EID_SSID)) + return r; /* SSID IE already present */ + + if (ssid->SsidLength == 0 || ssid->SsidLength > 32) + return r; /* No valid SSID inside scan data */ + + nr = os_realloc(r, sizeof(*r) + r->ie_len + 2 + ssid->SsidLength); + if (nr == NULL) + return r; + + pos = ((u8 *) (nr + 1)) + nr->ie_len; + *pos++ = WLAN_EID_SSID; + *pos++ = ssid->SsidLength; + os_memcpy(pos, ssid->Ssid, ssid->SsidLength); + nr->ie_len += 2 + ssid->SsidLength; + + return nr; +} + + static struct wpa_scan_results * wpa_driver_ndis_get_scan_results(void *priv) { struct wpa_driver_ndis_data *drv = priv; @@ -804,6 +830,7 @@ static struct wpa_scan_results * wpa_driver_ndis_get_scan_results(void *priv) os_memcpy(r + 1, bss->IEs + sizeof(NDIS_802_11_FIXED_IEs), bss->IELength - sizeof(NDIS_802_11_FIXED_IEs)); r->ie_len = bss->IELength - sizeof(NDIS_802_11_FIXED_IEs); + r = wpa_driver_ndis_add_scan_ssid(r, &bss->Ssid); results->res[results->num++] = r;