diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-12-28 04:34:03 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-12-28 04:34:03 +0100 |
commit | b9d2a9efd5cb230009b3181d4699017155187b19 (patch) | |
tree | 5d674abde452a86ad92c9a5079f55e1c6454ed1a /sys/src/9 | |
parent | d13142b3daba5e76646cd36f718a1ff5ae9e25d4 (diff) |
wifi: don't implicitely update lastseen timestamp on nodelookup()
in case we continue to send traffic (like ping) with the ap gone,
the sending would keep updating bss->lastseen which prevents the
timeout to happen to switch bss.
Diffstat (limited to 'sys/src/9')
-rw-r--r-- | sys/src/9/pc/wifi.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/sys/src/9/pc/wifi.c b/sys/src/9/pc/wifi.c index 5b22e3309..b2defe6d4 100644 --- a/sys/src/9/pc/wifi.c +++ b/sys/src/9/pc/wifi.c @@ -189,21 +189,18 @@ nodelookup(Wifi *wifi, uchar *bssid, int new) if(memcmp(bssid, wifi->ether->bcast, Eaddrlen) == 0) return nil; if((wn = wifi->bss) != nil){ - if(memcmp(wn->bssid, bssid, Eaddrlen) == 0){ - wn->lastseen = MACHP(0)->ticks; + if(memcmp(wn->bssid, bssid, Eaddrlen) == 0) return wn; - } } if((nn = wifi->node) == wn) nn++; for(wn = wifi->node; wn != &wifi->node[nelem(wifi->node)]; wn++){ if(wn == wifi->bss) continue; - if(memcmp(wn->bssid, bssid, Eaddrlen) == 0){ - wn->lastseen = MACHP(0)->ticks; + if(memcmp(wn->bssid, bssid, Eaddrlen) == 0) return wn; - } - if((long)(wn->lastseen - nn->lastseen) < 0) + if((long)(wn->lastsend - nn->lastsend) < 0 + || (long)(wn->lastseen - nn->lastseen) < 0) nn = wn; } if(!new) @@ -211,7 +208,6 @@ nodelookup(Wifi *wifi, uchar *bssid, int new) freewifikeys(wifi, nn); memset(nn, 0, sizeof(Wnode)); memmove(nn->bssid, bssid, Eaddrlen); - nn->lastseen = MACHP(0)->ticks; return nn; } @@ -577,6 +573,7 @@ wifiproc(void *arg) /* encrypted */ if((wn = nodelookup(wifi, w->a2, 0)) == nil) continue; + wn->lastseen = MACHP(0)->ticks; if((b = wifidecrypt(wifi, wn, b)) != nil){ w = (Wifipkt*)b->rp; if(w->fc[1] & 0x40) @@ -598,6 +595,7 @@ wifiproc(void *arg) case 0x80: /* beacon */ if((wn = nodelookup(wifi, w->a3, 1)) == nil) continue; + wn->lastseen = MACHP(0)->ticks; b->rp += wifihdrlen(w); recvbeacon(wifi, wn, b->rp, BLEN(b)); @@ -615,6 +613,7 @@ wifiproc(void *arg) continue; if((wn = nodelookup(wifi, w->a3, 0)) == nil) continue; + wn->lastseen = MACHP(0)->ticks; switch(w->fc[0] & 0xf0){ case 0x10: /* assoc response */ case 0x30: /* reassoc response */ |