diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-08-16 16:44:43 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-08-16 16:44:43 +0000 |
commit | ea3293d7c0f1b578df5835c94f469d7b59bca2a4 (patch) | |
tree | d11e943b9c202541172c1f3aa67c457ac89a9f88 | |
parent | 92138f613e1ac19b6dbfb5dde8efa9c70f131f8c (diff) | |
parent | 0d29af0577e86424b4a6b4ea56e180680e46554e (diff) | |
download | wpa_supplicant_8-aml_tz4_332714070.tar.gz |
Snap for 8953554 from 0d29af0577e86424b4a6b4ea56e180680e46554e to mainline-tzdata4-releaseaml_tz4_332714070aml_tz4_332714050aml_tz4_332714010aml_tz4_331910000aml_tz4_331314030aml_tz4_331314020aml_tz4_331314010aml_tz4_331012050aml_tz4_331012040aml_tz4_331012000android13-mainline-tzdata4-releaseaml_tz4_332714010
Change-Id: I96c71f3d6ed4e7aa5d17f11f39b842d073bcea3b
-rw-r--r-- | src/eap_peer/eap_aka.c | 12 | ||||
-rw-r--r-- | src/eap_peer/eap_sim.c | 12 | ||||
-rw-r--r-- | wpa_supplicant/aidl/aidl.cpp | 8 | ||||
-rw-r--r-- | wpa_supplicant/aidl/aidl.h | 4 | ||||
-rw-r--r-- | wpa_supplicant/aidl/aidl_manager.cpp | 11 | ||||
-rw-r--r-- | wpa_supplicant/aidl/aidl_manager.h | 2 | ||||
-rw-r--r-- | wpa_supplicant/aidl/sta_network.cpp | 39 | ||||
-rw-r--r-- | wpa_supplicant/aidl/sta_network.h | 4 | ||||
-rw-r--r-- | wpa_supplicant/events.c | 4 | ||||
-rw-r--r-- | wpa_supplicant/notify.c | 10 | ||||
-rw-r--r-- | wpa_supplicant/notify.h | 1 | ||||
-rw-r--r-- | wpa_supplicant/scan.c | 21 |
12 files changed, 90 insertions, 38 deletions
diff --git a/src/eap_peer/eap_aka.c b/src/eap_peer/eap_aka.c index 8c475f13..ee7010d4 100644 --- a/src/eap_peer/eap_aka.c +++ b/src/eap_peer/eap_aka.c @@ -385,6 +385,7 @@ static int eap_aka_learn_ids(struct eap_sm *sm, struct eap_aka_data *data, size_t identity_len = 0; const u8 *realm = NULL; size_t realm_len = 0; + struct eap_peer_config *config = eap_get_config(sm); wpa_hexdump_ascii(MSG_DEBUG, "EAP-AKA: (encr) AT_NEXT_PSEUDONYM", @@ -400,6 +401,17 @@ static int eap_aka_learn_ids(struct eap_sm *sm, struct eap_aka_data *data, break; } } + // If no realm from the permanent identity, look for the + // realm of the anonymous identity. + if (realm_len == 0 && config && config->anonymous_identity + && config->anonymous_identity_len > 0) { + for (realm = config->anonymous_identity, + realm_len = config->anonymous_identity_len; + realm_len > 0; realm_len--, realm++) { + if (*realm == '@') + break; + } + } data->pseudonym = os_malloc(attr->next_pseudonym_len + realm_len); if (data->pseudonym == NULL) { diff --git a/src/eap_peer/eap_sim.c b/src/eap_peer/eap_sim.c index 09866277..de423e8b 100644 --- a/src/eap_peer/eap_sim.c +++ b/src/eap_peer/eap_sim.c @@ -407,6 +407,7 @@ static int eap_sim_learn_ids(struct eap_sm *sm, struct eap_sim_data *data, size_t identity_len = 0; const u8 *realm = NULL; size_t realm_len = 0; + struct eap_peer_config *config = eap_get_config(sm); wpa_hexdump_ascii(MSG_DEBUG, "EAP-SIM: (encr) AT_NEXT_PSEUDONYM", @@ -422,6 +423,17 @@ static int eap_sim_learn_ids(struct eap_sm *sm, struct eap_sim_data *data, break; } } + // If no realm from the permanent identity, look for the + // realm of the anonymous identity. + if (realm_len == 0 && config && config->anonymous_identity + && config->anonymous_identity_len > 0) { + for (realm = config->anonymous_identity, + realm_len = config->anonymous_identity_len; + realm_len > 0; realm_len--, realm++) { + if (*realm == '@') + break; + } + } data->pseudonym = os_malloc(attr->next_pseudonym_len + realm_len); if (data->pseudonym == NULL) { diff --git a/wpa_supplicant/aidl/aidl.cpp b/wpa_supplicant/aidl/aidl.cpp index 1add3df4..a7945cc6 100644 --- a/wpa_supplicant/aidl/aidl.cpp +++ b/wpa_supplicant/aidl/aidl.cpp @@ -923,7 +923,7 @@ void wpas_aidl_notify_network_not_found(struct wpa_supplicant *wpa_s) aidl_manager->notifyNetworkNotFound(wpa_s); } -void wpas_aidl_notify_bss_freq_changed(struct wpa_supplicant *wpa_s) +void wpas_aidl_notify_frequency_changed(struct wpa_supplicant *wpa_s, int frequency) { if (!wpa_s) return; @@ -932,10 +932,10 @@ void wpas_aidl_notify_bss_freq_changed(struct wpa_supplicant *wpa_s) if (!aidl_manager) return; - wpa_printf(MSG_DEBUG, "Notify %s frequency changed to %d", - wpa_s->ifname, wpa_s->assoc_freq); + wpa_printf(MSG_INFO, "Notify %s frequency changed to %d", + wpa_s->ifname, frequency); - aidl_manager->notifyBssFreqChanged(wpa_s); + aidl_manager->notifyFrequencyChanged(wpa_s, frequency); } void wpas_aidl_notify_ceritification(struct wpa_supplicant *wpa_s, diff --git a/wpa_supplicant/aidl/aidl.h b/wpa_supplicant/aidl/aidl.h index d9ab7bd2..2f3c7a05 100644 --- a/wpa_supplicant/aidl/aidl.h +++ b/wpa_supplicant/aidl/aidl.h @@ -126,7 +126,7 @@ extern "C" void wpas_aidl_notify_transition_disable( struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid, u8 bitmap); void wpas_aidl_notify_network_not_found(struct wpa_supplicant *wpa_s); - void wpas_aidl_notify_bss_freq_changed(struct wpa_supplicant *wpa_s); + void wpas_aidl_notify_frequency_changed(struct wpa_supplicant *wpa_s, int frequency); void wpas_aidl_notify_ceritification(struct wpa_supplicant *wpa_s, int depth, const char *subject, const char *altsubject[], @@ -293,7 +293,7 @@ static void wpas_aidl_notify_transition_disable(struct wpa_supplicant *wpa_s, {} static void wpas_aidl_notify_network_not_found(struct wpa_supplicant *wpa_s) {} -void wpas_aidl_notify_bss_freq_changed(struct wpa_supplicant *wpa_s) +void wpas_aidl_notify_frequency_changed(struct wpa_supplicant *wpa_s, int frequency) {} void wpas_aidl_notify_ceritification(struct wpa_supplicant *wpa_s, int depth, const char *subject, diff --git a/wpa_supplicant/aidl/aidl_manager.cpp b/wpa_supplicant/aidl/aidl_manager.cpp index ac7b8e84..da90c389 100644 --- a/wpa_supplicant/aidl/aidl_manager.cpp +++ b/wpa_supplicant/aidl/aidl_manager.cpp @@ -1905,7 +1905,7 @@ void AidlManager::notifyNetworkNotFound(struct wpa_supplicant *wpa_s) callWithEachStaIfaceCallback(misc_utils::charBufToString(wpa_s->ifname), func); } -void AidlManager::notifyBssFreqChanged(struct wpa_supplicant *wpa_group_s) +void AidlManager::notifyFrequencyChanged(struct wpa_supplicant *wpa_group_s, int frequency) { if (!wpa_group_s || !wpa_group_s->parent) return; @@ -1913,18 +1913,15 @@ void AidlManager::notifyBssFreqChanged(struct wpa_supplicant *wpa_group_s) // For group notifications, need to use the parent iface for callbacks. struct wpa_supplicant *wpa_s = getTargetP2pIfaceForGroup(wpa_group_s); if (!wpa_s) { - wpa_printf(MSG_INFO, "Drop BSS frequency changed event"); + wpa_printf(MSG_INFO, "Drop frequency changed event"); return; } - uint32_t aidl_freq = wpa_group_s->current_bss - ? wpa_group_s->current_bss->freq - : wpa_group_s->assoc_freq; - const std::function< ndk::ScopedAStatus(std::shared_ptr<ISupplicantP2pIfaceCallback>)> func = std::bind(&ISupplicantP2pIfaceCallback::onGroupFrequencyChanged, - std::placeholders::_1, misc_utils::charBufToString(wpa_group_s->ifname), aidl_freq); + std::placeholders::_1, misc_utils::charBufToString(wpa_group_s->ifname), + frequency); callWithEachP2pIfaceCallback(misc_utils::charBufToString(wpa_s->ifname), func); } diff --git a/wpa_supplicant/aidl/aidl_manager.h b/wpa_supplicant/aidl/aidl_manager.h index 6acacf56..1ed6899c 100644 --- a/wpa_supplicant/aidl/aidl_manager.h +++ b/wpa_supplicant/aidl/aidl_manager.h @@ -143,7 +143,7 @@ public: struct wpa_ssid *ssid, u8 bitmap); void notifyNetworkNotFound(struct wpa_supplicant *wpa_s); - void notifyBssFreqChanged(struct wpa_supplicant *wpa_s); + void notifyFrequencyChanged(struct wpa_supplicant *wpa_s, int frequency); void notifyCertification(struct wpa_supplicant *wpa_s, int depth, const char *subject, const char *altsubject[], diff --git a/wpa_supplicant/aidl/sta_network.cpp b/wpa_supplicant/aidl/sta_network.cpp index 88e7b74c..fe4a7604 100644 --- a/wpa_supplicant/aidl/sta_network.cpp +++ b/wpa_supplicant/aidl/sta_network.cpp @@ -1242,11 +1242,24 @@ ndk::ScopedAStatus StaNetwork::setEapAnonymousIdentityInternal( const std::vector<uint8_t> &identity) { struct wpa_ssid *wpa_ssid = retrieveNetworkPtr(); - if (setByteArrayFieldAndResetState( + // If current supplicant pseudonym is the prefix of new pseudonym, + // the credential is not changed, just update the decoration. + // As a result, no need to reset the state. + // The decorated identity will have a postfix like + // @mncXXX.mccYYY.3gppnetwork.org, so the length will be always + // greater than the current one. + bool resetState = wpa_ssid->eap.anonymous_identity == NULL + || wpa_ssid->eap.anonymous_identity_len == 0 + || identity.size() == 0 + || wpa_ssid->eap.anonymous_identity_len >= identity.size() + || os_strncmp((char *) identity.data(), + (char *) wpa_ssid->eap.anonymous_identity, + wpa_ssid->eap.anonymous_identity_len) != 0; + if (setByteArrayField( identity.data(), identity.size(), &(wpa_ssid->eap.anonymous_identity), &(wpa_ssid->eap.anonymous_identity_len), - "eap anonymous_identity")) { + "eap anonymous_identity", resetState)) { return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN); } return ndk::ScopedAStatus::ok(); @@ -2385,9 +2398,9 @@ int StaNetwork::setStringKeyFieldAndResetState( * field in |wpa_ssid| structure instance for this network. * This function frees any existing data in these fields. */ -int StaNetwork::setByteArrayFieldAndResetState( +int StaNetwork::setByteArrayField( const uint8_t *value, const size_t value_len, uint8_t **to_update_field, - size_t *to_update_field_len, const char *hexdump_prefix) + size_t *to_update_field_len, const char *hexdump_prefix, bool resetState) { if (*to_update_field) { os_free(*to_update_field); @@ -2402,11 +2415,27 @@ int StaNetwork::setByteArrayFieldAndResetState( wpa_hexdump_ascii( MSG_MSGDUMP, hexdump_prefix, *to_update_field, *to_update_field_len); - resetInternalStateAfterParamsUpdate(); + + if (resetState) { + resetInternalStateAfterParamsUpdate(); + } return 0; } /** + * Helper function to set value in a string field with a corresponding length + * field in |wpa_ssid| structure instance for this network. + * This function frees any existing data in these fields. + */ +int StaNetwork::setByteArrayFieldAndResetState( + const uint8_t *value, const size_t value_len, uint8_t **to_update_field, + size_t *to_update_field_len, const char *hexdump_prefix) +{ + return setByteArrayField(value, value_len, to_update_field, + to_update_field_len, hexdump_prefix, true); +} + +/** * Helper function to set value in a string key field with a corresponding * length field in |wpa_ssid| structue instance for this network. * This function frees any existing data in these fields. diff --git a/wpa_supplicant/aidl/sta_network.h b/wpa_supplicant/aidl/sta_network.h index 51056690..524f44a4 100644 --- a/wpa_supplicant/aidl/sta_network.h +++ b/wpa_supplicant/aidl/sta_network.h @@ -327,6 +327,10 @@ private: void setFastTransitionKeyMgmt(uint32_t &key_mgmt_mask); void resetFastTransitionKeyMgmt(uint32_t &key_mgmt_mask); ndk::ScopedAStatus setEapErpInternal(bool enable); + int setByteArrayField( + const uint8_t* value, const size_t value_len, + uint8_t** to_update_field, size_t* to_update_field_len, + const char* hexdump_prefix, bool resetState); // Reference to the global wpa_struct. This is assumed to be valid // for the lifetime of the process. diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index b724eec0..0003d1f5 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -5345,6 +5345,10 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, if (event == EVENT_CH_SWITCH_STARTED) break; + if (wpa_s->assoc_freq && data->ch_switch.freq && + (int) wpa_s->assoc_freq != data->ch_switch.freq) { + wpas_notify_frequency_changed(wpa_s, data->ch_switch.freq); + } wpa_s->assoc_freq = data->ch_switch.freq; wpa_s->current_ssid->frequency = data->ch_switch.freq; if (wpa_s->current_bss && diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c index 4c305186..c52e88fd 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -472,8 +472,6 @@ void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s, return; wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id); - - wpas_aidl_notify_bss_freq_changed(wpa_s); } @@ -1321,3 +1319,11 @@ void wpas_notify_qos_policy_request(struct wpa_supplicant *wpa_s, wpas_aidl_notify_qos_policy_request(wpa_s, policies, num_policies); } + +void wpas_notify_frequency_changed(struct wpa_supplicant *wpa_s, int frequency) +{ + if (!wpa_s) + return; + + wpas_aidl_notify_frequency_changed(wpa_s, frequency); +} diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h index f7000171..996be846 100644 --- a/wpa_supplicant/notify.h +++ b/wpa_supplicant/notify.h @@ -217,5 +217,6 @@ void wpas_notify_open_ssl_failure(struct wpa_supplicant *wpa_s, void wpas_notify_qos_policy_reset(struct wpa_supplicant *wpa_s); void wpas_notify_qos_policy_request(struct wpa_supplicant *wpa_s, struct dscp_policy_data *policies, int num_policies); +void wpas_notify_frequency_changed(struct wpa_supplicant *wpa_s, int frequency); #endif /* NOTIFY_H */ diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index dde2f444..2112ecd6 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -1380,26 +1380,13 @@ scan: is_6ghz_supported(wpa_s)) { int i; - /* Exclude 5 GHz channels from the full scan for P2P connection + /* Exclude 6 GHz channels from the full scan for P2P connection * since the 6 GHz band is disabled for P2P uses. */ wpa_printf(MSG_DEBUG, "P2P: 6 GHz disabled - update the scan frequency list"); - for (i = 0; i < wpa_s->hw.num_modes; i++) { - if (wpa_s->hw.modes[i].num_channels == 0) - continue; - if (wpa_s->hw.modes[i].mode == HOSTAPD_MODE_IEEE80211G) - wpa_add_scan_freqs_list( - wpa_s, HOSTAPD_MODE_IEEE80211G, - ¶ms, false); - if (wpa_s->hw.modes[i].mode == HOSTAPD_MODE_IEEE80211A) - wpa_add_scan_freqs_list( - wpa_s, HOSTAPD_MODE_IEEE80211A, - ¶ms, false); - if (wpa_s->hw.modes[i].mode == HOSTAPD_MODE_IEEE80211AD) - wpa_add_scan_freqs_list( - wpa_s, HOSTAPD_MODE_IEEE80211AD, - ¶ms, false); - } + wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211G, ¶ms, false); + wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A, ¶ms, false); + wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211AD, ¶ms, false); } #endif /* CONFIG_P2P */ |