hal: Branch 'master' - 2 commits

Danny Kukawka dkukawka at kemper.freedesktop.org
Fri May 23 08:32:18 PDT 2008


 hald/linux/device.c |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

New commits:
commit 41073645ea95e0bb478d6b26871a1bc4ccf832d1
Author: Johannes Berg <johannes at sipsolutions.net>
Date:   Fri May 23 17:31:51 2008 +0200

    use wext ioctl instead of sysfs to detect wireless
    
    The canonical way to check whether a network interface has wireless
    extensions is to try calling the SIOCGIWNAME ioctl on it.

diff --git a/hald/linux/device.c b/hald/linux/device.c
index 0760540..ac242ec 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -45,6 +45,10 @@
   #include <linux/input.h>
 #endif
 
+/* for wireless extensions */
+#include <linux/if.h>
+#include <linux/wireless.h>
+
 #include <dbus/dbus.h>
 #include <dbus/dbus-glib.h>
 
@@ -532,10 +536,14 @@ net_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_de
 		const char *addr;
 		const char *parent_subsys;
 		char bridge_path[HAL_PATH_MAX];
-		char wireless_path[HAL_PATH_MAX];
 		char phy80211_path[HAL_PATH_MAX];
 		struct stat s;
 		dbus_uint64_t mac_address = 0;
+		int ioctl_fd;
+		struct iwreq iwr;
+
+		ioctl_fd = socket (PF_INET, SOCK_DGRAM, 0);
+		strncpy (iwr.ifr_ifrn.ifrn_name, ifname, IFNAMSIZ);
 
 		addr = hal_device_property_get_string (d, "net.address");
 		if (addr != NULL) {
@@ -554,8 +562,6 @@ net_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_de
 		}
 
 		snprintf (bridge_path, HAL_PATH_MAX, "%s/bridge", sysfs_path);
-		/* wireless extensions */
-		snprintf (wireless_path, HAL_PATH_MAX, "%s/wireless", sysfs_path);
 		/* cfg80211 */
 		snprintf (phy80211_path, HAL_PATH_MAX, "%s/phy80211", sysfs_path);
 		parent_subsys = hal_device_property_get_string (parent_dev, "info.subsystem");
@@ -565,7 +571,7 @@ net_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_de
 			hal_device_property_set_string (d, "info.category", "net.bluetooth");
 			hal_device_add_capability (d, "net.bluetooth");
 			hal_device_property_set_uint64 (d, "net.bluetooth.mac_address", mac_address);
-		} else if ((stat (wireless_path, &s) == 0 && (s.st_mode & S_IFDIR)) ||
+		} else if ((ioctl (ioctl_fd, SIOCGIWNAME, &iwr) == 0) ||
 			(stat (phy80211_path, &s) == 0 && (s.st_mode & S_IFDIR))) {
 			hal_device_property_set_string (d, "info.product", "WLAN Interface");
 			hal_device_property_set_string (d, "info.category", "net.80211");
@@ -582,6 +588,8 @@ net_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_de
 			hal_device_add_capability (d, "net.80203");
 			hal_device_property_set_uint64 (d, "net.80203.mac_address", mac_address);
 		}
+
+		close (ioctl_fd);
 	} else if (media_type == ARPHRD_IRDA) {
 		hal_device_property_set_string (d, "info.product", "Networking Interface");
 		hal_device_property_set_string (d, "info.category", "net.irda");
commit d5d0b8cd48d07b5854565d9ad2c4dcc92fdda2e7
Author: Johannes Berg <johannes at sipsolutions.net>
Date:   Fri May 23 17:29:47 2008 +0200

    use 'phy80211' instead of 'wiphy' symlink to detect wireless
    
    When hal wants to determine whether a device is wireless or not,
    it looks up the 'wiphy' symlink that only existed in unreleased
    versions of cfg80211, mainline uses 'phy80211' now.

diff --git a/hald/linux/device.c b/hald/linux/device.c
index 99450d0..0760540 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -533,7 +533,7 @@ net_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_de
 		const char *parent_subsys;
 		char bridge_path[HAL_PATH_MAX];
 		char wireless_path[HAL_PATH_MAX];
-		char wiphy_path[HAL_PATH_MAX];
+		char phy80211_path[HAL_PATH_MAX];
 		struct stat s;
 		dbus_uint64_t mac_address = 0;
 
@@ -554,9 +554,10 @@ net_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_de
 		}
 
 		snprintf (bridge_path, HAL_PATH_MAX, "%s/bridge", sysfs_path);
+		/* wireless extensions */
 		snprintf (wireless_path, HAL_PATH_MAX, "%s/wireless", sysfs_path);
-		/* wireless dscape stack e.g. from rt2500pci driver*/
-		snprintf (wiphy_path, HAL_PATH_MAX, "%s/wiphy", sysfs_path);
+		/* cfg80211 */
+		snprintf (phy80211_path, HAL_PATH_MAX, "%s/phy80211", sysfs_path);
 		parent_subsys = hal_device_property_get_string (parent_dev, "info.subsystem");
 
 		if (parent_subsys && strcmp(parent_subsys, "bluetooth") == 0) {
@@ -565,7 +566,7 @@ net_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_de
 			hal_device_add_capability (d, "net.bluetooth");
 			hal_device_property_set_uint64 (d, "net.bluetooth.mac_address", mac_address);
 		} else if ((stat (wireless_path, &s) == 0 && (s.st_mode & S_IFDIR)) ||
-			(stat (wiphy_path, &s) == 0 && (s.st_mode & S_IFDIR))) {
+			(stat (phy80211_path, &s) == 0 && (s.st_mode & S_IFDIR))) {
 			hal_device_property_set_string (d, "info.product", "WLAN Interface");
 			hal_device_property_set_string (d, "info.category", "net.80211");
 			hal_device_add_capability (d, "net.80211");


More information about the hal-commit mailing list