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

Side by Side Diff: src/wifi.c

Issue 6659006: flimflam: add support for multiple profiles (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/flimflam.git@master
Patch Set: more ers comments 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/storage.c ('k') | test/create-profile » ('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> 26 #include <net/ethernet.h>
27 27
28 #include <glib.h> 28 #include <glib.h>
29 29
30 #include <connman/blob.h>
31
30 #include "connman.h" 32 #include "connman.h"
31 33
34 #define _DBG_WIFI(fmt, arg...) DBG(DBG_WIFI, fmt, ## arg)
35
32 static inline gboolean ispsk(const char *security) 36 static inline gboolean ispsk(const char *security)
33 { 37 {
34 return (g_strcmp0(security, "wpa") == 0 || 38 return (g_strcmp0(security, "wpa") == 0 ||
35 g_strcmp0(security, "rsn") == 0 || 39 g_strcmp0(security, "rsn") == 0 ||
36 g_strcmp0(security, "psk") == 0); 40 g_strcmp0(security, "psk") == 0);
37 } 41 }
38 42
39 /* 43 /*
40 * Construct a ``group name'' when creating a wifi service (see 44 * Construct a ``group name'' when creating a wifi service (see
41 * __connman_get_wifi_service_int). This string incorporates the 45 * __connman_get_wifi_service_int). This string incorporates the
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 g_string_append_printf(str, "%02x", ssid[i]); 150 g_string_append_printf(str, "%02x", ssid[i]);
147 } else 151 } else
148 g_string_append_printf(str, "hidden_%.*s", 2*ETH_ALEN, addr); 152 g_string_append_printf(str, "hidden_%.*s", 2*ETH_ALEN, addr);
149 done: 153 done:
150 /* NB: use "psk" for all wpa/rsn/psk services */ 154 /* NB: use "psk" for all wpa/rsn/psk services */
151 g_string_append_printf(str, "_%s_%s", mode, 155 g_string_append_printf(str, "_%s_%s", mode,
152 ispsk(security) ? "psk" : security); 156 ispsk(security) ? "psk" : security);
153 157
154 return g_string_free(str, FALSE); 158 return g_string_free(str, FALSE);
155 } 159 }
160
161 /*
162 * NB: this knows a bit too much about how services are written to the profile.
163 */
164 static void append_hidden_ssids(GKeyFile *keyfile, GSList **hidden_ssids)
165 {
166 gchar **keys;
167
168 keys = g_key_file_get_groups(keyfile, NULL);
169 if (keys == NULL) {
170 connman_warn("%s: unable to retrieve groups", __func__);
171 return;
172 }
173
174 for (; *keys != NULL; keys++) {
175 gchar *key = *keys;
176 gchar *hex_ssid;
177 struct blob *ssid;
178 int ret;
179
180 if (g_ascii_strncasecmp(key, "wifi_", 5) != 0)
181 continue;
182
183 if (!g_key_file_get_boolean(keyfile, key, "WiFi.HiddenSSID",
184 NULL))
185 continue;
186
187 hex_ssid = g_key_file_get_string(keyfile, key, "SSID", NULL);
188 if (hex_ssid == NULL)
189 continue;
190
191 _DBG_WIFI("service %s", key);
192
193 ret = blob_new_from_hex(&ssid, hex_ssid);
194 g_free(hex_ssid);
195 if (ret < 0) {
196 connman_warn("%s: skip hex ssid %s for key %s",
197 __func__, hex_ssid, key);
198 continue;
199 }
200
201 _DBG_WIFI("ssid %.*s", ssid->len, ssid->data);
202 *hidden_ssids = g_slist_prepend(*hidden_ssids, ssid);
203 }
204 }
205
206 /**
207 * connman_wifi_append_hidden_ssids:
208 * @ssids: pointer to a list of hidden SSIDs
209 *
210 * Append the list of SSIDs whose services whose WiFi.HiddenSSID property is
211 * TRUE. These SSIDs should be directly probed whenever performing a WiFi
212 * network scan.
213 */
214 void connman_wifi_append_hidden_ssids(GSList **ssids)
215 {
216 __connman_profile_append_hidden_ssids(ssids, append_hidden_ssids);
217 }
OLDNEW
« no previous file with comments | « src/storage.c ('k') | test/create-profile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698