Re: RFC: WPA-related API changes



On Wed, 2005-12-07 at 12:58 -0500, Dan Williams wrote:

> 1) Use the enc_capa field in the iw_range info for the driver to
> determine WPA capabilities.  Not many drivers support this yet.

Attached patch checks enc_capa for the presence of WPA and WPA2.

What you had in mind?

	Robert Love

Index: include/NetworkManager.h
===================================================================
RCS file: /cvs/gnome/NetworkManager/include/NetworkManager.h,v
retrieving revision 1.4
diff -u -r1.4 NetworkManager.h
--- include/NetworkManager.h	7 Dec 2005 20:21:28 -0000	1.4
+++ include/NetworkManager.h	8 Dec 2005 19:39:38 -0000
@@ -101,6 +101,8 @@
 #define NM_DEVICE_CAP_NM_SUPPORTED		0x0001
 #define NM_DEVICE_CAP_CARRIER_DETECT	0x0002
 #define NM_DEVICE_CAP_WIRELESS_SCAN	0x0004
+#define NM_DEVICE_CAP_WIRELESS_WAP		0x0008
+#define NM_DEVICE_CAP_WIRELESS_WAP2	0x0010
 
 
 /*
Index: src/NetworkManagerDevice.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerDevice.c,v
retrieving revision 1.189
diff -u -r1.189 NetworkManagerDevice.c
--- src/NetworkManagerDevice.c	8 Dec 2005 15:40:24 -0000	1.189
+++ src/NetworkManagerDevice.c	8 Dec 2005 19:39:39 -0000
@@ -653,14 +653,40 @@
 		}
 	}
 
+	/* A test wireless device is a pro at WPA and WPA2 */
+	if (dev->test_device)
+		   caps |= NM_DEVICE_CAP_WIRELESS_WAP | NM_DEVICE_CAP_WIRELESS_WAP2;
+	else
+	{
+		if ((sk = nm_dev_sock_open (dev, DEV_WIRELESS, __FUNCTION__, NULL)))
+		{
+			struct iw_range range;
+			struct iwreq wrq;
+
+			memset (&wrq, 0, sizeof (wrq));
+			strncpy (wrq.ifr_name, nm_device_get_iface (dev), IFNAMSIZ);
+			wrq.u.data.pointer = (caddr_t) ⦥
+			wrq.u.data.length = sizeof (struct iw_range);
+
+			if (ioctl (nm_dev_sock_get_fd (sk), SIOCGIWRANGE, &wrq) >= 0)
+			{
+				if (range.enc_capa & IW_ENC_CAPA_WPA)
+					caps |= NM_DEVICE_CAP_WIRELESS_WAP;
+				if (range.enc_capa & IW_ENC_CAPA_WPA2)
+					caps |= NM_DEVICE_CAP_WIRELESS_WAP2;
+			}
+			nm_dev_sock_close (sk);
+		}
+	}
+
 	return caps;
 }
 
 
 /*
- * nm_device_wireless_discover_capabilities
+ * nm_device_wired_discover_capabilities
  *
- * Figure out wireless-specific capabilities
+ * Figure out wired-specific capabilities
  *
  */
 static guint32 nm_device_wired_discover_capabilities (NMDevice *dev)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]