[PATCH] hostapd: add set_40mhz cli
Johannes Berg
johannes
Fri Feb 8 16:12:04 PST 2013
From: Johannes Berg <johannes.berg at intel.com>
I've been using this for testing the 20/40 changes in
mac80211... This is probably not all that useful for
most people, but maybe there could be a config option
that enables such testing features?
---
hostapd/config_file.c | 1 +
hostapd/ctrl_iface.c | 33 +++++++++++++++++++++++++++++++++
hostapd/hostapd_cli.c | 19 +++++++++++++++++++
src/ap/ap_config.h | 2 +-
4 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index 7b22dfd..56392d1 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -989,6 +989,7 @@ static int hostapd_config_ht_capab(struct hostapd_config *conf,
conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
conf->secondary_channel = 1;
}
+ conf->orig_secondary_channel = conf->secondary_channel;
if (os_strstr(capab, "[SMPS-STATIC]")) {
conf->ht_capab &= ~HT_CAP_INFO_SMPS_MASK;
conf->ht_capab |= HT_CAP_INFO_SMPS_STATIC;
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 93b740e..cf9d577 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -29,6 +29,7 @@
#include "ap/wps_hostapd.h"
#include "ap/ctrl_iface_ap.h"
#include "ap/ap_drv_ops.h"
+#include "ap/beacon.h"
#include "wps/wps_defs.h"
#include "wps/wps.h"
#include "config_file.h"
@@ -780,6 +781,35 @@ static int hostapd_ctrl_iface_disable(struct hostapd_iface *iface)
}
+static int hostapd_ctrl_iface_set_40mhz(struct hostapd_data *hapd,
+ char *offset)
+{
+ int sec = atoi(offset);
+
+ if (!hapd->iconf->orig_secondary_channel)
+ return -1;
+ if (!hapd->iconf->ieee80211n || hapd->iconf->ieee80211ac)
+ return -1;
+
+ switch (sec) {
+ case 1:
+ case -1:
+ if (hapd->iconf->orig_secondary_channel != sec)
+ return -1;
+ case 0:
+ break;
+ default:
+ return -1;
+ }
+
+ hapd->iconf->secondary_channel = sec;
+
+ ieee802_11_update_beacons(hapd->iface);
+
+ return 0;
+}
+
+
static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
void *sock_ctx)
{
@@ -941,6 +971,9 @@ static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
} else if (os_strncmp(buf, "DISABLE", 7) == 0) {
if (hostapd_ctrl_iface_disable(hapd->iface))
reply_len = -1;
+ } else if (os_strncmp(buf, "SET_40MHZ ", 8) == 0) {
+ if (hostapd_ctrl_iface_set_40mhz(hapd, buf + 9))
+ reply_len = -1;
} else {
os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
reply_len = 16;
diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c
index 0e840ea..29bb558 100644
--- a/hostapd/hostapd_cli.c
+++ b/hostapd/hostapd_cli.c
@@ -80,6 +80,7 @@ static const char *commands_help =
" wps_ap_pin <cmd> [params..] enable/disable AP PIN\n"
" wps_config <SSID> <auth> <encr> <key> configure AP\n"
#endif /* CONFIG_WPS */
+" set_40mhz <-1|0|1> set 40 MHz secondary channel (below/off/above)\n"
" get_config show current configuration\n"
" help show this usage help\n"
" interface [ifname] show interfaces/select interface\n"
@@ -559,6 +560,23 @@ static int hostapd_cli_cmd_disassoc_imminent(struct wpa_ctrl *ctrl, int argc,
}
+static int hostapd_cli_set_40mhz(struct wpa_ctrl *ctrl, int argc, char *argv[])
+{
+ char buf[50];
+ int res;
+
+ if (argc != 1) {
+ printf("Invalid 'set_40mhz' command - need sec argument\n");
+ return -1;
+ }
+
+ res = os_snprintf(buf, sizeof(buf), "SET_40MHZ %s", argv[0]);
+ if (res < 0 || res >= (int) sizeof(buf))
+ return -1;
+ return wpa_ctrl_command(ctrl, buf);
+}
+
+
static int hostapd_cli_cmd_ess_disassoc(struct wpa_ctrl *ctrl, int argc,
char *argv[])
{
@@ -795,6 +813,7 @@ static struct hostapd_cli_cmd hostapd_cli_commands[] = {
{ "wps_ap_pin", hostapd_cli_cmd_wps_ap_pin },
{ "wps_config", hostapd_cli_cmd_wps_config },
#endif /* CONFIG_WPS */
+ { "set_40mhz", hostapd_cli_set_40mhz },
{ "disassoc_imminent", hostapd_cli_cmd_disassoc_imminent },
{ "ess_disassoc", hostapd_cli_cmd_ess_disassoc },
{ "get_config", hostapd_cli_cmd_get_config },
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index 4742107..a57a8ca 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -510,7 +510,7 @@ struct hostapd_config {
int ht_op_mode_fixed;
u16 ht_capab;
int ieee80211n;
- int secondary_channel;
+ int secondary_channel, orig_secondary_channel;
int require_ht;
u32 vht_capab;
int ieee80211ac;
--
1.8.0
More information about the Hostap
mailing list