OpenWrt – Blame information for rev 3
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --- a/hostapd/Makefile |
2 | +++ b/hostapd/Makefile |
||
3 | @@ -165,6 +165,11 @@ OBJS += ../src/common/hw_features_common |
||
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 | ifdef CONFIG_CODE_COVERAGE |
||
14 | CFLAGS += -O0 -fprofile-arcs -ftest-coverage |
||
15 | --- a/src/ap/hostapd.h |
||
16 | +++ b/src/ap/hostapd.h |
||
17 | @@ -13,6 +13,7 @@ |
||
18 | #include "utils/list.h" |
||
19 | #include "ap_config.h" |
||
20 | #include "drivers/driver.h" |
||
21 | +#include "ubus.h" |
||
22 | |||
3 | office | 23 | struct wpa_ctrl_dst; |
24 | struct radius_server_data; |
||
25 | @@ -129,6 +130,7 @@ struct hostapd_data { |
||
1 | office | 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; |
||
3 | office | 33 | @@ -392,6 +394,8 @@ struct hostapd_iface { |
34 | struct hostapd_config *conf; |
||
35 | char phy[16]; /* Name of the PHY (radio) */ |
||
36 | |||
37 | + struct hostapd_ubus_iface ubus; |
||
38 | + |
||
39 | enum hostapd_iface_state { |
||
40 | HAPD_IFACE_UNINITIALIZED, |
||
41 | HAPD_IFACE_DISABLED, |
||
42 | @@ -544,6 +548,7 @@ hostapd_alloc_bss_data(struct hostapd_if |
||
1 | office | 43 | struct hostapd_bss_config *bss); |
44 | int hostapd_setup_interface(struct hostapd_iface *iface); |
||
45 | int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err); |
||
46 | +void hostapd_set_own_neighbor_report(struct hostapd_data *hapd); |
||
47 | void hostapd_interface_deinit(struct hostapd_iface *iface); |
||
48 | void hostapd_interface_free(struct hostapd_iface *iface); |
||
49 | struct hostapd_iface * hostapd_alloc_iface(void); |
||
50 | --- a/src/ap/hostapd.c |
||
51 | +++ b/src/ap/hostapd.c |
||
3 | office | 52 | @@ -312,6 +312,7 @@ static void hostapd_free_hapd_data(struc |
1 | office | 53 | hapd->started = 0; |
54 | |||
55 | wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface); |
||
56 | + hostapd_ubus_free_bss(hapd); |
||
57 | iapp_deinit(hapd->iapp); |
||
58 | hapd->iapp = NULL; |
||
59 | accounting_deinit(hapd); |
||
3 | office | 60 | @@ -1189,6 +1190,8 @@ static int hostapd_setup_bss(struct host |
1 | office | 61 | if (hapd->driver && hapd->driver->set_operstate) |
62 | hapd->driver->set_operstate(hapd->drv_priv, 1); |
||
63 | |||
64 | + hostapd_ubus_add_bss(hapd); |
||
65 | + |
||
66 | return 0; |
||
67 | } |
||
68 | |||
3 | office | 69 | @@ -1603,7 +1606,7 @@ static enum nr_chan_width hostapd_get_nr |
1 | office | 70 | #endif /* NEED_AP_MLME */ |
71 | |||
72 | |||
73 | -static void hostapd_set_own_neighbor_report(struct hostapd_data *hapd) |
||
74 | +void hostapd_set_own_neighbor_report(struct hostapd_data *hapd) |
||
75 | { |
||
76 | #ifdef NEED_AP_MLME |
||
77 | u16 capab = hostapd_own_capab_info(hapd); |
||
3 | office | 78 | @@ -1810,6 +1813,7 @@ static int hostapd_setup_interface_compl |
1 | office | 79 | if (err) |
80 | goto fail; |
||
81 | |||
82 | + hostapd_ubus_add_iface(iface); |
||
83 | wpa_printf(MSG_DEBUG, "Completing interface initialization"); |
||
84 | if (iface->conf->channel) { |
||
85 | #ifdef NEED_AP_MLME |
||
3 | office | 86 | @@ -1990,6 +1994,7 @@ dfs_offload: |
1 | office | 87 | |
88 | fail: |
||
89 | wpa_printf(MSG_ERROR, "Interface initialization failed"); |
||
90 | + hostapd_ubus_free_iface(iface); |
||
91 | hostapd_set_state(iface, HAPD_IFACE_DISABLED); |
||
92 | wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED); |
||
93 | #ifdef CONFIG_FST |
||
3 | office | 94 | @@ -2444,6 +2449,7 @@ void hostapd_interface_deinit_free(struc |
1 | office | 95 | (unsigned int) iface->conf->num_bss); |
96 | driver = iface->bss[0]->driver; |
||
97 | drv_priv = iface->bss[0]->drv_priv; |
||
98 | + hostapd_ubus_free_iface(iface); |
||
99 | hostapd_interface_deinit(iface); |
||
100 | wpa_printf(MSG_DEBUG, "%s: driver=%p drv_priv=%p -> hapd_deinit", |
||
101 | __func__, driver, drv_priv); |
||
102 | --- a/src/ap/ieee802_11.c |
||
103 | +++ b/src/ap/ieee802_11.c |
||
3 | office | 104 | @@ -1682,12 +1682,13 @@ ieee802_11_set_radius_info(struct hostap |
1 | office | 105 | |
106 | |||
107 | static void handle_auth(struct hostapd_data *hapd, |
||
108 | - const struct ieee80211_mgmt *mgmt, size_t len) |
||
109 | + const struct ieee80211_mgmt *mgmt, size_t len, |
||
110 | + struct hostapd_frame_info *fi) |
||
111 | { |
||
112 | u16 auth_alg, auth_transaction, status_code; |
||
113 | u16 resp = WLAN_STATUS_SUCCESS; |
||
114 | struct sta_info *sta = NULL; |
||
115 | - int res, reply_res; |
||
116 | + int res, reply_res, ubus_resp; |
||
117 | u16 fc; |
||
118 | const u8 *challenge = NULL; |
||
119 | u32 session_timeout, acct_interim_interval; |
||
3 | office | 120 | @@ -1698,6 +1699,11 @@ static void handle_auth(struct hostapd_d |
1 | office | 121 | char *identity = NULL; |
122 | char *radius_cui = NULL; |
||
123 | u16 seq_ctrl; |
||
124 | + struct hostapd_ubus_request req = { |
||
125 | + .type = HOSTAPD_UBUS_AUTH_REQ, |
||
126 | + .mgmt_frame = mgmt, |
||
127 | + .frame_info = fi, |
||
128 | + }; |
||
129 | |||
130 | if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) { |
||
131 | wpa_printf(MSG_INFO, "handle_auth - too short payload (len=%lu)", |
||
3 | office | 132 | @@ -1858,6 +1864,13 @@ static void handle_auth(struct hostapd_d |
1 | office | 133 | resp = WLAN_STATUS_UNSPECIFIED_FAILURE; |
134 | goto fail; |
||
135 | } |
||
136 | + ubus_resp = hostapd_ubus_handle_event(hapd, &req); |
||
137 | + if (ubus_resp) { |
||
138 | + wpa_printf(MSG_DEBUG, "Station " MACSTR " rejected by ubus handler.\n", |
||
139 | + MAC2STR(mgmt->sa)); |
||
140 | + resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE; |
||
141 | + goto fail; |
||
142 | + } |
||
143 | if (res == HOSTAPD_ACL_PENDING) |
||
144 | return; |
||
145 | |||
3 | office | 146 | @@ -3129,12 +3142,12 @@ void fils_hlp_timeout(void *eloop_ctx, v |
1 | office | 147 | |
148 | static void handle_assoc(struct hostapd_data *hapd, |
||
149 | const struct ieee80211_mgmt *mgmt, size_t len, |
||
150 | - int reassoc) |
||
151 | + int reassoc, struct hostapd_frame_info *fi) |
||
152 | { |
||
153 | u16 capab_info, listen_interval, seq_ctrl, fc; |
||
154 | u16 resp = WLAN_STATUS_SUCCESS, reply_res; |
||
155 | const u8 *pos; |
||
156 | - int left, i; |
||
157 | + int left, i, ubus_resp; |
||
158 | struct sta_info *sta; |
||
159 | u8 *tmp = NULL; |
||
160 | struct hostapd_sta_wpa_psk_short *psk = NULL; |
||
3 | office | 161 | @@ -3143,6 +3156,11 @@ static void handle_assoc(struct hostapd_ |
1 | office | 162 | #ifdef CONFIG_FILS |
163 | int delay_assoc = 0; |
||
164 | #endif /* CONFIG_FILS */ |
||
165 | + struct hostapd_ubus_request req = { |
||
166 | + .type = HOSTAPD_UBUS_ASSOC_REQ, |
||
167 | + .mgmt_frame = mgmt, |
||
168 | + .frame_info = fi, |
||
169 | + }; |
||
170 | |||
171 | if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_req) : |
||
172 | sizeof(mgmt->u.assoc_req))) { |
||
3 | office | 173 | @@ -3314,6 +3332,14 @@ static void handle_assoc(struct hostapd_ |
1 | office | 174 | } |
175 | #endif /* CONFIG_MBO */ |
||
176 | |||
177 | + ubus_resp = hostapd_ubus_handle_event(hapd, &req); |
||
178 | + if (ubus_resp) { |
||
179 | + wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n", |
||
180 | + MAC2STR(mgmt->sa)); |
||
181 | + resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE; |
||
182 | + goto fail; |
||
183 | + } |
||
184 | + |
||
185 | /* |
||
186 | * sta->capability is used in check_assoc_ies() for RRM enabled |
||
187 | * capability element. |
||
3 | office | 188 | @@ -3527,6 +3553,7 @@ static void handle_disassoc(struct hosta |
1 | office | 189 | wpa_printf(MSG_DEBUG, "disassocation: STA=" MACSTR " reason_code=%d", |
190 | MAC2STR(mgmt->sa), |
||
191 | le_to_host16(mgmt->u.disassoc.reason_code)); |
||
192 | + hostapd_ubus_notify(hapd, "disassoc", mgmt->sa); |
||
193 | |||
194 | sta = ap_get_sta(hapd, mgmt->sa); |
||
195 | if (sta == NULL) { |
||
3 | office | 196 | @@ -3592,6 +3619,8 @@ static void handle_deauth(struct hostapd |
1 | office | 197 | " reason_code=%d", |
198 | MAC2STR(mgmt->sa), le_to_host16(mgmt->u.deauth.reason_code)); |
||
199 | |||
200 | + hostapd_ubus_notify(hapd, "deauth", mgmt->sa); |
||
201 | + |
||
202 | sta = ap_get_sta(hapd, mgmt->sa); |
||
203 | if (sta == NULL) { |
||
204 | wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Station " MACSTR " trying " |
||
3 | office | 205 | @@ -3911,7 +3940,7 @@ int ieee802_11_mgmt(struct hostapd_data |
1 | office | 206 | |
207 | |||
208 | if (stype == WLAN_FC_STYPE_PROBE_REQ) { |
||
209 | - handle_probe_req(hapd, mgmt, len, ssi_signal); |
||
210 | + handle_probe_req(hapd, mgmt, len, fi); |
||
211 | return 1; |
||
212 | } |
||
213 | |||
3 | office | 214 | @@ -3931,17 +3960,17 @@ int ieee802_11_mgmt(struct hostapd_data |
1 | office | 215 | switch (stype) { |
216 | case WLAN_FC_STYPE_AUTH: |
||
217 | wpa_printf(MSG_DEBUG, "mgmt::auth"); |
||
218 | - handle_auth(hapd, mgmt, len); |
||
219 | + handle_auth(hapd, mgmt, len, fi); |
||
220 | ret = 1; |
||
221 | break; |
||
222 | case WLAN_FC_STYPE_ASSOC_REQ: |
||
223 | wpa_printf(MSG_DEBUG, "mgmt::assoc_req"); |
||
224 | - handle_assoc(hapd, mgmt, len, 0); |
||
225 | + handle_assoc(hapd, mgmt, len, 0, fi); |
||
226 | ret = 1; |
||
227 | break; |
||
228 | case WLAN_FC_STYPE_REASSOC_REQ: |
||
229 | wpa_printf(MSG_DEBUG, "mgmt::reassoc_req"); |
||
230 | - handle_assoc(hapd, mgmt, len, 1); |
||
231 | + handle_assoc(hapd, mgmt, len, 1, fi); |
||
232 | ret = 1; |
||
233 | break; |
||
234 | case WLAN_FC_STYPE_DISASSOC: |
||
235 | --- a/src/ap/beacon.c |
||
236 | +++ b/src/ap/beacon.c |
||
3 | office | 237 | @@ -720,7 +720,7 @@ void sta_track_claim_taxonomy_info(struc |
1 | office | 238 | |
239 | void handle_probe_req(struct hostapd_data *hapd, |
||
240 | const struct ieee80211_mgmt *mgmt, size_t len, |
||
241 | - int ssi_signal) |
||
242 | + struct hostapd_frame_info *fi) |
||
243 | { |
||
244 | u8 *resp; |
||
245 | struct ieee802_11_elems elems; |
||
3 | office | 246 | @@ -729,6 +729,7 @@ void handle_probe_req(struct hostapd_dat |
1 | office | 247 | size_t i, resp_len; |
248 | int noack; |
||
249 | enum ssid_match_result res; |
||
250 | + int ssi_signal = fi->ssi_signal; |
||
251 | int ret; |
||
252 | u16 csa_offs[2]; |
||
253 | size_t csa_offs_len; |
||
3 | office | 254 | @@ -737,6 +738,11 @@ void handle_probe_req(struct hostapd_dat |
1 | office | 255 | struct hostapd_sta_wpa_psk_short *psk = NULL; |
256 | char *identity = NULL; |
||
257 | char *radius_cui = NULL; |
||
258 | + struct hostapd_ubus_request req = { |
||
259 | + .type = HOSTAPD_UBUS_PROBE_REQ, |
||
260 | + .mgmt_frame = mgmt, |
||
261 | + .frame_info = fi, |
||
262 | + }; |
||
263 | |||
264 | if (len < IEEE80211_HDRLEN) |
||
265 | return; |
||
3 | office | 266 | @@ -914,6 +920,12 @@ void handle_probe_req(struct hostapd_dat |
1 | office | 267 | } |
268 | #endif /* CONFIG_P2P */ |
||
269 | |||
270 | + if (hostapd_ubus_handle_event(hapd, &req)) { |
||
271 | + wpa_printf(MSG_DEBUG, "Probe request for " MACSTR " rejected by ubus handler.\n", |
||
272 | + MAC2STR(mgmt->sa)); |
||
273 | + return; |
||
274 | + } |
||
275 | + |
||
276 | /* TODO: verify that supp_rates contains at least one matching rate |
||
277 | * with AP configuration */ |
||
278 | |||
279 | --- a/src/ap/beacon.h |
||
280 | +++ b/src/ap/beacon.h |
||
281 | @@ -14,7 +14,7 @@ struct ieee80211_mgmt; |
||
282 | |||
283 | void handle_probe_req(struct hostapd_data *hapd, |
||
284 | const struct ieee80211_mgmt *mgmt, size_t len, |
||
285 | - int ssi_signal); |
||
286 | + struct hostapd_frame_info *fi); |
||
287 | int ieee802_11_set_beacon(struct hostapd_data *hapd); |
||
288 | int ieee802_11_set_beacons(struct hostapd_iface *iface); |
||
289 | int ieee802_11_update_beacons(struct hostapd_iface *iface); |
||
290 | --- a/src/ap/drv_callbacks.c |
||
291 | +++ b/src/ap/drv_callbacks.c |
||
292 | @@ -116,6 +116,10 @@ int hostapd_notif_assoc(struct hostapd_d |
||
293 | u16 reason = WLAN_REASON_UNSPECIFIED; |
||
294 | u16 status = WLAN_STATUS_SUCCESS; |
||
295 | const u8 *p2p_dev_addr = NULL; |
||
296 | + struct hostapd_ubus_request req = { |
||
297 | + .type = HOSTAPD_UBUS_ASSOC_REQ, |
||
298 | + .addr = addr, |
||
299 | + }; |
||
300 | |||
301 | if (addr == NULL) { |
||
302 | /* |
||
303 | @@ -195,6 +199,12 @@ int hostapd_notif_assoc(struct hostapd_d |
||
304 | goto fail; |
||
305 | } |
||
306 | |||
307 | + if (hostapd_ubus_handle_event(hapd, &req)) { |
||
308 | + wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n", |
||
309 | + MAC2STR(req.addr)); |
||
310 | + goto fail; |
||
311 | + } |
||
312 | + |
||
313 | #ifdef CONFIG_P2P |
||
314 | if (elems.p2p) { |
||
315 | wpabuf_free(sta->p2p_ie); |
||
316 | --- a/src/ap/sta_info.c |
||
317 | +++ b/src/ap/sta_info.c |
||
3 | office | 318 | @@ -412,6 +412,7 @@ void ap_handle_timer(void *eloop_ctx, vo |
1 | office | 319 | HOSTAPD_LEVEL_INFO, "deauthenticated due to " |
320 | "local deauth request"); |
||
321 | ap_free_sta(hapd, sta); |
||
322 | + hostapd_ubus_notify(hapd, "local-deauth", sta->addr); |
||
323 | return; |
||
324 | } |
||
325 | |||
3 | office | 326 | @@ -559,6 +560,7 @@ skip_poll: |
1 | office | 327 | hapd, sta, |
328 | WLAN_REASON_PREV_AUTH_NOT_VALID); |
||
329 | ap_free_sta(hapd, sta); |
||
330 | + hostapd_ubus_notify(hapd, "inactive-deauth", sta->addr); |
||
331 | break; |
||
332 | } |
||
333 | } |
||
3 | office | 334 | @@ -1220,6 +1222,7 @@ void ap_sta_set_authorized(struct hostap |
1 | office | 335 | buf, ip_addr); |
336 | } else { |
||
337 | wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED "%s", buf); |
||
338 | + hostapd_ubus_notify(hapd, "disassoc", sta->addr); |
||
339 | |||
340 | if (hapd->msg_ctx_parent && |
||
341 | hapd->msg_ctx_parent != hapd->msg_ctx) |
||
342 | --- a/src/ap/wpa_auth_glue.c |
||
343 | +++ b/src/ap/wpa_auth_glue.c |
||
344 | @@ -177,6 +177,7 @@ static void hostapd_wpa_auth_psk_failure |
||
345 | struct hostapd_data *hapd = ctx; |
||
346 | wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_POSSIBLE_PSK_MISMATCH MACSTR, |
||
347 | MAC2STR(addr)); |
||
348 | + hostapd_ubus_notify(hapd, "key-mismatch", addr); |
||
349 | } |
||
350 | |||
351 |