ref: 82ccf5b26a8cc6b15216823f7694cb8570f2ccc4
parent: 6c2e9a98e217e95d75c511561e1198e2d926adfd
author: cinap_lenrek <[email protected]>
date: Sun Jun 30 20:55:34 EDT 2013
wifi: send probe requests for hidden ssid
--- a/sys/src/9/pc/etheriwl.c
+++ b/sys/src/9/pc/etheriwl.c
@@ -1846,6 +1846,7 @@
return;
}
+ if(wn != nil)
if((wn->channel != ctlr->channel)
|| (!ctlr->prom && (wn->aid != ctlr->aid || memcmp(wn->bssid, ctlr->bssid, Eaddrlen) != 0)))
rxon(edev, wn);
@@ -2012,6 +2013,7 @@
ctlr->aid = 0;
rxon(edev, nil);
qunlock(ctlr);
+ wifiprobe(ctlr->wifi, ctlr->channel);
tsleep(&up->sleep, return0, 0, 1000);
}
@@ -2023,7 +2025,7 @@
tsleep(&up->sleep, return0, 0, 1000);
}
- if(bss == nil)
+ if(wifi->bss == nil)
continue;
/* wait for disassociation */
--- a/sys/src/9/pc/wifi.c
+++ b/sys/src/9/pc/wifi.c
@@ -132,7 +132,8 @@
Wifipkt *w;
uint seq;
- wn->lastsend = MACHP(0)->ticks;
+ if(wn != nil)
+ wn->lastsend = MACHP(0)->ticks;
seq = incref(&wifi->txseq);
seq <<= 4;
@@ -142,7 +143,7 @@
w->seq[0] = seq;
w->seq[1] = seq>>8;
- if((w->fc[0] & 0x0c) != 0x00)
+ if((w->fc[0] & 0x0c) != 0x00 && wn != nil)
b = wifiencrypt(wifi, wn, b);
if(b != nil)
@@ -182,6 +183,50 @@
return nn;
}
+void
+wifiprobe(Wifi *wifi, int channel)
+{
+ Wifipkt *w;
+ Block *b;
+ uchar *p;
+ int n;
+
+ n = strlen(wifi->essid);
+ if(n == 0)
+ return;
+
+ b = allocb(WIFIHDRSIZE + 512);
+ w = (Wifipkt*)b->wp;
+ w->fc[0] = 0x40; /* probe request */
+ w->fc[1] = 0x00; /* STA->STA */
+ memmove(w->a1, wifi->ether->bcast, Eaddrlen); /* ??? */
+ memmove(w->a2, wifi->ether->ea, Eaddrlen);
+ memmove(w->a3, wifi->ether->bcast, Eaddrlen);
+ b->wp += WIFIHDRSIZE;
+ p = b->wp;
+
+ *p++ = 0x00; /* set */
+ *p++ = n;
+ memmove(p, wifi->essid, n);
+ p += n;
+
+ *p++ = 1; /* RATES (BUG: these are all lies!) */
+ *p++ = 4;
+ *p++ = 0x82;
+ *p++ = 0x84;
+ *p++ = 0x8b;
+ *p++ = 0x96;
+
+ if(channel > 0){
+ *p++ = 0x03; /* ds parameter set */
+ *p++ = 1;
+ *p++ = channel;
+ }
+
+ b->wp = p;
+ wifitx(wifi, nil, b);
+}
+
static void
sendauth(Wifi *wifi, Wnode *bss)
{
@@ -425,6 +470,9 @@
switch(w->fc[0] & 0xf0){
case 0x50: /* probe response */
+ if(wifi->debug)
+ print("#l%d: got probe from %E\n", wifi->ether->ctlrno, w->a3);
+ /* no break */
case 0x80: /* beacon */
if((wn = nodelookup(wifi, w->a3, 1)) == nil)
continue;
--- a/sys/src/9/pc/wifi.h
+++ b/sys/src/9/pc/wifi.h
@@ -83,3 +83,4 @@
long wifictl(Wifi*, void*, long);
int wifichecklink(Wifi*);
+void wifiprobe(Wifi*, int);