mirror of
https://github.com/reactos/reactos.git
synced 2024-11-20 06:15:26 +00:00
[WLANCONF]
- Fix network scanning when many base stations are in range - Fix input buffer size for OID_802_11_DISASSOCIATE and OID_802_11_BSSID_LIST_SCAN [NDISUIO] - Return STATUS_BUFFER_TOO_SMALL when the OID buffer length is too small svn path=/trunk/; revision=66778
This commit is contained in:
parent
b8e34eb9ae
commit
930db86cda
2 changed files with 57 additions and 19 deletions
|
@ -271,7 +271,7 @@ WlanDisconnect(HANDLE hAdapter, PIP_ADAPTER_INDEX_MAP IpInfo)
|
|||
bSuccess = DeviceIoControl(hAdapter,
|
||||
IOCTL_NDISUIO_SET_OID_VALUE,
|
||||
&SetOid,
|
||||
sizeof(SetOid),
|
||||
FIELD_OFFSET(NDISUIO_SET_OID, Data),
|
||||
NULL,
|
||||
0,
|
||||
&dwBytesReturned,
|
||||
|
@ -739,6 +739,7 @@ WlanScan(HANDLE hAdapter)
|
|||
DWORD QueryOidSize;
|
||||
PNDIS_802_11_BSSID_LIST BssidList;
|
||||
DWORD i, j;
|
||||
DWORD dwNetworkCount;
|
||||
WCHAR szMsgBuf[128];
|
||||
|
||||
SetOid.Oid = OID_802_11_BSSID_LIST_SCAN;
|
||||
|
@ -747,7 +748,7 @@ WlanScan(HANDLE hAdapter)
|
|||
bSuccess = DeviceIoControl(hAdapter,
|
||||
IOCTL_NDISUIO_SET_OID_VALUE,
|
||||
&SetOid,
|
||||
sizeof(SetOid),
|
||||
FIELD_OFFSET(NDISUIO_SET_OID, Data),
|
||||
NULL,
|
||||
0,
|
||||
&dwBytesReturned,
|
||||
|
@ -755,23 +756,44 @@ WlanScan(HANDLE hAdapter)
|
|||
if (!bSuccess)
|
||||
return FALSE;
|
||||
|
||||
/* Allocate space for 15 networks to be returned */
|
||||
QueryOidSize = sizeof(NDISUIO_QUERY_OID) + (sizeof(NDIS_WLAN_BSSID) * 15);
|
||||
QueryOid = HeapAlloc(GetProcessHeap(), 0, QueryOidSize);
|
||||
if (!QueryOid)
|
||||
return FALSE;
|
||||
/* Wait 2 seconds for the scan to return some results */
|
||||
Sleep(2000);
|
||||
|
||||
QueryOid->Oid = OID_802_11_BSSID_LIST;
|
||||
BssidList = (PNDIS_802_11_BSSID_LIST)QueryOid->Data;
|
||||
/* Allocate space for 10 networks to be returned initially */
|
||||
QueryOid = NULL;
|
||||
dwNetworkCount = 10;
|
||||
for (;;)
|
||||
{
|
||||
if (QueryOid)
|
||||
HeapFree(GetProcessHeap(), 0, QueryOid);
|
||||
|
||||
QueryOidSize = sizeof(NDISUIO_QUERY_OID) + (sizeof(NDIS_WLAN_BSSID) * dwNetworkCount);
|
||||
QueryOid = HeapAlloc(GetProcessHeap(), 0, QueryOidSize);
|
||||
if (!QueryOid)
|
||||
return FALSE;
|
||||
|
||||
QueryOid->Oid = OID_802_11_BSSID_LIST;
|
||||
BssidList = (PNDIS_802_11_BSSID_LIST)QueryOid->Data;
|
||||
|
||||
bSuccess = DeviceIoControl(hAdapter,
|
||||
IOCTL_NDISUIO_QUERY_OID_VALUE,
|
||||
QueryOid,
|
||||
QueryOidSize,
|
||||
QueryOid,
|
||||
QueryOidSize,
|
||||
&dwBytesReturned,
|
||||
NULL);
|
||||
if (!bSuccess && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
/* Try allocating space for 10 more networks */
|
||||
dwNetworkCount += 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bSuccess = DeviceIoControl(hAdapter,
|
||||
IOCTL_NDISUIO_QUERY_OID_VALUE,
|
||||
QueryOid,
|
||||
QueryOidSize,
|
||||
QueryOid,
|
||||
QueryOidSize,
|
||||
&dwBytesReturned,
|
||||
NULL);
|
||||
if (!bSuccess)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, QueryOid);
|
||||
|
|
|
@ -190,7 +190,15 @@ SetAdapterOid(PIRP Irp, PIO_STACK_LOCATION IrpSp)
|
|||
}
|
||||
|
||||
/* Return the bytes read */
|
||||
if (NT_SUCCESS(Status)) Irp->IoStatus.Information = sizeof(NDIS_OID) + Request.DATA.SET_INFORMATION.BytesRead;
|
||||
if (Status == NDIS_STATUS_INVALID_LENGTH ||
|
||||
Status == NDIS_STATUS_BUFFER_TOO_SHORT)
|
||||
{
|
||||
Status = STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
else if (Status == NDIS_STATUS_SUCCESS)
|
||||
{
|
||||
Irp->IoStatus.Information = sizeof(NDIS_OID) + Request.DATA.SET_INFORMATION.BytesRead;
|
||||
}
|
||||
|
||||
DPRINT("Final request status: 0x%x (%d)\n", Status, Irp->IoStatus.Information);
|
||||
}
|
||||
|
@ -256,7 +264,15 @@ QueryAdapterOid(PIRP Irp, PIO_STACK_LOCATION IrpSp)
|
|||
}
|
||||
|
||||
/* Return the bytes written */
|
||||
if (NT_SUCCESS(Status)) Irp->IoStatus.Information = sizeof(NDIS_OID) + Request.DATA.QUERY_INFORMATION.BytesWritten;
|
||||
if (Status == NDIS_STATUS_INVALID_LENGTH ||
|
||||
Status == NDIS_STATUS_BUFFER_TOO_SHORT)
|
||||
{
|
||||
Status = STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
else if (Status == NDIS_STATUS_SUCCESS)
|
||||
{
|
||||
Irp->IoStatus.Information = sizeof(NDIS_OID) + Request.DATA.QUERY_INFORMATION.BytesWritten;
|
||||
}
|
||||
|
||||
DPRINT("Final request status: 0x%x (%d)\n", Status, Irp->IoStatus.Information);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue