[PATCH] Re: hostapd/wpa_supplicant - new development release v0.4.3

Leonardo Maccari maccari-thisaintpartofmyaddress-
Fri Jul 1 09:39:29 PDT 2005


On Wed, Jun 29, 2005 at 06:54:27PM -0700, Jouni Malinen wrote:
> On Wed, Jun 29, 2005 at 05:35:21PM +0200, Leonardo Maccari wrote:
> 
> Yes, that should be quite a bit easier now, though all the cleanup is
> not yet complete. There's still number of functions that the other part
> of the program (mainly wpa_supplicant.c in case of wpa_supplicant) will
> still need to export. The main change was that struct wpa_supplicant and
> wpa_supplicant_i.h is not used in wpa.c anymore.

does this patch does something similar to what you ment in the comment in
wpa_supplicant_s.h ? 

i didn't touch other prototypes present in the file and used by other
files the wpa.c

ciao,
leonardo.

-- 
   Key fingerprint = 3129 C583 F03B 2E73 0115  C040 3489 0185 B592 19FE
 Obviously -thisaintpartofmyaddress- is not part of my real email address 

-------------- next part --------------
Common subdirectories: wpa_supplicant-0.4.3/doc and wpa_supplicant-0.4.3-dev/doc
diff -x '*.swp' -xcscope.out -x tags -u -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-01 18:28:37.000000000 +0200
@@ -35,6 +35,26 @@
 #include "preauth.h"
 #include "wpa_i.h"
 
+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);
+
+};
+
+
+extern struct wpa_sm_interface wpa_sm_i;
 
 static const int WPA_SELECTOR_LEN = 4;
 static const u8 WPA_OUI_TYPE[] = { 0x00, 0x50, 0xf2, 1 };
@@ -741,7 +761,7 @@
 				  key_mic);
 	}
 	wpa_hexdump(MSG_MSGDUMP, "WPA: TX EAPOL-Key", msg, msg_len);
-	wpa_ether_send(sm->ctx, msg, msg_len);
+	wpa_sm_i.ether_send(sm->ctx, msg, msg_len);
 	eapol_sm_notify_tx_eapol_key(sm->eapol);
 	free(msg);
 }
@@ -770,7 +790,7 @@
 	else
 		ver = WPA_KEY_INFO_TYPE_HMAC_MD5_RC4;
 
-	if (wpa_supplicant_get_bssid(sm->ctx, bssid) < 0) {
+	if (wpa_sm_i.get_bssid(sm->ctx, bssid) < 0) {
 		wpa_printf(MSG_WARNING, "Failed to read BSSID for EAPOL-Key "
 			   "request");
 		return;
@@ -981,7 +1001,7 @@
 				      IEEE802_1X_TYPE_EAPOL_START, NULL, 0,
 				      &buflen, NULL);
 		if (buf) {
-			wpa_ether_send(sm->ctx, buf, buflen);
+			wpa_sm_i.ether_send(sm->ctx, buf, buflen);
 			free(buf);
 		}
 
@@ -1073,13 +1093,13 @@
 {
 	struct wpa_eapol_ie_parse ie;
 
-	if (wpa_supplicant_get_ssid(sm->ctx) == NULL) {
+	if (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);
+	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 +1141,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);
+	eloop_cancel_timeout(wpa_sm_i.scan, sm->ctx, NULL);
 	wpa_supplicant_cancel_auth_timeout(sm->ctx);
-	wpa_supplicant_set_state(sm->ctx, WPA_COMPLETED);
+	wpa_sm_i.set_state(sm->ctx, WPA_COMPLETED);
 
 	if (secure) {
 		/* MLME.SETPROTECTION.request(TA, Tx_Rx) */
@@ -1186,7 +1206,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 (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 +1297,7 @@
 		_gtk = gtk_buf;
 	}
 	if (sm->pairwise_cipher == WPA_CIPHER_NONE) {
-		if (wpa_supplicant_set_key(sm->ctx, gd->alg,
+		if (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 +1306,7 @@
 				   "GTK to the driver (Group only).");
 			return -1;
 		}
-	} else if (wpa_supplicant_set_key(sm->ctx, gd->alg,
+	} else if (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) <
@@ -1411,7 +1431,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 (wpa_sm_i.get_beacon_ie(sm->ctx) < 0) {
 			wpa_printf(MSG_WARNING, "WPA: Could not find AP from "
 				   "the scan results");
 		} else {
@@ -1495,7 +1515,7 @@
 	const u8 *pos;
 	struct wpa_eapol_ie_parse ie;
 
-	wpa_supplicant_set_state(sm->ctx, WPA_4WAY_HANDSHAKE);
+	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 +1576,7 @@
 		/* MLME.SETPROTECTION.request(TA, Tx_Rx) */
 		eapol_sm_notify_portValid(sm->eapol, TRUE);
 	}
-	wpa_supplicant_set_state(sm->ctx, WPA_GROUP_HANDSHAKE);
+	wpa_sm_i.set_state(sm->ctx, WPA_GROUP_HANDSHAKE);
 
 	if (ie.gtk &&
 	    wpa_supplicant_pairwise_gtk(sm, src_addr, key,
@@ -1713,8 +1733,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 = wpa_sm_i.get_state(sm->ctx) == WPA_COMPLETED;
+	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 +1762,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);
+		wpa_sm_i.set_state(sm->ctx, WPA_COMPLETED);
 	} else {
 		wpa_supplicant_key_neg_complete(sm, src_addr,
 						key_info &
@@ -2229,7 +2249,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 (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 -x '*.swp' -xcscope.out -x tags -u -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-01 18:28:31.000000000 +0200
@@ -108,6 +108,48 @@
 extern int wpa_debug_timestamp;
 
 
+
+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_get_beacon_ie(struct wpa_supplicant *wpa_s);
+void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
+void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
+				 int reason_code);
+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);
+void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx);
+struct wpa_ssid * wpa_supplicant_get_ssid(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_supplicant_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid);
+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_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);
+
+};
+
+struct wpa_sm_interface wpa_sm_i;
+
 void wpa_msg(struct wpa_supplicant *wpa_s, int level, char *fmt, ...)
 {
 	va_list ap;
@@ -1919,6 +1961,16 @@
 	memset(iface, 0, sizeof(*iface));
 	iface_count = 1;
 
+	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_supplicant_fd_workaround();
 
 	for (;;) {
diff -x '*.swp' -xcscope.out -x tags -u -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-06-26 05:27:00.000000000 +0200
+++ wpa_supplicant-0.4.3-dev/wpa_supplicant_s.h	2005-07-01 18:36:55.000000000 +0200
@@ -26,35 +26,23 @@
 	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);
 
+wpa_states wpa_supplicant_get_state(struct wpa_supplicant *wpa_s);
+struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
+void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
+				 int reason_code);
 void wpa_supplicant_req_scan(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_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,



More information about the Hostap mailing list