Commit Graph

487 Commits

Author SHA1 Message Date
AndersBroman 754cce9531 Add ENC_APN_STR to handle APN strings 2021-05-20 09:27:53 +00:00
Nicolás Alvarez ebfbf958f6 Add ENC_TIME_NSECS timestamp encoding
Add a new timestamp encoding format ENC_TIME_NSECS, like ENC_TIME_SEC but
for nanosecond values. Needed for my work-in-progress dissector for Apple
push notifications.
2021-02-10 12:45:54 +00:00
João Valverde 89fee9321e Avoid exposing HAVE_PLUGINS in the public API
Instead *_register_plugin() is turned into a noop (with a warning).

The test suit is failing with ENABLE_PLUGINS=Off (it was already failing
before and this patch didn't affect that).

Closes #17202.
2021-02-06 16:35:51 +00:00
Nicolás Alvarez 981e662a0a Minor changes to ENC_TIME documentation
- Fix duplicate "are are".
- Fix NTP epoch year in ENC_TIME_NTP docs (572b80d2 fixed it in the README
  but not in proto.h).
- Remove completely redundant "(ie. )" clauses.
2021-02-04 10:13:36 +00:00
Nicolás Alvarez 0e86ea6c57 Update documentation for ENC_TIME_* constants
ENC_TIME_MIP6 and ENC_TIME_CLASSIC_MAC_OS_SECS were added recently by
factoring them out of specific dissectors, but they weren't documented.
I added documentation, based on comments in the dissector code they came
from.
2021-02-03 21:03:11 -03:00
João Valverde be0171019c UDP: Clean up handling of zero-valued UDP checksums
Replace the somewhat weird field format
    "[Checksum: [missing]]"
with
    "Checksum: 0x0000 [ignored or illegal value]"

Improve code redability and fix XXX comment.
2021-01-27 16:46:15 +00:00
Jaap Keuter a260f6a4e0 Correct comment on expert values 2021-01-17 20:08:10 +00:00
Anders Broman 9a46fabf52 Introduce ENC_BCD_ODD_NUM_DIG in order to handle odd number of digits 2020-12-10 16:02:10 +01:00
Alexis La Goutte f71458c601 proto(.h): fix -Wdocumentation
proto.h:2373:9: warning: parameter 'fi' not found in the function declaration [-Wdocumentation]
2020-11-23 20:06:49 +00:00
Gerald Combs 3a7966c716 Qt+epan: Print better-looking values in the packet diagram.
Pull the value-formatting code in proto_custom_set into
proto_item_fill_display_label. Use that in FieldInformation::toString
instead of fvalue_to_string_repr. Fixes #16911.
2020-11-13 19:41:51 +00:00
John Thacker 524a28c4b1 QT/CLI: Move max tree items and depth to prefs
Move the maximum number of tree items and maximum tree depth to
preferences instead of hardcoded values. Refer to issue #12584 for
an example VNC capture where real data exceeds the current limit.
2020-10-23 04:18:36 +00:00
John Thacker e20bd408de Use iconv to support GB 18030 and EUC-KR, allow future encodings
Add support internally to using iconv (always present with glib) to convert
strings from various encodings to UTF-8 (using REPLACEMENT CHARACTER as
recommended), and use that to support GB 18030 and EUC-KR. Replace call
directly to iconv in ANSI 637 for EUC-KR to new API. Update comments
and documentation around character encodings. It is possible to replace
the calls to iconv with an internal decoder later. Tested on Linux and
on Windows (including with illegal characters). Closes #16630.
2020-10-21 11:26:23 +00:00
Guy Harris 5dd6fc9459 Add proto_tree_add_item_ret_ipv4().
Change some guint32's to ws_in4_addr while we're at it.
2020-10-11 17:54:58 -07:00
Guy Harris e013c5ec7f Clean up URLs.
Add ui/urls.h to define some URLs on various of our websites.  Use the
GitLab URL for the wiki.  Add a macro to generate wiki URLs.

Update wiki URLs in comments etc.

Use the #defined URL for the docs page in
WelcomePage::on_helpLabel_clicked; that removes the last user of
topic_online_url(), so get rid of it and swallow it up into
topic_action_url().
2020-10-02 20:13:42 -07:00
Guy Harris c597927da8 Add some more string encodings.
Add an encoding for "unpacked" 3GPP TS 23.038 7-bit strings, in which
each code position is in a byte of its own, rather than with the code
positions packed into 7 bits.  Rename the packed encoding to explicitly
indicate that it's packed.

Add an encoding for ETSI TS 102 221 Annex A strings.

Use the new encodings.
2020-09-28 22:30:35 +00:00
Guy Harris 272502790b Add FT_STRINGZTRUNC.
FT_STRINGZPAD is for null-*padded* strings, where the field is in an
area of specified length, and, if the string is shorter than that
length, all bytes past the end of the string are NULs.

FT_STRINGZTRUNC is for null-*truncated* strings, where the field is in
an area of specified length and, if the string is shorter than that
length, there's a null character (which might be more than one byte, for
UCS-2, UTF-16, or UTF-32), and anything after that is not guaranteed to
have any particular value.

Use IS_FT_STRING() in some places rather than enumerating all the string
types, so that those places get automatically changed if the set of
string types changes.
2020-09-12 14:16:12 -07:00
Gerald Combs c2075185de epan: Fixup proto_item_set_bits_offset_len.
Export proto_item_set_bits_offset_len and fix

In file included from ../epan/dfilter/dfilter.h:18:
../epan/proto.h:1113:11: warning: parameter 'bits_offset' is already documented [-Wdocumentation]
 * @param bits_offset The new length in bits.
          ^~~~~~~~~~~
../epan/proto.h:1112:5: note: previous documentation
 * @param bits_offset The number of bits from the beginning of the field.
    ^     ~~~~~~~~~~~

Change-Id: Ib171ce38607b9656baea5eb7a3e6aee3b99ddbac
Reviewed-on: https://code.wireshark.org/review/38115
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>
2020-08-11 03:25:17 +00:00
Gerald Combs 9b07412277 Qt: Add a packet diagram view.
Add a new top-level view that shows each packet as a series of diagrams
similar to what you'd find in a networking textook or an RFC.

Add proto_item_set_bits_offset_len so that we can display some diagram
fields correctly.

Bugs / to do:
  - Make this a separate dialog instead of a main window view?
  - Handle bitfields / flags

Change-Id: Iba4897a5bf1dcd73929dde6210d5483cf07f54df
Reviewed-on: https://code.wireshark.org/review/37497
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>
2020-08-10 18:17:50 +00:00
Guy Harris 2356415cfe libwireshark: define ENC_ANTI_HOST_ENDIAN in epan/proto.h.
We have two places where we want to dissect some fields as being in the
opposite byte ordere from the host on which we're running; move the
definition of ENC_ANTI_HOST_ENDIAN from packet-socketcan.c to proto.h,
and use it in packet-enc.c.

Change-Id: I1d0f9b037fe3b8ca6ed774a11063ba518a3922bf
Reviewed-on: https://code.wireshark.org/review/38023
Petri-Dish: Guy Harris <gharris@sonic.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <gharris@sonic.net>
2020-08-02 08:30:09 +00:00
Guy Harris e1d9a226a2 Fix the type of arrays of pointers to hf_ values for bitfield routines.
The static arrays are supposed to be arrays of const pointers to int,
not arrays of non-const pointers to const int.

Fixing that means some bugs (scribbling on what's *supposed* to be a
const array) will be caught (see packet-ieee80211-radiotap.c for
examples, the first of which inspired this change and the second of
which was discovered while testing compiles with this change), and
removes the need for some annoying casts.

Also make some of those arrays static while we're at it.

Update documentation and dissector-generator tools.

Change-Id: I789da5fc60aadc15797cefecfd9a9fbe9a130ccc
Reviewed-on: https://code.wireshark.org/review/37517
Petri-Dish: Guy Harris <gharris@sonic.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-06-19 11:32:26 +00:00
Guy Harris e4aeb1d2bb Clean up the encoding value definitions.
Group them by the data types for which they're used, starting with the
byte-order definitions which (with the inclusion of ENC_NA) are used
with all types.

Put all the ones used for strings together, starting with the character
encodings, with the Zigbee flag and the flags for "this is a string but
we're going to interpret it as a byte array or time stamp".

Make ENC_CHARENCODING_MASK equal to ENC_STR_MASK; no, there's no reason
for ENC_STR_MASK to replace ENC_CHARENCODING_MASK - the opposite should
happen, as ENC_CHARENCODING_MASK at least specifies what the bits set in
it are used for, namely character encodings.  If all #defines for
strings should have _STR_ in them, start with the character encoings.

Change-Id: I072420f313086153b4ea4034911fc293453dea00
Reviewed-on: https://code.wireshark.org/review/36962
Petri-Dish: Guy Harris <gharris@sonic.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <gharris@sonic.net>
2020-04-28 06:05:52 +00:00
Alexis La Goutte 9eaf9a5648 proto(.h): fix parameter (it is pi not it) like on proto.c
Change-Id: I3cc02538e3a9293e2fd3af7feaee59ef360ca8da
Reviewed-on: https://code.wireshark.org/review/36956
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-04-28 04:02:25 +00:00
Alexis La Goutte ca4cc6a34f proto(.h): fix -Wdocumentation
parameter 'ti' not found in the function declaration [-Wdocumentation]

Change-Id: I4080cf118c3a81fd47fd4c32e8809d83256893dd
Reviewed-on: https://code.wireshark.org/review/36955
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-04-27 14:33:18 +00:00
Guy Harris 524baee94f Add string encoding values for various BCD encodings, and use them.
Add some ENC_ values for various flavors of packed BCD, and use that
instead of explicitly calling tvb_bcd_dig_to_wmem_packet_str() and
adding the result.

Change-Id: I07511d9d09c9231b610c121cd6ffb3b16fb017a9
Reviewed-on: https://code.wireshark.org/review/36952
Reviewed-by: Guy Harris <gharris@sonic.net>
2020-04-27 01:53:09 +00:00
Guy Harris 9f03cde5a5 Add a routine to get the representation of a protocol tree item and use it.
Add proto_item_get_display_repr(), which returns a string, allocated
with a specified wmem scope, containing the display representation of
the value of a proto_item.

Use it in the LLDP dissector, to append that string to the parent
protocol tree item; use packet scope, so it doesn't hang around forever
(the previous code used the NULL scope, meaning explicit freeing was
required, but it wasn't explicitly freeing the value, so it was
leaking).

Change-Id: I146380118833b1daef9dea8bd9463001e5b9325f
Reviewed-on: https://code.wireshark.org/review/36931
Petri-Dish: Guy Harris <gharris@sonic.net>
Reviewed-by: Guy Harris <gharris@sonic.net>
2020-04-25 06:27:53 +00:00
Guy Harris fc31446277 Add support for "classic Mac OS" timestamps and use them in file-mp4.c.
Those times are in seconds since January 1, 1904, 00:00:00 (proleptic?)
UTC.

MPEG-4 Part 14 (MP4) is based on QuickTime, so it uses classic Mac OS
time stamps, in seconds.

Change-Id: Ibcd7faf1b119d8acbb294c95b66ca0d1fb70cbb3
Reviewed-on: https://code.wireshark.org/review/35886
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2020-01-21 20:54:25 +00:00
Jaap Keuter f9c2bdc413 Implement all mapping macros for the new proto tree API
The new proto tree API uses mapping macros to map calls to the
proto_tree_add_* functions. These were defined for the up til then
in use functions. In the mean time functions have been added and
workarounds for non mapped functions were used.
This change adds the missing mapping macros so that now all
proto_tree_add_* functions taking a hfi address are mapped properly.
Also fix two dissectors that failed the mapping.

Change-Id: I91d800439fe2c4487ca53c00c44d7aa46ce70e1d
Reviewed-on: https://code.wireshark.org/review/35743
Petri-Dish: Jaap Keuter <jaap.keuter@xs4all.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
2020-01-11 08:02:30 +00:00
Gerald Combs 2ff32787c5 epan: Make proto_tree_add_oid* usable from DLLs.
Prefix proto_tree_add_oid, proto_tree_add_oid_format_value, and
proto_tree_add_oid_format with WS_DLL_PUBLIC.

Change-Id: Ia3fa8fb762869bb1afa1c1f57a3a5f02aa126a3f
Reviewed-on: https://code.wireshark.org/review/35018
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
2019-11-07 16:43:43 +00:00
Stig Bjørlykke 551745998e wslua: Fix memleak of unregistered ProtoField strings
If a ProtoField object was created, but not linked to a Proto, then the
strings field and all elements (depending on type) would leak.

This is a follow-up to g79fef2ae and fixes the real issue in g44870fb1.

Change-Id: I01880a92bb20fae45f68c754b07daeb07630deec
Reviewed-on: https://code.wireshark.org/review/34872
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Vasil Velichkov <vvvelichkov@gmail.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
2019-10-28 15:05:54 +00:00
Michael Mann 168ee5003f kafka: Cleanup to use "native" APIs.
Add "native" support for the "zig-zag" version of a varint in proto.[ch] and
tvbuff.[ch].  Convert the use of varint in the KAFKA dissector to use the (new)
"native" API.

Ping-Bug: 15988
Change-Id: Ia83569203877df8c780f4f182916ed6327d0ec6c
Reviewed-on: https://code.wireshark.org/review/34386
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-09-05 03:25:39 +00:00
Michael Mann 01d7793976 Add proto_tree_add_item_ret_time_string
A few dissectors need the functionality of adding a time field to a proto_tree
while also needing the "time to string" value (typically to show on a tree above).
The functionality to do "get value from tvb and convert to string" was being done
in packet-ntp.c.
Instead proto_tree_add_item_ret_time_string can be used with various encoding to
get the necessary functionality with less code duplication.

ENC_TIME_MIP6 was added as a result of the refactoring.
ABSOLUTE_TIME_NTP_UTC was added as another potential "base" type for time fields.

Change-Id: Ie460c33370b0af59ef60bdab893ce9d6eb23b94f
Reviewed-on: https://code.wireshark.org/review/34390
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-08-29 13:31:48 +00:00
Guy Harris e26e0b4de0 Add support for the ISO 646 "Basic code table" encoding.
The "Basic code table" in ISO 646 is mostly ASCII, but some code points
either 1) have more than one glyph that can be assigned to them or 2)
have no glyph assigned to them.  National versions choose one of the two
glyphs for the code points in group 1) and assign specific glyphs to the
code points in group 2); the International Reference Version assigns the
same glyphs to those code points as does ASCII.

For the "Basic code table" encoding, we map the code points in groups 1)
and 2) to a REPLACEMENT CHARACTER; additional encodings can be added for
the national versions.

Add ENC_ISO_646_IRV (International Reference Version) as an alias for
ENC_ASCII.

Expand some comments, and add some comments, while we're at it.

Change-Id: I4f1b5e426ec193775e919731c5cae1224dc65115
Reviewed-on: https://code.wireshark.org/review/33941
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-15 07:50:30 +00:00
Anders Broman 496fe3dfbf Doxygen: Fix some warnings.
Change-Id: I0344d44d08d2e159c895d693500403c067039a44
Reviewed-on: https://code.wireshark.org/review/33894
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-07-11 11:03:00 +00:00
Anders Broman f7cf0b7ec7 Doxygen: Try to fix reported warnings.
Change-Id: Ia2e08265681c6700328a5782a70c3108eeb443bf
Reviewed-on: https://code.wireshark.org/review/33887
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-07-10 12:48:21 +00:00
Guy Harris 1c601c204a Have routines to add a protocol tree item and return a display string.
That way, even if we're not building a protocol tree, so that you don't
get protocol tree items, you can get the display string, e.g.  to use in
a column.

Replace the use of the "get display string" routines with calls to those
routines.

Change-Id: I23e3e88838bdf837d8660c271f78c79b7d1c5620
Reviewed-on: https://code.wireshark.org/review/33519
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-06-08 09:11:22 +00:00
Guy Harris ee35570e90 Improve handling of binary data that *might* be text.
Add a BASE_SHOW_ASCII_PRINTABLE flag for the "display" field, to use
with FT_BYTES and FT_UINT_BYTES fields; it specifies that, if the field
consists solely of printable ASCII characters, its value be displayed as
a string, in quotes.  Have a routine hfinfo_format_bytes() to do that
formatting, depending on the display field value.

Add routines to fetch the display value of string and
FT_BYTES/FT_UINT_BYTES fields; for strings, it's the result of
hfinfo_format_text(), and for byte arrays, it's the result of
hfinfo_format_bytes().

Use BASE_SHOW_ASCII_PRINTABLE for extended attribute data in SMB and
SMB2.  Use the routines in question for extended attribute names
(string) and data (bytes).  That keeps us from displaying non-text
extended attribute data as if it were text.

Document BASE_SHOW_ASCII_PRINTABLE.

Change-Id: I24dcf459c14f00985e4daaf9b58f5933964eabd8
Reviewed-on: https://code.wireshark.org/review/33517
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-06-07 21:15:23 +00:00
Guy Harris 03c5da8d89 Add Windows code page 1252.
While we're at it, add the Euro to code page 1251, expand the comments
for 1250 and 1251 and some DOS code pages, and add support for code page
1251 to tvb_get_stringz_enc().

Change-Id: I053d58f87cac26ad7c109e2f1cd8807ffec0622d
Reviewed-on: https://code.wireshark.org/review/33342
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-05-25 01:07:36 +00:00
Guy Harris 1fd3003a6d "Zigbee" encoding is not a character encoding or an integer encoding.
It's a rule for interpretation of the length field of counted-string and
counted-octet-string fields.  This means it's 1) not a general rule for
interpreting integers and 2) not a character encoding, as it also
applies to octet strings and, even for character strings, it's
*orthogonal* to the character encoding.

Therefore, it should *not* be one of the character encoding values; it
should be a bit flag.

Make it so.  This means that

1) a character encoding can be specified for Zigbee Cluster Library
strings (they appear to have multiple character encodings possible);

2) the test of it that tested it as if it were a flag will no longer get
confused by character encodings that set one or more of the bits in the
old encoding value;

3) you don't have to special-case the encoding value passed to
get_uint_value().

Put in a comment emphasizing that values that aren't character encodings
should *not* be placed in the set of character encodings.

Change-Id: I8f50aaee8ca60b0781044287e9b38111de38c81f
Reviewed-on: https://code.wireshark.org/review/33341
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-05-24 21:26:16 +00:00
Alexis La Goutte ef44a8151a proto.h: avoid warning about not really deprecated (Clang) (v2)
proto.h:853:5: warning: declaration is marked with '\deprecated' command but does not have a deprecation attribute [-Wdocumentation-deprecated-sync]
proto.h:866:5: warning: declaration is marked with '\deprecated' command but does not have a deprecation attribute [-Wdocumentation-deprecated-sync]

Change-Id: I50a462c7a05f36ba60484980fd8ae9026effc047
Reviewed-on: https://code.wireshark.org/review/32922
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-04-26 11:56:37 +00:00
Alexis La Goutte ae3e6712f3 proto.h: avoid warning about not really deprecated (Clang)
proto.h:853:5: warning: declaration is marked with '\deprecated' command but does not have a deprecation attribute [-Wdocumentation-deprecated-sync]
proto.h:866:5: warning: declaration is marked with '\deprecated' command but does not have a deprecation attribute [-Wdocumentation-deprecated-sync]

Change-Id: I6da6048b2c4e2860f655ae595f4f800587c63217
Reviewed-on: https://code.wireshark.org/review/32770
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-04-07 18:37:14 +00:00
Gerald Combs 8d3ac3af86 epan: Convert our PROTO_ITEM_ macros to inline functions.
Convert our various PROTO_ITEM_ macros to inline functions and document
them.

Change-Id: I070b15d4f70d2189217a177ee8ba2740be36327c
Reviewed-on: https://code.wireshark.org/review/32706
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-04-04 04:03:38 +00:00
Dario Lombardo e984cdeb22 proto.h: fix indentation and add modeline.
Change-Id: I1d1adb6456c4a80f2a157cb29dc19c63755ee3fd
Reviewed-on: https://code.wireshark.org/review/31485
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-01-13 07:12:31 +00:00
kanidef 5fa9257704 add encoding windows 1251, cp855, cp866
Change-Id: I0e8507cf63d89942167ca579ef304bc3d679346e
Reviewed-on: https://code.wireshark.org/review/31316
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-01-04 23:37:17 +00:00
Peter Wu 656cc19fc7 Replace JSON-GLib by custom JSON dumper library
The (optional) JSON-GLib library adds dependencies on GObject, GIO. For
statically linked oss-fuzz builds it also adds libffi and more. To avoid
these dependencies, replace JSON-GLib by some custom code. This allows
`tshark -G elastic-mapping` to be enabled by default without extra deps.

API design goals of the new JSON dumper library:

- Small interface without a lot of abstraction.
- Avoid memory allocations if possible (currently none, but maybe
  json_puts_string will be replaced to improve UTF-8 support).
- Do not implement parsing, this is currently handled by jsmn.

Methods to open/close array/objects and to set members are inspired by
the JsonGlib interface. The interfaces to write values is inspired by
the sharkd code (json_puts_string is also borrowed from that).

The only observed differences in the tshark output:
- JSON-GLib ignores duplicates, json_dumper does not and may produce
  duplicates and currently print two "ip.opt.sec_prot_auth_unassigned".
- JSON-GLib adds a space before a colon (unimportant formatting detail).
- (Not observed, but UTF-8 strings will be wrong like bug 14948.)

A test was added to catch changes in the tshark output. I also fuzzed
json_dumper with libFuzzer + UBSAN/ASAN and fixed an off-by-one error.

Change-Id: I0c85b18777b04d1e0f613a3d59935ec59be87ff4
Link: https://www.wireshark.org/lists/wireshark-dev/201811/msg00052.html
Reviewed-on: https://code.wireshark.org/review/30732
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-20 05:03:56 +00:00
Pascal Quantin a99bba4c7c Fix "Follow TLS Stream" after ssl -> tls rename
Change-Id: I53be2ae6fae135b2da98ae95deac535bcd37af74
Reviewed-on: https://code.wireshark.org/review/30473
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-11-01 17:09:33 +00:00
Pascal Quantin 4a5812aca2 Revert "FT_BYTES: fix dissection of FT_BYTES when using SEP_SPACE and "NONE" options"
This reverts commit 0457e60419.

Change-Id: Id39722872efbe98648754d7543da7ae5b08f8b67
Reviewed-on: https://code.wireshark.org/review/30451
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-11-01 07:49:02 +00:00
Jeremy Martin 0457e60419 FT_BYTES: fix dissection of FT_BYTES when using SEP_SPACE and "NONE" options
SEP_SPACE and BASE_NONE both default to colon (:).  Fix SEP_SPACE and add SEP_NONE

Bug: 15253
Change-Id: Ib5db997714414370b08ffb9458c73d4aeef6aacf
Reviewed-on: https://code.wireshark.org/review/30447
Reviewed-by: Jeremy Martin <boardermartin@gmail.com>
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-01 06:25:31 +00:00
Richard Sharpe 6eba988f7c wslua: Add support for base.RANGE_STRING handling.
A range string is passed as a table of tables, eg:

  range_string = {
     { 0, 24, "Some string for values 0 to 24" },
     { 25, 25, "The string for value 25" },
     { 26, 255, "The string for the remainder" }
  }

Included is a minimal Lua test for range strings and value strings
(which did not have one previously.) It will take more time than I
currently have to figure out how to do a more exhaustive test.

Also fixed some grammar issues in error messages along the way.

Change-Id: Ia9d1efc8adabb6528c4bdcf1624c9ede49e2fdc6
Reviewed-on: https://code.wireshark.org/review/30211
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
2018-10-17 20:08:57 +00:00
Peter Wu f3296cdbb6 proto.h: add type checks for VALS/VALS64/VALS_EXT_PTR/TFS/RVALS
These macros were evil as they silently ignored bad casts. Together with
an updated checkAPIs.pl, this should reduce the likelihood of errors.

Change-Id: I40ecc48a57b2061b4c65db4f4f7fffff21f159a8
Reviewed-on: https://code.wireshark.org/review/29757
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-09-20 20:59:57 +00:00
Gerald Combs ef01359849 Add support for protocol aliases. Switch BOOTP to DHCP.
Add support for aliasing one protocol name to another and for filtering
using aliased fields. Mark aliased fields as deprecated.

Rename the BOOTP dissector to DHCP and alias "bootp" to "dhcp". This
lets you use both "dhcp.type" and "bootp.type" as display filter fields
without having to duplicate all 500+ DHCP/BOOTP fields.

To do:
- Add checks to proto.c:check_valid_filter_name_or_fail?
- Transition SSL to TLS.
- Rename packet-bootp.c to packet-dhcp.c?

Change-Id: I29977859995e8347d80b8e83f1618db441b10279
Ping-Bug: 14922
Reviewed-on: https://code.wireshark.org/review/29327
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-08-31 05:25:17 +00:00