Skip to content
Snippets Groups Projects
Commit d8c9326e authored by Dirk Loss's avatar Dirk Loss
Browse files

Remove dependency on special 'scapy' string in pcap.__version__

Newer versions of the pypcap library now include our fixes
and support the timeout_ms argument. So we should not depend
on our customized, specially marked, pypcap version anymore.
parent aedda4a9
No related branches found
No related tags found
No related merge requests found
...@@ -43,11 +43,10 @@ if conf.use_pcap: ...@@ -43,11 +43,10 @@ if conf.use_pcap:
if hasattr(pcap,"pcap"): # python-pypcap if hasattr(pcap,"pcap"): # python-pypcap
class _PcapWrapper_pypcap: class _PcapWrapper_pypcap:
def __init__(self, device, snaplen, promisc, to_ms): def __init__(self, device, snaplen, promisc, to_ms):
# Normal pypcap module has no timeout parameter, try:
# only the specially patched "scapy" variant has.
if "scapy" in pcap.__version__.lower():
self.pcap = pcap.pcap(device, snaplen, promisc, immediate=1, timeout_ms=to_ms) self.pcap = pcap.pcap(device, snaplen, promisc, immediate=1, timeout_ms=to_ms)
else: except TypeError:
# Older pypcap versions do not support the timeout_ms argument
self.pcap = pcap.pcap(device, snaplen, promisc, immediate=1) self.pcap = pcap.pcap(device, snaplen, promisc, immediate=1)
def __getattr__(self, attr): def __getattr__(self, attr):
return getattr(self.pcap, attr) return getattr(self.pcap, attr)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment