diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2014-07-11 20:03:11 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2014-07-11 20:03:11 +0000 |
commit | ddf2470b2e659ff6d94d5a9598f87946299a38c4 (patch) | |
tree | 9b78da3961c4c98e66be739e55dba4133aea51b1 /regress | |
parent | 0245074ca729549db71d8bfd70574a0937d41649 (diff) |
Verify the checksum of the echo reply fragment based on the echo
request.
Diffstat (limited to 'regress')
-rw-r--r-- | regress/sys/netinet6/frag6/frag6_refrag.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/regress/sys/netinet6/frag6/frag6_refrag.py b/regress/sys/netinet6/frag6/frag6_refrag.py index 8622c984231..a0697ba5406 100644 --- a/regress/sys/netinet6/frag6/frag6_refrag.py +++ b/regress/sys/netinet6/frag6/frag6_refrag.py @@ -14,6 +14,8 @@ from scapy.all import * pid=os.getpid() payload=100 * "ABCDEFGHIJKLMNOP" packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/ICMPv6EchoRequest(id=pid, data=payload) +request_cksum=ICMPv6Unknown(str(packet.payload)).cksum +print "request cksum=%#x" % (request_cksum) frag=[] frag.append(IPv6ExtHdrFragment(nh=58, id=pid, m=1)/str(packet)[40:56]) offset=2 @@ -47,6 +49,13 @@ for a in ans: if id != pid: print "WRONG ECHO REPLY ID" exit(2) + reply_cksum=a.payload.payload.payload.cksum + print "reply cksum=%#x" % (reply_cksum) + # change request checksum incrementaly and check with reply + diff_cksum=~(~reply_cksum+~(~request_cksum+~0x8000+0x8100)) + if diff_cksum != -1: + print "CHECKSUM ERROR diff cksum=%#x" % (diff_cksum) + exit(1) exit(0) print "NO ECHO REPLY" exit(2) |