1 Index: hostapd-2017-08-24-c2d4f2eb/hostapd/Makefile
2 ===================================================================
3 --- hostapd-2017-08-24-c2d4f2eb.orig/hostapd/Makefile
4 +++ hostapd-2017-08-24-c2d4f2eb/hostapd/Makefile
5 @@ -165,6 +165,11 @@ OBJS += ../src/common/hw_features_common
7 OBJS += ../src/eapol_auth/eapol_auth_sm.o
10 +CFLAGS += -DUBUS_SUPPORT
11 +OBJS += ../src/ap/ubus.o
12 +LIBS += -lubox -lubus
15 ifdef CONFIG_CODE_COVERAGE
16 CFLAGS += -O0 -fprofile-arcs -ftest-coverage
17 Index: hostapd-2017-08-24-c2d4f2eb/src/ap/hostapd.h
18 ===================================================================
19 --- hostapd-2017-08-24-c2d4f2eb.orig/src/ap/hostapd.h
20 +++ hostapd-2017-08-24-c2d4f2eb/src/ap/hostapd.h
22 #include "utils/list.h"
23 #include "ap_config.h"
24 #include "drivers/driver.h"
28 struct radius_server_data;
29 @@ -122,6 +123,7 @@ struct hostapd_data {
30 struct hostapd_iface *iface;
31 struct hostapd_config *iconf;
32 struct hostapd_bss_config *conf;
33 + struct hostapd_ubus_bss ubus;
34 int interface_added; /* virtual interface added for this BSS */
35 unsigned int started:1;
36 unsigned int disabled:1;
37 @@ -370,6 +372,8 @@ struct hostapd_iface {
38 struct hostapd_config *conf;
39 char phy[16]; /* Name of the PHY (radio) */
41 + struct hostapd_ubus_iface ubus;
43 enum hostapd_iface_state {
44 HAPD_IFACE_UNINITIALIZED,
46 Index: hostapd-2017-08-24-c2d4f2eb/src/ap/hostapd.c
47 ===================================================================
48 --- hostapd-2017-08-24-c2d4f2eb.orig/src/ap/hostapd.c
49 +++ hostapd-2017-08-24-c2d4f2eb/src/ap/hostapd.c
50 @@ -309,6 +309,7 @@ static void hostapd_free_hapd_data(struc
53 wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
54 + hostapd_ubus_free_bss(hapd);
55 iapp_deinit(hapd->iapp);
57 accounting_deinit(hapd);
58 @@ -1186,6 +1187,8 @@ static int hostapd_setup_bss(struct host
59 if (hapd->driver && hapd->driver->set_operstate)
60 hapd->driver->set_operstate(hapd->drv_priv, 1);
62 + hostapd_ubus_add_bss(hapd);
67 @@ -1711,6 +1714,7 @@ static int hostapd_setup_interface_compl
71 + hostapd_ubus_add_iface(iface);
72 wpa_printf(MSG_DEBUG, "Completing interface initialization");
73 if (iface->conf->channel) {
75 @@ -1890,6 +1894,7 @@ dfs_offload:
78 wpa_printf(MSG_ERROR, "Interface initialization failed");
79 + hostapd_ubus_free_iface(iface);
80 hostapd_set_state(iface, HAPD_IFACE_DISABLED);
81 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED);
83 @@ -2344,6 +2349,7 @@ void hostapd_interface_deinit_free(struc
84 (unsigned int) iface->conf->num_bss);
85 driver = iface->bss[0]->driver;
86 drv_priv = iface->bss[0]->drv_priv;
87 + hostapd_ubus_free_iface(iface);
88 hostapd_interface_deinit(iface);
89 wpa_printf(MSG_DEBUG, "%s: driver=%p drv_priv=%p -> hapd_deinit",
90 __func__, driver, drv_priv);
91 Index: hostapd-2017-08-24-c2d4f2eb/src/ap/ieee802_11.c
92 ===================================================================
93 --- hostapd-2017-08-24-c2d4f2eb.orig/src/ap/ieee802_11.c
94 +++ hostapd-2017-08-24-c2d4f2eb/src/ap/ieee802_11.c
95 @@ -1587,7 +1587,8 @@ ieee802_11_set_radius_info(struct hostap
98 static void handle_auth(struct hostapd_data *hapd,
99 - const struct ieee80211_mgmt *mgmt, size_t len)
100 + const struct ieee80211_mgmt *mgmt, size_t len,
101 + struct hostapd_frame_info *fi)
103 u16 auth_alg, auth_transaction, status_code;
104 u16 resp = WLAN_STATUS_SUCCESS;
105 @@ -1603,6 +1604,11 @@ static void handle_auth(struct hostapd_d
106 char *identity = NULL;
107 char *radius_cui = NULL;
109 + struct hostapd_ubus_request req = {
110 + .type = HOSTAPD_UBUS_AUTH_REQ,
111 + .mgmt_frame = mgmt,
115 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
116 wpa_printf(MSG_INFO, "handle_auth - too short payload (len=%lu)",
117 @@ -1757,6 +1763,12 @@ static void handle_auth(struct hostapd_d
118 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
121 + if (hostapd_ubus_handle_event(hapd, &req)) {
122 + wpa_printf(MSG_DEBUG, "Station " MACSTR " rejected by ubus handler.\n",
123 + MAC2STR(mgmt->sa));
124 + resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
127 if (res == HOSTAPD_ACL_PENDING)
130 @@ -2870,7 +2882,7 @@ void fils_hlp_timeout(void *eloop_ctx, v
132 static void handle_assoc(struct hostapd_data *hapd,
133 const struct ieee80211_mgmt *mgmt, size_t len,
135 + int reassoc, struct hostapd_frame_info *fi)
137 u16 capab_info, listen_interval, seq_ctrl, fc;
138 u16 resp = WLAN_STATUS_SUCCESS, reply_res;
139 @@ -2884,6 +2896,11 @@ static void handle_assoc(struct hostapd_
142 #endif /* CONFIG_FILS */
143 + struct hostapd_ubus_request req = {
144 + .type = HOSTAPD_UBUS_ASSOC_REQ,
145 + .mgmt_frame = mgmt,
149 if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_req) :
150 sizeof(mgmt->u.assoc_req))) {
151 @@ -3051,6 +3068,13 @@ static void handle_assoc(struct hostapd_
153 #endif /* CONFIG_MBO */
155 + if (hostapd_ubus_handle_event(hapd, &req)) {
156 + wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n",
157 + MAC2STR(mgmt->sa));
158 + resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
163 * sta->capability is used in check_assoc_ies() for RRM enabled
164 * capability element.
165 @@ -3258,6 +3282,7 @@ static void handle_disassoc(struct hosta
166 wpa_printf(MSG_DEBUG, "disassocation: STA=" MACSTR " reason_code=%d",
168 le_to_host16(mgmt->u.disassoc.reason_code));
169 + hostapd_ubus_notify(hapd, "disassoc", mgmt->sa);
171 sta = ap_get_sta(hapd, mgmt->sa);
173 @@ -3323,6 +3348,8 @@ static void handle_deauth(struct hostapd
175 MAC2STR(mgmt->sa), le_to_host16(mgmt->u.deauth.reason_code));
177 + hostapd_ubus_notify(hapd, "deauth", mgmt->sa);
179 sta = ap_get_sta(hapd, mgmt->sa);
181 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Station " MACSTR " trying "
182 @@ -3637,7 +3664,7 @@ int ieee802_11_mgmt(struct hostapd_data
185 if (stype == WLAN_FC_STYPE_PROBE_REQ) {
186 - handle_probe_req(hapd, mgmt, len, fi->ssi_signal);
187 + handle_probe_req(hapd, mgmt, len, fi);
191 @@ -3657,17 +3684,17 @@ int ieee802_11_mgmt(struct hostapd_data
193 case WLAN_FC_STYPE_AUTH:
194 wpa_printf(MSG_DEBUG, "mgmt::auth");
195 - handle_auth(hapd, mgmt, len);
196 + handle_auth(hapd, mgmt, len, fi);
199 case WLAN_FC_STYPE_ASSOC_REQ:
200 wpa_printf(MSG_DEBUG, "mgmt::assoc_req");
201 - handle_assoc(hapd, mgmt, len, 0);
202 + handle_assoc(hapd, mgmt, len, 0, fi);
205 case WLAN_FC_STYPE_REASSOC_REQ:
206 wpa_printf(MSG_DEBUG, "mgmt::reassoc_req");
207 - handle_assoc(hapd, mgmt, len, 1);
208 + handle_assoc(hapd, mgmt, len, 1, fi);
211 case WLAN_FC_STYPE_DISASSOC:
212 Index: hostapd-2017-08-24-c2d4f2eb/src/ap/beacon.c
213 ===================================================================
214 --- hostapd-2017-08-24-c2d4f2eb.orig/src/ap/beacon.c
215 +++ hostapd-2017-08-24-c2d4f2eb/src/ap/beacon.c
216 @@ -716,7 +716,7 @@ void sta_track_claim_taxonomy_info(struc
218 void handle_probe_req(struct hostapd_data *hapd,
219 const struct ieee80211_mgmt *mgmt, size_t len,
221 + struct hostapd_frame_info *fi)
224 struct ieee802_11_elems elems;
225 @@ -725,9 +725,15 @@ void handle_probe_req(struct hostapd_dat
228 enum ssid_match_result res;
229 + int ssi_signal = fi->ssi_signal;
233 + struct hostapd_ubus_request req = {
234 + .type = HOSTAPD_UBUS_PROBE_REQ,
235 + .mgmt_frame = mgmt,
239 if (len < IEEE80211_HDRLEN)
241 @@ -894,6 +900,12 @@ void handle_probe_req(struct hostapd_dat
243 #endif /* CONFIG_P2P */
245 + if (hostapd_ubus_handle_event(hapd, &req)) {
246 + wpa_printf(MSG_DEBUG, "Probe request for " MACSTR " rejected by ubus handler.\n",
247 + MAC2STR(mgmt->sa));
251 /* TODO: verify that supp_rates contains at least one matching rate
252 * with AP configuration */
254 Index: hostapd-2017-08-24-c2d4f2eb/src/ap/beacon.h
255 ===================================================================
256 --- hostapd-2017-08-24-c2d4f2eb.orig/src/ap/beacon.h
257 +++ hostapd-2017-08-24-c2d4f2eb/src/ap/beacon.h
258 @@ -14,7 +14,7 @@ struct ieee80211_mgmt;
260 void handle_probe_req(struct hostapd_data *hapd,
261 const struct ieee80211_mgmt *mgmt, size_t len,
263 + struct hostapd_frame_info *fi);
264 int ieee802_11_set_beacon(struct hostapd_data *hapd);
265 int ieee802_11_set_beacons(struct hostapd_iface *iface);
266 int ieee802_11_update_beacons(struct hostapd_iface *iface);
267 Index: hostapd-2017-08-24-c2d4f2eb/src/ap/drv_callbacks.c
268 ===================================================================
269 --- hostapd-2017-08-24-c2d4f2eb.orig/src/ap/drv_callbacks.c
270 +++ hostapd-2017-08-24-c2d4f2eb/src/ap/drv_callbacks.c
271 @@ -116,6 +116,10 @@ int hostapd_notif_assoc(struct hostapd_d
272 u16 reason = WLAN_REASON_UNSPECIFIED;
273 u16 status = WLAN_STATUS_SUCCESS;
274 const u8 *p2p_dev_addr = NULL;
275 + struct hostapd_ubus_request req = {
276 + .type = HOSTAPD_UBUS_ASSOC_REQ,
282 @@ -195,6 +199,12 @@ int hostapd_notif_assoc(struct hostapd_d
286 + if (hostapd_ubus_handle_event(hapd, &req)) {
287 + wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n",
288 + MAC2STR(req.addr));
294 wpabuf_free(sta->p2p_ie);
295 Index: hostapd-2017-08-24-c2d4f2eb/src/ap/sta_info.c
296 ===================================================================
297 --- hostapd-2017-08-24-c2d4f2eb.orig/src/ap/sta_info.c
298 +++ hostapd-2017-08-24-c2d4f2eb/src/ap/sta_info.c
299 @@ -404,6 +404,7 @@ void ap_handle_timer(void *eloop_ctx, vo
300 HOSTAPD_LEVEL_INFO, "deauthenticated due to "
301 "local deauth request");
302 ap_free_sta(hapd, sta);
303 + hostapd_ubus_notify(hapd, "local-deauth", sta->addr);
307 @@ -551,6 +552,7 @@ skip_poll:
309 WLAN_REASON_PREV_AUTH_NOT_VALID);
310 ap_free_sta(hapd, sta);
311 + hostapd_ubus_notify(hapd, "inactive-deauth", sta->addr);
315 @@ -1212,6 +1214,7 @@ void ap_sta_set_authorized(struct hostap
318 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED "%s", buf);
319 + hostapd_ubus_notify(hapd, "disassoc", sta->addr);
321 if (hapd->msg_ctx_parent &&
322 hapd->msg_ctx_parent != hapd->msg_ctx)
323 Index: hostapd-2017-08-24-c2d4f2eb/src/ap/wpa_auth_glue.c
324 ===================================================================
325 --- hostapd-2017-08-24-c2d4f2eb.orig/src/ap/wpa_auth_glue.c
326 +++ hostapd-2017-08-24-c2d4f2eb/src/ap/wpa_auth_glue.c
327 @@ -175,6 +175,7 @@ static void hostapd_wpa_auth_psk_failure
328 struct hostapd_data *hapd = ctx;
329 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_POSSIBLE_PSK_MISMATCH MACSTR,
331 + hostapd_ubus_notify(hapd, "key-mismatch", addr);