+static char *build_group(const char *addr,
+ const unsigned char *ssid, unsigned int ssid_len,
+ const char *mode, const char *security)
+{
+ GString *str;
+ unsigned int i;
+
+ if (ssid_len > 0 && ssid[0] != '\0') {
+ str = g_string_sized_new((ssid_len * 2) + 24);
+ if (str == NULL)
+ return NULL;
+
+ for (i = 0; i < ssid_len; i++)
+ g_string_append_printf(str, "%02x", ssid[i]);
+ } else {
+ if (addr == NULL)
+ return NULL;
+
+ str = g_string_sized_new(15 + 24);
+ if (str == NULL)
+ return NULL;
+
+ g_string_append_printf(str, "hidden_%s", addr);
+ }
+
+ 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)
+{
+ DBusMessageIter array;
+ struct ether_addr *eth;
+ unsigned char *addr;
+ int addr_len;
+
+ dbus_message_iter_recurse(value, &array);
+ dbus_message_iter_get_fixed_array(&array, &addr, &addr_len);
+
+ if (addr_len != 6)
+ return;
+
+ eth = (void *) addr;
+
+ result->addr = g_try_malloc0(18);
+ if (result->addr == NULL)
+ return;
+
+ snprintf(result->addr, 18, "%02X:%02X:%02X:%02X:%02X:%02X",
+ eth->ether_addr_octet[0],
+ eth->ether_addr_octet[1],
+ eth->ether_addr_octet[2],
+ eth->ether_addr_octet[3],
+ eth->ether_addr_octet[4],
+ eth->ether_addr_octet[5]);
+
+ result->path = g_try_malloc0(18);
+ if (result->path == NULL)
+ return;
+
+ snprintf(result->path, 18, "%02x%02x%02x%02x%02x%02x",
+ eth->ether_addr_octet[0],
+ eth->ether_addr_octet[1],
+ eth->ether_addr_octet[2],
+ eth->ether_addr_octet[3],
+ eth->ether_addr_octet[4],
+ eth->ether_addr_octet[5]);
+}
+