Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1795)

Unified Diff: src/wifi.c

Issue 6609007: flimflam: add "psk" security as a way to specify either "wpa" or "rsn" (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/flimflam.git@master
Patch Set: add backwards compat Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/service.c ('K') | « src/service.c ('k') | test/configure-wifi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« src/service.c ('K') | « src/service.c ('k') | test/configure-wifi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698