]> git.lizzy.rs Git - plan9front.git/commitdiff
wifi: send probe requests for hidden ssid
authorcinap_lenrek <cinap_lenrek@gmx.de>
Sun, 30 Jun 2013 22:55:34 +0000 (00:55 +0200)
committercinap_lenrek <cinap_lenrek@gmx.de>
Sun, 30 Jun 2013 22:55:34 +0000 (00:55 +0200)
sys/src/9/pc/etheriwl.c
sys/src/9/pc/wifi.c
sys/src/9/pc/wifi.h

index fe555c6511acf58108730cb66dda78a0ca109d43..e61d725d7c0317f0b9baa76d6bbeb1bd80499061 100644 (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 */
index 5a3071e9ad3fc3eb5e674cd73113cee34041b582..345cf458ce576a20cae80095d09af78dfc683ef6 100644 (file)
@@ -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;
index 1fbdd7ece5a1fc242de41b63f1d8f8682fcd87e5..0989ae45b1e67604b6d410e2b7334490d681a69f 100644 (file)
@@ -83,3 +83,4 @@ long wifistat(Wifi*, void*, long, ulong);
 long wifictl(Wifi*, void*, long);
 
 int wifichecklink(Wifi*);
+void wifiprobe(Wifi*, int);