code: plan9front

Download patch

ref: ee735f1088282a7c34a97f4ccb44a1d5127a006d
parent: 6b4a9c5d8d291ce15e9f31cb130537fe47a9688e
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Jun 21 15:35:08 EDT 2015

wifi: berlin prime bunny hopping

- reduce delay for channel hop to 200ms
- use 1000ms timeout for auth response (dont hop channels while we wait)
- bunny hop sequence is mathematically prooven

--- a/sys/src/9/pc/wifi.c
+++ b/sys/src/9/pc/wifi.c
@@ -533,6 +533,7 @@
 			&& goodbss(wifi, wn)){
 				setstatus(wifi, wn, Sconn);
 				sendauth(wifi, wn);
+				wifi->lastauth = wn->lastsend;
 			}
 			continue;
 		}
@@ -664,9 +665,12 @@
 	/* scan for access point */
 	while(wifi->bss == nil){
 		ether->link = 0;
-		wnscan.channel = 1 + wnscan.channel % 11;
+		wnscan.channel = 1 + ((wnscan.channel+4) % 13);
 		wifiprobe(wifi, &wnscan);
-		tsleep(&up->sleep, return0, 0, 1000);
+		do {
+			tsleep(&up->sleep, return0, 0, 200);
+			now = MACHP(0)->ticks;
+		} while(TK2MS(now-wifi->lastauth) < 1000);
 	}
 
 	/* maintain access point */
@@ -715,6 +719,8 @@
 
 	wifi->essid[0] = 0;
 	memmove(wifi->bssid, ether->bcast, Eaddrlen);
+
+	wifi->lastauth = MACHP(0)->ticks;
 
 	snprint(name, sizeof(name), "#l%dwifi", ether->ctlrno);
 	kproc(name, wifiproc, wifi);
--- a/sys/src/9/pc/wifi.h
+++ b/sys/src/9/pc/wifi.h
@@ -56,6 +56,7 @@
 
 	Queue	*iq;
 	ulong	watchdog;
+	ulong	lastauth;
 	Ref	txseq;
 	void	(*transmit)(Wifi*, Wnode*, Block*);