Commit Graph

436 Commits

Author SHA1 Message Date
Guy Harris ba589a4e44 Move some command-line-oriented routines from wsutil to ui.
cmdarg_err() is for reporting errors for command-line programs and
command-line errors in GUI programs; it's not something for any of the
Wireshark libraries to use.

The various routines for parsing numerical command-line arguments are
not for general use, they're just for use when parsing arguments.

Change-Id: I100bd4a55ab8ee4497f41d9651b0c5670e6c1e7f
Reviewed-on: https://code.wireshark.org/review/31281
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-01-01 02:07:06 +00:00
Alexis La Goutte ee58c3fc70 ssh-base: fix no previous prototype for ‘extcap_log’ [-Wmissing-prototypes]
Change-Id: I96f937ac7f0b085cd1db80b67f490193b02f9aca
Reviewed-on: https://code.wireshark.org/review/31203
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-12-26 20:14:37 +00:00
Jaap Keuter afc1265b63 writecap: rename pcapng_write_session_block to _section_block
The pcapng file format specification speaks of a secion block, not
a session block. Let the function name reflect the proper name of
the block it writes.

Change-Id: Id399fae3648c93f4750fedaa297b18f95f2bb96f
Signed-off-by: Jaap Keuter <jaap.keuter@xs4all.nl>
Reviewed-on: https://code.wireshark.org/review/31099
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-12-18 23:41:41 +00:00
Guy Harris a34cc98b2a Put the main() and wmain() routines for CLI programs into a separate file.
That means that code is only in one place, rather than having copies of
it in each of those programs.

CLI programs that, on Windows, should get UTF-8 arguments rather than
arguments in the local code page should:

	include the top-level cli_main.h header;

	define the main function as real_main();

	be built with the top-level cli_main.c file.

On UN*X, cli_main.c has a main() program, and just passes the arguments
on to real_main().

On Windows, cli_main.c has a wmain() function that converts the UTF-16
arguments it's handed to UTF-8 arguments, using WideCharToMultiByte() so
that it doesn't use any functions other than those provided by the
system, and then calls real_main() with the argument count and UTF-8
arguments.

Change-Id: I8b11f01dbc5c63fce599d1bef9ad96cd92c3c01e
Reviewed-on: https://code.wireshark.org/review/31017
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-12-13 00:52:11 +00:00
João Valverde 697623411c CMake: Use $ORIGIN with RPATH
Make our package relocatable on Unix systems.

Linux, Solaris and FreeBSD are known to support $ORIGIN.

Change-Id: Ibcdda33d62c075bfa867d006cb6aaf5824609011
Reviewed-on: https://code.wireshark.org/review/30896
Petri-Dish: João Valverde <j@v6e.pt>
Reviewed-by: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-12-03 23:54:15 +00:00
Mikael Kanstrup 22db1f066f androiddump: Don't present the verbose config option
The verbose config option has been replaced by an extcap base debug
option. Presenting verbose as an available option makes Wireshark
trying to retrieve the value of this option. As the option is not
really supported and invalid options after a recent change now
generate errors the androiddump tool does not start properly.

For reference the problem happens due the unfortunate combo of
these two patches:
v2.3.0rc0-1108-gb83ea46 ("extcap: put missed parameters into the help")
v2.9.0rc0-2431-g945d441 ("extcap: fix return value in extcap_base_parse_options().")

Fix by removing verbose as an available config option.

Change-Id: I894f599708a7160f50ca9ee1f9586022342705cb
Reviewed-on: https://code.wireshark.org/review/30716
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-20 05:08:46 +00:00
Mikael Kanstrup 51fb5081b3 androiddump: Add packets with same encap type as used when open wtap
Already when selecting the extcap interface to use the encap type is
known. For some reason when adding packets the type is explicitly
checked for certain values and if not known type is set to
WTAP_ENCAP_WIRESHARK_UPPER_PDU.

This conversion break tcpdump function for all but ETHERNET interface
type. For example NLMON and 802.11 radiotap interfaces does not work.

This problem has probably been there since quite a while back but was not
seen (in the sense that current capture looked OK). Though when:

"3aec5e1 Catch attempts to write multiple encapsulation types if unsupported."

got applied the encap type mismatch is now detected and packet capture stops.
As encap type is known already when selecting the interface to use, fix
this by simply reusing the initial value when dumping the packets.

Change-Id: Ica9824e715c47b285c985ea48cbae0e10e18d542
Reviewed-on: https://code.wireshark.org/review/30715
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-20 05:08:35 +00:00
Guy Harris a1372f6d01 Use an enum for compression types in various interfaces.
This:

1) means that we don't have to flag the compression argument with a
comment to indicate what it means (FALSE doesn't obviously say "not
compressed", WTAP_UNCOMPRESSED does);

2) leaves space in the interfaces in question for additional compression
types.

(No, this is not part 1 of an implementation of additional compression
types, it's just an API cleanup.  Implementing additional compression
types involves significant work in libwiretap, as well as UI changes to
replace "compress the file" checkboxes with something to indicate *how*
to compress the file, or to always use some other form of compression).

Change-Id: I1d23dc720be10158e6b34f97baa247ba8a537abf
Reviewed-on: https://code.wireshark.org/review/30660
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-11-16 09:20:36 +00:00
Guy Harris 4e17bd6229 Use the dump parameters structure for non-pcapng-specific stuff.
Use it for all the per-file information, including the per-file
link-layer type and the per-file snapshot length.

Change-Id: Id75687c7faa6418a2bfcf7f8198206a9f95db629
Reviewed-on: https://code.wireshark.org/review/30616
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-11-16 02:18:26 +00:00
Dario Lombardo 0795c988b0 extcap: save debug flag and use it to activate ssh debug.
Change-Id: Ida32834f8c0838f1d815f7e33116b6a6161acf34
Reviewed-on: https://code.wireshark.org/review/30572
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-14 04:58:38 +00:00
Dario Lombardo 7a29c3d2eb ssh-base: define a struct for storing ssh parameters.
Update sshdump and ciscodump to use it.

Change-Id: I5fbb9e3a870ec8baa0f326ad34733743cbb981f3
Reviewed-on: https://code.wireshark.org/review/30571
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-14 04:58:15 +00:00
Dario Lombardo cd0a98e221 ssh-base: support libssh config file.
It's operating system dependent, but the library takes care of it
on different operating systems.

Options are set with this precedence:
- if user-provided, use it
- if not, take the one from config file
- (username only) if none in the config file, take the current user from OS

Change-Id: I00dcc1c9a8613e6d1250b6404bf2100f6ccff7b7
Reviewed-on: https://code.wireshark.org/review/30558
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-14 04:57:48 +00:00
Guy Harris 3faa45d4ec Don't have _ng versions of the dumper open routines.
Have the routines always take a parameters pointer; pass either null or
a pointer to an initialized-to-nothing structure in cases where we were
calling the non-_ng versions.

Change-Id: I23b779d87f3fbd29306ebe1df568852be113d3b2
Reviewed-on: https://code.wireshark.org/review/30590
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-11-13 03:37:29 +00:00
Dario Lombardo 3486243361 sshdump: fix generation of error message from remote side.
Change-Id: I15f5989f08b7e3851a7c4b949d63434fbc750020
Reviewed-on: https://code.wireshark.org/review/30557
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-11-11 09:51:33 +00:00
Dario Lombardo 5d73f57f54 sshdump: fix some debug messages.
Change-Id: I92d157367efc36d4c1d1a53a201ed652d701894e
Reviewed-on: https://code.wireshark.org/review/30556
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-11-10 21:24:20 +00:00
Dario Lombardo f2a9cfcf24 ssh-base: fix wrong type for ssh port.
According to documentation:

http://api.libssh.org/master/group__libssh__session.html#ga82371e723260c7572ea061edecc2e9f1

Change-Id: I788f909efdb263d645bf402ad5a293a4b3e8d089
Reviewed-on: https://code.wireshark.org/review/30555
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-11-10 16:21:49 +00:00
Stig Bjørlykke 163e4637d5 extcap: Cleanup an if-statement
Change-Id: If56f3837e8bcf0ef3a11579ca031223909ac47b9
Reviewed-on: https://code.wireshark.org/review/30528
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-07 09:57:00 +00:00
Dario Lombardo 0a5770a78a extcap: add option to set proxycommand to ssh sessions.
sshdump and ciscodump have been updated to use it.

Change-Id: I4e1e0d35f086d76c13264939bc4f14308cc88cfb
Reviewed-on: https://code.wireshark.org/review/30496
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-05 05:59:38 +00:00
Dario Lombardo 2be2febfc6 extcap: change boolean to boolflag for --debug option.
Change-Id: I6a42e689fa9a914f7f3bee1c1ade2218573a1c3f
Reviewed-on: https://code.wireshark.org/review/30502
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-05 05:58:12 +00:00
Dario Lombardo 945d441b24 extcap: fix return value in extcap_base_parse_options().
We need to split good options' from bad options' return value.

Change-Id: I836e58c0f05716484664f354e7332a74d6a08c20
Reviewed-on: https://code.wireshark.org/review/30503
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-05 05:56:51 +00:00
Dario Lombardo 6910cb138b sshdump: add missing space.
Change-Id: I593ccf333db91dd9877cf5e8ef30c3e722c6df89
Reviewed-on: https://code.wireshark.org/review/30497
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2018-11-03 14:18:05 +00:00
Gerald Combs aba59e5973 Win32: Make extcap utilities console applications.
Switch from using WinMain in extcap to wmain.

Change-Id: I54fafad598f5ff74fe84a3ce3e993ac5a31188f7
Reviewed-on: https://code.wireshark.org/review/30094
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-10-12 19:01:49 +00:00
Gerald Combs 573e842002 Windows: Make our program details more consistent.
Use a single template file for most of our program resources. Encode
our resource files as UTF-8. Add resources to extcap/*.exe.

Replace a regex with concatenation.

Change-Id: I0ed49086618127ca4fdef69272f849d8f16e4dab
Reviewed-on: https://code.wireshark.org/review/30088
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-10-10 15:40:21 +00:00
Gerald Combs f69108b84e Add a systemd Journal Export extcap.
Add an sdjournal extcap, which reads journal entries using the
sd-journal API and dumps them as journal Export Format records.

Change-Id: I17ccfa88ab5d053c16c869cd26e580d84022502e
Reviewed-on: https://code.wireshark.org/review/29479
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-01 08:58:13 +00:00
João Valverde f0b41190eb CMake: Clean up and homogenize plugin dir configuration
Change-Id: If43c7b124afdf6471164675f8a0c55a76e998ea1
Reviewed-on: https://code.wireshark.org/review/29254
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2018-08-23 08:33:56 +00:00
João Valverde 7d76d0ce28 Revert "CMake: Clean up plugin dirs"
Broke system (global) binary plugin path.

This reverts commit 450ff674a6.

Change-Id: I5353d2f3acf4450aed243040ef71425a71542a08
Reviewed-on: https://code.wireshark.org/review/29240
Reviewed-by: João Valverde <j@v6e.pt>
2018-08-22 00:49:16 +00:00
João Valverde 450ff674a6 CMake: Clean up plugin dirs
Change-Id: Ie41366205db19b8a9714ad5259c3f958e1e9ee95
Reviewed-on: https://code.wireshark.org/review/29233
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2018-08-21 23:06:38 +00:00
Guy Harris 065a762579 Extcap programs must write to the packet pipe in binary mode.
It doesn't matter on UN*X, but it definitely matters on Windows; we're
writing a pcap file, not a text file, so every byte we write should go
down the pipe as is.

Bug: 14989
Change-Id: I26c067b8ff5dba644a579846dd97b568a81c7053
Reviewed-on: https://code.wireshark.org/review/28764
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-07-19 09:30:52 +00:00
Peter Wu f7b91633c4 randpktdump: add --delay option
For testing live capture mode in the Qt UI, it is useful to have a
continous capture source with some dummy packets.

Change-Id: Id76ecbf24828dd3212b208c96679524e4c25b00f
Reviewed-on: https://code.wireshark.org/review/28537
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-07-01 06:57:23 +00:00
David Kreitschmann 11ba10dd4b Fix build paths for cmake's Xcode project generator on macOS.
Multi-configuration generators (such as Xcode or VS) append the current build configuration to most paths (eg. Debug/Release). Currently this results in inconsistent paths for the application bundle and the included command line tools. This commit sets the correct path information for multi-configuration generators for macOS application bundles. The standard Makefile behaviour is untouched.

One Windows specific configuration was changed, as it was conflicting with these changes. This needs to be checked before merging.

Additionally the wrapper scripts are omitted for Xcode, as the path to the binaries depends on the configuration chosen in Xcode. Therefore it is not viable to create these scripts in the cmake run.

Bug: 11816

Change-Id: Ib43d82eb04600a0e2f2b020afb44b579ffc7a7c9
Reviewed-on: https://code.wireshark.org/review/28291
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-06-21 03:33:03 +00:00
Dario Lombardo 169887f170 udpdump: add error message from libwritecap.
Change-Id: Ida86772c88af6b35e2d3b3864e1b1b551cfd1d96
Reviewed-on: https://code.wireshark.org/review/27804
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-26 05:52:28 +00:00
Dario Lombardo 7f4c2bae5c ciscodump: check return value of libpcap_write_packet (CID: 1435606).
Change-Id: Ifb89952b48bf300168b5f775ac3c2777c0c93877
Reviewed-on: https://code.wireshark.org/review/27803
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-26 05:51:31 +00:00
Dario Lombardo 25a95709a1 extcap: set EXTCAP_DIR in the root cmake file and propagate it.
The EXTCAP_DIR must be known in the root file to be set in config.h
and it's still needed in extcap/ to install the binaries, hence we
need caching it as well.

Bug: 14724

Change-Id: I58bac7de7a00e06c23fe8c8f1a7e3d299de6a560
Reviewed-on: https://code.wireshark.org/review/27776
Reviewed-by: Mikael Kanstrup <mikael.kanstrup@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-24 13:58:13 +00:00
Mikael Kanstrup afd0eef4f6 androiddump: Fix tcpdump encap type when libwiretap is used
androiddump determines encap type by parsing pcap global header from
tcpdump binary output. Only when libpcap is used with androiddump
this (pcap linktype) value can be used right away. Libwiretap
uses its own encap values but is feed with pcap linktype values
making the whole packet encapsulation invalid.

Fix by converting pcap linktype values into wiretap encap values

(For pcap linktype definitions see http://www.tcpdump.org/linktypes.html)
(For wtap encap defininitions see wiretap/wtap.h)

Fixes: bfef57ebb7 ("androiddump: Fix and simplify tcpdump capture")
Change-Id: I5ea86204b8e5774fd84d4007db8c2910680dbd53
Reviewed-on: https://code.wireshark.org/review/27747
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Florian Bezold <florian.bezold@esrlabs.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2018-05-24 07:55:00 +00:00
Martin Kaiser 675e0649c0 make our version of nla_for_each_nested() public
caputils/ws80211_utils.c contains a re-definition of the linux kernel's
nla_for_each_nested() macro that applies the correct casts to allow
compilation with a C++ compiler.

Make this definition public by moving it into a new wsutil/netlink.h
file. Include the kernel's original definition before we overwrite it. This
way, it's not necessary for a .c file to include wsutil/netlink.h after
the system includes.

Use our nla_for_each_nested() version in extcap/dpauxmon.c to squelch the
following compiler warning:

[1664/2251] Building C object
extcap/CMakeFiles/dpauxmon.dir/dpauxmon.c.o
../extcap/dpauxmon.c: In function ‘family_handler’:
../extcap/dpauxmon.c:168:13: warning: request for implicit conversion
        from ‘void *’ to ‘struct nlattr *’ not permitted in C++ [-Wc++-compat]
  nla_for_each_nested(mcgrp, tb[CTRL_ATTR_MCAST_GROUPS], rem_mcgrp) {

Change-Id: I6ba40ef6343c5d168c1b0c4554f13202911ded76
Reviewed-on: https://code.wireshark.org/review/27688
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-23 13:18:00 +00:00
Dario Lombardo 7655e0bad6 cmake: move extcap sections to extcap/CMakeLists.txt.
Change-Id: Ie7d9f6ad3d8b788e0d22e3ce15159fc46f5a93e8
Reviewed-on: https://code.wireshark.org/review/27638
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-19 06:20:47 +00:00
Dario Lombardo b849730be7 randpktdump: use boolflag instead of boolean in config.
Change-Id: I259382352d4c79755c095b1e23325265226acd23
Reviewed-on: https://code.wireshark.org/review/27613
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-18 05:48:58 +00:00
Dario Lombardo c57695a13e dpauxmon: remove precision loss in dump_packet.
../extcap/dpauxmon.c:129:72: warning: implicit conversion loses integer
precision: 'const ssize_t' (aka 'const long') to 'guint32' (aka 'unsigned
int') [-Wshorten-64-to-32]

Change-Id: If835baec3c51eecd4aff9ad7dab052192de78455
Reviewed-on: https://code.wireshark.org/review/27616
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-18 04:10:47 +00:00
Alexis La Goutte c4ba94f398 dpauxmon (extcap): fix no previous prototype for function 'nl_receive_timeout' [-Wmissing-prototypes]
Change-Id: Iaeda0a1c677b3ec605d1a419b1230cf994ccdf4e
Reviewed-on: https://code.wireshark.org/review/27609
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-17 06:35:53 +00:00
Dirk Eibach e0002b0427 extcap: Support for DisplayPort AUX channel monitors
Support for the generic netlink DisplayPort AUX channel monitor kernel driver.

Change-Id: Iab445229ecef082968355f604993292f5f2d8d69
Reviewed-on: https://code.wireshark.org/review/27313
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
2018-05-14 10:44:37 +00:00
Guy Harris 4513c66b1a You have to set tm_isdst before calling mktime().
You either need to tell mktime() that 1) DST/Summer Time is in effect,
2) DST/Summer Time isn't in effect, or 3) we don't know whether
DST/Summer Time is in effect, you figure it out.

We set tm_isdst to -1, to choose option 3), which is what we want.

Fixes Coverity CID 1435496.

Change-Id: I0f22ef1201ee8abefb3fa75aa3432b021fb13cfd
Reviewed-on: https://code.wireshark.org/review/27408
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-05-09 03:49:07 +00:00
Dario Lombardo 8756d0ad12 sshdump/ciscodump: use groups in config.
Change-Id: I3d6689738aee32bf720e6ebca1d4462429fdc1eb
Reviewed-on: https://code.wireshark.org/review/27397
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2018-05-08 14:06:22 +00:00
Pascal Quantin acdda66ce8 extcap-base.c: fix compilation with gcc 8
extcap-base.c:293:43: error: cast between incompatible function types from ‘void (*)(void *)’ to ‘void (*)(void *, void *)’ [-Werror=cast-function-type]
extcap-base.c:302:45: error: cast between incompatible function types from ‘void (*)(void *)’ to ‘void (*)(void *, void *)’ [-Werror=cast-function-type]
extcap-base.c:321:42: error: cast between incompatible function types from ‘void (*)(void *)’ to ‘void (*)(void *, void *)’ [-Werror=cast-function-type]

Change-Id: Ifd9151d04412c5e29636dc14c57a327cc12d33f3
Reviewed-on: https://code.wireshark.org/review/27265
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-05-02 19:33:10 +00:00
Dario Lombardo 4a156da068 Remove autotools build system.
It has been replaced by cmake.

Change-Id: I83a5eddb8645dbbf6bca9f026066d2e995d8e87a
Reviewed-on: https://code.wireshark.org/review/26969
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-04-18 03:46:17 +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
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
Mikael Kanstrup 2fb9c8244e androiddump: Read btsnoop header separately from rest of data
The code to read and skip btsnoop header was written in a way where
it reads up to PACKET_LENGTH bytes of data, skips the header, then
move rest of data back start of buffer. So far so good. The code
then resets number of bytes used in buffer making it skip rest of
all data read.

Many times this works fine but only by luck. When there's no data
transfers first recv call will always only return the header
(sender side writes header separately right after accept).

When data transfers are ongoing first recv call will return both
header and data. Then initial data is lost but more importantly
risk parsing data with invalid offset.

Fix by reading btsnoop header separately from rest of data.

Change-Id: Ie52c33f943d8b311e0cd5638ec1a7d4840e271b8
Reviewed-on: https://code.wireshark.org/review/26659
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michal Labedzki <michal.labedzki@wireshark.org>
2018-03-27 15:22:12 +00:00
Mikael Kanstrup a37045adcd androiddump: Update ps command parameter for Android Oreo
ps command is used to find com.android.bluetooth process. From
Android Oreo the ps command needs -A parameter for listing all
processes.

Change-Id: I1a547a0d61175c1e194823462661ec69e711ca50
Reviewed-on: https://code.wireshark.org/review/26652
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2018-03-26 15:03:52 +00:00
Mikael Kanstrup 789db1f15d androiddump: Fix btsnoop net port lookup
Code assumes btsnoop net port is the first tcp socket found in
/proc/<pid>/net/tcp. If it is not the port number lookup will
fail.

Fixed by searching all open tcp sockets for a match.

Change-Id: I988fe18680600b59c595f3d619d95c72c1a6966d
Reviewed-on: https://code.wireshark.org/review/26651
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2018-03-26 14:42:03 +00:00
Mikael Kanstrup 69d080700d androiddump: Fix some error messages
Change-Id: I1b3ad9fdafb08307a9863469f8478ecde0000acc
Reviewed-on: https://code.wireshark.org/review/26650
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-03-26 14:40:54 +00:00
Florian Bezold 02a3056af3 androiddump: Fix non-blocking connect on Windows
Commit 043ed1f6 enabled non-blocking connect on Windows. This seems to
break androiddump on Windows completely, since a successful connection
always returns SOCKET_ERROR on connect, with WSAGetLastError() set to
WSAEWOULDBLOCK.

Apparently, the only way to check for a real connection is to try a
write select on the socket:
https://stackoverflow.com/questions/35370239/timeout-in-connect-function-from-winsock

This fixes androiddump on Windows:
- If ADB server is running, extcap interfaces are listed
- If ADB is not running, there is no noticeable delay in Wireshark

Change-Id: I6bd772215c7b232c8fe8e840cb7ad1d54c7d8860
Reviewed-on: https://code.wireshark.org/review/25715
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-10 07:45:56 +00:00
Florian Bezold bfef57ebb7 androiddump: Fix and simplify tcpdump capture
1. Use "exec:" ADB command to get raw (non-PTY) tcpdump output
This is also supported on Android devices before Android 7, and is a
much easier approach than testing the new "shell,raw:" command and
falling back if unsupported. This basically undoes commit 5ebc3277.

2. Pass "-U" to tcpdump to prevent on-target buffering
Before using the "shell,raw" approach in commit 5ebc3277, I tried the
"exec:" command already, but experienced extreme buffering of the
tcpdump output, which is unacceptable for live trace viewing.
Turns out, the buffering is determined "automatically" by libpcap:
- When running in a PTY, output is flushed fast for viewing
- When _not_ in a PTY, output is not flushed and thus heavily buffered.
The "exec" command obviously doesn't use a PTY.
Fortunately, tcpdump has a "-U" option to flush the output after each
catpured packet, which is exactly what we need.

3. Ignore tcpdump stderr output
Enabling "-U" caused androiddump to fail, because it happened that the
tcpdump stderr logs were mixed with the stdout data. (We were probably
lucky this didn't happen without -U as well).
To fix this, we just ignore stderr completely by adding "2>/dev/null" to
the tcpdump command.

4. Get linktype from pcap global header
The stderr logs were previously parsed to get the textual linktype.
This is now replaced by a simpler & less fragile approach: tcpdump
prints the global pcap header, which contains precicesly the linktype
info we need.

5. Parse pcap global header magic correctly for timestamps & endianness
The previous code only supported the "classic" pcap header magic and
might also been incorrect on big-endian host machines.
Now, endian handling is simplified and we can detect the "nanosecond
timestamp" magic values as well.
This fixes the problem that extcap_dumper_dump expects *nano*second
timestamps, but the previous code supplied *micro*seconds if on-target
tcpdump outputs microseconds.

6. The parsing simplifications above allowed the main loop for tcpdump
capture to be simplified considerably.

Change-Id: Id66791e700a8943b86128f044f080bee60a9fa79
Reviewed-on: https://code.wireshark.org/review/25713
Petri-Dish: Michael Mann <mmann78@netscape.net>
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-10 07:45:23 +00:00
Guy Harris 1f5f63f8ef Generalize wtap_pkthdr into a structure for packet and non-packet records.
Separate the stuff that any record could have from the stuff that only
particular record types have; put the latter into a union, and put all
that into a wtap_rec structure.

Add some record-type checks as necessary.

Change-Id: Id6b3486858f826fce4b096c59231f463e44bfaa2
Reviewed-on: https://code.wireshark.org/review/25696
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-09 00:29:51 +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
Florian Bezold 20d4c7bb62 androiddump: Raise ADB timeout to 2s for slower devices
Running "tcpdump -D" on target seems to be a expensive operation in some
cases, not finishing within the 500ms timeout on several devices (~1000 ms
in one of our cases).

Change-Id: I57e4d31f12c4e393ff84e79b64cb024b74a11f0e
Reviewed-on: https://code.wireshark.org/review/24719
Reviewed-by: Michal Labedzki <michal.labedzki@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-01-28 21:57:34 +00:00
Pascal Quantin fc9af81a13 wiretap: add a parameter to wtap_init() indicating whether plugins must be loaded
g995812c5f1 moved wiretap plugins registration from applications to
wiretap library init function.
As we do not want to load plugins for all users of libwiretap, let's
make it configurable.

Bug: 14314
Change-Id: Id8fdcc484e2d0d31d3ab0bd357d3a6678570f700
Reviewed-on: https://code.wireshark.org/review/25194
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>
2018-01-09 21:25:06 +00:00
Mikael Kanstrup bde402840f androiddump: Fix crash in add_tcpdump_interfaces
If there's a network interface on the device without the 'flags'
field and at the same time exist other network interfaces
with the 'flags' field present a null-dereference happens accessing
the non-matched regex flags field.

Fix crash by adding explicit null check to ensure (optional) regex
group really matched.

Fixes: 7dcf57719f ("androiddump: Support older on-target tcpdump versions")

Change-Id: Ia08dd8547c9cdda96b3c62b99d98ff1d85bd6cd2
Reviewed-on: https://code.wireshark.org/review/25198
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-01-08 20:57:54 +00:00
Florian Bezold 7dcf57719f androiddump: Support older on-target tcpdump versions
The output of 'tcpdump -D' only outputs interface flags from Android 7
onwards. Since it would be sad to lose the great androiddump support for
all older devices because of this, the logic is extended so that it
lists all interfaces if no '[' and ']' is found in the output.

Also, the used regex seemed to require an interface description, which
might not exist (even with new tcpdump versions). Now, interfaces
without description are not filtered.

Change-Id: I92b550a37b9bc0d0142aed68ee98f26de79be759
Reviewed-on: https://code.wireshark.org/review/24720
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-01-02 04:29:48 +00:00
Florian Bezold 5ebc3277ed androiddump: Fix adb tcpdump PTY CR/LF handling
Devices running Android >= 7 have a different adb shell handling than
before:
- Before Android 7, adb always runs shell commands in a PTY
  (pseudoterminal), which automatically converts all \n to \r\n
- Since Android 7, adb no longer uses a PTY if a command is directly
  started (like 'tcpdump' in our case).

The original androiddump code reversed the PTY \r\n handling as for
older devices. Commit 66507b9 for bug 13510 removed that which supported
newer devices while breaking all older devices.

This fix tries to support both by first trying to use the new
"shell,raw:" adb command syntax. If that succeeds, adb/device must
support non-PTY shells and we don't reverse any \r\n.
If that fails, it's most likely an older device, and we fall back to the
original "shell:" command and enable \r\n reversal.

(To prevent misleading error popups in Wireshark, the warning log in
adb_send when the first attempt fails is changed to a debug log).

Ping-Bug: 13510
Change-Id: I7e0a4f594ebe5dde682cceb667330459337a0c9c
Reviewed-on: https://code.wireshark.org/review/24721
Reviewed-by: Mikael Kanstrup <mikael.kanstrup@gmail.com>
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-12-18 14:45:49 +00:00
Alexis La Goutte 0ffee1526b ciscodump(extcap): fix 'packet' was marked unused but was used [-Wused-but-marked-unused]
Change-Id: I04a52c37404fe6a91740b766de1482376d7128fa
Reviewed-on: https://code.wireshark.org/review/24825
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-12-14 18:45:14 +00:00
João Valverde 995812c5f1 Refactor plugin registration and loading
Put different types of plugins (libwiretap, libwireshark) in different
subdirectories, give libwiretap and libwireshark init routines that
load the plugins, and have them scan the appropriate subdirectories
so that we don't even *try* to, for example, load libwireshark plugins
in programs that only use libwiretap.

Compiled plugins are stored in subfolders of the plugin folders, with
the subfolder name being the Wireshark minor version number (X.Y). There is
another hierarchical level for each Wireshark library (libwireshark, libwscodecs
and libwiretap).

The folder names are respectively plugins/X.Y/{epan,codecs,wiretap}.

Currently we only distribute "epan" (libwireshark) plugins.

Change-Id: I3438787a6f45820d64ba4ca91cbe3c8864708acb
Reviewed-on: https://code.wireshark.org/review/23983
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2017-12-14 08:43:57 +00:00
Dario Lombardo b993c6f05c sshdump: remove extra option check.
This looked a bit odd since the capture filter is variable length.
Removing it makes sshdump work.

Change-Id: I454c6263c04019d5e8ecbecd2490dd10185f5c67
Reviewed-on: https://code.wireshark.org/review/24531
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-11-22 15:40:13 +00:00
Dario Lombardo c58aed9b73 sshdump: add option to prevent promiscuous mode.
Bug: 14237
Change-Id: I5cecca8ed638c3935c7c77e3a304e4b0527d7fa3
Reviewed-on: https://code.wireshark.org/review/24530
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-11-22 15:16:24 +00:00
João Valverde 262a84c384 Fix (and chop) static build option
This sets the scope of the static build option to Wireshark support
libraries only.

Before the patch:

Static plugins don't work with CMake and autotools.

autotools static build is broken, and most likely will always be, as
building Wireshark all-static is difficult and time-consuming.

After the patch:

For CMake Wireshark will be built with static or shared libraries and
dynamic plugins. Everything just works. CMake apparently doesn't want
you building static and shared libraries at the same time.

For autotools Wireshark will be built with shared libraries by default.
--disable-shared and --enable-static options work as usual. Dlopened
plugins are not built if --disable-shared is given to configure (to
disable shared libraries). This is a limitations imposed by libtool.

Tested on Linux. This removes broken support for building plugins
statically.

Change-Id: Ib8e8176976f136eea93a2ce8f9857b6cf9bec64c
Reviewed-on: https://code.wireshark.org/review/24241
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2017-11-19 20:16:50 +00:00
Dario Lombardo f4e958c2ea udpdump: add space.
Change-Id: I44960f64f16434ccdf033eaa2bfa96579da7cc4b
Reviewed-on: https://code.wireshark.org/review/24439
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-11-15 10:51:57 +00:00
Dario Lombardo 66b5afa216 extcap: use SPDX identifiers for licences.
Change-Id: Id56687f86f4c60494dad0b6d58550ee45b0b203c
Reviewed-on: https://code.wireshark.org/review/24381
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-11-12 18:27:24 +00:00
Dario Lombardo 414a63f160 extcap: rename interface names.
The new names better reflect the utility.

Change-Id: I54105fc8be6735d3febbcc68837990758a5e52c3
Reviewed-on: https://code.wireshark.org/review/24320
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-11-09 17:27:41 +00:00
João Valverde 3996701183 Replace inet_addr() with our inet_pton() wrapper
Error checking omitted like in original code.

Change-Id: If8b4181d30ddf5717951aaf7ec61db25c0bc5322
Reviewed-on: https://code.wireshark.org/review/24309
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2017-11-09 16:08:25 +00:00
Dario Lombardo 36faf3203a udpdump: don't call inet_addr() for every packet.
Change-Id: Id3d9229f5d61390f2f4127c8dfdf445935297e85
Reviewed-on: https://code.wireshark.org/review/24300
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-11-08 15:36:09 +00:00
Mikael Kanstrup 282b59a853 [RFC]androiddump: Support extcap-dlts option
According to README.extcap documentation all extcap tools must
support the --extcap-dlts option. For performance reasons support
for this option was removed by commit:

9328eb6 androiddump: Register interfaces when list interfaces

A side effect of not implementing the option is that dumpcap is
then also called to try to retrieve interface capabilities
for all androiddump interfaces. As extcap interfaces are not
local network interfaces errors like these are logged
whenever the interface list is refreshed:

 Capture Dbg  sync_if_capabilities_open
 Capture Info sync_pipe_run_command() starts
 Capture Dbg    argv[0]: /usr/local/bin/wireshark/dumpcap
 Capture Dbg    argv[1]: -i
 Capture Dbg    argv[2]: android-tcpdump-wlan0...
 Capture Dbg    argv[3]: -L
 Capture Dbg    argv[4]: -Z
 Capture Dbg    argv[5]: none
 Capture Dbg  sync_pipe_open_command
 Capture Dbg  read 25 ok indicator: E len: 333 msg: E
 Capture Dbg  sync_pipe_wait_for_child: wait till child closed
 Capture Dbg  sync_pipe_wait_for_child: capture child closed after 0.000s
 Capture Info sync_pipe_run_command() ends, taking 0.012s, result=-1
 Capture Msg  Capture Interface Capabilities failed. Error -1, The
              capabilities of the capture device "android-tcpdump-wlan0..."
              could not be obtained (android-tcpdump-wlan0...:
              SIOCETHTOOL(ETHTOOL_GET_TS_INFO) ioctl failed: No such device).
              Please check to make sure you have sufficient permissions, and
              that you have the proper interface or pipe specified. ()

To avoid error prints and to fulfil the documented equirements for extcap
tools register a fake interface with what would be the properties of such
an interface.

Change-Id: If174adbb64c66132be4225f854bbf9f66d2f5ed1
Reviewed-on: https://code.wireshark.org/review/23093
Reviewed-by: Michael Mann <mmann78@netscape.net>
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-10-16 04:29:21 +00:00
João Valverde 9764cd0a83 autotools: make maintainer-clean should allow rerunning 'configure'
Change-Id: Iedae94ffefe27b13b1967d69cacb757b5aa4576d
Reviewed-on: https://code.wireshark.org/review/23928
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>
2017-10-15 14:17:20 +00:00
Ahmad Fatoum 9d49e13166 Remove superfluous null-checks before strdup/free
NULL checks were removed for following free functions:

- g_free "If mem is NULL it simply returns"
  https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html#g-free

- g_slist_free(_full)? "NULL is considered to be the empty list"
  https://developer.gnome.org/glib/stable/glib-Singly-Linked-Lists.html

- g_strfreev "If str_array is NULL, this function simply returns."
  https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strfreev

- g_slice_free "If mem is NULL, this macro does nothing."
  https://developer.gnome.org/glib/stable/glib-Memory-Slices.html#g-slice-free

- g_match_info_free "not NULL... otherwise does nothing"
  https://developer.gnome.org/glib/stable/glib-Perl-compatible-regular-expressions.html#g-match-info-free

- dfilter_free defined in Wireshark code. Returns early when passed NULL
  epan/dfilter/dfilter.c

They were also removed around calls to g_strdup where applicable:

- g_strdup "If str is NULL it returns NULL."
  https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strdup

Change-Id: Ie80c2db89bef531edc3aed7b7c9f654e1d654d04
Reviewed-on: https://code.wireshark.org/review/23406
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2017-10-15 12:38:51 +00:00
Martin Mathieson 2ecc51f28f Some trivial fixes from running cppcheck.
The packet-per.c intialisation of ext_length is not really
needed - idx could be -1 with or without extension_flag
being set. But it'd be best not to have someone need to
think this through again.

Change-Id: If07f98ac7d7f2619149e35a2a0d75b765839a7ba
Reviewed-on: https://code.wireshark.org/review/23905
Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-10-14 20:51:18 +00:00
Jakub Zawadzki 8b5b843fcb udpdump: Add missing include for timeval struct.
struct timeval is defined in <sys/time.h>, include it.

It should fix building with musl:

udpdump.c: In function 'setup_listener':
udpdump.c:126:9: error: variable 'timeout' has initializer but incomplete type
  struct timeval timeout = { 1, 0 };

Change-Id: Id9be579e50ea2845ca609708e8ec4d1a3858ecc0
Reviewed-on: https://code.wireshark.org/review/23728
Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
2017-09-25 16:42:17 +00:00
João Valverde d7ec2cbc38 autotools: Use package flags to configure libpcap
Change-Id: Icd64014b597a8e60d2aff9d180c441c6ffccff26
Reviewed-on: https://code.wireshark.org/review/23329
Reviewed-by: João Valverde <j@v6e.pt>
2017-09-24 12:58:06 +00:00
João Valverde d0a91b27f2 plugins: config.h must not be included by public headers
For a sane plugin build environment. Include config.h as the first
header in the .c file instead.

Fix by moving required compiler attribute macros to a new
"ws_attributes.h" API header.

Change-Id: I34f58a927f68c1a0e59686c14d214825149749e1
Reviewed-on: https://code.wireshark.org/review/23400
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>
2017-09-06 08:10:56 +00:00
Ulf 5574b78dae Fix potential oob write crashes
Bug: 13847
Change-Id: I3a706db25204fe4c1fd1b7be3b17b8c55365dccf
Reviewed-on: https://code.wireshark.org/review/23169
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-08-23 02:58:08 +00:00
Mikael Kanstrup 5f52e65500 androiddump: Support 802.11 monitor and nlmon interfaces
Some Android devices support 802.11 monitor mode and nlmon
interfaces. Add linktype defines to be able to capture frames
from such interfaces.

Change-Id: I8b8b444ac2821542fc946694b71c8d9fb7ba1238
Reviewed-on: https://code.wireshark.org/review/23080
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-08-18 07:04:19 +00:00
Mikael Kanstrup d56de21d6a androiddump: Fix bt snoop capturing
Recent changes had the bt snoop capturing function stop working for
Android API versions >= 21. One of the command strings used for
detecting btsnoop server socket interface got messed up when
refactoring code. Fix by using the correct command strings again.

Fixes: faf100ec ("androiddump: Introduce adb_connect_transport helper function")
Change-Id: Id645d24cfb0cb23f36484cfd6416768c89bce51b
Reviewed-on: https://code.wireshark.org/review/23106
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-08-17 13:12:43 +00:00
Mikael Kanstrup f4ca61220a androiddump: Avoid linktype/encap conversion
Let androiddump's internal definition of encap types directly
use linktype values from libpcap/wiretap. This way back and forth
conversion between internal and public values can be avoided.

Change-Id: I67522283cc3eb15cbdb1bfdd829bb1ff0031bb82
Reviewed-on: https://code.wireshark.org/review/23079
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-08-15 14:44:31 +00:00
Dario Lombardo e3d0bf0bb2 extcap: skip custom log if filename is space.
Change-Id: I98b890316af05d9c5359dc38a30d07ac55f262fe
Reviewed-on: https://code.wireshark.org/review/22932
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-08-03 13:04:33 +00:00
Dario Lombardo f978465fb3 extcap: add debug log file feature to extcap-base.
Change-Id: I3bfc9b2fd7b73dcfef52c5101360384d205c0d12
Reviewed-on: https://code.wireshark.org/review/22835
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2017-08-02 17:41:24 +00:00
Dario Lombardo 963707ab3c extcap: add command line debug function to extcap-base.
This function is helpful to debug the interaction between the
calling UI and the extcap itself.

All extcaps have been changed accordingly.

Change-Id: I358caf4c50797501672bf77fdd91f7276897078c
Reviewed-on: https://code.wireshark.org/review/22806
Reviewed-by: Roland Knall <rknall@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-07-27 15:19:47 +00:00
Dario Lombardo 3e9b256238 androiddump: check return value of localtime() before dereference (CID 1400829).
Change-Id: I03c851e56f5bd967a35c668bcbc4e98170251b2c
Reviewed-on: https://code.wireshark.org/review/22750
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-07-21 12:41:52 +00:00
Pascal Quantin 725b7ef175 androiddump: add a cast to please MSVC x64
Change-Id: I43cf913d48afabd826f7d6f861876e1cb62e7e7a
Reviewed-on: https://code.wireshark.org/review/22751
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-07-21 11:50:38 +00:00
Dario Lombardo 420aab387f androiddump: use actual buffer length instead of pointer sizeof.
Change-Id: I3481c98377a31fbef2ef8ad931e2a8d66f507e58
CID: 1414110
CID: 1414058
Reviewed-on: https://code.wireshark.org/review/22743
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-07-20 21:42:47 +00:00
Mikael Kanstrup 9830b7b261 androiddump: Reduce code duplication
Some more repeated code patterns identified. Reduce code duplication
by adding some helper functions.

Change-Id: I0fecd511fd56049e9eae111cdad08252dffff6cb
Reviewed-on: https://code.wireshark.org/review/22480
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-07-07 23:17:58 +00:00
Mikael Kanstrup f9fd438b6d androiddump: Close socket on failure path
Fix a few cases where socket is not closed on failure path.

Change-Id: Id116a8e5f14979f962fdf725c62999758b79109e
Reviewed-on: https://code.wireshark.org/review/22481
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-07-01 01:24:44 +00:00
Mikael Kanstrup 91e512985f androiddump: Fix null dereference if linktype not found
If linktype cannot be determined from tcpdump output the
lookup function is handed a NULL which is then strcmp:ed.
Handle NULL parameter by explicit check.

Fixes Coverity CID 1413923

Change-Id: I290c116991d15cef0a1e954a9f8b76722a5f450c
Reviewed-on: https://code.wireshark.org/review/22483
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-07-01 01:24:31 +00:00
Mikael Kanstrup b3453b9be4 androiddump: Fix leaked linktype string
The regex matching for linktype might be performed multiple
times. Make sure string is freed before fetched again.

Change-Id: Ice7812ff4a3a8e6a1497ab2ef5aa94976502c16f
Reviewed-on: https://code.wireshark.org/review/22482
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-06-30 22:43:11 +00:00
Stig Bjørlykke 064e34b215 androiddump: Fix printf format for size_t
Change-Id: Ia4646b649881316350ee1aed7d8cc9626036dd30
Reviewed-on: https://code.wireshark.org/review/22442
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-06-28 15:46:51 +00:00
Mikael Kanstrup 564445f799 androiddump: Support packet capture on any interface that is up
androiddump used to start tcpdump without specifying the interface
to capture packets on. This works when only one interface is up
but when multiple interfaces are up the output might be empty.

This change let tcpdump list all available network interfaces
and adds a unique extcap interface for each interface that is 'up'
on the device.

Change-Id: Icf0d7fa8f38320092579d4163dcdbcf2b687d8cc
Reviewed-on: https://code.wireshark.org/review/22402
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-06-27 12:43:44 +00:00
Mikael Kanstrup 129a84df60 androiddump: Use Android tcpdump reported data link type
Instead of treating all output from Android tcpdump as Ethernet
data link type parse what tcpdump acually tells it to be.

This is needed as there are cases when the output is not Ethernet.
For example when starting packet capture on a device with multiple
interfaces up.

NOTE: As translation between tcpdump reported DLT and androiddump's
internal type was needed for now support is only added for types
used by network interfaces of tested devices (i.e. ETHERNET and
LINUX_SSL).

Change-Id: Ie3f9167176c336cb31f6e681f1daac6135a78883
Reviewed-on: https://code.wireshark.org/review/22401
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-27 12:42:58 +00:00
Guy Harris f27699c746 The 3rd argument to recv() is an int on Windows.
Make the variable used for it an int; that's large enough, and, on
Windows, not so large that it provokes warnings.

Change-Id: I00600d816f69d79f7a42eb09b1290ff7708b0bfc
Reviewed-on: https://code.wireshark.org/review/22420
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-27 08:26:55 +00:00
Mikael Kanstrup d84da1eb97 androiddump: Let adb_send funcs generate string length prefix
All strings sent to adb are prefixed with the length as a 4 byte
hex string. The length info prefix was manually hard coded into
strings. To avoid mistakes when updating code and to simplify
reading the source code instead let the various adb_send functions
calculate string lengths and generate the 4 byte hex string
prefixes.

Change-Id: I4178e9df5930a1c7904053e5a7750c943efddc84
Reviewed-on: https://code.wireshark.org/review/22399
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: Anders Broman <a.broman58@gmail.com>
2017-06-27 04:12:58 +00:00
Mikael Kanstrup 707b789074 androiddump: Add helper functions for data link type conversions
Change-Id: I406f5cd6d979442014fdda01deacbcec2052ec18
Reviewed-on: https://code.wireshark.org/review/22400
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-06-26 14:16:33 +00:00
Mikael Kanstrup faf100ecc5 androiddump: Introduce adb_connect_transport helper function
Same code pattern is used over and over when connecting to an adb
server. Introduce a helper function that perform the function of
connecting to specified adb server and transport.

Change-Id: Id2f72f1eb976fa0d742a6db1ef6d592264990ba1
Reviewed-on: https://code.wireshark.org/review/22398
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-06-26 14:16:14 +00:00
Mikael Kanstrup 66507b9052 [RFC]androiddump: Only filter CR/LFs on Windows
Comments in code claim:
"The data we are getting from the tcpdump stdoutput stream as the
 stdout is the text stream it is convertinng the 0A=0D0A; So we
 need to remove these extra character."

This is not true on non-Windows systems at least so avoid the filter
when not built for Windows.

NOTE: A problem with the filter is that it operates on all bytes
received on the socket, including packet data(!). Capturing
data with CR/LFs (for example an HTTP request) will fail. Ideally
the filter should be replaced with some other mechanism but as I
don't have a Windows system to verify that the comment claims are
valid, this change will at least make androiddump work on
non-Windows systems.

Bug: 13510
Change-Id: Ic00f44fa7516c0db7fc015ed8685deb365a347db
Reviewed-on: https://code.wireshark.org/review/22397
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-06-26 11:17:30 +00:00
Michael Mann 828e1f07a8 udpdump.c: Don't include epan headers.
udpdump has local copies of the tag values from exported_pdu.h, so the
dependency isn't needed.  exported_pdu.h required tv_buff.h and packet_info.h,
whose inclusion caused link errors on SPARC.

Bug: 13801
Change-Id: Icbf7b59b8af0d3a0fc73599baad6932e76dc3462
Reviewed-on: https://code.wireshark.org/review/22131
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-06-15 04:18:20 +00:00
Guy Harris 7321183716 Put the HAVE_REMOTE hack into wsutil/wspcap.h, and include that file.
Have a header file that defines HAVE_REMOTE if HAVE_PCAP_REMOTE is
defined, and then includes pcap.h.  Replace all other includes of
pcap.h, and the definition of HAVE_REMOTE, with includes of that file.
Check for anything other than wspcap.h including pcap.h in checkAPIs.pl.

Change-Id: I3cbee8208944ad6f006f568b3fe3134e10b2a883
Reviewed-on: https://code.wireshark.org/review/21605
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-11 19:58:15 +00:00
Guy Harris 79eab8ca07 Force HAVE_REMOTE to be defined when including pcap.h with remote support.
WinPcap made the mistake of having stuff in its public header fines
depend on a configuration #define, HAVE_REMOTE; this means that we need
to forcibly define it when building with remote capture support.

The tip of the libpcap master branch does not have that botch; hopefully
future versions of libpcap-for-Windows will be based on that libpcap and
thus lack that botch as well.

Defining HAVE_REMOTE in config.h is not the right fix, as it makes it
look like a *Wireshark* configuration option that code in Wireshark
should test, rather than a *WinPcap* configuration option that the
pcap.h that ships with the WinPcap SDK should have been changed, as part
of the build process, to correctly define or not, so that users of
WinPcap don't have to define it themselves.

Change-Id: I62d1eca6d3c900d0dcc9fbc011db77f595a86313
Reviewed-on: https://code.wireshark.org/review/21593
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-11 10:57:22 +00:00
Guy Harris 67a5d9bebe Use the cfile_ failure_message routines in androiddump.
Change-Id: Ic310eaafac054db7736c503252062c3dd3e00a99
Reviewed-on: https://code.wireshark.org/review/21265
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-21 06:50:21 +00:00
Guy Harris 804d3f6245 Use cfile_write_failure_message() in the randpkt code.
Change-Id: I32ef7ff85f854782e5dd02c3e7f12436a120bc13
Reviewed-on: https://code.wireshark.org/review/21259
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-20 21:07:35 +00:00
Alexis La Goutte ff6058039a udpdump: fix indent (use tab)
Change-Id: Ibfe9ad19d12a84794f5e84ebaf3b9de5d4e419e8
Reviewed-on: https://code.wireshark.org/review/20733
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-03-27 07:37:35 +00:00
Michael Mann 677e103d10 udpdump.c: warning C6262: Function uses '65608' bytes of stack: exceeds /analyze:stacksize '16384'
Change-Id: I1d82c62dd30497db6a88ba3d3c973799ba7631ab
Reviewed-on: https://code.wireshark.org/review/20730
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-03-27 03:13:02 +00:00
Mikael Kanstrup bb017f3eb3 androiddump: Fix tcpdump op prec bug with used_buffer_length calc
androiddump reads data from tcpdump in chunks that not necessarily
match packet sizes. Whenever a partly read packet is found in buffers
more data is read and the number of used bytes in buffer is updated.
The calculation of used_buffer_length is wrong though leading to most
packets are read and thrown away.

Problem fixed by correcting an operator precedence mistake where
used_buffer_length would only be increaded with 0 or 1 insted of
actual number of read bytes.

Change-Id: Ib5c4e1d96e7ba499f26796ffa5d7ce6a116b9a6e
Reviewed-on: https://code.wireshark.org/review/20666
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-03-23 04:48:23 +00:00
Stig Bjørlykke b56afb1211 androiddump: Fix a type
Change-Id: I839e7e7300af9b90e91548fa29157143ae00adee
Reviewed-on: https://code.wireshark.org/review/20434
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2017-03-07 07:57:38 +00:00
Michal Labedzki cec782cb29 androiddump: Add ignore log-buffer and custom-options for logcat-text
Logcat Text interfaces have now two new options:
1. Ignore log-buffer - this means you start capturing immediately
   and there will no logs from buffer
2. Custom-options - pass command line parameters to logcat, like tags
For example:
adb logcat -v threadtime -b main #now custom parameters starts# -T 20 -s Ads Wireshark

Please note that some custom options are banned to avoid unexpected
behaviour (like "not working")

Change-Id: I015d1aeae35cfed712de59138288d82d3a491c38
Reviewed-on: https://code.wireshark.org/review/20358
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>
2017-03-07 05:38:15 +00:00
AndersBroman 2f6ba75347 Use glib-compat
Change-Id: I510af18d433c4db360243dda72260e59eb84355f
Reviewed-on: https://code.wireshark.org/review/20336
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-03-02 15:20:05 +00:00
Dario Lombardo 929e0e897c udpdump: fix recvfrom error on windows.
Change-Id: Ia88d00593163b1c1e9a0e120aeff5e36f0135474
Reviewed-on: https://code.wireshark.org/review/20319
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2017-03-01 19:47:09 +00:00
Michal Labedzki 5c6f633376 androiddump: Use only non-blocking connect() instead of the socket
Architecture of androiddump based on "blocking" sockets,
however for start-up it is better to use non-bloking connect()
to avoid long waiting time then fail.

Change-Id: I2bb8ea51e24db4dd1f5a6b97e1d2bc0156342d97
Reviewed-on: https://code.wireshark.org/review/20293
Petri-Dish: Michal Labedzki <michal.tomasz.labedzki@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-02-28 05:24:50 +00:00
Michael Mann 043ed1f6b3 androiddump: Set connect socket to non-blocking on Windows
Bug: 13104
Change-Id: I05248dad8e72272cf0933c766ec0bf5160075e1e
Reviewed-on: https://code.wireshark.org/review/20275
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-26 03:14:44 +00:00
Dario Lombardo 43487d825b udpdump: fix help.
Change-Id: Iad0e802f8c5d3920104751fab5135d71f02b29b8
Reviewed-on: https://code.wireshark.org/review/20264
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-02-24 15:39:19 +00:00
Michal Labedzki 147d0c2e36 androiddump: Use nonblocking connect
Release as version 1.0.5:
All connects to ADB are now non-blocking.
Try to connect up to 10 times with 1ms delays,
so in worst-case it takes ~10ms (for example 14ms)

Bug: 13104
Change-Id: I791909c9c951b62195b48acd82490e1b9ebf2be0
Reviewed-on: https://code.wireshark.org/review/19968
Petri-Dish: Michal Labedzki <michal.tomasz.labedzki@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michal Labedzki <michal.tomasz.labedzki@gmail.com>
Tested-by: Michal Labedzki <michal.tomasz.labedzki@gmail.com>
2017-02-24 13:57:21 +00:00
AndersBroman 16c3ecbd4c g_slist_free_full requires glib 2.28
Change-Id: I4f9ce7f65da0349b962f6be317635c5acb2daf73
Reviewed-on: https://code.wireshark.org/review/20148
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-02-16 21:03:44 +00:00
Pascal Quantin bc29b8c9b6 androiddump: fix compilation with ANDROIDDUMP_USE_LIBPCAP define
Change-Id: I6edc4ff9f4db5fab9b80cb0be56639443ab22518
Reviewed-on: https://code.wireshark.org/review/20105
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2017-02-14 17:23:58 +00:00
Dario Lombardo 7c0c580c4b wiretap: add cleanup routine.
The cleanup routine has been added to exit section of the applications.
Those which required a exit restyle have been patched as well.

Change-Id: I3a8787f0718ac7fef00dc58176869c7510fda7b1
Reviewed-on: https://code.wireshark.org/review/19949
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-02-14 10:22:20 +00:00
Guy Harris 6a99a2ce43 Cast arguments to socklen_t.
That should squelch some warnings on Windows.

Change-Id: I55b394be12203e14af023fdcc5d46564d0fcfa34
Reviewed-on: https://code.wireshark.org/review/19797
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-01-26 07:15:54 +00:00
Guy Harris 5fbcfd632a Clean up some UN*X-vs-Windows socket issues.
Have a wsutil/socket.h file, for inclusion by everything that uses
sockets, that contains the UN*X-vs-Windows #includes and #defines to
hide some UN*X-sockets vs. Winsock API differences.  That stuff mostly
comes from from extcap/extcap-base.h; have that file just include
wsutil/socket.h rather than defining that stuff itself.

Include it in sharkd_daemon.c.  Use socklen_t for the size of things to
pass to bind() as the last argument; wsutil/socket.h defines it as int
on Windows.

Ignore sharkd in Git.

Change-Id: I3f2171b7aa613717f52305f62bfd7d43e0172dc6
Reviewed-on: https://code.wireshark.org/review/19796
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-01-26 07:00:06 +00:00
Dario Lombardo c6cb16bef6 sshdump: add sudo option.
Basic installation of tcpdump (the default remote capture binary)
don't have setcap option. Give the user the option to run tcpdump
with sudo (already possible with a custom remote capture command).

Change-Id: I273798b5f7dc63b468b03eb633bfc60f53e30743
Reviewed-on: https://code.wireshark.org/review/19672
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-01-20 15:33:26 +00:00
Frank Carpenter 3b6fe2bfb4 Populate logcat year based on localtime
Change-Id: If7c790c25ed24da1b1442ee86e3a2f75bd3f8856
Reviewed-on: https://code.wireshark.org/review/19658
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michal Labedzki <michal.tomasz.labedzki@gmail.com>
Tested-by: Michal Labedzki <michal.tomasz.labedzki@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-01-19 04:40:04 +00:00
Peter Wu 2009dcc98d extcap: fix memleak via data_file_url
Commit v2.1.0rc0-2181-ga4e2263ac4 introduced a helppage parameter, but
all callers were NULL. In a later change, callers would use the
data_file_url() function, but this needs to be freed, so do that.

Fixes: v2.3.0rc0-1825-ge5596b74bd ("extcap: set help page for all extcaps.")
Change-Id: I967c0f8c6b50d9e78ac227575de24a81f97d376a
Reviewed-on: https://code.wireshark.org/review/19570
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-01-07 20:32:43 +00:00
Baruch Siach 3761ef3785 androiddump: add missing sys/time.h header
struct timeval requires sys/time.h. Fixes the following musl libc build error:

androiddump.c: In function 'useSndTimeout':
androiddump.c:262:18: error: variable 'socket_timeout' has initializer but incomplete type
     const struct timeval socket_timeout = {
                  ^

Change-Id: I52e204f32a012aabea2e54877e564576c072fe08
Reviewed-on: https://code.wireshark.org/review/19460
Reviewed-by: Michal Labedzki <michal.tomasz.labedzki@gmail.com>
Petri-Dish: Michal Labedzki <michal.tomasz.labedzki@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-12-30 09:02:47 +00:00
Guy Harris 14603ea376 Fix some narrowing warnings.
Don't narrow values until it's necessary, and then put in explicit casts
to indicate that the narrowing is intentional.

Change-Id: I8afc2a457822febbed33cee573953993013a7185
Reviewed-on: https://code.wireshark.org/review/19423
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-25 08:26:21 +00:00
Dario Lombardo 194433a503 udpdump: remove libwireshark dependancy.
Export pdu routines have been rewritten here on purpose.

Change-Id: If4879de4c98b6f20a75df158cae0cf9a80ffae57
Reviewed-on: https://code.wireshark.org/review/19384
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-12-25 03:33:01 +00:00
Dario Lombardo b97af3af2c udpdump: set default value for payload
Change-Id: Iad8624cbb9102611f806cdcce152b8ed14ce4474
Reviewed-on: https://code.wireshark.org/review/19383
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-12-22 19:34:52 +00:00
Dario Lombardo e5596b74bd extcap: set help page for all extcaps.
They've been set to the manpage of the local filesystem.

Ping-Bug: 13218
Change-Id: Iacd5d2ba7ae39ee1718b59747c245d1c07785e8f
Reviewed-on: https://code.wireshark.org/review/19179
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-12-20 08:23:11 +00:00
Michal Labedzki a7d404a972 androiddump: Add support for Bluetooth on Android 7.0
Now "ps" command does not support process name as parameter,
use grep instead.

Change-Id: I0c35bc7d560e237e4140000e67af097744cb2c1b
Reviewed-on: https://code.wireshark.org/review/19087
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2016-12-05 11:44:00 +00:00
Guy Harris ab07f8e0f8 Have a routine to do all the work of initializing libwiretap.
Have programs that use libwiretap call that routine rather than
separately calling some or all of init_open_routines(),
wtap_register_plugin_types(), and wtap_opttypes_initialize().

Also don't have routines internal to libwiretap call those.  Yes, this
means doing some initialization work when it isn't necessary, but
scattering on-demand calls throughout the code is a great way to forget
to make those calls.

Change-Id: I5828e1c5591c9d94fbb3eb0a0e54591e8fc61710
Reviewed-on: https://code.wireshark.org/review/19069
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-04 21:42:44 +00:00
Dario Lombardo 6a91e8aba7 androiddump: check return value in useSndTimeout() (CID 1394378).
Change-Id: I14109ffe1b9930c464ce2c42767f96b8ba4e5b67
Reviewed-on: https://code.wireshark.org/review/18855
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
2016-11-18 09:26:41 +00:00
Michal Labedzki 720927a10e androiddump: Set socket connect() timeout to 500ms
This should avoid neverending or long time to obtain timeout
in some cases like firewall's drop rules, etc.

Bump version to 1.0.4

Bug: 13104
Ping-Bug: 13114

Change-Id: I9bef714b6d92b3516a2a95ebdbe1ba594fa60e34
Reviewed-on: https://code.wireshark.org/review/18728
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-11-10 12:41:06 +00:00
Dario Lombardo 9e2a9d0eaf sshdump: use g_shell_quote in the right way.
Change-Id: I3f71dabe92d3b00192f36fc57ebb7673b2327620
Reviewed-on: https://code.wireshark.org/review/18623
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2016-11-02 19:36:39 +00:00
Dario Lombardo 7bdcf75a5c sshdump: remove default filter from capture mode.
This allow to capture without any filter.

Bug: 13048
Change-Id: I29fb1a7367375b9f3d83a4f610789ae159735198
Reviewed-on: https://code.wireshark.org/review/18561
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-10-31 09:38:42 +00:00
Michal Labedzki b4f86c9cb8 androiddump: Fix help - interfaces
Fix help output that describes interfaces provided by tool
to reflect reality - add missed DEVICE_ID that is part of interface.

Change-Id: Ib6374db28d8d4696ce27c5358da49d3ebfcf31e1
Reviewed-on: https://code.wireshark.org/review/18267
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Tested-by: Michael Mann <mmann78@netscape.net>
2016-10-19 12:20:05 +00:00
Michal Labedzki b83ea46665 extcap: put missed parameters into the help
"--debug" and "--extcap-version" are part of extcap-base helper,
do not hide them.

Change-Id: I287b68dbed5344c188fede69d112ab007a6ee18b
Reviewed-on: https://code.wireshark.org/review/18279
Reviewed-by: Dario Lombardo <lomato@gmail.com>
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-10-19 06:44:05 +00:00
Dario Lombardo a19c12b4a9 udpdump: fix issues from coverity.
Change-Id: I1d82d8166abe8eda6588ae2970ae9f2d096adf9d
Reviewed-on: https://code.wireshark.org/review/18198
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
2016-10-15 10:22:21 +00:00
Dario Lombardo d8fdf5454a sshdump: add remote capture command.
This new option adds the chance to use a custom capture command.
It must produce a PCAP stream that will be read by Wireshark,
written to STDOUT.

Change-Id: I34a72465eb369194f24ecf0594df143b8ad6555f
Reviewed-on: https://code.wireshark.org/review/18037
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-10-04 09:58:25 +00:00
Dario Lombardo 99367fc513 sshdump: use tcpdump as default capture binary.
This removes the option to specify a custom capture binary due to
incompatibilities between different binaries options. A following
change will add the chance to use a custom capture command that
will cover all the cases that the default doesn't.

Bug: 12952
Change-Id: Idbde3e27f34c28f4ce622c3a860994e25ce5f92f
Reviewed-on: https://code.wireshark.org/review/18040
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-10-04 09:57:51 +00:00
Dario Lombardo 6fcce373b1 sshdump: restyle the output write routine.
Bug: 12884
Change-Id: I90733bbcbbd8fafc0421b3fb9c6f9b48f178583c
Reviewed-on: https://code.wireshark.org/review/17710
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-09-26 13:17:18 +00:00
Uli Heilmeier ca232b1d12 Udpdump: Fix g_debug() for ssize_t buflen
Using %lu for ssize_t throws an error. This commit change it to %zd.

Change-Id: I19ae72fe0836424bcb93e912e9b1757df4ae5fb1
Reviewed-on: https://code.wireshark.org/review/17900
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-09-24 11:56:07 +00:00
Guy Harris 686d72fc7d Type and size cleanups.
Use size_t for sizes.  Do checks to make sure we don't overflow ints.

Change-Id: Id0846cc5c6348d67a23064517ad1c432cf1cb61a
Reviewed-on: https://code.wireshark.org/review/17742
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-16 19:45:13 +00:00
Guy Harris 770a8737d7 Add ws_hexstrtou{bits} and use ws_hexstrtou32 in androiddump.
Make the reply length unsigned - there's no reason for it to be signed.

Change-Id: I5f4d1f027eeddee939547c052220efb89800f4b1
Reviewed-on: https://code.wireshark.org/review/17740
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-16 17:42:03 +00:00
Dario Lombardo 1ca260bbb4 udpdump: use socket_handle_t instead of int for portability.
Change-Id: Ic31302046e95d1678073a8a77812316be367e9a5
Reviewed-on: https://code.wireshark.org/review/17736
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-09-16 15:58:12 +00:00
Dario Lombardo d67c1db3f2 extcap: make extcap use the ws_strtoi/u functions.
Change-Id: Id75c72eba869c8a0f413ce8b5d6329ce172aed1f
Reviewed-on: https://code.wireshark.org/review/17415
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-09-16 14:21:16 +00:00
Guy Harris 6d13aebde9 ws_strou16() now takes three arguments.
Change-Id: I94a3a8707de724b1b4c2fafaa4c96d2a52b418c6
Reviewed-on: https://code.wireshark.org/review/17732
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-16 10:02:24 +00:00
Dario Lombardo 47650d357e extcap: add udpdump.
Udpdump is a generic UDP receiver that exports datagram in PCAP format.

Change-Id: I52620a92b12530b6f9b5449c43e692663acdfc14
Reviewed-on: https://code.wireshark.org/review/17195
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
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-09-16 08:07:30 +00:00
Dario Lombardo 5b03a42489 sshdump: remove -P.
This option is incompatible with other capture binaries (like tcpdump).

Change-Id: If93fca69f93b7833e7f8bb28b70311373f42f3f5
Reviewed-on: https://code.wireshark.org/review/17682
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-09-13 10:37:00 +00:00
Peter Wu 159d4317dc androiddump: fix memleaks
Most of the actions (e.g.  `androiddump --extcap-interfaces`) return
immediately without cleaning up. Fix this by adding a common exit path.

Change-Id: If02b18da49d866fb5525306e52fbf4590d98ecd2
Reviewed-on: https://code.wireshark.org/review/17634
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-09-12 12:23:20 +00:00
Peter Wu af3a0654a2 extcap-base: fix memleak from help options
Also correct modelines, this file really uses 4 spaces and not tabs.

Change-Id: I828d0249cc7637275e5a04e9117b22e9eea6bd8c
Reviewed-on: https://code.wireshark.org/review/17625
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-09-10 17:35:26 +00:00
Dario Lombardo 26551ba411 ciscodump: fix line parsing and fix memleak.
Change-Id: I4aee51d7def06317a543fdc8fa05120af0e68453
Reviewed-on: https://code.wireshark.org/review/17531
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-09-06 19:58:26 +00:00
Dario Lombardo 124fb83079 extcap: improve interface print in help.
Change-Id: Ife8e73b6cb1756623e937452fc042d8b31e2554f
Reviewed-on: https://code.wireshark.org/review/17321
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-08-26 21:05:12 +00:00
Dario Lombardo f597234785 extcap: add binary name and version to help message.
Change-Id: I8f8083c817065cf66fd006a1caeb309d26209509
Reviewed-on: https://code.wireshark.org/review/17305
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-08-25 12:29:49 +00:00
Dario Lombardo 1c7a96076e extcap: remove unused #define from ssh-base.
Change-Id: I52d26cb1e60452f8fa4d79f988fde2268486fc1c
Reviewed-on: https://code.wireshark.org/review/17306
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2016-08-24 18:00:17 +00:00
Dario Lombardo f269f56c1a extcap: make extcaps use the version registered in config.
Change-Id: I12d0d0bec06e02af0a9d0877c0f0f1d86261d752
Reviewed-on: https://code.wireshark.org/review/17296
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-08-24 12:25:56 +00:00
Dario Lombardo b7515b352a androiddump: use socklen_t (32bit) instead of gssize (64bit) (CID 1293384).
Change-Id: Ia5b7bc190eb8af509a880bb23bc0879a2dcfd39c
Reviewed-on: https://code.wireshark.org/review/16972
Reviewed-by: João Valverde <j@v6e.pt>
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-08-11 13:31:32 +00:00
Dario Lombardo b669ca75c4 androiddump: fix bug in socket retry (CID 1293391).
Change-Id: I61914d208e984d202506cdc885493e841e929990
Reviewed-on: https://code.wireshark.org/review/16948
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
2016-08-09 10:19:57 +00:00
Dario Lombardo b626ad1f85 extcap: move defines from sshdump & ciscodump to ssh-base.
Change-Id: I51769e2427b0119aefe57ebcc08406434ffbfead
Reviewed-on: https://code.wireshark.org/review/16918
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-08-06 02:13:47 +00:00
Dario Lombardo a671bab337 extcap: restyle the help function.
Change-Id: Ia742dffb1fd4cd5780b8ba44f7064d1874e473da
Reviewed-on: https://code.wireshark.org/review/16842
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-08-04 14:13:53 +00:00
Dario Lombardo 41e659d91e extcap: prevent registration of wrong version.
This prevents the user to run

extcap_base_set_util_info(extcap, "1", NULL, "0", NULL);

that would result in version = 1.0.

Change-Id: I67532459c852bdceb16693553e90da88a1043435
Reviewed-on: https://code.wireshark.org/review/16858
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-08-04 11:28:40 +00:00
Dario Lombardo 5adde36520 extcap: restyle the output subsystem.
Change-Id: I3e0674751eb97bf30ae6d70c4e51f347d63b1697
Reviewed-on: https://code.wireshark.org/review/16849
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-08-04 11:26:26 +00:00
Dario Lombardo 289d14b9c1 extcap: fix indentation in extcap-base.
Change-Id: Ic8e9634c9568d32fdeca8cc84a9c2f5b9757a5ae
Reviewed-on: https://code.wireshark.org/review/16806
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-07-31 16:53:52 +00:00
Roland Knall 4a6089795a sshdump: Change ws_close to closesocket
ws_close just calls _close(); that doesn't close sockets.  closesocket()
is the API to close a socket on Windows, and is defined as close()
on UN*X, so using closesocket() will close sockets on Windows and UN*X.

This way, we close the pipe socket correctly on Windows.

Change-Id: I6d50e26bfabac5618c74a180cbe94d444b591bd4
Reviewed-on: https://code.wireshark.org/review/16582
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-22 21:59:31 +00:00
Michael Mann db1e0bcf65 Fix printf style parameters complaints from VS Code Analysis
Change-Id: I5669e2442582f899643fae4a9f86ab6d505dde07
Reviewed-on: https://code.wireshark.org/review/16505
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-07-17 13:10:37 +00:00
Michael Mann 25dfe445a1 ciscodump.c - Address VS Code Analysis warnings.
1. Check sscanf return value
2. Take large "packet" byte array off of stack and onto heap.

Change-Id: I8ade76359f1b0739ec31d7f3b688d212f21357ba
Reviewed-on: https://code.wireshark.org/review/16498
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-07-17 13:10:23 +00:00
Michael Mann abd0033c7e androiddump.c - Address VS Code Analysis warnings.
1. Take large "packet" byte arrays off of stack and onto heap.
2. Cast away an shift operation that should have been identified as safe anyway.

Change-Id: I159c4a7452744763f667336cf4824d5ac3472343
Reviewed-on: https://code.wireshark.org/review/16500
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-07-16 19:52:48 +00:00
Michael Mann 9a9c72ccea Have extcap executables mirror the GTK's WinMain signature.
This is for appeasing VS Code Analysis.

Change-Id: Ib7b3d8a3025dd764da283335051d0f77b45f6dee
Reviewed-on: https://code.wireshark.org/review/16499
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-07-16 19:52:00 +00:00
Michael Mann ed27ad491d androiddump.c: Use preprocessor directive to distinguish E_AGAIN and E_WOULDBLOCK.
VS Code analysis considers them hardcoded values so the if statement is either
always true or always false.

Change-Id: Iad04add9391c515873e2e00d2c6cbd682fbf5b3f
Reviewed-on: https://code.wireshark.org/review/16419
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-07-14 07:05:50 +00:00
Dario Lombardo 01b28caf75 randpkt_core: change rand() to g_rand_int (CID 1355360).
Change-Id: I48560cbb6007eb16aa545a3e8e6a0e8e3b206930
Reviewed-on: https://code.wireshark.org/review/16326
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2016-07-09 15:29:55 +00:00
Dario Lombardo cf508f8960 androiddump: fix leak (CID 1293387).
Change-Id: I27e167368575dfddf78c237723d20c8b790e5f15
Reviewed-on: https://code.wireshark.org/review/16268
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
2016-07-04 06:07:41 +00:00
João Valverde a16d401b25 Remove Makefile.common files
Now that nmake build system has been removed they are not needed anymore.

Change-Id: I88075f955bb4349185859c1af4be22e53de5850f
Reviewed-on: https://code.wireshark.org/review/16050
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-06-30 11:04:17 +00:00
Pascal Quantin 6baa1b544c Remove Nmake build system
Change-Id: I3bd474f3cda9667dec66426b5729449953df3e61
Reviewed-on: https://code.wireshark.org/review/15777
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
Reviewed-by: Balint Reczey <balint@balintreczey.hu>
2016-06-15 19:21:57 +00:00
Peter Wu babb9e32e9 androiddump: fix leak on --extcap-interfaces
extcap_base_register_interface duplicates the memory, so there is no
need to keep it around.

Change-Id: I2bac8be519b659504c512d4eb29be8f7ef6dbd59
Reviewed-on: https://code.wireshark.org/review/15919
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-06-15 17:31:01 +00:00
Michael Mann 57ef06e242 *_stdup_printf -> strdup for "single string only" formatting.
Done for performance improvements.

This could probably be done in checkAPIs.pl, but this was just
a quick manual check with grepping.

Change-Id: I91ff102cb528bb00fa2f65489de53890e7e46f2d
Reviewed-on: https://code.wireshark.org/review/15751
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
2016-06-06 06:03:58 +00:00
Michal Labedzki 3a637f342e androiddump: Add model name to user-friendly interface name
This can speed up searching for interface specified to model of Android
device - in most cases it is its market name.

Change-Id: Ib5a3b96d9a2a8cf325f62614d395508b4ec58199
Reviewed-on: https://code.wireshark.org/review/15454
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-05-18 03:37:41 +00:00
Alexis La Goutte dee238b9c8 ssh-base(.h) : fix no newline at end of file [-Wnewline-eof]
Change-Id: I0e5898a0b0a48dd777c3ac249a23c872ff45df80
Reviewed-on: https://code.wireshark.org/review/15253
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-05-03 10:49:48 +00:00
Alexis La Goutte 13e302f33d ssh-base : fix no newline at end of file [-Wnewline-eof]
Change-Id: Id9a132f9cec7df451c8fbed851ed560ba45747bb
Reviewed-on: https://code.wireshark.org/review/15250
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-05-03 07:15:20 +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
Michal Labedzki 0c27e92d8e androiddump 1.0.3: Return more specific error codes
There is 68 generic error exit codes + 45 specific error codes.
Total: 113 error codes, so it is possible to have all specific
exit codes in future - max is 254 (UNIX limitation).

Change-Id: I798bf77b03031a701e90272d01e90b04e7e31940
Reviewed-on: https://code.wireshark.org/review/14763
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.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-04-19 04:03:26 +00:00
AndersBroman 6206f347df g_list_free_full() only exists since 2.28
Change-Id: I41f8b0b27390788b76919791ba03bf97d699a623
Reviewed-on: https://code.wireshark.org/review/14992
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-04-18 20:21:24 +00:00
Dario Lombardo a7e04fcca9 ciscodump: bugfix
Change-Id: I4b2012fd23524485b24064707316d4e58a838660
Reviewed-on: https://code.wireshark.org/review/14914
Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
2016-04-14 20:47:37 +00:00
Michal Labedzki 301aa193f0 extcap-base: There is no need to register interfaces everytime
If extcap tool run on not existing interfaces it will fail.
There is no need to register ALL interfaces while only one is
needed. Extcap tool check it in other way (aka try to capture
but cannot for some reasons).

Change-Id: I6d60da97ce4175f19656d8c18ad8cacd25b0e99a
Reviewed-on: https://code.wireshark.org/review/14765
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-04-14 12:55:24 +00:00
Peter Wu bee73f5d04 sshdump,ciscodump: fix local addresses discovery
Fixes a NULL-deref when no interface addresses are discovered.

Remove NULL interface from list (an empty GSList is represented by NULL
while g_slist_alloc returns a list with a single NULL data).

Change-Id: I2eded40bb697e051445a526d1f34d8a50ef9ccd4
Reviewed-on: https://code.wireshark.org/review/14888
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-04-12 08:21:17 +00:00
Michal Labedzki 5f4f7bcdc1 androiddump: Change insecure sprint into g_snprintf
This avoid potential overflows.

Bug: 12093
Change-Id: Icbfe4a9f04c5f8d4e0284e4800d4775773246abf
Reviewed-on: https://code.wireshark.org/review/14762
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
2016-04-06 09:00:02 +00:00
Michal Labedzki 1cf7834b2d androiddump: Fix crash on start capturing
Wiretap require registration right now. Do it.

Change-Id: I7ec4c4a4c6d3fa6625fff970f7f39f1ab74e3ef5
Reviewed-on: https://code.wireshark.org/review/14761
Reviewed-by: Michael Mann <mmann78@netscape.net>
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>
2016-04-04 06:47:39 +00:00
Michal Labedzki 9328eb6234 androiddump: Register interfaces when list interfaces
Trying to find interfaces every androiddump run use
a lot of system resources so Wireshark can hang for a while.
Back to old behaviour and register interfaces only when
list them.

Change-Id: Ib63cad05fb47722d3b9de24abf28a86e614417cd
Reviewed-on: https://code.wireshark.org/review/14764
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-04-02 18:25:32 +00:00
Dario Lombardo c119296504 randpkt: restyle the list generation to get rid of the const compiler warning.
Change-Id: Id7c62ef18f919ba8a476898bc88c02fd3b6bf5a1
Reviewed-on: https://code.wireshark.org/review/14730
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-04-01 00:33:09 +00:00
Dario Lombardo f4bdaf9d15 extcap: fix const warnings
Change-Id: Iac94349069485207d24ac1b8c1c5c09778c12e03
Reviewed-on: https://code.wireshark.org/review/14729
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-04-01 00:26:50 +00:00
Peter Wu 130ecc3ab3 Fix modeline definitions
Fix mismatching emacs and vi modelines.

Change-Id: I5cab8c5b7692746a5fa731c977cef903ad19a6f6
Reviewed-on: https://code.wireshark.org/review/14688
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-03-29 09:45:27 +00:00
Peter Wu 0aa0fb25e0 Another round of extcap memleak fixes
Fix a bunch of memory leaks, mainly because extcap_base_cleanup is not
called on most execution paths and because memory allocated for options
were not freed.

Additionally, randpkt will now fail if no option is given (it previously
returned 0 if --capture was missing). Logic using "goto" is introduced
with the idea that a program should fail (ret = EXIT_FAILURE) unless
proven otherwise.

Now none of the extcap programs are leaking:

    for what in ssh cisco; do
    for arg in '' --help --extcap-interfaces --extcap-interface=$what; do
        extcap/${what}dump $arg; done; done
    ./tshark -D

Change-Id: I6df1027ed0c32bd53fe87e6c54d355bc8ddd01f5
Reviewed-on: https://code.wireshark.org/review/14671
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-03-29 06:01:31 +00:00
Michael Mann 2b8f409324 Fix nmake build for new extcap and writecap binaries.
Change-Id: Ic7f370cfe5e2a3aad81c77baab066e95a249238f
Reviewed-on: https://code.wireshark.org/review/14631
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-03-26 00:51:04 +00:00
João Valverde a1ed731413 Add ax_lib_socket_nsl.m4 macro
Add SOCKET_LIBS and NSL_LIBS to global LIBS variables on platforms
where it is required.

Make configure checks for getaddrinfo/gethostname unconditional,
that is handled with #ifdefs if necessary.

Change-Id: Ia874038454fb9cf3bdbf8e6fd829f319e331837e
Reviewed-on: https://code.wireshark.org/review/14560
Reviewed-by: João Valverde <j@v6e.pt>
2016-03-25 00:16:19 +00:00
Guy Harris b0db6a01a8 First convert the string to a number, then convert it to network byte order.
That should squelch some warnings from the compiler on the OS X
buildbot.

Change-Id: I0da16469fb48e26677c5366d6fe290db2bf52a10
Reviewed-on: https://code.wireshark.org/review/14619
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-03-24 21:20:00 +00:00
Guy Harris a4aa8930bb Put pcapio.c into a writecap library, and use it.
Change-Id: Ib89f345c072a38bc01f0513366a4bdae3bf6f08e
Reviewed-on: https://code.wireshark.org/review/14615
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-03-24 20:49:37 +00:00
Dario Lombardo 5861c12d1b sshdump: use arg define.
Change-Id: I49ccfc3f616d2d6660c46d6a47d2409e25ad842a
Reviewed-on: https://code.wireshark.org/review/14512
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-03-24 20:15:26 +00:00
Dario Lombardo cb08496418 ciscodump: fix OSX compilation error.
Change-Id: I65d0c5bc6178ef3c2a7e9d5cf8e81d985f9d555a
Reviewed-on: https://code.wireshark.org/review/14613
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2016-03-24 20:10:18 +00:00
Dario Lombardo a6921c79ab extcap: add ciscodump.
Ciscodump is a new extcap that allows packet capture
on Cisco routers (IOS 12.4 and later) through SSH.

Change-Id: Ic9c5be01d3bd0112116f7fc9fa10e26c1552b007
Reviewed-on: https://code.wireshark.org/review/13886
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-03-24 12:07:28 +00:00
João Valverde c57b3777f8 Add pkg.m4 and remove aclocal-flags script
Add pkg-config 0.29.1 macros to our distribution. This makes the
aclocal-flags script obsolete, since we are already not using GLib
autoconf macros.

ACLOCAL_AMFLAGS need only be defined on the top-level Makefile.am.

Change-Id: Idd868dcfeb8f279517970d0f96d9d53e3a7e4d5c
Reviewed-on: https://code.wireshark.org/review/14568
Reviewed-by: João Valverde <j@v6e.pt>
2016-03-23 02:33:43 +00:00
João Valverde b8ab3afc4a Move extcap EditorConfig settings to source dir
To comply with the procedure in README.developer.

Change-Id: If68da7b5ff27c3b250200cd17c80a005d51c631d
Reviewed-on: https://code.wireshark.org/review/14573
Reviewed-by: João Valverde <j@v6e.pt>
2016-03-23 00:24:52 +00:00
João Valverde 7a1d3f67ac Remove ADNS support
Relevant mailing list message:

  https://www.wireshark.org/lists/wireshark-dev/201503/msg00007.html

Change-Id: I0cff6d4d64fb52a651bcf6b28c183e43653b1cc2
Reviewed-on: https://code.wireshark.org/review/14519
Reviewed-by: João Valverde <j@v6e.pt>
2016-03-21 19:32:00 +00:00
Dario Lombardo 8def5c40de extcap-base: remove print of version if no interfaces present.
When no interfaces are available (as with androiddump when adb
is not running) version is not printed anymore, for a cleaner
output.

Change-Id: Ia150a58ff1c04e412ff29a540f18e1fe9612f633
Reviewed-on: https://code.wireshark.org/review/14289
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-03-17 07:28:52 +00:00