3 @@ -157,6 +157,11 @@ OBJS += ../src/common/hw_features_common
5 OBJS += ../src/eapol_auth/eapol_auth_sm.o
8 +CFLAGS += -DUBUS_SUPPORT
9 +OBJS += ../src/ap/ubus.o
10 +LIBS += -lubox -lubus
13 ifdef CONFIG_CODE_COVERAGE
14 CFLAGS += -O0 -fprofile-arcs -ftest-coverage
15 --- a/src/ap/hostapd.h
16 +++ b/src/ap/hostapd.h
18 #include "utils/list.h"
19 #include "ap_config.h"
20 #include "drivers/driver.h"
24 struct radius_server_data;
25 @@ -118,6 +119,7 @@ struct hostapd_data {
26 struct hostapd_iface *iface;
27 struct hostapd_config *iconf;
28 struct hostapd_bss_config *conf;
29 + struct hostapd_ubus_bss ubus;
30 int interface_added; /* virtual interface added for this BSS */
31 unsigned int started:1;
32 unsigned int disabled:1;
33 @@ -323,6 +325,8 @@ struct hostapd_iface {
34 struct hostapd_config *conf;
35 char phy[16]; /* Name of the PHY (radio) */
37 + struct hostapd_ubus_iface ubus;
39 enum hostapd_iface_state {
40 HAPD_IFACE_UNINITIALIZED,
46 + * hostapd / ubus support
47 + * Copyright (c) 2013, Felix Fietkau <nbd@nbd.name>
49 + * This software may be distributed under the terms of the BSD license.
50 + * See README for more details.
53 +#include "utils/includes.h"
54 +#include "utils/common.h"
55 +#include "utils/eloop.h"
56 +#include "common/ieee802_11_defs.h"
58 +#include "wps_hostapd.h"
59 +#include "sta_info.h"
61 +#include "ap_drv_ops.h"
64 +static struct ubus_context *ctx;
65 +static struct blob_buf b;
68 +static inline struct hostapd_data *get_hapd_from_object(struct ubus_object *obj)
70 + return container_of(obj, struct hostapd_data, ubus.obj);
74 +struct ubus_banned_client {
75 + struct avl_node avl;
79 +static void ubus_receive(int sock, void *eloop_ctx, void *sock_ctx)
81 + struct ubus_context *ctx = eloop_ctx;
82 + ubus_handle_event(ctx);
85 +static void ubus_reconnect_timeout(void *eloop_data, void *user_ctx)
87 + if (ubus_reconnect(ctx, NULL)) {
88 + eloop_register_timeout(1, 0, ubus_reconnect_timeout, ctx, NULL);
92 + eloop_register_read_sock(ctx->sock.fd, ubus_receive, ctx, NULL);
95 +static void hostapd_ubus_connection_lost(struct ubus_context *ctx)
97 + eloop_unregister_read_sock(ctx->sock.fd);
98 + eloop_register_timeout(1, 0, ubus_reconnect_timeout, ctx, NULL);
101 +static bool hostapd_ubus_init(void)
106 + ctx = ubus_connect(NULL);
110 + ctx->connection_lost = hostapd_ubus_connection_lost;
111 + eloop_register_read_sock(ctx->sock.fd, ubus_receive, ctx, NULL);
115 +static void hostapd_ubus_ref_inc(void)
120 +static void hostapd_ubus_ref_dec(void)
129 + eloop_unregister_read_sock(ctx->sock.fd);
134 +void hostapd_ubus_add_iface(struct hostapd_iface *iface)
136 + if (!hostapd_ubus_init())
140 +void hostapd_ubus_free_iface(struct hostapd_iface *iface)
147 +hostapd_bss_del_ban(void *eloop_data, void *user_ctx)
149 + struct ubus_banned_client *ban = eloop_data;
150 + struct hostapd_data *hapd = user_ctx;
152 + avl_delete(&hapd->ubus.banned, &ban->avl);
157 +hostapd_bss_ban_client(struct hostapd_data *hapd, u8 *addr, int time)
159 + struct ubus_banned_client *ban;
164 + ban = avl_find_element(&hapd->ubus.banned, addr, ban, avl);
169 + ban = os_zalloc(sizeof(*ban));
170 + memcpy(ban->addr, addr, sizeof(ban->addr));
171 + ban->avl.key = ban->addr;
172 + avl_insert(&hapd->ubus.banned, &ban->avl);
174 + eloop_cancel_timeout(hostapd_bss_del_ban, ban, hapd);
176 + hostapd_bss_del_ban(ban, hapd);
181 + eloop_register_timeout(0, time * 1000, hostapd_bss_del_ban, ban, hapd);
185 +hostapd_bss_get_clients(struct ubus_context *ctx, struct ubus_object *obj,
186 + struct ubus_request_data *req, const char *method,
187 + struct blob_attr *msg)
189 + struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj);
190 + struct sta_info *sta;
193 + static const struct {
197 + { "auth", WLAN_STA_AUTH },
198 + { "assoc", WLAN_STA_ASSOC },
199 + { "authorized", WLAN_STA_AUTHORIZED },
200 + { "preauth", WLAN_STA_PREAUTH },
201 + { "wds", WLAN_STA_WDS },
202 + { "wmm", WLAN_STA_WMM },
203 + { "ht", WLAN_STA_HT },
204 + { "vht", WLAN_STA_VHT },
205 + { "wps", WLAN_STA_WPS },
206 + { "mfp", WLAN_STA_MFP },
209 + blob_buf_init(&b, 0);
210 + blobmsg_add_u32(&b, "freq", hapd->iface->freq);
211 + list = blobmsg_open_table(&b, "clients");
212 + for (sta = hapd->sta_list; sta; sta = sta->next) {
215 + sprintf(mac_buf, MACSTR, MAC2STR(sta->addr));
216 + c = blobmsg_open_table(&b, mac_buf);
217 + for (i = 0; i < ARRAY_SIZE(sta_flags); i++)
218 + blobmsg_add_u8(&b, sta_flags[i].name,
219 + !!(sta->flags & sta_flags[i].flag));
220 + blobmsg_add_u32(&b, "aid", sta->aid);
221 + blobmsg_close_table(&b, c);
223 + blobmsg_close_array(&b, list);
224 + ubus_send_reply(ctx, req, b.head);
233 + DEL_CLIENT_BAN_TIME,
237 +static const struct blobmsg_policy del_policy[__DEL_CLIENT_MAX] = {
238 + [DEL_CLIENT_ADDR] = { "addr", BLOBMSG_TYPE_STRING },
239 + [DEL_CLIENT_REASON] = { "reason", BLOBMSG_TYPE_INT32 },
240 + [DEL_CLIENT_DEAUTH] = { "deauth", BLOBMSG_TYPE_INT8 },
241 + [DEL_CLIENT_BAN_TIME] = { "ban_time", BLOBMSG_TYPE_INT32 },
245 +hostapd_bss_del_client(struct ubus_context *ctx, struct ubus_object *obj,
246 + struct ubus_request_data *req, const char *method,
247 + struct blob_attr *msg)
249 + struct blob_attr *tb[__DEL_CLIENT_MAX];
250 + struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj);
251 + struct sta_info *sta;
252 + bool deauth = false;
256 + blobmsg_parse(del_policy, __DEL_CLIENT_MAX, tb, blob_data(msg), blob_len(msg));
258 + if (!tb[DEL_CLIENT_ADDR])
259 + return UBUS_STATUS_INVALID_ARGUMENT;
261 + if (hwaddr_aton(blobmsg_data(tb[DEL_CLIENT_ADDR]), addr))
262 + return UBUS_STATUS_INVALID_ARGUMENT;
264 + if (tb[DEL_CLIENT_REASON])
265 + reason = blobmsg_get_u32(tb[DEL_CLIENT_REASON]);
267 + if (tb[DEL_CLIENT_DEAUTH])
268 + deauth = blobmsg_get_bool(tb[DEL_CLIENT_DEAUTH]);
270 + sta = ap_get_sta(hapd, addr);
273 + hostapd_drv_sta_deauth(hapd, addr, reason);
274 + ap_sta_deauthenticate(hapd, sta, reason);
276 + hostapd_drv_sta_disassoc(hapd, addr, reason);
277 + ap_sta_disassociate(hapd, sta, reason);
281 + if (tb[DEL_CLIENT_BAN_TIME])
282 + hostapd_bss_ban_client(hapd, addr, blobmsg_get_u32(tb[DEL_CLIENT_BAN_TIME]));
288 +blobmsg_add_macaddr(struct blob_buf *buf, const char *name, const u8 *addr)
292 + s = blobmsg_alloc_string_buffer(buf, name, 20);
293 + sprintf(s, MACSTR, MAC2STR(addr));
294 + blobmsg_add_string_buffer(buf);
298 +hostapd_bss_list_bans(struct ubus_context *ctx, struct ubus_object *obj,
299 + struct ubus_request_data *req, const char *method,
300 + struct blob_attr *msg)
302 + struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj);
303 + struct ubus_banned_client *ban;
306 + blob_buf_init(&b, 0);
307 + c = blobmsg_open_array(&b, "clients");
308 + avl_for_each_element(&hapd->ubus.banned, ban, avl)
309 + blobmsg_add_macaddr(&b, NULL, ban->addr);
310 + blobmsg_close_array(&b, c);
311 + ubus_send_reply(ctx, req, b.head);
317 +hostapd_bss_wps_start(struct ubus_context *ctx, struct ubus_object *obj,
318 + struct ubus_request_data *req, const char *method,
319 + struct blob_attr *msg)
322 + struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj);
324 + rc = hostapd_wps_button_pushed(hapd, NULL);
327 + return UBUS_STATUS_NOT_SUPPORTED;
333 +hostapd_bss_wps_cancel(struct ubus_context *ctx, struct ubus_object *obj,
334 + struct ubus_request_data *req, const char *method,
335 + struct blob_attr *msg)
338 + struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj);
340 + rc = hostapd_wps_cancel(hapd);
343 + return UBUS_STATUS_NOT_SUPPORTED;
349 +hostapd_bss_update_beacon(struct ubus_context *ctx, struct ubus_object *obj,
350 + struct ubus_request_data *req, const char *method,
351 + struct blob_attr *msg)
354 + struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj);
356 + rc = ieee802_11_set_beacon(hapd);
359 + return UBUS_STATUS_NOT_SUPPORTED;
370 +static const struct blobmsg_policy csa_policy[__CSA_MAX] = {
372 + * for now, frequency and beacon count are enough, add more
373 + * parameters on demand
375 + [CSA_FREQ] = { "freq", BLOBMSG_TYPE_INT32 },
376 + [CSA_BCN_COUNT] = { "bcn_count", BLOBMSG_TYPE_INT32 },
381 +hostapd_switch_chan(struct ubus_context *ctx, struct ubus_object *obj,
382 + struct ubus_request_data *req, const char *method,
383 + struct blob_attr *msg)
385 + struct blob_attr *tb[__CSA_MAX];
386 + struct hostapd_data *hapd = get_hapd_from_object(obj);
387 + struct csa_settings css;
389 + blobmsg_parse(csa_policy, __CSA_MAX, tb, blob_data(msg), blob_len(msg));
392 + return UBUS_STATUS_INVALID_ARGUMENT;
394 + memset(&css, 0, sizeof(css));
395 + css.freq_params.freq = blobmsg_get_u32(tb[CSA_FREQ]);
396 + if (tb[CSA_BCN_COUNT])
397 + css.cs_count = blobmsg_get_u32(tb[CSA_BCN_COUNT]);
399 + if (hostapd_switch_channel(hapd, &css) != 0)
400 + return UBUS_STATUS_NOT_SUPPORTED;
401 + return UBUS_STATUS_OK;
407 + __VENDOR_ELEMENTS_MAX
410 +static const struct blobmsg_policy ve_policy[__VENDOR_ELEMENTS_MAX] = {
411 + /* vendor elements are provided as hex-string */
412 + [VENDOR_ELEMENTS] = { "vendor_elements", BLOBMSG_TYPE_STRING },
416 +hostapd_vendor_elements(struct ubus_context *ctx, struct ubus_object *obj,
417 + struct ubus_request_data *req, const char *method,
418 + struct blob_attr *msg)
420 + struct blob_attr *tb[__VENDOR_ELEMENTS_MAX];
421 + struct hostapd_data *hapd = get_hapd_from_object(obj);
422 + struct hostapd_bss_config *bss = hapd->conf;
423 + struct wpabuf *elems;
427 + blobmsg_parse(ve_policy, __VENDOR_ELEMENTS_MAX, tb,
428 + blob_data(msg), blob_len(msg));
430 + if (!tb[VENDOR_ELEMENTS])
431 + return UBUS_STATUS_INVALID_ARGUMENT;
433 + pos = blobmsg_data(tb[VENDOR_ELEMENTS]);
434 + len = os_strlen(pos);
436 + return UBUS_STATUS_INVALID_ARGUMENT;
440 + wpabuf_free(bss->vendor_elements);
441 + bss->vendor_elements = NULL;
445 + elems = wpabuf_alloc(len);
449 + if (hexstr2bin(pos, wpabuf_put(elems, len), len)) {
450 + wpabuf_free(elems);
451 + return UBUS_STATUS_INVALID_ARGUMENT;
454 + wpabuf_free(bss->vendor_elements);
455 + bss->vendor_elements = elems;
457 + /* update beacons if vendor elements were set successfully */
458 + if (ieee802_11_update_beacons(hapd->iface) != 0)
459 + return UBUS_STATUS_NOT_SUPPORTED;
460 + return UBUS_STATUS_OK;
463 +static const struct ubus_method bss_methods[] = {
464 + UBUS_METHOD_NOARG("get_clients", hostapd_bss_get_clients),
465 + UBUS_METHOD("del_client", hostapd_bss_del_client, del_policy),
466 + UBUS_METHOD_NOARG("list_bans", hostapd_bss_list_bans),
467 + UBUS_METHOD_NOARG("wps_start", hostapd_bss_wps_start),
468 + UBUS_METHOD_NOARG("wps_cancel", hostapd_bss_wps_cancel),
469 + UBUS_METHOD_NOARG("update_beacon", hostapd_bss_update_beacon),
471 + UBUS_METHOD("switch_chan", hostapd_switch_chan, csa_policy),
473 + UBUS_METHOD("set_vendor_elements", hostapd_vendor_elements, ve_policy),
476 +static struct ubus_object_type bss_object_type =
477 + UBUS_OBJECT_TYPE("hostapd_bss", bss_methods);
479 +static int avl_compare_macaddr(const void *k1, const void *k2, void *ptr)
481 + return memcmp(k1, k2, ETH_ALEN);
484 +void hostapd_ubus_add_bss(struct hostapd_data *hapd)
486 + struct ubus_object *obj = &hapd->ubus.obj;
490 + if (!hostapd_ubus_init())
493 + if (asprintf(&name, "hostapd.%s", hapd->conf->iface) < 0)
496 + avl_init(&hapd->ubus.banned, avl_compare_macaddr, false, NULL);
498 + obj->type = &bss_object_type;
499 + obj->methods = bss_object_type.methods;
500 + obj->n_methods = bss_object_type.n_methods;
501 + ret = ubus_add_object(ctx, obj);
502 + hostapd_ubus_ref_inc();
505 +void hostapd_ubus_free_bss(struct hostapd_data *hapd)
507 + struct ubus_object *obj = &hapd->ubus.obj;
508 + char *name = (char *) obj->name;
514 + ubus_remove_object(ctx, obj);
515 + hostapd_ubus_ref_dec();
521 +struct ubus_event_req {
522 + struct ubus_notify_request nreq;
527 +ubus_event_cb(struct ubus_notify_request *req, int idx, int ret)
529 + struct ubus_event_req *ureq = container_of(req, struct ubus_event_req, nreq);
535 +int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req)
537 + struct ubus_banned_client *ban;
538 + const char *types[HOSTAPD_UBUS_TYPE_MAX] = {
539 + [HOSTAPD_UBUS_PROBE_REQ] = "probe",
540 + [HOSTAPD_UBUS_AUTH_REQ] = "auth",
541 + [HOSTAPD_UBUS_ASSOC_REQ] = "assoc",
543 + const char *type = "mgmt";
544 + struct ubus_event_req ureq = {};
547 + if (req->mgmt_frame)
548 + addr = req->mgmt_frame->sa;
552 + ban = avl_find_element(&hapd->ubus.banned, addr, ban, avl);
556 + if (!hapd->ubus.obj.has_subscribers)
559 + if (req->type < ARRAY_SIZE(types))
560 + type = types[req->type];
562 + blob_buf_init(&b, 0);
563 + blobmsg_add_macaddr(&b, "address", addr);
564 + if (req->mgmt_frame)
565 + blobmsg_add_macaddr(&b, "target", req->mgmt_frame->da);
566 + if (req->frame_info)
567 + blobmsg_add_u32(&b, "signal", req->frame_info->ssi_signal);
568 + blobmsg_add_u32(&b, "freq", hapd->iface->freq);
570 + if (ubus_notify_async(ctx, &hapd->ubus.obj, type, b.head, &ureq.nreq))
573 + ureq.nreq.status_cb = ubus_event_cb;
574 + ubus_complete_request(ctx, &ureq.nreq.req, 100);
585 + * hostapd / ubus support
586 + * Copyright (c) 2013, Felix Fietkau <nbd@nbd.name>
588 + * This software may be distributed under the terms of the BSD license.
589 + * See README for more details.
591 +#ifndef __HOSTAPD_UBUS_H
592 +#define __HOSTAPD_UBUS_H
594 +enum hostapd_ubus_event_type {
595 + HOSTAPD_UBUS_PROBE_REQ,
596 + HOSTAPD_UBUS_AUTH_REQ,
597 + HOSTAPD_UBUS_ASSOC_REQ,
598 + HOSTAPD_UBUS_TYPE_MAX
601 +struct hostapd_ubus_request {
602 + enum hostapd_ubus_event_type type;
603 + const struct ieee80211_mgmt *mgmt_frame;
604 + const struct hostapd_frame_info *frame_info;
608 +struct hostapd_iface;
609 +struct hostapd_data;
613 +#include <libubox/avl.h>
614 +#include <libubus.h>
616 +struct hostapd_ubus_iface {
617 + struct ubus_object obj;
620 +struct hostapd_ubus_bss {
621 + struct ubus_object obj;
622 + struct avl_tree banned;
625 +void hostapd_ubus_add_iface(struct hostapd_iface *iface);
626 +void hostapd_ubus_free_iface(struct hostapd_iface *iface);
627 +void hostapd_ubus_add_bss(struct hostapd_data *hapd);
628 +void hostapd_ubus_free_bss(struct hostapd_data *hapd);
630 +int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req);
634 +struct hostapd_ubus_iface {};
636 +struct hostapd_ubus_bss {};
638 +static inline void hostapd_ubus_add_iface(struct hostapd_iface *iface)
642 +static inline void hostapd_ubus_free_iface(struct hostapd_iface *iface)
646 +static inline void hostapd_ubus_add_bss(struct hostapd_data *hapd)
650 +static inline void hostapd_ubus_free_bss(struct hostapd_data *hapd)
654 +static inline int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req)
662 --- a/src/ap/hostapd.c
663 +++ b/src/ap/hostapd.c
664 @@ -284,6 +284,7 @@ static void hostapd_free_hapd_data(struc
667 wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
668 + hostapd_ubus_free_bss(hapd);
669 iapp_deinit(hapd->iapp);
671 accounting_deinit(hapd);
672 @@ -1139,6 +1140,8 @@ static int hostapd_setup_bss(struct host
673 if (hapd->driver && hapd->driver->set_operstate)
674 hapd->driver->set_operstate(hapd->drv_priv, 1);
676 + hostapd_ubus_add_bss(hapd);
681 @@ -1664,6 +1667,7 @@ static int hostapd_setup_interface_compl
685 + hostapd_ubus_add_iface(iface);
686 wpa_printf(MSG_DEBUG, "Completing interface initialization");
687 if (iface->conf->channel) {
689 @@ -1844,6 +1848,7 @@ dfs_offload:
692 wpa_printf(MSG_ERROR, "Interface initialization failed");
693 + hostapd_ubus_free_iface(iface);
694 hostapd_set_state(iface, HAPD_IFACE_DISABLED);
695 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED);
697 @@ -2277,6 +2282,7 @@ void hostapd_interface_deinit_free(struc
698 (unsigned int) iface->conf->num_bss);
699 driver = iface->bss[0]->driver;
700 drv_priv = iface->bss[0]->drv_priv;
701 + hostapd_ubus_free_iface(iface);
702 hostapd_interface_deinit(iface);
703 wpa_printf(MSG_DEBUG, "%s: driver=%p drv_priv=%p -> hapd_deinit",
704 __func__, driver, drv_priv);
705 --- a/src/ap/ieee802_11.c
706 +++ b/src/ap/ieee802_11.c
707 @@ -980,7 +980,8 @@ int auth_sae_init_committed(struct hosta
710 static void handle_auth(struct hostapd_data *hapd,
711 - const struct ieee80211_mgmt *mgmt, size_t len)
712 + const struct ieee80211_mgmt *mgmt, size_t len,
713 + struct hostapd_frame_info *fi)
715 u16 auth_alg, auth_transaction, status_code;
716 u16 resp = WLAN_STATUS_SUCCESS;
717 @@ -996,6 +997,11 @@ static void handle_auth(struct hostapd_d
718 char *identity = NULL;
719 char *radius_cui = NULL;
721 + struct hostapd_ubus_request req = {
722 + .type = HOSTAPD_UBUS_AUTH_REQ,
723 + .mgmt_frame = mgmt,
727 os_memset(&vlan_id, 0, sizeof(vlan_id));
729 @@ -1149,6 +1155,14 @@ static void handle_auth(struct hostapd_d
730 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
734 + if (hostapd_ubus_handle_event(hapd, &req)) {
735 + wpa_printf(MSG_DEBUG, "Station " MACSTR " rejected by ubus handler.\n",
736 + MAC2STR(mgmt->sa));
737 + resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
741 if (res == HOSTAPD_ACL_PENDING) {
742 wpa_printf(MSG_DEBUG, "Authentication frame from " MACSTR
743 " waiting for an external authentication",
744 @@ -2033,13 +2047,18 @@ static u16 send_assoc_resp(struct hostap
746 static void handle_assoc(struct hostapd_data *hapd,
747 const struct ieee80211_mgmt *mgmt, size_t len,
749 + int reassoc, struct hostapd_frame_info *fi)
751 u16 capab_info, listen_interval, seq_ctrl, fc;
752 u16 resp = WLAN_STATUS_SUCCESS, reply_res;
755 struct sta_info *sta;
756 + struct hostapd_ubus_request req = {
757 + .type = HOSTAPD_UBUS_ASSOC_REQ,
758 + .mgmt_frame = mgmt,
762 if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_req) :
763 sizeof(mgmt->u.assoc_req))) {
764 @@ -2159,6 +2178,13 @@ static void handle_assoc(struct hostapd_
766 #endif /* CONFIG_MBO */
768 + if (hostapd_ubus_handle_event(hapd, &req)) {
769 + wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n",
770 + MAC2STR(mgmt->sa));
771 + resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
776 * sta->capability is used in check_assoc_ies() for RRM enabled
777 * capability element.
778 @@ -2639,7 +2665,7 @@ int ieee802_11_mgmt(struct hostapd_data
781 if (stype == WLAN_FC_STYPE_PROBE_REQ) {
782 - handle_probe_req(hapd, mgmt, len, fi->ssi_signal);
783 + handle_probe_req(hapd, mgmt, len, fi);
787 @@ -2657,17 +2683,17 @@ int ieee802_11_mgmt(struct hostapd_data
789 case WLAN_FC_STYPE_AUTH:
790 wpa_printf(MSG_DEBUG, "mgmt::auth");
791 - handle_auth(hapd, mgmt, len);
792 + handle_auth(hapd, mgmt, len, fi);
795 case WLAN_FC_STYPE_ASSOC_REQ:
796 wpa_printf(MSG_DEBUG, "mgmt::assoc_req");
797 - handle_assoc(hapd, mgmt, len, 0);
798 + handle_assoc(hapd, mgmt, len, 0, fi);
801 case WLAN_FC_STYPE_REASSOC_REQ:
802 wpa_printf(MSG_DEBUG, "mgmt::reassoc_req");
803 - handle_assoc(hapd, mgmt, len, 1);
804 + handle_assoc(hapd, mgmt, len, 1, fi);
807 case WLAN_FC_STYPE_DISASSOC:
808 --- a/src/ap/beacon.c
809 +++ b/src/ap/beacon.c
810 @@ -675,7 +675,7 @@ sta_track_seen_on(struct hostapd_iface *
812 void handle_probe_req(struct hostapd_data *hapd,
813 const struct ieee80211_mgmt *mgmt, size_t len,
815 + struct hostapd_frame_info *fi)
818 struct ieee802_11_elems elems;
819 @@ -684,9 +684,15 @@ void handle_probe_req(struct hostapd_dat
822 enum ssid_match_result res;
823 + int ssi_signal = fi->ssi_signal;
827 + struct hostapd_ubus_request req = {
828 + .type = HOSTAPD_UBUS_PROBE_REQ,
829 + .mgmt_frame = mgmt,
833 if (len < IEEE80211_HDRLEN)
835 @@ -838,6 +844,12 @@ void handle_probe_req(struct hostapd_dat
837 #endif /* CONFIG_P2P */
839 + if (hostapd_ubus_handle_event(hapd, &req)) {
840 + wpa_printf(MSG_DEBUG, "Probe request for " MACSTR " rejected by ubus handler.\n",
841 + MAC2STR(mgmt->sa));
845 /* TODO: verify that supp_rates contains at least one matching rate
846 * with AP configuration */
848 --- a/src/ap/beacon.h
849 +++ b/src/ap/beacon.h
850 @@ -14,7 +14,7 @@ struct ieee80211_mgmt;
852 void handle_probe_req(struct hostapd_data *hapd,
853 const struct ieee80211_mgmt *mgmt, size_t len,
855 + struct hostapd_frame_info *fi);
856 int ieee802_11_set_beacon(struct hostapd_data *hapd);
857 int ieee802_11_set_beacons(struct hostapd_iface *iface);
858 int ieee802_11_update_beacons(struct hostapd_iface *iface);
859 --- a/src/ap/drv_callbacks.c
860 +++ b/src/ap/drv_callbacks.c
861 @@ -52,6 +52,10 @@ int hostapd_notif_assoc(struct hostapd_d
862 u16 reason = WLAN_REASON_UNSPECIFIED;
863 u16 status = WLAN_STATUS_SUCCESS;
864 const u8 *p2p_dev_addr = NULL;
865 + struct hostapd_ubus_request req = {
866 + .type = HOSTAPD_UBUS_ASSOC_REQ,
872 @@ -124,6 +128,12 @@ int hostapd_notif_assoc(struct hostapd_d
876 + if (hostapd_ubus_handle_event(hapd, &req)) {
877 + wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n",
878 + MAC2STR(req.addr));
884 wpabuf_free(sta->p2p_ie);