1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef CHRE_WIFI_OFFLOAD_SCAN_RESULT_H_ 18 #define CHRE_WIFI_OFFLOAD_SCAN_RESULT_H_ 19 20 // First to pickup the LOG_TAG 21 #include "chre/apps/wifi_offload/wifi_offload.h" 22 23 #include "chre/apps/wifi_offload/flatbuffers_types_generated.h" 24 #include "chre/apps/wifi_offload/preferred_network.h" 25 #include "chre/apps/wifi_offload/ssid.h" 26 27 namespace wifi_offload { 28 29 /** 30 * Scan Results returned by offload nanoapp to the offload HAL 31 */ 32 class ScanResult { 33 public: 34 /** 35 * This is a bit mask describing the capabilities of a BSS. 36 * See IEEE Std 802.11: 8.4.1.4 37 */ 38 enum Capability : uint16_t { 39 UNKNOWN = 0, 40 ESS = 1 << 0, 41 IBSS = 1 << 1, 42 CF_POLLABLE = 1 << 2, 43 CF_POLL_REQ = 1 << 3, 44 PRIVACY = 1 << 4, 45 SHORT_PREAMBLE = 1 << 5, 46 PBCC = 1 << 6, 47 CHANNEL_AGILITY = 1 << 7, 48 SPECTURM_MGMT = 1 << 8, 49 QOS = 1 << 9, 50 SHORT_SLOT_TIME = 1 << 10, 51 APSD = 1 << 11, 52 RADIO_MEASUREMENT = 1 << 12, 53 DSSS_OFDM = 1 << 13, 54 DELAYED_BLOCK_ACK = 1 << 14, 55 IMMEDIATE_BLOCK_ACK = 1 << 15, 56 ALL_CAPABILITIES_MASK = 0xffff, 57 }; 58 59 /* Corresponding flatbuffers-generated data-type used to serialize and 60 * deserialize instances of this class */ 61 using FbsType = fbs::ScanResult; 62 63 static constexpr int kBssidSize = CHRE_WIFI_BSSID_LEN; 64 65 ScanResult(); 66 67 ScanResult(const ScanResult &other); 68 69 ScanResult(ScanResult &&other) = default; 70 71 explicit ScanResult(const chreWifiScanResult &chre_scan_result); 72 73 ~ScanResult() = default; 74 75 bool operator==(const ScanResult &other) const; 76 77 flatbuffers::Offset<ScanResult::FbsType> Serialize( 78 flatbuffers::FlatBufferBuilder *builder) const; 79 80 bool Deserialize(const ScanResult::FbsType &fbs_result); 81 82 void Log() const; 83 84 Ssid ssid_; 85 uint8_t security_modes_; // SecurityMode flags, see SecurityMode 86 uint8_t bssid_[kBssidSize]; 87 uint16_t capability_; // Can have multiple bits set, see Capability 88 uint32_t frequency_scanned_mhz_; 89 int8_t rssi_dbm_; // Signal strength 90 uint64_t tsf_; // TSF found in beacon/probe response 91 92 private: 93 void UpdateFromChreWifiScanResult(const chreWifiScanResult &chre_scan_result); 94 }; 95 96 } // namespace wifi_offload 97 98 #endif // CHRE_WIFI_OFFLOAD_SCAN_RESULT_H_ 99