From f2775554a14d0ab929e149f72235db3e6bef1378 Mon Sep 17 00:00:00 2001 From: Alexander Bluhm Date: Fri, 27 Jan 2012 17:28:01 +0000 Subject: Test sending a short atomic IPv6 fragment. --- regress/sys/netinet6/frag6/Makefile | 9 ++++- regress/sys/netinet6/frag6/frag6_shortatomic.py | 49 +++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 regress/sys/netinet6/frag6/frag6_shortatomic.py (limited to 'regress') diff --git a/regress/sys/netinet6/frag6/Makefile b/regress/sys/netinet6/frag6/Makefile index bf0998e3745..a093f5e31aa 100644 --- a/regress/sys/netinet6/frag6/Makefile +++ b/regress/sys/netinet6/frag6/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.4 2012/01/24 19:12:34 bluhm Exp $ +# $OpenBSD: Makefile,v 1.5 2012/01/27 17:28:00 bluhm Exp $ # The following ports must be installed: # @@ -109,6 +109,13 @@ run-regress-frag6-overatomic: addr.py @echo Check ping6 overlapping and atomic fragments ${SUDO} python2.7 frag6_overatomic.py +# atomic fragment with short fragmented payload +TARGETS += frag6-shortatomic +run-regress-frag6-shortatomic: addr.py + @echo '\n======== $@ ========' + @echo Check ping6 short atomic fragments + ${SUDO} python2.7 frag6_shortatomic.py + # fragmented packet permuted fragments TARGETS += frag6-permute run-regress-frag6-permute: addr.py diff --git a/regress/sys/netinet6/frag6/frag6_shortatomic.py b/regress/sys/netinet6/frag6/frag6_shortatomic.py new file mode 100644 index 00000000000..12e978e7ce9 --- /dev/null +++ b/regress/sys/netinet6/frag6/frag6_shortatomic.py @@ -0,0 +1,49 @@ +#!/usr/local/bin/python2.7 +# send ping6 fragments containig destination option extension header +# and the same as atomic fragments with missing protocol header + +# |-IP-|-Frag-|-ExtDest-|-ICMP6-|-pay| +# |-- atomic fragment --| +# |load-| + +import os +from addr import * +from scapy.all import * + +pid=os.getpid() +payload="ABCDEFGHIJKLOMNO" +packet=IPv6(src=SRC_OUT6, dst=DST_IN6)/IPv6ExtHdrDestOpt()/ \ + ICMPv6EchoRequest(id=pid, data=payload) +frag=[] +frag.append(IPv6ExtHdrFragment(nh=60, id=pid, m=1)/str(packet)[40:64]) +frag.append(IPv6ExtHdrFragment(nh=60, id=pid)/str(packet)[40:48]) +frag.append(IPv6ExtHdrFragment(nh=60, id=pid, offset=3)/str(packet)[64:72]) +eth=[] +for f in frag: + pkt=IPv6(src=SRC_OUT6, dst=DST_IN6)/f + eth.append(Ether(src=SRC_MAC, dst=DST_MAC)/pkt) + +if os.fork() == 0: + time.sleep(1) + sendp(eth, iface=SRC_IF) + os._exit(0) + +ans=sniff(iface=SRC_IF, timeout=3, filter= + "ip6 and src "+DST_IN6+" and dst "+SRC_OUT6+" and icmp6") +for a in ans: + if a and a.type == scapy.layers.dot11.ETHER_TYPES.IPv6 and \ + ipv6nh[a.payload.nh] == 'ICMPv6' and \ + icmp6types[a.payload.payload.type] == 'Echo Reply': + id=a.payload.payload.id + print "id=%#x" % (id) + if id != pid: + print "WRONG ECHO REPLY ID" + exit(2) + data=a.payload.payload.data + print "payload=%s" % (data) + if data == payload: + exit(0) + print "PAYLOAD!=%s" % (payload) + exit(2) +print "NO ECHO REPLY" +exit(1) -- cgit v1.2.3