Native Wifi
Purpose
The Native Wifi automatic configuration component configures, connects to, and disconnects from wireless networks. Native Wifi can store profiles on the networks it interacts with in the form of XML documents.
Developer audience
The Native Wifi API is designed for C/C++ developers. Programmers should be familiar with wireless networking concepts and terminology.
Run-time requirements
The Native Wifi component requires clients running Windows Vista, Windows XP with Service Pack 3 (SP3), or Wireless LAN API for Windows XP with Service Pack 2 (SP2).
Introduction
Sample application is used how to use WlanOpenHandle, WlanEnumInterfaces, WlanRegisterNotification, WlanScan, WlanGetNetworkBssList, WlanGetAvailableNetworkList. Parse the IES from last beacon and probe response from BSS network. Add the IE(Information Element) during WlanScan request. I have checked with (Intel(R) Centrino(R) Advanced-N 6205). This interface is not allowing to send reserved Information wifi IES(52-126 according IEEE 802.11 spec) but all other i am able to include in scan request. I hope this code will be usefull.
Background
Using the code
Requirements:
1) Visual studio.
2) WDK and SDK.
3) Wireshark for verification for added IES in WlanScan request.
// Open handle session and enumerate all wifi adapters. I have considered first adapter only if you
// have more than one adapter u need to add logic which adapter u need.
int FuncWlanOpenAndEnum()
{
DWORD dwClientVersion=(IsVistaOrHigher() ? 2 : 1);
printf("######## FuncWlanOpenAndEnum--->######## \n\n");
//creating session handle for the client to connect to server.
hResult=WlanOpenHandle(dwClientVersion,NULL,&pdwNegotiatedVersion,&phClientHandle);
if(hResult!=ERROR_SUCCESS)
{
printf("failed WlanOpenHandle=%d \n",hResult);
return hResult;
}
else
{
printf("WlanOpenHandle is success=%d \n",hResult);
}
//Enumerates all the wifi adapters currently enabled on PC.
//Returns the list of interface list that are enabled on PC.
hResult=WlanEnumInterfaces(phClientHandle,NULL,&pIfList);
if(hResult!=ERROR_SUCCESS)
{
printf("failed WlanEnumInterfaces check adapter is on=%d \n",hResult);
return hResult;
}
else
{
printf("WlanEnumInterfaces is success=%d \n",hResult);
}
printf("######## FuncWlanOpenAndEnum<---######## \n \n");
return hResult;
} // prints the enumerated the interfaces add stores the interface in global variable void FuncWlanPrintInterfaceNames()
{
WCHAR SGuid[256]={0};
printf("######## FuncWlanPrintInterfaceNames--->######## \n\n");
for(unsigned int i=0;(i < pIfList->dwNumberOfItems);i++)
{
printf("WIFI Adapter Description =%ws \n",pIfList->InterfaceInfo[pIfList->dwIndex].strInterfaceDescription);
StringFromGUID2(pIfList->InterfaceInfo[pIfList->dwIndex].InterfaceGuid,SGuid,256);
printf("WIFI Adapter GUID=%ws \n",SGuid);
}
Read more: Codeproject
QR:
0 comments:
Post a Comment