2011-04-24 00:34:35 +03:00
|
|
|
--- a/hostapd/config_file.c
|
|
|
|
+++ b/hostapd/config_file.c
|
2012-04-29 14:14:53 +03:00
|
|
|
@@ -1957,6 +1957,10 @@ static int hostapd_config_fill(struct ho
|
2011-04-24 00:34:35 +03:00
|
|
|
"ht_capab", line);
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
+ } else if (os_strcmp(buf, "dynamic_ht40") == 0) {
|
|
|
|
+ conf->dynamic_ht40 = atoi(pos);
|
|
|
|
+ if (conf->dynamic_ht40 == 1)
|
|
|
|
+ conf->dynamic_ht40 = 1500;
|
|
|
|
} else if (os_strcmp(buf, "require_ht") == 0) {
|
|
|
|
conf->require_ht = atoi(pos);
|
|
|
|
#endif /* CONFIG_IEEE80211N */
|
|
|
|
--- a/src/ap/ap_config.h
|
|
|
|
+++ b/src/ap/ap_config.h
|
2012-03-27 13:42:47 +03:00
|
|
|
@@ -434,6 +434,7 @@ struct hostapd_config {
|
2011-04-24 00:34:35 +03:00
|
|
|
int ieee80211n;
|
|
|
|
int secondary_channel;
|
|
|
|
int require_ht;
|
|
|
|
+ int dynamic_ht40;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
--- a/src/ap/hostapd.c
|
|
|
|
+++ b/src/ap/hostapd.c
|
2012-03-27 13:42:47 +03:00
|
|
|
@@ -21,6 +21,7 @@
|
2011-04-24 06:34:46 +03:00
|
|
|
#include "beacon.h"
|
|
|
|
#include "iapp.h"
|
|
|
|
#include "ieee802_1x.h"
|
|
|
|
+#include "ieee802_11.h"
|
|
|
|
#include "ieee802_11_auth.h"
|
|
|
|
#include "vlan_init.h"
|
|
|
|
#include "wpa_auth.h"
|
2012-04-29 14:14:53 +03:00
|
|
|
@@ -307,6 +308,7 @@ static void hostapd_cleanup_iface_pre(st
|
2012-03-27 13:42:47 +03:00
|
|
|
|
|
|
|
static void hostapd_cleanup_iface_partial(struct hostapd_iface *iface)
|
2011-04-24 00:34:35 +03:00
|
|
|
{
|
|
|
|
+ hostapd_deinit_ht(iface);
|
|
|
|
hostapd_free_hw_features(iface->hw_features, iface->num_hw_features);
|
|
|
|
iface->hw_features = NULL;
|
|
|
|
os_free(iface->current_rates);
|
|
|
|
--- a/src/ap/hostapd.h
|
|
|
|
+++ b/src/ap/hostapd.h
|
2012-03-27 13:42:47 +03:00
|
|
|
@@ -238,6 +238,9 @@ struct hostapd_iface {
|
2011-04-24 00:34:35 +03:00
|
|
|
/* Overlapping BSS information */
|
|
|
|
int olbc_ht;
|
|
|
|
|
|
|
|
+ int force_20mhz;
|
|
|
|
+ struct os_time last_20mhz_trigger;
|
|
|
|
+
|
|
|
|
u16 ht_op_mode;
|
|
|
|
void (*scan_cb)(struct hostapd_iface *iface);
|
|
|
|
|
|
|
|
--- a/src/ap/ieee802_11.c
|
|
|
|
+++ b/src/ap/ieee802_11.c
|
2012-03-27 13:42:47 +03:00
|
|
|
@@ -1205,6 +1205,9 @@ static void handle_beacon(struct hostapd
|
2011-04-24 00:34:35 +03:00
|
|
|
sizeof(mgmt->u.beacon)), &elems,
|
|
|
|
0);
|
|
|
|
|
|
|
|
+ if (!elems.ht_capabilities)
|
|
|
|
+ hostapd_trigger_20mhz(hapd->iface);
|
|
|
|
+
|
|
|
|
ap_list_process_beacon(hapd->iface, mgmt, &elems, fi);
|
|
|
|
}
|
|
|
|
|
|
|
|
--- a/src/ap/ieee802_11.h
|
|
|
|
+++ b/src/ap/ieee802_11.h
|
2012-03-27 13:42:47 +03:00
|
|
|
@@ -73,4 +73,17 @@ u8 * hostapd_eid_time_zone(struct hostap
|
2011-11-04 03:05:26 +02:00
|
|
|
int hostapd_update_time_adv(struct hostapd_data *hapd);
|
|
|
|
void hostapd_client_poll_ok(struct hostapd_data *hapd, const u8 *addr);
|
2011-04-24 00:34:35 +03:00
|
|
|
|
|
|
|
+#ifdef CONFIG_IEEE80211N
|
|
|
|
+void hostapd_trigger_20mhz(struct hostapd_iface *iface);
|
|
|
|
+void hostapd_deinit_ht(struct hostapd_iface *iface);
|
|
|
|
+
|
|
|
|
+#else
|
|
|
|
+static inline void hostapd_deinit_ht(struct hostapd_iface *iface)
|
|
|
|
+{
|
|
|
|
+}
|
|
|
|
+static inline void hostapd_trigger_20mhz(struct hostapd_iface *iface)
|
|
|
|
+{
|
|
|
|
+}
|
|
|
|
+#endif /* CONFIG_IEEE80211N */
|
|
|
|
+
|
|
|
|
#endif /* IEEE802_11_H */
|
|
|
|
--- a/src/ap/ieee802_11_ht.c
|
|
|
|
+++ b/src/ap/ieee802_11_ht.c
|
2011-04-24 06:34:46 +03:00
|
|
|
@@ -20,9 +20,11 @@
|
|
|
|
#include "drivers/driver.h"
|
|
|
|
#include "hostapd.h"
|
|
|
|
#include "ap_config.h"
|
|
|
|
+#include "ap_drv_ops.h"
|
|
|
|
#include "sta_info.h"
|
|
|
|
#include "beacon.h"
|
|
|
|
#include "ieee802_11.h"
|
|
|
|
+#include "utils/eloop.h"
|
|
|
|
|
|
|
|
|
|
|
|
u8 * hostapd_eid_ht_capabilities(struct hostapd_data *hapd, u8 *eid)
|
|
|
|
@@ -70,12 +72,15 @@ u8 * hostapd_eid_ht_operation(struct hos
|
2011-04-24 00:34:35 +03:00
|
|
|
|
|
|
|
oper->control_chan = hapd->iconf->channel;
|
|
|
|
oper->operation_mode = host_to_le16(hapd->iface->ht_op_mode);
|
|
|
|
- if (hapd->iconf->secondary_channel == 1)
|
|
|
|
- oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE |
|
|
|
|
- HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
|
|
|
|
- if (hapd->iconf->secondary_channel == -1)
|
|
|
|
- oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW |
|
|
|
|
- HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
|
|
|
|
+
|
|
|
|
+ if (!hapd->iface->force_20mhz) {
|
|
|
|
+ if (hapd->iconf->secondary_channel == 1)
|
|
|
|
+ oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE |
|
|
|
|
+ HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
|
|
|
|
+ if (hapd->iconf->secondary_channel == -1)
|
|
|
|
+ oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW |
|
|
|
|
+ HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
pos += sizeof(*oper);
|
|
|
|
|
2011-11-04 03:05:26 +02:00
|
|
|
@@ -271,3 +276,80 @@ void hostapd_get_ht_capab(struct hostapd
|
2011-04-24 00:34:35 +03:00
|
|
|
|
|
|
|
neg_ht_cap->ht_capabilities_info = host_to_le16(cap);
|
|
|
|
}
|
|
|
|
+
|
2011-04-24 06:34:46 +03:00
|
|
|
+static void hostapd_set_force_20mhz(struct hostapd_iface *iface);
|
2011-04-24 00:34:35 +03:00
|
|
|
+
|
2011-04-24 06:34:46 +03:00
|
|
|
+static void hostapd_restore_40mhz(void *eloop_data, void *user_ctx)
|
2011-04-24 00:34:35 +03:00
|
|
|
+{
|
|
|
|
+ struct hostapd_iface *iface = eloop_data;
|
|
|
|
+ struct os_time time;
|
|
|
|
+ int timeout;
|
|
|
|
+
|
|
|
|
+ if (!iface->last_20mhz_trigger.sec)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ os_get_time(&time);
|
|
|
|
+ timeout = iface->last_20mhz_trigger.sec + iface->conf->dynamic_ht40 -
|
|
|
|
+ time.sec;
|
|
|
|
+
|
|
|
|
+ if (timeout > 0) {
|
|
|
|
+ eloop_register_timeout(timeout, 0, hostapd_restore_40mhz,
|
|
|
|
+ iface, NULL);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ iface->last_20mhz_trigger.sec = 0;
|
|
|
|
+ iface->last_20mhz_trigger.usec = 0;
|
|
|
|
+
|
|
|
|
+ iface->force_20mhz = 0;
|
|
|
|
+ hostapd_set_force_20mhz(iface);
|
|
|
|
+}
|
|
|
|
+
|
2011-04-24 06:34:46 +03:00
|
|
|
+static void hostapd_set_force_20mhz(struct hostapd_iface *iface)
|
2011-04-24 00:34:35 +03:00
|
|
|
+{
|
|
|
|
+ int secondary_channel;
|
|
|
|
+ int i;
|
|
|
|
+
|
|
|
|
+ ieee802_11_set_beacons(iface);
|
|
|
|
+
|
|
|
|
+ for (i = 0; i < iface->num_bss; i++) {
|
|
|
|
+ struct hostapd_data *hapd = iface->bss[i];
|
|
|
|
+
|
|
|
|
+ if (iface->force_20mhz)
|
|
|
|
+ secondary_channel = 0;
|
|
|
|
+ else
|
|
|
|
+ secondary_channel = hapd->iconf->secondary_channel;
|
|
|
|
+
|
|
|
|
+ if (hostapd_set_freq(hapd, hapd->iconf->hw_mode, iface->freq,
|
|
|
|
+ hapd->iconf->channel,
|
|
|
|
+ hapd->iconf->ieee80211n,
|
|
|
|
+ secondary_channel)) {
|
|
|
|
+ wpa_printf(MSG_ERROR, "Could not set channel for "
|
|
|
|
+ "kernel driver");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void hostapd_deinit_ht(struct hostapd_iface *iface)
|
|
|
|
+{
|
|
|
|
+ eloop_cancel_timeout(hostapd_restore_40mhz, iface, NULL);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void hostapd_trigger_20mhz(struct hostapd_iface *iface)
|
|
|
|
+{
|
|
|
|
+ if (!iface->conf->dynamic_ht40)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ if (!iface->force_20mhz) {
|
|
|
|
+ iface->force_20mhz = 1;
|
|
|
|
+ hostapd_set_force_20mhz(iface);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!iface->last_20mhz_trigger.sec) {
|
|
|
|
+ eloop_cancel_timeout(hostapd_restore_40mhz, iface, NULL);
|
|
|
|
+ eloop_register_timeout(iface->conf->dynamic_ht40, 0,
|
|
|
|
+ hostapd_restore_40mhz, iface, NULL);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ os_get_time(&iface->last_20mhz_trigger);
|
|
|
|
+}
|