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 @@ -167,6 +167,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 @@ -1437,6 +1437,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 @@ -1623,6 +1629,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 @@ -1243,6 +1243,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 @@ -317,6 +317,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 @@ -461,6 +465,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 @@ -1385,6 +1395,7 @@ void hostapd_event_ch_switch(struct host
121 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_CSA_FINISHED
122 "freq=%d dfs=%d", freq, is_dfs);
123 + hostapd_ubus_notify_csa(hapd, freq);
124 } else if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) {
125 /* Complete AP configuration for the first bring up. */
127 --- a/src/ap/hostapd.c
128 +++ b/src/ap/hostapd.c
129 @@ -479,6 +479,7 @@ void hostapd_free_hapd_data(struct hosta
130 hapd->beacon_set_done = 0;
132 wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
133 + hostapd_ubus_free_bss(hapd);
134 accounting_deinit(hapd);
135 hostapd_deinit_wpa(hapd);
137 @@ -1324,6 +1325,8 @@ static int hostapd_start_beacon(struct h
138 if (hapd->driver && hapd->driver->set_operstate)
139 hapd->driver->set_operstate(hapd->drv_priv, 1);
141 + hostapd_ubus_add_bss(hapd);
146 @@ -2546,6 +2549,7 @@ static int hostapd_setup_interface_compl
150 + hostapd_ubus_add_iface(iface);
151 wpa_printf(MSG_DEBUG, "Completing interface initialization");
154 @@ -2771,6 +2775,7 @@ dfs_offload:
157 wpa_printf(MSG_ERROR, "Interface initialization failed");
158 + hostapd_ubus_free_iface(iface);
160 if (iface->is_no_ir) {
161 hostapd_set_state(iface, HAPD_IFACE_NO_IR);
162 @@ -3501,6 +3506,7 @@ void hostapd_interface_deinit_free(struc
163 (unsigned int) iface->conf->num_bss);
164 driver = iface->bss[0]->driver;
165 drv_priv = iface->bss[0]->drv_priv;
166 + hostapd_ubus_free_iface(iface);
167 hostapd_interface_deinit(iface);
168 wpa_printf(MSG_DEBUG, "%s: driver=%p drv_priv=%p -> hapd_deinit",
169 __func__, driver, drv_priv);
170 --- a/src/ap/hostapd.h
171 +++ b/src/ap/hostapd.h
173 #include "utils/list.h"
174 #include "ap_config.h"
175 #include "drivers/driver.h"
178 #define OCE_STA_CFON_ENABLED(hapd) \
179 ((hapd->conf->oce & OCE_STA_CFON) && \
180 @@ -206,6 +207,7 @@ struct hostapd_data {
181 struct hostapd_iface *iface;
182 struct hostapd_config *iconf;
183 struct hostapd_bss_config *conf;
184 + struct hostapd_ubus_bss ubus;
185 int interface_added; /* virtual interface added for this BSS */
186 unsigned int started:1;
187 unsigned int disabled:1;
188 @@ -776,6 +778,7 @@ hostapd_alloc_bss_data(struct hostapd_if
189 struct hostapd_bss_config *bss);
190 int hostapd_setup_interface(struct hostapd_iface *iface);
191 int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
192 +void hostapd_set_own_neighbor_report(struct hostapd_data *hapd);
193 void hostapd_interface_deinit(struct hostapd_iface *iface);
194 void hostapd_interface_free(struct hostapd_iface *iface);
195 struct hostapd_iface * hostapd_alloc_iface(void);
196 --- a/src/ap/ieee802_11.c
197 +++ b/src/ap/ieee802_11.c
198 @@ -2941,7 +2941,7 @@ static void handle_auth(struct hostapd_d
199 u16 auth_alg, auth_transaction, status_code;
200 u16 resp = WLAN_STATUS_SUCCESS;
201 struct sta_info *sta = NULL;
202 - int res, reply_res;
203 + int res, reply_res, ubus_resp;
205 const u8 *challenge = NULL;
206 u8 resp_ies[2 + WLAN_AUTH_CHALLENGE_LEN];
207 @@ -2952,6 +2952,11 @@ static void handle_auth(struct hostapd_d
208 #ifdef CONFIG_IEEE80211BE
209 bool mld_sta = false;
210 #endif /* CONFIG_IEEE80211BE */
211 + struct hostapd_ubus_request req = {
212 + .type = HOSTAPD_UBUS_AUTH_REQ,
213 + .mgmt_frame = mgmt,
214 + .ssi_signal = rssi,
217 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
218 wpa_printf(MSG_INFO, "handle_auth - too short payload (len=%lu)",
219 @@ -3148,6 +3153,13 @@ static void handle_auth(struct hostapd_d
220 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
223 + ubus_resp = hostapd_ubus_handle_event(hapd, &req);
225 + wpa_printf(MSG_DEBUG, "Station " MACSTR " rejected by ubus handler.\n",
226 + MAC2STR(mgmt->sa));
227 + resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE;
230 if (res == HOSTAPD_ACL_PENDING)
233 @@ -5477,7 +5489,7 @@ static void handle_assoc(struct hostapd_
234 int resp = WLAN_STATUS_SUCCESS;
235 u16 reply_res = WLAN_STATUS_UNSPECIFIED_FAILURE;
238 + int left, i, ubus_resp;
239 struct sta_info *sta;
242 @@ -5719,6 +5731,11 @@ static void handle_assoc(struct hostapd_
245 #endif /* CONFIG_FILS */
246 + struct hostapd_ubus_request req = {
247 + .type = HOSTAPD_UBUS_ASSOC_REQ,
248 + .mgmt_frame = mgmt,
249 + .ssi_signal = rssi,
252 /* followed by SSID and Supported rates; and HT capabilities if 802.11n
254 @@ -5826,6 +5843,13 @@ static void handle_assoc(struct hostapd_
256 ieee802_11_update_beacons(hapd->iface);
258 + ubus_resp = hostapd_ubus_handle_event(hapd, &req);
260 + wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n",
261 + MAC2STR(mgmt->sa));
262 + resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE;
268 @@ -6055,6 +6079,7 @@ static void handle_disassoc(struct hosta
269 (unsigned long) len);
272 + hostapd_ubus_notify(hapd, "disassoc", mgmt->sa);
274 sta = ap_get_sta(hapd, mgmt->sa);
276 @@ -6086,6 +6111,8 @@ static void handle_deauth(struct hostapd
277 /* Clear the PTKSA cache entries for PASN */
278 ptksa_cache_flush(hapd->ptksa, mgmt->sa, WPA_CIPHER_NONE);
280 + hostapd_ubus_notify(hapd, "deauth", mgmt->sa);
282 sta = ap_get_sta(hapd, mgmt->sa);
284 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Station " MACSTR
287 @@ -89,6 +89,9 @@ static void hostapd_handle_beacon_report
289 wpa_msg(hapd->msg_ctx, MSG_INFO, BEACON_RESP_RX MACSTR " %u %02x %s",
290 MAC2STR(addr), token, rep_mode, report);
291 + if (len < sizeof(struct rrm_measurement_beacon_report))
293 + hostapd_ubus_notify_beacon_report(hapd, addr, token, rep_mode, (struct rrm_measurement_beacon_report*) pos, len);
297 @@ -406,7 +409,7 @@ void hostapd_handle_radio_measurement(st
298 hostapd_handle_nei_report_req(hapd, buf, len);
300 case WLAN_RRM_LINK_MEASUREMENT_REPORT:
301 - hostapd_handle_link_mesr_report(hapd, buf, len);
302 + hostapd_ubus_handle_link_measurement(hapd, buf, len);
305 wpa_printf(MSG_DEBUG, "RRM action %u is not supported",
306 --- a/src/ap/sta_info.c
307 +++ b/src/ap/sta_info.c
308 @@ -543,6 +543,7 @@ void ap_handle_timer(void *eloop_ctx, vo
309 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
310 HOSTAPD_LEVEL_INFO, "deauthenticated due to "
311 "local deauth request");
312 + hostapd_ubus_notify(hapd, "local-deauth", sta->addr);
313 ap_free_sta(hapd, sta);
316 @@ -700,6 +701,7 @@ skip_poll:
317 mlme_deauthenticate_indication(
319 WLAN_REASON_PREV_AUTH_NOT_VALID);
320 + hostapd_ubus_notify(hapd, "inactive-deauth", sta->addr);
321 ap_free_sta(hapd, sta);
324 @@ -1588,15 +1590,28 @@ void ap_sta_set_authorized_event(struct
325 os_snprintf(buf, sizeof(buf), MACSTR, MAC2STR(sta->addr));
328 + static const char * const auth_algs[] = {
329 + [WLAN_AUTH_OPEN] = "open",
330 + [WLAN_AUTH_SHARED_KEY] = "shared",
331 + [WLAN_AUTH_FT] = "ft",
332 + [WLAN_AUTH_SAE] = "sae",
333 + [WLAN_AUTH_FILS_SK] = "fils-sk",
334 + [WLAN_AUTH_FILS_SK_PFS] = "fils-sk-pfs",
335 + [WLAN_AUTH_FILS_PK] = "fils-pk",
336 + [WLAN_AUTH_PASN] = "pasn",
338 + const char *auth_alg = NULL;
339 const u8 *dpp_pkhash;
341 char dpp_pkhash_buf[100];
346 dpp_pkhash_buf[0] = '\0';
351 if (wpa_auth_get_ip_addr(sta->wpa_sm, ip_addr_buf) == 0) {
352 os_snprintf(ip_addr, sizeof(ip_addr),
353 @@ -1607,6 +1622,13 @@ void ap_sta_set_authorized_event(struct
355 #endif /* CONFIG_P2P */
357 + if (sta->auth_alg < ARRAY_SIZE(auth_algs))
358 + auth_alg = auth_algs[sta->auth_alg];
361 + os_snprintf(alg_buf, sizeof(alg_buf),
362 + " auth_alg=%s", auth_alg);
364 keyid = ap_sta_wpa_get_keyid(hapd, sta);
366 os_snprintf(keyid_buf, sizeof(keyid_buf),
367 @@ -1625,17 +1647,19 @@ void ap_sta_set_authorized_event(struct
368 dpp_pkhash, SHA256_MAC_LEN);
371 - wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED "%s%s%s%s",
372 - buf, ip_addr, keyid_buf, dpp_pkhash_buf);
373 + hostapd_ubus_notify_authorized(hapd, sta, auth_alg);
374 + wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED "%s%s%s%s%s",
375 + buf, ip_addr, keyid_buf, dpp_pkhash_buf, alg_buf);
377 if (hapd->msg_ctx_parent &&
378 hapd->msg_ctx_parent != hapd->msg_ctx)
379 wpa_msg_no_global(hapd->msg_ctx_parent, MSG_INFO,
380 - AP_STA_CONNECTED "%s%s%s%s",
381 + AP_STA_CONNECTED "%s%s%s%s%s",
382 buf, ip_addr, keyid_buf,
384 + dpp_pkhash_buf, alg_buf);
386 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED "%s", buf);
387 + hostapd_ubus_notify(hapd, "disassoc", sta->addr);
389 if (hapd->msg_ctx_parent &&
390 hapd->msg_ctx_parent != hapd->msg_ctx)
391 --- a/src/ap/sta_info.h
392 +++ b/src/ap/sta_info.h
393 @@ -305,6 +305,7 @@ struct sta_info {
394 #endif /* CONFIG_TESTING_OPTIONS */
395 #ifdef CONFIG_AIRTIME_POLICY
396 unsigned int airtime_weight;
397 + unsigned int dyn_airtime_weight;
398 struct os_reltime backlogged_until;
399 #endif /* CONFIG_AIRTIME_POLICY */
401 --- a/src/ap/vlan_init.c
402 +++ b/src/ap/vlan_init.c
404 static int vlan_if_add(struct hostapd_data *hapd, struct hostapd_vlan *vlan,
407 + bool vlan_exists = iface_exists(vlan->ifname);
411 @@ -36,7 +37,7 @@ static int vlan_if_add(struct hostapd_da
413 #endif /* CONFIG_WEP */
415 - if (!iface_exists(vlan->ifname))
417 ret = hostapd_vlan_if_add(hapd, vlan->ifname);
420 @@ -51,6 +52,9 @@ static int vlan_if_add(struct hostapd_da
422 ret = wpa_auth_ensure_group(hapd->wpa_auth, vlan->vlan_id);
424 + if (!ret && !vlan_exists)
425 + hostapd_ubus_add_vlan(hapd, vlan);
430 @@ -77,6 +81,8 @@ int vlan_if_remove(struct hostapd_data *
431 "WPA deinitialization for VLAN %d failed (%d)",
434 + hostapd_ubus_remove_vlan(hapd, vlan);
436 return hostapd_vlan_if_remove(hapd, vlan->ifname);
439 --- a/src/ap/wnm_ap.c
440 +++ b/src/ap/wnm_ap.c
441 @@ -479,7 +479,8 @@ static void ieee802_11_rx_bss_trans_mgmt
442 MAC2STR(addr), reason, hex ? " neighbor=" : "", hex);
445 - ieee802_11_send_bss_trans_mgmt_request(hapd, addr, dialog_token);
446 + if (!hostapd_ubus_notify_bss_transition_query(hapd, addr, dialog_token, reason, pos, end - pos))
447 + ieee802_11_send_bss_trans_mgmt_request(hapd, addr, dialog_token);
451 @@ -501,7 +502,7 @@ static void ieee802_11_rx_bss_trans_mgmt
454 u8 dialog_token, status_code, bss_termination_delay;
455 - const u8 *pos, *end;
456 + const u8 *pos, *end, *target_bssid = NULL;
457 int enabled = hapd->conf->bss_transition;
458 struct sta_info *sta;
460 @@ -548,6 +549,7 @@ static void ieee802_11_rx_bss_trans_mgmt
461 wpa_printf(MSG_DEBUG, "WNM: not enough room for Target BSSID field");
464 + target_bssid = pos;
465 sta->agreed_to_steer = 1;
466 eloop_cancel_timeout(ap_sta_reset_steer_flag_timer, hapd, sta);
467 eloop_register_timeout(2, 0, ap_sta_reset_steer_flag_timer,
468 @@ -567,6 +569,10 @@ static void ieee802_11_rx_bss_trans_mgmt
469 MAC2STR(addr), status_code, bss_termination_delay);
472 + hostapd_ubus_notify_bss_transition_response(hapd, sta->addr, dialog_token,
473 + status_code, bss_termination_delay,
474 + target_bssid, pos, end - pos);
476 wpa_hexdump(MSG_DEBUG, "WNM: BSS Transition Candidate List Entries",
479 --- a/src/ap/wpa_auth_glue.c
480 +++ b/src/ap/wpa_auth_glue.c
481 @@ -331,6 +331,7 @@ static void hostapd_wpa_auth_psk_failure
482 struct hostapd_data *hapd = ctx;
483 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_POSSIBLE_PSK_MISMATCH MACSTR,
485 + hostapd_ubus_notify(hapd, "key-mismatch", addr);
489 --- a/src/utils/eloop.c
490 +++ b/src/utils/eloop.c
491 @@ -77,6 +77,9 @@ struct eloop_sock_table {
495 + eloop_timeout_poll_handler timeout_poll_cb;
496 + eloop_poll_handler poll_cb;
498 size_t count; /* sum of all table counts */
499 #ifdef CONFIG_ELOOP_POLL
500 size_t max_pollfd_map; /* number of pollfds_map currently allocated */
501 @@ -1121,6 +1124,12 @@ void eloop_run(void)
502 os_reltime_sub(&timeout->time, &now, &tv);
504 tv.sec = tv.usec = 0;
507 + if (eloop.timeout_poll_cb && eloop.timeout_poll_cb(&tv, !!timeout))
508 + timeout = (void *)1;
511 #if defined(CONFIG_ELOOP_POLL) || defined(CONFIG_ELOOP_EPOLL)
512 timeout_ms = tv.sec * 1000 + tv.usec / 1000;
513 #endif /* defined(CONFIG_ELOOP_POLL) || defined(CONFIG_ELOOP_EPOLL) */
514 @@ -1190,7 +1199,8 @@ void eloop_run(void)
515 eloop.exceptions.changed = 0;
517 eloop_process_pending_signals();
522 /* check if some registered timeouts have occurred */
523 timeout = dl_list_first(&eloop.timeout, struct eloop_timeout,
524 @@ -1252,6 +1262,14 @@ out:
528 +int eloop_register_cb(eloop_poll_handler poll_cb,
529 + eloop_timeout_poll_handler timeout_cb)
531 + eloop.poll_cb = poll_cb;
532 + eloop.timeout_poll_cb = timeout_cb;
537 void eloop_terminate(void)
539 --- a/src/utils/eloop.h
540 +++ b/src/utils/eloop.h
541 @@ -65,6 +65,9 @@ typedef void (*eloop_timeout_handler)(vo
543 typedef void (*eloop_signal_handler)(int sig, void *signal_ctx);
545 +typedef bool (*eloop_timeout_poll_handler)(struct os_reltime *tv, bool tv_set);
546 +typedef void (*eloop_poll_handler)(void);
549 * eloop_init() - Initialize global event loop data
550 * Returns: 0 on success, -1 on failure
551 @@ -73,6 +76,9 @@ typedef void (*eloop_signal_handler)(int
553 int eloop_init(void);
555 +int eloop_register_cb(eloop_poll_handler poll_cb,
556 + eloop_timeout_poll_handler timeout_cb);
559 * eloop_register_read_sock - Register handler for read events
560 * @sock: File descriptor number for the socket
561 @@ -320,6 +326,8 @@ int eloop_register_signal_reconfig(eloop
563 int eloop_sock_requeue(void);
565 +void eloop_add_uloop(void);
568 * eloop_run - Start the event loop
571 +++ b/src/utils/uloop.c
573 +#include <libubox/uloop.h>
574 +#include "includes.h"
578 +static void eloop_uloop_event_cb(int sock, void *eloop_ctx, void *sock_ctx)
582 +static void eloop_uloop_fd_cb(struct uloop_fd *fd, unsigned int events)
584 + unsigned int changed = events ^ fd->flags;
586 + if (changed & ULOOP_READ) {
587 + if (events & ULOOP_READ)
588 + eloop_register_sock(fd->fd, EVENT_TYPE_READ, eloop_uloop_event_cb, fd, fd);
590 + eloop_unregister_sock(fd->fd, EVENT_TYPE_READ);
593 + if (changed & ULOOP_WRITE) {
594 + if (events & ULOOP_WRITE)
595 + eloop_register_sock(fd->fd, EVENT_TYPE_WRITE, eloop_uloop_event_cb, fd, fd);
597 + eloop_unregister_sock(fd->fd, EVENT_TYPE_WRITE);
601 +static bool uloop_timeout_poll_handler(struct os_reltime *tv, bool tv_set)
603 + struct os_reltime tv_uloop;
604 + int timeout_ms = uloop_get_next_timeout();
606 + if (timeout_ms < 0)
609 + tv_uloop.sec = timeout_ms / 1000;
610 + tv_uloop.usec = (timeout_ms % 1000) * 1000;
612 + if (!tv_set || os_reltime_before(&tv_uloop, tv)) {
620 +static void uloop_poll_handler(void)
622 + uloop_run_timeout(0);
625 +void eloop_add_uloop(void)
627 + static bool init_done = false;
631 + uloop_fd_set_cb = eloop_uloop_fd_cb;
635 + eloop_register_cb(uloop_poll_handler, uloop_timeout_poll_handler);
637 --- a/wpa_supplicant/Makefile
638 +++ b/wpa_supplicant/Makefile
639 @@ -191,6 +191,13 @@ ifdef CONFIG_EAPOL_TEST
640 CFLAGS += -Werror -DEAPOL_TEST
644 +CFLAGS += -DUBUS_SUPPORT
646 +OBJS += ../src/utils/uloop.o
647 +LIBS += -lubox -lubus
650 ifdef CONFIG_CODE_COVERAGE
651 CFLAGS += -O0 -fprofile-arcs -ftest-coverage -U_FORTIFY_SOURCE
653 @@ -1044,6 +1051,9 @@ ifdef CONFIG_CTRL_IFACE_MIB
654 CFLAGS += -DCONFIG_CTRL_IFACE_MIB
656 OBJS += ../src/ap/ctrl_iface_ap.o
658 +OBJS += ../src/ap/ubus.o
662 CFLAGS += -DEAP_SERVER -DEAP_SERVER_IDENTITY
663 --- a/wpa_supplicant/main.c
664 +++ b/wpa_supplicant/main.c
665 @@ -203,7 +203,7 @@ int main(int argc, char *argv[])
668 c = getopt(argc, argv,
669 - "b:Bc:C:D:de:f:g:G:hi:I:KLMm:No:O:p:P:qsTtuv::W");
670 + "b:Bc:C:D:de:f:g:G:hi:I:KLMm:nNo:O:p:P:qsTtuv::W");
674 @@ -268,6 +268,9 @@ int main(int argc, char *argv[])
675 params.conf_p2p_dev = optarg;
677 #endif /* CONFIG_P2P */
682 params.override_driver = optarg;
684 --- a/wpa_supplicant/wpa_supplicant.c
685 +++ b/wpa_supplicant/wpa_supplicant.c
686 @@ -8195,6 +8195,8 @@ struct wpa_supplicant * wpa_supplicant_a
688 #endif /* CONFIG_P2P */
690 + wpas_ubus_add_bss(wpa_s);
695 @@ -8221,6 +8223,8 @@ int wpa_supplicant_remove_iface(struct w
696 struct wpa_supplicant *parent = wpa_s->parent;
697 #endif /* CONFIG_MESH */
699 + wpas_ubus_free_bss(wpa_s);
701 /* Remove interface from the global list of interfaces */
702 prev = global->ifaces;
704 @@ -8567,8 +8571,12 @@ int wpa_supplicant_run(struct wpa_global
705 eloop_register_signal_terminate(wpa_supplicant_terminate, global);
706 eloop_register_signal_reconfig(wpa_supplicant_reconfig, global);
708 + wpas_ubus_add(global);
712 + wpas_ubus_free(global);
717 --- a/wpa_supplicant/wpa_supplicant_i.h
718 +++ b/wpa_supplicant/wpa_supplicant_i.h
720 #include "config_ssid.h"
722 #include "pasn/pasn_common.h"
725 extern const char *const wpa_supplicant_version;
726 extern const char *const wpa_supplicant_license;
727 @@ -319,6 +320,8 @@ struct wpa_global {
728 #endif /* CONFIG_WIFI_DISPLAY */
730 struct psk_list_entry *add_psk; /* From group formation */
732 + struct ubus_object ubus_global;
736 @@ -705,6 +708,7 @@ struct wpa_supplicant {
737 unsigned char own_addr[ETH_ALEN];
738 unsigned char perm_addr[ETH_ALEN];
740 + struct wpas_ubus_bss ubus;
741 #ifdef CONFIG_MATCH_IFACE
743 #endif /* CONFIG_MATCH_IFACE */
744 --- a/wpa_supplicant/wps_supplicant.c
745 +++ b/wpa_supplicant/wps_supplicant.c
748 #include "p2p_supplicant.h"
749 #include "wps_supplicant.h"
753 #ifndef WPS_PIN_SCAN_IGNORE_SEL_REG
754 @@ -401,6 +402,8 @@ static int wpa_supplicant_wps_cred(void
755 wpa_hexdump_key(MSG_DEBUG, "WPS: Received Credential attribute",
756 cred->cred_attr, cred->cred_attr_len);
758 + wpas_ubus_notify(wpa_s, cred);
760 if (wpa_s->conf->wps_cred_processing == 1)