From 5448fcd034e5f1b0dbc307c18217775fe4adc72d Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Wed, 24 Apr 2024 17:27:27 +0900 Subject: [PATCH] Remove WPA2 and WPA3 service together Change-Id: I8ca4010821194027d95d1b99a9f468b464381a32 Signed-off-by: Jaehyun Kim --- src/service.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/src/service.c b/src/service.c index dbd36f3..9f7c469 100755 --- a/src/service.c +++ b/src/service.c @@ -7344,13 +7344,90 @@ bool __connman_service_remove(struct connman_service *service) return true; } +#if defined TIZEN_EXT +static char *__connman_service_get_wpa_id_to_remove(struct connman_service *service) +{ + char *identifier; + char *ptr; + + if (service->type != CONNMAN_SERVICE_TYPE_WIFI) + return NULL; + + if (service->security != CONNMAN_SERVICE_SECURITY_SAE && + service->security != CONNMAN_SERVICE_SECURITY_PSK) + return NULL; + + identifier = g_strdup(service->identifier); + if (!identifier) + return NULL; + + if (service->security == CONNMAN_SERVICE_SECURITY_SAE) { + ptr = strstr(identifier, "_sae"); + if (!ptr) { + g_free(identifier); + return NULL; + } + + memcpy(ptr, "_psk", strlen("_psk")); + } else if (service->security == CONNMAN_SERVICE_SECURITY_PSK) { + ptr = strstr(identifier, "_psk"); + if (!ptr) { + g_free(identifier); + return NULL; + } + + memcpy(ptr, "_sae", strlen("_sae")); + } + + return identifier; +} + + +static void __connman_service_remove_wpa_service(struct connman_service *service) +{ + gchar *dir; + GList *list; + char *identifier = __connman_service_get_wpa_id_to_remove(service); + + if (!identifier) + return; + + dir = g_strdup_printf("%s/%s", STORAGEDIR, identifier); + if (!dir) + goto done; + + if (g_file_test(dir, G_FILE_TEST_EXISTS) != TRUE) + goto done; + + for (list = service_list; list; list = list->next) { + struct connman_service *dst_service = list->data; + + if (dst_service->type != CONNMAN_SERVICE_TYPE_WIFI) + continue; + + if (g_strcmp0(dst_service->identifier, identifier) == 0) { + __connman_service_remove(dst_service); + goto done; + } + } + + __connman_storage_remove_service(identifier); + +done: + g_free(identifier); + g_free(dir); +} +#endif + static DBusMessage *remove_service(DBusConnection *conn, DBusMessage *msg, void *user_data) { struct connman_service *service = user_data; DBG("service %p", service); - +#if defined TIZEN_EXT + __connman_service_remove_wpa_service(service); +#endif if (!__connman_service_remove(service)) return __connman_error_not_supported(msg); -- 2.7.4