madwifi-ng works sporadically, or not at all, with wpa_supplicant when one attempts to use a network whose access points are "stealthed" (not broadcasting beacons with ESSID).
There appear to be two closely-related reasons for this:
[1] The ieee80211_ioctl_siwscan handler doesn't process the ioctl parameters, and will thus ignore the IW_SCAN_THIS_ESSID flag and the specified ESSID. The VAP's default ESSID is the one actually scanned for. This problem affects the wpa_supplicant "wext" driver, which passes the scan ESSID via the SIWSCAN ioctl data. It doesn't affect the wpa_supplicant "madwifi" driver, which changes the VAP's default ESSID before scanning.
[2] It's often the case in practice that ieee80211_ioctl_siwscan will be called, to scan for a desired ESSID, when there's already an active scan in progress. When this happens, ieee80211_ioctl_siwscan has no effect... it calls ieee80211_start_scan which simply logs an "active scan already in progress" and returns. No scan for the newly-desired ESSID is performed. This problem tends to prevent wpa_supplicant from working with either the wext or madwifi drivers - there always seems to be an active scan running (usually with no ESSID specified) when wpa-supplicant calls for a new active scan, and the new scan(s) lose out.
I've worked up a patch which resolves both of these issues, and seems to allow wpa_supplicant to find and associate with stealthed APs quickly and reliably. It adds handling of the IW_SCAN_THIS_ESSID and its data (enabling use of the wext driver), and it adds logic to cancel any existing active scan and wait for a few milliseconds to allow the cancellation to take effect before starting the new scan. The latter isn't the most elegant solution in the world, but changing the driver to support multiple simultaneous scans is more than I'm about to try to tackle (if it's even possible).
The patch is attached.
Signed-off-by: Dave Platt <dplatt@radagast.org>