From dea4825d7f5677ea92163f31a5fb38238a520772 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 31 Mar 2009 18:51:21 -0700 Subject: [PATCH] Set an unqiue group name based on SSID, mode and security details --- plugins/supplicant.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/plugins/supplicant.c b/plugins/supplicant.c index 4b587b8..2009f7a 100644 --- a/plugins/supplicant.c +++ b/plugins/supplicant.c @@ -783,6 +783,29 @@ static int initiate_scan(struct supplicant_task *task) return 0; } +static char *build_group(const unsigned char *ssid, unsigned int ssid_len, + const char *mode, const char *security) +{ + GString *str; + unsigned int i; + + if (ssid_len < 1) + return NULL; + + str = g_string_sized_new((ssid_len * 2) + 24); + if (str == NULL) + return NULL; + + g_string_append_printf(str, "wifi_"); + + for (i = 0; i < ssid_len; i++) + g_string_append_printf(str, "%02x", ssid[i]); + + g_string_append_printf(str, "_%s_%s", mode, security); + + return g_string_free(str, FALSE); +} + static void extract_addr(DBusMessageIter *value, struct supplicant_result *result) { @@ -919,8 +942,9 @@ static void properties_reply(DBusPendingCall *call, void *user_data) struct connman_network *network; DBusMessage *reply; DBusMessageIter array, dict; - const char *mode, *security; unsigned char strength; + const char *mode, *security; + char *group; DBG("task %p", task); @@ -1043,6 +1067,10 @@ static void properties_reply(DBusPendingCall *call, void *user_data) mode = (result.adhoc == TRUE) ? "adhoc" : "managed"; connman_network_set_string(network, "WiFi.Mode", mode); + group = build_group(result.ssid, result.ssid_len, mode, security); + connman_network_set_group(network, group); + g_free(group); + DBG("%s (%s %s) strength %d (%s)", result.name, mode, security, strength, (result.has_wps == TRUE) ? "WPS" : "no WPS"); -- 2.7.4