def __init__(self, device, snaplen, promisc, to_ms, monitor=False): try: self.pcap = pcap.pcap(device, snaplen, promisc, immediate=1, timeout_ms=to_ms, rfmon=monitor) # noqa: E501 except TypeError: try: if monitor: warning( "Your pypcap version is too old to support monitor mode, Please use pypcap 1.2.1+ !" ) # noqa: E501 self.pcap = pcap.pcap( device, snaplen, promisc, immediate=1, timeout_ms=to_ms) # noqa: E501 except TypeError: # Even older pypcap versions do not support the timeout_ms argument # noqa: E501 self.pcap = pcap.pcap(device, snaplen, promisc, immediate=1) # noqa: E501
def __init__(self, device, snaplen, promisc, to_ms, monitor=False): try: self.pcap = pcap.pcap(device, snaplen, promisc, immediate=1, timeout_ms=to_ms, rfmon=monitor) # noqa: E501 except TypeError: try: if monitor: warning("Your pypcap version is too old to support monitor mode, Please use pypcap 1.2.1+ !") # noqa: E501 self.pcap = pcap.pcap(device, snaplen, promisc, immediate=1, timeout_ms=to_ms) # noqa: E501 except TypeError: # Even older pypcap versions do not support the timeout_ms argument # noqa: E501 self.pcap = pcap.pcap(device, snaplen, promisc, immediate=1) # noqa: E501