Commit Graph

100 Commits

Author SHA1 Message Date
Roland Knall 2cf938cfa8 tap: Adding flags for tap_packet
This allows flags to be passed by the registering listener
to the collection of information
2022-06-10 05:46:15 +00:00
Gerald Combs ca04f4c8cb Qt: Update our dynamic menu groups.
Add log-specific statistics groups, and use them to limit the dynamic
menu items in Wireshark and Logwolf.
2022-04-12 12:14:03 -07:00
João Valverde c5a19582e4 epan: Convert to use stdio.h from GLib
Replace:
    g_snprintf() -> snprintf()
    g_vsnprintf() -> vsnprintf()
    g_strdup_printf() -> ws_strdup_printf()
    g_strdup_vprintf() -> ws_strdup_vprintf()

This is more portable, user-friendly and faster on platforms
where GLib does not like the native I/O.

Adjust the format string to use macros from intypes.h.
2021-12-19 19:29:53 +00:00
João Valverde 0e50979b3f Replace g_assert() with ws_assert() 2021-06-19 01:23:31 +00:00
Moshe Kaplan 6bce7b859a Detect and replace bad allocation patterns (more)
Extension of !1413, to improve regex, detect
additional opportunities to replace
`g_malloc` with `g_new`, and fix them.
2020-12-23 14:07:18 +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
Gerald Combs fac6a2179e WSUG: Add a Packet Lengths dialog section.
Add a section for the Packet Lengths window. Use title case for the
column headers. Fix a button name and other issues elsewhere.

Change-Id: I339d56aa169158e0788acd02a897729205e9f50e
Reviewed-on: https://code.wireshark.org/review/35615
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2020-01-03 16:37:08 +00:00
Tomasz Moń 5f5a934bca Use g_hash_table_replace() when key depends on data
Using g_hash_table_insert() in cases where the key is contained within
value is error prone. Use g_hash_table_replace() to eliminate the risk
of ending up with incoherent hash table state.

Change-Id: I595457476a2682e927d2c56b2692404aef4dc43a
Reviewed-on: https://code.wireshark.org/review/34385
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>
2019-08-28 03:51:32 +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
Dario Lombardo 8ab0932aa1 stats_tree: use the right modifier for int values.
Ping-Bug: 15416
Change-Id: I24593bdc9f2399085926724176b1a0a8197d7e1a
Reviewed-on: https://code.wireshark.org/review/31662
Reviewed-by: 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>
2019-01-23 08:01:35 +00:00
Dario Lombardo b67b47558d epan: remove redundant casts.
Found by clang-tidy.

Change-Id: Iaf6cf84c33b03ddfcd39a333b49f4987002afa56
Reviewed-on: https://code.wireshark.org/review/31338
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-01-03 23:39:43 +00:00
Guy Harris 2d41b15495 Add a "failed" return for tap packet routines.
This allows taps that can fail to report an error and fail; a failed
tap's packet routine won't be called again, so they don't have to keep
track of whether they've failed themselves.

We make the return value from the packet routine an enum.

Don't have a separate type for the per-packet routine for "follow" taps;
they're expected to act like tap packet routines, so just use the type
for tap packet routines.

One tap packet routine returned -1; that's not a valid return value, and
wasn't one before this change (the return value was a boolean), so
presume the intent was "don't redraw".

Another tap routine's early return, without doing any work, returned
TRUE; this is presumably an error (no work done, no need to redraw), so
presumably it should be "don't redraw".

Clean up some white space while we're at it.

Change-Id: Ia7d2b717b2cace4b13c2b886e699aa4d79cc82c8
Reviewed-on: https://code.wireshark.org/review/31283
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-01-01 05:03:42 +00:00
Michael Mann c10c7737cc Allow floating point values for stats_tree
Bug: 4234
Change-Id: Ibd59809b2dd9890a7851eb57ef7af384e280a74b
Reviewed-on: https://code.wireshark.org/review/31222
Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-12-28 14:50:45 +00:00
Peter Wu 10306f9a32 Free g_array_free-related memory leaks
g_array_free(a, FALSE) returns "a->data". Callers that do not handle
this will leak memory. Convert other users to use the return value
instead of direct access to "a->data".

Change-Id: I0a29864e8106c0bf09e9573ef29e4474179c4171
Reviewed-on: https://code.wireshark.org/review/27438
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-05-14 13:44:23 +00:00
Gerald Combs 1d030928ef Remove some GTK+-only code.
Change-Id: Ic2498c7acd6a1a522be45094148402ee34a6b4d1
Reviewed-on: https://code.wireshark.org/review/26958
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-04-17 03:44:47 +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
Martin Kaiser e155e91599 stats tree: (trivial) reformat assignments
a= b; looks a bit strange. Replace such assignments with a = b;

Change-Id: I09534e0201906490daeb5cd35c55df00e139cf30
Reviewed-on: https://code.wireshark.org/review/23800
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-10-01 15:11:51 +00:00
Martin Kaiser 9ab17810bc stats_tree: fix the comparison routine for COL_AVERAGE
Generally, the average is calculated as node->total / node->count.

The curent code does not handle the case where we compare two nodes
and both have count == 0. It defines one of the nodes to be bigger.
This triggers (at least on Windows) an assertion about invalid operator<.

To fix this, we define average = 0 for a node with count == 0.
We can then simply compare the two averages.

Change-Id: Ie7d9cd590deddcdb9214c4a2693c2eb47c66b287
Reviewed-on: https://code.wireshark.org/review/23799
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-10-01 15:11:10 +00:00
Silvio Gissi aefd4e1844 Fix Packet Lengths statistics count
Packet statistics were not showing the packets above 5120 due to
the last entry being reformatted and not parsed correctly.
Since the last entry is "reformatted" for better user string,
also "reformat" the last entry as it goes through "range processing".

Bug: 13844
Change-Id: Id49b41c08111dcad1590e034159b81ead8636c4e
Reviewed-on: https://code.wireshark.org/review/22382
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-06-26 04:04:35 +00:00
Alexis La Goutte 02ea90f3cc stats_tree: fix this statement may fall through [-Werror=implicit-fallthrough] found by gcc7
Change-Id: Idd5ab938b95d515cdf8b2a8568456f44b3dd85ac
Reviewed-on: https://code.wireshark.org/review/20496
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-03-11 17:28:58 +00:00
Alexis La Goutte 6e8066cc28 stats_tree: fix no previous prototype for ‘stats_tree_cfg_free’ [-Wmissing-prototypes]
Change-Id: Iddf63fabec9a2abb5b3d75fb5289f769e0175b55
Reviewed-on: https://code.wireshark.org/review/20197
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-02-20 16:51:59 +00:00
Dario Lombardo c31b8da721 stats_tree: add cleanup function.
Change-Id: Iefd264bdd79af172c245c3a30119999cca9d56c0
Reviewed-on: https://code.wireshark.org/review/19976
Reviewed-by: Michael Mann <mmann78@netscape.net>
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-02-07 15:28:15 +00:00
João Valverde b82e1e0e9e Cleanup indentation
Change-Id: I59e9a4806d047e8cc26e9927e76243ce58a57e6d
Reviewed-on: https://code.wireshark.org/review/13811
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-02-08 05:51:14 +00:00
João Valverde d8e9862044 Fix constness
Change-Id: I23a01f86d6934f3d6c048015c47ae690742173c8
Reviewed-on: https://code.wireshark.org/review/13437
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>
2016-01-20 16:10:17 +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
Alexis La Goutte 21ac94a323 stats_tree: re-indent else for avoid warning found by PVS Studio (V705)
It is possible that 'else' block was forgotten or commented out, thus altering the program's operation logics

Change-Id: Ie246592282bd0791021159f90b4b8aeb92cff86f
Reviewed-on: https://code.wireshark.org/review/12333
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-12-01 21:08:04 +00:00
João Valverde 532070b4e7 Add support for IPv6 stats tree statistics
Also add support for alphabetizing stat tree items as the addition of IPv6 stats tree makes it more obvious its needed.

Change-Id: I8b319ceac805ce7e3a1fd59f92c1c6fe2a54d3de
Reviewed-on: https://code.wireshark.org/review/10062
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: Alexis La Goutte <alexis.lagoutte@gmail.com>
2015-08-22 08:30:52 +00:00
Gerald Combs 36a74cb13a Tap parameter and stats dialog fixups.
If we run into an error when trying to register a tap listener, return
instead of tapping packets. This should fix some (but likely not all)
double frees found by Stig. For now close each statistics dialog if we
find an error. Note that we might want to keep them open instead.

Add checks and cleanups to some of the stats table free routines.

Call fillTree once in TapParameterDialog's constructor instead of each
time it's shown. Make fillTree a slot which lets us use a delay timer so
that the dialog is visible when we retap packets.

Change-Id: Id49f2f2a99bc8e5b1d32990024986b3c8b1abe24
Reviewed-on: https://code.wireshark.org/review/10153
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-08-20 18:07:02 +00:00
Gerald Combs fdb85029fd Add ServiceResponseTimeDialog.
Add ServiceResponseTimeDialog as a subclass of TapParameterDialog,
similar to StatsTreeDialog. Add initial plumbing for statistics menu
items and command line invocation.

Don't append "..." to menu item names. Don't add menu icons. In each
case this avoids repetitive UI clutter.

Change-Id: I463b95c93090160bb81d2e80b16aad389dc0bd6c
Reviewed-on: https://code.wireshark.org/review/8864
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-07-03 23:09:13 +00:00
Gerald Combs 1736a1bcc6 Clean up stats_tree_presentation.
Remove some unused struct members and accompanying callbacks.

Change-Id: I64d32ddf886038e8f19bc3f88e86c8d7578db648
Reviewed-on: https://code.wireshark.org/review/8779
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-06-05 21:39:08 +00:00
Gerald Combs e0d268bd5f stats_tree: Make sure some structs are fully initialized.
Get rid of a strcpy.

Change-Id: I49460969fdf627fdb89030115ad5a658e300a5d4
Reviewed-on: https://code.wireshark.org/review/6130
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-12-30 13:01:08 +00:00
Bill Meier 971d4e4ad1 stats_tree: g_sprintf()-->g_snprintf(); cleanup #includes.
Change-Id: I862fed818cd1f14584b082f87b1d4d305cf78687
Reviewed-on: https://code.wireshark.org/review/5970
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-12-22 04:59:47 +00:00
Bill Meier 5051ae1cbe Convert "4 space tabs" to spaces; Adjust editor modelines.
Change-Id: I8d61d959c79e6aa9875c58680c54a331d18079cc
Reviewed-on: https://code.wireshark.org/review/4504
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-10-06 18:29:40 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Gerald Combs 79ef36a5f0 Fix some scan-build warnings.
Fix a modeline while we're at it.

Change-Id: Ief6d5edbe33456170059cfab4f436f0844de32a1
Reviewed-on: https://code.wireshark.org/review/440
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-03-01 19:15:38 +00:00
Bill Meier 11b5c15fdb Remove trailing whitespace
Change-Id: I8116f63ff88687c8db3fd6e8e23b22ab2f759af0
Reviewed-on: https://code.wireshark.org/review/385
Reviewed-by: Bill Meier <wmeier@newsguy.com>
Tested-by: Bill Meier <wmeier@newsguy.com>
2014-02-25 20:46:49 +00:00
Alexis La Goutte 2108ccad09 Fix indent (Use tabs) and add modelines
svn path=/trunk/; revision=54610
2014-01-05 18:39:50 +00:00
Jakub Zawadzki 3ae2e5ece2 Fix warnings
svn path=/trunk/; revision=53885
2013-12-09 20:15:47 +00:00
Alexis La Goutte 006f84a565 From Deon van der Westhuysen via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9452
Patch: Stats_tree enhancements for sorting, averages and burst rate

Add sort, save-as and new columns to Qt ui, remove old functions

stats_tree.c / stats_tree_priv.h: Make all columns sortable. Remove unneeded functions stats_tree_get_strs_from_node, stats_tree_branch_to_str and stats_tree_is_sortable_column.

stats_tree_stat.c: Set all columns sortable.

stats_tree_dialog.cpp / stats_tree_dialog.h: Add new stats_tree columns. Make columns sortable. Remove copy to csv and copy to yaml buttons. Add copy to clipboard as plain text and save as buttons.

stats_tree_dialog.ui: Remove copy to csv and copy to yaml buttons. Add copy to clipboard as plain text and save as buttons. Only define one column in ui, rest are added dynmically.

From me : fix trailing whitespace

svn path=/trunk/; revision=53848
2013-12-08 11:09:54 +00:00
Jakub Zawadzki c193f9c9e4 Use strutil xml_escape() function
svn path=/trunk/; revision=53832
2013-12-07 19:46:05 +00:00
Guy Harris 55544b5c39 Get rid of a stray semicolon, as it upsets Sun^WOracle Studio's C
compiler.

Clean up escape_xml_chars() a bit, so that there's no extra unreached
"return s;", and so that it's clearer that it runs until it hits a NUL. 
(XXX - are there GLib routines that will do this?)

svn path=/trunk/; revision=53716
2013-12-02 09:30:31 +00:00
Michael Mann 0c9aa51ec5 Patch to include YAML export. Bug 9452 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9452)
From Deon van der Westhuysen
From me: use switch statements instead of if-else

svn path=/trunk/; revision=53698
2013-12-01 15:44:22 +00:00
Michael Mann ac9b982868 Better fix for uninitialized variable warning. Part of bug 9452 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9452)
From Peter Wu.
From me: Leave the "result" variable initialized because I'm not sure code analyzers will consider g_assert_not_reached() enough prevention from using uninitialized "result"

svn path=/trunk/; revision=53679
2013-11-30 21:00:21 +00:00
Pascal Quantin 021efe411c Try to please GCC 4.3.2
svn path=/trunk/; revision=53675
2013-11-30 12:31:36 +00:00
Guy Harris 216f631e8a Casts required from void * in C++.
svn path=/trunk/; revision=53664
2013-11-30 00:05:24 +00:00
Guy Harris 1d80b1e16c Constify to squelch some warnings.
svn path=/trunk/; revision=53663
2013-11-30 00:02:46 +00:00
Guy Harris 52cfff996e Squelch some "use parentheses" warnings.
Use tab indentation uniformly.

svn path=/trunk/; revision=53662
2013-11-29 23:57:23 +00:00
Guy Harris 488e61fea0 Rename variable to avoid collisions with standard function names.
Use the st_format_type type.

svn path=/trunk/; revision=53661
2013-11-29 23:54:12 +00:00
Michael Mann 60d6b05e23 Stats_tree enhancements for sorting, averages and burst rate. Bug 9452 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9452)
From Deon van der Westhuysen

- Bug fix: object leak in stats_tree after a tap reset (for example apply statistics preferences with a stats_tree window open)
- Bug fix: correct sample code in README.stats_tree
- Add: slash in plug-in name now creates submenu as docs describe (was a bug?)
- Add: menu separator before the stat_tree registered plug-ins
- Add: stats_tree can now calculate averages for nodes; automatically calculated for range nodes. Add section in README.stats_tree describing averages.
- Add: stats_tree can now calculate burst rate of each node (like rate but with a shorter, sliding time window)
- Add: sorting for stats_tree plug-ins. Can sort on node name, count, average, min, max values and burst rate.
- Add: preferences for stats_tree system (default sort column, burst calc params)
- Add: stats_tree window copy to clipboard and export and plain text, csv and XML.
- Added sample of new functionality in $srcdir/plugins/stats_tree/pinfo_stats_tree.c
- Moved all stats_tree sample plug-ins to "IP Statistics" submenu.

svn path=/trunk/; revision=53657
2013-11-29 22:47:59 +00:00
Gerald Combs ea28298e96 Add a statistics tree dialog.
Add menu items for each corresponding item in gtk/main_menubar.c that
calls gtk_stats_tree_cb(). Hopefully that's everything. Note that we use
quite a bit less code than the GTK+ flavor and why we might not want to
do that. Change a few things in ui/qt/CMakeLists.txt to more closely
match the GTK+ version. Add plumbing for tap registrations in
CMakeLists.txt and Makefile.am. Add the ability to copy text as CSV or
YAML.

svn path=/trunk/; revision=53464
2013-11-21 01:28:17 +00:00