xref: /dflybsd-src/contrib/wpa_supplicant/src/rsn_supp/wpa_i.h (revision 3a84a4273475ed07d0ab1c2dfeffdfedef35d9cd)
16d49e1aeSJan Lentfer /*
23ff40c12SJohn Marino  * Internal WPA/RSN supplicant state machine definitions
3*a1157835SDaniel Fojt  * Copyright (c) 2004-2018, Jouni Malinen <j@w1.fi>
46d49e1aeSJan Lentfer  *
53ff40c12SJohn Marino  * This software may be distributed under the terms of the BSD license.
63ff40c12SJohn Marino  * See README for more details.
76d49e1aeSJan Lentfer  */
86d49e1aeSJan Lentfer 
96d49e1aeSJan Lentfer #ifndef WPA_I_H
106d49e1aeSJan Lentfer #define WPA_I_H
116d49e1aeSJan Lentfer 
123ff40c12SJohn Marino #include "utils/list.h"
133ff40c12SJohn Marino 
143ff40c12SJohn Marino struct wpa_tdls_peer;
156d49e1aeSJan Lentfer struct wpa_eapol_key;
166d49e1aeSJan Lentfer 
176d49e1aeSJan Lentfer /**
186d49e1aeSJan Lentfer  * struct wpa_sm - Internal WPA state machine data
196d49e1aeSJan Lentfer  */
206d49e1aeSJan Lentfer struct wpa_sm {
21*a1157835SDaniel Fojt 	u8 pmk[PMK_LEN_MAX];
226d49e1aeSJan Lentfer 	size_t pmk_len;
236d49e1aeSJan Lentfer 	struct wpa_ptk ptk, tptk;
246d49e1aeSJan Lentfer 	int ptk_set, tptk_set;
25*a1157835SDaniel Fojt 	unsigned int msg_3_of_4_ok:1;
266d49e1aeSJan Lentfer 	u8 snonce[WPA_NONCE_LEN];
276d49e1aeSJan Lentfer 	u8 anonce[WPA_NONCE_LEN]; /* ANonce from the last 1/4 msg */
286d49e1aeSJan Lentfer 	int renew_snonce;
296d49e1aeSJan Lentfer 	u8 rx_replay_counter[WPA_REPLAY_COUNTER_LEN];
306d49e1aeSJan Lentfer 	int rx_replay_counter_set;
316d49e1aeSJan Lentfer 	u8 request_counter[WPA_REPLAY_COUNTER_LEN];
32*a1157835SDaniel Fojt 	struct wpa_gtk gtk;
33*a1157835SDaniel Fojt 	struct wpa_gtk gtk_wnm_sleep;
34*a1157835SDaniel Fojt #ifdef CONFIG_IEEE80211W
35*a1157835SDaniel Fojt 	struct wpa_igtk igtk;
36*a1157835SDaniel Fojt 	struct wpa_igtk igtk_wnm_sleep;
37*a1157835SDaniel Fojt #endif /* CONFIG_IEEE80211W */
386d49e1aeSJan Lentfer 
396d49e1aeSJan Lentfer 	struct eapol_sm *eapol; /* EAPOL state machine from upper level code */
406d49e1aeSJan Lentfer 
416d49e1aeSJan Lentfer 	struct rsn_pmksa_cache *pmksa; /* PMKSA cache */
426d49e1aeSJan Lentfer 	struct rsn_pmksa_cache_entry *cur_pmksa; /* current PMKSA entry */
433ff40c12SJohn Marino 	struct dl_list pmksa_candidates;
446d49e1aeSJan Lentfer 
456d49e1aeSJan Lentfer 	struct l2_packet_data *l2_preauth;
466d49e1aeSJan Lentfer 	struct l2_packet_data *l2_preauth_br;
473ff40c12SJohn Marino 	struct l2_packet_data *l2_tdls;
486d49e1aeSJan Lentfer 	u8 preauth_bssid[ETH_ALEN]; /* current RSN pre-auth peer or
496d49e1aeSJan Lentfer 				     * 00:00:00:00:00:00 if no pre-auth is
506d49e1aeSJan Lentfer 				     * in progress */
516d49e1aeSJan Lentfer 	struct eapol_sm *preauth_eapol;
526d49e1aeSJan Lentfer 
536d49e1aeSJan Lentfer 	struct wpa_sm_ctx *ctx;
546d49e1aeSJan Lentfer 
556d49e1aeSJan Lentfer 	void *scard_ctx; /* context for smartcard callbacks */
566d49e1aeSJan Lentfer 	int fast_reauth; /* whether EAP fast re-authentication is enabled */
576d49e1aeSJan Lentfer 
586d49e1aeSJan Lentfer 	void *network_ctx;
596d49e1aeSJan Lentfer 	int allowed_pairwise_cipher; /* bitfield of WPA_CIPHER_* */
606d49e1aeSJan Lentfer 	int proactive_key_caching;
616d49e1aeSJan Lentfer 	int eap_workaround;
626d49e1aeSJan Lentfer 	void *eap_conf_ctx;
636d49e1aeSJan Lentfer 	u8 ssid[32];
646d49e1aeSJan Lentfer 	size_t ssid_len;
656d49e1aeSJan Lentfer 	int wpa_ptk_rekey;
663ff40c12SJohn Marino 	int p2p;
67*a1157835SDaniel Fojt 	int wpa_rsc_relaxation;
686d49e1aeSJan Lentfer 
696d49e1aeSJan Lentfer 	u8 own_addr[ETH_ALEN];
706d49e1aeSJan Lentfer 	const char *ifname;
716d49e1aeSJan Lentfer 	const char *bridge_ifname;
726d49e1aeSJan Lentfer 	u8 bssid[ETH_ALEN];
736d49e1aeSJan Lentfer 
746d49e1aeSJan Lentfer 	unsigned int dot11RSNAConfigPMKLifetime;
756d49e1aeSJan Lentfer 	unsigned int dot11RSNAConfigPMKReauthThreshold;
766d49e1aeSJan Lentfer 	unsigned int dot11RSNAConfigSATimeout;
776d49e1aeSJan Lentfer 
786d49e1aeSJan Lentfer 	unsigned int dot11RSNA4WayHandshakeFailures;
796d49e1aeSJan Lentfer 
806d49e1aeSJan Lentfer 	/* Selected configuration (based on Beacon/ProbeResp WPA IE) */
816d49e1aeSJan Lentfer 	unsigned int proto;
826d49e1aeSJan Lentfer 	unsigned int pairwise_cipher;
836d49e1aeSJan Lentfer 	unsigned int group_cipher;
846d49e1aeSJan Lentfer 	unsigned int key_mgmt;
856d49e1aeSJan Lentfer 	unsigned int mgmt_group_cipher;
866d49e1aeSJan Lentfer 
876d49e1aeSJan Lentfer 	int rsn_enabled; /* Whether RSN is enabled in configuration */
883ff40c12SJohn Marino 	int mfp; /* 0 = disabled, 1 = optional, 2 = mandatory */
89*a1157835SDaniel Fojt 	int ocv; /* Operating Channel Validation */
906d49e1aeSJan Lentfer 
916d49e1aeSJan Lentfer 	u8 *assoc_wpa_ie; /* Own WPA/RSN IE from (Re)AssocReq */
926d49e1aeSJan Lentfer 	size_t assoc_wpa_ie_len;
936d49e1aeSJan Lentfer 	u8 *ap_wpa_ie, *ap_rsn_ie;
946d49e1aeSJan Lentfer 	size_t ap_wpa_ie_len, ap_rsn_ie_len;
956d49e1aeSJan Lentfer 
963ff40c12SJohn Marino #ifdef CONFIG_TDLS
973ff40c12SJohn Marino 	struct wpa_tdls_peer *tdls;
983ff40c12SJohn Marino 	int tdls_prohibited;
99*a1157835SDaniel Fojt 	int tdls_chan_switch_prohibited;
1003ff40c12SJohn Marino 	int tdls_disabled;
1013ff40c12SJohn Marino 
1023ff40c12SJohn Marino 	/* The driver supports TDLS */
1033ff40c12SJohn Marino 	int tdls_supported;
1043ff40c12SJohn Marino 
1053ff40c12SJohn Marino 	/*
1063ff40c12SJohn Marino 	 * The driver requires explicit discovery/setup/teardown frames sent
1073ff40c12SJohn Marino 	 * to it via tdls_mgmt.
1083ff40c12SJohn Marino 	 */
1093ff40c12SJohn Marino 	int tdls_external_setup;
110*a1157835SDaniel Fojt 
111*a1157835SDaniel Fojt 	/* The driver supports TDLS channel switching */
112*a1157835SDaniel Fojt 	int tdls_chan_switch;
1133ff40c12SJohn Marino #endif /* CONFIG_TDLS */
1146d49e1aeSJan Lentfer 
1156d49e1aeSJan Lentfer #ifdef CONFIG_IEEE80211R
116*a1157835SDaniel Fojt 	u8 xxkey[PMK_LEN_MAX]; /* PSK or the second 256 bits of MSK, or the
117*a1157835SDaniel Fojt 				* first 384 bits of MSK */
1186d49e1aeSJan Lentfer 	size_t xxkey_len;
119*a1157835SDaniel Fojt 	u8 pmk_r0[PMK_LEN_MAX];
120*a1157835SDaniel Fojt 	size_t pmk_r0_len;
1216d49e1aeSJan Lentfer 	u8 pmk_r0_name[WPA_PMK_NAME_LEN];
122*a1157835SDaniel Fojt 	u8 pmk_r1[PMK_LEN_MAX];
123*a1157835SDaniel Fojt 	size_t pmk_r1_len;
1246d49e1aeSJan Lentfer 	u8 pmk_r1_name[WPA_PMK_NAME_LEN];
1256d49e1aeSJan Lentfer 	u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
1266d49e1aeSJan Lentfer 	u8 r0kh_id[FT_R0KH_ID_MAX_LEN];
1276d49e1aeSJan Lentfer 	size_t r0kh_id_len;
1286d49e1aeSJan Lentfer 	u8 r1kh_id[FT_R1KH_ID_LEN];
129*a1157835SDaniel Fojt 	unsigned int ft_completed:1;
130*a1157835SDaniel Fojt 	unsigned int ft_reassoc_completed:1;
131*a1157835SDaniel Fojt 	unsigned int ft_protocol:1;
1326d49e1aeSJan Lentfer 	int over_the_ds_in_progress;
1336d49e1aeSJan Lentfer 	u8 target_ap[ETH_ALEN]; /* over-the-DS target AP */
1343ff40c12SJohn Marino 	int set_ptk_after_assoc;
1353ff40c12SJohn Marino 	u8 mdie_ft_capab; /* FT Capability and Policy from target AP MDIE */
1363ff40c12SJohn Marino 	u8 *assoc_resp_ies; /* MDIE and FTIE from (Re)Association Response */
1373ff40c12SJohn Marino 	size_t assoc_resp_ies_len;
1386d49e1aeSJan Lentfer #endif /* CONFIG_IEEE80211R */
1393ff40c12SJohn Marino 
1403ff40c12SJohn Marino #ifdef CONFIG_P2P
1413ff40c12SJohn Marino 	u8 p2p_ip_addr[3 * 4];
1423ff40c12SJohn Marino #endif /* CONFIG_P2P */
143*a1157835SDaniel Fojt 
144*a1157835SDaniel Fojt #ifdef CONFIG_TESTING_OPTIONS
145*a1157835SDaniel Fojt 	struct wpabuf *test_assoc_ie;
146*a1157835SDaniel Fojt #endif /* CONFIG_TESTING_OPTIONS */
147*a1157835SDaniel Fojt 
148*a1157835SDaniel Fojt #ifdef CONFIG_FILS
149*a1157835SDaniel Fojt 	u8 fils_nonce[FILS_NONCE_LEN];
150*a1157835SDaniel Fojt 	u8 fils_session[FILS_SESSION_LEN];
151*a1157835SDaniel Fojt 	u8 fils_anonce[FILS_NONCE_LEN];
152*a1157835SDaniel Fojt 	u8 fils_key_auth_ap[FILS_MAX_KEY_AUTH_LEN];
153*a1157835SDaniel Fojt 	u8 fils_key_auth_sta[FILS_MAX_KEY_AUTH_LEN];
154*a1157835SDaniel Fojt 	size_t fils_key_auth_len;
155*a1157835SDaniel Fojt 	unsigned int fils_completed:1;
156*a1157835SDaniel Fojt 	unsigned int fils_erp_pmkid_set:1;
157*a1157835SDaniel Fojt 	unsigned int fils_cache_id_set:1;
158*a1157835SDaniel Fojt 	u8 fils_erp_pmkid[PMKID_LEN];
159*a1157835SDaniel Fojt 	u8 fils_cache_id[FILS_CACHE_ID_LEN];
160*a1157835SDaniel Fojt 	struct crypto_ecdh *fils_ecdh;
161*a1157835SDaniel Fojt 	int fils_dh_group;
162*a1157835SDaniel Fojt 	size_t fils_dh_elem_len;
163*a1157835SDaniel Fojt 	struct wpabuf *fils_ft_ies;
164*a1157835SDaniel Fojt 	u8 fils_ft[FILS_FT_MAX_LEN];
165*a1157835SDaniel Fojt 	size_t fils_ft_len;
166*a1157835SDaniel Fojt #endif /* CONFIG_FILS */
167*a1157835SDaniel Fojt 
168*a1157835SDaniel Fojt #ifdef CONFIG_OWE
169*a1157835SDaniel Fojt 	struct crypto_ecdh *owe_ecdh;
170*a1157835SDaniel Fojt 	u16 owe_group;
171*a1157835SDaniel Fojt #endif /* CONFIG_OWE */
172*a1157835SDaniel Fojt 
173*a1157835SDaniel Fojt #ifdef CONFIG_DPP2
174*a1157835SDaniel Fojt 	struct wpabuf *dpp_z;
175*a1157835SDaniel Fojt #endif /* CONFIG_DPP2 */
1766d49e1aeSJan Lentfer };
1776d49e1aeSJan Lentfer 
1786d49e1aeSJan Lentfer 
wpa_sm_set_state(struct wpa_sm * sm,enum wpa_states state)1793ff40c12SJohn Marino static inline void wpa_sm_set_state(struct wpa_sm *sm, enum wpa_states state)
1806d49e1aeSJan Lentfer {
1816d49e1aeSJan Lentfer 	WPA_ASSERT(sm->ctx->set_state);
1826d49e1aeSJan Lentfer 	sm->ctx->set_state(sm->ctx->ctx, state);
1836d49e1aeSJan Lentfer }
1846d49e1aeSJan Lentfer 
wpa_sm_get_state(struct wpa_sm * sm)1853ff40c12SJohn Marino static inline enum wpa_states wpa_sm_get_state(struct wpa_sm *sm)
1866d49e1aeSJan Lentfer {
1876d49e1aeSJan Lentfer 	WPA_ASSERT(sm->ctx->get_state);
1886d49e1aeSJan Lentfer 	return sm->ctx->get_state(sm->ctx->ctx);
1896d49e1aeSJan Lentfer }
1906d49e1aeSJan Lentfer 
wpa_sm_deauthenticate(struct wpa_sm * sm,u16 reason_code)191*a1157835SDaniel Fojt static inline void wpa_sm_deauthenticate(struct wpa_sm *sm, u16 reason_code)
1926d49e1aeSJan Lentfer {
1936d49e1aeSJan Lentfer 	WPA_ASSERT(sm->ctx->deauthenticate);
1946d49e1aeSJan Lentfer 	sm->ctx->deauthenticate(sm->ctx->ctx, reason_code);
1956d49e1aeSJan Lentfer }
1966d49e1aeSJan Lentfer 
wpa_sm_set_key(struct wpa_sm * sm,enum wpa_alg alg,const u8 * addr,int key_idx,int set_tx,const u8 * seq,size_t seq_len,const u8 * key,size_t key_len)1973ff40c12SJohn Marino static inline int wpa_sm_set_key(struct wpa_sm *sm, enum wpa_alg alg,
1986d49e1aeSJan Lentfer 				 const u8 *addr, int key_idx, int set_tx,
1996d49e1aeSJan Lentfer 				 const u8 *seq, size_t seq_len,
2006d49e1aeSJan Lentfer 				 const u8 *key, size_t key_len)
2016d49e1aeSJan Lentfer {
2026d49e1aeSJan Lentfer 	WPA_ASSERT(sm->ctx->set_key);
2036d49e1aeSJan Lentfer 	return sm->ctx->set_key(sm->ctx->ctx, alg, addr, key_idx, set_tx,
2046d49e1aeSJan Lentfer 				seq, seq_len, key, key_len);
2056d49e1aeSJan Lentfer }
2066d49e1aeSJan Lentfer 
wpa_sm_get_network_ctx(struct wpa_sm * sm)2076d49e1aeSJan Lentfer static inline void * wpa_sm_get_network_ctx(struct wpa_sm *sm)
2086d49e1aeSJan Lentfer {
2096d49e1aeSJan Lentfer 	WPA_ASSERT(sm->ctx->get_network_ctx);
2106d49e1aeSJan Lentfer 	return sm->ctx->get_network_ctx(sm->ctx->ctx);
2116d49e1aeSJan Lentfer }
2126d49e1aeSJan Lentfer 
wpa_sm_get_bssid(struct wpa_sm * sm,u8 * bssid)2136d49e1aeSJan Lentfer static inline int wpa_sm_get_bssid(struct wpa_sm *sm, u8 *bssid)
2146d49e1aeSJan Lentfer {
2156d49e1aeSJan Lentfer 	WPA_ASSERT(sm->ctx->get_bssid);
2166d49e1aeSJan Lentfer 	return sm->ctx->get_bssid(sm->ctx->ctx, bssid);
2176d49e1aeSJan Lentfer }
2186d49e1aeSJan Lentfer 
wpa_sm_ether_send(struct wpa_sm * sm,const u8 * dest,u16 proto,const u8 * buf,size_t len)2196d49e1aeSJan Lentfer static inline int wpa_sm_ether_send(struct wpa_sm *sm, const u8 *dest,
2206d49e1aeSJan Lentfer 				    u16 proto, const u8 *buf, size_t len)
2216d49e1aeSJan Lentfer {
2226d49e1aeSJan Lentfer 	WPA_ASSERT(sm->ctx->ether_send);
2236d49e1aeSJan Lentfer 	return sm->ctx->ether_send(sm->ctx->ctx, dest, proto, buf, len);
2246d49e1aeSJan Lentfer }
2256d49e1aeSJan Lentfer 
wpa_sm_get_beacon_ie(struct wpa_sm * sm)2266d49e1aeSJan Lentfer static inline int wpa_sm_get_beacon_ie(struct wpa_sm *sm)
2276d49e1aeSJan Lentfer {
2286d49e1aeSJan Lentfer 	WPA_ASSERT(sm->ctx->get_beacon_ie);
2296d49e1aeSJan Lentfer 	return sm->ctx->get_beacon_ie(sm->ctx->ctx);
2306d49e1aeSJan Lentfer }
2316d49e1aeSJan Lentfer 
wpa_sm_cancel_auth_timeout(struct wpa_sm * sm)2326d49e1aeSJan Lentfer static inline void wpa_sm_cancel_auth_timeout(struct wpa_sm *sm)
2336d49e1aeSJan Lentfer {
2346d49e1aeSJan Lentfer 	WPA_ASSERT(sm->ctx->cancel_auth_timeout);
2356d49e1aeSJan Lentfer 	sm->ctx->cancel_auth_timeout(sm->ctx->ctx);
2366d49e1aeSJan Lentfer }
2376d49e1aeSJan Lentfer 
wpa_sm_alloc_eapol(struct wpa_sm * sm,u8 type,const void * data,u16 data_len,size_t * msg_len,void ** data_pos)2386d49e1aeSJan Lentfer static inline u8 * wpa_sm_alloc_eapol(struct wpa_sm *sm, u8 type,
2396d49e1aeSJan Lentfer 				      const void *data, u16 data_len,
2406d49e1aeSJan Lentfer 				      size_t *msg_len, void **data_pos)
2416d49e1aeSJan Lentfer {
2426d49e1aeSJan Lentfer 	WPA_ASSERT(sm->ctx->alloc_eapol);
2436d49e1aeSJan Lentfer 	return sm->ctx->alloc_eapol(sm->ctx->ctx, type, data, data_len,
2446d49e1aeSJan Lentfer 				    msg_len, data_pos);
2456d49e1aeSJan Lentfer }
2466d49e1aeSJan Lentfer 
wpa_sm_add_pmkid(struct wpa_sm * sm,void * network_ctx,const u8 * bssid,const u8 * pmkid,const u8 * cache_id,const u8 * pmk,size_t pmk_len)247*a1157835SDaniel Fojt static inline int wpa_sm_add_pmkid(struct wpa_sm *sm, void *network_ctx,
248*a1157835SDaniel Fojt 				   const u8 *bssid, const u8 *pmkid,
249*a1157835SDaniel Fojt 				   const u8 *cache_id, const u8 *pmk,
250*a1157835SDaniel Fojt 				   size_t pmk_len)
2516d49e1aeSJan Lentfer {
2526d49e1aeSJan Lentfer 	WPA_ASSERT(sm->ctx->add_pmkid);
253*a1157835SDaniel Fojt 	return sm->ctx->add_pmkid(sm->ctx->ctx, network_ctx, bssid, pmkid,
254*a1157835SDaniel Fojt 				  cache_id, pmk, pmk_len);
2556d49e1aeSJan Lentfer }
2566d49e1aeSJan Lentfer 
wpa_sm_remove_pmkid(struct wpa_sm * sm,void * network_ctx,const u8 * bssid,const u8 * pmkid,const u8 * cache_id)257*a1157835SDaniel Fojt static inline int wpa_sm_remove_pmkid(struct wpa_sm *sm, void *network_ctx,
258*a1157835SDaniel Fojt 				      const u8 *bssid, const u8 *pmkid,
259*a1157835SDaniel Fojt 				      const u8 *cache_id)
2606d49e1aeSJan Lentfer {
2616d49e1aeSJan Lentfer 	WPA_ASSERT(sm->ctx->remove_pmkid);
262*a1157835SDaniel Fojt 	return sm->ctx->remove_pmkid(sm->ctx->ctx, network_ctx, bssid, pmkid,
263*a1157835SDaniel Fojt 				     cache_id);
2646d49e1aeSJan Lentfer }
2656d49e1aeSJan Lentfer 
wpa_sm_mlme_setprotection(struct wpa_sm * sm,const u8 * addr,int protect_type,int key_type)2666d49e1aeSJan Lentfer static inline int wpa_sm_mlme_setprotection(struct wpa_sm *sm, const u8 *addr,
2676d49e1aeSJan Lentfer 					    int protect_type, int key_type)
2686d49e1aeSJan Lentfer {
2696d49e1aeSJan Lentfer 	WPA_ASSERT(sm->ctx->mlme_setprotection);
2706d49e1aeSJan Lentfer 	return sm->ctx->mlme_setprotection(sm->ctx->ctx, addr, protect_type,
2716d49e1aeSJan Lentfer 					   key_type);
2726d49e1aeSJan Lentfer }
2736d49e1aeSJan Lentfer 
wpa_sm_update_ft_ies(struct wpa_sm * sm,const u8 * md,const u8 * ies,size_t ies_len)2746d49e1aeSJan Lentfer static inline int wpa_sm_update_ft_ies(struct wpa_sm *sm, const u8 *md,
2756d49e1aeSJan Lentfer 				       const u8 *ies, size_t ies_len)
2766d49e1aeSJan Lentfer {
2776d49e1aeSJan Lentfer 	if (sm->ctx->update_ft_ies)
2786d49e1aeSJan Lentfer 		return sm->ctx->update_ft_ies(sm->ctx->ctx, md, ies, ies_len);
2796d49e1aeSJan Lentfer 	return -1;
2806d49e1aeSJan Lentfer }
2816d49e1aeSJan Lentfer 
wpa_sm_send_ft_action(struct wpa_sm * sm,u8 action,const u8 * target_ap,const u8 * ies,size_t ies_len)2826d49e1aeSJan Lentfer static inline int wpa_sm_send_ft_action(struct wpa_sm *sm, u8 action,
2836d49e1aeSJan Lentfer 					const u8 *target_ap,
2846d49e1aeSJan Lentfer 					const u8 *ies, size_t ies_len)
2856d49e1aeSJan Lentfer {
2866d49e1aeSJan Lentfer 	if (sm->ctx->send_ft_action)
2876d49e1aeSJan Lentfer 		return sm->ctx->send_ft_action(sm->ctx->ctx, action, target_ap,
2886d49e1aeSJan Lentfer 					       ies, ies_len);
2896d49e1aeSJan Lentfer 	return -1;
2906d49e1aeSJan Lentfer }
2916d49e1aeSJan Lentfer 
wpa_sm_mark_authenticated(struct wpa_sm * sm,const u8 * target_ap)2923ff40c12SJohn Marino static inline int wpa_sm_mark_authenticated(struct wpa_sm *sm,
2933ff40c12SJohn Marino 					    const u8 *target_ap)
2943ff40c12SJohn Marino {
2953ff40c12SJohn Marino 	if (sm->ctx->mark_authenticated)
2963ff40c12SJohn Marino 		return sm->ctx->mark_authenticated(sm->ctx->ctx, target_ap);
2973ff40c12SJohn Marino 	return -1;
2983ff40c12SJohn Marino }
2993ff40c12SJohn Marino 
wpa_sm_set_rekey_offload(struct wpa_sm * sm)3003ff40c12SJohn Marino static inline void wpa_sm_set_rekey_offload(struct wpa_sm *sm)
3013ff40c12SJohn Marino {
3023ff40c12SJohn Marino 	if (!sm->ctx->set_rekey_offload)
3033ff40c12SJohn Marino 		return;
304*a1157835SDaniel Fojt 	sm->ctx->set_rekey_offload(sm->ctx->ctx, sm->ptk.kek, sm->ptk.kek_len,
305*a1157835SDaniel Fojt 				   sm->ptk.kck, sm->ptk.kck_len,
306*a1157835SDaniel Fojt 				   sm->rx_replay_counter);
3073ff40c12SJohn Marino }
3083ff40c12SJohn Marino 
3093ff40c12SJohn Marino #ifdef CONFIG_TDLS
wpa_sm_tdls_get_capa(struct wpa_sm * sm,int * tdls_supported,int * tdls_ext_setup,int * tdls_chan_switch)3103ff40c12SJohn Marino static inline int wpa_sm_tdls_get_capa(struct wpa_sm *sm,
3113ff40c12SJohn Marino 				       int *tdls_supported,
312*a1157835SDaniel Fojt 				       int *tdls_ext_setup,
313*a1157835SDaniel Fojt 				       int *tdls_chan_switch)
3143ff40c12SJohn Marino {
3153ff40c12SJohn Marino 	if (sm->ctx->tdls_get_capa)
3163ff40c12SJohn Marino 		return sm->ctx->tdls_get_capa(sm->ctx->ctx, tdls_supported,
317*a1157835SDaniel Fojt 					      tdls_ext_setup, tdls_chan_switch);
3183ff40c12SJohn Marino 	return -1;
3193ff40c12SJohn Marino }
3203ff40c12SJohn Marino 
wpa_sm_send_tdls_mgmt(struct wpa_sm * sm,const u8 * dst,u8 action_code,u8 dialog_token,u16 status_code,u32 peer_capab,int initiator,const u8 * buf,size_t len)3213ff40c12SJohn Marino static inline int wpa_sm_send_tdls_mgmt(struct wpa_sm *sm, const u8 *dst,
3223ff40c12SJohn Marino 					u8 action_code, u8 dialog_token,
323*a1157835SDaniel Fojt 					u16 status_code, u32 peer_capab,
324*a1157835SDaniel Fojt 					int initiator, const u8 *buf,
3253ff40c12SJohn Marino 					size_t len)
3263ff40c12SJohn Marino {
3273ff40c12SJohn Marino 	if (sm->ctx->send_tdls_mgmt)
3283ff40c12SJohn Marino 		return sm->ctx->send_tdls_mgmt(sm->ctx->ctx, dst, action_code,
3293ff40c12SJohn Marino 					       dialog_token, status_code,
330*a1157835SDaniel Fojt 					       peer_capab, initiator, buf,
331*a1157835SDaniel Fojt 					       len);
3323ff40c12SJohn Marino 	return -1;
3333ff40c12SJohn Marino }
3343ff40c12SJohn Marino 
wpa_sm_tdls_oper(struct wpa_sm * sm,int oper,const u8 * peer)3353ff40c12SJohn Marino static inline int wpa_sm_tdls_oper(struct wpa_sm *sm, int oper,
3363ff40c12SJohn Marino 				   const u8 *peer)
3373ff40c12SJohn Marino {
3383ff40c12SJohn Marino 	if (sm->ctx->tdls_oper)
3393ff40c12SJohn Marino 		return sm->ctx->tdls_oper(sm->ctx->ctx, oper, peer);
3403ff40c12SJohn Marino 	return -1;
3413ff40c12SJohn Marino }
3423ff40c12SJohn Marino 
3433ff40c12SJohn Marino static inline int
wpa_sm_tdls_peer_addset(struct wpa_sm * sm,const u8 * addr,int add,u16 aid,u16 capability,const u8 * supp_rates,size_t supp_rates_len,const struct ieee80211_ht_capabilities * ht_capab,const struct ieee80211_vht_capabilities * vht_capab,u8 qosinfo,int wmm,const u8 * ext_capab,size_t ext_capab_len,const u8 * supp_channels,size_t supp_channels_len,const u8 * supp_oper_classes,size_t supp_oper_classes_len)3443ff40c12SJohn Marino wpa_sm_tdls_peer_addset(struct wpa_sm *sm, const u8 *addr, int add,
3453ff40c12SJohn Marino 			u16 aid, u16 capability, const u8 *supp_rates,
3463ff40c12SJohn Marino 			size_t supp_rates_len,
3473ff40c12SJohn Marino 			const struct ieee80211_ht_capabilities *ht_capab,
3483ff40c12SJohn Marino 			const struct ieee80211_vht_capabilities *vht_capab,
349*a1157835SDaniel Fojt 			u8 qosinfo, int wmm, const u8 *ext_capab,
350*a1157835SDaniel Fojt 			size_t ext_capab_len, const u8 *supp_channels,
351*a1157835SDaniel Fojt 			size_t supp_channels_len, const u8 *supp_oper_classes,
3523ff40c12SJohn Marino 			size_t supp_oper_classes_len)
3533ff40c12SJohn Marino {
3543ff40c12SJohn Marino 	if (sm->ctx->tdls_peer_addset)
3553ff40c12SJohn Marino 		return sm->ctx->tdls_peer_addset(sm->ctx->ctx, addr, add,
3563ff40c12SJohn Marino 						 aid, capability, supp_rates,
3573ff40c12SJohn Marino 						 supp_rates_len, ht_capab,
358*a1157835SDaniel Fojt 						 vht_capab, qosinfo, wmm,
3593ff40c12SJohn Marino 						 ext_capab, ext_capab_len,
3603ff40c12SJohn Marino 						 supp_channels,
3613ff40c12SJohn Marino 						 supp_channels_len,
3623ff40c12SJohn Marino 						 supp_oper_classes,
3633ff40c12SJohn Marino 						 supp_oper_classes_len);
3643ff40c12SJohn Marino 	return -1;
3653ff40c12SJohn Marino }
366*a1157835SDaniel Fojt 
367*a1157835SDaniel Fojt static inline int
wpa_sm_tdls_enable_channel_switch(struct wpa_sm * sm,const u8 * addr,u8 oper_class,const struct hostapd_freq_params * freq_params)368*a1157835SDaniel Fojt wpa_sm_tdls_enable_channel_switch(struct wpa_sm *sm, const u8 *addr,
369*a1157835SDaniel Fojt 				  u8 oper_class,
370*a1157835SDaniel Fojt 				  const struct hostapd_freq_params *freq_params)
371*a1157835SDaniel Fojt {
372*a1157835SDaniel Fojt 	if (sm->ctx->tdls_enable_channel_switch)
373*a1157835SDaniel Fojt 		return sm->ctx->tdls_enable_channel_switch(sm->ctx->ctx, addr,
374*a1157835SDaniel Fojt 							   oper_class,
375*a1157835SDaniel Fojt 							   freq_params);
376*a1157835SDaniel Fojt 	return -1;
377*a1157835SDaniel Fojt }
378*a1157835SDaniel Fojt 
379*a1157835SDaniel Fojt static inline int
wpa_sm_tdls_disable_channel_switch(struct wpa_sm * sm,const u8 * addr)380*a1157835SDaniel Fojt wpa_sm_tdls_disable_channel_switch(struct wpa_sm *sm, const u8 *addr)
381*a1157835SDaniel Fojt {
382*a1157835SDaniel Fojt 	if (sm->ctx->tdls_disable_channel_switch)
383*a1157835SDaniel Fojt 		return sm->ctx->tdls_disable_channel_switch(sm->ctx->ctx, addr);
384*a1157835SDaniel Fojt 	return -1;
385*a1157835SDaniel Fojt }
3863ff40c12SJohn Marino #endif /* CONFIG_TDLS */
3876d49e1aeSJan Lentfer 
wpa_sm_key_mgmt_set_pmk(struct wpa_sm * sm,const u8 * pmk,size_t pmk_len)388*a1157835SDaniel Fojt static inline int wpa_sm_key_mgmt_set_pmk(struct wpa_sm *sm,
389*a1157835SDaniel Fojt 					  const u8 *pmk, size_t pmk_len)
390*a1157835SDaniel Fojt {
391*a1157835SDaniel Fojt 	if (!sm->ctx->key_mgmt_set_pmk)
392*a1157835SDaniel Fojt 		return -1;
393*a1157835SDaniel Fojt 	return sm->ctx->key_mgmt_set_pmk(sm->ctx->ctx, pmk, pmk_len);
394*a1157835SDaniel Fojt }
395*a1157835SDaniel Fojt 
wpa_sm_fils_hlp_rx(struct wpa_sm * sm,const u8 * dst,const u8 * src,const u8 * pkt,size_t pkt_len)396*a1157835SDaniel Fojt static inline void wpa_sm_fils_hlp_rx(struct wpa_sm *sm,
397*a1157835SDaniel Fojt 				      const u8 *dst, const u8 *src,
398*a1157835SDaniel Fojt 				      const u8 *pkt, size_t pkt_len)
399*a1157835SDaniel Fojt {
400*a1157835SDaniel Fojt 	if (sm->ctx->fils_hlp_rx)
401*a1157835SDaniel Fojt 		sm->ctx->fils_hlp_rx(sm->ctx->ctx, dst, src, pkt, pkt_len);
402*a1157835SDaniel Fojt }
403*a1157835SDaniel Fojt 
wpa_sm_channel_info(struct wpa_sm * sm,struct wpa_channel_info * ci)404*a1157835SDaniel Fojt static inline int wpa_sm_channel_info(struct wpa_sm *sm,
405*a1157835SDaniel Fojt 				      struct wpa_channel_info *ci)
406*a1157835SDaniel Fojt {
407*a1157835SDaniel Fojt 	if (!sm->ctx->channel_info)
408*a1157835SDaniel Fojt 		return -1;
409*a1157835SDaniel Fojt 	return sm->ctx->channel_info(sm->ctx->ctx, ci);
410*a1157835SDaniel Fojt }
411*a1157835SDaniel Fojt 
412*a1157835SDaniel Fojt 
413*a1157835SDaniel Fojt int wpa_eapol_key_send(struct wpa_sm *sm, struct wpa_ptk *ptk,
4146d49e1aeSJan Lentfer 		       int ver, const u8 *dest, u16 proto,
4156d49e1aeSJan Lentfer 		       u8 *msg, size_t msg_len, u8 *key_mic);
4166d49e1aeSJan Lentfer int wpa_supplicant_send_2_of_4(struct wpa_sm *sm, const unsigned char *dst,
4176d49e1aeSJan Lentfer 			       const struct wpa_eapol_key *key,
4186d49e1aeSJan Lentfer 			       int ver, const u8 *nonce,
4196d49e1aeSJan Lentfer 			       const u8 *wpa_ie, size_t wpa_ie_len,
4206d49e1aeSJan Lentfer 			       struct wpa_ptk *ptk);
4216d49e1aeSJan Lentfer int wpa_supplicant_send_4_of_4(struct wpa_sm *sm, const unsigned char *dst,
4226d49e1aeSJan Lentfer 			       const struct wpa_eapol_key *key,
4236d49e1aeSJan Lentfer 			       u16 ver, u16 key_info,
4246d49e1aeSJan Lentfer 			       struct wpa_ptk *ptk);
4256d49e1aeSJan Lentfer 
4266d49e1aeSJan Lentfer int wpa_derive_ptk_ft(struct wpa_sm *sm, const unsigned char *src_addr,
427*a1157835SDaniel Fojt 		      const struct wpa_eapol_key *key, struct wpa_ptk *ptk);
4286d49e1aeSJan Lentfer 
4293ff40c12SJohn Marino void wpa_tdls_assoc(struct wpa_sm *sm);
4303ff40c12SJohn Marino void wpa_tdls_disassoc(struct wpa_sm *sm);
4313ff40c12SJohn Marino 
4326d49e1aeSJan Lentfer #endif /* WPA_I_H */
433