diff options
author | Gabriel Biren <gbiren@google.com> | 2023-03-17 17:12:52 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-03-17 17:12:52 +0000 |
commit | 5ea7f79ae3147d3fcb5a1e24f92f42ce05164aff (patch) | |
tree | 9fc4cb0b378c2599c6f91546c9f6df03b13173eb | |
parent | 04a57ce08cc29bad73b602f35c286032c4f2bb42 (diff) | |
parent | 92af4bd7d58b093570e176080d3c7a25cc784477 (diff) | |
download | wpa_supplicant_8-5ea7f79ae3147d3fcb5a1e24f92f42ce05164aff.tar.gz |
Update fixed-size arrays in the supplicant service am: 92af4bd7d5
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/wpa_supplicant_8/+/22119073
Change-Id: Iaf1dfdcb00750369cf97457ac10befb45b9ae800
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | wpa_supplicant/aidl/aidl_manager.cpp | 20 | ||||
-rw-r--r-- | wpa_supplicant/aidl/sta_iface.cpp | 12 |
2 files changed, 21 insertions, 11 deletions
diff --git a/wpa_supplicant/aidl/aidl_manager.cpp b/wpa_supplicant/aidl/aidl_manager.cpp index e2523d45..5c363017 100644 --- a/wpa_supplicant/aidl/aidl_manager.cpp +++ b/wpa_supplicant/aidl/aidl_manager.cpp @@ -364,6 +364,12 @@ inline std::vector<uint8_t> macAddrToVec(const uint8_t* mac_addr) { return byteArrToVec(mac_addr, ETH_ALEN); } +inline std::array<uint8_t, ETH_ALEN> macAddrToArray(const uint8_t* mac_addr) { + std::array<uint8_t, ETH_ALEN> arr; + std::copy(mac_addr, mac_addr + ETH_ALEN, std::begin(arr)); + return arr; +} + // Raw pointer to the global structure maintained by the core. // Declared here to be accessible to onDeath() struct wpa_global *wpa_global_; @@ -669,14 +675,14 @@ int AidlManager::notifyStateChange(struct wpa_supplicant *wpa_s) wpa_printf(MSG_INFO, "assoc key_mgmt 0x%x network key_mgmt 0x%x", wpa_s->key_mgmt, wpa_s->current_ssid->key_mgmt); } - std::vector<uint8_t> aidl_bssid; + std::array<uint8_t, ETH_ALEN> aidl_bssid; // wpa_supplicant sets the |pending_bssid| field when it starts a // connection. Only after association state does it update the |bssid| // field. So, in the AIDL callback send the appropriate bssid. if (wpa_s->wpa_state <= WPA_ASSOCIATED) { - aidl_bssid = macAddrToVec(wpa_s->pending_bssid); + aidl_bssid = macAddrToArray(wpa_s->pending_bssid); } else { - aidl_bssid = macAddrToVec(wpa_s->bssid); + aidl_bssid = macAddrToArray(wpa_s->bssid); } aidl_state_change_data.bssid = aidl_bssid; @@ -1391,9 +1397,9 @@ void AidlManager::notifyP2pGroupStarted( params.psk = aidl_psk; params.passphrase = misc_utils::charBufToString(ssid->passphrase); params.isPersistent = aidl_is_persistent; - params.goDeviceAddress = macAddrToVec(wpa_group_s->go_dev_addr); - params.goInterfaceAddress = aidl_is_go ? macAddrToVec(wpa_group_s->own_addr) : - macAddrToVec(wpa_group_s->current_bss->bssid); + params.goDeviceAddress = macAddrToArray(wpa_group_s->go_dev_addr); + params.goInterfaceAddress = aidl_is_go ? macAddrToArray(wpa_group_s->own_addr) : + macAddrToArray(wpa_group_s->current_bss->bssid); if (NULL != ip && !aidl_is_go) { params.isP2pClientEapolIpAddressInfoPresent = true; os_memcpy(¶ms.p2pClientIpInfo.ipAddressClient, &ip[0], 4); @@ -1791,7 +1797,7 @@ void AidlManager::notifyPmkCacheAdded( std::string aidl_ifname = misc_utils::charBufToString(wpa_s->ifname); PmkSaCacheData aidl_pmksa_data = {}; - aidl_pmksa_data.bssid = macAddrToVec(pmksa_entry->aa); + aidl_pmksa_data.bssid = macAddrToArray(pmksa_entry->aa); // Serialize PmkCacheEntry into blob. std::stringstream ss( std::stringstream::in | std::stringstream::out | std::stringstream::binary); diff --git a/wpa_supplicant/aidl/sta_iface.cpp b/wpa_supplicant/aidl/sta_iface.cpp index 75385042..674b30c9 100644 --- a/wpa_supplicant/aidl/sta_iface.cpp +++ b/wpa_supplicant/aidl/sta_iface.cpp @@ -290,6 +290,12 @@ const std::string convertCurveTypeToName(DppCurve curve) WPA_ASSERT(false); } +inline std::array<uint8_t, ETH_ALEN> macAddrToArray(const uint8_t* mac_addr) { + std::array<uint8_t, ETH_ALEN> arr; + std::copy(mac_addr, mac_addr + ETH_ALEN, std::begin(arr)); + return arr; +} + } // namespace namespace aidl { @@ -2006,8 +2012,7 @@ std::pair<MloLinksInfo, ndk::ScopedAStatus> StaIface::getConnectionMloLinksInfoI MloLinksInfo linksInfo; MloLink link; - linksInfo.apMldMacAddress->assign( - wpa_s->ap_mld_addr, wpa_s->ap_mld_addr + ETH_ALEN); + linksInfo.apMldMacAddress = macAddrToArray(wpa_s->ap_mld_addr); if (!wpa_s->valid_links) return {linksInfo, ndk::ScopedAStatus::ok()}; @@ -2023,8 +2028,7 @@ std::pair<MloLinksInfo, ndk::ScopedAStatus> StaIface::getConnectionMloLinksInfoI link.linkId = i; link.staLinkMacAddress.assign( wpa_s->links[i].addr, wpa_s->links[i].addr + ETH_ALEN); - link.apLinkMacAddress->assign( - wpa_s->links[i].bssid, wpa_s->links[i].bssid + ETH_ALEN); + link.apLinkMacAddress = macAddrToArray(wpa_s->links[i].bssid); link.frequencyMHz = wpa_s->links[i].freq; // TODO (b/259710591): Once supplicant implements TID-to-link // mapping, copy it here. Mapping can be changed in two |