summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2020-12-25 18:25:44 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2020-12-25 18:25:44 +0000
commit06f63664fb499b0dc80c2d81f0b693baf50432ff (patch)
tree008ba17dfb03c95d31be7fcddad0db391379cdac
parentb076a4ce3441ffde6f43779bde8949af58118170 (diff)
Switch to scapy with python 3.
-rw-r--r--regress/sys/netinet/frag/LICENSE26
-rw-r--r--regress/sys/netinet/frag/Makefile13
-rw-r--r--regress/sys/netinet/frag/frag.py20
-rw-r--r--regress/sys/netinet/frag/frag_maxlen.py21
-rw-r--r--regress/sys/netinet/frag/frag_mf0long.py22
-rw-r--r--regress/sys/netinet/frag/frag_mf0middle.py22
-rw-r--r--regress/sys/netinet/frag/frag_mf0short.py22
-rw-r--r--regress/sys/netinet/frag/frag_mf1end.py22
-rw-r--r--regress/sys/netinet/frag/frag_opt.py20
-rw-r--r--regress/sys/netinet/frag/frag_overhead.py24
-rw-r--r--regress/sys/netinet/frag/frag_overhead0.py22
-rw-r--r--regress/sys/netinet/frag/frag_overhead1.py22
-rw-r--r--regress/sys/netinet/frag/frag_overtail.py22
-rw-r--r--regress/sys/netinet/frag/frag_overtail0.py22
-rw-r--r--regress/sys/netinet/frag/frag_overtail1.py22
-rw-r--r--regress/sys/netinet/frag/frag_padding.py24
-rw-r--r--regress/sys/netinet/frag/frag_permute.py22
-rw-r--r--regress/sys/netinet/frag/frag_queuelimit.py22
-rw-r--r--regress/sys/netinet/frag/frag_refrag.py26
-rw-r--r--regress/sys/netinet/frag/frag_timeout.py30
-rw-r--r--regress/sys/netinet/frag/frag_udpheader.py20
-rw-r--r--regress/sys/netinet/frag/frag_udppayload.py20
-rw-r--r--regress/sys/netinet/frag/frag_zerofirst.py20
-rw-r--r--regress/sys/netinet/frag/frag_zerosecond.py20
24 files changed, 263 insertions, 263 deletions
diff --git a/regress/sys/netinet/frag/LICENSE b/regress/sys/netinet/frag/LICENSE
index 8132b495a44..866739d7ee3 100644
--- a/regress/sys/netinet/frag/LICENSE
+++ b/regress/sys/netinet/frag/LICENSE
@@ -1,13 +1,13 @@
-# Copyright (c) 2012-2017 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/netinet/frag/Makefile b/regress/sys/netinet/frag/Makefile
index 27dfc8c119a..ba046da1758 100644
--- a/regress/sys/netinet/frag/Makefile
+++ b/regress/sys/netinet/frag/Makefile
@@ -1,15 +1,14 @@
-# $OpenBSD: Makefile,v 1.7 2020/12/17 00:51:13 bluhm Exp $
+# $OpenBSD: Makefile,v 1.8 2020/12/25 18:25:43 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/netinet/frag/frag.py b/regress/sys/netinet/frag/frag.py
index 17febd8f63e..8d12a8737ec 100644
--- a/regress/sys/netinet/frag/frag.py
+++ b/regress/sys/netinet/frag/frag.py
@@ -1,6 +1,6 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
-print "non-overlapping ping fragments"
+print("non-overlapping ping fragments")
# |--------|
# |----|
@@ -11,15 +11,15 @@ from scapy.all import *
pid=os.getpid()
eid=pid & 0xffff
-payload="ABCDEFGHIJKLMNOP"
+payload=b"ABCDEFGHIJKLMNOP"
packet=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
ICMP(type='echo-request', id=eid)/payload
frag=[]
fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- flags='MF')/str(packet)[20:36])
+ flags='MF')/bytes(packet)[20:36])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=2)/str(packet)[36:44])
+ frag=2)/bytes(packet)[36:44])
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -37,15 +37,15 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 and \
icmptypes[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.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 ECHO REPLY"
+print("NO ECHO REPLY")
exit(2)
diff --git a/regress/sys/netinet/frag/frag_maxlen.py b/regress/sys/netinet/frag/frag_maxlen.py
index 1e727e29684..7fa8d34be2c 100644
--- a/regress/sys/netinet/frag/frag_maxlen.py
+++ b/regress/sys/netinet/frag/frag_maxlen.py
@@ -1,6 +1,6 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
-print "fully fragmented maximum size ping packet, sent in random order"
+print("fully fragmented maximum size ping packet, sent in random order")
# |----|
# |----|
@@ -17,17 +17,18 @@ pid=os.getpid()
eid=pid & 0xffff
iplen=2**16
size=424
-payload="ABCDEFGHIJKLMNOP" * (iplen / 16)
+payload=b"ABCDEFGHIJKLMNOP" * int(iplen / 16)
packet=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
- ICMP(type='echo-request', id=eid)/str(payload)[0:iplen-20-8-1]
+ ICMP(type='echo-request', id=eid)/bytes(payload)[0:iplen-20-8-1]
frag=[]
fid=pid & 0xffff
-max=(iplen-20)/size
+max=int((iplen-20)/size)
for i in range(max):
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=i*(size/8), flags='MF')/str(packet)[20+i*size:20+(i+1)*size])
+ frag=i*int(size/8), flags='MF')/
+ bytes(packet)[20+i*size:20+(i+1)*size])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=max*(size/8))/str(packet)[20+max*size:])
+ frag=max*int(size/8))/bytes(packet)[20+max*size:])
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -53,10 +54,10 @@ for a in ans:
a.payload.proto == 1 and \
icmptypes[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)
exit(0)
-print "NO ECHO REPLY"
+print("NO ECHO REPLY")
exit(1)
diff --git a/regress/sys/netinet/frag/frag_mf0long.py b/regress/sys/netinet/frag/frag_mf0long.py
index c3a3b3782b0..4d16574601d 100644
--- a/regress/sys/netinet/frag/frag_mf0long.py
+++ b/regress/sys/netinet/frag/frag_mf0long.py
@@ -1,6 +1,6 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
-print "ping fragment that overlaps longer than the last fragment without MF"
+print("ping fragment that overlaps longer than the last fragment without MF")
# |---------|
# |XXXX|
@@ -12,18 +12,18 @@ from scapy.all import *
pid=os.getpid()
eid=pid & 0xffff
-payload="ABCDEFGHIJKLMNOP"
-dummy="01234567"
+payload=b"ABCDEFGHIJKLMNOP"
+dummy=b"01234567"
packet=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
ICMP(type='echo-request', id=eid)/payload
frag=[]
fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=1)/str(packet)[28:44])
+ frag=1)/bytes(packet)[28:44])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
frag=3)/dummy)
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- flags='MF')/str(packet)[20:28])
+ flags='MF')/bytes(packet)[20:28])
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -41,15 +41,15 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 and \
icmptypes[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.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 ECHO REPLY"
+print("NO ECHO REPLY")
exit(2)
diff --git a/regress/sys/netinet/frag/frag_mf0middle.py b/regress/sys/netinet/frag/frag_mf0middle.py
index e8cf64fc755..f92c9b62476 100644
--- a/regress/sys/netinet/frag/frag_mf0middle.py
+++ b/regress/sys/netinet/frag/frag_mf0middle.py
@@ -1,6 +1,6 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
-print "ping fragment without MF that overlaps the first fragment"
+print("ping fragment without MF that overlaps the first fragment")
# |---------|
# |XXXX|
@@ -12,18 +12,18 @@ from scapy.all import *
pid=os.getpid()
eid=pid & 0xffff
-payload="ABCDEFGHIJKLMNOP"
-dummy="01234567"
+payload=b"ABCDEFGHIJKLMNOP"
+dummy=b"01234567"
packet=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
ICMP(type='echo-request', id=eid)/payload
frag=[]
fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- flags='MF')/str(packet)[20:36])
+ flags='MF')/bytes(packet)[20:36])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
frag=1)/dummy)
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=2)/str(packet)[36:44])
+ frag=2)/bytes(packet)[36:44])
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -41,15 +41,15 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 and \
icmptypes[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.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 ECHO REPLY"
+print("NO ECHO REPLY")
exit(2)
diff --git a/regress/sys/netinet/frag/frag_mf0short.py b/regress/sys/netinet/frag/frag_mf0short.py
index b072d596009..870afdf727d 100644
--- a/regress/sys/netinet/frag/frag_mf0short.py
+++ b/regress/sys/netinet/frag/frag_mf0short.py
@@ -1,6 +1,6 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
-print "ping fragment without MF that overlaps the last fragment at beginning"
+print("ping fragment without MF that overlaps the last fragment at beginning")
# |---------|
# |XXXXXXXXX|
@@ -12,18 +12,18 @@ from scapy.all import *
pid=os.getpid()
eid=pid & 0xffff
-payload="ABCDEFGHIJKLMNOPQRSTUVWX"
-dummy="0123456701234567"
+payload=b"ABCDEFGHIJKLMNOPQRSTUVWX"
+dummy=b"0123456701234567"
packet=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
ICMP(type='echo-request', id=eid)/payload
frag=[]
fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=2)/str(packet)[36:52])
+ frag=2)/bytes(packet)[36:52])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
frag=1)/dummy)
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- flags='MF')/str(packet)[20:36])
+ flags='MF')/bytes(packet)[20:36])
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -41,15 +41,15 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 and \
icmptypes[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.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 ECHO REPLY"
+print("NO ECHO REPLY")
exit(2)
diff --git a/regress/sys/netinet/frag/frag_mf1end.py b/regress/sys/netinet/frag/frag_mf1end.py
index 27713bba740..1da1944db19 100644
--- a/regress/sys/netinet/frag/frag_mf1end.py
+++ b/regress/sys/netinet/frag/frag_mf1end.py
@@ -1,6 +1,6 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
-print "ping fragment with MF that overlaps fragment without MF at the end"
+print("ping fragment with MF that overlaps fragment without MF at the end")
# |----|
# |XXXXXXXXX|
@@ -12,18 +12,18 @@ from scapy.all import *
pid=os.getpid()
eid=pid & 0xffff
-payload="ABCDEFGHIJKLMNOP"
-dummy="0123456701234567"
+payload=b"ABCDEFGHIJKLMNOP"
+dummy=b"0123456701234567"
packet=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
ICMP(type='echo-request', id=eid)/payload
frag=[]
fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=2)/str(packet)[36:44])
+ frag=2)/bytes(packet)[36:44])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
frag=1, flags='MF')/dummy)
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- flags='MF')/str(packet)[20:36])
+ flags='MF')/bytes(packet)[20:36])
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -41,15 +41,15 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 and \
icmptypes[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.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 ECHO REPLY"
+print("NO ECHO REPLY")
exit(2)
diff --git a/regress/sys/netinet/frag/frag_opt.py b/regress/sys/netinet/frag/frag_opt.py
index 877b57f3bf2..0cc645ce211 100644
--- a/regress/sys/netinet/frag/frag_opt.py
+++ b/regress/sys/netinet/frag/frag_opt.py
@@ -1,6 +1,6 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
-print "ping fragments with IP option"
+print("ping fragments with IP option")
# OO|--------|
# OO|----|
@@ -11,15 +11,15 @@ from scapy.all import *
pid=os.getpid()
eid=pid & 0xffff
-payload="ABCDEFGHIJKLMNOP"
+payload=b"ABCDEFGHIJKLMNOP"
packet=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
ICMP(type='echo-request', id=eid)/payload
frag=[]
fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- flags='MF', options=IPOption_NOP())/str(packet)[20:36])
+ flags='MF', options=IPOption_NOP())/bytes(packet)[20:36])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=2, options=IPOption_NOP())/str(packet)[36:44])
+ frag=2, options=IPOption_NOP())/bytes(packet)[36:44])
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -37,15 +37,15 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 and \
icmptypes[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.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 ECHO REPLY"
+print("NO ECHO REPLY")
exit(2)
diff --git a/regress/sys/netinet/frag/frag_overhead.py b/regress/sys/netinet/frag/frag_overhead.py
index 43cb8c1b7c5..67b0d79dd0f 100644
--- a/regress/sys/netinet/frag/frag_overhead.py
+++ b/regress/sys/netinet/frag/frag_overhead.py
@@ -1,6 +1,6 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
-print "ping fragment that overlaps the second fragment with its head"
+print("ping fragment that overlaps the second fragment with its head")
# |----|
# |----|
@@ -12,18 +12,18 @@ from scapy.all import *
pid=os.getpid()
eid=pid & 0xffff
-payload="ABCDEFGHIJKLMNOP"
-dummy="01234567"
+payload=b"ABCDEFGHIJKLMNOP"
+dummy=b"01234567"
packet=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
ICMP(type='echo-request', id=eid)/payload
frag=[]
fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- flags='MF')/str(packet)[20:28])
+ flags='MF')/bytes(packet)[20:28])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=1, flags='MF')/str(packet)[28:36])
+ frag=1, flags='MF')/bytes(packet)[28:36])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=1)/(dummy+str(packet)[36:44]))
+ frag=1)/(dummy+bytes(packet)[36:44]))
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -41,15 +41,15 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 and \
icmptypes[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.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 ECHO REPLY"
+print("NO ECHO REPLY")
exit(2)
diff --git a/regress/sys/netinet/frag/frag_overhead0.py b/regress/sys/netinet/frag/frag_overhead0.py
index 0a1f64721d7..db135f34977 100644
--- a/regress/sys/netinet/frag/frag_overhead0.py
+++ b/regress/sys/netinet/frag/frag_overhead0.py
@@ -1,6 +1,6 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
-print "ping fragment that overlaps the first fragment with its head"
+print("ping fragment that overlaps the first fragment with its head")
# |---------|
# |XXXX-----|
@@ -11,16 +11,16 @@ from scapy.all import *
pid=os.getpid()
eid=pid & 0xffff
-payload="ABCDEFGHIJKLMNOP"
-dummy="01234567"
+payload=b"ABCDEFGHIJKLMNOP"
+dummy=b"01234567"
packet=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
ICMP(type='echo-request', id=eid)/payload
frag=[]
fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- flags='MF')/str(packet)[20:36])
+ flags='MF')/bytes(packet)[20:36])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=1)/(dummy+str(packet)[36:44]))
+ frag=1)/(dummy+bytes(packet)[36:44]))
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -38,15 +38,15 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 and \
icmptypes[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.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 ECHO REPLY"
+print("NO ECHO REPLY")
exit(2)
diff --git a/regress/sys/netinet/frag/frag_overhead1.py b/regress/sys/netinet/frag/frag_overhead1.py
index d7ab1f17884..e2edf293a7e 100644
--- a/regress/sys/netinet/frag/frag_overhead1.py
+++ b/regress/sys/netinet/frag/frag_overhead1.py
@@ -1,6 +1,6 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
-print "ping fragment head that overlaps the first fragment completely"
+print("ping fragment head that overlaps the first fragment completely")
# |---------|
# |XXXX|
@@ -12,18 +12,18 @@ from scapy.all import *
pid=os.getpid()
eid=pid & 0xffff
-payload="ABCDEFGHIJKLMNOP"
-dummy="01234567"
+payload=b"ABCDEFGHIJKLMNOP"
+dummy=b"01234567"
packet=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
ICMP(type='echo-request', id=eid)/payload
frag=[]
fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- flags='MF')/str(packet)[20:36])
+ flags='MF')/bytes(packet)[20:36])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
frag=1, flags='MF')/dummy)
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=2)/str(packet)[36:44])
+ frag=2)/bytes(packet)[36:44])
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -41,15 +41,15 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 and \
icmptypes[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.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 ECHO REPLY"
+print("NO ECHO REPLY")
exit(2)
diff --git a/regress/sys/netinet/frag/frag_overtail.py b/regress/sys/netinet/frag/frag_overtail.py
index 1052aa32e38..236fdf5d970 100644
--- a/regress/sys/netinet/frag/frag_overtail.py
+++ b/regress/sys/netinet/frag/frag_overtail.py
@@ -1,6 +1,6 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
-print "ping fragment that overlaps the second fragment with its tail"
+print("ping fragment that overlaps the second fragment with its tail")
# |----|
# |XXXX|
@@ -12,18 +12,18 @@ from scapy.all import *
pid=os.getpid()
eid=pid & 0xffff
-payload="ABCDEFGHIJKLMNOP"
-dummy="01234567"
+payload=b"ABCDEFGHIJKLMNOP"
+dummy=b"01234567"
packet=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
ICMP(type='echo-request', id=eid)/payload
frag=[]
fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=2)/str(packet)[36:44])
+ frag=2)/bytes(packet)[36:44])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
frag=1, flags='MF')/dummy)
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- flags='MF')/str(packet)[20:36])
+ flags='MF')/bytes(packet)[20:36])
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -41,15 +41,15 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 and \
icmptypes[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.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 ECHO REPLY"
+print("NO ECHO REPLY")
exit(2)
diff --git a/regress/sys/netinet/frag/frag_overtail0.py b/regress/sys/netinet/frag/frag_overtail0.py
index 4c828b43b8a..e917fbee08c 100644
--- a/regress/sys/netinet/frag/frag_overtail0.py
+++ b/regress/sys/netinet/frag/frag_overtail0.py
@@ -1,6 +1,6 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
-print "ping fragment that overlaps the first fragment with its tail"
+print("ping fragment that overlaps the first fragment with its tail")
# |XXXX-----|
# |---------|
@@ -11,16 +11,16 @@ from scapy.all import *
pid=os.getpid()
eid=pid & 0xffff
-payload="ABCDEFGHIJKLMNOP"
-dummy="01234567"
+payload=b"ABCDEFGHIJKLMNOP"
+dummy=b"01234567"
packet=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
ICMP(type='echo-request', id=eid)/payload
frag=[]
fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=1)/(dummy+str(packet)[36:44]))
+ frag=1)/(dummy+bytes(packet)[36:44]))
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- flags='MF')/str(packet)[20:36])
+ flags='MF')/bytes(packet)[20:36])
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -38,15 +38,15 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 and \
icmptypes[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.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 ECHO REPLY"
+print("NO ECHO REPLY")
exit(2)
diff --git a/regress/sys/netinet/frag/frag_overtail1.py b/regress/sys/netinet/frag/frag_overtail1.py
index 8f37e350ca4..b0a25dc4bf5 100644
--- a/regress/sys/netinet/frag/frag_overtail1.py
+++ b/regress/sys/netinet/frag/frag_overtail1.py
@@ -1,6 +1,6 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
-print "ping fragment tail that overlaps the first fragment completely"
+print("ping fragment tail that overlaps the first fragment completely")
# |---------|
# |XXXX|
@@ -12,18 +12,18 @@ from scapy.all import *
pid=os.getpid()
eid=pid & 0xffff
-payload="ABCDEFGHIJKLMNOP"
-dummy="01234567"
+payload=b"ABCDEFGHIJKLMNOP"
+dummy=b"01234567"
packet=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
ICMP(type='echo-request', id=eid)/payload
frag=[]
fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=1)/str(packet)[28:44])
+ frag=1)/bytes(packet)[28:44])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
frag=1, flags='MF')/dummy)
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- flags='MF')/str(packet)[20:28])
+ flags='MF')/bytes(packet)[20:28])
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -41,15 +41,15 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 and \
icmptypes[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.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 ECHO REPLY"
+print("NO ECHO REPLY")
exit(2)
diff --git a/regress/sys/netinet/frag/frag_padding.py b/regress/sys/netinet/frag/frag_padding.py
index f6117ff7afb..1226b7e6475 100644
--- a/regress/sys/netinet/frag/frag_padding.py
+++ b/regress/sys/netinet/frag/frag_padding.py
@@ -1,6 +1,6 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
-print "non-overlapping ping fragments with ethernet padding"
+print("non-overlapping ping fragments with ethernet padding")
# |--------|XX|
# |----|XX|
@@ -11,19 +11,19 @@ from scapy.all import *
pid=os.getpid()
eid=pid & 0xffff
-payload="ABCDEFGHIJKLMNOP"
-padding="0123"
+payload=b"ABCDEFGHIJKLMNOP"
+padding=b"0123"
packet=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
ICMP(type='echo-request', id=eid)/payload
frag=[]
fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- flags='MF')/str(packet)[20:36])
+ flags='MF')/bytes(packet)[20:36])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=2)/str(packet)[36:44])
+ frag=2)/bytes(packet)[36:44])
eth=[]
for f in frag:
- pkt=str(f) + padding
+ pkt=bytes(f) + padding
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC, type=0x0800)/pkt)
if os.fork() == 0:
@@ -39,15 +39,15 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 and \
icmptypes[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.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 ECHO REPLY"
+print("NO ECHO REPLY")
exit(2)
diff --git a/regress/sys/netinet/frag/frag_permute.py b/regress/sys/netinet/frag/frag_permute.py
index d3a1cc02efc..45c6f1f7c44 100644
--- a/regress/sys/netinet/frag/frag_permute.py
+++ b/regress/sys/netinet/frag/frag_permute.py
@@ -1,6 +1,6 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
-print "send 3 non-overlapping ping fragments in all possible orders"
+print("send 3 non-overlapping ping 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 & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- flags='MF')/str(packet)[20:28])
+ flags='MF')/bytes(packet)[20:28])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=1, flags='MF')/str(packet)[28:36])
+ frag=1, flags='MF')/bytes(packet)[28:36])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=2)/str(packet)[36:48])
+ frag=2)/bytes(packet)[36:48])
eth=[]
for i in range(3):
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/frag[p[i]])
@@ -50,16 +50,16 @@ for p in permute:
a.payload.frag == 0 and a.payload.flags == 0 and \
icmptypes[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.payload.load
- 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/netinet/frag/frag_queuelimit.py b/regress/sys/netinet/frag/frag_queuelimit.py
index 2edf4b6d3cf..0e89a1ae79e 100644
--- a/regress/sys/netinet/frag/frag_queuelimit.py
+++ b/regress/sys/netinet/frag/frag_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 & 0xffff
# send packets with 65 and 64 fragments
@@ -25,9 +25,9 @@ for max in (64, 63):
fid = ~fid & 0xffff
for i in range(max):
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=i, flags='MF')/str(packet)[20+i*8:20+(i+1)*8])
+ frag=i, flags='MF')/bytes(packet)[20+i*8:20+(i+1)*8])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=max)/str(packet)[20+max*8:])
+ frag=max)/bytes(packet)[20+max*8:])
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -52,20 +52,20 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 and \
icmptypes[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.payload.load
- 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/netinet/frag/frag_refrag.py b/regress/sys/netinet/frag/frag_refrag.py
index 9ac27897f8e..0171d9e98ef 100644
--- a/regress/sys/netinet/frag/frag_refrag.py
+++ b/regress/sys/netinet/frag/frag_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,24 +14,24 @@ from scapy.all import *
pid=os.getpid()
eid=pid & 0xffff
-payload=100 * "ABCDEFGHIJKLMNOP"
+payload=b"ABCDEFGHIJKLMNOP" * 100
packet=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
ICMP(type='echo-request', id=eid)/payload
-request_cksum=ICMP(str(packet.payload)).chksum
-print "request cksum=%#x" % (request_cksum)
+request_cksum=ICMP(bytes(packet.payload)).chksum
+print("request cksum=%#x" % (request_cksum))
frag=[]
fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid, flags='MF')/
- str(packet)[20:36])
+ bytes(packet)[20:36])
offset=2
chunk=4
while 40+8*(offset+chunk) < len(payload):
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
frag=offset, flags='MF')/
- str(packet)[20+(8*offset):20+8*(offset+chunk)])
+ bytes(packet)[20+(8*offset):20+8*(offset+chunk)])
offset+=chunk
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=offset)/str(packet)[20+(8*offset):])
+ frag=offset)/bytes(packet)[20+(8*offset):])
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -49,17 +49,17 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 1 and \
icmptypes[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)
reply_cksum=a.payload.payload.chksum
- 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+~0x0800+0x0000))
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/netinet/frag/frag_timeout.py b/regress/sys/netinet/frag/frag_timeout.py
index e33af304cc0..0487adfcc98 100644
--- a/regress/sys/netinet/frag/frag_timeout.py
+++ b/regress/sys/netinet/frag/frag_timeout.py
@@ -1,6 +1,6 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
-print "6 non-overlapping ping fragments in 75 seconds, timeout is 60"
+print("6 non-overlapping ping fragments in 75 seconds, timeout is 60")
# |----|
# |----|
@@ -15,23 +15,23 @@ from scapy.all import *
pid=os.getpid()
eid=pid & 0xffff
-payload="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcd"
+payload=b"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcd"
packet=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
ICMP(type='echo-request', id=eid)/payload
frag=[]
fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- flags='MF')/str(packet)[20:28])
+ flags='MF')/bytes(packet)[20:28])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=1, flags='MF')/str(packet)[28:36])
+ frag=1, flags='MF')/bytes(packet)[28:36])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=2, flags='MF')/str(packet)[36:44])
+ frag=2, flags='MF')/bytes(packet)[36:44])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=3, flags='MF')/str(packet)[44:52])
+ frag=3, flags='MF')/bytes(packet)[44:52])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=4, flags='MF')/str(packet)[52:60])
+ frag=4, flags='MF')/bytes(packet)[52:60])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=5)/str(packet)[60:68])
+ frag=5)/bytes(packet)[60:68])
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -51,16 +51,16 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 and \
icmptypes[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.payload.load
- 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(1)
-print "no echo reply"
+print("no echo reply")
exit(0)
diff --git a/regress/sys/netinet/frag/frag_udpheader.py b/regress/sys/netinet/frag/frag_udpheader.py
index f187b1f92ab..9c173fe07f5 100644
--- a/regress/sys/netinet/frag/frag_udpheader.py
+++ b/regress/sys/netinet/frag/frag_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,15 +14,15 @@ 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=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
UDP(sport=uport, dport=7)/payload
frag=[]
fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=17, id=fid,
- flags='MF')/str(packet)[20:28])
+ flags='MF')/bytes(packet)[20:28])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=17, id=fid,
- frag=1)/str(packet)[28:44])
+ frag=1)/bytes(packet)[28:44])
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -40,15 +40,15 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 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.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/netinet/frag/frag_udppayload.py b/regress/sys/netinet/frag/frag_udppayload.py
index 97cc4eb3427..e91a720a0c3 100644
--- a/regress/sys/netinet/frag/frag_udppayload.py
+++ b/regress/sys/netinet/frag/frag_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,15 +14,15 @@ 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=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
UDP(sport=uport, dport=7)/payload
frag=[]
fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=17, id=fid,
- flags='MF')/str(packet)[20:36])
+ flags='MF')/bytes(packet)[20:36])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=17, id=fid,
- frag=2)/str(packet)[36:44])
+ frag=2)/bytes(packet)[36:44])
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -40,15 +40,15 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 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.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/netinet/frag/frag_zerofirst.py b/regress/sys/netinet/frag/frag_zerofirst.py
index 2a5991fd2db..8bac8854322 100644
--- a/regress/sys/netinet/frag/frag_zerofirst.py
+++ b/regress/sys/netinet/frag/frag_zerofirst.py
@@ -1,6 +1,6 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
-print "ping fragment without payload before first fragment"
+print("ping fragment without payload before first fragment")
# ||
# |--------|
@@ -12,7 +12,7 @@ from scapy.all import *
pid=os.getpid()
eid=pid & 0xffff
-payload="ABCDEFGHIJKLMNOP"
+payload=b"ABCDEFGHIJKLMNOP"
packet=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
ICMP(type='echo-request', id=eid)/payload
frag=[]
@@ -20,9 +20,9 @@ fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
flags='MF'))
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- flags='MF')/str(packet)[20:36])
+ flags='MF')/bytes(packet)[20:36])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=2)/str(packet)[36:44])
+ frag=2)/bytes(packet)[36:44])
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -40,15 +40,15 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 and \
icmptypes[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.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 ECHO REPLY"
+print("NO ECHO REPLY")
exit(2)
diff --git a/regress/sys/netinet/frag/frag_zerosecond.py b/regress/sys/netinet/frag/frag_zerosecond.py
index 4522ee2e435..db8452e0b01 100644
--- a/regress/sys/netinet/frag/frag_zerosecond.py
+++ b/regress/sys/netinet/frag/frag_zerosecond.py
@@ -1,6 +1,6 @@
-#!/usr/local/bin/python2.7
+#!/usr/local/bin/python3
-print "ping fragment without payload after first fragment"
+print("ping fragment without payload after first fragment")
# |--------|
# ||
@@ -12,17 +12,17 @@ from scapy.all import *
pid=os.getpid()
eid=pid & 0xffff
-payload="ABCDEFGHIJKLMNOP"
+payload=b"ABCDEFGHIJKLMNOP"
packet=IP(src=LOCAL_ADDR, dst=REMOTE_ADDR)/ \
ICMP(type='echo-request', id=eid)/payload
frag=[]
fid=pid & 0xffff
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- flags='MF')/str(packet)[20:36])
+ flags='MF')/bytes(packet)[20:36])
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
flags='MF'))
frag.append(IP(src=LOCAL_ADDR, dst=REMOTE_ADDR, proto=1, id=fid,
- frag=2)/str(packet)[36:44])
+ frag=2)/bytes(packet)[36:44])
eth=[]
for f in frag:
eth.append(Ether(src=LOCAL_MAC, dst=REMOTE_MAC)/f)
@@ -40,15 +40,15 @@ for a in ans:
a.payload.frag == 0 and a.payload.flags == 0 and \
icmptypes[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.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 ECHO REPLY"
+print("NO ECHO REPLY")
exit(2)