3 @@ -165,6 +165,11 @@ OBJS += ../src/common/hw_features_common
5 OBJS += ../src/eapol_auth/eapol_auth_sm.o
8 +CFLAGS += -DUBUS_SUPPORT
9 +OBJS += ../src/ap/ubus.o
10 +LIBS += -lubox -lubus
13 ifdef CONFIG_CODE_COVERAGE
14 CFLAGS += -O0 -fprofile-arcs -ftest-coverage
15 --- a/src/ap/hostapd.h
16 +++ b/src/ap/hostapd.h
18 #include "utils/list.h"
19 #include "ap_config.h"
20 #include "drivers/driver.h"
23 #define OCE_STA_CFON_ENABLED(hapd) \
24 ((hapd->conf->oce & OCE_STA_CFON) && \
25 @@ -141,6 +142,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 unsigned int started:1;
32 unsigned int disabled:1;
33 --- a/src/ap/hostapd.c
34 +++ b/src/ap/hostapd.c
35 @@ -374,6 +374,7 @@ static void hostapd_free_hapd_data(struc
36 hapd->beacon_set_done = 0;
38 wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
39 + hostapd_ubus_free_bss(hapd);
40 iapp_deinit(hapd->iapp);
42 accounting_deinit(hapd);
43 @@ -1314,6 +1315,8 @@ static int hostapd_setup_bss(struct host
44 if (hapd->driver && hapd->driver->set_operstate)
45 hapd->driver->set_operstate(hapd->drv_priv, 1);
47 + hostapd_ubus_add_bss(hapd);
52 @@ -1828,6 +1831,7 @@ static int hostapd_setup_interface_compl
56 + hostapd_ubus_add_iface(iface);
57 wpa_printf(MSG_DEBUG, "Completing interface initialization");
58 if (iface->conf->channel) {
60 @@ -2020,6 +2024,7 @@ dfs_offload:
63 wpa_printf(MSG_ERROR, "Interface initialization failed");
64 + hostapd_ubus_free_iface(iface);
65 hostapd_set_state(iface, HAPD_IFACE_DISABLED);
66 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED);
68 @@ -2489,6 +2494,7 @@ void hostapd_interface_deinit_free(struc
69 (unsigned int) iface->conf->num_bss);
70 driver = iface->bss[0]->driver;
71 drv_priv = iface->bss[0]->drv_priv;
72 + hostapd_ubus_free_iface(iface);
73 hostapd_interface_deinit(iface);
74 wpa_printf(MSG_DEBUG, "%s: driver=%p drv_priv=%p -> hapd_deinit",
75 __func__, driver, drv_priv);
76 --- a/src/ap/ieee802_11.c
77 +++ b/src/ap/ieee802_11.c
78 @@ -2029,7 +2029,7 @@ static void handle_auth(struct hostapd_d
79 u16 auth_alg, auth_transaction, status_code;
80 u16 resp = WLAN_STATUS_SUCCESS;
81 struct sta_info *sta = NULL;
83 + int res, reply_res, ubus_resp;
85 const u8 *challenge = NULL;
86 u32 session_timeout, acct_interim_interval;
87 @@ -2040,6 +2040,11 @@ static void handle_auth(struct hostapd_d
88 char *identity = NULL;
89 char *radius_cui = NULL;
91 + struct hostapd_ubus_request req = {
92 + .type = HOSTAPD_UBUS_AUTH_REQ,
97 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
98 wpa_printf(MSG_INFO, "handle_auth - too short payload (len=%lu)",
99 @@ -2201,6 +2206,13 @@ static void handle_auth(struct hostapd_d
100 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
103 + ubus_resp = hostapd_ubus_handle_event(hapd, &req);
105 + wpa_printf(MSG_DEBUG, "Station " MACSTR " rejected by ubus handler.\n",
106 + MAC2STR(mgmt->sa));
107 + resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE;
110 if (res == HOSTAPD_ACL_PENDING)
113 @@ -3699,7 +3711,7 @@ static void handle_assoc(struct hostapd_
114 u16 capab_info, listen_interval, seq_ctrl, fc;
115 u16 resp = WLAN_STATUS_SUCCESS, reply_res;
118 + int left, i, ubus_resp;
119 struct sta_info *sta;
121 struct hostapd_sta_wpa_psk_short *psk = NULL;
122 @@ -3708,6 +3720,11 @@ static void handle_assoc(struct hostapd_
125 #endif /* CONFIG_FILS */
126 + struct hostapd_ubus_request req = {
127 + .type = HOSTAPD_UBUS_ASSOC_REQ,
128 + .mgmt_frame = mgmt,
129 + .ssi_signal = rssi,
132 if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_req) :
133 sizeof(mgmt->u.assoc_req))) {
134 @@ -3887,6 +3904,14 @@ static void handle_assoc(struct hostapd_
136 #endif /* CONFIG_MBO */
138 + ubus_resp = hostapd_ubus_handle_event(hapd, &req);
140 + wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n",
141 + MAC2STR(mgmt->sa));
142 + resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE;
147 * sta->capability is used in check_assoc_ies() for RRM enabled
148 * capability element.
149 @@ -4114,6 +4139,7 @@ static void handle_disassoc(struct hosta
150 wpa_printf(MSG_DEBUG, "disassocation: STA=" MACSTR " reason_code=%d",
152 le_to_host16(mgmt->u.disassoc.reason_code));
153 + hostapd_ubus_notify(hapd, "disassoc", mgmt->sa);
155 sta = ap_get_sta(hapd, mgmt->sa);
157 @@ -4179,6 +4205,8 @@ static void handle_deauth(struct hostapd
159 MAC2STR(mgmt->sa), le_to_host16(mgmt->u.deauth.reason_code));
161 + hostapd_ubus_notify(hapd, "deauth", mgmt->sa);
163 sta = ap_get_sta(hapd, mgmt->sa);
165 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Station " MACSTR " trying "
166 --- a/src/ap/beacon.c
167 +++ b/src/ap/beacon.c
168 @@ -744,6 +744,12 @@ void handle_probe_req(struct hostapd_dat
169 struct hostapd_sta_wpa_psk_short *psk = NULL;
170 char *identity = NULL;
171 char *radius_cui = NULL;
172 + struct hostapd_ubus_request req = {
173 + .type = HOSTAPD_UBUS_PROBE_REQ,
174 + .mgmt_frame = mgmt,
175 + .ssi_signal = ssi_signal,
179 if (len < IEEE80211_HDRLEN)
181 @@ -921,6 +927,12 @@ void handle_probe_req(struct hostapd_dat
183 #endif /* CONFIG_P2P */
185 + if (hostapd_ubus_handle_event(hapd, &req)) {
186 + wpa_printf(MSG_DEBUG, "Probe request for " MACSTR " rejected by ubus handler.\n",
187 + MAC2STR(mgmt->sa));
191 /* TODO: verify that supp_rates contains at least one matching rate
192 * with AP configuration */
194 --- a/src/ap/drv_callbacks.c
195 +++ b/src/ap/drv_callbacks.c
196 @@ -118,6 +118,10 @@ int hostapd_notif_assoc(struct hostapd_d
197 u16 reason = WLAN_REASON_UNSPECIFIED;
198 u16 status = WLAN_STATUS_SUCCESS;
199 const u8 *p2p_dev_addr = NULL;
200 + struct hostapd_ubus_request req = {
201 + .type = HOSTAPD_UBUS_ASSOC_REQ,
207 @@ -210,6 +214,12 @@ int hostapd_notif_assoc(struct hostapd_d
211 + if (hostapd_ubus_handle_event(hapd, &req)) {
212 + wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n",
213 + MAC2STR(req.addr));
219 wpabuf_free(sta->p2p_ie);
220 --- a/src/ap/sta_info.c
221 +++ b/src/ap/sta_info.c
222 @@ -423,6 +423,7 @@ void ap_handle_timer(void *eloop_ctx, vo
223 HOSTAPD_LEVEL_INFO, "deauthenticated due to "
224 "local deauth request");
225 ap_free_sta(hapd, sta);
226 + hostapd_ubus_notify(hapd, "local-deauth", sta->addr);
230 @@ -577,6 +578,7 @@ skip_poll:
232 WLAN_REASON_PREV_AUTH_NOT_VALID);
233 ap_free_sta(hapd, sta);
234 + hostapd_ubus_notify(hapd, "inactive-deauth", sta->addr);
238 @@ -1273,6 +1275,7 @@ void ap_sta_set_authorized(struct hostap
239 buf, ip_addr, keyid_buf);
241 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED "%s", buf);
242 + hostapd_ubus_notify(hapd, "disassoc", sta->addr);
244 if (hapd->msg_ctx_parent &&
245 hapd->msg_ctx_parent != hapd->msg_ctx)
246 --- a/src/ap/wpa_auth_glue.c
247 +++ b/src/ap/wpa_auth_glue.c
248 @@ -181,6 +181,7 @@ static void hostapd_wpa_auth_psk_failure
249 struct hostapd_data *hapd = ctx;
250 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_POSSIBLE_PSK_MISMATCH MACSTR,
252 + hostapd_ubus_notify(hapd, "key-mismatch", addr);
256 --- a/wpa_supplicant/Makefile
257 +++ b/wpa_supplicant/Makefile
258 @@ -188,6 +188,12 @@ ifdef CONFIG_EAPOL_TEST
259 CFLAGS += -Werror -DEAPOL_TEST
263 +CFLAGS += -DUBUS_SUPPORT
265 +LIBS += -lubox -lubus
268 ifdef CONFIG_CODE_COVERAGE
269 CFLAGS += -O0 -fprofile-arcs -ftest-coverage
271 @@ -923,6 +929,9 @@ endif
272 ifdef CONFIG_IEEE80211AX
273 OBJS += ../src/ap/ieee802_11_he.o
276 +OBJS += ../src/ap/ubus.o
280 CFLAGS += -DCONFIG_WNM_AP
281 --- a/wpa_supplicant/wpa_supplicant.c
282 +++ b/wpa_supplicant/wpa_supplicant.c
283 @@ -6288,6 +6288,8 @@ struct wpa_supplicant * wpa_supplicant_a
285 #endif /* CONFIG_P2P */
287 + wpas_ubus_add_bss(wpa_s);
292 @@ -6314,6 +6316,8 @@ int wpa_supplicant_remove_iface(struct w
293 struct wpa_supplicant *parent = wpa_s->parent;
294 #endif /* CONFIG_MESH */
296 + wpas_ubus_free_bss(wpa_s);
298 /* Remove interface from the global list of interfaces */
299 prev = global->ifaces;
301 --- a/wpa_supplicant/wpa_supplicant_i.h
302 +++ b/wpa_supplicant/wpa_supplicant_i.h
304 #include "wps/wps_defs.h"
305 #include "config_ssid.h"
309 extern const char *const wpa_supplicant_version;
310 extern const char *const wpa_supplicant_license;
311 @@ -506,6 +507,7 @@ struct wpa_supplicant {
312 unsigned char own_addr[ETH_ALEN];
313 unsigned char perm_addr[ETH_ALEN];
315 + struct wpas_ubus_bss ubus;
316 #ifdef CONFIG_MATCH_IFACE
318 #endif /* CONFIG_MATCH_IFACE */
319 --- a/wpa_supplicant/wps_supplicant.c
320 +++ b/wpa_supplicant/wps_supplicant.c
323 #include "p2p_supplicant.h"
324 #include "wps_supplicant.h"
328 #ifndef WPS_PIN_SCAN_IGNORE_SEL_REG
329 @@ -388,6 +389,8 @@ static int wpa_supplicant_wps_cred(void
330 wpa_hexdump_key(MSG_DEBUG, "WPS: Received Credential attribute",
331 cred->cred_attr, cred->cred_attr_len);
333 + wpas_ubus_notify(wpa_s, cred);
335 if (wpa_s->conf->wps_cred_processing == 1)