hostapd: update to 2023-06-22
[openwrt/openwrt.git] / package / network / services / hostapd / patches / 600-ubus_support.patch
1 --- a/hostapd/Makefile
2 +++ b/hostapd/Makefile
3 @@ -166,6 +166,11 @@ OBJS += ../src/common/hw_features_common
4
5 OBJS += ../src/eapol_auth/eapol_auth_sm.o
6
7 +ifdef CONFIG_UBUS
8 +CFLAGS += -DUBUS_SUPPORT
9 +OBJS += ../src/ap/ubus.o
10 +LIBS += -lubox -lubus
11 +endif
12
13 ifdef CONFIG_CODE_COVERAGE
14 CFLAGS += -O0 -fprofile-arcs -ftest-coverage
15 --- a/src/ap/hostapd.h
16 +++ b/src/ap/hostapd.h
17 @@ -18,6 +18,7 @@
18 #include "utils/list.h"
19 #include "ap_config.h"
20 #include "drivers/driver.h"
21 +#include "ubus.h"
22
23 #define OCE_STA_CFON_ENABLED(hapd) \
24 ((hapd->conf->oce & OCE_STA_CFON) && \
25 @@ -92,7 +93,7 @@ struct hapd_interfaces {
26 #ifdef CONFIG_CTRL_IFACE_UDP
27 unsigned char ctrl_iface_cookie[CTRL_IFACE_COOKIE_LEN];
28 #endif /* CONFIG_CTRL_IFACE_UDP */
29 -
30 + struct ubus_object ubus;
31 };
32
33 enum hostapd_chan_status {
34 @@ -184,6 +185,7 @@ struct hostapd_data {
35 struct hostapd_iface *iface;
36 struct hostapd_config *iconf;
37 struct hostapd_bss_config *conf;
38 + struct hostapd_ubus_bss ubus;
39 int interface_added; /* virtual interface added for this BSS */
40 unsigned int started:1;
41 unsigned int disabled:1;
42 @@ -695,6 +697,7 @@ hostapd_alloc_bss_data(struct hostapd_if
43 struct hostapd_bss_config *bss);
44 int hostapd_setup_interface(struct hostapd_iface *iface);
45 int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
46 +void hostapd_set_own_neighbor_report(struct hostapd_data *hapd);
47 void hostapd_interface_deinit(struct hostapd_iface *iface);
48 void hostapd_interface_free(struct hostapd_iface *iface);
49 struct hostapd_iface * hostapd_alloc_iface(void);
50 --- a/src/ap/hostapd.c
51 +++ b/src/ap/hostapd.c
52 @@ -455,6 +455,7 @@ void hostapd_free_hapd_data(struct hosta
53 hapd->beacon_set_done = 0;
54
55 wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
56 + hostapd_ubus_free_bss(hapd);
57 accounting_deinit(hapd);
58 hostapd_deinit_wpa(hapd);
59 vlan_deinit(hapd);
60 @@ -1207,6 +1208,8 @@ static int hostapd_start_beacon(struct h
61 if (hapd->driver && hapd->driver->set_operstate)
62 hapd->driver->set_operstate(hapd->drv_priv, 1);
63
64 + hostapd_ubus_add_bss(hapd);
65 +
66 return 0;
67 }
68
69 @@ -2295,6 +2298,7 @@ static int hostapd_setup_interface_compl
70 if (err)
71 goto fail;
72
73 + hostapd_ubus_add_iface(iface);
74 wpa_printf(MSG_DEBUG, "Completing interface initialization");
75 if (iface->freq) {
76 #ifdef NEED_AP_MLME
77 @@ -2514,6 +2518,7 @@ dfs_offload:
78
79 fail:
80 wpa_printf(MSG_ERROR, "Interface initialization failed");
81 + hostapd_ubus_free_iface(iface);
82
83 if (iface->is_no_ir) {
84 hostapd_set_state(iface, HAPD_IFACE_NO_IR);
85 @@ -3004,6 +3009,7 @@ void hostapd_interface_deinit_free(struc
86 (unsigned int) iface->conf->num_bss);
87 driver = iface->bss[0]->driver;
88 drv_priv = iface->bss[0]->drv_priv;
89 + hostapd_ubus_free_iface(iface);
90 hostapd_interface_deinit(iface);
91 wpa_printf(MSG_DEBUG, "%s: driver=%p drv_priv=%p -> hapd_deinit",
92 __func__, driver, drv_priv);
93 --- a/src/ap/ieee802_11.c
94 +++ b/src/ap/ieee802_11.c
95 @@ -2778,7 +2778,7 @@ static void handle_auth(struct hostapd_d
96 u16 auth_alg, auth_transaction, status_code;
97 u16 resp = WLAN_STATUS_SUCCESS;
98 struct sta_info *sta = NULL;
99 - int res, reply_res;
100 + int res, reply_res, ubus_resp;
101 u16 fc;
102 const u8 *challenge = NULL;
103 u8 resp_ies[2 + WLAN_AUTH_CHALLENGE_LEN];
104 @@ -2787,6 +2787,11 @@ static void handle_auth(struct hostapd_d
105 struct radius_sta rad_info;
106 const u8 *dst, *sa, *bssid;
107 bool mld_sta = false;
108 + struct hostapd_ubus_request req = {
109 + .type = HOSTAPD_UBUS_AUTH_REQ,
110 + .mgmt_frame = mgmt,
111 + .ssi_signal = rssi,
112 + };
113
114 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
115 wpa_printf(MSG_INFO, "handle_auth - too short payload (len=%lu)",
116 @@ -2978,6 +2983,13 @@ static void handle_auth(struct hostapd_d
117 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
118 goto fail;
119 }
120 + ubus_resp = hostapd_ubus_handle_event(hapd, &req);
121 + if (ubus_resp) {
122 + wpa_printf(MSG_DEBUG, "Station " MACSTR " rejected by ubus handler.\n",
123 + MAC2STR(mgmt->sa));
124 + resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE;
125 + goto fail;
126 + }
127 if (res == HOSTAPD_ACL_PENDING)
128 return;
129
130 @@ -5141,7 +5153,7 @@ static void handle_assoc(struct hostapd_
131 int resp = WLAN_STATUS_SUCCESS;
132 u16 reply_res = WLAN_STATUS_UNSPECIFIED_FAILURE;
133 const u8 *pos;
134 - int left, i;
135 + int left, i, ubus_resp;
136 struct sta_info *sta;
137 u8 *tmp = NULL;
138 #ifdef CONFIG_FILS
139 @@ -5354,6 +5366,11 @@ static void handle_assoc(struct hostapd_
140 left = res;
141 }
142 #endif /* CONFIG_FILS */
143 + struct hostapd_ubus_request req = {
144 + .type = HOSTAPD_UBUS_ASSOC_REQ,
145 + .mgmt_frame = mgmt,
146 + .ssi_signal = rssi,
147 + };
148
149 /* followed by SSID and Supported rates; and HT capabilities if 802.11n
150 * is used */
151 @@ -5452,6 +5469,13 @@ static void handle_assoc(struct hostapd_
152 }
153 #endif /* CONFIG_FILS */
154
155 + ubus_resp = hostapd_ubus_handle_event(hapd, &req);
156 + if (ubus_resp) {
157 + wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n",
158 + MAC2STR(mgmt->sa));
159 + resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE;
160 + goto fail;
161 + }
162 fail:
163
164 /*
165 @@ -5733,6 +5757,7 @@ static void handle_disassoc(struct hosta
166 (unsigned long) len);
167 return;
168 }
169 + hostapd_ubus_notify(hapd, "disassoc", mgmt->sa);
170
171 sta = ap_get_sta(hapd, mgmt->sa);
172 if (!sta) {
173 @@ -5764,6 +5789,8 @@ static void handle_deauth(struct hostapd
174 /* Clear the PTKSA cache entries for PASN */
175 ptksa_cache_flush(hapd->ptksa, mgmt->sa, WPA_CIPHER_NONE);
176
177 + hostapd_ubus_notify(hapd, "deauth", mgmt->sa);
178 +
179 sta = ap_get_sta(hapd, mgmt->sa);
180 if (!sta) {
181 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Station " MACSTR
182 --- a/src/ap/beacon.c
183 +++ b/src/ap/beacon.c
184 @@ -1036,6 +1036,12 @@ void handle_probe_req(struct hostapd_dat
185 u16 csa_offs[2];
186 size_t csa_offs_len;
187 struct radius_sta rad_info;
188 + struct hostapd_ubus_request req = {
189 + .type = HOSTAPD_UBUS_PROBE_REQ,
190 + .mgmt_frame = mgmt,
191 + .ssi_signal = ssi_signal,
192 + .elems = &elems,
193 + };
194
195 if (hapd->iconf->rssi_ignore_probe_request && ssi_signal &&
196 ssi_signal < hapd->iconf->rssi_ignore_probe_request)
197 @@ -1222,6 +1228,12 @@ void handle_probe_req(struct hostapd_dat
198 }
199 #endif /* CONFIG_P2P */
200
201 + if (hostapd_ubus_handle_event(hapd, &req)) {
202 + wpa_printf(MSG_DEBUG, "Probe request for " MACSTR " rejected by ubus handler.\n",
203 + MAC2STR(mgmt->sa));
204 + return;
205 + }
206 +
207 /* TODO: verify that supp_rates contains at least one matching rate
208 * with AP configuration */
209
210 --- a/src/ap/drv_callbacks.c
211 +++ b/src/ap/drv_callbacks.c
212 @@ -145,6 +145,10 @@ int hostapd_notif_assoc(struct hostapd_d
213 u16 reason = WLAN_REASON_UNSPECIFIED;
214 int status = WLAN_STATUS_SUCCESS;
215 const u8 *p2p_dev_addr = NULL;
216 + struct hostapd_ubus_request req = {
217 + .type = HOSTAPD_UBUS_ASSOC_REQ,
218 + .addr = addr,
219 + };
220
221 if (addr == NULL) {
222 /*
223 @@ -237,6 +241,12 @@ int hostapd_notif_assoc(struct hostapd_d
224 goto fail;
225 }
226
227 + if (hostapd_ubus_handle_event(hapd, &req)) {
228 + wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n",
229 + MAC2STR(req.addr));
230 + goto fail;
231 + }
232 +
233 #ifdef CONFIG_P2P
234 if (elems.p2p) {
235 wpabuf_free(sta->p2p_ie);
236 --- a/src/ap/sta_info.c
237 +++ b/src/ap/sta_info.c
238 @@ -471,6 +471,7 @@ void ap_handle_timer(void *eloop_ctx, vo
239 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
240 HOSTAPD_LEVEL_INFO, "deauthenticated due to "
241 "local deauth request");
242 + hostapd_ubus_notify(hapd, "local-deauth", sta->addr);
243 ap_free_sta(hapd, sta);
244 return;
245 }
246 @@ -626,6 +627,7 @@ skip_poll:
247 mlme_deauthenticate_indication(
248 hapd, sta,
249 WLAN_REASON_PREV_AUTH_NOT_VALID);
250 + hostapd_ubus_notify(hapd, "inactive-deauth", sta->addr);
251 ap_free_sta(hapd, sta);
252 break;
253 }
254 @@ -1344,15 +1346,28 @@ void ap_sta_set_authorized(struct hostap
255 sta->addr, authorized, dev_addr);
256
257 if (authorized) {
258 + static const char * const auth_algs[] = {
259 + [WLAN_AUTH_OPEN] = "open",
260 + [WLAN_AUTH_SHARED_KEY] = "shared",
261 + [WLAN_AUTH_FT] = "ft",
262 + [WLAN_AUTH_SAE] = "sae",
263 + [WLAN_AUTH_FILS_SK] = "fils-sk",
264 + [WLAN_AUTH_FILS_SK_PFS] = "fils-sk-pfs",
265 + [WLAN_AUTH_FILS_PK] = "fils-pk",
266 + [WLAN_AUTH_PASN] = "pasn",
267 + };
268 + const char *auth_alg = NULL;
269 const u8 *dpp_pkhash;
270 const char *keyid;
271 char dpp_pkhash_buf[100];
272 char keyid_buf[100];
273 char ip_addr[100];
274 + char alg_buf[100];
275
276 dpp_pkhash_buf[0] = '\0';
277 keyid_buf[0] = '\0';
278 ip_addr[0] = '\0';
279 + alg_buf[0] = '\0';
280 #ifdef CONFIG_P2P
281 if (wpa_auth_get_ip_addr(sta->wpa_sm, ip_addr_buf) == 0) {
282 os_snprintf(ip_addr, sizeof(ip_addr),
283 @@ -1362,6 +1377,13 @@ void ap_sta_set_authorized(struct hostap
284 }
285 #endif /* CONFIG_P2P */
286
287 + if (sta->auth_alg < ARRAY_SIZE(auth_algs))
288 + auth_alg = auth_algs[sta->auth_alg];
289 +
290 + if (auth_alg)
291 + os_snprintf(alg_buf, sizeof(alg_buf),
292 + " auth_alg=%s", auth_alg);
293 +
294 keyid = ap_sta_wpa_get_keyid(hapd, sta);
295 if (keyid) {
296 os_snprintf(keyid_buf, sizeof(keyid_buf),
297 @@ -1380,17 +1402,19 @@ void ap_sta_set_authorized(struct hostap
298 dpp_pkhash, SHA256_MAC_LEN);
299 }
300
301 - wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED "%s%s%s%s",
302 - buf, ip_addr, keyid_buf, dpp_pkhash_buf);
303 + hostapd_ubus_notify_authorized(hapd, sta, auth_alg);
304 + wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED "%s%s%s%s%s",
305 + buf, ip_addr, keyid_buf, dpp_pkhash_buf, alg_buf);
306
307 if (hapd->msg_ctx_parent &&
308 hapd->msg_ctx_parent != hapd->msg_ctx)
309 wpa_msg_no_global(hapd->msg_ctx_parent, MSG_INFO,
310 - AP_STA_CONNECTED "%s%s%s%s",
311 + AP_STA_CONNECTED "%s%s%s%s%s",
312 buf, ip_addr, keyid_buf,
313 - dpp_pkhash_buf);
314 + dpp_pkhash_buf, alg_buf);
315 } else {
316 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED "%s", buf);
317 + hostapd_ubus_notify(hapd, "disassoc", sta->addr);
318
319 if (hapd->msg_ctx_parent &&
320 hapd->msg_ctx_parent != hapd->msg_ctx)
321 --- a/src/ap/wpa_auth_glue.c
322 +++ b/src/ap/wpa_auth_glue.c
323 @@ -269,6 +269,7 @@ static void hostapd_wpa_auth_psk_failure
324 struct hostapd_data *hapd = ctx;
325 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_POSSIBLE_PSK_MISMATCH MACSTR,
326 MAC2STR(addr));
327 + hostapd_ubus_notify(hapd, "key-mismatch", addr);
328 }
329
330
331 --- a/wpa_supplicant/Makefile
332 +++ b/wpa_supplicant/Makefile
333 @@ -194,6 +194,12 @@ ifdef CONFIG_EAPOL_TEST
334 CFLAGS += -Werror -DEAPOL_TEST
335 endif
336
337 +ifdef CONFIG_UBUS
338 +CFLAGS += -DUBUS_SUPPORT
339 +OBJS += ubus.o
340 +LIBS += -lubox -lubus
341 +endif
342 +
343 ifdef CONFIG_CODE_COVERAGE
344 CFLAGS += -O0 -fprofile-arcs -ftest-coverage
345 LIBS += -lgcov
346 @@ -989,6 +995,9 @@ ifdef CONFIG_CTRL_IFACE_MIB
347 CFLAGS += -DCONFIG_CTRL_IFACE_MIB
348 endif
349 OBJS += ../src/ap/ctrl_iface_ap.o
350 +ifdef CONFIG_UBUS
351 +OBJS += ../src/ap/ubus.o
352 +endif
353 endif
354
355 CFLAGS += -DEAP_SERVER -DEAP_SERVER_IDENTITY
356 --- a/wpa_supplicant/wpa_supplicant.c
357 +++ b/wpa_supplicant/wpa_supplicant.c
358 @@ -7635,6 +7635,8 @@ struct wpa_supplicant * wpa_supplicant_a
359 }
360 #endif /* CONFIG_P2P */
361
362 + wpas_ubus_add_bss(wpa_s);
363 +
364 return wpa_s;
365 }
366
367 @@ -7661,6 +7663,8 @@ int wpa_supplicant_remove_iface(struct w
368 struct wpa_supplicant *parent = wpa_s->parent;
369 #endif /* CONFIG_MESH */
370
371 + wpas_ubus_free_bss(wpa_s);
372 +
373 /* Remove interface from the global list of interfaces */
374 prev = global->ifaces;
375 if (prev == wpa_s) {
376 @@ -8007,8 +8011,12 @@ int wpa_supplicant_run(struct wpa_global
377 eloop_register_signal_terminate(wpa_supplicant_terminate, global);
378 eloop_register_signal_reconfig(wpa_supplicant_reconfig, global);
379
380 + wpas_ubus_add(global);
381 +
382 eloop_run();
383
384 + wpas_ubus_free(global);
385 +
386 return 0;
387 }
388
389 --- a/wpa_supplicant/wpa_supplicant_i.h
390 +++ b/wpa_supplicant/wpa_supplicant_i.h
391 @@ -21,6 +21,7 @@
392 #include "config_ssid.h"
393 #include "wmm_ac.h"
394 #include "pasn/pasn_common.h"
395 +#include "ubus.h"
396
397 extern const char *const wpa_supplicant_version;
398 extern const char *const wpa_supplicant_license;
399 @@ -324,6 +325,8 @@ struct wpa_global {
400 #endif /* CONFIG_WIFI_DISPLAY */
401
402 struct psk_list_entry *add_psk; /* From group formation */
403 +
404 + struct ubus_object ubus_global;
405 };
406
407
408 @@ -655,6 +658,7 @@ struct wpa_supplicant {
409 unsigned char own_addr[ETH_ALEN];
410 unsigned char perm_addr[ETH_ALEN];
411 char ifname[100];
412 + struct wpas_ubus_bss ubus;
413 #ifdef CONFIG_MATCH_IFACE
414 int matched;
415 #endif /* CONFIG_MATCH_IFACE */
416 --- a/wpa_supplicant/wps_supplicant.c
417 +++ b/wpa_supplicant/wps_supplicant.c
418 @@ -33,6 +33,7 @@
419 #include "p2p/p2p.h"
420 #include "p2p_supplicant.h"
421 #include "wps_supplicant.h"
422 +#include "ubus.h"
423
424
425 #ifndef WPS_PIN_SCAN_IGNORE_SEL_REG
426 @@ -402,6 +403,8 @@ static int wpa_supplicant_wps_cred(void
427 wpa_hexdump_key(MSG_DEBUG, "WPS: Received Credential attribute",
428 cred->cred_attr, cred->cred_attr_len);
429
430 + wpas_ubus_notify(wpa_s, cred);
431 +
432 if (wpa_s->conf->wps_cred_processing == 1)
433 return 0;
434
435 --- a/hostapd/main.c
436 +++ b/hostapd/main.c
437 @@ -991,6 +991,7 @@ int main(int argc, char *argv[])
438 }
439
440 hostapd_global_ctrl_iface_init(&interfaces);
441 + hostapd_ubus_add(&interfaces);
442
443 if (hostapd_global_run(&interfaces, daemonize, pid_file)) {
444 wpa_printf(MSG_ERROR, "Failed to start eloop");
445 @@ -1000,6 +1001,7 @@ int main(int argc, char *argv[])
446 ret = 0;
447
448 out:
449 + hostapd_ubus_free(&interfaces);
450 hostapd_global_ctrl_iface_deinit(&interfaces);
451 /* Deinitialize all interfaces */
452 for (i = 0; i < interfaces.count; i++) {
453 --- a/wpa_supplicant/main.c
454 +++ b/wpa_supplicant/main.c
455 @@ -204,7 +204,7 @@ int main(int argc, char *argv[])
456
457 for (;;) {
458 c = getopt(argc, argv,
459 - "b:Bc:C:D:de:f:g:G:hH:i:I:KLMm:No:O:p:P:qsTtuv::W");
460 + "b:Bc:C:D:de:f:g:G:hH:i:I:KLMm:nNo:O:p:P:qsTtuv::W");
461 if (c < 0)
462 break;
463 switch (c) {
464 @@ -272,6 +272,9 @@ int main(int argc, char *argv[])
465 params.conf_p2p_dev = optarg;
466 break;
467 #endif /* CONFIG_P2P */
468 + case 'n':
469 + iface_count = 0;
470 + break;
471 case 'o':
472 params.override_driver = optarg;
473 break;
474 --- a/src/ap/rrm.c
475 +++ b/src/ap/rrm.c
476 @@ -89,6 +89,9 @@ static void hostapd_handle_beacon_report
477 return;
478 wpa_msg(hapd->msg_ctx, MSG_INFO, BEACON_RESP_RX MACSTR " %u %02x %s",
479 MAC2STR(addr), token, rep_mode, report);
480 + if (len < sizeof(struct rrm_measurement_beacon_report))
481 + return;
482 + hostapd_ubus_notify_beacon_report(hapd, addr, token, rep_mode, (struct rrm_measurement_beacon_report*) pos, len);
483 }
484
485
486 @@ -352,6 +355,9 @@ void hostapd_handle_radio_measurement(st
487 mgmt->u.action.u.rrm.action, MAC2STR(mgmt->sa));
488
489 switch (mgmt->u.action.u.rrm.action) {
490 + case WLAN_RRM_LINK_MEASUREMENT_REPORT:
491 + hostapd_ubus_handle_link_measurement(hapd, buf, len);
492 + break;
493 case WLAN_RRM_RADIO_MEASUREMENT_REPORT:
494 hostapd_handle_radio_msmt_report(hapd, buf, len);
495 break;
496 --- a/src/ap/vlan_init.c
497 +++ b/src/ap/vlan_init.c
498 @@ -22,6 +22,7 @@
499 static int vlan_if_add(struct hostapd_data *hapd, struct hostapd_vlan *vlan,
500 int existsok)
501 {
502 + bool vlan_exists = iface_exists(vlan->ifname);
503 int ret;
504 #ifdef CONFIG_WEP
505 int i;
506 @@ -36,7 +37,7 @@ static int vlan_if_add(struct hostapd_da
507 }
508 #endif /* CONFIG_WEP */
509
510 - if (!iface_exists(vlan->ifname))
511 + if (!vlan_exists)
512 ret = hostapd_vlan_if_add(hapd, vlan->ifname);
513 else if (!existsok)
514 return -1;
515 @@ -51,6 +52,9 @@ static int vlan_if_add(struct hostapd_da
516 if (hapd->wpa_auth)
517 ret = wpa_auth_ensure_group(hapd->wpa_auth, vlan->vlan_id);
518
519 + if (!ret && !vlan_exists)
520 + hostapd_ubus_add_vlan(hapd, vlan);
521 +
522 if (ret == 0)
523 return ret;
524
525 @@ -77,6 +81,8 @@ int vlan_if_remove(struct hostapd_data *
526 "WPA deinitialization for VLAN %d failed (%d)",
527 vlan->vlan_id, ret);
528
529 + hostapd_ubus_remove_vlan(hapd, vlan);
530 +
531 return hostapd_vlan_if_remove(hapd, vlan->ifname);
532 }
533
534 --- a/src/ap/dfs.c
535 +++ b/src/ap/dfs.c
536 @@ -1211,6 +1211,8 @@ int hostapd_dfs_pre_cac_expired(struct h
537 "freq=%d ht_enabled=%d chan_offset=%d chan_width=%d cf1=%d cf2=%d",
538 freq, ht_enabled, chan_offset, chan_width, cf1, cf2);
539
540 + hostapd_ubus_notify_radar_detected(iface, freq, chan_width, cf1, cf2);
541 +
542 /* Proceed only if DFS is not offloaded to the driver */
543 if (iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD)
544 return 0;
545 --- a/src/ap/airtime_policy.c
546 +++ b/src/ap/airtime_policy.c
547 @@ -112,8 +112,14 @@ static void set_sta_weights(struct hosta
548 {
549 struct sta_info *sta;
550
551 - for (sta = hapd->sta_list; sta; sta = sta->next)
552 - sta_set_airtime_weight(hapd, sta, weight);
553 + for (sta = hapd->sta_list; sta; sta = sta->next) {
554 + unsigned int sta_weight = weight;
555 +
556 + if (sta->dyn_airtime_weight)
557 + sta_weight = (weight * sta->dyn_airtime_weight) / 256;
558 +
559 + sta_set_airtime_weight(hapd, sta, sta_weight);
560 + }
561 }
562
563
564 @@ -244,7 +250,10 @@ int airtime_policy_new_sta(struct hostap
565 unsigned int weight;
566
567 if (hapd->iconf->airtime_mode == AIRTIME_MODE_STATIC) {
568 - weight = get_weight_for_sta(hapd, sta->addr);
569 + if (sta->dyn_airtime_weight)
570 + weight = sta->dyn_airtime_weight;
571 + else
572 + weight = get_weight_for_sta(hapd, sta->addr);
573 if (weight)
574 return sta_set_airtime_weight(hapd, sta, weight);
575 }
576 --- a/src/ap/sta_info.h
577 +++ b/src/ap/sta_info.h
578 @@ -322,6 +322,7 @@ struct sta_info {
579 #endif /* CONFIG_TESTING_OPTIONS */
580 #ifdef CONFIG_AIRTIME_POLICY
581 unsigned int airtime_weight;
582 + unsigned int dyn_airtime_weight;
583 struct os_reltime backlogged_until;
584 #endif /* CONFIG_AIRTIME_POLICY */
585
586 --- a/src/ap/wnm_ap.c
587 +++ b/src/ap/wnm_ap.c
588 @@ -455,7 +455,8 @@ static void ieee802_11_rx_bss_trans_mgmt
589 MAC2STR(addr), reason, hex ? " neighbor=" : "", hex);
590 os_free(hex);
591
592 - ieee802_11_send_bss_trans_mgmt_request(hapd, addr, dialog_token);
593 + if (!hostapd_ubus_notify_bss_transition_query(hapd, addr, dialog_token, reason, pos, end - pos))
594 + ieee802_11_send_bss_trans_mgmt_request(hapd, addr, dialog_token);
595 }
596
597
598 @@ -477,7 +478,7 @@ static void ieee802_11_rx_bss_trans_mgmt
599 size_t len)
600 {
601 u8 dialog_token, status_code, bss_termination_delay;
602 - const u8 *pos, *end;
603 + const u8 *pos, *end, *target_bssid = NULL;
604 int enabled = hapd->conf->bss_transition;
605 struct sta_info *sta;
606
607 @@ -524,6 +525,7 @@ static void ieee802_11_rx_bss_trans_mgmt
608 wpa_printf(MSG_DEBUG, "WNM: not enough room for Target BSSID field");
609 return;
610 }
611 + target_bssid = pos;
612 sta->agreed_to_steer = 1;
613 eloop_cancel_timeout(ap_sta_reset_steer_flag_timer, hapd, sta);
614 eloop_register_timeout(2, 0, ap_sta_reset_steer_flag_timer,
615 @@ -543,6 +545,10 @@ static void ieee802_11_rx_bss_trans_mgmt
616 MAC2STR(addr), status_code, bss_termination_delay);
617 }
618
619 + hostapd_ubus_notify_bss_transition_response(hapd, sta->addr, dialog_token,
620 + status_code, bss_termination_delay,
621 + target_bssid, pos, end - pos);
622 +
623 wpa_hexdump(MSG_DEBUG, "WNM: BSS Transition Candidate List Entries",
624 pos, end - pos);
625 }