summaryrefslogtreecommitdiff
authorDan Williams <dcbw@redhat.com>2008-03-14 21:12:03 (GMT)
committer Dan Williams <dcbw@redhat.com>2008-03-14 21:12:03 (GMT)
commita90c522da9cc2a21b63acf59d813572fa12334f4 (patch) (side-by-side diff)
tree5d9bd04e4e17bc3f5e69b13cda62b95700ca3c82
parentdd11e9a5eda6c95f8b2dc0d98ac0ad54d7a9187f (diff)
downloadNetworkManager-a90c522da9cc2a21b63acf59d813572fa12334f4.zip
NetworkManager-a90c522da9cc2a21b63acf59d813572fa12334f4.tar.gz
2008-03-14 Dan Williams <dcbw@redhat.com>
* include/wireless-helper.h include/Makefile.am - One place for all the junk needed for #including wireless.h * test/nm-tool.c src/NetworkManagerAP.c src/wpa.c src/Makefile.am libnm-util/nm-utils.c libnm-util/nm-setting-wireless.c libnm-glib/nm-device-802-11-wireless.c libnm-glib/nm-access-point.c libnm-glib/libnm-glib-test.c - include wireless-helper.h, not iwlib.h * configure.in - Don't need libiw really, just need to check for wireless.h * src/kernel-types.h - Remove; used types moved into wpa.c * src/nm-device-802-11-wireless.c - (nm_device_802_11_wireless_update_signal_strength, real_get_generic_capabilities, nm_device_802_11_wireless_get_mode, nm_device_802_11_wireless_set_mode, nm_device_802_11_wireless_get_frequency, nm_device_802_11_wireless_get_ssid, nm_device_802_11_wireless_set_ssid, nm_device_802_11_wireless_get_bitrate, nm_device_802_11_wireless_get_bssid, nm_device_802_11_wireless_disable_encryption): use ioctl() directly instead of iwlib functions git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3462 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ChangeLog35
-rw-r--r--configure.in13
-rw-r--r--include/Makefile.am5
-rw-r--r--include/wireless-helper.h11
-rw-r--r--libnm-glib/libnm-glib-test.c4
-rw-r--r--libnm-glib/nm-access-point.c4
-rw-r--r--libnm-glib/nm-device-802-11-wireless.c5
-rw-r--r--libnm-util/nm-setting-wireless.c6
-rw-r--r--libnm-util/nm-utils.c4
-rw-r--r--src/Makefile.am2
-rw-r--r--src/NetworkManagerAP.c5
-rw-r--r--src/kernel-types.h18
-rw-r--r--src/nm-device-802-11-wireless.c74
-rw-r--r--src/wpa.c8
-rw-r--r--test/nm-tool.c2
15 files changed, 129 insertions, 67 deletions
diff --git a/ChangeLog b/ChangeLog
index 0ada4e1..9f610d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,40 @@
2008-03-14 Dan Williams <dcbw@redhat.com>
+ * include/wireless-helper.h
+ include/Makefile.am
+ - One place for all the junk needed for #including wireless.h
+
+ * test/nm-tool.c
+ src/NetworkManagerAP.c
+ src/wpa.c
+ src/Makefile.am
+ libnm-util/nm-utils.c
+ libnm-util/nm-setting-wireless.c
+ libnm-glib/nm-device-802-11-wireless.c
+ libnm-glib/nm-access-point.c
+ libnm-glib/libnm-glib-test.c
+ - include wireless-helper.h, not iwlib.h
+
+ * configure.in
+ - Don't need libiw really, just need to check for wireless.h
+
+ * src/kernel-types.h
+ - Remove; used types moved into wpa.c
+
+ * src/nm-device-802-11-wireless.c
+ - (nm_device_802_11_wireless_update_signal_strength,
+ real_get_generic_capabilities, nm_device_802_11_wireless_get_mode,
+ nm_device_802_11_wireless_set_mode,
+ nm_device_802_11_wireless_get_frequency,
+ nm_device_802_11_wireless_get_ssid,
+ nm_device_802_11_wireless_set_ssid,
+ nm_device_802_11_wireless_get_bitrate,
+ nm_device_802_11_wireless_get_bssid,
+ nm_device_802_11_wireless_disable_encryption): use ioctl() directly
+ instead of iwlib functions
+
+2008-03-14 Dan Williams <dcbw@redhat.com>
+
* src/ppp-manager/nm-ppp-manager.c
- (impl_ppp_manager_need_secrets): since it's asynchronous now, it
should only take the DBusGMethodInvocation argument, not user/pass
diff --git a/configure.in b/configure.in
index 37a2d92..7ee7b4b 100644
--- a/configure.in
+++ b/configure.in
@@ -133,8 +133,15 @@ if test x"$with_distro" = xgentoo ; then
esac
fi
-AC_MSG_CHECKING([for wireless-tools >= 28pre9])
-AC_TRY_COMPILE([#include <iwlib.h>],
+AC_MSG_CHECKING([Linux Wireless Extensions >= 18])
+AC_TRY_COMPILE([#ifndef __user
+ #define __user
+ #endif
+ #include <sys/types.h>
+ #include <linux/types.h>
+ #include <sys/socket.h>
+ #include <net/if.h>
+ #include <wireless.h>],
[#ifndef IWEVGENIE
#error "not found"
#endif],
@@ -144,8 +151,6 @@ AC_MSG_RESULT($ac_have_iwevgenie)
if test "$ac_have_iwevgenie" = no; then
AC_MSG_ERROR(wireless-tools >= 28pre9 not installed or not functional)
fi
-IWLIB=-liw
-AC_SUBST(IWLIB)
PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.72)
diff --git a/include/Makefile.am b/include/Makefile.am
index 280122f..efcac76 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -4,4 +4,7 @@ EXTRA_DIST = \
NetworkManagerincludedir=$(includedir)/NetworkManager
-NetworkManagerinclude_HEADERS = NetworkManager.h NetworkManagerVPN.h
+NetworkManagerinclude_HEADERS = \
+ NetworkManager.h \
+ NetworkManagerVPN.h \
+ wireless-helper.h
diff --git a/include/wireless-helper.h b/include/wireless-helper.h
new file mode 100644
index 0000000..7dc10c8
--- a/dev/null
+++ b/include/wireless-helper.h
@@ -0,0 +1,11 @@
+/* Hacks necessary to #include wireless.h; yay for WEXT */
+
+#ifndef __user
+#define __user
+#endif
+#include <sys/types.h>
+#include <linux/types.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <wireless.h>
+
diff --git a/libnm-glib/libnm-glib-test.c b/libnm-glib/libnm-glib-test.c
index 0a004c4..1f15531 100644
--- a/libnm-glib/libnm-glib-test.c
+++ b/libnm-glib/libnm-glib-test.c
@@ -3,8 +3,8 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <iwlib.h>
-#include <wireless.h>
+
+#include "wireless-helper.h"
#include "nm-client.h"
#include "nm-device.h"
diff --git a/libnm-glib/nm-access-point.c b/libnm-glib/nm-access-point.c
index c0c3ce4..2373c95 100644
--- a/libnm-glib/nm-access-point.c
+++ b/libnm-glib/nm-access-point.c
@@ -1,6 +1,8 @@
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
-#include <iwlib.h>
+#include "wireless-helper.h"
+
+#include <string.h>
#include "nm-access-point.h"
#include "NetworkManager.h"
diff --git a/libnm-glib/nm-device-802-11-wireless.c b/libnm-glib/nm-device-802-11-wireless.c
index de3e913..c4d4be6 100644
--- a/libnm-glib/nm-device-802-11-wireless.c
+++ b/libnm-glib/nm-device-802-11-wireless.c
@@ -1,5 +1,8 @@
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
-#include <iwlib.h>
+
+#include "wireless-helper.h"
+
+#include <string.h>
#include "nm-device-802-11-wireless.h"
#include "nm-device-private.h"
diff --git a/libnm-util/nm-setting-wireless.c b/libnm-util/nm-setting-wireless.c
index 5e01d06..79472ba 100644
--- a/libnm-util/nm-setting-wireless.c
+++ b/libnm-util/nm-setting-wireless.c
@@ -2,9 +2,11 @@
#include <string.h>
#include <netinet/ether.h>
+
+#include "wireless-helper.h"
+
#include <dbus/dbus-glib.h>
-#include <iwlib.h>
-#include <wireless.h>
+
#include "NetworkManager.h"
#include "nm-setting-wireless.h"
diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c
index 5190350..df00dd4 100644
--- a/libnm-util/nm-utils.c
+++ b/libnm-util/nm-utils.c
@@ -25,10 +25,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
-#include <iwlib.h>
-#include <wireless.h>
#include <arpa/inet.h>
+#include "wireless-helper.h"
+
#include <glib.h>
#include <glib-object.h>
#include <dbus/dbus-glib.h>
diff --git a/src/Makefile.am b/src/Makefile.am
index 19f6dfd..efa17f6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -63,7 +63,6 @@ NetworkManager_SOURCES = \
nm-cdma-device.h \
autoip.c \
autoip.h \
- kernel-types.h \
wpa.c \
wpa.h \
nm-netlink.c \
@@ -121,7 +120,6 @@ NetworkManager_LDADD = \
$(DBUS_LIBS) \
$(GTHREAD_LIBS) \
$(HAL_LIBS) \
- $(IWLIB) \
$(LIBNL_LIBS) \
./marshallers/libmarshallers.la \
./named-manager/libnamed-manager.la \
diff --git a/src/NetworkManagerAP.c b/src/NetworkManagerAP.c
index 5681305..11e573f 100644
--- a/src/NetworkManagerAP.c
+++ b/src/NetworkManagerAP.c
@@ -20,11 +20,14 @@
* (C) Copyright 2004 Red Hat, Inc.
*/
+#include "wireless-helper.h"
+
+#include <string.h>
+
#include "NetworkManagerAP.h"
#include "NetworkManagerUtils.h"
#include "nm-utils.h"
#include "nm-dbus-manager.h"
-#include <wireless.h>
#include "wpa.h"
#include "nm-properties-changed-signal.h"
#include "nm-setting-wireless.h"
diff --git a/src/kernel-types.h b/src/kernel-types.h
deleted file mode 100644
index e4faa66..0000000
--- a/src/kernel-types.h
+++ b/dev/null
@@ -1,18 +0,0 @@
-#ifndef _KERNEL_TYPES_H
-#define _KERNEL_TYPES_H
-
-/*
- * Various headers leak the kernel-only types u16, u32, et al. User-space
- * does not supply these types, so we define them here.
- */
-
-typedef __u64 u64;
-typedef __u32 u32;
-typedef __u16 u16;
-typedef __u8 u8;
-typedef __s64 s64;
-typedef __s32 s32;
-typedef __s16 s16;
-typedef __s8 s8;
-
-#endif /* _KERNEL_TYPES_H */
diff --git a/src/nm-device-802-11-wireless.c b/src/nm-device-802-11-wireless.c
index 3c35b98..e25c935 100644
--- a/src/nm-device-802-11-wireless.c
+++ b/src/nm-device-802-11-wireless.c
@@ -215,15 +215,17 @@ nm_device_802_11_wireless_update_signal_strength (NMDevice80211Wireless *self,
fd = socket (PF_INET, SOCK_DGRAM, 0);
if (fd >= 0) {
- gboolean has_range = FALSE;
- iwrange range;
- iwstats stats;
+ struct iwreq wrq;
+ struct iw_statistics stats;
- memset (&range, 0, sizeof (iwrange));
- has_range = (iw_get_range_info (fd, iface, &range) >= 0);
+ memset (&stats, 0, sizeof (stats));
- memset (&stats, 0, sizeof (iwstats));
- if (iw_get_stats (fd, iface, &stats, &range, has_range) == 0) {
+ wrq.u.data.pointer = &stats;
+ wrq.u.data.length = sizeof (stats);
+ wrq.u.data.flags = 1; /* Clear updated flag */
+ strncpy (wrq.ifr_name, iface, IFNAMSIZ);
+
+ if (ioctl (fd, SIOCGIWSTATS, &wrq) == 0) {
percent = wireless_qual_to_percent (&stats.qual, (const iwqual *)(&self->priv->max_qual),
(const iwqual *)(&self->priv->avg_qual));
}
@@ -245,7 +247,7 @@ real_get_generic_capabilities (NMDevice *dev)
{
int fd, err;
guint32 caps = NM_DEVICE_CAP_NONE;
- iwrange range;
+ struct iw_range range;
struct iwreq wrq;
const char *iface = nm_device_get_iface (dev);
@@ -257,12 +259,18 @@ real_get_generic_capabilities (NMDevice *dev)
goto out;
}
- if (iw_get_range_info (fd, iface, &range) < 0) {
+ memset (&wrq, 0, sizeof (struct iwreq));
+ memset (&range, 0, sizeof (struct iw_range));
+ strncpy (wrq.ifr_name, iface, IFNAMSIZ);
+ wrq.u.data.pointer = (caddr_t) &range;
+ wrq.u.data.length = sizeof (struct iw_range);
+
+ if (ioctl (fd, SIOCGIWRANGE, &wrq) < 0) {
nm_warning ("couldn't get driver range information.");
goto out;
}
- if (range.we_version_compiled < 16) {
+ if ((wrq.u.data.length < 300) || (range.we_version_compiled < 16)) {
nm_warning ("%s: driver's Wireless Extensions version (%d) is too old.",
iface, range.we_version_compiled);
goto out;
@@ -272,7 +280,8 @@ real_get_generic_capabilities (NMDevice *dev)
/* Card's that don't scan aren't supported */
memset (&wrq, 0, sizeof (struct iwreq));
- err = iw_set_ext (fd, iface, SIOCSIWSCAN, &wrq);
+ strncpy (wrq.ifr_name, iface, IFNAMSIZ);
+ err = ioctl (fd, SIOCSIWSCAN, &wrq);
if ((err == -1) && (errno == EOPNOTSUPP))
caps = NM_DEVICE_CAP_NONE;
@@ -968,14 +977,15 @@ nm_device_802_11_wireless_get_mode (NMDevice80211Wireless *self)
g_return_val_if_fail (self != NULL, -1);
- iface = nm_device_get_iface (NM_DEVICE (self));
fd = socket (PF_INET, SOCK_DGRAM, 0);
if (fd < 0)
goto out;
memset (&wrq, 0, sizeof (struct iwreq));
+ iface = nm_device_get_iface (NM_DEVICE (self));
+ strncpy (wrq.ifr_name, iface, IFNAMSIZ);
- if (iw_get_ext (fd, iface, SIOCGIWMODE, &wrq) == 0) {
+ if (ioctl (fd, SIOCGIWMODE, &wrq) == 0) {
if ((wrq.u.mode == IW_MODE_ADHOC) || (wrq.u.mode == IW_MODE_INFRA))
mode = wrq.u.mode;
} else {
@@ -1010,15 +1020,16 @@ nm_device_802_11_wireless_set_mode (NMDevice80211Wireless *self,
if (nm_device_802_11_wireless_get_mode (self) == mode)
return TRUE;
- iface = nm_device_get_iface (NM_DEVICE (self));
-
fd = socket (PF_INET, SOCK_DGRAM, 0);
if (fd < 0)
goto out;
memset (&wrq, 0, sizeof (struct iwreq));
wrq.u.mode = mode;
- if (iw_set_ext (fd, iface, SIOCSIWMODE, &wrq) == 0)
+ iface = nm_device_get_iface (NM_DEVICE (self));
+ strncpy (wrq.ifr_name, iface, IFNAMSIZ);
+
+ if (ioctl (fd, SIOCSIWMODE, &wrq) == 0)
success = TRUE;
else {
if (errno != ENODEV) {
@@ -1049,14 +1060,15 @@ nm_device_802_11_wireless_get_frequency (NMDevice80211Wireless *self)
g_return_val_if_fail (self != NULL, 0);
- iface = nm_device_get_iface (NM_DEVICE (self));
fd = socket (PF_INET, SOCK_DGRAM, 0);
if (fd < 0)
return 0;
memset (&wrq, 0, sizeof (struct iwreq));
+ iface = nm_device_get_iface (NM_DEVICE (self));
+ strncpy (wrq.ifr_name, iface, IFNAMSIZ);
- err = iw_get_ext (fd, iface, SIOCGIWFREQ, &wrq);
+ err = ioctl (fd, SIOCGIWFREQ, &wrq);
if (err >= 0)
freq = iw_freq_to_uint32 (&wrq.u.freq);
else if (err == -1)
@@ -1189,7 +1201,6 @@ const GByteArray *
nm_device_802_11_wireless_get_ssid (NMDevice80211Wireless *self)
{
NMDevice80211WirelessPrivate *priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (self);
- const char * iface;
int sk;
struct iwreq wrq;
char ssid[IW_ESSID_MAX_SIZE + 1];
@@ -1197,7 +1208,6 @@ nm_device_802_11_wireless_get_ssid (NMDevice80211Wireless *self)
g_return_val_if_fail (self != NULL, NULL);
- iface = nm_device_get_iface (NM_DEVICE (self));
sk = socket (AF_INET, SOCK_DGRAM, 0);
if (!sk) {
nm_error ("Couldn't create socket: %d.", errno);
@@ -1208,7 +1218,9 @@ nm_device_802_11_wireless_get_ssid (NMDevice80211Wireless *self)
wrq.u.essid.pointer = (caddr_t) &ssid;
wrq.u.essid.length = sizeof (ssid);
wrq.u.essid.flags = 0;
- if (iw_get_ext (sk, iface, SIOCGIWESSID, &wrq) < 0) {
+ strncpy (wrq.ifr_name, nm_device_get_iface (NM_DEVICE (self)), IFNAMSIZ);
+
+ if (ioctl (sk, SIOCGIWESSID, &wrq) < 0) {
nm_warning ("Couldn't get SSID: %d", errno);
goto out;
}
@@ -1286,7 +1298,9 @@ nm_device_802_11_wireless_set_ssid (NMDevice80211Wireless *self,
wrq.u.essid.length = len;
wrq.u.essid.flags = (len > 0) ? 1 : 0; /* 1=enable SSID, 0=disable/any */
- if (iw_get_ext (sk, iface, SIOCSIWESSID, &wrq) < 0) {
+ strncpy (wrq.ifr_name, iface, IFNAMSIZ);
+
+ if (ioctl (sk, SIOCSIWESSID, &wrq) < 0) {
if (errno != ENODEV) {
nm_warning ("error setting SSID to '%s' for device %s: %s",
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(null)",
@@ -1319,17 +1333,16 @@ nm_device_802_11_wireless_get_bitrate (NMDevice80211Wireless *self)
{
int err = -1, fd;
struct iwreq wrq;
- const char *iface;
g_return_val_if_fail (self != NULL, 0);
- iface = nm_device_get_iface (NM_DEVICE (self));
fd = socket (PF_INET, SOCK_DGRAM, 0);
if (fd < 0)
return 0;
memset (&wrq, 0, sizeof (wrq));
- err = iw_get_ext (fd, iface, SIOCGIWRATE, &wrq);
+ strncpy (wrq.ifr_name, nm_device_get_iface (NM_DEVICE (self)), IFNAMSIZ);
+ err = ioctl (fd, SIOCGIWRATE, &wrq);
close (fd);
return ((err >= 0) ? wrq.u.bitrate.value / 1000 : 0);
@@ -1347,14 +1360,12 @@ nm_device_802_11_wireless_get_bssid (NMDevice80211Wireless *self,
{
int fd;
struct iwreq wrq;
- const char *iface;
g_return_if_fail (self != NULL);
g_return_if_fail (bssid != NULL);
memset (bssid, 0, sizeof (struct ether_addr));
- iface = nm_device_get_iface (NM_DEVICE (self));
fd = socket (PF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
g_warning ("failed to open control socket.");
@@ -1362,7 +1373,8 @@ nm_device_802_11_wireless_get_bssid (NMDevice80211Wireless *self,
}
memset (&wrq, 0, sizeof (wrq));
- if (iw_get_ext (fd, iface, SIOCGIWAP, &wrq) >= 0)
+ strncpy (wrq.ifr_name, nm_device_get_iface (NM_DEVICE (self)), IFNAMSIZ);
+ if (ioctl (fd, SIOCGIWAP, &wrq) >= 0)
memcpy (bssid->ether_addr_octet, &(wrq.u.ap_addr.sa_data), ETH_ALEN);
close (fd);
@@ -1380,7 +1392,7 @@ nm_device_802_11_wireless_disable_encryption (NMDevice80211Wireless *self)
{
int fd;
const char *iface;
- struct iwreq wreq = {
+ struct iwreq wrq = {
.u.data.pointer = (caddr_t) NULL,
.u.data.length = 0,
.u.data.flags = IW_ENCODE_DISABLED
@@ -1395,7 +1407,9 @@ nm_device_802_11_wireless_disable_encryption (NMDevice80211Wireless *self)
}
iface = nm_device_get_iface (NM_DEVICE (self));
- if (iw_set_ext (fd, iface, SIOCSIWENCODE, &wreq) == -1) {
+ strncpy (wrq.ifr_name, iface, IFNAMSIZ);
+
+ if (ioctl (fd, SIOCSIWENCODE, &wrq) == -1) {
if (errno != ENODEV) {
nm_warning ("error setting key for device %s: %s",
iface, strerror (errno));
diff --git a/src/wpa.c b/src/wpa.c
index 1092be4..8f50047 100644
--- a/src/wpa.c
+++ b/src/wpa.c
@@ -12,14 +12,18 @@
* See README and COPYING for more details.
*/
+#include "wireless-helper.h"
+
#include <stdint.h>
-#include <iwlib.h>
+#include <string.h>
#include <glib.h>
-#include "kernel-types.h"
#include "wpa.h"
#include "nm-utils.h"
+typedef guint16 u16;
+typedef guint8 u8;
+
#define WPA_GET_LE16(a) ((u16) (((a)[1] << 8) | (a)[0]))
#define BIT(n) (1 << (n))
diff --git a/test/nm-tool.c b/test/nm-tool.c
index d285841..2a38320 100644
--- a/test/nm-tool.c
+++ b/test/nm-tool.c
@@ -26,7 +26,7 @@
#include <string.h>
#include <stdlib.h>
-#include <iwlib.h>
+#include "wireless-helper.h"
#include <sys/socket.h>
#include <netinet/in.h>