ravi_pvkumar
asked on
How to set the Wireless Key and access the Wireless Access point.
Hi,
We are facing the problem to access the Wireless Router, we are using the D-Link router.
We are able to Enumerate the device and also able to retrieve the list of AP's. We need to access the router using the SSID and Wireless key as the inputs and we are failing to do so.
steps followed are:
1.net stop ndisuio - asks for stopping wzc serivce and we stopped it.
2.net start ndisuio
and excuting following program.
WRAPI_NDIS_DEVICE *pDeviceList = NULL;
HRESULT hRes;
long lItems = 0;
long lNumItems = 0;
UCHAR Ssid[32] = {0};
AP_DATA *pAP_list = NULL;
CHAR *pSSId
ULONG lSSIdLength = strlen(pSSId);
ULONG lRTSThresh = 0;
MAC_ADDR addr = {0};
DOT_11_STATS DOT11Stats;
// Get the list of Devices in the System
hRes = WRAPIEnumerateDevices(&pDe viceList, &lItems);
// Print the list of devices obtained
for ( int i = 0; i < lItems; i++)
{
printf("%ws\n - %ws\n", pDeviceList[i].pDeviceDesc ription, pDeviceList[i].pDeviceName );
}
// Open the device at pDeviceList[1] -- pDeviceList[0] happens to be the * Ethernet Interface
hRes = WRAPIOpenNdisDevice(pDevic eList[0].p DeviceName );
int mymode;
WRAPIGetAuthMode(&mymode);
PrintAuthMode(mymode);
mymode=Ndis802_11AuthModeS hared;//Nd is802_11Au thModeOpen ;//Ndis802 _11AuthMod eAutoSwitc h;//Ndis80 2_11AuthMo deShared;
hRes=WRAPISetAuthMode(&mym ode);
hRes=WRAPIGetAuthMode(&mym ode);
PrintAuthMode(mymode);
// Get the value of RTS Threshold
hRes = WRAPIGetRTSThreshold(&lRTS Thresh);
// Get the MAC address of the AP to which this station is associated
// Get Packet-level statistics from the 802.11 interface
hRes = WRAPIGetPacketStats(&DOT11 Stats);
// Get a list of all APs within range of this station in a list of AP_DATA
// structures
hRes = WRAPIGetAPList(&pAP_list, &lNumItems);
// Print out the list of all APs and their signal strengths
printf("MAC Address \t\tSignal Strength (dBm) \n");
for ( i = 0; i < lNumItems; i++ )
{
for ( int j = 0; j < 6; j++)
{
printf("%02x", pAP_list[i].mac_addr[j]);
}
printf("\t\t%d\n", pAP_list[i].Rssi);
}
// Print out the list of all APs and their signal strengths
printf("MAC Address \t\tSignal Strength (dBm) \n");
for ( i = 0; i < lNumItems; i++ )
{
for ( int j = 0; j < 6; j++)
{
printf("%02x", pAP_info[i].mac_addr[j]);
}
printf("\t\t%d\t%s\n", pAP_info[i].Rssi, pAP_info[i].Ssid.Ssid);
}
if(pAP_list[0].mac_addr!=N ULL)
{
MAC_ADDR mac_addr;
for ( int j = 0; j < 6; j++)
{
mac_addr[j]=pAP_list[0].ma c_addr[j];
}
hRes=WRAPISetAssociatedAP( mac_addr);
printf("\nAssociatedAP:%02 x\n",mac_a ddr);
}
///Setting Infrastructure mode
int mynetworkmode;
hRes=WRAPIGetNetworkMode(& mynetworkm ode);
mynetworkmode=Ndis802_11In frastructu re;
hRes=WRAPISetNetworkMode(& mynetworkm ode);
///Set WEP Wnable
hRes=WRAPISetWEPEnable();
///////Set Wep Key
UCHAR mykey[]="abcdefghijklm";
WCHAR wkey[13];
for(i=0;i<13;i++)
wkey[i]=(WCHAR)mykey[i];
hRes=WRAPISetWirelessKey(w key);
/////Set Associate AP
if(pAP_info[0].mac_addr!=N ULL)
{
MAC_ADDR mac_addr;
for ( int j = 0; j < 6; j++)
{
mac_addr[j]=pAP_info[0].ma c_addr[j];
}
hRes=WRAPIDisassociate();
hRes=WRAPISetAssociatedAP( mac_addr);
printf("\nAssociatedAP:%02 x\n",mac_a ddr);
}
// Free all the memory that gets allocated inside the WRAPI dll
free(pAP_list);
free(pAP_info);
for (i = 0; i < lItems; i++ )
{
free(pDeviceList[i].pDevic eName);
free(pDeviceList[i].pDevic eDescripti on);
}
free(pDeviceList);
return 0;
can anybody help us to access the router using the SSID and Wireless Key we are using WRAPI.dll as a reference.
regards,
RKV
We are facing the problem to access the Wireless Router, we are using the D-Link router.
We are able to Enumerate the device and also able to retrieve the list of AP's. We need to access the router using the SSID and Wireless key as the inputs and we are failing to do so.
steps followed are:
1.net stop ndisuio - asks for stopping wzc serivce and we stopped it.
2.net start ndisuio
and excuting following program.
WRAPI_NDIS_DEVICE *pDeviceList = NULL;
HRESULT hRes;
long lItems = 0;
long lNumItems = 0;
UCHAR Ssid[32] = {0};
AP_DATA *pAP_list = NULL;
CHAR *pSSId
ULONG lSSIdLength = strlen(pSSId);
ULONG lRTSThresh = 0;
MAC_ADDR addr = {0};
DOT_11_STATS DOT11Stats;
// Get the list of Devices in the System
hRes = WRAPIEnumerateDevices(&pDe
// Print the list of devices obtained
for ( int i = 0; i < lItems; i++)
{
printf("%ws\n - %ws\n", pDeviceList[i].pDeviceDesc
}
// Open the device at pDeviceList[1] -- pDeviceList[0] happens to be the * Ethernet Interface
hRes = WRAPIOpenNdisDevice(pDevic
int mymode;
WRAPIGetAuthMode(&mymode);
PrintAuthMode(mymode);
mymode=Ndis802_11AuthModeS
hRes=WRAPISetAuthMode(&mym
hRes=WRAPIGetAuthMode(&mym
PrintAuthMode(mymode);
// Get the value of RTS Threshold
hRes = WRAPIGetRTSThreshold(&lRTS
// Get the MAC address of the AP to which this station is associated
// Get Packet-level statistics from the 802.11 interface
hRes = WRAPIGetPacketStats(&DOT11
// Get a list of all APs within range of this station in a list of AP_DATA
// structures
hRes = WRAPIGetAPList(&pAP_list, &lNumItems);
// Print out the list of all APs and their signal strengths
printf("MAC Address \t\tSignal Strength (dBm) \n");
for ( i = 0; i < lNumItems; i++ )
{
for ( int j = 0; j < 6; j++)
{
printf("%02x", pAP_list[i].mac_addr[j]);
}
printf("\t\t%d\n", pAP_list[i].Rssi);
}
// Print out the list of all APs and their signal strengths
printf("MAC Address \t\tSignal Strength (dBm) \n");
for ( i = 0; i < lNumItems; i++ )
{
for ( int j = 0; j < 6; j++)
{
printf("%02x", pAP_info[i].mac_addr[j]);
}
printf("\t\t%d\t%s\n", pAP_info[i].Rssi, pAP_info[i].Ssid.Ssid);
}
if(pAP_list[0].mac_addr!=N
{
MAC_ADDR mac_addr;
for ( int j = 0; j < 6; j++)
{
mac_addr[j]=pAP_list[0].ma
}
hRes=WRAPISetAssociatedAP(
printf("\nAssociatedAP:%02
}
///Setting Infrastructure mode
int mynetworkmode;
hRes=WRAPIGetNetworkMode(&
mynetworkmode=Ndis802_11In
hRes=WRAPISetNetworkMode(&
///Set WEP Wnable
hRes=WRAPISetWEPEnable();
///////Set Wep Key
UCHAR mykey[]="abcdefghijklm";
WCHAR wkey[13];
for(i=0;i<13;i++)
wkey[i]=(WCHAR)mykey[i];
hRes=WRAPISetWirelessKey(w
/////Set Associate AP
if(pAP_info[0].mac_addr!=N
{
MAC_ADDR mac_addr;
for ( int j = 0; j < 6; j++)
{
mac_addr[j]=pAP_info[0].ma
}
hRes=WRAPIDisassociate();
hRes=WRAPISetAssociatedAP(
printf("\nAssociatedAP:%02
}
// Free all the memory that gets allocated inside the WRAPI dll
free(pAP_list);
free(pAP_info);
for (i = 0; i < lItems; i++ )
{
free(pDeviceList[i].pDevic
free(pDeviceList[i].pDevic
}
free(pDeviceList);
return 0;
can anybody help us to access the router using the SSID and Wireless Key we are using WRAPI.dll as a reference.
regards,
RKV
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.