diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2009-07-11 00:32:00 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-07-11 12:44:41 -0700 |
commit | 25b307d79d15753950e1686044bce7dba0baa721 (patch) | |
tree | 40a787bec7a050d2c8c454f1abc8028869048b6c /plugins | |
parent | 1c15286b47171d00721f871111db770706b5cccb (diff) | |
download | connman-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.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/supplicant.c | 63 |
1 files changed, 63 insertions, 0 deletions
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; |