summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2009-07-11 00:32:00 +0200
committerMarcel Holtmann <marcel@holtmann.org>2009-07-11 12:44:41 -0700
commit25b307d79d15753950e1686044bce7dba0baa721 (patch)
tree40a787bec7a050d2c8c454f1abc8028869048b6c
parent1c15286b47171d00721f871111db770706b5cccb (diff)
downloadconnman-25b307d79d15753950e1686044bce7dba0baa721.tar.gz
connman-25b307d79d15753950e1686044bce7dba0baa721.tar.bz2
connman-25b307d79d15753950e1686044bce7dba0baa721.zip
Set hidden network group name at time of association
We want to keep hidden network's group as hidden_BSSID_mode_security in order to store them with this name and match them properly against our initial scan results. To achieve that we need to set a joined network group at associated time since we don't know its BSSID before that.
-rw-r--r--include/network.h1
-rw-r--r--plugins/supplicant.c63
-rw-r--r--src/device.c2
-rw-r--r--src/network.c2
-rw-r--r--src/service.c4
5 files changed, 67 insertions, 5 deletions
diff --git a/include/network.h b/include/network.h
index 8d9a2fdb..04981097 100644
--- a/include/network.h
+++ b/include/network.h
@@ -69,6 +69,7 @@ void connman_network_set_protocol(struct connman_network *network,
enum connman_network_protocol protocol);
void connman_network_set_group(struct connman_network *network,
const char *group);
+const char *connman_network_get_group(struct connman_network *network);
int connman_network_set_available(struct connman_network *network,
connman_bool_t available);
diff --git a/plugins/supplicant.c b/plugins/supplicant.c
index ea348eca..832509ae 100644
--- a/plugins/supplicant.c
+++ b/plugins/supplicant.c
@@ -1423,6 +1423,43 @@ static int task_connect(struct supplicant_task *task)
return 0;
}
+static char *get_bssid(struct connman_device *device)
+{
+ char *bssid;
+ unsigned char ioctl_bssid[ETH_ALEN];
+ int fd, ret;
+ struct iwreq wrq;
+
+ if (connman_device_get_type(device) != CONNMAN_DEVICE_TYPE_WIFI)
+ return NULL;
+
+ fd = socket(PF_INET, SOCK_DGRAM, 0);
+ if (fd < 0)
+ return NULL;
+
+ memset(&wrq, 0, sizeof(wrq));
+ strncpy(wrq.ifr_name, connman_device_get_interface(device), IFNAMSIZ);
+
+ ret = ioctl(fd, SIOCGIWAP, &wrq);
+ close(fd);
+ if (ret != 0)
+ return NULL;
+
+ memcpy(ioctl_bssid, wrq.u.ap_addr.sa_data, ETH_ALEN);
+
+ bssid = g_try_malloc0(13);
+ if (bssid == NULL)
+ return NULL;
+
+ snprintf(bssid, 13, "%02x%02x%02x%02x%02x%02x",
+ ioctl_bssid[0], ioctl_bssid[1],
+ ioctl_bssid[2], ioctl_bssid[3],
+ ioctl_bssid[4], ioctl_bssid[5]);
+
+ return bssid;
+}
+
+
static void state_change(struct supplicant_task *task, DBusMessage *msg)
{
DBusError error;
@@ -1479,6 +1516,32 @@ static void state_change(struct supplicant_task *task, DBusMessage *msg)
switch (task->state) {
case WPA_COMPLETED:
/* carrier on */
+ if (connman_network_get_group(task->network) == NULL) {
+ const char *name, *mode, *security;
+ char *group, *bssid;
+
+ /*
+ * This is a hidden network, we need to set its
+ * group based on the BSSID we just joined.
+ */
+ bssid = get_bssid(task->device);
+
+ name = connman_network_get_string(task->network,
+ "Name");
+ mode = connman_network_get_string(task->network,
+ "WiFi.Mode");
+ security = connman_network_get_string(task->network,
+ "WiFi.Security");
+
+ if (bssid && name && mode && security) {
+ group = build_group(bssid, name, NULL, 0,
+ mode, security);
+ connman_network_set_group(task->network, group);
+ }
+
+ g_free(bssid);
+ g_free(group);
+ }
connman_network_set_connected(task->network, TRUE);
connman_device_set_scanning(task->device, FALSE);
break;
diff --git a/src/device.c b/src/device.c
index 563bf2dc..4a4d2e8b 100644
--- a/src/device.c
+++ b/src/device.c
@@ -636,8 +636,6 @@ static DBusMessage *join_network(DBusConnection *conn,
group = build_group(ssid, ssid_size, mode, security);
- connman_network_set_group(network, group);
-
index = connman_device_get_index(device);
connman_network_set_index(network, index);
diff --git a/src/network.c b/src/network.c
index 45284fa9..c4dabcea 100644
--- a/src/network.c
+++ b/src/network.c
@@ -629,7 +629,7 @@ void connman_network_set_group(struct connman_network *network,
__connman_profile_add_network(network);
}
-const char *__connman_network_get_group(struct connman_network *network)
+const char *connman_network_get_group(struct connman_network *network)
{
return network->group;
}
diff --git a/src/service.c b/src/service.c
index da75ca7c..d44e91be 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1313,7 +1313,7 @@ struct connman_service *__connman_service_lookup_from_network(struct connman_net
if (ident == NULL)
return NULL;
- group = __connman_network_get_group(network);
+ group = connman_network_get_group(network);
if (group == NULL)
return NULL;
@@ -1459,7 +1459,7 @@ struct connman_service *__connman_service_create_from_network(struct connman_net
if (ident == NULL)
return NULL;
- group = __connman_network_get_group(network);
+ group = connman_network_get_group(network);
if (group == NULL)
return NULL;