aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy Chen <jimmycmchen@google.com>2022-07-11 23:49:12 +0800
committerJimmy Chen <jimmycmchen@google.com>2022-08-04 05:20:01 +0000
commit0a229ee013fbf04b1d40bc8df0ffd265a8a8fe8b (patch)
treeed6edbf7d089ed125db1d2f1fdafcf722a86b36a
parent6f3aa559f8dd7d90eb80201dd35f0664aa6ceedd (diff)
downloadwpa_supplicant_8-0a229ee013fbf04b1d40bc8df0ffd265a8a8fe8b.tar.gz
P2P: support p2p configuration for the dedicated P2P interface
The dedicated P2P interface might be created along with STA interface via nl80211 interface added event. To ensure overlay configuration is loaded, re-initialize p2p device interface on calling addP2pInterface from wifi service. Bug: 238505271 Bug: 238601241 Test: check p2p_supplicant.conf is overlayed. Merged-In: I789e9edbbeeab492f74a8df05978318ed2faec53 Change-Id: I789e9edbbeeab492f74a8df05978318ed2faec53
-rw-r--r--wpa_supplicant/aidl/supplicant.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/wpa_supplicant/aidl/supplicant.cpp b/wpa_supplicant/aidl/supplicant.cpp
index ee6f8097..799790b2 100644
--- a/wpa_supplicant/aidl/supplicant.cpp
+++ b/wpa_supplicant/aidl/supplicant.cpp
@@ -303,12 +303,38 @@ ndk::ScopedAStatus Supplicant::addP2pDevInterface(struct wpa_interface iface_par
wpa_printf(MSG_DEBUG, "%s,NULL wpa_s for wlan0", __FUNCTION__);
return createStatus(SupplicantStatusCode::FAILURE_IFACE_UNKNOWN);
}
- if (wpas_p2p_add_p2pdev_interface(
- wpa_s, wpa_s->global->params.conf_p2p_dev) < 0) {
+
+ const u8 *if_addr = NULL;
+ char force_name[100] = {'\0'};
+ wpa_s->pending_interface_type = WPA_IF_P2P_DEVICE;
+ if (wpa_s->conf->p2p_device_random_mac_addr == 2 &&
+ !is_zero_ether_addr(wpa_s->conf->p2p_device_persistent_mac_addr))
+ if_addr = wpa_s->conf->p2p_device_persistent_mac_addr;
+
+ int ret = wpa_drv_if_add(wpa_s, WPA_IF_P2P_DEVICE, iface_params.ifname, if_addr, NULL,
+ force_name, wpa_s->pending_interface_addr, NULL);
+ if (ret < 0) {
+ wpa_printf(MSG_DEBUG, "P2P: Failed to create P2P Device interface");
+ return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN);
+ }
+
+ os_strlcpy(wpa_s->pending_interface_name, iface_params.ifname,
+ sizeof(wpa_s->pending_interface_name));
+ iface_params.p2p_mgmt = 1;
+ iface_params.driver_param = wpa_s->conf->driver_param;
+ iface_params.ctrl_interface = NULL;
+
+ struct wpa_supplicant *p2pdev_wpa_s = wpa_supplicant_add_iface(
+ wpa_s->global, &iface_params, wpa_s);
+
+ if (!p2pdev_wpa_s) {
wpa_printf(MSG_INFO,
"Failed to enable P2P Device");
return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN);
}
+ p2pdev_wpa_s->p2pdev = p2pdev_wpa_s;
+ wpa_s->pending_interface_name[0] = '\0';
+
return ndk::ScopedAStatus::ok();
}
@@ -321,6 +347,13 @@ Supplicant::addP2pInterfaceInternal(const std::string& name)
if (name.empty()) {
return {nullptr, createStatus(SupplicantStatusCode::FAILURE_ARGS_INVALID)};
}
+ if (strncmp(name.c_str(), P2P_MGMT_DEVICE_PREFIX, strlen(P2P_MGMT_DEVICE_PREFIX)) == 0) {
+ struct wpa_supplicant* wpa_s = wpa_supplicant_get_iface(wpa_global_, name.c_str());
+ if (wpa_s) {
+ wpa_printf(MSG_DEBUG, "Remove existing p2p dev interface");
+ wpa_supplicant_remove_iface(wpa_global_, wpa_s, 0);
+ }
+ }
// Try to get the wpa_supplicant record for this iface, return
// the iface object with the appropriate status code if it exists.
ndk::ScopedAStatus status;