Chromium Code Reviews| Index: src/wifi.c | 
| diff --git a/src/wifi.c b/src/wifi.c | 
| index 72f250079ea0edfff9d76b049157a73d55d70349..42c3def446411e04bdf1a946ca363ccbb7b2175f 100644 | 
| --- a/src/wifi.c | 
| +++ b/src/wifi.c | 
| @@ -23,10 +23,19 @@ | 
| #include <config.h> | 
| #endif | 
| +#include <net/ethernet.h> | 
| + | 
| #include <glib.h> | 
| #include "connman.h" | 
| +static inline gboolean ispsk(const char *security) | 
| +{ | 
| + return (g_strcmp0(security, "wpa") == 0 || | 
| + g_strcmp0(security, "rsn") == 0 || | 
| + g_strcmp0(security, "psk") == 0); | 
| +} | 
| + | 
| char *connman_wifi_build_group_name(const unsigned char *ssid, | 
| unsigned int ssid_len, | 
| const char *mode, | 
| @@ -44,7 +53,75 @@ char *connman_wifi_build_group_name(const unsigned char *ssid, | 
| g_string_append_printf(str, "%02x", ssid[i]); | 
| } | 
| - g_string_append_printf(str, "_%s_%s", mode, security); | 
| + /* NB: use "psk" for all wpa/rsn/psk services */ | 
| + g_string_append_printf(str, "_%s_%s", mode, | 
| + ispsk(security) ? "psk" : security); | 
| + | 
| + return g_string_free(str, FALSE); | 
| +} | 
| + | 
| +static struct { | 
| + char *name; | 
| + char *value; | 
| +} special_ssid[] = { | 
| + { "<hidden>", "hidden" }, | 
| + { "default", "linksys" }, | 
| + { "wireless" }, | 
| + { "linksys" }, | 
| + { "netgear" }, | 
| + { "dlink" }, | 
| + { "2wire" }, | 
| + { "compaq" }, | 
| + { "tsunami" }, | 
| + { "comcomcom", "3com" }, | 
| + { "3Com", "3com" }, | 
| + { "Symbol", "symbol" }, | 
| + { "Motorola", "motorola" }, | 
| + { "Wireless" , "wireless" }, | 
| + { "WLAN", "wlan" }, | 
| + { } | 
| +}; | 
| + | 
| +char *connman_wifi_build_group(const char *addr, const char *name, | 
| 
 
Paul Stewart
2011/03/03 19:55:04
Could you comment these specifically so that peopl
 
 | 
| + const unsigned char *ssid, unsigned int ssid_len, | 
| + const char *mode, const char *security) | 
| +{ | 
| + GString *str; | 
| + unsigned int i; | 
| + | 
| + if (addr == NULL) | 
| + return NULL; | 
| + | 
| + str = g_string_sized_new((ssid_len * 2) + 24); | 
| + if (str == NULL) | 
| + return NULL; | 
| + | 
| + if (ssid == NULL) { | 
| + g_string_append_printf(str, "hidden_%s", addr); | 
| + goto done; | 
| + } | 
| + | 
| + for (i = 0; special_ssid[i].name; i++) { | 
| + if (g_strcmp0(special_ssid[i].name, name) == 0) { | 
| + if (special_ssid[i].value == NULL) | 
| + g_string_append_printf(str, "%s_%.*s", | 
| + name, 2*ETH_ALEN, addr); | 
| + else | 
| + g_string_append_printf(str, "%s_%.*s", | 
| + special_ssid[i].value, 2*ETH_ALEN, addr); | 
| + goto done; | 
| + } | 
| + } | 
| + | 
| + if (ssid_len > 0 && ssid[0] != '\0') { | 
| + for (i = 0; i < ssid_len; i++) | 
| + g_string_append_printf(str, "%02x", ssid[i]); | 
| + } else | 
| + g_string_append_printf(str, "hidden_%.*s", 2*ETH_ALEN, addr); | 
| +done: | 
| + /* NB: use "psk" for all wpa/rsn/psk services */ | 
| + g_string_append_printf(str, "_%s_%s", mode, | 
| + ispsk(security) ? "psk" : security); | 
| return g_string_free(str, FALSE); | 
| } |