Commit Graph

33 Commits

Author SHA1 Message Date
João Valverde 041aa24a37 ftypes: Rewrite FT_PROTOCOL comparison operator
For efficiency do the comparison in a single function call
instead of trying to preserving exactly the previous semantics.

Still I tried not to deviate much.
2021-10-10 20:48:29 +00:00
João Valverde 13e9e7199c ftypes: Use an order function to compare ftypes
All the order operators can be defined in terms of 'lt'
and 'eq' so use that to reduce the number of required
methods from 6 to 2.

Further reduce to one by combining those two into a single
function that has memcmp semantics: negative return is
"less than", positive is "greater than" and zero is equal.
2021-10-10 20:48:29 +00:00
João Valverde 24fd8c6740 Move more numerical epan/*to_str() routines to wsutil 2021-09-16 18:21:14 +01:00
João Valverde c3bd5c9d91 Move bytes_to_str() to wsutil
This utility function is useful outside of epan. Move it to wsutil
and export the interface.

The move isn't completely clean as it requires duplicating two small
inline functions but that was necessary to avoiding moving too much at
once.
2021-07-29 17:23:04 +00:00
João Valverde 0e50979b3f Replace g_assert() with ws_assert() 2021-06-19 01:23:31 +00:00
John Thacker 31297dbb82 ftype-protocol: Fix crash when comparing _ws.expert to literals
The ftype-protocol has two components to its value - a tvb, which is
allowed to be be NULL (most notably in _ws.expert), and a string
description. They can also be created from string literals, such as
in display filters. It's possible to compare protocols with a NULL
tvb with protocol terms created from literals, e.g. entering the
display filter "_ws_expert < 1".

Partially revert 69e2603c48 so that
this doesn't crash, by assigning proto_string to the empty string
instead of null when creating from a literal. Fixes #17316
2021-05-24 22:37:56 +00:00
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
Guy Harris b61fd6d76a dfilter, ftypes: get rid of FT_PCRE.
It's not a valid field type, it's only a hack to support regular
expression matching in packet-matching expressions.

Instead, in the packet-matching code, have a separate syntax tree type
for Perl-compatible regular expressions, and a separate instruction to
load one into a register, and have the "matching" operator for field
types take a GRegex * as the second argument.
2021-03-21 03:27:44 -07: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 8c31cdc13c ftype-protocol: do not return from TRY/CATCH
TRY/CATCH are macros, before returning the ENDTRY block must be executed
or the weirdest crashes can occur.

Change-Id: Ic56871322f8567263e2b8a81cce5a3c7042301b7
Fixes: v2.1.0rc0-2939-g5493fe0167 ("Convert ftype-tvbuff.c to ftype-protocol.c")
Reviewed-on: https://code.wireshark.org/review/30095
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-10 04:03:15 +00:00
Peter Wu 69e2603c48 ftypes: fix memleak when converting protocol values
When converting byte array strings to a FT_PROTOCOL value (for example,
when using a display filter such as `eth contains aa:bb`), the converted
memory in GByteArray was not freed. If an error occurred (the value
cannot be parsed as hex string), then an error message was leaked.

Fix the above issues and avoid an unnecessary g_memdup.

Change-Id: I3a076b3a2384b1a0e15ea8518f2e0f66a7b6ea49
Reviewed-on: https://code.wireshark.org/review/27130
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-04-25 06:55:52 +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 2d0ae39bd6 ftypes: move get_value_ptr into the union
Delete get_value_ptr from struct _ftype_t, make it
part of the get_value union.

Change-Id: I947331069662a7043bd838e622d286629cc7be9a
Reviewed-on: https://code.wireshark.org/review/20647
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-03-20 17:01:10 +00:00
Martin Kaiser c258b6b056 ftypes: move get_value_uinteger into the union
Delete get_value_uinteger from struct _ftype_t, make it
part of the get_value union.

Change-Id: I4a6c8341676c442e2bf8ae3b8f771b72161d133c
Reviewed-on: https://code.wireshark.org/review/20640
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-03-20 01:28:42 +00:00
Martin Kaiser e94bd9b4ee ftypes: move get_value_sinteger into the union
Delete get_value_sinteger from struct _ftype_t, make it
part of the get_value union.

Change-Id: I3127252cafc62389ce426639992f1d59f7ac9731
Reviewed-on: https://code.wireshark.org/review/20637
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-03-19 22:53:57 +00:00
Martin Kaiser 5d9cfea5d9 ftypes: move get_value_uinteger64 into the union
Delete get_value_uinteger64 from struct _ftype_t, make it
part of the get_value union.

Change-Id: I2b06efb7691c1bd4089994849373ab8b5ff0bcc7
Reviewed-on: https://code.wireshark.org/review/20618
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-03-19 15:01:09 +00:00
Martin Kaiser 5bb8f1a241 ftypes: move get_value_sinteger64 into the union
Delete get_value_sinteger64 from struct _ftype_t, make it
part of the get_value union.

Change-Id: I0113f70ab0aadd1aa655466e896e3acce6c8faeb
Reviewed-on: https://code.wireshark.org/review/20617
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-03-19 13:47:57 +00:00
Martin Kaiser 74e793e8ba ftypes: create a get_value union, move get_value_floating into the union
Change-Id: I6bbaf6a7c8a3124e5eab7a7b97c6be082fe8beff
Reviewed-on: https://code.wireshark.org/review/20611
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-03-19 12:08:33 +00:00
Martin Kaiser a126c8093d ftypes: rename get_value to get_value_ptr
This is in preparation for introducing a get_value union, similar to
set_value.

Change-Id: Id0cf913a616e0314638f1531836c3136ed02631d
Reviewed-on: https://code.wireshark.org/review/20610
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
2017-03-18 23:18:16 +00:00
Martin Kaiser b8ede14d44 ftypes: move set_value_floating into the union
Delete set_value_floating from struct _ftype_t, make it
part of the set_value union.

Change-Id: Ic00e1c70488ddc4422c34657c62af7dc07db02d9
Reviewed-on: https://code.wireshark.org/review/20556
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-03-15 11:24:10 +00:00
Martin Kaiser 5f4f62bde0 ftypes: move set_value_sinteger64 into the union
Delete set_value_sinteger64 from struct _ftype_t, make it
part of the set_value union.

Change-Id: I76668f0a6455c5d75c703cd4f440757601246bdb
Reviewed-on: https://code.wireshark.org/review/20551
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-03-14 23:40:10 +00:00
Martin Kaiser b11d4e7ed0 ftypes: move set_value_uinteger64 into the union
Delete set_value_uinteger64 from struct _ftype_t, make it
part of the set_value union.

Change-Id: I12407b7336282daa60fe6e0e742d65e205dc84fd
Reviewed-on: https://code.wireshark.org/review/20539
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-03-14 12:09:16 +00:00
Martin Kaiser a6d69084dc ftypes: move set_value_sinteger into the union
Delete set_value_sinteger from struct _ftype_t, make it part of the
set_value union.

Change-Id: I084c4c9beba9978b538d359ebaac21391ebd7f82
Reviewed-on: https://code.wireshark.org/review/20523
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-03-13 11:39:43 +00:00
Martin Kaiser 9e82cffeea ftypes: move set_value_uinteger into the union
Delete set_value_uinteger from struct _ftype_t, make it part of the
set_value union.

Change-Id: I26de15be8ea0ede76236a8f8a4958bfd97ad9d52
Reviewed-on: https://code.wireshark.org/review/20521
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-03-13 03:06:31 +00:00
Martin Kaiser 8b11bc7b04 ftypes: move set_value_protocol into the union
Delete set_value_protocol from struct _ftype_t, make it part of the
set_value union.

Change-Id: Iae55388b8a2c965944028499619282c3232c31f3
Reviewed-on: https://code.wireshark.org/review/20475
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-03-10 02:35:21 +00:00
Martin Kaiser 3bcda66971 ftypes: move set_value_string into the union
Delete set_value_string from struct _ftype_t, make it part of the
set_value union.

Change-Id: Ia3a57245330ed0d158c8c3e4552ec5d80752fe0f
Reviewed-on: https://code.wireshark.org/review/20474
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-03-10 02:35:00 +00:00
Martin Kaiser abcaf3e370 ftypes: move set_value_time into the union
Delete set_value_time from struct _ftype_t, make it part of the
set_value union.

Change-Id: Ieee3b083d52afdd608e31e8ca75b50016fec8a69
Reviewed-on: https://code.wireshark.org/review/20442
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: Peter Wu <peter@lekensteyn.nl>
2017-03-09 23:06:44 +00:00
Martin Kaiser d7fc8abc94 ftypes: move set_value_guid into the union
Delete set_value_guid from struct _ftype_t, make it part of the
set_value union.

Change-Id: I3a04ff6b1ab179063ef77a3c475809df0bde5c68
Reviewed-on: https://code.wireshark.org/review/20441
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
2017-03-08 16:03:53 +00:00
Martin Kaiser da78a59744 ftypes: move set_value_bytes into the union
Delete set_value_bytes from struct _ftype_t, make it part of the
set_value union.

Change-Id: I3ee6a9f68b269ee083794947816e13ea6c1b9d29
Reviewed-on: https://code.wireshark.org/review/20440
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
2017-03-08 14:36:08 +00:00
Martin Kaiser 25015a00a3 ftypes: create a set_value union
struct _ftype_t contains a number of pointers to set_value_...()
functions. For each pre-defined ftype_t, only one of these pointers
is != NULL.

As the comment already says, we should move these functions into a
union. ftenum_t ftype will be used for selecting the correct function
pointer from the union.

Create a set_value union and move the FvalueSetByteArrayFunc pointer
into the union. Update fvalue_set_byte_array() accordingly. Check
that the fvalue_t parameter is of the correct type.

Change-Id: I6568d8f47108311289c0cd425f28ea8b38046141
Reviewed-on: https://code.wireshark.org/review/20433
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
2017-03-07 21:55:22 +00:00
João Valverde 5932044112 ftype-protocol: Fix [-Wcast-qual] warnings
Change-Id: Ia8a02d8dc66aead486c8ae3f0bdf4cd82717ed20
Reviewed-on: https://code.wireshark.org/review/15817
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-06-10 23:43:10 +00:00
Michael Mann 4d3df66af4 Give FvalueToStringRepr a length parameter.
This allows the conversion of a few straggler strcpy calls
in ftype library. Also provides a more accurate size value
instead of the many hard coded values the ftypes were using.

Change-Id: Ia6273980432e16ad3a6233816a6054d9fed5d2a4
Reviewed-on: https://code.wireshark.org/review/15344
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-05-10 22:49:25 +00:00
Michael Mann 5493fe0167 Convert ftype-tvbuff.c to ftype-protocol.c
As noted in https://www.wireshark.org/lists/wireshark-dev/201604/msg00103.html
a protocol field isn't really a tv_buff, so allow for the possibility
of a NULL tv_buff in a "protocol type".  If the tvb is NULL, use the
string of the protocol field for comparison

Bug: 12335
Change-Id: Ie12a5f7b31c7293c61006b0f70135d100a97c4e0
Reviewed-on: https://code.wireshark.org/review/15261
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-05-05 19:27:55 +00:00