This source file includes following definitions.
- ConvertToAccessPointData
- GetDataFromBssIdList
#include "content/browser/geolocation/wifi_data_provider_common_win.h"
#include <assert.h>
#include "base/strings/utf_string_conversions.h"
#include "content/browser/geolocation/wifi_data_provider_common.h"
namespace content {
bool ConvertToAccessPointData(const NDIS_WLAN_BSSID& data,
AccessPointData *access_point_data) {
DCHECK(access_point_data);
access_point_data->mac_address = MacAddressAsString16(data.MacAddress);
access_point_data->radio_signal_strength = data.Rssi;
base::UTF8ToUTF16(reinterpret_cast<const char*>(data.Ssid.Ssid),
data.Ssid.SsidLength,
&access_point_data->ssid);
return true;
}
int GetDataFromBssIdList(const NDIS_802_11_BSSID_LIST& bss_id_list,
int list_size,
WifiData::AccessPointDataSet* data) {
int found = 0;
const uint8 *iterator = reinterpret_cast<const uint8*>(&bss_id_list.Bssid[0]);
const uint8 *end_of_buffer =
reinterpret_cast<const uint8*>(&bss_id_list) + list_size;
for (int i = 0; i < static_cast<int>(bss_id_list.NumberOfItems); ++i) {
const NDIS_WLAN_BSSID *bss_id =
reinterpret_cast<const NDIS_WLAN_BSSID*>(iterator);
if (bss_id->Length < sizeof(NDIS_WLAN_BSSID) ||
iterator + bss_id->Length > end_of_buffer) {
break;
}
AccessPointData access_point_data;
if (ConvertToAccessPointData(*bss_id, &access_point_data)) {
data->insert(access_point_data);
++found;
}
iterator += bss_id->Length;
}
return found;
}
}