Include diff complement

This commit is contained in:
Nico Schottelius 2019-07-10 15:11:19 +02:00
parent 046bb21bbb
commit 5a093cf0cf
3 changed files with 12 additions and 4 deletions

View file

@ -149,9 +149,13 @@ if __name__ == '__main__':
# print("chk_t = {}".format(t))
e = Ether(src="02:53:55:42:45:01", dst='ff:ff:ff:ff:ff:ff')
i4 = IP(src = "192.168.1.1", dst = "192.168.4.2")
i6 = IPv6(src = "2001:db8:42::1", dst = "2001:db8::2")
e = Ether(src="00:00:0a:00:00:03", dst='00:00:0a:00:00:01')
i4 = IP(src = "10.0.0.1", dst = "10.1.1.1")
i6 = IPv6(src="2001:db8:1::a00:1", dst="2001:db8::1")
# e = Ether(src="02:53:55:42:45:01", dst='ff:ff:ff:ff:ff:ff')
# i4 = IP(src = "192.168.1.1", dst = "192.168.4.2")
# i6 = IPv6(src = "2001:db8:42::1", dst = "2001:db8::2")
i62 = IPv6(src = "2001:db8:42::2", dst = "2001:db8::2")
t = TCP(dport=80, sport=1337)
u = UDP(dport=80, sport=1337)

View file

@ -3,6 +3,8 @@
import sys
from scapy.all import *
import checksum_from_scapy
if __name__ == '__main__':
iface = sys.argv[1]
@ -25,5 +27,7 @@ if __name__ == '__main__':
v6_rebuild = pkg_v6.__class__(str(pkg_v6))
print("v6: {} - {}".format(v6_rebuild.__repr__(), v6_rebuild[UDP].chksum))
checksum_from_scapy.checksum()
sendp(pkg, iface=iface, verbose=True)

View file

@ -198,7 +198,7 @@ control MyIngress(inout headers hdr,
v6sum();
bit<16> diff = meta.v6sum - meta.v4sum;
# hdr.udp.checksum = hdr.udp.checksum + diff;
hdr.udp.checksum = diff;
hdr.udp.checksum = ~diff;
#else
meta.chk_udp_v6 = 1;