00001
00016 #ifndef WPA_I_H
00017 #define WPA_I_H
00018
00019 struct rsn_pmksa_candidate;
00020
00021 #ifdef _MSC_VER
00022 #pragma pack(push, 1)
00023 #endif
00024
00030 struct wpa_ptk {
00031 u8 kck[16];
00032 u8 kek[16];
00033 u8 tk1[16];
00034 union {
00035 u8 tk2[16];
00036 struct {
00037 u8 tx_mic_key[8];
00038 u8 rx_mic_key[8];
00039 } auth;
00040 } u;
00041 } STRUCT_PACKED;
00042
00043 #ifdef _MSC_VER
00044 #pragma pack(pop)
00045 #endif
00046
00047
00048 #ifdef CONFIG_PEERKEY
00049 #define PEERKEY_MAX_IE_LEN 80
00050 struct wpa_peerkey {
00051 struct wpa_peerkey *next;
00052 int initiator;
00053 u8 addr[ETH_ALEN];
00054 u8 inonce[WPA_NONCE_LEN];
00055 u8 pnonce[WPA_NONCE_LEN];
00056 u8 rsnie_i[PEERKEY_MAX_IE_LEN];
00057 size_t rsnie_i_len;
00058 u8 rsnie_p[PEERKEY_MAX_IE_LEN];
00059 size_t rsnie_p_len;
00060 u8 smk[PMK_LEN];
00061 int smk_complete;
00062 u8 smkid[PMKID_LEN];
00063 u32 lifetime;
00064 os_time_t expiration;
00065 int cipher;
00066 u8 replay_counter[WPA_REPLAY_COUNTER_LEN];
00067 int replay_counter_set;
00068
00069 struct wpa_ptk stk, tstk;
00070 int stk_set, tstk_set;
00071 };
00072 #else
00073 struct wpa_peerkey;
00074 #endif
00075
00076
00081 struct wpa_sm {
00082 u8 pmk[PMK_LEN];
00083 size_t pmk_len;
00084 struct wpa_ptk ptk, tptk;
00085 int ptk_set, tptk_set;
00086 u8 snonce[WPA_NONCE_LEN];
00087 u8 anonce[WPA_NONCE_LEN];
00088 int renew_snonce;
00089 u8 rx_replay_counter[WPA_REPLAY_COUNTER_LEN];
00090 int rx_replay_counter_set;
00091 u8 request_counter[WPA_REPLAY_COUNTER_LEN];
00092
00093 struct eapol_sm *eapol;
00094
00095 struct rsn_pmksa_cache *pmksa;
00096 struct rsn_pmksa_cache_entry *cur_pmksa;
00097 struct rsn_pmksa_candidate *pmksa_candidates;
00098
00099 struct l2_packet_data *l2_preauth;
00100 struct l2_packet_data *l2_preauth_br;
00101 u8 preauth_bssid[ETH_ALEN];
00102
00103
00104 struct eapol_sm *preauth_eapol;
00105
00106 struct wpa_sm_ctx *ctx;
00107
00108 void *scard_ctx;
00109 int fast_reauth;
00110
00111 struct wpa_ssid *cur_ssid;
00112
00113 u8 own_addr[ETH_ALEN];
00114 const char *ifname;
00115 const char *bridge_ifname;
00116 u8 bssid[ETH_ALEN];
00117
00118 unsigned int dot11RSNAConfigPMKLifetime;
00119 unsigned int dot11RSNAConfigPMKReauthThreshold;
00120 unsigned int dot11RSNAConfigSATimeout;
00121
00122 unsigned int dot11RSNA4WayHandshakeFailures;
00123
00124
00125 unsigned int proto;
00126 unsigned int pairwise_cipher;
00127 unsigned int group_cipher;
00128 unsigned int key_mgmt;
00129 unsigned int mgmt_group_cipher;
00130
00131 u8 *assoc_wpa_ie;
00132 size_t assoc_wpa_ie_len;
00133 u8 *ap_wpa_ie, *ap_rsn_ie;
00134 size_t ap_wpa_ie_len, ap_rsn_ie_len;
00135
00136 #ifdef CONFIG_PEERKEY
00137 struct wpa_peerkey *peerkey;
00138 #endif
00139 };
00140
00141
00142 static inline void wpa_sm_set_state(struct wpa_sm *sm, wpa_states state)
00143 {
00144 sm->ctx->set_state(sm->ctx->ctx, state);
00145 }
00146
00147 static inline wpa_states wpa_sm_get_state(struct wpa_sm *sm)
00148 {
00149 return sm->ctx->get_state(sm->ctx->ctx);
00150 }
00151
00152 static inline void wpa_sm_req_scan(struct wpa_sm *sm, int sec, int usec)
00153 {
00154 sm->ctx->req_scan(sm->ctx->ctx, sec, usec);
00155 }
00156
00157 static inline void wpa_sm_deauthenticate(struct wpa_sm *sm, int reason_code)
00158 {
00159 sm->ctx->deauthenticate(sm->ctx->ctx, reason_code);
00160 }
00161
00162 static inline void wpa_sm_disassociate(struct wpa_sm *sm, int reason_code)
00163 {
00164 sm->ctx->disassociate(sm->ctx->ctx, reason_code);
00165 }
00166
00167 static inline int wpa_sm_set_key(struct wpa_sm *sm, wpa_alg alg,
00168 const u8 *addr, int key_idx, int set_tx,
00169 const u8 *seq, size_t seq_len,
00170 const u8 *key, size_t key_len)
00171 {
00172 return sm->ctx->set_key(sm->ctx->ctx, alg, addr, key_idx, set_tx,
00173 seq, seq_len, key, key_len);
00174 }
00175
00176 static inline struct wpa_ssid * wpa_sm_get_ssid(struct wpa_sm *sm)
00177 {
00178 return sm->ctx->get_ssid(sm->ctx->ctx);
00179 }
00180
00181 static inline int wpa_sm_get_bssid(struct wpa_sm *sm, u8 *bssid)
00182 {
00183 return sm->ctx->get_bssid(sm->ctx->ctx, bssid);
00184 }
00185
00186 static inline int wpa_sm_ether_send(struct wpa_sm *sm, const u8 *dest,
00187 u16 proto, const u8 *buf, size_t len)
00188 {
00189 return sm->ctx->ether_send(sm->ctx->ctx, dest, proto, buf, len);
00190 }
00191
00192 static inline int wpa_sm_get_beacon_ie(struct wpa_sm *sm)
00193 {
00194 return sm->ctx->get_beacon_ie(sm->ctx->ctx);
00195 }
00196
00197 static inline void wpa_sm_cancel_auth_timeout(struct wpa_sm *sm)
00198 {
00199 sm->ctx->cancel_auth_timeout(sm->ctx->ctx);
00200 }
00201
00202 static inline u8 * wpa_sm_alloc_eapol(struct wpa_sm *sm, u8 type,
00203 const void *data, u16 data_len,
00204 size_t *msg_len, void **data_pos)
00205 {
00206 return sm->ctx->alloc_eapol(sm->ctx->ctx, type, data, data_len,
00207 msg_len, data_pos);
00208 }
00209
00210 static inline int wpa_sm_add_pmkid(struct wpa_sm *sm, const u8 *bssid,
00211 const u8 *pmkid)
00212 {
00213 return sm->ctx->add_pmkid(sm->ctx->ctx, bssid, pmkid);
00214 }
00215
00216 static inline int wpa_sm_remove_pmkid(struct wpa_sm *sm, const u8 *bssid,
00217 const u8 *pmkid)
00218 {
00219 return sm->ctx->remove_pmkid(sm->ctx->ctx, bssid, pmkid);
00220 }
00221
00222 static inline int wpa_sm_mlme_setprotection(struct wpa_sm *sm, const u8 *addr,
00223 int protect_type, int key_type)
00224 {
00225 return sm->ctx->mlme_setprotection(sm->ctx->ctx, addr, protect_type,
00226 key_type);
00227 }
00228
00229 #endif
00230