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