diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2010-10-15 15:27:52 +0200 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2010-10-15 15:27:52 +0200 |
commit | d21f6934b7891237edb0c321720dc8b402a911f6 (patch) | |
tree | f50d95401a7d25c6eaab1a567ec476fb149d6fec /src/rtnl.c | |
parent | 6d8db41a79c9e84260afca853715e0856245882a (diff) | |
download | connman-d21f6934b7891237edb0c321720dc8b402a911f6.tar.gz connman-d21f6934b7891237edb0c321720dc8b402a911f6.tar.bz2 connman-d21f6934b7891237edb0c321720dc8b402a911f6.zip |
rtnl: Check for wireless extensions when missing DEVTYPE
Checking for wireless extensions is a bit more reliable than looking for
a potentially missing wireless directory.
Diffstat (limited to 'src/rtnl.c')
-rw-r--r-- | src/rtnl.c | 36 |
1 files changed, 28 insertions, 8 deletions
@@ -27,12 +27,14 @@ #include <unistd.h> #include <string.h> #include <sys/socket.h> +#include <sys/ioctl.h> #include <arpa/inet.h> #include <netinet/ether.h> #include <net/if_arp.h> #include <linux/if.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> +#include <linux/wireless.h> #include <glib.h> @@ -101,6 +103,28 @@ static connman_bool_t ether_blacklisted(const char *name) return FALSE; } +static connman_bool_t wext_interface(char *ifname) +{ + struct iwreq wrq; + int fd, err; + + fd = socket(PF_INET, SOCK_DGRAM, 0); + if (fd < 0) + return FALSE; + + memset(&wrq, 0, sizeof(wrq)); + strncpy(wrq.ifr_name, ifname, IFNAMSIZ); + + err = ioctl(fd, SIOCGIWNAME, &wrq); + + close(fd); + + if (err < 0) + return FALSE; + + return TRUE; +} + static void read_uevent(struct interface_data *interface) { char *filename, line[128]; @@ -163,16 +187,12 @@ static void read_uevent(struct interface_data *interface) return; /* We haven't got a DEVTYPE, let's check if it's a wireless device */ - filename = g_strdup_printf("/sys/class/net/%s/wireless/", - interface->name); - - f = fopen(filename, "re"); - - g_free(filename); - - if (f != NULL) { + if (wext_interface(interface->name)) { interface->service_type = CONNMAN_SERVICE_TYPE_WIFI; interface->device_type = CONNMAN_DEVICE_TYPE_WIFI; + + connman_error("%s runs an unsupported 802.11 driver", + interface->name); } } |