Date: Wed, 6 Nov 2019 17:56:47 +0000 (UTC) From: Li-Wen Hsu <lwhsu@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r516910 - in head/net/scapy: . files Message-ID: <201911061756.xA6Hulf8084543@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: lwhsu Date: Wed Nov 6 17:56:47 2019 New Revision: 516910 URL: https://svnweb.freebsd.org/changeset/ports/516910 Log: Add a patch which fixes both the alignment on (32bit) platforms where sizeof(long) == 4 and for i386 the offset on the bpf_hdr struct as time_t still is 32bit. PR: 239380 Approved by: bofh (maintainer) Sponsored by: Netflix (bz) Sponsored by: The FreeBSD Foundation (lwhsu) Added: head/net/scapy/files/ head/net/scapy/files/patch-i386 (contents, props changed) Modified: head/net/scapy/Makefile Modified: head/net/scapy/Makefile ============================================================================== --- head/net/scapy/Makefile Wed Nov 6 17:39:03 2019 (r516909) +++ head/net/scapy/Makefile Wed Nov 6 17:56:47 2019 (r516910) @@ -3,7 +3,7 @@ PORTNAME= scapy PORTVERSION= 2.4.3 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= net python MASTER_SITES= CHEESESHOP PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} Added: head/net/scapy/files/patch-i386 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/scapy/files/patch-i386 Wed Nov 6 17:56:47 2019 (r516910) @@ -0,0 +1,50 @@ +--- scapy/arch/bpf/supersocket.py.orig 2019-07-29 18:49:37 UTC ++++ scapy/arch/bpf/supersocket.py +@@ -4,9 +4,11 @@ + Scapy *BSD native support - BPF sockets + """ + ++from ctypes import c_long, sizeof + import errno + import fcntl + import os ++import platform + from select import select + import struct + import time +@@ -23,7 +25,10 @@ from scapy.supersocket import SuperSocket + from scapy.compat import raw + + +-if FREEBSD or NETBSD: ++if FREEBSD: ++ # On 32bit architectures long might be 32bit. ++ BPF_ALIGNMENT = sizeof(c_long) ++elif NETBSD: + BPF_ALIGNMENT = 8 # sizeof(long) + else: + BPF_ALIGNMENT = 4 # sizeof(int32_t) +@@ -260,8 +265,21 @@ class L2bpfListenSocket(_L2bpfSocket): + return + + # Extract useful information from the BPF header +- if FREEBSD or NETBSD: +- # struct bpf_xhdr or struct bpf_hdr32 ++ if FREEBSD: ++ # Unless we set BIOCSTSTAMP to something different than BPF_T_MICROTIME ++ # we will get bpf_hdr on FreeBSD, which means that we'll get a ++ # struct timeval, which is time_t, suseconds_t. ++ # On i386 time_t still is 32bit so the bh_tstamp will only be 8 bytes. ++ # We really want to set BIOCSTSTAMP to BPF_T_NANOTIME and be done with this ++ # and it always be 16? ++ if platform.machine() == "i386": ++ # struct bpf_hdr ++ bh_tstamp_offset = 8 ++ else: ++ # struct bpf_hdr (64bit time_t) or struct bpf_xhdr ++ bh_tstamp_offset = 16 ++ elif NETBSD: ++ # struct bpf_hdr or struct bpf_hdr32 + bh_tstamp_offset = 16 + else: + # struct bpf_hdr
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201911061756.xA6Hulf8084543>