[PATCH] Use hal device type instead of poking with ioctl
- From: Jeremy Katz <katzj redhat com>
- To: networkmanager-list gnome org
- Subject: [PATCH] Use hal device type instead of poking with ioctl
- Date: Thu, 27 Apr 2006 11:08:38 -0400
NM should just use what hal has already determined as the type of device
instead of going and poking via ioctl again. Especially as poking via
ioctls isn't necessarily going to work if, eg, the kill switch is in
use.
Patch attached -- look okay to commit?
Jeremy
Index: src/nm-device.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/nm-device.c,v
retrieving revision 1.23
diff -u -r1.23 nm-device.c
--- src/nm-device.c 21 Mar 2006 17:57:01 -0000 1.23
+++ src/nm-device.c 27 Apr 2006 15:05:01 -0000
@@ -82,30 +82,17 @@
*
*/
static NMDeviceType
-discover_device_type (const char *iface)
+discover_device_type (LibHalContext *ctx, const char *udi)
{
- int err = -1;
- int fd;
+ char * category = NULL;
- g_return_val_if_fail (iface != NULL, FALSE);
-
- if ((fd = iw_sockets_open ()) >= 0)
- {
- char buf[64];
-
- strncpy (buf, iface, 62);
- buf[63] = '\0';
-
-#ifdef IOCTL_DEBUG
- nm_info ("%s: About to GET IWNAME", iface);
-#endif
- err = ioctl (fd, SIOCGIWNAME, buf);
-#ifdef IOCTL_DEBUG
- nm_info ("%s: Done with GET IWNAME", iface);
-#endif
- close (fd);
- }
- return err == 0 ? DEVICE_TYPE_802_11_WIRELESS : DEVICE_TYPE_802_3_ETHERNET;
+ if (libhal_device_property_exists (ctx, udi, "info.category", NULL))
+ category = libhal_device_get_property_string(ctx, udi, "info.category", NULL);
+ if (category && (!strcmp (category, "net.80211")))
+ return DEVICE_TYPE_802_11_WIRELESS;
+ else if (category && (!strcmp (category, "net.80203")))
+ return DEVICE_TYPE_802_3_ETHERNET;
+ return DEVICE_TYPE_UNKNOWN;
}
/*
@@ -152,7 +139,7 @@
g_return_val_if_fail (strlen (iface) > 0, NULL);
g_return_val_if_fail (app_data != NULL, NULL);
- type = discover_device_type (iface);
+ type = discover_device_type (app_data->hal_ctx, udi);
switch (type)
{
case DEVICE_TYPE_802_11_WIRELESS:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]