aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2005-06-26 03:27:00 (GMT)
committerJouni Malinen <j@w1.fi>2005-06-26 03:27:00 (GMT)
commit03e5e948bbe4c41e700feb56991441e9436bfb49 (patch)
tree1db315d9b648a05c1b5778f04f00b1c03ba1a287
parent7b579f429aa2bb66cc47092049bff0fc3873b9ef (diff)
downloadhostap-history-03e5e948bbe4c41e700feb56991441e9436bfb49.zip
hostap-history-03e5e948bbe4c41e700feb56991441e9436bfb49.tar.gz
hostap-history-03e5e948bbe4c41e700feb56991441e9436bfb49.tar.bz2
Moved prototypes for core wpa_supplicant functions called from wpa.c
and preauth.c into a new header file, wpa_supplicant_s.h, so that wpa_supplicant_i.h is not included into wpa.c/preauth.c anymore. wpa_supplicant_s.h should be removed once the direct calls from wpa.c/preauth.c to core functions is cleaned up, e.g., by using registered callback function pointers. If some of the direct calls remain, the prototypes for these functions should be moved to wpa_supplicant.h.
-rw-r--r--wpa_supplicant/preauth.c12
-rw-r--r--wpa_supplicant/preauth_test.c33
-rw-r--r--wpa_supplicant/wpa.c28
-rw-r--r--wpa_supplicant/wpa_supplicant.c31
-rw-r--r--wpa_supplicant/wpa_supplicant_i.h31
-rw-r--r--wpa_supplicant/wpa_supplicant_s.h63
6 files changed, 149 insertions, 49 deletions
diff --git a/wpa_supplicant/preauth.c b/wpa_supplicant/preauth.c
index 20acda5..431074d 100644
--- a/wpa_supplicant/preauth.c
+++ b/wpa_supplicant/preauth.c
@@ -30,7 +30,7 @@
#include "config.h"
#include "l2_packet.h"
#include "eapol_sm.h"
-#include "wpa_supplicant_i.h"
+#include "wpa_supplicant_s.h"
#include "preauth.h"
#include "wpa_i.h"
@@ -220,7 +220,7 @@ pmksa_cache_add(struct wpa_sm *sm, const u8 *pmk,
wpa_printf(MSG_DEBUG, "RSN: removed the oldest PMKSA cache "
"entry (for " MACSTR ") to make room for new one",
MAC2STR(pos->aa));
- wpa_drv_remove_pmkid(sm->ctx, pos->aa, pos->pmkid);
+ wpa_supplicant_remove_pmkid(sm->ctx, pos->aa, pos->pmkid);
pmksa_cache_free_entry(sm, pos);
}
@@ -244,7 +244,7 @@ pmksa_cache_add(struct wpa_sm *sm, const u8 *pmk,
sm->pmksa_count++;
wpa_printf(MSG_DEBUG, "RSN: added PMKSA cache entry for " MACSTR,
MAC2STR(entry->aa));
- wpa_drv_add_pmkid(sm->ctx, entry->aa, entry->pmkid);
+ wpa_supplicant_add_pmkid(sm->ctx, entry->aa, entry->pmkid);
return entry;
}
@@ -730,8 +730,10 @@ void rsn_preauth_candidate_process(struct wpa_sm *sm)
MAC2STR(candidate->bssid));
/* Some drivers (e.g., NDIS) expect to get notified about the
* PMKIDs again, so report the existing data now. */
- if (p)
- wpa_drv_add_pmkid(sm->ctx, candidate->bssid, p->pmkid);
+ if (p) {
+ wpa_supplicant_add_pmkid(sm->ctx, candidate->bssid,
+ p->pmkid);
+ }
sm->pmksa_candidates = candidate->next;
free(candidate);
diff --git a/wpa_supplicant/preauth_test.c b/wpa_supplicant/preauth_test.c
index bbfa18e..55dbc40 100644
--- a/wpa_supplicant/preauth_test.c
+++ b/wpa_supplicant/preauth_test.c
@@ -199,6 +199,39 @@ void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
}
+int wpa_supplicant_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
+{
+ printf("%s - not implemented\n", __func__);
+ return -1;
+}
+
+
+int wpa_supplicant_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg,
+ const u8 *addr, int key_idx, int set_tx,
+ const u8 *seq, size_t seq_len,
+ const u8 *key, size_t key_len)
+{
+ printf("%s - not implemented\n", __func__);
+ return -1;
+}
+
+
+int wpa_supplicant_add_pmkid(struct wpa_supplicant *wpa_s,
+ const u8 *bssid, const u8 *pmkid)
+{
+ printf("%s - not implemented\n", __func__);
+ return -1;
+}
+
+
+int wpa_supplicant_remove_pmkid(struct wpa_supplicant *wpa_s,
+ const u8 *bssid, const u8 *pmkid)
+{
+ printf("%s - not implemented\n", __func__);
+ return -1;
+}
+
+
static void test_eapol_clean(struct wpa_supplicant *wpa_s)
{
rsn_preauth_deinit(wpa_s->wpa);
diff --git a/wpa_supplicant/wpa.c b/wpa_supplicant/wpa.c
index 1bf663f..45526d5 100644
--- a/wpa_supplicant/wpa.c
+++ b/wpa_supplicant/wpa.c
@@ -31,7 +31,7 @@
#include "config.h"
#include "l2_packet.h"
#include "eapol_sm.h"
-#include "wpa_supplicant_i.h"
+#include "wpa_supplicant_s.h"
#include "preauth.h"
#include "wpa_i.h"
@@ -770,7 +770,7 @@ void wpa_sm_key_request(struct wpa_sm *sm, int error, int pairwise)
else
ver = WPA_KEY_INFO_TYPE_HMAC_MD5_RC4;
- if (wpa_drv_get_bssid(sm->ctx, bssid) < 0) {
+ if (wpa_supplicant_get_bssid(sm->ctx, bssid) < 0) {
wpa_printf(MSG_WARNING, "Failed to read BSSID for EAPOL-Key "
"request");
return;
@@ -1186,8 +1186,8 @@ static int wpa_supplicant_install_ptk(struct wpa_sm *sm,
wpa_hexdump(MSG_DEBUG, "WPA: RSC", key_rsc, rsclen);
}
- if (wpa_drv_set_key(sm->ctx, alg, src_addr, 0, 1, key_rsc, rsclen,
- (u8 *) &sm->ptk.tk1, keylen) < 0) {
+ if (wpa_supplicant_set_key(sm->ctx, alg, src_addr, 0, 1, key_rsc,
+ rsclen, (u8 *) &sm->ptk.tk1, keylen) < 0) {
wpa_printf(MSG_WARNING, "WPA: Failed to set PTK to the "
"driver.");
return -1;
@@ -1277,18 +1277,20 @@ static int wpa_supplicant_install_gtk(struct wpa_sm *sm,
_gtk = gtk_buf;
}
if (sm->pairwise_cipher == WPA_CIPHER_NONE) {
- if (wpa_drv_set_key(sm->ctx, gd->alg,
- (u8 *) "\xff\xff\xff\xff\xff\xff",
- gd->keyidx, 1, key_rsc, gd->key_rsc_len,
- _gtk, gd->gtk_len) < 0) {
+ if (wpa_supplicant_set_key(sm->ctx, gd->alg,
+ (u8 *) "\xff\xff\xff\xff\xff\xff",
+ gd->keyidx, 1, key_rsc,
+ gd->key_rsc_len, _gtk, gd->gtk_len)
+ < 0) {
wpa_printf(MSG_WARNING, "WPA: Failed to set "
"GTK to the driver (Group only).");
return -1;
}
- } else if (wpa_drv_set_key(sm->ctx, gd->alg,
- (u8 *) "\xff\xff\xff\xff\xff\xff",
- gd->keyidx, gd->tx, key_rsc,
- gd->key_rsc_len, _gtk, gd->gtk_len) < 0) {
+ } else if (wpa_supplicant_set_key(sm->ctx, gd->alg,
+ (u8 *) "\xff\xff\xff\xff\xff\xff",
+ gd->keyidx, gd->tx, key_rsc,
+ gd->key_rsc_len, _gtk, gd->gtk_len) <
+ 0) {
wpa_printf(MSG_WARNING, "WPA: Failed to set GTK to "
"the driver.");
return -1;
@@ -1888,8 +1890,6 @@ int wpa_sm_rx_eapol(struct wpa_sm *sm, const unsigned char *src_addr,
wpa_printf(MSG_DEBUG, "IEEE 802.1X RX: version=%d type=%d length=%lu",
hdr->version, hdr->type, (unsigned long) plen);
- wpa_drv_poll(sm->ctx);
-
if (hdr->version < EAPOL_VERSION) {
/* TODO: backwards compatibility */
}
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index c8486c3..6c94202 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -1371,6 +1371,36 @@ struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s)
}
+int wpa_supplicant_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
+{
+ return wpa_drv_get_bssid(wpa_s, bssid);
+}
+
+
+int wpa_supplicant_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg,
+ const u8 *addr, int key_idx, int set_tx,
+ const u8 *seq, size_t seq_len,
+ const u8 *key, size_t key_len)
+{
+ return wpa_drv_set_key(wpa_s, alg, addr, key_idx, set_tx, seq, seq_len,
+ key, key_len);
+}
+
+
+int wpa_supplicant_add_pmkid(struct wpa_supplicant *wpa_s,
+ const u8 *bssid, const u8 *pmkid)
+{
+ return wpa_drv_add_pmkid(wpa_s, bssid, pmkid);
+}
+
+
+int wpa_supplicant_remove_pmkid(struct wpa_supplicant *wpa_s,
+ const u8 *bssid, const u8 *pmkid)
+{
+ return wpa_drv_remove_pmkid(wpa_s, bssid, pmkid);
+}
+
+
static int wpa_supplicant_set_driver(struct wpa_supplicant *wpa_s,
const char *name)
{
@@ -1461,6 +1491,7 @@ void wpa_supplicant_rx_eapol(void *ctx, unsigned char *src_addr,
if (wpa_s->key_mgmt != WPA_KEY_MGMT_PSK &&
eapol_sm_rx_eapol(wpa_s->eapol, src_addr, buf, len) > 0)
return;
+ wpa_drv_poll(wpa_s);
wpa_sm_rx_eapol(wpa_s->wpa, src_addr, buf, len);
}
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index a89d100..374550a 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -16,6 +16,7 @@
#define WPA_SUPPLICANT_I_H
#include "driver.h"
+#include "wpa_supplicant_s.h"
struct wpa_blacklist {
struct wpa_blacklist *next;
@@ -24,13 +25,6 @@ struct wpa_blacklist {
};
-typedef enum {
- WPA_DISCONNECTED, WPA_SCANNING, WPA_ASSOCIATING,
- WPA_ASSOCIATED, WPA_4WAY_HANDSHAKE, WPA_GROUP_HANDSHAKE,
- WPA_COMPLETED
-} wpa_states;
-
-
struct wpa_scan_result;
struct wpa_sm;
@@ -105,28 +99,11 @@ struct wpa_supplicant {
/* wpa_supplicant.c */
-void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx);
-
-void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
-
void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
-void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
- int reason_code);
-void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
- int reason_code);
-
-void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
-
int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
-int wpa_supplicant_get_beacon_ie(struct wpa_supplicant *wpa_s);
-
-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,
@@ -150,12 +127,6 @@ void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
int sec, int usec);
-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);
-int wpa_ether_send(struct wpa_supplicant *wpa_s, u8 *buf, size_t len);
-
-
/* driver_ops */
static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s,
const char *ifname)
diff --git a/wpa_supplicant/wpa_supplicant_s.h b/wpa_supplicant/wpa_supplicant_s.h
new file mode 100644
index 0000000..bf35842
--- /dev/null
+++ b/wpa_supplicant/wpa_supplicant_s.h
@@ -0,0 +1,63 @@
+/*
+ * wpa_supplicant - Semi-internal definitions
+ * Copyright (c) 2003-2005, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ * See README and COPYING for more details.
+ *
+ * These definitions are currently shared between the core wpa_supplicant code
+ * and WPA state machines. These will likely be replaced with something cleaner
+ * (e.g., registered callback functions) to get rid of direct function calls
+ * from wpa.c/preauth.c to core wpa_supplicant code.
+ */
+
+#ifndef WPA_SUPPLICANT_S_H
+#define WPA_SUPPLICANT_S_H
+
+typedef enum {
+ WPA_DISCONNECTED, WPA_SCANNING, WPA_ASSOCIATING,
+ WPA_ASSOCIATED, WPA_4WAY_HANDSHAKE, WPA_GROUP_HANDSHAKE,
+ WPA_COMPLETED
+} wpa_states;
+
+void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state);
+wpa_states wpa_supplicant_get_state(struct wpa_supplicant *wpa_s);
+
+
+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);
+int wpa_ether_send(struct wpa_supplicant *wpa_s, u8 *buf, size_t len);
+
+int wpa_supplicant_get_beacon_ie(struct wpa_supplicant *wpa_s);
+
+struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
+
+void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
+
+void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
+ int reason_code);
+void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
+ int reason_code);
+
+void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx);
+
+void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
+
+int wpa_supplicant_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid);
+int wpa_supplicant_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg,
+ const u8 *addr, int key_idx, int set_tx,
+ const u8 *seq, size_t seq_len,
+ const u8 *key, size_t key_len);
+int wpa_supplicant_add_pmkid(struct wpa_supplicant *wpa_s,
+ const u8 *bssid, const u8 *pmkid);
+int wpa_supplicant_remove_pmkid(struct wpa_supplicant *wpa_s,
+ const u8 *bssid, const u8 *pmkid);
+
+#endif /* WPA_SUPPLICANT_S_H */