summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehyun Kim <jeik01.kim@samsung.com>2022-10-29 14:33:50 +0900
committerJaehyun Kim <jeik01.kim@samsung.com>2022-10-29 14:33:50 +0900
commitce694409b243886b6001c03bbfe7a82484280363 (patch)
tree500a959b74c48807a0d99c0b86cfbefbf0f46c27
parente1d8239d47f47fd98fa52bf59d823fbc44644e15 (diff)
downloadconnman-ce694409b243886b6001c03bbfe7a82484280363.tar.gz
connman-ce694409b243886b6001c03bbfe7a82484280363.tar.bz2
connman-ce694409b243886b6001c03bbfe7a82484280363.zip
Remove useless network path of the wifi interface when removing network
When removing a network, if the network path of the interface is not NULL and has the same information as the network to be removed, it need to be removed. Otherwise, when a connection to the same network is attempted later, the connection may not work normally. Change-Id: Ia1702c05bb19c581b31070fbc7741a846d87a6ee Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
-rwxr-xr-xgsupplicant/gsupplicant.h5
-rwxr-xr-xgsupplicant/supplicant.c43
-rwxr-xr-xplugins/wifi.c36
3 files changed, 84 insertions, 0 deletions
diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index 3b19519f..b1493187 100755
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -400,6 +400,11 @@ int g_supplicant_interface_disconnect(GSupplicantInterface *interface,
int g_supplicant_interface_set_bss_expiration_age(GSupplicantInterface *interface,
unsigned int bss_expiration_age);
+#if defined TIZEN_EXT
+void g_supplicant_interface_remove_network(GSupplicantInterface *interface,
+ GSupplicantSSID *ssid);
+#endif
+
int g_supplicant_interface_set_apscan(GSupplicantInterface *interface,
unsigned int ap_scan);
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 7f65e025..2538333e 100755
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -8189,6 +8189,49 @@ int g_supplicant_interface_disconnect(GSupplicantInterface *interface,
return ret;
}
+#if defined TIZEN_EXT
+void g_supplicant_interface_remove_network(GSupplicantInterface *interface,
+ GSupplicantSSID *ssid)
+{
+ struct interface_data *data;
+ int ret;
+
+ SUPPLICANT_DBG("");
+
+ if (!interface)
+ return;
+
+ if (interface->network_path == NULL)
+ return;
+
+ if (!interface->network_info.ssid)
+ return;
+
+ if (memcmp(interface->network_info.ssid, ssid->ssid, ssid->ssid_len))
+ return;
+
+ if (interface->network_info.security != ssid->security)
+ return;
+
+ data = dbus_malloc0(sizeof(*data));
+ if (!data)
+ return;
+
+ data->interface = interface;
+ data->path = g_strdup(interface->path);
+
+ ret = supplicant_dbus_method_call(interface->path,
+ SUPPLICANT_INTERFACE ".Interface", "RemoveNetwork",
+ network_remove_params, network_remove_result, data,
+ interface);
+
+ if (ret < 0) {
+ g_free(data->path);
+ dbus_free(data);
+ }
+}
+#endif
+
static void interface_p2p_find_result(const char *error,
DBusMessageIter *iter, void *user_data)
{
diff --git a/plugins/wifi.c b/plugins/wifi.c
index 20b1293e..46a886a9 100755
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -249,6 +249,8 @@ struct enc_method_call_data {
static struct enc_method_call_data encrypt_request_data;
+static GSupplicantSecurity network_security(const char *security);
+
static void encryption_request_reply(DBusPendingCall *call,
void *user_data)
{
@@ -3644,6 +3646,11 @@ static void network_remove(struct connman_network *network)
{
struct connman_device *device = connman_network_get_device(network);
struct wifi_data *wifi;
+#if defined TIZEN_EXT
+ GSupplicantSSID *ssid;
+ const void *ssid_data;
+ const char *security;
+#endif
DBG("network %p", network);
@@ -3664,6 +3671,35 @@ static void network_remove(struct connman_network *network)
if (wifi->scan_pending_network == network)
wifi->scan_pending_network = NULL;
+
+ /*
+ * If this remove network is for the same network
+ * for which wpa_supplicant already has a profile
+ * then need to remove that profile.
+ */
+ ssid = g_try_malloc0(sizeof(GSupplicantSSID));
+ if (!ssid)
+ return;
+
+ ssid_data = connman_network_get_blob(network, "WiFi.SSID",
+ &ssid->ssid_len);
+
+ ssid->ssid = g_try_malloc0(ssid->ssid_len);
+
+ if (!ssid->ssid) {
+ g_free(ssid);
+ return;
+ } else {
+ memcpy(ssid->ssid, ssid_data, ssid->ssid_len);
+ }
+
+ security = connman_network_get_string(network, "WiFi.Security");
+ ssid->security = network_security(security);
+
+ g_supplicant_interface_remove_network(wifi->interface, ssid);
+
+ g_free(ssid->ssid);
+ g_free(ssid);
#endif
}