1 From: Felix Fietkau <nbd@openwrt.org>
2 Date: Sun, 17 Mar 2013 20:47:18 +0000
3 Subject: [PATCH] hostapd: initial prototype of an ubus binding
5 Supports listing, removing and banning clients, and hooking into
6 probe/assoc/auth requests via object subscribe.
10 @@ -166,6 +166,12 @@ OBJS += ../src/common/hw_features_common
12 OBJS += ../src/eapol_auth/eapol_auth_sm.o
15 +CFLAGS += -DUBUS_SUPPORT
16 +OBJS += ../src/utils/uloop.o
17 +OBJS += ../src/ap/ubus.o
18 +LIBS += -lubox -lubus
21 ifdef CONFIG_CODE_COVERAGE
22 CFLAGS += -O0 -fprofile-arcs -ftest-coverage -U_FORTIFY_SOURCE
23 --- a/src/ap/airtime_policy.c
24 +++ b/src/ap/airtime_policy.c
25 @@ -112,8 +112,14 @@ static void set_sta_weights(struct hosta
29 - for (sta = hapd->sta_list; sta; sta = sta->next)
30 - sta_set_airtime_weight(hapd, sta, weight);
31 + for (sta = hapd->sta_list; sta; sta = sta->next) {
32 + unsigned int sta_weight = weight;
34 + if (sta->dyn_airtime_weight)
35 + sta_weight = (weight * sta->dyn_airtime_weight) / 256;
37 + sta_set_airtime_weight(hapd, sta, sta_weight);
42 @@ -244,7 +250,10 @@ int airtime_policy_new_sta(struct hostap
45 if (hapd->iconf->airtime_mode == AIRTIME_MODE_STATIC) {
46 - weight = get_weight_for_sta(hapd, sta->addr);
47 + if (sta->dyn_airtime_weight)
48 + weight = sta->dyn_airtime_weight;
50 + weight = get_weight_for_sta(hapd, sta->addr);
52 return sta_set_airtime_weight(hapd, sta, weight);
56 @@ -1351,6 +1351,12 @@ void handle_probe_req(struct hostapd_dat
59 #endif /* CONFIG_IEEE80211BE */
60 + struct hostapd_ubus_request req = {
61 + .type = HOSTAPD_UBUS_PROBE_REQ,
63 + .ssi_signal = ssi_signal,
67 if (hapd->iconf->rssi_ignore_probe_request && ssi_signal &&
68 ssi_signal < hapd->iconf->rssi_ignore_probe_request)
69 @@ -1537,6 +1543,12 @@ void handle_probe_req(struct hostapd_dat
71 #endif /* CONFIG_P2P */
73 + if (hostapd_ubus_handle_event(hapd, &req)) {
74 + wpa_printf(MSG_DEBUG, "Probe request for " MACSTR " rejected by ubus handler.\n",
79 /* TODO: verify that supp_rates contains at least one matching rate
80 * with AP configuration */
84 @@ -1225,6 +1225,8 @@ int hostapd_dfs_pre_cac_expired(struct h
85 "freq=%d ht_enabled=%d chan_offset=%d chan_width=%d cf1=%d cf2=%d",
86 freq, ht_enabled, chan_offset, chan_width, cf1, cf2);
88 + hostapd_ubus_notify_radar_detected(iface, freq, chan_width, cf1, cf2);
90 /* Proceed only if DFS is not offloaded to the driver */
91 if (iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD)
93 --- a/src/ap/drv_callbacks.c
94 +++ b/src/ap/drv_callbacks.c
95 @@ -268,6 +268,10 @@ int hostapd_notif_assoc(struct hostapd_d
96 struct hostapd_iface *iface = hapd->iface;
97 #endif /* CONFIG_OWE */
99 + struct hostapd_ubus_request req = {
100 + .type = HOSTAPD_UBUS_ASSOC_REQ,
106 @@ -412,6 +416,12 @@ int hostapd_notif_assoc(struct hostapd_d
110 + if (hostapd_ubus_handle_event(hapd, &req)) {
111 + wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n",
112 + MAC2STR(req.addr));
118 wpabuf_free(sta->p2p_ie);
119 --- a/src/ap/hostapd.c
120 +++ b/src/ap/hostapd.c
121 @@ -493,6 +493,7 @@ void hostapd_free_hapd_data(struct hosta
122 hapd->beacon_set_done = 0;
124 wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
125 + hostapd_ubus_free_bss(hapd);
126 accounting_deinit(hapd);
127 hostapd_deinit_wpa(hapd);
129 @@ -1274,6 +1275,8 @@ static int hostapd_start_beacon(struct h
130 if (hapd->driver && hapd->driver->set_operstate)
131 hapd->driver->set_operstate(hapd->drv_priv, 1);
133 + hostapd_ubus_add_bss(hapd);
138 @@ -2367,6 +2370,7 @@ static int hostapd_setup_interface_compl
142 + hostapd_ubus_add_iface(iface);
143 wpa_printf(MSG_DEBUG, "Completing interface initialization");
146 @@ -2586,6 +2590,7 @@ dfs_offload:
149 wpa_printf(MSG_ERROR, "Interface initialization failed");
150 + hostapd_ubus_free_iface(iface);
152 if (iface->is_no_ir) {
153 hostapd_set_state(iface, HAPD_IFACE_NO_IR);
154 @@ -3076,6 +3081,7 @@ void hostapd_interface_deinit_free(struc
155 (unsigned int) iface->conf->num_bss);
156 driver = iface->bss[0]->driver;
157 drv_priv = iface->bss[0]->drv_priv;
158 + hostapd_ubus_free_iface(iface);
159 hostapd_interface_deinit(iface);
160 wpa_printf(MSG_DEBUG, "%s: driver=%p drv_priv=%p -> hapd_deinit",
161 __func__, driver, drv_priv);
162 --- a/src/ap/hostapd.h
163 +++ b/src/ap/hostapd.h
165 #include "utils/list.h"
166 #include "ap_config.h"
167 #include "drivers/driver.h"
170 #define OCE_STA_CFON_ENABLED(hapd) \
171 ((hapd->conf->oce & OCE_STA_CFON) && \
172 @@ -184,6 +185,7 @@ struct hostapd_data {
173 struct hostapd_iface *iface;
174 struct hostapd_config *iconf;
175 struct hostapd_bss_config *conf;
176 + struct hostapd_ubus_bss ubus;
177 int interface_added; /* virtual interface added for this BSS */
178 unsigned int started:1;
179 unsigned int disabled:1;
180 @@ -707,6 +709,7 @@ hostapd_alloc_bss_data(struct hostapd_if
181 struct hostapd_bss_config *bss);
182 int hostapd_setup_interface(struct hostapd_iface *iface);
183 int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
184 +void hostapd_set_own_neighbor_report(struct hostapd_data *hapd);
185 void hostapd_interface_deinit(struct hostapd_iface *iface);
186 void hostapd_interface_free(struct hostapd_iface *iface);
187 struct hostapd_iface * hostapd_alloc_iface(void);
188 --- a/src/ap/ieee802_11.c
189 +++ b/src/ap/ieee802_11.c
190 @@ -2798,7 +2798,7 @@ static void handle_auth(struct hostapd_d
191 u16 auth_alg, auth_transaction, status_code;
192 u16 resp = WLAN_STATUS_SUCCESS;
193 struct sta_info *sta = NULL;
194 - int res, reply_res;
195 + int res, reply_res, ubus_resp;
197 const u8 *challenge = NULL;
198 u8 resp_ies[2 + WLAN_AUTH_CHALLENGE_LEN];
199 @@ -2807,6 +2807,11 @@ static void handle_auth(struct hostapd_d
200 struct radius_sta rad_info;
201 const u8 *dst, *sa, *bssid;
202 bool mld_sta = false;
203 + struct hostapd_ubus_request req = {
204 + .type = HOSTAPD_UBUS_AUTH_REQ,
205 + .mgmt_frame = mgmt,
206 + .ssi_signal = rssi,
209 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
210 wpa_printf(MSG_INFO, "handle_auth - too short payload (len=%lu)",
211 @@ -2998,6 +3003,13 @@ static void handle_auth(struct hostapd_d
212 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
215 + ubus_resp = hostapd_ubus_handle_event(hapd, &req);
217 + wpa_printf(MSG_DEBUG, "Station " MACSTR " rejected by ubus handler.\n",
218 + MAC2STR(mgmt->sa));
219 + resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE;
222 if (res == HOSTAPD_ACL_PENDING)
225 @@ -5242,7 +5254,7 @@ static void handle_assoc(struct hostapd_
226 int resp = WLAN_STATUS_SUCCESS;
227 u16 reply_res = WLAN_STATUS_UNSPECIFIED_FAILURE;
230 + int left, i, ubus_resp;
231 struct sta_info *sta;
234 @@ -5484,6 +5496,11 @@ static void handle_assoc(struct hostapd_
237 #endif /* CONFIG_FILS */
238 + struct hostapd_ubus_request req = {
239 + .type = HOSTAPD_UBUS_ASSOC_REQ,
240 + .mgmt_frame = mgmt,
241 + .ssi_signal = rssi,
244 /* followed by SSID and Supported rates; and HT capabilities if 802.11n
246 @@ -5586,6 +5603,13 @@ static void handle_assoc(struct hostapd_
248 ieee802_11_set_beacons(hapd->iface);
250 + ubus_resp = hostapd_ubus_handle_event(hapd, &req);
252 + wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n",
253 + MAC2STR(mgmt->sa));
254 + resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE;
260 @@ -5836,6 +5860,7 @@ static void handle_disassoc(struct hosta
261 (unsigned long) len);
264 + hostapd_ubus_notify(hapd, "disassoc", mgmt->sa);
266 sta = ap_get_sta(hapd, mgmt->sa);
268 @@ -5867,6 +5892,8 @@ static void handle_deauth(struct hostapd
269 /* Clear the PTKSA cache entries for PASN */
270 ptksa_cache_flush(hapd->ptksa, mgmt->sa, WPA_CIPHER_NONE);
272 + hostapd_ubus_notify(hapd, "deauth", mgmt->sa);
274 sta = ap_get_sta(hapd, mgmt->sa);
276 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Station " MACSTR
279 @@ -89,6 +89,9 @@ static void hostapd_handle_beacon_report
281 wpa_msg(hapd->msg_ctx, MSG_INFO, BEACON_RESP_RX MACSTR " %u %02x %s",
282 MAC2STR(addr), token, rep_mode, report);
283 + if (len < sizeof(struct rrm_measurement_beacon_report))
285 + hostapd_ubus_notify_beacon_report(hapd, addr, token, rep_mode, (struct rrm_measurement_beacon_report*) pos, len);
289 @@ -352,6 +355,9 @@ void hostapd_handle_radio_measurement(st
290 mgmt->u.action.u.rrm.action, MAC2STR(mgmt->sa));
292 switch (mgmt->u.action.u.rrm.action) {
293 + case WLAN_RRM_LINK_MEASUREMENT_REPORT:
294 + hostapd_ubus_handle_link_measurement(hapd, buf, len);
296 case WLAN_RRM_RADIO_MEASUREMENT_REPORT:
297 hostapd_handle_radio_msmt_report(hapd, buf, len);
299 --- a/src/ap/sta_info.c
300 +++ b/src/ap/sta_info.c
301 @@ -476,6 +476,7 @@ void ap_handle_timer(void *eloop_ctx, vo
302 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
303 HOSTAPD_LEVEL_INFO, "deauthenticated due to "
304 "local deauth request");
305 + hostapd_ubus_notify(hapd, "local-deauth", sta->addr);
306 ap_free_sta(hapd, sta);
309 @@ -631,6 +632,7 @@ skip_poll:
310 mlme_deauthenticate_indication(
312 WLAN_REASON_PREV_AUTH_NOT_VALID);
313 + hostapd_ubus_notify(hapd, "inactive-deauth", sta->addr);
314 ap_free_sta(hapd, sta);
317 @@ -1451,15 +1453,28 @@ void ap_sta_set_authorized_event(struct
318 os_snprintf(buf, sizeof(buf), MACSTR, MAC2STR(sta->addr));
321 + static const char * const auth_algs[] = {
322 + [WLAN_AUTH_OPEN] = "open",
323 + [WLAN_AUTH_SHARED_KEY] = "shared",
324 + [WLAN_AUTH_FT] = "ft",
325 + [WLAN_AUTH_SAE] = "sae",
326 + [WLAN_AUTH_FILS_SK] = "fils-sk",
327 + [WLAN_AUTH_FILS_SK_PFS] = "fils-sk-pfs",
328 + [WLAN_AUTH_FILS_PK] = "fils-pk",
329 + [WLAN_AUTH_PASN] = "pasn",
331 + const char *auth_alg = NULL;
332 const u8 *dpp_pkhash;
334 char dpp_pkhash_buf[100];
339 dpp_pkhash_buf[0] = '\0';
344 if (wpa_auth_get_ip_addr(sta->wpa_sm, ip_addr_buf) == 0) {
345 os_snprintf(ip_addr, sizeof(ip_addr),
346 @@ -1470,6 +1485,13 @@ void ap_sta_set_authorized_event(struct
348 #endif /* CONFIG_P2P */
350 + if (sta->auth_alg < ARRAY_SIZE(auth_algs))
351 + auth_alg = auth_algs[sta->auth_alg];
354 + os_snprintf(alg_buf, sizeof(alg_buf),
355 + " auth_alg=%s", auth_alg);
357 keyid = ap_sta_wpa_get_keyid(hapd, sta);
359 os_snprintf(keyid_buf, sizeof(keyid_buf),
360 @@ -1488,17 +1510,19 @@ void ap_sta_set_authorized_event(struct
361 dpp_pkhash, SHA256_MAC_LEN);
364 - wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED "%s%s%s%s",
365 - buf, ip_addr, keyid_buf, dpp_pkhash_buf);
366 + hostapd_ubus_notify_authorized(hapd, sta, auth_alg);
367 + wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED "%s%s%s%s%s",
368 + buf, ip_addr, keyid_buf, dpp_pkhash_buf, alg_buf);
370 if (hapd->msg_ctx_parent &&
371 hapd->msg_ctx_parent != hapd->msg_ctx)
372 wpa_msg_no_global(hapd->msg_ctx_parent, MSG_INFO,
373 - AP_STA_CONNECTED "%s%s%s%s",
374 + AP_STA_CONNECTED "%s%s%s%s%s",
375 buf, ip_addr, keyid_buf,
377 + dpp_pkhash_buf, alg_buf);
379 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED "%s", buf);
380 + hostapd_ubus_notify(hapd, "disassoc", sta->addr);
382 if (hapd->msg_ctx_parent &&
383 hapd->msg_ctx_parent != hapd->msg_ctx)
384 --- a/src/ap/sta_info.h
385 +++ b/src/ap/sta_info.h
386 @@ -319,6 +319,7 @@ struct sta_info {
387 #endif /* CONFIG_TESTING_OPTIONS */
388 #ifdef CONFIG_AIRTIME_POLICY
389 unsigned int airtime_weight;
390 + unsigned int dyn_airtime_weight;
391 struct os_reltime backlogged_until;
392 #endif /* CONFIG_AIRTIME_POLICY */
394 --- a/src/ap/vlan_init.c
395 +++ b/src/ap/vlan_init.c
397 static int vlan_if_add(struct hostapd_data *hapd, struct hostapd_vlan *vlan,
400 + bool vlan_exists = iface_exists(vlan->ifname);
404 @@ -36,7 +37,7 @@ static int vlan_if_add(struct hostapd_da
406 #endif /* CONFIG_WEP */
408 - if (!iface_exists(vlan->ifname))
410 ret = hostapd_vlan_if_add(hapd, vlan->ifname);
413 @@ -51,6 +52,9 @@ static int vlan_if_add(struct hostapd_da
415 ret = wpa_auth_ensure_group(hapd->wpa_auth, vlan->vlan_id);
417 + if (!ret && !vlan_exists)
418 + hostapd_ubus_add_vlan(hapd, vlan);
423 @@ -77,6 +81,8 @@ int vlan_if_remove(struct hostapd_data *
424 "WPA deinitialization for VLAN %d failed (%d)",
427 + hostapd_ubus_remove_vlan(hapd, vlan);
429 return hostapd_vlan_if_remove(hapd, vlan->ifname);
432 --- a/src/ap/wnm_ap.c
433 +++ b/src/ap/wnm_ap.c
434 @@ -479,7 +479,8 @@ static void ieee802_11_rx_bss_trans_mgmt
435 MAC2STR(addr), reason, hex ? " neighbor=" : "", hex);
438 - ieee802_11_send_bss_trans_mgmt_request(hapd, addr, dialog_token);
439 + if (!hostapd_ubus_notify_bss_transition_query(hapd, addr, dialog_token, reason, pos, end - pos))
440 + ieee802_11_send_bss_trans_mgmt_request(hapd, addr, dialog_token);
444 @@ -501,7 +502,7 @@ static void ieee802_11_rx_bss_trans_mgmt
447 u8 dialog_token, status_code, bss_termination_delay;
448 - const u8 *pos, *end;
449 + const u8 *pos, *end, *target_bssid = NULL;
450 int enabled = hapd->conf->bss_transition;
451 struct sta_info *sta;
453 @@ -548,6 +549,7 @@ static void ieee802_11_rx_bss_trans_mgmt
454 wpa_printf(MSG_DEBUG, "WNM: not enough room for Target BSSID field");
457 + target_bssid = pos;
458 sta->agreed_to_steer = 1;
459 eloop_cancel_timeout(ap_sta_reset_steer_flag_timer, hapd, sta);
460 eloop_register_timeout(2, 0, ap_sta_reset_steer_flag_timer,
461 @@ -567,6 +569,10 @@ static void ieee802_11_rx_bss_trans_mgmt
462 MAC2STR(addr), status_code, bss_termination_delay);
465 + hostapd_ubus_notify_bss_transition_response(hapd, sta->addr, dialog_token,
466 + status_code, bss_termination_delay,
467 + target_bssid, pos, end - pos);
469 wpa_hexdump(MSG_DEBUG, "WNM: BSS Transition Candidate List Entries",
472 --- a/src/ap/wpa_auth_glue.c
473 +++ b/src/ap/wpa_auth_glue.c
474 @@ -275,6 +275,7 @@ static void hostapd_wpa_auth_psk_failure
475 struct hostapd_data *hapd = ctx;
476 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_POSSIBLE_PSK_MISMATCH MACSTR,
478 + hostapd_ubus_notify(hapd, "key-mismatch", addr);
482 --- a/src/utils/eloop.c
483 +++ b/src/utils/eloop.c
484 @@ -77,6 +77,9 @@ struct eloop_sock_table {
488 + eloop_timeout_poll_handler timeout_poll_cb;
489 + eloop_poll_handler poll_cb;
491 size_t count; /* sum of all table counts */
492 #ifdef CONFIG_ELOOP_POLL
493 size_t max_pollfd_map; /* number of pollfds_map currently allocated */
494 @@ -1121,6 +1124,12 @@ void eloop_run(void)
495 os_reltime_sub(&timeout->time, &now, &tv);
497 tv.sec = tv.usec = 0;
500 + if (eloop.timeout_poll_cb && eloop.timeout_poll_cb(&tv, !!timeout))
501 + timeout = (void *)1;
504 #if defined(CONFIG_ELOOP_POLL) || defined(CONFIG_ELOOP_EPOLL)
505 timeout_ms = tv.sec * 1000 + tv.usec / 1000;
506 #endif /* defined(CONFIG_ELOOP_POLL) || defined(CONFIG_ELOOP_EPOLL) */
507 @@ -1190,7 +1199,8 @@ void eloop_run(void)
508 eloop.exceptions.changed = 0;
510 eloop_process_pending_signals();
515 /* check if some registered timeouts have occurred */
516 timeout = dl_list_first(&eloop.timeout, struct eloop_timeout,
517 @@ -1252,6 +1262,14 @@ out:
521 +int eloop_register_cb(eloop_poll_handler poll_cb,
522 + eloop_timeout_poll_handler timeout_cb)
524 + eloop.poll_cb = poll_cb;
525 + eloop.timeout_poll_cb = timeout_cb;
530 void eloop_terminate(void)
532 --- a/src/utils/eloop.h
533 +++ b/src/utils/eloop.h
534 @@ -65,6 +65,9 @@ typedef void (*eloop_timeout_handler)(vo
536 typedef void (*eloop_signal_handler)(int sig, void *signal_ctx);
538 +typedef bool (*eloop_timeout_poll_handler)(struct os_reltime *tv, bool tv_set);
539 +typedef void (*eloop_poll_handler)(void);
542 * eloop_init() - Initialize global event loop data
543 * Returns: 0 on success, -1 on failure
544 @@ -73,6 +76,9 @@ typedef void (*eloop_signal_handler)(int
546 int eloop_init(void);
548 +int eloop_register_cb(eloop_poll_handler poll_cb,
549 + eloop_timeout_poll_handler timeout_cb);
552 * eloop_register_read_sock - Register handler for read events
553 * @sock: File descriptor number for the socket
554 @@ -320,6 +326,8 @@ int eloop_register_signal_reconfig(eloop
556 int eloop_sock_requeue(void);
558 +void eloop_add_uloop(void);
561 * eloop_run - Start the event loop
564 +++ b/src/utils/uloop.c
566 +#include <libubox/uloop.h>
567 +#include "includes.h"
571 +static void eloop_uloop_event_cb(int sock, void *eloop_ctx, void *sock_ctx)
575 +static void eloop_uloop_fd_cb(struct uloop_fd *fd, unsigned int events)
577 + unsigned int changed = events ^ fd->flags;
579 + if (changed & ULOOP_READ) {
580 + if (events & ULOOP_READ)
581 + eloop_register_sock(fd->fd, EVENT_TYPE_READ, eloop_uloop_event_cb, fd, fd);
583 + eloop_unregister_sock(fd->fd, EVENT_TYPE_READ);
586 + if (changed & ULOOP_WRITE) {
587 + if (events & ULOOP_WRITE)
588 + eloop_register_sock(fd->fd, EVENT_TYPE_WRITE, eloop_uloop_event_cb, fd, fd);
590 + eloop_unregister_sock(fd->fd, EVENT_TYPE_WRITE);
594 +static bool uloop_timeout_poll_handler(struct os_reltime *tv, bool tv_set)
596 + struct os_reltime tv_uloop;
597 + int timeout_ms = uloop_get_next_timeout();
599 + if (timeout_ms < 0)
602 + tv_uloop.sec = timeout_ms / 1000;
603 + tv_uloop.usec = (timeout_ms % 1000) * 1000;
605 + if (!tv_set || os_reltime_before(&tv_uloop, tv)) {
613 +static void uloop_poll_handler(void)
615 + uloop_run_timeout(0);
618 +void eloop_add_uloop(void)
620 + static bool init_done = false;
624 + uloop_fd_set_cb = eloop_uloop_fd_cb;
628 + eloop_register_cb(uloop_poll_handler, uloop_timeout_poll_handler);
630 --- a/wpa_supplicant/Makefile
631 +++ b/wpa_supplicant/Makefile
632 @@ -189,6 +189,13 @@ ifdef CONFIG_EAPOL_TEST
633 CFLAGS += -Werror -DEAPOL_TEST
637 +CFLAGS += -DUBUS_SUPPORT
639 +OBJS += ../src/utils/uloop.o
640 +LIBS += -lubox -lubus
643 ifdef CONFIG_CODE_COVERAGE
644 CFLAGS += -O0 -fprofile-arcs -ftest-coverage -U_FORTIFY_SOURCE
646 @@ -1042,6 +1049,9 @@ ifdef CONFIG_CTRL_IFACE_MIB
647 CFLAGS += -DCONFIG_CTRL_IFACE_MIB
649 OBJS += ../src/ap/ctrl_iface_ap.o
651 +OBJS += ../src/ap/ubus.o
655 CFLAGS += -DEAP_SERVER -DEAP_SERVER_IDENTITY
656 --- a/wpa_supplicant/main.c
657 +++ b/wpa_supplicant/main.c
658 @@ -203,7 +203,7 @@ int main(int argc, char *argv[])
661 c = getopt(argc, argv,
662 - "b:Bc:C:D:de:f:g:G:hi:I:KLMm:No:O:p:P:qsTtuv::W");
663 + "b:Bc:C:D:de:f:g:G:hi:I:KLMm:nNo:O:p:P:qsTtuv::W");
667 @@ -268,6 +268,9 @@ int main(int argc, char *argv[])
668 params.conf_p2p_dev = optarg;
670 #endif /* CONFIG_P2P */
675 params.override_driver = optarg;
677 --- a/wpa_supplicant/wpa_supplicant.c
678 +++ b/wpa_supplicant/wpa_supplicant.c
679 @@ -7716,6 +7716,8 @@ struct wpa_supplicant * wpa_supplicant_a
681 #endif /* CONFIG_P2P */
683 + wpas_ubus_add_bss(wpa_s);
688 @@ -7742,6 +7744,8 @@ int wpa_supplicant_remove_iface(struct w
689 struct wpa_supplicant *parent = wpa_s->parent;
690 #endif /* CONFIG_MESH */
692 + wpas_ubus_free_bss(wpa_s);
694 /* Remove interface from the global list of interfaces */
695 prev = global->ifaces;
697 @@ -8088,8 +8092,12 @@ int wpa_supplicant_run(struct wpa_global
698 eloop_register_signal_terminate(wpa_supplicant_terminate, global);
699 eloop_register_signal_reconfig(wpa_supplicant_reconfig, global);
701 + wpas_ubus_add(global);
705 + wpas_ubus_free(global);
710 --- a/wpa_supplicant/wpa_supplicant_i.h
711 +++ b/wpa_supplicant/wpa_supplicant_i.h
713 #include "config_ssid.h"
715 #include "pasn/pasn_common.h"
718 extern const char *const wpa_supplicant_version;
719 extern const char *const wpa_supplicant_license;
720 @@ -319,6 +320,8 @@ struct wpa_global {
721 #endif /* CONFIG_WIFI_DISPLAY */
723 struct psk_list_entry *add_psk; /* From group formation */
725 + struct ubus_object ubus_global;
729 @@ -693,6 +696,7 @@ struct wpa_supplicant {
730 unsigned char own_addr[ETH_ALEN];
731 unsigned char perm_addr[ETH_ALEN];
733 + struct wpas_ubus_bss ubus;
734 #ifdef CONFIG_MATCH_IFACE
736 #endif /* CONFIG_MATCH_IFACE */
737 --- a/wpa_supplicant/wps_supplicant.c
738 +++ b/wpa_supplicant/wps_supplicant.c
741 #include "p2p_supplicant.h"
742 #include "wps_supplicant.h"
746 #ifndef WPS_PIN_SCAN_IGNORE_SEL_REG
747 @@ -401,6 +402,8 @@ static int wpa_supplicant_wps_cred(void
748 wpa_hexdump_key(MSG_DEBUG, "WPS: Received Credential attribute",
749 cred->cred_attr, cred->cred_attr_len);
751 + wpas_ubus_notify(wpa_s, cred);
753 if (wpa_s->conf->wps_cred_processing == 1)