Commit Graph

175 Commits

Author SHA1 Message Date
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
Dario Lombardo 779003b6a9 extcap: add check before using pipedata.
In line 1131 the check assumes that pipedata can be NULL. All subsequent
uses require it is not NULL, otherwise it may result in a NULL
dereference.

Found by Clang.

Change-Id: I9bd35b6213adfb41de2e96d5cc6da2b3bac4dd95
Reviewed-on: https://code.wireshark.org/review/30478
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-02 14:49:14 +00:00
Pascal Quantin bcaf997f8a wsutil: introduce ws_pipe_close() helper and use it to terminate mmdbresolve
We were not calling TerminateProcess() to stop mmdbresolve.Exe process on
Windows.

Bug: 15248
Change-Id: Ic90cf438a8003a6fefb023b7056984681ce09b46
Reviewed-on: https://code.wireshark.org/review/30449
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-01 06:26:13 +00:00
Stig Bjørlykke c826e2a77e extcap: Close stdout_fd and stderr_fd when done
The documentation for g_spawn_async_with_pipes() states that stdout_fd
and stderr_fd must be closed when they are no longer in use.

Ping-Bug: 15205
Change-Id: I943eaa68058b0828686469672ea3611e67390b2f
Reviewed-on: https://code.wireshark.org/review/30221
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2018-10-17 17:46:22 +00:00
Stig Bjørlykke f86d6203a9 extcap: Read stderr on extcap error without an infinite loop
Check if data is available on stderr before doing a blocking read() to
avoid an infinite read loop when having less data than STDERR_BUFFER_SIZE.

Append data instead of overwrite when doing multiple read() to fetch
available data.

This is a regression from g6a949ed155.

Bug: 15205
Change-Id: I84b232aeafb6123f77f3f5d48bbe89326fe7eb0f
Reviewed-on: https://code.wireshark.org/review/30209
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2018-10-14 19:05:27 +00:00
Guy Harris 99242affde Revert "Pass all arguments to options as --option=argument."
This reverts commit 137d45f52c.

Don't. Make. The. Argument. To. Your. Extcap. Program. Specific.
Options. Optional. (Unless they're Boolean, in which case we never
pass an argument - we just pass the option if it's true and don't
pass it if it's false.)

Change-Id: I11e4ecaa196fd94c493d51e1f73e90267e1d9b1d
Reviewed-on: https://code.wireshark.org/review/28866
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-07-26 21:43:24 +00:00
Guy Harris 137d45f52c Pass all arguments to options as --option=argument.
For options with optional arguments, the only syntax that's *guaranteed*
to be handled by getopt_long() is --option=argument, not --option
argument.  The BSD/macOS version of getopt_long() only supports the
former, not the latter.

Change-Id: Icfaec9eda49f5a947961251ebd377d7c1684c823
Reviewed-on: https://code.wireshark.org/review/28865
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-07-26 21:29:22 +00:00
Stig Bjørlykke 26be931810 extcap: Fix a potential leak of memory pointed to by 'toolbar_entry'
Initialize toolbar_entry after error checking is done to avoid a
potential memory leak when exiting early from cb_load_interfaces().

Change-Id: I925d9296085964c6d5c3a9ccae85137285bf9220
Reviewed-on: https://code.wireshark.org/review/28060
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2018-06-06 12:39:17 +00:00
Guy Harris d08d0a87c5 Eliminate some unneeded header checks.
sys/stat.h and sys/types.h date back to V7 UNIX, so they should be
present on all UN*Xes, and we're assuming they're available on Windows,
so, unless and until we ever support platforms that are neither UN*Xes
nor Windows, we don't need to check for them.

Remove the CMake checks for them, remove the HAVE_ values from
cmakeconfig.h.in, and remove all tests for the HAVE_ values.

Change-Id: I90bb2aab37958553673b03b52f4931d3b304b9d0
Reviewed-on: https://code.wireshark.org/review/27603
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-05-16 22:03:09 +00:00
Pascal Quantin ac1c1c3e58 extcap.c: fix compilation with gcc 8
extcap.c:228:37: error: cast between incompatible function types from ‘void (*)(iface_toolbar_value *)’ {aka ‘void (*)(struct _iface_toolbar_value *)’} to ‘void (*)(void *, void *)’ [-Werror=cast-function-type]
extcap.c:246:39: error: cast between incompatible function types from ‘void (*)(iface_toolbar_control *)’ {aka ‘void (*)(struct _iface_toolbar_control *)’} to ‘void (*)(void *, void *)’ [-Werror=cast-function-type]
extcap.c:521:32: error: cast between incompatible function types from ‘void (*)(void *)’ to ‘void (*)(void *, void *)’ [-Werror=cast-function-type]
extcap.c:1440:35: error: cast between incompatible function types from ‘void (*)(void *)’ to ‘void (*)(void *, void *)’ [-Werror=cast-function-type]

Change-Id: I2422e9b59c288907882c9ffd57cbae12011f7832
Reviewed-on: https://code.wireshark.org/review/27264
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-05-02 19:33:30 +00:00
Anders bb81bef535 glib: Get rid of GLIB_CHECK_VERSION as we now require 2.32.0
Change-Id: Ie95cf37f9cd283545693e290340a7489cc989c95
Reviewed-on: https://code.wireshark.org/review/26970
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-04-16 16:07:46 +00:00
Stig Bjørlykke 89904b6133 extcap: Fix crash in extcap_verify_capture_filter
This fixes a regression issue from g57fed5d1 when freeing the
arguments passed to extcap.

Change-Id: Ic4d6a129569f9e691fd2608e0229342b8b5e9783
Reviewed-on: https://code.wireshark.org/review/26870
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2018-04-11 07:28:17 +00:00
Stig Bjørlykke 1549cc122c extcap: Fix whitespace issues
Change-Id: I70066077a55b094eb2e667d31190ae80c3b97b5f
Reviewed-on: https://code.wireshark.org/review/26871
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2018-04-11 07:27:43 +00:00
Stig Bjørlykke 5d1b5648fa extcap: Always use byte mode in pipes
The original PipeMode parameter to CreateNamedPipe() was wrong but
when running gave a correct value. The changes in g00373a1f tried to fix
this parameter but this gave incorrect values.

Bug: 14532
Change-Id: Ia1e8e9ba54abfcc3bd0856fd715b7c69ee54ccfe
Reviewed-on: https://code.wireshark.org/review/26786
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2018-04-07 18:02:23 +00:00
Roland Knall 485cec5bdf extcap: Fix version request
The original implementation lead to multiple extcap interfaces
being loaded, as well as an error output from the default example.

This fixes both

Change-Id: Icb6fbda7bcb11ed0d14cb683ddcdabdc20a7070d
Reviewed-on: https://code.wireshark.org/review/26773
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2018-04-06 10:41:53 +00:00
Guy Harris 024f75fb3e Fix handling of --extcap-version with an argument.
Not all versions of getopt_long() allow, for an option for which the
argument is optional, --xyzzy {value}; at least some of them, such as
the *BSD/macOS one, require --xyzzy={value}.  Make it so.

Change-Id: I856d9f253535d804c7674d209054bc6ce10ee91d
Reviewed-on: https://code.wireshark.org/review/26772
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-04-06 05:06:18 +00:00
Roland Knall 6124ee2a1c extcap: Reload values on request
Allow certaing elements to be reloaded upon request. The way
this works is, certain elements can be configured to be reloadable.

By doing so, the extcap is asked once more just for the values
list of this item, together with all already set options, and
reloads the available options depending on the response.

Only supported for selector. Radio and Multiselect will need
additional patches, also moving those parts outside of extcap_argument.cpp
might make sense before hand.

Change-Id: I2e9e3d109b334bf878835a7cc9354f468bc22dee
Reviewed-on: https://code.wireshark.org/review/26223
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2018-04-05 09:31:23 +00:00
Roland Knall c2422d7828 extcap: Tell utilities the wireshark version
Add an optional argument to extcap-version, which tells the utilities
the wireshark version and therefore allows them to handle different
versions differently.

If no version is provided, the utility has to assume it is dealing
with a Wireshark 2.x version (default behavior).

Change-Id: I51658300f28f503ca8050d204b73749f1a54df16
Reviewed-on: https://code.wireshark.org/review/26752
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2018-04-05 08:40:04 +00:00
Roland Knall 57fed5d17f extcap: Move extcap_foreach to a GList
Allow for a higher flexibility of the arguments passed to extcap_foreach

Change-Id: I19708ac9d6c2aceecd88d0f691b5155bb8027675
Reviewed-on: https://code.wireshark.org/review/26736
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2018-04-04 18:08:43 +00:00
Gerald Combs 80d652f06e More spawned process handling updates.
Document ws_pipe.h. Define invalid PIDs in one place.

Extcap didn't use stdin before 1a0987904f. Make sure we close it.

Change-Id: I7a69cd9b5137ae82435e64628a22e4d812d58f89
Reviewed-on: https://code.wireshark.org/review/26226
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-02 18:07:58 +00:00
Gerald Combs 1a0987904f Generalize our process spawning code.
Move the contents of extcap_spawn to ws_pipe. Rename various extcap_*
prefixes to ws_pipe_*. Open stdin when we spawn processes.

Change-Id: I9286295443ee955bb6328b0ed6f945ee0bb2a798
Reviewed-on: https://code.wireshark.org/review/26216
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-03-02 05:22:20 +00:00
Guy Harris 00373a1fd4 Simplify the mode passed to CreateNamedPipe().
There's one mode you use if byte_mode is true, and another mode you use
if it's false.  My head hurts when I try to pretend to be a top-down
parser for C and feed myself the existing expression, and Visual Studio
Code Analyzer says "are you sure that's what you had in mind?", so I'm
guessing the modes are:

	byte mode: PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT
	not byte mode: PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT

and am just using one test of byte_mode to choose between them.

Put the entire function under an #ifdef, so we can mark the byte_mode
argument as unused on UN*X but not on Windows.

Change-Id: Ib2d0b80f870b1789c1375ccb017bd90e93dca5ce
Reviewed-on: https://code.wireshark.org/review/26201
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-03-01 04:05:03 +00:00
Dario Lombardo 8cd389e161 replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.
The first is deprecated, as per https://spdx.org/licenses/.

Change-Id: I8e21e1d32d09b8b94b93a2dc9fbdde5ffeba6bed
Reviewed-on: https://code.wireshark.org/review/25661
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08 14:57:36 +00:00
Dario Lombardo df45d5b1ac extcap: check preference in extcap_ensure_interface().
Change-Id: I2b854b410e54b9f85ce26212d908c474f4611929
Reviewed-on: https://code.wireshark.org/review/25289
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-01-14 08:33:14 +00:00
Dario Lombardo 73f26e4d24 extcap: check preference in extcap_loaded_interfaces().
Change-Id: Ie1fd214eb8f9d55f1ce400b7227ad9887f05da76
Reviewed-on: https://code.wireshark.org/review/25286
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-01-14 08:33:02 +00:00
Dario Lombardo c1301a4862 extcap: add more checks for extcap disabled.
Change-Id: I914efbb4293518a8a3f8aaa8739c9915c63d941c
Reviewed-on: https://code.wireshark.org/review/25278
Petri-Dish: Roland Knall <rknall@gmail.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-01-12 12:14:56 +00:00
Dario Lombardo 22b5ffad86 extcap: add preference to prevent interfaces loading.
Change-Id: Ia5865a40c75e582f28408a0515c5c0b38e43a916
Reviewed-on: https://code.wireshark.org/review/25188
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2018-01-09 09:58:48 +00:00
Guy Harris 6a949ed155 Put special pipe-handling code into libwsutil.
Ask, in a comment, why we're doing PeekNamedPipe() when we're trying
to read everyting in the pipe, up to the EOF, into a string.

On UN*X, do the same "read up to an EOF and then NUL-terminate the
result" stuff that we did on Windows; nothing guarantees that, on all
UN*Xes, in all circumstances, until the end of time, world without end,
amen, we can do one read and get the entire string.

Change-Id: I578802b23fec1051139eaefd9a09fe2a6de06a11
Reviewed-on: https://code.wireshark.org/review/24959
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-12-23 20:43:32 +00:00
Dario Lombardo 271d6c14ef extcap: null terminate the string that will be used in strlen (CID 1364684).
Change-Id: Ie4c7eed2ac24327292af9a45ffc7e4630338a6b4
Reviewed-on: https://code.wireshark.org/review/24948
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-12-23 01:31:31 +00:00
Michael Mann bb5ade02d5 NULL check some g_log statements for extcap.
"Yes, on *most* UN*Xes, that causes "(null)" to be printed, but it causes a crash on at
least some versions of Solaris, so Don't Do It." - Guy Harris

Bug: 14194
Change-Id: Iff0d59803d78b1e87a564e8bcdc5c84af485eea6
Reviewed-on: https://code.wireshark.org/review/24922
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-12-21 01:16:26 +00:00
Gerald Combs 775bbbcded Start using SPDX license identifiers.
A while back Graham pointed out the SPDX project (spdx.org), which is
working on standardizing license specifications:

https://www.wireshark.org/lists/wireshark-dev/201509/msg00119.html

Appendix V of the specification describes a short identifier
(SPDX-License-Identifier) that you can use in place of boilerplate in
your source files:

https://spdx.org/spdx-specification-21-web-version#h.twlc0ztnng3b

Start the conversion process with our top-level C and C++ files.

Change-Id: Iba1d835776714deb6285e2181e8ca17f95221878
Reviewed-on: https://code.wireshark.org/review/24302
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Balint Reczey <balint@balintreczey.hu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-11-09 20:03:51 +00:00
Pascal Quantin c199952f5c extcap: fix parameters save in preferences file
Since g583150198b, extcap_arg structures holds a pointer to the current
preference value. So let's not update its value outside of the prefs API
otherwise the call to prefs_set_string_value() with pref_current done
afterwards will never notify the change and the updated value will not
be written in the preference file.
Moreover update ExtcapArgument::resetValue() method to have an empty
string instead of a NULL pointer. Otherwise prefs_set_string_value()
will not notify the change and save the restored default value in the
preference file either.

Change-Id: Ie70e79d471c75e25705c7654e420a7706ebc4032
Reviewed-on: https://code.wireshark.org/review/23308
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-08-31 04:34:39 +00:00
Pascal Quantin fa8a6a3eee extcap: check that argument parameter is not null before adding it to command line
Without this test, we add an argument with an empty parameter

Bug: 14006
Change-Id: I7e5313f652691808735f54b533cf5a7f7adeeae1
Reviewed-on: https://code.wireshark.org/review/23271
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-08-29 07:44:28 +00:00
Mikael Kanstrup 3b16cc8b21 iface_lists: Access ifaces member by reference
Change access of ifaces elements from by val to by reference.
With this change unnecessary copying of the whole struct is avoided
but even more important is that elements no longer have to be
removed and inserted whenever data is updated.

This change aims to make it more clear that ifaces elements shall
never directly be removed from the array. Instead use function
capture_opts_del_iface

NOTE: Code for GTK UI not updated

Ping-Bug: 13864
Change-Id: I04b65d5ee36526b30d959b8e5a2a48a3c7c4f15b
Reviewed-on: https://code.wireshark.org/review/23204
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-08-28 14:43:13 +00:00
Håkon Øye Amundsen 018f6bff18 extcap: Interface Toolbar support on Windows
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 <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-08-28 05:48:01 +00:00
Stig Bjørlykke 4540195025 extcap: Create unique pipe names for each interface
On Windows the pipe names does not get random characters appended.
Add the interface name and pipe type to make it unique.

This partly fixes the issue with capturing from multiple extcap
interfaces on Windows.

Ping-Bug: 13653
Ping-Bug: 13833
Change-Id: I4290b37cf789bf77608993682a803aca29513d28
Reviewed-on: https://code.wireshark.org/review/23158
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-08-23 07:26:18 +00:00
Ahmad Fatoum aca55a29f7 Add hardware timestamping support
pcap provides a pcap_set_tstamp_type function, which can be used to request
hardware timestamps from a supporting kernel.

This patch adds support for aforementioned function as well as two new
command line options to dumpcap, wireshark and tshark:

    --list-time-stamp-types
                             List time stamp types supported for the interface
    --time-stamp-type <type>
                             Change the interface's timestamp method

Name choice mimics those used by tcpdump(1), which already supports this
feature. However, unlike tcpdump, we provide both options unconditionally.
If Wireshark was configured without pcap_set_tstamp_type being available,
--list-time-stamp-types reports an empty list.

Change-Id: I418a4b2b84cb01949cd262aad0ad8427f5ac0652
Signed-off-by: Ahmad Fatoum <ahmad.fatoum@siemens.com>
Reviewed-on: https://code.wireshark.org/review/23113
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-08-22 07:55:26 +00:00
Dario Lombardo f49ae745c1 extcap: use options as they are shown in the dialog.
Bug: 13051
Change-Id: I287a4e1d529cc281aaae4a786010358c108d5f93
Reviewed-on: https://code.wireshark.org/review/22933
Petri-Dish: Roland Knall <rknall@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-08-15 14:49:41 +00:00
Peter Wu 1c7e393af3 extcap: another round of memory leak fixes
Fix assorted memory leaks. Note that _tool_for_ifname is cleaned up at
exit by extcap_cleanup, but lacked key/value destructors, so add them.
After this, ASAN reports no more extcap memleaks.

Change-Id: Ie5f4b1e2453a0beb52d617670202973839ca1416
Reviewed-on: https://code.wireshark.org/review/22466
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-06-30 05:47:54 +00:00
Michael Mann 6c44f2017c Qt: Add support to verify extcap capture filter
Bug: 11668
Change-Id: Ib218d87c1905e53ffdab4e3dd6f93ba2c3d07c8b
Reviewed-on: https://code.wireshark.org/review/21770
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Roland Knall <rknall@gmail.com>
2017-05-30 18:10:03 +00:00
Martin Mathieson e0ab0b72ae Extcap: use glib-compat for g_list_free_full()
Change-Id: I13e6a465b0e169f2f4ce134df3c873c416737b33
Reviewed-on: https://code.wireshark.org/review/21476
Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-05-03 18:56:22 +00:00
Martin Kaiser acdc0a0230 extcap_free_interface_info: data param is used
The data parameter is used, remove the _U_ qualifier.

Change-Id: I3a3935bae958103da1a7a1abe0636e4781424aa7
Reviewed-on: https://code.wireshark.org/review/21408
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
2017-04-29 12:04:31 +00:00
Stig Bjørlykke 77751c94f1 Qt: Add interface toolbar support
An extcap utility can provide configuration for controls to use in a
GUI interface toolbar.  This controls are bidirectional and can be
used to control the extcap utility while capturing.

This is useful in scenarios where configuration can be done based on
findings in the capture process, setting temporary values or give other
inputs without restarting current capture.

Todo:
- Add support for Windows

Change-Id: Ie15fa67f92eb27d8b73df6bb36f66b9a7d81932d
Reviewed-on: https://code.wireshark.org/review/19982
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2017-04-25 06:19:39 +00:00
Max Dmitrichenko 9e8bc9fee8 extcap: fix memory leak
found by valgrind

Change-Id: I8c5226a08be797ce72ec937138a6681d946fb13c
Reviewed-on: https://code.wireshark.org/review/20720
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2017-04-19 22:32:58 +00:00
Guy Harris bd3196b094 Don't waste time trying to run non-plain file and non-executable files.
Directories, and non-executable files, aren't going to be extcap
executables.

This may not make much of a difference for an installed version of
Wireshark, but it makes a difference if you're running from the build
directory.

Change-Id: Ib9953fa04392dc7a8420ddf28bab9726e6050c12
Reviewed-on: https://code.wireshark.org/review/20752
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-27 19:51:26 +00:00
Roland Knall ee9b998d64 extcap: Minor improvements
Add method for searching for tools by ifname and minor improvements
in the interface callback to save time and space

Change-Id: I0073c96fbee846cc5ff6304823fa14564ff36c22
Reviewed-on: https://code.wireshark.org/review/20376
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2017-03-04 07:32:25 +00:00
Roland Knall 1d31986e8d extcap: Create callback structure
To ease development of callbacks and new parameters,
move all parameters for the callback methods to a
struct

Change-Id: I160277acf4d0473897172124f7c7aa744718da9c
Reviewed-on: https://code.wireshark.org/review/20316
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2017-03-01 12:50:01 +00:00
Dario Lombardo 8851c1c56e extcap: remove leak in interface lists.
Change-Id: Ib57292afc88cd32736b78a901385cfdde84c46c9
Reviewed-on: https://code.wireshark.org/review/20297
Reviewed-by: Roland Knall <rknall@gmail.com>
Petri-Dish: Roland Knall <rknall@gmail.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-02-27 13:25:59 +00:00
Roland Knall 6dce310305 extcap: Reduce number of scans and storage
Reduce the number of storage arrays and the number
of necessary loads. Also include cleaner methods for
reloading the interfaces and cleanly reload if asked by
the overall system

Change-Id: I529465ec2593d40c955c6cdeaf3a85e3021c0596
Reviewed-on: https://code.wireshark.org/review/20230
Petri-Dish: Roland Knall <rknall@gmail.com>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2017-02-22 13:40:33 +00:00
Dario Lombardo 3481ca8733 extcap: destroy hash tables on exit.
Change-Id: Ia6a1d8a45c36aff7f2bea8bde2ed5f308bddd2e1
Reviewed-on: https://code.wireshark.org/review/19919
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
2017-02-03 11:19:15 +00:00
Michael Mann 21a3b8cc71 Internalize struct preference
Move "struct preference" into prefs.c, essentially creating a "private"
structure to handle preferences. The 2 motivating factors were:
1. Better memory management so that clients/users of API don't have to worry
about it.
2. Hide the ugliness of the union stuff and make it transparent to the API.

A few bugs related to preference <-> Decode As integration were fixed
while in the neighborhood.

Change-Id: I509b9a236235d066b139c98222b701475e0ed365
Reviewed-on: https://code.wireshark.org/review/19578
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-01-22 10:43:57 +00:00
Michael Mann 4b3b3f5877 Extcap: Restore previously created preference from hash table, not preference pointer
Change-Id: Ie68a5c6c193f362e78d4f4b1f20edf7747e2313f
Reviewed-on: https://code.wireshark.org/review/19614
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2017-01-12 13:33:49 +00:00
Guy Harris 26430ff647 Include extcap binaries in the count of things to point out during startup.
The GTK+ version, at least, crashes if there are more "doing XXX..."
items put up than the calculated count, so, now that we're putting up
items for extcap binaries, we need to count the extcap binaries.

Clean up some stuff we found doing this (indentation, a _U_ on something
that's used).

Change-Id: I1f88042b64ce4b9ae352de37689677c694e3770b
Reviewed-on: https://code.wireshark.org/review/19549
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-01-04 22:10:48 +00:00
Stig Bjørlykke 07ffcf9042 extcap: Avoid double free of help.
Avoid double free of help when having multiple extcap interfaces.

Ping-Bug: 13218
Change-Id: I6a0d6afd645787f9814c02e84079b4e8763d05f1
Reviewed-on: https://code.wireshark.org/review/19261
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-12-14 14:35:30 +00:00
Dario Lombardo 1c2d224647 extcap: set help for interfaces.
The help statement is in the first sentence, while interfaces are
in others. We need to keep state of it.

Ping-Bug: 13218
Change-Id: Iad1d403d5e8bc34e2489daaa3b14d469d5ee5b5b
Reviewed-on: https://code.wireshark.org/review/19148
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-12-14 10:12:43 +00:00
Stig Bjørlykke 6b064e0e14 extcap: Whitespace cleanup.
Cleanup code to use uniform whitespace to make it more readable.
Also added brackets to unbracketed one line conditional statements.

This was done using "astyle -A1cHjk3pU".

Change-Id: Iebe96c488c843ce1d790ede0016eb9df025e98a5
Reviewed-on: https://code.wireshark.org/review/19133
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-12-08 21:18:41 +00:00
Stig Bjørlykke fa47c368c6 extcap: Separate dirname and file with G_DIR_SEPARATOR_S.
Change-Id: I9e1e9b1a10a15ca95519392a7a19ba77f460141e
Reviewed-on: https://code.wireshark.org/review/19131
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-12-07 19:46:49 +00:00
Guy Harris 10ca4c7527 More checks for localtime() and gmtime() returning NULL.
And some comments in the case where we're converting the result of
time() - if your machine's idea of time predates January 1, 1970,
00:00:00 UTC, it'll crash on Windows, but that's not a case where a
*file* can cause the problem due either to a bad file time stamp or bad
time stamps in the file.

Change-Id: I837a438e4b875dd8c4f3ec2137df7a16ee4e9498
Reviewed-on: https://code.wireshark.org/review/18369
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-10-22 02:27:32 +00:00
Pascal Quantin 66203b4f31 extcap: fix management of multicheck and saved non boolean arguments
Launching USBPcap without going in the interface options menu exhibits 2 bugs:
- we should restore a value only if it is not an empty string (otherwise USBPcap with an ampty --devices multicheck argument)
- when building the argument list for a non boolean argument not using the default value, do not call g_strconcat. It will
build a string concatenating the option and value (for example "--devices 1" that will be treated as a single argument).
Instead option and value must be given separately to argument list.

Bug: 12846
Change-Id: I5628cb264a7632089e6579e9ae7400e2c0e500e2
Reviewed-on: https://code.wireshark.org/review/17773
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-09-18 09:01:08 +00:00
Peter Wu 2c33f74bc6 extcap: fix heap-use-after free after saving prefs
All strings passed to prefs must be valid for the lifetime of the
program (before prefs_cleanup is called). Use wmem for this purpose.
Fixes v2.3.0rc0-660-g26bf66f

Change-Id: I94f3bbb8ac6e18ae59d6462525f6bbc46fdb0f1f
Reviewed-on: https://code.wireshark.org/review/17737
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-09-17 10:44:23 +00:00
Guy Harris 84436438a8 Fix file name in comment.
Change-Id: I2a5b6e5c0ba8e729fbfa7e9e218aca1c747d6e45
Reviewed-on: https://code.wireshark.org/review/17667
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-12 16:52:17 +00:00
Peter Wu 26bf66f423 extcap: plug more memory leaks
Fix leak of the preference key name which happen for every new extcap
argument. Fix leak of extcap arguments and the interface names in
extcap_register_preferences.

Change-Id: Idd68f924baa000303043cb98b32b23ce34fddb64
Reviewed-on: https://code.wireshark.org/review/17637
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-09-12 12:14:46 +00:00
Mikael Kanstrup c64762d33c extcap: Fix misc memory leaks triggered by network interface changes
Valgrind reports plenty of misc memory leaks in extcap after the network
interface list has changed or is refreshed. Errors can be seen by
starting Wireshark with Valgrind's memcheck tool and bringing a network
interface up and down a few times with:

ifconfig eth0 up
ifconfig eth0 down

Change-Id: I90f53847071854b7d02facb39b7a380732de79b4
Reviewed-on: https://code.wireshark.org/review/17606
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-09-12 12:13:41 +00:00
Peter Wu 583150198b extcap: fix use-after-free for preferences
In commit v2.3.0rc0-117-g485bc45 (backported to v2.2.0rc0-44-g66721ca),
extcap_prefs_dynamic_vals and extcap_cleanup were added in an attempt to
address dangling pointers.

Unfortunately it is not sufficient:

 - A pointer to the preference value is stored in extcap_arg and passed
   to the prefs API, but this extcap_arg structure can become invalid
   which result in use-after-free whenever the preference is accessed.
 - On exit, a use-after-free occurs in prefs_cleanup when the preference
   value is being checked.

As the preference subsystem actually manages the memory for the string
value and consumers should only provide a pointer where the value can be
stored, convert the char* field in extcap to char**. This has as
additional benefit that values are not limited to 256 bytes anymore.

extcap_cleanup is moved after epan_cleanup to ensure that prefs_cleanup
does not operate on dangling pointers.

Crash is reproducible under ASAN with: tshark -i randpkt

Ping-Bug: 12183
Change-Id: Ibf1ba1102a5633aa085dc278a12ffc05a4f4a34b
Reviewed-on: https://code.wireshark.org/review/17631
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-09-11 08:33:42 +00:00
Guy Harris bd45929ba6 extcap_child_watch_cb() always uses the status argument.
Change-Id: I2537f2e3babe2158796acda6855f5aebeb0b7d4d
Reviewed-on: https://code.wireshark.org/review/17595
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-08 20:43:28 +00:00
Roland Knall ee1a4109cf extcap: Add tool-specified helppage
Allow the tool to provide a link to a helppage, displayed
by clicking on help in the configuration dialog.

The URL will be opened using an URL based service, therefore local
as well as remote URLs are possible.

Change-Id: I58b30244e97919d5cf6892faf96536ddc30fb5a7
Reviewed-on: https://code.wireshark.org/review/17549
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-09-07 09:09:30 +00:00
Roland Knall 9b39db04d3 extcap:Replace self-organized lists with glib ones
Replace the error-prone next/prev handling with GList and GHashTable
Cleanup extcap_parser to only expose necessary functions
Remove token know-how from extcap

Change-Id: I7cc5ea06f58ad6c7a85ac292f5d2cb3d33e59833
Reviewed-on: https://code.wireshark.org/review/17496
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-09-06 04:19:45 +00:00
Alexis La Goutte 5ebfbf4fec extcap: Fix Dereference of null pointer
Change-Id: I03098de9bd8684953a4fe024a3e6b604eeecf03f
Reviewed-on: https://code.wireshark.org/review/17066
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2016-08-15 20:52:07 +00:00
Pascal Quantin 0bf1288607 extcap: preference name must only contain lower case ASCII, numbers, dots or underscores
This chage set restores the normalization that was done before g485bc45.
Without it, USBPcap extacp utility triggers a crash.

Change-Id: Id960db186888452ec3d04df1ee48dcc3899e8951
Reviewed-on: https://code.wireshark.org/review/16871
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-08-04 11:27:19 +00:00
Michael Tuexen 18f775af55 Fix compilation on FreeBSD.
Includes are needed for using macros like WIFEXITED.

Change-Id: Ia09ca58eeab2d151a756d285b0aeb55141c4d24a
Reviewed-on: https://code.wireshark.org/review/16841
Reviewed-by: Michael Tüxen <tuexen@wireshark.org>
2016-08-02 12:33:52 +00:00
Roland Knall d62ad9dd47 extcap: Remove g_spawn_check_exit_status
This function is not supported in the min GLIB version, therefore
the code is to be removed

Change-Id: Ie39170bfc0662e5a477cbc45d7eadebcf2c70d4e
Reviewed-on: https://code.wireshark.org/review/16827
Petri-Dish: Roland Knall <rknall@gmail.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-08-02 11:16:16 +00:00
Dario Lombardo 867d7ca399 extcap: add null check (CID 1364683).
Change-Id: I1d81d6f043fa695ed507cf733fffa832922a708c
Reviewed-on: https://code.wireshark.org/review/16832
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-08-02 04:16:45 +00:00
Dario Lombardo abe8e51dbf extcap: extend buffer (CID 1364684).
Change-Id: I4ed6965fa1173b69d9e325bc814e382b5368d40c
Reviewed-on: https://code.wireshark.org/review/16831
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-08-02 04:15:19 +00:00
Roland Knall c611eded22 extcap: Use stderr to print error message
This patch reads out the stderr messages from an extcap
utility and displays it to an user. It was tested on Qt
but not on GTK, but should work their as well.

On Mac OS/X and Windows the child_watch does not behave
as it was intended. Therefore in extcap_cleanup, the callbacks
are called manually, if and only if, they have not been
called already.

The reason why it displays two error messages is, that
by the time the first one is being displayed, glib has not
returned from the spawned process on Linux yet. So there
is no way to add the stderr correctly, and putting a handler
to stderr into interface_opts will lead to memory errors,
cause then the code tries to access memory outside of its
protection.

Bug: 11892
Change-Id: I2db60dd480fed3e01428b91a705057e4f088bd15
Reviewed-on: https://code.wireshark.org/review/12954
Reviewed-by: Roland Knall <rknall@gmail.com>
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-07-30 21:15:39 +00:00
Roland Knall 485bc456c5 extcap: Restore functionality for options
Allow stored options to be restored to their default values. This
adds a global cleanup method for extcap and globally defined
preference values, which fixes the parameter problem with windows

Change-Id: I48e0cf846ef81f4732d652c6a2ad0020db5df08e
Reviewed-on: https://code.wireshark.org/review/13741
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-07-29 03:15:54 +00:00
Roland Knall f2786bc8ff extcap: Remove g_spawn_helper support
Move g_spawn to separate file and implement functions to
 use Windows based method of spawning, instead of the glib
 based version

Change-Id: Ibae03d834ec86531eba37dc8768fbf17ddadf57f
Reviewed-on: https://code.wireshark.org/review/16049
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-07-05 11:54:43 +00:00
Michael Mann acc018b8d1 Allow create_tempfile to support a suffix.
Ping-Bug: 10203
Change-Id: Ifa24870d711449b87e9839dd46af614e4aa28fde
Reviewed-on: https://code.wireshark.org/review/15608
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2016-06-01 06:24:05 +00:00
Pascal Quantin ae316e2d88 Compile sshdump and ciscodump for Windows
Use libSSH 0.7.2 compiled with MinGW(32|64) and linked with zlib and gcrypt support

Change-Id: I7c17d1ba3dd1890e2f83c119f5ea851834807e43
Reviewed-on: https://code.wireshark.org/review/12117
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-04-25 07:22:28 +00:00
Dario Lombardo 20e7accf8c extcap: fix const compiler warnings.
Change-Id: I849b16597829212b195bd75a2aab8e1db49f1ccf
Reviewed-on: https://code.wireshark.org/review/14827
Reviewed-by: Roland Knall <rknall@gmail.com>
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-04-19 01:42:19 +00:00
João Valverde 52dd4fb633 Fix building without extcap enabled
Using cmake -DENABLE_EXTCAP=no or ./configure --without-extcap.

Some documentation fixes too.

Change-Id: Iebf9c843d67e10a32de1a62904de8f88b872ec99
Reviewed-on: https://code.wireshark.org/review/14522
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2016-03-21 17:10:21 +00:00
Guy Harris 842a9b5100 Replace extcap_interface_list() with append_extcap_interface_list().
Pull the "rebuild the list of extcap interfaces and, optionally, return
a list of if_infos for them" into a separate
extcap_reload_interface_list() routine, call it in the cases where we
don't want the if_infos list, and have append_extcap_interface_list()
call it, asking it for the if_infos list, and then append the interfaces
to that list.

Change-Id: I07478ab133859484b3e0916144971639f961224b
Reviewed-on: https://code.wireshark.org/review/14189
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-02-27 01:04:33 +00:00
Guy Harris 60f87ca919 Put the extcap interfaces at the *end* of the interface list.
The list should start with the native local interfaces, as returned by
pcap, so that we default to the interface pcap gives first, rather than
to whatever extcap interface happens to be at the beginning.

This also means that, if we're only calling extcap_interface_list() to
regenerate our internal data structures, we don't bother allocating -
and leaking! - a list of if_info structures.

Change-Id: Ida651b5b081883f118a300b9f57403f2dc5c4363
Ping-Bug: 12183
Reviewed-on: https://code.wireshark.org/review/14187
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-02-27 00:37:22 +00:00
Guy Harris c5c10581b6 Clean up setting *err_str to NULL.
Just do it upfront.

Change-Id: I5305882b8efd080fcb3e8ea626e09f4682729702
Reviewed-on: https://code.wireshark.org/review/14185
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-02-26 23:29:44 +00:00
Guy Harris 9253791648 Fix indentation.
Change-Id: I201c35e1f6dfdb67a68dbc0ee684e0231842f00b
Reviewed-on: https://code.wireshark.org/review/14182
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-02-26 22:56:28 +00:00
Roland Knall 3f43b1df44 extcap: Fix call to child watch
Child watch seems to keep executables in limbo, if extcap_cleanup
removed the watch before it could be fired at least once

Bug: 12080
Change-Id: I74afafe8545d464ec08b1043a6377a6450e4c772
Reviewed-on: https://code.wireshark.org/review/13900
Petri-Dish: Roland Knall <rknall@gmail.com>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-02-11 08:49:54 +00:00
Mikael Kanstrup 7a1eca1726 extcap: Convert settings to preference friendly key names
Preferences are only allowed to contain lowercase ASCII letters,
numbers, underscores or dot characters. Create a utility function
to convert an extcap setting to its equivalent preference key and
use it wherever conversion from setting to preference key is needed.

Bug: 12064
Change-Id: I39bbac7de5f0f905bd41c54257fa997a3b32442d
Reviewed-on: https://code.wireshark.org/review/13687
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-02-11 06:40:16 +00:00
Mikael Kanstrup a53ab9dfcc Fix leaks when spawning extcap processes
Valgrind reports leaks like these when spawning extcap processes (for
example when displaying or refreshing interface list with extcap
interfaces present):

3,917 (464 direct, 3,453 indirect) bytes in 29 blocks are definitely lost in loss record 58,301 of 58,638
   at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0xA6D2610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA6E822D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA6B913B: g_error_new_valist (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA6B94ED: g_set_error (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA710B03: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA710E17: g_spawn_sync (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0x44C677: extcap_foreach (extcap.c:199)
   by 0x44CCAD: extcap_interface_list (extcap.c:413)
   by 0x72B548: capture_interface_list (capture_ifinfo.c:126)
   by 0x7336FA: scan_local_interfaces (iface_lists.c:141)
   by 0x55F01F: WiresharkApplication::refreshLocalInterfaces() (wireshark_application.cpp:898)
   ...

Change-Id: If8f750f5f8fa42a6f0884bb0e6bbbd71bd8f68aa
Reviewed-on: https://code.wireshark.org/review/13631
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-02-01 20:36:37 +00:00
Roland Knall 71a21d79cf extcap: Correct save for file arguments
Also add check to has_configuration

Change-Id: Ia0ffbd3bf68ad51c26bc75b5ee179db179e22bd4
Reviewed-on: https://code.wireshark.org/review/13635
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-02-01 12:14:44 +00:00
Roland Knall 927ffaa794 extcap: Add Save functionality to options dialog
This patch creates the functionality of saving all parameters
for extcap devices in the general preference section.

For now, multiselect and fileselect do not save their values
but patches for this will be provided in the future

Also, all preferences are stored as strings to make handling
easier. This might change in the future, but for the first version
it will stick.

Restore to Defaults is not implemented as of yet, and will be
in a future version, once the preference storing is finalized

Bug: 11666
Change-Id: I178346405146d2e43f4f3481c05c92c0b3595af5
Reviewed-on: https://code.wireshark.org/review/13451
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-02-01 12:12:41 +00:00
Mikael Kanstrup 96acb62c82 Fix memleaks on interface refresh when extcap configs exists
If there are extcap interfaces present then each time the capture
interfaces list is displayed or refreshed a number of extcap related
allocations are leaked.

Valgrind reports leaks like these:

2,007 (144 direct, 1,863 indirect) bytes in 6 blocks are definitely lost in loss record 64,328 of 65,138
   at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0xA6D2610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA6E822D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA6C94F3: g_list_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0x44C9AF: search_cb (extcap.c:451)
   by 0x44C6FC: extcap_foreach (extcap.c:204)
   by 0x44CDFF: extcap_get_if_configuration (extcap.c:473)
   by 0x44CE3C: extcap_has_configuration (extcap.c:489)
   by 0x654356: InterfaceTree::display() (interface_tree.cpp:199)
   by 0x6547DF: InterfaceTree::getInterfaceList() (interface_tree.cpp:252)
   by 0xBFCF2A5: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1)
   by 0x563F9A: WiresharkApplication::allSystemsGo() (wireshark_application.cpp:914)
   by 0x4478D9: main (wireshark-qt.cpp:1373)

9,126 (432 direct, 8,694 indirect) bytes in 18 blocks are definitely lost in loss record 58,524 of 58,638
   at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0xA6D2610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA6E822D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA6C94F3: g_list_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0x44C9AF: search_cb (extcap.c:451)
   by 0x44C6FC: extcap_foreach (extcap.c:204)
   by 0x44CDFF: extcap_get_if_configuration (extcap.c:473)
   by 0x44CE3C: extcap_has_configuration (extcap.c:489)
   by 0x654356: InterfaceTree::display() (interface_tree.cpp:199)
   by 0xBFCF2A5: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1)
   by 0x4A3214: MainWindow::on_actionCaptureRefreshInterfaces_triggered() (main_window_slots.cpp:3605)
   ...

Change-Id: I9433b8e36813cbef9dca5ab08074e985793f4d0d
Reviewed-on: https://code.wireshark.org/review/13617
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-01-31 10:48:53 +00:00
Dario Lombardo ff033c6a2f extcap: add masked to options.
This allows an option to be masked (like a password), by using
the argument-type password.

Change-Id: I2eae1be2e6672bff28ba5f749d7a3f687ebd4631
Reviewed-on: https://code.wireshark.org/review/13385
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-01-18 15:04:33 +00:00
Stig Bjørlykke e3ab748b7d extcap: Code cleanup
Rewrote to avoid unneeded g_strdup/g_free constructs, made some
arguments const, simplified some code and fixed some whitespace.

Plugged a memory leak in extcap_free_info().

Change-Id: I0bfcd86e6464d8bc592329b05dc994191a430096
Reviewed-on: https://code.wireshark.org/review/13306
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-01-16 08:50:27 +00:00
Roland Knall 75ff25f285 extcap: Add list of extcaps to about dialog
Adds the list of available extcaps to the plugin list in the
About dialog of Wireshark (Qt only). To do this, and additional
sentence is provided in the extcap arguments list, which allows
for additional information to be passed (as of right now, just
version and display is used)

Additionally, cleans up the code when using g_free.

Bug: 11683
Change-Id: I04a958e2b73c9a707ab1cb4f2fc8345833a854a9
Reviewed-on: https://code.wireshark.org/review/13224
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-01-15 11:30:39 +00:00
Guy Harris 8b7020597a Don't use g_list_free_full().
It first appeared in GLib 2.28, and we support - and use, in the 32-bit
OS X buildbot - earlier versions.

Change-Id: I941a0206507e532c31cb13a918e3eb4d081e6ea3
Reviewed-on: https://code.wireshark.org/review/13240
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-12 20:08:49 +00:00