xref: /freebsd/contrib/wpa/wpa_supplicant/wpa_supplicant_i.h (revision 71e72c9e91c4b8007a4292e09669e8b549c29e97)
1 /*
2  * wpa_supplicant - Internal definitions
3  * Copyright (c) 2003-2024, 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 #ifndef WPA_SUPPLICANT_I_H
10 #define WPA_SUPPLICANT_I_H
11 
12 #include "utils/bitfield.h"
13 #include "utils/list.h"
14 #include "common/defs.h"
15 #include "common/sae.h"
16 #include "common/wpa_ctrl.h"
17 #include "common/dpp.h"
18 #include "crypto/sha384.h"
19 #include "eapol_supp/eapol_supp_sm.h"
20 #include "wps/wps_defs.h"
21 #include "config_ssid.h"
22 #include "wmm_ac.h"
23 #include "pasn/pasn_common.h"
24 #include "nan/nan.h"
25 
26 extern const char *const wpa_supplicant_version;
27 extern const char *const wpa_supplicant_license;
28 #ifndef CONFIG_NO_STDOUT_DEBUG
29 extern const char *const wpa_supplicant_full_license1;
30 extern const char *const wpa_supplicant_full_license2;
31 extern const char *const wpa_supplicant_full_license3;
32 extern const char *const wpa_supplicant_full_license4;
33 extern const char *const wpa_supplicant_full_license5;
34 #endif /* CONFIG_NO_STDOUT_DEBUG */
35 
36 struct wpa_sm;
37 struct wpa_supplicant;
38 struct ibss_rsn;
39 struct scan_info;
40 struct wpa_bss;
41 struct wpa_scan_results;
42 struct hostapd_hw_modes;
43 struct wpa_driver_associate_params;
44 struct wpa_cred;
45 
46 /*
47  * Forward declarations of private structures used within the ctrl_iface
48  * backends. Other parts of wpa_supplicant do not have access to data stored in
49  * these structures.
50  */
51 struct ctrl_iface_priv;
52 struct ctrl_iface_global_priv;
53 struct wpas_dbus_priv;
54 struct wpas_binder_priv;
55 
56 /**
57  * struct wpa_interface - Parameters for wpa_supplicant_add_iface()
58  */
59 struct wpa_interface {
60 	/**
61 	 * confname - Configuration name (file or profile) name
62 	 *
63 	 * This can also be %NULL when a configuration file is not used. In
64 	 * that case, ctrl_interface must be set to allow the interface to be
65 	 * configured.
66 	 */
67 	const char *confname;
68 
69 	/**
70 	 * confanother - Additional configuration name (file or profile) name
71 	 *
72 	 * This can also be %NULL when the additional configuration file is not
73 	 * used.
74 	 */
75 	const char *confanother;
76 
77 	/**
78 	 * ctrl_interface - Control interface parameter
79 	 *
80 	 * If a configuration file is not used, this variable can be used to
81 	 * set the ctrl_interface parameter that would have otherwise been read
82 	 * from the configuration file. If both confname and ctrl_interface are
83 	 * set, ctrl_interface is used to override the value from configuration
84 	 * file.
85 	 */
86 	const char *ctrl_interface;
87 
88 	/**
89 	 * driver - Driver interface name, or %NULL to use the default driver
90 	 */
91 	const char *driver;
92 
93 	/**
94 	 * driver_param - Driver interface parameters
95 	 *
96 	 * If a configuration file is not used, this variable can be used to
97 	 * set the driver_param parameters that would have otherwise been read
98 	 * from the configuration file. If both confname and driver_param are
99 	 * set, driver_param is used to override the value from configuration
100 	 * file.
101 	 */
102 	const char *driver_param;
103 
104 	/**
105 	 * ifname - Interface name
106 	 */
107 	const char *ifname;
108 
109 	/**
110 	 * bridge_ifname - Optional bridge interface name
111 	 *
112 	 * If the driver interface (ifname) is included in a Linux bridge
113 	 * device, the bridge interface may need to be used for receiving EAPOL
114 	 * frames. This can be enabled by setting this variable to enable
115 	 * receiving of EAPOL frames from an additional interface.
116 	 */
117 	const char *bridge_ifname;
118 
119 	/**
120 	 * p2p_mgmt - Interface used for P2P management (P2P Device operations)
121 	 *
122 	 * Indicates whether wpas_p2p_init() must be called for this interface.
123 	 * This is used only when the driver supports a dedicated P2P Device
124 	 * interface that is not a network interface.
125 	 */
126 	int p2p_mgmt;
127 
128 #ifdef CONFIG_MATCH_IFACE
129 	/**
130 	 * matched - Interface was matched rather than specified
131 	 *
132 	 */
133 	enum {
134 		WPA_IFACE_NOT_MATCHED,
135 		WPA_IFACE_MATCHED_NULL,
136 		WPA_IFACE_MATCHED
137 	} matched;
138 #endif /* CONFIG_MATCH_IFACE */
139 
140 	/**
141 	 * nan_mgmt - Interface used for NAN management (NAN Device operations)
142 	 */
143 	bool nan_mgmt;
144 
145 	/**
146 	 * nan_data - Interface used for NAN data path operations
147 	 */
148 	bool nan_data;
149 };
150 
151 /**
152  * struct wpa_params - Parameters for wpa_supplicant_init()
153  */
154 struct wpa_params {
155 	/**
156 	 * daemonize - Run %wpa_supplicant in the background
157 	 */
158 	int daemonize;
159 
160 	/**
161 	 * wait_for_monitor - Wait for a monitor program before starting
162 	 */
163 	int wait_for_monitor;
164 
165 	/**
166 	 * pid_file - Path to a PID (process ID) file
167 	 *
168 	 * If this and daemonize are set, process ID of the background process
169 	 * will be written to the specified file.
170 	 */
171 	char *pid_file;
172 
173 	/**
174 	 * wpa_debug_level - Debugging verbosity level (e.g., MSG_INFO)
175 	 */
176 	int wpa_debug_level;
177 
178 	/**
179 	 * wpa_debug_show_keys - Whether keying material is included in debug
180 	 *
181 	 * This parameter can be used to allow keying material to be included
182 	 * in debug messages. This is a security risk and this option should
183 	 * not be enabled in normal configuration. If needed during
184 	 * development or while troubleshooting, this option can provide more
185 	 * details for figuring out what is happening.
186 	 */
187 	int wpa_debug_show_keys;
188 
189 	/**
190 	 * wpa_debug_timestamp - Whether to include timestamp in debug messages
191 	 */
192 	int wpa_debug_timestamp;
193 
194 	/**
195 	 * ctrl_interface - Global ctrl_iface path/parameter
196 	 */
197 	char *ctrl_interface;
198 
199 	/**
200 	 * ctrl_interface_group - Global ctrl_iface group
201 	 */
202 	char *ctrl_interface_group;
203 
204 	/**
205 	 * dbus_ctrl_interface - Enable the DBus control interface
206 	 */
207 	int dbus_ctrl_interface;
208 
209 	/**
210 	 * wpa_debug_file_path - Path of debug file or %NULL to use stdout
211 	 */
212 	const char *wpa_debug_file_path;
213 
214 	/**
215 	 * wpa_debug_syslog - Enable log output through syslog
216 	 */
217 	int wpa_debug_syslog;
218 
219 	/**
220 	 * wpa_debug_tracing - Enable log output through Linux tracing
221 	 */
222 	int wpa_debug_tracing;
223 
224 	/**
225 	 * override_driver - Optional driver parameter override
226 	 *
227 	 * This parameter can be used to override the driver parameter in
228 	 * dynamic interface addition to force a specific driver wrapper to be
229 	 * used instead.
230 	 */
231 	char *override_driver;
232 
233 	/**
234 	 * override_ctrl_interface - Optional ctrl_interface override
235 	 *
236 	 * This parameter can be used to override the ctrl_interface parameter
237 	 * in dynamic interface addition to force a control interface to be
238 	 * created.
239 	 */
240 	char *override_ctrl_interface;
241 
242 	/**
243 	 * entropy_file - Optional entropy file
244 	 *
245 	 * This parameter can be used to configure wpa_supplicant to maintain
246 	 * its internal entropy store over restarts.
247 	 */
248 	char *entropy_file;
249 
250 #ifdef CONFIG_P2P
251 	/**
252 	 * conf_p2p_dev - Configuration file used to hold the
253 	 * P2P Device configuration parameters.
254 	 *
255 	 * This can also be %NULL. In such a case, if a P2P Device dedicated
256 	 * interfaces is created, the main configuration file will be used.
257 	 */
258 	char *conf_p2p_dev;
259 #endif /* CONFIG_P2P */
260 
261 #ifdef CONFIG_MATCH_IFACE
262 	/**
263 	 * match_ifaces - Interface descriptions to match
264 	 */
265 	struct wpa_interface *match_ifaces;
266 
267 	/**
268 	 * match_iface_count - Number of defined matching interfaces
269 	 */
270 	int match_iface_count;
271 #endif /* CONFIG_MATCH_IFACE */
272 
273 	/**
274 	 * show_details - Whether to show config parsing details in debug log
275 	 */
276 	bool show_details;
277 
278 	/**
279 	 * proc_coord_dir - Process coordination directory
280 	 */
281 	const char *proc_coord_dir;
282 };
283 
284 struct p2p_srv_bonjour {
285 	struct dl_list list;
286 	struct wpabuf *query;
287 	struct wpabuf *resp;
288 };
289 
290 struct p2p_srv_upnp {
291 	struct dl_list list;
292 	u8 version;
293 	char *service;
294 };
295 
296 /**
297  * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces
298  *
299  * This structure is initialized by calling wpa_supplicant_init() when starting
300  * %wpa_supplicant.
301  */
302 struct wpa_global {
303 	struct wpa_supplicant *ifaces;
304 	struct wpa_params params;
305 	struct ctrl_iface_global_priv *ctrl_iface;
306 	struct wpas_dbus_priv *dbus;
307 	struct wpas_binder_priv *binder;
308 	void **drv_priv;
309 	size_t drv_count;
310 	struct os_time suspend_time;
311 	struct p2p_data *p2p;
312 	struct pr_data *pr;
313 	struct wpa_supplicant *p2p_init_wpa_s;
314 	struct wpa_supplicant *p2p_group_formation;
315 	struct wpa_supplicant *p2p_invite_group;
316 	struct wpa_supplicant *pr_init_wpa_s;
317 	u8 p2p_dev_addr[ETH_ALEN];
318 	struct os_reltime p2p_go_wait_client;
319 	struct dl_list p2p_srv_bonjour; /* struct p2p_srv_bonjour */
320 	struct dl_list p2p_srv_upnp; /* struct p2p_srv_upnp */
321 	int p2p_disabled;
322 	int cross_connection;
323 	int p2p_long_listen; /* remaining time in long Listen state in ms */
324 	struct wpa_freq_range_list p2p_disallow_freq;
325 	struct wpa_freq_range_list p2p_go_avoid_freq;
326 	enum wpa_conc_pref {
327 		WPA_CONC_PREF_NOT_SET,
328 		WPA_CONC_PREF_STA,
329 		WPA_CONC_PREF_P2P
330 	} conc_pref;
331 	unsigned int p2p_per_sta_psk:1;
332 	unsigned int p2p_fail_on_wps_complete:1;
333 	unsigned int p2p_24ghz_social_channels:1;
334 	unsigned int pending_p2ps_group:1;
335 	unsigned int pending_group_iface_for_p2ps:1;
336 	unsigned int pending_p2ps_group_freq;
337 
338 #ifdef CONFIG_WIFI_DISPLAY
339 	int wifi_display;
340 #define MAX_WFD_SUBELEMS 12
341 	struct wpabuf *wfd_subelem[MAX_WFD_SUBELEMS];
342 #endif /* CONFIG_WIFI_DISPLAY */
343 
344 	struct psk_list_entry *add_psk; /* From group formation */
345 
346 #ifdef CONFIG_PROCESS_COORDINATION
347 	struct proc_coord *pc;
348 #endif /* CONFIG_PROCESS_COORDINATION */
349 };
350 
351 
352 /**
353  * struct wpa_radio - Internal data for per-radio information
354  *
355  * This structure is used to share data about configured interfaces
356  * (struct wpa_supplicant) that share the same physical radio, e.g., to allow
357  * better coordination of offchannel operations.
358  */
359 struct wpa_radio {
360 	char name[16]; /* from driver_ops get_radio_name() or empty if not
361 			* available */
362 	/** NULL if no external scan running. */
363 	struct wpa_supplicant *external_scan_req_interface;
364 	unsigned int num_active_works;
365 	struct dl_list ifaces; /* struct wpa_supplicant::radio_list entries */
366 	struct dl_list work; /* struct wpa_radio_work::list entries */
367 };
368 
369 /**
370  * Checks whether an external scan is running on a given radio.
371  * @radio: Pointer to radio struct
372  * Returns: true if an external scan is running, false otherwise.
373  */
external_scan_running(struct wpa_radio * radio)374 static inline bool external_scan_running(struct wpa_radio *radio)
375 {
376 	return radio && radio->external_scan_req_interface;
377 }
378 
379 #define MAX_ACTIVE_WORKS 2
380 
381 
382 /**
383  * struct wpa_radio_work - Radio work item
384  */
385 struct wpa_radio_work {
386 	struct dl_list list;
387 	unsigned int freq; /* known frequency (MHz) or 0 for multiple/unknown */
388 	const char *type;
389 	struct wpa_supplicant *wpa_s;
390 	void (*cb)(struct wpa_radio_work *work, int deinit);
391 	void *ctx;
392 	unsigned int started:1;
393 	struct os_reltime time;
394 	unsigned int bands;
395 };
396 
397 struct wpa_radio_work *
398 radio_add_work(struct wpa_supplicant *wpa_s, unsigned int freq,
399 	       const char *type, int next,
400 	       void (*cb)(struct wpa_radio_work *work, int deinit),
401 	       void *ctx);
402 void radio_work_done(struct wpa_radio_work *work);
403 void radio_remove_works(struct wpa_supplicant *wpa_s,
404 			const char *type, int remove_all);
405 void radio_work_check_next(struct wpa_supplicant *wpa_s);
406 struct wpa_radio_work *
407 radio_work_pending(struct wpa_supplicant *wpa_s, const char *type);
408 
409 struct wpa_connect_work {
410 	unsigned int sme:1;
411 	unsigned int bss_removed:1;
412 	struct wpa_bss *bss;
413 	struct wpa_ssid *ssid;
414 };
415 
416 int wpas_valid_bss_ssid(struct wpa_supplicant *wpa_s, struct wpa_bss *test_bss,
417 			struct wpa_ssid *test_ssid);
418 void wpas_connect_work_free(struct wpa_connect_work *cwork);
419 void wpas_connect_work_done(struct wpa_supplicant *wpa_s);
420 
421 struct wpa_external_work {
422 	unsigned int id;
423 	char type[100];
424 	unsigned int timeout;
425 };
426 
427 enum wpa_radio_work_band wpas_freq_to_band(int freq);
428 unsigned int wpas_get_bands(struct wpa_supplicant *wpa_s, const int *freqs);
429 
430 /**
431  * offchannel_send_action_result - Result of offchannel send Action frame
432  */
433 enum offchannel_send_action_result {
434 	OFFCHANNEL_SEND_ACTION_SUCCESS /**< Frame was send and acknowledged */,
435 	OFFCHANNEL_SEND_ACTION_NO_ACK /**< Frame was sent, but not acknowledged
436 				       */,
437 	OFFCHANNEL_SEND_ACTION_FAILED /**< Frame was not sent due to a failure
438 				       */
439 };
440 
441 struct wps_ap_info {
442 	u8 bssid[ETH_ALEN];
443 	enum wps_ap_info_type {
444 		WPS_AP_NOT_SEL_REG,
445 		WPS_AP_SEL_REG,
446 		WPS_AP_SEL_REG_OUR
447 	} type;
448 	unsigned int tries;
449 	struct os_reltime last_attempt;
450 	unsigned int pbc_active;
451 	u8 uuid[WPS_UUID_LEN];
452 };
453 
454 #define WPA_FREQ_USED_BY_INFRA_STATION BIT(0)
455 #define WPA_FREQ_USED_BY_P2P_CLIENT BIT(1)
456 
457 struct wpa_used_freq_data {
458 	int freq;
459 	unsigned int flags;
460 };
461 
462 #define RRM_NEIGHBOR_REPORT_TIMEOUT 1 /* 1 second for AP to send a report */
463 
464 /*
465  * struct rrm_data - Data used for managing RRM features
466  */
467 struct rrm_data {
468 	/* rrm_used - indication regarding the current connection */
469 	unsigned int rrm_used:1;
470 
471 	/*
472 	 * notify_neighbor_rep - Callback for notifying report requester
473 	 */
474 	void (*notify_neighbor_rep)(void *ctx, struct wpabuf *neighbor_rep);
475 
476 	/*
477 	 * neighbor_rep_cb_ctx - Callback context
478 	 * Received in the callback registration, and sent to the callback
479 	 * function as a parameter.
480 	 */
481 	void *neighbor_rep_cb_ctx;
482 
483 	/* next_neighbor_rep_token - Next request's dialog token */
484 	u8 next_neighbor_rep_token;
485 
486 	/* token - Dialog token of the current radio measurement */
487 	u8 token;
488 
489 	/* destination address of the current radio measurement request */
490 	u8 dst_addr[ETH_ALEN];
491 };
492 
493 enum wpa_supplicant_test_failure {
494 	WPAS_TEST_FAILURE_NONE,
495 	WPAS_TEST_FAILURE_SCAN_TRIGGER,
496 };
497 
498 struct wpa_bss_tmp_disallowed {
499 	struct dl_list list;
500 	u8 bssid[ETH_ALEN];
501 	int rssi_threshold;
502 };
503 
504 struct beacon_rep_data {
505 	u8 token;
506 	u8 last_indication;
507 	struct wpa_driver_scan_params scan_params;
508 	u8 ssid[SSID_MAX_LEN];
509 	size_t ssid_len;
510 	u8 bssid[ETH_ALEN];
511 	enum beacon_report_detail report_detail;
512 	struct bitfield *eids;
513 	struct bitfield *ext_eids;
514 };
515 
516 
517 struct external_pmksa_cache {
518 	struct dl_list list;
519 	void *pmksa_cache;
520 };
521 
522 struct fils_hlp_req {
523 	struct dl_list list;
524 	u8 dst[ETH_ALEN];
525 	struct wpabuf *pkt;
526 };
527 
528 struct driver_signal_override {
529 	struct dl_list list;
530 	u8 bssid[ETH_ALEN];
531 	int si_current_signal;
532 	int si_avg_signal;
533 	int si_avg_beacon_signal;
534 	int si_current_noise;
535 	int scan_level;
536 };
537 
538 struct robust_av_data {
539 	u8 dialog_token;
540 	enum scs_request_type request_type;
541 	u8 up_bitmap;
542 	u8 up_limit;
543 	u32 stream_timeout;
544 	u8 frame_classifier[48];
545 	size_t frame_classifier_len;
546 	bool valid_config;
547 };
548 
549 struct dscp_policy_status {
550 	u8 id;
551 	u8 status;
552 };
553 
554 struct dscp_resp_data {
555 	bool more;
556 	bool reset;
557 	bool solicited;
558 	struct dscp_policy_status *policy;
559 	int num_policies;
560 };
561 
562 enum ip_version {
563 	IPV4 = 4,
564 	IPV6 = 6,
565 };
566 
567 
568 struct ipv4_params {
569 	struct in_addr src_ip;
570 	struct in_addr dst_ip;
571 	u16 src_port;
572 	u16 dst_port;
573 	u8 dscp;
574 	u8 protocol;
575 };
576 
577 
578 struct ipv6_params {
579 	struct in6_addr src_ip;
580 	struct in6_addr dst_ip;
581 	u16 src_port;
582 	u16 dst_port;
583 	u8 dscp;
584 	u8 next_header;
585 	u8 flow_label[3];
586 };
587 
588 
589 struct type4_params {
590 	u8 classifier_mask;
591 	enum ip_version ip_version;
592 	union {
593 		struct ipv4_params v4;
594 		struct ipv6_params v6;
595 	} ip_params;
596 };
597 
598 
599 struct type10_params {
600 	u8 prot_instance;
601 	u8 prot_number;
602 	u8 *filter_value;
603 	u8 *filter_mask;
604 	size_t filter_len;
605 };
606 
607 
608 struct tclas_element {
609 	u8 user_priority;
610 	u8 classifier_type;
611 	union {
612 		struct type4_params type4_param;
613 		struct type10_params type10_param;
614 	} frame_classifier;
615 };
616 
617 
618 struct qos_characteristics {
619 	bool available;
620 
621 	/* Control Info Direction */
622 	u8 direction;
623 	/* Presence Bitmap Of Additional Parameters */
624 	u16 mask;
625 	/* Minimum Service Interval */
626 	u32 min_si;
627 	/* Maximum Service Interval */
628 	u32 max_si;
629 	/* Minimum Data Rate */
630 	u32 min_data_rate;
631 	/* Delay Bound */
632 	u32 delay_bound;
633 	/* Maximum MSDU Size */
634 	u16 max_msdu_size;
635 	/* Service Start Time */
636 	u32 service_start_time;
637 	/* Service Start Time LinkID */
638 	u8 service_start_time_link_id;
639 	/* Mean Data Rate */
640 	u32 mean_data_rate;
641 	/* Delayed Bounded Burst Size */
642 	u32 burst_size;
643 	/* MSDU Lifetime */
644 	u16 msdu_lifetime;
645 	/* MSDU Delivery Info */
646 	u8 msdu_delivery_info;
647 	/* Medium Time */
648 	u16 medium_time;
649 };
650 
651 
652 struct scs_desc_elem {
653 	u8 scs_id;
654 	enum scs_request_type request_type;
655 	u8 intra_access_priority;
656 	bool scs_up_avail;
657 	struct tclas_element *tclas_elems;
658 	unsigned int num_tclas_elem;
659 	u8 tclas_processing;
660 	struct qos_characteristics qos_char_elem;
661 };
662 
663 
664 struct scs_robust_av_data {
665 	struct scs_desc_elem *scs_desc_elems;
666 	unsigned int num_scs_desc;
667 };
668 
669 
670 enum scs_response_status {
671 	SCS_DESC_SENT = 0,
672 	SCS_DESC_SUCCESS = 1,
673 };
674 
675 
676 struct active_scs_elem {
677 	struct dl_list list;
678 	u8 scs_id;
679 	enum scs_response_status status;
680 	struct scs_desc_elem desc_elem;
681 };
682 
683 
684 struct ml_sta_link_info {
685 	u8 link_id;
686 	u8 bssid[ETH_ALEN];
687 	u16 status;
688 };
689 
690 
691 enum local_hw_capab {
692 	CAPAB_HT,
693 	CAPAB_VHT,
694 	CAPAB_HE,
695 	CAPAB_EHT,
696 };
697 
698 struct last_scan_ssid {
699 	u8 ssid[SSID_MAX_LEN];
700 	size_t ssid_len;
701 };
702 
703 #ifdef CONFIG_IEEE8021X_AUTH
704 /**
705  * struct auth_802_1x_data - Data for IEEE 802.1X Authentication algorithm
706  * @auth_trans: Authentication transaction sequence number
707  * @status: Status code
708  * @derive_ptk: Whether to derive a PTK for association
709  * @pmksa_caching: Whether PMKSA caching is being used
710  * @pmkid_found: Whether PMKID is identified by AP
711  * @pmkid: PMKID for PMKSA caching
712  * @snonce: SNonce
713  * @anonce: ANonce
714  * @dh_group: DH group for key exchange
715  * @ecdh: ECDH context
716  * @dhss: DH shared secret
717  * @rsne: RSNE
718  * @rsne_len: Length of RSNE
719  * @rsnxe: RSNXE
720  * @rsnxe_len: Length of RSNXE
721  */
722 struct auth_802_1x_data {
723 	u16 auth_trans;
724 	u16 status;
725 	bool derive_ptk;
726 	bool pmksa_caching;
727 	bool pmkid_found;
728 	u8 pmkid[PMKID_LEN];
729 	u8 snonce[WPA_NONCE_LEN];
730 	u8 anonce[WPA_NONCE_LEN];
731 	u16 dh_group;
732 	struct crypto_ecdh *ecdh;
733 	struct wpabuf *dhss;
734 	u8 rsne[257];
735 	size_t rsne_len;
736 	u8 rsnxe[257];
737 	size_t rsnxe_len;
738 };
739 #endif /* CONFIG_IEEE8021X_AUTH */
740 
741 /**
742  * struct wpa_supplicant - Internal data for wpa_supplicant interface
743  *
744  * This structure contains the internal data for core wpa_supplicant code. This
745  * should be only used directly from the core code. However, a pointer to this
746  * data is used from other files as an arbitrary context pointer in calls to
747  * core functions.
748  */
749 struct wpa_supplicant {
750 	struct wpa_global *global;
751 	struct wpa_radio *radio; /* shared radio context */
752 	struct dl_list radio_list; /* list head: struct wpa_radio::ifaces */
753 	struct wpa_supplicant *parent;
754 	struct wpa_supplicant *p2pdev;
755 	struct wpa_supplicant *next;
756 	struct l2_packet_data *l2;
757 	struct l2_packet_data *l2_br;
758 	struct os_reltime roam_start;
759 	struct os_reltime roam_time;
760 	struct os_reltime session_start;
761 	struct os_reltime session_length;
762 	unsigned char own_addr[ETH_ALEN];
763 	unsigned char perm_addr[ETH_ALEN];
764 	char ifname[100];
765 	u8 hw_dfs_domain;
766 #ifdef CONFIG_MATCH_IFACE
767 	int matched;
768 #endif /* CONFIG_MATCH_IFACE */
769 #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
770 	char *dbus_new_path;
771 	char *dbus_groupobj_path;
772 #ifdef CONFIG_AP
773 	char *preq_notify_peer;
774 #endif /* CONFIG_AP */
775 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
776 #ifdef CONFIG_CTRL_IFACE_BINDER
777 	const void *binder_object_key;
778 #endif /* CONFIG_CTRL_IFACE_BINDER */
779 	char bridge_ifname[16];
780 
781 	char *confname;
782 	char *confanother;
783 
784 	struct wpa_config *conf;
785 	int countermeasures;
786 	struct os_reltime last_michael_mic_error;
787 	u8 bssid[ETH_ALEN];
788 	u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
789 				     * field contains the target BSSID. */
790 	int reassociate; /* reassociation requested */
791 	bool roam_in_progress; /* roam in progress */
792 	unsigned int reassoc_same_bss:1; /* reassociating to the same BSS */
793 	unsigned int reassoc_same_ess:1; /* reassociating to the same ESS */
794 	int disconnected; /* all connections disabled; i.e., do no reassociate
795 			   * before this has been cleared */
796 	struct wpa_ssid *current_ssid;
797 	struct wpa_ssid *last_ssid;
798 	struct wpa_bss *current_bss;
799 	int ap_ies_from_associnfo;
800 	unsigned int assoc_freq;
801 	u8 ap_mld_addr[ETH_ALEN];
802 	u8 mlo_assoc_link_id;
803 	u16 valid_links; /* bitmap of valid MLO link IDs */
804 	struct {
805 		u8 addr[ETH_ALEN];
806 		u8 bssid[ETH_ALEN];
807 		unsigned int freq;
808 		struct wpa_bss *bss;
809 		bool disabled;
810 		struct wpabuf *ies;
811 		unsigned int max_nss_rx:4;
812 		unsigned int max_nss_tx:4;
813 		enum chan_width channel_bandwidth;
814 	} links[MAX_NUM_MLD_LINKS];
815 	u8 *last_con_fail_realm;
816 	size_t last_con_fail_realm_len;
817 	bool sta_roaming_disabled;
818 
819 	/* Selected configuration (based on Beacon/ProbeResp WPA IE) */
820 	int pairwise_cipher;
821 	int deny_ptk0_rekey;
822 	int group_cipher;
823 	int key_mgmt;
824 	int wpa_proto;
825 	int mgmt_group_cipher;
826 	/*
827 	 * Allowed key management suites for roaming/initial connection
828 	 * when the driver's SME is in use.
829 	 */
830 	int allowed_key_mgmts;
831 
832 	void *drv_priv; /* private data used by driver_ops */
833 	void *global_drv_priv;
834 
835 	u8 *bssid_filter;
836 	size_t bssid_filter_count;
837 
838 	u8 *disallow_aps_bssid;
839 	size_t disallow_aps_bssid_count;
840 	struct wpa_ssid_value *disallow_aps_ssid;
841 	size_t disallow_aps_ssid_count;
842 
843 	u32 setband_mask;
844 
845 	/* Preferred network for the next connection attempt */
846 	struct wpa_ssid *next_ssid;
847 
848 	/* previous scan was wildcard when interleaving between
849 	 * wildcard scans and specific SSID scan when max_ssids=1 */
850 	int prev_scan_wildcard;
851 	struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
852 					  * NULL = not yet initialized (start
853 					  * with wildcard SSID)
854 					  * WILDCARD_SSID_SCAN = wildcard
855 					  * SSID was used in the previous scan
856 					  */
857 #define WILDCARD_SSID_SCAN ((struct wpa_ssid *) 1)
858 
859 	struct wpa_ssid *prev_sched_ssid; /* last SSID used in sched scan */
860 	int sched_scan_timeout;
861 	int first_sched_scan;
862 	int sched_scan_timed_out;
863 	struct sched_scan_plan *sched_scan_plans;
864 	size_t sched_scan_plans_num;
865 
866 	void (*scan_res_handler)(struct wpa_supplicant *wpa_s,
867 				 struct wpa_scan_results *scan_res);
868 	void (*scan_res_fail_handler)(struct wpa_supplicant *wpa_s);
869 	struct dl_list bss; /* struct wpa_bss::list */
870 	struct dl_list bss_id; /* struct wpa_bss::list_id */
871 	size_t num_bss;
872 	unsigned int bss_update_idx;
873 	unsigned int bss_next_id;
874 
875 	 /*
876 	  * Pointers to BSS entries in the order they were in the last scan
877 	  * results.
878 	  */
879 	struct wpa_bss **last_scan_res;
880 	size_t last_scan_res_used;
881 	size_t last_scan_res_size;
882 	struct os_reltime last_scan;
883 	bool last_scan_external;
884 	struct last_scan_ssid last_scan_ssids[WPAS_MAX_SCAN_SSIDS];
885 	size_t last_scan_num_ssids;
886 
887 	const struct wpa_driver_ops *driver;
888 	int interface_removed; /* whether the network interface has been
889 				* removed */
890 	struct wpa_sm *wpa;
891 	struct ptksa_cache *ptksa;
892 
893 	struct eapol_sm *eapol;
894 
895 	struct ctrl_iface_priv *ctrl_iface;
896 
897 	enum wpa_states wpa_state;
898 	struct wpa_radio_work *scan_work;
899 	int scanning;
900 	int sched_scanning;
901 	unsigned int sched_scan_stop_req:1;
902 	int new_connection;
903 
904 	int eapol_received; /* number of EAPOL packets received after the
905 			     * previous association event */
906 
907 	u8 rsnxe[257];
908 	size_t rsnxe_len;
909 
910 	struct scard_data *scard;
911 	char imsi[20];
912 	int mnc_len;
913 
914 	unsigned char last_eapol_src[ETH_ALEN];
915 
916 	unsigned int keys_cleared; /* bitfield of key indexes that the driver is
917 				    * known not to be configured with a key */
918 
919 	struct wpa_bssid_ignore *bssid_ignore;
920 
921 	/* Number of connection failures since last successful connection */
922 	unsigned int consecutive_conn_failures;
923 
924 	/**
925 	 * scan_req - Type of the scan request
926 	 */
927 	enum scan_req_type {
928 		/**
929 		 * NORMAL_SCAN_REQ - Normal scan request
930 		 *
931 		 * This is used for scans initiated by wpa_supplicant to find an
932 		 * AP for a connection.
933 		 */
934 		NORMAL_SCAN_REQ,
935 
936 		/**
937 		 * INITIAL_SCAN_REQ - Initial scan request
938 		 *
939 		 * This is used for the first scan on an interface to force at
940 		 * least one scan to be run even if the configuration does not
941 		 * include any enabled networks.
942 		 */
943 		INITIAL_SCAN_REQ,
944 
945 		/**
946 		 * MANUAL_SCAN_REQ - Manual scan request
947 		 *
948 		 * This is used for scans where the user request a scan or
949 		 * a specific wpa_supplicant operation (e.g., WPS) requires scan
950 		 * to be run.
951 		 */
952 		MANUAL_SCAN_REQ
953 	} scan_req, last_scan_req;
954 	enum wpa_states scan_prev_wpa_state;
955 	struct os_reltime scan_trigger_time, scan_start_time;
956 	/* Minimum freshness requirement for connection purposes */
957 	struct os_reltime scan_min_time;
958 	int scan_runs; /* number of scan runs since WPS was started */
959 	int *next_scan_freqs;
960 	int *select_network_scan_freqs;
961 	int *manual_scan_freqs;
962 	int *manual_sched_scan_freqs;
963 	unsigned int manual_scan_passive:1;
964 	unsigned int manual_scan_use_id:1;
965 	unsigned int manual_scan_only_new:1;
966 	unsigned int own_scan_requested:1;
967 	unsigned int own_scan_running:1;
968 	unsigned int clear_driver_scan_cache:1;
969 	unsigned int manual_non_coloc_6ghz:1;
970 	unsigned int manual_scan_id;
971 	int scan_interval; /* time in sec between scans to find suitable AP */
972 	int normal_scans; /* normal scans run before sched_scan */
973 	int scan_for_connection; /* whether the scan request was triggered for
974 				  * finding a connection */
975 	/*
976 	 * A unique cookie representing the vendor scan request. This cookie is
977 	 * returned from the driver interface. 0 indicates that there is no
978 	 * pending vendor scan request.
979 	 */
980 	u64 curr_scan_cookie;
981 #define MAX_SCAN_ID 16
982 	int scan_id[MAX_SCAN_ID];
983 	unsigned int scan_id_count;
984 	u8 next_scan_bssid[ETH_ALEN];
985 	unsigned int next_scan_bssid_wildcard_ssid:1;
986 
987 	struct wpa_ssid_value *ssids_from_scan_req;
988 	unsigned int num_ssids_from_scan_req;
989 	int *last_scan_freqs; /* int_array */
990 	unsigned int suitable_network;
991 	unsigned int no_suitable_network;
992 
993 	u8 ml_probe_bssid[ETH_ALEN];
994 	int ml_probe_mld_id;
995 	u16 ml_probe_links;
996 
997 	u64 drv_flags;
998 	u64 drv_flags2;
999 	unsigned int drv_enc;
1000 	unsigned int drv_key_mgmt;
1001 	unsigned int drv_rrm_flags;
1002 	unsigned int drv_max_acl_mac_addrs;
1003 	size_t drv_max_probe_req_ie_len;
1004 
1005 	/*
1006 	 * A bitmap of supported protocols for probe response offload. See
1007 	 * struct wpa_driver_capa in driver.h
1008 	 */
1009 	unsigned int probe_resp_offloads;
1010 
1011 	/* extended capabilities supported by the driver */
1012 	const u8 *extended_capa, *extended_capa_mask;
1013 	unsigned int extended_capa_len;
1014 
1015 	/* EML and MLD capabilities supported by the driver */
1016 	u16 eml_capa, mld_capa;
1017 
1018 	int max_scan_ssids;
1019 	int max_sched_scan_ssids;
1020 	unsigned int max_sched_scan_plans;
1021 	unsigned int max_sched_scan_plan_interval;
1022 	unsigned int max_sched_scan_plan_iterations;
1023 	int sched_scan_supported;
1024 	unsigned int max_match_sets;
1025 	unsigned int max_remain_on_chan;
1026 	unsigned int max_stations;
1027 	unsigned int max_num_akms;
1028 
1029 	int pending_mic_error_report;
1030 	int pending_mic_error_pairwise;
1031 	int mic_errors_seen; /* Michael MIC errors with the current PTK */
1032 
1033 	struct wps_context *wps;
1034 	int wps_success; /* WPS success event received */
1035 	struct wps_er *wps_er;
1036 	unsigned int wps_run;
1037 	struct os_reltime wps_pin_start_time;
1038 	bool bssid_ignore_cleared;
1039 
1040 	struct wpabuf *pending_eapol_rx;
1041 	struct os_reltime pending_eapol_rx_time;
1042 	u8 pending_eapol_rx_src[ETH_ALEN];
1043 	enum frame_encryption pending_eapol_encrypted;
1044 	unsigned int last_eapol_matches_bssid:1;
1045 	unsigned int eapol_failed:1;
1046 	unsigned int eap_expected_failure:1;
1047 	unsigned int reattach:1; /* reassociation to the same BSS requested */
1048 	unsigned int mac_addr_changed:1;
1049 	unsigned int added_vif:1;
1050 	unsigned int wnmsleep_used:1;
1051 	unsigned int owe_transition_select:1;
1052 	unsigned int owe_transition_search:1;
1053 	unsigned int connection_set:1;
1054 	unsigned int connection_ht:1;
1055 	unsigned int connection_vht:1;
1056 	unsigned int connection_he:1;
1057 	unsigned int connection_eht:1;
1058 	unsigned int disable_mbo_oce:1;
1059 	u8 connection_max_nss_rx;
1060 	u8 connection_max_nss_tx;
1061 	enum chan_width connection_channel_bandwidth;
1062 
1063 	struct os_reltime last_mac_addr_change;
1064 	enum wpas_mac_addr_style last_mac_addr_style;
1065 
1066 	struct ibss_rsn *ibss_rsn;
1067 
1068 	int set_sta_uapsd;
1069 	int sta_uapsd;
1070 	int set_ap_uapsd;
1071 	int ap_uapsd;
1072 	int auth_alg;
1073 	u16 last_owe_group;
1074 
1075 #ifdef CONFIG_SME
1076 	struct {
1077 		u8 ssid[SSID_MAX_LEN];
1078 		size_t ssid_len;
1079 		int freq;
1080 		u8 assoc_req_ie[1500];
1081 		size_t assoc_req_ie_len;
1082 		int mfp;
1083 		int ft_used;
1084 		u8 mobility_domain[2];
1085 		u8 *ft_ies;
1086 		size_t ft_ies_len;
1087 		u8 prev_bssid[ETH_ALEN];
1088 		int prev_bssid_set;
1089 		int auth_alg;
1090 		int proto;
1091 
1092 		int sa_query_count; /* number of pending SA Query requests;
1093 				     * 0 = no SA Query in progress */
1094 		int sa_query_timed_out;
1095 		u8 *sa_query_trans_id; /* buffer of WLAN_SA_QUERY_TR_ID_LEN *
1096 					* sa_query_count octets of pending
1097 					* SA Query transaction identifiers */
1098 		struct os_reltime sa_query_start;
1099 		struct os_reltime last_unprot_disconnect;
1100 		enum { HT_SEC_CHAN_UNKNOWN,
1101 		       HT_SEC_CHAN_ABOVE,
1102 		       HT_SEC_CHAN_BELOW } ht_sec_chan;
1103 		u8 sched_obss_scan;
1104 		u16 obss_scan_int;
1105 		u16 bss_max_idle_period;
1106 		bool spp_amsdu;
1107 #ifdef CONFIG_SAE
1108 		struct sae_data sae;
1109 		struct wpabuf *sae_token;
1110 		int sae_group_index;
1111 		unsigned int sae_pmksa_caching:1;
1112 		u16 seq_num;
1113 		int *sae_rejected_groups;
1114 #endif /* CONFIG_SAE */
1115 		u8 ext_auth_bssid[ETH_ALEN];
1116 		unsigned int ext_auth_freq;
1117 		struct wpa_ssid *ext_auth_wpa_ssid;
1118 		u8 ext_auth_ssid[SSID_MAX_LEN];
1119 		size_t ext_auth_ssid_len;
1120 		int ext_auth_key_mgmt;
1121 		u8 ext_auth_ap_mld_addr[ETH_ALEN];
1122 		bool ext_ml_auth;
1123 		u16 assoc_auth_type;
1124 		int ext_auth_alg;
1125 		int ext_pairwise_cipher;
1126 		int ext_group_cipher;
1127 		int ext_mgmt_group_cipher;
1128 		u16 ext_rsn_capab;
1129 		u8 ext_rsnxe[257];
1130 		size_t ext_rsnxe_len;
1131 	} sme;
1132 #endif /* CONFIG_SME */
1133 
1134 #ifdef CONFIG_AP
1135 	struct hostapd_iface *ap_iface;
1136 	void (*ap_configured_cb)(void *ctx, void *data);
1137 	void *ap_configured_cb_ctx;
1138 	void *ap_configured_cb_data;
1139 #endif /* CONFIG_AP */
1140 
1141 	struct hostapd_iface *ifmsh;
1142 #ifdef CONFIG_MESH
1143 	struct mesh_rsn *mesh_rsn;
1144 	int mesh_if_idx;
1145 	unsigned int mesh_if_created:1;
1146 	unsigned int mesh_ht_enabled:1;
1147 	unsigned int mesh_vht_enabled:1;
1148 	unsigned int mesh_he_enabled:1;
1149 	unsigned int mesh_eht_enabled:1;
1150 	struct wpa_driver_mesh_join_params *mesh_params;
1151 #ifdef CONFIG_PMKSA_CACHE_EXTERNAL
1152 	/* struct external_pmksa_cache::list */
1153 	struct dl_list mesh_external_pmksa_cache;
1154 #endif /* CONFIG_PMKSA_CACHE_EXTERNAL */
1155 #endif /* CONFIG_MESH */
1156 
1157 	unsigned int off_channel_freq;
1158 	struct wpabuf *pending_action_tx;
1159 	u8 pending_action_src[ETH_ALEN];
1160 	u8 pending_action_dst[ETH_ALEN];
1161 	u8 pending_action_bssid[ETH_ALEN];
1162 	unsigned int pending_action_freq;
1163 	int pending_action_no_cck;
1164 	int pending_action_without_roc;
1165 	unsigned int pending_action_tx_done:1;
1166 	void (*pending_action_tx_status_cb)(struct wpa_supplicant *wpa_s,
1167 					    unsigned int freq, const u8 *dst,
1168 					    const u8 *src, const u8 *bssid,
1169 					    const u8 *data, size_t data_len,
1170 					    enum offchannel_send_action_result
1171 					    result);
1172 	unsigned int roc_waiting_drv_freq;
1173 	int action_tx_wait_time;
1174 	int action_tx_wait_time_used;
1175 
1176 	int p2p_mgmt;
1177 
1178 #ifdef CONFIG_P2P
1179 	struct p2p_go_neg_results *go_params;
1180 	struct rsn_pmksa_cache_entry *p2p_pmksa_entry;
1181 	int create_p2p_iface;
1182 	u8 pending_interface_addr[ETH_ALEN];
1183 	char pending_interface_name[100];
1184 	int pending_interface_type;
1185 	int p2p_group_idx;
1186 	unsigned int pending_listen_freq;
1187 	unsigned int pending_listen_duration;
1188 	enum {
1189 		NOT_P2P_GROUP_INTERFACE,
1190 		P2P_GROUP_INTERFACE_PENDING,
1191 		P2P_GROUP_INTERFACE_GO,
1192 		P2P_GROUP_INTERFACE_CLIENT
1193 	} p2p_group_interface;
1194 	struct p2p_group *p2p_group;
1195 	char p2p_pin[10];
1196 	int p2p_wps_method;
1197 	u8 p2p_auth_invite[ETH_ALEN];
1198 	int p2p_sd_over_ctrl_iface;
1199 	int p2p_in_provisioning;
1200 	int p2p_in_invitation;
1201 	int p2p_retry_limit;
1202 	int p2p_invite_go_freq;
1203 	bool p2p_pairing_setup;
1204 	bool p2p_pairing_cache;
1205 	int pending_invite_ssid_id;
1206 	int show_group_started;
1207 	u8 go_dev_addr[ETH_ALEN];
1208 	int pending_pd_before_join;
1209 	u8 pending_join_iface_addr[ETH_ALEN];
1210 	u8 pending_join_dev_addr[ETH_ALEN];
1211 	u8 p2p_bootstrap_dev_addr[ETH_ALEN];
1212 	int pending_join_wps_method;
1213 	char pending_join_password[100];
1214 	u8 p2p_join_ssid[SSID_MAX_LEN];
1215 	size_t p2p_join_ssid_len;
1216 	int p2p_join_scan_count;
1217 	int auto_pd_scan_retry;
1218 	int force_long_sd;
1219 	u16 pending_pd_config_methods;
1220 	enum {
1221 		NORMAL_PD, AUTO_PD_GO_NEG, AUTO_PD_JOIN, AUTO_PD_ASP
1222 	} pending_pd_use;
1223 
1224 	/*
1225 	 * Whether cross connection is disallowed by the AP to which this
1226 	 * interface is associated (only valid if there is an association).
1227 	 */
1228 	int cross_connect_disallowed;
1229 
1230 	/*
1231 	 * Whether this P2P group is configured to use cross connection (only
1232 	 * valid if this is P2P GO interface). The actual cross connect packet
1233 	 * forwarding may not be configured depending on the uplink status.
1234 	 */
1235 	int cross_connect_enabled;
1236 
1237 	/* Whether cross connection forwarding is in use at the moment. */
1238 	int cross_connect_in_use;
1239 
1240 	/*
1241 	 * Uplink interface name for cross connection
1242 	 */
1243 	char cross_connect_uplink[100];
1244 
1245 	unsigned int p2p_auto_join:1;
1246 	unsigned int p2p_auto_pd:1;
1247 	unsigned int p2p_go_do_acs:1;
1248 	unsigned int p2p_persistent_group:1;
1249 	unsigned int p2p_fallback_to_go_neg:1;
1250 	unsigned int p2p_pd_before_go_neg:1;
1251 	unsigned int p2p_go_ht40:1;
1252 	unsigned int p2p_go_vht:1;
1253 	unsigned int p2p_go_edmg:1;
1254 	unsigned int p2p_go_he:1;
1255 	unsigned int user_initiated_pd:1;
1256 	unsigned int p2p_go_group_formation_completed:1;
1257 	unsigned int group_formation_reported:1;
1258 	unsigned int p2p_go_no_pri_sec_switch:1;
1259 	unsigned int waiting_presence_resp;
1260 	int p2p_first_connection_timeout;
1261 	unsigned int p2p_nfc_tag_enabled:1;
1262 	unsigned int p2p_peer_oob_pk_hash_known:1;
1263 	unsigned int p2p_disable_ip_addr_req:1;
1264 	unsigned int p2ps_method_config_any:1;
1265 	unsigned int p2p_cli_probe:1;
1266 	unsigned int p2p_go_allow_dfs:1;
1267 	unsigned int p2p2:1;
1268 	u16 p2p_bootstrap;
1269 	enum hostapd_hw_mode p2p_go_acs_band;
1270 	enum wpa_p2p_mode p2p_mode;
1271 	int p2p_persistent_go_freq;
1272 	int p2p_persistent_id;
1273 	int p2p_go_intent;
1274 	int p2p_connect_freq;
1275 	struct os_reltime p2p_auto_started;
1276 	struct wpa_ssid *p2p_last_4way_hs_fail;
1277 	struct wpa_radio_work *p2p_scan_work;
1278 	struct wpa_radio_work *p2p_listen_work;
1279 	struct wpa_radio_work *p2p_send_action_work;
1280 	bool p2p_removing_listen_work;
1281 
1282 	u16 p2p_oob_dev_pw_id; /* OOB Device Password Id for group formation */
1283 	struct wpabuf *p2p_oob_dev_pw; /* OOB Device Password for group
1284 					* formation */
1285 	u8 p2p_peer_oob_pubkey_hash[WPS_OOB_PUBKEY_HASH_LEN];
1286 	u8 p2p_ip_addr_info[3 * 4];
1287 
1288 	/* group common frequencies */
1289 	int *p2p_group_common_freqs;
1290 	unsigned int p2p_group_common_freqs_num;
1291 	u8 p2ps_join_addr[ETH_ALEN];
1292 
1293 	unsigned int p2p_go_max_oper_chwidth;
1294 	unsigned int p2p_go_vht_center_freq2;
1295 	int p2p_lo_started;
1296 	bool p2p_neg_go_setup;
1297 #endif /* CONFIG_P2P */
1298 
1299 	struct wpa_ssid *bgscan_ssid;
1300 	const struct bgscan_ops *bgscan;
1301 	void *bgscan_priv;
1302 	int signal_threshold;
1303 
1304 	const struct autoscan_ops *autoscan;
1305 	struct wpa_driver_scan_params *autoscan_params;
1306 	void *autoscan_priv;
1307 
1308 	struct wpa_ssid *connect_without_scan;
1309 
1310 	struct wps_ap_info *wps_ap;
1311 	size_t num_wps_ap;
1312 	int wps_ap_iter;
1313 
1314 	int after_wps;
1315 	int known_wps_freq;
1316 	unsigned int wps_freq;
1317 	int wps_fragment_size;
1318 	int auto_reconnect_disabled;
1319 
1320 	 /* Channel preferences for AP/P2P GO use */
1321 	int best_24_freq;
1322 	int best_5_freq;
1323 	int best_overall_freq;
1324 
1325 	struct gas_query *gas;
1326 	struct gas_server *gas_server;
1327 
1328 #ifdef CONFIG_INTERWORKING
1329 	unsigned int fetch_anqp_in_progress:1;
1330 	unsigned int network_select:1;
1331 	unsigned int auto_select:1;
1332 	unsigned int auto_network_select:1;
1333 	unsigned int interworking_fast_assoc_tried:1;
1334 	unsigned int fetch_all_anqp:1;
1335 	struct wpa_bss *interworking_gas_bss;
1336 #endif /* CONFIG_INTERWORKING */
1337 	unsigned int drv_capa_known;
1338 
1339 	struct {
1340 		struct hostapd_hw_modes *modes;
1341 		u16 num_modes;
1342 		u16 flags;
1343 	} hw;
1344 	unsigned int hw_capab; /* bitmap of enum local_hw_capab bits */
1345 #ifdef CONFIG_MACSEC
1346 	struct ieee802_1x_kay *kay;
1347 #endif /* CONFIG_MACSEC */
1348 
1349 	int pno;
1350 	int pno_sched_pending;
1351 
1352 	/* WLAN_REASON_* reason codes. Negative if locally generated. */
1353 	int disconnect_reason;
1354 
1355 	/* WLAN_STATUS_* status codes from last received Authentication frame
1356 	 * from the AP. */
1357 	u16 auth_status_code;
1358 
1359 	/* WLAN_STATUS_* status codes from (Re)Association Response frame. */
1360 	u16 assoc_status_code;
1361 
1362 	struct ext_password_data *ext_pw;
1363 
1364 	struct wpabuf *last_gas_resp, *prev_gas_resp;
1365 	u8 last_gas_addr[ETH_ALEN], prev_gas_addr[ETH_ALEN];
1366 	u8 last_gas_dialog_token, prev_gas_dialog_token;
1367 
1368 	unsigned int no_keep_alive:1;
1369 	unsigned int ext_mgmt_frame_handling:1;
1370 	unsigned int ext_eapol_frame_io:1;
1371 	unsigned int wmm_ac_supported:1;
1372 	unsigned int ext_work_in_progress:1;
1373 	unsigned int own_disconnect_req:1;
1374 	unsigned int own_reconnect_req:1;
1375 	unsigned int ignore_post_flush_scan_res:1;
1376 
1377 #define MAC_ADDR_RAND_SCAN       BIT(0)
1378 #define MAC_ADDR_RAND_SCHED_SCAN BIT(1)
1379 #define MAC_ADDR_RAND_PNO        BIT(2)
1380 #define MAC_ADDR_RAND_ALL        (MAC_ADDR_RAND_SCAN | \
1381 				  MAC_ADDR_RAND_SCHED_SCAN | \
1382 				  MAC_ADDR_RAND_PNO)
1383 	unsigned int mac_addr_rand_supported;
1384 	unsigned int mac_addr_rand_enable;
1385 
1386 	/* MAC Address followed by mask (2 * ETH_ALEN) */
1387 	u8 *mac_addr_scan;
1388 	u8 *mac_addr_sched_scan;
1389 	u8 *mac_addr_pno;
1390 
1391 #ifdef CONFIG_WNM
1392 	bool wnm_transition_scan;
1393 	u8 wnm_dialog_token;
1394 	u8 wnm_reply;
1395 	u8 wnm_num_neighbor_report;
1396 	u8 wnm_mode;
1397 	bool wnm_link_removal;
1398 	bool wnm_disassoc_mld;
1399 	u8 wnm_disassoc_addr[ETH_ALEN];
1400 	u16 wnm_disassoc_timer;
1401 	u8 wnm_bss_termination_duration[12];
1402 	struct neighbor_report *wnm_neighbor_report_elements;
1403 	struct os_reltime wnm_cand_valid_until;
1404 	struct wpa_bss *wnm_target_bss;
1405 	enum bss_trans_mgmt_status_code bss_tm_status;
1406 	bool bss_trans_mgmt_in_progress;
1407 	u8 coloc_intf_dialog_token;
1408 	u8 coloc_intf_auto_report;
1409 	u8 coloc_intf_timeout;
1410 #ifdef CONFIG_MBO
1411 	unsigned int wnm_mbo_trans_reason_present:1;
1412 	u8 wnm_mbo_transition_reason;
1413 #endif /* CONFIG_MBO */
1414 #endif /* CONFIG_WNM */
1415 
1416 #ifdef CONFIG_TESTING_GET_GTK
1417 	u8 last_gtk[32];
1418 	size_t last_gtk_len;
1419 #endif /* CONFIG_TESTING_GET_GTK */
1420 
1421 	unsigned int num_multichan_concurrent;
1422 	struct wpa_radio_work *connect_work;
1423 
1424 	unsigned int ext_work_id;
1425 
1426 	struct wpabuf *vendor_elem[NUM_VENDOR_ELEM_FRAMES];
1427 
1428 #ifdef CONFIG_TESTING_OPTIONS
1429 	struct l2_packet_data *l2_test;
1430 	unsigned int extra_roc_dur;
1431 	enum wpa_supplicant_test_failure test_failure;
1432 	char *get_pref_freq_list_override;
1433 	unsigned int reject_btm_req_reason;
1434 	unsigned int p2p_go_csa_on_inv:1;
1435 	unsigned int ignore_auth_resp:1;
1436 	unsigned int ignore_assoc_disallow:1;
1437 	unsigned int disable_sa_query:1;
1438 	unsigned int testing_resend_assoc:1;
1439 	unsigned int ignore_sae_h2e_only:1;
1440 	int ft_rsnxe_used;
1441 	struct wpabuf *sae_commit_override;
1442 	enum wpa_alg last_tk_alg;
1443 	u8 last_tk_addr[ETH_ALEN];
1444 	int last_tk_key_idx;
1445 	u8 last_tk[WPA_TK_MAX_LEN];
1446 	size_t last_tk_len;
1447 	struct wpabuf *last_assoc_req_wpa_ie;
1448 	int *extra_sae_rejected_groups;
1449 	struct wpabuf *rsne_override_eapol;
1450 	struct wpabuf *rsnxe_override_assoc;
1451 	struct wpabuf *rsnxe_override_eapol;
1452 	struct dl_list drv_signal_override;
1453 	unsigned int oci_freq_override_eapol;
1454 	unsigned int oci_freq_override_saquery_req;
1455 	unsigned int oci_freq_override_saquery_resp;
1456 	unsigned int oci_freq_override_eapol_g2;
1457 	unsigned int oci_freq_override_ft_assoc;
1458 	unsigned int oci_freq_override_fils_assoc;
1459 	unsigned int oci_freq_override_wnm_sleep;
1460 	unsigned int disable_eapol_g2_tx;
1461 	unsigned int eapol_2_key_info_set_mask;
1462 	int test_assoc_comeback_type;
1463 	struct wpabuf *link_ies[MAX_NUM_MLD_LINKS];
1464 #endif /* CONFIG_TESTING_OPTIONS */
1465 
1466 	struct wmm_ac_assoc_data *wmm_ac_assoc_info;
1467 	struct wmm_tspec_element *tspecs[WMM_AC_NUM][TS_DIR_IDX_COUNT];
1468 	struct wmm_ac_addts_request *addts_request;
1469 	u8 wmm_ac_last_dialog_token;
1470 	struct wmm_tspec_element *last_tspecs;
1471 	u8 last_tspecs_count;
1472 
1473 	struct rrm_data rrm;
1474 	struct beacon_rep_data beacon_rep_data;
1475 
1476 #ifdef CONFIG_FST
1477 	struct fst_iface *fst;
1478 	const struct wpabuf *fst_ies;
1479 	struct wpabuf *received_mb_ies;
1480 #endif /* CONFIG_FST */
1481 
1482 #ifdef CONFIG_MBO
1483 	/* Multiband operation non-preferred channel */
1484 	struct wpa_mbo_non_pref_channel {
1485 		enum mbo_non_pref_chan_reason reason;
1486 		u8 oper_class;
1487 		u8 chan;
1488 		u8 preference;
1489 	} *non_pref_chan;
1490 	size_t non_pref_chan_num;
1491 	u8 mbo_wnm_token;
1492 	/**
1493 	 * enable_oce - Enable OCE if it is enabled by user and device also
1494 	 *		supports OCE.
1495 	 * User can enable OCE with wpa_config's 'oce' parameter as follows -
1496 	 *  - Set BIT(0) to enable OCE in non-AP STA mode.
1497 	 *  - Set BIT(1) to enable OCE in STA-CFON mode.
1498 	 */
1499 	u8 enable_oce;
1500 #endif /* CONFIG_MBO */
1501 
1502 	/*
1503 	 * This should be under CONFIG_MBO, but it is left out to allow using
1504 	 * the bss_temp_disallowed list for other purposes as well.
1505 	 */
1506 	struct dl_list bss_tmp_disallowed;
1507 
1508 	/*
1509 	 * Content of a measurement report element with type 8 (LCI),
1510 	 * own location.
1511 	 */
1512 	struct wpabuf *lci;
1513 	struct os_reltime lci_time;
1514 
1515 	struct os_reltime beacon_rep_scan;
1516 
1517 	/* FILS HLP requests (struct fils_hlp_req) */
1518 	struct dl_list fils_hlp_req;
1519 
1520 	struct sched_scan_relative_params {
1521 		/**
1522 		 * relative_rssi_set - Enable relatively preferred BSS reporting
1523 		 *
1524 		 * 0 = Disable reporting relatively preferred BSSs
1525 		 * 1 = Enable reporting relatively preferred BSSs
1526 		 */
1527 		int relative_rssi_set;
1528 
1529 		/**
1530 		 * relative_rssi - Relative RSSI for reporting better BSSs
1531 		 *
1532 		 * Amount of RSSI by which a BSS should be better than the
1533 		 * current connected BSS so that the new BSS can be reported
1534 		 * to user space. This applies to sched_scan operations.
1535 		 */
1536 		int relative_rssi;
1537 
1538 		/**
1539 		 * relative_adjust_band - Band in which RSSI is to be adjusted
1540 		 */
1541 		enum set_band relative_adjust_band;
1542 
1543 		/**
1544 		 * relative_adjust_rssi - RSSI adjustment
1545 		 *
1546 		 * An amount of relative_adjust_rssi should be added to the
1547 		 * BSSs that belong to the relative_adjust_band while comparing
1548 		 * with other bands for BSS reporting.
1549 		 */
1550 		int relative_adjust_rssi;
1551 	} srp;
1552 
1553 	/* RIC elements for FT protocol */
1554 	struct wpabuf *ric_ies;
1555 
1556 	int last_auth_timeout_sec;
1557 
1558 #ifdef CONFIG_DPP
1559 	struct dpp_global *dpp;
1560 	struct dpp_authentication *dpp_auth;
1561 	struct wpa_radio_work *dpp_listen_work;
1562 	unsigned int dpp_pending_listen_freq;
1563 	unsigned int dpp_listen_freq;
1564 	struct os_reltime dpp_listen_end;
1565 	u8 dpp_allowed_roles;
1566 	int dpp_qr_mutual;
1567 	int dpp_netrole;
1568 	int dpp_auth_ok_on_ack;
1569 	int dpp_in_response_listen;
1570 	bool dpp_tx_auth_resp_on_roc_stop;
1571 	bool dpp_tx_chan_change;
1572 	bool dpp_listen_on_tx_expire;
1573 	int dpp_gas_client;
1574 	int dpp_gas_server;
1575 	int dpp_gas_dialog_token;
1576 	u8 dpp_intro_bssid[ETH_ALEN];
1577 	void *dpp_intro_network;
1578 	u8 dpp_intro_peer_version;
1579 	struct dpp_pkex *dpp_pkex;
1580 	struct dpp_bootstrap_info *dpp_pkex_bi;
1581 	char *dpp_pkex_code;
1582 	size_t dpp_pkex_code_len;
1583 	char *dpp_pkex_identifier;
1584 	enum dpp_pkex_ver dpp_pkex_ver;
1585 	char *dpp_pkex_auth_cmd;
1586 	char *dpp_configurator_params;
1587 	struct os_reltime dpp_last_init;
1588 	struct os_reltime dpp_init_iter_start;
1589 	unsigned int dpp_init_max_tries;
1590 	unsigned int dpp_init_retry_time;
1591 	unsigned int dpp_resp_wait_time;
1592 	unsigned int dpp_resp_max_tries;
1593 	unsigned int dpp_resp_retry_time;
1594 	u8 dpp_last_ssid[SSID_MAX_LEN];
1595 	size_t dpp_last_ssid_len;
1596 	bool dpp_conf_backup_received;
1597 	bool dpp_pkex_wait_auth_req;
1598 #ifdef CONFIG_DPP2
1599 	struct dpp_pfs *dpp_pfs;
1600 	int dpp_pfs_fallback;
1601 	struct wpabuf *dpp_presence_announcement;
1602 	struct dpp_bootstrap_info *dpp_chirp_bi;
1603 	int dpp_chirp_freq;
1604 	int *dpp_chirp_freqs;
1605 	int dpp_chirp_iter;
1606 	int dpp_chirp_round;
1607 	int dpp_chirp_scan_done;
1608 	int dpp_chirp_listen;
1609 	struct wpa_ssid *dpp_reconfig_ssid;
1610 	int dpp_reconfig_ssid_id;
1611 	struct dpp_reconfig_id *dpp_reconfig_id;
1612 #endif /* CONFIG_DPP2 */
1613 #ifdef CONFIG_DPP3
1614 	struct os_reltime dpp_pb_time;
1615 	bool dpp_pb_configurator;
1616 	int *dpp_pb_freqs;
1617 	unsigned int dpp_pb_freq_idx;
1618 	unsigned int dpp_pb_announce_count;
1619 	struct wpabuf *dpp_pb_announcement;
1620 	struct dpp_bootstrap_info *dpp_pb_bi;
1621 	unsigned int dpp_pb_resp_freq;
1622 	u8 dpp_pb_init_hash[SHA256_MAC_LEN];
1623 	int dpp_pb_stop_iter;
1624 	bool dpp_pb_discovery_done;
1625 	u8 dpp_pb_c_nonce[DPP_MAX_NONCE_LEN];
1626 	size_t dpp_pb_c_nonce_len;
1627 	bool dpp_pb_result_indicated;
1628 	struct os_reltime dpp_pb_announce_time;
1629 	struct dpp_pb_info dpp_pb[DPP_PB_INFO_COUNT];
1630 	u8 dpp_pb_resp_hash[SHA256_MAC_LEN];
1631 	struct os_reltime dpp_pb_last_resp;
1632 	char *dpp_pb_cmd;
1633 #endif /* CONFIG_DPP3 */
1634 #ifdef CONFIG_TESTING_OPTIONS
1635 	char *dpp_config_obj_override;
1636 	char *dpp_discovery_override;
1637 	char *dpp_groups_override;
1638 	unsigned int dpp_ignore_netaccesskey_mismatch:1;
1639 	unsigned int dpp_discard_public_action:1;
1640 #endif /* CONFIG_TESTING_OPTIONS */
1641 #endif /* CONFIG_DPP */
1642 
1643 #ifdef CONFIG_FILS
1644 	unsigned int disable_fils:1;
1645 #endif /* CONFIG_FILS */
1646 	unsigned int ieee80211ac:1;
1647 	unsigned int enabled_4addr_mode:1;
1648 	unsigned int multi_bss_support:1;
1649 	unsigned int drv_authorized_port:1;
1650 	unsigned int multi_ap_ie:1;
1651 	unsigned int multi_ap_backhaul:1;
1652 	unsigned int multi_ap_fronthaul:1;
1653 
1654 #ifndef CONFIG_NO_ROBUST_AV
1655 	struct robust_av_data robust_av;
1656 	bool mscs_setup_done;
1657 	struct scs_robust_av_data scs_robust_av_req;
1658 	u8 scs_dialog_token;
1659 	struct dl_list active_scs_ids;
1660 	bool ongoing_scs_req;
1661 	u8 dscp_req_dialog_token;
1662 	u8 dscp_query_dialog_token;
1663 	unsigned int enable_dscp_policy_capa:1;
1664 	unsigned int connection_dscp:1;
1665 	unsigned int wait_for_dscp_req:1;
1666 #ifdef CONFIG_TESTING_OPTIONS
1667 	unsigned int disable_scs_support:1;
1668 	unsigned int disable_mscs_support:1;
1669 #endif /* CONFIG_TESTING_OPTIONS */
1670 #endif /* CONFIG_NO_ROBUST_AV */
1671 
1672 	bool wps_scan_done; /* Set upon receiving scan results event */
1673 	bool supp_pbc_active; /* Set for interface when PBC is triggered */
1674 	bool wps_overlap;
1675 	bool scan_in_progress_6ghz; /* Set upon a 6 GHz scan being triggered */
1676 
1677 #ifdef CONFIG_IEEE8021X_AUTH
1678 	struct auth_802_1x_data *auth_1x;
1679 #endif /* CONFIG_IEEE8021X_AUTH */
1680 
1681 #ifdef CONFIG_PASN
1682 	struct pasn_data pasn;
1683 	struct wpa_radio_work *pasn_auth_work;
1684 	unsigned int pasn_count;
1685 	struct pasn_auth *pasn_params;
1686 	bool urnm_mfpr_x20;
1687 	bool disable_urnm_mfpr;
1688 #ifdef CONFIG_P2P
1689 	struct wpa_radio_work *p2p_pasn_auth_work;
1690 #endif /* CONFIG_P2P */
1691 	struct wpa_radio_work *pr_pasn_auth_work;
1692 	struct wpa_radio_work *pr_roc_work;
1693 #endif /* CONFIG_PASN */
1694 
1695 	bool is_6ghz_enabled;
1696 	bool crossed_6ghz_dom;
1697 	bool last_scan_all_chan;
1698 	bool last_scan_non_coloc_6ghz;
1699 	bool support_6ghz;
1700 	bool allow_p2p_assisted_dfs;
1701 	char device_country[3];
1702 	bool device_country_set;
1703 	bool assisted_dfs;
1704 
1705 	bool dfs_ap_connected;
1706 	int sta_connected_freq;
1707 	enum chan_width sta_connected_chan_width;
1708 
1709 	struct wpa_signal_info last_signal_info;
1710 
1711 	struct wpa_ssid *ml_connect_probe_ssid;
1712 	struct wpa_bss *ml_connect_probe_bss;
1713 
1714 #ifdef CONFIG_OWE
1715 	/* An array of frequencies to scan for OWE transition mode BSSs when
1716 	 * owe_transition_search == 1 */
1717 	int *owe_trans_scan_freq;
1718 #endif /* CONFIG_OWE */
1719 
1720 #ifdef CONFIG_NAN_USD
1721 	struct nan_de *nan_de;
1722 	struct wpa_radio_work *nan_usd_listen_work;
1723 	struct wpa_radio_work *nan_usd_tx_work;
1724 #endif /* CONFIG_NAN_USD */
1725 
1726 	bool ssid_verified;
1727 	bool bigtk_set;
1728 	u64 first_beacon_tsf;
1729 	unsigned int beacons_checked;
1730 	unsigned int next_beacon_check;
1731 
1732 	bool scs_reconfigure;
1733 	bool ext_auth_to_same_bss; /* Whether external authentication has been
1734 				    * completed successfully with the BSS that
1735 				    * we are already associated with. */
1736 
1737 	bool nan_mgmt;
1738 	bool nan_data;
1739 
1740 #ifdef CONFIG_NAN
1741 #define MAX_NAN_RADIOS 2
1742 	struct nan_capa nan_capa;
1743 	struct nan_data *nan;
1744 	struct nan_cluster_config nan_cluster_config;
1745 	u8 schedule_sequence_id;
1746 	struct nan_schedule_config nan_sched[MAX_NAN_RADIOS];
1747 	u16 nan_supported_csids;
1748 	struct nan_schedule_update {
1749 		struct nan_schedule_config sched;
1750 		u8 map_id;
1751 	} nan_sched_update;
1752 	struct wpabuf *nan_ulw_attr;
1753 	struct wpa_freq_range_list nan_disallowed_freqs;
1754 	u16 nan_max_bw;
1755 	struct nan_channels nan_override_potential_avail;
1756 	unsigned int nan_ndi_ndp_refcount; /* Active NDP count on this NDI */
1757 	struct nan_gtk ndi_gtk;
1758 #ifdef CONFIG_TESTING_OPTIONS
1759 	bool nan_force_conditional_sched;
1760 #endif /* CONFIG_TESTING_OPTIONS */
1761 #endif /* CONFIG_NAN */
1762 #ifdef CONFIG_ENC_ASSOC
1763 	bool assoc_resp_encrypted; /* Whether (Re)Association Response frame
1764 				    * is encrypted. */
1765 #endif /* CONFIG_ENC_ASSOC */
1766 #ifdef CONFIG_PMKSA_PRIVACY
1767 	u8 pmkid_snonce[NONCE_LEN];
1768 	bool pmkid_snonce_set;
1769 	u8 pmkid_anonce[NONCE_LEN];
1770 	bool pmkid_anonce_set;
1771 #endif /* CONFIG_PMKSA_PRIVACY */
1772 	u8 pd_addr[ETH_ALEN];
1773 
1774 	/**
1775 	 * pr_responder_mode - Waiting for PASN M1 as responder
1776 	 *
1777 	 * Set when ROC has been started on this interface to listen for an
1778 	 * incoming PASN Auth1 frame. Cleared once the dedicated PR interface
1779 	 * is created on M1 reception.
1780 	 */
1781 	bool pr_responder_mode;
1782 
1783 	/**
1784 	 * pr_responder_src_addr - Source MAC address used for responder ROC
1785 	 *
1786 	 * Stored when responder mode is activated so that the dedicated PR
1787 	 * interface can be created with the same address when M1 arrives.
1788 	 */
1789 	u8 pr_responder_src_addr[ETH_ALEN];
1790 };
1791 
1792 
1793 /* wpa_supplicant.c */
1794 void wpa_supplicant_apply_ht_overrides(
1795 	struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
1796 	struct wpa_driver_associate_params *params);
1797 void wpa_supplicant_apply_vht_overrides(
1798 	struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
1799 	struct wpa_driver_associate_params *params);
1800 void wpa_supplicant_apply_he_overrides(
1801 	struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
1802 	struct wpa_driver_associate_params *params);
1803 void wpa_supplicant_apply_eht_overrides(
1804 	struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
1805 	struct wpa_driver_associate_params *params);
1806 
1807 int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
1808 int wpa_supplicant_set_wpa_none_key(struct wpa_supplicant *wpa_s,
1809 				    struct wpa_ssid *ssid);
1810 
1811 int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
1812 
1813 const char * wpa_supplicant_state_txt(enum wpa_states state);
1814 int wpa_supplicant_update_mac_addr(struct wpa_supplicant *wpa_s);
1815 int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
1816 int wpa_supplicant_update_bridge_ifname(struct wpa_supplicant *wpa_s,
1817 					const char *bridge_ifname);
1818 void wpas_set_mgmt_group_cipher(struct wpa_supplicant *wpa_s,
1819 				struct wpa_ssid *ssid, struct wpa_ie_data *ie);
1820 int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
1821 			      struct wpa_bss *bss, struct wpa_ssid *ssid,
1822 			      u8 *wpa_ie, size_t *wpa_ie_len,
1823 			      bool skip_default_rsne);
1824 int wpas_restore_permanent_mac_addr(struct wpa_supplicant *wpa_s);
1825 void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
1826 			      struct wpa_bss *bss,
1827 			      struct wpa_ssid *ssid);
1828 void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
1829 				       struct wpa_ssid *ssid);
1830 void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
1831 void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
1832 void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
1833 				     int sec, int usec);
1834 void wpas_auth_timeout_restart(struct wpa_supplicant *wpa_s, int sec_diff);
1835 void wpa_supplicant_reinit_autoscan(struct wpa_supplicant *wpa_s);
1836 void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
1837 			      enum wpa_states state);
1838 struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
1839 const char * wpa_supplicant_get_eap_mode(struct wpa_supplicant *wpa_s);
1840 void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
1841 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
1842 				   u16 reason_code);
1843 void wpa_supplicant_reconnect(struct wpa_supplicant *wpa_s);
1844 
1845 struct wpa_ssid * wpa_supplicant_add_network(struct wpa_supplicant *wpa_s);
1846 int wpa_supplicant_remove_network(struct wpa_supplicant *wpa_s, int id);
1847 int wpa_supplicant_remove_all_networks(struct wpa_supplicant *wpa_s);
1848 void wpa_supplicant_enable_network(struct wpa_supplicant *wpa_s,
1849 				   struct wpa_ssid *ssid);
1850 void wpa_supplicant_disable_network(struct wpa_supplicant *wpa_s,
1851 				    struct wpa_ssid *ssid);
1852 void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
1853 				   struct wpa_ssid *ssid);
1854 int wpas_remove_cred(struct wpa_supplicant *wpa_s, struct wpa_cred *cred);
1855 int wpas_remove_all_creds(struct wpa_supplicant *wpa_s);
1856 int wpas_set_pkcs11_engine_and_module_path(struct wpa_supplicant *wpa_s,
1857 					   const char *pkcs11_engine_path,
1858 					   const char *pkcs11_module_path);
1859 int wpa_supplicant_set_ap_scan(struct wpa_supplicant *wpa_s,
1860 			       int ap_scan);
1861 int wpa_supplicant_set_bss_expiration_age(struct wpa_supplicant *wpa_s,
1862 					  unsigned int expire_age);
1863 int wpa_supplicant_set_bss_expiration_count(struct wpa_supplicant *wpa_s,
1864 					    unsigned int expire_count);
1865 int wpa_supplicant_set_scan_interval(struct wpa_supplicant *wpa_s,
1866 				     int scan_interval);
1867 int wpa_supplicant_set_debug_params(struct wpa_global *global,
1868 				    int debug_level, int debug_timestamp,
1869 				    int debug_show_keys);
1870 void free_hw_features(struct wpa_supplicant *wpa_s);
1871 
1872 void wpa_show_license(void);
1873 
1874 struct wpa_interface * wpa_supplicant_match_iface(struct wpa_global *global,
1875 						  const char *ifname);
1876 struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
1877 						 struct wpa_interface *iface,
1878 						 struct wpa_supplicant *parent);
1879 int wpa_supplicant_remove_iface(struct wpa_global *global,
1880 				struct wpa_supplicant *wpa_s,
1881 				int terminate);
1882 struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
1883 						 const char *ifname);
1884 struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
1885 int wpa_supplicant_run(struct wpa_global *global);
1886 void wpa_supplicant_deinit(struct wpa_global *global);
1887 int wpa_supplicant_parse_config(const char *fname);
1888 
1889 int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
1890 			      struct wpa_ssid *ssid);
1891 void wpa_supplicant_terminate_proc(struct wpa_global *global);
1892 void wpa_supplicant_rx_eapol(void *ctx, const u8 *own_addr,
1893 			     const u8 *buf, size_t len,
1894 			     enum frame_encryption encrypted);
1895 void wpa_supplicant_update_config(struct wpa_supplicant *wpa_s);
1896 void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s);
1897 void wpas_connection_failed(struct wpa_supplicant *wpa_s, const u8 *bssid,
1898 			    const u8 **link_bssids);
1899 void fils_connection_failure(struct wpa_supplicant *wpa_s);
1900 void fils_pmksa_cache_flush(struct wpa_supplicant *wpa_s);
1901 int wpas_driver_bss_selection(struct wpa_supplicant *wpa_s);
1902 bool wpas_rsn_overriding(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
1903 int wpas_is_p2p_prioritized(struct wpa_supplicant *wpa_s);
1904 void wpas_auth_failed(struct wpa_supplicant *wpa_s, const char *reason,
1905 		      const u8 *bssid);
1906 void wpas_clear_temp_disabled(struct wpa_supplicant *wpa_s,
1907 			      struct wpa_ssid *ssid, int clear_failures);
1908 int disallowed_bssid(struct wpa_supplicant *wpa_s, const u8 *bssid);
1909 int disallowed_ssid(struct wpa_supplicant *wpa_s, const u8 *ssid,
1910 		    size_t ssid_len);
1911 void wpas_request_connection(struct wpa_supplicant *wpa_s);
1912 void wpas_request_disconnection(struct wpa_supplicant *wpa_s);
1913 int wpas_build_ext_capab(struct wpa_supplicant *wpa_s, u8 *buf, size_t buflen,
1914 			 struct wpa_bss *bss);
1915 int wpas_populate_wfa_capa(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
1916 			   u8 *wpa_ie, size_t wpa_ie_len,
1917 			   size_t max_wpa_ie_len);
1918 int wpas_update_random_addr(struct wpa_supplicant *wpa_s,
1919 			    enum wpas_mac_addr_style style,
1920 			    struct wpa_ssid *ssid);
1921 int wpas_update_random_addr_disassoc(struct wpa_supplicant *wpa_s);
1922 
1923 int wpas_get_op_chan_phy(int freq, const u8 *ies, size_t ies_len,
1924 			 u8 *op_class, u8 *chan, u8 *phy_type);
1925 
1926 int wpas_twt_send_setup(struct wpa_supplicant *wpa_s, u8 dtok, int exponent,
1927 			int mantissa, u8 min_twt, int setup_cmd, u64 twt,
1928 			bool requestor, bool trigger, bool implicit,
1929 			bool flow_type, u8 flow_id, bool protection,
1930 			u8 twt_channel, u8 control);
1931 int wpas_twt_send_teardown(struct wpa_supplicant *wpa_s, u8 flags);
1932 
1933 void wpas_rrm_reset(struct wpa_supplicant *wpa_s);
1934 void wpas_rrm_process_neighbor_rep(struct wpa_supplicant *wpa_s,
1935 				   const u8 *da, const u8 *sa,
1936 				   const u8 *report, size_t report_len);
1937 int wpas_rrm_send_neighbor_rep_request(struct wpa_supplicant *wpa_s,
1938 				       const struct wpa_ssid_value *ssid,
1939 				       int lci, int civic,
1940 				       void (*cb)(void *ctx,
1941 						  struct wpabuf *neighbor_rep),
1942 				       void *cb_ctx);
1943 void wpas_rrm_handle_radio_measurement_request(struct wpa_supplicant *wpa_s,
1944 					       const u8 *src, const u8 *dst,
1945 					       const u8 *frame, size_t len);
1946 void wpas_rrm_handle_link_measurement_request(struct wpa_supplicant *wpa_s,
1947 					      const u8 *src,
1948 					      const u8 *frame, size_t len,
1949 					      int rssi);
1950 void wpas_rrm_refuse_request(struct wpa_supplicant *wpa_s);
1951 int wpas_beacon_rep_scan_process(struct wpa_supplicant *wpa_s,
1952 				 struct wpa_scan_results *scan_res,
1953 				 struct scan_info *info);
1954 void wpas_clear_beacon_rep_data(struct wpa_supplicant *wpa_s);
1955 void wpas_flush_fils_hlp_req(struct wpa_supplicant *wpa_s);
1956 void wpas_clear_disabled_interface(void *eloop_ctx, void *timeout_ctx);
1957 void wpa_supplicant_reset_bgscan(struct wpa_supplicant *wpa_s);
1958 
1959 
1960 /* MBO functions */
1961 int wpas_mbo_ie(struct wpa_supplicant *wpa_s, u8 *buf, size_t len,
1962 		int add_oce_capa);
1963 const u8 * mbo_attr_from_mbo_ie(const u8 *mbo_ie, enum mbo_attr_id attr);
1964 const u8 * wpas_mbo_check_assoc_disallow(struct wpa_bss *bss);
1965 void wpas_mbo_check_pmf(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
1966 			struct wpa_ssid *ssid);
1967 const u8 * mbo_get_attr_from_ies(const u8 *ies, size_t ies_len,
1968 				 enum mbo_attr_id attr);
1969 int wpas_mbo_update_non_pref_chan(struct wpa_supplicant *wpa_s,
1970 				  const char *non_pref_chan);
1971 void wpas_mbo_scan_ie(struct wpa_supplicant *wpa_s, struct wpabuf *ie);
1972 void wpas_mbo_ie_trans_req(struct wpa_supplicant *wpa_s, const u8 *ie,
1973 			   size_t len);
1974 size_t wpas_mbo_ie_bss_trans_reject(struct wpa_supplicant *wpa_s, u8 *pos,
1975 				    size_t len,
1976 				    enum mbo_transition_reject_reason reason);
1977 void wpas_mbo_update_cell_capa(struct wpa_supplicant *wpa_s, u8 mbo_cell_capa);
1978 struct wpabuf * mbo_build_anqp_buf(struct wpa_supplicant *wpa_s,
1979 				   struct wpa_bss *bss, u32 mbo_subtypes);
1980 void mbo_parse_rx_anqp_resp(struct wpa_supplicant *wpa_s,
1981 			    struct wpa_bss *bss, const u8 *sa,
1982 			    const u8 *data, size_t slen);
1983 void wpas_update_mbo_connect_params(struct wpa_supplicant *wpa_s);
1984 
1985 /* op_classes.c */
1986 enum chan_allowed {
1987 	NOT_ALLOWED, NO_IR, RADAR, ALLOWED
1988 };
1989 
1990 enum chan_allowed verify_channel(struct hostapd_hw_modes *mode, u8 op_class,
1991 				 u8 channel, u8 bw);
1992 size_t wpas_supp_op_class_ie(struct wpa_supplicant *wpa_s,
1993 			     struct wpa_ssid *ssid,
1994 			     struct wpa_bss *bss, u8 *pos, size_t len);
1995 int * wpas_supp_op_classes(struct wpa_supplicant *wpa_s);
1996 
1997 int wpas_enable_mac_addr_randomization(struct wpa_supplicant *wpa_s,
1998 				       unsigned int type, const u8 *addr,
1999 				       const u8 *mask);
2000 int wpas_disable_mac_addr_randomization(struct wpa_supplicant *wpa_s,
2001 					unsigned int type);
2002 
2003 /**
2004  * wpa_supplicant_ctrl_iface_ctrl_rsp_handle - Handle a control response
2005  * @wpa_s: Pointer to wpa_supplicant data
2006  * @ssid: Pointer to the network block the reply is for
2007  * @field: field the response is a reply for
2008  * @value: value (ie, password, etc) for @field
2009  * Returns: 0 on success, non-zero on error
2010  *
2011  * Helper function to handle replies to control interface requests.
2012  */
2013 int wpa_supplicant_ctrl_iface_ctrl_rsp_handle(struct wpa_supplicant *wpa_s,
2014 					      struct wpa_ssid *ssid,
2015 					      const char *field,
2016 					      const char *value);
2017 
2018 void ibss_mesh_setup_freq(struct wpa_supplicant *wpa_s,
2019 			  const struct wpa_ssid *ssid,
2020 			  struct hostapd_freq_params *freq);
2021 
2022 /* events.c */
2023 void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
2024 int wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
2025 			   struct wpa_bss *selected,
2026 			   struct wpa_ssid *ssid);
2027 void wpa_supplicant_stop_countermeasures(void *eloop_ctx, void *sock_ctx);
2028 void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx, void *sock_ctx);
2029 void wnm_bss_keep_alive_deinit(struct wpa_supplicant *wpa_s);
2030 int wpa_supplicant_fast_associate(struct wpa_supplicant *wpa_s);
2031 int wpa_wps_supplicant_fast_associate(struct wpa_supplicant *wpa_s);
2032 struct wpa_bss * wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
2033 					     struct wpa_ssid **selected_ssid,
2034 					     bool clear_ignorelist);
2035 int wpas_temp_disabled(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
2036 void wpa_supplicant_update_channel_list(struct wpa_supplicant *wpa_s,
2037 					struct channel_list_changed *info);
2038 int wpa_supplicant_need_to_roam_within_ess(struct wpa_supplicant *wpa_s,
2039 					   struct wpa_bss *current_bss,
2040 					   struct wpa_bss *selected,
2041 					   bool poll_current);
2042 void wpas_reset_mlo_info(struct wpa_supplicant *wpa_s);
2043 
2044 /* eap_register.c */
2045 int eap_register_methods(void);
2046 
2047 /**
2048  * Utility method to tell if a given network is for persistent group storage
2049  * @ssid: Network object
2050  * Returns: 1 if network is a persistent group, 0 otherwise
2051  */
network_is_persistent_group(struct wpa_ssid * ssid)2052 static inline int network_is_persistent_group(struct wpa_ssid *ssid)
2053 {
2054 	return ssid->disabled == 2 && ssid->p2p_persistent_group;
2055 }
2056 
2057 
wpas_mode_to_ieee80211_mode(enum wpas_mode mode)2058 static inline int wpas_mode_to_ieee80211_mode(enum wpas_mode mode)
2059 {
2060 	switch (mode) {
2061 	default:
2062 	case WPAS_MODE_INFRA:
2063 		return IEEE80211_MODE_INFRA;
2064 	case WPAS_MODE_IBSS:
2065 		return IEEE80211_MODE_IBSS;
2066 	case WPAS_MODE_AP:
2067 	case WPAS_MODE_P2P_GO:
2068 	case WPAS_MODE_P2P_GROUP_FORMATION:
2069 		return IEEE80211_MODE_AP;
2070 	case WPAS_MODE_MESH:
2071 		return IEEE80211_MODE_MESH;
2072 	}
2073 }
2074 
2075 
2076 int wpas_network_disabled(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
2077 int wpas_get_ssid_pmf(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
2078 enum sae_pwe wpas_get_ssid_sae_pwe(struct wpa_supplicant *wpa_s,
2079 				   struct wpa_ssid *ssid);
2080 int pmf_in_use(struct wpa_supplicant *wpa_s, const u8 *addr);
2081 void wpa_s_setup_sae_pt(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
2082 			bool force);
2083 void wpa_s_clear_sae_rejected(struct wpa_supplicant *wpa_s);
2084 
2085 bool wpas_is_sae_avoided(struct wpa_supplicant *wpa_s,
2086 			struct wpa_ssid *ssid,
2087 			const struct wpa_ie_data *ie);
2088 
2089 int wpas_init_ext_pw(struct wpa_supplicant *wpa_s);
2090 
2091 void dump_freq_data(struct wpa_supplicant *wpa_s, const char *title,
2092 		    struct wpa_used_freq_data *freqs_data,
2093 		    unsigned int len);
2094 
2095 int get_shared_radio_freqs_data(struct wpa_supplicant *wpa_s,
2096 				struct wpa_used_freq_data *freqs_data,
2097 				unsigned int len, bool exclude_current);
2098 int get_shared_radio_freqs(struct wpa_supplicant *wpa_s,
2099 			   int *freq_array, unsigned int len,
2100 			   bool exclude_current);
2101 int disabled_freq(struct wpa_supplicant *wpa_s, int freq);
2102 
2103 void wpas_network_reenabled(void *eloop_ctx, void *timeout_ctx);
2104 
2105 void wpas_vendor_elem_update(struct wpa_supplicant *wpa_s);
2106 struct wpa_supplicant * wpas_vendor_elem(struct wpa_supplicant *wpa_s,
2107 					 enum wpa_vendor_elem_frame frame);
2108 int wpas_vendor_elem_remove(struct wpa_supplicant *wpa_s, int frame,
2109 			    const u8 *elem, size_t len);
2110 
2111 #ifdef CONFIG_FST
2112 
2113 struct fst_wpa_obj;
2114 
2115 void fst_wpa_supplicant_fill_iface_obj(struct wpa_supplicant *wpa_s,
2116 				       struct fst_wpa_obj *iface_obj);
2117 
2118 #endif /* CONFIG_FST */
2119 
2120 int wpas_sched_scan_plans_set(struct wpa_supplicant *wpa_s, const char *cmd);
2121 
2122 struct hostapd_hw_modes * get_mode(struct hostapd_hw_modes *modes,
2123 				   u16 num_modes, enum hostapd_hw_mode mode,
2124 				   bool is_6ghz);
2125 struct hostapd_hw_modes * get_mode_with_freq(struct hostapd_hw_modes *modes,
2126 					     u16 num_modes, int freq);
2127 
2128 void wpa_bss_tmp_disallow(struct wpa_supplicant *wpa_s, const u8 *bssid,
2129 			  unsigned int sec, int rssi_threshold);
2130 int wpa_is_bss_tmp_disallowed(struct wpa_supplicant *wpa_s,
2131 			      struct wpa_bss *bss);
2132 void free_bss_tmp_disallowed(struct wpa_supplicant *wpa_s);
2133 
2134 struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
2135 				     int i, struct wpa_bss *bss,
2136 				     struct wpa_ssid *group,
2137 				     int only_first_ssid, int debug_print,
2138 				     bool link);
2139 
2140 struct wpa_bss * wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s,
2141 					   struct wpa_ssid *group,
2142 					   struct wpa_ssid **selected_ssid,
2143 					   int only_first_ssid);
2144 
2145 int wpas_ctrl_iface_get_pref_freq_list_override(struct wpa_supplicant *wpa_s,
2146 						enum wpa_driver_if_type if_type,
2147 						unsigned int *num,
2148 						struct weighted_pcl *freq_list);
2149 
2150 int wpa_is_fils_supported(struct wpa_supplicant *wpa_s);
2151 int wpa_is_fils_sk_pfs_supported(struct wpa_supplicant *wpa_s);
2152 
2153 void wpas_clear_driver_signal_override(struct wpa_supplicant *wpa_s);
2154 
2155 int wpas_send_mscs_req(struct wpa_supplicant *wpa_s);
2156 void wpas_populate_mscs_descriptor_ie(struct robust_av_data *robust_av,
2157 				      struct wpabuf *buf);
2158 void wpas_handle_robust_av_recv_action(struct wpa_supplicant *wpa_s,
2159 				       const u8 *dst, const u8 *src,
2160 				       const u8 *buf, size_t len);
2161 void wpas_handle_assoc_resp_mscs(struct wpa_supplicant *wpa_s, const u8 *bssid,
2162 				 const u8 *ies, size_t ies_len);
2163 int wpas_send_scs_req(struct wpa_supplicant *wpa_s);
2164 int wpas_scs_reconfigure(struct wpa_supplicant *wpa_s);
2165 void free_up_tclas_elem(struct scs_desc_elem *elem);
2166 void free_up_scs_desc(struct scs_robust_av_data *data);
2167 void wpas_handle_robust_av_scs_recv_action(struct wpa_supplicant *wpa_s,
2168 					   const u8 *dst, const u8 *src,
2169 					   const u8 *buf, size_t len);
2170 void wpas_scs_deinit(struct wpa_supplicant *wpa_s);
2171 void wpas_handle_qos_mgmt_recv_action(struct wpa_supplicant *wpa_s,
2172 				      const u8 *dst, const u8 *src,
2173 				      const u8 *buf, size_t len);
2174 void wpas_dscp_deinit(struct wpa_supplicant *wpa_s);
2175 int wpas_send_dscp_response(struct wpa_supplicant *wpa_s,
2176 			    struct dscp_resp_data *resp_data);
2177 void wpas_handle_assoc_resp_qos_mgmt(struct wpa_supplicant *wpa_s,
2178 				     const u8 *ies, size_t ies_len);
2179 int wpas_send_dscp_query(struct wpa_supplicant *wpa_s, const char *domain_name,
2180 			 size_t domain_name_length);
2181 
2182 int wpas_pasn_auth_start(struct wpa_supplicant *wpa_s, const u8 *own_addr,
2183 			 const u8 *bssid, int akmp, int cipher,
2184 			 u16 group, int network_id,
2185 			 const u8 *comeback, size_t comeback_len,
2186 			 unsigned int auth_alg, int group_cipher,
2187 			 int group_mgmt_cipher, u16 rsn_capab,
2188 			 const u8 *rsnxe_data, bool is_ml_peer);
2189 void wpas_pasn_auth_stop(struct wpa_supplicant *wpa_s);
2190 void wpas_pasn_free_params(struct wpa_supplicant *wpa_s);
2191 int wpas_pasn_auth_tx_status(struct wpa_supplicant *wpa_s,
2192 			     const u8 *data, size_t data_len, u8 acked);
2193 int wpas_pasn_auth_rx(struct wpa_supplicant *wpa_s,
2194 		      const struct ieee80211_mgmt *mgmt, size_t len);
2195 int wpas_pasn_get_group(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
2196 			struct pasn_data *pasn);
2197 
2198 int wpas_pasn_deauthenticate(struct wpa_supplicant *wpa_s, const u8 *own_addr,
2199 			     const u8 *bssid);
2200 void wpas_pasn_auth_trigger(struct wpa_supplicant *wpa_s,
2201 			    struct pasn_auth *pasn_auth);
2202 void wpas_pasn_auth_work_done(struct wpa_supplicant *wpa_s, int status);
2203 struct sae_pt * wpas_pasn_sae_derive_pt_for_eppke(struct wpa_ssid *ssid,
2204 						  int group);
2205 bool wpas_is_6ghz_supported(struct wpa_supplicant *wpa_s, bool only_enabled);
2206 
2207 bool wpa_is_non_eht_scs_traffic_desc_supported(struct wpa_bss *bss);
2208 bool wpas_ap_link_address(struct wpa_supplicant *wpa_s, const u8 *addr);
2209 bool wpas_ap_supports_rsn_overriding(struct wpa_supplicant *wpa_s,
2210 				     struct wpa_bss *bss);
2211 bool wpas_ap_supports_rsn_overriding_2(struct wpa_supplicant *wpa_s,
2212 				       struct wpa_bss *bss);
2213 int wpas_get_owe_trans_network(const u8 *owe_ie, const u8 **bssid,
2214 			       const u8 **ssid, size_t *ssid_len);
2215 void wpas_update_dfs_ap_info(struct wpa_supplicant *wpa_s, int freq,
2216 			     enum chan_width ap_ch_width,
2217 			     bool disconnect_evt);
2218 void wpas_configure_frame_filters(struct wpa_supplicant *wpa_s);
2219 
wpas_is_nan_iface(struct wpa_supplicant * wpa_s)2220 static inline bool wpas_is_nan_iface(struct wpa_supplicant *wpa_s)
2221 {
2222 #ifdef CONFIG_NAN
2223 	return wpa_s->nan_mgmt || wpa_s->nan_data;
2224 #else /* CONFIG_NAN */
2225 	return false;
2226 #endif /* CONFIG_NAN */
2227 }
2228 
2229 bool wpas_eppke_ap_capable(struct wpa_supplicant *wpa_s,
2230 			   struct wpa_bss *bss, bool unauth_eppke);
2231 
2232 #endif /* WPA_SUPPLICANT_I_H */
2233