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
This commit is contained in:
35
ChangeLog
35
ChangeLog
@@ -1,3 +1,38 @@
|
|||||||
|
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>
|
2008-03-14 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
* src/ppp-manager/nm-ppp-manager.c
|
* src/ppp-manager/nm-ppp-manager.c
|
||||||
|
13
configure.in
13
configure.in
@@ -133,8 +133,15 @@ if test x"$with_distro" = xgentoo ; then
|
|||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_MSG_CHECKING([for wireless-tools >= 28pre9])
|
AC_MSG_CHECKING([Linux Wireless Extensions >= 18])
|
||||||
AC_TRY_COMPILE([#include <iwlib.h>],
|
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
|
[#ifndef IWEVGENIE
|
||||||
#error "not found"
|
#error "not found"
|
||||||
#endif],
|
#endif],
|
||||||
@@ -144,8 +151,6 @@ AC_MSG_RESULT($ac_have_iwevgenie)
|
|||||||
if test "$ac_have_iwevgenie" = no; then
|
if test "$ac_have_iwevgenie" = no; then
|
||||||
AC_MSG_ERROR(wireless-tools >= 28pre9 not installed or not functional)
|
AC_MSG_ERROR(wireless-tools >= 28pre9 not installed or not functional)
|
||||||
fi
|
fi
|
||||||
IWLIB=-liw
|
|
||||||
AC_SUBST(IWLIB)
|
|
||||||
|
|
||||||
PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.72)
|
PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.72)
|
||||||
|
|
||||||
|
@@ -4,4 +4,7 @@ EXTRA_DIST = \
|
|||||||
|
|
||||||
NetworkManagerincludedir=$(includedir)/NetworkManager
|
NetworkManagerincludedir=$(includedir)/NetworkManager
|
||||||
|
|
||||||
NetworkManagerinclude_HEADERS = NetworkManager.h NetworkManagerVPN.h
|
NetworkManagerinclude_HEADERS = \
|
||||||
|
NetworkManager.h \
|
||||||
|
NetworkManagerVPN.h \
|
||||||
|
wireless-helper.h
|
||||||
|
11
include/wireless-helper.h
Normal file
11
include/wireless-helper.h
Normal file
@@ -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>
|
||||||
|
|
@@ -3,8 +3,8 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <iwlib.h>
|
|
||||||
#include <wireless.h>
|
#include "wireless-helper.h"
|
||||||
|
|
||||||
#include "nm-client.h"
|
#include "nm-client.h"
|
||||||
#include "nm-device.h"
|
#include "nm-device.h"
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
|
/* -*- 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 "nm-access-point.h"
|
||||||
#include "NetworkManager.h"
|
#include "NetworkManager.h"
|
||||||
|
@@ -1,5 +1,8 @@
|
|||||||
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
|
/* -*- 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-802-11-wireless.h"
|
||||||
#include "nm-device-private.h"
|
#include "nm-device-private.h"
|
||||||
|
@@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <netinet/ether.h>
|
#include <netinet/ether.h>
|
||||||
|
|
||||||
|
#include "wireless-helper.h"
|
||||||
|
|
||||||
#include <dbus/dbus-glib.h>
|
#include <dbus/dbus-glib.h>
|
||||||
#include <iwlib.h>
|
|
||||||
#include <wireless.h>
|
|
||||||
#include "NetworkManager.h"
|
#include "NetworkManager.h"
|
||||||
|
|
||||||
#include "nm-setting-wireless.h"
|
#include "nm-setting-wireless.h"
|
||||||
|
@@ -25,10 +25,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <iwlib.h>
|
|
||||||
#include <wireless.h>
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
#include "wireless-helper.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <dbus/dbus-glib.h>
|
#include <dbus/dbus-glib.h>
|
||||||
|
@@ -63,7 +63,6 @@ NetworkManager_SOURCES = \
|
|||||||
nm-cdma-device.h \
|
nm-cdma-device.h \
|
||||||
autoip.c \
|
autoip.c \
|
||||||
autoip.h \
|
autoip.h \
|
||||||
kernel-types.h \
|
|
||||||
wpa.c \
|
wpa.c \
|
||||||
wpa.h \
|
wpa.h \
|
||||||
nm-netlink.c \
|
nm-netlink.c \
|
||||||
@@ -121,7 +120,6 @@ NetworkManager_LDADD = \
|
|||||||
$(DBUS_LIBS) \
|
$(DBUS_LIBS) \
|
||||||
$(GTHREAD_LIBS) \
|
$(GTHREAD_LIBS) \
|
||||||
$(HAL_LIBS) \
|
$(HAL_LIBS) \
|
||||||
$(IWLIB) \
|
|
||||||
$(LIBNL_LIBS) \
|
$(LIBNL_LIBS) \
|
||||||
./marshallers/libmarshallers.la \
|
./marshallers/libmarshallers.la \
|
||||||
./named-manager/libnamed-manager.la \
|
./named-manager/libnamed-manager.la \
|
||||||
|
@@ -20,11 +20,14 @@
|
|||||||
* (C) Copyright 2004 Red Hat, Inc.
|
* (C) Copyright 2004 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "wireless-helper.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "NetworkManagerAP.h"
|
#include "NetworkManagerAP.h"
|
||||||
#include "NetworkManagerUtils.h"
|
#include "NetworkManagerUtils.h"
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
#include "nm-dbus-manager.h"
|
#include "nm-dbus-manager.h"
|
||||||
#include <wireless.h>
|
|
||||||
#include "wpa.h"
|
#include "wpa.h"
|
||||||
#include "nm-properties-changed-signal.h"
|
#include "nm-properties-changed-signal.h"
|
||||||
#include "nm-setting-wireless.h"
|
#include "nm-setting-wireless.h"
|
||||||
|
@@ -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 */
|
|
@@ -215,15 +215,17 @@ nm_device_802_11_wireless_update_signal_strength (NMDevice80211Wireless *self,
|
|||||||
|
|
||||||
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
gboolean has_range = FALSE;
|
struct iwreq wrq;
|
||||||
iwrange range;
|
struct iw_statistics stats;
|
||||||
iwstats stats;
|
|
||||||
|
|
||||||
memset (&range, 0, sizeof (iwrange));
|
memset (&stats, 0, sizeof (stats));
|
||||||
has_range = (iw_get_range_info (fd, iface, &range) >= 0);
|
|
||||||
|
|
||||||
memset (&stats, 0, sizeof (iwstats));
|
wrq.u.data.pointer = &stats;
|
||||||
if (iw_get_stats (fd, iface, &stats, &range, has_range) == 0) {
|
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),
|
percent = wireless_qual_to_percent (&stats.qual, (const iwqual *)(&self->priv->max_qual),
|
||||||
(const iwqual *)(&self->priv->avg_qual));
|
(const iwqual *)(&self->priv->avg_qual));
|
||||||
}
|
}
|
||||||
@@ -245,7 +247,7 @@ real_get_generic_capabilities (NMDevice *dev)
|
|||||||
{
|
{
|
||||||
int fd, err;
|
int fd, err;
|
||||||
guint32 caps = NM_DEVICE_CAP_NONE;
|
guint32 caps = NM_DEVICE_CAP_NONE;
|
||||||
iwrange range;
|
struct iw_range range;
|
||||||
struct iwreq wrq;
|
struct iwreq wrq;
|
||||||
const char *iface = nm_device_get_iface (dev);
|
const char *iface = nm_device_get_iface (dev);
|
||||||
|
|
||||||
@@ -257,12 +259,18 @@ real_get_generic_capabilities (NMDevice *dev)
|
|||||||
goto out;
|
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) ⦥
|
||||||
|
wrq.u.data.length = sizeof (struct iw_range);
|
||||||
|
|
||||||
|
if (ioctl (fd, SIOCGIWRANGE, &wrq) < 0) {
|
||||||
nm_warning ("couldn't get driver range information.");
|
nm_warning ("couldn't get driver range information.");
|
||||||
goto out;
|
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.",
|
nm_warning ("%s: driver's Wireless Extensions version (%d) is too old.",
|
||||||
iface, range.we_version_compiled);
|
iface, range.we_version_compiled);
|
||||||
goto out;
|
goto out;
|
||||||
@@ -272,7 +280,8 @@ real_get_generic_capabilities (NMDevice *dev)
|
|||||||
|
|
||||||
/* Card's that don't scan aren't supported */
|
/* Card's that don't scan aren't supported */
|
||||||
memset (&wrq, 0, sizeof (struct iwreq));
|
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))
|
if ((err == -1) && (errno == EOPNOTSUPP))
|
||||||
caps = NM_DEVICE_CAP_NONE;
|
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);
|
g_return_val_if_fail (self != NULL, -1);
|
||||||
|
|
||||||
iface = nm_device_get_iface (NM_DEVICE (self));
|
|
||||||
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
memset (&wrq, 0, sizeof (struct iwreq));
|
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))
|
if ((wrq.u.mode == IW_MODE_ADHOC) || (wrq.u.mode == IW_MODE_INFRA))
|
||||||
mode = wrq.u.mode;
|
mode = wrq.u.mode;
|
||||||
} else {
|
} else {
|
||||||
@@ -1010,15 +1020,16 @@ nm_device_802_11_wireless_set_mode (NMDevice80211Wireless *self,
|
|||||||
if (nm_device_802_11_wireless_get_mode (self) == mode)
|
if (nm_device_802_11_wireless_get_mode (self) == mode)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
iface = nm_device_get_iface (NM_DEVICE (self));
|
|
||||||
|
|
||||||
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
memset (&wrq, 0, sizeof (struct iwreq));
|
memset (&wrq, 0, sizeof (struct iwreq));
|
||||||
wrq.u.mode = mode;
|
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;
|
success = TRUE;
|
||||||
else {
|
else {
|
||||||
if (errno != ENODEV) {
|
if (errno != ENODEV) {
|
||||||
@@ -1049,14 +1060,15 @@ nm_device_802_11_wireless_get_frequency (NMDevice80211Wireless *self)
|
|||||||
|
|
||||||
g_return_val_if_fail (self != NULL, 0);
|
g_return_val_if_fail (self != NULL, 0);
|
||||||
|
|
||||||
iface = nm_device_get_iface (NM_DEVICE (self));
|
|
||||||
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
memset (&wrq, 0, sizeof (struct iwreq));
|
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)
|
if (err >= 0)
|
||||||
freq = iw_freq_to_uint32 (&wrq.u.freq);
|
freq = iw_freq_to_uint32 (&wrq.u.freq);
|
||||||
else if (err == -1)
|
else if (err == -1)
|
||||||
@@ -1189,7 +1201,6 @@ const GByteArray *
|
|||||||
nm_device_802_11_wireless_get_ssid (NMDevice80211Wireless *self)
|
nm_device_802_11_wireless_get_ssid (NMDevice80211Wireless *self)
|
||||||
{
|
{
|
||||||
NMDevice80211WirelessPrivate *priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (self);
|
NMDevice80211WirelessPrivate *priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (self);
|
||||||
const char * iface;
|
|
||||||
int sk;
|
int sk;
|
||||||
struct iwreq wrq;
|
struct iwreq wrq;
|
||||||
char ssid[IW_ESSID_MAX_SIZE + 1];
|
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);
|
g_return_val_if_fail (self != NULL, NULL);
|
||||||
|
|
||||||
iface = nm_device_get_iface (NM_DEVICE (self));
|
|
||||||
sk = socket (AF_INET, SOCK_DGRAM, 0);
|
sk = socket (AF_INET, SOCK_DGRAM, 0);
|
||||||
if (!sk) {
|
if (!sk) {
|
||||||
nm_error ("Couldn't create socket: %d.", errno);
|
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.pointer = (caddr_t) &ssid;
|
||||||
wrq.u.essid.length = sizeof (ssid);
|
wrq.u.essid.length = sizeof (ssid);
|
||||||
wrq.u.essid.flags = 0;
|
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);
|
nm_warning ("Couldn't get SSID: %d", errno);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -1286,7 +1298,9 @@ nm_device_802_11_wireless_set_ssid (NMDevice80211Wireless *self,
|
|||||||
wrq.u.essid.length = len;
|
wrq.u.essid.length = len;
|
||||||
wrq.u.essid.flags = (len > 0) ? 1 : 0; /* 1=enable SSID, 0=disable/any */
|
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) {
|
if (errno != ENODEV) {
|
||||||
nm_warning ("error setting SSID to '%s' for device %s: %s",
|
nm_warning ("error setting SSID to '%s' for device %s: %s",
|
||||||
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(null)",
|
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;
|
int err = -1, fd;
|
||||||
struct iwreq wrq;
|
struct iwreq wrq;
|
||||||
const char *iface;
|
|
||||||
|
|
||||||
g_return_val_if_fail (self != NULL, 0);
|
g_return_val_if_fail (self != NULL, 0);
|
||||||
|
|
||||||
iface = nm_device_get_iface (NM_DEVICE (self));
|
|
||||||
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
memset (&wrq, 0, sizeof (wrq));
|
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);
|
close (fd);
|
||||||
|
|
||||||
return ((err >= 0) ? wrq.u.bitrate.value / 1000 : 0);
|
return ((err >= 0) ? wrq.u.bitrate.value / 1000 : 0);
|
||||||
@@ -1347,14 +1360,12 @@ nm_device_802_11_wireless_get_bssid (NMDevice80211Wireless *self,
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
struct iwreq wrq;
|
struct iwreq wrq;
|
||||||
const char *iface;
|
|
||||||
|
|
||||||
g_return_if_fail (self != NULL);
|
g_return_if_fail (self != NULL);
|
||||||
g_return_if_fail (bssid != NULL);
|
g_return_if_fail (bssid != NULL);
|
||||||
|
|
||||||
memset (bssid, 0, sizeof (struct ether_addr));
|
memset (bssid, 0, sizeof (struct ether_addr));
|
||||||
|
|
||||||
iface = nm_device_get_iface (NM_DEVICE (self));
|
|
||||||
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
g_warning ("failed to open control socket.");
|
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));
|
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);
|
memcpy (bssid->ether_addr_octet, &(wrq.u.ap_addr.sa_data), ETH_ALEN);
|
||||||
|
|
||||||
close (fd);
|
close (fd);
|
||||||
@@ -1380,7 +1392,7 @@ nm_device_802_11_wireless_disable_encryption (NMDevice80211Wireless *self)
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
const char *iface;
|
const char *iface;
|
||||||
struct iwreq wreq = {
|
struct iwreq wrq = {
|
||||||
.u.data.pointer = (caddr_t) NULL,
|
.u.data.pointer = (caddr_t) NULL,
|
||||||
.u.data.length = 0,
|
.u.data.length = 0,
|
||||||
.u.data.flags = IW_ENCODE_DISABLED
|
.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));
|
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) {
|
if (errno != ENODEV) {
|
||||||
nm_warning ("error setting key for device %s: %s",
|
nm_warning ("error setting key for device %s: %s",
|
||||||
iface, strerror (errno));
|
iface, strerror (errno));
|
||||||
|
@@ -12,14 +12,18 @@
|
|||||||
* See README and COPYING for more details.
|
* See README and COPYING for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "wireless-helper.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <iwlib.h>
|
#include <string.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include "kernel-types.h"
|
|
||||||
#include "wpa.h"
|
#include "wpa.h"
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
|
|
||||||
|
typedef guint16 u16;
|
||||||
|
typedef guint8 u8;
|
||||||
|
|
||||||
#define WPA_GET_LE16(a) ((u16) (((a)[1] << 8) | (a)[0]))
|
#define WPA_GET_LE16(a) ((u16) (((a)[1] << 8) | (a)[0]))
|
||||||
|
|
||||||
#define BIT(n) (1 << (n))
|
#define BIT(n) (1 << (n))
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <iwlib.h>
|
#include "wireless-helper.h"
|
||||||
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
Reference in New Issue
Block a user