wpa_i.h
Go to the documentation of this file.
00001 /*
00002  * Internal WPA/RSN supplicant state machine definitions
00003  * Copyright (c) 2004-2010, Jouni Malinen <j@w1.fi>
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 2 as
00007  * published by the Free Software Foundation.
00008  *
00009  * Alternatively, this software may be distributed under the terms of BSD
00010  * license.
00011  *
00012  * See README and COPYING for more details.
00013  */
00014 
00015 #ifndef WPA_I_H
00016 #define WPA_I_H
00017 
00018 #include "utils/list.h"
00019 
00020 struct wpa_peerkey;
00021 struct wpa_eapol_key;
00022 
00026 struct wpa_sm {
00027         u8 pmk[PMK_LEN];
00028         size_t pmk_len;
00029         struct wpa_ptk ptk, tptk;
00030         int ptk_set, tptk_set;
00031         u8 snonce[WPA_NONCE_LEN];
00032         u8 anonce[WPA_NONCE_LEN]; /* ANonce from the last 1/4 msg */
00033         int renew_snonce;
00034         u8 rx_replay_counter[WPA_REPLAY_COUNTER_LEN];
00035         int rx_replay_counter_set;
00036         u8 request_counter[WPA_REPLAY_COUNTER_LEN];
00037 
00038         struct eapol_sm *eapol; /* EAPOL state machine from upper level code */
00039 
00040         struct rsn_pmksa_cache *pmksa; /* PMKSA cache */
00041         struct rsn_pmksa_cache_entry *cur_pmksa; /* current PMKSA entry */
00042         struct dl_list pmksa_candidates;
00043 
00044         struct l2_packet_data *l2_preauth;
00045         struct l2_packet_data *l2_preauth_br;
00046         u8 preauth_bssid[ETH_ALEN]; /* current RSN pre-auth peer or
00047                                      * 00:00:00:00:00:00 if no pre-auth is
00048                                      * in progress */
00049         struct eapol_sm *preauth_eapol;
00050 
00051         struct wpa_sm_ctx *ctx;
00052 
00053         void *scard_ctx; /* context for smartcard callbacks */
00054         int fast_reauth; /* whether EAP fast re-authentication is enabled */
00055 
00056         void *network_ctx;
00057         int peerkey_enabled;
00058         int allowed_pairwise_cipher; /* bitfield of WPA_CIPHER_* */
00059         int proactive_key_caching;
00060         int eap_workaround;
00061         void *eap_conf_ctx;
00062         u8 ssid[32];
00063         size_t ssid_len;
00064         int wpa_ptk_rekey;
00065 
00066         u8 own_addr[ETH_ALEN];
00067         const char *ifname;
00068         const char *bridge_ifname;
00069         u8 bssid[ETH_ALEN];
00070 
00071         unsigned int dot11RSNAConfigPMKLifetime;
00072         unsigned int dot11RSNAConfigPMKReauthThreshold;
00073         unsigned int dot11RSNAConfigSATimeout;
00074 
00075         unsigned int dot11RSNA4WayHandshakeFailures;
00076 
00077         /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
00078         unsigned int proto;
00079         unsigned int pairwise_cipher;
00080         unsigned int group_cipher;
00081         unsigned int key_mgmt;
00082         unsigned int mgmt_group_cipher;
00083 
00084         int rsn_enabled; /* Whether RSN is enabled in configuration */
00085         int mfp; /* 0 = disabled, 1 = optional, 2 = mandatory */
00086 
00087         u8 *assoc_wpa_ie; /* Own WPA/RSN IE from (Re)AssocReq */
00088         size_t assoc_wpa_ie_len;
00089         u8 *ap_wpa_ie, *ap_rsn_ie;
00090         size_t ap_wpa_ie_len, ap_rsn_ie_len;
00091 
00092 #ifdef CONFIG_PEERKEY
00093         struct wpa_peerkey *peerkey;
00094 #endif /* CONFIG_PEERKEY */
00095 
00096 #ifdef CONFIG_IEEE80211R
00097         u8 xxkey[PMK_LEN]; /* PSK or the second 256 bits of MSK */
00098         size_t xxkey_len;
00099         u8 pmk_r0[PMK_LEN];
00100         u8 pmk_r0_name[WPA_PMK_NAME_LEN];
00101         u8 pmk_r1[PMK_LEN];
00102         u8 pmk_r1_name[WPA_PMK_NAME_LEN];
00103         u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
00104         u8 r0kh_id[FT_R0KH_ID_MAX_LEN];
00105         size_t r0kh_id_len;
00106         u8 r1kh_id[FT_R1KH_ID_LEN];
00107         int ft_completed;
00108         int over_the_ds_in_progress;
00109         u8 target_ap[ETH_ALEN]; /* over-the-DS target AP */
00110         int set_ptk_after_assoc;
00111         u8 mdie_ft_capab; /* FT Capability and Policy from target AP MDIE */
00112         u8 *assoc_resp_ies; /* MDIE and FTIE from (Re)Association Response */
00113         size_t assoc_resp_ies_len;
00114 #endif /* CONFIG_IEEE80211R */
00115 };
00116 
00117 
00118 static inline void wpa_sm_set_state(struct wpa_sm *sm, enum wpa_states state)
00119 {
00120         WPA_ASSERT(sm->ctx->set_state);
00121         sm->ctx->set_state(sm->ctx->ctx, state);
00122 }
00123 
00124 static inline enum wpa_states wpa_sm_get_state(struct wpa_sm *sm)
00125 {
00126         WPA_ASSERT(sm->ctx->get_state);
00127         return sm->ctx->get_state(sm->ctx->ctx);
00128 }
00129 
00130 static inline void wpa_sm_deauthenticate(struct wpa_sm *sm, int reason_code)
00131 {
00132         WPA_ASSERT(sm->ctx->deauthenticate);
00133         sm->ctx->deauthenticate(sm->ctx->ctx, reason_code);
00134 }
00135 
00136 static inline void wpa_sm_disassociate(struct wpa_sm *sm, int reason_code)
00137 {
00138         WPA_ASSERT(sm->ctx->disassociate);
00139         sm->ctx->disassociate(sm->ctx->ctx, reason_code);
00140 }
00141 
00142 static inline int wpa_sm_set_key(struct wpa_sm *sm, enum wpa_alg alg,
00143                                  const u8 *addr, int key_idx, int set_tx,
00144                                  const u8 *seq, size_t seq_len,
00145                                  const u8 *key, size_t key_len)
00146 {
00147         WPA_ASSERT(sm->ctx->set_key);
00148         return sm->ctx->set_key(sm->ctx->ctx, alg, addr, key_idx, set_tx,
00149                                 seq, seq_len, key, key_len);
00150 }
00151 
00152 static inline void * wpa_sm_get_network_ctx(struct wpa_sm *sm)
00153 {
00154         WPA_ASSERT(sm->ctx->get_network_ctx);
00155         return sm->ctx->get_network_ctx(sm->ctx->ctx);
00156 }
00157 
00158 static inline int wpa_sm_get_bssid(struct wpa_sm *sm, u8 *bssid)
00159 {
00160         WPA_ASSERT(sm->ctx->get_bssid);
00161         return sm->ctx->get_bssid(sm->ctx->ctx, bssid);
00162 }
00163 
00164 static inline int wpa_sm_ether_send(struct wpa_sm *sm, const u8 *dest,
00165                                     u16 proto, const u8 *buf, size_t len)
00166 {
00167         WPA_ASSERT(sm->ctx->ether_send);
00168         return sm->ctx->ether_send(sm->ctx->ctx, dest, proto, buf, len);
00169 }
00170 
00171 static inline int wpa_sm_get_beacon_ie(struct wpa_sm *sm)
00172 {
00173         WPA_ASSERT(sm->ctx->get_beacon_ie);
00174         return sm->ctx->get_beacon_ie(sm->ctx->ctx);
00175 }
00176 
00177 static inline void wpa_sm_cancel_auth_timeout(struct wpa_sm *sm)
00178 {
00179         WPA_ASSERT(sm->ctx->cancel_auth_timeout);
00180         sm->ctx->cancel_auth_timeout(sm->ctx->ctx);
00181 }
00182 
00183 static inline u8 * wpa_sm_alloc_eapol(struct wpa_sm *sm, u8 type,
00184                                       const void *data, u16 data_len,
00185                                       size_t *msg_len, void **data_pos)
00186 {
00187         WPA_ASSERT(sm->ctx->alloc_eapol);
00188         return sm->ctx->alloc_eapol(sm->ctx->ctx, type, data, data_len,
00189                                     msg_len, data_pos);
00190 }
00191 
00192 static inline int wpa_sm_add_pmkid(struct wpa_sm *sm, const u8 *bssid,
00193                                    const u8 *pmkid)
00194 {
00195         WPA_ASSERT(sm->ctx->add_pmkid);
00196         return sm->ctx->add_pmkid(sm->ctx->ctx, bssid, pmkid);
00197 }
00198 
00199 static inline int wpa_sm_remove_pmkid(struct wpa_sm *sm, const u8 *bssid,
00200                                       const u8 *pmkid)
00201 {
00202         WPA_ASSERT(sm->ctx->remove_pmkid);
00203         return sm->ctx->remove_pmkid(sm->ctx->ctx, bssid, pmkid);
00204 }
00205 
00206 static inline int wpa_sm_mlme_setprotection(struct wpa_sm *sm, const u8 *addr,
00207                                             int protect_type, int key_type)
00208 {
00209         WPA_ASSERT(sm->ctx->mlme_setprotection);
00210         return sm->ctx->mlme_setprotection(sm->ctx->ctx, addr, protect_type,
00211                                            key_type);
00212 }
00213 
00214 static inline int wpa_sm_update_ft_ies(struct wpa_sm *sm, const u8 *md,
00215                                        const u8 *ies, size_t ies_len)
00216 {
00217         if (sm->ctx->update_ft_ies)
00218                 return sm->ctx->update_ft_ies(sm->ctx->ctx, md, ies, ies_len);
00219         return -1;
00220 }
00221 
00222 static inline int wpa_sm_send_ft_action(struct wpa_sm *sm, u8 action,
00223                                         const u8 *target_ap,
00224                                         const u8 *ies, size_t ies_len)
00225 {
00226         if (sm->ctx->send_ft_action)
00227                 return sm->ctx->send_ft_action(sm->ctx->ctx, action, target_ap,
00228                                                ies, ies_len);
00229         return -1;
00230 }
00231 
00232 static inline int wpa_sm_mark_authenticated(struct wpa_sm *sm,
00233                                             const u8 *target_ap)
00234 {
00235         if (sm->ctx->mark_authenticated)
00236                 return sm->ctx->mark_authenticated(sm->ctx->ctx, target_ap);
00237         return -1;
00238 }
00239 
00240 
00241 void wpa_eapol_key_send(struct wpa_sm *sm, const u8 *kck,
00242                         int ver, const u8 *dest, u16 proto,
00243                         u8 *msg, size_t msg_len, u8 *key_mic);
00244 int wpa_supplicant_send_2_of_4(struct wpa_sm *sm, const unsigned char *dst,
00245                                const struct wpa_eapol_key *key,
00246                                int ver, const u8 *nonce,
00247                                const u8 *wpa_ie, size_t wpa_ie_len,
00248                                struct wpa_ptk *ptk);
00249 int wpa_supplicant_send_4_of_4(struct wpa_sm *sm, const unsigned char *dst,
00250                                const struct wpa_eapol_key *key,
00251                                u16 ver, u16 key_info,
00252                                const u8 *kde, size_t kde_len,
00253                                struct wpa_ptk *ptk);
00254 
00255 int wpa_derive_ptk_ft(struct wpa_sm *sm, const unsigned char *src_addr,
00256                       const struct wpa_eapol_key *key,
00257                       struct wpa_ptk *ptk, size_t ptk_len);
00258 
00259 #endif /* WPA_I_H */


wpa_supplicant
Author(s): Package maintained by Blaise Gassend
autogenerated on Thu Apr 24 2014 15:34:36