+static int get_range(struct supplicant_task *task)
+{
+ struct iwreq wrq;
+ int fd, err;
+
+ fd = socket(PF_INET, SOCK_DGRAM, 0);
+ if (fd < 0)
+ return -1;
+
+ memset(&wrq, 0, sizeof(struct iwreq));
+ strncpy(wrq.ifr_name, task->ifname, IFNAMSIZ);
+ wrq.u.data.pointer = task->range;
+ wrq.u.data.length = sizeof(struct iw_range);
+
+ err = ioctl(fd, SIOCGIWRANGE, &wrq);
+
+ close(fd);
+
+ return err;
+}
+
+static char *get_bssid(struct connman_device *device)
+{
+ char *bssid;
+ unsigned char ioctl_bssid[ETH_ALEN];
+ int ifindex;
+ char *ifname;
+ struct iwreq wrq;
+ int fd, err;
+
+ ifindex = connman_device_get_index(device);
+ if (ifindex < 0)
+ return NULL;
+
+ ifname = connman_inet_ifname(ifindex);
+ if (ifname == NULL)
+ return NULL;
+
+ fd = socket(PF_INET, SOCK_DGRAM, 0);
+ if (fd < 0) {
+ g_free(ifname);
+ return NULL;
+ }
+
+ memset(&wrq, 0, sizeof(wrq));
+ strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
+
+ err = ioctl(fd, SIOCGIWAP, &wrq);
+
+ g_free(ifname);
+ 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;
+
+ 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;
+}
+