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

Side by Side 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 comments; be more careful doing compat work Created 9 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/service.c ('k') | test/configure-wifi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * 2 *
3 * Connection Manager 3 * Connection Manager
4 * 4 *
5 * Copyright (C) 2007-2009 Intel Corporation. All rights reserved. 5 * Copyright (C) 2007-2009 Intel Corporation. All rights reserved.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 * 10 *
11 * This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License 16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * 19 *
20 */ 20 */
21 21
22 #ifdef HAVE_CONFIG_H 22 #ifdef HAVE_CONFIG_H
23 #include <config.h> 23 #include <config.h>
24 #endif 24 #endif
25 25
26 #include <net/ethernet.h>
27
26 #include <glib.h> 28 #include <glib.h>
27 29
28 #include "connman.h" 30 #include "connman.h"
29 31
32 static inline gboolean ispsk(const char *security)
33 {
34 return (g_strcmp0(security, "wpa") == 0 ||
35 g_strcmp0(security, "rsn") == 0 ||
36 g_strcmp0(security, "psk") == 0);
37 }
38
39 /*
40 * Construct a ``group name'' when creating a wifi service (see
41 * __connman_get_wifi_service_int). This string incorporates the
42 * SSID, security, and operating mode of all devices that should
43 * be grouped together. Note that we promote all PSK security
44 * settings to "psk" so services created before the device shows
45 * up in a scan result can be located when their associated
46 * network is created.
47 */
30 char *connman_wifi_build_group_name(const unsigned char *ssid, 48 char *connman_wifi_build_group_name(const unsigned char *ssid,
31 unsigned int ssid_len, 49 unsigned int ssid_len,
32 const char *mode, 50 const char *mode,
33 const char *security) 51 const char *security)
34 { 52 {
35 GString *str; 53 GString *str;
36 unsigned int i; 54 unsigned int i;
37 55
38 str = g_string_sized_new((ssid_len * 2) + 24); 56 str = g_string_sized_new((ssid_len * 2) + 24);
39 if (str == NULL) 57 if (str == NULL)
40 return NULL; 58 return NULL;
41 59
42 if (ssid_len > 0 && ssid[0] != '\0') { 60 if (ssid_len > 0 && ssid[0] != '\0') {
43 for (i = 0; i < ssid_len; i++) 61 for (i = 0; i < ssid_len; i++)
44 g_string_append_printf(str, "%02x", ssid[i]); 62 g_string_append_printf(str, "%02x", ssid[i]);
45 } 63 }
46 64
47 » g_string_append_printf(str, "_%s_%s", mode, security); 65 » /* NB: use "psk" for all wpa/rsn/psk services */
66 » g_string_append_printf(str, "_%s_%s", mode,
67 » ispsk(security) ? "psk" : security);
48 68
49 return g_string_free(str, FALSE); 69 return g_string_free(str, FALSE);
50 } 70 }
71
72 /*
73 * Table of well-known SSID's that we want to disambiguate when
74 * constructing service identifiers. Normally all devices with
75 * the same SSID, security setup, and operating mode will be
76 * merged to the same service. A service advertising one of
77 * these SSID's will have a unique group name constructed that
78 * ensures like-devices will not be grouped together.
79 *
80 * TODO(sleffler) externalize this table and make it's use optional
81 */
82 static struct {
83 char *name;
84 char *value;
85 } special_ssid[] = {
86 { "<hidden>", "hidden" },
87 { "default", "linksys" },
88 { "wireless" },
89 { "linksys" },
90 { "netgear" },
91 { "dlink" },
92 { "2wire" },
93 { "compaq" },
94 { "tsunami" },
95 { "comcomcom", "3com" },
96 { "3Com", "3com" },
97 { "Symbol", "symbol" },
98 { "Motorola", "motorola" },
99 { "Wireless" , "wireless" },
100 { "WLAN", "wlan" },
101 { }
102 };
103
104 /*
105 * Like connman_wifi_build_group_name but used in the wifi plugins
106 * when creating network objects from scan results. The group name
107 * must match the strings constructed above so the associated services
Paul Stewart 2011/03/03 23:08:06 Need to disambiguate "above" here.
108 * are matched up. This routine differs in that it does uniquification
109 * of devices that beacon well-known SSID's that we don't want to
110 * merge into a group.
111 */
112 char *connman_wifi_build_group(const char *addr, const char *name,
113 const unsigned char *ssid, unsigned int ssid_len,
114 const char *mode, const char *security)
115 {
116 GString *str;
117 unsigned int i;
118
119 if (addr == NULL)
120 return NULL;
121
122 str = g_string_sized_new((ssid_len * 2) + 24);
123 if (str == NULL)
124 return NULL;
125
126 if (ssid == NULL) {
127 g_string_append_printf(str, "hidden_%s", addr);
128 goto done;
129 }
130
131 for (i = 0; special_ssid[i].name; i++) {
132 if (g_strcmp0(special_ssid[i].name, name) == 0) {
133 if (special_ssid[i].value == NULL)
134 g_string_append_printf(str, "%s_%.*s",
135 name, 2*ETH_ALEN, addr);
136 else
137 g_string_append_printf(str, "%s_%.*s",
138 special_ssid[i].value, 2*ETH_ALEN, addr);
139 goto done;
140 }
141 }
142
143 if (ssid_len > 0 && ssid[0] != '\0') {
144 for (i = 0; i < ssid_len; i++)
145 g_string_append_printf(str, "%02x", ssid[i]);
146 } else
147 g_string_append_printf(str, "hidden_%.*s", 2*ETH_ALEN, addr);
148 done:
149 /* NB: use "psk" for all wpa/rsn/psk services */
150 g_string_append_printf(str, "_%s_%s", mode,
151 ispsk(security) ? "psk" : security);
152
153 return g_string_free(str, FALSE);
154 }
OLDNEW
« no previous file with comments | « src/service.c ('k') | test/configure-wifi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698