|
wpa_supplicant / hostapd 2.0
|
00001 00010 #ifndef WPA_I_H 00011 #define WPA_I_H 00012 00013 #include "utils/list.h" 00014 00015 struct wpa_peerkey; 00016 struct wpa_tdls_peer; 00017 struct wpa_eapol_key; 00018 00023 struct wpa_sm { 00024 u8 pmk[PMK_LEN]; 00025 size_t pmk_len; 00026 struct wpa_ptk ptk, tptk; 00027 int ptk_set, tptk_set; 00028 u8 snonce[WPA_NONCE_LEN]; 00029 u8 anonce[WPA_NONCE_LEN]; /* ANonce from the last 1/4 msg */ 00030 int renew_snonce; 00031 u8 rx_replay_counter[WPA_REPLAY_COUNTER_LEN]; 00032 int rx_replay_counter_set; 00033 u8 request_counter[WPA_REPLAY_COUNTER_LEN]; 00034 00035 struct eapol_sm *eapol; /* EAPOL state machine from upper level code */ 00036 00037 struct rsn_pmksa_cache *pmksa; /* PMKSA cache */ 00038 struct rsn_pmksa_cache_entry *cur_pmksa; /* current PMKSA entry */ 00039 struct dl_list pmksa_candidates; 00040 00041 struct l2_packet_data *l2_preauth; 00042 struct l2_packet_data *l2_preauth_br; 00043 struct l2_packet_data *l2_tdls; 00044 u8 preauth_bssid[ETH_ALEN]; /* current RSN pre-auth peer or 00045 * 00:00:00:00:00:00 if no pre-auth is 00046 * in progress */ 00047 struct eapol_sm *preauth_eapol; 00048 00049 struct wpa_sm_ctx *ctx; 00050 00051 void *scard_ctx; /* context for smartcard callbacks */ 00052 int fast_reauth; /* whether EAP fast re-authentication is enabled */ 00053 00054 void *network_ctx; 00055 int peerkey_enabled; 00056 int allowed_pairwise_cipher; /* bitfield of WPA_CIPHER_* */ 00057 int proactive_key_caching; 00058 int eap_workaround; 00059 void *eap_conf_ctx; 00060 u8 ssid[32]; 00061 size_t ssid_len; 00062 int wpa_ptk_rekey; 00063 00064 u8 own_addr[ETH_ALEN]; 00065 const char *ifname; 00066 const char *bridge_ifname; 00067 u8 bssid[ETH_ALEN]; 00068 00069 unsigned int dot11RSNAConfigPMKLifetime; 00070 unsigned int dot11RSNAConfigPMKReauthThreshold; 00071 unsigned int dot11RSNAConfigSATimeout; 00072 00073 unsigned int dot11RSNA4WayHandshakeFailures; 00074 00075 /* Selected configuration (based on Beacon/ProbeResp WPA IE) */ 00076 unsigned int proto; 00077 unsigned int pairwise_cipher; 00078 unsigned int group_cipher; 00079 unsigned int key_mgmt; 00080 unsigned int mgmt_group_cipher; 00081 00082 int rsn_enabled; /* Whether RSN is enabled in configuration */ 00083 int mfp; /* 0 = disabled, 1 = optional, 2 = mandatory */ 00084 00085 u8 *assoc_wpa_ie; /* Own WPA/RSN IE from (Re)AssocReq */ 00086 size_t assoc_wpa_ie_len; 00087 u8 *ap_wpa_ie, *ap_rsn_ie; 00088 size_t ap_wpa_ie_len, ap_rsn_ie_len; 00089 00090 #ifdef CONFIG_PEERKEY 00091 struct wpa_peerkey *peerkey; 00092 #endif /* CONFIG_PEERKEY */ 00093 #ifdef CONFIG_TDLS 00094 struct wpa_tdls_peer *tdls; 00095 int tdls_prohibited; 00096 int tdls_disabled; 00097 00098 /* The driver supports TDLS */ 00099 int tdls_supported; 00100 00101 /* 00102 * The driver requires explicit discovery/setup/teardown frames sent 00103 * to it via tdls_mgmt. 00104 */ 00105 int tdls_external_setup; 00106 #endif /* CONFIG_TDLS */ 00107 00108 #ifdef CONFIG_IEEE80211R 00109 u8 xxkey[PMK_LEN]; /* PSK or the second 256 bits of MSK */ 00110 size_t xxkey_len; 00111 u8 pmk_r0[PMK_LEN]; 00112 u8 pmk_r0_name[WPA_PMK_NAME_LEN]; 00113 u8 pmk_r1[PMK_LEN]; 00114 u8 pmk_r1_name[WPA_PMK_NAME_LEN]; 00115 u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN]; 00116 u8 r0kh_id[FT_R0KH_ID_MAX_LEN]; 00117 size_t r0kh_id_len; 00118 u8 r1kh_id[FT_R1KH_ID_LEN]; 00119 int ft_completed; 00120 int over_the_ds_in_progress; 00121 u8 target_ap[ETH_ALEN]; /* over-the-DS target AP */ 00122 int set_ptk_after_assoc; 00123 u8 mdie_ft_capab; /* FT Capability and Policy from target AP MDIE */ 00124 u8 *assoc_resp_ies; /* MDIE and FTIE from (Re)Association Response */ 00125 size_t assoc_resp_ies_len; 00126 #endif /* CONFIG_IEEE80211R */ 00127 }; 00128 00129 00130 static inline void wpa_sm_set_state(struct wpa_sm *sm, enum wpa_states state) 00131 { 00132 WPA_ASSERT(sm->ctx->set_state); 00133 sm->ctx->set_state(sm->ctx->ctx, state); 00134 } 00135 00136 static inline enum wpa_states wpa_sm_get_state(struct wpa_sm *sm) 00137 { 00138 WPA_ASSERT(sm->ctx->get_state); 00139 return sm->ctx->get_state(sm->ctx->ctx); 00140 } 00141 00142 static inline void wpa_sm_deauthenticate(struct wpa_sm *sm, int reason_code) 00143 { 00144 WPA_ASSERT(sm->ctx->deauthenticate); 00145 sm->ctx->deauthenticate(sm->ctx->ctx, reason_code); 00146 } 00147 00148 static inline void wpa_sm_disassociate(struct wpa_sm *sm, int reason_code) 00149 { 00150 WPA_ASSERT(sm->ctx->disassociate); 00151 sm->ctx->disassociate(sm->ctx->ctx, reason_code); 00152 } 00153 00154 static inline int wpa_sm_set_key(struct wpa_sm *sm, enum wpa_alg alg, 00155 const u8 *addr, int key_idx, int set_tx, 00156 const u8 *seq, size_t seq_len, 00157 const u8 *key, size_t key_len) 00158 { 00159 WPA_ASSERT(sm->ctx->set_key); 00160 return sm->ctx->set_key(sm->ctx->ctx, alg, addr, key_idx, set_tx, 00161 seq, seq_len, key, key_len); 00162 } 00163 00164 static inline void * wpa_sm_get_network_ctx(struct wpa_sm *sm) 00165 { 00166 WPA_ASSERT(sm->ctx->get_network_ctx); 00167 return sm->ctx->get_network_ctx(sm->ctx->ctx); 00168 } 00169 00170 static inline int wpa_sm_get_bssid(struct wpa_sm *sm, u8 *bssid) 00171 { 00172 WPA_ASSERT(sm->ctx->get_bssid); 00173 return sm->ctx->get_bssid(sm->ctx->ctx, bssid); 00174 } 00175 00176 static inline int wpa_sm_ether_send(struct wpa_sm *sm, const u8 *dest, 00177 u16 proto, const u8 *buf, size_t len) 00178 { 00179 WPA_ASSERT(sm->ctx->ether_send); 00180 return sm->ctx->ether_send(sm->ctx->ctx, dest, proto, buf, len); 00181 } 00182 00183 static inline int wpa_sm_get_beacon_ie(struct wpa_sm *sm) 00184 { 00185 WPA_ASSERT(sm->ctx->get_beacon_ie); 00186 return sm->ctx->get_beacon_ie(sm->ctx->ctx); 00187 } 00188 00189 static inline void wpa_sm_cancel_auth_timeout(struct wpa_sm *sm) 00190 { 00191 WPA_ASSERT(sm->ctx->cancel_auth_timeout); 00192 sm->ctx->cancel_auth_timeout(sm->ctx->ctx); 00193 } 00194 00195 static inline u8 * wpa_sm_alloc_eapol(struct wpa_sm *sm, u8 type, 00196 const void *data, u16 data_len, 00197 size_t *msg_len, void **data_pos) 00198 { 00199 WPA_ASSERT(sm->ctx->alloc_eapol); 00200 return sm->ctx->alloc_eapol(sm->ctx->ctx, type, data, data_len, 00201 msg_len, data_pos); 00202 } 00203 00204 static inline int wpa_sm_add_pmkid(struct wpa_sm *sm, const u8 *bssid, 00205 const u8 *pmkid) 00206 { 00207 WPA_ASSERT(sm->ctx->add_pmkid); 00208 return sm->ctx->add_pmkid(sm->ctx->ctx, bssid, pmkid); 00209 } 00210 00211 static inline int wpa_sm_remove_pmkid(struct wpa_sm *sm, const u8 *bssid, 00212 const u8 *pmkid) 00213 { 00214 WPA_ASSERT(sm->ctx->remove_pmkid); 00215 return sm->ctx->remove_pmkid(sm->ctx->ctx, bssid, pmkid); 00216 } 00217 00218 static inline int wpa_sm_mlme_setprotection(struct wpa_sm *sm, const u8 *addr, 00219 int protect_type, int key_type) 00220 { 00221 WPA_ASSERT(sm->ctx->mlme_setprotection); 00222 return sm->ctx->mlme_setprotection(sm->ctx->ctx, addr, protect_type, 00223 key_type); 00224 } 00225 00226 static inline int wpa_sm_update_ft_ies(struct wpa_sm *sm, const u8 *md, 00227 const u8 *ies, size_t ies_len) 00228 { 00229 if (sm->ctx->update_ft_ies) 00230 return sm->ctx->update_ft_ies(sm->ctx->ctx, md, ies, ies_len); 00231 return -1; 00232 } 00233 00234 static inline int wpa_sm_send_ft_action(struct wpa_sm *sm, u8 action, 00235 const u8 *target_ap, 00236 const u8 *ies, size_t ies_len) 00237 { 00238 if (sm->ctx->send_ft_action) 00239 return sm->ctx->send_ft_action(sm->ctx->ctx, action, target_ap, 00240 ies, ies_len); 00241 return -1; 00242 } 00243 00244 static inline int wpa_sm_mark_authenticated(struct wpa_sm *sm, 00245 const u8 *target_ap) 00246 { 00247 if (sm->ctx->mark_authenticated) 00248 return sm->ctx->mark_authenticated(sm->ctx->ctx, target_ap); 00249 return -1; 00250 } 00251 00252 static inline void wpa_sm_set_rekey_offload(struct wpa_sm *sm) 00253 { 00254 if (!sm->ctx->set_rekey_offload) 00255 return; 00256 sm->ctx->set_rekey_offload(sm->ctx->ctx, sm->ptk.kek, 00257 sm->ptk.kck, sm->rx_replay_counter); 00258 } 00259 00260 #ifdef CONFIG_TDLS 00261 static inline int wpa_sm_tdls_get_capa(struct wpa_sm *sm, 00262 int *tdls_supported, 00263 int *tdls_ext_setup) 00264 { 00265 if (sm->ctx->tdls_get_capa) 00266 return sm->ctx->tdls_get_capa(sm->ctx->ctx, tdls_supported, 00267 tdls_ext_setup); 00268 return -1; 00269 } 00270 00271 static inline int wpa_sm_send_tdls_mgmt(struct wpa_sm *sm, const u8 *dst, 00272 u8 action_code, u8 dialog_token, 00273 u16 status_code, const u8 *buf, 00274 size_t len) 00275 { 00276 if (sm->ctx->send_tdls_mgmt) 00277 return sm->ctx->send_tdls_mgmt(sm->ctx->ctx, dst, action_code, 00278 dialog_token, status_code, 00279 buf, len); 00280 return -1; 00281 } 00282 00283 static inline int wpa_sm_tdls_oper(struct wpa_sm *sm, int oper, 00284 const u8 *peer) 00285 { 00286 if (sm->ctx->tdls_oper) 00287 return sm->ctx->tdls_oper(sm->ctx->ctx, oper, peer); 00288 return -1; 00289 } 00290 00291 static inline int 00292 wpa_sm_tdls_peer_addset(struct wpa_sm *sm, const u8 *addr, int add, 00293 u16 capability, const u8 *supp_rates, 00294 size_t supp_rates_len) 00295 { 00296 if (sm->ctx->tdls_peer_addset) 00297 return sm->ctx->tdls_peer_addset(sm->ctx->ctx, addr, add, 00298 capability, supp_rates, 00299 supp_rates_len); 00300 return -1; 00301 } 00302 #endif /* CONFIG_TDLS */ 00303 00304 void wpa_eapol_key_send(struct wpa_sm *sm, const u8 *kck, 00305 int ver, const u8 *dest, u16 proto, 00306 u8 *msg, size_t msg_len, u8 *key_mic); 00307 int wpa_supplicant_send_2_of_4(struct wpa_sm *sm, const unsigned char *dst, 00308 const struct wpa_eapol_key *key, 00309 int ver, const u8 *nonce, 00310 const u8 *wpa_ie, size_t wpa_ie_len, 00311 struct wpa_ptk *ptk); 00312 int wpa_supplicant_send_4_of_4(struct wpa_sm *sm, const unsigned char *dst, 00313 const struct wpa_eapol_key *key, 00314 u16 ver, u16 key_info, 00315 const u8 *kde, size_t kde_len, 00316 struct wpa_ptk *ptk); 00317 00318 int wpa_derive_ptk_ft(struct wpa_sm *sm, const unsigned char *src_addr, 00319 const struct wpa_eapol_key *key, 00320 struct wpa_ptk *ptk, size_t ptk_len); 00321 00322 void wpa_tdls_assoc(struct wpa_sm *sm); 00323 void wpa_tdls_disassoc(struct wpa_sm *sm); 00324 00325 #endif /* WPA_I_H */ 00326
1.7.3