diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-07-12 00:21:38 -0700 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-07-12 00:21:38 -0700 |
commit | 7d71de5a36bda0b7583f7e513b481ba1906c008d (patch) | |
tree | 6660377e6e99d3394d1f1bd3d4c2951ed979c73e /plugins | |
parent | 381c6f2ce0894c5ac2779c04323be2017f2f1dd3 (diff) | |
download | connman-7d71de5a36bda0b7583f7e513b481ba1906c008d.tar.gz connman-7d71de5a36bda0b7583f7e513b481ba1906c008d.tar.bz2 connman-7d71de5a36bda0b7583f7e513b481ba1906c008d.zip |
Use interface index to resolve interface name
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/supplicant.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/plugins/supplicant.c b/plugins/supplicant.c index 8f185e09..92668f81 100644 --- a/plugins/supplicant.c +++ b/plugins/supplicant.c @@ -254,22 +254,34 @@ static char *get_bssid(struct connman_device *device) { char *bssid; unsigned char ioctl_bssid[ETH_ALEN]; - int fd, ret; + int ifindex; + char *ifname; struct iwreq wrq; + int fd, err; + + ifindex = connman_device_get_index(device); + if (ifindex < 0) + return NULL; - if (connman_device_get_type(device) != CONNMAN_DEVICE_TYPE_WIFI) + ifname = connman_inet_ifname(ifindex); + if (ifname == NULL) return NULL; fd = socket(PF_INET, SOCK_DGRAM, 0); - if (fd < 0) + if (fd < 0) { + g_free(ifname); return NULL; + } memset(&wrq, 0, sizeof(wrq)); - strncpy(wrq.ifr_name, connman_device_get_interface(device), IFNAMSIZ); + strncpy(wrq.ifr_name, ifname, IFNAMSIZ); + + err = ioctl(fd, SIOCGIWAP, &wrq); - ret = ioctl(fd, SIOCGIWAP, &wrq); + g_free(ifname); close(fd); - if (ret != 0) + + if (err < 0) return NULL; memcpy(ioctl_bssid, wrq.u.ap_addr.sa_data, ETH_ALEN); |