Commit Graph

186 Commits

Author SHA1 Message Date
João Valverde 71cfbd81b3 Remove wspcap.h and use config.h instead
Forcing the use of a dedicated header to replace pcap.h is
unnecessary code and mental overhead in this case. We can
use config.h instead for the same purpose of defining a
macro symbol before including pcap.h.
2023-02-06 15:05:36 +00:00
João Valverde cdff6da68e MinGW: Cast away a -Wincompatible-pointer-types warning
extcap/androiddump.c:1712:36: warning: passing argument 2 of 'ws_inet_pton4' from incompatible pointer type [-Wincompatible-pointer-types]
 1712 |         ws_inet_pton4(bt_local_ip, &(server.sin_addr.s_addr));
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                                    |
      |                                    u_long * {aka long unsigned int *}
2023-01-14 14:52:53 +00:00
Jakub Pawlowski c95e8bd38a androiddump: btsnoop support on android T and onwards
After android T, BT process might be called i.e.
com.google.android.bluetooth, instead of com.android.bluetooth

It depends on what APEX version is installed.
2023-01-05 06:52:02 +00:00
Guy Harris e5951765d8 Dissector names are not protocol names.
A given protocol's packet format may depend, for example, on which
lower-level protocol is transporting the protocol in question.  For
example, protocols that run atop both byte-stream protocols such as TCP
and TLS, and packet-oriented protocols such as UDP or DTLS, might begin
the packet with a length when running atop a byte-stream protocol, to
indicate where this packet ends and the next packet begins in the byte
stream, but not do so when running atop a packet-oriented protocol.

Dissectors can handle this in various ways:

For example, the dissector could attempt to determine the protocol over
which the packet was transported.

Unfortunately, many of those mechanisms do so by fetching data from the
packet_info structure, and many items in that structure act as global
variables, so that, for example, if there are two two PDUs for protocol
A inside a TCP segment, and the first protocol for PDU A contains a PDU
for protocol B, and protocol B's dissector, or a dissector it calls,
modifies the information in the packet_info structure so that it no
longer indicates that the parent protocol is TCP, the second PDU for
protocol A might not be correctly dissected.

Another such mechanism is to query the previous element in the layers
structure of the packet_info structure, which is a list of protocol IDs.

Unfortunately, that is not a list of earlier protocols in the protocol
stack, it's a list of earlier protocols in the dissection, which means
that, in the above example, when the second PDU for protocol A is
dissected, the list is {...,TCP,A,B,...,A}, which means that the
previous element in the list is not TCP, so, again, the second PDU for
protocol A will not be correctly dissected.

An alternative is to have multiple dissectors for the same protocol,
with the part of the protocol that's independent of the protocol
transporting the PDU being dissected by common code.  Protocol B might
have an "over a byte-stream transport" dissector and an "over a packet
transport" dissector, with the first dissector being registered for use
over TCP and TLS and the other dissector being registered for use over
packet protocols.  This mechanism, unlike the other mechanisms, is not
dependent on information in the packet_info structure that might be
affected by dissectors other than the one for the protocol that
transports protocol B.

Furthermore, in a LINKTYPE_WIRESHARK_UPPER_PDU pcap or pcapng packet for
protocol B, there might not be any information to indicate the protocol
that transports protocol B, so there would have to be separate
dissectors for protocol B, with separate names, so that a tag giving the
protocol name would differ for B-over-byte-stream and B-over-packets.

So:

We rename EXP_PDU_TAG_PROTO_NAME and EXP_PDU_TAG_HEUR_PROTO_NAME to
EXP_PDU_TAG_DISSECTOR_NAME and EXP_PDU_TAG_HEUR_DISSECTOR_NAME, to
emphasize that they are *not* protocol names, they are dissector names
(which has always been the case - if there's a protocol with that name,
but no dissector with that name, Wireshark will not be able to handle
the packet, as it will try to look up a dissector given that name and
fail).

We fix that exported PDU dissector to refer to those tags as dissector
names, not protocol names.

We update documentation to refer to them as DISSECTOR_NAME tags, not
PROTO_NAME tags.  (If there is any documentation for this outside the
Wireshark source, it should be updated as well.)

We add comments for calls to dissector_handle_get_dissector_name() where
the dissector name is shown to the user, to indicate that it might be
that the protocol name should be used.

We update the TLS and DTLS dissectors to show the encapsulated protocol
as the string returned by dissector_handle_get_long_name(); as the
default is "Application Data", it appeaers that a descriptive name,
rather than a short API name, should be used.  (We continue to use the
dissector name in debugging messages, to indicate which dissector was
called.)
2022-09-10 22:37:11 -07:00
Gerald Combs 3086774fa6 wsutil: Add configuration namespaces.
Rename init_progfile_dir to configuration_init. Add an argument which
specifies our configuration namespace, which can be "Wireshark"
(default) or "Logwolf".
2022-04-04 09:39:27 -07:00
João Valverde 2c44afbba3 Use UINT64_C() with two constants 2021-12-22 01:53:46 +00:00
João Valverde 5ce2ae2804 Clean up some printf() format strings 2021-12-21 02:15:46 +00:00
João Valverde 0ccd69e530 Replace g_strdup_printf() with ws_strdup_printf()
Use macros from inttypes.h.
2021-12-19 21:21:58 +00:00
João Valverde fe5248717f Replace g_snprintf() with snprintf()
Use macros from inttypes.h with format strings.
2021-12-19 20:06:13 +00:00
João Valverde cef5e81146 Define more log domains for extcaps 2021-12-05 00:28:26 +00:00
João Valverde e921b804d0 Fix logging with extcaps
Extcaps require a log file when invoked in child mode. It also has
a specific flag to enable debugging, other that the wslog options.

Fix the logging to:
  1. Enable debug log level if --debug is used.
  2. Do not emit messages to the stderr if debug is enabled.

This brings extcap logging to the same feature level it had before
wslog replaced GLib logging.
2021-12-03 12:30:53 +00:00
Chuck Craft a3625ec9f6 extcap: reword error message referencing captype
There exists a program called "captype" but it's not used here.
2021-10-13 05:03:31 +00:00
João Valverde 5362d0c31b ws_getopt: Rename struct and macros
This is part of the API and should also be renamed to avoid conflicts.
2021-09-30 13:59:28 +00:00
João Valverde 8df2a73594 Use the musl in-tree getopt_long() everywhere
Besides the obvious limitation of being unavailable on Windows,
the standard is vague about getopt() and getopt_long() has many
non-portable pitfalls and buggy implementations, that increase
the maintainance cost a lot. Also the GNU libc code currently
in the tree is not suited for embedding and is unmaintainable.

Own maintainership for getopt_long() and use the musl implementation
everywhere. This way we don't need to worry if optreset is available,
or if the $OPERATING_SYSTEM version behaves in subtly different ways.

The API is under the Wireshark namespace to avoid conflicts with
system headers.

Side-note, the Mingw-w64 9.0 getopt_long() implementation is buggy
with opterr and known to crash. In my experience it's a headache to
use the embedded getopt implementation if the system provides one.
2021-09-17 00:43:54 +01:00
Guy Harris 097656e805 androiddump: get the WIRESHARK_UPPER_PDU tags from the header.
Don't define WIRESHARK_UPPER_PDU_TAG_DISSECTOR_NAME ourselves and use
it, use EXP_PDU_TAG_PROTO_NAME from wsutil/exported_pdu_tlvs.h.
2021-08-20 13:16:15 -07:00
David Perry dc7089e831 Carry drop count/packet ID/queue ID as options on packet block 2021-07-19 21:25:40 +00:00
David Perry 06ed6930dc Carry EPB flags as an option on the packet block
As requested by [this comment][1] on !2859, move `pack_flags` from a
dedicated field in `wtap_rec` to a block option on the packet block in
`wtap_rec.block`.

[1]: https://gitlab.com/wireshark/wireshark/-/merge_requests/2859#note_615984624
2021-07-12 12:41:57 -04:00
David Perry 73087d6fb4 Use wtap_blocks for packet comments
Mostly functioning proof of concept for #14329. This work is intended to
allow Wireshark to support multiple packet comments per packet.

Uses and expands upon the `wtap_block` API in `wiretap/wtap_opttypes.h`.
It attaches a `wtap_block` structure to `wtap_rec` in place of its
current `opt_comment` and `packet_verdict` members to hold OPT_COMMENT
and OPT_PKT_VERDICT option values.
2021-07-07 18:40:24 +00:00
João Valverde c6a920686c wslog: Check environment initialization for errors
Initialiaze the cmdarg error stream earlier.

Dumpcap also needs to know earlier if it is running in capture
child mode.
2021-06-26 00:18:26 +01:00
João Valverde 759bb234d0 wslog: Check if we are initialized and add missing inits
Instead of receiving the program name from GLib, pass it explicitly
to ws_log_init() instead  and use that to initialize the GLib program
name.

ws_log_parse_args() will now exit the program when it encounters an
argument error if exit_failure >= 0.
2021-06-21 16:03:29 +00:00
João Valverde 39df3ae3c0 Replace g_log() calls with ws_log() 2021-06-16 12:50:27 +00:00
João Valverde e86ac706ca wslog: Parse cmd line options in one pass 2021-06-14 22:05:35 +00:00
João Valverde 5ddc007023 wslog: Include pid in format 2021-06-14 14:18:38 +01:00
João Valverde 5a662ba3fb wslog: Add support for domain filtering
A domain filter can be given in the environment variable
'WS_LOG_DOMAINS' or in a command-line options "--log-domains".

The filter is specified as a comma separated case insensitive list,
for example:

    ./tshark  --log-domains=main,capture

Domain data type switches from an enum to a string. There is no
constaint on adding new domains, neither in code or at runtime.
The string format is arbitrary, only positive matches will produce
output.
2021-06-14 13:13:12 +01:00
João Valverde dc7f0b88bb Refactor our logging and extend the wslog API
Experience has shown that:

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

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

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

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

  5. Using this logger seems to be noticeably faster.

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

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

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

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

In the future a mechanism may be added to selectively enable these
domains at runtime while trying to avoid the problems introduced
by G_MESSAGES_DEBUG.
2021-06-11 09:40:28 +00:00
Guy Harris c33e2f7b51 Add more error-reporting routines that call through a function pointer.
Have routines to report capture-file errors, using libwireshark error
codes and strings, that call through a pointer, so they can pop up
dialogs in GUI apps, print a message to the standard error on
command-line apps, and possibly do something different on server
programs.

Have init_report_message() take a pointer to structure containing those
function pointers, rather than the function pointers themselves, as
arguments.

Make other API changes to make that work.
2021-03-15 12:17:59 -07:00
Guy Harris 166159f15d wiretap: eliminate the pcap/nspcap/pcapng WTAP_FILE_TYPE_SUBTYPE_ values.
Register the pcap and pcapng file types/subtypes rather than hardwiring
them into the table.

Call the registration routines for them directly, rather than through a
generated table; they're always supposed to be there, as some code in
Wireshark either writes only one of those formats or defaults to writing
one of those formats.  Don't run their source code through the
registration-routine-finder script.

Have the file type/subtype codes for them be directly exported to the
libwiretap core, and provide routines to return each of them, to be used
by the aforementioned code.

When reporting errors with cfile_write_failure_message(), use
wtap_dump_file_type_subtype() to get the file type/subtype value for the
wtap_dumper to which we're writing, rather than hardcoding it.

Have the "export PDU" code capable of supporting arbitrary file
types/subtypes, although we currently only use pcapng.

Get rid of declarations of now-static can_write_encap and
dump_open routines in various headers.
2021-02-23 21:56:20 +00:00
Guy Harris bb494c11de Fix various spelling errors.
Found by lintian and by looking for the misspelled words that lintian
found.

(Does not fix spelling errors in .asn1 files.)
2020-12-09 05:52:50 +00:00
Guy Harris 6e6233521a Have WTAP_ERR_INTERNAL include an err_info string giving details.
That way, users won't just see "You got an internal error", the details
will be given, so they can report them in a bug.
2020-10-14 04:51:45 +00:00
Guy Harris 74e917fc6c wiretap: have wtap_dump_flush(), and its callers, check for errors.
Change-Id: Ibcddf1a949f775afa49d36a2d165c3685556035d
Reviewed-on: https://code.wireshark.org/review/38104
Petri-Dish: Guy Harris <gharris@sonic.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <gharris@sonic.net>
2020-08-09 23:08:51 +00:00
Guy Harris e4835191cb extcap: clean up the version number handling.
Have the version parameter be just the version number; other code
expects it to be that.

Have additional parameters for the "compiled with" and "running with"
information.

Add a extcap_version_print() routine to show the version message,
printing

	{exename} version {version}

and then printing

	Compiled with {compiled_with}

if "compiled with" information is supplied and printing

	Running with {running_with}

if "running with" information is supplied.

This fixes some messages, as well as fixing the display of extcap
modules in the About dialog.

Change-Id: I3d298d30e83bd363abd599d75adfc780a90f34fd
Reviewed-on: https://code.wireshark.org/review/37877
Petri-Dish: Guy Harris <gharris@sonic.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <gharris@sonic.net>
2020-07-16 02:48:45 +00:00
Martin Mathieson 569f3bd611 More PVS-Studio issues flagged by Valerii Zapodovnikov.
/opt/SourceCode/wireshark/epan/dissectors/packet-frame.c	818	warn	V547 Expression 'fi' is always true.
/opt/SourceCode/wireshark/epan/dissectors/packet-gsm_sms.c	2692	warn	V547 Expression 'length <= (offset - saved_offset)' is always false.
/opt/SourceCode/wireshark/epan/dissectors/packet-isup.c	4688	warn	V1037 Two or more case-branches perform the same actions. Check lines: 4688, 4697
/opt/SourceCode/wireshark/extcap/androiddump.c	1237	warn	V560 A part of conditional expression is always true: data_str.
/opt/SourceCode/wireshark/extcap/androiddump.c	1603	warn	V547 Expression is always true.
/opt/SourceCode/wireshark/ui/qt/models/packet_list_model.cpp	497	warn	V560 A part of conditional expression is always true: ok_r1.

For the voip_calls.c change, I preferred to initailize along with every other field, rather than set to actual value it gets set to later.

For the isobus-vt change, I could not find a spec but followed the pattern from other error bit fields.

Bug: 16335
Change-Id: Ie55082222b582f6fff4e8c7a992d863acee6cf15
Reviewed-on: https://code.wireshark.org/review/37160
Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com>
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2020-05-09 11:34:12 +00:00
Jeroen Roovers fde8f715ed androiddump: Provide fifo argument to g_warning()
When EXTCAP_ANDROIDDUMP_LIBPCAP=1, the compiler warns:

In file included from /usr/include/glib-2.0/glib.h:62:0,
                 from extcap-base.h:29,
                 from androiddump.c:26:
androiddump.c: In function ‘extcap_dumper_open’:
androiddump.c:366:19: warning: format ‘%s’ expects a matching ‘char *’
argument [-Wformat=]
         g_warning("Can't open %s for saving packets: %s",
pcap_geterr(pcap));
(et cetera)

Fix three occurrences of that warning by using char *fifo as it was
apparently intended.

Fixes: 67a5d9bebe
Change-Id: I0597a345d87594cbe548d118a57e3751d0e3abf6
Reviewed-on: https://code.wireshark.org/review/35853
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-01-18 08:12:03 +00:00
Mikael Kanstrup 32d1d96721 androiddump: Fix tcpdump encap type signed/unsigned conversion error
androiddump determines encap type by reading the data link type
value from pcap content generated by tcpdump running on the device.
The data link type is converted from an uint type to an int type
because int is what the pcap/wtap API expects. However the signed
to unsigned conversion is performed on an 8-bit data value rather
than the full 32-bit value making DLT values larger than 127 fail.

Fix the unsigned to signed conversion by determining DLT from the
full 32-bit "network" field from pcap global header instead of
the 8-bit data char array. While at it also take caore of device
to host endianness conversion.

Fixes: v2.5.1rc0-65-gbfef57ebb7 ("androiddump: Fix and simplify tcpdump capture")
Fixes: v2.9.0rc0-694-gafd0eef4f6 ("androiddump: Fix tcpdump encap type when libwiretap is used")

Change-Id: I71629b166a6893763b16e9df33408fee8c99cbd2
Reviewed-on: https://code.wireshark.org/review/34788
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2019-10-16 11:53:04 +00:00
João Valverde 97cb389a35 Revert "CMake: Don't install HTML manuals twice"
This reverts commit f1285fcf06.

NSIS package is broken with this commit.

Change-Id: Ief22a308edad188fa2d5fab79355f19493359fa6
Reviewed-on: https://code.wireshark.org/review/34758
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2019-10-10 15:58:41 +00:00
João Valverde f1285fcf06 CMake: Don't install HTML manuals twice
HTML docs are installed to both $docdir and $pkgdatadir. Fix that
to install to $docdir only.

Change-Id: I115158585b6df9170d9a01249adbc8548df91f14
Reviewed-on: https://code.wireshark.org/review/34640
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2019-10-09 13:24:58 +00:00
Guy Harris 20800366dd HTTPS (almost) everywhere.
Change all wireshark.org URLs to use https.

Fix some broken links while we're at it.

Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c
Reviewed-on: https://code.wireshark.org/review/34089
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-26 18:44:40 +00:00
João Valverde c7d86568a0 CMake: Remove wsutil pcap dependency
Change-Id: Ic5a3653cb8bcc33e0be108c8b201567e7090f9f5
Reviewed-on: https://code.wireshark.org/review/33043
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: João Valverde <j@v6e.pt>
2019-05-03 21:57:05 +00:00
Guy Harris 2ee483a222 Move the Winsock initialization and cleanup to wsutil routines.
Those routines exist on both Windows and UN*X, but they don't do
anything on UN*X (they could if it were ever necessary).

That eliminates some #ifdefs, and also means that the gory details of
initializing Winsock, including the Winsock version being requested,
are buried in one routine.

The initialization routine returns NULL on success and a pointer to a
g_malloc()ated error message on failure; report the error to the user,
along with a "report this to the Wireshark developers" suggestion.

That means including wsutil/socket.h, which obviates the need to include
some headers for socket APIs, as it includes them for you.

Change-Id: I9327bbf25effbb441e4217edc5354a4d5ab07186
Reviewed-on: https://code.wireshark.org/review/33045
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-05-02 09:29:01 +00:00
Gerald Combs cec5991f40 Windows: Modernize our WSAStartup usage.
Make sure we link each application that calls WSAStartup with ws2_32.lib.
Pass version 2.2 to WSAStartup. Wikipedia says it was introduced in 1996,
so we should be OK.

Ping-Bug: 15711
Change-Id: I431839e930e7c646669af7373789640b5180ec28
Reviewed-on: https://code.wireshark.org/review/33033
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Tomasz Moń <desowin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2019-05-01 17:51:59 +00:00
Guy Harris bbc8cbfb9c If you use data_file_url(), you must first call init_progfile_dir().
And if you call init_progfile_dir(), you must call
init_process_policies() before that.

And even if you *don't* use data_file_url(), you might use it in the
future, or you might use other calls to get data file paths, so make
*all* the extcap programs make those calls.

(Yes, this is important on macOS, for example; it may also be important
on Windows.  On other UN*Xes we may just compile in the data file path,
but that's not true on *all* our platforms.)

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

Change-Id: I6f3113cfd9da04ae3fa2b0ece7b0a3a94312830e
Ping-Bug: 14905
Reviewed-on: https://code.wireshark.org/review/31939
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-02-10 16:12:46 +00:00
Peter Wu e2e5b01d77 cli_main: remove real_main from stack traces for non-Windows
Restore the "main" name since that is used everywhere else except for
Windows. On Windows, "main" is renamed via a macro to avoid a conflict
with "wmain" and to allow it to be called in cli_main.c.

For those wondering, GUI applications (such as Qt) have a different
entry point, namely WinMain. In Qt5, src/winmain/qtmain_win.cpp defines
WinMain, but seems to convert its arguments from Unicode to CP_ACP
(ASCII). It might not support UTF-8, but I did not verify this.

Change-Id: I93fa59324eb2ef95a305b08fc5ba34d49cc73bf0
Reviewed-on: https://code.wireshark.org/review/31208
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-01-02 12:08:20 +00:00
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
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
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
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