Commit Graph

37 Commits

Author SHA1 Message Date
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 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
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
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
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 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
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
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 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
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
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 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 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
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 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 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 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
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 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
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 3771a790b7 Fix randpktdump build in Windows.
Change-Id: If749635d771443542285a74f05f37156123b2991
Reviewed-on: https://code.wireshark.org/review/14238
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-02-29 13:15:07 +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
Guy Harris e9b2859c45 Clean up modelines and indentation.
HT tab stops are set every 8 spaces on UN*X; UN*X tools that treat an HT
character as tabbing to 4-space tab stops, or that even are configurable
but *default* to 4-space tab stops (I'm looking at *you*, Xcode!) are
broken.  tab-width: 4, tabstop=4, and tabSize=4 are errors if you ever
expect anybody to look at your file with a UN*X tool, and every text
file will probably be looked at by a UN*X tool at some point, so Don't
Do That.

Adjust indentation to reflect the mode lines.

Change-Id: Icf0831717de10fc615971fa1cf75af2f1ea2d03d
Reviewed-on: https://code.wireshark.org/review/14150
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-02-25 21:34:36 +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
Guy Harris 58d00bad1a Build the extcap programs in the extcap directory.
That lets the version of Wireshark built with autotools find the extcap
programs.

Don't install the extcap programs under ${datadir} - that puts it under
a share directory, and share directories are for platform-independent
files, which executable images aren't (they're instruction-set
dependent, hence platform-dependent).

Change-Id: I992eeb984bdbe6b3476777f7114628c83df6080f
Reviewed-on: https://code.wireshark.org/review/13943
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-02-15 08:31:06 +00:00
Dario Lombardo 6fde7da633 randpktdump: change error messages.
Change-Id: Icf020d92cb2bef22afac2c74d3a719e54d36f95d
Reviewed-on: https://code.wireshark.org/review/13887
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: Dario Lombardo <lomato@gmail.com>
2016-02-11 11:37:59 +00:00
Alexis La Goutte d326eb98f6 fix spelling-error-in-binary found by lintian
Change-Id: I2bdb40d287b2c19d40679fb73a8bae5f1debdd98
Reviewed-on: https://code.wireshark.org/review/13330
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>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-01-16 14:06:10 +00:00
Roland Knall 5d4a71a1a2 ssh/randpktdump: Add version to extcap utility
Add a version to each utility, displayed in the about dialog of Wireshark

Change-Id: I64936072b13116b3e173c50411e9fff45d5fbf4c
Reviewed-on: https://code.wireshark.org/review/13290
Reviewed-by: Roland Knall <rknall@gmail.com>
Petri-Dish: Roland Knall <rknall@gmail.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-01-14 18:46:56 +00:00
Thomas Wiens 3866df04dd Moved variable declaration top, to be C89 compliant
Change-Id: I83b96f8cdabbb3ae67172659492f5992c95fbe73
Reviewed-on: https://code.wireshark.org/review/13004
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-01-02 14:27:10 +00:00
Dario Lombardo ac0eb6043b extcap: add randpktdump, a random packet generator.
This new extcap is for testing and educational purpose.
It relies on rankpkt-core functions to generate random packets.

Change-Id: If6890f0673545682995a2079458108edc0913b30
Reviewed-on: https://code.wireshark.org/review/11764
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>
2015-12-22 12:24:16 +00:00