ref: ba87e58876d01cdd4c0634ef7ab40ba680092e09
parent: 2088f8c991de090e8b9e75ecbd416c98a511b214
author: cinap_lenrek <[email protected]>
date: Fri Jan 12 13:28:50 EST 2018
wifi: learn target ip address from neighbor advertisements in dmat proxy
--- a/sys/src/9/pc/wifi.c
+++ b/sys/src/9/pc/wifi.c
@@ -1713,7 +1713,7 @@
0x06, 0x04,
0x00,
};
- uchar ip[IPaddrlen], mac[Eaddrlen], *end, *a, *o;
+ uchar ip[IPaddrlen], mac[Eaddrlen], *targ, *end, *a, *o;
ulong csum, c, h;
Etherpkt *pkt;
int proto, i;
@@ -1730,6 +1730,7 @@
else if(t->map == 0 || (pkt->d[0]&1) != 0 || memcmp(pkt->d, proxy, Eaddrlen) != 0)
return;
+ targ = nil;
switch(pkt->type[0]<<8 | pkt->type[1]){
default:
return;
@@ -1768,8 +1769,10 @@
case 134: /* Router Advertisement */
o = a+8+8;
break;
- case 135: /* Neighbor Solicitation */
case 136: /* Neighbor Advertisement */
+ targ = a+8;
+ /* wet floor */
+ case 135: /* Neighbor Solicitation */
o = a+8+16;
break;
case 137: /* Redirect */
@@ -1837,6 +1840,7 @@
break;
}
+Again:
h = ( (ip[IPaddrlen-1] ^ proxy[2])<<24 |
(ip[IPaddrlen-2] ^ proxy[3])<<16 |
(ip[IPaddrlen-3] ^ proxy[4])<<8 |
@@ -1857,6 +1861,11 @@
memmove(te->ip, ip, IPaddrlen);
te->valid = 1;
t->map |= 1ULL<<h;
+ if(targ != nil){
+ memmove(ip, targ, IPaddrlen);
+ targ = nil;
+ goto Again;
+ }
} else {
if((t->map>>h & 1) == 0)
return;