• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * hostapd - Driver operations
3  * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #include "utils/includes.h"
10 
11 #include "utils/common.h"
12 #include "common/ieee802_11_defs.h"
13 #include "common/ieee802_11_common.h"
14 #include "common/hw_features_common.h"
15 #include "wps/wps.h"
16 #include "p2p/p2p.h"
17 #include "hostapd.h"
18 #include "ieee802_11.h"
19 #include "sta_info.h"
20 #include "ap_config.h"
21 #include "p2p_hostapd.h"
22 #include "hs20.h"
23 #include "wpa_auth.h"
24 #include "ap_drv_ops.h"
25 
26 
hostapd_sta_flags_to_drv(u32 flags)27 u32 hostapd_sta_flags_to_drv(u32 flags)
28 {
29 	int res = 0;
30 	if (flags & WLAN_STA_AUTHORIZED)
31 		res |= WPA_STA_AUTHORIZED;
32 	if (flags & WLAN_STA_WMM)
33 		res |= WPA_STA_WMM;
34 	if (flags & WLAN_STA_SHORT_PREAMBLE)
35 		res |= WPA_STA_SHORT_PREAMBLE;
36 	if (flags & WLAN_STA_MFP)
37 		res |= WPA_STA_MFP;
38 	if (flags & WLAN_STA_AUTH)
39 		res |= WPA_STA_AUTHENTICATED;
40 	if (flags & WLAN_STA_ASSOC)
41 		res |= WPA_STA_ASSOCIATED;
42 	return res;
43 }
44 
45 
add_buf(struct wpabuf ** dst,const struct wpabuf * src)46 static int add_buf(struct wpabuf **dst, const struct wpabuf *src)
47 {
48 	if (!src)
49 		return 0;
50 	if (wpabuf_resize(dst, wpabuf_len(src)) != 0)
51 		return -1;
52 	wpabuf_put_buf(*dst, src);
53 	return 0;
54 }
55 
56 
add_buf_data(struct wpabuf ** dst,const u8 * data,size_t len)57 static int add_buf_data(struct wpabuf **dst, const u8 *data, size_t len)
58 {
59 	if (!data || !len)
60 		return 0;
61 	if (wpabuf_resize(dst, len) != 0)
62 		return -1;
63 	wpabuf_put_data(*dst, data, len);
64 	return 0;
65 }
66 
67 
hostapd_build_ap_extra_ies(struct hostapd_data * hapd,struct wpabuf ** beacon_ret,struct wpabuf ** proberesp_ret,struct wpabuf ** assocresp_ret)68 int hostapd_build_ap_extra_ies(struct hostapd_data *hapd,
69 			       struct wpabuf **beacon_ret,
70 			       struct wpabuf **proberesp_ret,
71 			       struct wpabuf **assocresp_ret)
72 {
73 	struct wpabuf *beacon = NULL, *proberesp = NULL, *assocresp = NULL;
74 	u8 buf[200], *pos;
75 
76 	*beacon_ret = *proberesp_ret = *assocresp_ret = NULL;
77 
78 #ifdef NEED_AP_MLME
79 	pos = buf;
80 	pos = hostapd_eid_rm_enabled_capab(hapd, pos, sizeof(buf));
81 	if (add_buf_data(&assocresp, buf, pos - buf) < 0 ||
82 	    add_buf_data(&proberesp, buf, pos - buf) < 0)
83 		goto fail;
84 #endif /* NEED_AP_MLME */
85 
86 	pos = buf;
87 	pos = hostapd_eid_time_adv(hapd, pos);
88 	if (add_buf_data(&beacon, buf, pos - buf) < 0)
89 		goto fail;
90 	pos = hostapd_eid_time_zone(hapd, pos);
91 	if (add_buf_data(&proberesp, buf, pos - buf) < 0)
92 		goto fail;
93 
94 	pos = buf;
95 	pos = hostapd_eid_ext_capab(hapd, pos, false);
96 	if (add_buf_data(&assocresp, buf, pos - buf) < 0)
97 		goto fail;
98 	pos = hostapd_eid_interworking(hapd, pos);
99 	pos = hostapd_eid_adv_proto(hapd, pos);
100 	pos = hostapd_eid_roaming_consortium(hapd, pos);
101 	if (add_buf_data(&beacon, buf, pos - buf) < 0 ||
102 	    add_buf_data(&proberesp, buf, pos - buf) < 0)
103 		goto fail;
104 
105 #ifdef CONFIG_FST
106 	if (add_buf(&beacon, hapd->iface->fst_ies) < 0 ||
107 	    add_buf(&proberesp, hapd->iface->fst_ies) < 0 ||
108 	    add_buf(&assocresp, hapd->iface->fst_ies) < 0)
109 		goto fail;
110 #endif /* CONFIG_FST */
111 
112 #ifdef CONFIG_FILS
113 	pos = hostapd_eid_fils_indic(hapd, buf, 0);
114 	if (add_buf_data(&beacon, buf, pos - buf) < 0 ||
115 	    add_buf_data(&proberesp, buf, pos - buf) < 0)
116 		goto fail;
117 #endif /* CONFIG_FILS */
118 
119 	pos = hostapd_eid_rsnxe(hapd, buf, sizeof(buf));
120 	if (add_buf_data(&assocresp, buf, pos - buf) < 0)
121 		goto fail;
122 
123 	if (add_buf(&beacon, hapd->wps_beacon_ie) < 0 ||
124 	    add_buf(&proberesp, hapd->wps_probe_resp_ie) < 0)
125 		goto fail;
126 
127 #ifdef CONFIG_P2P
128 	if (add_buf(&beacon, hapd->p2p_beacon_ie) < 0 ||
129 	    add_buf(&proberesp, hapd->p2p_probe_resp_ie) < 0)
130 		goto fail;
131 #endif /* CONFIG_P2P */
132 
133 #ifdef CONFIG_P2P_MANAGER
134 	if (hapd->conf->p2p & P2P_MANAGE) {
135 		if (wpabuf_resize(&beacon, 100) == 0) {
136 			u8 *start, *p;
137 			start = wpabuf_put(beacon, 0);
138 			p = hostapd_eid_p2p_manage(hapd, start);
139 			wpabuf_put(beacon, p - start);
140 		}
141 
142 		if (wpabuf_resize(&proberesp, 100) == 0) {
143 			u8 *start, *p;
144 			start = wpabuf_put(proberesp, 0);
145 			p = hostapd_eid_p2p_manage(hapd, start);
146 			wpabuf_put(proberesp, p - start);
147 		}
148 	}
149 #endif /* CONFIG_P2P_MANAGER */
150 
151 #ifdef CONFIG_WPS
152 	if (hapd->conf->wps_state) {
153 		struct wpabuf *a = wps_build_assoc_resp_ie();
154 		add_buf(&assocresp, a);
155 		wpabuf_free(a);
156 	}
157 #endif /* CONFIG_WPS */
158 
159 #ifdef CONFIG_P2P_MANAGER
160 	if (hapd->conf->p2p & P2P_MANAGE) {
161 		if (wpabuf_resize(&assocresp, 100) == 0) {
162 			u8 *start, *p;
163 			start = wpabuf_put(assocresp, 0);
164 			p = hostapd_eid_p2p_manage(hapd, start);
165 			wpabuf_put(assocresp, p - start);
166 		}
167 	}
168 #endif /* CONFIG_P2P_MANAGER */
169 
170 #ifdef CONFIG_WIFI_DISPLAY
171 	if (hapd->p2p_group) {
172 		struct wpabuf *a;
173 		a = p2p_group_assoc_resp_ie(hapd->p2p_group, P2P_SC_SUCCESS);
174 		add_buf(&assocresp, a);
175 		wpabuf_free(a);
176 	}
177 #endif /* CONFIG_WIFI_DISPLAY */
178 
179 #ifdef CONFIG_HS20
180 	pos = hostapd_eid_hs20_indication(hapd, buf);
181 	if (add_buf_data(&beacon, buf, pos - buf) < 0 ||
182 	    add_buf_data(&proberesp, buf, pos - buf) < 0)
183 		goto fail;
184 
185 	pos = hostapd_eid_osen(hapd, buf);
186 	if (add_buf_data(&beacon, buf, pos - buf) < 0 ||
187 	    add_buf_data(&proberesp, buf, pos - buf) < 0)
188 		goto fail;
189 #endif /* CONFIG_HS20 */
190 
191 #ifdef CONFIG_MBO
192 	if (hapd->conf->mbo_enabled ||
193 	    OCE_STA_CFON_ENABLED(hapd) || OCE_AP_ENABLED(hapd)) {
194 		pos = hostapd_eid_mbo(hapd, buf, sizeof(buf));
195 		if (add_buf_data(&beacon, buf, pos - buf) < 0 ||
196 		    add_buf_data(&proberesp, buf, pos - buf) < 0 ||
197 		    add_buf_data(&assocresp, buf, pos - buf) < 0)
198 			goto fail;
199 	}
200 #endif /* CONFIG_MBO */
201 
202 #ifdef CONFIG_OWE
203 	pos = hostapd_eid_owe_trans(hapd, buf, sizeof(buf));
204 	if (add_buf_data(&beacon, buf, pos - buf) < 0 ||
205 	    add_buf_data(&proberesp, buf, pos - buf) < 0)
206 		goto fail;
207 #endif /* CONFIG_OWE */
208 
209 	add_buf(&beacon, hapd->conf->vendor_elements);
210 	add_buf(&proberesp, hapd->conf->vendor_elements);
211 	add_buf(&assocresp, hapd->conf->assocresp_elements);
212 
213 	*beacon_ret = beacon;
214 	*proberesp_ret = proberesp;
215 	*assocresp_ret = assocresp;
216 
217 	return 0;
218 
219 fail:
220 	wpabuf_free(beacon);
221 	wpabuf_free(proberesp);
222 	wpabuf_free(assocresp);
223 	return -1;
224 }
225 
226 
hostapd_free_ap_extra_ies(struct hostapd_data * hapd,struct wpabuf * beacon,struct wpabuf * proberesp,struct wpabuf * assocresp)227 void hostapd_free_ap_extra_ies(struct hostapd_data *hapd,
228 			       struct wpabuf *beacon,
229 			       struct wpabuf *proberesp,
230 			       struct wpabuf *assocresp)
231 {
232 	wpabuf_free(beacon);
233 	wpabuf_free(proberesp);
234 	wpabuf_free(assocresp);
235 }
236 
237 
hostapd_reset_ap_wps_ie(struct hostapd_data * hapd)238 int hostapd_reset_ap_wps_ie(struct hostapd_data *hapd)
239 {
240 	if (hapd->driver == NULL || hapd->driver->set_ap_wps_ie == NULL)
241 		return 0;
242 
243 	return hapd->driver->set_ap_wps_ie(hapd->drv_priv, NULL, NULL, NULL);
244 }
245 
246 
hostapd_set_ap_wps_ie(struct hostapd_data * hapd)247 int hostapd_set_ap_wps_ie(struct hostapd_data *hapd)
248 {
249 	struct wpabuf *beacon, *proberesp, *assocresp;
250 	int ret;
251 
252 	if (hapd->driver == NULL || hapd->driver->set_ap_wps_ie == NULL)
253 		return 0;
254 
255 	if (hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp) <
256 	    0)
257 		return -1;
258 
259 	ret = hapd->driver->set_ap_wps_ie(hapd->drv_priv, beacon, proberesp,
260 					  assocresp);
261 
262 	hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp);
263 
264 	return ret;
265 }
266 
267 
hostapd_set_authorized(struct hostapd_data * hapd,struct sta_info * sta,int authorized)268 int hostapd_set_authorized(struct hostapd_data *hapd,
269 			   struct sta_info *sta, int authorized)
270 {
271 	if (authorized) {
272 		return hostapd_sta_set_flags(hapd, sta->addr,
273 					     hostapd_sta_flags_to_drv(
274 						     sta->flags),
275 					     WPA_STA_AUTHORIZED, ~0);
276 	}
277 
278 	return hostapd_sta_set_flags(hapd, sta->addr,
279 				     hostapd_sta_flags_to_drv(sta->flags),
280 				     0, ~WPA_STA_AUTHORIZED);
281 }
282 
283 
hostapd_set_sta_flags(struct hostapd_data * hapd,struct sta_info * sta)284 int hostapd_set_sta_flags(struct hostapd_data *hapd, struct sta_info *sta)
285 {
286 	int set_flags, total_flags, flags_and, flags_or;
287 	total_flags = hostapd_sta_flags_to_drv(sta->flags);
288 	set_flags = WPA_STA_SHORT_PREAMBLE | WPA_STA_WMM | WPA_STA_MFP;
289 	if (((!hapd->conf->ieee802_1x && !hapd->conf->wpa) ||
290 	     sta->auth_alg == WLAN_AUTH_FT) &&
291 	    sta->flags & WLAN_STA_AUTHORIZED)
292 		set_flags |= WPA_STA_AUTHORIZED;
293 	flags_or = total_flags & set_flags;
294 	flags_and = total_flags | ~set_flags;
295 	return hostapd_sta_set_flags(hapd, sta->addr, total_flags,
296 				     flags_or, flags_and);
297 }
298 
299 
hostapd_set_drv_ieee8021x(struct hostapd_data * hapd,const char * ifname,int enabled)300 int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname,
301 			      int enabled)
302 {
303 	struct wpa_bss_params params;
304 	os_memset(&params, 0, sizeof(params));
305 	params.ifname = ifname;
306 	params.enabled = enabled;
307 	if (enabled) {
308 		params.wpa = hapd->conf->wpa;
309 		params.ieee802_1x = hapd->conf->ieee802_1x;
310 		params.wpa_group = hapd->conf->wpa_group;
311 		if ((hapd->conf->wpa & (WPA_PROTO_WPA | WPA_PROTO_RSN)) ==
312 		    (WPA_PROTO_WPA | WPA_PROTO_RSN))
313 			params.wpa_pairwise = hapd->conf->wpa_pairwise |
314 				hapd->conf->rsn_pairwise;
315 		else if (hapd->conf->wpa & WPA_PROTO_RSN)
316 			params.wpa_pairwise = hapd->conf->rsn_pairwise;
317 		else if (hapd->conf->wpa & WPA_PROTO_WPA)
318 			params.wpa_pairwise = hapd->conf->wpa_pairwise;
319 		params.wpa_key_mgmt = hapd->conf->wpa_key_mgmt;
320 		params.rsn_preauth = hapd->conf->rsn_preauth;
321 		params.ieee80211w = hapd->conf->ieee80211w;
322 	}
323 	return hostapd_set_ieee8021x(hapd, &params);
324 }
325 
326 
hostapd_vlan_if_add(struct hostapd_data * hapd,const char * ifname)327 int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname)
328 {
329 	char force_ifname[IFNAMSIZ];
330 	u8 if_addr[ETH_ALEN];
331 	return hostapd_if_add(hapd, WPA_IF_AP_VLAN, ifname, hapd->own_addr,
332 			      NULL, NULL, force_ifname, if_addr, NULL, 0);
333 }
334 
335 
hostapd_vlan_if_remove(struct hostapd_data * hapd,const char * ifname)336 int hostapd_vlan_if_remove(struct hostapd_data *hapd, const char *ifname)
337 {
338 	return hostapd_if_remove(hapd, WPA_IF_AP_VLAN, ifname);
339 }
340 
341 
hostapd_set_wds_sta(struct hostapd_data * hapd,char * ifname_wds,const u8 * addr,int aid,int val)342 int hostapd_set_wds_sta(struct hostapd_data *hapd, char *ifname_wds,
343 			const u8 *addr, int aid, int val)
344 {
345 	const char *bridge = NULL;
346 
347 	if (hapd->driver == NULL || hapd->driver->set_wds_sta == NULL)
348 		return -1;
349 	if (hapd->conf->wds_bridge[0])
350 		bridge = hapd->conf->wds_bridge;
351 	else if (hapd->conf->bridge[0])
352 		bridge = hapd->conf->bridge;
353 	return hapd->driver->set_wds_sta(hapd->drv_priv, addr, aid, val,
354 					 bridge, ifname_wds);
355 }
356 
357 
hostapd_add_sta_node(struct hostapd_data * hapd,const u8 * addr,u16 auth_alg)358 int hostapd_add_sta_node(struct hostapd_data *hapd, const u8 *addr,
359 			 u16 auth_alg)
360 {
361 	if (hapd->driver == NULL || hapd->driver->add_sta_node == NULL)
362 		return -EOPNOTSUPP;
363 	return hapd->driver->add_sta_node(hapd->drv_priv, addr, auth_alg);
364 }
365 
366 
hostapd_sta_auth(struct hostapd_data * hapd,const u8 * addr,u16 seq,u16 status,const u8 * ie,size_t len)367 int hostapd_sta_auth(struct hostapd_data *hapd, const u8 *addr,
368 		     u16 seq, u16 status, const u8 *ie, size_t len)
369 {
370 	struct wpa_driver_sta_auth_params params;
371 #ifdef CONFIG_FILS
372 	struct sta_info *sta;
373 #endif /* CONFIG_FILS */
374 
375 	if (hapd->driver == NULL || hapd->driver->sta_auth == NULL)
376 		return 0;
377 
378 	os_memset(&params, 0, sizeof(params));
379 
380 #ifdef CONFIG_FILS
381 	sta = ap_get_sta(hapd, addr);
382 	if (!sta) {
383 		wpa_printf(MSG_DEBUG, "Station " MACSTR
384 			   " not found for sta_auth processing",
385 			   MAC2STR(addr));
386 		return 0;
387 	}
388 
389 	if (sta->auth_alg == WLAN_AUTH_FILS_SK ||
390 	    sta->auth_alg == WLAN_AUTH_FILS_SK_PFS ||
391 	    sta->auth_alg == WLAN_AUTH_FILS_PK) {
392 		params.fils_auth = 1;
393 		wpa_auth_get_fils_aead_params(sta->wpa_sm, params.fils_anonce,
394 					      params.fils_snonce,
395 					      params.fils_kek,
396 					      &params.fils_kek_len);
397 	}
398 #endif /* CONFIG_FILS */
399 
400 	params.own_addr = hapd->own_addr;
401 	params.addr = addr;
402 	params.seq = seq;
403 	params.status = status;
404 	params.ie = ie;
405 	params.len = len;
406 
407 	return hapd->driver->sta_auth(hapd->drv_priv, &params);
408 }
409 
410 
hostapd_sta_assoc(struct hostapd_data * hapd,const u8 * addr,int reassoc,u16 status,const u8 * ie,size_t len)411 int hostapd_sta_assoc(struct hostapd_data *hapd, const u8 *addr,
412 		      int reassoc, u16 status, const u8 *ie, size_t len)
413 {
414 	if (hapd->driver == NULL || hapd->driver->sta_assoc == NULL)
415 		return 0;
416 	return hapd->driver->sta_assoc(hapd->drv_priv, hapd->own_addr, addr,
417 				       reassoc, status, ie, len);
418 }
419 
420 
hostapd_sta_add(struct hostapd_data * hapd,const u8 * addr,u16 aid,u16 capability,const u8 * supp_rates,size_t supp_rates_len,u16 listen_interval,const struct ieee80211_ht_capabilities * ht_capab,const struct ieee80211_vht_capabilities * vht_capab,const struct ieee80211_he_capabilities * he_capab,size_t he_capab_len,const struct ieee80211_eht_capabilities * eht_capab,size_t eht_capab_len,const struct ieee80211_he_6ghz_band_cap * he_6ghz_capab,u32 flags,u8 qosinfo,u8 vht_opmode,int supp_p2p_ps,int set)421 int hostapd_sta_add(struct hostapd_data *hapd,
422 		    const u8 *addr, u16 aid, u16 capability,
423 		    const u8 *supp_rates, size_t supp_rates_len,
424 		    u16 listen_interval,
425 		    const struct ieee80211_ht_capabilities *ht_capab,
426 		    const struct ieee80211_vht_capabilities *vht_capab,
427 		    const struct ieee80211_he_capabilities *he_capab,
428 		    size_t he_capab_len,
429 		    const struct ieee80211_eht_capabilities *eht_capab,
430 		    size_t eht_capab_len,
431 		    const struct ieee80211_he_6ghz_band_cap *he_6ghz_capab,
432 		    u32 flags, u8 qosinfo, u8 vht_opmode, int supp_p2p_ps,
433 		    int set)
434 {
435 	struct hostapd_sta_add_params params;
436 
437 	if (hapd->driver == NULL)
438 		return 0;
439 	if (hapd->driver->sta_add == NULL)
440 		return 0;
441 
442 	os_memset(&params, 0, sizeof(params));
443 	params.addr = addr;
444 	params.aid = aid;
445 	params.capability = capability;
446 	params.supp_rates = supp_rates;
447 	params.supp_rates_len = supp_rates_len;
448 	params.listen_interval = listen_interval;
449 	params.ht_capabilities = ht_capab;
450 	params.vht_capabilities = vht_capab;
451 	params.he_capab = he_capab;
452 	params.he_capab_len = he_capab_len;
453 	params.eht_capab = eht_capab;
454 	params.eht_capab_len = eht_capab_len;
455 	params.he_6ghz_capab = he_6ghz_capab;
456 	params.vht_opmode_enabled = !!(flags & WLAN_STA_VHT_OPMODE_ENABLED);
457 	params.vht_opmode = vht_opmode;
458 	params.flags = hostapd_sta_flags_to_drv(flags);
459 	params.qosinfo = qosinfo;
460 	params.support_p2p_ps = supp_p2p_ps;
461 	params.set = set;
462 	params.mld_link_id = -1;
463 	return hapd->driver->sta_add(hapd->drv_priv, &params);
464 }
465 
466 
hostapd_add_tspec(struct hostapd_data * hapd,const u8 * addr,u8 * tspec_ie,size_t tspec_ielen)467 int hostapd_add_tspec(struct hostapd_data *hapd, const u8 *addr,
468 		      u8 *tspec_ie, size_t tspec_ielen)
469 {
470 	if (hapd->driver == NULL || hapd->driver->add_tspec == NULL)
471 		return 0;
472 	return hapd->driver->add_tspec(hapd->drv_priv, addr, tspec_ie,
473 				       tspec_ielen);
474 }
475 
476 
hostapd_set_privacy(struct hostapd_data * hapd,int enabled)477 int hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
478 {
479 	if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
480 		return 0;
481 	return hapd->driver->set_privacy(hapd->drv_priv, enabled);
482 }
483 
484 
hostapd_set_generic_elem(struct hostapd_data * hapd,const u8 * elem,size_t elem_len)485 int hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
486 			     size_t elem_len)
487 {
488 	if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
489 		return 0;
490 	return hapd->driver->set_generic_elem(hapd->drv_priv, elem, elem_len);
491 }
492 
493 
hostapd_get_ssid(struct hostapd_data * hapd,u8 * buf,size_t len)494 int hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
495 {
496 	if (hapd->driver == NULL || hapd->driver->hapd_get_ssid == NULL)
497 		return 0;
498 	return hapd->driver->hapd_get_ssid(hapd->drv_priv, buf, len);
499 }
500 
501 
hostapd_set_ssid(struct hostapd_data * hapd,const u8 * buf,size_t len)502 int hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
503 {
504 	if (hapd->driver == NULL || hapd->driver->hapd_set_ssid == NULL)
505 		return 0;
506 	return hapd->driver->hapd_set_ssid(hapd->drv_priv, buf, len);
507 }
508 
509 
hostapd_if_add(struct hostapd_data * hapd,enum wpa_driver_if_type type,const char * ifname,const u8 * addr,void * bss_ctx,void ** drv_priv,char * force_ifname,u8 * if_addr,const char * bridge,int use_existing)510 int hostapd_if_add(struct hostapd_data *hapd, enum wpa_driver_if_type type,
511 		   const char *ifname, const u8 *addr, void *bss_ctx,
512 		   void **drv_priv, char *force_ifname, u8 *if_addr,
513 		   const char *bridge, int use_existing)
514 {
515 	if (hapd->driver == NULL || hapd->driver->if_add == NULL)
516 		return -1;
517 	return hapd->driver->if_add(hapd->drv_priv, type, ifname, addr,
518 				    bss_ctx, drv_priv, force_ifname, if_addr,
519 				    bridge, use_existing, 1);
520 }
521 
522 
hostapd_if_remove(struct hostapd_data * hapd,enum wpa_driver_if_type type,const char * ifname)523 int hostapd_if_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type,
524 		      const char *ifname)
525 {
526 	if (hapd->driver == NULL || hapd->drv_priv == NULL ||
527 	    hapd->driver->if_remove == NULL)
528 		return -1;
529 	return hapd->driver->if_remove(hapd->drv_priv, type, ifname);
530 }
531 
532 
hostapd_set_ieee8021x(struct hostapd_data * hapd,struct wpa_bss_params * params)533 int hostapd_set_ieee8021x(struct hostapd_data *hapd,
534 			  struct wpa_bss_params *params)
535 {
536 	if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
537 		return 0;
538 	return hapd->driver->set_ieee8021x(hapd->drv_priv, params);
539 }
540 
541 
hostapd_get_seqnum(const char * ifname,struct hostapd_data * hapd,const u8 * addr,int idx,u8 * seq)542 int hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
543 		       const u8 *addr, int idx, u8 *seq)
544 {
545 	if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
546 		return 0;
547 	return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
548 					seq);
549 }
550 
551 
hostapd_flush(struct hostapd_data * hapd)552 int hostapd_flush(struct hostapd_data *hapd)
553 {
554 	if (hapd->driver == NULL || hapd->driver->flush == NULL)
555 		return 0;
556 	return hapd->driver->flush(hapd->drv_priv);
557 }
558 
559 
hostapd_set_freq(struct hostapd_data * hapd,enum hostapd_hw_mode mode,int freq,int channel,int edmg,u8 edmg_channel,int ht_enabled,int vht_enabled,int he_enabled,bool eht_enabled,int sec_channel_offset,int oper_chwidth,int center_segment0,int center_segment1)560 int hostapd_set_freq(struct hostapd_data *hapd, enum hostapd_hw_mode mode,
561 		     int freq, int channel, int edmg, u8 edmg_channel,
562 		     int ht_enabled, int vht_enabled,
563 		     int he_enabled, bool eht_enabled,
564 		     int sec_channel_offset, int oper_chwidth,
565 		     int center_segment0, int center_segment1)
566 {
567 	struct hostapd_freq_params data;
568 	struct hostapd_hw_modes *cmode = hapd->iface->current_mode;
569 
570 	if (hostapd_set_freq_params(&data, mode, freq, channel, edmg,
571 				    edmg_channel, ht_enabled,
572 				    vht_enabled, he_enabled, eht_enabled,
573 				    sec_channel_offset, oper_chwidth,
574 				    center_segment0, center_segment1,
575 				    cmode ? cmode->vht_capab : 0,
576 				    cmode ?
577 				    &cmode->he_capab[IEEE80211_MODE_AP] : NULL,
578 				    cmode ?
579 				    &cmode->eht_capab[IEEE80211_MODE_AP] :
580 				    NULL))
581 		return -1;
582 
583 	if (hapd->driver == NULL)
584 		return 0;
585 	if (hapd->driver->set_freq == NULL)
586 		return 0;
587 	return hapd->driver->set_freq(hapd->drv_priv, &data);
588 }
589 
hostapd_set_rts(struct hostapd_data * hapd,int rts)590 int hostapd_set_rts(struct hostapd_data *hapd, int rts)
591 {
592 	if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
593 		return 0;
594 	return hapd->driver->set_rts(hapd->drv_priv, rts);
595 }
596 
597 
hostapd_set_frag(struct hostapd_data * hapd,int frag)598 int hostapd_set_frag(struct hostapd_data *hapd, int frag)
599 {
600 	if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
601 		return 0;
602 	return hapd->driver->set_frag(hapd->drv_priv, frag);
603 }
604 
605 
hostapd_sta_set_flags(struct hostapd_data * hapd,u8 * addr,int total_flags,int flags_or,int flags_and)606 int hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
607 			  int total_flags, int flags_or, int flags_and)
608 {
609 	if (!hapd->driver || !hapd->drv_priv || !hapd->driver->sta_set_flags)
610 		return 0;
611 	return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags,
612 					   flags_or, flags_and);
613 }
614 
615 
hostapd_sta_set_airtime_weight(struct hostapd_data * hapd,const u8 * addr,unsigned int weight)616 int hostapd_sta_set_airtime_weight(struct hostapd_data *hapd, const u8 *addr,
617 				   unsigned int weight)
618 {
619 	if (!hapd->driver || !hapd->driver->sta_set_airtime_weight)
620 		return 0;
621 	return hapd->driver->sta_set_airtime_weight(hapd->drv_priv, addr,
622 						    weight);
623 }
624 
625 
hostapd_set_country(struct hostapd_data * hapd,const char * country)626 int hostapd_set_country(struct hostapd_data *hapd, const char *country)
627 {
628 	if (hapd->driver == NULL ||
629 	    hapd->driver->set_country == NULL)
630 		return 0;
631 	return hapd->driver->set_country(hapd->drv_priv, country);
632 }
633 
634 
hostapd_set_tx_queue_params(struct hostapd_data * hapd,int queue,int aifs,int cw_min,int cw_max,int burst_time)635 int hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
636 				int cw_min, int cw_max, int burst_time)
637 {
638 	if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
639 		return 0;
640 	return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs,
641 						 cw_min, cw_max, burst_time);
642 }
643 
644 
645 struct hostapd_hw_modes *
hostapd_get_hw_feature_data(struct hostapd_data * hapd,u16 * num_modes,u16 * flags,u8 * dfs_domain)646 hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
647 			    u16 *flags, u8 *dfs_domain)
648 {
649 	if (hapd->driver == NULL ||
650 	    hapd->driver->get_hw_feature_data == NULL)
651 		return NULL;
652 	return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes,
653 						 flags, dfs_domain);
654 }
655 
656 
hostapd_driver_commit(struct hostapd_data * hapd)657 int hostapd_driver_commit(struct hostapd_data *hapd)
658 {
659 	if (hapd->driver == NULL || hapd->driver->commit == NULL)
660 		return 0;
661 	return hapd->driver->commit(hapd->drv_priv);
662 }
663 
664 
hostapd_drv_none(struct hostapd_data * hapd)665 int hostapd_drv_none(struct hostapd_data *hapd)
666 {
667 	return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
668 }
669 
670 
hostapd_drv_nl80211(struct hostapd_data * hapd)671 bool hostapd_drv_nl80211(struct hostapd_data *hapd)
672 {
673 	return hapd->driver && os_strcmp(hapd->driver->name, "nl80211") == 0;
674 }
675 
676 
hostapd_driver_scan(struct hostapd_data * hapd,struct wpa_driver_scan_params * params)677 int hostapd_driver_scan(struct hostapd_data *hapd,
678 			struct wpa_driver_scan_params *params)
679 {
680 	if (hapd->driver && hapd->driver->scan2)
681 		return hapd->driver->scan2(hapd->drv_priv, params);
682 	return -1;
683 }
684 
685 
hostapd_driver_get_scan_results(struct hostapd_data * hapd)686 struct wpa_scan_results * hostapd_driver_get_scan_results(
687 	struct hostapd_data *hapd)
688 {
689 	if (hapd->driver && hapd->driver->get_scan_results2)
690 		return hapd->driver->get_scan_results2(hapd->drv_priv);
691 	return NULL;
692 }
693 
694 
hostapd_driver_set_noa(struct hostapd_data * hapd,u8 count,int start,int duration)695 int hostapd_driver_set_noa(struct hostapd_data *hapd, u8 count, int start,
696 			   int duration)
697 {
698 	if (hapd->driver && hapd->driver->set_noa)
699 		return hapd->driver->set_noa(hapd->drv_priv, count, start,
700 					     duration);
701 	return -1;
702 }
703 
704 
hostapd_drv_set_key(const char * ifname,struct hostapd_data * hapd,enum wpa_alg alg,const u8 * addr,int key_idx,int vlan_id,int set_tx,const u8 * seq,size_t seq_len,const u8 * key,size_t key_len,enum key_flag key_flag)705 int hostapd_drv_set_key(const char *ifname, struct hostapd_data *hapd,
706 			enum wpa_alg alg, const u8 *addr,
707 			int key_idx, int vlan_id, int set_tx,
708 			const u8 *seq, size_t seq_len,
709 			const u8 *key, size_t key_len, enum key_flag key_flag)
710 {
711 	struct wpa_driver_set_key_params params;
712 
713 	if (hapd->driver == NULL || hapd->driver->set_key == NULL)
714 		return 0;
715 
716 	os_memset(&params, 0, sizeof(params));
717 	params.ifname = ifname;
718 	params.alg = alg;
719 	params.addr = addr;
720 	params.key_idx = key_idx;
721 	params.set_tx = set_tx;
722 	params.seq = seq;
723 	params.seq_len = seq_len;
724 	params.key = key;
725 	params.key_len = key_len;
726 	params.vlan_id = vlan_id;
727 	params.key_flag = key_flag;
728 	params.link_id = -1;
729 
730 	return hapd->driver->set_key(hapd->drv_priv, &params);
731 }
732 
733 
hostapd_drv_send_mlme(struct hostapd_data * hapd,const void * msg,size_t len,int noack,const u16 * csa_offs,size_t csa_offs_len,int no_encrypt)734 int hostapd_drv_send_mlme(struct hostapd_data *hapd,
735 			  const void *msg, size_t len, int noack,
736 			  const u16 *csa_offs, size_t csa_offs_len,
737 			  int no_encrypt)
738 {
739 	if (!hapd->driver || !hapd->driver->send_mlme || !hapd->drv_priv)
740 		return 0;
741 	return hapd->driver->send_mlme(hapd->drv_priv, msg, len, noack, 0,
742 				       csa_offs, csa_offs_len, no_encrypt, 0);
743 }
744 
745 
hostapd_drv_sta_deauth(struct hostapd_data * hapd,const u8 * addr,int reason)746 int hostapd_drv_sta_deauth(struct hostapd_data *hapd,
747 			   const u8 *addr, int reason)
748 {
749 	if (!hapd->driver || !hapd->driver->sta_deauth || !hapd->drv_priv)
750 		return 0;
751 	return hapd->driver->sta_deauth(hapd->drv_priv, hapd->own_addr, addr,
752 					reason);
753 }
754 
755 
hostapd_drv_sta_disassoc(struct hostapd_data * hapd,const u8 * addr,int reason)756 int hostapd_drv_sta_disassoc(struct hostapd_data *hapd,
757 			     const u8 *addr, int reason)
758 {
759 	if (!hapd->driver || !hapd->driver->sta_disassoc || !hapd->drv_priv)
760 		return 0;
761 	return hapd->driver->sta_disassoc(hapd->drv_priv, hapd->own_addr, addr,
762 					  reason);
763 }
764 
765 
hostapd_drv_wnm_oper(struct hostapd_data * hapd,enum wnm_oper oper,const u8 * peer,u8 * buf,u16 * buf_len)766 int hostapd_drv_wnm_oper(struct hostapd_data *hapd, enum wnm_oper oper,
767 			 const u8 *peer, u8 *buf, u16 *buf_len)
768 {
769 	if (hapd->driver == NULL || hapd->driver->wnm_oper == NULL)
770 		return -1;
771 	return hapd->driver->wnm_oper(hapd->drv_priv, oper, peer, buf,
772 				      buf_len);
773 }
774 
775 
hostapd_drv_send_action(struct hostapd_data * hapd,unsigned int freq,unsigned int wait,const u8 * dst,const u8 * data,size_t len)776 int hostapd_drv_send_action(struct hostapd_data *hapd, unsigned int freq,
777 			    unsigned int wait, const u8 *dst, const u8 *data,
778 			    size_t len)
779 {
780 	const u8 *bssid;
781 	const u8 wildcard_bssid[ETH_ALEN] = {
782 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff
783 	};
784 
785 	if (!hapd->driver || !hapd->driver->send_action || !hapd->drv_priv)
786 		return 0;
787 	bssid = hapd->own_addr;
788 	if (!is_multicast_ether_addr(dst) &&
789 	    len > 0 && data[0] == WLAN_ACTION_PUBLIC) {
790 		struct sta_info *sta;
791 
792 		/*
793 		 * Public Action frames to a STA that is not a member of the BSS
794 		 * shall use wildcard BSSID value.
795 		 */
796 		sta = ap_get_sta(hapd, dst);
797 		if (!sta || !(sta->flags & WLAN_STA_ASSOC))
798 			bssid = wildcard_bssid;
799 	} else if (is_broadcast_ether_addr(dst) &&
800 		   len > 0 && data[0] == WLAN_ACTION_PUBLIC) {
801 		/*
802 		 * The only current use case of Public Action frames with
803 		 * broadcast destination address is DPP PKEX. That case is
804 		 * directing all devices and not just the STAs within the BSS,
805 		 * so have to use the wildcard BSSID value.
806 		 */
807 		bssid = wildcard_bssid;
808 	}
809 	return hapd->driver->send_action(hapd->drv_priv, freq, wait, dst,
810 					 hapd->own_addr, bssid, data, len, 0);
811 }
812 
813 
hostapd_drv_send_action_addr3_ap(struct hostapd_data * hapd,unsigned int freq,unsigned int wait,const u8 * dst,const u8 * data,size_t len)814 int hostapd_drv_send_action_addr3_ap(struct hostapd_data *hapd,
815 				     unsigned int freq,
816 				     unsigned int wait, const u8 *dst,
817 				     const u8 *data, size_t len)
818 {
819 	if (hapd->driver == NULL || hapd->driver->send_action == NULL)
820 		return 0;
821 	return hapd->driver->send_action(hapd->drv_priv, freq, wait, dst,
822 					 hapd->own_addr, hapd->own_addr, data,
823 					 len, 0);
824 }
825 
826 
hostapd_start_dfs_cac(struct hostapd_iface * iface,enum hostapd_hw_mode mode,int freq,int channel,int ht_enabled,int vht_enabled,int he_enabled,bool eht_enabled,int sec_channel_offset,int oper_chwidth,int center_segment0,int center_segment1,bool radar_background)827 int hostapd_start_dfs_cac(struct hostapd_iface *iface,
828 			  enum hostapd_hw_mode mode, int freq,
829 			  int channel, int ht_enabled, int vht_enabled,
830 			  int he_enabled, bool eht_enabled,
831 			  int sec_channel_offset, int oper_chwidth,
832 			  int center_segment0, int center_segment1,
833 			  bool radar_background)
834 {
835 	struct hostapd_data *hapd = iface->bss[0];
836 	struct hostapd_freq_params data;
837 	int res;
838 	struct hostapd_hw_modes *cmode = iface->current_mode;
839 
840 	if (!hapd->driver || !hapd->driver->start_dfs_cac || !cmode)
841 		return 0;
842 
843 	if (!iface->conf->ieee80211h) {
844 		wpa_printf(MSG_ERROR, "Can't start DFS CAC, DFS functionality "
845 			   "is not enabled");
846 		return -1;
847 	}
848 
849 	if (hostapd_set_freq_params(&data, mode, freq, channel, 0, 0,
850 				    ht_enabled,
851 				    vht_enabled, he_enabled, eht_enabled,
852 				    sec_channel_offset,
853 				    oper_chwidth, center_segment0,
854 				    center_segment1,
855 				    cmode->vht_capab,
856 				    &cmode->he_capab[IEEE80211_MODE_AP],
857 				    &cmode->eht_capab[IEEE80211_MODE_AP])) {
858 		wpa_printf(MSG_ERROR, "Can't set freq params");
859 		return -1;
860 	}
861 	data.radar_background = radar_background;
862 
863 	res = hapd->driver->start_dfs_cac(hapd->drv_priv, &data);
864 	if (!res) {
865 		if (radar_background)
866 			iface->radar_background.cac_started = 1;
867 		else
868 			iface->cac_started = 1;
869 		os_get_reltime(&iface->dfs_cac_start);
870 	}
871 
872 	return res;
873 }
874 
875 
hostapd_drv_set_qos_map(struct hostapd_data * hapd,const u8 * qos_map_set,u8 qos_map_set_len)876 int hostapd_drv_set_qos_map(struct hostapd_data *hapd,
877 			    const u8 *qos_map_set, u8 qos_map_set_len)
878 {
879 	if (!hapd->driver || !hapd->driver->set_qos_map || !hapd->drv_priv)
880 		return 0;
881 	return hapd->driver->set_qos_map(hapd->drv_priv, qos_map_set,
882 					 qos_map_set_len);
883 }
884 
885 
hostapd_get_hw_mode_any_channels(struct hostapd_data * hapd,struct hostapd_hw_modes * mode,int acs_ch_list_all,bool allow_disabled,int ** freq_list)886 void hostapd_get_hw_mode_any_channels(struct hostapd_data *hapd,
887 				      struct hostapd_hw_modes *mode,
888 				      int acs_ch_list_all, bool allow_disabled,
889 				      int **freq_list)
890 {
891 	int i;
892 
893 	for (i = 0; i < mode->num_channels; i++) {
894 		struct hostapd_channel_data *chan = &mode->channels[i];
895 
896 		if (!acs_ch_list_all &&
897 		    (hapd->iface->conf->acs_freq_list.num &&
898 		     !freq_range_list_includes(
899 			     &hapd->iface->conf->acs_freq_list,
900 			     chan->freq)))
901 			continue;
902 		if (!acs_ch_list_all &&
903 		    (!hapd->iface->conf->acs_freq_list_present &&
904 		     hapd->iface->conf->acs_ch_list.num &&
905 		     !freq_range_list_includes(
906 			     &hapd->iface->conf->acs_ch_list,
907 			     chan->chan)))
908 			continue;
909 		if (is_6ghz_freq(chan->freq) &&
910 		    ((hapd->iface->conf->acs_exclude_6ghz_non_psc &&
911 		      !is_6ghz_psc_frequency(chan->freq)) ||
912 		     (!hapd->iface->conf->ieee80211ax &&
913 		      !hapd->iface->conf->ieee80211be)))
914 			continue;
915 		if ((!(chan->flag & HOSTAPD_CHAN_DISABLED) || allow_disabled) &&
916 		    !(hapd->iface->conf->acs_exclude_dfs &&
917 		      (chan->flag & HOSTAPD_CHAN_RADAR)) &&
918 		    !(chan->max_tx_power < hapd->iface->conf->min_tx_power))
919 			int_array_add_unique(freq_list, chan->freq);
920 	}
921 }
922 
923 
hostapd_get_ext_capa(struct hostapd_iface * iface)924 void hostapd_get_ext_capa(struct hostapd_iface *iface)
925 {
926 	struct hostapd_data *hapd = iface->bss[0];
927 
928 	if (!hapd->driver || !hapd->driver->get_ext_capab)
929 		return;
930 
931 	hapd->driver->get_ext_capab(hapd->drv_priv, WPA_IF_AP_BSS,
932 				    &iface->extended_capa,
933 				    &iface->extended_capa_mask,
934 				    &iface->extended_capa_len);
935 }
936 
937 
hostapd_drv_do_acs(struct hostapd_data * hapd)938 int hostapd_drv_do_acs(struct hostapd_data *hapd)
939 {
940 	struct drv_acs_params params;
941 	int ret, i, acs_ch_list_all = 0;
942 	struct hostapd_hw_modes *mode;
943 	int *freq_list = NULL;
944 	enum hostapd_hw_mode selected_mode;
945 
946 	if (hapd->driver == NULL || hapd->driver->do_acs == NULL)
947 		return 0;
948 
949 	os_memset(&params, 0, sizeof(params));
950 	params.hw_mode = hapd->iface->conf->hw_mode;
951 
952 	/*
953 	 * If no chanlist config parameter is provided, include all enabled
954 	 * channels of the selected hw_mode.
955 	 */
956 	if (hapd->iface->conf->acs_freq_list_present)
957 		acs_ch_list_all = !hapd->iface->conf->acs_freq_list.num;
958 	else
959 		acs_ch_list_all = !hapd->iface->conf->acs_ch_list.num;
960 
961 	if (hapd->iface->current_mode)
962 		selected_mode = hapd->iface->current_mode->mode;
963 	else
964 		selected_mode = HOSTAPD_MODE_IEEE80211ANY;
965 
966 	for (i = 0; i < hapd->iface->num_hw_features; i++) {
967 		mode = &hapd->iface->hw_features[i];
968 		if (selected_mode != HOSTAPD_MODE_IEEE80211ANY &&
969 		    selected_mode != mode->mode)
970 			continue;
971 		hostapd_get_hw_mode_any_channels(hapd, mode, acs_ch_list_all,
972 						 false, &freq_list);
973 	}
974 
975 	params.freq_list = freq_list;
976 	params.edmg_enabled = hapd->iface->conf->enable_edmg;
977 
978 	params.ht_enabled = !!(hapd->iface->conf->ieee80211n);
979 	params.ht40_enabled = !!(hapd->iface->conf->ht_capab &
980 				 HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET);
981 	params.vht_enabled = !!(hapd->iface->conf->ieee80211ac);
982 	params.eht_enabled = !!(hapd->iface->conf->ieee80211be);
983 	params.ch_width = 20;
984 	if (hapd->iface->conf->ieee80211n && params.ht40_enabled)
985 		params.ch_width = 40;
986 
987 	/* Note: VHT20 is defined by combination of ht_capab & oper_chwidth
988 	 */
989 	if ((hapd->iface->conf->ieee80211be ||
990 	     hapd->iface->conf->ieee80211ax ||
991 	     hapd->iface->conf->ieee80211ac) &&
992 	    params.ht40_enabled) {
993 		enum oper_chan_width oper_chwidth;
994 
995 		oper_chwidth = hostapd_get_oper_chwidth(hapd->iface->conf);
996 		if (oper_chwidth == CONF_OPER_CHWIDTH_80MHZ)
997 			params.ch_width = 80;
998 		else if (oper_chwidth == CONF_OPER_CHWIDTH_160MHZ ||
999 			 oper_chwidth == CONF_OPER_CHWIDTH_80P80MHZ)
1000 			params.ch_width = 160;
1001 		else if (oper_chwidth == CONF_OPER_CHWIDTH_320MHZ)
1002 			params.ch_width = 320;
1003 	}
1004 
1005 	if (hapd->iface->conf->op_class)
1006 		params.ch_width = op_class_to_bandwidth(
1007 			hapd->iface->conf->op_class);
1008 	ret = hapd->driver->do_acs(hapd->drv_priv, &params);
1009 	os_free(freq_list);
1010 
1011 	return ret;
1012 }
1013 
1014 
hostapd_drv_update_dh_ie(struct hostapd_data * hapd,const u8 * peer,u16 reason_code,const u8 * ie,size_t ielen)1015 int hostapd_drv_update_dh_ie(struct hostapd_data *hapd, const u8 *peer,
1016 			     u16 reason_code, const u8 *ie, size_t ielen)
1017 {
1018 	if (!hapd->driver || !hapd->driver->update_dh_ie || !hapd->drv_priv)
1019 		return 0;
1020 	return hapd->driver->update_dh_ie(hapd->drv_priv, peer, reason_code,
1021 					  ie, ielen);
1022 }
1023 
1024 
hostapd_drv_dpp_listen(struct hostapd_data * hapd,bool enable)1025 int hostapd_drv_dpp_listen(struct hostapd_data *hapd, bool enable)
1026 {
1027 	if (!hapd->driver || !hapd->driver->dpp_listen || !hapd->drv_priv)
1028 		return 0;
1029 	return hapd->driver->dpp_listen(hapd->drv_priv, enable);
1030 }
1031 
1032 
1033 #ifdef CONFIG_PASN
hostapd_drv_set_secure_ranging_ctx(struct hostapd_data * hapd,const u8 * own_addr,const u8 * peer_addr,u32 cipher,u8 tk_len,const u8 * tk,u8 ltf_keyseed_len,const u8 * ltf_keyseed,u32 action)1034 int hostapd_drv_set_secure_ranging_ctx(struct hostapd_data *hapd,
1035 				       const u8 *own_addr, const u8 *peer_addr,
1036 				       u32 cipher, u8 tk_len, const u8 *tk,
1037 				       u8 ltf_keyseed_len,
1038 				       const u8 *ltf_keyseed, u32 action)
1039 {
1040 	struct secure_ranging_params params;
1041 
1042 	if (!hapd->driver || !hapd->driver->set_secure_ranging_ctx)
1043 		return 0;
1044 
1045 	os_memset(&params, 0, sizeof(params));
1046 	params.own_addr = own_addr;
1047 	params.peer_addr = peer_addr;
1048 	params.cipher = cipher;
1049 	params.tk_len = tk_len;
1050 	params.tk = tk;
1051 	params.ltf_keyseed_len = ltf_keyseed_len;
1052 	params.ltf_keyseed = ltf_keyseed;
1053 	params.action = action;
1054 
1055 	return hapd->driver->set_secure_ranging_ctx(hapd->drv_priv, &params);
1056 }
1057 #endif /* CONFIG_PASN */
1058