diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2020-12-24 22:39:58 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2020-12-24 22:39:58 +0000 |
commit | b6a637057dd888656856c3388db1085832e141d8 (patch) | |
tree | 5ecf7d5a564dcee864979a98f3802b762650bc79 | |
parent | 14397865a676d26e7f73ea4897f12dc1db8a3406 (diff) |
Switch to scapy with python 3.
-rw-r--r-- | regress/sys/net/pf_forward/Makefile | 12 | ||||
-rw-r--r-- | regress/sys/net/pf_forward/ping6_mtu.py | 20 | ||||
-rw-r--r-- | regress/sys/net/pf_forward/ping_mtu.py | 20 |
3 files changed, 26 insertions, 26 deletions
diff --git a/regress/sys/net/pf_forward/Makefile b/regress/sys/net/pf_forward/Makefile index 6416b6baded..aea57f25406 100644 --- a/regress/sys/net/pf_forward/Makefile +++ b/regress/sys/net/pf_forward/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.32 2020/12/17 00:51:12 bluhm Exp $ +# $OpenBSD: Makefile,v 1.33 2020/12/24 22:39:57 bluhm Exp $ # Copyright (c) 2012-2020 Alexander Bluhm <bluhm@openbsd.org> # @@ -18,9 +18,9 @@ # # scapy powerful interactive packet manipulation in python -.if ! exists(/usr/local/bin/scapy) +.if ! exists(/usr/local/bin/scapy-3) regress: - @echo Install scapy package to run this regress. + @echo Install py3-scapy package to run this regress. @echo SKIPPED .endif @@ -108,10 +108,10 @@ regress: .if ! empty (PF_SSH) .if make (regress) || make (all) .BEGIN: - @echo ${SUDO} true ssh -t ${PF_SSH} ${SUDO} true rm -f stamp-pfctl + @echo .endif .endif @@ -142,9 +142,9 @@ stamp-pfctl: addr.py pf.conf # 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 .for inet in inet inet6 diff --git a/regress/sys/net/pf_forward/ping6_mtu.py b/regress/sys/net/pf_forward/ping6_mtu.py index 405e2d635c3..9d938a0ad48 100644 --- a/regress/sys/net/pf_forward/ping6_mtu.py +++ b/regress/sys/net/pf_forward/ping6_mtu.py @@ -1,4 +1,4 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 # check wether path mtu to dst is as expected import os @@ -26,9 +26,9 @@ size=int(sys.argv[3]) expect=int(sys.argv[4]) eid=os.getpid() & 0xffff hdr=IPv6(src=srcaddr, dst=dstaddr)/ICMPv6EchoRequest(id=eid) -payload="a" * (size - len(str(hdr))) +payload="a" * (size - len(bytes(hdr))) ip=hdr/payload -iplen=IPv6(str(ip)).plen +iplen=IPv6(bytes(ip)).plen eth=Ether(src=SRC_MAC, dst=PF_MAC)/ip sniffer = Sniff1(); @@ -42,29 +42,29 @@ sniffer.join(timeout=5) a = sniffer.packet if a is None: - print "no packet sniffed" + print("no packet sniffed") exit(2) if a and a.type == ETH_P_IPV6 and \ ipv6nh[a.payload.nh] == 'ICMPv6' and \ icmp6types[a.payload.payload.type] == 'Packet too big': mtu=a.payload.payload.mtu - print "mtu=%d" % (mtu) + print("mtu=%d" % (mtu)) if mtu != expect: - print "MTU!=%d" % (expect) + print("MTU!=%d" % (expect)) exit(1) iip=a.payload.payload.payload iiplen=iip.plen if iiplen != iplen: - print "inner IPv6 plen %d!=%d" % (iiplen, iplen) + print("inner IPv6 plen %d!=%d" % (iiplen, iplen)) exit(1) isrc=iip.src if isrc != srcaddr: - print "inner IPv6 src %d!=%d" % (isrc, srcaddr) + print("inner IPv6 src %d!=%d" % (isrc, srcaddr)) exit(1) idst=iip.dst if idst != dstaddr: - print "inner IPv6 dst %d!=%d" % (idst, dstaddr) + print("inner IPv6 dst %d!=%d" % (idst, dstaddr)) exit(1) exit(0) -print "MTU=UNKNOWN" +print("MTU=UNKNOWN") exit(2) diff --git a/regress/sys/net/pf_forward/ping_mtu.py b/regress/sys/net/pf_forward/ping_mtu.py index 7e952ab0046..aa8470d05ab 100644 --- a/regress/sys/net/pf_forward/ping_mtu.py +++ b/regress/sys/net/pf_forward/ping_mtu.py @@ -1,4 +1,4 @@ -#!/usr/local/bin/python2.7 +#!/usr/local/bin/python3 # check wether path mtu to dst is as expected import os @@ -13,34 +13,34 @@ size=int(sys.argv[3]) expect=int(sys.argv[4]) eid=os.getpid() & 0xffff hdr=IP(flags="DF", src=srcaddr, dst=dstaddr)/ICMP(type='echo-request', id=eid) -payload="a" * (size - len(str(hdr))) +payload="a" * (size - len(bytes(hdr))) ip=hdr/payload -iplen=IP(str(ip)).len +iplen=IP(bytes(ip)).len eth=Ether(src=SRC_MAC, dst=PF_MAC)/ip a=srp1(eth, iface=SRC_IF, timeout=2) if a is None: - print "no packet sniffed" + print("no packet sniffed") exit(2) if a and a.payload.payload.type==3 and a.payload.payload.code==4: mtu=a.payload.payload.nexthopmtu - print "mtu=%d" % (mtu) + print("mtu=%d" % (mtu)) if mtu != expect: - print "MTU!=%d" % (expect) + print("MTU!=%d" % (expect)) exit(1) iip=a.payload.payload.payload iiplen=iip.len if iiplen != iplen: - print "inner IP len %d!=%d" % (iiplen, iplen) + print("inner IP len %d!=%d" % (iiplen, iplen)) exit(1) isrc=iip.src if isrc != srcaddr: - print "inner IP src %d!=%d" % (isrc, srcaddr) + print("inner IP src %d!=%d" % (isrc, srcaddr)) exit(1) idst=iip.dst if idst != dstaddr: - print "inner IP dst %d!=%d" % (idst, dstaddr) + print("inner IP dst %d!=%d" % (idst, dstaddr)) exit(1) exit(0) -print "MTU=UNKNOWN" +print("MTU=UNKNOWN") exit(2) |