From 82ccf5b26a8cc6b15216823f7694cb8570f2ccc4 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Mon, 1 Jul 2013 00:55:34 +0200 Subject: wifi: send probe requests for hidden ssid --- sys/src/9/pc/etheriwl.c | 4 +++- sys/src/9/pc/wifi.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++-- sys/src/9/pc/wifi.h | 1 + 3 files changed, 54 insertions(+), 3 deletions(-) (limited to 'sys/src') diff --git a/sys/src/9/pc/etheriwl.c b/sys/src/9/pc/etheriwl.c index fe555c651..e61d725d7 100644 --- a/sys/src/9/pc/etheriwl.c +++ b/sys/src/9/pc/etheriwl.c @@ -1846,6 +1846,7 @@ transmit(Wifi *wifi, Wnode *wn, Block *b) 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 @@ iwlproc(void *arg) ctlr->aid = 0; rxon(edev, nil); qunlock(ctlr); + wifiprobe(ctlr->wifi, ctlr->channel); tsleep(&up->sleep, return0, 0, 1000); } @@ -2023,7 +2025,7 @@ iwlproc(void *arg) tsleep(&up->sleep, return0, 0, 1000); } - if(bss == nil) + if(wifi->bss == nil) continue; /* wait for disassociation */ diff --git a/sys/src/9/pc/wifi.c b/sys/src/9/pc/wifi.c index 5a3071e9a..345cf458c 100644 --- a/sys/src/9/pc/wifi.c +++ b/sys/src/9/pc/wifi.c @@ -132,7 +132,8 @@ wifitx(Wifi *wifi, Wnode *wn, Block *b) 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 @@ wifitx(Wifi *wifi, Wnode *wn, Block *b) 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 @@ nodelookup(Wifi *wifi, uchar *bssid, int new) 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 @@ wifiproc(void *arg) 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; diff --git a/sys/src/9/pc/wifi.h b/sys/src/9/pc/wifi.h index 1fbdd7ece..0989ae45b 100644 --- a/sys/src/9/pc/wifi.h +++ b/sys/src/9/pc/wifi.h @@ -83,3 +83,4 @@ long wifistat(Wifi*, void*, long, ulong); long wifictl(Wifi*, void*, long); int wifichecklink(Wifi*); +void wifiprobe(Wifi*, int); -- cgit v1.2.3