[pypy-issue] [issue1318] Scapy.sniff returns an error
Amaury Forgeot d Arc
tracker at bugs.pypy.org
Fri Nov 9 17:07:07 CET 2012
Amaury Forgeot d Arc <amauryfa at gmail.com> added the comment:
>From scapy/arch/linux.py::
# XXX. Argl! We need to give the kernel a pointer on the BPF,
# python object header seems to be 20 bytes. 36 bytes for x86 64bits arch.
if scapy.arch.X86_64:
bpfh = struct.pack("HL", nb, id(bpf)+36)
else:
bpfh = struct.pack("HI", nb, id(bpf)+20)
s.setsockopt(SOL_SOCKET, SO_ATTACH_FILTER, bpfh)
This kind of code won't work at all with PyPy: the object layout is very different, id(bpf) is not
the address of the object, and PyPy moves objects anyway.
I don't know why the code is written like this - setsockopt() accepts a string.
Would the following work?
# (remove all the bpfh stuff)
s.setsockopt(SOL_SOCKET, SO_ATTACH_FILTER, bpf)
----------
nosy: +afa
status: unread -> chatting
________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1318>
________________________________________
More information about the pypy-issue
mailing list