We help IT Professionals succeed at work.

How to set the Wireless Key and access the Wireless Access point.

ravi_pvkumar
ravi_pvkumar asked
on
700 Views
Last Modified: 2013-12-09
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(&pDeviceList, &lItems);

      // Print the list of devices obtained
      for ( int i = 0; i < lItems; i++)
      {
            printf("%ws\n  - %ws\n", pDeviceList[i].pDeviceDescription, pDeviceList[i].pDeviceName);
      }

      
      // Open the device at pDeviceList[1] -- pDeviceList[0] happens to be the        * Ethernet Interface
      hRes = WRAPIOpenNdisDevice(pDeviceList[0].pDeviceName);
      
      int mymode;
      
      WRAPIGetAuthMode(&mymode);
      PrintAuthMode(mymode);

      mymode=Ndis802_11AuthModeShared;//Ndis802_11AuthModeOpen;//Ndis802_11AuthModeAutoSwitch;//Ndis802_11AuthModeShared;
      hRes=WRAPISetAuthMode(&mymode);
      
      hRes=WRAPIGetAuthMode(&mymode);
      PrintAuthMode(mymode);


      // Get the value of RTS Threshold
      hRes = WRAPIGetRTSThreshold(&lRTSThresh);
      
      // Get the MAC address of the AP to which this station is associated
      // Get Packet-level statistics from the 802.11 interface
      hRes = WRAPIGetPacketStats(&DOT11Stats);

      // 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!=NULL)
      {
            MAC_ADDR mac_addr;
            for ( int j = 0; j < 6; j++)
            {
                   mac_addr[j]=pAP_list[0].mac_addr[j];
            }
            hRes=WRAPISetAssociatedAP(mac_addr);
            printf("\nAssociatedAP:%02x\n",mac_addr);
      }

      ///Setting Infrastructure mode
      int mynetworkmode;
      hRes=WRAPIGetNetworkMode(&mynetworkmode);
      mynetworkmode=Ndis802_11Infrastructure;
      hRes=WRAPISetNetworkMode(&mynetworkmode);

      ///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(wkey);

/////Set Associate AP
      if(pAP_info[0].mac_addr!=NULL)
      {
            MAC_ADDR mac_addr;
            for ( int j = 0; j < 6; j++)
            {
                   mac_addr[j]=pAP_info[0].mac_addr[j];
            }
            hRes=WRAPIDisassociate();
            hRes=WRAPISetAssociatedAP(mac_addr);
            printf("\nAssociatedAP:%02x\n",mac_addr);
      }
      
      // 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].pDeviceName);
            free(pDeviceList[i].pDeviceDescription);
      }

      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
Comment
Watch Question

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.