From: Samuel Ortiz Date: Fri, 15 Oct 2010 13:27:52 +0000 (+0200) Subject: rtnl: Check for wireless extensions when missing DEVTYPE X-Git-Tag: 2.0_alpha~2281 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d21f6934b7891237edb0c321720dc8b402a911f6;p=framework%2Fconnectivity%2Fconnman.git 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. --- diff --git a/src/rtnl.c b/src/rtnl.c index 95663db..1993493 100644 --- a/src/rtnl.c +++ b/src/rtnl.c @@ -27,12 +27,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include @@ -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); } }