Commit Graph

62 Commits

Author SHA1 Message Date
Guy Harris 8195bdd340 Rename a bunch of things with "conversation".
A conversation in Wireshark might have two endpoints or might have no
endpoints; few if any have one endpoint.  Distinguish between
conversations and endpoints.
2022-08-25 20:02:20 -07:00
Gerald Combs 8020aea27a epan: Fix our conversation flags
Make sure we pass NO_ADDR2 and NO_PORT2 to conversation_new and
NO_ADDR_B and NO_PORT_B to find_conversation.
2022-05-15 16:36:43 +00:00
John Thacker b80cdaa243 libgcrypt: Require version 1.8.0
Libgcrypt 1.8.x is required for a large amount of decryption
support and is the current LTS version of libgcrypt. The 1.6 and
1.7 series have been end-of-life since 2017-06-30 and 2019-06-30,
respectively.

The Linux distributions that have versions of libgcrypt before 1.8.0
are nearing or at end of support (RHEL7, SLES 12, Debian stretch,
Ubuntu 16.04LTS) and can be supported by the Wireshark 3.6 LTS release
series.

Remove an enormous amount of ifdefs based on libgcrypt versions
1.6.0, 1.7.0, and 1.8.0. There will be a second pass for the
commons defines HAVE_LIBGCRYPT_AEAD, HAVE_LIBGCRYPT_CHACHA20, and
HAVE_LIBGCRYPT_CHACHA20_POLY1305, which are now always defined.

The ISAKMP dissector has some comments noting that some workarounds
were used for libgcrypt 1.6 that aren't needed with 1.7; perhaps
that could be updated now.
2022-04-20 21:30:21 -04:00
Guy Harris 66accecf3e dof: clean up adding the session key to the dissection.
Let the libwireshark code format the value of the session key, by
setting its display format to SEP_COLON.

Use proto_tree_add_bytes_with_length(), so that the session key becomes
the value of the field; otherwise, the length of the key isn't
specified.

This means we don't need to call bytestring_to_str() (the code in
epan/proto.c calls it for us).

This also plugs a leak of the string generated by bytestring_to_str().
2021-05-22 03:00:39 -07:00
Guy Harris 57a1514ac7 Cast away the return value of g_strlcpy() and g_strlcat().
Most of the time, the return value tells us nothing useful, as we've
already decided that we're perfectly willing to live with string
truncation.  Hopefully this keeps Coverity from whining that those
routines could return an error code (NARRATOR: They don't) and thus that
we're ignoring the possibility of failure (as indicated, we've already
decided that we can live with string truncation, so truncation is *NOT*
a failure).
2021-04-30 03:19:19 -07:00
Martin Mathieson 2753c4c27e Expert info: check group and severity
Add a check for valid group and severity values, and fix violations foud.
2021-03-09 19:14:29 +00:00
Martin Mathieson 0cf834f909 Make some more variables and functions static. 2021-02-14 19:42:01 +00:00
Martin Mathieson b8a773dddc Fix some spelling errors in dissector strings.
A first batch of spelling errors, detected using a script that uses
pyspellcheck and a Wireshark-specific dictionary file.
2020-08-29 19:31:11 +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
Moshe Kaplan fd7895d37c Replace instances of wmem_alloc with wmem_new
This commit replaces instances of
  (myobj *)wmem_alloc(wmem_file_scope(), sizeof(myobj))
and replaces them with:
  wmem_new(wmem_file_scope(), myobj)
to improve the readability of Wireshark's code.

The replacement locations were identified with grep
and replaced with the Python script below.

grep command:
  egrep "wmem_alloc0?\(wmem_file_scope\(\), sizeof\([a-z_]+\)\)" . -R -l

python script:

import re
import sys
import fileinput

pattern = r'\(([^\s]+) ?\*\) ?wmem_alloc(0?)\((wmem_[a-z]+_scope\(\)), sizeof\(\1\)\)'
replacewith = r'wmem_new\2(\3, \1)'

fname = sys.argv[1]

for line in fileinput.input(fname, inplace=1, mode='rb'):
    output = re.sub(pattern, replacewith, line)
    sys.stdout.write(output)

Change-Id: Ieac246c104bf01e32cbc6e11e53e81c7f639d870
Reviewed-on: https://code.wireshark.org/review/37158
Petri-Dish: Pascal Quantin <pascal@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
2020-05-07 14:47:54 +00:00
Moshe Kaplan b869452ba3 packet-dof.c: Remove fprintf
d5fc969e57 removed
stdio.h's include. The missing stdio.h broke
the CentOS7 build. This commit removes calls to
fprintf to fix the CentOS7 build.

Change-Id: I3f93973ae6901a30414a75a8156967a0e470db90
Reviewed-on: https://code.wireshark.org/review/37137
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-05-07 03:47:02 +00:00
Jaap Keuter d5fc969e57 No explicit glib.h include required
Stop including glib.h in dissectors, this will come in implicitly with
packet.h including proto.h, an essential include file for dissectors.
While at it, config.h is no longer conditional and stdio.h is usually
not needed either. Some other cleanups too.

Change-Id: I60c12f16d7ef1e6398509293031ffed7460d2c61
Reviewed-on: https://code.wireshark.org/review/36969
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Petri-Dish: Jaap Keuter <jaap.keuter@xs4all.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2020-05-01 21:28:27 +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
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
Gerald Combs b572b65e51 DOF: Fix alias binding dissection.
When adding generated IID and OID bytes to the tree, use a zero offset
and length like we do elsewhere in the dissector.

Bug: 15617
Change-Id: Id900f2aeeef7926706b417622d452ffa72949e8a
Reviewed-on: https://code.wireshark.org/review/32698
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2019-04-04 23:31:49 +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 1ce2918fc8 dof: don't use src/dst addresses if they don't exist.
Bug: 15617
Change-Id: I1177e704d33626d126b7e835e5a8db3162847fbf
Reviewed-on: https://code.wireshark.org/review/32442
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-03-24 17:48:01 +00:00
Guy Harris 7eb3e47fa4 Try to squeeze some bytes out of the frame_data structure.
Make the time stamp precision a 4-bit bitfield, so, when combined with
the other bitfields, we have 32 bits.  That means we put the flags at
the same structure level as the time stamp precision, so they can be
combined; that gets rid of an extra "flags." for references to the flags.

Put the two pointers next to each other, and after a multiple of 8 bytes
worth of other fields, so that there's no padding before or between them.

It's still not down to 64 bytes, which is the next lower power of 2, so
there's more work to do.

Change-Id: I6f3e9d9f6f48137bbee8f100c152d2c42adb8fbe
Reviewed-on: https://code.wireshark.org/review/31213
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-12-27 04:34:29 +00:00
Peter Wu f618fcd3af dof: remove unnecessary uat_load calls
UATs are loaded at startup, no need to do it again. Call chain:
epan_load_settings -> read_prefs -> init_prefs -> uat_load_all.

Change-Id: I57caabafb16b0b46fcb6d1621dd6b503154c805c
Reviewed-on: https://code.wireshark.org/review/30958
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-12-07 14:05:02 +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
Guy Harris aa6d5ee1a7 Use the time stamps in the packet_info structure, not the frame_data structure.
In the long run, we'd like to remove the time stamp from the frame_data
structure, as, in Wireshark, and in TShark in two-pass mode, there's one
allocated for every frame in the file, and shrinking the size of that
structure reduces the memory usage.

This removes one obstacle to that.

Change-Id: Ia8f87522cd974555c57e0ac1e742b097e8b0f2fc
Reviewed-on: https://code.wireshark.org/review/29881
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-09-26 20:34:21 +00:00
Pascal Quantin 4536696507 DOF: restore correct memory scope for decrypted buffer
Change-Id: I143f73f7921187bac5de46cd07344b015a06a578
Reviewed-on: https://code.wireshark.org/review/26420
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-03-11 06:39:12 +00:00
Dario Lombardo b99b9b81dd dof: use tvb_memdup instead of g_memdup.
Change-Id: I0d1e6a09fa6fcf09c40c6e77b79cc97e0723bff5
Reviewed-on: https://code.wireshark.org/review/26144
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-03-04 18:52:12 +00:00
Dario Lombardo 07bb8fc047 dof: don't initialize nonce it is useless.
Change-Id: I300145c04293fa06ea6af0a5797d27023c3b2fbc
Reviewed-on: https://code.wireshark.org/review/26177
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-28 15:06:16 +00:00
Dario Lombardo 95e33c7097 dof: use g_malloc0 to prevent uninitialized memory (found by clang).
Change-Id: Iac8b077e7223668b58158a29628748aae85ed73e
Reviewed-on: https://code.wireshark.org/review/25885
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
2018-02-21 21:51:12 +00:00
Dario Lombardo fe219637a6 dissectors: use SPDX identifiers.
Change-Id: I92c94448e6641716d03158a5f332c8b53709423a
Reviewed-on: https://code.wireshark.org/review/25756
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-12 16:49:58 +00:00
Michael Mann abfb644117 Add conversation endpoint type
For the moment this mirrors the port_type enumeration (PT_XXX), but the
intent is to move away from using "port types", eliminating most (if not
all)

Added conversation_pt_to_endpoint_type() so that conversations deal with the
correct enumeration.  This is for dissector that use pinfo->ptype as input
to conversation APIs.  Explicit use of port types are converted to using
ENDPOINT_XXX type.

Change-Id: Ia0bf553a3943b702c921f185407e03ce93ebf0ef
Reviewed-on: https://code.wireshark.org/review/24166
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-10-29 16:53:57 +00:00
Michael Mann 7dbc520d57 Privatize the conversation_key structure
The intention is to make it more transparent when making a switch
to an "endpoint" over address/port combination.

Change-Id: Ic424c32095ecb103bcb4f7f4079c549de2c8d9c4
Reviewed-on: https://code.wireshark.org/review/24148
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-10-28 19:22:24 +00:00
Michael Mann 23afd9a184 Convert to using find_conversation_pinfo where appropriate
This makes it easier to identify the simpler/common conversations

Change-Id: I7094f23e49156ee27f5f72c8e130308470f3e462
Reviewed-on: https://code.wireshark.org/review/24145
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-10-28 14:33:11 +00:00
Ahmad Fatoum 9d49e13166 Remove superfluous null-checks before strdup/free
NULL checks were removed for following free functions:

- g_free "If mem is NULL it simply returns"
  https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html#g-free

- g_slist_free(_full)? "NULL is considered to be the empty list"
  https://developer.gnome.org/glib/stable/glib-Singly-Linked-Lists.html

- g_strfreev "If str_array is NULL, this function simply returns."
  https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strfreev

- g_slice_free "If mem is NULL, this macro does nothing."
  https://developer.gnome.org/glib/stable/glib-Memory-Slices.html#g-slice-free

- g_match_info_free "not NULL... otherwise does nothing"
  https://developer.gnome.org/glib/stable/glib-Perl-compatible-regular-expressions.html#g-match-info-free

- dfilter_free defined in Wireshark code. Returns early when passed NULL
  epan/dfilter/dfilter.c

They were also removed around calls to g_strdup where applicable:

- g_strdup "If str is NULL it returns NULL."
  https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strdup

Change-Id: Ie80c2db89bef531edc3aed7b7c9f654e1d654d04
Reviewed-on: https://code.wireshark.org/review/23406
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2017-10-15 12:38:51 +00:00
Björn Ruytenberg 6fdf8eb5a9 DOF: Fix buffer overflow (read)
Perform sanity check on buffer length parsed from data. Check buffer
size before reading value.

Change-Id: I8beaf8860b39426d79867b0dd2221e57e32da8e0
Link: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1151
Bug: 13608
Reviewed-on: https://code.wireshark.org/review/21287
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-04-23 00:29:50 +00:00
Stig Bjørlykke 9d1f2efa51 Use col_append_sep_str() for fixed strings
Change from col_append_sep_fstr() to col_append_sep_str() when
appending strings without formatting.

Change-Id: I315aca9b815c204a5bc78f7326402c40d1325f0e
Reviewed-on: https://code.wireshark.org/review/20846
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>
2017-04-02 16:40:28 +00:00
erikdejong fe285c640b Replace aes.c and des.c by Libgcrypt
Follow-up of https://code.wireshark.org/review/20095

Rewritten functions:
- crypt_des_ecb

crypt_des_ecb verified against previous crypt_des_ecb implementation with
4294967295 random keys and input buffers from /dev/random as I cannot find a
suitable pcap which uses DES

Change-Id: I21ec2572451e0ded4299ffadd8dd687817bc6318
Reviewed-on: https://code.wireshark.org/review/20429
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2017-03-10 02:54:51 +00:00
Alexis La Goutte c1e6724cf6 dissectors: fix this statement may fall through [-Werror=implicit-fallthrough=] found by gcc7
Change-Id: Iba6238988ded675cba328ab512232d1919d93b4a
Reviewed-on: https://code.wireshark.org/review/20415
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-03-05 22:39:13 +00:00
Pascal Quantin 78d168fcbb DOF: ensure to return a value different from 0 when asking for more data
Bug: 13453
Change-Id: I331fb5f662f152c9c16b0d8ccbe228cded8ca85d
Reviewed-on: https://code.wireshark.org/review/20389
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2017-03-05 11:17:40 +00:00
Pascal Quantin c3dde590d8 DOF: fix an infinite loop in sid_buffer_hash_fn()
The sid buffer can contain up to 255 bytes of data, so the loop counter must
be a guint16 at least.

Bug: 13453
Change-Id: I997ce1a737532d94796586d7e109d89b2dc1911b
Reviewed-on: https://code.wireshark.org/review/20388
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2017-03-05 11:15:55 +00:00
Peter Wu 6b84ddee83 Make Libgcrypt a mandatory dependency
Removed all guards for HAVE_LIBGCRYPT, change autotools and CMake to
error out if it is not available. Update release notes, developer
documentation and README with the new status. Clarify relation with
GnuTLS in macosx-setup.sh. Install Libgcrypt via brew script.

Motivation for this change is that many dissectors depend on Libgcrypt
and having it optional increases the maintenance burden (there have been
several compile issues in the past due to the optional status).
Furthermore, wsutil has crypto code that can be replaced by Libgcrypt.

Change-Id: Idf0021b8c4cd5db70b8766f7dcc2a8b3acbf042f
Link: https://www.wireshark.org/lists/wireshark-dev/201702/msg00011.html
Reviewed-on: https://code.wireshark.org/review/20030
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2017-02-13 18:35:47 +00:00
Dario Lombardo f6d9f7fb30 dof: free more memory on shutdown.
Change-Id: Ic4604cc2f999f4e669af00e37dad9b60cb06e599
Reviewed-on: https://code.wireshark.org/review/19977
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-09 18:12:56 +00:00
Dario Lombardo 19ba947d9a dof: add shutdown routine.
Change-Id: I91bc792302f61fd8f20fa41ec067534316e26074
Reviewed-on: https://code.wireshark.org/review/19742
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-02-08 17:10:28 +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
Guy Harris 0ecfc7280c Use tvb_new_subset_remaining() rather than tvb_new_subset_length_caplen().
Any call of the form tvb_new_subset_length_caplen(tvb, offset, -1, -1)
should instead be tvb_new_subset_remaining(tvb, offset).

Change-Id: I4bc95b028103ea4fc82453ef3460c147d7ccabd6
Reviewed-on: https://code.wireshark.org/review/19598
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-01-10 06:40:45 +00:00
Guy Harris 7cd6906056 Rename tvb_new_subset() to tvb_new_subset_length_caplen().
This emphasizes that there is no such thing as *the* routine to
construct a subset tvbuff; you need to choose one of
tvb_new_subset_remaining() (if you want a new tvbuff that contains
everything past a certain point in an existing tvbuff),
tvb_new_subset_length() (if you want a subset that contains everything
past a certain point, for some number of bytes, in an existing tvbuff),
and tvb_new_subset_length_caplen() (for all other cases).

Many of the calls to tvb_new_subset_length_caplen() should really be
calling one of the other routines; that's the next step.  (This also
makes it easier to find the calls that need fixing.)

Change-Id: Ieb3d676d8cda535451c119487d7cd3b559221f2b
Reviewed-on: https://code.wireshark.org/review/19597
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-01-10 06:19:37 +00:00
Michael Mann f4b0abc729 Dissectors don't need a journey of self discovery.
They already know who they are when they register themselves.  Saving the
handle then to avoid finding it later.
Not sure if this will increase unnecessary register_dissector functions
(instead of using create_dissector_handle in proto_reg_handoff function)
when other dissectors copy/paste, but it should make startup time
a few microseconds better.

Change-Id: I3839be791b32b84887ac51a6a65fb5733e9f1f43
Reviewed-on: https://code.wireshark.org/review/19481
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-12-31 07:31:42 +00:00
Pascal Quantin 7c3ecc6956 DOF: fix UAT update callbacks
- update callback must return a boolean to indicate success / failure
- error message must be allcoated in glib memory as GUI will g_free it

Bug: 13209
Change-Id: Ibb9690034d66dae85e775d0010aadeb192c76b4a
Reviewed-on: https://code.wireshark.org/review/19111
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-12-06 16:05:23 +00:00
Michael Mann 9b25c5ebf7 Fix lintian found spelling error "identifer" -> "identifier"
Change-Id: I78281ce097e36df546338a5dacb03a11bedd2b24
Reviewed-on: https://code.wireshark.org/review/18642
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-11-03 02:31:36 +00:00
Michael Mann 2eb7b05b8c Convert most UDP dissectors to use "auto" preferences.
Similar to the "tcp.port" changes in I99604f95d426ad345f4b494598d94178b886eb67,
convert dissectors that use "udp.port".

More cleanup done on dissectors that use both TCP and UDP dissector
tables, so that less preference callbacks exist.

Change-Id: If07be9b9e850c244336a7069599cd554ce312dd3
Reviewed-on: https://code.wireshark.org/review/18120
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-10-13 02:51:18 +00:00
Michael Mann 268841f3e0 Combine Decode As and port preferences for tcp.port dissector table.
This patch introduces new APIs to allow dissectors to have a preference for
a (TCP) port, but the underlying data is actually part of Decode As functionality.
For now the APIs are intentionally separate from the regular APIs that register a
dissector within a dissector table.  It may be possible to eventually combine the
two so that all dissectors that register with a dissector table have an opportunity
to "automatically" have a preference to adjust the "table value" through the
preferences dialog.

The tcp.port dissector table was used as the guinea pig.  This will eventually be
expanded to other dissector tables as well (most notably UDP ports).  Some
dissectors that "shared" a TCP/UDP port preference were also converted. It also
removed the need for some preference callback functions (mostly when the callback
function was the proto_reg_handoff function) so there is cleanup around that.

Dissectors that has a port preference whose default was 0 were switched to using
the dissector_add_for_decode_as_with_preference API rather than dissector_add_uint_with_preference

Also added comments for TCP ports used that aren't IANA registered.

Change-Id: I99604f95d426ad345f4b494598d94178b886eb67
Reviewed-on: https://code.wireshark.org/review/17724
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-10-08 02:44:53 +00:00
AndersBroman 0b3d679368 Don't call proto_register_field_array() or expert_register_protocol() with
proto = -1

Change-Id: I60f899ad748b5d3e17f237552af7d2dbc8f27bd2
Reviewed-on: https://code.wireshark.org/review/17864
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-09-22 14:13:12 +00:00
Pascal Quantin 22257e8cf5 p_XXX_proto_data: only allow the use of pinfo and file scopes
Those are the only ones meaningful. Let's convert the buggy dissectors
and add an assert to avoid the misuse of the pool parameter in the future

Change-Id: I65f470b757f163f11a25cd352ffe168d1f8a86d3
Reviewed-on: https://code.wireshark.org/review/17748
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2016-09-17 15:46:36 +00:00
Guy Harris a4c8ebc18b Don't do any Decode As stuff for dissector tables not used with Decode As.
Have all dissector tables have a "supports Decode As" flag, which
defaults to FALSE, and which is set to TRUE if a register_decode_as()
refers to it.

When adding a dissector to a dissector table with a given key, only add
it for Decode As if the dissector table supports it.

For non-FT_STRING dissector tables, always check for multiple entries
for the same protocol with different dissectors, and report an error if
we found them.

This means there's no need for the creator of a dissector table to
specify whether duplicates of that sort should be allowed - we always do
the check when registering something for "Decode As" (in a non-FT_STRING
dissector table), and just don't bother registering anything for "Decode
As" if the dissector table doesn't support "Decode As", so there's no
check done for those dissector tables.

Change-Id: I4a1fdea3bddc2af27a65cfbca23edc99b26c0eed
Reviewed-on: https://code.wireshark.org/review/17402
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-08-31 00:08:01 +00:00