Do not use on any
shared computer
September 6, 2008 03:06pm pdt
 
[x]
Attachment Details

How to get other bss information from ndisuio?

Tags: ioctl, bssid_list, failed
Hello expert,

I meet a tricky problem to get the multiple AP's information detected by local 802.11 NIC.  When I prase the data which is returned from kernel, only the information of first AP is correct.  I miss the address of other AP.

The data sturctures defined in "Ntddndis.h" are here:

typedef struct _NDIS_WLAN_BSSID
{
    ULONG                               Length;             // Length of this structure
    NDIS_802_11_MAC_ADDRESS             MacAddress;         // BSSID
    UCHAR                               Reserved[2];
    NDIS_802_11_SSID                    Ssid;               // SSID
    ULONG                               Privacy;            // WEP encryption requirement
    NDIS_802_11_RSSI                    Rssi;               // receive signal
                                                            // strength in dBm
    NDIS_802_11_NETWORK_TYPE            NetworkTypeInUse;
    NDIS_802_11_CONFIGURATION           Configuration;
    NDIS_802_11_NETWORK_INFRASTRUCTURE  InfrastructureMode;
    NDIS_802_11_RATES                   SupportedRates;
} NDIS_WLAN_BSSID, *PNDIS_WLAN_BSSID;

typedef struct _NDIS_802_11_BSSID_LIST
{
    ULONG           NumberOfItems;      // in list below, at least 1
    NDIS_WLAN_BSSID Bssid[1];
} NDIS_802_11_BSSID_LIST, *PNDIS_802_11_BSSID_LIST;


The code to access NDIS_802_11_BSSID_LIST:

NDIS_STATUS            Dot11_GetAPList(
      HANDLE      handle,
      DOT11_BSS_LIST *pBssList )
{
      UCHAR                                    buf[4096];
      PNDISUIO_QUERY_OID                  pQueryOid;
      PNDISUIO_SET_OID                  pSetOid;
      PNDIS_802_11_BSSID_LIST            pBssid_List;
      ULONG                                    i = 0;
      int                                          j = 0;
      NDIS_STATUS                              status = S_OK;
      DWORD                                    dwBytesReturned = 0;
      DWORD                                    dwErrorCode = 0;
      int                                          bufSize;
      AP_DATA                                    *pTempApData = NULL;
      NDIS_WLAN_BSSID                  *pBssId = NULL;
      

      if (!pBssList )
      {
            status = E_POINTER;
      }

      else
      {
            pSetOid = (PNDISUIO_SET_OID) &buf[0];
            pSetOid->Oid = OID_802_11_BSSID_LIST_SCAN;
            
      
            if (!DeviceIoControl(
                              handle,
                              IOCTL_NDISUIO_SET_OID_VALUE,
                              (LPVOID) &buf[0],
                              sizeof(buf),                  // BUGBUG: ??
                              (LPVOID) &buf[0],
                              0,
                              &dwBytesReturned,
                              NULL))
            {
                  dwErrorCode = GetLastError();
                  DEBUGP(("IOCTL SET BSSID_LIST_SCAN failed: %d\n", dwErrorCode));
                  status = E_FAIL;
            }

            pQueryOid = (PNDISUIO_QUERY_OID) &buf[0];
            pQueryOid->Oid = OID_802_11_BSSID_LIST;

            if (DeviceIoControl(
                              handle,
                              IOCTL_NDISUIO_QUERY_OID_VALUE,
                              (LPVOID) &buf[0],
                              sizeof(buf),                  // BUGBUG: ??
                              (LPVOID) &buf[0],
                              sizeof(buf),
                              &dwBytesReturned,
                              NULL))
            {
                  DEBUGP(("IOCTL BSSID_LIST succeeded\n"));

                  pBssid_List = (PNDIS_802_11_BSSID_LIST)pQueryOid->Data;

                  pBssList->size = pBssid_List->NumberOfItems;
                  pBssList->pAP_Data = calloc( pBssid_List->NumberOfItems, sizeof(AP_DATA));

                  PRINTF(("\n\n===========  802.11 BSS List ==============\n"));
                  PRINTF(( "ID\tMAC\t\t\tRSSI(dBm)\tBSSID\n" ));      


                  for ( i = 0; i < pBssid_List->NumberOfItems; i++ )
                  {                        
                        pTempApData = &pBssList->pAP_Data[i] ;
                  
                        for ( j = 0; j < MAC_ADDR_LEN; j++ )
                        {
                              pTempApData->mac_addr[j] = (pBssid_List->Bssid[i]).MacAddress[j];
                        }

                        pTempApData->Rssi = (pBssid_List->Bssid[i]).Rssi;

                        PRINTF(( "%2u\t", i ));

                        PRINTF(("%02X-%02X-%02X-%02X-%02X-%02X",
                              (pBssid_List->Bssid[i]).MacAddress[0],
                              (pBssid_List->Bssid[i]).MacAddress[1],
                              (pBssid_List->Bssid[i]).MacAddress[2],
                              (pBssid_List->Bssid[i]).MacAddress[3],
                              (pBssid_List->Bssid[i]).MacAddress[4],
                              (pBssid_List->Bssid[i]).MacAddress[5] ));

                        PRINTF(( "\t%d", (pBssid_List->Bssid[i]).Rssi));

                        PRINTF(( "\t\t%s\n", (pBssid_List->Bssid[i]).Ssid.Ssid));

                  }                  
            }
            else
            {
                  status = E_FAIL;
                  dwErrorCode = GetLastError();
                  DEBUGP(("IOCTL BSSID_LIST failed: %d\n", dwErrorCode));
            }            
      }

      return status;

} //Dot11_GetAPList


Here is the output reslut:
===========  802.11 BSS List ==============
ID      MAC                            RSSI(dBm)  BSSID
 0      00-02-2D-B4-32-C2       -55             My Wireless Network A
 1      00-00-00-00-2C-00       33620758                v
 2      A5-FF-FF-FF-01-00       0               P
 3      28-40-00-00-04-00       3


According to the output, the first item in NDIS_802_11_BSSID_LIST struct, i.e, Bssid[0], is correct.  Unfortunately, I can not get the right address for Bssid[1] and Bssid[2].  How to get the right address?  Or the kernel only return the first AP's information indeed?

Thank you!

-Liang

typedef struct _NDIS_802_11_BSSID_LIST
{
    ULONG           NumberOfItems;      // in list below, at least 1
    NDIS_WLAN_BSSID Bssid[1];
} NDIS_802_11_BSSID_LIST, *PNDIS_802_11_BSSID_LIST;
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Programming
Question Asked By: overlook
Solution Provided By: jhance
Participating Experts: 2
Solution Grade: A
Views: 28
Translate:
Loading Advertisement...
 
[+][-]Accepted Solution by jhance
Accepted Solution by jhance:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Assisted Solution by opanza
Assisted Solution by opanza:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34