diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2020-12-25 20:18:12 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2020-12-25 20:18:12 +0000 |
commit | 511012d5d1052348c29a0ea59eea894f0b00f66d (patch) | |
tree | 47cf3089f098604b3764cc21122327c2581ed610 | |
parent | a03ca66dfd31fea3bddc2f9f99e558dcef179b59 (diff) |
Switch to scapy with python 3.
34 files changed, 376 insertions, 377 deletions
diff --git a/regress/sys/netinet6/frag6/LICENSE b/regress/sys/netinet6/frag6/LICENSE index 5764ecdb0f9..866739d7ee3 100644 --- a/regress/sys/netinet6/frag6/LICENSE +++ b/regress/sys/netinet6/frag6/LICENSE @@ -1,13 +1,13 @@ -# Copyright (c) 2012-2019 Alexander Bluhm <bluhm@openbsd.org> -# -# Permission to use, copy, modify, and distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +Copyright (c) 2012-2020 Alexander Bluhm <bluhm@openbsd.org> + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/regress/sys/netinet6/frag6/Makefile b/regress/sys/netinet6/frag6/Makefile index 7aae512b354..60bd2e1e1c0 100644 --- a/regress/sys/netinet6/frag6/Makefile +++ b/regress/sys/netinet6/frag6/Makefile @@ -1,15 +1,14 @@ -# $OpenBSD: Makefile,v 1.26 2020/12/17 00:51:13 bluhm Exp $ +# $OpenBSD: Makefile,v 1.27 2020/12/25 20:18:11 bluhm Exp $ # The following ports must be installed: # -# python-2.7 interpreted object-oriented programming language # scapy powerful interactive packet manipulation in python -.if ! exists(/usr/local/bin/python2.7) || ! exists(/usr/local/bin/scapy) +.if ! exists(/usr/local/bin/scapy-3) .BEGIN: @true regress: - @echo Install python and the scapy module for additional tests. + @echo Install py3-scapy package to run this regress. @echo SKIPPED .endif @@ -47,10 +46,10 @@ regress: .if make (regress) || make (all) .BEGIN: - @echo ${SUDO} true ssh -t ${REMOTE_SSH} ${SUDO} true rm -f stamp-stack stamp-pf + @echo .endif # Create python include file containing the addresses. @@ -67,9 +66,9 @@ addr.py: Makefile # Set variables so that make runs with and without obj directory. # Only do that if necessary to keep visible output short. .if ${.CURDIR} == ${.OBJDIR} -PYTHON = python2.7 -u ./ +PYTHON = python3 -u ./ .else -PYTHON = PYTHONPATH=${.OBJDIR} python2.7 -u ${.CURDIR}/ +PYTHON = PYTHONPATH=${.OBJDIR} python3 -u ${.CURDIR}/ .endif stamp-stack: diff --git a/regress/sys/netinet6/frag6/frag6.py b/regress/sys/netinet6/frag6/frag6.py index e6a8b104135..44caeda1736 100644 --- a/regress/sys/netinet6/frag6/frag6.py +++ b/regress/sys/netinet6/frag6/frag6.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "non-overlapping ping6 fragments" +print("non-overlapping ping6 fragments") # |--------| # |----| @@ -11,13 +11,13 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/bytes(packet)[56:64]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -35,15 +35,15 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: exit(0) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(1) -print "NO ECHO REPLY" +print("NO ECHO REPLY") exit(2) diff --git a/regress/sys/netinet6/frag6/frag6_ext.py b/regress/sys/netinet6/frag6/frag6_ext.py index cb08a0eed60..06b487dae59 100644 --- a/regress/sys/netinet6/frag6/frag6_ext.py +++ b/regress/sys/netinet6/frag6/frag6_ext.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "ping6 fragments with hop-by-hop extension header before fragment header" +print("ping6 fragments with hop-by-hop extension header before fragment header") # E|---------| # E|----| @@ -11,13 +11,13 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/bytes(packet)[56:64]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/IPv6ExtHdrHopByHop()/f @@ -35,15 +35,15 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: exit(0) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(1) -print "NO ECHO REPLY" +print("NO ECHO REPLY") exit(2) diff --git a/regress/sys/netinet6/frag6/frag6_ext2long.py b/regress/sys/netinet6/frag6/frag6_ext2long.py index 21215100b77..9c626adf337 100644 --- a/regress/sys/netinet6/frag6/frag6_ext2long.py +++ b/regress/sys/netinet6/frag6/frag6_ext2long.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "ping6 fragments with long extension header in second fragment" +print("ping6 fragments with long extension header in second fragment") # |FFFF|---------| # |HHHHHHHHHHHHHHHHHHHH|DDDD|FFFF|----| @@ -11,15 +11,15 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:56]) frag.append(IPv6ExtHdrHopByHop(options=PadN(optdata="\0"*28))/ \ IPv6ExtHdrDestOpt()/ \ - IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) + IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/bytes(packet)[56:64]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -37,15 +37,15 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: exit(0) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(1) -print "NO ECHO REPLY" +print("NO ECHO REPLY") exit(2) diff --git a/regress/sys/netinet6/frag6/frag6_hop.py b/regress/sys/netinet6/frag6/frag6_hop.py index a04ae7b4c5a..8a936e49591 100644 --- a/regress/sys/netinet6/frag6/frag6_hop.py +++ b/regress/sys/netinet6/frag6/frag6_hop.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "ping6 fragments with missplaced hop-by-hop extension header" +print("ping6 fragments with missplaced hop-by-hop extension header") # |HHHH----------| # |----| @@ -11,13 +11,13 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/IPv6ExtHdrHopByHop()/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=0, id=fid, m=1)/str(packet)[40:64]) -frag.append(IPv6ExtHdrFragment(nh=0, id=fid, offset=3)/str(packet)[64:72]) +frag.append(IPv6ExtHdrFragment(nh=0, id=fid, m=1)/bytes(packet)[40:64]) +frag.append(IPv6ExtHdrFragment(nh=0, id=fid, offset=3)/bytes(packet)[64:72]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -35,16 +35,16 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: - print "ECHO REPLY" + print("ECHO REPLY") exit(1) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) -print "no echo reply" +print("no echo reply") exit(0) diff --git a/regress/sys/netinet6/frag6/frag6_maxlen.py b/regress/sys/netinet6/frag6/frag6_maxlen.py index 70040b3ae29..bdfc8ee50a2 100644 --- a/regress/sys/netinet6/frag6/frag6_maxlen.py +++ b/regress/sys/netinet6/frag6/frag6_maxlen.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "fully fragmented maximum size ping6 packet, sent in random order" +print("fully fragmented maximum size ping6 packet, sent in random order") # |----| # |----| @@ -17,17 +17,17 @@ pid=os.getpid() eid=pid & 0xffff iplen=2**16 size=424 -payload="ABCDEFGHIJKLMNOP" * (iplen / 16) +payload=b"ABCDEFGHIJKLMNOP" * int(iplen / 16) packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ - ICMPv6EchoRequest(id=eid, data=str(payload)[0:iplen-8-1]) + ICMPv6EchoRequest(id=eid, data=bytes(payload)[0:iplen-8-1]) frag=[] fid=pid & 0xffffffff -max=iplen/size +max=int(iplen/size) for i in range(max): frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1, - offset=i*(size/8))/str(packet)[40+i*size:40+(i+1)*size]) + offset=i*int(size/8))/bytes(packet)[40+i*size:40+(i+1)*size]) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, - offset=max*(size/8))/str(packet)[40+max*size:]) + offset=max*int(size/8))/bytes(packet)[40+max*size:]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -55,10 +55,10 @@ for a in ans: ipv6nh[a.payload.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.payload.type] == 'Echo Reply': id=a.payload.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) exit(0) -print "NO ECHO REPLY" +print("NO ECHO REPLY") exit(1) diff --git a/regress/sys/netinet6/frag6/frag6_maxpacket.py b/regress/sys/netinet6/frag6/frag6_maxpacket.py index 23472889921..ce86b704a52 100644 --- a/regress/sys/netinet6/frag6/frag6_maxpacket.py +++ b/regress/sys/netinet6/frag6/frag6_maxpacket.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "send ping6 fragment that ends behind ipv6 max packet size" +print("send ping6 fragment that ends behind ipv6 max packet size") # IPV6_MAXPACKET | # |--------| @@ -13,14 +13,14 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=8191)/str(packet)[56:64]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=8191)/bytes(packet)[56:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/bytes(packet)[56:64]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -38,15 +38,15 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: exit(0) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(1) -print "NO ECHO REPLY" +print("NO ECHO REPLY") exit(2) diff --git a/regress/sys/netinet6/frag6/frag6_maxpacket0.py b/regress/sys/netinet6/frag6/frag6_maxpacket0.py index c1997fe6749..cc2b4fa0ddb 100644 --- a/regress/sys/netinet6/frag6/frag6_maxpacket0.py +++ b/regress/sys/netinet6/frag6/frag6_maxpacket0.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "send first ping6 fragment that ends behind ipv6 max packet size" +print("send first ping6 fragment that ends behind ipv6 max packet size") # IPV6_MAXPACKET | # |----| @@ -13,14 +13,14 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=8191)/str(packet)[56:64]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=8191)/bytes(packet)[56:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/bytes(packet)[56:64]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -38,15 +38,15 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: exit(0) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(1) -print "NO ECHO REPLY" +print("NO ECHO REPLY") exit(2) diff --git a/regress/sys/netinet6/frag6/frag6_mf0atomic.py b/regress/sys/netinet6/frag6/frag6_mf0atomic.py index 46c9d2fd015..4ea83385a72 100644 --- a/regress/sys/netinet6/frag6/frag6_mf0atomic.py +++ b/regress/sys/netinet6/frag6/frag6_mf0atomic.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "ping6 fragments with an atomic fragment with mf=0 overlapping" +print("ping6 fragments with an atomic fragment with mf=0 overlapping") # |---------| # |XXXX| @@ -12,14 +12,14 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid)/str(packet)[40:48]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid)/bytes(packet)[40:48]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/bytes(packet)[56:64]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -37,15 +37,15 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: exit(0) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) -print "NO ECHO REPLY" +print("NO ECHO REPLY") exit(1) diff --git a/regress/sys/netinet6/frag6/frag6_mf0long.py b/regress/sys/netinet6/frag6/frag6_mf0long.py index b2dd9895b6e..85ea494873f 100644 --- a/regress/sys/netinet6/frag6/frag6_mf0long.py +++ b/regress/sys/netinet6/frag6/frag6_mf0long.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "ping6 fragment that overlaps longer than the last fragment with m=0" +print("ping6 fragment that overlaps longer than the last fragment with m=0") # |---------| # |XXXX| @@ -12,15 +12,15 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" -dummy="01234567" +payload=b"ABCDEFGHIJKLMNOP" +dummy=b"01234567" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/str(packet)[48:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/bytes(packet)[48:64]) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=3)/dummy) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:48]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:48]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -38,16 +38,16 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: - print "ECHO REPLY" + print("ECHO REPLY") exit(1) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) -print "no echo reply" +print("no echo reply") exit(0) diff --git a/regress/sys/netinet6/frag6/frag6_mf0middle.py b/regress/sys/netinet6/frag6/frag6_mf0middle.py index 20d2dcc1e2b..a6f114b4cd0 100644 --- a/regress/sys/netinet6/frag6/frag6_mf0middle.py +++ b/regress/sys/netinet6/frag6/frag6_mf0middle.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "ping6 fragment with mf=0 that overlaps the first fragment" +print("ping6 fragment with mf=0 that overlaps the first fragment") # |---------| # |XXXX| @@ -12,14 +12,14 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/str(packet)[48:56]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/bytes(packet)[48:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/bytes(packet)[56:64]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -37,16 +37,16 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: - print "ECHO REPLY" + print("ECHO REPLY") exit(1) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) -print "no echo reply" +print("no echo reply") exit(0) diff --git a/regress/sys/netinet6/frag6/frag6_mf0short.py b/regress/sys/netinet6/frag6/frag6_mf0short.py index a041abcac34..3a3b5633b83 100644 --- a/regress/sys/netinet6/frag6/frag6_mf0short.py +++ b/regress/sys/netinet6/frag6/frag6_mf0short.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "ping6 fragment with m=0 that overlaps the last fragment at beginning" +print("ping6 fragment with m=0 that overlaps the last fragment at beginning") # |---------| # |XXXXXXXXX| @@ -12,14 +12,14 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOPQRSTUVWX" +payload=b"ABCDEFGHIJKLMNOPQRSTUVWX" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:72]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/str(packet)[48:64]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/bytes(packet)[56:72]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/bytes(packet)[48:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:56]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -37,16 +37,16 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: - print "ECHO REPLY" + print("ECHO REPLY") exit(1) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) -print "no echo reply" +print("no echo reply") exit(0) diff --git a/regress/sys/netinet6/frag6/frag6_mf1end.py b/regress/sys/netinet6/frag6/frag6_mf1end.py index bae5eed31ef..c8a2b6f17a8 100644 --- a/regress/sys/netinet6/frag6/frag6_mf1end.py +++ b/regress/sys/netinet6/frag6/frag6_mf1end.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "ping6 fragment with mf=1 that overlaps fragment with mf=0 at the end" +print("ping6 fragment with mf=1 that overlaps fragment with mf=0 at the end") # |----| # |XXXXXXXXX| @@ -12,14 +12,14 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1, m=1)/str(packet)[48:64]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/bytes(packet)[56:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1, m=1)/bytes(packet)[48:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:56]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -37,16 +37,16 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: - print "ECHO REPLY" + print("ECHO REPLY") exit(1) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) -print "no echo reply" +print("no echo reply") exit(0) diff --git a/regress/sys/netinet6/frag6/frag6_opt.py b/regress/sys/netinet6/frag6/frag6_opt.py index 1dc87ca94e5..e4c02c95bdc 100644 --- a/regress/sys/netinet6/frag6/frag6_opt.py +++ b/regress/sys/netinet6/frag6/frag6_opt.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "ping6 fragments with fragmented destination option" +print("ping6 fragments with fragmented destination option") # |OOOO| # |OOOOOOOOOO--------------| @@ -11,14 +11,14 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/IPv6ExtHdrDestOpt( \ options=PadN(optdata='\0'*12)/PadN(optdata='\0'*6))/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=60, id=fid, m=1)/str(packet)[40:48]) -frag.append(IPv6ExtHdrFragment(nh=60, id=fid, offset=1)/str(packet)[48:88]) +frag.append(IPv6ExtHdrFragment(nh=60, id=fid, m=1)/bytes(packet)[40:48]) +frag.append(IPv6ExtHdrFragment(nh=60, id=fid, offset=1)/bytes(packet)[48:88]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -36,15 +36,15 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: exit(0) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(1) -print "NO ECHO REPLY" +print("NO ECHO REPLY") exit(2) diff --git a/regress/sys/netinet6/frag6/frag6_overatomic.py b/regress/sys/netinet6/frag6/frag6_overatomic.py index 3759db1312e..d5f9703d3cd 100644 --- a/regress/sys/netinet6/frag6/frag6_overatomic.py +++ b/regress/sys/netinet6/frag6/frag6_overatomic.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "atomic fragment with offset=0 and more=0, it must be processed" +print("atomic fragment with offset=0 and more=0, it must be processed") # |XXXXXXXX| # |-------------| @@ -11,14 +11,14 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" -dummy="0123456701234567" +payload=b"ABCDEFGHIJKLMNOP" +dummy=b"0123456701234567" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/dummy) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid)/str(packet)[40:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid)/bytes(packet)[40:64]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -36,15 +36,15 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: exit(0) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) -print "NO ECHO REPLY" +print("NO ECHO REPLY") exit(1) diff --git a/regress/sys/netinet6/frag6/frag6_overdrop.py b/regress/sys/netinet6/frag6/frag6_overdrop.py index ac50b177764..8d57884f141 100644 --- a/regress/sys/netinet6/frag6/frag6_overdrop.py +++ b/regress/sys/netinet6/frag6/frag6_overdrop.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "ping6 fragment that overlaps the first fragment with the head" +print("ping6 fragment that overlaps the first fragment with the head") # |---------| # |XXXXXXXXX| @@ -14,17 +14,17 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" -dummy="0123456701234567" +payload=b"ABCDEFGHIJKLMNOP" +dummy=b"0123456701234567" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:56]) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/dummy) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:48]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1, m=1)/str(packet)[48:56]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:48]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1, m=1)/bytes(packet)[48:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/bytes(packet)[56:64]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -42,15 +42,15 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: exit(0) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) -print "NO ECHO REPLY" +print("NO ECHO REPLY") exit(1) diff --git a/regress/sys/netinet6/frag6/frag6_overhead.py b/regress/sys/netinet6/frag6/frag6_overhead.py index c42da517bf0..9847cf793b9 100644 --- a/regress/sys/netinet6/frag6/frag6_overhead.py +++ b/regress/sys/netinet6/frag6/frag6_overhead.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "ping6 fragment that overlaps the second fragment with its head" +print("ping6 fragment that overlaps the second fragment with its head") # |----| # |----| @@ -12,14 +12,14 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:48]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1, m=1)/str(packet)[48:56]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/str(packet)[48:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:48]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1, m=1)/bytes(packet)[48:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/bytes(packet)[48:64]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -37,16 +37,16 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: - print "ECHO REPLY" + print("ECHO REPLY") exit(1) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) -print "no echo reply" +print("no echo reply") exit(0) diff --git a/regress/sys/netinet6/frag6/frag6_overhead0.py b/regress/sys/netinet6/frag6/frag6_overhead0.py index 190e9177bf8..9d192d6c11e 100644 --- a/regress/sys/netinet6/frag6/frag6_overhead0.py +++ b/regress/sys/netinet6/frag6/frag6_overhead0.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "ping6 fragment that overlaps the first fragment with its head" +print("ping6 fragment that overlaps the first fragment with its head") # |---------| # |XXXX-----| @@ -11,13 +11,13 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/str(packet)[48:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/bytes(packet)[48:64]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -35,16 +35,16 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: - print "ECHO REPLY" + print("ECHO REPLY") exit(1) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) -print "no echo reply" +print("no echo reply") exit(0) diff --git a/regress/sys/netinet6/frag6/frag6_overhead1.py b/regress/sys/netinet6/frag6/frag6_overhead1.py index 31483b1f09d..2f15e0db062 100644 --- a/regress/sys/netinet6/frag6/frag6_overhead1.py +++ b/regress/sys/netinet6/frag6/frag6_overhead1.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "ping6 fragment head that overlaps the first fragment completely" +print("ping6 fragment head that overlaps the first fragment completely") # |---------| # |XXXX| @@ -12,14 +12,14 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1, m=1)/str(packet)[48:56]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1, m=1)/bytes(packet)[48:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/bytes(packet)[56:64]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -37,16 +37,16 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: - print "ECHO REPLY" + print("ECHO REPLY") exit(1) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) -print "no echo reply" +print("no echo reply") exit(0) diff --git a/regress/sys/netinet6/frag6/frag6_overtail.py b/regress/sys/netinet6/frag6/frag6_overtail.py index 4c6dba0fa9d..8c1556eb196 100644 --- a/regress/sys/netinet6/frag6/frag6_overtail.py +++ b/regress/sys/netinet6/frag6/frag6_overtail.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "ping6 fragment that overlaps the last fragment with its tail" +print("ping6 fragment that overlaps the last fragment with its tail") # |----| # |XXXX| @@ -12,14 +12,14 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1, m=1)/str(packet)[48:56]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/bytes(packet)[56:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1, m=1)/bytes(packet)[48:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:56]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -37,16 +37,16 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: - print "ECHO REPLY" + print("ECHO REPLY") exit(1) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) -print "no echo reply" +print("no echo reply") exit(0) diff --git a/regress/sys/netinet6/frag6/frag6_overtail0.py b/regress/sys/netinet6/frag6/frag6_overtail0.py index a627fe9de3b..c5b3ec0a49b 100644 --- a/regress/sys/netinet6/frag6/frag6_overtail0.py +++ b/regress/sys/netinet6/frag6/frag6_overtail0.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "ping6 fragment that overlaps the fist fragment with its tail" +print("ping6 fragment that overlaps the fist fragment with its tail") # |XXXX-----| # |---------| @@ -11,13 +11,13 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/str(packet)[48:64]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/bytes(packet)[48:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:56]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -35,16 +35,16 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: - print "ECHO REPLY" + print("ECHO REPLY") exit(1) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) -print "no echo reply" +print("no echo reply") exit(0) diff --git a/regress/sys/netinet6/frag6/frag6_overtail1.py b/regress/sys/netinet6/frag6/frag6_overtail1.py index eb2460dc3c7..8807dd605b3 100644 --- a/regress/sys/netinet6/frag6/frag6_overtail1.py +++ b/regress/sys/netinet6/frag6/frag6_overtail1.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "ping6 fragment tail that overlaps the first fragment completely" +print("ping6 fragment tail that overlaps the first fragment completely") # |---------| # |XXXX| @@ -12,14 +12,14 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/str(packet)[48:64]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1, m=1)/str(packet)[48:56]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:48]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1)/bytes(packet)[48:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1, m=1)/bytes(packet)[48:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:48]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -37,16 +37,16 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: - print "ECHO REPLY" + print("ECHO REPLY") exit(1) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) -print "no echo reply" +print("no echo reply") exit(0) diff --git a/regress/sys/netinet6/frag6/frag6_padding.py b/regress/sys/netinet6/frag6/frag6_padding.py index 4ca8c073c28..b299f47bc3f 100644 --- a/regress/sys/netinet6/frag6/frag6_padding.py +++ b/regress/sys/netinet6/frag6/frag6_padding.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "non-overlapping ping6 fragments with ethernet padding" +print("non-overlapping ping6 fragments with ethernet padding") # |--------|XX| # |----|XX| @@ -11,17 +11,17 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" -padding="0123" +payload=b"ABCDEFGHIJKLMNOP" +padding=b"0123" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/bytes(packet)[56:64]) eth=[] for f in frag: - pkt=str(IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f) + padding + pkt=bytes(IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f) + padding eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC, type=0x86dd)/pkt) if os.fork() == 0: @@ -36,15 +36,15 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: exit(0) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(1) -print "NO ECHO REPLY" +print("NO ECHO REPLY") exit(2) diff --git a/regress/sys/netinet6/frag6/frag6_permute.py b/regress/sys/netinet6/frag6/frag6_permute.py index de3973ef5ba..9ea015c6bb4 100644 --- a/regress/sys/netinet6/frag6/frag6_permute.py +++ b/regress/sys/netinet6/frag6/frag6_permute.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "send 3 non-overlapping ping6 fragments in all possible orders" +print("send 3 non-overlapping ping6 fragments in all possible orders") # |----| # |----| @@ -19,7 +19,7 @@ permute.append([1,2,0]) permute.append([2,1,0]) pid=os.getpid() -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" for p in permute: pid += 1 eid=pid & 0xffff @@ -28,11 +28,11 @@ for p in permute: frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/ - str(packet)[40:48]) + bytes(packet)[40:48]) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1, m=1)/ - str(packet)[48:56]) + bytes(packet)[48:56]) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/ - str(packet)[56:64]) + bytes(packet)[56:64]) eth=[] for i in range(3): pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/frag[p[i]] @@ -50,16 +50,16 @@ for p in permute: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: break - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(1) else: - print "NO ECHO REPLY" + print("NO ECHO REPLY") exit(2) diff --git a/regress/sys/netinet6/frag6/frag6_queuelimit.py b/regress/sys/netinet6/frag6/frag6_queuelimit.py index 8f14522f6bd..07c69ce2eb3 100644 --- a/regress/sys/netinet6/frag6/frag6_queuelimit.py +++ b/regress/sys/netinet6/frag6/frag6_queuelimit.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "drop too long fragment queue, reassemble less fragments" +print("drop too long fragment queue, reassemble less fragments") # |----| # |----| @@ -14,7 +14,7 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" * 70 +payload=b"ABCDEFGHIJKLMNOP" * 70 frag=[] fid=pid & 0xffffffff # send packets with 65 and 64 fragments @@ -25,9 +25,9 @@ for max in (64, 63): fid = ~fid & 0xffffffff for i in range(max): frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1, - offset=i)/str(packet)[40+i*8:40+(i+1)*8]) + offset=i)/bytes(packet)[40+i*8:40+(i+1)*8]) frag.append(IPv6ExtHdrFragment(nh=58, id=fid, - offset=max)/str(packet)[40+max*8:]) + offset=max)/bytes(packet)[40+max*8:]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -52,20 +52,20 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id == ~eid & 0xffff: - print "ECHO REPLY FROM 65 FRAGMENTS" + print("ECHO REPLY FROM 65 FRAGMENTS") exit(1) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data != payload: - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) reply=True if not reply: - print "NO ECHO REPLY FROM 64 FRAGMENTS" + print("NO ECHO REPLY FROM 64 FRAGMENTS") exit(1) exit(0) diff --git a/regress/sys/netinet6/frag6/frag6_refrag.py b/regress/sys/netinet6/frag6/frag6_refrag.py index 61f6dff4711..ebcdfb0171e 100644 --- a/regress/sys/netinet6/frag6/frag6_refrag.py +++ b/regress/sys/netinet6/frag6/frag6_refrag.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "fragments of a large packet that has to be refragmented by reflector" +print("fragments of a large packet that has to be refragmented by reflector") # |--------| # |------------------| @@ -14,22 +14,22 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload=100 * "ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" * 100 packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) -request_cksum=ICMPv6Unknown(str(packet.payload)).cksum -print "request cksum=%#x" % (request_cksum) +request_cksum=ICMPv6Unknown(bytes(packet.payload)).cksum +print("request cksum=%#x" % (request_cksum)) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:56]) offset=2 chunk=4 while 40+8*(offset+chunk) < len(payload): frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=offset, m=1)/ - str(packet)[40+(8*offset):40+8*(offset+chunk)]) + bytes(packet)[40+(8*offset):40+8*(offset+chunk)]) offset+=chunk frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=offset)/ - str(packet)[40+(8*offset):]) + bytes(packet)[40+(8*offset):]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -49,17 +49,17 @@ for a in ans: ipv6nh[a.payload.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.payload.type] == 'Echo Reply': id=a.payload.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) reply_cksum=a.payload.payload.payload.cksum - print "reply cksum=%#x" % (reply_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 & 0xffff != 0xffff and diff_cksum & 0xffff != 0: - print "CHECKSUM ERROR diff cksum=%#x" % (diff_cksum) + print("CHECKSUM ERROR diff cksum=%#x" % (diff_cksum)) exit(1) exit(0) -print "NO ECHO REPLY" +print("NO ECHO REPLY") exit(2) diff --git a/regress/sys/netinet6/frag6/frag6_shortatomic.py b/regress/sys/netinet6/frag6/frag6_shortatomic.py index 7df4e1e35ab..e6548b2fc52 100644 --- a/regress/sys/netinet6/frag6/frag6_shortatomic.py +++ b/regress/sys/netinet6/frag6/frag6_shortatomic.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "fragment with dest option and atomic fragment without protocol header" +print("fragment with dest option and atomic fragment without protocol header") # |-IP-|-Frag-|-ExtDest-|-ICMP6-|-pay| # |-- atomic fragment --| @@ -12,14 +12,14 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/IPv6ExtHdrDestOpt()/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=60, id=fid, m=1)/str(packet)[40:64]) -frag.append(IPv6ExtHdrFragment(nh=60, id=fid)/str(packet)[40:48]) -frag.append(IPv6ExtHdrFragment(nh=60, id=fid, offset=3)/str(packet)[64:72]) +frag.append(IPv6ExtHdrFragment(nh=60, id=fid, m=1)/bytes(packet)[40:64]) +frag.append(IPv6ExtHdrFragment(nh=60, id=fid)/bytes(packet)[40:48]) +frag.append(IPv6ExtHdrFragment(nh=60, id=fid, offset=3)/bytes(packet)[64:72]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -37,15 +37,15 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: exit(0) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) -print "NO ECHO REPLY" +print("NO ECHO REPLY") exit(1) diff --git a/regress/sys/netinet6/frag6/frag6_timeout.py b/regress/sys/netinet6/frag6/frag6_timeout.py index 63488b16182..7b88986db58 100644 --- a/regress/sys/netinet6/frag6/frag6_timeout.py +++ b/regress/sys/netinet6/frag6/frag6_timeout.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "6 non-overlapping ping6 fragments in 75 seconds, timeout is 60" +print("6 non-overlapping ping6 fragments in 75 seconds, timeout is 60") # |----| # |----| @@ -15,17 +15,17 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcd" +payload=b"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcd" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:48]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1, m=1)/str(packet)[48:56]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2, m=1)/str(packet)[56:64]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=3, m=1)/str(packet)[64:72]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=4, m=1)/str(packet)[72:80]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=5)/str(packet)[80:88]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:48]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=1, m=1)/bytes(packet)[48:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2, m=1)/bytes(packet)[56:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=3, m=1)/bytes(packet)[64:72]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=4, m=1)/bytes(packet)[72:80]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=5)/bytes(packet)[80:88]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -45,16 +45,16 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: - print "ECHO REPLY" + print("ECHO REPLY") exit(1) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) -print "no echo reply" +print("no echo reply") exit(0) diff --git a/regress/sys/netinet6/frag6/frag6_udpatomic.py b/regress/sys/netinet6/frag6/frag6_udpatomic.py index c4e3879dcad..ee681acb9c4 100644 --- a/regress/sys/netinet6/frag6/frag6_udpatomic.py +++ b/regress/sys/netinet6/frag6/frag6_udpatomic.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "atomic udp fragment" +print("atomic udp fragment") # |-------------| @@ -13,12 +13,12 @@ uport=pid & 0xffff # inetd ignores UDP packets from privileged port or nfs if uport < 1024 or uport == 2049: uport+=1024 -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ UDP(sport=uport, dport=7)/payload frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=17, id=fid)/str(packet)[40:64]) +frag.append(IPv6ExtHdrFragment(nh=17, id=fid)/bytes(packet)[40:64]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -36,15 +36,15 @@ for a in ans: ipv6nh[a.payload.nh] == 'UDP' and \ a.payload.payload.sport == 7: port=a.payload.payload.dport - print "port=%d" % (port) + print("port=%d" % (port)) if port != uport: - print "WRONG UDP ECHO REPLY PORT" + print("WRONG UDP ECHO REPLY PORT") exit(2) data=a.payload.payload.load - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: exit(0) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(1) -print "NO UDP ECHO REPLY" +print("NO UDP ECHO REPLY") exit(2) diff --git a/regress/sys/netinet6/frag6/frag6_udpheader.py b/regress/sys/netinet6/frag6/frag6_udpheader.py index f56e1a669d5..2c728c37591 100644 --- a/regress/sys/netinet6/frag6/frag6_udpheader.py +++ b/regress/sys/netinet6/frag6/frag6_udpheader.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "udp fragments splitted after udp header" +print("udp fragments splitted after udp header") # |----| # |--------| @@ -14,13 +14,13 @@ uport=pid & 0xffff # inetd ignores UDP packets from privileged port or nfs if uport < 1024 or uport == 2049: uport+=1024 -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ UDP(sport=uport, dport=7)/payload frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=17, id=fid, m=1)/str(packet)[40:48]) -frag.append(IPv6ExtHdrFragment(nh=17, id=fid, offset=1)/str(packet)[48:64]) +frag.append(IPv6ExtHdrFragment(nh=17, id=fid, m=1)/bytes(packet)[40:48]) +frag.append(IPv6ExtHdrFragment(nh=17, id=fid, offset=1)/bytes(packet)[48:64]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -38,15 +38,15 @@ for a in ans: ipv6nh[a.payload.nh] == 'UDP' and \ a.payload.payload.sport == 7: port=a.payload.payload.dport - print "port=%d" % (port) + print("port=%d" % (port)) if port != uport: - print "WRONG UDP ECHO REPLY PORT" + print("WRONG UDP ECHO REPLY PORT") exit(2) data=a.payload.payload.load - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: exit(0) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(1) -print "NO UDP ECHO REPLY" +print("NO UDP ECHO REPLY") exit(2) diff --git a/regress/sys/netinet6/frag6/frag6_udppayload.py b/regress/sys/netinet6/frag6/frag6_udppayload.py index cc4a995f549..70f91856fd7 100644 --- a/regress/sys/netinet6/frag6/frag6_udppayload.py +++ b/regress/sys/netinet6/frag6/frag6_udppayload.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "udp fragments with splitted payload" +print("udp fragments with splitted payload") # |--------| # |----| @@ -14,13 +14,13 @@ uport=pid & 0xffff # inetd ignores UDP packets from privileged port or nfs if uport < 1024 or uport == 2049: uport+=1024 -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ UDP(sport=uport, dport=7)/payload frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=17, id=fid, m=1)/str(packet)[40:56]) -frag.append(IPv6ExtHdrFragment(nh=17, id=fid, offset=2)/str(packet)[56:64]) +frag.append(IPv6ExtHdrFragment(nh=17, id=fid, m=1)/bytes(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=17, id=fid, offset=2)/bytes(packet)[56:64]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -38,15 +38,15 @@ for a in ans: ipv6nh[a.payload.nh] == 'UDP' and \ a.payload.payload.sport == 7: port=a.payload.payload.dport - print "port=%d" % (port) + print("port=%d" % (port)) if port != uport: - print "WRONG UDP ECHO REPLY PORT" + print("WRONG UDP ECHO REPLY PORT") exit(2) data=a.payload.payload.load - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: exit(0) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(1) -print "NO UDP ECHO REPLY" +print("NO UDP ECHO REPLY") exit(2) diff --git a/regress/sys/netinet6/frag6/frag6_zerofirst.py b/regress/sys/netinet6/frag6/frag6_zerofirst.py index b739ae33aa6..83dd31ff8ec 100644 --- a/regress/sys/netinet6/frag6/frag6_zerofirst.py +++ b/regress/sys/netinet6/frag6/frag6_zerofirst.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "ping6 fragment without payload with other proto before first fragment" +print("ping6 fragment without payload with other proto before first fragment") # || # |---------| @@ -12,14 +12,14 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff frag.append(IPv6ExtHdrFragment(nh=59, id=fid, m=1)) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/bytes(packet)[56:64]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -37,15 +37,15 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: exit(0) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) -print "NO ECHO REPLY" +print("NO ECHO REPLY") exit(1) diff --git a/regress/sys/netinet6/frag6/frag6_zerosecond.py b/regress/sys/netinet6/frag6/frag6_zerosecond.py index 63b2d4ebd6b..44e9d5f1bab 100644 --- a/regress/sys/netinet6/frag6/frag6_zerosecond.py +++ b/regress/sys/netinet6/frag6/frag6_zerosecond.py @@ -1,6 +1,6 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 -print "ping6 fragment without payload with other proto after first fragment" +print("ping6 fragment without payload with other proto after first fragment") # |---------| # || @@ -12,14 +12,14 @@ from scapy.all import * pid=os.getpid() eid=pid & 0xffff -payload="ABCDEFGHIJKLMNOP" +payload=b"ABCDEFGHIJKLMNOP" packet=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/ \ ICMPv6EchoRequest(id=eid, data=payload) frag=[] fid=pid & 0xffffffff -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/str(packet)[40:56]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, m=1)/bytes(packet)[40:56]) frag.append(IPv6ExtHdrFragment(nh=59, id=fid, m=1)) -frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/str(packet)[56:64]) +frag.append(IPv6ExtHdrFragment(nh=58, id=fid, offset=2)/bytes(packet)[56:64]) eth=[] for f in frag: pkt=IPv6(src=LOCAL_ADDR6, dst=REMOTE_ADDR6)/f @@ -37,15 +37,15 @@ for a in ans: ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Echo Reply': id=a.payload.payload.id - print "id=%#x" % (id) + print("id=%#x" % (id)) if id != eid: - print "WRONG ECHO REPLY ID" + print("WRONG ECHO REPLY ID") exit(2) data=a.payload.payload.data - print "payload=%s" % (data) + print("payload=%s" % (data)) if data == payload: exit(0) - print "PAYLOAD!=%s" % (payload) + print("PAYLOAD!=%s" % (payload)) exit(2) -print "NO ECHO REPLY" +print("NO ECHO REPLY") exit(1) |