hostapd: refresh patchset
[openwrt/openwrt.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 @@ -2875,6 +2875,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 @@ -666,6 +666,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 /* utils.c */
27 int hostapd_register_probereq_cb(struct hostapd_data *hapd,
28 --- a/src/ap/hostapd.c
29 +++ b/src/ap/hostapd.c
30 @@ -236,6 +236,30 @@ static int hostapd_iface_conf_changed(st
31 }
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, int reconf)
59 {
60 struct hapd_interfaces *interfaces = iface->interfaces;
61 --- a/src/ap/beacon.c
62 +++ b/src/ap/beacon.c
63 @@ -1039,7 +1039,7 @@ void handle_probe_req(struct hostapd_dat
64 if (hapd->conf->no_probe_resp_if_max_sta &&
65 is_multicast_ether_addr(mgmt->da) &&
66 is_multicast_ether_addr(mgmt->bssid) &&
67 - hapd->num_sta >= hapd->conf->max_num_sta &&
68 + hostapd_check_max_sta(hapd) &&
69 !ap_get_sta(hapd, mgmt->sa)) {
70 wpa_printf(MSG_MSGDUMP, "%s: Ignore Probe Request from " MACSTR
71 " since no room for additional STA",
72 --- a/src/ap/ap_config.h
73 +++ b/src/ap/ap_config.h
74 @@ -976,6 +976,8 @@ struct hostapd_config {
75 unsigned int track_sta_max_num;
76 unsigned int track_sta_max_age;
77
78 + int max_num_sta;
79 +
80 char country[3]; /* first two octets: country code as described in
81 * ISO/IEC 3166-1. Third octet:
82 * ' ' (ascii 32): all environments