blob: f67aaa3dadef4af58503170effa134aca3b35463 [file] [log] [blame]
Gabriel Biren72cf9a52021-06-25 23:29:26 +00001/*
2 * aidl interface for wpa_hostapd daemon
3 * Copyright (c) 2004-2018, Jouni Malinen <j@w1.fi>
4 * Copyright (c) 2004-2018, Roshan Pius <rpius@google.com>
5 *
6 * This software may be distributed under the terms of the BSD license.
7 * See README for more details.
8 */
9#include <iomanip>
10#include <sstream>
11#include <string>
12#include <vector>
13#include <net/if.h>
14#include <sys/socket.h>
15#include <linux/if_bridge.h>
16
17#include <android-base/file.h>
18#include <android-base/stringprintf.h>
19#include <android-base/unique_fd.h>
20
21#include "hostapd.h"
22#include <aidl/android/hardware/wifi/hostapd/ApInfo.h>
23#include <aidl/android/hardware/wifi/hostapd/BandMask.h>
24#include <aidl/android/hardware/wifi/hostapd/ChannelParams.h>
25#include <aidl/android/hardware/wifi/hostapd/ClientInfo.h>
26#include <aidl/android/hardware/wifi/hostapd/EncryptionType.h>
27#include <aidl/android/hardware/wifi/hostapd/HostapdStatusCode.h>
28#include <aidl/android/hardware/wifi/hostapd/IfaceParams.h>
29#include <aidl/android/hardware/wifi/hostapd/NetworkParams.h>
30#include <aidl/android/hardware/wifi/hostapd/ParamSizeLimits.h>
31
32extern "C"
33{
34#include "common/wpa_ctrl.h"
35#include "drivers/linux_ioctl.h"
36}
37
38// The AIDL implementation for hostapd creates a hostapd.conf dynamically for
39// each interface. This file can then be used to hook onto the normal config
40// file parsing logic in hostapd code. Helps us to avoid duplication of code
41// in the AIDL interface.
42// TOOD(b/71872409): Add unit tests for this.
43namespace {
44constexpr char kConfFileNameFmt[] = "/data/vendor/wifi/hostapd/hostapd_%s.conf";
45
46using android::base::RemoveFileIfExists;
47using android::base::StringPrintf;
48using android::base::WriteStringToFile;
49using aidl::android::hardware::wifi::hostapd::BandMask;
Ahmed ElArabawyb4115792022-02-08 09:33:01 -080050using aidl::android::hardware::wifi::hostapd::ChannelBandwidth;
Gabriel Biren72cf9a52021-06-25 23:29:26 +000051using aidl::android::hardware::wifi::hostapd::ChannelParams;
52using aidl::android::hardware::wifi::hostapd::EncryptionType;
53using aidl::android::hardware::wifi::hostapd::Generation;
54using aidl::android::hardware::wifi::hostapd::HostapdStatusCode;
55using aidl::android::hardware::wifi::hostapd::IfaceParams;
56using aidl::android::hardware::wifi::hostapd::NetworkParams;
57using aidl::android::hardware::wifi::hostapd::ParamSizeLimits;
58
59int band2Ghz = (int)BandMask::BAND_2_GHZ;
60int band5Ghz = (int)BandMask::BAND_5_GHZ;
61int band6Ghz = (int)BandMask::BAND_6_GHZ;
62int band60Ghz = (int)BandMask::BAND_60_GHZ;
63
64#define MAX_PORTS 1024
65bool GetInterfacesInBridge(std::string br_name,
66 std::vector<std::string>* interfaces) {
67 android::base::unique_fd sock(socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0));
68 if (sock.get() < 0) {
69 wpa_printf(MSG_ERROR, "Failed to create sock (%s) in %s",
70 strerror(errno), __FUNCTION__);
71 return false;
72 }
73
74 struct ifreq request;
75 int i, ifindices[MAX_PORTS];
76 char if_name[IFNAMSIZ];
77 unsigned long args[3];
78
79 memset(ifindices, 0, MAX_PORTS * sizeof(int));
80
81 args[0] = BRCTL_GET_PORT_LIST;
82 args[1] = (unsigned long) ifindices;
83 args[2] = MAX_PORTS;
84
85 strlcpy(request.ifr_name, br_name.c_str(), IFNAMSIZ);
86 request.ifr_data = (char *)args;
87
88 if (ioctl(sock.get(), SIOCDEVPRIVATE, &request) < 0) {
89 wpa_printf(MSG_ERROR, "Failed to ioctl SIOCDEVPRIVATE in %s",
90 __FUNCTION__);
91 return false;
92 }
93
94 for (i = 0; i < MAX_PORTS; i ++) {
95 memset(if_name, 0, IFNAMSIZ);
96 if (ifindices[i] == 0 || !if_indextoname(ifindices[i], if_name)) {
97 continue;
98 }
99 interfaces->push_back(if_name);
100 }
101 return true;
102}
103
104std::string WriteHostapdConfig(
105 const std::string& interface_name, const std::string& config)
106{
107 const std::string file_path =
108 StringPrintf(kConfFileNameFmt, interface_name.c_str());
109 if (WriteStringToFile(
110 config, file_path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
111 getuid(), getgid())) {
112 return file_path;
113 }
114 // Diagnose failure
115 int error = errno;
116 wpa_printf(
117 MSG_ERROR, "Cannot write hostapd config to %s, error: %s",
118 file_path.c_str(), strerror(error));
119 struct stat st;
120 int result = stat(file_path.c_str(), &st);
121 if (result == 0) {
122 wpa_printf(
123 MSG_ERROR, "hostapd config file uid: %d, gid: %d, mode: %d",
124 st.st_uid, st.st_gid, st.st_mode);
125 } else {
126 wpa_printf(
127 MSG_ERROR,
128 "Error calling stat() on hostapd config file: %s",
129 strerror(errno));
130 }
131 return "";
132}
133
134/*
135 * Get the op_class for a channel/band
136 * The logic here is based on Table E-4 in the 802.11 Specification
137 */
138int getOpClassForChannel(int channel, int band, bool support11n, bool support11ac) {
139 // 2GHz Band
140 if ((band & band2Ghz) != 0) {
141 if (channel == 14) {
142 return 82;
143 }
144 if (channel >= 1 && channel <= 13) {
145 if (!support11n) {
146 //20MHz channel
147 return 81;
148 }
149 if (channel <= 9) {
150 // HT40 with secondary channel above primary
151 return 83;
152 }
153 // HT40 with secondary channel below primary
154 return 84;
155 }
156 // Error
157 return 0;
158 }
159
160 // 5GHz Band
161 if ((band & band5Ghz) != 0) {
162 if (support11ac) {
163 switch (channel) {
164 case 42:
165 case 58:
166 case 106:
167 case 122:
168 case 138:
169 case 155:
170 // 80MHz channel
171 return 128;
172 case 50:
173 case 114:
174 // 160MHz channel
175 return 129;
176 }
177 }
178
179 if (!support11n) {
180 if (channel >= 36 && channel <= 48) {
181 return 115;
182 }
183 if (channel >= 52 && channel <= 64) {
184 return 118;
185 }
186 if (channel >= 100 && channel <= 144) {
187 return 121;
188 }
189 if (channel >= 149 && channel <= 161) {
190 return 124;
191 }
192 if (channel >= 165 && channel <= 169) {
193 return 125;
194 }
195 } else {
196 switch (channel) {
197 case 36:
198 case 44:
199 // HT40 with secondary channel above primary
200 return 116;
201 case 40:
202 case 48:
203 // HT40 with secondary channel below primary
204 return 117;
205 case 52:
206 case 60:
207 // HT40 with secondary channel above primary
208 return 119;
209 case 56:
210 case 64:
211 // HT40 with secondary channel below primary
212 return 120;
213 case 100:
214 case 108:
215 case 116:
216 case 124:
217 case 132:
218 case 140:
219 // HT40 with secondary channel above primary
220 return 122;
221 case 104:
222 case 112:
223 case 120:
224 case 128:
225 case 136:
226 case 144:
227 // HT40 with secondary channel below primary
228 return 123;
229 case 149:
230 case 157:
231 // HT40 with secondary channel above primary
232 return 126;
233 case 153:
234 case 161:
235 // HT40 with secondary channel below primary
236 return 127;
237 }
238 }
239 // Error
240 return 0;
241 }
242
243 // 6GHz Band
244 if ((band & band6Ghz) != 0) {
245 // Channels 1, 5. 9, 13, ...
246 if ((channel & 0x03) == 0x01) {
247 // 20MHz channel
248 return 131;
249 }
250 // Channels 3, 11, 19, 27, ...
251 if ((channel & 0x07) == 0x03) {
252 // 40MHz channel
253 return 132;
254 }
255 // Channels 7, 23, 39, 55, ...
256 if ((channel & 0x0F) == 0x07) {
257 // 80MHz channel
258 return 133;
259 }
260 // Channels 15, 47, 69, ...
261 if ((channel & 0x1F) == 0x0F) {
262 // 160MHz channel
263 return 134;
264 }
265 if (channel == 2) {
266 // 20MHz channel
267 return 136;
268 }
269 // Error
270 return 0;
271 }
272
273 if ((band & band60Ghz) != 0) {
274 if (1 <= channel && channel <= 8) {
275 return 180;
276 } else if (9 <= channel && channel <= 15) {
277 return 181;
278 } else if (17 <= channel && channel <= 22) {
279 return 182;
280 } else if (25 <= channel && channel <= 29) {
281 return 183;
282 }
283 // Error
284 return 0;
285 }
286
287 return 0;
288}
289
290bool validatePassphrase(int passphrase_len, int min_len, int max_len)
291{
292 if (min_len != -1 && passphrase_len < min_len) return false;
293 if (max_len != -1 && passphrase_len > max_len) return false;
294 return true;
295}
296
297std::string CreateHostapdConfig(
298 const IfaceParams& iface_params,
299 const ChannelParams& channelParams,
300 const NetworkParams& nw_params,
Purushottam Kushwaha0316c882021-12-20 15:07:44 +0530301 const std::string br_name,
302 const std::string owe_transition_ifname)
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000303{
304 if (nw_params.ssid.size() >
305 static_cast<uint32_t>(
306 ParamSizeLimits::SSID_MAX_LEN_IN_BYTES)) {
307 wpa_printf(
308 MSG_ERROR, "Invalid SSID size: %zu", nw_params.ssid.size());
309 return "";
310 }
311
312 // SSID string
313 std::stringstream ss;
314 ss << std::hex;
315 ss << std::setfill('0');
316 for (uint8_t b : nw_params.ssid) {
317 ss << std::setw(2) << static_cast<unsigned int>(b);
318 }
319 const std::string ssid_as_string = ss.str();
320
321 // Encryption config string
322 uint32_t band = 0;
323 band |= static_cast<uint32_t>(channelParams.bandMask);
324 bool is_6Ghz_band_only = band == static_cast<uint32_t>(band6Ghz);
325 bool is_60Ghz_band_only = band == static_cast<uint32_t>(band60Ghz);
326 std::string encryption_config_as_string;
327 switch (nw_params.encryptionType) {
328 case EncryptionType::NONE:
329 // no security params
330 break;
331 case EncryptionType::WPA:
332 if (!validatePassphrase(
333 nw_params.passphrase.size(),
334 static_cast<uint32_t>(ParamSizeLimits::
335 WPA2_PSK_PASSPHRASE_MIN_LEN_IN_BYTES),
336 static_cast<uint32_t>(ParamSizeLimits::
337 WPA2_PSK_PASSPHRASE_MAX_LEN_IN_BYTES))) {
338 return "";
339 }
340 encryption_config_as_string = StringPrintf(
341 "wpa=3\n"
342 "wpa_pairwise=%s\n"
343 "wpa_passphrase=%s",
344 is_60Ghz_band_only ? "GCMP" : "TKIP CCMP",
345 nw_params.passphrase.c_str());
346 break;
347 case EncryptionType::WPA2:
348 if (!validatePassphrase(
349 nw_params.passphrase.size(),
350 static_cast<uint32_t>(ParamSizeLimits::
351 WPA2_PSK_PASSPHRASE_MIN_LEN_IN_BYTES),
352 static_cast<uint32_t>(ParamSizeLimits::
353 WPA2_PSK_PASSPHRASE_MAX_LEN_IN_BYTES))) {
354 return "";
355 }
356 encryption_config_as_string = StringPrintf(
357 "wpa=2\n"
358 "rsn_pairwise=%s\n"
Sunil Ravib3580db2022-01-28 12:25:46 -0800359#ifdef ENABLE_HOSTAPD_CONFIG_80211W_MFP_OPTIONAL
360 "ieee80211w=1\n"
361#endif
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000362 "wpa_passphrase=%s",
363 is_60Ghz_band_only ? "GCMP" : "CCMP",
364 nw_params.passphrase.c_str());
365 break;
366 case EncryptionType::WPA3_SAE_TRANSITION:
367 if (!validatePassphrase(
368 nw_params.passphrase.size(),
369 static_cast<uint32_t>(ParamSizeLimits::
370 WPA2_PSK_PASSPHRASE_MIN_LEN_IN_BYTES),
371 static_cast<uint32_t>(ParamSizeLimits::
372 WPA2_PSK_PASSPHRASE_MAX_LEN_IN_BYTES))) {
373 return "";
374 }
375 encryption_config_as_string = StringPrintf(
376 "wpa=2\n"
377 "rsn_pairwise=%s\n"
378 "wpa_key_mgmt=WPA-PSK SAE\n"
379 "ieee80211w=1\n"
380 "sae_require_mfp=1\n"
381 "wpa_passphrase=%s\n"
382 "sae_password=%s",
383 is_60Ghz_band_only ? "GCMP" : "CCMP",
384 nw_params.passphrase.c_str(),
385 nw_params.passphrase.c_str());
386 break;
387 case EncryptionType::WPA3_SAE:
388 if (!validatePassphrase(nw_params.passphrase.size(), 1, -1)) {
389 return "";
390 }
391 encryption_config_as_string = StringPrintf(
392 "wpa=2\n"
393 "rsn_pairwise=%s\n"
394 "wpa_key_mgmt=SAE\n"
395 "ieee80211w=2\n"
396 "sae_require_mfp=2\n"
397 "sae_pwe=%d\n"
398 "sae_password=%s",
399 is_60Ghz_band_only ? "GCMP" : "CCMP",
400 is_6Ghz_band_only ? 1 : 2,
401 nw_params.passphrase.c_str());
402 break;
Ahmed ElArabawy1aaf1802022-02-04 15:58:55 -0800403 case EncryptionType::WPA3_OWE_TRANSITION:
404 encryption_config_as_string = StringPrintf(
405 "wpa=2\n"
406 "rsn_pairwise=%s\n"
407 "wpa_key_mgmt=OWE\n"
408 "ieee80211w=2",
409 is_60Ghz_band_only ? "GCMP" : "CCMP");
410 break;
411 case EncryptionType::WPA3_OWE:
Purushottam Kushwaha0316c882021-12-20 15:07:44 +0530412 encryption_config_as_string = StringPrintf(
413 "wpa=2\n"
414 "rsn_pairwise=%s\n"
415 "wpa_key_mgmt=OWE\n"
416 "ieee80211w=2",
417 is_60Ghz_band_only ? "GCMP" : "CCMP");
418 break;
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000419 default:
420 wpa_printf(MSG_ERROR, "Unknown encryption type");
421 return "";
422 }
423
424 std::string channel_config_as_string;
425 bool isFirst = true;
426 if (channelParams.enableAcs) {
427 std::string freqList_as_string;
428 for (const auto &range :
429 channelParams.acsChannelFreqRangesMhz) {
430 if (!isFirst) {
431 freqList_as_string += ",";
432 }
433 isFirst = false;
434
435 if (range.startMhz != range.endMhz) {
436 freqList_as_string +=
437 StringPrintf("%d-%d", range.startMhz, range.endMhz);
438 } else {
439 freqList_as_string += StringPrintf("%d", range.startMhz);
440 }
441 }
442 channel_config_as_string = StringPrintf(
443 "channel=0\n"
444 "acs_exclude_dfs=%d\n"
445 "freqlist=%s",
446 channelParams.acsShouldExcludeDfs,
447 freqList_as_string.c_str());
448 } else {
449 int op_class = getOpClassForChannel(
450 channelParams.channel,
451 band,
452 iface_params.hwModeParams.enable80211N,
453 iface_params.hwModeParams.enable80211AC);
454 channel_config_as_string = StringPrintf(
455 "channel=%d\n"
456 "op_class=%d",
457 channelParams.channel, op_class);
458 }
459
460 std::string hw_mode_as_string;
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000461 std::string enable_edmg_as_string;
462 std::string edmg_channel_as_string;
463 bool is_60Ghz_used = false;
464
465 if (((band & band60Ghz) != 0)) {
466 hw_mode_as_string = "hw_mode=ad";
467 if (iface_params.hwModeParams.enableEdmg) {
468 enable_edmg_as_string = "enable_edmg=1";
469 edmg_channel_as_string = StringPrintf(
470 "edmg_channel=%d",
471 channelParams.channel);
472 }
473 is_60Ghz_used = true;
474 } else if ((band & band2Ghz) != 0) {
475 if (((band & band5Ghz) != 0)
476 || ((band & band6Ghz) != 0)) {
477 hw_mode_as_string = "hw_mode=any";
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000478 } else {
479 hw_mode_as_string = "hw_mode=g";
480 }
481 } else if (((band & band5Ghz) != 0)
482 || ((band & band6Ghz) != 0)) {
483 hw_mode_as_string = "hw_mode=a";
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000484 } else {
485 wpa_printf(MSG_ERROR, "Invalid band");
486 return "";
487 }
488
489 std::string he_params_as_string;
490#ifdef CONFIG_IEEE80211AX
491 if (iface_params.hwModeParams.enable80211AX && !is_60Ghz_used) {
492 he_params_as_string = StringPrintf(
493 "ieee80211ax=1\n"
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000494 "he_su_beamformer=%d\n"
495 "he_su_beamformee=%d\n"
496 "he_mu_beamformer=%d\n"
497 "he_twt_required=%d\n",
498 iface_params.hwModeParams.enableHeSingleUserBeamformer ? 1 : 0,
499 iface_params.hwModeParams.enableHeSingleUserBeamformee ? 1 : 0,
500 iface_params.hwModeParams.enableHeMultiUserBeamformer ? 1 : 0,
501 iface_params.hwModeParams.enableHeTargetWakeTime ? 1 : 0);
502 } else {
503 he_params_as_string = "ieee80211ax=0";
504 }
505#endif /* CONFIG_IEEE80211AX */
506
Purushottam Kushwaha90c710b2022-02-04 19:00:34 +0530507 std::string ht_cap_vht_oper_he_oper_chwidth_as_string;
508 switch (iface_params.hwModeParams.maximumChannelBandwidth) {
509 case ChannelBandwidth::BANDWIDTH_20:
510 ht_cap_vht_oper_he_oper_chwidth_as_string = StringPrintf(
511#ifdef CONFIG_IEEE80211AX
512 "he_oper_chwidth=0\n"
513#endif
514 "vht_oper_chwidth=0");
515 break;
516 case ChannelBandwidth::BANDWIDTH_40:
517 ht_cap_vht_oper_he_oper_chwidth_as_string = StringPrintf(
518 "ht_capab=[HT40+]\n"
519#ifdef CONFIG_IEEE80211AX
520 "he_oper_chwidth=0\n"
521#endif
522 "vht_oper_chwidth=0");
523 break;
524 case ChannelBandwidth::BANDWIDTH_80:
525 ht_cap_vht_oper_he_oper_chwidth_as_string = StringPrintf(
526 "ht_capab=[HT40+]\n"
527#ifdef CONFIG_IEEE80211AX
528 "he_oper_chwidth=%d\n"
529#endif
530 "vht_oper_chwidth=%d",
531#ifdef CONFIG_IEEE80211AX
532 (iface_params.hwModeParams.enable80211AX && !is_60Ghz_used) ? 1 : 0,
533#endif
534 iface_params.hwModeParams.enable80211AC ? 1 : 0);
535 break;
536 case ChannelBandwidth::BANDWIDTH_160:
537 ht_cap_vht_oper_he_oper_chwidth_as_string = StringPrintf(
538 "ht_capab=[HT40+]\n"
539#ifdef CONFIG_IEEE80211AX
540 "he_oper_chwidth=%d\n"
541#endif
542 "vht_oper_chwidth=%d",
543#ifdef CONFIG_IEEE80211AX
544 (iface_params.hwModeParams.enable80211AX && !is_60Ghz_used) ? 2 : 0,
545#endif
546 iface_params.hwModeParams.enable80211AC ? 2 : 0);
547 break;
548 default:
549 ht_cap_vht_oper_he_oper_chwidth_as_string = StringPrintf(
550 "ht_capab=[HT40+]\n"
551#ifdef CONFIG_IEEE80211AX
552 "he_oper_chwidth=%d\n"
553#endif
554 "vht_oper_chwidth=%d",
555#ifdef CONFIG_IEEE80211AX
556 (iface_params.hwModeParams.enable80211AX && !is_60Ghz_used) ? 1 : 0,
557#endif
558 ((((band & band5Ghz) != 0) || ((band & band6Ghz) != 0))
559 && iface_params.hwModeParams.enable80211AC) ? 1 : 0);
560 break;
561 }
562
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000563#ifdef CONFIG_INTERWORKING
564 std::string access_network_params_as_string;
565 if (nw_params.isMetered) {
566 access_network_params_as_string = StringPrintf(
567 "interworking=1\n"
568 "access_network_type=2\n"); // CHARGEABLE_PUBLIC_NETWORK
569 } else {
570 access_network_params_as_string = StringPrintf(
571 "interworking=0\n");
572 }
573#endif /* CONFIG_INTERWORKING */
574
575 std::string bridge_as_string;
576 if (!br_name.empty()) {
577 bridge_as_string = StringPrintf("bridge=%s", br_name.c_str());
578 }
579
Serik Beketayev8af7a722021-12-23 12:25:36 -0800580 // vendor_elements string
581 std::string vendor_elements_as_string;
582 if (nw_params.vendorElements.size() > 0) {
583 std::stringstream ss;
584 ss << std::hex;
585 ss << std::setfill('0');
586 for (uint8_t b : nw_params.vendorElements) {
587 ss << std::setw(2) << static_cast<unsigned int>(b);
588 }
589 vendor_elements_as_string = StringPrintf("vendor_elements=%s", ss.str().c_str());
590 }
591
Purushottam Kushwaha0316c882021-12-20 15:07:44 +0530592 std::string owe_transition_ifname_as_string;
593 if (!owe_transition_ifname.empty()) {
594 owe_transition_ifname_as_string = StringPrintf(
595 "owe_transition_ifname=%s", owe_transition_ifname.c_str());
596 }
597
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000598 return StringPrintf(
599 "interface=%s\n"
600 "driver=nl80211\n"
601 "ctrl_interface=/data/vendor/wifi/hostapd/ctrl\n"
602 // ssid2 signals to hostapd that the value is not a literal value
603 // for use as a SSID. In this case, we're giving it a hex
604 // std::string and hostapd needs to expect that.
605 "ssid2=%s\n"
606 "%s\n"
607 "ieee80211n=%d\n"
608 "ieee80211ac=%d\n"
609 "%s\n"
610 "%s\n"
611 "%s\n"
612 "ignore_broadcast_ssid=%d\n"
613 "wowlan_triggers=any\n"
614#ifdef CONFIG_INTERWORKING
615 "%s\n"
616#endif /* CONFIG_INTERWORKING */
617 "%s\n"
618 "%s\n"
619 "%s\n"
Serik Beketayev8af7a722021-12-23 12:25:36 -0800620 "%s\n"
Purushottam Kushwaha0316c882021-12-20 15:07:44 +0530621 "%s\n"
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000622 "%s\n",
623 iface_params.name.c_str(), ssid_as_string.c_str(),
624 channel_config_as_string.c_str(),
625 iface_params.hwModeParams.enable80211N ? 1 : 0,
626 iface_params.hwModeParams.enable80211AC ? 1 : 0,
627 he_params_as_string.c_str(),
Purushottam Kushwaha90c710b2022-02-04 19:00:34 +0530628 hw_mode_as_string.c_str(), ht_cap_vht_oper_he_oper_chwidth_as_string.c_str(),
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000629 nw_params.isHidden ? 1 : 0,
630#ifdef CONFIG_INTERWORKING
631 access_network_params_as_string.c_str(),
632#endif /* CONFIG_INTERWORKING */
633 encryption_config_as_string.c_str(),
634 bridge_as_string.c_str(),
Purushottam Kushwaha0316c882021-12-20 15:07:44 +0530635 owe_transition_ifname_as_string.c_str(),
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000636 enable_edmg_as_string.c_str(),
Serik Beketayev8af7a722021-12-23 12:25:36 -0800637 edmg_channel_as_string.c_str(),
638 vendor_elements_as_string.c_str());
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000639}
640
641Generation getGeneration(hostapd_hw_modes *current_mode)
642{
643 wpa_printf(MSG_DEBUG, "getGeneration hwmode=%d, ht_enabled=%d,"
644 " vht_enabled=%d, he_supported=%d",
645 current_mode->mode, current_mode->ht_capab != 0,
646 current_mode->vht_capab != 0, current_mode->he_capab->he_supported);
647 switch (current_mode->mode) {
648 case HOSTAPD_MODE_IEEE80211B:
649 return Generation::WIFI_STANDARD_LEGACY;
650 case HOSTAPD_MODE_IEEE80211G:
651 return current_mode->ht_capab == 0 ?
652 Generation::WIFI_STANDARD_LEGACY : Generation::WIFI_STANDARD_11N;
653 case HOSTAPD_MODE_IEEE80211A:
654 if (current_mode->he_capab->he_supported) {
655 return Generation::WIFI_STANDARD_11AX;
656 }
657 return current_mode->vht_capab == 0 ?
658 Generation::WIFI_STANDARD_11N : Generation::WIFI_STANDARD_11AC;
659 case HOSTAPD_MODE_IEEE80211AD:
660 return Generation::WIFI_STANDARD_11AD;
661 default:
662 return Generation::WIFI_STANDARD_UNKNOWN;
663 }
664}
665
Ahmed ElArabawyb4115792022-02-08 09:33:01 -0800666ChannelBandwidth getChannelBandwidth(struct hostapd_config *iconf)
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000667{
Ahmed ElArabawyb4115792022-02-08 09:33:01 -0800668 wpa_printf(MSG_DEBUG, "getChannelBandwidth %d, isHT=%d, isHT40=%d",
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000669 iconf->vht_oper_chwidth, iconf->ieee80211n,
670 iconf->secondary_channel);
671 switch (iconf->vht_oper_chwidth) {
672 case CHANWIDTH_80MHZ:
Ahmed ElArabawyb4115792022-02-08 09:33:01 -0800673 return ChannelBandwidth::BANDWIDTH_80;
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000674 case CHANWIDTH_80P80MHZ:
Ahmed ElArabawyb4115792022-02-08 09:33:01 -0800675 return ChannelBandwidth::BANDWIDTH_80P80;
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000676 break;
677 case CHANWIDTH_160MHZ:
Ahmed ElArabawyb4115792022-02-08 09:33:01 -0800678 return ChannelBandwidth::BANDWIDTH_160;
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000679 break;
680 case CHANWIDTH_USE_HT:
681 if (iconf->ieee80211n) {
682 return iconf->secondary_channel != 0 ?
Ahmed ElArabawyb4115792022-02-08 09:33:01 -0800683 ChannelBandwidth::BANDWIDTH_40 : ChannelBandwidth::BANDWIDTH_20;
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000684 }
Ahmed ElArabawyb4115792022-02-08 09:33:01 -0800685 return ChannelBandwidth::BANDWIDTH_20_NOHT;
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000686 case CHANWIDTH_2160MHZ:
Ahmed ElArabawyb4115792022-02-08 09:33:01 -0800687 return ChannelBandwidth::BANDWIDTH_2160;
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000688 case CHANWIDTH_4320MHZ:
Ahmed ElArabawyb4115792022-02-08 09:33:01 -0800689 return ChannelBandwidth::BANDWIDTH_4320;
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000690 case CHANWIDTH_6480MHZ:
Ahmed ElArabawyb4115792022-02-08 09:33:01 -0800691 return ChannelBandwidth::BANDWIDTH_6480;
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000692 case CHANWIDTH_8640MHZ:
Ahmed ElArabawyb4115792022-02-08 09:33:01 -0800693 return ChannelBandwidth::BANDWIDTH_8640;
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000694 default:
Ahmed ElArabawyb4115792022-02-08 09:33:01 -0800695 return ChannelBandwidth::BANDWIDTH_INVALID;
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000696 }
697}
698
699bool forceStaDisconnection(struct hostapd_data* hapd,
700 const std::vector<uint8_t>& client_address,
701 const uint16_t reason_code) {
702 struct sta_info *sta;
703 for (sta = hapd->sta_list; sta; sta = sta->next) {
704 int res;
705 res = memcmp(sta->addr, client_address.data(), ETH_ALEN);
706 if (res == 0) {
707 wpa_printf(MSG_INFO, "Force client:" MACSTR " disconnect with reason: %d",
708 MAC2STR(client_address.data()), reason_code);
709 ap_sta_disconnect(hapd, sta, sta->addr, reason_code);
710 return true;
711 }
712 }
713 return false;
714}
715
716// hostapd core functions accept "C" style function pointers, so use global
717// functions to pass to the hostapd core function and store the corresponding
718// std::function methods to be invoked.
719//
720// NOTE: Using the pattern from the vendor HAL (wifi_legacy_hal.cpp).
721//
722// Callback to be invoked once setup is complete
723std::function<void(struct hostapd_data*)> on_setup_complete_internal_callback;
724void onAsyncSetupCompleteCb(void* ctx)
725{
726 struct hostapd_data* iface_hapd = (struct hostapd_data*)ctx;
727 if (on_setup_complete_internal_callback) {
728 on_setup_complete_internal_callback(iface_hapd);
729 // Invalidate this callback since we don't want this firing
730 // again in single AP mode.
731 if (strlen(iface_hapd->conf->bridge) > 0) {
732 on_setup_complete_internal_callback = nullptr;
733 }
734 }
735}
736
737// Callback to be invoked on hotspot client connection/disconnection
738std::function<void(struct hostapd_data*, const u8 *mac_addr, int authorized,
739 const u8 *p2p_dev_addr)> on_sta_authorized_internal_callback;
740void onAsyncStaAuthorizedCb(void* ctx, const u8 *mac_addr, int authorized,
741 const u8 *p2p_dev_addr)
742{
743 struct hostapd_data* iface_hapd = (struct hostapd_data*)ctx;
744 if (on_sta_authorized_internal_callback) {
745 on_sta_authorized_internal_callback(iface_hapd, mac_addr,
746 authorized, p2p_dev_addr);
747 }
748}
749
750std::function<void(struct hostapd_data*, int level,
751 enum wpa_msg_type type, const char *txt,
752 size_t len)> on_wpa_msg_internal_callback;
753
754void onAsyncWpaEventCb(void *ctx, int level,
755 enum wpa_msg_type type, const char *txt,
756 size_t len)
757{
758 struct hostapd_data* iface_hapd = (struct hostapd_data*)ctx;
759 if (on_wpa_msg_internal_callback) {
760 on_wpa_msg_internal_callback(iface_hapd, level,
761 type, txt, len);
762 }
763}
764
765inline ndk::ScopedAStatus createStatus(HostapdStatusCode status_code) {
766 return ndk::ScopedAStatus::fromServiceSpecificError(
767 static_cast<int32_t>(status_code));
768}
769
770inline ndk::ScopedAStatus createStatusWithMsg(
771 HostapdStatusCode status_code, std::string msg)
772{
773 return ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(
774 static_cast<int32_t>(status_code), msg.c_str());
775}
776
777// Method called by death_notifier_ on client death.
778void onDeath(void* cookie) {
779 wpa_printf(MSG_ERROR, "Client died. Terminating...");
780 eloop_terminate();
781}
782
783} // namespace
784
785namespace aidl {
786namespace android {
787namespace hardware {
788namespace wifi {
789namespace hostapd {
790
791Hostapd::Hostapd(struct hapd_interfaces* interfaces)
792 : interfaces_(interfaces)
793{
794 death_notifier_ = AIBinder_DeathRecipient_new(onDeath);
795}
796
797::ndk::ScopedAStatus Hostapd::addAccessPoint(
798 const IfaceParams& iface_params, const NetworkParams& nw_params)
799{
800 return addAccessPointInternal(iface_params, nw_params);
801}
802
803::ndk::ScopedAStatus Hostapd::removeAccessPoint(const std::string& iface_name)
804{
805 return removeAccessPointInternal(iface_name);
806}
807
808::ndk::ScopedAStatus Hostapd::terminate()
809{
810 wpa_printf(MSG_INFO, "Terminating...");
811 // Clear the callback to avoid IPCThreadState shutdown during the
812 // callback event.
813 callbacks_.clear();
814 eloop_terminate();
815 return ndk::ScopedAStatus::ok();
816}
817
818::ndk::ScopedAStatus Hostapd::registerCallback(
819 const std::shared_ptr<IHostapdCallback>& callback)
820{
821 return registerCallbackInternal(callback);
822}
823
824::ndk::ScopedAStatus Hostapd::forceClientDisconnect(
825 const std::string& iface_name, const std::vector<uint8_t>& client_address,
826 Ieee80211ReasonCode reason_code)
827{
828 return forceClientDisconnectInternal(iface_name, client_address, reason_code);
829}
830
831::ndk::ScopedAStatus Hostapd::setDebugParams(DebugLevel level)
832{
833 return setDebugParamsInternal(level);
834}
835
836::ndk::ScopedAStatus Hostapd::addAccessPointInternal(
837 const IfaceParams& iface_params,
838 const NetworkParams& nw_params)
839{
840 int channelParamsSize = iface_params.channelParams.size();
841 if (channelParamsSize == 1) {
842 // Single AP
843 wpa_printf(MSG_INFO, "AddSingleAccessPoint, iface=%s",
844 iface_params.name.c_str());
845 return addSingleAccessPoint(iface_params, iface_params.channelParams[0],
Purushottam Kushwaha0316c882021-12-20 15:07:44 +0530846 nw_params, "", "");
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000847 } else if (channelParamsSize == 2) {
848 // Concurrent APs
849 wpa_printf(MSG_INFO, "AddDualAccessPoint, iface=%s",
850 iface_params.name.c_str());
851 return addConcurrentAccessPoints(iface_params, nw_params);
852 }
853 return createStatus(HostapdStatusCode::FAILURE_ARGS_INVALID);
854}
855
Purushottam Kushwaha0316c882021-12-20 15:07:44 +0530856std::vector<uint8_t> generateRandomOweSsid()
857{
858 u8 random[8] = {0};
859 os_get_random(random, 8);
860
861 std::string ssid = StringPrintf("Owe-%s", random);
862 wpa_printf(MSG_INFO, "Generated OWE SSID: %s", ssid.c_str());
863 std::vector<uint8_t> vssid(ssid.begin(), ssid.end());
864
865 return vssid;
866}
867
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000868::ndk::ScopedAStatus Hostapd::addConcurrentAccessPoints(
869 const IfaceParams& iface_params, const NetworkParams& nw_params)
870{
871 int channelParamsListSize = iface_params.channelParams.size();
872 // Get available interfaces in bridge
873 std::vector<std::string> managed_interfaces;
874 std::string br_name = StringPrintf(
875 "%s", iface_params.name.c_str());
876 if (!GetInterfacesInBridge(br_name, &managed_interfaces)) {
877 return createStatusWithMsg(HostapdStatusCode::FAILURE_UNKNOWN,
878 "Get interfaces in bridge failed.");
879 }
880 if (managed_interfaces.size() < channelParamsListSize) {
881 return createStatusWithMsg(HostapdStatusCode::FAILURE_UNKNOWN,
882 "Available interfaces less than requested bands");
883 }
884 // start BSS on specified bands
885 for (std::size_t i = 0; i < channelParamsListSize; i ++) {
886 IfaceParams iface_params_new = iface_params;
Purushottam Kushwaha0316c882021-12-20 15:07:44 +0530887 NetworkParams nw_params_new = nw_params;
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000888 iface_params_new.name = managed_interfaces[i];
Purushottam Kushwaha0316c882021-12-20 15:07:44 +0530889
890 std::string owe_transition_ifname = "";
Ahmed ElArabawy1aaf1802022-02-04 15:58:55 -0800891 if (nw_params.encryptionType == EncryptionType::WPA3_OWE_TRANSITION) {
Purushottam Kushwaha0316c882021-12-20 15:07:44 +0530892 if (i == 0 && i+1 < channelParamsListSize) {
893 owe_transition_ifname = managed_interfaces[i+1];
894 nw_params_new.encryptionType = EncryptionType::NONE;
895 } else {
896 owe_transition_ifname = managed_interfaces[0];
897 nw_params_new.isHidden = true;
898 nw_params_new.ssid = generateRandomOweSsid();
899 }
900 }
901
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000902 ndk::ScopedAStatus status = addSingleAccessPoint(
Purushottam Kushwaha0316c882021-12-20 15:07:44 +0530903 iface_params_new, iface_params.channelParams[i], nw_params_new,
904 br_name, owe_transition_ifname);
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000905 if (!status.isOk()) {
906 wpa_printf(MSG_ERROR, "Failed to addAccessPoint %s",
907 managed_interfaces[i].c_str());
908 return status;
909 }
910 }
911 // Save bridge interface info
912 br_interfaces_[br_name] = managed_interfaces;
913 return ndk::ScopedAStatus::ok();
914}
915
916::ndk::ScopedAStatus Hostapd::addSingleAccessPoint(
917 const IfaceParams& iface_params,
918 const ChannelParams& channelParams,
919 const NetworkParams& nw_params,
Purushottam Kushwaha0316c882021-12-20 15:07:44 +0530920 const std::string br_name,
921 const std::string owe_transition_ifname)
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000922{
923 if (hostapd_get_iface(interfaces_, iface_params.name.c_str())) {
924 wpa_printf(
925 MSG_ERROR, "Interface %s already present",
926 iface_params.name.c_str());
927 return createStatus(HostapdStatusCode::FAILURE_IFACE_EXISTS);
928 }
Purushottam Kushwaha0316c882021-12-20 15:07:44 +0530929 const auto conf_params = CreateHostapdConfig(iface_params, channelParams, nw_params,
930 br_name, owe_transition_ifname);
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000931 if (conf_params.empty()) {
932 wpa_printf(MSG_ERROR, "Failed to create config params");
933 return createStatus(HostapdStatusCode::FAILURE_ARGS_INVALID);
934 }
935 const auto conf_file_path =
936 WriteHostapdConfig(iface_params.name, conf_params);
937 if (conf_file_path.empty()) {
938 wpa_printf(MSG_ERROR, "Failed to write config file");
939 return createStatus(HostapdStatusCode::FAILURE_UNKNOWN);
940 }
941 std::string add_iface_param_str = StringPrintf(
942 "%s config=%s", iface_params.name.c_str(),
943 conf_file_path.c_str());
944 std::vector<char> add_iface_param_vec(
945 add_iface_param_str.begin(), add_iface_param_str.end() + 1);
946 if (hostapd_add_iface(interfaces_, add_iface_param_vec.data()) < 0) {
947 wpa_printf(
948 MSG_ERROR, "Adding interface %s failed",
949 add_iface_param_str.c_str());
950 return createStatus(HostapdStatusCode::FAILURE_UNKNOWN);
951 }
952 struct hostapd_data* iface_hapd =
953 hostapd_get_iface(interfaces_, iface_params.name.c_str());
954 WPA_ASSERT(iface_hapd != nullptr && iface_hapd->iface != nullptr);
955 // Register the setup complete callbacks
956 on_setup_complete_internal_callback =
957 [this](struct hostapd_data* iface_hapd) {
958 wpa_printf(
959 MSG_INFO, "AP interface setup completed - state %s",
960 hostapd_state_text(iface_hapd->iface->state));
961 if (iface_hapd->iface->state == HAPD_IFACE_DISABLED) {
962 // Invoke the failure callback on all registered
963 // clients.
964 for (const auto& callback : callbacks_) {
965 callback->onFailure(strlen(iface_hapd->conf->bridge) > 0 ?
Les Leee08c2862021-10-29 16:36:41 +0800966 iface_hapd->conf->bridge : iface_hapd->conf->iface,
967 iface_hapd->conf->iface);
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000968 }
969 }
970 };
971
972 // Register for new client connect/disconnect indication.
973 on_sta_authorized_internal_callback =
974 [this](struct hostapd_data* iface_hapd, const u8 *mac_addr,
975 int authorized, const u8 *p2p_dev_addr) {
976 wpa_printf(MSG_DEBUG, "notify client " MACSTR " %s",
977 MAC2STR(mac_addr),
978 (authorized) ? "Connected" : "Disconnected");
979 ClientInfo info;
980 info.ifaceName = strlen(iface_hapd->conf->bridge) > 0 ?
981 iface_hapd->conf->bridge : iface_hapd->conf->iface;
982 info.apIfaceInstance = iface_hapd->conf->iface;
983 info.clientAddress.assign(mac_addr, mac_addr + ETH_ALEN);
984 info.isConnected = authorized;
985 for (const auto &callback : callbacks_) {
986 callback->onConnectedClientsChanged(info);
987 }
988 };
989
990 // Register for wpa_event which used to get channel switch event
991 on_wpa_msg_internal_callback =
992 [this](struct hostapd_data* iface_hapd, int level,
993 enum wpa_msg_type type, const char *txt,
994 size_t len) {
995 wpa_printf(MSG_DEBUG, "Receive wpa msg : %s", txt);
996 if (os_strncmp(txt, AP_EVENT_ENABLED,
997 strlen(AP_EVENT_ENABLED)) == 0 ||
998 os_strncmp(txt, WPA_EVENT_CHANNEL_SWITCH,
999 strlen(WPA_EVENT_CHANNEL_SWITCH)) == 0) {
1000 ApInfo info;
1001 info.ifaceName = strlen(iface_hapd->conf->bridge) > 0 ?
1002 iface_hapd->conf->bridge : iface_hapd->conf->iface,
1003 info.apIfaceInstance = iface_hapd->conf->iface;
1004 info.freqMhz = iface_hapd->iface->freq;
Ahmed ElArabawyb4115792022-02-08 09:33:01 -08001005 info.channelBandwidth = getChannelBandwidth(iface_hapd->iconf);
Gabriel Biren72cf9a52021-06-25 23:29:26 +00001006 info.generation = getGeneration(iface_hapd->iface->current_mode);
1007 info.apIfaceInstanceMacAddress.assign(iface_hapd->own_addr,
1008 iface_hapd->own_addr + ETH_ALEN);
1009 for (const auto &callback : callbacks_) {
1010 callback->onApInstanceInfoChanged(info);
1011 }
Yu Ouyang378d3c42021-08-20 17:31:08 +08001012 } else if (os_strncmp(txt, AP_EVENT_DISABLED, strlen(AP_EVENT_DISABLED)) == 0) {
1013 // Invoke the failure callback on all registered clients.
1014 for (const auto& callback : callbacks_) {
1015 callback->onFailure(strlen(iface_hapd->conf->bridge) > 0 ?
Les Leee08c2862021-10-29 16:36:41 +08001016 iface_hapd->conf->bridge : iface_hapd->conf->iface,
1017 iface_hapd->conf->iface);
Yu Ouyang378d3c42021-08-20 17:31:08 +08001018 }
Gabriel Biren72cf9a52021-06-25 23:29:26 +00001019 }
Yu Ouyang378d3c42021-08-20 17:31:08 +08001020 };
Gabriel Biren72cf9a52021-06-25 23:29:26 +00001021
1022 // Setup callback
1023 iface_hapd->setup_complete_cb = onAsyncSetupCompleteCb;
1024 iface_hapd->setup_complete_cb_ctx = iface_hapd;
1025 iface_hapd->sta_authorized_cb = onAsyncStaAuthorizedCb;
1026 iface_hapd->sta_authorized_cb_ctx = iface_hapd;
1027 wpa_msg_register_cb(onAsyncWpaEventCb);
1028
1029 if (hostapd_enable_iface(iface_hapd->iface) < 0) {
1030 wpa_printf(
1031 MSG_ERROR, "Enabling interface %s failed",
1032 iface_params.name.c_str());
1033 return createStatus(HostapdStatusCode::FAILURE_UNKNOWN);
1034 }
1035 return ndk::ScopedAStatus::ok();
1036}
1037
1038::ndk::ScopedAStatus Hostapd::removeAccessPointInternal(const std::string& iface_name)
1039{
1040 // interfaces to be removed
1041 std::vector<std::string> interfaces;
1042 bool is_error = false;
1043
1044 const auto it = br_interfaces_.find(iface_name);
1045 if (it != br_interfaces_.end()) {
1046 // In case bridge, remove managed interfaces
1047 interfaces = it->second;
1048 br_interfaces_.erase(iface_name);
1049 } else {
1050 // else remove current interface
1051 interfaces.push_back(iface_name);
1052 }
1053
1054 for (auto& iface : interfaces) {
1055 std::vector<char> remove_iface_param_vec(
1056 iface.begin(), iface.end() + 1);
1057 if (hostapd_remove_iface(interfaces_, remove_iface_param_vec.data()) < 0) {
1058 wpa_printf(MSG_INFO, "Remove interface %s failed", iface.c_str());
1059 is_error = true;
1060 }
1061 }
1062 if (is_error) {
1063 return createStatus(HostapdStatusCode::FAILURE_UNKNOWN);
1064 }
1065 return ndk::ScopedAStatus::ok();
1066}
1067
1068::ndk::ScopedAStatus Hostapd::registerCallbackInternal(
1069 const std::shared_ptr<IHostapdCallback>& callback)
1070{
1071 binder_status_t status = AIBinder_linkToDeath(callback->asBinder().get(),
1072 death_notifier_, this /* cookie */);
1073 if (status != STATUS_OK) {
1074 wpa_printf(
1075 MSG_ERROR,
1076 "Error registering for death notification for "
1077 "hostapd callback object");
1078 return createStatus(HostapdStatusCode::FAILURE_UNKNOWN);
1079 }
1080 callbacks_.push_back(callback);
1081 return ndk::ScopedAStatus::ok();
1082}
1083
1084::ndk::ScopedAStatus Hostapd::forceClientDisconnectInternal(const std::string& iface_name,
1085 const std::vector<uint8_t>& client_address, Ieee80211ReasonCode reason_code)
1086{
1087 struct hostapd_data *hapd = hostapd_get_iface(interfaces_, iface_name.c_str());
1088 bool result;
1089 if (!hapd) {
1090 for (auto const& iface : br_interfaces_) {
1091 if (iface.first == iface_name) {
1092 for (auto const& instance : iface.second) {
1093 hapd = hostapd_get_iface(interfaces_, instance.c_str());
1094 if (hapd) {
1095 result = forceStaDisconnection(hapd, client_address,
1096 (uint16_t) reason_code);
1097 if (result) break;
1098 }
1099 }
1100 }
1101 }
1102 } else {
1103 result = forceStaDisconnection(hapd, client_address, (uint16_t) reason_code);
1104 }
1105 if (!hapd) {
1106 wpa_printf(MSG_ERROR, "Interface %s doesn't exist", iface_name.c_str());
1107 return createStatus(HostapdStatusCode::FAILURE_IFACE_UNKNOWN);
1108 }
1109 if (result) {
1110 return ndk::ScopedAStatus::ok();
1111 }
1112 return createStatus(HostapdStatusCode::FAILURE_CLIENT_UNKNOWN);
1113}
1114
1115::ndk::ScopedAStatus Hostapd::setDebugParamsInternal(DebugLevel level)
1116{
1117 wpa_debug_level = static_cast<uint32_t>(level);
1118 return ndk::ScopedAStatus::ok();
1119}
1120
1121} // namespace hostapd
1122} // namespace wifi
1123} // namespace hardware
1124} // namespace android
Les Leee08c2862021-10-29 16:36:41 +08001125} // namespace aidl