Commit Graph

97 Commits

Author SHA1 Message Date
John Thacker c7a136a5c0 epan: Rearrange column includes
Move all the declarations of routines that are internal and
not for use by dissectors from column-utils.h column-info.h
Move the column max length defines into column-utils.h because
dissectors might need that

Since packet.h already includes column-utils.h, dissectors don't
need to include column-utils.h anymore.
Remove or downgrade a few other column header includes that are
unnecessary.
2022-08-13 19:37:28 +00:00
John Thacker 8ac995578c epan: Respect custom column resolved/unresolved status everywhere
Add a function to get the column text of the nth column, taking
into account whether the column is resolved or unresolved. Use
this function in the GUI, as well as in tshark, when writing
PSML, exporting dissection to PSML, etc., instead of accessing
col_data directly.

This removes the direct accesses of col_data from outside
column.c and column-utils.c

Fix #18168.
2022-07-12 00:22:11 +00: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
João Valverde 9ba97d12d6 Add ws_debug() and use it
Replace most instances of ws_debug_printf() except in
epan/dissectors and dissector plugins.

Some replacements use printf(), some use ws_debug(), and
some were removed because they were dead or judged to be
temporary.
2021-05-24 01:13:19 +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
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
Peter Wu 720c3bdc04 column: set G_REGEX_RAW for the custom column filter
Neither the pattern nor the intended subject (a custom fields filter)
contain UTF-8, so set G_REGEX_RAW accordingly. While a filter such as
`tcp matches "foo\xff"` (with `\xff` being a single byte) was accepted,
it did not trigger a crash though even if the precondition was violated.

Change-Id: I45d76b9abbd942d186dcf70f581121769bbd2d0a
Ping-Bug: 14905
Reviewed-on: https://code.wireshark.org/review/31940
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-02-10 16:12:59 +00:00
Gerald Combs a7610e837b Sort our column descriptions.
Convert our column descriptions to a value_string and sort it by
description. This ensures that they are properly sorted in the UI.

Change-Id: I7d699a1c45906b9c42e443fcdcdcb4d8d49deb77
Reviewed-on: https://code.wireshark.org/review/28492
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-06-27 23:40:05 +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
Jakub Zawadzki 0553cda6da Instroduce col_finalize(), to allow creating column_info based not only on preferences.
Change-Id: I417e6accff3390a9b1839cd6b44266b76aa754c3
Reviewed-on: https://code.wireshark.org/review/23767
Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-10-04 03:48:12 +00:00
Michael Mann 2c8c42df3c Fix lintian found spelling error "occurence" -> "occurrence"
Change-Id: I4fcff029ec15a1627dde0d311b063a249f0e0c0a
Reviewed-on: https://code.wireshark.org/review/18643
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-11-03 02:31:20 +00:00
Gerald Combs 5846524f0b Qt: Conversation time column updates.
Add a checkbox which lets you toggle between absolute and relative start
times. Use the local time for now. Fixes bug 11618.

Adjust our time precision based on the capture file's time precision.
Fixes bug 12803.

Update the User's Guide accordingly.

Bug: 11618
Bug: 12803
Change-Id: I0049d6db6e4d0b6967bf35e6d056a61bfb4de10f
Reviewed-on: https://code.wireshark.org/review/17448
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2016-09-02 23:53:37 +00:00
Michael Mann 1da1f945e2 Fix checkAPI.pl warnings about printf
Many of the complaints from checkAPI.pl for use of printf are when its embedded
in an #ifdef and checkAPI isn't smart enough to figure that out.
The other (non-ifdef) use is dumping internal structures (which is a type of
debug functionality)
Add a "ws_debug_printf" macro for printf to pacify the warnings.

Change-Id: I63610e1adbbaf2feffb4ec9d4f817247d833f7fd
Reviewed-on: https://code.wireshark.org/review/16623
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>
2016-07-25 04:26:50 +00:00
João Valverde 9ba9a05ef0 Display "IP DSCP" column as short text
Ping-Bug: 12429
Change-Id: I618b2017e161d89f0efa25ce2fb82a1808e8d315
Reviewed-on: https://code.wireshark.org/review/10701
Reviewed-by: João Valverde <j@v6e.pt>
2016-06-15 17:34:34 +00:00
Michael Mann 850f5d3be0 Remove the deprecated column types so users don't think they still exist.
Bug: 11559
Change-Id: I51836dc9a4fa399835c7bdabcba577ebd40327ad
Reviewed-on: https://code.wireshark.org/review/13538
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>
2016-01-27 07:54:24 +00:00
Stig Bjørlykke a6de714ee1 ui: Optimize col_custom_prime_edt()
The col_item->col_custom_fields_ids list does not change between
packet so this can be initialized in build_column_format_array().

Change-Id: I171b583912dbd1568c3d85159fac1ab435dcaa7c
Reviewed-on: https://code.wireshark.org/review/12801
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-12-22 05:17:02 +00:00
Stig Bjørlykke dca8f092dd ui: Fixed column tooltip when having multi-field custom columns.
Change-Id: Iac09b841ff782ea351052ad6b20f5b4ff170e8e8
Reviewed-on: https://code.wireshark.org/review/12752
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2015-12-21 07:32:00 +00:00
Michal Labedzki 9bb3f6be4c Qt: Add missing multi-field column validation
GTK already has it, but Qt forgot about it, so multi-field custom column
works ok if previously saved in GTK-shark. Invalid validation prevent from
modifying and saving multi-field custom column in Qt version.

While at it, rename "custom field" to "custom fields" to ensure
we think about multi-field custom column.

Change-Id: I99588150ccb38be11b75f5dd5b0f6443e7055ebb
Reviewed-on: https://code.wireshark.org/review/12685
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-12-20 08:21:02 +00:00
Stig Bjørlykke c5fb402222 Qt: Set tooltip for packet list header
Added get_column_tooltip() to use common code in GTK and Qt.

Change-Id: I2f6ce95e2e129752bbb958a28aec6f42aa81be3d
Reviewed-on: https://code.wireshark.org/review/12047
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-11-23 05:41:09 +00:00
Michael Mann da09a1bfd8 Take all epan_column_info members that always get allocated to "number of columns" to share their own data structure.
Change-Id: Ib982662db6cf68730a7d121eac60d9bc5ae67429
Reviewed-on: https://code.wireshark.org/review/9195
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-06-29 02:11:04 +00:00
Guy Harris cfcbb28671 Clean up ftype-conversion and dfilter error message string handling.
Have dfilter_compile() take an additional gchar ** argument, pointing to
a gchar * item that, on error, gets set to point to a g_malloc()ed error
string.  That removes one bit of global state from the display filter
parser, and doesn't impose a fixed limit on the error message strings.

Have fvalue_from_string() and fvalue_from_unparsed() take a gchar **
argument, pointer to a gchar * item, rather than an error-reporting
function, and set the gchar * item to point to a g_malloc()ed error
string on an error.

Allow either gchar ** argument to be null; if the argument is null, no
error message is allocated or provided.

Change-Id: Ibd36b8aaa9bf4234aa6efa1e7fb95f7037493b4c
Reviewed-on: https://code.wireshark.org/review/6608
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-01-18 10:22:59 +00:00
Stig Bjørlykke d58567bd78 Fixed memory leakage in col_cleanup.
Several fields in cinfo is allocated memory and must be freed here
to avoid memory leakage when recreating the packet list.

Do not allocate memory for col_expr[] as this points to static strings
or other allocated strings.

Change-Id: I840377e3c590b1a3e2a38e0537465a028041d1e9
Reviewed-on: https://code.wireshark.org/review/5137
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>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-11-10 08:00:56 +00:00
Guy Harris 19b7819694 Get rid of unnecessary includes of ctype.h.
Change-Id: Ibb194cd839d174af9c96f7bb1e2941b3dd6c1ce1
Reviewed-on: https://code.wireshark.org/review/4797
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-17 23:31:20 +00:00
Guy Harris 54b733ce9a Make the time stamp resolution per-packet.
Pcap-ng files don't have a per-file time stamp resolution, they have a
per-interface time stamp resolution.  Add new time stamp resolution
types of "unknown" and "per-packet", add the time stamp resolution to
struct wtap_pkthdr, have the libwiretap core initialize it to the
per-file time stamp resolution, and have pcap-ng do the same thing with
the resolution that it does with the packet encapsulation.

Get rid of the TS_PREC_AUTO_XXX values; just have TS_PREC_AUTO, which
means "use the packet's resolution to determine how many significant
digits to display".  Rename all the WTAP_FILE_TSPREC_XXX values to
WTAP_TSPREC_XXX, as they're also used for per-packet values.

Change-Id: If9fd8f799b19836a5104aaa0870a951498886c69
Reviewed-on: https://code.wireshark.org/review/4349
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-09-28 18:38:18 +00:00
Guy Harris 006790927f Make get_column_longest_string() static.
It's not used outside epan/column.c, so don't export it.

Change-Id: I38e084946d92f3c31b06fc4fc1991c88e652f58a
Reviewed-on: https://code.wireshark.org/review/4334
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-09-27 18:29:31 +00:00
Bill Meier c0b0a11e4e (Pedantic): set editor modelines tab-width & etc to 8; Also: fix some indentation in packet-sip.c
Change-Id: I623fc5e4c1247dbe5e15f0f33270f4f0994268ab
Reviewed-on: https://code.wireshark.org/review/943
Reviewed-by: Bill Meier <wmeier@newsguy.com>
Tested-by: Bill Meier <wmeier@newsguy.com>
2014-04-03 15:31:56 +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
Jakub Zawadzki 0f8572cb51 Avoid including definition of column_info structure in dissectors.
Move COL_* enum to <epan/column-utils.h>

XXX Later we can rename epan/column-info.h to column-int.h (or smth like this)

svn path=/trunk/; revision=54352
2013-12-22 10:41:27 +00:00
Guy Harris 2a088c1d53 Add support for displaying dates as year and day-of-year (1-origin).
In the process, fix various man page descriptions of the -t flag,
and add support for UTC absolute times in the iousers and iostat TShark
taps.

svn path=/trunk/; revision=53114
2013-11-06 20:39:09 +00:00
Michael Mann 3ead3a994a Remove "Cisco MDS-specific" fields from packet_info. 2 of the 3 fields were used strictly for columns that are considered "deprecated" and I think the third could be put in that category as well.
I assume the column enumerations haven't already been removed because of legacy "indexing issues", but if I'm wrong, we should definitely remove the columns altogether.  Could also see renaming columns to DEPRECATED_[X].

svn path=/trunk/; revision=52910
2013-10-27 23:18:19 +00:00
Chris Maynard e41d5b9049 Provide a usage example of the column formats.
svn path=/trunk/; revision=52802
2013-10-23 17:47:47 +00:00
Jörg Mayer 662c7704f8 After looking for something in the column-*.h files and
not finding it, I finally found it in column_info.h
Renamed column_info.h to column-info.h to have consistency
with the column*h files.

svn path=/trunk/; revision=52667
2013-10-18 13:06:05 +00:00
Chris Maynard 63e4539229 From Ed Beroset via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9272
Add tshark -G column-formats report and document the missing ftypes, heuristic-decodes and plugins reports.

From me: Sort the reports.  Add modelines to epan/column.c.  Minor whitespace changes.

svn path=/trunk/; revision=52627
2013-10-15 18:27:35 +00:00
Bill Meier 6499394c78 Declare slist[] as static (reduces storage & code executed: *See below);
Declare dlist[] similarly to slist[] (not really needed since generated storage/code was OK as is)

*On Windows the following program generates sub-optimal code
 (when built using VC10 or VC11 with CFLAGS as used when building Wireshark).

void foo(void) {
    const char *const zz[] = {"ABC", "abc"};
}
-------------

Code generated:

<snip>
_DATA	SEGMENT
$SG1013	DB	'ABC', 00H  !!! note string stored twice !!
$SG1014	DB	'ABC', 00H
$SG1015	DB	'abc', 00H
$SG1016	DB	'abc', 00H
_DATA	ENDS

<snip>
; 1    : void foo(void) {

	push	ebp
	mov	ebp, esp
	sub	esp, 8

; 2    :     const char *const zz[] = {"ABC", "abc"};

	mov	DWORD PTR _zz$[ebp], OFFSET $SG1014    !! note: each ptr of array
	mov	DWORD PTR _zz$[ebp+4], OFFSET $SG1016  !!  individually pushed on stack

<snip>

Not shown: Declaring zz as 'static' generates much better code....


svn path=/trunk/; revision=50271
2013-06-30 23:03:20 +00:00
Jeff Morriss a441793cba Move a couple of time-related modules into wsutil.
A bunch of files didn't really need to include these header files so remove
the include line rather than changing it.

svn path=/trunk/; revision=50154
2013-06-25 22:02:20 +00:00
Jeff Morriss 3729335973 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45016
2012-09-20 01:48:30 +00:00
Jakub Zawadzki bc67498fb4 cleanup get_column_format_matches()
fmt_list[format] is set to TRUE on begin of function as 'obvious' thing to do

svn path=/trunk/; revision=44494
2012-08-14 16:58:34 +00:00
Jakub Zawadzki bf81b42e1e Update Free Software Foundation address.
(COPYING will be updated in next commit)

svn path=/trunk/; revision=43536
2012-06-28 22:56:06 +00:00
Guy Harris a6ccc83e22 If we set "column.hidden" on the command line but don't set
"column.format" in a later argument, make sure we mark the appropriate
existing columns as hidden.

As part of cleaning up the infrastructure for doing this, store the COL_
code for a column in a fmt_data structure rather than a pointer to the
raw column format string; this simplifies some code.

Have a routine to return whether a column is visible, not hidden, as
it's used to set a "visible" flag.

svn path=/trunk/; revision=39822
2011-11-13 22:51:49 +00:00
Anders Broman 2f05cf4dcf From Michael Mann:
Added ability to display UTC time or UTC time with date.  I liked having the
difference between UTC and local time, not just setting local=UTC.

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=2629

svn path=/trunk/; revision=37898
2011-07-04 21:43:34 +00:00
Stig Bjørlykke ccfe41300c Added "Edit Column Details" functions to the packet list heading popup.
Removed "Rename Column Title" as this is moved to "Edit Column Details".

svn path=/trunk/; revision=34444
2010-10-09 15:22:53 +00:00
Sake Blok 7364bef1b3 When using a custom column, make it possible to select which occurrence to show if the field has multiple occurrences.
svn path=/trunk/; revision=34186
2010-09-22 20:56:14 +00:00
Stig Bjørlykke beb4314276 Introduce "Show Resolved" as an option in custom columns. This will determine
if we show the value or the string representing the value.

This setting is not stored in the preferences file yet, and the option is
not available in the columns preferences window.

svn path=/trunk/; revision=33317
2010-06-25 06:42:34 +00:00
Stig Bjørlykke d3e1e2df1e Added "Hide Column" functionality.
svn path=/trunk/; revision=33266
2010-06-20 16:23:43 +00:00
Bill Meier 6812b68eb1 From Yaniv Kaul: constify parameters
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4422

 From me: Fix a number of instances where the function prototype or
  the function definition wasn't changed so there was a mismatch 
  thus causing Windows (but not gcc) compilation errors.

svn path=/trunk/; revision=32365
2010-04-03 18:18:50 +00:00
Bill Meier d32b4c0758 Revert SVN #32360 until Windows compilation errors corrected.
svn path=/trunk/; revision=32361
2010-04-02 15:18:03 +00:00
Bill Meier 049f9eac85 From Yaniv Kaul: constify parameters
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4422

svn path=/trunk/; revision=32360
2010-04-02 14:37:49 +00:00
Gerasimos Dimitriadis c08fa6f3cf Move underscore escaping/unscaping function to strutil.c;
Update decoding of IS-801 Request GPS Acquisition Assistance

svn path=/trunk/; revision=31685
2010-01-26 18:21:17 +00:00
Gerasimos Dimitriadis e50527b8e1 Handle underscore escaping/unescaping for old packet list; Simplify
and make more robust the unescaping function.

svn path=/trunk/; revision=31668
2010-01-25 20:30:09 +00:00