[PATCH] Use hal device type instead of poking with ioctl

2006-04-27 Thread Jeremy Katz
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 -	1.23
+++ src/nm-device.c	27 Apr 2006 15:05:01 -
@@ -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:
___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: [PATCH] Use hal device type instead of poking with ioctl

2006-04-27 Thread Jeremy Katz
On Thu, 2006-04-27 at 11:36 -0400, Dan Williams wrote:
 On Thu, 2006-04-27 at 11:08 -0400, Jeremy Katz wrote:
  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?
 
 Yup, go ahead.  Can you check out the NETWORKMANAGER_0_6_0_RELEASE
 branch and commit it there too?  That one is the 0.6.x branch.

Yep, committed both places

Jeremy

___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list