From 018f6bff18785a1c3971a1ccfe3b1b5243d4d154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20=C3=98ye=20Amundsen?= Date: Fri, 25 Aug 2017 11:28:34 +0200 Subject: extcap: Interface Toolbar support on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for extcap control pipes on Windows. Improved read loop in InterfaceToolbarReader. Delay opening control pipes until extcap has opened the fifo pipe. Make extcap_example.py work on Windows. Bug: 13833 Change-Id: I4b47d25452637759b8a3be53be48eee5365bc0e4 Reviewed-on: https://code.wireshark.org/review/23211 Petri-Dish: Stig Bjørlykke Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- doc/extcap_example.py | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'doc/extcap_example.py') diff --git a/doc/extcap_example.py b/doc/extcap_example.py index e984b374aa..9c14ddeae7 100755 --- a/doc/extcap_example.py +++ b/doc/extcap_example.py @@ -340,28 +340,22 @@ def extcap_capture(interface, fifo, control_in, control_out, in_delay, in_verify message = in_message verify = in_verify counter = 1 - - if not os.path.exists(fifo): - print ( "Fifo does not exist, exiting!", file=sys.stderr ) - sys.exit(1) - fn_out = None - if control_out != None: - fn_out = open(control_out, 'wb', 0) - control_write(fn_out, CTRL_ARG_LOGGER, CTRL_CMD_SET, "Log started at " + time.strftime("%c") + "\n") + with open(fifo, 'wb', 0 ) as fh: + fh.write (pcap_fake_header()) - if control_in != None: - # Start reading thread - thread = Thread(target = control_read_thread, args = (control_in, fn_out)) - thread.start() + if control_out != None: + fn_out = open(control_out, 'wb', 0) + control_write(fn_out, CTRL_ARG_LOGGER, CTRL_CMD_SET, "Log started at " + time.strftime("%c") + "\n") + if control_in != None: + # Start reading thread + thread = Thread(target = control_read_thread, args = (control_in, fn_out)) + thread.start() - if fn_out != None: - control_write_defaults(fn_out) - - with open(fifo, 'wb', 0 ) as fh: - fh.write (pcap_fake_header()) + if fn_out != None: + control_write_defaults(fn_out) while True: if fn_out != None: @@ -383,10 +377,6 @@ def extcap_capture(interface, fifo, control_in, control_out, in_delay, in_verify fn_out.close() def extcap_close_fifo(fifo): - if not os.path.exists(fifo): - print ( "Fifo does not exist!", file=sys.stderr ) - return - # This is apparently needed to workaround an issue on Windows/macOS # where the message cannot be read. (really?) fh = open(fifo, 'wb', 0 ) -- cgit v1.2.3