$OpenBSD: patch-scapy_arch_bpf_consts_py,v 1.1 2018/07/30 14:27:37 bluhm Exp $

https://github.com/secdev/scapy/pull/1538

commit e5ed0aab5a2028d8807b98e444c2e04cd29ba7b6 (origin/ioctl-sizeof, ioctl-sizeof)
Author: Alexander Bluhm <alexander.bluhm@gmx.net>
Date:   Thu Jul 26 16:52:36 2018 +0200

    Calculate BIOCSETF ioctl constant for 32 bit architectures.
    
    The size of the ioctl(2) argument is embeded in the constant.  Struct
    bpf_program is 16 bytes on 64 bit architectures but only 8 bytes
    on 32 bit architectures.  Use ctypes to calculate the size dynamically
    in Python and adjust BIOCSETF.  Fixes sniff(filter="ip") on
    OpenBSD/i386.

Index: scapy/arch/bpf/consts.py
--- scapy/arch/bpf/consts.py.orig
+++ scapy/arch/bpf/consts.py
@@ -4,6 +4,7 @@
 Scapy *BSD native support - constants
 """
 
+from ctypes import Structure, c_uint, c_void_p, sizeof
 
 from scapy.data import MTU
 
@@ -12,13 +13,19 @@ SIOCGIFFLAGS = 0xc0206911
 BPF_BUFFER_LENGTH = MTU
 
 # From net/bpf.h
+
+
+class bpf_program(Structure):
+    _fields_ = [("bf_len", c_uint), ("bf_insns", c_void_p)]
+
+
 BIOCIMMEDIATE = 0x80044270
 BIOCGSTATS = 0x4008426f
 BIOCPROMISC = 0x20004269
 BIOCSETIF = 0x8020426c
 BIOCSBLEN = 0xc0044266
 BIOCGBLEN = 0x40044266
-BIOCSETF = 0x80104267
+BIOCSETF = 0x80004267 | ((sizeof(bpf_program) & 0x1fff) << 16)
 BIOCSDLT = 0x80044278
 BIOCSHDRCMPLT = 0x80044275
 BIOCGDLT = 0x4004426a
