kernel/modules: snd-pcm-dmaengine only if CONFIG_SND_DMAENGINE_PCM is set
[openwrt/staging/dedeckeh.git] / package / network / services / hostapd / patches / 700-ubus_support.patch
1 --- a/hostapd/Makefile
2 +++ b/hostapd/Makefile
3 @@ -97,6 +97,11 @@ OBJS += ../src/common/wpa_common.o
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 ifndef CONFIG_NO_DUMP_STATE
14 # define HOSTAPD_DUMP_STATE to include SIGUSR1 handler for dumping state to
15 --- a/src/ap/hostapd.h
16 +++ b/src/ap/hostapd.h
17 @@ -11,6 +11,7 @@
18
19 #include "common/defs.h"
20 #include "ap_config.h"
21 +#include "ubus.h"
22
23 struct wpa_driver_ops;
24 struct wpa_ctrl_dst;
25 @@ -75,6 +76,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
32 u8 own_addr[ETH_ALEN];
33 @@ -216,6 +218,7 @@ struct hostapd_iface {
34 void *owner;
35 char *config_fname;
36 struct hostapd_config *conf;
37 + struct hostapd_ubus_iface ubus;
38
39 size_t num_bss;
40 struct hostapd_data **bss;
41 --- /dev/null
42 +++ b/src/ap/ubus.c
43 @@ -0,0 +1,373 @@
44 +/*
45 + * hostapd / ubus support
46 + * Copyright (c) 2013, Felix Fietkau <nbd@openwrt.org>
47 + *
48 + * This software may be distributed under the terms of the BSD license.
49 + * See README for more details.
50 + */
51 +
52 +#include "utils/includes.h"
53 +#include "utils/common.h"
54 +#include "utils/eloop.h"
55 +#include "common/ieee802_11_defs.h"
56 +#include "hostapd.h"
57 +#include "sta_info.h"
58 +#include "ubus.h"
59 +
60 +static struct ubus_context *ctx;
61 +static struct blob_buf b;
62 +static int ctx_ref;
63 +
64 +struct ubus_banned_client {
65 + struct avl_node avl;
66 + u8 addr[ETH_ALEN];
67 +};
68 +
69 +static void ubus_receive(int sock, void *eloop_ctx, void *sock_ctx)
70 +{
71 + struct ubus_context *ctx = eloop_ctx;
72 + ubus_handle_event(ctx);
73 +}
74 +
75 +static void ubus_reconnect_timeout(void *eloop_data, void *user_ctx)
76 +{
77 + if (ubus_reconnect(ctx, NULL)) {
78 + eloop_register_timeout(1, 0, ubus_reconnect_timeout, ctx, NULL);
79 + return;
80 + }
81 +
82 + eloop_register_read_sock(ctx->sock.fd, ubus_receive, ctx, NULL);
83 +}
84 +
85 +static void hostapd_ubus_connection_lost(struct ubus_context *ctx)
86 +{
87 + eloop_unregister_read_sock(ctx->sock.fd);
88 + eloop_register_timeout(1, 0, ubus_reconnect_timeout, ctx, NULL);
89 +}
90 +
91 +static bool hostapd_ubus_init(void)
92 +{
93 + if (ctx)
94 + return true;
95 +
96 + ctx = ubus_connect(NULL);
97 + if (!ctx)
98 + return false;
99 +
100 + ctx->connection_lost = hostapd_ubus_connection_lost;
101 + eloop_register_read_sock(ctx->sock.fd, ubus_receive, ctx, NULL);
102 + return true;
103 +}
104 +
105 +static void hostapd_ubus_ref_inc(void)
106 +{
107 + ctx_ref++;
108 +}
109 +
110 +static void hostapd_ubus_ref_dec(void)
111 +{
112 + ctx_ref--;
113 + if (!ctx)
114 + return;
115 +
116 + if (ctx_ref)
117 + return;
118 +
119 + eloop_unregister_read_sock(ctx->sock.fd);
120 + ubus_free(ctx);
121 + ctx = NULL;
122 +}
123 +
124 +void hostapd_ubus_add_iface(struct hostapd_iface *iface)
125 +{
126 + if (!hostapd_ubus_init())
127 + return;
128 +}
129 +
130 +void hostapd_ubus_free_iface(struct hostapd_iface *iface)
131 +{
132 + if (!ctx)
133 + return;
134 +}
135 +
136 +static void
137 +hostapd_bss_del_ban(void *eloop_data, void *user_ctx)
138 +{
139 + struct ubus_banned_client *ban = eloop_data;
140 + struct hostapd_data *hapd = user_ctx;
141 +
142 + avl_delete(&hapd->ubus.banned, &ban->avl);
143 + free(ban);
144 +}
145 +
146 +static void
147 +hostapd_bss_ban_client(struct hostapd_data *hapd, u8 *addr, int time)
148 +{
149 + struct ubus_banned_client *ban;
150 +
151 + if (time < 0)
152 + time = 0;
153 +
154 + ban = avl_find_element(&hapd->ubus.banned, addr, ban, avl);
155 + if (!ban) {
156 + if (!time)
157 + return;
158 +
159 + ban = os_zalloc(sizeof(*ban));
160 + memcpy(ban->addr, addr, sizeof(ban->addr));
161 + ban->avl.key = ban->addr;
162 + avl_insert(&hapd->ubus.banned, &ban->avl);
163 + } else {
164 + eloop_cancel_timeout(hostapd_bss_del_ban, ban, hapd);
165 + if (!time) {
166 + hostapd_bss_del_ban(ban, hapd);
167 + return;
168 + }
169 + }
170 +
171 + eloop_register_timeout(0, time * 1000, hostapd_bss_del_ban, ban, hapd);
172 +}
173 +
174 +static int
175 +hostapd_bss_get_clients(struct ubus_context *ctx, struct ubus_object *obj,
176 + struct ubus_request_data *req, const char *method,
177 + struct blob_attr *msg)
178 +{
179 + struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj);
180 + struct sta_info *sta;
181 + void *list, *c;
182 + char mac_buf[20];
183 + static const struct {
184 + const char *name;
185 + uint32_t flag;
186 + } sta_flags[] = {
187 + { "auth", WLAN_STA_AUTH },
188 + { "assoc", WLAN_STA_ASSOC },
189 + { "authorized", WLAN_STA_AUTHORIZED },
190 + { "preauth", WLAN_STA_PREAUTH },
191 + { "wds", WLAN_STA_WDS },
192 + { "wmm", WLAN_STA_WMM },
193 + { "ht", WLAN_STA_HT },
194 + { "vht", WLAN_STA_VHT },
195 + { "wps", WLAN_STA_WPS },
196 + { "mfp", WLAN_STA_MFP },
197 + };
198 +
199 + blob_buf_init(&b, 0);
200 + blobmsg_add_u32(&b, "freq", hapd->iface->freq);
201 + list = blobmsg_open_table(&b, "clients");
202 + for (sta = hapd->sta_list; sta; sta = sta->next) {
203 + int i;
204 +
205 + sprintf(mac_buf, MACSTR, MAC2STR(sta->addr));
206 + c = blobmsg_open_table(&b, mac_buf);
207 + for (i = 0; i < ARRAY_SIZE(sta_flags); i++)
208 + blobmsg_add_u8(&b, sta_flags[i].name,
209 + !!(sta->flags & sta_flags[i].flag));
210 + blobmsg_add_u32(&b, "aid", sta->aid);
211 + blobmsg_close_table(&b, c);
212 + }
213 + blobmsg_close_array(&b, list);
214 + ubus_send_reply(ctx, req, b.head);
215 +
216 + return 0;
217 +}
218 +
219 +enum {
220 + DEL_CLIENT_ADDR,
221 + DEL_CLIENT_REASON,
222 + DEL_CLIENT_DEAUTH,
223 + DEL_CLIENT_BAN_TIME,
224 + __DEL_CLIENT_MAX
225 +};
226 +
227 +static const struct blobmsg_policy del_policy[__DEL_CLIENT_MAX] = {
228 + [DEL_CLIENT_ADDR] = { "addr", BLOBMSG_TYPE_STRING },
229 + [DEL_CLIENT_REASON] = { "reason", BLOBMSG_TYPE_INT32 },
230 + [DEL_CLIENT_DEAUTH] = { "deauth", BLOBMSG_TYPE_INT8 },
231 + [DEL_CLIENT_BAN_TIME] = { "ban_time", BLOBMSG_TYPE_INT32 },
232 +};
233 +
234 +static int
235 +hostapd_bss_del_client(struct ubus_context *ctx, struct ubus_object *obj,
236 + struct ubus_request_data *req, const char *method,
237 + struct blob_attr *msg)
238 +{
239 + struct blob_attr *tb[__DEL_CLIENT_MAX];
240 + struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj);
241 + struct sta_info *sta;
242 + bool deauth = false;
243 + int reason;
244 + u8 addr[ETH_ALEN];
245 +
246 + blobmsg_parse(del_policy, __DEL_CLIENT_MAX, tb, blob_data(msg), blob_len(msg));
247 +
248 + if (!tb[DEL_CLIENT_ADDR])
249 + return UBUS_STATUS_INVALID_ARGUMENT;
250 +
251 + if (hwaddr_aton(blobmsg_data(tb[DEL_CLIENT_ADDR]), addr))
252 + return UBUS_STATUS_INVALID_ARGUMENT;
253 +
254 + if (tb[DEL_CLIENT_REASON])
255 + reason = blobmsg_get_u32(tb[DEL_CLIENT_REASON]);
256 +
257 + if (tb[DEL_CLIENT_DEAUTH])
258 + deauth = blobmsg_get_bool(tb[DEL_CLIENT_DEAUTH]);
259 +
260 + sta = ap_get_sta(hapd, addr);
261 + if (sta) {
262 + if (deauth) {
263 + hostapd_drv_sta_deauth(hapd, addr, reason);
264 + ap_sta_deauthenticate(hapd, sta, reason);
265 + } else {
266 + hostapd_drv_sta_disassoc(hapd, addr, reason);
267 + ap_sta_disassociate(hapd, sta, reason);
268 + }
269 + }
270 +
271 + if (tb[DEL_CLIENT_BAN_TIME])
272 + hostapd_bss_ban_client(hapd, addr, blobmsg_get_u32(tb[DEL_CLIENT_BAN_TIME]));
273 +
274 + return 0;
275 +}
276 +
277 +static void
278 +blobmsg_add_macaddr(struct blob_buf *buf, const char *name, const u8 *addr)
279 +{
280 + char *s;
281 +
282 + s = blobmsg_alloc_string_buffer(buf, name, 20);
283 + sprintf(s, MACSTR, MAC2STR(addr));
284 + blobmsg_add_string_buffer(buf);
285 +}
286 +
287 +static int
288 +hostapd_bss_list_bans(struct ubus_context *ctx, struct ubus_object *obj,
289 + struct ubus_request_data *req, const char *method,
290 + struct blob_attr *msg)
291 +{
292 + struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj);
293 + struct ubus_banned_client *ban;
294 + void *c;
295 +
296 + blob_buf_init(&b, 0);
297 + c = blobmsg_open_array(&b, "clients");
298 + avl_for_each_element(&hapd->ubus.banned, ban, avl)
299 + blobmsg_add_macaddr(&b, NULL, ban->addr);
300 + blobmsg_close_array(&b, c);
301 + ubus_send_reply(ctx, req, b.head);
302 +
303 + return 0;
304 +}
305 +
306 +static const struct ubus_method bss_methods[] = {
307 + UBUS_METHOD_NOARG("get_clients", hostapd_bss_get_clients),
308 + UBUS_METHOD("del_client", hostapd_bss_del_client, del_policy),
309 + UBUS_METHOD_NOARG("list_bans", hostapd_bss_list_bans),
310 +};
311 +
312 +static struct ubus_object_type bss_object_type =
313 + UBUS_OBJECT_TYPE("hostapd_bss", bss_methods);
314 +
315 +static int avl_compare_macaddr(const void *k1, const void *k2, void *ptr)
316 +{
317 + return memcmp(k1, k2, ETH_ALEN);
318 +}
319 +
320 +void hostapd_ubus_add_bss(struct hostapd_data *hapd)
321 +{
322 + struct ubus_object *obj = &hapd->ubus.obj;
323 + char *name;
324 + int ret;
325 +
326 + if (!hostapd_ubus_init())
327 + return;
328 +
329 + if (asprintf(&name, "hostapd.%s", hapd->conf->iface) < 0)
330 + return;
331 +
332 + avl_init(&hapd->ubus.banned, avl_compare_macaddr, false, NULL);
333 + obj->name = name;
334 + obj->type = &bss_object_type;
335 + obj->methods = bss_object_type.methods;
336 + obj->n_methods = bss_object_type.n_methods;
337 + ret = ubus_add_object(ctx, obj);
338 + hostapd_ubus_ref_inc();
339 +}
340 +
341 +void hostapd_ubus_free_bss(struct hostapd_data *hapd)
342 +{
343 + struct ubus_object *obj = &hapd->ubus.obj;
344 + char *name = (char *) obj->name;
345 +
346 + if (!ctx)
347 + return;
348 +
349 + if (obj->id) {
350 + ubus_remove_object(ctx, obj);
351 + hostapd_ubus_ref_dec();
352 + }
353 +
354 + free(name);
355 +}
356 +
357 +struct ubus_event_req {
358 + struct ubus_notify_request nreq;
359 + bool deny;
360 +};
361 +
362 +static void
363 +ubus_event_cb(struct ubus_notify_request *req, int idx, int ret)
364 +{
365 + struct ubus_event_req *ureq = container_of(req, struct ubus_event_req, nreq);
366 +
367 + if (ret)
368 + ureq->deny = true;
369 +}
370 +
371 +int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req)
372 +{
373 + struct ubus_banned_client *ban;
374 + const char *types[HOSTAPD_UBUS_TYPE_MAX] = {
375 + [HOSTAPD_UBUS_PROBE_REQ] = "probe",
376 + [HOSTAPD_UBUS_AUTH_REQ] = "auth",
377 + [HOSTAPD_UBUS_ASSOC_REQ] = "assoc",
378 + };
379 + const char *type = "mgmt";
380 + struct ubus_event_req ureq = {};
381 + const u8 *addr;
382 +
383 + if (req->mgmt_frame)
384 + addr = req->mgmt_frame->sa;
385 + else
386 + addr = req->addr;
387 +
388 + ban = avl_find_element(&hapd->ubus.banned, addr, ban, avl);
389 + if (ban)
390 + return -2;
391 +
392 + if (!hapd->ubus.obj.has_subscribers)
393 + return 0;
394 +
395 + if (req->type < ARRAY_SIZE(types))
396 + type = types[req->type];
397 +
398 + blob_buf_init(&b, 0);
399 + blobmsg_add_macaddr(&b, "address", addr);
400 + if (req->mgmt_frame)
401 + blobmsg_add_macaddr(&b, "target", req->mgmt_frame->da);
402 + if (req->frame_info)
403 + blobmsg_add_u32(&b, "signal", req->frame_info->ssi_signal);
404 + blobmsg_add_u32(&b, "freq", hapd->iface->freq);
405 +
406 + if (ubus_notify_async(ctx, &hapd->ubus.obj, type, b.head, &ureq.nreq))
407 + return 0;
408 +
409 + ureq.nreq.status_cb = ubus_event_cb;
410 + ubus_complete_request(ctx, &ureq.nreq.req, 100);
411 +
412 + if (ureq.deny)
413 + return -1;
414 +
415 + return 0;
416 +}
417 --- /dev/null
418 +++ b/src/ap/ubus.h
419 @@ -0,0 +1,78 @@
420 +/*
421 + * hostapd / ubus support
422 + * Copyright (c) 2013, Felix Fietkau <nbd@openwrt.org>
423 + *
424 + * This software may be distributed under the terms of the BSD license.
425 + * See README for more details.
426 + */
427 +#ifndef __HOSTAPD_UBUS_H
428 +#define __HOSTAPD_UBUS_H
429 +
430 +enum hostapd_ubus_event_type {
431 + HOSTAPD_UBUS_PROBE_REQ,
432 + HOSTAPD_UBUS_AUTH_REQ,
433 + HOSTAPD_UBUS_ASSOC_REQ,
434 + HOSTAPD_UBUS_TYPE_MAX
435 +};
436 +
437 +struct hostapd_ubus_request {
438 + enum hostapd_ubus_event_type type;
439 + const struct ieee80211_mgmt *mgmt_frame;
440 + const struct hostapd_frame_info *frame_info;
441 + const u8 *addr;
442 +};
443 +
444 +struct hostapd_iface;
445 +struct hostapd_data;
446 +
447 +#ifdef UBUS_SUPPORT
448 +
449 +#include <libubox/avl.h>
450 +#include <libubus.h>
451 +
452 +struct hostapd_ubus_iface {
453 + struct ubus_object obj;
454 +};
455 +
456 +struct hostapd_ubus_bss {
457 + struct ubus_object obj;
458 + struct avl_tree banned;
459 +};
460 +
461 +void hostapd_ubus_add_iface(struct hostapd_iface *iface);
462 +void hostapd_ubus_free_iface(struct hostapd_iface *iface);
463 +void hostapd_ubus_add_bss(struct hostapd_data *hapd);
464 +void hostapd_ubus_free_bss(struct hostapd_data *hapd);
465 +
466 +int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req);
467 +
468 +#else
469 +
470 +struct hostapd_ubus_iface {};
471 +
472 +struct hostapd_ubus_bss {};
473 +
474 +static inline void hostapd_ubus_add_iface(struct hostapd_iface *iface)
475 +{
476 +}
477 +
478 +static inline void hostapd_ubus_free_iface(struct hostapd_iface *iface)
479 +{
480 +}
481 +
482 +static inline void hostapd_ubus_add_bss(struct hostapd_data *hapd)
483 +{
484 +}
485 +
486 +static inline void hostapd_ubus_free_bss(struct hostapd_data *hapd)
487 +{
488 +}
489 +
490 +static inline int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req)
491 +{
492 + return 0;
493 +}
494 +
495 +#endif
496 +
497 +#endif
498 --- a/src/ap/hostapd.c
499 +++ b/src/ap/hostapd.c
500 @@ -241,6 +241,7 @@ static int hostapd_broadcast_wep_set(str
501
502 static void hostapd_free_hapd_data(struct hostapd_data *hapd)
503 {
504 + hostapd_ubus_free_bss(hapd);
505 iapp_deinit(hapd->iapp);
506 hapd->iapp = NULL;
507 accounting_deinit(hapd);
508 @@ -806,6 +807,8 @@ static int hostapd_setup_bss(struct host
509 if (hapd->driver && hapd->driver->set_operstate)
510 hapd->driver->set_operstate(hapd->drv_priv, 1);
511
512 + hostapd_ubus_add_bss(hapd);
513 +
514 return 0;
515 }
516
517 @@ -956,6 +959,7 @@ int hostapd_setup_interface_complete(str
518 if (err)
519 goto error;
520
521 + hostapd_ubus_add_iface(iface);
522 wpa_printf(MSG_DEBUG, "Completing interface initialization");
523 if (hapd->iconf->channel) {
524 iface->freq = hostapd_hw_get_freq(hapd, hapd->iconf->channel);
525 @@ -1048,6 +1052,7 @@ int hostapd_setup_interface_complete(str
526
527 error:
528 wpa_printf(MSG_ERROR, "Interface initialization failed");
529 + hostapd_ubus_free_iface(iface);
530 eloop_terminate();
531 return -1;
532 }
533 @@ -1146,6 +1151,8 @@ void hostapd_interface_deinit_free(struc
534 void *drv_priv;
535 if (iface == NULL)
536 return;
537 +
538 + hostapd_ubus_free_iface(iface);
539 driver = iface->bss[0]->driver;
540 drv_priv = iface->bss[0]->drv_priv;
541 hostapd_interface_deinit(iface);
542 --- a/src/ap/ieee802_11.c
543 +++ b/src/ap/ieee802_11.c
544 @@ -535,7 +535,8 @@ static void handle_auth_sae(struct hosta
545
546
547 static void handle_auth(struct hostapd_data *hapd,
548 - const struct ieee80211_mgmt *mgmt, size_t len)
549 + const struct ieee80211_mgmt *mgmt, size_t len,
550 + struct hostapd_frame_info *fi)
551 {
552 u16 auth_alg, auth_transaction, status_code;
553 u16 resp = WLAN_STATUS_SUCCESS;
554 @@ -550,6 +551,11 @@ static void handle_auth(struct hostapd_d
555 size_t resp_ies_len = 0;
556 char *identity = NULL;
557 char *radius_cui = NULL;
558 + struct hostapd_ubus_request req = {
559 + .type = HOSTAPD_UBUS_AUTH_REQ,
560 + .mgmt_frame = mgmt,
561 + .frame_info = fi,
562 + };
563
564 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
565 printf("handle_auth - too short payload (len=%lu)\n",
566 @@ -633,6 +639,14 @@ static void handle_auth(struct hostapd_d
567 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
568 goto fail;
569 }
570 +
571 + if (hostapd_ubus_handle_event(hapd, &req)) {
572 + wpa_printf(MSG_DEBUG, "Station " MACSTR " rejected by ubus handler.\n",
573 + MAC2STR(mgmt->sa));
574 + resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
575 + goto fail;
576 + }
577 +
578 if (res == HOSTAPD_ACL_PENDING) {
579 wpa_printf(MSG_DEBUG, "Authentication frame from " MACSTR
580 " waiting for an external authentication",
581 @@ -1220,13 +1234,18 @@ static void send_assoc_resp(struct hosta
582
583 static void handle_assoc(struct hostapd_data *hapd,
584 const struct ieee80211_mgmt *mgmt, size_t len,
585 - int reassoc)
586 + int reassoc, struct hostapd_frame_info *fi)
587 {
588 u16 capab_info, listen_interval;
589 u16 resp = WLAN_STATUS_SUCCESS;
590 const u8 *pos;
591 int left, i;
592 struct sta_info *sta;
593 + struct hostapd_ubus_request req = {
594 + .type = HOSTAPD_UBUS_ASSOC_REQ,
595 + .mgmt_frame = mgmt,
596 + .frame_info = fi,
597 + };
598
599 if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_req) :
600 sizeof(mgmt->u.assoc_req))) {
601 @@ -1325,6 +1344,13 @@ static void handle_assoc(struct hostapd_
602 goto fail;
603 }
604
605 + if (hostapd_ubus_handle_event(hapd, &req)) {
606 + wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n",
607 + MAC2STR(mgmt->sa));
608 + resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
609 + goto fail;
610 + }
611 +
612 sta->capability = capab_info;
613 sta->listen_interval = listen_interval;
614
615 @@ -1734,7 +1760,7 @@ void ieee802_11_mgmt(struct hostapd_data
616
617
618 if (stype == WLAN_FC_STYPE_PROBE_REQ) {
619 - handle_probe_req(hapd, mgmt, len, fi->ssi_signal);
620 + handle_probe_req(hapd, mgmt, len, fi);
621 return;
622 }
623
624 @@ -1749,15 +1775,15 @@ void ieee802_11_mgmt(struct hostapd_data
625 switch (stype) {
626 case WLAN_FC_STYPE_AUTH:
627 wpa_printf(MSG_DEBUG, "mgmt::auth");
628 - handle_auth(hapd, mgmt, len);
629 + handle_auth(hapd, mgmt, len, fi);
630 break;
631 case WLAN_FC_STYPE_ASSOC_REQ:
632 wpa_printf(MSG_DEBUG, "mgmt::assoc_req");
633 - handle_assoc(hapd, mgmt, len, 0);
634 + handle_assoc(hapd, mgmt, len, 0, fi);
635 break;
636 case WLAN_FC_STYPE_REASSOC_REQ:
637 wpa_printf(MSG_DEBUG, "mgmt::reassoc_req");
638 - handle_assoc(hapd, mgmt, len, 1);
639 + handle_assoc(hapd, mgmt, len, 1, fi);
640 break;
641 case WLAN_FC_STYPE_DISASSOC:
642 wpa_printf(MSG_DEBUG, "mgmt::disassoc");
643 --- a/src/ap/beacon.c
644 +++ b/src/ap/beacon.c
645 @@ -352,7 +352,7 @@ static enum ssid_match_result ssid_match
646
647 void handle_probe_req(struct hostapd_data *hapd,
648 const struct ieee80211_mgmt *mgmt, size_t len,
649 - int ssi_signal)
650 + struct hostapd_frame_info *fi)
651 {
652 u8 *resp;
653 struct ieee802_11_elems elems;
654 @@ -360,8 +360,14 @@ void handle_probe_req(struct hostapd_dat
655 size_t ie_len;
656 struct sta_info *sta = NULL;
657 size_t i, resp_len;
658 + int ssi_signal = fi->ssi_signal;
659 int noack;
660 enum ssid_match_result res;
661 + struct hostapd_ubus_request req = {
662 + .type = HOSTAPD_UBUS_PROBE_REQ,
663 + .mgmt_frame = mgmt,
664 + .frame_info = fi,
665 + };
666
667 ie = mgmt->u.probe_req.variable;
668 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req))
669 @@ -500,6 +506,12 @@ void handle_probe_req(struct hostapd_dat
670 }
671 #endif /* CONFIG_P2P */
672
673 + if (hostapd_ubus_handle_event(hapd, &req)) {
674 + wpa_printf(MSG_DEBUG, "Probe request for " MACSTR " rejected by ubus handler.\n",
675 + MAC2STR(mgmt->sa));
676 + return;
677 + }
678 +
679 /* TODO: verify that supp_rates contains at least one matching rate
680 * with AP configuration */
681
682 --- a/src/ap/beacon.h
683 +++ b/src/ap/beacon.h
684 @@ -20,7 +20,7 @@ struct ieee80211_mgmt;
685
686 void handle_probe_req(struct hostapd_data *hapd,
687 const struct ieee80211_mgmt *mgmt, size_t len,
688 - int ssi_signal);
689 + struct hostapd_frame_info *fi);
690 void ieee802_11_set_beacon(struct hostapd_data *hapd);
691 void ieee802_11_set_beacons(struct hostapd_iface *iface);
692 void ieee802_11_update_beacons(struct hostapd_iface *iface);