diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-07-17 15:12:02 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-07-17 15:12:02 +0200 |
commit | 6f163a150d297569fa3300e546c7b1af50c4c7d8 (patch) | |
tree | 7a9a1c7707bfc5b244cdc48b2e337d59d1bde143 /plugins | |
parent | 8ebd478b503b5967a670cd127c0972615b977be9 (diff) | |
download | connman-6f163a150d297569fa3300e546c7b1af50c4c7d8.tar.gz connman-6f163a150d297569fa3300e546c7b1af50c4c7d8.tar.bz2 connman-6f163a150d297569fa3300e546c7b1af50c4c7d8.zip |
Update the network address when connected
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/supplicant.c | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/plugins/supplicant.c b/plugins/supplicant.c index ca478f7b..542b34b3 100644 --- a/plugins/supplicant.c +++ b/plugins/supplicant.c @@ -250,28 +250,26 @@ static int get_range(struct supplicant_task *task) return err; } -#if 0 -static char *get_bssid(struct connman_device *device) +static int get_bssid(struct connman_device *device, + unsigned char *bssid, unsigned int *bssid_len) { - char *bssid; - unsigned char ioctl_bssid[ETH_ALEN]; - int ifindex; - char *ifname; struct iwreq wrq; + char *ifname; + int ifindex; int fd, err; ifindex = connman_device_get_index(device); if (ifindex < 0) - return NULL; + return -EINVAL; ifname = connman_inet_ifname(ifindex); if (ifname == NULL) - return NULL; + return -EINVAL; fd = socket(PF_INET, SOCK_DGRAM, 0); if (fd < 0) { g_free(ifname); - return NULL; + return -EINVAL; } memset(&wrq, 0, sizeof(wrq)); @@ -283,22 +281,13 @@ static char *get_bssid(struct connman_device *device) close(fd); if (err < 0) - return NULL; - - memcpy(ioctl_bssid, wrq.u.ap_addr.sa_data, ETH_ALEN); - - bssid = g_try_malloc0(13); - if (bssid == NULL) - return NULL; + return -EIO; - 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]); + memcpy(bssid, wrq.u.ap_addr.sa_data, ETH_ALEN); + *bssid_len = ETH_ALEN; - return bssid; + return 0; } -#endif static void add_interface_reply(DBusPendingCall *call, void *user_data) { @@ -1510,6 +1499,8 @@ static void state_change(struct supplicant_task *task, DBusMessage *msg) { DBusError error; const char *newstate, *oldstate; + unsigned char bssid[ETH_ALEN]; + unsigned int bssid_len; enum supplicant_state state; dbus_error_init(&error); @@ -1561,6 +1552,10 @@ static void state_change(struct supplicant_task *task, DBusMessage *msg) switch (task->state) { case WPA_COMPLETED: + if (get_bssid(task->device, bssid, &bssid_len) == 0) + connman_network_set_address(task->network, + bssid, bssid_len); + /* carrier on */ connman_network_set_connected(task->network, TRUE); connman_device_set_scanning(task->device, FALSE); |