aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2005-06-25 15:57:17 (GMT)
committerJouni Malinen <j@w1.fi>2005-06-25 15:57:17 (GMT)
commit45ff640254e10e2cb164b040c43f89c7c03009c6 (patch)
tree09898d6f31a7b1c74d817e3b872e29546985388d
parent90ff33a82ae732e5220840689f39cc6c2774dff8 (diff)
downloadhostap-history-45ff640254e10e2cb164b040c43f89c7c03009c6.zip
hostap-history-45ff640254e10e2cb164b040c43f89c7c03009c6.tar.gz
hostap-history-45ff640254e10e2cb164b040c43f89c7c03009c6.tar.bz2
Continued WPA state machine separation:
- moved wpa_s->dot11RSNA4WayHandshakeFailures into struct wpa_sm and increment this from wpa_sm_notify_disassoc() - renamed wpa_get_mib() to wpa_sm_get_mib() - replaced direct wpa_s->wpa_state reads in wpa.c and preauth.c with wpa_supplicant_get_state() call - fixed preauth_test and eapol_test builds - moved function prototypes for wpa.c function from wpa_supplicant_i.h to wpa.h
-rw-r--r--wpa_supplicant/ctrl_iface.c2
-rw-r--r--wpa_supplicant/eapol_test.c16
-rw-r--r--wpa_supplicant/events.c4
-rw-r--r--wpa_supplicant/preauth.c3
-rw-r--r--wpa_supplicant/preauth_test.c14
-rw-r--r--wpa_supplicant/wpa.c13
-rw-r--r--wpa_supplicant/wpa.h21
-rw-r--r--wpa_supplicant/wpa_i.h2
-rw-r--r--wpa_supplicant/wpa_supplicant.c9
-rw-r--r--wpa_supplicant/wpa_supplicant_i.h24
10 files changed, 69 insertions, 39 deletions
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 9ff76b5..adc305d 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -633,7 +633,7 @@ static void wpa_supplicant_ctrl_iface_receive(int sock, void *eloop_ctx,
memcpy(reply, "PONG\n", 5);
reply_len = 5;
} else if (strcmp(buf, "MIB") == 0) {
- reply_len = wpa_get_mib(wpa_s, reply, reply_size);
+ reply_len = wpa_sm_get_mib(wpa_s->wpa, reply, reply_size);
if (reply_len >= 0) {
res = eapol_sm_get_mib(wpa_s->eapol, reply + reply_len,
reply_size - reply_len);
diff --git a/wpa_supplicant/eapol_test.c b/wpa_supplicant/eapol_test.c
index 3fc962b..4b91f91 100644
--- a/wpa_supplicant/eapol_test.c
+++ b/wpa_supplicant/eapol_test.c
@@ -150,7 +150,21 @@ int pmksa_cache_list(struct wpa_supplicant *wpa_s, char *buf, size_t len)
}
-int wpa_get_mib(struct wpa_supplicant *wpa_s, char *buf, size_t buflen)
+int wpa_sm_get_mib(struct wpa_sm *sm, char *buf, size_t buflen)
+{
+ return 0;
+}
+
+
+int wpa_sm_set_param(struct wpa_sm *sm, enum wpa_sm_conf_params param,
+ unsigned int value)
+{
+ return 0;
+}
+
+
+int wpa_sm_get_status(struct wpa_sm *sm, char *buf, size_t buflen,
+ int verbose)
{
return 0;
}
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index eab32c9..c21c5a1 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -541,8 +541,7 @@ static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s)
if (wpa_s->wpa_state >= WPA_ASSOCIATED)
wpa_supplicant_req_scan(wpa_s, 0, 100000);
wpa_blacklist_add(wpa_s, wpa_s->bssid);
- if (wpa_s->wpa_state == WPA_4WAY_HANDSHAKE)
- wpa_s->dot11RSNA4WayHandshakeFailures++;
+ wpa_sm_notify_disassoc(wpa_s->wpa);
wpa_supplicant_mark_disassoc(wpa_s);
wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "- Disconnect event - "
"remove keys");
@@ -550,7 +549,6 @@ static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s)
wpa_s->keys_cleared = 0;
wpa_clear_keys(wpa_s, wpa_s->bssid);
}
- wpa_sm_notify_disassoc(wpa_s->wpa);
}
diff --git a/wpa_supplicant/preauth.c b/wpa_supplicant/preauth.c
index bd90e76..bd61e0b 100644
--- a/wpa_supplicant/preauth.c
+++ b/wpa_supplicant/preauth.c
@@ -688,7 +688,6 @@ void rsn_preauth_deinit(struct wpa_sm *sm)
*/
void rsn_preauth_candidate_process(struct wpa_sm *sm)
{
- struct wpa_supplicant *wpa_s = sm->ctx;
struct rsn_pmksa_candidate *candidate;
if (sm->pmksa_candidates == NULL)
@@ -699,7 +698,7 @@ void rsn_preauth_candidate_process(struct wpa_sm *sm)
wpa_msg(sm->ctx, MSG_DEBUG, "RSN: processing PMKSA candidate list");
if (sm->preauth_eapol ||
sm->proto != WPA_PROTO_RSN ||
- wpa_s->wpa_state != WPA_COMPLETED ||
+ wpa_supplicant_get_state(sm->ctx) != WPA_COMPLETED ||
sm->key_mgmt != WPA_KEY_MGMT_IEEE8021X) {
wpa_msg(sm->ctx, MSG_DEBUG, "RSN: not in suitable state for "
"new pre-authentication");
diff --git a/wpa_supplicant/preauth_test.c b/wpa_supplicant/preauth_test.c
index 6fe2906..cc86f62 100644
--- a/wpa_supplicant/preauth_test.c
+++ b/wpa_supplicant/preauth_test.c
@@ -119,6 +119,12 @@ void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
}
+void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
+ int reason_code)
+{
+}
+
+
u8 * wpa_alloc_eapol(const struct wpa_supplicant *wpa_s, const u8 *dest,
u16 proto, u8 type, const void *data, u16 data_len,
size_t *msg_len, void **data_pos)
@@ -154,6 +160,12 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state)
}
+wpa_states wpa_supplicant_get_state(struct wpa_supplicant *wpa_s)
+{
+ return wpa_s->wpa_state;
+}
+
+
int wpa_eapol_send(void *ctx, int type, u8 *buf, size_t len)
{
printf("%s - not implemented\n", __func__);
@@ -244,12 +256,12 @@ static void wpa_init_conf(struct wpa_supplicant *wpa_s, const char *ifname)
{
struct l2_packet_data *l2;
- wpa_s->proto = WPA_PROTO_RSN;
memset(&dummy_driver, 0, sizeof(dummy_driver));
wpa_s->driver = &dummy_driver;
wpa_s->wpa = wpa_sm_init(wpa_s);
assert(wpa_s->wpa != NULL);
+ wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_PROTO, WPA_PROTO_RSN);
strncpy(wpa_s->ifname, ifname, sizeof(wpa_s->ifname));
wpa_sm_set_ifname(wpa_s->wpa, wpa_s->ifname);
diff --git a/wpa_supplicant/wpa.c b/wpa_supplicant/wpa.c
index 95d57fd..1148720 100644
--- a/wpa_supplicant/wpa.c
+++ b/wpa_supplicant/wpa.c
@@ -1732,7 +1732,7 @@ static void wpa_supplicant_process_1_of_2(struct wpa_supplicant *wpa_s,
memset(&gd, 0, sizeof(gd));
- rekey = wpa_s->wpa_state == WPA_COMPLETED;
+ rekey = wpa_supplicant_get_state(wpa_s) == WPA_COMPLETED;
wpa_supplicant_set_state(wpa_s, WPA_GROUP_HANDSHAKE);
wpa_printf(MSG_DEBUG, "WPA: RX message 1 of Group Key Handshake from "
MACSTR " (ver=%d)", MAC2STR(src_addr), ver);
@@ -2106,17 +2106,16 @@ static const u8 * wpa_cipher_suite(struct wpa_sm *sm, int cipher)
#define RSN_SUITE_ARG(s) (s)[0], (s)[1], (s)[2], (s)[3]
/**
- * wpa_get_mib - Dump text list of MIB entries
- * @wpa_s: Pointer to wpa_supplicant data
+ * wpa_sm_get_mib - Dump text list of MIB entries
+ * @sm: Pointer to WPA state machine data from wpa_sm_init()
* @buf: Buffer for the list
* @buflen: Length of the buffer
* Returns: Number of bytes written to buffer
*
* This function is used fetch dot11 MIB variables.
*/
-int wpa_get_mib(struct wpa_supplicant *wpa_s, char *buf, size_t buflen)
+int wpa_sm_get_mib(struct wpa_sm *sm, char *buf, size_t buflen)
{
- struct wpa_sm *sm = wpa_s->wpa;
int len, i;
char pmkid_txt[PMKID_LEN * 2 + 1];
int rsna;
@@ -2173,7 +2172,7 @@ int wpa_get_mib(struct wpa_supplicant *wpa_s, char *buf, size_t buflen)
RSN_SUITE_ARG(wpa_cipher_suite(sm,
sm->pairwise_cipher)),
RSN_SUITE_ARG(wpa_cipher_suite(sm, sm->group_cipher)),
- wpa_s->dot11RSNA4WayHandshakeFailures);
+ sm->dot11RSNA4WayHandshakeFailures);
return len;
}
@@ -2249,6 +2248,8 @@ void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid)
void wpa_sm_notify_disassoc(struct wpa_sm *sm)
{
rsn_preauth_deinit(sm);
+ if (wpa_supplicant_get_state(sm->ctx) == WPA_4WAY_HANDSHAKE)
+ sm->dot11RSNA4WayHandshakeFailures++;
}
diff --git a/wpa_supplicant/wpa.h b/wpa_supplicant/wpa.h
index 67a93d1..af31783 100644
--- a/wpa_supplicant/wpa.h
+++ b/wpa_supplicant/wpa.h
@@ -142,6 +142,7 @@ void wpa_sm_set_scard_ctx(struct wpa_sm *sm, void *scard_ctx);
void wpa_sm_set_config(struct wpa_sm *sm, struct wpa_ssid *config);
void wpa_sm_set_own_addr(struct wpa_sm *sm, const u8 *addr);
void wpa_sm_set_ifname(struct wpa_sm *sm, const char *ifname);
+int wpa_sm_get_mib(struct wpa_sm *sm, char *buf, size_t buflen);
enum wpa_sm_conf_params {
RSNA_PMK_LIFETIME /* dot11RSNAConfigPMKLifetime */,
@@ -167,4 +168,24 @@ struct wpa_supplicant;
void wpa_supplicant_key_request(struct wpa_supplicant *wpa_s,
int error, int pairwise);
+
+struct wpa_ie_data {
+ int proto;
+ int pairwise_cipher;
+ int group_cipher;
+ int key_mgmt;
+ int capabilities;
+ int num_pmkid;
+ const u8 *pmkid;
+};
+
+int wpa_parse_wpa_ie(struct wpa_supplicant *wpa_s, const u8 *wpa_ie,
+ size_t wpa_ie_len, struct wpa_ie_data *data);
+
+int wpa_gen_wpa_ie(struct wpa_supplicant *wpa_s, u8 *wpa_ie,
+ size_t wpa_ie_len);
+
+int wpa_sm_rx_eapol(struct wpa_supplicant *wpa_s, unsigned char *src_addr,
+ unsigned char *buf, size_t len);
+
#endif /* WPA_H */
diff --git a/wpa_supplicant/wpa_i.h b/wpa_supplicant/wpa_i.h
index 903cf20..3fafe48 100644
--- a/wpa_supplicant/wpa_i.h
+++ b/wpa_supplicant/wpa_i.h
@@ -86,6 +86,8 @@ struct wpa_sm {
unsigned int dot11RSNAConfigPMKReauthThreshold;
unsigned int dot11RSNAConfigSATimeout;
+ unsigned int dot11RSNA4WayHandshakeFailures;
+
/* Selected configuration (based on Beacon/ProbeResp WPA IE) */
unsigned int proto;
unsigned int pairwise_cipher;
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index ece51e8..c7dff17 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -448,8 +448,7 @@ static void wpa_supplicant_timeout(void *eloop_ctx, void *timeout_ctx)
wpa_msg(wpa_s, MSG_INFO, "Authentication with " MACSTR " timed out.",
MAC2STR(wpa_s->bssid));
wpa_blacklist_add(wpa_s, wpa_s->bssid);
- if (wpa_s->wpa_state == WPA_4WAY_HANDSHAKE)
- wpa_s->dot11RSNA4WayHandshakeFailures++;
+ wpa_sm_notify_disassoc(wpa_s->wpa);
wpa_supplicant_disassociate(wpa_s, REASON_DEAUTH_LEAVING);
wpa_s->reassociate = 1;
wpa_supplicant_req_scan(wpa_s, 0, 0);
@@ -668,6 +667,12 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state)
}
+wpa_states wpa_supplicant_get_state(struct wpa_supplicant *wpa_s)
+{
+ return wpa_s->wpa_state;
+}
+
+
static void wpa_supplicant_terminate(int sig, void *eloop_ctx,
void *signal_ctx)
{
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index 2698d8f..227d4bb 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -105,8 +105,6 @@ struct wpa_supplicant {
int keys_cleared;
struct wpa_blacklist *blacklist;
-
- unsigned int dot11RSNA4WayHandshakeFailures;
};
@@ -132,6 +130,7 @@ struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
const char * wpa_supplicant_state_txt(int state);
void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state);
+wpa_states wpa_supplicant_get_state(struct wpa_supplicant *wpa_s);
int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s,
int wait_for_interface);
struct wpa_blacklist * wpa_blacklist_get(struct wpa_supplicant *wpa_s,
@@ -155,27 +154,6 @@ void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
int sec, int usec);
-struct wpa_ie_data {
- int proto;
- int pairwise_cipher;
- int group_cipher;
- int key_mgmt;
- int capabilities;
- int num_pmkid;
- const u8 *pmkid;
-};
-
-int wpa_parse_wpa_ie(struct wpa_supplicant *wpa_s, const u8 *wpa_ie,
- size_t wpa_ie_len, struct wpa_ie_data *data);
-
-int wpa_gen_wpa_ie(struct wpa_supplicant *wpa_s, u8 *wpa_ie,
- size_t wpa_ie_len);
-
-int wpa_sm_rx_eapol(struct wpa_supplicant *wpa_s, unsigned char *src_addr,
- unsigned char *buf, size_t len);
-
-int wpa_get_mib(struct wpa_supplicant *wpa_s, char *buf, size_t buflen);
-
u8 * wpa_alloc_eapol(const struct wpa_supplicant *wpa_s, const u8 *dest,
u16 proto, u8 type, const void *data, u16 data_len,
size_t *msg_len, void **data_pos);