Skip to content

dispatch not working #63

@havihu

Description

@havihu

Hi,
im trying to capture packets and im using open_live(timeout 0) with dispatch instead of next, and I dont know why but its sniffing only a few packets and then close pip.
my code:

import pcapy
import threading
import time
from pcapy import open_live, PcapError

def parse_eth_packet_hndlr(header, packet):
print('header len:%s\n'%header.getlen())

def start():
try:
packets_reader = open_live('eth2', 200, 0, 0)
except PcapError as e:
if 'That device is not up' in str(e):
logging.debug(e)
return None
try:
print('Try to start capturing packets')
packets_reader.dispatch(-1, parse_eth_packet_hndlr)
except PcapError as e:
return

if name == 'main':
start()

pcapy version:pcapy-0.11.5.dev0
python version: 2.7
please advice

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions