View | Details | Raw Unified | Return to bug 239380
Collapse All | Expand All

(-)arch/bpf/supersocket.py (-3 / +21 lines)
Lines 4-12 Link Here
4
Scapy *BSD native support - BPF sockets
4
Scapy *BSD native support - BPF sockets
5
"""
5
"""
6
6
7
from ctypes import c_long, sizeof
7
import errno
8
import errno
8
import fcntl
9
import fcntl
9
import os
10
import os
11
import platform
10
from select import select
12
from select import select
11
import struct
13
import struct
12
import time
14
import time
Lines 23-29 from scapy.supersocket import SuperSocket Link Here
23
from scapy.compat import raw
25
from scapy.compat import raw
24
26
25
27
26
if FREEBSD or NETBSD:
28
if FREEBSD:
29
    # On 32bit architectures long might be 32bit.
30
    BPF_ALIGNMENT = sizeof(c_long)
31
elif NETBSD:
27
    BPF_ALIGNMENT = 8  # sizeof(long)
32
    BPF_ALIGNMENT = 8  # sizeof(long)
28
else:
33
else:
29
    BPF_ALIGNMENT = 4  # sizeof(int32_t)
34
    BPF_ALIGNMENT = 4  # sizeof(int32_t)
Lines 260-267 class L2bpfListenSocket(_L2bpfSocket): Link Here
260
            return
265
            return
261
266
262
        # Extract useful information from the BPF header
267
        # Extract useful information from the BPF header
263
        if FREEBSD or NETBSD:
268
        if FREEBSD:
264
            # struct bpf_xhdr or struct bpf_hdr32
269
            # Unless we set BIOCSTSTAMP to something different than BPF_T_MICROTIME
270
            # we will get bpf_hdr on FreeBSD, which means that we'll get a
271
            # struct timeval, which is time_t, suseconds_t.
272
            # On i386 time_t still is 32bit so the bh_tstamp will only be 8 bytes.
273
            # We really want to set BIOCSTSTAMP to BPF_T_NANOTIME and be done with this
274
            # and it always be 16?
275
            if platform.machine() == "i386":
276
                # struct bpf_hdr
277
                bh_tstamp_offset = 8
278
            else:
279
                # struct bpf_hdr (64bit time_t) or struct bpf_xhdr
280
                bh_tstamp_offset = 16
281
        elif NETBSD:
282
            # struct bpf_hdr or struct bpf_hdr32
265
            bh_tstamp_offset = 16
283
            bh_tstamp_offset = 16
266
        else:
284
        else:
267
            # struct bpf_hdr
285
            # struct bpf_hdr

Return to bug 239380