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