Commit Graph

168 Commits

Author SHA1 Message Date
Tomasz Moń c6ef99f006
win32-utils: Explicitly list inherited handles
Windows processes inherit all inheritable handles when a new process is
created using CreateProcess() with bInheritHandles set to TRUE. This can
lead to undesired object lifetime extension. That is, the child process
will keep ineritable handles alive even if it does not use them. Up to
Windows Vista it was not possible explicitly list handles that should be
inherited. Wireshark no longer works on Windows releases earlier than
Vista, so use the new API without checking Windows version.

Require all callers to win32_create_process() to pass in the list of
handles to inherit. Set the listed handles as inheritable shortly before
calling CreateProcess() and set them as not inheritable shortly after
the process is created. This minimizes possibility for other callers
(especially in 3rd party libraries) to inherit handles by accident.

Do not terminate mmdbresolve process on exit. Instead rely on process
exit when EOF is received on standard input. Previously the EOF was
never received because mmdbresolve inherited both ends of standard input
pipe, i.e. the fact that Wireshark closed the write end was not observed
by mmdbresolve because mmdbresolve kept write handle the standard input
pipe open.
2022-08-16 20:53:22 +02:00
Tomasz Moń d0a9de2af1
capture: Stop extcaps before dumpcap
Send SIGTERM on UNIX systems to all extcap processes when user requests
capture stop. Wait up to 30 seconds for extcaps to finish. If extcaps do
not finish in time, send SIGKILL to remaining extcaps.

Do not call TerminateProcess() on Windows in the same place where UNIX
SIGTERM is sent. Instead schedule extcap termination timeout to happen
as soon as control returns back to the event loop.

There is no universally agreed replacement for SIGTERM on Windows, so
just keep things simple (forcefully terminate like always) until we
have agreed on something.
2022-08-13 20:23:51 +02:00
Tomasz Moń 0bca2419d6
extcap: Do not drain stderr on process exit
Extcap child watch callback assumed that the stderr pipe is broken.
However the stdout and stderr pipes are not necessarily broken if the
child process spawned new processes that inherited standard handles.

Do not drain stderr in busy loop to prevent UI freeze. Stop capture
session only when all extcap watches are removed. Remove stdout and
stderr watches on capture stop timer (30 seconds) expiration, even if
the pipes are not broken.

Do not rely only on 0 bytes read to cease reading stdout and stderr.
Stop reading if the status is anything else than G_IO_STATUS_NORMAL
(especially it can be G_IO_STATUS_EOF).
2022-08-12 06:50:09 +02:00
Tomasz Moń 7316b16e1d
extcap: Read stdout and stderr during capture
Read extcap stdout/stderr data when available to prevent extcap hang on
stdout/stderr write. Discard stdout data as it was not used earlier.
Store up to 1024 bytes of stderr and display it to user after capture
stops.

Fixes #17827
2022-08-10 06:18:25 +02:00
Tomasz Moń ac4e1b86b8
wsutil: Use GIOChannel for standard pipes
Remove ws_read_string_from_pipe() as this function encourages bad design
and is no longer necessary. Extcap stderr is read only after the child
process has finished and thus the read will never block.

Close process information thread handle right away as we don't use it.
Remove unused ws_pipe_t member variables.
2022-08-10 06:18:25 +02:00
Tomasz Moń c1861ad1cc
extcap: Close capture session after extcap finishes
Wait up to 30 seconds for extcap process to finish after closing pipes.
The wait is achieved in non-blocking fashion, i.e. the UI is completely
responsive during the wait. Only actions related to capture process like
capture control, file open, save, export are inactive during the wait.

On Windows extcap child watch callback gets called immediately as the
process is forcefully terminated. Prior to this change the extcap was
forcefully terminated on Windows anyway.

The wait is possible on UNIX systems if extcap does handle SIGPIPE and
SIGTERM signals. The defaults handlers for SIGPIPE and SIGTERM simply
terminate the process so for large number of extcaps there is no change.
If extcap does not finish within 30 seconds, it is forcefully terminated
using SIGKILL signal.
2022-08-10 06:18:15 +02:00
David Perry 1e0d117eb7 Specify directory for temporary captures 2022-02-09 14:32:28 +00:00
j.novak@netsystem.cz 6c9cb8f3fa Prefs/Extcap: Added support for password which is never stored on the disk 2021-12-30 16:03:15 +00:00
João Valverde 0ccd69e530 Replace g_strdup_printf() with ws_strdup_printf()
Use macros from inttypes.h.
2021-12-19 21:21:58 +00:00
João Valverde fe5248717f Replace g_snprintf() with snprintf()
Use macros from inttypes.h with format strings.
2021-12-19 20:06:13 +00:00
João Valverde cef5e81146 Define more log domains for extcaps 2021-12-05 00:28:26 +00:00
João Valverde 100876337a Move version_info.[ch] to ui/
Version info is an aspect of UI implementation so move it to
a more appropriate place, such as ui/. This also helps declutter
the top-level.

A static library is appropriate to encapsulate the dependencies
as private and it is better supported by CMake than object libraries.

Also version_info.h should not be installed as a public header.
2021-07-04 10:37:49 +00:00
João Valverde 0e50979b3f Replace g_assert() with ws_assert() 2021-06-19 01:23:31 +00:00
João Valverde dc7f0b88bb Refactor our logging and extend the wslog API
Experience has shown that:

  1. The current logging methods are not very reliable or practical.
A logging bitmask makes little sense as the user-facing interface (who
would want debug but not crtical messages for example?); it's
computer-friendly and user-unfriendly. More importantly the console
log level preference is initialized too late in the startup process
to be used for the logging subsystem and that fact raises a number
of annoying and hard-to-fix usability issues.

  2. Coding around G_MESSAGES_DEBUG to comply with our log level mask
and not clobber the user's settings or not create unexpected log misses
is unworkable and generally follows the principle of most surprise.
The fact that G_MESSAGES_DEBUG="all" can leak to other programs using
GLib is also annoying.

  3. The non-structured GLib logging API is very opinionated and lacks
configurability beyond replacing the log handler.

  4. Windows GUI has some special code to attach to a console,
but it would be nice to abstract away the rest under a single
interface.

  5. Using this logger seems to be noticeably faster.

Deprecate the console log level preference and extend our API to
implement a log handler in wsutil/wslog.h to provide easy-to-use,
flexible and dependable logging during all execution phases.

Log levels have a hierarchy, from most verbose to least verbose
(debug to error). When a given level is set everything above that
is also enabled.

The log level can be set with an environment variable or a command
line option (parsed as soon as possible but still later than the
environment). The default log level is "message".

Dissector logging is not included because it is not clear what log
domain they should use. An explosion to thousands of domains is
not desirable and putting everything in a single domain is probably
too coarse and noisy. For now I think it makes sense to let them do
their own thing using g_log_default_handler() and continue using the
G_MESSAGES_DEBUG mechanism with specific domains for each individual
dissector.

In the future a mechanism may be added to selectively enable these
domains at runtime while trying to avoid the problems introduced
by G_MESSAGES_DEBUG.
2021-06-11 09:40:28 +00:00
João Valverde 9ba97d12d6 Add ws_debug() and use it
Replace most instances of ws_debug_printf() except in
epan/dissectors and dissector plugins.

Some replacements use printf(), some use ws_debug(), and
some were removed because they were dead or judged to be
temporary.
2021-05-24 01:13:19 +00:00
Alexis La Goutte 6fc94ac462 extcap: Fix Dead Store found by Clang Analyzer
extcap.c:876:26: warning: Although the value stored to 'pref' is used in the enclosing expression, the value is never actually read from 'pref'
2021-02-11 21:56:37 +00:00
John Thacker 15d315c2ae GLib: Bump requirement 2.32 -> 2.36 2020-11-25 06:25:38 +00:00
Gerald Combs 9c53ac0187 extcap: Lazily load our interface list.
Add extcap_ensure_all_interfaces_loaded, which calls
extcap_load_interface_list if our interface list is empty. Call it in
each of our public functions that require a valid interface list.

Clean up the extcap API documentation and note which routines initialize
the interface list.

In tshark, don't unconditionally call extcap_register_preferences and
instead rely on lazy loading.

Change-Id: I8493ae5f4d703b0fd767246557d17723bcf207c6
Ping-Bug: 15295
Reviewed-on: https://code.wireshark.org/review/37750
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-07-07 05:28:29 +00:00
Mikael Kanstrup f5c70db3b4 extcap: Check for valid PID before killing child process
If an extcap tool fails to start or the tool exits unexpectedly
Wireshark will try to kill PID -1. This has very unexpected results
on Linux, like bringing down the whole window manager.

Make sure it's a valid PID before killing the extcap child process.

Bug: 16362
Change-Id: I58c0cb409fec3f35d3c76d841e2430a2f8742301
Fixes: v3.3.0rc0-461-g8efde39805 ("extcap: terminate the child process using kill.")
Reviewed-on: https://code.wireshark.org/review/35998
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
Petri-Dish: Pascal Quantin <pascal@wireshark.org>
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2020-02-01 17:51:02 +00:00
Anders Esbensen 8efde39805 extcap: terminate the child process using kill.
On linux and osx extcap would potentially leave
the external dumper process running after stopping the capture.
With this change the child process will receive a TERM signal
when the capture stops.

Change-Id: I2681a26509c90696c98c7615fbab172604ce6e31
Reviewed-on: https://code.wireshark.org/review/35959
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-01-29 15:52:27 +00:00
Michael Mann 2925fb0850 Use g_file_open_tmp within create_tempfile
Much better to use a known library than create it ourselves.

Also remove get_tempfile_path as it's not used.

Bug: 15992
Change-Id: I17b9bd879e8bdb540f79db83c6c138f8ee724764
Reviewed-on: https://code.wireshark.org/review/34420
Reviewed-by: Tomasz Moń <desowin@gmail.com>
Petri-Dish: Tomasz Moń <desowin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2019-12-20 19:26:38 +00:00
Dario Lombardo 89dfd3d378 extcap: fix use-after-free bug.
Regression introduced in g1cd1e36.

Change-Id: I85775ef86d9325d4f5bf811a5f52925a2cf0d387
Reviewed-on: https://code.wireshark.org/review/35503
Petri-Dish: Tomasz Moń <desowin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Tomasz Moń <desowin@gmail.com>
2019-12-19 16:20:08 +00:00
Dario Lombardo 1cd1e36a05 extcap: remove potential leak.
Found by clang.

Change-Id: I84359a2f7985bca8b0089200b3c37d04e06effe2
Reviewed-on: https://code.wireshark.org/review/35354
Petri-Dish: Tomasz Moń <desowin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Tomasz Moń <desowin@gmail.com>
2019-12-15 12:23:49 +00:00
Gerald Combs e8aa574aff Revert "extcap: Pass --extcap-version if extcap supports it"
This reverts commit 9910d8c913.

Reasons for revert:

- We need to improve the reliability of extcap-version=x.y detection.

- WSDG_chapter_capture.adoc needs to be more clear about extcap-version=x.y support.

- Our extcap utilities need to be updated.

Change-Id: Ic8dd2018489f5ec03c35b18e6b09faf69defd59b
Reviewed-on: https://code.wireshark.org/review/35393
Reviewed-by: Rafał Kuźnia <rafal.kuznia@protonmail.com>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2019-12-10 21:09:35 +00:00
Rafał Kuźnia 9910d8c913 extcap: Pass --extcap-version if extcap supports it
This change makes the --extcap-version argument to be passed to the extcap
script, if it is supported. If the extcap fails with --extcap-version argument,
it is treated as legacy and will not receive the additional argument in all
subsequent runs.

Change-Id: I279aa38d9f39ed85ccb84ba2c09dd93a0492ca51
Reviewed-on: https://code.wireshark.org/review/34914
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-12-10 08:49:31 +00:00
Vasil Velichkov 1675e0fe72 extcap: Fix memory leak in extcap_get_extcap_paths
The path returned by get_persconffile_path needs to be freed.

Direct leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x5653e6c98e06 in realloc (/home/vasko/sources/wireshark/build_clang/run/wireshark+0x2486e06)
    #1 0x7f5b697f2e7d in g_realloc gmem.c:164:16
    #2 0x7f5b69810016 in g_string_maybe_expand gstring.c:102:21
    #3 0x7f5b69810369  gstring.c:476:7
    #4 0x7f5b69810369 in g_string_insert_len gstring.c:424:1
    #5 0x7f5b697d808d in g_build_path_va gfileutils.c:1766:7
    #6 0x7f5b697d9518 in g_build_filename_va gfileutils.c:1987:9
    #7 0x7f5b697d9518 in g_build_filename gfileutils.c:2069:9
    #8 0x7f5b69bd0c28 in get_persconffile_path /home/vasko/sources/wireshark/wsutil/filesystem.c:1856:12
    #9 0x5653e8825f82 in extcap_get_extcap_paths /home/vasko/sources/wireshark/extcap.c:258:53
    #10 0x5653e8825f82 in extcap_run_all /home/vasko/sources/wireshark/extcap.c:449
    #11 0x5653e8825f82 in extcap_load_interface_list /home/vasko/sources/wireshark/extcap.c:2024
    #12 0x5653e7775356 in main /home/vasko/sources/wireshark/ui/qt/main.cpp:726:5

Change-Id: I275d0ad6f06fbf3222c2d4ebef7f3079073404a0
Reviewed-on: https://code.wireshark.org/review/34994
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2019-11-06 07:44:19 +00:00
Roland Knall 0e64e9f3ca extcap: Allow loading of extcap files from personal directory
Allow the storage of extcap plugins in the personal directory and
enable loading from there. It will also take precedence of any
system-wide extcaps with an identical name

Change-Id: Ib88e09a26c4f99cf5e793327f2808c7445c6b1b5
Reviewed-on: https://code.wireshark.org/review/34988
Reviewed-by: Roland Knall <rknall@gmail.com>
2019-11-05 16:57:09 +00:00
Tomasz Moń b1e9de7eb8 extcap: Do not append disabled boolflags
If boolean flag is active by default, then when launching extcap without
opening configuration dialog it would be added to extcap call regardless
of user configuration. Modify the logic so default value is used only if
there is no stored user configuration available.

Change-Id: I1855a058a99e2395da5593486411e160d48fca4b
Reviewed-on: https://code.wireshark.org/review/34865
Petri-Dish: Tomasz Moń <desowin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2019-10-27 20:28:32 +00:00
Tomasz Moń e52f33f66c extcap: Multiple extcap instance support on Windows
Wireshark does create named pipes and waits for the child process to
connect. The named pipe server handle is inheritable and thus available
in child dumpcap process. Pass the handle identifier instead of named
pipe name so dumpcap can use it.

Bug: 13653
Change-Id: Id2c019f67a63f1ea3d98b9da2153d6de5078cd01
Reviewed-on: https://code.wireshark.org/review/34503
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-09-23 04:38:00 +00:00
Peter Wu 29be7f9d9a Qt, docs, ieee1905: fix some spelling errors
The spelling error for "Desription" in the context menu was very
obvious. The others were found by scanning the output of:

    grep -Po '<source>\K.*(?=</source>)' wireshark_en.ts

Change-Id: I4b95236c82f76828a115d59d7c8e0b853eae1d26
Reviewed-on: https://code.wireshark.org/review/34582
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-09-21 08:33:58 +00:00
Guy Harris 20800366dd HTTPS (almost) everywhere.
Change all wireshark.org URLs to use https.

Fix some broken links while we're at it.

Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c
Reviewed-on: https://code.wireshark.org/review/34089
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-26 18:44:40 +00:00
Tomasz Moń c0a49d7237 extcap: Do not use global pipe handle on Windows
Make extcap_create_pipe() static.

Change-Id: I06a0af2dcf9fb4a51b4f7ba6ee7c57e7a52c5e97
Reviewed-on: https://code.wireshark.org/review/33250
Petri-Dish: Pascal Quantin <pascal@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
2019-06-10 23:03:09 +00:00
Tomasz Moń 5d2af76c98 extcap: Fix memory leak in extcap_load_interface_list()
The content of the list returned by g_hash_table_get_values() is owned by
GHashTable and should not be modified or freed. However, the list itself
should be freed using g_list_free().

Change-Id: Ie4a1da290f25dbd6dc2f3a01f051bfca13bb01d3
Reviewed-on: https://code.wireshark.org/review/33281
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-05-21 11:01:19 +00:00
Tomasz Moń 0955f15ba2 extcap: Fix memory leak in extcap_free_toolbar_control()
Remove duplicate defition of extcap_free_toolbar_control() and
extcap_free_toolbar_value().

Change-Id: Ia4c8ca6160017d769616579db158419426e664b7
Reviewed-on: https://code.wireshark.org/review/33224
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-05-20 14:30:32 +00:00
Tomasz Moń 81cea3def7 extcap: Do not free mutex and cond in thread_pool_wait()
The name does not suggest that variables are freed in any way. Free the
mutex and cond where they are initialized, ie. in extcap_run_all().

Change-Id: I4e2ffacd32a8ba74831682438baed52e714433bb
Reviewed-on: https://code.wireshark.org/review/33223
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-05-20 14:16:54 +00:00
Tomasz Moń c52776da62 extcap: Fix memory leak in extcap_get_descriptions()
The content of the list returned by g_hash_table_get_keys() is owned by
GHashTable and should not be modified or freed. However, the list itself
should be freed using g_list_free().

Change-Id: I272616924bfd9178a925878a0458a173aff403ba
Reviewed-on: https://code.wireshark.org/review/33222
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-05-20 13:37:37 +00:00
Tomasz Moń e803f83ac8 extcap: Fix memory leak in extcap_has_toolbar()
The content of the list returned by g_hash_table_get_values() is owned by
GHashTable and should not be modified or freed. However, the list itself
should be freed using g_list_free().

Use g_strcmp0() to compare keys instead of strcmp() as it handles NULL
gracefully.

Change-Id: I8f5d70ffc2cd6eb5001b5086e4e31256b65431c7
Reviewed-on: https://code.wireshark.org/review/33246
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-05-20 13:19:37 +00:00
Tomasz Moń 40f6cb70e9 extcap: Fix memory leak in extcap_get_if_configuration_values()
The content of the list returned by g_hash_table_get_keys() is owned by
GHashTable and should not be modified or freed. However, the list itself
should be freed using g_list_free().

This fixes memory leak that happened on every selector option reload.

Change-Id: Id91055264fed9f7b8ab8dba9292d5f35389ca235
Reviewed-on: https://code.wireshark.org/review/33244
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-05-20 12:49:37 +00:00
Guy Harris 5dfde7ff83 Print extcap plugins with "tshark -G plugins".
This makes it match the "Plugins" tab of the "About" dialog.

While we're at it, use the same code to enumerate extcap plugins in that
dialog.

Change-Id: I50f402a7ab5d83d46baab070d145558ed8f688f4
Reviewed-on: https://code.wireshark.org/review/32589
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-03-26 21:53:20 +00:00
Peter Wu 567fe966b1 extcap: set G_REGEX_RAW to avoid potential crashes
None of the patterns try to match UTF-8 text. Treat the inputs as bytes
to avoid potential crashes on invalid subjects (e.g. malformed data from
an extcap binary, ADB or SSH server).

Change-Id: I6f3113cfd9da04ae3fa2b0ece7b0a3a94312830e
Ping-Bug: 14905
Reviewed-on: https://code.wireshark.org/review/31939
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-02-10 16:12:46 +00:00
Peter Wu aba0e8eec0 extcap: fix --extcap-version argument to include the version
Change-Id: I727864ae0a210fea2dc90624102b793f5a98e395
Fixes: v2.9.0rc0-2648-g9ae02a5918 ("extcap: run --extcap-config in parallel to reduce startup time")
Reviewed-on: https://code.wireshark.org/review/31367
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-04 15:29:54 +00:00
Dario Lombardo 14c61f14fc extcap: remove redundant casts.
Found by clang-tidy.

Change-Id: Icd4a72d840092ce9c5e18e3d16a94b785b4521dc
Reviewed-on: https://code.wireshark.org/review/31333
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-01-03 22:19:55 +00:00
Peter Wu 9ae02a5918 extcap: run --extcap-config in parallel to reduce startup time
While --extcap-interfaces is now run in parallel, --extcap-config (for
each discovered interface) would only run sequentially after that. Make
sure that the latter command also fully parallel and do not wait for all
extcap interfaces to be discovered first.

This saves another 80ms startup time on Linux (unoptimized ASAN+Debug).

Change-Id: I303fd8fda647b304d5bdaf048a3d1628ec9e02b4
Ping-Bug: 15295
Reviewed-on: https://code.wireshark.org/review/30773
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-25 07:10:45 +00:00
Peter Wu 6d9bc4bd65 extcap: discover interfaces in a parallel
Split interface discovery in three stages: discover available programs
(extcap_get_extcap_paths), obtain outputs for each (extcap_run_all) and
processing of the output (process_new_extcap). The second step is most
expensive, do it in parallel in multiple threads.

extcap_foreach used to call extcap_if_exists, but as "cb_info.ifname" is
always NULL for interface discovery, it would always pass. Remove this
check and all other unused functions.

This saves 100ms startup time on Linux with 7 extcap tools.

Change-Id: I511e491d3b23c0a7f2fe2447842e87a9bd75adbe
Ping-Bug: 15295
Reviewed-on: https://code.wireshark.org/review/30766
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-22 20:54:41 +00:00
Peter Wu 73ded3a1d9 extcap: simplify execution of single extcap programs
extcap_foreach has two purposes: discovery of all interfaces for each
tool and querying info for an extcap interface. Observe that the latter
requires extcap_if_exists(ifname) to be true. This makes extcap_foreach
match exactly one interface, so we can avoid some complexity.

Change-Id: I1842f50aa19553608ee5f2bb7bd8d94bba9629f2
Reviewed-on: https://code.wireshark.org/review/30764
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-22 20:50:17 +00:00
Peter Wu 85dc646327 ws_pipe_spawn_sync: mark arguments as const where possible
This avoids an unnecessary explicit cast. For clarity, rename the
working directory argument to match g_spawn_sync.

Change-Id: Idf7072cd590e686294d953f77da2a52c861a89c0
Reviewed-on: https://code.wireshark.org/review/30763
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-22 20:49:44 +00:00
Stig Bjørlykke d2227b768e extcap: Allow ASCII '0' in preference name
Update another regex to also allow '0' in the preference name.

Change-Id: I61e39a160d86195c989ab53623bc5887a10dcaad
Reviewed-on: https://code.wireshark.org/review/30606
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2018-11-13 18:08:02 +00:00
Stig Bjørlykke b2c244e92d extcap: Allow ASCII '0' in preference name
Update the regex to also allow '0' in the preference name.

Change-Id: I881079b579b9193dd31dda2150d9a50c000c0dd3
Reviewed-on: https://code.wireshark.org/review/30602
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-13 14:51:32 +00:00
Dario Lombardo 89d74238d9 extcap: use the correct values for comparing.
Change-Id: Ieb9c0940065aeff1234998aaec37f05fb7f80ed9
Reviewed-on: https://code.wireshark.org/review/30484
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2018-11-02 15:17:58 +00:00
Dario Lombardo fc17bfc4f1 extcap: small fix.
Change-Id: I043bef4eb1f1fe74f277bcdb3d7a3d1c8d2ec1a9
Reviewed-on: https://code.wireshark.org/review/30485
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2018-11-02 15:17:45 +00:00