Active scan on a WiFi NIC, including flush of old scan results - how ?
-
Hi, I wrote a program using VC++ that should scan for available wireless networks in the area. In my SW I use the commands OID_802_11_BSSID_LIST_SCAN and OID_802_11_BSSID_LIST. My questions are: 1. How can I Force the Wireless NIC to do ACTIVE SCAN (as contrary to PASSIVE scan) ? 2. According to tests that I did, the card does not flush the list between scans, i.e. I get for several scan a result of an AP that was on air during an old scan, but is no longer there, and new scans return's it's data as if it is still there. A code part that I used is attached - in order to illustrate which functions I am using.
NDIS_802_11_BSSID_LIST* m_pBSSIDList;
m_pBSSIDList = (NDIS_802_11_BSSID_LIST *) VirtualAlloc (NULL,
sizeof (NDIS_802_11_BSSID_LIST) * NUMBEROF_BSSIDS,
MEM_RESERVE | MEM_COMMIT,
PAGE_READWRITE) ;memset (m_pBSSIDList, 0, sizeof (NDIS_802_11_BSSID_LIST) * NUMBEROF_BSSIDS);
// Do Scan
oidcode = OID_802_11_BSSID_LIST_SCAN;
DeviceIoControl (m_handle,
IOCTL_NDIS_QUERY_GLOBAL_STATS,
&oidcode,
sizeof(oidcode),
(ULONG *) NULL,
0,
&bytesreturned,
NULL);Sleep (6100); // According to the documentation the result of the scan should be valid after 6 seconds.
// The original line was delay of 2000 mSec. find out why...
//Sleep (2000);// Read scan results
oidcode = OID_802_11_BSSID_LIST;
if (DeviceIoControl( m_handle,
IOCTL_NDIS_QUERY_GLOBAL_STATS,
&oidcode,
sizeof(oidcode),
(ULONG *) m_pBSSIDList,
sizeof(NDIS_802_11_BSSID_LIST) * NUMBEROF_BSSIDS,
&bytesreturned,
NULL) == 0)
{
// List failed
return NULL;
}
else
{
return m_pBSSIDList;
}If you have any idea of how can I solve my problems, or if you see that I forgot any important line- please let me know. I am open to hear about completely new ways to do this. only requirement is that I will use VC++. Thanks a lot, --Amit.