105 lines
3.4 KiB
Diff
105 lines
3.4 KiB
Diff
From 0682b469685046b6f963c97edf0c72df4e3728b6 Mon Sep 17 00:00:00 2001
|
|
From: OpenEmbedded <oe.patch@oe>
|
|
Date: Thu, 15 Sep 2022 12:35:29 +0000
|
|
|
|
---
|
|
hostapd/config_file.c | 8 ++++++++
|
|
src/ap/ap_config.h | 2 ++
|
|
src/ap/beacon.c | 2 +-
|
|
src/ap/hostapd.c | 24 ++++++++++++++++++++++++
|
|
src/ap/hostapd.h | 1 +
|
|
5 files changed, 36 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/hostapd/config_file.c b/hostapd/config_file.c
|
|
index 24f044ae2..a7b7b91ae 100644
|
|
--- a/hostapd/config_file.c
|
|
+++ b/hostapd/config_file.c
|
|
@@ -2837,6 +2837,14 @@ static int hostapd_config_fill(struct hostapd_config *conf,
|
|
line, bss->max_num_sta, MAX_STA_COUNT);
|
|
return 1;
|
|
}
|
|
+ } else if (os_strcmp(buf, "iface_max_num_sta") == 0) {
|
|
+ conf->max_num_sta = atoi(pos);
|
|
+ if (conf->max_num_sta < 0 ||
|
|
+ conf->max_num_sta > MAX_STA_COUNT) {
|
|
+ wpa_printf(MSG_ERROR, "Line %d: Invalid max_num_sta=%d; allowed range 0..%d",
|
|
+ line, conf->max_num_sta, MAX_STA_COUNT);
|
|
+ return 1;
|
|
+ }
|
|
} else if (os_strcmp(buf, "wpa") == 0) {
|
|
bss->wpa = atoi(pos);
|
|
} else if (os_strcmp(buf, "extended_key_id") == 0) {
|
|
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
|
|
index 6884d30be..5c466d529 100644
|
|
--- a/src/ap/ap_config.h
|
|
+++ b/src/ap/ap_config.h
|
|
@@ -1007,6 +1007,8 @@ struct hostapd_config {
|
|
unsigned int track_sta_max_num;
|
|
unsigned int track_sta_max_age;
|
|
|
|
+ int max_num_sta;
|
|
+
|
|
char country[3]; /* first two octets: country code as described in
|
|
* ISO/IEC 3166-1. Third octet:
|
|
* ' ' (ascii 32): all environments
|
|
diff --git a/src/ap/beacon.c b/src/ap/beacon.c
|
|
index 7c9b589e0..4e02739e5 100644
|
|
--- a/src/ap/beacon.c
|
|
+++ b/src/ap/beacon.c
|
|
@@ -1135,7 +1135,7 @@ void handle_probe_req(struct hostapd_data *hapd,
|
|
if (hapd->conf->no_probe_resp_if_max_sta &&
|
|
is_multicast_ether_addr(mgmt->da) &&
|
|
is_multicast_ether_addr(mgmt->bssid) &&
|
|
- hapd->num_sta >= hapd->conf->max_num_sta &&
|
|
+ hostapd_check_max_sta(hapd) &&
|
|
!ap_get_sta(hapd, mgmt->sa)) {
|
|
wpa_printf(MSG_MSGDUMP, "%s: Ignore Probe Request from " MACSTR
|
|
" since no room for additional STA",
|
|
diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
|
|
index 72ab76e93..377436263 100644
|
|
--- a/src/ap/hostapd.c
|
|
+++ b/src/ap/hostapd.c
|
|
@@ -241,6 +241,30 @@ static int hostapd_iface_conf_changed(struct hostapd_config *newconf,
|
|
}
|
|
|
|
|
|
+static inline int hostapd_iface_num_sta(struct hostapd_iface *iface)
|
|
+{
|
|
+ int num_sta = 0;
|
|
+ int i;
|
|
+
|
|
+ for (i = 0; i < iface->num_bss; i++)
|
|
+ num_sta += iface->bss[i]->num_sta;
|
|
+
|
|
+ return num_sta;
|
|
+}
|
|
+
|
|
+
|
|
+int hostapd_check_max_sta(struct hostapd_data *hapd)
|
|
+{
|
|
+ if (hapd->num_sta >= hapd->conf->max_num_sta)
|
|
+ return 1;
|
|
+
|
|
+ if (hapd->iconf->max_num_sta &&
|
|
+ hostapd_iface_num_sta(hapd->iface) >= hapd->iconf->max_num_sta)
|
|
+ return 1;
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
int hostapd_reload_config(struct hostapd_iface *iface, int reconf)
|
|
{
|
|
struct hapd_interfaces *interfaces = iface->interfaces;
|
|
diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
|
|
index 0c1bca809..0e588ce91 100644
|
|
--- a/src/ap/hostapd.h
|
|
+++ b/src/ap/hostapd.h
|
|
@@ -698,6 +698,7 @@ void hostapd_cleanup_cs_params(struct hostapd_data *hapd);
|
|
void hostapd_periodic_iface(struct hostapd_iface *iface);
|
|
int hostapd_owe_trans_get_info(struct hostapd_data *hapd);
|
|
void hostapd_ocv_check_csa_sa_query(void *eloop_ctx, void *timeout_ctx);
|
|
+int hostapd_check_max_sta(struct hostapd_data *hapd);
|
|
|
|
void hostapd_switch_color(struct hostapd_data *hapd, u64 bitmap);
|
|
void hostapd_cleanup_cca_params(struct hostapd_data *hapd);
|