hostapd: bump to 2024-03-09
[openwrt/staging/xback.git] / package / network / services / hostapd / patches / 720-iface_max_num_sta.patch
1 --- a/hostapd/config_file.c
2 +++ b/hostapd/config_file.c
3 @@ -3041,6 +3041,14 @@ static int hostapd_config_fill(struct ho
4 line, bss->max_num_sta, MAX_STA_COUNT);
5 return 1;
6 }
7 + } else if (os_strcmp(buf, "iface_max_num_sta") == 0) {
8 + conf->max_num_sta = atoi(pos);
9 + if (conf->max_num_sta < 0 ||
10 + conf->max_num_sta > MAX_STA_COUNT) {
11 + wpa_printf(MSG_ERROR, "Line %d: Invalid max_num_sta=%d; allowed range 0..%d",
12 + line, conf->max_num_sta, MAX_STA_COUNT);
13 + return 1;
14 + }
15 } else if (os_strcmp(buf, "wpa") == 0) {
16 bss->wpa = atoi(pos);
17 } else if (os_strcmp(buf, "extended_key_id") == 0) {
18 --- a/src/ap/hostapd.h
19 +++ b/src/ap/hostapd.h
20 @@ -754,6 +754,7 @@ void hostapd_cleanup_cs_params(struct ho
21 void hostapd_periodic_iface(struct hostapd_iface *iface);
22 int hostapd_owe_trans_get_info(struct hostapd_data *hapd);
23 void hostapd_ocv_check_csa_sa_query(void *eloop_ctx, void *timeout_ctx);
24 +int hostapd_check_max_sta(struct hostapd_data *hapd);
25
26 void hostapd_switch_color(struct hostapd_data *hapd, u64 bitmap);
27 void hostapd_cleanup_cca_params(struct hostapd_data *hapd);
28 --- a/src/ap/hostapd.c
29 +++ b/src/ap/hostapd.c
30 @@ -247,6 +247,29 @@ static int hostapd_iface_conf_changed(st
31 return 0;
32 }
33
34 +static inline int hostapd_iface_num_sta(struct hostapd_iface *iface)
35 +{
36 + int num_sta = 0;
37 + int i;
38 +
39 + for (i = 0; i < iface->num_bss; i++)
40 + num_sta += iface->bss[i]->num_sta;
41 +
42 + return num_sta;
43 +}
44 +
45 +
46 +int hostapd_check_max_sta(struct hostapd_data *hapd)
47 +{
48 + if (hapd->num_sta >= hapd->conf->max_num_sta)
49 + return 1;
50 +
51 + if (hapd->iconf->max_num_sta &&
52 + hostapd_iface_num_sta(hapd->iface) >= hapd->iconf->max_num_sta)
53 + return 1;
54 +
55 + return 0;
56 +}
57
58 int hostapd_reload_config(struct hostapd_iface *iface)
59 {
60 --- a/src/ap/beacon.c
61 +++ b/src/ap/beacon.c
62 @@ -1567,7 +1567,7 @@ void handle_probe_req(struct hostapd_dat
63 if (hapd->conf->no_probe_resp_if_max_sta &&
64 is_multicast_ether_addr(mgmt->da) &&
65 is_multicast_ether_addr(mgmt->bssid) &&
66 - hapd->num_sta >= hapd->conf->max_num_sta &&
67 + hostapd_check_max_sta(hapd) &&
68 !ap_get_sta(hapd, mgmt->sa)) {
69 wpa_printf(MSG_MSGDUMP, "%s: Ignore Probe Request from " MACSTR
70 " since no room for additional STA",
71 --- a/src/ap/ap_config.h
72 +++ b/src/ap/ap_config.h
73 @@ -1057,6 +1057,8 @@ struct hostapd_config {
74 unsigned int track_sta_max_num;
75 unsigned int track_sta_max_age;
76
77 + int max_num_sta;
78 +
79 char country[3]; /* first two octets: country code as described in
80 * ISO/IEC 3166-1. Third octet:
81 * ' ' (ascii 32): all environments