You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After installing scapy and libpcap via nixpkgs, I tried to use scapy's libpcap support using a filter expression. This fails, claiming nothing provides libpcap.
AsyncSniffer(iface="wlo1",count=200,filter="icmp6").start()
ERROR: Cannot set filter: libpcap is not available. Cannot compile filter !
Expected behavior
scapy starts sniffing and filtering packets.
Additional context
I've identified the source of the problem in lib/python3.9/site-packages/scapy/libs/winpcapy.py, which tries to load libpcap via python's ctypes package. I've manually called the corresponding python calls from a REPL and discovered that the call to the CDLL constructor needs the full path to the library on NixOS, presumably because of different library locations in the nix store vs where it's expected on other Linux systems. Related issue: #7307
>>> import ctypes, ctypes.util
>>> ctypes.util.find_library('pcap')
'libpcap.so.1'
>>> ctypes.CDLL('libpcap.so.1')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/nix/store/xpwwghl72bb7f48m51amvqiv1l25pa01-python3-3.9.13/lib/python3.9/ctypes/__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libpcap.so.1: cannot open shared object file: No such file or directory
>>> ctypes.CDLL('/nix/store/zghjn85hhlkr81n32rqy0r5lvf96nsn8-libpcap-1.10.1/lib/libpcap.so.1')
<CDLL '/nix/store/zghjn85hhlkr81n32rqy0r5lvf96nsn8-libpcap-1.10.1/lib/libpcap.so.1', handle 738b20 at 0x7f2eac85c8b0>
Describe the bug
After installing scapy and libpcap via nixpkgs, I tried to use scapy's libpcap support using a filter expression. This fails, claiming nothing provides libpcap.
Steps To Reproduce
Steps to reproduce the behavior:
nix-shell -p python39Packages.scapy -p libpcap --run 'sudo scapy'
AsyncSniffer(iface="wlo1",count=200,filter="icmp6").start()
ERROR: Cannot set filter: libpcap is not available. Cannot compile filter !
Expected behavior
scapy starts sniffing and filtering packets.
Additional context
I've identified the source of the problem in
lib/python3.9/site-packages/scapy/libs/winpcapy.py
, which tries to load libpcap via python's ctypes package. I've manually called the corresponding python calls from a REPL and discovered that the call to the CDLL constructor needs the full path to the library on NixOS, presumably because of different library locations in the nix store vs where it's expected on other Linux systems. Related issue: #7307Notify maintainers
@primeos @bjornfor
Metadata
"x86_64-linux"
Linux 5.15.54, NixOS, 22.05 (Quokka), 22.05.1744.07a2e6a4e31
yes
yes
nix-env (Nix) 2.8.1
"home-manager-22.05.tar.gz"
/nix/var/nix/profiles/per-user/root/channels/nixos
The text was updated successfully, but these errors were encountered: