internal static List <IAccessPoint> GetAPs(string adapterName) { var apList = new List <IAccessPoint>(); INTF_ENTRY entry = new INTF_ENTRY(); entry.Guid = adapterName; INTF_FLAGS flags = 0; int result = WZCQueryInterface(null, INTF_FLAGS.INTF_ALL, ref entry, out flags); if (result != 0) { entry.Dispose(); throw new Exception("WZCQueryInterface failed for " + adapterName); } try { // Figure out how many SSIDs there are. if (entry.rdBSSIDList.cbData == 0) { // list is empty return(apList); } NDIS_802_11_BSSID_LIST rawlist = new NDIS_802_11_BSSID_LIST(entry.rdBSSIDList.lpData, true); for (int i = 0; i < rawlist.NumberOfItems; i++) { // Get the next raw item from the list. BSSID bssid = rawlist.Item(i); // Using the raw item, create a cooked // SSID item. AccessPoint ssid = new AccessPoint(bssid); // Add the new item to this. apList.Add(ssid); } return(apList); } finally { WZCDeleteIntfObj(ref entry); } }
internal unsafe void RefreshListPreferred(bool nearbyOnly) { // If the caller wants only the local preferred APs, // we check nearby list and, if the AP is not there, // we don't add it to our own preferred list. AccessPointCollection apc = null; if (nearbyOnly) { apc = m_adapter.NearbyAccessPoints; } // First step is to get the INTF_ENTRY for the adapter. // This includes the list of preferred SSID values. INTF_ENTRY ie = INTF_ENTRY.GetEntry(this.m_adapter.Name); // The field rdStSSIDList is the preferred list. It comes // in the form of a WZC_802_11_CONFIG_LIST. RAW_DATA rd = ie.rdStSSIDList; WLANConfigurationList cl = new WLANConfigurationList(rd); // Step through the list and add a new AP to the // collection for each entry. for (int i = 0; i < cl.NumberOfItems; i++) { WLANConfiguration c = cl.Item(i); //Debug.WriteLine(c.SSID); //for (int d = 1; d <= c.Data.Length; d++) //{ // Debug.Write(string.Format("{0:x2}{1}", c.Data[d - 1], (d%8 == 0) ? "\r\n" : " ")); //} //Debug.WriteLine(string.Empty); // If we're only showing those which we can hear, // see if the current SSID is in the nearby list. if (nearbyOnly) { // Find the currently active AP with the SSID // to match the one we're working on. AccessPoint activeAP = apc.FindBySSID(c.SSID); int ss; // If the given SSID is not in range, don't add // an entry to the list. if (activeAP != null) { // Update signal strength. ss = activeAP.SignalStrengthInDecibels; // Copy the signal strength value to the // NDIS_WLAN_BSSID structure for the // preferred list entry. c.Rssi = ss; // Create the AP instance and add it to the // preferred list. AccessPoint ap = new AccessPoint(c); m_aps.Add(ap); } } else { // Create the AP instance and add it to the // preferred list. The signal strength will // not necessarily be valid. AccessPoint ap = new AccessPoint(c); m_aps.Add(ap); } } // Dispose of INTF_ENTRY ie.Dispose(); }