Commit Graph

264 Commits

Author SHA1 Message Date
João Valverde 02238edf92 Do not require using wsgcrypt.h
The reason to use wsgcrypt.h was to wrap it around DIAG_OFF()
macros and that should no longer be necessary.
2023-02-06 15:52:10 +00:00
João Valverde b07ab25a1c CMake: Cleanup unnecessary linking with shared libraries 2023-02-06 15:04:46 +00:00
João Valverde 7e6266d33d MSYS2: Add Lua 5.1 support and fix test suite failures 2023-01-16 11:54:43 +00:00
Sake Blok f870c6085d epan: Allow nested dependent packets
Save all dependent frames when there are multiple levels
of reassembly.

This is a retry of !6329, combined with the fix in !6509 which
were reverted in !6545.

epan: fix a segfault, introduced in !6329
2023-01-06 23:15:48 +00:00
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
João Valverde caacdae870 epan: Add a post_init() plugin routine
Epan plugins init runs before proto_init() to setup for that but there
is also a need to have a routine that runs at the end of epan_init(),
which can do pretty much anything using epan, like runnning tests.
2022-06-02 14:11:17 +00:00
Gerald Combs 87b0288b8d epan: Add the ability to add conversation filter protocols.
Convert our conversation protocols to a dynamic list and add
add_conversation_filter_protocol(). Use it in the Falco Bridge plugin to
add protocols with conversation filters.
2022-04-19 22:25:32 +00:00
João Valverde 842f53c329 Revert "epan: Allow nested dependent packets"
This reverts commit 2d8607e7e0.

This reverts commit be915d7374.

Introduces a segmentation fault, needs more work.
2022-03-28 12:40:21 +00:00
Sake Blok be915d7374 epan: Allow nested dependent packets
Save all dependent frames when there are multiple levels
of reassembly.
2022-03-06 23:43:03 +00:00
John Thacker cbf76ea22f Export PDU: Allow native encapsulations / strip headers
Allow export PDU taps to be registered with a wiretap encapsulation
instead of always using WTAP_ENCAP_WIRESHARK_UPPER_PDU. This allows
creating normal capture files that aren't tied to wireshark without
having to do a "editcap -C -L -T", as well as creating files in
formats other than pcapng and pcap with tshark.

Provide a couple sample implementations in Ethernet (WTAP_ENCAP_ETHERNET)
and IP (v4 and v6, WTAP_ENCAP_RAW_IP) that are the most common use cases.
(I can imagine a few others; WTAP_ENCAP_MPEG_2_TS could probably be
useful, for example.) Fixes #15141
2022-02-25 20:29:16 -05:00
David Perry e2fab18853 wsutil: New API to gather compile/runtime info 2022-02-24 13:27:08 +00:00
João Valverde 12d39efdca Revert "epan: Initialize wiretap"
This reverts commit c15f2aadc1.

Crashes on exit. Needs more work.

Fixes #17821.
2022-01-01 16:23:04 +00:00
João Valverde c15f2aadc1 epan: Initialize wiretap
Clients of libwireshark should not be required to initialize
explicitly wiretap, if they don't use it themselves.
2021-11-27 08:41:01 +00:00
João Valverde b9f2e4b7fa Make PCRE2 a required dependency 2021-11-14 21:00:59 +00:00
João Valverde ed8a02af17 dfilter: Add support for PCRE2
PCRE2 is the future of PCRE. The only advantage of GRegex is that
it comes bundled with GLib, which is not an advantage at all.
PCRE2 is widely available, the GRegex abstractions layer are not a
good fit and abstract things that don't need abstracting or that we
could handle better ourselves, there are open bugs (#12997) and
maintenance is spotty at best.

GRegex comes with many of the problems of bundled code, aggravated by
the fact that it completely falls outside of our control.
2021-11-14 21:00:59 +00:00
Gerald Combs 87b84b7813 Lua is a proper name. Fix its capitalization. 2021-11-11 01:08:51 +00:00
Brian Sipos abd0f1183f COSE dissector from dtn-wireshark project 2021-09-29 08:51:13 +00:00
João Valverde 750cc38669 epan: Remove some extraneous #ifdefs
If a macro identifier is not defined it evaluates to zero in an
expression, so the outer #ifdef is unnecessary and should be
avoided (the less the better).

Add a missing CMake comment while here.
2021-09-18 23:25:31 +01:00
Toni Uhlig a823e34642 Fix build error if ENABLE_SMI=OFF
* introduced with 9b13c4352d
 * HAVE_SMI_VERSION_STRING is always defined if libsmi found

Change-Id: I50480d37a3a6f31bcfe768f030af9176213b7366
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-09-17 19:29:48 +00:00
João Valverde 2cb1eb955f epan: Rename SMI dependency to "libsmi" 2021-09-16 00:42:03 +01:00
João Valverde 133b0c583f Move epan/wmem/wmem_scopes.h to epan/
This header was installed incorrectly to epan/wmem_scopes.h.

Instead of creating additional installation rules for a single
header in a subfolder (kept for backward compatibility) just
rename the standard "epan/wmem/wmem.h" include to
"epan/wmem_scopes.h" and fix the documentation.

Now the header is installed *correctly* to epan/wmem_scopes.h.
2021-07-26 14:56:11 +00:00
João Valverde 7f9c1f5f92 Move wmem to wsutil
This allows wmem to be used from other libraries, namely wsutil.
It is often the case that a funtion exists in wsutil and cannot
be used with a wmem scope, requiring some code duplication or
extra memory allocations, or vice-versa, code in epan cannot be
moved to wsutil because it has a wmem dependency.

To this end wmem is moved to wsutil. Scope management remains part
of epan because those scope semantics are specific to dissection.
2021-07-26 14:56:11 +00:00
Guy Harris dd5907d2a3 Consistently refer to blocks that have been modified as "modified".
"User" sounds as if the blocks belong to the user; at most, the current
user might have modified them directly, but they might also have, for
example, run a Lua script that, unknown to them, modified comments.
Also, a file might have "user comments" added by a previous user, who
them wrote the file and and provided it to the current user.

"Modified" seems a bit clearer than "changed".
2021-07-08 00:05:35 -07:00
David Perry 73087d6fb4 Use wtap_blocks for packet comments
Mostly functioning proof of concept for #14329. This work is intended to
allow Wireshark to support multiple packet comments per packet.

Uses and expands upon the `wtap_block` API in `wiretap/wtap_opttypes.h`.
It attaches a `wtap_block` structure to `wtap_rec` in place of its
current `opt_comment` and `packet_verdict` members to hold OPT_COMMENT
and OPT_PKT_VERDICT option values.
2021-07-07 18:40:24 +00:00
João Valverde 3a3fda2ca4 epan: Remove dependency on version_info object library
Dependending on version_info is unnecessary and forces an epan
rebuild every time the git commit id changes, which can be slow,
especially with LTO enabled, and again is unnecessary.

Printing the VCS version to the TLS debug log is a minor convenience
that doesn't justify the cost to relink epan with every commit.
2021-07-04 10:37:49 +00:00
João Valverde 0e50979b3f Replace g_assert() with ws_assert() 2021-06-19 01:23:31 +00:00
João Valverde 39df3ae3c0 Replace g_log() calls with ws_log() 2021-06-16 12:50:27 +00:00
João Valverde dc7f0b88bb Refactor our logging and extend the wslog API
Experience has shown that:

  1. The current logging methods are not very reliable or practical.
A logging bitmask makes little sense as the user-facing interface (who
would want debug but not crtical messages for example?); it's
computer-friendly and user-unfriendly. More importantly the console
log level preference is initialized too late in the startup process
to be used for the logging subsystem and that fact raises a number
of annoying and hard-to-fix usability issues.

  2. Coding around G_MESSAGES_DEBUG to comply with our log level mask
and not clobber the user's settings or not create unexpected log misses
is unworkable and generally follows the principle of most surprise.
The fact that G_MESSAGES_DEBUG="all" can leak to other programs using
GLib is also annoying.

  3. The non-structured GLib logging API is very opinionated and lacks
configurability beyond replacing the log handler.

  4. Windows GUI has some special code to attach to a console,
but it would be nice to abstract away the rest under a single
interface.

  5. Using this logger seems to be noticeably faster.

Deprecate the console log level preference and extend our API to
implement a log handler in wsutil/wslog.h to provide easy-to-use,
flexible and dependable logging during all execution phases.

Log levels have a hierarchy, from most verbose to least verbose
(debug to error). When a given level is set everything above that
is also enabled.

The log level can be set with an environment variable or a command
line option (parsed as soon as possible but still later than the
environment). The default log level is "message".

Dissector logging is not included because it is not clear what log
domain they should use. An explosion to thousands of domains is
not desirable and putting everything in a single domain is probably
too coarse and noisy. For now I think it makes sense to let them do
their own thing using g_log_default_handler() and continue using the
G_MESSAGES_DEBUG mechanism with specific domains for each individual
dissector.

In the future a mechanism may be added to selectively enable these
domains at runtime while trying to avoid the problems introduced
by G_MESSAGES_DEBUG.
2021-06-11 09:40:28 +00:00
João Valverde 9b13c4352d epan: Add SMI version 2021-05-25 20:10:37 +01:00
João Valverde ea424f881f epan: Add c-ares version 2021-05-25 18:54:21 +01:00
João Valverde d0717c151a epan: Add nghttp2 version 2021-05-25 18:54:14 +01:00
João Valverde 9ae2820ff3 epan: Remove some superfluous calls 2021-05-25 18:54:04 +01:00
João Valverde ab4a2aa0f2 epan: Add some minimum version checks 2021-05-25 13:15:47 +00:00
David Perry 32cc1c7906 Remove use of PACKAGE_VERSION in maxminddb version 2021-05-19 17:16:01 +00:00
David Perry a1ba9453ef Add version info for lz4, zstd, maxmind
This simply implements the patches given in a comment on bug 16270.
<https://gitlab.com/wireshark/wireshark/-/issues/16270#note_400748726>
2021-05-19 13:38:25 +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
Stig Bjørlykke 3dc5f5c2d6 epan: Keep decode_as_list when changing profile
The decode_as_list is built at startup and contains all protocols
registered for "decode as". Do not clear this list on profile change,
only on exit.

Bug: 16635
Change-Id: I832a042327603ae0f01b10ab620fccc03d4fd3a3
Reviewed-on: https://code.wireshark.org/review/37579
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2020-06-29 18:40:27 +00:00
Gerald Combs 451a241e50 Add c-ares to the required library list.
Although c-ares support was techically optional, it was either on by
default or required in all of our packaging. Go ahead and require it
globally. C-ares is widely available and synchronous name resolution can
easily result in a horrific user experience.

Change-Id: Id67c797316ed6b8a0ab5052e55a43a1b9e2a2464
Reviewed-on: https://code.wireshark.org/review/35188
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2019-11-23 22:45:59 +00:00
Stig Bjørlykke a673a50ad8 epan: Rename dissector_filters.c to conversation_filter.c
For the same reason as in g89c9d909.

Change-Id: I5e344ebdf8ba05d169484aa32b409d84edc6124f
Reviewed-on: https://code.wireshark.org/review/34943
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-11-04 10:17:16 +00:00
Anders Broman 98cda1bf46 Load environment vars to globals for efficency.
These environment variables are read very frequently, read them once to
globals for performance improvment.

Change-Id: I4f05a5edca85b370674cc5f85fce40bd1af695cb
Reviewed-on: https://code.wireshark.org/review/34449
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-09-04 12:31:53 +00:00
Piotr Smolinski ad94c4d459 Kafka: include zstd compression in Kafka message batches
Change-Id: I1d06486ccf7b174ee9aa621fa3d8acb8b3673777
Reviewed-on: https://code.wireshark.org/review/34222
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-08-20 13:50:45 +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
João Valverde 1d1679f061 Extend epan library plugins with a tap registration callback
tap_register_plugin() is not sufficient for an extension language
implementation because the epan plugin is initialized before
proto_init(), therefore before dissectors have registered taps.

Change-Id: Ief213f85ff4f7182f9af985e5f45476355cc2b86
Reviewed-on: https://code.wireshark.org/review/34048
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2019-07-21 22:46:57 +00:00
Dániel Bakai 9ce60b173b Add brotli decompression support for HTTP and HTTP2 dissectors.
Change-Id: I9c09f55673187f6fee723fcd72798fb6b9958b03
Reviewed-on: https://code.wireshark.org/review/32745
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-04-22 15:24:46 +00:00
Dario Lombardo 77b7b021b9 epan: add missing include.
Fix broken compilation on fedora28.

Change-Id: Ib2c4ec3b2437bab0b8bf35e8a3c8072cf1c0f996
Reviewed-on: https://code.wireshark.org/review/31772
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Vasil Velichkov <vvvelichkov@gmail.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2019-01-28 16:43:47 +00:00
Stig Bjørlykke 6cab8c57bd funnel: Fix memleaks in funnel_remove_menu
The loop to remove all matching callbacks was skipping every second
entry which would give some leaks when reloading Lua plugins.

Add funnel_cleanup() to be called in epan_cleanup() at shutdown
to remove all allocated menu entries.

Change-Id: I3a50ba2070c8675fee1385f25e9e109db57c2dc5
Reviewed-on: https://code.wireshark.org/review/31769
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2019-01-28 10:57:30 +00:00
Peter Wu 03e13a6a9f wslua: fix memleaks related to Proto and Pref
Proto objects were only freed while reloading Lua plugins, be sure to
release these on program exit too. Fix missing deallocation of heur_list
(matches per-protocol cleanup in proto_cleanup_base).

Be sure to keep a reference to the "Pref" object after registering it to
a Proto, otherwise it could be garbage-collected early, resulting in
memleaks (because the preference was still in use).

Fixes a lot of memory leaks reported by ASAN for tests, ten tests were
affected by Proto_new leaks, four were affected by the new_pref leaks.

Change-Id: Ica52718849a33eda614775f533dc0fcefec9cc74
Reviewed-on: https://code.wireshark.org/review/31746
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-27 09:43:05 +00:00
Peter Wu ac58eafa32 Add support for RSA decryption using PKCS #11 tokens
Add support for loading RSA private key files from PKCS #11 tokens,
identified by PKCS #11 URIs. Add a new 'pkcs11_libs' UAT which can
dynamically load PKCS #11 provider libraries that are not found by
p11-kit.

The configuration GUI will need additional code to discover available
PKCS #11 tokens and will be added later.

This feature requires GnuTLS 3.4 with PKCS #11 support, so Windows,
macOS via Homebrew, Ubuntu 16.04, Debian Stretch. Not supported: RHEL7.
Currently macOS via official packages disables PKCS #11 support, so that
will also not work.

Change-Id: I20646bfd69c6bd13c8c2d27cb65c164a4b0b7a66
Reviewed-on: https://code.wireshark.org/review/30855
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-12-29 10:40:16 +00:00
Peter Wu df7af28f39 Add new Secrets API and allow TLS to use pcapng decryption secrets
Add a new secrets API to the core, one that can outlive the lifetime of
a single capture file. Expose decryption secrets from wiretap through a
callback and let the secrets API route it to a dissector.

Bug: 15252
Change-Id: Ie2f1867bdfd265bad11fc58f1e8d8e7295c0d1e7
Reviewed-on: https://code.wireshark.org/review/30705
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-20 05:14:35 +00:00
Gerald Combs 8f08a4e74e Try to discourage the use of APIs via counting.
Add the ability to specify maximum function counts for each group to
checkAPIs. Add maximum counts for the "termoutput" and "abort" groups
where needed. Show summaries in various checkAPI targets.

Switch uses of ws_g_warning back to plain g_warning.

Change-Id: I5cbddc8c671729e424eed8551f69116d16491976
Reviewed-on: https://code.wireshark.org/review/29721
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-09-19 16:07:03 +00:00