wifi: send probe requests for hidden ssid

This commit is contained in:
cinap_lenrek 2013-07-01 00:55:34 +02:00
parent 6c2e9a98e2
commit 82ccf5b26a
3 changed files with 54 additions and 3 deletions

View file

@ -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 */

View file

@ -132,6 +132,7 @@ wifitx(Wifi *wifi, Wnode *wn, Block *b)
Wifipkt *w;
uint seq;
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;

View file

@ -83,3 +83,4 @@ long wifistat(Wifi*, void*, long, ulong);
long wifictl(Wifi*, void*, long);
int wifichecklink(Wifi*);
void wifiprobe(Wifi*, int);