Commit Graph

60 Commits

Author SHA1 Message Date
Moshe Kaplan e16166a74c Detect and replace bad allocation patterns
Adds a pre-commit hook for detecting and replacing
occurrences of `g_malloc()` and `wmem_alloc()` with
`g_new()` and `wmem_new()`, to improve the
readability of Wireshark's code, and
occurrences of
`g_malloc(sizeof(struct myobj) * foo)`
with
`g_new(struct myobj, foo)`
to prevent integer overflows

Also fixes all existing occurrences across
the codebase.
2020-12-22 14:56:38 +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
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
Peter Wu 13150c9564 Exported PDU: adjust protocol and tag tree lengths
Change the exported_pdu size from two to the full size of the tag
(including type and length fields) and limit the protocol length to just
the tags (without the PDU data).

Change-Id: I1c20740627ebd74c117bb1735ff4c189d2d750d6
Reviewed-on: https://code.wireshark.org/review/28470
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-06-27 00:34:22 +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 147e491025 Convert PT_EXCHG into using conversation endpoints
Change-Id: Id5857a58513c38dd0ab5b30b61113bcc14e1ecee
Reviewed-on: https://code.wireshark.org/review/24258
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-11-06 15:19:15 +00:00
Michael Mann 23afd28daf Convert TIPC to use endpoint conversations
Change-Id: Iab03ebbfc982bf7182851f63c17fa59bc71d7709
Reviewed-on: https://code.wireshark.org/review/24219
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-11-05 23:17:32 +00:00
Pascal Quantin b227943e66 Exported PDU: apply EXP_PDU_TAG_COL_PROT_TEXT whatever the next_prot_type tag
The include file suggests that it will always fill the protocol column if
present. Let's make that happen.

Change-Id: I265e2f4d1c2dcd7cf2ff121499694cde14a595f3
Reviewed-on: https://code.wireshark.org/review/24220
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2017-11-03 17:46:23 +00:00
Michael Mann 66b441f3d6 Add ability to create endpoints through conversations
Add endpoint information to the packet_info structure for dissectors
to potentially use as their data to create conversations.

This patch includes a simple "example" of using conversation_create_endpoint
with TDMoP.  The assignment of the PT_TDMOP "port type" has been replaced by
setting ENDPOINT_TDMOP within the endpoint structure.  Then when subdissectors
of TDMoP call find_or_create_conversation(), it implicitly picks up the
conversation information set by TDMoP

Change-Id: I11dc29989cccd3b0f0349ee901babb455ca02d19
Reviewed-on: https://code.wireshark.org/review/24190
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Andrew Chernyh <andrew.chernyh@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-11-01 02:41:45 +00:00
Michael Mann d597b5d61e Remove port_type values not set in pinfo->ptype
NCP and SBCCS values used for conversation (endpoints) and not
to pass "type" to subdissectors.

Change-Id: I56a13d2bb7d718b340e9b5a102c43f6e0012bfb9
Reviewed-on: https://code.wireshark.org/review/24174
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-10-30 02:26:59 +00:00
Michael Mann 765a67b68a "Hardcode" the port types used by Export PDU functionality
The "internal" port type has been serialized by export PDU functionality
and nettrace_3gpp_32_423 wiretap.  To better support "endpoint" functionality
the port types will be removed/updated and that changes the implicit values
from the port_type enum.

Take a snapshot of the current port_type values and use those specific values
when reading/writing export PDU data and provide conversion functions that can
be modified when port_types are removed.  Do the same for nettrace_3gpp_32_423
wiretap.

Change-Id: I770bd0cab22e84f3cf49032fc86c5927bf85263f
Reviewed-on: https://code.wireshark.org/review/24169
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-10-29 19:55:24 +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 fab5a74074 Exported PDU: dump payload before calling sub dissector
This way, the payload is displayed even if the sub dissector triggers an exception

Change-Id: Ife062f59035776c4eb9e550eb202a5e40afc4b60
Reviewed-on: https://code.wireshark.org/review/17063
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-08-15 19:04:41 +00:00
Pascal Quantin ede140a46a Exported PDU: fix a typo
While we are at it, let's remove dead code

Change-Id: I3a001f07b9becc885d544551a1fa578642517d08
Reviewed-on: https://code.wireshark.org/review/17061
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2016-08-15 16:44:43 +00:00
Michael Mann edcc2f019e Add OSI Layer 4 to exported PDU to handle TCP and UDP payloads.
This allows for much easier anonymized captures for protocols running
atop TCP/UDP.

Added support for "TCP dissector data" tag within export PDU (34) so that
the tcpinfo struct that TCP dissector normally passes to its subdissectors
can be saved.

Change-Id: Icd63c049162332e5bcb2720159e5cf8aac893788
Reviewed-on: https://code.wireshark.org/review/16285
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-08-01 15:19:59 +00:00
Michael Mann 2ab4155794 tvb_get_string_enc + proto_tree_add_item = proto_tree_add_item_ret_string
Also some other tricks to remove unnecessary tvb_get_string_enc calls.

Change-Id: I2f40d9175b6c0bb0b1364b4089bfaa287edf0914
Reviewed-on: https://code.wireshark.org/review/16158
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2016-06-27 15:20:06 +00:00
Michael Mann 04b82a7dc9 Convert AT_SS7PC to a "dissector address type"
The formatting of the address type is determined by a preference in
packet-mtp3.c, so just make MTP3 register the address type.
Use address_type_get_by_name in other dissectors (and export_pdu)
to use the address type.

Change-Id: Ifb32d7de27aeaa23cee8e803e25ffb3c905547b5
Reviewed-on: https://code.wireshark.org/review/15856
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-06-13 17:06:38 +00:00
AndersBroman 9294f542a0 [Exported PDU] Add filters for ip.addr ip.dest etc for IPv4 and Ipv6 tags.
Change-Id: Id9a7872ed982e3b615563ca8c6b264f2de8be837
Reviewed-on: https://code.wireshark.org/review/15262
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-05-04 13:27:19 +00:00
AndersBroman 7b406ea3ea [Exported PDU] Add the abillity to use dissector tables from the file.
Change-Id: I51ac8ce56641cf6eeda18c2a3f6d6952d3126415
Reviewed-on: https://code.wireshark.org/review/14693
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-03-29 21:25:39 +00:00
Michael Mann 31a54708f4 new_register_dissector -> register_dissector for dissector directory.
Change-Id: Ie39ef054a4a942687bd079f3a4d8c2cc55d5f22c
Reviewed-on: https://code.wireshark.org/review/12485
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-12-09 12:38:06 +00:00
Balint Reczey c297df134b More spelling fixes found by lintian
Change-Id: Id218dec9e5a721d6c63fd34962ffe50b6ab8dd56
Reviewed-on: https://code.wireshark.org/review/11946
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Diederik de Groot <dkgroot@talon.nl>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-11-20 05:47:29 +00:00
Michael Mann 01f7356f85 register_dissector -> new_register_dissector
Picking off "easy" dissectors that only have one or two exit points at most.

Change-Id: I3d5e576b796556ef070bb36d8b55da0b175dcba8
Reviewed-on: https://code.wireshark.org/review/11805
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-11-13 17:44:24 +00:00
João Valverde 3df2333155 Remaining ADDRESS macro to address function conversions
Change-Id: I8bc9af431e70243b05f4f0ce8c2b8ee451383788
Reviewed-on: https://code.wireshark.org/review/11463
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-11-03 12:20:34 +00:00
Gerald Combs 86fe2be4dc Use address functions instead of ADDRESS macros in asn1 and epan
Replace CMP_ADDRESS, COPY_ADDRESS, et al with their lower-case
equivalents in the asn1 and epan directories.

Change-Id: I4043b0931d4353d60cffbd829e30269eb8d08cf4
Reviewed-on: https://code.wireshark.org/review/11200
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-10-22 11:45:56 +00:00
Pascal Quantin 79774329d7 Simply code for export of PDUs coming from heuristic dissectors
Let's use the newly introduced find_heur_dissector_by_unique_short_name() function

Change-Id: I5781b9b2f1ab679da07e97755b71840b4b3a9361
Reviewed-on: https://code.wireshark.org/review/9645
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>
2015-07-15 18:30:57 +00:00
Pascal Quantin cdc7d25004 Add ability to export PDUs for heuristic dissectors also
Change-Id: I1bf1aa9794f9b4f106edffd4986fc0b1014522fa
Reviewed-on: https://code.wireshark.org/review/9099
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-06-25 00:10:13 +00:00
Michael Mann 9c55903029 Use COPY_ADDRESS_SHALLOW instead of duplicating TVB_SET_ADDRESS and SET_ADDRESS calls for the same address.
Change-Id: I0c9cc5d574fdd73ecf1f8b32dbbf0ddb2b885116
Reviewed-on: https://code.wireshark.org/review/7437
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-03-01 12:54:33 +00:00
Michael Mann 4088a8286d SET_ADDRESS -> TVB_SET_ADDRESS to "hide" some of the tvb_get_ptr use.
Not all changes were able to remove their corresponding tvb_get_ptr, because there are other API dependent on the (tvb_get)pointer, but future iterations optimizing those other APIs will then be able to remove it.

Change-Id: Id7cefd440b81834de1d1aace7cd0789b1c871a22
Reviewed-on: https://code.wireshark.org/review/6358
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-01-07 12:37:52 +00:00
Martin Mathieson 48db2548a9 Deleting unneccessary #includes from dissectors.
Second batch (packet-eth.c -> packet-icmpv6.d).

Will look at cleaning up and committing script afterwards.

Change-Id: I14295758b81a59115d8c88899f166cc3d5d17594
Reviewed-on: https://code.wireshark.org/review/6013
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2014-12-23 12:22:54 +00:00
Bill Meier b5d7b7ab6e Cleanup use of #includes in non-generated epan/dissector/*.c
Specifically:
- Set packet.h to be the first wireshark #include after
   config.h and "system" #includes.
   packet.h added as an #include in some cases when missing.
- Remove some #includes included (directly/indirectly) in
   packet.h. E.g., glib.h.
   (Done only for those files including packet.h).
- As needed, move "system" #includes to be after config.h and
   before wireshark #includes.
- Rework various #include file specifications for consistency.
- Misc.

Change-Id: Ifaa1a14b50b69fbad38ea4838a49dfe595c54c95
Reviewed-on: https://code.wireshark.org/review/5923
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-12-21 05:46:22 +00:00
Michael Mann 9d5f9141af Eliminate proto_tree_add_text from some dissectors.
Other minor cleanup while in the area.

Change-Id: Id8d957d3d68a2e3dd5089f490bd59d773e1be967
Reviewed-on: https://code.wireshark.org/review/3427
Reviewed-by: Michael Mann <mmann78@netscape.net>
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>
2014-08-05 07:36:26 +00:00
Pascal Quantin bcff3c57cc Add the ability to dynamically add a new protocol to export PDU dialog box
Change-Id: I83012cc963d514982e40010e837e11a6fcf1bc3e
Reviewed-on: https://code.wireshark.org/review/2423
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-06-19 06:48:32 +00:00
AndersBroman b40b655298 Change tvb_get_string() -> tvb_get_string_enc and ENC_ASCII -> ENC_UTF_8
Change-Id: I07ecca5612ae9fa2b053a62c69014612c5125d5e
Reviewed-on: https://code.wireshark.org/review/962
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-04-04 14:37:02 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Michal Labedzki ff0468f6d3 Add Logcat to Exported PDU
Logcat can be exported from ADB over USB or ADB over TCP where can occur
multiple Logcat PDUs in one frame.

Change-Id: I290fa131e5600c62357e5be4e76096ea5c35364b
Reviewed-on: https://code.wireshark.org/review/234
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-02-18 11:14:01 +00:00
Bill Meier 9d0207ed90 Comment out unused hf[] entries and related found by checkhf.
svn path=/trunk/; revision=54989
2014-01-28 03:06:03 +00:00
Jakub Zawadzki c45475ab45 Fix [-Wmissing-prototypes]
svn path=/trunk/; revision=54135
2013-12-15 23:44:12 +00:00
Jakub Zawadzki 82e2675f45 Avoid including <wiretap/wtap.h> in dissectors.
svn path=/trunk/; revision=53655
2013-11-29 20:53:00 +00:00
Guy Harris dad2b94703 Get rid of unused variable.
svn path=/trunk/; revision=53492
2013-11-21 20:33:28 +00:00
Michael Mann eabaddaca9 Remove ethertype, mpls_label and ppids from packet_info structure.
The information was converted to "proto" data within their respective dissectors strictly for use in "Decode As".

svn path=/trunk/; revision=53489
2013-11-21 20:08:20 +00:00
Pascal Quantin 2f3d057857 Do not add an unknown tag item for End-of-options
svn path=/trunk/; revision=53471
2013-11-21 09:33:01 +00:00
Pascal Quantin 28886d126b Clear protocol column when the dissector is known
svn path=/trunk/; revision=53368
2013-11-16 14:08:03 +00:00
Jeff Morriss a97460a39c Add an item for any unknown tags we come across (just as FT_BYTES).
svn path=/trunk/; revision=53278
2013-11-12 18:57:14 +00:00
Jeff Morriss 64f0cafbad De-duplicate some code by changing a while loop to a do-while loop.
svn path=/trunk/; revision=53277
2013-11-12 18:49:57 +00:00
Jakub Zawadzki 1899903f69 Include <epan/to_str.h> only when needed.
svn path=/trunk/; revision=53189
2013-11-09 13:41:10 +00:00
Bill Meier 2ac134b3c5 whitespace fixes; mostly: remove trailing blanks
svn path=/trunk/; revision=52591
2013-10-13 19:56:52 +00:00
Pascal Quantin a0c53ffaa1 emem -> wmem conversion:
- ep_tvb_get_bits() -> wmem_packet_tvb_get_bits()
- tvb_g_memdup()/ep_tvb_memdup() -> tvb_memdup()
- tvb_fake_unicode()/tvb_get_ephemeral_faked_unicode() -> tvb_get_faked_unicode()
- tvb_get_g_string()/tvb_get_ephemeral_string()/tvb_get_seasonal_string() -> tvb_get_string()
- tvb_get_g_unicode_string()/tvb_get_ephemeral_unicode_string() -> tvb_get_unicode_string()
- tvb_get_ephemeral_string_enc() -> tvb_get_string_enc()
- update docs accordingly

svn path=/trunk/; revision=52172
2013-09-22 15:50:55 +00:00
Martin Kaiser 174fa28a31 support exporting decrypted DVB-CI/CI+ SAC messages
using the new export PDU mechanism

svn path=/trunk/; revision=51019
2013-07-29 20:38:20 +00:00
Pascal Quantin b5187b496b Use newly assigned DLT for PDU export functionality
svn path=/trunk/; revision=50212
2013-06-28 13:05:12 +00:00
Pascal Quantin 014e2deec6 Add export of SS7 OPC/DPC
svn path=/trunk/; revision=50060
2013-06-19 21:49:12 +00:00