summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Kukawka <danny.kukawka@web.de>2006-09-12 00:25:11 +0200
committerDanny Kukawka <danny.kukawka@web.de>2006-09-12 00:25:11 +0200
commit5d11ae01e6ea1b2adceb1fed20ce4288d43a2748 (patch)
tree468fc70918f5e4fafb1095fdeb6ef6d70114c168
parent64cc367c425c6af0b85b8b34bd31e2a56b119d98 (diff)
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).
-rw-r--r--doc/spec/hal-spec-properties.xml30
-rw-r--r--hald/linux/classdev.c55
2 files changed, 47 insertions, 38 deletions
diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 77fac0bd..97d2580f 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 98ab2bcb..4e6d2c23 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 gchar *device_file, HalDevice *physdev,
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 gchar *device_file, HalDevice *physdev,
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;