ref: 2a89e34cd0b8015dc6b8f679e5cc17511a4743ca
parent: 52d0ccf0d31f471093d99a10ca7c17f4487d6906
author: 9ferno <[email protected]>
date: Thu Aug 26 10:00:25 EDT 2021
fixed nat udp wrong length bug
--- a/os/ip/nat.c
+++ b/os/ip/nat.c
@@ -128,8 +128,8 @@
if(ip4cmp(h->src, laddr) != 0){
if((np=parseproto(h->proto)) != nil){
/* Protocol layer */
- sport = (b->rp)+sizeof(Ip4hdr)+np->sport;
- cksum = (b->rp)+sizeof(Ip4hdr)+np->cksum;
+ sport = (b->rp)+IP4HDR+np->sport;
+ cksum = (b->rp)+IP4HDR+np->cksum;
if((n = natlport(p, h, sport)) == nil)
return -1;
memmove(sport, n->lport, 2);
@@ -171,10 +171,10 @@
return;
if((np=parseproto(h->proto)) != nil){
- lport = (b->rp)+sizeof(Ip4hdr)+np->dport;
+ lport = (b->rp)+IP4HDR+np->dport;
if((n=natexistin(h->proto, lport)) != nil){
/* Protocol layer */
- cksum = (b->rp)+sizeof(Ip4hdr)+np->cksum;
+ cksum = (b->rp)+IP4HDR+np->cksum;
checksumadjust(cksum, lport, 2, n->sport, 2);
memmove(lport, n->sport, 2);
if(np->proto != 1)