From 432b300341618d46a27c4b035d84f081435ffdeb Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Thu, 29 Apr 2021 15:31:45 +0530 Subject: [PATCH] Send Mac policy parameters in CreateInterface dbus call. This patch will send mac policy parameters in CreateInteraface dbus call and will make 3 dbus calls to set mac policy parameters when interface is already created in wpa_supplicant. Change-Id: Icd7ce43d1b67fe5211ab15d2ab20fd47038907f1 Signed-off-by: Nishant Chaprana --- gsupplicant/gsupplicant.h | 5 +++++ gsupplicant/supplicant.c | 12 +++++++++++- packaging/connman.spec | 2 +- plugins/ethernet.c | 2 +- plugins/wifi.c | 28 +++++++++++----------------- src/device.c | 7 +++++++ 6 files changed, 36 insertions(+), 20 deletions(-) diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h index 991554b..05af5de 100755 --- a/gsupplicant/gsupplicant.h +++ b/gsupplicant/gsupplicant.h @@ -312,6 +312,11 @@ void g_supplicant_interface_cancel(GSupplicantInterface *interface); int g_supplicant_interface_create(const char *ifname, const char *driver, const char *bridge, +#ifdef TIZEN_EXT + unsigned int mac_policy, + unsigned int preassoc_mac_policy, + unsigned int random_mac_lifetime, +#endif /* TIZEN_EXT */ GSupplicantInterfaceCallback callback, void *user_data); int g_supplicant_interface_remove(GSupplicantInterface *interface, diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c index bb1bfa7..0f01e95 100755 --- a/gsupplicant/supplicant.c +++ b/gsupplicant/supplicant.c @@ -5692,7 +5692,7 @@ static void interface_create_params(DBusMessageIter *iter, void *user_data) } #ifdef TIZEN_EXT - if (!g_strcmp0(data->driver, "wifi")) { + if (data->driver && g_strstr_len(data->driver, strlen(data->driver), "nl80211")) { supplicant_dbus_dict_append_basic(&dict, "MacAddr", DBUS_TYPE_UINT32, &data->mac_addr); @@ -5967,6 +5967,11 @@ int g_supplicant_interface_mesh_peer_change_status( int g_supplicant_interface_create(const char *ifname, const char *driver, const char *bridge, +#ifdef TIZEN_EXT + unsigned int mac_policy, + unsigned int preassoc_mac_policy, + unsigned int random_mac_lifetime, +#endif /* TIZEN_EXT */ GSupplicantInterfaceCallback callback, void *user_data) { @@ -5989,6 +5994,11 @@ int g_supplicant_interface_create(const char *ifname, const char *driver, data->driver = g_strdup(driver); data->bridge = g_strdup(bridge); data->callback = callback; +#ifdef TIZEN_EXT + data->mac_addr = mac_policy; + data->preassoc_mac_addr = preassoc_mac_policy; + data->random_mac_lifetime = random_mac_lifetime; +#endif /* TIZEN_EXT */ data->user_data = user_data; ret = supplicant_dbus_method_call(SUPPLICANT_PATH, diff --git a/packaging/connman.spec b/packaging/connman.spec index ac63c63..72c277a 100644 --- a/packaging/connman.spec +++ b/packaging/connman.spec @@ -6,7 +6,7 @@ Name: connman Version: 1.38 -Release: 6 +Release: 7 License: GPL-2.0+ Summary: Connection Manager Url: http://connman.net diff --git a/plugins/ethernet.c b/plugins/ethernet.c index 3bf80a5..4dda80c 100644 --- a/plugins/ethernet.c +++ b/plugins/ethernet.c @@ -247,7 +247,7 @@ static int eapol_interface_create(void) * already created interface will not start EAP handshake. */ return g_supplicant_interface_create(ifname, driver, NULL, - interface_create_callback, ethernet); + 0, 0, 60, interface_create_callback, ethernet); } static void enable_eapol_reply(DBusPendingCall *call, void *user_data) diff --git a/plugins/wifi.c b/plugins/wifi.c index 5b4a0aa..6a886d5 100755 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -175,6 +175,9 @@ struct wifi_data { bool allow_full_scan; unsigned int automaxspeed_timeout; GSupplicantScanParams *hidden_scan_params; + unsigned int mac_policy; + unsigned int preassoc_mac_policy; + unsigned int mac_lifetime; #endif int disconnect_code; int assoc_code; @@ -2435,12 +2438,6 @@ static void setup_autoscan(struct wifi_data *wifi) #endif } -#ifdef TIZEN_EXT -int wifi_set_mac_policy(struct connman_device *device, unsigned int policy); -int wifi_set_preassoc_mac_policy(struct connman_device *device, unsigned int policy); -int wifi_set_random_mac_lifetime(struct connman_device *device, unsigned int lifetime); -#endif /* TIZEN_EXT */ - static void finalize_interface_creation(struct wifi_data *wifi) { DBG("interface is ready wifi %p tethering %d", wifi, wifi->tethering); @@ -2452,17 +2449,6 @@ static void finalize_interface_creation(struct wifi_data *wifi) connman_device_set_powered(wifi->device, true); -#ifdef TIZEN_EXT - wifi_set_mac_policy(wifi->device, - connman_device_get_mac_policy(wifi->device)); - - wifi_set_preassoc_mac_policy(wifi->device, - connman_device_get_preassoc_mac_policy(wifi->device)); - - wifi_set_random_mac_lifetime(wifi->device, - connman_device_get_random_mac_lifetime(wifi->device)); -#endif /* TIZEN_EXT */ - if (wifi->p2p_device) return; @@ -2513,6 +2499,11 @@ static int wifi_enable(struct connman_device *device) interface = connman_inet_ifname(index); ret = g_supplicant_interface_create(interface, driver, NULL, +#ifdef TIZEN_EXT + connman_device_get_mac_policy(device), + connman_device_get_preassoc_mac_policy(device), + connman_device_get_random_mac_lifetime(device), +#endif /* TIZEN_EXT */ interface_create_callback, wifi); g_free(interface); @@ -5963,6 +5954,9 @@ static void sta_remove_callback(int result, info->wifi->interface = NULL; g_supplicant_interface_create(info->ifname, driver, info->wifi->bridge, +#ifdef TIZEN_EXT + 0, 0, 60, +#endif /* TIZEN_EXT */ ap_create_callback, info); } diff --git a/src/device.c b/src/device.c index 53aa111..89258ba 100755 --- a/src/device.c +++ b/src/device.c @@ -266,6 +266,13 @@ int __connman_device_enable(struct connman_device *device) if (err == -EALREADY) { /* If device is already powered, but connman is not updated */ connman_device_set_powered(device, true); +#ifdef TIZEN_EXT + if (device->type == CONNMAN_DEVICE_TYPE_WIFI) { + device->driver->set_mac_policy(device, device->mac_policy); + device->driver->set_preassoc_mac_policy(device, device->preassoc_mac_policy); + device->driver->set_random_mac_lifetime(device, device->random_mac_lifetime); + } +#endif /* TIZEN_EXT */ goto done; } /* -- 2.7.4