hal: Branch 'master'

Danny Kukawka dkukawka at kemper.freedesktop.org
Mon Sep 11 15:26:22 PDT 2006


 doc/spec/hal-spec-properties.xml |   30 +++++++++++++++++++++
 hald/linux/classdev.c            |   55 ++++++++++++---------------------------
 2 files changed, 47 insertions(+), 38 deletions(-)

New commits:
diff-tree 5d11ae01e6ea1b2adceb1fed20ce4288d43a2748 (from 64cc367c425c6af0b85b8b34bd31e2a56b119d98)
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Tue Sep 12 00:25:11 2006 +0200

    change detection of wireless, add net.irda and net.80211control
    
    Changed the detection of wireless network devices. The currently used
    proc file is/become IIRC deprecated. I change the detection to check
    for /sys/class/net/*/wireless (which was already in the code but commented
    out).
    
    I added also some code and spec information for IrDA net devices (net.irda)
    and ARPHRD_IEEE80211* (wireless lan control-) devices (net.80211control).

diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 77fac0b..97d2580 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -3711,6 +3711,36 @@
       <para>
       </para>
     </sect2>
+    <sect2 id="device-properties-net-irda">
+      <title>
+        <literal>net.irda</literal> namespace
+      </title>
+      <para>
+        IrDA (Infrared Data Association) Networking devices are described in 
+	this namespace for device objects with the capability
+        <literal>net.irda</literal>.
+        Note that device objects can only have the <literal>net.irda</literal> 
+	capability if they already have the capability <literal>net</literal>.
+      </para>
+      <para>
+      </para>
+    </sect2>
+    <sect2 id="device-properties-net-80211control">
+      <title>
+        <literal>net.80211control</literal> namespace
+      </title>
+      <para>
+        Control devices for Wireless ethernet networking devices are described in 
+	this namespace for device objects with the capability
+        <literal>net.80211control</literal>.
+        Note that device objects can only have the <literal>net.80211control</literal> 
+	capability if they already have the capability <literal>net</literal>.
+	Warning: You should know what you do if you touch this devices. They are 
+	not always stable and can cause (kernel) crashes (on linux).
+      </para>
+      <para>
+      </para>
+    </sect2>
     <sect2 id="device-properties-input">
       <title>
         <literal>input</literal> namespace
diff --git a/hald/linux/classdev.c b/hald/linux/classdev.c
index 98ab2bc..4e6d2c2 100644
--- a/hald/linux/classdev.c
+++ b/hald/linux/classdev.c
@@ -36,6 +36,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdint.h>
+#include <sys/stat.h>
 #include <unistd.h>
 
 #include <dbus/dbus.h>
@@ -189,53 +190,22 @@ net_add (const gchar *sysfs_path, const 
 
 	media_type = hal_device_property_get_int (d, "net.arp_proto_hw_id");
 	if (media_type == ARPHRD_ETHER) {
-		FILE *f;
-		gboolean is_wireless;
 		const char *addr;
+		char wireless_path[HAL_PATH_MAX];
+		gboolean is_wireless;
+		struct stat s;
 
-		is_wireless = FALSE;
-
-		f = fopen ("/proc/net/wireless", "ro");
-		if (f != NULL) {
-			unsigned int i;
-			unsigned int ifname_len;
-			char buf[128];
-
-			ifname_len = strlen (ifname);
-
-			do {
-				if (fgets (buf, sizeof (buf), f) == NULL)
-					break;
-
-				for (i=0; i < sizeof (buf); i++) {
-					if (isspace (buf[i]))
-						continue;
-					else
-						break;
-				}
-
-				if (strncmp (ifname, buf + i, ifname_len) == 0) {
-					is_wireless = TRUE;
-					break;
-				}
-
-			} while (TRUE);
-			fclose (f);
-		}
-
-		if (is_wireless) {
-		/* Check to see if this interface supports wireless extensions */
-		/*
-		snprintf (wireless_path, SYSFS_PATH_MAX, "%s/wireless", sysfs_path);
-		if (stat (wireless_path, &statbuf) == 0) {
-		*/
+		snprintf (wireless_path, HAL_PATH_MAX, "%s/wireless", sysfs_path);
+                if (stat (wireless_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");
+			is_wireless = TRUE;
 		} else {
 			hal_device_property_set_string (d, "info.product", "Networking Interface");
 			hal_device_property_set_string (d, "info.category", "net.80203");
 			hal_device_add_capability (d, "net.80203");
+			is_wireless = FALSE;
 		}
 
 		addr = hal_device_property_get_string (d, "net.address");
@@ -259,6 +229,15 @@ net_add (const gchar *sysfs_path, const 
 								mac_address);
 			}
 		}
+	} 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");
+		hal_device_add_capability (d, "net.irda");
+	} else if (media_type == ARPHRD_IEEE80211 || media_type == ARPHRD_IEEE80211_PRISM || 
+		   media_type == ARPHRD_IEEE80211_RADIOTAP) {
+		hal_device_property_set_string (d, "info.product", "Networking Wireless Control Interface");
+		hal_device_property_set_string (d, "info.category", "net.80211control");
+		hal_device_add_capability (d, "net.80211control");
 	}
 
 	return d;


More information about the hal-commit mailing list