def __init__(self, filter, optimize=True, netmask=None, pcap_obj=None, link_type=1, snaplen=65535): self._pprogram = None if netmask is None: netmask = 0 elif isinstance(netmask, IPAddr): netmask = netmask.toSignedN() delpc = False if pcap_obj is None: delpc = True pcap_obj = pcapc.open_dead(link_type, snaplen) if isinstance(pcap_obj, PCap): pcap_obj = pcap_obj.pcap with _compile_lock: self._pprogram = pcapc.compile(pcap_obj, filter, 1 if optimize else 0, netmask) if delpc: pcapc.close(pcap_obj)
def __init__ (self, filter, optimize = True, netmask = None, pcap_obj = None, link_type = 1, snaplen = 65535): self._pprogram = None if netmask is None: netmask = 0 elif isinstance(netmask, IPAddr): netmask = netmask.toSignedN() delpc = False if pcap_obj is None: delpc = True pcap_obj = pcapc.open_dead(link_type, snaplen) if isinstance(pcap_obj, PCap): pcap_obj = pcap_obj.pcap self._pprogram = pcapc.compile(pcap_obj, filter, 1 if optimize else 0, netmask) if delpc: pcapc.close(pcap_obj)
def close(self): if self.pcap is None: return self.stop() pcapc.close(self.pcap) self.pcap = None
def close (self): if self.pcap is None: return self.stop() pcapc.close(self.pcap) self.pcap = None