Commit Graph

91 Commits

Author SHA1 Message Date
Dario Lombardo ea929d6401 wsutils: add local implementation of g_memdup2.
g_memdup() was deprecated and replaced with g_memdup2() in GLib 2.68,
we provide our own copy of g_memdup2() for older GLib versions.
2021-03-25 09:38:10 +00:00
Dr. Lars Völker 8902386c76 UAT: Adding support for uint64 (dec/hex), int64 (dec)
This patch adds 64bit support for uint and int to uats.
2021-01-05 11:20:47 +00:00
Guy Harris 8652762738 Separate signed and unsigned decimal UAT fields.
Most of them are unsigned; do the appropriate fetching, checking, and
writing-to-UAT-file for them.  Have separate macros and routines for the
one signed one, which is the drbid in the LTE MAC dissector.

Use the Wireshark string-to-number routines; they do the appropriate
bounds checking, and make sure unsigned numbers don't start with a -.

Change-Id: I4f137aa31d631c5b5622b2c320574b8ab3333f31
Reviewed-on: https://code.wireshark.org/review/30288
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-10-20 21:03:51 +00:00
Guy Harris 7ff2cadf16 Fix up some comments.
Change-Id: I0dba163baa5d4fdaa321a92bc95808300d5c8456
Reviewed-on: https://code.wireshark.org/review/30286
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-10-20 19:04:11 +00:00
Stig Bjørlykke 75c46e80bf Qt: Add copy from another profile in UAT dialogs
Add a new button to UAT dialogs to copy entries from another profile.

Change-Id: I641ba764d8738f738466529d74d4a21ff13075a0
Reviewed-on: https://code.wireshark.org/review/30028
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2018-10-05 12:38:32 +00:00
Anders c57a52f68c UAT: HEX Values should be allowed the full uint32 range e.g allow 0xffffffff
Change-Id: I13ec13646271bd9de543d02de5c7cbc0d6d02019
Reviewed-on: https://code.wireshark.org/review/29219
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-08-22 03:57:55 +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
Michael Mann 907d8ff41f Protect UAT color "datatype" from an empty string
UAT color "datatype" has the format of #XXXXXX so the XXXXXX is strduped
to pass to strtol(). The "pointer math" assumed the # was always present
and would result in large memory allocation if string was empty.

Bug: 14357
Change-Id: Idc43b17f0e07705880d0d77f106991d10e09f072
Reviewed-on: https://code.wireshark.org/review/25504
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-01-29 00:03:16 +00:00
Michael Mann 5b3e3ee587 Use UAT model for I/O graph
Convert from using TreeWidgetItems to UAT model/delegate.  More of the GUI
is "just handled" within the table.
Required to add support for "colors" and "protocol fields" to UAT types.
Also needed to add some hacks for "custom" UAT field handlers for
backwards compatibility with the existing UAT structure used.

Because UAT functionality was switched completely to the model, some
information in the table was "lost in translation" because the UATs
themselves aren't translated to other languages.

TODO:
2. Better "order of operations"?  A bunch of NULL/size checks needed to be added to prevent crashing.
Now with model/"view" should events/functions be reordered?

Bug: 13585
Change-Id: I2bbba78182317c4fada07b927c05d0c6f4cdc0fe
Reviewed-on: https://code.wireshark.org/review/22766
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-08-07 17:25:02 +00:00
Michael Mann 29e726a606 Add support for "bool" and "display filter" types for UATs.
Filter expressions needs support for a checkbox (bool) and
string field that verifies display filters.

Change-Id: Idfbffd6cdb5abaee8914126a05d890e834c17306
Reviewed-on: https://code.wireshark.org/review/22340
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-06-22 13:07:11 +00:00
Dario Lombardo 6322f9ce61 uat: add missing parameter to documentation.
Change-Id: Ic39b00e0800c123083a6583d78eb96154b93e49f
Reviewed-on: https://code.wireshark.org/review/20075
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-02-12 17:00:51 +00:00
Dario Lombardo 805ddd1add uat: add a reset callback.
This function will free the resources allocated by the caller.

Change-Id: Ib486c14e4fd3c321662fb71f7fd06733ce9a64a4
Reviewed-on: https://code.wireshark.org/review/19375
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-01-12 12:39:15 +00:00
Michael Mann 6a6d7ea34f Convert range API to always use wmem memory.
This is mostly to address memory leaks in range preferences (the biggest
user of range functionality) on shutdown.
Now range preferences must use epan scoped memory when referencing
internal preference structures to keep consistency.

Change-Id: Idc644f59b5b42fa1d46891542b53ff13ea754157
Reviewed-on: https://code.wireshark.org/review/19387
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-01-07 00:44:10 +00:00
Peter Wu a59e64c906 uat: fix PT_TXTMOD_HEXBYTES/PT_TXTMOD_ENUM comments
The PT_TXTMOD_HEXBYTES comment was misleading, edit it to reflect the
actual implementation in GTK+/Qt.

Change-Id: I1506ad9189296dcc09cc20eafb0d65eaf291d79f
Reviewed-on: https://code.wireshark.org/review/18058
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-10-04 01:11:14 +00:00
Peter Wu e7cac432fb uat: clarify documentation
No functional change, fixes typos, adds some meaningful function
parameters and tries to clarify the memory management concerns.

Also fix a -Wdocumentation issue in epan/proto.h

Change-Id: I59d1fcd2ce96178e0a64a0709409a9a7a447c7c6
Reviewed-on: https://code.wireshark.org/review/17431
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-09-01 19:06:49 +00:00
João Valverde 146c4b7016 uat: Fix warnings [-Wcast-qual]
uat_fld_tostr_cb_t callback *out_ptr argument is g_mallocated and
is to be freed by the caller so drop constness requirement to fix
the corresponding g_free warnings.

Change-Id: I1be25fa3e2f54fb32058ac0b5c1631b193b07701
Reviewed-on: https://code.wireshark.org/review/12943
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-31 22:56:34 +00:00
Guy Harris c14df7f7a8 Don't allocate something until we know we need it.
From change I1be25fa3e2f54fb32058ac0b5c1631b193b07701.

Change-Id: Iad01cd4c5920afcdc1f8329937f4141cf8bc0ab4
Reviewed-on: https://code.wireshark.org/review/12979
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-31 22:54:27 +00:00
Guy Harris 01dc475484 Don't cast away constness.
Save a non-const pointer and use it when freeing.

Fix some indentation while we're at it.

Change-Id: Iad2451130c4d1f252ad9f63b12205cd1aae70eb7
Reviewed-on: https://code.wireshark.org/review/12978
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-31 22:41:06 +00:00
Balint Reczey 9a9b1c9bba Spelling fixes for errors found by lintian
Change-Id: I889283902875193f4d3f3fd59788f59f8d9bcc20
Reviewed-on: https://code.wireshark.org/review/11945
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-12-07 07:11:54 +00:00
Gerald Combs a25c4841d2 Get rid of a couple of UAT macros.
Declare and fill in some functions normally instead of using macros.

Change-Id: I06323ecf53e0fe8ce7299168984838c87209acc5
Reviewed-on: https://code.wireshark.org/review/11336
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-10-28 02:40:47 +00:00
Gerald Combs 61cef23486 Use an "Open" instead of a "Save" dialog for UAT prefs.
When selecting a file for a PT_TXTMOD_FILENAME UAT preference, use
QFileDialog::getOpenFileName instead of QFileDialog::getSaveFileName.
This matches current GTK+ behavior and the two preferences that use
PT_TXTMOD_FILENAME.

Add a comment noting that the PT_TXTMOD_FILENAME is Open-only.

Bug: 11027
Change-Id: I29eb056422949eda700d448621e508cf094fd7b7
Reviewed-on: https://code.wireshark.org/review/8678
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-05-28 21:16:39 +00:00
Guy Harris 9d1ea65f3f Fix comments to reflect reality.
Change-Id: I63aeb49e442eb6eba5cdf35ded221894c1d0ea6c
Reviewed-on: https://code.wireshark.org/review/7223
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-18 00:48:52 +00:00
Guy Harris 859511db14 Make UAT record update callbacks return a success/failure indication.
Have them return TRUE on success and FALSE on failure.  Check the return
value rather than whether the error string pointer is null or not.

Change-Id: I800a03bcd70a6bbb7b217cf7c4800e9cdcf2189c
Reviewed-on: https://code.wireshark.org/review/7222
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-18 00:41:09 +00:00
Guy Harris 44e7ce54ff Remove some apparently-unnecessary includes of emem.h.
Change-Id: Ib7d1b587b439ff21ec6b7f1756ce6ccf25b66f80
Reviewed-on: https://code.wireshark.org/review/6635
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-01-18 20:19:05 +00:00
Guy Harris bc23f79729 UAT error string pointers should not be const pointers.
UAT error strings are usually allocated by g_strdup() or
g_strdup_printf(), and must ultimately be freed by the caller.

Make the pointer-to-error-string-pointer arguments to various functions
be "char **", not "const char **".

Fix cases that finds where a raw string was being used, as that won't
work if you try to free it; g_strdup() it instead.

Add a missing free of an error string.

Remove some no-longer-necessary casts.

Remove some unnecessary g_strdup()s (the string being handed to it was
already g_malloc()ated).

Change some variable declarations to match.

Put in XXX comments for some cases where the error string is just freed,
without being shown to the user.

Change-Id: I40297746a2ef729c56763baeddbb0842386fa0d0
Reviewed-on: https://code.wireshark.org/review/6525
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-01-13 20:20:03 +00:00
Michael Mann 7967ef9510 Remove emem APIs from UAT functionality.
Change-Id: I009c09f25d170e5c9aaaef713eaacb3252817856
Reviewed-on: https://code.wireshark.org/review/6460
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Evan Huus <eapache@gmail.com>
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-01-12 14:25:12 +00:00
Guy Harris 033f096ee9 Don't use ctype.h routines.
That avoids locale dependency and handles possibly-signed chars (which
we weren't always doing before).

Change-Id: Ieceb93029252f646397b6488f2df8a57c6d2a23d
Reviewed-on: https://code.wireshark.org/review/4794
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-17 23:11:18 +00:00
Guy Harris d853e92b75 Convert all the other function-defining macros.
(Perhaps C2099 will finally deprecate old-style function definitions and
allow you to declare parameters without names, just as C++ does, and
compilers will - obviously - not warn about those parameters being
unreferenced, obviating the need for __attribute((unused))__ and the
like.  And perhaps monkeys will fly out of....)

Change-Id: Iff295c1854e66eb4f9e02cdd5761e0191d371365
Reviewed-on: https://code.wireshark.org/review/4018
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-09-06 22:37:50 +00:00
Guy Harris 746a265f99 Try to suppress MSVC++ unused parameter warnings.
I haven't found a way to with MSVC to mark parameters in the argument
list as unused.  MSVC doesn't give warnings about them in C code, but
does appear to give them with C++ code.  An answer to

	http://stackoverflow.com/questions/3020584/avoid-warning-unreferenced-formal-parameter

suggests not giving the formal parameter a name in C++.

Have a macro UNUSED_PARAMETER(), which takes as an argument a variable
name, and expands to nothing in C++ and to the variable name followed by
_U_ in C, and use that for some unused parameters.  If it works, we'll
use it for all of them.

Change-Id: I76107bed037f1f0d94615adb42234c9faf83b4db
Reviewed-on: https://code.wireshark.org/review/4016
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-09-06 20:09:16 +00:00
Evan Huus 39a14ab75f Remove now-unused functions.
Change-Id: Iecf230d493b31ecab25b33c67323987459b23bd7
Reviewed-on: https://code.wireshark.org/review/2242
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-06-16 15:19:48 +00:00
Alexis La Goutte 3170f2e418 Continue to remove $Id$ from top of file
(Using sed : sed -i '/^ \*  \$Id\$/,+1 d') (Double space between star and $Id$)

Change-Id: If9b8f345e3b6493de0b573600e60005c8b0b33c3
Reviewed-on: https://code.wireshark.org/review/877
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-03-31 15:59:51 +00:00
Gilbert Ramirez 4cc694839d Fix all -fstrict-alias warnings found by gcc 4.1.2
The majority of the fixes are for calls to uat_new(). Instead of
having each caller cast its private data to (void**), we use void*
in the uat_new() API itself. Inside uat_new(), we cast the void*
to void**.

Some dissectors use val64_string arrays, so a VALS64() macro was
added for those, to avoid using VALS(), which is useful only for
value_string arrays.

packet-mq.c was changed because dissect_nt_sid() requires
a char**, not a guint**. All other callers of dissect_nt_sid() use
char*'s (and take the address of it) for their local storage. So,
this was changed to follow the other practices.

A confusion between gint and absolute_time_display_e in packet-time.c
was cleared up.

The ugliest fix is the addition of ip6_guint8_to_str(), for exactly
one caller. The caller uses one type of ip6 address byte array,
while ip6_to_str() expects another. This new function is in place
until the various address implementations can be consolidated.

Add VALS64() to the developer documentation.

Change-Id: If93ff5c6c8c7cc3c9510d7fb78fa9108e4552805
Reviewed-on: https://code.wireshark.org/review/48
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-02-03 09:26:10 +00:00
Irene Rüngeler 85d84776b8 Use PT_TXTMOD_NONE for columns that should not be editable.
svn path=/trunk/; revision=53906
2013-12-10 15:33:07 +00:00
Jakub Zawadzki f91eba752b Fix some warnings: cast discards `__attribute__((const))' qualifier from pointer target type
svn path=/trunk/; revision=53875
2013-12-08 23:16:06 +00:00
Jakub Zawadzki bf0de4310b Rename struct _uat_t to epan_uat
Leave typedef (uat_t) unchanged.

svn path=/trunk/; revision=53767
2013-12-03 21:35:36 +00:00
Jakub Zawadzki cedb73c7f7 Dissectors should not use dfilter.h, don't include it.
XXX ncp2222 dissector is using dfilter_compile(), why?

svn path=/trunk/; revision=53766
2013-12-03 21:31:04 +00:00
Jakub Zawadzki ae59b09443 Add missing includes in order to remove exceptions.h from proto.h (next commit).
svn path=/trunk/; revision=53230
2013-11-10 15:59:37 +00:00
Alexis La Goutte a7c7742dc2 Fix (-W)documentation error found by Clang
../../epan/uat.h:245:23: error: empty paragraph passed to '@param' command [-Werror,-Wdocumentation]
 * @param num_items_ptr
   ~~~~~~~~~~~~~~~~~~~^
1 error generated.

svn path=/trunk/; revision=51257
2013-08-10 21:28:25 +00:00
Gerald Combs a05f55bffc Add a UAT dialog. Make UAT preferences uat_t * instead of void *.
C++-ize the UAT headers.

Add an ElidedLabel widget. Use it in the File Set, Profile, and UAT
dialogs.

Update the Qt README.

svn path=/trunk/; revision=50896
2013-07-25 23:49:47 +00:00
Anders Broman d0efafbcb1 From beroset:
remove C++ incompatibilities from UAT_VS_DEF macro and all uses

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

svn path=/trunk/; revision=48259
2013-03-12 06:40:13 +00:00
Balint Reczey 1ebdb2e521 Export libwireshark symbols using WS_DLL_PUBLIC define
Also remove old WS_VAR_IMPORT define and related Makefile magic
everywhere in the project.

svn path=/trunk/; revision=47992
2013-03-01 23:53:11 +00:00
Michael Mann fd44f9a339 Remove C++ incompatibilities in c1222 dissector.
Also addresses an implicit cast in the epan/uat.h file

Bug 8342 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8342)

svn path=/trunk/; revision=47721
2013-02-17 22:15:16 +00:00
Guy Harris 922a57753b Constify the second argument to uat_load(), to squelch some warnings.
svn path=/trunk/; revision=47560
2013-02-08 09:06:08 +00:00
Michael Mann 86d690880f replace "unsigned" datatype with "guint". Some mpeg files needed "unsigned int" instead.
bugs 7825-7827 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7825)

svn path=/trunk/; revision=46928
2013-01-04 05:22:43 +00:00
Guy Harris 8ed7a73e22 Fix a bunch of warnings.
Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
sizeof.

Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
strtol() and strtoul().

Change some data types to avoid those implicit conversion warnings.

When assigning a constant to a float, make sure the constant isn't a
double, by appending "f" to the constant.

Constify a bunch of variables, parameters, and return values to
eliminate warnings due to strings being given const qualifiers.  Cast
away those warnings in some cases where an API we don't control forces
us to do so.

Enable a bunch of additional warnings by default.  Note why at least
some of the other warnings aren't enabled.

randpkt.c and text2pcap.c are used to build programs, so they don't need
to be in EXTRA_DIST.

If the user specifies --enable-warnings-as-errors, add -Werror *even if
the user specified --enable-extra-gcc-flags; assume they know what
they're doing and are willing to have the compile fail due to the extra
GCC warnings being treated as errors.

svn path=/trunk/; revision=46748
2012-12-26 05:57:06 +00:00
Guy Harris 659cf0527a UATs could be put into "categories". The categories were defined only
implicitly by the #define name and string they were defined to; not all
UATs neatly fit into any of the categories, so some of them were put
into categories that weren't obviously correct for them, and one - the
display filter macro UAT - wasn't put into any category at all (which
caused crashes when editing them, as the GUI code that handled UAT
changes from a dialog assumed the category field was non-null).

The category was, in practice, used only to decide, in the
aforementioned GUI code, whether the packet summary pane needed to be
updated or not.  It also offered no option of "don't update the packet
summary pane *and* don't redissect anything", which is what would be
appropriate for the display filter macro UAT.

Replace the category with a set of fields indicating what the UAT
affects; we currently offer "dissection", which applies to most UATs
(any UAT in libwireshark presumably affects dissection at a minimum) and
"the set of named fields that exist".  Changing any UAT that affects
dissection requires a redissection; changing any UAT that affects the
set of named fields that exist requires a redissection *and* rebuilding
the packet summary pane.

Perhaps we also need "filtering", so that if you change a display filter
macro, we re-filter, in case the display is currently filtered with a
display filter that uses a macro that changed.

svn path=/trunk/; revision=43603
2012-07-08 01:00:46 +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
Anders Broman 41cbf49820 Fix a typo.
svn path=/trunk/; revision=42401
2012-05-03 15:31:45 +00:00
Stig Bjørlykke 019008548b Recreate the packet list when changing UAT for header fields.
This fixes a crash when changing settings for fields used as a custom column.

svn path=/trunk/; revision=41840
2012-03-30 08:57:57 +00:00
Guy Harris 6f59700722 Fix usage of g_ascii_strdown() and g_ascii_strup() - they do *not*
modify the string in place, they return a g_mallocated modified version
of the string passed into them.

svn path=/trunk/; revision=40727
2012-01-25 23:03:33 +00:00