wifi: use protocol constants from ip/ip.h and ip/ipv6.h for dmatproxy()
This commit is contained in:
parent
070a9ef753
commit
15ff38e818
3 changed files with 19 additions and 15 deletions
|
@ -125,7 +125,8 @@ etherm10g.$O: etherm10g2k.i etherm10g4k.i
|
||||||
etheriwl.$O: wifi.h
|
etheriwl.$O: wifi.h
|
||||||
etherwpi.$O: wifi.h
|
etherwpi.$O: wifi.h
|
||||||
etherrt2860.$O: wifi.h
|
etherrt2860.$O: wifi.h
|
||||||
wifi.$O: wifi.h etherif.h ../port/netif.h ../ip/ip.h /sys/include/libsec.h
|
wifi.$O: wifi.h etherif.h ../port/netif.h /sys/include/libsec.h
|
||||||
|
wifi.$O: ../ip/ip.h ../ip/ipv6.h
|
||||||
|
|
||||||
init.h:D: ../port/initcode.c init9.c
|
init.h:D: ../port/initcode.c init9.c
|
||||||
$CC ../port/initcode.c
|
$CC ../port/initcode.c
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include "ureg.h"
|
#include "ureg.h"
|
||||||
#include "../port/error.h"
|
#include "../port/error.h"
|
||||||
#include "../port/netif.h"
|
#include "../port/netif.h"
|
||||||
#include "../ip/ip.h"
|
|
||||||
|
|
||||||
#include "etherif.h"
|
#include "etherif.h"
|
||||||
#include "wifi.h"
|
#include "wifi.h"
|
||||||
|
@ -1708,6 +1707,9 @@ ccmpdecrypt(Wkey *k, Wifipkt *w, Block *b, uvlong tsc)
|
||||||
* for downstream translation. The proxy does not appear in the
|
* for downstream translation. The proxy does not appear in the
|
||||||
* table.
|
* table.
|
||||||
*/
|
*/
|
||||||
|
#include "../ip/ip.h"
|
||||||
|
#include "../ip/ipv6.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dmatproxy(Block *bp, int upstream, uchar proxy[Eaddrlen], DMAT *t)
|
dmatproxy(Block *bp, int upstream, uchar proxy[Eaddrlen], DMAT *t)
|
||||||
{
|
{
|
||||||
|
@ -1737,30 +1739,30 @@ dmatproxy(Block *bp, int upstream, uchar proxy[Eaddrlen], DMAT *t)
|
||||||
switch(pkt->type[0]<<8 | pkt->type[1]){
|
switch(pkt->type[0]<<8 | pkt->type[1]){
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
case 0x0800: /* IPv4 */
|
case ETIP4:
|
||||||
case 0x86dd: /* IPv6 */
|
case ETIP6:
|
||||||
switch(a[0]&0xF0){
|
switch(a[0]&0xF0){
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
case 0x40: /* IPv4 */
|
case IP_VER4:
|
||||||
if(a+20 > end)
|
if(a+IP4HDR > end || (a[0]&15) < IP_HLEN4)
|
||||||
return;
|
return;
|
||||||
v4tov6(ip, a+12+4*(upstream==0));
|
v4tov6(ip, a+12+4*(upstream==0));
|
||||||
proto = a[9];
|
proto = a[9];
|
||||||
a += (a[0]&15)*4;
|
a += (a[0]&15)*4;
|
||||||
break;
|
break;
|
||||||
case 0x60: /* IPv6 */
|
case IP_VER6:
|
||||||
if(a+40 > end)
|
if(a+IP6HDR > end)
|
||||||
return;
|
return;
|
||||||
memmove(ip, a+8+16*(upstream==0), 16);
|
memmove(ip, a+8+16*(upstream==0), 16);
|
||||||
proto = a[6];
|
proto = a[6];
|
||||||
a += 40;
|
a += IP6HDR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!upstream)
|
if(!upstream)
|
||||||
break;
|
break;
|
||||||
switch(proto){
|
switch(proto){
|
||||||
case 58: /* ICMPv6 */
|
case ICMPv6:
|
||||||
if(a+8 > end)
|
if(a+8 > end)
|
||||||
return;
|
return;
|
||||||
switch(a[0]){
|
switch(a[0]){
|
||||||
|
@ -1784,8 +1786,8 @@ dmatproxy(Block *bp, int upstream, uchar proxy[Eaddrlen], DMAT *t)
|
||||||
csum = (a[2]<<8 | a[3])^0xFFFF;
|
csum = (a[2]<<8 | a[3])^0xFFFF;
|
||||||
while(o+8 <= end && o[1] != 0){
|
while(o+8 <= end && o[1] != 0){
|
||||||
switch(o[0]){
|
switch(o[0]){
|
||||||
case 1: /* SLLA, for RS, RA and NS */
|
case SRC_LLADDR:
|
||||||
case 2: /* TLLA, for NA and RD */
|
case TARGET_LLADDR:
|
||||||
for(i=0; i<Eaddrlen; i += 2)
|
for(i=0; i<Eaddrlen; i += 2)
|
||||||
csum += (o[2+i]<<8 | o[3+i])^0xFFFF;
|
csum += (o[2+i]<<8 | o[3+i])^0xFFFF;
|
||||||
memmove(mac, o+2, Eaddrlen);
|
memmove(mac, o+2, Eaddrlen);
|
||||||
|
@ -1802,7 +1804,7 @@ dmatproxy(Block *bp, int upstream, uchar proxy[Eaddrlen], DMAT *t)
|
||||||
a[2] = csum>>8;
|
a[2] = csum>>8;
|
||||||
a[3] = csum;
|
a[3] = csum;
|
||||||
break;
|
break;
|
||||||
case 17: /* UDP (bootp) */
|
case UDP: /* for BOOTP */
|
||||||
if(a+42 > end
|
if(a+42 > end
|
||||||
|| (a[0]<<8 | a[1]) != 68
|
|| (a[0]<<8 | a[1]) != 68
|
||||||
|| (a[2]<<8 | a[3]) != 67
|
|| (a[2]<<8 | a[3]) != 67
|
||||||
|
@ -1830,7 +1832,7 @@ dmatproxy(Block *bp, int upstream, uchar proxy[Eaddrlen], DMAT *t)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x0806: /* ARP */
|
case ETARP:
|
||||||
if(a+26 > end || memcmp(a, arp4, sizeof(arp4)) != 0 || (a[7] != 1 && a[7] != 2))
|
if(a+26 > end || memcmp(a, arp4, sizeof(arp4)) != 0 || (a[7] != 1 && a[7] != 2))
|
||||||
return;
|
return;
|
||||||
v4tov6(ip, a+14+10*(upstream==0));
|
v4tov6(ip, a+14+10*(upstream==0));
|
||||||
|
|
|
@ -125,7 +125,8 @@ ethermii.$O: ethermii.h
|
||||||
etheriwl.$O: wifi.h
|
etheriwl.$O: wifi.h
|
||||||
etherwpi.$O: wifi.h
|
etherwpi.$O: wifi.h
|
||||||
etherrt2860.$O: wifi.h
|
etherrt2860.$O: wifi.h
|
||||||
wifi.$O: wifi.h etherif.h ../port/netif.h ../ip/ip.h /sys/include/libsec.h
|
wifi.$O: wifi.h etherif.h ../port/netif.h /sys/include/libsec.h
|
||||||
|
wifi.$O: ../ip/ip.h ../ip/ipv6.h
|
||||||
|
|
||||||
init.h:D: ../port/initcode.c ../pc/init9.c
|
init.h:D: ../port/initcode.c ../pc/init9.c
|
||||||
$CC ../port/initcode.c
|
$CC ../port/initcode.c
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue