How to use WPS support with madwifi driver, or should I use some other Wi-Fi card

Masashi Honma honma
Sun Mar 22 19:14:41 PDT 2009


Hello.

> I'm trying to run WPS client with madwifi 0.9.4 and wpa_supplicant 
> 0.6.8, but cannot find WPS support from my APs. My APs do have WPS 
> turned on.

I have encountered same problem.

This is my patch for madwifi-0.9.4.

diff -ru madwifi-0.9.4.old/net80211/ieee80211.h madwifi-0.9.4.new/net80211/ieee80211.h
--- madwifi-0.9.4.old/net80211/ieee80211.h	2008-01-31 06:07:22.000000000 +0900
+++ madwifi-0.9.4.new/net80211/ieee80211.h	2009-01-19 11:55:56.000000000 +0900
@@ -752,6 +752,7 @@
 
 #define	WPA_OUI			0xf25000
 #define	WPA_OUI_TYPE		0x01
+#define	WSC_OUI_TYPE		0x04
 #define	WPA_VERSION		1		/* current supported version */
 
 #define	WPA_CSE_NULL		0x00
diff -ru madwifi-0.9.4.old/net80211/ieee80211_input.c madwifi-0.9.4.new/net80211/ieee80211_input.c
--- madwifi-0.9.4.old/net80211/ieee80211_input.c	2007-07-26 00:26:38.000000000 +0900
+++ madwifi-0.9.4.new/net80211/ieee80211_input.c	2009-01-19 12:01:05.000000000 +0900
@@ -1715,6 +1715,12 @@
 }
 
 static __inline int
+iswscoui(const u_int8_t *frm)
+{
+	return frm[1] > 3 && LE_READ_4(frm+2) == ((WSC_OUI_TYPE<<24)|WPA_OUI);
+}
+
+static __inline int
 isatherosoui(const u_int8_t *frm)
 {
 	return frm[1] > 3 && LE_READ_4(frm+2) == ((ATH_OUI_TYPE<<24)|ATH_OUI);
@@ -2676,6 +2682,8 @@
 					scan.wpa = frm;
 				else if (iswmeparam(frm) || iswmeinfo(frm))
 					scan.wme = frm;
+				else if (iswscoui(frm))
+					scan.wsc = frm;
 				else if (isatherosoui(frm))
 					scan.ath = frm;
 				break;
@@ -2922,6 +2930,8 @@
 					ieee80211_saveie(&ni->ni_wpa_ie, scan.wpa);
 				if (scan.rsn != NULL)
 					ieee80211_saveie(&ni->ni_rsn_ie, scan.rsn);
+				if (scan.wsc != NULL)
+					ieee80211_saveie(&ni->ni_wsc_ie, scan.wsc);
 				if (scan.ath != NULL)
 					ieee80211_saveath(ni, scan.ath);
 
diff -ru madwifi-0.9.4.old/net80211/ieee80211_node.c madwifi-0.9.4.new/net80211/ieee80211_node.c
--- madwifi-0.9.4.old/net80211/ieee80211_node.c	2007-05-23 17:43:05.000000000 +0900
+++ madwifi-0.9.4.new/net80211/ieee80211_node.c	2009-01-19 12:05:46.000000000 +0900
@@ -829,6 +829,8 @@
 		FREE(ni->ni_rsn_ie, M_DEVBUF);
 	if (ni->ni_wme_ie != NULL)
 		FREE(ni->ni_wme_ie, M_DEVBUF);
+	if (ni->ni_wsc_ie != NULL)
+		FREE(ni->ni_wsc_ie, M_DEVBUF);
 	if (ni->ni_ath_ie != NULL)
 		FREE(ni->ni_ath_ie, M_DEVBUF);
 	IEEE80211_NODE_SAVEQ_DESTROY(ni);
diff -ru madwifi-0.9.4.old/net80211/ieee80211_node.h madwifi-0.9.4.new/net80211/ieee80211_node.h
--- madwifi-0.9.4.old/net80211/ieee80211_node.h	2007-07-26 00:20:59.000000000 +0900
+++ madwifi-0.9.4.new/net80211/ieee80211_node.h	2009-01-19 12:00:58.000000000 +0900
@@ -125,6 +125,7 @@
 	u_int8_t *ni_wpa_ie;			/* captured WPA ie */
 	u_int8_t *ni_rsn_ie;			/* captured RSN ie */
 	u_int8_t *ni_wme_ie;			/* captured WME ie */
+	u_int8_t *ni_wsc_ie;			/* captured WSC ie */
 	u_int8_t *ni_ath_ie;			/* captured Atheros ie */
 	u_int16_t ni_txseqs[17];			/* tx seq per-tid */
 	u_int16_t ni_rxseqs[17];			/* rx seq previous per-tid*/
diff -ru madwifi-0.9.4.old/net80211/ieee80211_scan.h madwifi-0.9.4.new/net80211/ieee80211_scan.h
--- madwifi-0.9.4.old/net80211/ieee80211_scan.h	2007-05-23 17:43:05.000000000 +0900
+++ madwifi-0.9.4.new/net80211/ieee80211_scan.h	2009-01-19 13:04:28.000000000 +0900
@@ -142,6 +142,7 @@
 	u_int8_t *wpa;
 	u_int8_t *rsn;
 	u_int8_t *wme;
+	u_int8_t *wsc;
 	u_int8_t *ath;
 };
 
@@ -172,6 +173,7 @@
 	u_int8_t *se_wpa_ie;		/* captured WPA ie */
 	u_int8_t *se_rsn_ie;		/* captured RSN ie */
 	u_int8_t *se_wme_ie;		/* captured WME ie */
+	u_int8_t *se_wsc_ie;		/* captured WSC ie */
 	u_int8_t *se_ath_ie;		/* captured Atheros ie */
 	u_int se_age;			/* age of entry (0 on create) */
 };
diff -ru madwifi-0.9.4.old/net80211/ieee80211_scan_sta.c madwifi-0.9.4.new/net80211/ieee80211_scan_sta.c
--- madwifi-0.9.4.old/net80211/ieee80211_scan_sta.c	2007-10-16 17:58:14.000000000 +0900
+++ madwifi-0.9.4.new/net80211/ieee80211_scan_sta.c	2009-01-19 13:04:58.000000000 +0900
@@ -268,6 +268,7 @@
 	saveie(&ise->se_wme_ie, sp->wme);
 	saveie(&ise->se_wpa_ie, sp->wpa);
 	saveie(&ise->se_rsn_ie, sp->rsn);
+	saveie(&ise->se_wsc_ie, sp->wsc);
 	saveie(&ise->se_ath_ie, sp->ath);
 
 	/* clear failure count after STA_FAIL_AGE passes */
diff -ru madwifi-0.9.4.old/net80211/ieee80211_wireless.c madwifi-0.9.4.new/net80211/ieee80211_wireless.c
--- madwifi-0.9.4.old/net80211/ieee80211_wireless.c	2007-12-25 12:15:19.000000000 +0900
+++ madwifi-0.9.4.new/net80211/ieee80211_wireless.c	2009-01-19 13:18:10.000000000 +0900
@@ -1781,6 +1781,25 @@
 			  return E2BIG;
 		}
 	}
+	if (se->se_wsc_ie != NULL) {
+		last_ev = current_ev;
+#ifdef IWEVGENIE
+		memset(&iwe, 0, sizeof(iwe));
+		if ((se->se_wsc_ie[1] + 2) > 257)
+			return E2BIG;
+		memcpy(buf, se->se_wsc_ie, se->se_wsc_ie[1] + 2);
+		iwe.cmd = IWEVGENIE;
+		iwe.u.data.length = se->se_wsc_ie[1] + 2;
+#endif
+		if (iwe.u.data.length != 0) {
+			current_ev = iwe_stream_add_point(current_ev, end_buf,
+				&iwe, buf);
+			
+			/* We ran out of space in the buffer. */
+			if (last_ev == current_ev)
+			  return E2BIG;
+		}
+	}
 	if (se->se_ath_ie != NULL) {
 		static const char ath_leader[] = "ath_ie=";
 


I'm using WPS with this patch.

Regards,
Masashi Honma.



More information about the Hostap mailing list