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