diff --git a/ChangeLog b/ChangeLog index b374ec5424..e74a6ec56d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-12-08 Robert Love + + * include/NetworkManager.h: add WPA capabilities constants + * src/NetworkManagerDevice.c: detect if wireless devices support WPA + or WPA2 and add the capabilities bits as appropriate. + 2005-12-08 Robert Love * initscript/SUSE/networkmanager-dispatcher.in: new initscript for diff --git a/include/NetworkManager.h b/include/NetworkManager.h index 82c230a4db..1d8b35e4a5 100644 --- a/include/NetworkManager.h +++ b/include/NetworkManager.h @@ -101,6 +101,8 @@ typedef enum NMEncKeyType #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_WPA 0x0008 +#define NM_DEVICE_CAP_WIRELESS_WPA2 0x0010 /* diff --git a/src/NetworkManagerDevice.c b/src/NetworkManagerDevice.c index bca7d1bf8a..53e83dde4f 100644 --- a/src/NetworkManagerDevice.c +++ b/src/NetworkManagerDevice.c @@ -653,14 +653,46 @@ static guint32 nm_device_wireless_discover_capabilities (NMDevice *dev) } } + /* A test wireless device is a pro at WPA and WPA2 */ + if (dev->test_device) + caps |= NM_DEVICE_CAP_WIRELESS_WPA | NM_DEVICE_CAP_WIRELESS_WPA2; + 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_WPA; + if (range.enc_capa & IW_ENC_CAPA_WPA2) + caps |= NM_DEVICE_CAP_WIRELESS_WPA2; + } + + /* + * FIXME: Most drivers do not yet support enc_capa, so we should + * try another method here if neither WPA cap was set. + */ + + 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)