diff --git a/src/pyshark/__init__.py b/src/pyshark/__init__.py index e9e0784b..a3c6eb7c 100644 --- a/src/pyshark/__init__.py +++ b/src/pyshark/__init__.py @@ -15,3 +15,4 @@ class UnsupportedVersionException(Exception): from pyshark.capture.file_capture import FileCapture from pyshark.capture.remote_capture import RemoteCapture from pyshark.capture.inmem_capture import InMemCapture +from pyshark.capture.pipe_capture import PipeCapture \ No newline at end of file diff --git a/src/pyshark/capture/pipe_capture.py b/src/pyshark/capture/pipe_capture.py index a8ff246a..2cba1af4 100644 --- a/src/pyshark/capture/pipe_capture.py +++ b/src/pyshark/capture/pipe_capture.py @@ -50,3 +50,18 @@ def close(self): # Close pipe os.close(self._pipe) super(PipeCapture, self).close() + + def sniff_continuously(self, packet_count=None): + """ + Captures from the set interface, returning a generator which returns packets continuously. + + Can be used as follows: + for packet in capture.sniff_continuously(); + print 'Woo, another packet:', packet + + Note: you can also call capture.apply_on_packets(packet_callback) which should have a slight performance boost. + + :param packet_count: an amount of packets to capture, then stop. + """ + # Retained for backwards compatibility and to add documentation. + return self._packets_from_tshark_sync(packet_count=packet_count)