Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 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; |
Ahmed ElArabawy | b411579 | 2022-02-08 09:33:01 -0800 | [diff] [blame] | 50 | using aidl::android::hardware::wifi::hostapd::ChannelBandwidth; |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 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 | |
Manaswini Paluri | 76ae698 | 2024-02-29 14:49:20 +0530 | [diff] [blame] | 64 | int32_t aidl_client_version = 0; |
| 65 | int32_t aidl_service_version = 0; |
| 66 | |
| 67 | /** |
| 68 | * Check that the AIDL service is running at least the expected version. |
| 69 | * Use to avoid the case where the AIDL interface version |
| 70 | * is greater than the version implemented by the service. |
| 71 | */ |
| 72 | inline int32_t isAidlServiceVersionAtLeast(int32_t expected_version) |
| 73 | { |
| 74 | return expected_version <= aidl_service_version; |
| 75 | } |
| 76 | |
| 77 | inline int32_t isAidlClientVersionAtLeast(int32_t expected_version) |
| 78 | { |
| 79 | return expected_version <= aidl_client_version; |
| 80 | } |
| 81 | |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 82 | #define MAX_PORTS 1024 |
| 83 | bool GetInterfacesInBridge(std::string br_name, |
| 84 | std::vector<std::string>* interfaces) { |
| 85 | android::base::unique_fd sock(socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0)); |
| 86 | if (sock.get() < 0) { |
| 87 | wpa_printf(MSG_ERROR, "Failed to create sock (%s) in %s", |
| 88 | strerror(errno), __FUNCTION__); |
| 89 | return false; |
| 90 | } |
| 91 | |
| 92 | struct ifreq request; |
| 93 | int i, ifindices[MAX_PORTS]; |
| 94 | char if_name[IFNAMSIZ]; |
| 95 | unsigned long args[3]; |
| 96 | |
| 97 | memset(ifindices, 0, MAX_PORTS * sizeof(int)); |
| 98 | |
| 99 | args[0] = BRCTL_GET_PORT_LIST; |
| 100 | args[1] = (unsigned long) ifindices; |
| 101 | args[2] = MAX_PORTS; |
| 102 | |
| 103 | strlcpy(request.ifr_name, br_name.c_str(), IFNAMSIZ); |
| 104 | request.ifr_data = (char *)args; |
| 105 | |
| 106 | if (ioctl(sock.get(), SIOCDEVPRIVATE, &request) < 0) { |
| 107 | wpa_printf(MSG_ERROR, "Failed to ioctl SIOCDEVPRIVATE in %s", |
| 108 | __FUNCTION__); |
| 109 | return false; |
| 110 | } |
| 111 | |
| 112 | for (i = 0; i < MAX_PORTS; i ++) { |
| 113 | memset(if_name, 0, IFNAMSIZ); |
| 114 | if (ifindices[i] == 0 || !if_indextoname(ifindices[i], if_name)) { |
| 115 | continue; |
| 116 | } |
| 117 | interfaces->push_back(if_name); |
| 118 | } |
| 119 | return true; |
| 120 | } |
| 121 | |
| 122 | std::string WriteHostapdConfig( |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 123 | const std::string& instance_name, const std::string& config, |
| 124 | const std::string br_name, const bool usesMlo) |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 125 | { |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 126 | std::string conf_name_as_string = instance_name; |
| 127 | if (usesMlo) { |
| 128 | conf_name_as_string = StringPrintf( |
| 129 | "%s-%s", br_name.c_str(), instance_name.c_str()); |
| 130 | } |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 131 | const std::string file_path = |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 132 | StringPrintf(kConfFileNameFmt, conf_name_as_string.c_str()); |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 133 | if (WriteStringToFile( |
| 134 | config, file_path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, |
| 135 | getuid(), getgid())) { |
| 136 | return file_path; |
| 137 | } |
| 138 | // Diagnose failure |
| 139 | int error = errno; |
| 140 | wpa_printf( |
| 141 | MSG_ERROR, "Cannot write hostapd config to %s, error: %s", |
| 142 | file_path.c_str(), strerror(error)); |
| 143 | struct stat st; |
| 144 | int result = stat(file_path.c_str(), &st); |
| 145 | if (result == 0) { |
| 146 | wpa_printf( |
| 147 | MSG_ERROR, "hostapd config file uid: %d, gid: %d, mode: %d", |
| 148 | st.st_uid, st.st_gid, st.st_mode); |
| 149 | } else { |
| 150 | wpa_printf( |
| 151 | MSG_ERROR, |
| 152 | "Error calling stat() on hostapd config file: %s", |
| 153 | strerror(errno)); |
| 154 | } |
| 155 | return ""; |
| 156 | } |
| 157 | |
| 158 | /* |
| 159 | * Get the op_class for a channel/band |
| 160 | * The logic here is based on Table E-4 in the 802.11 Specification |
| 161 | */ |
| 162 | int getOpClassForChannel(int channel, int band, bool support11n, bool support11ac) { |
| 163 | // 2GHz Band |
| 164 | if ((band & band2Ghz) != 0) { |
| 165 | if (channel == 14) { |
| 166 | return 82; |
| 167 | } |
| 168 | if (channel >= 1 && channel <= 13) { |
| 169 | if (!support11n) { |
| 170 | //20MHz channel |
| 171 | return 81; |
| 172 | } |
| 173 | if (channel <= 9) { |
| 174 | // HT40 with secondary channel above primary |
| 175 | return 83; |
| 176 | } |
| 177 | // HT40 with secondary channel below primary |
| 178 | return 84; |
| 179 | } |
| 180 | // Error |
| 181 | return 0; |
| 182 | } |
| 183 | |
| 184 | // 5GHz Band |
| 185 | if ((band & band5Ghz) != 0) { |
| 186 | if (support11ac) { |
| 187 | switch (channel) { |
| 188 | case 42: |
| 189 | case 58: |
| 190 | case 106: |
| 191 | case 122: |
| 192 | case 138: |
| 193 | case 155: |
| 194 | // 80MHz channel |
| 195 | return 128; |
| 196 | case 50: |
| 197 | case 114: |
| 198 | // 160MHz channel |
| 199 | return 129; |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | if (!support11n) { |
| 204 | if (channel >= 36 && channel <= 48) { |
| 205 | return 115; |
| 206 | } |
| 207 | if (channel >= 52 && channel <= 64) { |
| 208 | return 118; |
| 209 | } |
| 210 | if (channel >= 100 && channel <= 144) { |
| 211 | return 121; |
| 212 | } |
| 213 | if (channel >= 149 && channel <= 161) { |
| 214 | return 124; |
| 215 | } |
| 216 | if (channel >= 165 && channel <= 169) { |
| 217 | return 125; |
| 218 | } |
| 219 | } else { |
| 220 | switch (channel) { |
| 221 | case 36: |
| 222 | case 44: |
| 223 | // HT40 with secondary channel above primary |
| 224 | return 116; |
| 225 | case 40: |
| 226 | case 48: |
| 227 | // HT40 with secondary channel below primary |
| 228 | return 117; |
| 229 | case 52: |
| 230 | case 60: |
| 231 | // HT40 with secondary channel above primary |
| 232 | return 119; |
| 233 | case 56: |
| 234 | case 64: |
| 235 | // HT40 with secondary channel below primary |
| 236 | return 120; |
| 237 | case 100: |
| 238 | case 108: |
| 239 | case 116: |
| 240 | case 124: |
| 241 | case 132: |
| 242 | case 140: |
| 243 | // HT40 with secondary channel above primary |
| 244 | return 122; |
| 245 | case 104: |
| 246 | case 112: |
| 247 | case 120: |
| 248 | case 128: |
| 249 | case 136: |
| 250 | case 144: |
| 251 | // HT40 with secondary channel below primary |
| 252 | return 123; |
| 253 | case 149: |
| 254 | case 157: |
| 255 | // HT40 with secondary channel above primary |
| 256 | return 126; |
| 257 | case 153: |
| 258 | case 161: |
| 259 | // HT40 with secondary channel below primary |
| 260 | return 127; |
| 261 | } |
| 262 | } |
| 263 | // Error |
| 264 | return 0; |
| 265 | } |
| 266 | |
| 267 | // 6GHz Band |
| 268 | if ((band & band6Ghz) != 0) { |
| 269 | // Channels 1, 5. 9, 13, ... |
| 270 | if ((channel & 0x03) == 0x01) { |
| 271 | // 20MHz channel |
| 272 | return 131; |
| 273 | } |
| 274 | // Channels 3, 11, 19, 27, ... |
| 275 | if ((channel & 0x07) == 0x03) { |
| 276 | // 40MHz channel |
| 277 | return 132; |
| 278 | } |
| 279 | // Channels 7, 23, 39, 55, ... |
| 280 | if ((channel & 0x0F) == 0x07) { |
| 281 | // 80MHz channel |
| 282 | return 133; |
| 283 | } |
| 284 | // Channels 15, 47, 69, ... |
| 285 | if ((channel & 0x1F) == 0x0F) { |
| 286 | // 160MHz channel |
| 287 | return 134; |
| 288 | } |
| 289 | if (channel == 2) { |
| 290 | // 20MHz channel |
| 291 | return 136; |
| 292 | } |
| 293 | // Error |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | if ((band & band60Ghz) != 0) { |
| 298 | if (1 <= channel && channel <= 8) { |
| 299 | return 180; |
| 300 | } else if (9 <= channel && channel <= 15) { |
| 301 | return 181; |
| 302 | } else if (17 <= channel && channel <= 22) { |
| 303 | return 182; |
| 304 | } else if (25 <= channel && channel <= 29) { |
| 305 | return 183; |
| 306 | } |
| 307 | // Error |
| 308 | return 0; |
| 309 | } |
| 310 | |
| 311 | return 0; |
| 312 | } |
| 313 | |
| 314 | bool validatePassphrase(int passphrase_len, int min_len, int max_len) |
| 315 | { |
| 316 | if (min_len != -1 && passphrase_len < min_len) return false; |
| 317 | if (max_len != -1 && passphrase_len > max_len) return false; |
| 318 | return true; |
| 319 | } |
| 320 | |
Manaswini Paluri | 76ae698 | 2024-02-29 14:49:20 +0530 | [diff] [blame] | 321 | std::string getInterfaceMacAddress(const std::string& if_name) |
| 322 | { |
| 323 | u8 addr[ETH_ALEN] = {}; |
| 324 | struct ifreq ifr; |
| 325 | std::string mac_addr; |
| 326 | |
| 327 | android::base::unique_fd sock(socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0)); |
| 328 | if (sock.get() < 0) { |
| 329 | wpa_printf(MSG_ERROR, "Failed to create sock (%s) in %s", |
| 330 | strerror(errno), __FUNCTION__); |
| 331 | return ""; |
| 332 | } |
| 333 | |
| 334 | memset(&ifr, 0, sizeof(ifr)); |
| 335 | strlcpy(ifr.ifr_name, if_name.c_str(), IFNAMSIZ); |
| 336 | if (ioctl(sock.get(), SIOCGIFHWADDR, &ifr) < 0) { |
| 337 | wpa_printf(MSG_ERROR, "Could not get interface %s hwaddr: %s", |
| 338 | if_name.c_str(), strerror(errno)); |
| 339 | return ""; |
| 340 | } |
| 341 | |
| 342 | memcpy(addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN); |
| 343 | mac_addr = StringPrintf("" MACSTR, MAC2STR(addr)); |
| 344 | |
| 345 | return mac_addr; |
| 346 | } |
| 347 | |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 348 | std::string CreateHostapdConfig( |
| 349 | const IfaceParams& iface_params, |
| 350 | const ChannelParams& channelParams, |
| 351 | const NetworkParams& nw_params, |
Purushottam Kushwaha | 0316c88 | 2021-12-20 15:07:44 +0530 | [diff] [blame] | 352 | const std::string br_name, |
| 353 | const std::string owe_transition_ifname) |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 354 | { |
| 355 | if (nw_params.ssid.size() > |
| 356 | static_cast<uint32_t>( |
| 357 | ParamSizeLimits::SSID_MAX_LEN_IN_BYTES)) { |
| 358 | wpa_printf( |
| 359 | MSG_ERROR, "Invalid SSID size: %zu", nw_params.ssid.size()); |
| 360 | return ""; |
| 361 | } |
| 362 | |
| 363 | // SSID string |
| 364 | std::stringstream ss; |
| 365 | ss << std::hex; |
| 366 | ss << std::setfill('0'); |
| 367 | for (uint8_t b : nw_params.ssid) { |
| 368 | ss << std::setw(2) << static_cast<unsigned int>(b); |
| 369 | } |
| 370 | const std::string ssid_as_string = ss.str(); |
| 371 | |
| 372 | // Encryption config string |
| 373 | uint32_t band = 0; |
| 374 | band |= static_cast<uint32_t>(channelParams.bandMask); |
Sunil Ravi | 4fc918f | 2022-04-17 09:26:48 -0700 | [diff] [blame] | 375 | bool is_2Ghz_band_only = band == static_cast<uint32_t>(band2Ghz); |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 376 | bool is_6Ghz_band_only = band == static_cast<uint32_t>(band6Ghz); |
| 377 | bool is_60Ghz_band_only = band == static_cast<uint32_t>(band60Ghz); |
| 378 | std::string encryption_config_as_string; |
| 379 | switch (nw_params.encryptionType) { |
| 380 | case EncryptionType::NONE: |
| 381 | // no security params |
| 382 | break; |
| 383 | case EncryptionType::WPA: |
| 384 | if (!validatePassphrase( |
| 385 | nw_params.passphrase.size(), |
| 386 | static_cast<uint32_t>(ParamSizeLimits:: |
| 387 | WPA2_PSK_PASSPHRASE_MIN_LEN_IN_BYTES), |
| 388 | static_cast<uint32_t>(ParamSizeLimits:: |
| 389 | WPA2_PSK_PASSPHRASE_MAX_LEN_IN_BYTES))) { |
| 390 | return ""; |
| 391 | } |
| 392 | encryption_config_as_string = StringPrintf( |
| 393 | "wpa=3\n" |
| 394 | "wpa_pairwise=%s\n" |
| 395 | "wpa_passphrase=%s", |
| 396 | is_60Ghz_band_only ? "GCMP" : "TKIP CCMP", |
| 397 | nw_params.passphrase.c_str()); |
| 398 | break; |
| 399 | case EncryptionType::WPA2: |
| 400 | if (!validatePassphrase( |
| 401 | nw_params.passphrase.size(), |
| 402 | static_cast<uint32_t>(ParamSizeLimits:: |
| 403 | WPA2_PSK_PASSPHRASE_MIN_LEN_IN_BYTES), |
| 404 | static_cast<uint32_t>(ParamSizeLimits:: |
| 405 | WPA2_PSK_PASSPHRASE_MAX_LEN_IN_BYTES))) { |
| 406 | return ""; |
| 407 | } |
| 408 | encryption_config_as_string = StringPrintf( |
| 409 | "wpa=2\n" |
| 410 | "rsn_pairwise=%s\n" |
Sunil Ravi | b3580db | 2022-01-28 12:25:46 -0800 | [diff] [blame] | 411 | #ifdef ENABLE_HOSTAPD_CONFIG_80211W_MFP_OPTIONAL |
| 412 | "ieee80211w=1\n" |
| 413 | #endif |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 414 | "wpa_passphrase=%s", |
| 415 | is_60Ghz_band_only ? "GCMP" : "CCMP", |
| 416 | nw_params.passphrase.c_str()); |
| 417 | break; |
| 418 | case EncryptionType::WPA3_SAE_TRANSITION: |
| 419 | if (!validatePassphrase( |
| 420 | nw_params.passphrase.size(), |
| 421 | static_cast<uint32_t>(ParamSizeLimits:: |
| 422 | WPA2_PSK_PASSPHRASE_MIN_LEN_IN_BYTES), |
| 423 | static_cast<uint32_t>(ParamSizeLimits:: |
| 424 | WPA2_PSK_PASSPHRASE_MAX_LEN_IN_BYTES))) { |
| 425 | return ""; |
| 426 | } |
Sunil Ravi | d917c83 | 2023-07-07 17:30:33 +0000 | [diff] [blame] | 427 | // WPA3 transition mode or SAE+WPA_PSK key management(AKM) is not allowed in 6GHz. |
| 428 | // Auto-convert any such configurations to SAE. |
| 429 | if ((band & band6Ghz) != 0) { |
| 430 | wpa_printf(MSG_INFO, "WPA3_SAE_TRANSITION configured in 6GHz band." |
| 431 | "Enable only SAE in key_mgmt"); |
| 432 | encryption_config_as_string = StringPrintf( |
| 433 | "wpa=2\n" |
| 434 | "rsn_pairwise=CCMP\n" |
| 435 | "wpa_key_mgmt=%s\n" |
| 436 | "ieee80211w=2\n" |
| 437 | "sae_require_mfp=2\n" |
| 438 | "sae_pwe=%d\n" |
| 439 | "sae_password=%s", |
Sunil Ravi | c1edd3e | 2023-02-06 18:52:51 +0000 | [diff] [blame] | 440 | #ifdef CONFIG_IEEE80211BE |
Sunil Ravi | d917c83 | 2023-07-07 17:30:33 +0000 | [diff] [blame] | 441 | iface_params.hwModeParams.enable80211BE ? |
| 442 | "SAE SAE-EXT-KEY" : "SAE", |
Sunil Ravi | c1edd3e | 2023-02-06 18:52:51 +0000 | [diff] [blame] | 443 | #else |
Sunil Ravi | d917c83 | 2023-07-07 17:30:33 +0000 | [diff] [blame] | 444 | "SAE", |
Sunil Ravi | c1edd3e | 2023-02-06 18:52:51 +0000 | [diff] [blame] | 445 | #endif |
Sunil Ravi | d917c83 | 2023-07-07 17:30:33 +0000 | [diff] [blame] | 446 | is_6Ghz_band_only ? 1 : 2, |
| 447 | nw_params.passphrase.c_str()); |
| 448 | } else { |
| 449 | encryption_config_as_string = StringPrintf( |
| 450 | "wpa=2\n" |
| 451 | "rsn_pairwise=%s\n" |
| 452 | "wpa_key_mgmt=%s\n" |
| 453 | "ieee80211w=1\n" |
| 454 | "sae_require_mfp=1\n" |
| 455 | "wpa_passphrase=%s\n" |
| 456 | "sae_password=%s", |
| 457 | is_60Ghz_band_only ? "GCMP" : "CCMP", |
| 458 | #ifdef CONFIG_IEEE80211BE |
| 459 | iface_params.hwModeParams.enable80211BE ? |
| 460 | "WPA-PSK SAE SAE-EXT-KEY" : "WPA-PSK SAE", |
| 461 | #else |
| 462 | "WPA-PSK SAE", |
| 463 | #endif |
| 464 | nw_params.passphrase.c_str(), |
| 465 | nw_params.passphrase.c_str()); |
| 466 | } |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 467 | break; |
| 468 | case EncryptionType::WPA3_SAE: |
| 469 | if (!validatePassphrase(nw_params.passphrase.size(), 1, -1)) { |
| 470 | return ""; |
| 471 | } |
| 472 | encryption_config_as_string = StringPrintf( |
| 473 | "wpa=2\n" |
| 474 | "rsn_pairwise=%s\n" |
Sunil Ravi | 6525173 | 2023-01-24 05:03:35 +0000 | [diff] [blame] | 475 | "wpa_key_mgmt=%s\n" |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 476 | "ieee80211w=2\n" |
| 477 | "sae_require_mfp=2\n" |
| 478 | "sae_pwe=%d\n" |
| 479 | "sae_password=%s", |
| 480 | is_60Ghz_band_only ? "GCMP" : "CCMP", |
Sunil Ravi | 6525173 | 2023-01-24 05:03:35 +0000 | [diff] [blame] | 481 | #ifdef CONFIG_IEEE80211BE |
| 482 | iface_params.hwModeParams.enable80211BE ? "SAE SAE-EXT-KEY" : "SAE", |
| 483 | #else |
| 484 | "SAE", |
| 485 | #endif |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 486 | is_6Ghz_band_only ? 1 : 2, |
| 487 | nw_params.passphrase.c_str()); |
| 488 | break; |
Ahmed ElArabawy | 1aaf180 | 2022-02-04 15:58:55 -0800 | [diff] [blame] | 489 | case EncryptionType::WPA3_OWE_TRANSITION: |
| 490 | encryption_config_as_string = StringPrintf( |
| 491 | "wpa=2\n" |
| 492 | "rsn_pairwise=%s\n" |
| 493 | "wpa_key_mgmt=OWE\n" |
| 494 | "ieee80211w=2", |
| 495 | is_60Ghz_band_only ? "GCMP" : "CCMP"); |
| 496 | break; |
| 497 | case EncryptionType::WPA3_OWE: |
Purushottam Kushwaha | 0316c88 | 2021-12-20 15:07:44 +0530 | [diff] [blame] | 498 | encryption_config_as_string = StringPrintf( |
| 499 | "wpa=2\n" |
| 500 | "rsn_pairwise=%s\n" |
| 501 | "wpa_key_mgmt=OWE\n" |
| 502 | "ieee80211w=2", |
| 503 | is_60Ghz_band_only ? "GCMP" : "CCMP"); |
| 504 | break; |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 505 | default: |
| 506 | wpa_printf(MSG_ERROR, "Unknown encryption type"); |
| 507 | return ""; |
| 508 | } |
| 509 | |
| 510 | std::string channel_config_as_string; |
| 511 | bool isFirst = true; |
| 512 | if (channelParams.enableAcs) { |
| 513 | std::string freqList_as_string; |
| 514 | for (const auto &range : |
| 515 | channelParams.acsChannelFreqRangesMhz) { |
| 516 | if (!isFirst) { |
| 517 | freqList_as_string += ","; |
| 518 | } |
| 519 | isFirst = false; |
| 520 | |
| 521 | if (range.startMhz != range.endMhz) { |
| 522 | freqList_as_string += |
| 523 | StringPrintf("%d-%d", range.startMhz, range.endMhz); |
| 524 | } else { |
| 525 | freqList_as_string += StringPrintf("%d", range.startMhz); |
| 526 | } |
| 527 | } |
| 528 | channel_config_as_string = StringPrintf( |
| 529 | "channel=0\n" |
| 530 | "acs_exclude_dfs=%d\n" |
| 531 | "freqlist=%s", |
| 532 | channelParams.acsShouldExcludeDfs, |
| 533 | freqList_as_string.c_str()); |
| 534 | } else { |
| 535 | int op_class = getOpClassForChannel( |
| 536 | channelParams.channel, |
| 537 | band, |
| 538 | iface_params.hwModeParams.enable80211N, |
| 539 | iface_params.hwModeParams.enable80211AC); |
| 540 | channel_config_as_string = StringPrintf( |
| 541 | "channel=%d\n" |
| 542 | "op_class=%d", |
| 543 | channelParams.channel, op_class); |
| 544 | } |
| 545 | |
| 546 | std::string hw_mode_as_string; |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 547 | std::string enable_edmg_as_string; |
| 548 | std::string edmg_channel_as_string; |
| 549 | bool is_60Ghz_used = false; |
| 550 | |
| 551 | if (((band & band60Ghz) != 0)) { |
| 552 | hw_mode_as_string = "hw_mode=ad"; |
| 553 | if (iface_params.hwModeParams.enableEdmg) { |
| 554 | enable_edmg_as_string = "enable_edmg=1"; |
| 555 | edmg_channel_as_string = StringPrintf( |
| 556 | "edmg_channel=%d", |
| 557 | channelParams.channel); |
| 558 | } |
| 559 | is_60Ghz_used = true; |
| 560 | } else if ((band & band2Ghz) != 0) { |
| 561 | if (((band & band5Ghz) != 0) |
| 562 | || ((band & band6Ghz) != 0)) { |
| 563 | hw_mode_as_string = "hw_mode=any"; |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 564 | } else { |
| 565 | hw_mode_as_string = "hw_mode=g"; |
| 566 | } |
| 567 | } else if (((band & band5Ghz) != 0) |
| 568 | || ((band & band6Ghz) != 0)) { |
| 569 | hw_mode_as_string = "hw_mode=a"; |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 570 | } else { |
| 571 | wpa_printf(MSG_ERROR, "Invalid band"); |
| 572 | return ""; |
| 573 | } |
| 574 | |
| 575 | std::string he_params_as_string; |
| 576 | #ifdef CONFIG_IEEE80211AX |
| 577 | if (iface_params.hwModeParams.enable80211AX && !is_60Ghz_used) { |
| 578 | he_params_as_string = StringPrintf( |
| 579 | "ieee80211ax=1\n" |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 580 | "he_su_beamformer=%d\n" |
| 581 | "he_su_beamformee=%d\n" |
| 582 | "he_mu_beamformer=%d\n" |
| 583 | "he_twt_required=%d\n", |
| 584 | iface_params.hwModeParams.enableHeSingleUserBeamformer ? 1 : 0, |
| 585 | iface_params.hwModeParams.enableHeSingleUserBeamformee ? 1 : 0, |
| 586 | iface_params.hwModeParams.enableHeMultiUserBeamformer ? 1 : 0, |
| 587 | iface_params.hwModeParams.enableHeTargetWakeTime ? 1 : 0); |
| 588 | } else { |
| 589 | he_params_as_string = "ieee80211ax=0"; |
| 590 | } |
| 591 | #endif /* CONFIG_IEEE80211AX */ |
Sunil Ravi | 6525173 | 2023-01-24 05:03:35 +0000 | [diff] [blame] | 592 | std::string eht_params_as_string; |
| 593 | #ifdef CONFIG_IEEE80211BE |
| 594 | if (iface_params.hwModeParams.enable80211BE && !is_60Ghz_used) { |
Manaswini Paluri | 76ae698 | 2024-02-29 14:49:20 +0530 | [diff] [blame] | 595 | eht_params_as_string = "ieee80211be=1\n"; |
| 596 | if (isAidlServiceVersionAtLeast(2) && isAidlClientVersionAtLeast(2)) { |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 597 | std::string interface_mac_addr = getInterfaceMacAddress( |
| 598 | iface_params.usesMlo ? br_name : iface_params.name); |
Manaswini Paluri | 76ae698 | 2024-02-29 14:49:20 +0530 | [diff] [blame] | 599 | if (interface_mac_addr.empty()) { |
| 600 | wpa_printf(MSG_ERROR, |
| 601 | "Unable to set interface mac address as bssid for 11BE SAP"); |
| 602 | return ""; |
| 603 | } |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 604 | if (iface_params.usesMlo) { |
| 605 | eht_params_as_string += StringPrintf( |
| 606 | "mld_addr=%s\n" |
| 607 | "mld_ap=1", |
| 608 | interface_mac_addr.c_str()); |
| 609 | } else { |
| 610 | eht_params_as_string += StringPrintf( |
| 611 | "bssid=%s\n" |
| 612 | "mld_ap=1", |
| 613 | interface_mac_addr.c_str()); |
| 614 | } |
Manaswini Paluri | 76ae698 | 2024-02-29 14:49:20 +0530 | [diff] [blame] | 615 | } |
Sunil Ravi | 6525173 | 2023-01-24 05:03:35 +0000 | [diff] [blame] | 616 | /* TODO set eht_su_beamformer, eht_su_beamformee, eht_mu_beamformer */ |
| 617 | } else { |
| 618 | eht_params_as_string = "ieee80211be=0"; |
| 619 | } |
| 620 | #endif /* CONFIG_IEEE80211BE */ |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 621 | |
Xin Deng | fec682f | 2024-02-06 22:59:39 -0800 | [diff] [blame] | 622 | std::string ht_cap_vht_oper_he_oper_eht_oper_chwidth_as_string; |
Purushottam Kushwaha | 90c710b | 2022-02-04 19:00:34 +0530 | [diff] [blame] | 623 | switch (iface_params.hwModeParams.maximumChannelBandwidth) { |
| 624 | case ChannelBandwidth::BANDWIDTH_20: |
Xin Deng | fec682f | 2024-02-06 22:59:39 -0800 | [diff] [blame] | 625 | ht_cap_vht_oper_he_oper_eht_oper_chwidth_as_string = StringPrintf( |
| 626 | #ifdef CONFIG_IEEE80211BE |
| 627 | "eht_oper_chwidth=0\n" |
| 628 | #endif /* CONFIG_IEEE80211BE */ |
Purushottam Kushwaha | 90c710b | 2022-02-04 19:00:34 +0530 | [diff] [blame] | 629 | #ifdef CONFIG_IEEE80211AX |
| 630 | "he_oper_chwidth=0\n" |
| 631 | #endif |
Kiran Kumar Lokere | b644512 | 2024-02-06 20:06:27 -0800 | [diff] [blame] | 632 | "vht_oper_chwidth=0\n" |
| 633 | "%s", (band & band6Ghz) ? "op_class=131" : ""); |
Purushottam Kushwaha | 90c710b | 2022-02-04 19:00:34 +0530 | [diff] [blame] | 634 | break; |
| 635 | case ChannelBandwidth::BANDWIDTH_40: |
Xin Deng | fec682f | 2024-02-06 22:59:39 -0800 | [diff] [blame] | 636 | ht_cap_vht_oper_he_oper_eht_oper_chwidth_as_string = StringPrintf( |
Purushottam Kushwaha | 90c710b | 2022-02-04 19:00:34 +0530 | [diff] [blame] | 637 | "ht_capab=[HT40+]\n" |
Xin Deng | fec682f | 2024-02-06 22:59:39 -0800 | [diff] [blame] | 638 | #ifdef CONFIG_IEEE80211BE |
| 639 | "eht_oper_chwidth=0\n" |
| 640 | #endif /* CONFIG_IEEE80211BE */ |
Purushottam Kushwaha | 90c710b | 2022-02-04 19:00:34 +0530 | [diff] [blame] | 641 | #ifdef CONFIG_IEEE80211AX |
| 642 | "he_oper_chwidth=0\n" |
| 643 | #endif |
Kiran Kumar Lokere | b644512 | 2024-02-06 20:06:27 -0800 | [diff] [blame] | 644 | "vht_oper_chwidth=0\n" |
| 645 | "%s", (band & band6Ghz) ? "op_class=132" : ""); |
Purushottam Kushwaha | 90c710b | 2022-02-04 19:00:34 +0530 | [diff] [blame] | 646 | break; |
| 647 | case ChannelBandwidth::BANDWIDTH_80: |
Xin Deng | fec682f | 2024-02-06 22:59:39 -0800 | [diff] [blame] | 648 | ht_cap_vht_oper_he_oper_eht_oper_chwidth_as_string = StringPrintf( |
Purushottam Kushwaha | 90c710b | 2022-02-04 19:00:34 +0530 | [diff] [blame] | 649 | "ht_capab=[HT40+]\n" |
Xin Deng | fec682f | 2024-02-06 22:59:39 -0800 | [diff] [blame] | 650 | #ifdef CONFIG_IEEE80211BE |
| 651 | "eht_oper_chwidth=%d\n" |
| 652 | #endif /* CONFIG_IEEE80211BE */ |
Purushottam Kushwaha | 90c710b | 2022-02-04 19:00:34 +0530 | [diff] [blame] | 653 | #ifdef CONFIG_IEEE80211AX |
| 654 | "he_oper_chwidth=%d\n" |
| 655 | #endif |
Kiran Kumar Lokere | b644512 | 2024-02-06 20:06:27 -0800 | [diff] [blame] | 656 | "vht_oper_chwidth=%d\n" |
| 657 | "%s", |
Xin Deng | fec682f | 2024-02-06 22:59:39 -0800 | [diff] [blame] | 658 | #ifdef CONFIG_IEEE80211BE |
| 659 | (iface_params.hwModeParams.enable80211BE && !is_60Ghz_used) ? 1 : 0, |
| 660 | #endif |
Purushottam Kushwaha | 90c710b | 2022-02-04 19:00:34 +0530 | [diff] [blame] | 661 | #ifdef CONFIG_IEEE80211AX |
| 662 | (iface_params.hwModeParams.enable80211AX && !is_60Ghz_used) ? 1 : 0, |
| 663 | #endif |
Kiran Kumar Lokere | b644512 | 2024-02-06 20:06:27 -0800 | [diff] [blame] | 664 | iface_params.hwModeParams.enable80211AC ? 1 : 0, |
| 665 | (band & band6Ghz) ? "op_class=133" : ""); |
Purushottam Kushwaha | 90c710b | 2022-02-04 19:00:34 +0530 | [diff] [blame] | 666 | break; |
| 667 | case ChannelBandwidth::BANDWIDTH_160: |
Xin Deng | fec682f | 2024-02-06 22:59:39 -0800 | [diff] [blame] | 668 | ht_cap_vht_oper_he_oper_eht_oper_chwidth_as_string = StringPrintf( |
Purushottam Kushwaha | 90c710b | 2022-02-04 19:00:34 +0530 | [diff] [blame] | 669 | "ht_capab=[HT40+]\n" |
Xin Deng | fec682f | 2024-02-06 22:59:39 -0800 | [diff] [blame] | 670 | #ifdef CONFIG_IEEE80211BE |
| 671 | "eht_oper_chwidth=%d\n" |
| 672 | #endif /* CONFIG_IEEE80211BE */ |
Purushottam Kushwaha | 90c710b | 2022-02-04 19:00:34 +0530 | [diff] [blame] | 673 | #ifdef CONFIG_IEEE80211AX |
| 674 | "he_oper_chwidth=%d\n" |
| 675 | #endif |
Kiran Kumar Lokere | b644512 | 2024-02-06 20:06:27 -0800 | [diff] [blame] | 676 | "vht_oper_chwidth=%d\n" |
| 677 | "%s", |
Xin Deng | fec682f | 2024-02-06 22:59:39 -0800 | [diff] [blame] | 678 | #ifdef CONFIG_IEEE80211BE |
| 679 | (iface_params.hwModeParams.enable80211BE && !is_60Ghz_used) ? 2 : 0, |
| 680 | #endif |
Purushottam Kushwaha | 90c710b | 2022-02-04 19:00:34 +0530 | [diff] [blame] | 681 | #ifdef CONFIG_IEEE80211AX |
| 682 | (iface_params.hwModeParams.enable80211AX && !is_60Ghz_used) ? 2 : 0, |
| 683 | #endif |
Kiran Kumar Lokere | b644512 | 2024-02-06 20:06:27 -0800 | [diff] [blame] | 684 | iface_params.hwModeParams.enable80211AC ? 2 : 0, |
| 685 | (band & band6Ghz) ? "op_class=134" : ""); |
Purushottam Kushwaha | 90c710b | 2022-02-04 19:00:34 +0530 | [diff] [blame] | 686 | break; |
| 687 | default: |
Sunil Ravi | ffa5cce | 2022-08-22 23:37:16 +0000 | [diff] [blame] | 688 | if (!is_2Ghz_band_only && !is_60Ghz_used) { |
| 689 | if (iface_params.hwModeParams.enable80211AC) { |
Xin Deng | fec682f | 2024-02-06 22:59:39 -0800 | [diff] [blame] | 690 | ht_cap_vht_oper_he_oper_eht_oper_chwidth_as_string = |
Sunil Ravi | 4fc918f | 2022-04-17 09:26:48 -0700 | [diff] [blame] | 691 | "ht_capab=[HT40+]\n" |
| 692 | "vht_oper_chwidth=1\n"; |
Sunil Ravi | ffa5cce | 2022-08-22 23:37:16 +0000 | [diff] [blame] | 693 | } |
Kiran Kumar Lokere | b644512 | 2024-02-06 20:06:27 -0800 | [diff] [blame] | 694 | if (band & band6Ghz) { |
Xin Deng | 3ee3fe1 | 2024-02-20 23:24:37 -0800 | [diff] [blame] | 695 | #ifdef CONFIG_IEEE80211BE |
| 696 | if (iface_params.hwModeParams.enable80211BE) |
| 697 | ht_cap_vht_oper_he_oper_eht_oper_chwidth_as_string += "op_class=137\n"; |
| 698 | else |
| 699 | ht_cap_vht_oper_he_oper_eht_oper_chwidth_as_string += "op_class=134\n"; |
| 700 | #else /* CONFIG_IEEE80211BE */ |
Xin Deng | fec682f | 2024-02-06 22:59:39 -0800 | [diff] [blame] | 701 | ht_cap_vht_oper_he_oper_eht_oper_chwidth_as_string += "op_class=134\n"; |
Xin Deng | 3ee3fe1 | 2024-02-20 23:24:37 -0800 | [diff] [blame] | 702 | #endif /* CONFIG_IEEE80211BE */ |
Kiran Kumar Lokere | b644512 | 2024-02-06 20:06:27 -0800 | [diff] [blame] | 703 | } |
Purushottam Kushwaha | 90c710b | 2022-02-04 19:00:34 +0530 | [diff] [blame] | 704 | #ifdef CONFIG_IEEE80211AX |
Sunil Ravi | ffa5cce | 2022-08-22 23:37:16 +0000 | [diff] [blame] | 705 | if (iface_params.hwModeParams.enable80211AX) { |
Xin Deng | fec682f | 2024-02-06 22:59:39 -0800 | [diff] [blame] | 706 | ht_cap_vht_oper_he_oper_eht_oper_chwidth_as_string += "he_oper_chwidth=1\n"; |
| 707 | } |
| 708 | #endif |
| 709 | #ifdef CONFIG_IEEE80211BE |
| 710 | if (iface_params.hwModeParams.enable80211BE) { |
| 711 | ht_cap_vht_oper_he_oper_eht_oper_chwidth_as_string += "eht_oper_chwidth=1"; |
Sunil Ravi | ffa5cce | 2022-08-22 23:37:16 +0000 | [diff] [blame] | 712 | } |
Purushottam Kushwaha | 90c710b | 2022-02-04 19:00:34 +0530 | [diff] [blame] | 713 | #endif |
Sunil Ravi | ffa5cce | 2022-08-22 23:37:16 +0000 | [diff] [blame] | 714 | } |
Purushottam Kushwaha | 90c710b | 2022-02-04 19:00:34 +0530 | [diff] [blame] | 715 | break; |
| 716 | } |
| 717 | |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 718 | #ifdef CONFIG_INTERWORKING |
| 719 | std::string access_network_params_as_string; |
| 720 | if (nw_params.isMetered) { |
| 721 | access_network_params_as_string = StringPrintf( |
| 722 | "interworking=1\n" |
| 723 | "access_network_type=2\n"); // CHARGEABLE_PUBLIC_NETWORK |
| 724 | } else { |
| 725 | access_network_params_as_string = StringPrintf( |
| 726 | "interworking=0\n"); |
| 727 | } |
| 728 | #endif /* CONFIG_INTERWORKING */ |
| 729 | |
| 730 | std::string bridge_as_string; |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 731 | if (!br_name.empty() && !iface_params.usesMlo) { |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 732 | bridge_as_string = StringPrintf("bridge=%s", br_name.c_str()); |
| 733 | } |
| 734 | |
Serik Beketayev | 8af7a72 | 2021-12-23 12:25:36 -0800 | [diff] [blame] | 735 | // vendor_elements string |
| 736 | std::string vendor_elements_as_string; |
| 737 | if (nw_params.vendorElements.size() > 0) { |
| 738 | std::stringstream ss; |
| 739 | ss << std::hex; |
| 740 | ss << std::setfill('0'); |
| 741 | for (uint8_t b : nw_params.vendorElements) { |
| 742 | ss << std::setw(2) << static_cast<unsigned int>(b); |
| 743 | } |
| 744 | vendor_elements_as_string = StringPrintf("vendor_elements=%s", ss.str().c_str()); |
| 745 | } |
| 746 | |
Purushottam Kushwaha | 0316c88 | 2021-12-20 15:07:44 +0530 | [diff] [blame] | 747 | std::string owe_transition_ifname_as_string; |
| 748 | if (!owe_transition_ifname.empty()) { |
| 749 | owe_transition_ifname_as_string = StringPrintf( |
| 750 | "owe_transition_ifname=%s", owe_transition_ifname.c_str()); |
| 751 | } |
| 752 | |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 753 | return StringPrintf( |
| 754 | "interface=%s\n" |
| 755 | "driver=nl80211\n" |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 756 | "ctrl_interface=/data/vendor/wifi/hostapd/ctrl_%s\n" |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 757 | // ssid2 signals to hostapd that the value is not a literal value |
| 758 | // for use as a SSID. In this case, we're giving it a hex |
| 759 | // std::string and hostapd needs to expect that. |
| 760 | "ssid2=%s\n" |
| 761 | "%s\n" |
| 762 | "ieee80211n=%d\n" |
| 763 | "ieee80211ac=%d\n" |
| 764 | "%s\n" |
| 765 | "%s\n" |
| 766 | "%s\n" |
Sunil Ravi | 6525173 | 2023-01-24 05:03:35 +0000 | [diff] [blame] | 767 | "%s\n" |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 768 | "ignore_broadcast_ssid=%d\n" |
| 769 | "wowlan_triggers=any\n" |
| 770 | #ifdef CONFIG_INTERWORKING |
| 771 | "%s\n" |
| 772 | #endif /* CONFIG_INTERWORKING */ |
| 773 | "%s\n" |
| 774 | "%s\n" |
| 775 | "%s\n" |
Serik Beketayev | 8af7a72 | 2021-12-23 12:25:36 -0800 | [diff] [blame] | 776 | "%s\n" |
Purushottam Kushwaha | 0316c88 | 2021-12-20 15:07:44 +0530 | [diff] [blame] | 777 | "%s\n" |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 778 | "%s\n", |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 779 | iface_params.usesMlo ? br_name.c_str() : iface_params.name.c_str(), |
| 780 | iface_params.name.c_str(), |
| 781 | ssid_as_string.c_str(), |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 782 | channel_config_as_string.c_str(), |
| 783 | iface_params.hwModeParams.enable80211N ? 1 : 0, |
| 784 | iface_params.hwModeParams.enable80211AC ? 1 : 0, |
| 785 | he_params_as_string.c_str(), |
Sunil Ravi | 6525173 | 2023-01-24 05:03:35 +0000 | [diff] [blame] | 786 | eht_params_as_string.c_str(), |
Xin Deng | fec682f | 2024-02-06 22:59:39 -0800 | [diff] [blame] | 787 | hw_mode_as_string.c_str(), ht_cap_vht_oper_he_oper_eht_oper_chwidth_as_string.c_str(), |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 788 | nw_params.isHidden ? 1 : 0, |
| 789 | #ifdef CONFIG_INTERWORKING |
| 790 | access_network_params_as_string.c_str(), |
| 791 | #endif /* CONFIG_INTERWORKING */ |
| 792 | encryption_config_as_string.c_str(), |
| 793 | bridge_as_string.c_str(), |
Purushottam Kushwaha | 0316c88 | 2021-12-20 15:07:44 +0530 | [diff] [blame] | 794 | owe_transition_ifname_as_string.c_str(), |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 795 | enable_edmg_as_string.c_str(), |
Serik Beketayev | 8af7a72 | 2021-12-23 12:25:36 -0800 | [diff] [blame] | 796 | edmg_channel_as_string.c_str(), |
| 797 | vendor_elements_as_string.c_str()); |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 798 | } |
| 799 | |
| 800 | Generation getGeneration(hostapd_hw_modes *current_mode) |
| 801 | { |
| 802 | wpa_printf(MSG_DEBUG, "getGeneration hwmode=%d, ht_enabled=%d," |
| 803 | " vht_enabled=%d, he_supported=%d", |
| 804 | current_mode->mode, current_mode->ht_capab != 0, |
| 805 | current_mode->vht_capab != 0, current_mode->he_capab->he_supported); |
| 806 | switch (current_mode->mode) { |
| 807 | case HOSTAPD_MODE_IEEE80211B: |
| 808 | return Generation::WIFI_STANDARD_LEGACY; |
| 809 | case HOSTAPD_MODE_IEEE80211G: |
| 810 | return current_mode->ht_capab == 0 ? |
| 811 | Generation::WIFI_STANDARD_LEGACY : Generation::WIFI_STANDARD_11N; |
| 812 | case HOSTAPD_MODE_IEEE80211A: |
| 813 | if (current_mode->he_capab->he_supported) { |
| 814 | return Generation::WIFI_STANDARD_11AX; |
| 815 | } |
| 816 | return current_mode->vht_capab == 0 ? |
| 817 | Generation::WIFI_STANDARD_11N : Generation::WIFI_STANDARD_11AC; |
| 818 | case HOSTAPD_MODE_IEEE80211AD: |
| 819 | return Generation::WIFI_STANDARD_11AD; |
| 820 | default: |
| 821 | return Generation::WIFI_STANDARD_UNKNOWN; |
| 822 | } |
| 823 | } |
| 824 | |
Ahmed ElArabawy | b411579 | 2022-02-08 09:33:01 -0800 | [diff] [blame] | 825 | ChannelBandwidth getChannelBandwidth(struct hostapd_config *iconf) |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 826 | { |
Ahmed ElArabawy | b411579 | 2022-02-08 09:33:01 -0800 | [diff] [blame] | 827 | wpa_printf(MSG_DEBUG, "getChannelBandwidth %d, isHT=%d, isHT40=%d", |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 828 | iconf->vht_oper_chwidth, iconf->ieee80211n, |
| 829 | iconf->secondary_channel); |
| 830 | switch (iconf->vht_oper_chwidth) { |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 831 | case CONF_OPER_CHWIDTH_80MHZ: |
Ahmed ElArabawy | b411579 | 2022-02-08 09:33:01 -0800 | [diff] [blame] | 832 | return ChannelBandwidth::BANDWIDTH_80; |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 833 | case CONF_OPER_CHWIDTH_80P80MHZ: |
Ahmed ElArabawy | b411579 | 2022-02-08 09:33:01 -0800 | [diff] [blame] | 834 | return ChannelBandwidth::BANDWIDTH_80P80; |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 835 | break; |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 836 | case CONF_OPER_CHWIDTH_160MHZ: |
Ahmed ElArabawy | b411579 | 2022-02-08 09:33:01 -0800 | [diff] [blame] | 837 | return ChannelBandwidth::BANDWIDTH_160; |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 838 | break; |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 839 | case CONF_OPER_CHWIDTH_USE_HT: |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 840 | if (iconf->ieee80211n) { |
| 841 | return iconf->secondary_channel != 0 ? |
Ahmed ElArabawy | b411579 | 2022-02-08 09:33:01 -0800 | [diff] [blame] | 842 | ChannelBandwidth::BANDWIDTH_40 : ChannelBandwidth::BANDWIDTH_20; |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 843 | } |
Ahmed ElArabawy | b411579 | 2022-02-08 09:33:01 -0800 | [diff] [blame] | 844 | return ChannelBandwidth::BANDWIDTH_20_NOHT; |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 845 | case CONF_OPER_CHWIDTH_2160MHZ: |
Ahmed ElArabawy | b411579 | 2022-02-08 09:33:01 -0800 | [diff] [blame] | 846 | return ChannelBandwidth::BANDWIDTH_2160; |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 847 | case CONF_OPER_CHWIDTH_4320MHZ: |
Ahmed ElArabawy | b411579 | 2022-02-08 09:33:01 -0800 | [diff] [blame] | 848 | return ChannelBandwidth::BANDWIDTH_4320; |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 849 | case CONF_OPER_CHWIDTH_6480MHZ: |
Ahmed ElArabawy | b411579 | 2022-02-08 09:33:01 -0800 | [diff] [blame] | 850 | return ChannelBandwidth::BANDWIDTH_6480; |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 851 | case CONF_OPER_CHWIDTH_8640MHZ: |
Ahmed ElArabawy | b411579 | 2022-02-08 09:33:01 -0800 | [diff] [blame] | 852 | return ChannelBandwidth::BANDWIDTH_8640; |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 853 | default: |
Ahmed ElArabawy | b411579 | 2022-02-08 09:33:01 -0800 | [diff] [blame] | 854 | return ChannelBandwidth::BANDWIDTH_INVALID; |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 855 | } |
| 856 | } |
| 857 | |
| 858 | bool forceStaDisconnection(struct hostapd_data* hapd, |
| 859 | const std::vector<uint8_t>& client_address, |
| 860 | const uint16_t reason_code) { |
| 861 | struct sta_info *sta; |
Sunil Ravi | 1a36089 | 2022-11-29 20:16:01 +0000 | [diff] [blame] | 862 | if (client_address.size() != ETH_ALEN) { |
| 863 | return false; |
| 864 | } |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 865 | for (sta = hapd->sta_list; sta; sta = sta->next) { |
| 866 | int res; |
| 867 | res = memcmp(sta->addr, client_address.data(), ETH_ALEN); |
| 868 | if (res == 0) { |
| 869 | wpa_printf(MSG_INFO, "Force client:" MACSTR " disconnect with reason: %d", |
| 870 | MAC2STR(client_address.data()), reason_code); |
| 871 | ap_sta_disconnect(hapd, sta, sta->addr, reason_code); |
| 872 | return true; |
| 873 | } |
| 874 | } |
| 875 | return false; |
| 876 | } |
| 877 | |
| 878 | // hostapd core functions accept "C" style function pointers, so use global |
| 879 | // functions to pass to the hostapd core function and store the corresponding |
| 880 | // std::function methods to be invoked. |
| 881 | // |
| 882 | // NOTE: Using the pattern from the vendor HAL (wifi_legacy_hal.cpp). |
| 883 | // |
| 884 | // Callback to be invoked once setup is complete |
| 885 | std::function<void(struct hostapd_data*)> on_setup_complete_internal_callback; |
| 886 | void onAsyncSetupCompleteCb(void* ctx) |
| 887 | { |
| 888 | struct hostapd_data* iface_hapd = (struct hostapd_data*)ctx; |
| 889 | if (on_setup_complete_internal_callback) { |
| 890 | on_setup_complete_internal_callback(iface_hapd); |
| 891 | // Invalidate this callback since we don't want this firing |
| 892 | // again in single AP mode. |
| 893 | if (strlen(iface_hapd->conf->bridge) > 0) { |
| 894 | on_setup_complete_internal_callback = nullptr; |
| 895 | } |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | // Callback to be invoked on hotspot client connection/disconnection |
| 900 | std::function<void(struct hostapd_data*, const u8 *mac_addr, int authorized, |
| 901 | const u8 *p2p_dev_addr)> on_sta_authorized_internal_callback; |
| 902 | void onAsyncStaAuthorizedCb(void* ctx, const u8 *mac_addr, int authorized, |
Sunil Ravi | d8128a2 | 2023-11-06 23:53:58 +0000 | [diff] [blame] | 903 | const u8 *p2p_dev_addr, const u8 *ip) |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 904 | { |
| 905 | struct hostapd_data* iface_hapd = (struct hostapd_data*)ctx; |
| 906 | if (on_sta_authorized_internal_callback) { |
| 907 | on_sta_authorized_internal_callback(iface_hapd, mac_addr, |
| 908 | authorized, p2p_dev_addr); |
| 909 | } |
| 910 | } |
| 911 | |
| 912 | std::function<void(struct hostapd_data*, int level, |
| 913 | enum wpa_msg_type type, const char *txt, |
| 914 | size_t len)> on_wpa_msg_internal_callback; |
| 915 | |
| 916 | void onAsyncWpaEventCb(void *ctx, int level, |
| 917 | enum wpa_msg_type type, const char *txt, |
| 918 | size_t len) |
| 919 | { |
| 920 | struct hostapd_data* iface_hapd = (struct hostapd_data*)ctx; |
| 921 | if (on_wpa_msg_internal_callback) { |
| 922 | on_wpa_msg_internal_callback(iface_hapd, level, |
| 923 | type, txt, len); |
| 924 | } |
| 925 | } |
| 926 | |
| 927 | inline ndk::ScopedAStatus createStatus(HostapdStatusCode status_code) { |
| 928 | return ndk::ScopedAStatus::fromServiceSpecificError( |
| 929 | static_cast<int32_t>(status_code)); |
| 930 | } |
| 931 | |
| 932 | inline ndk::ScopedAStatus createStatusWithMsg( |
| 933 | HostapdStatusCode status_code, std::string msg) |
| 934 | { |
| 935 | return ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage( |
| 936 | static_cast<int32_t>(status_code), msg.c_str()); |
| 937 | } |
| 938 | |
| 939 | // Method called by death_notifier_ on client death. |
| 940 | void onDeath(void* cookie) { |
| 941 | wpa_printf(MSG_ERROR, "Client died. Terminating..."); |
| 942 | eloop_terminate(); |
| 943 | } |
| 944 | |
| 945 | } // namespace |
| 946 | |
| 947 | namespace aidl { |
| 948 | namespace android { |
| 949 | namespace hardware { |
| 950 | namespace wifi { |
| 951 | namespace hostapd { |
| 952 | |
| 953 | Hostapd::Hostapd(struct hapd_interfaces* interfaces) |
| 954 | : interfaces_(interfaces) |
| 955 | { |
| 956 | death_notifier_ = AIBinder_DeathRecipient_new(onDeath); |
| 957 | } |
| 958 | |
| 959 | ::ndk::ScopedAStatus Hostapd::addAccessPoint( |
| 960 | const IfaceParams& iface_params, const NetworkParams& nw_params) |
| 961 | { |
| 962 | return addAccessPointInternal(iface_params, nw_params); |
| 963 | } |
| 964 | |
| 965 | ::ndk::ScopedAStatus Hostapd::removeAccessPoint(const std::string& iface_name) |
| 966 | { |
| 967 | return removeAccessPointInternal(iface_name); |
| 968 | } |
| 969 | |
| 970 | ::ndk::ScopedAStatus Hostapd::terminate() |
| 971 | { |
| 972 | wpa_printf(MSG_INFO, "Terminating..."); |
| 973 | // Clear the callback to avoid IPCThreadState shutdown during the |
| 974 | // callback event. |
| 975 | callbacks_.clear(); |
| 976 | eloop_terminate(); |
| 977 | return ndk::ScopedAStatus::ok(); |
| 978 | } |
| 979 | |
| 980 | ::ndk::ScopedAStatus Hostapd::registerCallback( |
| 981 | const std::shared_ptr<IHostapdCallback>& callback) |
| 982 | { |
| 983 | return registerCallbackInternal(callback); |
| 984 | } |
| 985 | |
| 986 | ::ndk::ScopedAStatus Hostapd::forceClientDisconnect( |
| 987 | const std::string& iface_name, const std::vector<uint8_t>& client_address, |
| 988 | Ieee80211ReasonCode reason_code) |
| 989 | { |
| 990 | return forceClientDisconnectInternal(iface_name, client_address, reason_code); |
| 991 | } |
| 992 | |
| 993 | ::ndk::ScopedAStatus Hostapd::setDebugParams(DebugLevel level) |
| 994 | { |
| 995 | return setDebugParamsInternal(level); |
| 996 | } |
| 997 | |
| 998 | ::ndk::ScopedAStatus Hostapd::addAccessPointInternal( |
| 999 | const IfaceParams& iface_params, |
| 1000 | const NetworkParams& nw_params) |
| 1001 | { |
| 1002 | int channelParamsSize = iface_params.channelParams.size(); |
| 1003 | if (channelParamsSize == 1) { |
| 1004 | // Single AP |
| 1005 | wpa_printf(MSG_INFO, "AddSingleAccessPoint, iface=%s", |
| 1006 | iface_params.name.c_str()); |
| 1007 | return addSingleAccessPoint(iface_params, iface_params.channelParams[0], |
Purushottam Kushwaha | 0316c88 | 2021-12-20 15:07:44 +0530 | [diff] [blame] | 1008 | nw_params, "", ""); |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1009 | } else if (channelParamsSize == 2) { |
| 1010 | // Concurrent APs |
| 1011 | wpa_printf(MSG_INFO, "AddDualAccessPoint, iface=%s", |
| 1012 | iface_params.name.c_str()); |
| 1013 | return addConcurrentAccessPoints(iface_params, nw_params); |
| 1014 | } |
| 1015 | return createStatus(HostapdStatusCode::FAILURE_ARGS_INVALID); |
| 1016 | } |
| 1017 | |
Purushottam Kushwaha | 0316c88 | 2021-12-20 15:07:44 +0530 | [diff] [blame] | 1018 | std::vector<uint8_t> generateRandomOweSsid() |
| 1019 | { |
| 1020 | u8 random[8] = {0}; |
| 1021 | os_get_random(random, 8); |
| 1022 | |
| 1023 | std::string ssid = StringPrintf("Owe-%s", random); |
| 1024 | wpa_printf(MSG_INFO, "Generated OWE SSID: %s", ssid.c_str()); |
| 1025 | std::vector<uint8_t> vssid(ssid.begin(), ssid.end()); |
| 1026 | |
| 1027 | return vssid; |
| 1028 | } |
| 1029 | |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1030 | |
| 1031 | // Both of bridged dual APs and MLO AP will be treated as concurrenct APs. |
| 1032 | // ----------------------------------------- |
| 1033 | // | br_name | instance#1 | instance#2 | |
| 1034 | // ___________________________________________________________ |
| 1035 | // bridged dual APs | ap_br_wlanX | wlan X | wlanY | |
| 1036 | // ___________________________________________________________ |
| 1037 | // MLO AP | wlanX | 0 | 1 | |
| 1038 | // ___________________________________________________________ |
| 1039 | // Both will be added in br_interfaces_[$br_name] and use instance's name |
| 1040 | // to be iface_params_new.name to create single Access point. |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1041 | ::ndk::ScopedAStatus Hostapd::addConcurrentAccessPoints( |
| 1042 | const IfaceParams& iface_params, const NetworkParams& nw_params) |
| 1043 | { |
| 1044 | int channelParamsListSize = iface_params.channelParams.size(); |
| 1045 | // Get available interfaces in bridge |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1046 | std::vector<std::string> managed_instances; |
| 1047 | std::string br_name = StringPrintf("%s", iface_params.name.c_str()); |
| 1048 | if (iface_params.usesMlo) { |
| 1049 | // MLO AP is using link id as instance. |
| 1050 | for (std::size_t i = 0; i < iface_params.instanceIdentities->size(); i++) { |
| 1051 | managed_instances.push_back(iface_params.instanceIdentities->at(i)->c_str()); |
| 1052 | } |
| 1053 | } else { |
| 1054 | if (!GetInterfacesInBridge(br_name, &managed_instances)) { |
| 1055 | return createStatusWithMsg(HostapdStatusCode::FAILURE_UNKNOWN, |
| 1056 | "Get interfaces in bridge failed."); |
| 1057 | } |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1058 | } |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1059 | // Either bridged AP or MLO AP should have two instances. |
| 1060 | if (managed_instances.size() < channelParamsListSize) { |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1061 | return createStatusWithMsg(HostapdStatusCode::FAILURE_UNKNOWN, |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1062 | "Available interfaces less than requested bands"); |
| 1063 | } |
| 1064 | |
| 1065 | if (iface_params.usesMlo |
| 1066 | && nw_params.encryptionType == EncryptionType::WPA3_OWE_TRANSITION) { |
| 1067 | return createStatusWithMsg(HostapdStatusCode::FAILURE_UNKNOWN, |
| 1068 | "Invalid encryptionType (OWE transition) for MLO SAP."); |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1069 | } |
| 1070 | // start BSS on specified bands |
| 1071 | for (std::size_t i = 0; i < channelParamsListSize; i ++) { |
| 1072 | IfaceParams iface_params_new = iface_params; |
Purushottam Kushwaha | 0316c88 | 2021-12-20 15:07:44 +0530 | [diff] [blame] | 1073 | NetworkParams nw_params_new = nw_params; |
Purushottam Kushwaha | 0316c88 | 2021-12-20 15:07:44 +0530 | [diff] [blame] | 1074 | std::string owe_transition_ifname = ""; |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1075 | iface_params_new.name = managed_instances[i]; |
Ahmed ElArabawy | 1aaf180 | 2022-02-04 15:58:55 -0800 | [diff] [blame] | 1076 | if (nw_params.encryptionType == EncryptionType::WPA3_OWE_TRANSITION) { |
Purushottam Kushwaha | 0316c88 | 2021-12-20 15:07:44 +0530 | [diff] [blame] | 1077 | if (i == 0 && i+1 < channelParamsListSize) { |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1078 | owe_transition_ifname = managed_instances[i+1]; |
Purushottam Kushwaha | 0316c88 | 2021-12-20 15:07:44 +0530 | [diff] [blame] | 1079 | nw_params_new.encryptionType = EncryptionType::NONE; |
| 1080 | } else { |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1081 | owe_transition_ifname = managed_instances[0]; |
Purushottam Kushwaha | 0316c88 | 2021-12-20 15:07:44 +0530 | [diff] [blame] | 1082 | nw_params_new.isHidden = true; |
| 1083 | nw_params_new.ssid = generateRandomOweSsid(); |
| 1084 | } |
| 1085 | } |
| 1086 | |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1087 | ndk::ScopedAStatus status = addSingleAccessPoint( |
Purushottam Kushwaha | 0316c88 | 2021-12-20 15:07:44 +0530 | [diff] [blame] | 1088 | iface_params_new, iface_params.channelParams[i], nw_params_new, |
| 1089 | br_name, owe_transition_ifname); |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1090 | if (!status.isOk()) { |
| 1091 | wpa_printf(MSG_ERROR, "Failed to addAccessPoint %s", |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1092 | managed_instances[i].c_str()); |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1093 | return status; |
| 1094 | } |
| 1095 | } |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1096 | |
| 1097 | if (iface_params.usesMlo) { |
| 1098 | std::size_t i = 0; |
| 1099 | std::size_t j = 0; |
| 1100 | for (i = 0; i < interfaces_->count; i++) { |
| 1101 | struct hostapd_iface *iface = interfaces_->iface[i]; |
| 1102 | |
| 1103 | for (j = 0; j < iface->num_bss; j++) { |
| 1104 | struct hostapd_data *iface_hapd = iface->bss[j]; |
| 1105 | if (hostapd_enable_iface(iface_hapd->iface) < 0) { |
| 1106 | wpa_printf( |
| 1107 | MSG_ERROR, "Enabling interface %s failed on %zu", |
| 1108 | iface_params.name.c_str(), i); |
| 1109 | return createStatus(HostapdStatusCode::FAILURE_UNKNOWN); |
| 1110 | } |
| 1111 | } |
| 1112 | } |
| 1113 | } |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1114 | // Save bridge interface info |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1115 | br_interfaces_[br_name] = managed_instances; |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1116 | return ndk::ScopedAStatus::ok(); |
| 1117 | } |
| 1118 | |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1119 | struct hostapd_data * hostapd_get_iface_by_link_id(struct hapd_interfaces *interfaces, |
| 1120 | const size_t link_id) |
| 1121 | { |
| 1122 | #ifdef CONFIG_IEEE80211BE |
| 1123 | size_t i, j; |
| 1124 | |
| 1125 | for (i = 0; i < interfaces->count; i++) { |
| 1126 | struct hostapd_iface *iface = interfaces->iface[i]; |
| 1127 | |
| 1128 | for (j = 0; j < iface->num_bss; j++) { |
| 1129 | struct hostapd_data *hapd = iface->bss[j]; |
| 1130 | |
| 1131 | if (link_id == hapd->mld_link_id) |
| 1132 | return hapd; |
| 1133 | } |
| 1134 | } |
| 1135 | #endif |
| 1136 | return NULL; |
| 1137 | } |
| 1138 | |
| 1139 | // Both of bridged dual APs and MLO AP will be treated as concurrenct APs. |
| 1140 | // ----------------------------------------- |
| 1141 | // | br_name | iface_params.name |
| 1142 | // _______________________________________________________________ |
| 1143 | // bridged dual APs | bridged interface name | interface name |
| 1144 | // _______________________________________________________________ |
| 1145 | // MLO AP | AP interface name | mld link id as instance name |
| 1146 | // _______________________________________________________________ |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1147 | ::ndk::ScopedAStatus Hostapd::addSingleAccessPoint( |
| 1148 | const IfaceParams& iface_params, |
| 1149 | const ChannelParams& channelParams, |
| 1150 | const NetworkParams& nw_params, |
Purushottam Kushwaha | 0316c88 | 2021-12-20 15:07:44 +0530 | [diff] [blame] | 1151 | const std::string br_name, |
| 1152 | const std::string owe_transition_ifname) |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1153 | { |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1154 | if (iface_params.usesMlo) { // the mlo case, iface name is instance name which is mld_link_id |
| 1155 | if (hostapd_get_iface_by_link_id(interfaces_, (size_t) iface_params.name.c_str())) { |
| 1156 | wpa_printf( |
| 1157 | MSG_ERROR, "Instance link id %s already present", |
| 1158 | iface_params.name.c_str()); |
| 1159 | return createStatus(HostapdStatusCode::FAILURE_IFACE_EXISTS); |
| 1160 | } |
| 1161 | } |
| 1162 | if (hostapd_get_iface(interfaces_, |
| 1163 | iface_params.usesMlo ? br_name.c_str() : iface_params.name.c_str())) { |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1164 | wpa_printf( |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1165 | MSG_ERROR, "Instance interface %s already present", |
| 1166 | iface_params.usesMlo ? br_name.c_str() : iface_params.name.c_str()); |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1167 | return createStatus(HostapdStatusCode::FAILURE_IFACE_EXISTS); |
| 1168 | } |
Purushottam Kushwaha | 0316c88 | 2021-12-20 15:07:44 +0530 | [diff] [blame] | 1169 | const auto conf_params = CreateHostapdConfig(iface_params, channelParams, nw_params, |
| 1170 | br_name, owe_transition_ifname); |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1171 | if (conf_params.empty()) { |
| 1172 | wpa_printf(MSG_ERROR, "Failed to create config params"); |
| 1173 | return createStatus(HostapdStatusCode::FAILURE_ARGS_INVALID); |
| 1174 | } |
| 1175 | const auto conf_file_path = |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1176 | WriteHostapdConfig(iface_params.name, conf_params, br_name, iface_params.usesMlo); |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1177 | if (conf_file_path.empty()) { |
| 1178 | wpa_printf(MSG_ERROR, "Failed to write config file"); |
| 1179 | return createStatus(HostapdStatusCode::FAILURE_UNKNOWN); |
| 1180 | } |
| 1181 | std::string add_iface_param_str = StringPrintf( |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1182 | "%s config=%s", iface_params.usesMlo ? br_name.c_str(): iface_params.name.c_str(), |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1183 | conf_file_path.c_str()); |
| 1184 | std::vector<char> add_iface_param_vec( |
| 1185 | add_iface_param_str.begin(), add_iface_param_str.end() + 1); |
| 1186 | if (hostapd_add_iface(interfaces_, add_iface_param_vec.data()) < 0) { |
| 1187 | wpa_printf( |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1188 | MSG_ERROR, "Adding hostapd iface %s failed", |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1189 | add_iface_param_str.c_str()); |
| 1190 | return createStatus(HostapdStatusCode::FAILURE_UNKNOWN); |
| 1191 | } |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1192 | |
| 1193 | // find the iface and set up callback. |
| 1194 | struct hostapd_data* iface_hapd = iface_params.usesMlo ? |
| 1195 | hostapd_get_iface_by_link_id(interfaces_, (size_t) iface_params.name.c_str()) : |
| 1196 | hostapd_get_iface(interfaces_, iface_params.name.c_str()); |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1197 | WPA_ASSERT(iface_hapd != nullptr && iface_hapd->iface != nullptr); |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1198 | if (iface_params.usesMlo) { |
| 1199 | memcmp(iface_hapd->conf->iface, br_name.c_str(), br_name.size()); |
| 1200 | } |
| 1201 | |
| 1202 | // Callback discrepancy between bridged dual APs and MLO AP |
| 1203 | // Note: Only bridged dual APs will have "iface_hapd->conf->bridge" and |
| 1204 | // Only MLO AP will have "iface_hapd->mld_link_id" |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1205 | // Register the setup complete callbacks |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1206 | // ----------------------------------------- |
| 1207 | // | bridged dual APs | bridged single link MLO | MLO SAP |
| 1208 | // _________________________________________________________________________________________ |
| 1209 | // hapd->conf->bridge | bridged interface name | bridged interface nam | N/A |
| 1210 | // _________________________________________________________________________________________ |
| 1211 | // hapd->conf->iface | AP interface name | AP interface name | AP interface name |
| 1212 | // _________________________________________________________________________________________ |
| 1213 | // hapd->mld_link_id | 0 (default value) | link id (0) | link id (0 or 1) |
| 1214 | // _________________________________________________________________________________________ |
| 1215 | // hapd->mld_ap | 0 | 1 | 1 |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1216 | on_setup_complete_internal_callback = |
| 1217 | [this](struct hostapd_data* iface_hapd) { |
| 1218 | wpa_printf( |
| 1219 | MSG_INFO, "AP interface setup completed - state %s", |
| 1220 | hostapd_state_text(iface_hapd->iface->state)); |
| 1221 | if (iface_hapd->iface->state == HAPD_IFACE_DISABLED) { |
| 1222 | // Invoke the failure callback on all registered |
| 1223 | // clients. |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1224 | std::string instanceName = iface_hapd->conf->iface; |
| 1225 | #ifdef CONFIG_IEEE80211BE |
| 1226 | if (iface_hapd->conf->mld_ap |
| 1227 | && strlen(iface_hapd->conf->bridge) == 0) { |
| 1228 | instanceName = std::to_string(iface_hapd->mld_link_id); |
| 1229 | } |
| 1230 | #endif |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1231 | for (const auto& callback : callbacks_) { |
Chenming Huang | baa5e58 | 2024-04-02 08:21:10 +0530 | [diff] [blame] | 1232 | auto status = callback->onFailure( |
| 1233 | strlen(iface_hapd->conf->bridge) > 0 ? |
Les Lee | e08c286 | 2021-10-29 16:36:41 +0800 | [diff] [blame] | 1234 | iface_hapd->conf->bridge : iface_hapd->conf->iface, |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1235 | instanceName); |
Chenming Huang | baa5e58 | 2024-04-02 08:21:10 +0530 | [diff] [blame] | 1236 | if (!status.isOk()) { |
| 1237 | wpa_printf(MSG_ERROR, "Failed to invoke onFailure"); |
| 1238 | } |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1239 | } |
| 1240 | } |
| 1241 | }; |
| 1242 | |
| 1243 | // Register for new client connect/disconnect indication. |
| 1244 | on_sta_authorized_internal_callback = |
| 1245 | [this](struct hostapd_data* iface_hapd, const u8 *mac_addr, |
| 1246 | int authorized, const u8 *p2p_dev_addr) { |
| 1247 | wpa_printf(MSG_DEBUG, "notify client " MACSTR " %s", |
| 1248 | MAC2STR(mac_addr), |
| 1249 | (authorized) ? "Connected" : "Disconnected"); |
| 1250 | ClientInfo info; |
| 1251 | info.ifaceName = strlen(iface_hapd->conf->bridge) > 0 ? |
| 1252 | iface_hapd->conf->bridge : iface_hapd->conf->iface; |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1253 | std::string instanceName = iface_hapd->conf->iface; |
| 1254 | #ifdef CONFIG_IEEE80211BE |
| 1255 | if (iface_hapd->conf->mld_ap |
| 1256 | && strlen(iface_hapd->conf->bridge) == 0) { |
| 1257 | instanceName = std::to_string(iface_hapd->mld_link_id); |
| 1258 | } |
| 1259 | #endif |
| 1260 | info.apIfaceInstance = instanceName; |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1261 | info.clientAddress.assign(mac_addr, mac_addr + ETH_ALEN); |
| 1262 | info.isConnected = authorized; |
| 1263 | for (const auto &callback : callbacks_) { |
Chenming Huang | baa5e58 | 2024-04-02 08:21:10 +0530 | [diff] [blame] | 1264 | auto status = callback->onConnectedClientsChanged(info); |
| 1265 | if (!status.isOk()) { |
| 1266 | wpa_printf(MSG_ERROR, "Failed to invoke onConnectedClientsChanged"); |
| 1267 | } |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1268 | } |
| 1269 | }; |
| 1270 | |
| 1271 | // Register for wpa_event which used to get channel switch event |
| 1272 | on_wpa_msg_internal_callback = |
| 1273 | [this](struct hostapd_data* iface_hapd, int level, |
| 1274 | enum wpa_msg_type type, const char *txt, |
| 1275 | size_t len) { |
| 1276 | wpa_printf(MSG_DEBUG, "Receive wpa msg : %s", txt); |
| 1277 | if (os_strncmp(txt, AP_EVENT_ENABLED, |
| 1278 | strlen(AP_EVENT_ENABLED)) == 0 || |
| 1279 | os_strncmp(txt, WPA_EVENT_CHANNEL_SWITCH, |
| 1280 | strlen(WPA_EVENT_CHANNEL_SWITCH)) == 0) { |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1281 | std::string instanceName = iface_hapd->conf->iface; |
| 1282 | #ifdef CONFIG_IEEE80211BE |
| 1283 | if (iface_hapd->conf->mld_ap && strlen(iface_hapd->conf->bridge) == 0) { |
| 1284 | instanceName = std::to_string(iface_hapd->mld_link_id); |
| 1285 | } |
| 1286 | #endif |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1287 | ApInfo info; |
| 1288 | info.ifaceName = strlen(iface_hapd->conf->bridge) > 0 ? |
| 1289 | iface_hapd->conf->bridge : iface_hapd->conf->iface, |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1290 | info.apIfaceInstance = instanceName; |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1291 | info.freqMhz = iface_hapd->iface->freq; |
Ahmed ElArabawy | b411579 | 2022-02-08 09:33:01 -0800 | [diff] [blame] | 1292 | info.channelBandwidth = getChannelBandwidth(iface_hapd->iconf); |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1293 | info.generation = getGeneration(iface_hapd->iface->current_mode); |
| 1294 | info.apIfaceInstanceMacAddress.assign(iface_hapd->own_addr, |
| 1295 | iface_hapd->own_addr + ETH_ALEN); |
| 1296 | for (const auto &callback : callbacks_) { |
Chenming Huang | baa5e58 | 2024-04-02 08:21:10 +0530 | [diff] [blame] | 1297 | auto status = callback->onApInstanceInfoChanged(info); |
| 1298 | if (!status.isOk()) { |
| 1299 | wpa_printf(MSG_ERROR, |
| 1300 | "Failed to invoke onApInstanceInfoChanged"); |
| 1301 | } |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1302 | } |
Les Lee | a0c90cb | 2022-04-19 17:39:23 +0800 | [diff] [blame] | 1303 | } else if (os_strncmp(txt, AP_EVENT_DISABLED, strlen(AP_EVENT_DISABLED)) == 0 |
| 1304 | || os_strncmp(txt, INTERFACE_DISABLED, strlen(INTERFACE_DISABLED)) == 0) |
| 1305 | { |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1306 | std::string instanceName = iface_hapd->conf->iface; |
| 1307 | #ifdef CONFIG_IEEE80211BE |
| 1308 | if (iface_hapd->conf->mld_ap && strlen(iface_hapd->conf->bridge) == 0) { |
| 1309 | instanceName = std::to_string(iface_hapd->mld_link_id); |
| 1310 | } |
| 1311 | #endif |
Yu Ouyang | 378d3c4 | 2021-08-20 17:31:08 +0800 | [diff] [blame] | 1312 | // Invoke the failure callback on all registered clients. |
| 1313 | for (const auto& callback : callbacks_) { |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1314 | auto status = |
| 1315 | callback->onFailure(strlen(iface_hapd->conf->bridge) > 0 ? |
Les Lee | e08c286 | 2021-10-29 16:36:41 +0800 | [diff] [blame] | 1316 | iface_hapd->conf->bridge : iface_hapd->conf->iface, |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1317 | instanceName); |
Chenming Huang | baa5e58 | 2024-04-02 08:21:10 +0530 | [diff] [blame] | 1318 | if (!status.isOk()) { |
| 1319 | wpa_printf(MSG_ERROR, "Failed to invoke onFailure"); |
| 1320 | } |
Yu Ouyang | 378d3c4 | 2021-08-20 17:31:08 +0800 | [diff] [blame] | 1321 | } |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1322 | } |
Yu Ouyang | 378d3c4 | 2021-08-20 17:31:08 +0800 | [diff] [blame] | 1323 | }; |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1324 | |
| 1325 | // Setup callback |
| 1326 | iface_hapd->setup_complete_cb = onAsyncSetupCompleteCb; |
| 1327 | iface_hapd->setup_complete_cb_ctx = iface_hapd; |
| 1328 | iface_hapd->sta_authorized_cb = onAsyncStaAuthorizedCb; |
| 1329 | iface_hapd->sta_authorized_cb_ctx = iface_hapd; |
Hu Wang | 7c5a432 | 2021-06-24 17:24:59 +0800 | [diff] [blame] | 1330 | wpa_msg_register_aidl_cb(onAsyncWpaEventCb); |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1331 | |
Les Lee | 399c630 | 2024-09-12 03:03:38 +0000 | [diff] [blame^] | 1332 | // Multi-link MLO should enable iface after both links have been set. |
| 1333 | if (!iface_params.usesMlo && hostapd_enable_iface(iface_hapd->iface) < 0) { |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1334 | wpa_printf( |
| 1335 | MSG_ERROR, "Enabling interface %s failed", |
| 1336 | iface_params.name.c_str()); |
| 1337 | return createStatus(HostapdStatusCode::FAILURE_UNKNOWN); |
| 1338 | } |
| 1339 | return ndk::ScopedAStatus::ok(); |
| 1340 | } |
| 1341 | |
| 1342 | ::ndk::ScopedAStatus Hostapd::removeAccessPointInternal(const std::string& iface_name) |
| 1343 | { |
| 1344 | // interfaces to be removed |
| 1345 | std::vector<std::string> interfaces; |
| 1346 | bool is_error = false; |
| 1347 | |
| 1348 | const auto it = br_interfaces_.find(iface_name); |
| 1349 | if (it != br_interfaces_.end()) { |
| 1350 | // In case bridge, remove managed interfaces |
| 1351 | interfaces = it->second; |
| 1352 | br_interfaces_.erase(iface_name); |
| 1353 | } else { |
| 1354 | // else remove current interface |
| 1355 | interfaces.push_back(iface_name); |
| 1356 | } |
| 1357 | |
| 1358 | for (auto& iface : interfaces) { |
| 1359 | std::vector<char> remove_iface_param_vec( |
| 1360 | iface.begin(), iface.end() + 1); |
| 1361 | if (hostapd_remove_iface(interfaces_, remove_iface_param_vec.data()) < 0) { |
| 1362 | wpa_printf(MSG_INFO, "Remove interface %s failed", iface.c_str()); |
| 1363 | is_error = true; |
| 1364 | } |
| 1365 | } |
| 1366 | if (is_error) { |
| 1367 | return createStatus(HostapdStatusCode::FAILURE_UNKNOWN); |
| 1368 | } |
| 1369 | return ndk::ScopedAStatus::ok(); |
| 1370 | } |
| 1371 | |
| 1372 | ::ndk::ScopedAStatus Hostapd::registerCallbackInternal( |
| 1373 | const std::shared_ptr<IHostapdCallback>& callback) |
| 1374 | { |
| 1375 | binder_status_t status = AIBinder_linkToDeath(callback->asBinder().get(), |
| 1376 | death_notifier_, this /* cookie */); |
| 1377 | if (status != STATUS_OK) { |
| 1378 | wpa_printf( |
| 1379 | MSG_ERROR, |
| 1380 | "Error registering for death notification for " |
| 1381 | "hostapd callback object"); |
| 1382 | return createStatus(HostapdStatusCode::FAILURE_UNKNOWN); |
| 1383 | } |
| 1384 | callbacks_.push_back(callback); |
Manaswini Paluri | 76ae698 | 2024-02-29 14:49:20 +0530 | [diff] [blame] | 1385 | if (aidl_service_version == 0) { |
| 1386 | aidl_service_version = Hostapd::version; |
| 1387 | wpa_printf(MSG_INFO, "AIDL service version: %d", aidl_service_version); |
| 1388 | } |
| 1389 | if (aidl_client_version == 0) { |
| 1390 | callback->getInterfaceVersion(&aidl_client_version); |
| 1391 | wpa_printf(MSG_INFO, "AIDL client version: %d", aidl_client_version); |
| 1392 | } |
Gabriel Biren | 72cf9a5 | 2021-06-25 23:29:26 +0000 | [diff] [blame] | 1393 | return ndk::ScopedAStatus::ok(); |
| 1394 | } |
| 1395 | |
| 1396 | ::ndk::ScopedAStatus Hostapd::forceClientDisconnectInternal(const std::string& iface_name, |
| 1397 | const std::vector<uint8_t>& client_address, Ieee80211ReasonCode reason_code) |
| 1398 | { |
| 1399 | struct hostapd_data *hapd = hostapd_get_iface(interfaces_, iface_name.c_str()); |
| 1400 | bool result; |
| 1401 | if (!hapd) { |
| 1402 | for (auto const& iface : br_interfaces_) { |
| 1403 | if (iface.first == iface_name) { |
| 1404 | for (auto const& instance : iface.second) { |
| 1405 | hapd = hostapd_get_iface(interfaces_, instance.c_str()); |
| 1406 | if (hapd) { |
| 1407 | result = forceStaDisconnection(hapd, client_address, |
| 1408 | (uint16_t) reason_code); |
| 1409 | if (result) break; |
| 1410 | } |
| 1411 | } |
| 1412 | } |
| 1413 | } |
| 1414 | } else { |
| 1415 | result = forceStaDisconnection(hapd, client_address, (uint16_t) reason_code); |
| 1416 | } |
| 1417 | if (!hapd) { |
| 1418 | wpa_printf(MSG_ERROR, "Interface %s doesn't exist", iface_name.c_str()); |
| 1419 | return createStatus(HostapdStatusCode::FAILURE_IFACE_UNKNOWN); |
| 1420 | } |
| 1421 | if (result) { |
| 1422 | return ndk::ScopedAStatus::ok(); |
| 1423 | } |
| 1424 | return createStatus(HostapdStatusCode::FAILURE_CLIENT_UNKNOWN); |
| 1425 | } |
| 1426 | |
| 1427 | ::ndk::ScopedAStatus Hostapd::setDebugParamsInternal(DebugLevel level) |
| 1428 | { |
| 1429 | wpa_debug_level = static_cast<uint32_t>(level); |
| 1430 | return ndk::ScopedAStatus::ok(); |
| 1431 | } |
| 1432 | |
| 1433 | } // namespace hostapd |
| 1434 | } // namespace wifi |
| 1435 | } // namespace hardware |
| 1436 | } // namespace android |
Les Lee | e08c286 | 2021-10-29 16:36:41 +0800 | [diff] [blame] | 1437 | } // namespace aidl |