Merge commit 'crater/master'
[dragonfly.git] / contrib / wpa_supplicant-0.5.8 / wpa_i.h
blobb5adb5e2c0d7c617ae5d0c6283fb23948684e2ea
1 /*
2 * wpa_supplicant - Internal WPA state machine definitions
3 * Copyright (c) 2004-2006, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
12 * See README and COPYING for more details.
15 #ifndef WPA_I_H
16 #define WPA_I_H
18 struct rsn_pmksa_candidate;
20 #ifdef _MSC_VER
21 #pragma pack(push, 1)
22 #endif /* _MSC_VER */
24 /**
25 * struct wpa_ptk - WPA Pairwise Transient Key
26 * IEEE Std 802.11i-2004 - 8.5.1.2 Pairwise key hierarchy
28 struct wpa_ptk {
29 u8 kck[16]; /* EAPOL-Key Key Confirmation Key (KCK) */
30 u8 kek[16]; /* EAPOL-Key Key Encryption Key (KEK) */
31 u8 tk1[16]; /* Temporal Key 1 (TK1) */
32 union {
33 u8 tk2[16]; /* Temporal Key 2 (TK2) */
34 struct {
35 u8 tx_mic_key[8];
36 u8 rx_mic_key[8];
37 } auth;
38 } u;
39 } STRUCT_PACKED;
41 #ifdef _MSC_VER
42 #pragma pack(pop)
43 #endif /* _MSC_VER */
46 #ifdef CONFIG_PEERKEY
47 #define PEERKEY_MAX_IE_LEN 80
48 struct wpa_peerkey {
49 struct wpa_peerkey *next;
50 int initiator; /* whether this end was initator for SMK handshake */
51 u8 addr[ETH_ALEN]; /* other end MAC address */
52 u8 inonce[WPA_NONCE_LEN]; /* Initiator Nonce */
53 u8 pnonce[WPA_NONCE_LEN]; /* Peer Nonce */
54 u8 rsnie_i[PEERKEY_MAX_IE_LEN]; /* Initiator RSN IE */
55 size_t rsnie_i_len;
56 u8 rsnie_p[PEERKEY_MAX_IE_LEN]; /* Peer RSN IE */
57 size_t rsnie_p_len;
58 u8 smk[PMK_LEN];
59 int smk_complete;
60 u8 smkid[PMKID_LEN];
61 u32 lifetime;
62 os_time_t expiration;
63 int cipher; /* Selected cipher (WPA_CIPHER_*) */
64 u8 replay_counter[WPA_REPLAY_COUNTER_LEN];
65 int replay_counter_set;
67 struct wpa_ptk stk, tstk;
68 int stk_set, tstk_set;
70 #else /* CONFIG_PEERKEY */
71 struct wpa_peerkey;
72 #endif /* CONFIG_PEERKEY */
75 /**
76 * struct wpa_sm - Internal WPA state machine data
78 struct wpa_sm {
79 u8 pmk[PMK_LEN];
80 size_t pmk_len;
81 struct wpa_ptk ptk, tptk;
82 int ptk_set, tptk_set;
83 u8 snonce[WPA_NONCE_LEN];
84 u8 anonce[WPA_NONCE_LEN]; /* ANonce from the last 1/4 msg */
85 int renew_snonce;
86 u8 rx_replay_counter[WPA_REPLAY_COUNTER_LEN];
87 int rx_replay_counter_set;
88 u8 request_counter[WPA_REPLAY_COUNTER_LEN];
90 struct eapol_sm *eapol; /* EAPOL state machine from upper level code */
92 struct rsn_pmksa_cache *pmksa; /* PMKSA cache */
93 struct rsn_pmksa_cache_entry *cur_pmksa; /* current PMKSA entry */
94 struct rsn_pmksa_candidate *pmksa_candidates;
96 struct l2_packet_data *l2_preauth;
97 struct l2_packet_data *l2_preauth_br;
98 u8 preauth_bssid[ETH_ALEN]; /* current RSN pre-auth peer or
99 * 00:00:00:00:00:00 if no pre-auth is
100 * in progress */
101 struct eapol_sm *preauth_eapol;
103 struct wpa_sm_ctx *ctx;
105 void *scard_ctx; /* context for smartcard callbacks */
106 int fast_reauth; /* whether EAP fast re-authentication is enabled */
108 struct wpa_ssid *cur_ssid;
110 u8 own_addr[ETH_ALEN];
111 const char *ifname;
112 const char *bridge_ifname;
113 u8 bssid[ETH_ALEN];
115 unsigned int dot11RSNAConfigPMKLifetime;
116 unsigned int dot11RSNAConfigPMKReauthThreshold;
117 unsigned int dot11RSNAConfigSATimeout;
119 unsigned int dot11RSNA4WayHandshakeFailures;
121 /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
122 unsigned int proto;
123 unsigned int pairwise_cipher;
124 unsigned int group_cipher;
125 unsigned int key_mgmt;
126 unsigned int mgmt_group_cipher;
128 u8 *assoc_wpa_ie; /* Own WPA/RSN IE from (Re)AssocReq */
129 size_t assoc_wpa_ie_len;
130 u8 *ap_wpa_ie, *ap_rsn_ie;
131 size_t ap_wpa_ie_len, ap_rsn_ie_len;
133 #ifdef CONFIG_PEERKEY
134 struct wpa_peerkey *peerkey;
135 #endif /* CONFIG_PEERKEY */
139 static inline void wpa_sm_set_state(struct wpa_sm *sm, wpa_states state)
141 sm->ctx->set_state(sm->ctx->ctx, state);
144 static inline wpa_states wpa_sm_get_state(struct wpa_sm *sm)
146 return sm->ctx->get_state(sm->ctx->ctx);
149 static inline void wpa_sm_req_scan(struct wpa_sm *sm, int sec, int usec)
151 sm->ctx->req_scan(sm->ctx->ctx, sec, usec);
154 static inline void wpa_sm_deauthenticate(struct wpa_sm *sm, int reason_code)
156 sm->ctx->deauthenticate(sm->ctx->ctx, reason_code);
159 static inline void wpa_sm_disassociate(struct wpa_sm *sm, int reason_code)
161 sm->ctx->disassociate(sm->ctx->ctx, reason_code);
164 static inline int wpa_sm_set_key(struct wpa_sm *sm, wpa_alg alg,
165 const u8 *addr, int key_idx, int set_tx,
166 const u8 *seq, size_t seq_len,
167 const u8 *key, size_t key_len)
169 return sm->ctx->set_key(sm->ctx->ctx, alg, addr, key_idx, set_tx,
170 seq, seq_len, key, key_len);
173 static inline struct wpa_ssid * wpa_sm_get_ssid(struct wpa_sm *sm)
175 return sm->ctx->get_ssid(sm->ctx->ctx);
178 static inline int wpa_sm_get_bssid(struct wpa_sm *sm, u8 *bssid)
180 return sm->ctx->get_bssid(sm->ctx->ctx, bssid);
183 static inline int wpa_sm_ether_send(struct wpa_sm *sm, const u8 *dest,
184 u16 proto, const u8 *buf, size_t len)
186 return sm->ctx->ether_send(sm->ctx->ctx, dest, proto, buf, len);
189 static inline int wpa_sm_get_beacon_ie(struct wpa_sm *sm)
191 return sm->ctx->get_beacon_ie(sm->ctx->ctx);
194 static inline void wpa_sm_cancel_auth_timeout(struct wpa_sm *sm)
196 sm->ctx->cancel_auth_timeout(sm->ctx->ctx);
199 static inline u8 * wpa_sm_alloc_eapol(struct wpa_sm *sm, u8 type,
200 const void *data, u16 data_len,
201 size_t *msg_len, void **data_pos)
203 return sm->ctx->alloc_eapol(sm->ctx->ctx, type, data, data_len,
204 msg_len, data_pos);
207 static inline int wpa_sm_add_pmkid(struct wpa_sm *sm, const u8 *bssid,
208 const u8 *pmkid)
210 return sm->ctx->add_pmkid(sm->ctx->ctx, bssid, pmkid);
213 static inline int wpa_sm_remove_pmkid(struct wpa_sm *sm, const u8 *bssid,
214 const u8 *pmkid)
216 return sm->ctx->remove_pmkid(sm->ctx->ctx, bssid, pmkid);
219 static inline int wpa_sm_mlme_setprotection(struct wpa_sm *sm, const u8 *addr,
220 int protect_type, int key_type)
222 return sm->ctx->mlme_setprotection(sm->ctx->ctx, addr, protect_type,
223 key_type);
226 #endif /* WPA_I_H */