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
This commit is contained in:
Julian Harnath 2016-03-15 21:46:03 +01:00
parent 310238937c
commit 4fab1ac618
2 changed files with 42 additions and 2 deletions

View File

@ -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

View File

@ -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;
}