Commit Graph

28 Commits

Author SHA1 Message Date
João Valverde 0e50979b3f Replace g_assert() with ws_assert() 2021-06-19 01:23:31 +00:00
Martin Kaiser f4ac70818a stat_tap_table_ui: create tables only once during init
If you load a capture file and open any statistics dialog, you'll see the
list of collected items. Each time you press the Apply button (without entering a
display filter) another list of items will be created as a top-level entry
of the statistics tree. Only the first list will have the correct values,
all subsequent lists will not be populated.

Each statistic module defines a stat_tap_table_ui structure that contains a
stat_tap_init_cb function. This init function is called by
SimpleStatisticsDialog::fillTree before the tap listener is registered. This
happens each time we collect the statistics.

However, it seems that all init functions create a new stat_tap_table each
time they are called, even if they already have an existing stat_tap_table
of the same name.

This patch adds a stat_tap_find_table function to find a table by name.

As a first step, we update the ANSI A-I/F BSMAP Statistics to check if its
table is already registered. If it is, the table will not be created again.
2021-01-28 13:41:08 +00:00
Moshe Kaplan e16166a74c Detect and replace bad allocation patterns
Adds a pre-commit hook for detecting and replacing
occurrences of `g_malloc()` and `wmem_alloc()` with
`g_new()` and `wmem_new()`, to improve the
readability of Wireshark's code, and
occurrences of
`g_malloc(sizeof(struct myobj) * foo)`
with
`g_new(struct myobj, foo)`
to prevent integer overflows

Also fixes all existing occurrences across
the codebase.
2020-12-22 14:56:38 +00:00
Peter Wu 7c890e3307 Do not modify optarg with -zfollow,ssl,ascii,0
Most callers (in tshark.c, ui/commandline.c, etc.) do not modify their
optarg argument, so don't do that here either.

Fixes: v2.9.0rc0-2110-g872b573381 ("Recognize -zfollow,ssl,ascii,0 for compatibility")
Change-Id: I80d56aee7ba80591b684d847a9cc95cf9a96c5dd
Reviewed-on: https://code.wireshark.org/review/30031
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-05 13:19:32 +00:00
Peter Wu 872b573381 Recognize -zfollow,ssl,ascii,0 for compatibility
Instead of reporting it as unsupported, silently map ssl to tls.

Change-Id: I4c7436872137749634590a99201f2b8222c69fb4
Fixes: v2.9.0rc0-1819-gcd95e197ca ("Start renaming SSL to TLS.")
Reviewed-on: https://code.wireshark.org/review/30025
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-05 04:30:27 +00:00
Guy Harris afad14dcfe Get rid of some GTK+-only stuff.
Change-Id: I85806476246a567f747e3911e3d15716e9cfe06b
Reviewed-on: https://code.wireshark.org/review/27514
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-05-13 20:21:14 +00:00
Guy Harris c61b543e97 Get rid of more new_ prefixes for statistics functions and types.
There are no "old" versions of them that we're keeping around.

Change-Id: I3c76a14d0ec1a06df39c547da37f4dea9987df4d
Reviewed-on: https://code.wireshark.org/review/25892
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-19 00:12:51 +00:00
Dario Lombardo 55c68ee69c epan: use SPDX indentifiers.
Skipping dissectors dir for now.

Change-Id: I717b66bfbc7cc81b83f8c2cbc011fcad643796aa
Reviewed-on: https://code.wireshark.org/review/25694
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08 19:29:45 +00:00
Dario Lombardo 34381ed20c stat_tap: don't use-after-free (found by clang).
Change-Id: Ie7304ad70c8cf3ac62abdf07aaa94d12c409f1b0
Reviewed-on: https://code.wireshark.org/review/25339
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-01-16 22:31:51 +00:00
Jakub Zawadzki 60c8ada4c2 sharkd: output JSON for new_stat_ API.
Change-Id: I5b4b020029f3c1587f96ca1fcf5fbfa2ee78ac31
Reviewed-on: https://code.wireshark.org/review/21628
Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
2017-05-15 09:16:51 +00:00
Pascal Quantin 38bc42b00b Fix IPv6/IPX statistics generation
g70381f7 switched from a sorted GSList to a wmem_tree.
But the strings "ipx" or "ipv6" must be tested before "ip" to select the
right tap so the sorting does matter.
Use a wmem_list and parse it by reverse order like what was done with
the GSList to ensure proper selection of the tap.

Change-Id: Ic8d291c265e9c83c960d9a2f6713c25e3aa0e60d
Reviewed-on: https://code.wireshark.org/review/20813
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: Pascal Quantin <pascal.quantin@gmail.com>
2017-04-01 10:28:09 +00:00
Dario Lombardo d1b943dd7d stat_tap_ui: skip duplicate keys.
Change-Id: If2a2d6af94458a72dc304eae3cacac0a4af2d25a
Reviewed-on: https://code.wireshark.org/review/20092
Petri-Dish: Dario Lombardo <lomato@gmail.com>
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-02-19 22:45:22 +00:00
Dario Lombardo e2951a2ca8 stat_tap_ui: remove leaks.
Change-Id: If7a28ba305bed9f63f200f8a8a27a796f2df9c07
Reviewed-on: https://code.wireshark.org/review/20015
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-02-19 13:25:44 +00:00
Michael Mann 70381f774c Switch stat tap to use wmem_tree_t instead of (sorted) GSList.
Change-Id: I172167eb20793113562b69d1e0e93a4882200404
Reviewed-on: https://code.wireshark.org/review/20019
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-02-08 14:25:07 +00:00
Dario Lombardo fe89424160 stat_tap_ui: add cleanup function.
Change-Id: I0275a6e0d5d151f086d96c6388b9fa647ea0085c
Reviewed-on: https://code.wireshark.org/review/19654
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: Dario Lombardo <lomato@gmail.com>
2017-01-18 08:25:33 +00:00
Guy Harris 63a1e4ad85 Get rid of another unnecessary new_ prefix.
Change-Id: I99522c1e5f2a4aac091cb19dd7fff450ddc2c26e
Reviewed-on: https://code.wireshark.org/review/12898
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-29 00:48:29 +00:00
Guy Harris 9067ee8f5a Rename new_stat_tap_ui to stat_tap_table_ui.
A "new" statistics tap UI is a statistics tap UI where the statistics
are maintained as tables and common code handles the tables; what
matters is the tables, not that it's "new".

Change-Id: I7a0e63cfac98c24cd5e7dce973b9a0cc5b6a03ba
Reviewed-on: https://code.wireshark.org/review/12897
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-29 00:31:37 +00:00
Guy Harris 0c156fec93 There's no "old" stat_tap_table, so remove "new_" from the name.
Change-Id: I1a0349d5d9d47210a97ff7a99fb358e59fd70e72
Reviewed-on: https://code.wireshark.org/review/12896
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-29 00:20:09 +00:00
Guy Harris 18c5496137 Don't cast away constness unnecessarily.
Compare functions for various collection data types don't need to modify
what they're comparing, so keep everything const.

Change-Id: I1c2cff6954b1a8c5ade74943934324d0bd8f523c
Reviewed-on: https://code.wireshark.org/review/12884
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-28 20:34:15 +00:00
Gerald Combs ff24ecceb9 Fixup stat_tap table freeing.
As it turns out we *do* need to free table elements. We also need to
free the tables themselves and clear the table array. Do so.

Change-Id: Ic1c81388eac8f47f74caea0169c79685a83aaff9
Reviewed-on: https://code.wireshark.org/review/9901
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-08-06 21:22:13 +00:00
Gerald Combs 4e14a26372 Don't zero stat tap elements.
Let the reset callback take care of resetting our rows.

Change-Id: I59b0e9d36a9a1cedc5a5893664c875b7416a5229
Reviewed-on: https://code.wireshark.org/review/9868
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-08-04 18:46:41 +00:00
Gerald Combs 03802cc53e Convert H.225 tap stats to new "generic stat API".
Migrate the H.225 stats similar to the recent BOOTP migration.

Change-Id: I70ff7ab6cf3e9796f257412ba7d65ec9fe7f77ad
Reviewed-on: https://code.wireshark.org/review/9859
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-08-04 16:36:22 +00:00
Gerald Combs 632b4023fa Zero stat table elements instead of freeing them.
Stat table element arrays are allocated once at startup. Reset each
element in free_stat_table() instead of freeing them.

Change-Id: Ia63af93c76a1348bbb809137a521eead58a52dd1
Reviewed-on: https://code.wireshark.org/review/9860
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-08-04 16:14:22 +00:00
Gerald Combs 4eca268935 Add SimpleStatisticsDialog.
To do:
- Refactor dynamic menu item placement.

Change-Id: I087de9f2fa3c2ff7dc08e5d54bc9c1b984fdd7b1
Reviewed-on: https://code.wireshark.org/review/9561
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-07-08 17:01:15 +00:00
Michael Mann a8ff1e2778 Create very basic "generic" stat tap API to create a "GUI" independent table.
A few sample tap/dissectors (ANSI/A, ANSI MAP) are also included to test the API.  The "GUI output" is a bit raw and could use some "prettying up", but all the basic hooks are there.

Telephony "stat grouping" needs to be better alphabetized to properly populate menu (on GTK, probably Qt)

Change-Id: I98514171f69c4ab3a304dccb26c71d629703c9ab
Reviewed-on: https://code.wireshark.org/review/9110
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-07-03 23:08:28 +00:00
Pascal Quantin bc7a9e55fd Fix IPv6/IPX statistics generation
Use a doubly-linked list and iterate on the reversed statistics list to always test the bigger strings first

Bug: 10813
Change-Id: Ibfedac9648db58e6dadc2334eec678e26daca906
Reviewed-on: https://code.wireshark.org/review/6140
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-12-30 18:27:29 +00:00
Pascal Quantin 1ae0c4a643 Fix -z statistics command line parsing
The string comparison must be done against the length of the registered command, not against the length or the string given as an argument.
Otherwise optional parameters are taken into account.

Change-Id: Iec4032fc10b00e606770533c5a567d7b49663593
Reviewed-on: https://code.wireshark.org/review/6075
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-12-27 16:00:53 +00:00
Guy Harris 4d3c4c4f12 Rename stat_cmd_args.[ch] to stat_tap_ui.[ch].
The intent is to handle more than just command-line arguments; reflect that.

Change-Id: Ia10efda85a9d11c6579d1bec6f789cee30d9e825
Reviewed-on: https://code.wireshark.org/review/5304
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-11-14 18:52:06 +00:00