521e7df82e2b971dd438cdbc3c4b8df22a5892fd
[openwrt/staging/dedeckeh.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 @@ -673,6 +675,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 @@ -401,6 +401,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 @@ -1431,6 +1432,8 @@ static int hostapd_setup_bss(struct host
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 @@ -2050,6 +2053,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 @@ -2248,6 +2252,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 @@ -2723,6 +2728,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 @@ -3573,13 +3573,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 @@ -3747,6 +3752,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 @@ -5488,7 +5500,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 @@ -5701,6 +5713,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 @@ -5799,6 +5816,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 @@ -5892,6 +5916,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 @@ -5961,6 +5986,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 @@ -919,6 +919,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 @@ -1105,6 +1111,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 @@ -1298,12 +1300,25 @@ 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 char *keyid;
269 char keyid_buf[100];
270 char ip_addr[100];
271 + char alg_buf[100];
272
273 keyid_buf[0] = '\0';
274 ip_addr[0] = '\0';
275 + alg_buf[0] = '\0';
276 #ifdef CONFIG_P2P
277 if (wpa_auth_get_ip_addr(sta->wpa_sm, ip_addr_buf) == 0) {
278 os_snprintf(ip_addr, sizeof(ip_addr),
279 @@ -1313,22 +1328,31 @@ void ap_sta_set_authorized(struct hostap
280 }
281 #endif /* CONFIG_P2P */
282
283 + if (sta->auth_alg < ARRAY_SIZE(auth_algs))
284 + auth_alg = auth_algs[sta->auth_alg];
285 +
286 + if (auth_alg)
287 + os_snprintf(alg_buf, sizeof(alg_buf),
288 + " auth_alg=%s", auth_alg);
289 +
290 keyid = ap_sta_wpa_get_keyid(hapd, sta);
291 if (keyid) {
292 os_snprintf(keyid_buf, sizeof(keyid_buf),
293 " keyid=%s", keyid);
294 }
295
296 - wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED "%s%s%s",
297 - buf, ip_addr, keyid_buf);
298 + hostapd_ubus_notify_authorized(hapd, sta, auth_alg);
299 + wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED "%s%s%s%s",
300 + buf, ip_addr, keyid_buf, alg_buf);
301
302 if (hapd->msg_ctx_parent &&
303 hapd->msg_ctx_parent != hapd->msg_ctx)
304 wpa_msg_no_global(hapd->msg_ctx_parent, MSG_INFO,
305 - AP_STA_CONNECTED "%s%s%s",
306 - buf, ip_addr, keyid_buf);
307 + AP_STA_CONNECTED "%s%s%s%s",
308 + buf, ip_addr, keyid_buf, alg_buf);
309 } else {
310 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED "%s", buf);
311 + hostapd_ubus_notify(hapd, "disassoc", sta->addr);
312
313 if (hapd->msg_ctx_parent &&
314 hapd->msg_ctx_parent != hapd->msg_ctx)
315 --- a/src/ap/wpa_auth_glue.c
316 +++ b/src/ap/wpa_auth_glue.c
317 @@ -268,6 +268,7 @@ static void hostapd_wpa_auth_psk_failure
318 struct hostapd_data *hapd = ctx;
319 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_POSSIBLE_PSK_MISMATCH MACSTR,
320 MAC2STR(addr));
321 + hostapd_ubus_notify(hapd, "key-mismatch", addr);
322 }
323
324
325 --- a/wpa_supplicant/Makefile
326 +++ b/wpa_supplicant/Makefile
327 @@ -183,6 +183,12 @@ ifdef CONFIG_EAPOL_TEST
328 CFLAGS += -Werror -DEAPOL_TEST
329 endif
330
331 +ifdef CONFIG_UBUS
332 +CFLAGS += -DUBUS_SUPPORT
333 +OBJS += ubus.o
334 +LIBS += -lubox -lubus
335 +endif
336 +
337 ifdef CONFIG_CODE_COVERAGE
338 CFLAGS += -O0 -fprofile-arcs -ftest-coverage
339 LIBS += -lgcov
340 @@ -977,6 +983,9 @@ ifdef CONFIG_CTRL_IFACE_MIB
341 CFLAGS += -DCONFIG_CTRL_IFACE_MIB
342 endif
343 OBJS += ../src/ap/ctrl_iface_ap.o
344 +ifdef CONFIG_UBUS
345 +OBJS += ../src/ap/ubus.o
346 +endif
347 endif
348
349 CFLAGS += -DEAP_SERVER -DEAP_SERVER_IDENTITY
350 --- a/wpa_supplicant/wpa_supplicant.c
351 +++ b/wpa_supplicant/wpa_supplicant.c
352 @@ -7285,6 +7285,8 @@ struct wpa_supplicant * wpa_supplicant_a
353 }
354 #endif /* CONFIG_P2P */
355
356 + wpas_ubus_add_bss(wpa_s);
357 +
358 return wpa_s;
359 }
360
361 @@ -7311,6 +7313,8 @@ int wpa_supplicant_remove_iface(struct w
362 struct wpa_supplicant *parent = wpa_s->parent;
363 #endif /* CONFIG_MESH */
364
365 + wpas_ubus_free_bss(wpa_s);
366 +
367 /* Remove interface from the global list of interfaces */
368 prev = global->ifaces;
369 if (prev == wpa_s) {
370 @@ -7614,8 +7618,12 @@ int wpa_supplicant_run(struct wpa_global
371 eloop_register_signal_terminate(wpa_supplicant_terminate, global);
372 eloop_register_signal_reconfig(wpa_supplicant_reconfig, global);
373
374 + wpas_ubus_add(global);
375 +
376 eloop_run();
377
378 + wpas_ubus_free(global);
379 +
380 return 0;
381 }
382
383 --- a/wpa_supplicant/wpa_supplicant_i.h
384 +++ b/wpa_supplicant/wpa_supplicant_i.h
385 @@ -20,6 +20,7 @@
386 #include "wps/wps_defs.h"
387 #include "config_ssid.h"
388 #include "wmm_ac.h"
389 +#include "ubus.h"
390
391 extern const char *const wpa_supplicant_version;
392 extern const char *const wpa_supplicant_license;
393 @@ -323,6 +324,8 @@ struct wpa_global {
394 #endif /* CONFIG_WIFI_DISPLAY */
395
396 struct psk_list_entry *add_psk; /* From group formation */
397 +
398 + struct ubus_object ubus_global;
399 };
400
401
402 @@ -707,6 +710,7 @@ struct wpa_supplicant {
403 unsigned char own_addr[ETH_ALEN];
404 unsigned char perm_addr[ETH_ALEN];
405 char ifname[100];
406 + struct wpas_ubus_bss ubus;
407 #ifdef CONFIG_MATCH_IFACE
408 int matched;
409 #endif /* CONFIG_MATCH_IFACE */
410 --- a/wpa_supplicant/wps_supplicant.c
411 +++ b/wpa_supplicant/wps_supplicant.c
412 @@ -33,6 +33,7 @@
413 #include "p2p/p2p.h"
414 #include "p2p_supplicant.h"
415 #include "wps_supplicant.h"
416 +#include "ubus.h"
417
418
419 #ifndef WPS_PIN_SCAN_IGNORE_SEL_REG
420 @@ -391,6 +392,8 @@ static int wpa_supplicant_wps_cred(void
421 wpa_hexdump_key(MSG_DEBUG, "WPS: Received Credential attribute",
422 cred->cred_attr, cred->cred_attr_len);
423
424 + wpas_ubus_notify(wpa_s, cred);
425 +
426 if (wpa_s->conf->wps_cred_processing == 1)
427 return 0;
428
429 --- a/hostapd/main.c
430 +++ b/hostapd/main.c
431 @@ -897,6 +897,7 @@ int main(int argc, char *argv[])
432 }
433
434 hostapd_global_ctrl_iface_init(&interfaces);
435 + hostapd_ubus_add(&interfaces);
436
437 if (hostapd_global_run(&interfaces, daemonize, pid_file)) {
438 wpa_printf(MSG_ERROR, "Failed to start eloop");
439 @@ -906,6 +907,7 @@ int main(int argc, char *argv[])
440 ret = 0;
441
442 out:
443 + hostapd_ubus_free(&interfaces);
444 hostapd_global_ctrl_iface_deinit(&interfaces);
445 /* Deinitialize all interfaces */
446 for (i = 0; i < interfaces.count; i++) {
447 --- a/wpa_supplicant/main.c
448 +++ b/wpa_supplicant/main.c
449 @@ -204,7 +204,7 @@ int main(int argc, char *argv[])
450
451 for (;;) {
452 c = getopt(argc, argv,
453 - "b:Bc:C:D:de:f:g:G:hH:i:I:KLMm:No:O:p:P:qsTtuv::W");
454 + "b:Bc:C:D:de:f:g:G:hH:i:I:KLMm:nNo:O:p:P:qsTtuv::W");
455 if (c < 0)
456 break;
457 switch (c) {
458 @@ -272,6 +272,9 @@ int main(int argc, char *argv[])
459 params.conf_p2p_dev = optarg;
460 break;
461 #endif /* CONFIG_P2P */
462 + case 'n':
463 + iface_count = 0;
464 + break;
465 case 'o':
466 params.override_driver = optarg;
467 break;
468 --- a/src/ap/rrm.c
469 +++ b/src/ap/rrm.c
470 @@ -89,6 +89,9 @@ static void hostapd_handle_beacon_report
471 return;
472 wpa_msg(hapd->msg_ctx, MSG_INFO, BEACON_RESP_RX MACSTR " %u %02x %s",
473 MAC2STR(addr), token, rep_mode, report);
474 + if (len < sizeof(struct rrm_measurement_beacon_report))
475 + return;
476 + hostapd_ubus_notify_beacon_report(hapd, addr, token, rep_mode, (struct rrm_measurement_beacon_report*) pos, len);
477 }
478
479
480 @@ -352,6 +355,9 @@ void hostapd_handle_radio_measurement(st
481 mgmt->u.action.u.rrm.action, MAC2STR(mgmt->sa));
482
483 switch (mgmt->u.action.u.rrm.action) {
484 + case WLAN_RRM_LINK_MEASUREMENT_REPORT:
485 + hostapd_ubus_handle_link_measurement(hapd, buf, len);
486 + break;
487 case WLAN_RRM_RADIO_MEASUREMENT_REPORT:
488 hostapd_handle_radio_msmt_report(hapd, buf, len);
489 break;
490 --- a/src/ap/vlan_init.c
491 +++ b/src/ap/vlan_init.c
492 @@ -22,6 +22,7 @@
493 static int vlan_if_add(struct hostapd_data *hapd, struct hostapd_vlan *vlan,
494 int existsok)
495 {
496 + bool vlan_exists = iface_exists(vlan->ifname);
497 int ret;
498 #ifdef CONFIG_WEP
499 int i;
500 @@ -36,7 +37,7 @@ static int vlan_if_add(struct hostapd_da
501 }
502 #endif /* CONFIG_WEP */
503
504 - if (!iface_exists(vlan->ifname))
505 + if (!vlan_exists)
506 ret = hostapd_vlan_if_add(hapd, vlan->ifname);
507 else if (!existsok)
508 return -1;
509 @@ -51,6 +52,9 @@ static int vlan_if_add(struct hostapd_da
510 if (hapd->wpa_auth)
511 ret = wpa_auth_ensure_group(hapd->wpa_auth, vlan->vlan_id);
512
513 + if (!ret && !vlan_exists)
514 + hostapd_ubus_add_vlan(hapd, vlan);
515 +
516 if (ret == 0)
517 return ret;
518
519 @@ -77,6 +81,8 @@ int vlan_if_remove(struct hostapd_data *
520 "WPA deinitialization for VLAN %d failed (%d)",
521 vlan->vlan_id, ret);
522
523 + hostapd_ubus_remove_vlan(hapd, vlan);
524 +
525 return hostapd_vlan_if_remove(hapd, vlan->ifname);
526 }
527
528 --- a/src/ap/dfs.c
529 +++ b/src/ap/dfs.c
530 @@ -1203,6 +1203,8 @@ int hostapd_dfs_pre_cac_expired(struct h
531 "freq=%d ht_enabled=%d chan_offset=%d chan_width=%d cf1=%d cf2=%d",
532 freq, ht_enabled, chan_offset, chan_width, cf1, cf2);
533
534 + hostapd_ubus_notify_radar_detected(iface, freq, chan_width, cf1, cf2);
535 +
536 /* Proceed only if DFS is not offloaded to the driver */
537 if (iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD)
538 return 0;
539 --- a/src/ap/airtime_policy.c
540 +++ b/src/ap/airtime_policy.c
541 @@ -112,8 +112,14 @@ static void set_sta_weights(struct hosta
542 {
543 struct sta_info *sta;
544
545 - for (sta = hapd->sta_list; sta; sta = sta->next)
546 - sta_set_airtime_weight(hapd, sta, weight);
547 + for (sta = hapd->sta_list; sta; sta = sta->next) {
548 + unsigned int sta_weight = weight;
549 +
550 + if (sta->dyn_airtime_weight)
551 + sta_weight = (weight * sta->dyn_airtime_weight) / 256;
552 +
553 + sta_set_airtime_weight(hapd, sta, sta_weight);
554 + }
555 }
556
557
558 @@ -244,7 +250,10 @@ int airtime_policy_new_sta(struct hostap
559 unsigned int weight;
560
561 if (hapd->iconf->airtime_mode == AIRTIME_MODE_STATIC) {
562 - weight = get_weight_for_sta(hapd, sta->addr);
563 + if (sta->dyn_airtime_weight)
564 + weight = sta->dyn_airtime_weight;
565 + else
566 + weight = get_weight_for_sta(hapd, sta->addr);
567 if (weight)
568 return sta_set_airtime_weight(hapd, sta, weight);
569 }
570 --- a/src/ap/sta_info.h
571 +++ b/src/ap/sta_info.h
572 @@ -328,6 +328,7 @@ struct sta_info {
573 #endif /* CONFIG_TESTING_OPTIONS */
574 #ifdef CONFIG_AIRTIME_POLICY
575 unsigned int airtime_weight;
576 + unsigned int dyn_airtime_weight;
577 struct os_reltime backlogged_until;
578 #endif /* CONFIG_AIRTIME_POLICY */
579
580 --- a/src/ap/wnm_ap.c
581 +++ b/src/ap/wnm_ap.c
582 @@ -455,7 +455,8 @@ static void ieee802_11_rx_bss_trans_mgmt
583 MAC2STR(addr), reason, hex ? " neighbor=" : "", hex);
584 os_free(hex);
585
586 - ieee802_11_send_bss_trans_mgmt_request(hapd, addr, dialog_token);
587 + if (!hostapd_ubus_notify_bss_transition_query(hapd, addr, dialog_token, reason, pos, end - pos))
588 + ieee802_11_send_bss_trans_mgmt_request(hapd, addr, dialog_token);
589 }
590
591
592 @@ -477,7 +478,7 @@ static void ieee802_11_rx_bss_trans_mgmt
593 size_t len)
594 {
595 u8 dialog_token, status_code, bss_termination_delay;
596 - const u8 *pos, *end;
597 + const u8 *pos, *end, *target_bssid = NULL;
598 int enabled = hapd->conf->bss_transition;
599 struct sta_info *sta;
600
601 @@ -524,6 +525,7 @@ static void ieee802_11_rx_bss_trans_mgmt
602 wpa_printf(MSG_DEBUG, "WNM: not enough room for Target BSSID field");
603 return;
604 }
605 + target_bssid = pos;
606 sta->agreed_to_steer = 1;
607 eloop_cancel_timeout(ap_sta_reset_steer_flag_timer, hapd, sta);
608 eloop_register_timeout(2, 0, ap_sta_reset_steer_flag_timer,
609 @@ -543,6 +545,10 @@ static void ieee802_11_rx_bss_trans_mgmt
610 MAC2STR(addr), status_code, bss_termination_delay);
611 }
612
613 + hostapd_ubus_notify_bss_transition_response(hapd, sta->addr, dialog_token,
614 + status_code, bss_termination_delay,
615 + target_bssid, pos, end - pos);
616 +
617 wpa_hexdump(MSG_DEBUG, "WNM: BSS Transition Candidate List Entries",
618 pos, end - pos);
619 }