aboutsummaryrefslogtreecommitdiffstats
path: root/extcap/extcap-base.c
AgeCommit message (Collapse)AuthorFilesLines
2024-07-05Don't call g_string_free() with bool - it takes gbooleanStig Bjørlykke1-1/+1
2024-07-04Convert a bunch of gconstpointers to const void pointersGerald Combs1-1/+1
As README.developer says: "Avoid GLib synonyms like gchar and gint and especially don't use gpointer and gconstpointer, unless you are writing GLib callbacks and trying to match their signature exactly. These just obscure the code and gconstpointer in particular is just semantically weird and poor style." We didn't convert gconstpointers in convert-glib-types.py until 5f807da9ba, so make another pass and do so on everything except our dissector code. Convert some gpointers as well. Ping #19116
2024-04-05Remove init to zero for static variablesStig Bjørlykke1-3/+3
The C standard requires that objects with static storage duration is initialized to zero.
2024-04-03extcap: Fix a strlen checkStig Bjørlykke1-1/+1
Change a strlen() check because this can never be less than zero. This will remove this warning from cppcheck: warning: Checking if unsigned expression 'strlen(extcap->fifo)' is less than zero. [unsignedLessThanZero]
2024-01-19extcap: Set matching libssh log levelJohn Thacker1-3/+1
Instead of always setting the libssh log level to SSH_LOG_INFO when an extcap has a ws log level of LOG_LEVEL_DEBUG or lower, set the libssh log level to a corresponding log level (NOISY/TRACE, DEBUG/DEBUG, INFO/INFO, MESSAGE and above/WARN). Format the libssh logging messages more similar to our normal logging messages, with a libssh domain and using the libssh priority. Prior to 0.11.0 (that is, this commit: https://gitlab.com/libssh/libssh-mirror/-/commit/657d9143d121dfff74f5a63f734d0096c7f37194 ) libssh sends some merely informational messages at their WARN level, so lower that down to INFO, which isn't printed by default and doesn't get printed in the GUI. Related to #17888
2023-06-15Convert our extcaps to C99 typesGerald Combs1-21/+21
Convert our extcaps to C99 types. Try to preserve padding in convert-glib-types.py and add globbing support on Windows. Ping #19116
2022-10-08Add log init message to main()João Valverde1-0/+1
2022-08-29extcap: Signal processing unified for C based extcapsj.novak@netsystem.cz1-0/+55
2021-12-21Extcap logging: Corrected incorrect selector default value syntaxj.novak@netsystem.cz1-2/+2
2021-12-19Replace g_strdup_printf() with ws_strdup_printf()João Valverde1-3/+3
Use macros from inttypes.h.
2021-12-14wslog: Avoid logging any output to stdoutJoão Valverde1-0/+2
For historical reasons our logging inherited from GLib the logging of some levels to stdout. Namely levels "info" and "debug" (to which we added "noisy"). However this practice is discouraged because it mixes debug output with application output for CLI tools and breaks many common usage scenarios, like using tshark in pipes. This change flips the logic on wslog to make logging to stderr the default behavior. Extcap subprocess have a hidden dependency on stdout so add that. Some GUI users may also have a dependency on stdout. Because GUI tools are unlikely to depend on stdout for programatic output add another exception for wireshark GUI, to preserve backward compatibility.
2021-12-07extcap: Use standard --log-level and --log-file CLI optionsJoão Valverde1-38/+29
This should allow simultaneous logging to the console and the log file when running an extcap from the CLI. One difference is that the extcap error/warning dialogs in the GUI have extra information in standard wslog format (may or may not be a good thing).
2021-12-06Extcap: Improve the log handler logicJoão Valverde1-6/+14
If we have a log file write everything to the file, to provide a complete picture in the log. Debug information cannot be written to the parent process when running in child mode.
2021-12-06extcap: Register log handler conditionallyJoão Valverde1-1/+2
This matches the original implementation and allows displaying logs to the console, including debug information, when running an extcap from the CLI for testing and development purposes. This should make extcap logging bug-for-bug compatible with the behavior before dc7f0b88bb.
2021-12-05Define more log domains for extcapsJoão Valverde1-0/+1
2021-12-03Fix logging with extcapsJoão Valverde1-2/+23
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-09-17Use the musl in-tree getopt_long() everywhereJoão Valverde1-12/+0
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-06-19Replace g_assert() with ws_assert()João Valverde1-2/+3
2021-06-16Replace g_log() calls with ws_log()João Valverde1-3/+3
2021-06-11Refactor our logging and extend the wslog APIJoão Valverde1-23/+3
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-02-14Enable -Wredundant-decls.Guy Harris1-5/+11
Add it to the default list of checks, and fix some errors it causes. (Sadly, it doesn't work in CLang.)
2020-07-16extcap: clean up the version number handling.Guy Harris1-9/+23
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-16extcap-base: no need to get the basename of the executable path twice.Guy Harris1-4/+1
Just use extcap->exename. Change-Id: I85cfda2afaf776f3222cf362bcd6c675b4ff1504 Reviewed-on: https://code.wireshark.org/review/37876 Petri-Dish: Guy Harris <gharris@sonic.net> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net>
2020-07-15Show the version of libssh being used, if possible.Guy Harris1-2/+9
If we have ssh_version(), then ssh_version(0) will return a string for the version being used. Change-Id: I0717f6d4d5c3fa04aa7938dc6bc0d4c8abfa95fd Reviewed-on: https://code.wireshark.org/review/37875 Petri-Dish: Guy Harris <gharris@sonic.net> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net>
2020-07-15extcap: add libssh version info to sshdump and ciscodump.Dario Lombardo1-0/+7
Change-Id: I1e13cc3471e37514a0dd181abd4938607a057ec6 Reviewed-on: https://code.wireshark.org/review/37870 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-07-15extcap: improve version output for all extcaps.Dario Lombardo1-2/+7
Change-Id: I6ecdbdbbdf852bc3b874ad6a9acdd94f8e839c89 Reviewed-on: https://code.wireshark.org/review/37869 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-03-15More modeline fixes to put HT tab stops every 8 characters.Guy Harris1-3/+3
Change-Id: If3ea65f24e33b89784b3d9a1e7009d09728d4f7a Reviewed-on: https://code.wireshark.org/review/36437 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-11-14extcap: save debug flag and use it to activate ssh debug.Dario Lombardo1-0/+1
Change-Id: Ida32834f8c0838f1d815f7e33116b6a6161acf34 Reviewed-on: https://code.wireshark.org/review/30572 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-07extcap: Cleanup an if-statementStig Bjørlykke1-4/+2
Change-Id: If56f3837e8bcf0ef3a11579ca031223909ac47b9 Reviewed-on: https://code.wireshark.org/review/30528 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-05extcap: change boolean to boolflag for --debug option.Dario Lombardo1-1/+1
Change-Id: I6a42e689fa9a914f7f3bee1c1ade2218573a1c3f Reviewed-on: https://code.wireshark.org/review/30502 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-05extcap: fix return value in extcap_base_parse_options().Dario Lombardo1-1/+5
We need to split good options' from bad options' return value. Change-Id: I836e58c0f05716484664f354e7332a74d6a08c20 Reviewed-on: https://code.wireshark.org/review/30503 Reviewed-by: Dario Lombardo <lomato@gmail.com> Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-12Win32: Make extcap utilities console applications.Gerald Combs1-47/+0
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-05-08sshdump/ciscodump: use groups in config.Dario Lombardo1-4/+4
Change-Id: I3d6689738aee32bf720e6ebca1d4462429fdc1eb Reviewed-on: https://code.wireshark.org/review/27397 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com> Reviewed-by: Dario Lombardo <lomato@gmail.com>
2018-05-02extcap-base.c: fix compilation with gcc 8Pascal Quantin1-7/+4
extcap-base.c:293:43: error: cast between incompatible function types from ‘void (*)(void *)’ to ‘void (*)(void *, void *)’ [-Werror=cast-function-type] extcap-base.c:302:45: error: cast between incompatible function types from ‘void (*)(void *)’ to ‘void (*)(void *, void *)’ [-Werror=cast-function-type] extcap-base.c:321:42: error: cast between incompatible function types from ‘void (*)(void *)’ to ‘void (*)(void *, void *)’ [-Werror=cast-function-type] Change-Id: Ifd9151d04412c5e29636dc14c57a327cc12d33f3 Reviewed-on: https://code.wireshark.org/review/27265 Petri-Dish: Guy Harris <guy@alum.mit.edu> Reviewed-by: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-04-05extcap: Tell utilities the wireshark versionRoland Knall1-0/+2
Add an optional argument to extcap-version, which tells the utilities the wireshark version and therefore allows them to handle different versions differently. If no version is provided, the utility has to assume it is dealing with a Wireshark 2.x version (default behavior). Change-Id: I51658300f28f503ca8050d204b73749f1a54df16 Reviewed-on: https://code.wireshark.org/review/26752 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
2018-02-08replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.Dario Lombardo1-1/+1
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>
2017-11-12extcap: use SPDX identifiers for licences.Dario Lombardo1-13/+1
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-09-06plugins: config.h must not be included by public headersJoão Valverde1-0/+1
For a sane plugin build environment. Include config.h as the first header in the .c file instead. Fix by moving required compiler attribute macros to a new "ws_attributes.h" API header. Change-Id: I34f58a927f68c1a0e59686c14d214825149749e1 Reviewed-on: https://code.wireshark.org/review/23400 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: João Valverde <j@v6e.pt>
2017-08-03extcap: skip custom log if filename is space.Dario Lombardo1-2/+4
Change-Id: I98b890316af05d9c5359dc38a30d07ac55f262fe Reviewed-on: https://code.wireshark.org/review/22932 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-08-02extcap: add debug log file feature to extcap-base.Dario Lombardo1-1/+41
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-07-27extcap: add command line debug function to extcap-base.Dario Lombardo1-0/+10
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>
2016-10-19extcap: put missed parameters into the helpMichal Labedzki1-0/+2
"--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-09-10extcap-base: fix memleak from help optionsPeter Wu1-4/+5
Also correct modelines, this file really uses 4 spaces and not tabs. Change-Id: I828d0249cc7637275e5a04e9117b22e9eea6bd8c Reviewed-on: https://code.wireshark.org/review/17625 Reviewed-by: Dario Lombardo <lomato@gmail.com> Petri-Dish: Dario Lombardo <lomato@gmail.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-08-25extcap: add binary name and version to help message.Dario Lombardo1-2/+6
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-24extcap: make extcaps use the version registered in config.Dario Lombardo1-1/+0
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-04extcap: restyle the help function.Dario Lombardo1-0/+53
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-04extcap: prevent registration of wrong version.Dario Lombardo1-0/+3
This prevents the user to run extcap_base_set_util_info(extcap, "1", NULL, "0", NULL); that would result in version = 1.0. Change-Id: I67532459c852bdceb16693553e90da88a1043435 Reviewed-on: https://code.wireshark.org/review/16858 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Roland Knall <rknall@gmail.com>
2016-08-04extcap: restyle the output subsystem.Dario Lombardo1-3/+10
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-07-31extcap: fix indentation in extcap-base.Dario Lombardo1-69/+69
Change-Id: Ic8e9634c9568d32fdeca8cc84a9c2f5b9757a5ae Reviewed-on: https://code.wireshark.org/review/16806 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-07-17Fix printf style parameters complaints from VS Code AnalysisMichael Mann1-2/+2
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>