mirror of
https://github.com/reactos/reactos.git
synced 2024-07-02 10:45:24 +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
|
@ -271,7 +271,7 @@ WlanDisconnect(HANDLE hAdapter, PIP_ADAPTER_INDEX_MAP IpInfo)
|
||||||
bSuccess = DeviceIoControl(hAdapter,
|
bSuccess = DeviceIoControl(hAdapter,
|
||||||
IOCTL_NDISUIO_SET_OID_VALUE,
|
IOCTL_NDISUIO_SET_OID_VALUE,
|
||||||
&SetOid,
|
&SetOid,
|
||||||
sizeof(SetOid),
|
FIELD_OFFSET(NDISUIO_SET_OID, Data),
|
||||||
NULL,
|
NULL,
|
||||||
0,
|
0,
|
||||||
&dwBytesReturned,
|
&dwBytesReturned,
|
||||||
|
@ -739,6 +739,7 @@ WlanScan(HANDLE hAdapter)
|
||||||
DWORD QueryOidSize;
|
DWORD QueryOidSize;
|
||||||
PNDIS_802_11_BSSID_LIST BssidList;
|
PNDIS_802_11_BSSID_LIST BssidList;
|
||||||
DWORD i, j;
|
DWORD i, j;
|
||||||
|
DWORD dwNetworkCount;
|
||||||
WCHAR szMsgBuf[128];
|
WCHAR szMsgBuf[128];
|
||||||
|
|
||||||
SetOid.Oid = OID_802_11_BSSID_LIST_SCAN;
|
SetOid.Oid = OID_802_11_BSSID_LIST_SCAN;
|
||||||
|
@ -747,7 +748,7 @@ WlanScan(HANDLE hAdapter)
|
||||||
bSuccess = DeviceIoControl(hAdapter,
|
bSuccess = DeviceIoControl(hAdapter,
|
||||||
IOCTL_NDISUIO_SET_OID_VALUE,
|
IOCTL_NDISUIO_SET_OID_VALUE,
|
||||||
&SetOid,
|
&SetOid,
|
||||||
sizeof(SetOid),
|
FIELD_OFFSET(NDISUIO_SET_OID, Data),
|
||||||
NULL,
|
NULL,
|
||||||
0,
|
0,
|
||||||
&dwBytesReturned,
|
&dwBytesReturned,
|
||||||
|
@ -755,23 +756,44 @@ WlanScan(HANDLE hAdapter)
|
||||||
if (!bSuccess)
|
if (!bSuccess)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Allocate space for 15 networks to be returned */
|
/* Wait 2 seconds for the scan to return some results */
|
||||||
QueryOidSize = sizeof(NDISUIO_QUERY_OID) + (sizeof(NDIS_WLAN_BSSID) * 15);
|
Sleep(2000);
|
||||||
QueryOid = HeapAlloc(GetProcessHeap(), 0, QueryOidSize);
|
|
||||||
if (!QueryOid)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
QueryOid->Oid = OID_802_11_BSSID_LIST;
|
/* Allocate space for 10 networks to be returned initially */
|
||||||
BssidList = (PNDIS_802_11_BSSID_LIST)QueryOid->Data;
|
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)
|
if (!bSuccess)
|
||||||
{
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, QueryOid);
|
HeapFree(GetProcessHeap(), 0, QueryOid);
|
||||||
|
|
|
@ -190,7 +190,15 @@ SetAdapterOid(PIRP Irp, PIO_STACK_LOCATION IrpSp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the bytes read */
|
/* 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);
|
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 */
|
/* 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);
|
DPRINT("Final request status: 0x%x (%d)\n", Status, Irp->IoStatus.Information);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue