~ubuntu-branches/ubuntu/gutsy/wpasupplicant/gutsy

« back to all changes in this revision

Viewing changes to wpa_i.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler, Alexander Sack
  • Date: 2007-08-26 16:06:57 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20070826160657-2m8pxoweuxe8f93t
Tags: 0.6.0+0.5.8-0ubuntu1
* New upstream release
* remove patch 11_erroneous_manpage_ref, applied upstream
* remove patch 25_wpas_dbus_unregister_iface_fix, applied upstream

[ Alexander Sack ]
* bumping upstream version to replace development version 0.6.0 with
  this package from stable release branch.
* attempt to fix wierd timeout and high latency issues by going
  back to stable upstream version (0.5.9) (LP: #140763,
  LP: #141233).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * wpa_supplicant - Internal WPA state machine definitions
 
3
 * Copyright (c) 2004-2006, Jouni Malinen <j@w1.fi>
 
4
 *
 
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.
 
8
 *
 
9
 * Alternatively, this software may be distributed under the terms of BSD
 
10
 * license.
 
11
 *
 
12
 * See README and COPYING for more details.
 
13
 */
 
14
 
 
15
#ifndef WPA_I_H
 
16
#define WPA_I_H
 
17
 
 
18
struct rsn_pmksa_candidate;
 
19
 
 
20
#ifdef _MSC_VER
 
21
#pragma pack(push, 1)
 
22
#endif /* _MSC_VER */
 
23
 
 
24
/**
 
25
 * struct wpa_ptk - WPA Pairwise Transient Key
 
26
 * IEEE Std 802.11i-2004 - 8.5.1.2 Pairwise key hierarchy
 
27
 */
 
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;
 
40
 
 
41
#ifdef _MSC_VER
 
42
#pragma pack(pop)
 
43
#endif /* _MSC_VER */
 
44
 
 
45
 
 
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;
 
66
 
 
67
        struct wpa_ptk stk, tstk;
 
68
        int stk_set, tstk_set;
 
69
};
 
70
#else /* CONFIG_PEERKEY */
 
71
struct wpa_peerkey;
 
72
#endif /* CONFIG_PEERKEY */
 
73
 
 
74
 
 
75
/**
 
76
 * struct wpa_sm - Internal WPA state machine data
 
77
 */
 
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];
 
89
 
 
90
        struct eapol_sm *eapol; /* EAPOL state machine from upper level code */
 
91
 
 
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;
 
95
 
 
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;
 
102
 
 
103
        struct wpa_sm_ctx *ctx;
 
104
 
 
105
        void *scard_ctx; /* context for smartcard callbacks */
 
106
        int fast_reauth; /* whether EAP fast re-authentication is enabled */
 
107
 
 
108
        struct wpa_ssid *cur_ssid;
 
109
 
 
110
        u8 own_addr[ETH_ALEN];
 
111
        const char *ifname;
 
112
        const char *bridge_ifname;
 
113
        u8 bssid[ETH_ALEN];
 
114
 
 
115
        unsigned int dot11RSNAConfigPMKLifetime;
 
116
        unsigned int dot11RSNAConfigPMKReauthThreshold;
 
117
        unsigned int dot11RSNAConfigSATimeout;
 
118
 
 
119
        unsigned int dot11RSNA4WayHandshakeFailures;
 
120
 
 
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;
 
127
 
 
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;
 
132
 
 
133
#ifdef CONFIG_PEERKEY
 
134
        struct wpa_peerkey *peerkey;
 
135
#endif /* CONFIG_PEERKEY */
 
136
};
 
137
 
 
138
 
 
139
static inline void wpa_sm_set_state(struct wpa_sm *sm, wpa_states state)
 
140
{
 
141
        sm->ctx->set_state(sm->ctx->ctx, state);
 
142
}
 
143
 
 
144
static inline wpa_states wpa_sm_get_state(struct wpa_sm *sm)
 
145
{
 
146
        return sm->ctx->get_state(sm->ctx->ctx);
 
147
}
 
148
 
 
149
static inline void wpa_sm_req_scan(struct wpa_sm *sm, int sec, int usec)
 
150
{
 
151
        sm->ctx->req_scan(sm->ctx->ctx, sec, usec);
 
152
}
 
153
 
 
154
static inline void wpa_sm_deauthenticate(struct wpa_sm *sm, int reason_code)
 
155
{
 
156
        sm->ctx->deauthenticate(sm->ctx->ctx, reason_code);
 
157
}
 
158
 
 
159
static inline void wpa_sm_disassociate(struct wpa_sm *sm, int reason_code)
 
160
{
 
161
        sm->ctx->disassociate(sm->ctx->ctx, reason_code);
 
162
}
 
163
 
 
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)
 
168
{
 
169
        return sm->ctx->set_key(sm->ctx->ctx, alg, addr, key_idx, set_tx,
 
170
                                seq, seq_len, key, key_len);
 
171
}
 
172
 
 
173
static inline struct wpa_ssid * wpa_sm_get_ssid(struct wpa_sm *sm)
 
174
{
 
175
        return sm->ctx->get_ssid(sm->ctx->ctx);
 
176
}
 
177
 
 
178
static inline int wpa_sm_get_bssid(struct wpa_sm *sm, u8 *bssid)
 
179
{
 
180
        return sm->ctx->get_bssid(sm->ctx->ctx, bssid);
 
181
}
 
182
 
 
183
static inline int wpa_sm_ether_send(struct wpa_sm *sm, const u8 *dest,
 
184
                                    u16 proto, const u8 *buf, size_t len)
 
185
{
 
186
        return sm->ctx->ether_send(sm->ctx->ctx, dest, proto, buf, len);
 
187
}
 
188
 
 
189
static inline int wpa_sm_get_beacon_ie(struct wpa_sm *sm)
 
190
{
 
191
        return sm->ctx->get_beacon_ie(sm->ctx->ctx);
 
192
}
 
193
 
 
194
static inline void wpa_sm_cancel_auth_timeout(struct wpa_sm *sm)
 
195
{
 
196
        sm->ctx->cancel_auth_timeout(sm->ctx->ctx);
 
197
}
 
198
 
 
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)
 
202
{
 
203
        return sm->ctx->alloc_eapol(sm->ctx->ctx, type, data, data_len,
 
204
                                    msg_len, data_pos);
 
205
}
 
206
 
 
207
static inline int wpa_sm_add_pmkid(struct wpa_sm *sm, const u8 *bssid,
 
208
                                   const u8 *pmkid)
 
209
{
 
210
        return sm->ctx->add_pmkid(sm->ctx->ctx, bssid, pmkid);
 
211
}
 
212
 
 
213
static inline int wpa_sm_remove_pmkid(struct wpa_sm *sm, const u8 *bssid,
 
214
                                      const u8 *pmkid)
 
215
{
 
216
        return sm->ctx->remove_pmkid(sm->ctx->ctx, bssid, pmkid);
 
217
}
 
218
 
 
219
static inline int wpa_sm_mlme_setprotection(struct wpa_sm *sm, const u8 *addr,
 
220
                                            int protect_type, int key_type)
 
221
{
 
222
        return sm->ctx->mlme_setprotection(sm->ctx->ctx, addr, protect_type,
 
223
                                           key_type);
 
224
}
 
225
 
 
226
#endif /* WPA_I_H */