Commit Graph

186 Commits

Author SHA1 Message Date
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
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
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
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
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 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
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
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
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 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
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
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
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
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
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
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
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
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
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 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
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
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 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 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 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
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 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
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
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
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
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
Michal Labedzki 3c143d2846 androiddump 1.0.2: Fix a lot of usage of recv()
recv() can return negative value or 0 in "error cases".
There is need to check it. This also solved empty interfaces
list if there is unauthenticated device.

Bug: 12080
Change-Id: If6cd0e0933b64e9ac9bbb66b3b8138f7177451d1
Reviewed-on: https://code.wireshark.org/review/14316
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-03-12 18:26:33 +00:00
Dario Lombardo b4f3255450 androiddump: change first error message into verbose_print()
This error occurs every run of wireshark if adb is not running.
This is a bit noisy, so androiddump is made less verbose.

Bug: 12185

Change-Id: Ia7d0b0aba95e90a7f602c2e340f6344d09205b32
Reviewed-on: https://code.wireshark.org/review/14288
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: Dario Lombardo <lomato@gmail.com>
2016-03-04 10:10:17 +00:00
Roland Knall a4e2263ac4 extcap: Move extcap handling to base
Also add the extcap-version parameter to enable parsing of
version and helppage separately

Change-Id: I35ba5aa992940ffbb0cd9ebea8b7c3a1e8629d74
Reviewed-on: https://code.wireshark.org/review/14094
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-02-29 12:32:03 +00:00
Dario Lombardo 298012359b extcap: move windows functions into extcap-base
Change-Id: Iec7fed027a24992afd673b09c32470af51739ae5
Reviewed-on: https://code.wireshark.org/review/14075
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-02-26 10:02:59 +00:00
Dario Lombardo a376915fdd extcap: move includes into extcap-base.
Change-Id: I802cc3a3bb3989411216ed070ecc018345e0d54f
Reviewed-on: https://code.wireshark.org/review/14073
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-02-25 14:05:51 +00:00
Dario Lombardo c154c75fef extcap: move common code into extcap-base files
Change-Id: Ia4a73c7df39426c8773fce04cac223bda3c6ef1c
Reviewed-on: https://code.wireshark.org/review/14071
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-02-25 12:54:27 +00:00
Alexis La Goutte 137358a404 androiddump: fix logical ‘or’ of equal expressions [-Werror=logical-op] found by gcc6
EAGAIN and EWOULDBLOCK is the same value (now)
http://www-numi.fnal.gov/offline_software/srt_public_context/WebDocs/Errors/unix_system_errors.html

Change-Id: Ia8101d05194910f306e8439507ae5bde3ccd00ce
Reviewed-on: https://code.wireshark.org/review/13905
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
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: Roland Knall <rknall@gmail.com>
2016-02-13 14:46:27 +00:00
Michal Labedzki c09d894f74 Fix some Coverity issue
>>>     CID 1349726:  Incorrect expression  (COPY_PASTE_ERROR)
>>>     "tvb_reported_length_remaining" in "tvb_reported_length_remaining(tvb, offset)" looks like a copy-paste error.
>>>     CID 1349727:  Incorrect expression  (COPY_PASTE_ERROR)
>>>     "tree" in "dissector_try_uint_new(bluetooth_eir_ad_manufacturer_company_id, company_id, new_tvb, pinfo,
>>>     CID 1349728:    (DEADCODE)
>>>     Execution cannot reach this expression "0" inside statement "(0 && ((__s1_len = __builti...".
>>>     CID 1306904:  Logically dead code (DEADCODE)
>>>     Execution cannot reach this statement "tap_hci_summary->interface_...".

Change-Id: I5f99e37e6d5fac39da7082649caa8373d06bb808
Reviewed-on: https://code.wireshark.org/review/13739
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-02-05 18:57:29 +00:00
Dario Lombardo 5e89f93322 androiddump: fix printf format warning.
Found by clang. Compiler warning:

warning: format specifies type 'void *' but the argument has type 'char *' [-Wformat-pedantic]

Change-Id: I7f370b06f98490cd6e363a9679a449420c8c8021
Reviewed-on: https://code.wireshark.org/review/13602
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
2016-02-01 11:50:38 +00:00
Michal Labedzki 7b2afd5ae6 androiddump: There is no need to make full copy optarg
Copy pointer is enough.

Change-Id: I51188a8434f6e4ba1d9bf3456bd29e027dd40f35
Reviewed-on: https://code.wireshark.org/review/13393
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-01-18 16:09:18 +00:00
Roland Knall ca512cf47c androiddump: Return extcap version information
Change-Id: I22cdf02286262ae55ea94b4387791d3d28769f31
Reviewed-on: https://code.wireshark.org/review/13286
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-01-15 11:30:48 +00:00
moshekaplan cd7026951b Fix a lot of typos and misspellings
Change-Id: I8512cfa1d424f82a873a0e0e1d22c7b075fdd7f3
Reviewed-on: https://code.wireshark.org/review/13069
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: Michael Mann <mmann78@netscape.net>
2016-01-08 20:04:56 +00:00
Pascal Quantin 97705dfdbd anddroiddump: fix compilation errors with Win64 and OSX 10.5 x86
Change-Id: Ie8aa666cd0b10b4260bf184ff35734589c71a8aa
Reviewed-on: https://code.wireshark.org/review/12705
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-12-17 19:34:52 +00:00
Michal Labedzki 2da59158a0 Try to fix some PVS Studio warnings
V814 Decreased performance. The 'strlen' function was called multiple times inside the body of a loop. androiddump.c 626
V814 Decreased performance. The 'strlen' function was called multiple times inside the body of a loop. androiddump.c 661
V814 Decreased performance. The 'strlen' function was called multiple times inside the body of a loop. androiddump.c 678
V814 Decreased performance. The 'strlen' function was called multiple times inside the body of a loop. androiddump.c 689
V814 Decreased performance. The 'strlen' function was called multiple times inside the body of a loop. androiddump.c 700
V814 Decreased performance. The 'strlen' function was called multiple times inside the body of a loop. androiddump.c 711
V814 Decreased performance. The 'strlen' function was called multiple times inside the body of a loop. androiddump.c 728
V814 Decreased performance. The 'strlen' function was called multiple times inside the body of a loop. androiddump.c 739
V814 Decreased performance. The 'strlen' function was called multiple times inside the body of a loop. androiddump.c 750
V814 Decreased performance. The 'strlen' function was called multiple times inside the body of a loop. androiddump.c 761
V814 Decreased performance. The 'strlen' function was called multiple times inside the body of a loop. androiddump.c 810
V814 Decreased performance. The 'strlen' function was called multiple times inside the body of a loop. androiddump.c 867
V814 Decreased performance. The 'strlen' function was called multiple times inside the body of a loop. androiddump.c 889
V814 Decreased performance. The 'strlen' function was called multiple times inside the body of a loop. androiddump.c 949
V814 Decreased performance. The 'strlen' function was called multiple times inside the body of a loop. androiddump.c 971
V804 Decreased performance. The 'strlen' function is called twice in the specified expression to calculate length of the same string. androiddump.c 1876
V512 A call of the 'memcpy' function will lead to underflow of the buffer 'packet + exported_pdu_headers_size'. androiddump.c 1950
V804 Decreased performance. The 'strlen' function is called twice in the specified expression to calculate length of the same string. androiddump.c 2053
V804 Decreased performance. The 'strlen' function is called twice in the specified expression to calculate length of the same string. androiddump.c 2056
V512 A call of the 'memcpy' function will lead to underflow of the buffer 'packet + exported_pdu_headers_size'. androiddump.c 2122
V590 Consider inspecting this expression. The expression is excessive or contains a misprint. androiddump.c 2207
V590 Consider inspecting this expression. The expression is excessive or contains a misprint. androiddump.c 2227
V530 The return value of function 'freopen' is required to be utilized. androiddump.c 2275
V530 The return value of function 'freopen' is required to be utilized. androiddump.c 2279
V808 'name' object of 'QString' type was created but was not utilized. bluetooth_devices_dialog.cpp 201
V807 Decreased performance. Consider creating a pointer to avoid using the 'ui->tableTreeWidget->headerItem()' expression repeatedly. bluetooth_devices_dialog.cpp 337
V807 Decreased performance. Consider creating a pointer to avoid using the 'item->child(i_item)' expression repeatedly. bluetooth_hci_summary_dialog.cpp 648
V807 Decreased performance. Consider creating a pointer to avoid using the 'ui->tableTreeWidget->headerItem()' expression repeatedly. bluetooth_hci_summary_dialog.cpp 669

Change-Id: Ia81b5f867b2b1e0ee58eed0bd297800774bc37f9
Reviewed-on: https://code.wireshark.org/review/12683
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>
2015-12-17 14:17:27 +00:00
Michal Labedzki 682cf6d72a androiddump: Remove all mallocs
Removing all malloc improve reliability, simplify code,
reduces memory usage...

Bug: 11608
Change-Id: Ie56312a1afdf298e926bb242825565b52dbd85d3
Reviewed-on: https://code.wireshark.org/review/12682
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Michal Labedzki <michal.labedzki@tieto.com>
2015-12-17 14:17:06 +00:00
Michal Labedzki 882f5becc2 androiddump: Some Coverity fixes
CID 1295677: (CHECKED_RETURN)
CID 1293385: (NEGATIVE_RETURNS)

Change-Id: I142f1f9629af9339261b74e54a1a40b595ddecb5
Reviewed-on: https://code.wireshark.org/review/12681
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
2015-12-17 14:16:34 +00:00