• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
32 extern "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.
43 namespace {
44 constexpr char kConfFileNameFmt[] = "/data/vendor/wifi/hostapd/hostapd_%s.conf";
45 
46 using android::base::RemoveFileIfExists;
47 using android::base::StringPrintf;
48 using android::base::WriteStringToFile;
49 using aidl::android::hardware::wifi::hostapd::BandMask;
50 using aidl::android::hardware::wifi::hostapd::ChannelBandwidth;
51 using aidl::android::hardware::wifi::hostapd::ChannelParams;
52 using aidl::android::hardware::wifi::hostapd::EncryptionType;
53 using aidl::android::hardware::wifi::hostapd::Generation;
54 using aidl::android::hardware::wifi::hostapd::HostapdStatusCode;
55 using aidl::android::hardware::wifi::hostapd::IfaceParams;
56 using aidl::android::hardware::wifi::hostapd::NetworkParams;
57 using aidl::android::hardware::wifi::hostapd::ParamSizeLimits;
58 
59 int band2Ghz = (int)BandMask::BAND_2_GHZ;
60 int band5Ghz = (int)BandMask::BAND_5_GHZ;
61 int band6Ghz = (int)BandMask::BAND_6_GHZ;
62 int band60Ghz = (int)BandMask::BAND_60_GHZ;
63 
64 #define MAX_PORTS 1024
GetInterfacesInBridge(std::string br_name,std::vector<std::string> * interfaces)65 bool 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 
WriteHostapdConfig(const std::string & interface_name,const std::string & config)104 std::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  */
getOpClassForChannel(int channel,int band,bool support11n,bool support11ac)138 int 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 
validatePassphrase(int passphrase_len,int min_len,int max_len)290 bool 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 
CreateHostapdConfig(const IfaceParams & iface_params,const ChannelParams & channelParams,const NetworkParams & nw_params,const std::string br_name,const std::string owe_transition_ifname)297 std::string CreateHostapdConfig(
298 	const IfaceParams& iface_params,
299 	const ChannelParams& channelParams,
300 	const NetworkParams& nw_params,
301 	const std::string br_name,
302 	const std::string owe_transition_ifname)
303 {
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_2Ghz_band_only = band == static_cast<uint32_t>(band2Ghz);
325 	bool is_6Ghz_band_only = band == static_cast<uint32_t>(band6Ghz);
326 	bool is_60Ghz_band_only = band == static_cast<uint32_t>(band60Ghz);
327 	std::string encryption_config_as_string;
328 	switch (nw_params.encryptionType) {
329 	case EncryptionType::NONE:
330 		// no security params
331 		break;
332 	case EncryptionType::WPA:
333 		if (!validatePassphrase(
334 			nw_params.passphrase.size(),
335 			static_cast<uint32_t>(ParamSizeLimits::
336 				WPA2_PSK_PASSPHRASE_MIN_LEN_IN_BYTES),
337 			static_cast<uint32_t>(ParamSizeLimits::
338 				WPA2_PSK_PASSPHRASE_MAX_LEN_IN_BYTES))) {
339 			return "";
340 		}
341 		encryption_config_as_string = StringPrintf(
342 			"wpa=3\n"
343 			"wpa_pairwise=%s\n"
344 			"wpa_passphrase=%s",
345 			is_60Ghz_band_only ? "GCMP" : "TKIP CCMP",
346 			nw_params.passphrase.c_str());
347 		break;
348 	case EncryptionType::WPA2:
349 		if (!validatePassphrase(
350 			nw_params.passphrase.size(),
351 			static_cast<uint32_t>(ParamSizeLimits::
352 				WPA2_PSK_PASSPHRASE_MIN_LEN_IN_BYTES),
353 			static_cast<uint32_t>(ParamSizeLimits::
354 				WPA2_PSK_PASSPHRASE_MAX_LEN_IN_BYTES))) {
355 			return "";
356 		}
357 		encryption_config_as_string = StringPrintf(
358 			"wpa=2\n"
359 			"rsn_pairwise=%s\n"
360 #ifdef ENABLE_HOSTAPD_CONFIG_80211W_MFP_OPTIONAL
361 			"ieee80211w=1\n"
362 #endif
363 			"wpa_passphrase=%s",
364 			is_60Ghz_band_only ? "GCMP" : "CCMP",
365 			nw_params.passphrase.c_str());
366 		break;
367 	case EncryptionType::WPA3_SAE_TRANSITION:
368 		if (!validatePassphrase(
369 			nw_params.passphrase.size(),
370 			static_cast<uint32_t>(ParamSizeLimits::
371 				WPA2_PSK_PASSPHRASE_MIN_LEN_IN_BYTES),
372 			static_cast<uint32_t>(ParamSizeLimits::
373 				WPA2_PSK_PASSPHRASE_MAX_LEN_IN_BYTES))) {
374 			return "";
375 		}
376 		encryption_config_as_string = StringPrintf(
377 			"wpa=2\n"
378 			"rsn_pairwise=%s\n"
379 			"wpa_key_mgmt=WPA-PSK SAE\n"
380 			"ieee80211w=1\n"
381 			"sae_require_mfp=1\n"
382 			"wpa_passphrase=%s\n"
383 			"sae_password=%s",
384 			is_60Ghz_band_only ? "GCMP" : "CCMP",
385 			nw_params.passphrase.c_str(),
386 			nw_params.passphrase.c_str());
387 		break;
388 	case EncryptionType::WPA3_SAE:
389 		if (!validatePassphrase(nw_params.passphrase.size(), 1, -1)) {
390 			return "";
391 		}
392 		encryption_config_as_string = StringPrintf(
393 			"wpa=2\n"
394 			"rsn_pairwise=%s\n"
395 			"wpa_key_mgmt=SAE\n"
396 			"ieee80211w=2\n"
397 			"sae_require_mfp=2\n"
398 			"sae_pwe=%d\n"
399 			"sae_password=%s",
400 			is_60Ghz_band_only ? "GCMP" : "CCMP",
401 			is_6Ghz_band_only ? 1 : 2,
402 			nw_params.passphrase.c_str());
403 		break;
404 	case EncryptionType::WPA3_OWE_TRANSITION:
405 		encryption_config_as_string = StringPrintf(
406 			"wpa=2\n"
407 			"rsn_pairwise=%s\n"
408 			"wpa_key_mgmt=OWE\n"
409 			"ieee80211w=2",
410 			is_60Ghz_band_only ? "GCMP" : "CCMP");
411 		break;
412 	case EncryptionType::WPA3_OWE:
413 		encryption_config_as_string = StringPrintf(
414 			"wpa=2\n"
415 			"rsn_pairwise=%s\n"
416 			"wpa_key_mgmt=OWE\n"
417 			"ieee80211w=2",
418 			is_60Ghz_band_only ? "GCMP" : "CCMP");
419 		break;
420 	default:
421 		wpa_printf(MSG_ERROR, "Unknown encryption type");
422 		return "";
423 	}
424 
425 	std::string channel_config_as_string;
426 	bool isFirst = true;
427 	if (channelParams.enableAcs) {
428 		std::string freqList_as_string;
429 		for (const auto &range :
430 			channelParams.acsChannelFreqRangesMhz) {
431 			if (!isFirst) {
432 				freqList_as_string += ",";
433 			}
434 			isFirst = false;
435 
436 			if (range.startMhz != range.endMhz) {
437 				freqList_as_string +=
438 					StringPrintf("%d-%d", range.startMhz, range.endMhz);
439 			} else {
440 				freqList_as_string += StringPrintf("%d", range.startMhz);
441 			}
442 		}
443 		channel_config_as_string = StringPrintf(
444 			"channel=0\n"
445 			"acs_exclude_dfs=%d\n"
446 			"freqlist=%s",
447 			channelParams.acsShouldExcludeDfs,
448 			freqList_as_string.c_str());
449 	} else {
450 		int op_class = getOpClassForChannel(
451 			channelParams.channel,
452 			band,
453 			iface_params.hwModeParams.enable80211N,
454 			iface_params.hwModeParams.enable80211AC);
455 		channel_config_as_string = StringPrintf(
456 			"channel=%d\n"
457 			"op_class=%d",
458 			channelParams.channel, op_class);
459 	}
460 
461 	std::string hw_mode_as_string;
462 	std::string enable_edmg_as_string;
463 	std::string edmg_channel_as_string;
464 	bool is_60Ghz_used = false;
465 
466 	if (((band & band60Ghz) != 0)) {
467 		hw_mode_as_string = "hw_mode=ad";
468 		if (iface_params.hwModeParams.enableEdmg) {
469 			enable_edmg_as_string = "enable_edmg=1";
470 			edmg_channel_as_string = StringPrintf(
471 				"edmg_channel=%d",
472 				channelParams.channel);
473 		}
474 		is_60Ghz_used = true;
475 	} else if ((band & band2Ghz) != 0) {
476 		if (((band & band5Ghz) != 0)
477 		    || ((band & band6Ghz) != 0)) {
478 			hw_mode_as_string = "hw_mode=any";
479 		} else {
480 			hw_mode_as_string = "hw_mode=g";
481 		}
482 	} else if (((band & band5Ghz) != 0)
483 		    || ((band & band6Ghz) != 0)) {
484 			hw_mode_as_string = "hw_mode=a";
485 	} else {
486 		wpa_printf(MSG_ERROR, "Invalid band");
487 		return "";
488 	}
489 
490 	std::string he_params_as_string;
491 #ifdef CONFIG_IEEE80211AX
492 	if (iface_params.hwModeParams.enable80211AX && !is_60Ghz_used) {
493 		he_params_as_string = StringPrintf(
494 			"ieee80211ax=1\n"
495 			"he_su_beamformer=%d\n"
496 			"he_su_beamformee=%d\n"
497 			"he_mu_beamformer=%d\n"
498 			"he_twt_required=%d\n",
499 			iface_params.hwModeParams.enableHeSingleUserBeamformer ? 1 : 0,
500 			iface_params.hwModeParams.enableHeSingleUserBeamformee ? 1 : 0,
501 			iface_params.hwModeParams.enableHeMultiUserBeamformer ? 1 : 0,
502 			iface_params.hwModeParams.enableHeTargetWakeTime ? 1 : 0);
503 	} else {
504 		he_params_as_string = "ieee80211ax=0";
505 	}
506 #endif /* CONFIG_IEEE80211AX */
507 
508 	std::string ht_cap_vht_oper_he_oper_chwidth_as_string;
509 	switch (iface_params.hwModeParams.maximumChannelBandwidth) {
510 	case ChannelBandwidth::BANDWIDTH_20:
511 		ht_cap_vht_oper_he_oper_chwidth_as_string = StringPrintf(
512 #ifdef CONFIG_IEEE80211AX
513 			"he_oper_chwidth=0\n"
514 #endif
515 			"vht_oper_chwidth=0");
516 		break;
517 	case ChannelBandwidth::BANDWIDTH_40:
518 		ht_cap_vht_oper_he_oper_chwidth_as_string = StringPrintf(
519 			"ht_capab=[HT40+]\n"
520 #ifdef CONFIG_IEEE80211AX
521 			"he_oper_chwidth=0\n"
522 #endif
523 			"vht_oper_chwidth=0");
524 		break;
525 	case ChannelBandwidth::BANDWIDTH_80:
526 		ht_cap_vht_oper_he_oper_chwidth_as_string = StringPrintf(
527 			"ht_capab=[HT40+]\n"
528 #ifdef CONFIG_IEEE80211AX
529 			"he_oper_chwidth=%d\n"
530 #endif
531 			"vht_oper_chwidth=%d",
532 #ifdef CONFIG_IEEE80211AX
533 			(iface_params.hwModeParams.enable80211AX && !is_60Ghz_used) ? 1 : 0,
534 #endif
535 			iface_params.hwModeParams.enable80211AC ? 1 : 0);
536 		break;
537 	case ChannelBandwidth::BANDWIDTH_160:
538 		ht_cap_vht_oper_he_oper_chwidth_as_string = StringPrintf(
539 			"ht_capab=[HT40+]\n"
540 #ifdef CONFIG_IEEE80211AX
541 			"he_oper_chwidth=%d\n"
542 #endif
543 			"vht_oper_chwidth=%d",
544 #ifdef CONFIG_IEEE80211AX
545 			(iface_params.hwModeParams.enable80211AX && !is_60Ghz_used) ? 2 : 0,
546 #endif
547 			iface_params.hwModeParams.enable80211AC ? 2 : 0);
548 		break;
549 	default:
550 		if (!is_2Ghz_band_only && !is_60Ghz_used
551 		    && iface_params.hwModeParams.enable80211AC) {
552 			ht_cap_vht_oper_he_oper_chwidth_as_string =
553 					"ht_capab=[HT40+]\n"
554 					"vht_oper_chwidth=1\n";
555 		}
556 #ifdef CONFIG_IEEE80211AX
557 		if (iface_params.hwModeParams.enable80211AX && !is_60Ghz_used) {
558 			ht_cap_vht_oper_he_oper_chwidth_as_string += "he_oper_chwidth=1";
559 		}
560 #endif
561 		break;
562 	}
563 
564 #ifdef CONFIG_INTERWORKING
565 	std::string access_network_params_as_string;
566 	if (nw_params.isMetered) {
567 		access_network_params_as_string = StringPrintf(
568 			"interworking=1\n"
569 			"access_network_type=2\n"); // CHARGEABLE_PUBLIC_NETWORK
570 	} else {
571 	    access_network_params_as_string = StringPrintf(
572 			"interworking=0\n");
573 	}
574 #endif /* CONFIG_INTERWORKING */
575 
576 	std::string bridge_as_string;
577 	if (!br_name.empty()) {
578 		bridge_as_string = StringPrintf("bridge=%s", br_name.c_str());
579 	}
580 
581 	// vendor_elements string
582 	std::string vendor_elements_as_string;
583 	if (nw_params.vendorElements.size() > 0) {
584 		std::stringstream ss;
585 		ss << std::hex;
586 		ss << std::setfill('0');
587 		for (uint8_t b : nw_params.vendorElements) {
588 			ss << std::setw(2) << static_cast<unsigned int>(b);
589 		}
590 		vendor_elements_as_string = StringPrintf("vendor_elements=%s", ss.str().c_str());
591 	}
592 
593 	std::string owe_transition_ifname_as_string;
594 	if (!owe_transition_ifname.empty()) {
595 		owe_transition_ifname_as_string = StringPrintf(
596 			"owe_transition_ifname=%s", owe_transition_ifname.c_str());
597 	}
598 
599 	return StringPrintf(
600 		"interface=%s\n"
601 		"driver=nl80211\n"
602 		"ctrl_interface=/data/vendor/wifi/hostapd/ctrl\n"
603 		// ssid2 signals to hostapd that the value is not a literal value
604 		// for use as a SSID.  In this case, we're giving it a hex
605 		// std::string and hostapd needs to expect that.
606 		"ssid2=%s\n"
607 		"%s\n"
608 		"ieee80211n=%d\n"
609 		"ieee80211ac=%d\n"
610 		"%s\n"
611 		"%s\n"
612 		"%s\n"
613 		"ignore_broadcast_ssid=%d\n"
614 		"wowlan_triggers=any\n"
615 #ifdef CONFIG_INTERWORKING
616 		"%s\n"
617 #endif /* CONFIG_INTERWORKING */
618 		"%s\n"
619 		"%s\n"
620 		"%s\n"
621 		"%s\n"
622 		"%s\n"
623 		"%s\n",
624 		iface_params.name.c_str(), ssid_as_string.c_str(),
625 		channel_config_as_string.c_str(),
626 		iface_params.hwModeParams.enable80211N ? 1 : 0,
627 		iface_params.hwModeParams.enable80211AC ? 1 : 0,
628 		he_params_as_string.c_str(),
629 		hw_mode_as_string.c_str(), ht_cap_vht_oper_he_oper_chwidth_as_string.c_str(),
630 		nw_params.isHidden ? 1 : 0,
631 #ifdef CONFIG_INTERWORKING
632 		access_network_params_as_string.c_str(),
633 #endif /* CONFIG_INTERWORKING */
634 		encryption_config_as_string.c_str(),
635 		bridge_as_string.c_str(),
636 		owe_transition_ifname_as_string.c_str(),
637 		enable_edmg_as_string.c_str(),
638 		edmg_channel_as_string.c_str(),
639 		vendor_elements_as_string.c_str());
640 }
641 
getGeneration(hostapd_hw_modes * current_mode)642 Generation getGeneration(hostapd_hw_modes *current_mode)
643 {
644 	wpa_printf(MSG_DEBUG, "getGeneration hwmode=%d, ht_enabled=%d,"
645 		   " vht_enabled=%d, he_supported=%d",
646 		   current_mode->mode, current_mode->ht_capab != 0,
647 		   current_mode->vht_capab != 0, current_mode->he_capab->he_supported);
648 	switch (current_mode->mode) {
649 	case HOSTAPD_MODE_IEEE80211B:
650 		return Generation::WIFI_STANDARD_LEGACY;
651 	case HOSTAPD_MODE_IEEE80211G:
652 		return current_mode->ht_capab == 0 ?
653 				Generation::WIFI_STANDARD_LEGACY : Generation::WIFI_STANDARD_11N;
654 	case HOSTAPD_MODE_IEEE80211A:
655 		if (current_mode->he_capab->he_supported) {
656 			return Generation::WIFI_STANDARD_11AX;
657 		}
658 		return current_mode->vht_capab == 0 ?
659 		       Generation::WIFI_STANDARD_11N : Generation::WIFI_STANDARD_11AC;
660 	case HOSTAPD_MODE_IEEE80211AD:
661 		return Generation::WIFI_STANDARD_11AD;
662 	default:
663 		return Generation::WIFI_STANDARD_UNKNOWN;
664 	}
665 }
666 
getChannelBandwidth(struct hostapd_config * iconf)667 ChannelBandwidth getChannelBandwidth(struct hostapd_config *iconf)
668 {
669 	wpa_printf(MSG_DEBUG, "getChannelBandwidth %d, isHT=%d, isHT40=%d",
670 		   iconf->vht_oper_chwidth, iconf->ieee80211n,
671 		   iconf->secondary_channel);
672 	switch (iconf->vht_oper_chwidth) {
673 	case CHANWIDTH_80MHZ:
674 		return ChannelBandwidth::BANDWIDTH_80;
675 	case CHANWIDTH_80P80MHZ:
676 		return ChannelBandwidth::BANDWIDTH_80P80;
677 		break;
678 	case CHANWIDTH_160MHZ:
679 		return ChannelBandwidth::BANDWIDTH_160;
680 		break;
681 	case CHANWIDTH_USE_HT:
682 		if (iconf->ieee80211n) {
683 			return iconf->secondary_channel != 0 ?
684 				ChannelBandwidth::BANDWIDTH_40 : ChannelBandwidth::BANDWIDTH_20;
685 		}
686 		return ChannelBandwidth::BANDWIDTH_20_NOHT;
687 	case CHANWIDTH_2160MHZ:
688 		return ChannelBandwidth::BANDWIDTH_2160;
689 	case CHANWIDTH_4320MHZ:
690 		return ChannelBandwidth::BANDWIDTH_4320;
691 	case CHANWIDTH_6480MHZ:
692 		return ChannelBandwidth::BANDWIDTH_6480;
693 	case CHANWIDTH_8640MHZ:
694 		return ChannelBandwidth::BANDWIDTH_8640;
695 	default:
696 		return ChannelBandwidth::BANDWIDTH_INVALID;
697 	}
698 }
699 
forceStaDisconnection(struct hostapd_data * hapd,const std::vector<uint8_t> & client_address,const uint16_t reason_code)700 bool forceStaDisconnection(struct hostapd_data* hapd,
701 			   const std::vector<uint8_t>& client_address,
702 			   const uint16_t reason_code) {
703 	struct sta_info *sta;
704 	if (client_address.size() != ETH_ALEN) {
705 		return false;
706 	}
707 	for (sta = hapd->sta_list; sta; sta = sta->next) {
708 		int res;
709 		res = memcmp(sta->addr, client_address.data(), ETH_ALEN);
710 		if (res == 0) {
711 			wpa_printf(MSG_INFO, "Force client:" MACSTR " disconnect with reason: %d",
712 			    MAC2STR(client_address.data()), reason_code);
713 			ap_sta_disconnect(hapd, sta, sta->addr, reason_code);
714 			return true;
715 		}
716 	}
717 	return false;
718 }
719 
720 // hostapd core functions accept "C" style function pointers, so use global
721 // functions to pass to the hostapd core function and store the corresponding
722 // std::function methods to be invoked.
723 //
724 // NOTE: Using the pattern from the vendor HAL (wifi_legacy_hal.cpp).
725 //
726 // Callback to be invoked once setup is complete
727 std::function<void(struct hostapd_data*)> on_setup_complete_internal_callback;
onAsyncSetupCompleteCb(void * ctx)728 void onAsyncSetupCompleteCb(void* ctx)
729 {
730 	struct hostapd_data* iface_hapd = (struct hostapd_data*)ctx;
731 	if (on_setup_complete_internal_callback) {
732 		on_setup_complete_internal_callback(iface_hapd);
733 		// Invalidate this callback since we don't want this firing
734 		// again in single AP mode.
735 		if (strlen(iface_hapd->conf->bridge) > 0) {
736 			on_setup_complete_internal_callback = nullptr;
737 		}
738 	}
739 }
740 
741 // Callback to be invoked on hotspot client connection/disconnection
742 std::function<void(struct hostapd_data*, const u8 *mac_addr, int authorized,
743 		const u8 *p2p_dev_addr)> on_sta_authorized_internal_callback;
onAsyncStaAuthorizedCb(void * ctx,const u8 * mac_addr,int authorized,const u8 * p2p_dev_addr)744 void onAsyncStaAuthorizedCb(void* ctx, const u8 *mac_addr, int authorized,
745 		const u8 *p2p_dev_addr)
746 {
747 	struct hostapd_data* iface_hapd = (struct hostapd_data*)ctx;
748 	if (on_sta_authorized_internal_callback) {
749 		on_sta_authorized_internal_callback(iface_hapd, mac_addr,
750 			authorized, p2p_dev_addr);
751 	}
752 }
753 
754 std::function<void(struct hostapd_data*, int level,
755 			enum wpa_msg_type type, const char *txt,
756 			size_t len)> on_wpa_msg_internal_callback;
757 
onAsyncWpaEventCb(void * ctx,int level,enum wpa_msg_type type,const char * txt,size_t len)758 void onAsyncWpaEventCb(void *ctx, int level,
759 			enum wpa_msg_type type, const char *txt,
760 			size_t len)
761 {
762 	struct hostapd_data* iface_hapd = (struct hostapd_data*)ctx;
763 	if (on_wpa_msg_internal_callback) {
764 		on_wpa_msg_internal_callback(iface_hapd, level,
765 					type, txt, len);
766 	}
767 }
768 
createStatus(HostapdStatusCode status_code)769 inline ndk::ScopedAStatus createStatus(HostapdStatusCode status_code) {
770 	return ndk::ScopedAStatus::fromServiceSpecificError(
771 		static_cast<int32_t>(status_code));
772 }
773 
createStatusWithMsg(HostapdStatusCode status_code,std::string msg)774 inline ndk::ScopedAStatus createStatusWithMsg(
775 	HostapdStatusCode status_code, std::string msg)
776 {
777 	return ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(
778 		static_cast<int32_t>(status_code), msg.c_str());
779 }
780 
781 // Method called by death_notifier_ on client death.
onDeath(void * cookie)782 void onDeath(void* cookie) {
783 	wpa_printf(MSG_ERROR, "Client died. Terminating...");
784 	eloop_terminate();
785 }
786 
787 }  // namespace
788 
789 namespace aidl {
790 namespace android {
791 namespace hardware {
792 namespace wifi {
793 namespace hostapd {
794 
Hostapd(struct hapd_interfaces * interfaces)795 Hostapd::Hostapd(struct hapd_interfaces* interfaces)
796 	: interfaces_(interfaces)
797 {
798 	death_notifier_ = AIBinder_DeathRecipient_new(onDeath);
799 }
800 
addAccessPoint(const IfaceParams & iface_params,const NetworkParams & nw_params)801 ::ndk::ScopedAStatus Hostapd::addAccessPoint(
802 	const IfaceParams& iface_params, const NetworkParams& nw_params)
803 {
804 	return addAccessPointInternal(iface_params, nw_params);
805 }
806 
removeAccessPoint(const std::string & iface_name)807 ::ndk::ScopedAStatus Hostapd::removeAccessPoint(const std::string& iface_name)
808 {
809 	return removeAccessPointInternal(iface_name);
810 }
811 
terminate()812 ::ndk::ScopedAStatus Hostapd::terminate()
813 {
814 	wpa_printf(MSG_INFO, "Terminating...");
815 	// Clear the callback to avoid IPCThreadState shutdown during the
816 	// callback event.
817 	callbacks_.clear();
818 	eloop_terminate();
819 	return ndk::ScopedAStatus::ok();
820 }
821 
registerCallback(const std::shared_ptr<IHostapdCallback> & callback)822 ::ndk::ScopedAStatus Hostapd::registerCallback(
823 	const std::shared_ptr<IHostapdCallback>& callback)
824 {
825 	return registerCallbackInternal(callback);
826 }
827 
forceClientDisconnect(const std::string & iface_name,const std::vector<uint8_t> & client_address,Ieee80211ReasonCode reason_code)828 ::ndk::ScopedAStatus Hostapd::forceClientDisconnect(
829 	const std::string& iface_name, const std::vector<uint8_t>& client_address,
830 	Ieee80211ReasonCode reason_code)
831 {
832 	return forceClientDisconnectInternal(iface_name, client_address, reason_code);
833 }
834 
setDebugParams(DebugLevel level)835 ::ndk::ScopedAStatus Hostapd::setDebugParams(DebugLevel level)
836 {
837 	return setDebugParamsInternal(level);
838 }
839 
addAccessPointInternal(const IfaceParams & iface_params,const NetworkParams & nw_params)840 ::ndk::ScopedAStatus Hostapd::addAccessPointInternal(
841 	const IfaceParams& iface_params,
842 	const NetworkParams& nw_params)
843 {
844 	int channelParamsSize = iface_params.channelParams.size();
845 	if (channelParamsSize == 1) {
846 		// Single AP
847 		wpa_printf(MSG_INFO, "AddSingleAccessPoint, iface=%s",
848 			iface_params.name.c_str());
849 		return addSingleAccessPoint(iface_params, iface_params.channelParams[0],
850 		    nw_params, "", "");
851 	} else if (channelParamsSize == 2) {
852 		// Concurrent APs
853 		wpa_printf(MSG_INFO, "AddDualAccessPoint, iface=%s",
854 			iface_params.name.c_str());
855 		return addConcurrentAccessPoints(iface_params, nw_params);
856 	}
857 	return createStatus(HostapdStatusCode::FAILURE_ARGS_INVALID);
858 }
859 
generateRandomOweSsid()860 std::vector<uint8_t>  generateRandomOweSsid()
861 {
862 	u8 random[8] = {0};
863 	os_get_random(random, 8);
864 
865 	std::string ssid = StringPrintf("Owe-%s", random);
866 	wpa_printf(MSG_INFO, "Generated OWE SSID: %s", ssid.c_str());
867 	std::vector<uint8_t> vssid(ssid.begin(), ssid.end());
868 
869 	return vssid;
870 }
871 
addConcurrentAccessPoints(const IfaceParams & iface_params,const NetworkParams & nw_params)872 ::ndk::ScopedAStatus Hostapd::addConcurrentAccessPoints(
873 	const IfaceParams& iface_params, const NetworkParams& nw_params)
874 {
875 	int channelParamsListSize = iface_params.channelParams.size();
876 	// Get available interfaces in bridge
877 	std::vector<std::string> managed_interfaces;
878 	std::string br_name = StringPrintf(
879 		"%s", iface_params.name.c_str());
880 	if (!GetInterfacesInBridge(br_name, &managed_interfaces)) {
881 		return createStatusWithMsg(HostapdStatusCode::FAILURE_UNKNOWN,
882 			"Get interfaces in bridge failed.");
883 	}
884 	if (managed_interfaces.size() < channelParamsListSize) {
885 		return createStatusWithMsg(HostapdStatusCode::FAILURE_UNKNOWN,
886 			"Available interfaces less than requested bands");
887 	}
888 	// start BSS on specified bands
889 	for (std::size_t i = 0; i < channelParamsListSize; i ++) {
890 		IfaceParams iface_params_new = iface_params;
891 		NetworkParams nw_params_new = nw_params;
892 		iface_params_new.name = managed_interfaces[i];
893 
894 		std::string owe_transition_ifname = "";
895 		if (nw_params.encryptionType == EncryptionType::WPA3_OWE_TRANSITION) {
896 			if (i == 0 && i+1 < channelParamsListSize) {
897 				owe_transition_ifname = managed_interfaces[i+1];
898 				nw_params_new.encryptionType = EncryptionType::NONE;
899 			} else {
900 				owe_transition_ifname = managed_interfaces[0];
901 				nw_params_new.isHidden = true;
902 				nw_params_new.ssid = generateRandomOweSsid();
903 			}
904 		}
905 
906 		ndk::ScopedAStatus status = addSingleAccessPoint(
907 		    iface_params_new, iface_params.channelParams[i], nw_params_new,
908 		    br_name, owe_transition_ifname);
909 		if (!status.isOk()) {
910 			wpa_printf(MSG_ERROR, "Failed to addAccessPoint %s",
911 				   managed_interfaces[i].c_str());
912 			return status;
913 		}
914 	}
915 	// Save bridge interface info
916 	br_interfaces_[br_name] = managed_interfaces;
917 	return ndk::ScopedAStatus::ok();
918 }
919 
addSingleAccessPoint(const IfaceParams & iface_params,const ChannelParams & channelParams,const NetworkParams & nw_params,const std::string br_name,const std::string owe_transition_ifname)920 ::ndk::ScopedAStatus Hostapd::addSingleAccessPoint(
921 	const IfaceParams& iface_params,
922 	const ChannelParams& channelParams,
923 	const NetworkParams& nw_params,
924 	const std::string br_name,
925 	const std::string owe_transition_ifname)
926 {
927 	if (hostapd_get_iface(interfaces_, iface_params.name.c_str())) {
928 		wpa_printf(
929 			MSG_ERROR, "Interface %s already present",
930 			iface_params.name.c_str());
931 		return createStatus(HostapdStatusCode::FAILURE_IFACE_EXISTS);
932 	}
933 	const auto conf_params = CreateHostapdConfig(iface_params, channelParams, nw_params,
934 					br_name, owe_transition_ifname);
935 	if (conf_params.empty()) {
936 		wpa_printf(MSG_ERROR, "Failed to create config params");
937 		return createStatus(HostapdStatusCode::FAILURE_ARGS_INVALID);
938 	}
939 	const auto conf_file_path =
940 		WriteHostapdConfig(iface_params.name, conf_params);
941 	if (conf_file_path.empty()) {
942 		wpa_printf(MSG_ERROR, "Failed to write config file");
943 		return createStatus(HostapdStatusCode::FAILURE_UNKNOWN);
944 	}
945 	std::string add_iface_param_str = StringPrintf(
946 		"%s config=%s", iface_params.name.c_str(),
947 		conf_file_path.c_str());
948 	std::vector<char> add_iface_param_vec(
949 		add_iface_param_str.begin(), add_iface_param_str.end() + 1);
950 	if (hostapd_add_iface(interfaces_, add_iface_param_vec.data()) < 0) {
951 		wpa_printf(
952 			MSG_ERROR, "Adding interface %s failed",
953 			add_iface_param_str.c_str());
954 		return createStatus(HostapdStatusCode::FAILURE_UNKNOWN);
955 	}
956 	struct hostapd_data* iface_hapd =
957 	    hostapd_get_iface(interfaces_, iface_params.name.c_str());
958 	WPA_ASSERT(iface_hapd != nullptr && iface_hapd->iface != nullptr);
959 	// Register the setup complete callbacks
960 	on_setup_complete_internal_callback =
961 		[this](struct hostapd_data* iface_hapd) {
962 			wpa_printf(
963 			MSG_INFO, "AP interface setup completed - state %s",
964 			hostapd_state_text(iface_hapd->iface->state));
965 			if (iface_hapd->iface->state == HAPD_IFACE_DISABLED) {
966 				// Invoke the failure callback on all registered
967 				// clients.
968 				for (const auto& callback : callbacks_) {
969 					callback->onFailure(strlen(iface_hapd->conf->bridge) > 0 ?
970 						iface_hapd->conf->bridge : iface_hapd->conf->iface,
971 							    iface_hapd->conf->iface);
972 				}
973 			}
974 		};
975 
976 	// Register for new client connect/disconnect indication.
977 	on_sta_authorized_internal_callback =
978 		[this](struct hostapd_data* iface_hapd, const u8 *mac_addr,
979 			int authorized, const u8 *p2p_dev_addr) {
980 		wpa_printf(MSG_DEBUG, "notify client " MACSTR " %s",
981 				MAC2STR(mac_addr),
982 				(authorized) ? "Connected" : "Disconnected");
983 		ClientInfo info;
984 		info.ifaceName = strlen(iface_hapd->conf->bridge) > 0 ?
985 			iface_hapd->conf->bridge : iface_hapd->conf->iface;
986 		info.apIfaceInstance = iface_hapd->conf->iface;
987 		info.clientAddress.assign(mac_addr, mac_addr + ETH_ALEN);
988 		info.isConnected = authorized;
989 		for (const auto &callback : callbacks_) {
990 			callback->onConnectedClientsChanged(info);
991 		}
992 		};
993 
994 	// Register for wpa_event which used to get channel switch event
995 	on_wpa_msg_internal_callback =
996 		[this](struct hostapd_data* iface_hapd, int level,
997 			enum wpa_msg_type type, const char *txt,
998 			size_t len) {
999 		wpa_printf(MSG_DEBUG, "Receive wpa msg : %s", txt);
1000 		if (os_strncmp(txt, AP_EVENT_ENABLED,
1001 					strlen(AP_EVENT_ENABLED)) == 0 ||
1002 			os_strncmp(txt, WPA_EVENT_CHANNEL_SWITCH,
1003 					strlen(WPA_EVENT_CHANNEL_SWITCH)) == 0) {
1004 			ApInfo info;
1005 			info.ifaceName = strlen(iface_hapd->conf->bridge) > 0 ?
1006 				iface_hapd->conf->bridge : iface_hapd->conf->iface,
1007 			info.apIfaceInstance = iface_hapd->conf->iface;
1008 			info.freqMhz = iface_hapd->iface->freq;
1009 			info.channelBandwidth = getChannelBandwidth(iface_hapd->iconf);
1010 			info.generation = getGeneration(iface_hapd->iface->current_mode);
1011 			info.apIfaceInstanceMacAddress.assign(iface_hapd->own_addr,
1012 				iface_hapd->own_addr + ETH_ALEN);
1013 			for (const auto &callback : callbacks_) {
1014 				callback->onApInstanceInfoChanged(info);
1015 			}
1016 		} else if (os_strncmp(txt, AP_EVENT_DISABLED, strlen(AP_EVENT_DISABLED)) == 0
1017                            || os_strncmp(txt, INTERFACE_DISABLED, strlen(INTERFACE_DISABLED)) == 0)
1018 		{
1019 			// Invoke the failure callback on all registered clients.
1020 			for (const auto& callback : callbacks_) {
1021 				callback->onFailure(strlen(iface_hapd->conf->bridge) > 0 ?
1022 					iface_hapd->conf->bridge : iface_hapd->conf->iface,
1023 						    iface_hapd->conf->iface);
1024 			}
1025 		}
1026 	};
1027 
1028 	// Setup callback
1029 	iface_hapd->setup_complete_cb = onAsyncSetupCompleteCb;
1030 	iface_hapd->setup_complete_cb_ctx = iface_hapd;
1031 	iface_hapd->sta_authorized_cb = onAsyncStaAuthorizedCb;
1032 	iface_hapd->sta_authorized_cb_ctx = iface_hapd;
1033 	wpa_msg_register_cb(onAsyncWpaEventCb);
1034 
1035 	if (hostapd_enable_iface(iface_hapd->iface) < 0) {
1036 		wpa_printf(
1037 			MSG_ERROR, "Enabling interface %s failed",
1038 			iface_params.name.c_str());
1039 		return createStatus(HostapdStatusCode::FAILURE_UNKNOWN);
1040 	}
1041 	return ndk::ScopedAStatus::ok();
1042 }
1043 
removeAccessPointInternal(const std::string & iface_name)1044 ::ndk::ScopedAStatus Hostapd::removeAccessPointInternal(const std::string& iface_name)
1045 {
1046 	// interfaces to be removed
1047 	std::vector<std::string> interfaces;
1048 	bool is_error = false;
1049 
1050 	const auto it = br_interfaces_.find(iface_name);
1051 	if (it != br_interfaces_.end()) {
1052 		// In case bridge, remove managed interfaces
1053 		interfaces = it->second;
1054 		br_interfaces_.erase(iface_name);
1055 	} else {
1056 		// else remove current interface
1057 		interfaces.push_back(iface_name);
1058 	}
1059 
1060 	for (auto& iface : interfaces) {
1061 		std::vector<char> remove_iface_param_vec(
1062 		    iface.begin(), iface.end() + 1);
1063 		if (hostapd_remove_iface(interfaces_, remove_iface_param_vec.data()) <  0) {
1064 			wpa_printf(MSG_INFO, "Remove interface %s failed", iface.c_str());
1065 			is_error = true;
1066 		}
1067 	}
1068 	if (is_error) {
1069 		return createStatus(HostapdStatusCode::FAILURE_UNKNOWN);
1070 	}
1071 	return ndk::ScopedAStatus::ok();
1072 }
1073 
registerCallbackInternal(const std::shared_ptr<IHostapdCallback> & callback)1074 ::ndk::ScopedAStatus Hostapd::registerCallbackInternal(
1075 	const std::shared_ptr<IHostapdCallback>& callback)
1076 {
1077 	binder_status_t status = AIBinder_linkToDeath(callback->asBinder().get(),
1078 			death_notifier_, this /* cookie */);
1079 	if (status != STATUS_OK) {
1080 		wpa_printf(
1081 			MSG_ERROR,
1082 			"Error registering for death notification for "
1083 			"hostapd callback object");
1084 		return createStatus(HostapdStatusCode::FAILURE_UNKNOWN);
1085 	}
1086 	callbacks_.push_back(callback);
1087 	return ndk::ScopedAStatus::ok();
1088 }
1089 
forceClientDisconnectInternal(const std::string & iface_name,const std::vector<uint8_t> & client_address,Ieee80211ReasonCode reason_code)1090 ::ndk::ScopedAStatus Hostapd::forceClientDisconnectInternal(const std::string& iface_name,
1091 	const std::vector<uint8_t>& client_address, Ieee80211ReasonCode reason_code)
1092 {
1093 	struct hostapd_data *hapd = hostapd_get_iface(interfaces_, iface_name.c_str());
1094 	bool result;
1095 	if (!hapd) {
1096 		for (auto const& iface : br_interfaces_) {
1097 			if (iface.first == iface_name) {
1098 				for (auto const& instance : iface.second) {
1099 					hapd = hostapd_get_iface(interfaces_, instance.c_str());
1100 					if (hapd) {
1101 						result = forceStaDisconnection(hapd, client_address,
1102 								(uint16_t) reason_code);
1103 						if (result) break;
1104 					}
1105 				}
1106 			}
1107 		}
1108 	} else {
1109 		result = forceStaDisconnection(hapd, client_address, (uint16_t) reason_code);
1110 	}
1111 	if (!hapd) {
1112 		wpa_printf(MSG_ERROR, "Interface %s doesn't exist", iface_name.c_str());
1113 		return createStatus(HostapdStatusCode::FAILURE_IFACE_UNKNOWN);
1114 	}
1115 	if (result) {
1116 		return ndk::ScopedAStatus::ok();
1117 	}
1118 	return createStatus(HostapdStatusCode::FAILURE_CLIENT_UNKNOWN);
1119 }
1120 
setDebugParamsInternal(DebugLevel level)1121 ::ndk::ScopedAStatus Hostapd::setDebugParamsInternal(DebugLevel level)
1122 {
1123 	wpa_debug_level = static_cast<uint32_t>(level);
1124 	return ndk::ScopedAStatus::ok();
1125 }
1126 
1127 }  // namespace hostapd
1128 }  // namespace wifi
1129 }  // namespace hardware
1130 }  // namespace android
1131 }  // namespace aidl
1132