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);
ctlr->aid = 0;
rxon(edev, nil);
qunlock(ctlr);
+ wifiprobe(ctlr->wifi, ctlr->channel);
tsleep(&up->sleep, return0, 0, 1000);
}
tsleep(&up->sleep, return0, 0, 1000);
}
- if(bss == nil)
+ if(wifi->bss == nil)
continue;
/* wait for disassociation */
Wifipkt *w;
uint seq;
- wn->lastsend = MACHP(0)->ticks;
+ if(wn != nil)
+ wn->lastsend = MACHP(0)->ticks;
seq = incref(&wifi->txseq);
seq <<= 4;
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)
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)
{
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;