• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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 #include "android/net/wifi/IWifiScannerImpl.h"
18 #include "wificond/scanning/scan_utils.h"
19 
20 #include <array>
21 #include <vector>
22 
23 #include <linux/netlink.h>
24 #include <linux/if_ether.h>
25 
26 #include <android-base/logging.h>
27 
28 #include "wificond/net/kernel-header-latest/nl80211.h"
29 #include "wificond/net/netlink_manager.h"
30 #include "wificond/net/nl80211_packet.h"
31 #include "wificond/scanning/scan_result.h"
32 
33 using android::net::wifi::IWifiScannerImpl;
34 using com::android::server::wifi::wificond::NativeScanResult;
35 using com::android::server::wifi::wificond::RadioChainInfo;
36 using std::array;
37 using std::unique_ptr;
38 using std::vector;
39 
40 namespace android {
41 namespace wificond {
42 namespace {
43 
44 constexpr uint8_t kElemIdSsid = 0;
45 constexpr unsigned int kMsecPerSec = 1000;
46 
47 }  // namespace
48 
ScanUtils(NetlinkManager * netlink_manager)49 ScanUtils::ScanUtils(NetlinkManager* netlink_manager)
50     : netlink_manager_(netlink_manager) {
51   if (!netlink_manager_->IsStarted()) {
52     netlink_manager_->Start();
53   }
54 }
55 
~ScanUtils()56 ScanUtils::~ScanUtils() {}
57 
SubscribeScanResultNotification(uint32_t interface_index,OnScanResultsReadyHandler handler)58 void ScanUtils::SubscribeScanResultNotification(
59     uint32_t interface_index,
60     OnScanResultsReadyHandler handler) {
61   netlink_manager_->SubscribeScanResultNotification(interface_index, handler);
62 }
63 
UnsubscribeScanResultNotification(uint32_t interface_index)64 void ScanUtils::UnsubscribeScanResultNotification(uint32_t interface_index) {
65   netlink_manager_->UnsubscribeScanResultNotification(interface_index);
66 }
67 
SubscribeSchedScanResultNotification(uint32_t interface_index,OnSchedScanResultsReadyHandler handler)68 void ScanUtils::SubscribeSchedScanResultNotification(
69     uint32_t interface_index,
70     OnSchedScanResultsReadyHandler handler) {
71   netlink_manager_->SubscribeSchedScanResultNotification(interface_index,
72                                                          handler);
73 }
74 
UnsubscribeSchedScanResultNotification(uint32_t interface_index)75 void ScanUtils::UnsubscribeSchedScanResultNotification(
76     uint32_t interface_index) {
77   netlink_manager_->UnsubscribeSchedScanResultNotification(interface_index);
78 }
79 
GetScanResult(uint32_t interface_index,vector<NativeScanResult> * out_scan_results)80 bool ScanUtils::GetScanResult(uint32_t interface_index,
81                               vector<NativeScanResult>* out_scan_results) {
82   NL80211Packet get_scan(
83       netlink_manager_->GetFamilyId(),
84       NL80211_CMD_GET_SCAN,
85       netlink_manager_->GetSequenceNumber(),
86       getpid());
87   get_scan.AddFlag(NLM_F_DUMP);
88   NL80211Attr<uint32_t> ifindex(NL80211_ATTR_IFINDEX, interface_index);
89   get_scan.AddAttribute(ifindex);
90 
91   vector<unique_ptr<const NL80211Packet>> response;
92   if (!netlink_manager_->SendMessageAndGetResponses(get_scan, &response))  {
93     LOG(ERROR) << "NL80211_CMD_GET_SCAN dump failed";
94     return false;
95   }
96   if (response.empty()) {
97     LOG(INFO) << "Unexpected empty scan result!";
98     return true;
99   }
100 
101   for (auto& packet : response) {
102     if (packet->GetMessageType() == NLMSG_ERROR) {
103       LOG(ERROR) << "Receive ERROR message: "
104                  << strerror(packet->GetErrorCode());
105       continue;
106     }
107     if (packet->GetMessageType() != netlink_manager_->GetFamilyId()) {
108       LOG(ERROR) << "Wrong message type: "
109                  << packet->GetMessageType();
110       continue;
111     }
112     uint32_t if_index;
113     if (!packet->GetAttributeValue(NL80211_ATTR_IFINDEX, &if_index)) {
114       LOG(ERROR) << "No interface index in scan result.";
115       continue;
116     }
117     if (if_index != interface_index) {
118       LOG(WARNING) << "Uninteresting scan result for interface: " << if_index;
119       continue;
120     }
121 
122     NativeScanResult scan_result;
123     if (!ParseScanResult(std::move(packet), &scan_result)) {
124       LOG(DEBUG) << "Ignore invalid scan result";
125       continue;
126     }
127     out_scan_results->push_back(std::move(scan_result));
128   }
129   return true;
130 }
131 
ParseScanResult(unique_ptr<const NL80211Packet> packet,NativeScanResult * scan_result)132 bool ScanUtils::ParseScanResult(unique_ptr<const NL80211Packet> packet,
133                                 NativeScanResult* scan_result) {
134   if (packet->GetCommand() != NL80211_CMD_NEW_SCAN_RESULTS) {
135     LOG(ERROR) << "Wrong command command for new scan result message";
136     return false;
137   }
138   NL80211NestedAttr bss(0);
139   if (packet->GetAttribute(NL80211_ATTR_BSS, &bss)) {
140     array<uint8_t, ETH_ALEN> bssid;
141     if (!bss.GetAttributeValue(NL80211_BSS_BSSID, &bssid)) {
142       LOG(ERROR) << "Failed to get BSSID from scan result packet";
143       return false;
144     }
145     uint32_t freq;
146     if (!bss.GetAttributeValue(NL80211_BSS_FREQUENCY, &freq)) {
147       LOG(ERROR) << "Failed to get Frequency from scan result packet";
148       return false;
149     }
150     vector<uint8_t> ie;
151     if (!bss.GetAttributeValue(NL80211_BSS_INFORMATION_ELEMENTS, &ie)) {
152       LOG(ERROR) << "Failed to get Information Element from scan result packet";
153       return false;
154     }
155     vector<uint8_t> ssid;
156     if (!GetSSIDFromInfoElement(ie, &ssid)) {
157       // Skip BSS without SSID IE.
158       // These scan results are considered as malformed.
159       return false;
160     }
161     uint64_t last_seen_since_boot_microseconds;
162     if (!GetBssTimestamp(bss, &last_seen_since_boot_microseconds)) {
163       // Logging is done inside |GetBssTimestamp|.
164       return false;
165     }
166     int32_t signal;
167     if (!bss.GetAttributeValue(NL80211_BSS_SIGNAL_MBM, &signal)) {
168       LOG(ERROR) << "Failed to get Signal Strength from scan result packet";
169       return false;
170     }
171     uint16_t capability;
172     if (!bss.GetAttributeValue(NL80211_BSS_CAPABILITY, &capability)) {
173       LOG(ERROR) << "Failed to get capability field from scan result packet";
174       return false;
175     }
176     bool associated = false;
177     uint32_t bss_status;
178     if (bss.GetAttributeValue(NL80211_BSS_STATUS, &bss_status) &&
179             (bss_status == NL80211_BSS_STATUS_AUTHENTICATED ||
180                 bss_status == NL80211_BSS_STATUS_ASSOCIATED)) {
181       associated = true;
182     }
183     std::vector<RadioChainInfo> radio_chain_infos;
184     ParseRadioChainInfos(bss, &radio_chain_infos);
185 
186     *scan_result =
187         NativeScanResult(ssid, bssid, ie, freq, signal,
188                          last_seen_since_boot_microseconds,
189                          capability, associated, radio_chain_infos);
190   }
191   return true;
192 }
193 
GetBssTimestampForTesting(const NL80211NestedAttr & bss,uint64_t * last_seen_since_boot_microseconds)194 bool ScanUtils::GetBssTimestampForTesting(
195     const NL80211NestedAttr& bss,
196     uint64_t* last_seen_since_boot_microseconds){
197   return GetBssTimestamp(bss, last_seen_since_boot_microseconds);
198 }
199 
GetBssTimestamp(const NL80211NestedAttr & bss,uint64_t * last_seen_since_boot_microseconds)200 bool ScanUtils::GetBssTimestamp(const NL80211NestedAttr& bss,
201                                 uint64_t* last_seen_since_boot_microseconds){
202   uint64_t last_seen_since_boot_nanoseconds;
203   if (bss.GetAttributeValue(NL80211_BSS_LAST_SEEN_BOOTTIME,
204                             &last_seen_since_boot_nanoseconds)) {
205     *last_seen_since_boot_microseconds = last_seen_since_boot_nanoseconds / 1000;
206   } else {
207     // Fall back to use TSF if we can't find NL80211_BSS_LAST_SEEN_BOOTTIME
208     // attribute.
209     if (!bss.GetAttributeValue(NL80211_BSS_TSF, last_seen_since_boot_microseconds)) {
210       LOG(ERROR) << "Failed to get TSF from scan result packet";
211       return false;
212     }
213     uint64_t beacon_tsf_microseconds;
214     if (bss.GetAttributeValue(NL80211_BSS_BEACON_TSF, &beacon_tsf_microseconds)) {
215       *last_seen_since_boot_microseconds = std::max(*last_seen_since_boot_microseconds,
216                                                     beacon_tsf_microseconds);
217     }
218   }
219   return true;
220 }
221 
ParseRadioChainInfos(const NL80211NestedAttr & bss,std::vector<RadioChainInfo> * radio_chain_infos)222 bool ScanUtils::ParseRadioChainInfos(
223     const NL80211NestedAttr& bss,
224     std::vector<RadioChainInfo> *radio_chain_infos) {
225   *radio_chain_infos = {};
226   // Contains a nested array of signal strength attributes: (ChainId, Rssi in dBm)
227   NL80211NestedAttr radio_chain_infos_attr(0);
228   if (!bss.GetAttribute(NL80211_BSS_CHAIN_SIGNAL, &radio_chain_infos_attr)) {
229     return false;
230   }
231   std::vector<NL80211Attr<int8_t>> radio_chain_infos_attrs;
232   if (!radio_chain_infos_attr.GetListOfAttributes(
233         &radio_chain_infos_attrs)) {
234     LOG(ERROR) << "Failed to get radio chain info attrs within "
235                << "NL80211_BSS_CHAIN_SIGNAL";
236     return false;
237   }
238   for (const auto& attr : radio_chain_infos_attrs) {
239     RadioChainInfo radio_chain_info;
240     radio_chain_info.chain_id = attr.GetAttributeId();
241     radio_chain_info.level = attr.GetValue();
242     radio_chain_infos->push_back(radio_chain_info);
243   }
244   return true;
245 }
246 
GetSSIDFromInfoElement(const vector<uint8_t> & ie,vector<uint8_t> * ssid)247 bool ScanUtils::GetSSIDFromInfoElement(const vector<uint8_t>& ie,
248                                        vector<uint8_t>* ssid) {
249   // Information elements are stored in 'TLV' format.
250   // Field:  |   Type     |          Length           |      Value      |
251   // Length: |     1      |             1             |     variable    |
252   // Content:| Element ID | Length of the Value field | Element payload |
253   const uint8_t* end = ie.data() + ie.size();
254   const uint8_t* ptr = ie.data();
255   // +1 means we must have space for the length field.
256   while (ptr + 1  < end) {
257     uint8_t type = *ptr;
258     uint8_t length = *(ptr + 1);
259     // Length field is invalid.
260     if (ptr + 1 + length >= end) {
261       return false;
262     }
263     // SSID element is found.
264     if (type == kElemIdSsid) {
265       // SSID is an empty string.
266       if (length == 0) {
267         *ssid = vector<uint8_t>();
268       } else {
269         *ssid = vector<uint8_t>(ptr + 2, ptr + length + 2);
270       }
271       return true;
272     }
273     ptr += 2 + length;
274   }
275   return false;
276 }
277 
Scan(uint32_t interface_index,bool request_random_mac,int scan_type,const vector<vector<uint8_t>> & ssids,const vector<uint32_t> & freqs,int * error_code)278 bool ScanUtils::Scan(uint32_t interface_index,
279                      bool request_random_mac,
280                      int scan_type,
281                      const vector<vector<uint8_t>>& ssids,
282                      const vector<uint32_t>& freqs,
283                      int* error_code) {
284   NL80211Packet trigger_scan(
285       netlink_manager_->GetFamilyId(),
286       NL80211_CMD_TRIGGER_SCAN,
287       netlink_manager_->GetSequenceNumber(),
288       getpid());
289   // If we do not use NLM_F_ACK, we only receive a unicast repsonse
290   // when there is an error. If everything is good, scan results notification
291   // will only be sent through multicast.
292   // If NLM_F_ACK is set, there will always be an unicast repsonse, either an
293   // ERROR or an ACK message. The handler will always be called and removed by
294   // NetlinkManager.
295   trigger_scan.AddFlag(NLM_F_ACK);
296   NL80211Attr<uint32_t> if_index_attr(NL80211_ATTR_IFINDEX, interface_index);
297 
298   NL80211NestedAttr ssids_attr(NL80211_ATTR_SCAN_SSIDS);
299   for (size_t i = 0; i < ssids.size(); i++) {
300     ssids_attr.AddAttribute(NL80211Attr<vector<uint8_t>>(i, ssids[i]));
301   }
302   NL80211NestedAttr freqs_attr(NL80211_ATTR_SCAN_FREQUENCIES);
303   for (size_t i = 0; i < freqs.size(); i++) {
304     freqs_attr.AddAttribute(NL80211Attr<uint32_t>(i, freqs[i]));
305   }
306 
307   trigger_scan.AddAttribute(if_index_attr);
308   trigger_scan.AddAttribute(ssids_attr);
309   // An absence of NL80211_ATTR_SCAN_FREQUENCIES attribue informs kernel to
310   // scan all supported frequencies.
311   if (!freqs.empty()) {
312     trigger_scan.AddAttribute(freqs_attr);
313   }
314 
315   uint32_t scan_flags = 0;
316   if (request_random_mac) {
317     scan_flags |= NL80211_SCAN_FLAG_RANDOM_ADDR;
318   }
319   switch (scan_type) {
320     case IWifiScannerImpl::SCAN_TYPE_LOW_SPAN:
321       scan_flags |= NL80211_SCAN_FLAG_LOW_SPAN;
322       break;
323     case IWifiScannerImpl::SCAN_TYPE_LOW_POWER:
324       scan_flags |= NL80211_SCAN_FLAG_LOW_POWER;
325       break;
326     case IWifiScannerImpl::SCAN_TYPE_HIGH_ACCURACY:
327       scan_flags |= NL80211_SCAN_FLAG_HIGH_ACCURACY;
328       break;
329     case IWifiScannerImpl::SCAN_TYPE_DEFAULT:
330       break;
331     default:
332       CHECK(0) << "Invalid scan type received: " << scan_type;
333   }
334   if (scan_flags) {
335     trigger_scan.AddAttribute(
336         NL80211Attr<uint32_t>(NL80211_ATTR_SCAN_FLAGS,
337                               scan_flags));
338   }
339   // We are receiving an ERROR/ACK message instead of the actual
340   // scan results here, so it is OK to expect a timely response because
341   // kernel is supposed to send the ERROR/ACK back before the scan starts.
342   vector<unique_ptr<const NL80211Packet>> response;
343   if (!netlink_manager_->SendMessageAndGetAckOrError(trigger_scan,
344                                                      error_code)) {
345     // Logging is done inside |SendMessageAndGetAckOrError|.
346     return false;
347   }
348   if (*error_code != 0) {
349     LOG(ERROR) << "NL80211_CMD_TRIGGER_SCAN failed: " << strerror(*error_code);
350     return false;
351   }
352   return true;
353 }
354 
StopScheduledScan(uint32_t interface_index)355 bool ScanUtils::StopScheduledScan(uint32_t interface_index) {
356   NL80211Packet stop_sched_scan(
357       netlink_manager_->GetFamilyId(),
358       NL80211_CMD_STOP_SCHED_SCAN,
359       netlink_manager_->GetSequenceNumber(),
360       getpid());
361   // Force an ACK response upon success.
362   stop_sched_scan.AddFlag(NLM_F_ACK);
363   stop_sched_scan.AddAttribute(
364       NL80211Attr<uint32_t>(NL80211_ATTR_IFINDEX, interface_index));
365   vector<unique_ptr<const NL80211Packet>> response;
366   int error_code;
367   if (!netlink_manager_->SendMessageAndGetAckOrError(stop_sched_scan,
368                                                      &error_code))  {
369     LOG(ERROR) << "NL80211_CMD_STOP_SCHED_SCAN failed";
370     return false;
371   }
372   if (error_code == ENOENT) {
373     LOG(WARNING) << "Scheduled scan is not running!";
374     return false;
375   } else if (error_code != 0) {
376     LOG(ERROR) << "Receive ERROR message in response to"
377                << " 'stop scheduled scan' request: "
378                << strerror(error_code);
379     return false;
380   }
381   return true;
382 }
383 
AbortScan(uint32_t interface_index)384 bool ScanUtils::AbortScan(uint32_t interface_index) {
385   NL80211Packet abort_scan(
386       netlink_manager_->GetFamilyId(),
387       NL80211_CMD_ABORT_SCAN,
388       netlink_manager_->GetSequenceNumber(),
389       getpid());
390 
391   // Force an ACK response upon success.
392   abort_scan.AddFlag(NLM_F_ACK);
393   abort_scan.AddAttribute(
394       NL80211Attr<uint32_t>(NL80211_ATTR_IFINDEX, interface_index));
395 
396   if (!netlink_manager_->SendMessageAndGetAck(abort_scan)) {
397     LOG(ERROR) << "NL80211_CMD_ABORT_SCAN failed";
398     return false;
399   }
400   return true;
401 }
402 
StartScheduledScan(uint32_t interface_index,const SchedScanIntervalSetting & interval_setting,int32_t rssi_threshold_2g,int32_t rssi_threshold_5g,const SchedScanReqFlags & req_flags,const std::vector<std::vector<uint8_t>> & scan_ssids,const std::vector<std::vector<uint8_t>> & match_ssids,const std::vector<uint32_t> & freqs,int * error_code)403 bool ScanUtils::StartScheduledScan(
404     uint32_t interface_index,
405     const SchedScanIntervalSetting& interval_setting,
406     int32_t rssi_threshold_2g,
407     int32_t rssi_threshold_5g,
408     const SchedScanReqFlags& req_flags,
409     const std::vector<std::vector<uint8_t>>& scan_ssids,
410     const std::vector<std::vector<uint8_t>>& match_ssids,
411     const std::vector<uint32_t>& freqs,
412     int* error_code) {
413   NL80211Packet start_sched_scan(
414       netlink_manager_->GetFamilyId(),
415       NL80211_CMD_START_SCHED_SCAN,
416       netlink_manager_->GetSequenceNumber(),
417       getpid());
418   // Force an ACK response upon success.
419   start_sched_scan.AddFlag(NLM_F_ACK);
420 
421   NL80211NestedAttr scan_ssids_attr(NL80211_ATTR_SCAN_SSIDS);
422   for (size_t i = 0; i < scan_ssids.size(); i++) {
423     scan_ssids_attr.AddAttribute(NL80211Attr<vector<uint8_t>>(i, scan_ssids[i]));
424   }
425   NL80211NestedAttr freqs_attr(NL80211_ATTR_SCAN_FREQUENCIES);
426   for (size_t i = 0; i < freqs.size(); i++) {
427     freqs_attr.AddAttribute(NL80211Attr<uint32_t>(i, freqs[i]));
428   }
429 
430   //   Structure of attributes of scheduled scan filters:
431   // |                                Nested Attribute: id: NL80211_ATTR_SCHED_SCAN_MATCH                           |
432   // |     Nested Attributed: id: 0       |    Nested Attributed: id: 1         |      Nested Attr: id: 2     | ... |
433   // | MATCH_SSID  | MATCH_RSSI(optional) | MATCH_SSID  | MACTCH_RSSI(optional) | MATCH_RSSI(optinal, global) | ... |
434   NL80211NestedAttr scan_match_attr(NL80211_ATTR_SCHED_SCAN_MATCH);
435   for (size_t i = 0; i < match_ssids.size(); i++) {
436     NL80211NestedAttr match_group(i);
437     match_group.AddAttribute(
438         NL80211Attr<vector<uint8_t>>(NL80211_SCHED_SCAN_MATCH_ATTR_SSID, match_ssids[i]));
439     match_group.AddAttribute(
440         NL80211Attr<int32_t>(NL80211_SCHED_SCAN_MATCH_ATTR_RSSI, rssi_threshold_5g));
441     scan_match_attr.AddAttribute(match_group);
442   }
443   start_sched_scan.AddAttribute(scan_match_attr);
444 
445   // We set 5g threshold for default and ajust threshold for 2g band.
446   // check sched_scan supported before set NL80211_ATTR_SCHED_SCAN_RSSI_ADJUST attribute.
447   if (req_flags.request_sched_scan_relative_rssi) {
448       struct nl80211_bss_select_rssi_adjust rssi_adjust;
449       rssi_adjust.band = NL80211_BAND_2GHZ;
450       rssi_adjust.delta = static_cast<int8_t>(rssi_threshold_2g - rssi_threshold_5g);
451       NL80211Attr<vector<uint8_t>> rssi_adjust_attr(
452           NL80211_ATTR_SCHED_SCAN_RSSI_ADJUST,
453           vector<uint8_t>(
454               reinterpret_cast<uint8_t*>(&rssi_adjust),
455               reinterpret_cast<uint8_t*>(&rssi_adjust) + sizeof(rssi_adjust)));
456       start_sched_scan.AddAttribute(rssi_adjust_attr);
457   }
458 
459   // Append all attributes to the NL80211_CMD_START_SCHED_SCAN packet.
460   start_sched_scan.AddAttribute(
461       NL80211Attr<uint32_t>(NL80211_ATTR_IFINDEX, interface_index));
462   start_sched_scan.AddAttribute(scan_ssids_attr);
463   // An absence of NL80211_ATTR_SCAN_FREQUENCIES attribue informs kernel to
464   // scan all supported frequencies.
465   if (!freqs.empty()) {
466     start_sched_scan.AddAttribute(freqs_attr);
467   }
468 
469   if (!interval_setting.plans.empty()) {
470     NL80211NestedAttr scan_plans(NL80211_ATTR_SCHED_SCAN_PLANS);
471     for (unsigned int i = 0; i < interval_setting.plans.size(); i++) {
472       NL80211NestedAttr scan_plan(i + 1);
473       scan_plan.AddAttribute(
474           NL80211Attr<uint32_t>(NL80211_SCHED_SCAN_PLAN_INTERVAL,
475                                 interval_setting.plans[i].interval_ms / kMsecPerSec));
476       scan_plan.AddAttribute(
477           NL80211Attr<uint32_t>(NL80211_SCHED_SCAN_PLAN_ITERATIONS,
478                                 interval_setting.plans[i].n_iterations));
479       scan_plans.AddAttribute(scan_plan);
480     }
481     NL80211NestedAttr last_scan_plan(interval_setting.plans.size() + 1);
482     last_scan_plan.AddAttribute(
483         NL80211Attr<uint32_t>(NL80211_SCHED_SCAN_PLAN_INTERVAL,
484                               interval_setting.final_interval_ms / kMsecPerSec));
485     scan_plans.AddAttribute(last_scan_plan);
486     start_sched_scan.AddAttribute(scan_plans);
487   } else {
488     start_sched_scan.AddAttribute(
489         NL80211Attr<uint32_t>(NL80211_ATTR_SCHED_SCAN_INTERVAL,
490                               interval_setting.final_interval_ms));
491   }
492   uint32_t scan_flags = 0;
493   if (req_flags.request_random_mac) {
494     scan_flags |= NL80211_SCAN_FLAG_RANDOM_ADDR;
495   }
496   if (req_flags.request_low_power) {
497     scan_flags |= NL80211_SCAN_FLAG_LOW_POWER;
498   }
499   if (scan_flags) {
500     start_sched_scan.AddAttribute(
501         NL80211Attr<uint32_t>(NL80211_ATTR_SCAN_FLAGS,
502                               scan_flags));
503   }
504 
505   vector<unique_ptr<const NL80211Packet>> response;
506   if (!netlink_manager_->SendMessageAndGetAckOrError(start_sched_scan,
507                                                      error_code)) {
508     // Logging is done inside |SendMessageAndGetAckOrError|.
509     return false;
510   }
511   if (*error_code != 0) {
512     LOG(ERROR) << "NL80211_CMD_START_SCHED_SCAN failed: " << strerror(*error_code);
513     return false;
514   }
515 
516   return true;
517 }
518 
519 }  // namespace wificond
520 }  // namespace android
521