hrev50150 adds 2 changesets to branch 'master'
old head: 1e3ca5cef9a2596c9c917550a3a368075bc9def7
new head: 4fab1ac6186f232710fba49995cbcb8bbe7b0736
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=4fab1ac6186f+%5E1e3ca5cef9a2
----------------------------------------------------------------------------
310238937c8c: Network Kit: add BNetworkDevice::Control
* Allows to do an arbitrary ioctl on the network device
* For ifreq and ieee80211req requests
4fab1ac6186f: ifconfig: add "[-]ht" control option for WLAN devices
* "ht" and "-ht" enable or disable the use of HT mode
(high throughput, 802.11n) for the wireless network device
* Analogous to the option with the same name in FreeBSD's ifconfig
* Disabling HT before associating with an AP is a workaround for
connection instability issues encountered with iprowifi4965
driver
[ Julian Harnath <julian.harnath@xxxxxxxxxxxxxx> ]
----------------------------------------------------------------------------
4 files changed, 80 insertions(+), 2 deletions(-)
headers/os/net/NetworkDevice.h | 2 ++
src/bin/network/ifconfig/Jamfile | 5 +++
src/bin/network/ifconfig/ifconfig.cpp | 39 ++++++++++++++++++++++--
src/kits/network/libnetapi/NetworkDevice.cpp | 36 ++++++++++++++++++++++
############################################################################
Commit: 310238937c8c14190818c505e4cb14a453bbdda7
URL: http://cgit.haiku-os.org/haiku/commit/?id=310238937c8c
Author: Julian Harnath <julian.harnath@xxxxxxxxxxxxxx>
Date: Tue Mar 15 20:40:29 2016 UTC
Network Kit: add BNetworkDevice::Control
* Allows to do an arbitrary ioctl on the network device
* For ifreq and ieee80211req requests
----------------------------------------------------------------------------
diff --git a/headers/os/net/NetworkDevice.h b/headers/os/net/NetworkDevice.h
index a99ae9e..a71d22c 100644
--- a/headers/os/net/NetworkDevice.h
+++ b/headers/os/net/NetworkDevice.h
@@ -96,6 +96,8 @@ public:
bool IsEthernet();
bool IsWireless();
+ status_t Control(int option,
void* request);
+
status_t Scan(bool wait = true,
bool
forceRescan = true);
diff --git a/src/kits/network/libnetapi/NetworkDevice.cpp
b/src/kits/network/libnetapi/NetworkDevice.cpp
index 29fade4..73f67f0 100644
--- a/src/kits/network/libnetapi/NetworkDevice.cpp
+++ b/src/kits/network/libnetapi/NetworkDevice.cpp
@@ -82,6 +82,24 @@ do_request(T& request, const char* name, int option)
}
+template<> status_t
+do_request<ieee80211req>(ieee80211req& request, const char* name, int option)
+{
+ int socket = ::socket(AF_INET, SOCK_DGRAM, 0);
+ if (socket < 0)
+ return errno;
+
+ FileDescriptorCloser closer(socket);
+
+ strlcpy(((struct ieee80211req&)request).i_name, name, IFNAMSIZ);
+
+ if (ioctl(socket, option, &request, sizeof(request)) < 0)
+ return errno;
+
+ return B_OK;
+}
+
+
//! Read a 16 bit little endian value
static uint16
read_le16(uint8*& data, int32& length)
@@ -647,6 +665,24 @@ BNetworkDevice::IsWireless()
status_t
+BNetworkDevice::Control(int option, void* request)
+{
+ switch (IFM_TYPE(Media())) {
+ case IFM_ETHER:
+ return do_request(*reinterpret_cast<ifreq*>(request),
+ &fName[0], option);
+
+ case IFM_IEEE80211:
+ return
do_request(*reinterpret_cast<ieee80211req*>(request),
+ &fName[0], option);
+
+ default:
+ return B_ERROR;
+ }
+}
+
+
+status_t
BNetworkDevice::Scan(bool wait, bool forceRescan)
{
#if 0
############################################################################
Revision: hrev50150
Commit: 4fab1ac6186f232710fba49995cbcb8bbe7b0736
URL: http://cgit.haiku-os.org/haiku/commit/?id=4fab1ac6186f
Author: Julian Harnath <julian.harnath@xxxxxxxxxxxxxx>
Date: Tue Mar 15 20:46:03 2016 UTC
ifconfig: add "[-]ht" control option for WLAN devices
* "ht" and "-ht" enable or disable the use of HT mode
(high throughput, 802.11n) for the wireless network device
* Analogous to the option with the same name in FreeBSD's ifconfig
* Disabling HT before associating with an AP is a workaround for
connection instability issues encountered with iprowifi4965
driver
----------------------------------------------------------------------------
diff --git a/src/bin/network/ifconfig/Jamfile b/src/bin/network/ifconfig/Jamfile
index 14fa7bb..679d290 100644
--- a/src/bin/network/ifconfig/Jamfile
+++ b/src/bin/network/ifconfig/Jamfile
@@ -2,6 +2,11 @@ SubDir HAIKU_TOP src bin network ifconfig ;
UsePrivateHeaders net ;
+UseHeaders [ FDirName $(HAIKU_TOP) src libs compat ] : true ;
+UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_wlan ] : true ;
+
+SubDirC++Flags [ FDefines _BSD_SOURCE=1 ] ;
+
BinCommand ifconfig :
ifconfig.cpp
MediaTypes.cpp
diff --git a/src/bin/network/ifconfig/ifconfig.cpp
b/src/bin/network/ifconfig/ifconfig.cpp
index eeda9d9..9c14bff 100644
--- a/src/bin/network/ifconfig/ifconfig.cpp
+++ b/src/bin/network/ifconfig/ifconfig.cpp
@@ -15,6 +15,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/sockio.h>
#include <unistd.h>
#include <Message.h>
@@ -25,6 +26,12 @@
#include <NetServer.h>
+extern "C" {
+# include <freebsd_network/compat/sys/cdefs.h>
+# include <freebsd_network/compat/sys/ioccom.h>
+# include <net80211/ieee80211_ioctl.h>
+}
+
#include "MediaTypes.h"
@@ -90,7 +97,7 @@ usage(int status)
printf("\n");
}
printf("And <flags> can be: up, down, [-]promisc, [-]allmulti,
[-]bcast, "
- "loopback\n"
+ "[-]ht, loopback\n"
"If you specify \"auto-config\" instead of an address, it will
be "
"configured automatically.\n\n"
"Example:\n"
@@ -276,15 +283,28 @@ configure_wireless(const char* name, char* const* args,
int32 argCount)
NONE,
LIST,
JOIN,
- LEAVE
+ LEAVE,
+ CONTROL
} mode = NONE;
+ int controlOption = -1;
+ int controlValue = -1;
+
if (!strcmp(args[0], "list") || !strcmp(args[0], "scan"))
mode = LIST;
else if (!strcmp(args[0], "join"))
mode = JOIN;
else if (!strcmp(args[0], "leave"))
mode = LEAVE;
+ else if (!strcmp(args[0], "ht")) {
+ mode = CONTROL;
+ controlOption = IEEE80211_IOC_HTCONF;
+ controlValue = 3;
+ } else if (!strcmp(args[0], "-ht")) {
+ mode = CONTROL;
+ controlOption = IEEE80211_IOC_HTCONF;
+ controlValue = 0;
+ }
if (mode == NONE)
return false;
@@ -392,6 +412,21 @@ configure_wireless(const char* name, char* const* args,
int32 argCount)
break;
}
+ case CONTROL:
+ {
+ ieee80211req request;
+ memset(&request, 0, sizeof(request));
+ request.i_type = controlOption;
+ request.i_val = controlValue;
+ status_t status = device.Control(SIOCS80211, &request);
+ if (status != B_OK) {
+ fprintf(stderr, "%s: Control failed: %s\n",
kProgramName,
+ strerror(status));
+ exit(1);
+ }
+ break;
+ }
+
case NONE:
break;
}