Closed erezsh closed 3 years ago
You can use: LIBPCAP = "npcap" # or libpcap shared library absolute path in libpcap.cfg
Options in libpcap.libpcap.cfg are: For Windows: LIBPCAP = "npcap" # default for now # system's npcap's dlls will be used
LIBPCAP = "wpcap" # internal wpcap's dlls will be used LIBPCAP = "<absolute path for pcap's .dll>"
For Linux: LIBPCAP = "tcpdump" # or other no path str # default # internal tcpdump's libpcap.so will be used
LIBPCAP = "<absolute path for pcap's .so>"
You completely missed my point.
But it doesn't matter anymore.
No no! My note, is only hint for possible useful workaround, but not as final solution.
@erezsh I plan to achieve your requirement by adding extras for pip, so installing e.g by: pip install -U libpcap[npcap] pip install -U libpcap[wpcap] ... pip install -U libpcap[system] will be possible.
Another way (probably right/final) is to use config function after import e.g.: import libpcap libpcap.backend("npcap") # "wpcap" or "system"
FYI: For now this way to programmatically setting backend is already implemented: import libpcap libpcap.config(LIBPCAP="npcap") # or "wpcap" or... libpcap.config(LIBPCAP=None) # for use system backend or... libpcap.config(LIBPCAP=r"C:\XXX\YYY\backend.dll") # for use of arbitrary backend's shared library
@erezsh and others: Is it proper solution for your needs? If so, it will be comited to the repo today's evening as 1.10.0b12
I like the solution of adding extras for pip. I didn't try using the config()
function, but I guess it's also okay. As long as it doesn't require manually editing anything.
https://pypi.org/project/libpcap/1.10.0b12/ https://libpcap.readthedocs.io/en/latest/CHANGES.html#b12-2020-10-05 has been released with appropriate note in docs: https://libpcap.readthedocs.io/en/latest/
libpcap uses the underlying libpcap C shared library as specified in libpcap.cfg (system's libpcap shared library is the default), but there is also ability to specify it programmatically by one of the following ways:
import libpcap libpcap.config(LIBPCAP=None) # system's libpcap library will be use # or libpcap.config(LIBPCAP="npcap") # or libpcap.config(LIBPCAP="wpcap") # included wpcap library will be use # or libpcap.config(LIBPCAP="tcpdump") # included tcpdump library will be use (currently works only for Linux x64) # or libpcap.config(LIBPCAP="libpcap shared library absolute path")
There doesn't seem a way to specify programmatically to use a different backend. What's the simplest way to add this?
Changing the path manually in the code works, but I'm hoping for something that would work from a clean pip install.
I don't mind sending a pull-request for it myself, once we agree on the approach.