Ejemplo n.º 1
0
 def __init__(self, device, snaplen, promisc, to_ms, monitor=False):  # noqa: E501
     self.errbuf = create_string_buffer(PCAP_ERRBUF_SIZE)
     if monitor:
         self.pcap = pcap.pcap_create(device, self.errbuf)
         pcap.pcap_set_snaplen(self.pcap, snaplen)
         pcap.pcap_set_promisc(self.pcap, promisc)
         pcap.pcap_set_timeout(self.pcap, to_ms)
         if pcap.pcap_set_rfmon(self.pcap, 1) != 0:
             warning("Could not set monitor mode")
         if pcap.pcap_activate(self.pcap) != 0:
             raise OSError("Could not activate the pcap handler")  # noqa: E501
     else:
         self.pcap = pcap.open_live(device, snaplen, promisc, to_ms)  # noqa: E501
Ejemplo n.º 2
0
 def __init__(self, device, snaplen, promisc, to_ms, monitor=False):  # noqa: E501
     self.errbuf = create_string_buffer(PCAP_ERRBUF_SIZE)
     if monitor:
         self.pcap = pcap.pcap_create(device, self.errbuf)
         pcap.pcap_set_snaplen(self.pcap, snaplen)
         pcap.pcap_set_promisc(self.pcap, promisc)
         pcap.pcap_set_timeout(self.pcap, to_ms)
         if pcap.pcap_set_rfmon(self.pcap, 1) != 0:
             warning("Could not set monitor mode")
         if pcap.pcap_activate(self.pcap) != 0:
             raise OSError("Could not activate the pcap handler")  # noqa: E501
     else:
         self.pcap = pcap.open_live(device, snaplen, promisc, to_ms)  # noqa: E501