mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-30 18:07:52 +00:00
hostapd: improve switch_chan support
Make the code retain current op_class if no new one was provided via ubus. Fixes: WIFI-7050 Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "utils/eloop.h"
|
||||
#include "utils/wpabuf.h"
|
||||
#include "common/ieee802_11_defs.h"
|
||||
#include "common/hw_features_common.h"
|
||||
#include "hostapd.h"
|
||||
#include "neighbor_db.h"
|
||||
#include "wps_hostapd.h"
|
||||
@@ -22,6 +23,7 @@
|
||||
#include "wnm_ap.h"
|
||||
#include "taxonomy.h"
|
||||
#include "airtime_policy.h"
|
||||
#include "hw_features.h"
|
||||
|
||||
static struct ubus_context *ctx;
|
||||
static struct blob_buf b;
|
||||
@@ -781,6 +783,7 @@ hostapd_switch_chan(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
struct hostapd_data *hapd = get_hapd_from_object(obj);
|
||||
struct hostapd_config *iconf = hapd->iface->conf;
|
||||
struct hostapd_freq_params *freq_params;
|
||||
struct hostapd_hw_modes *mode = hapd->iface->current_mode;
|
||||
struct csa_settings css = {
|
||||
.freq_params = {
|
||||
.ht_enabled = iconf->ieee80211n,
|
||||
@@ -789,6 +792,8 @@ hostapd_switch_chan(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
.sec_channel_offset = iconf->secondary_channel,
|
||||
}
|
||||
};
|
||||
u8 chwidth = hostapd_get_oper_chwidth(iconf);
|
||||
u8 seg0 = 0, seg1 = 0;
|
||||
int ret = UBUS_STATUS_OK;
|
||||
int i;
|
||||
|
||||
@@ -830,6 +835,35 @@ hostapd_switch_chan(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
SET_CSA_SETTING(CSA_HE, freq_params.he_enabled, bool);
|
||||
SET_CSA_SETTING(CSA_BLOCK_TX, block_tx, bool);
|
||||
|
||||
css.freq_params.channel = hostapd_hw_get_channel(hapd, css.freq_params.freq);
|
||||
if (!css.freq_params.channel)
|
||||
return UBUS_STATUS_NOT_SUPPORTED;
|
||||
|
||||
switch (css.freq_params.bandwidth) {
|
||||
case 160:
|
||||
chwidth = CHANWIDTH_160MHZ;
|
||||
break;
|
||||
case 80:
|
||||
chwidth = css.freq_params.center_freq2 ? CHANWIDTH_80P80MHZ : CHANWIDTH_80MHZ;
|
||||
break;
|
||||
default:
|
||||
chwidth = CHANWIDTH_USE_HT;
|
||||
break;
|
||||
}
|
||||
|
||||
hostapd_set_freq_params(&css.freq_params, iconf->hw_mode,
|
||||
css.freq_params.freq,
|
||||
css.freq_params.channel, iconf->enable_edmg,
|
||||
iconf->edmg_channel,
|
||||
css.freq_params.ht_enabled,
|
||||
css.freq_params.vht_enabled,
|
||||
css.freq_params.he_enabled,
|
||||
css.freq_params.sec_channel_offset,
|
||||
chwidth, seg0, seg1,
|
||||
iconf->vht_capab,
|
||||
mode ? &mode->he_capab[IEEE80211_MODE_AP] :
|
||||
NULL);
|
||||
|
||||
for (i = 0; i < hapd->iface->num_bss; i++) {
|
||||
struct hostapd_data *bss = hapd->iface->bss[i];
|
||||
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
From ec58340d35489da5851ccd75e921ecd700ace471 Mon Sep 17 00:00:00 2001
|
||||
From: Felix Fietkau <nbd@nbd.name>
|
||||
Date: Mon, 7 Feb 2022 13:11:01 +0100
|
||||
Subject: [PATCH] hostapd: automatically calculate channel center freq on
|
||||
chan_switch
|
||||
|
||||
Simplifies switching to different channels when on >= VHT80
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
---
|
||||
.../services/hostapd/src/src/ap/ubus.c | 34 +++++++++++++++++++
|
||||
1 file changed, 34 insertions(+)
|
||||
|
||||
diff --git a/package/network/services/hostapd/src/src/ap/ubus.c b/package/network/services/hostapd/src/src/ap/ubus.c
|
||||
index bcb80f4a33..5c9e966f70 100644
|
||||
--- a/package/network/services/hostapd/src/src/ap/ubus.c
|
||||
+++ b/package/network/services/hostapd/src/src/ap/ubus.c
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "utils/eloop.h"
|
||||
#include "utils/wpabuf.h"
|
||||
#include "common/ieee802_11_defs.h"
|
||||
+#include "common/hw_features_common.h"
|
||||
#include "hostapd.h"
|
||||
#include "neighbor_db.h"
|
||||
#include "wps_hostapd.h"
|
||||
@@ -22,6 +23,7 @@
|
||||
#include "wnm_ap.h"
|
||||
#include "taxonomy.h"
|
||||
#include "airtime_policy.h"
|
||||
+#include "hw_features.h"
|
||||
|
||||
static struct ubus_context *ctx;
|
||||
static struct blob_buf b;
|
||||
@@ -794,6 +796,7 @@ hostapd_switch_chan(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
struct hostapd_data *hapd = get_hapd_from_object(obj);
|
||||
struct hostapd_config *iconf = hapd->iface->conf;
|
||||
struct hostapd_freq_params *freq_params;
|
||||
+ struct hostapd_hw_modes *mode = hapd->iface->current_mode;
|
||||
struct csa_settings css = {
|
||||
.freq_params = {
|
||||
.ht_enabled = iconf->ieee80211n,
|
||||
@@ -802,6 +805,8 @@ hostapd_switch_chan(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
.sec_channel_offset = iconf->secondary_channel,
|
||||
}
|
||||
};
|
||||
+ u8 chwidth = hostapd_get_oper_chwidth(iconf);
|
||||
+ u8 seg0 = 0, seg1 = 0;
|
||||
int ret = UBUS_STATUS_OK;
|
||||
int i;
|
||||
|
||||
@@ -843,6 +848,35 @@ hostapd_switch_chan(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
SET_CSA_SETTING(CSA_HE, freq_params.he_enabled, bool);
|
||||
SET_CSA_SETTING(CSA_BLOCK_TX, block_tx, bool);
|
||||
|
||||
+ css.freq_params.channel = hostapd_hw_get_channel(hapd, css.freq_params.freq);
|
||||
+ if (!css.freq_params.channel)
|
||||
+ return UBUS_STATUS_NOT_SUPPORTED;
|
||||
+
|
||||
+ switch (css.freq_params.bandwidth) {
|
||||
+ case 160:
|
||||
+ chwidth = CHANWIDTH_160MHZ;
|
||||
+ break;
|
||||
+ case 80:
|
||||
+ chwidth = css.freq_params.center_freq2 ? CHANWIDTH_80P80MHZ : CHANWIDTH_80MHZ;
|
||||
+ break;
|
||||
+ default:
|
||||
+ chwidth = CHANWIDTH_USE_HT;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ hostapd_set_freq_params(&css.freq_params, iconf->hw_mode,
|
||||
+ css.freq_params.freq,
|
||||
+ css.freq_params.channel, iconf->enable_edmg,
|
||||
+ iconf->edmg_channel,
|
||||
+ css.freq_params.ht_enabled,
|
||||
+ css.freq_params.vht_enabled,
|
||||
+ css.freq_params.he_enabled,
|
||||
+ css.freq_params.sec_channel_offset,
|
||||
+ chwidth, seg0, seg1,
|
||||
+ iconf->vht_capab,
|
||||
+ mode ? &mode->he_capab[IEEE80211_MODE_AP] :
|
||||
+ NULL);
|
||||
+
|
||||
for (i = 0; i < hapd->iface->num_bss; i++) {
|
||||
struct hostapd_data *bss = hapd->iface->bss[i];
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
||||
Reference in New Issue
Block a user