Skip to content
Snippets Groups Projects
Commit eee40b92 authored by Dmitriy Vorotnikov's avatar Dmitriy Vorotnikov Committed by Dmitriy Vorotnikov
Browse files

Allow L2pcapListenSocket.recv() to return None if where is no captured...

Allow L2pcapListenSocket.recv() to return None if where is no captured packets. Make sniff() to continue loop if received pkt is None (issue #74)
parent 0eae79be
No related branches found
No related tags found
No related merge requests found
...@@ -203,7 +203,7 @@ if conf.use_winpcapy: ...@@ -203,7 +203,7 @@ if conf.use_winpcapy:
else: else:
cls = conf.default_l2 cls = conf.default_l2
warning("Unable to guess datalink type (interface=%s linktype=%i). Using %s" % (self.iface, ll, cls.name)) warning("Unable to guess datalink type (interface=%s linktype=%i). Using %s" % (self.iface, ll, cls.name))
pkt = None pkt = None
while pkt is None: while pkt is None:
pkt = self.ins.next() pkt = self.ins.next()
...@@ -438,23 +438,20 @@ if conf.use_pcap: ...@@ -438,23 +438,20 @@ if conf.use_pcap:
cls = conf.default_l2 cls = conf.default_l2
warning("Unable to guess datalink type (interface=%s linktype=%i). Using %s" % (self.iface, ll, cls.name)) warning("Unable to guess datalink type (interface=%s linktype=%i). Using %s" % (self.iface, ll, cls.name))
pkt = None pkt = self.ins.next()
while pkt is None: if scapy.arch.WINDOWS and pkt is None:
pkt = self.ins.next()
if pkt is not None:
ts,pkt = pkt
if scapy.arch.WINDOWS and pkt is None:
raise PcapTimeoutElapsed raise PcapTimeoutElapsed
if pkt is not None:
try: ts,pkt = pkt
pkt = cls(pkt) try:
except KeyboardInterrupt: pkt = cls(pkt)
raise except KeyboardInterrupt:
except:
if conf.debug_dissector:
raise raise
pkt = conf.raw_layer(pkt) except:
pkt.time = ts if conf.debug_dissector:
raise
pkt = conf.raw_layer(pkt)
pkt.time = ts
return pkt return pkt
def send(self, x): def send(self, x):
......
...@@ -585,7 +585,7 @@ stop_filter: python function applied to each packet to determine ...@@ -585,7 +585,7 @@ stop_filter: python function applied to each packet to determine
if s in sel[0]: if s in sel[0]:
p = s.recv(MTU) p = s.recv(MTU)
if p is None: if p is None:
break continue
if lfilter and not lfilter(p): if lfilter and not lfilter(p):
continue continue
if store: if store:
......
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