[RESEND][PATCH] code cleanup
Leonardo Maccari
maccari-thisaintpartofmyaddress-
Wed Aug 17 00:47:57 PDT 2005
On Tue, Jul 12, 2005 at 10:54:04AM +0200, Leonardo Maccari wrote:
I resend the patch, waiting for some feedback on it.
ciao,
leonardo.
-------------- next part --------------
Common subdirectories: wpa_supplicant-0.4.3/doc and wpa_supplicant-0.4.3-dev/doc
diff -u -x cscope.out -x tags -x '*swp' -N wpa_supplicant-0.4.3/preauth.c wpa_supplicant-0.4.3-dev/preauth.c
--- wpa_supplicant-0.4.3/preauth.c 2005-06-26 05:27:00.000000000 +0200
+++ wpa_supplicant-0.4.3-dev/preauth.c 2005-07-11 14:59:05.000000000 +0200
@@ -30,7 +30,6 @@
#include "config.h"
#include "l2_packet.h"
#include "eapol_sm.h"
-#include "wpa_supplicant_s.h"
#include "preauth.h"
#include "wpa_i.h"
@@ -90,8 +89,8 @@
wpa_printf(MSG_DEBUG, "RSN: removed current PMKSA entry");
sm->cur_pmksa = NULL;
memset(sm->pmk, 0, sizeof(sm->pmk));
- wpa_supplicant_deauthenticate(sm->ctx, REASON_UNSPECIFIED);
- wpa_supplicant_req_scan(sm->ctx, 0, 0);
+ sm->preauth_i->deauthenticate(sm->ctx, REASON_UNSPECIFIED);
+ sm->preauth_i->req_scan(sm->ctx, 0, 0);
}
}
@@ -220,7 +219,7 @@
wpa_printf(MSG_DEBUG, "RSN: removed the oldest PMKSA cache "
"entry (for " MACSTR ") to make room for new one",
MAC2STR(pos->aa));
- wpa_supplicant_remove_pmkid(sm->ctx, pos->aa, pos->pmkid);
+ sm->preauth_i->remove_pmkid(sm->ctx, pos->aa, pos->pmkid);
pmksa_cache_free_entry(sm, pos);
}
@@ -244,7 +243,7 @@
sm->pmksa_count++;
wpa_printf(MSG_DEBUG, "RSN: added PMKSA cache entry for " MACSTR,
MAC2STR(entry->aa));
- wpa_supplicant_add_pmkid(sm->ctx, entry->aa, entry->pmkid);
+ sm->preauth_i->add_pmkid(sm->ctx, entry->aa, entry->pmkid);
return entry;
}
@@ -567,7 +566,7 @@
if (sm->l2_preauth == NULL)
return -1;
- msg = wpa_alloc_eapol(sm->ctx, sm->preauth_bssid, ETH_P_RSN_PREAUTH,
+ msg = sm->preauth_i->alloc_eapol(sm->ctx, sm->preauth_bssid, ETH_P_RSN_PREAUTH,
type, buf, len, &msglen, NULL);
if (msg == NULL)
return -1;
@@ -704,7 +703,7 @@
wpa_msg(sm->ctx, MSG_DEBUG, "RSN: processing PMKSA candidate list");
if (sm->preauth_eapol ||
sm->proto != WPA_PROTO_RSN ||
- wpa_supplicant_get_state(sm->ctx) != WPA_COMPLETED ||
+ sm->preauth_i->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");
@@ -731,7 +730,7 @@
/* Some drivers (e.g., NDIS) expect to get notified about the
* PMKIDs again, so report the existing data now. */
if (p) {
- wpa_supplicant_add_pmkid(sm->ctx, candidate->bssid,
+ sm->preauth_i->add_pmkid(sm->ctx, candidate->bssid,
p->pmkid);
}
diff -u -x cscope.out -x tags -x '*swp' -N wpa_supplicant-0.4.3/wpa.c wpa_supplicant-0.4.3-dev/wpa.c
--- wpa_supplicant-0.4.3/wpa.c 2005-06-26 05:27:00.000000000 +0200
+++ wpa_supplicant-0.4.3-dev/wpa.c 2005-07-11 15:15:01.000000000 +0200
@@ -31,7 +31,6 @@
#include "config.h"
#include "l2_packet.h"
#include "eapol_sm.h"
-#include "wpa_supplicant_s.h"
#include "preauth.h"
#include "wpa_i.h"
@@ -741,7 +740,7 @@
key_mic);
}
wpa_hexdump(MSG_MSGDUMP, "WPA: TX EAPOL-Key", msg, msg_len);
- wpa_ether_send(sm->ctx, msg, msg_len);
+ sm->wpa_sm_i->ether_send(sm->ctx, msg, msg_len);
eapol_sm_notify_tx_eapol_key(sm->eapol);
free(msg);
}
@@ -770,13 +769,13 @@
else
ver = WPA_KEY_INFO_TYPE_HMAC_MD5_RC4;
- if (wpa_supplicant_get_bssid(sm->ctx, bssid) < 0) {
+ if (sm->wpa_sm_i->get_bssid(sm->ctx, bssid) < 0) {
wpa_printf(MSG_WARNING, "Failed to read BSSID for EAPOL-Key "
"request");
return;
}
- rbuf = wpa_alloc_eapol(sm->ctx, bssid, ETH_P_EAPOL,
+ rbuf = sm->wpa_sm_i->alloc_eapol(sm->ctx, bssid, ETH_P_EAPOL,
IEEE802_1X_TYPE_EAPOL_KEY, NULL, sizeof(*reply),
&rlen, (void *) &reply);
if (rbuf == NULL)
@@ -977,11 +976,11 @@
wpa_printf(MSG_DEBUG, "RSN: no PMKSA entry found - trigger "
"full EAP authentication");
- buf = wpa_alloc_eapol(sm->ctx, sm->bssid, ETH_P_EAPOL,
+ buf = sm->wpa_sm_i->alloc_eapol(sm->ctx, sm->bssid, ETH_P_EAPOL,
IEEE802_1X_TYPE_EAPOL_START, NULL, 0,
&buflen, NULL);
if (buf) {
- wpa_ether_send(sm->ctx, buf, buflen);
+ sm->wpa_sm_i->ether_send(sm->ctx, buf, buflen);
free(buf);
}
@@ -1013,7 +1012,7 @@
wpa_ie_len = sm->assoc_wpa_ie_len;
wpa_hexdump(MSG_DEBUG, "WPA: WPA IE for msg 2/4", wpa_ie, wpa_ie_len);
- rbuf = wpa_alloc_eapol(sm->ctx, src_addr, ETH_P_EAPOL,
+ rbuf = sm->wpa_sm_i->alloc_eapol(sm->ctx, src_addr, ETH_P_EAPOL,
IEEE802_1X_TYPE_EAPOL_KEY, NULL,
sizeof(*reply) + wpa_ie_len,
&rlen, (void *) &reply);
@@ -1073,13 +1072,13 @@
{
struct wpa_eapol_ie_parse ie;
- if (wpa_supplicant_get_ssid(sm->ctx) == NULL) {
+ if (sm->wpa_sm_i->get_ssid(sm->ctx) == NULL) {
wpa_printf(MSG_WARNING, "WPA: No SSID info found (msg 1 of "
"4).");
return;
}
- wpa_supplicant_set_state(sm->ctx, WPA_4WAY_HANDSHAKE);
+ sm->wpa_sm_i->set_state(sm->ctx, WPA_4WAY_HANDSHAKE);
wpa_printf(MSG_DEBUG, "WPA: RX message 1 of 4-Way Handshake from "
MACSTR " (ver=%d)", MAC2STR(src_addr), ver);
@@ -1121,9 +1120,9 @@
MACSTR " [PTK=%s GTK=%s]", MAC2STR(addr),
wpa_cipher_txt(sm->pairwise_cipher),
wpa_cipher_txt(sm->group_cipher));
- eloop_cancel_timeout(wpa_supplicant_scan, sm->ctx, NULL);
- wpa_supplicant_cancel_auth_timeout(sm->ctx);
- wpa_supplicant_set_state(sm->ctx, WPA_COMPLETED);
+ eloop_cancel_timeout(sm->wpa_sm_i->scan, sm->ctx, NULL);
+ sm->wpa_sm_i->cancel_auth_timeout(sm->ctx);
+ sm->wpa_sm_i->set_state(sm->ctx, WPA_COMPLETED);
if (secure) {
/* MLME.SETPROTECTION.request(TA, Tx_Rx) */
@@ -1186,7 +1185,7 @@
wpa_hexdump(MSG_DEBUG, "WPA: RSC", key_rsc, rsclen);
}
- if (wpa_supplicant_set_key(sm->ctx, alg, src_addr, 0, 1, key_rsc,
+ if (sm->wpa_sm_i->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.");
@@ -1277,7 +1276,7 @@
_gtk = gtk_buf;
}
if (sm->pairwise_cipher == WPA_CIPHER_NONE) {
- if (wpa_supplicant_set_key(sm->ctx, gd->alg,
+ if (sm->wpa_sm_i->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)
@@ -1286,7 +1285,7 @@
"GTK to the driver (Group only).");
return -1;
}
- } else if (wpa_supplicant_set_key(sm->ctx, gd->alg,
+ } else if (sm->wpa_sm_i->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) <
@@ -1397,8 +1396,8 @@
rsn_ie, rsn_ie_len);
}
- wpa_supplicant_disassociate(sm->ctx, REASON_IE_IN_4WAY_DIFFERS);
- wpa_supplicant_req_scan(sm->ctx, 0, 0);
+ sm->wpa_sm_i->disassociate(sm->ctx, REASON_IE_IN_4WAY_DIFFERS);
+ sm->wpa_sm_i->req_scan(sm->ctx, 0, 0);
}
@@ -1411,7 +1410,7 @@
if (sm->ap_wpa_ie == NULL && sm->ap_rsn_ie == NULL) {
wpa_printf(MSG_DEBUG, "WPA: No WPA/RSN IE for this AP known. "
"Trying to get from scan results");
- if (wpa_supplicant_get_beacon_ie(sm->ctx) < 0) {
+ if (sm->wpa_sm_i->get_beacon_ie(sm->ctx) < 0) {
wpa_printf(MSG_WARNING, "WPA: Could not find AP from "
"the scan results");
} else {
@@ -1458,7 +1457,7 @@
struct wpa_eapol_key *reply;
u8 *rbuf;
- rbuf = wpa_alloc_eapol(sm->ctx, src_addr, ETH_P_EAPOL,
+ rbuf = sm->wpa_sm_i->alloc_eapol(sm->ctx, src_addr, ETH_P_EAPOL,
IEEE802_1X_TYPE_EAPOL_KEY, NULL,
sizeof(*reply), &rlen, (void *) &reply);
if (rbuf == NULL)
@@ -1495,7 +1494,7 @@
const u8 *pos;
struct wpa_eapol_ie_parse ie;
- wpa_supplicant_set_state(sm->ctx, WPA_4WAY_HANDSHAKE);
+ sm->wpa_sm_i->set_state(sm->ctx, WPA_4WAY_HANDSHAKE);
wpa_printf(MSG_DEBUG, "WPA: RX message 3 of 4-Way Handshake from "
MACSTR " (ver=%d)", MAC2STR(src_addr), ver);
@@ -1556,7 +1555,7 @@
/* MLME.SETPROTECTION.request(TA, Tx_Rx) */
eapol_sm_notify_portValid(sm->eapol, TRUE);
}
- wpa_supplicant_set_state(sm->ctx, WPA_GROUP_HANDSHAKE);
+ sm->wpa_sm_i->set_state(sm->ctx, WPA_GROUP_HANDSHAKE);
if (ie.gtk &&
wpa_supplicant_pairwise_gtk(sm, src_addr, key,
@@ -1674,7 +1673,7 @@
struct wpa_eapol_key *reply;
u8 *rbuf;
- rbuf = wpa_alloc_eapol(sm->ctx, src_addr, ETH_P_EAPOL,
+ rbuf = sm->wpa_sm_i->alloc_eapol(sm->ctx, src_addr, ETH_P_EAPOL,
IEEE802_1X_TYPE_EAPOL_KEY, NULL,
sizeof(*reply), &rlen, (void *) &reply);
if (rbuf == NULL)
@@ -1713,8 +1712,8 @@
memset(&gd, 0, sizeof(gd));
- rekey = wpa_supplicant_get_state(sm->ctx) == WPA_COMPLETED;
- wpa_supplicant_set_state(sm->ctx, WPA_GROUP_HANDSHAKE);
+ rekey = sm->wpa_sm_i->get_state(sm->ctx) == WPA_COMPLETED;
+ sm->wpa_sm_i->set_state(sm->ctx, WPA_GROUP_HANDSHAKE);
wpa_printf(MSG_DEBUG, "WPA: RX message 1 of Group Key Handshake from "
MACSTR " (ver=%d)", MAC2STR(src_addr), ver);
@@ -1742,7 +1741,7 @@
wpa_msg(sm->ctx, MSG_INFO, "WPA: Group rekeying completed "
"with " MACSTR " [GTK=%s]", MAC2STR(src_addr),
wpa_cipher_txt(sm->group_cipher));
- wpa_supplicant_set_state(sm->ctx, WPA_COMPLETED);
+ sm->wpa_sm_i->set_state(sm->ctx, WPA_COMPLETED);
} else {
wpa_supplicant_key_neg_complete(sm, src_addr,
key_info &
@@ -2163,7 +2162,7 @@
* This function is used to allocate a new WPA state machine and the returned
* value is passed to all WPA state machine calls.
*/
-struct wpa_sm * wpa_sm_init(void *ctx)
+struct wpa_sm * wpa_sm_init(void *ctx, struct wpa_sm_interface * wpa_sm_i, struct preauth_interface * preauth_i)
{
struct wpa_sm *sm;
@@ -2173,6 +2172,8 @@
memset(sm, 0, sizeof(*sm));
sm->renew_snonce = 1;
sm->ctx = ctx;
+ sm->wpa_sm_i = wpa_sm_i;
+ sm->preauth_i = preauth_i;
sm->dot11RSNAConfigPMKLifetime = 43200;
sm->dot11RSNAConfigPMKReauthThreshold = 70;
@@ -2192,6 +2193,8 @@
free(sm->assoc_wpa_ie);
free(sm->ap_wpa_ie);
free(sm->ap_rsn_ie);
+ free(sm->wpa_sm_i);
+ free(sm->preauth_i);
free(sm);
}
@@ -2229,7 +2232,7 @@
void wpa_sm_notify_disassoc(struct wpa_sm *sm)
{
rsn_preauth_deinit(sm);
- if (wpa_supplicant_get_state(sm->ctx) == WPA_4WAY_HANDSHAKE)
+ if (sm->wpa_sm_i->get_state(sm->ctx) == WPA_4WAY_HANDSHAKE)
sm->dot11RSNA4WayHandshakeFailures++;
}
Common subdirectories: wpa_supplicant-0.4.3/wpa_gui and wpa_supplicant-0.4.3-dev/wpa_gui
diff -u -x cscope.out -x tags -x '*swp' -N wpa_supplicant-0.4.3/wpa.h wpa_supplicant-0.4.3-dev/wpa.h
--- wpa_supplicant-0.4.3/wpa.h 2005-06-26 04:58:29.000000000 +0200
+++ wpa_supplicant-0.4.3-dev/wpa.h 2005-07-11 15:00:36.000000000 +0200
@@ -131,8 +131,10 @@
struct wpa_sm;
struct wpa_ssid;
struct eapol_sm;
+struct wpa_sm_interface;
+struct preauth_interface;
-struct wpa_sm * wpa_sm_init(void *ctx);
+struct wpa_sm * wpa_sm_init(void *ctx, struct wpa_sm_interface *wpa_sm_i, struct preauth_interface *preauth_i);
void wpa_sm_deinit(struct wpa_sm *sm);
void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid);
void wpa_sm_notify_disassoc(struct wpa_sm *sm);
@@ -189,4 +191,11 @@
unsigned char *buf, size_t len);
int wpa_sm_parse_own_wpa_ie(struct wpa_sm *sm, struct wpa_ie_data *data);
+typedef enum {
+ WPA_DISCONNECTED, WPA_SCANNING, WPA_ASSOCIATING,
+ WPA_ASSOCIATED, WPA_4WAY_HANDSHAKE, WPA_GROUP_HANDSHAKE,
+ WPA_COMPLETED
+} wpa_states;
+
+
#endif /* WPA_H */
diff -u -x cscope.out -x tags -x '*swp' -N wpa_supplicant-0.4.3/wpa_i.h wpa_supplicant-0.4.3-dev/wpa_i.h
--- wpa_supplicant-0.4.3/wpa_i.h 2005-06-26 04:58:29.000000000 +0200
+++ wpa_supplicant-0.4.3-dev/wpa_i.h 2005-07-11 15:09:46.000000000 +0200
@@ -45,6 +45,45 @@
int opportunistic;
};
+struct wpa_sm_interface {
+ void (*set_state)(void *ctx, wpa_states state);
+ wpa_states (*get_state)(void *ctx);
+ void (*req_scan)(void *ctx , int sec, int usec);
+ void (*disassociate)(void *ctx,
+ int reason_code);
+ int (*set_key)(void *ctx, 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);
+ void (*scan)(void *eloop_ctx, void *timeout_ctx);
+ struct wpa_ssid * (*get_ssid)(void *ctx);
+ int (*get_bssid)(void *ctx, u8 *bssid);
+ int (*ether_send)(void *ctx, u8 *buf, size_t len);
+ int (*get_beacon_ie)(void *ctx);
+ void (*cancel_auth_timeout)(void *ctx);
+ u8 * (*alloc_eapol)(void * ctx, const u8 *dest,
+ u16 proto, u8 type, const void *data, u16 data_len,
+ size_t *msg_len, void **data_pos); /*preauth.c*/
+
+
+};
+
+struct preauth_interface {
+
+ wpa_states (*get_state)(void * ctx);
+ void (*deauthenticate)(void * ctx, int reason_code);
+ void (*req_scan)(void * ctx, int sec, int usec);
+
+ u8 * (*alloc_eapol)(void * ctx, const u8 *dest,
+ u16 proto, u8 type, const void *data, u16 data_len,
+ size_t *msg_len, void **data_pos);
+
+ int (*add_pmkid)(void * ctx, const u8 *bssid, const u8
+ *pmkid);
+ int (*remove_pmkid)(void * ctx, const u8 *bssid, const
+ u8 *pmkid);
+};
+
/**
* struct wpa_sm - Internal WPA state machine data
@@ -75,6 +114,14 @@
struct eapol_sm *preauth_eapol;
void *ctx; /* default context for callbacks */
+
+ struct wpa_sm_interface *wpa_sm_i; /* structure with pointers to
+ callback functions to interface
+ wpa state machine code*/
+ struct preauth_interface *preauth_i; /* structure with pointers to
+ callback functions to interface
+ preauth code*/
+
void *scard_ctx; /* context for smartcard callbacks */
int fast_reauth; /* whether EAP fast re-authentication is enabled */
@@ -102,4 +149,5 @@
size_t ap_wpa_ie_len, ap_rsn_ie_len;
};
+
#endif /* WPA_I_H */
diff -u -x cscope.out -x tags -x '*swp' -N wpa_supplicant-0.4.3/wpa_supplicant.c wpa_supplicant-0.4.3-dev/wpa_supplicant.c
--- wpa_supplicant-0.4.3/wpa_supplicant.c 2005-06-26 20:34:34.000000000 +0200
+++ wpa_supplicant-0.4.3-dev/wpa_supplicant.c 2005-07-12 10:46:24.000000000 +0200
@@ -107,6 +107,7 @@
extern int wpa_debug_show_keys;
extern int wpa_debug_timestamp;
+void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx);
void wpa_msg(struct wpa_supplicant *wpa_s, int level, char *fmt, ...)
{
@@ -1611,6 +1612,72 @@
const char *confname, *driver, *ifname;
};
+struct wpa_sm_interface {
+ void (*set_state)(struct wpa_supplicant *wpa_s, wpa_states state);
+ wpa_states (*get_state)(struct wpa_supplicant *wpa_s);
+ void (*req_scan)(struct wpa_supplicant *wpa_s, int sec, int usec);
+ void (*disassociate)(struct wpa_supplicant *wpa_s,
+ int reason_code);
+ int (*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);
+ void (*scan)(void *eloop_ctx, void *timeout_ctx);
+ struct wpa_ssid * (*get_ssid)(struct wpa_supplicant *wpa_s);
+ int (*get_bssid)(struct wpa_supplicant *wpa_s, u8 *bssid);
+ int (*ether_send)(struct wpa_supplicant *wpa_s, u8 *buf, size_t len);
+ int (*get_beacon_ie)(struct wpa_supplicant *wpa_s);
+ void (*cancel_auth_timeout)(struct wpa_supplicant *wpa_s);
+ u8 * (*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);
+};
+
+
+struct preauth_interface {
+
+ wpa_states (*get_state)(struct wpa_supplicant *wpa_s);
+ void (*deauthenticate)(struct wpa_supplicant *wpa_s, int reason_code);
+ void (*req_scan)(struct wpa_supplicant *wpa_s, int sec, int usec);
+
+ u8 * (*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 (*add_pmkid)(struct wpa_supplicant *wpa_s, const u8 *bssid, const u8
+ *pmkid);
+ int (*remove_pmkid)(struct wpa_supplicant *wpa_s, const u8 *bssid, const
+ u8 *pmkid);
+};
+
+
+void export_wpa_interface(struct wpa_sm_interface * wpa_sm_i){
+
+ wpa_sm_i->set_state = wpa_supplicant_set_state;
+ wpa_sm_i->get_state = wpa_supplicant_get_state;
+ wpa_sm_i->req_scan = wpa_supplicant_req_scan;
+ wpa_sm_i->disassociate = wpa_supplicant_disassociate;
+ wpa_sm_i->set_key = wpa_supplicant_set_key;
+ wpa_sm_i->scan = wpa_supplicant_scan;
+ wpa_sm_i->get_ssid = wpa_supplicant_get_ssid;
+ wpa_sm_i->ether_send = wpa_ether_send;
+ wpa_sm_i->get_beacon_ie = wpa_supplicant_get_beacon_ie;
+ wpa_sm_i->alloc_eapol = wpa_alloc_eapol;
+ wpa_sm_i->cancel_auth_timeout = wpa_supplicant_cancel_auth_timeout;
+}
+
+void export_preauth_interface(struct preauth_interface * preauth_i){
+
+ preauth_i->get_state = wpa_supplicant_get_state;
+ preauth_i->deauthenticate = wpa_supplicant_deauthenticate;
+ preauth_i->req_scan = wpa_supplicant_req_scan;
+ preauth_i->alloc_eapol = wpa_alloc_eapol;
+ preauth_i->add_pmkid = wpa_supplicant_add_pmkid;
+ preauth_i->remove_pmkid = wpa_supplicant_remove_pmkid;
+}
+
+
+
static int wpa_supplicant_init(struct wpa_supplicant *wpa_s,
struct wpa_interface *iface)
@@ -1667,6 +1734,8 @@
{
const char *ifname;
struct eapol_ctx *ctx;
+ struct wpa_sm_interface *wpa_sm_i;
+ struct preauth_interface *preauth_i;
wpa_printf(MSG_DEBUG, "Initializing interface (2) '%s'",
wpa_s->ifname);
@@ -1720,7 +1789,13 @@
strncpy(wpa_s->ifname, ifname, sizeof(wpa_s->ifname));
}
- wpa_s->wpa = wpa_sm_init(wpa_s);
+ wpa_sm_i = malloc(sizeof(struct wpa_sm_interface));
+ preauth_i = malloc(sizeof(struct preauth_interface));
+
+ export_wpa_interface(wpa_sm_i);
+ export_preauth_interface(preauth_i);
+
+ wpa_s->wpa = wpa_sm_init(wpa_s, wpa_sm_i, preauth_i);
if (wpa_s->wpa == NULL) {
fprintf(stderr, "Failed to initialize WPA state machine\n");
return -1;
diff -u -x cscope.out -x tags -x '*swp' -N wpa_supplicant-0.4.3/wpa_supplicant_s.h wpa_supplicant-0.4.3-dev/wpa_supplicant_s.h
--- wpa_supplicant-0.4.3/wpa_supplicant_s.h 2005-07-08 16:47:20.000000000 +0200
+++ wpa_supplicant-0.4.3-dev/wpa_supplicant_s.h 2005-07-08 16:48:50.000000000 +0200
@@ -20,44 +20,18 @@
#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); /* needed by events.c*/
-void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state);
-wpa_states wpa_supplicant_get_state(struct wpa_supplicant *wpa_s);
+struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s); /* needed by events.c*/
+void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s); /* needed by events.c*/
-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);
+void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
+ int reason_code);/*needed by events.c preauth.c*/
-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 reason_code);/*needed by ctrl_iface.c events.c*/
-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);
+void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);/*needed by ctrl_iface.c events.c preauth.c*/
#endif /* WPA_SUPPLICANT_S_H */
More information about the Hostap
mailing list