Commit Graph

149 Commits

Author SHA1 Message Date
John Thacker 55ffdb08bb conversation: Remove conversation from the correct table
In conversation_set_addr2, if the existing conversation has
a port2, remove it from the _no_addr2 hashtable, not the _no_port2
hashtable.

Fix #18766
2022-12-30 13:16:56 +00:00
Jeremy Kerr e1cbe02cce Add Management Component Transport Protocol (MCTP) dissector
This change adds a protocol dissector for the Management Component
Transport Protocol (MCTP). This is a failry simple datagram-based
protocol for messaging between components within a single platform,
typically over I2C, serial or PCIe.

This dissector just implements the header fields, and sequence-number
based message reassembly. Inner protocols will be added as follow-up
changes.

Linux has support for AF_MCTP data, so decode from the MCTP SLL ltype.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2022-11-15 09:05:05 +00:00
Guy Harris 308e295669 conversation: bring back conversation_pt_to_endpoint_type().
It may be used by third-party code, and it may be useful on its own, at
least for now.
2022-09-02 00:07:53 -07:00
Guy Harris 2aebd660ac conversation: fix debug logging code so that it compiles. 2022-08-31 18:54:19 -07:00
Guy Harris a6ee179427 conversation: speak of the "conversation key" as just address/port endpoints.
It's not a general key for looking up arbitrary conversations - that's
what an array of conversation elements is for - it's just a pair of
address/port endpoints.  (It's not even hijacked for conversations
identified by a circuit ID any more.)
2022-08-29 19:19:59 -07:00
Guy Harris deb95a275d Rename routines that talk about conversation keys to talk about elements.
And change them to say "set" rather than "create"; they do more than
just allocate an array of conversation elements, they stuff a pointer to
that array into pinfo, which may affect what other dissectors do.
2022-08-25 22:37:19 -07:00
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
John Thacker b093b6a992 epan: Make find_or_create_conversation create what it finds and vice versa
The endpoint elements pinfo->conv_endpoint and pinfo->conv_elements
cause find_or_create_conversation (via find_conversation_pinfo) to
look for conversations based on those endpoints. It should also
make it create conversations based on those endpoints, so that
subsequent calls find the same conversation it just created instead
of repeatedly creating new ones.
2022-07-25 20:35:56 +00:00
Eugène Adell 2068ec0f95 TCP: Fix conversation overlapping when reusing ports 2022-07-20 15:53:46 +00:00
John Thacker 66978182d0 epan: Fix typo in conversation_create_endpoint_by_id 2022-07-18 12:00:42 +00:00
Alexis La Goutte b9bc750fd8 conversation: fix -Wmissing-prototypes
conversation.c:339:1: warning: no previous prototype for function 'conversation_hash_element_list'
2022-07-15 13:45:52 +00:00
John Thacker 3e012e2a87 epan: Finish converting endpoint_by_id to elements
Since the endpoint_by_id code uses elements and not the old
endpoint structure, it shouldn't set pinfo->use_endpoint to
TRUE when creating, and it should check if pinfo->conv_elements
is NULL, not pinfo->conv_endpoint.
2022-06-16 20:59:52 -04:00
Gerald Combs c9396bba11 epan: Remove an unneeded null check.
Fix

```
*** CID 1505356:  Null pointer dereferences  (REVERSE_INULL)
/builds/wireshark/wireshark/epan/conversation.c: 1427 in find_conversation()
1421              * conversation with the specified address B and port B as the
1422              * first address and port, and with any second address and port
1423              * (this packet may be going in the opposite direction from the
1424              * first packet in the conversation).
1425              * (Neither "addr_a" nor "port_a" take part in this lookup.)
1426              */
>>>     CID 1505356:  Null pointer dereferences  (REVERSE_INULL)
>>>     Null-checking "addr_a" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
1427             if ((addr_a != NULL) && (addr_a->type == AT_FC)) {
1428                 DPRINT(("trying wildcarded match: %s:%d -> *:*",
1429                             addr_b_str, port_a));
1430                 conversation = conversation_lookup_no_addr2_or_port2(frame_num, addr_b, port_a, etype);
1431             } else {
1432                 DPRINT(("trying wildcarded match: %s:%d -> *:*",
```
2022-06-07 16:42:49 -07:00
Gerald Combs 286f57a2c7 epan: Check for null addresses in find_conversation.
Make sure we don't pass null address pointers to conversation_lookup_*.
Fixes #18126.
2022-06-05 17:58:50 -07:00
Gerald Combs 5cd591129f epan: Convert remaining conversation code to elements.
Convert the address+port conversation code to element lists. Make our
conversation keys element lists. Document more of the conversation API.

Update the Conversation Hash Table dialog to use the new API.

Describe an alternative key type and data structure at the top of
conversation.c.
2022-06-05 19:05:33 +00:00
Jaap Keuter 709593ee91 Make distinction between conversation options for creation and search 2022-06-02 22:58:15 +00:00
Gerald Combs 429c7a6ce3 epan: Don't free epan-scoped memory.
e6a8318f18 allocated our element list map key in epan scope. Don't try
to free it.
2022-05-31 10:31:22 -07:00
Gerald Combs e8dc20899f epan: Remove conversation_create_endpoint options.
The "options" paramameter was never used, so remove it.
2022-05-29 18:00:09 -07:00
Gerald Combs e6a8318f18 epan: Fix our conversation key lifetimes.
wmem_map doesn't copy keys, so we need to keep them around.
2022-05-26 11:28:21 -07:00
Gerald Combs 34d74031a9 epan+Qt: Add element tables to the ConversationHashTablesDialog.
Add get_conversation_hashtables() and use it to populate the
conversation hash tables dialog.
2022-05-25 19:09:12 +00:00
Gerald Combs aef4c0c60a epan: Allocate a conversation key.
Blind attempt at fixing #18113.
2022-05-25 10:38:36 -07:00
Gerald Combs 19e1764ca5 epan: Lazily create conversation dissector trees.
Create our dissector tree maps only when we need them.
Fixes #18109.
2022-05-25 09:40:55 -07:00
Gerald Combs c0032f2f0d epan: Switch the conversation IDs back to guint32s.
Switch the _by_id IDs back to guint32s. None of the current callers need
64 bits and if someone needs 64-bit IDs they can use conversation_new_full.
2022-05-24 12:07:48 -07:00
Gerald Combs 865feb2bf8 epan: Switch some _by_id conversation routines to elements.
Switch the non-endpoint *_by_id conversation routines to use element
lists. Change the ID type from guint32 to guint64. None of them used the
address+port option flag arguments, so remove them.
2022-05-24 17:18:21 +00:00
Gerald Combs f6fdf53eca epan: Consolidate some duplicate conversation code.
Rename conversation_lookup_hashtable to conversation_lookup_addr_port.
Add a new conversation_lookup_hashtable that consolidates some duplicate
code and takes a general set of arguments similar to the other
conversation_*_hashtable routines.
2022-05-23 13:57:08 -07:00
Gerald Combs be929e162d epan: Allow conversations based on arbitrary element lists.
Add conversation_new_full and find_conversation_full, which take
arbitrary element lists instead of fixed addresses and ports.

Update the comments in conversation.h to be more Doxygen-conformant.
Update README.dissector.

Use the new functionality to add initial conversation support to the
Falco Bridge dissector.
2022-05-23 18:12:26 +00:00
Gerald Combs b09263f1a3 epan: Normalize conversation code indentation.
Change the indentation of conversation.[ch] to 4 spaces to match
conversation_table.[ch] and conversation_filter.[ch].
2022-05-09 10:50:17 -07:00
Gerald Combs 88f07ff5d1 epan: Add a null conversation checks.
Check for null conversations in conversation_add_proto_data,
conversation_get_proto_data, and conversation_delete_proto_data.
Document them as well. Ping #18043.
2022-04-21 16:27:43 +00:00
Jorge Mora 981ec7f3c7 iwarp_mpa: fix iWarp MPA for NFS-over-RDMA
On the first packet of the conversation, the MPA layer is
dissected correctly followed by the DDP, RDMAP, RPC-over-RDMA,
RPC and NFS layers. The MPA layer sets the TCP conversation as
MPA protocol but when it dissects the RPC layer it also sets
the TCP conversation as RPC protocol thus overwriting the previous
protocol.

Added new port type PT_IWARP_MPA so that when the RPC layer
is dissected it does not overwrite the default protocol for
the TCP conversation which has already been set to MPA.

Fixes #15869.
2021-08-31 08:14:31 +00:00
Guy Harris 94bb564996 conversation: use the Wayback Machine for a URL.
That's now a dead link; use the Wayback Machine to get at it.
2021-03-30 14:46:34 -07:00
Dario Lombardo 9eeb1c80fb conversation: use wmem_new0 instead of memset.
Change-Id: I8ceb8f908920bab21cb6893c4532da0857ecfcd2
Reviewed-on: https://code.wireshark.org/review/36837
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-04-14 06:03:33 +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
Pascal Quantin 54cccedfbe conversation.c: do not use wmem packet scope for debug strings
The code can be called by the GUI, outside of the scope validity.

Bug: 15810
Change-Id: I1f394cb3d1f978d6e99fe15d8238153aad62ebee
Reviewed-on: https://code.wireshark.org/review/33499
Petri-Dish: Pascal Quantin <pascal@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2019-06-05 10:29:13 +00:00
Darius Davis c66fbf481f Re-balance DINDENT/DENDENT macros in conversation.c.
The indent macros used for DEBUG_CONVERSATION have become unbalanced, making
the conversation debug output migrate rightwards for no good reason.  This
simple change corrects it by ensuring that DINDENT and DENDENT are neatly
paired up throughout conversation.c .

Testing Done: Built on macOS 10.12.6 with DEBUG_CONVERSATION enabled.  Tested
   tshark with a few captures, and observed that the debug output, while still
   being indented, generally stayed along the left margin of the screen instead
   of migrating steadily over to the right.

Change-Id: Ic91e4562296d34f74c4d832edbf75172562672b8
Reviewed-on: https://code.wireshark.org/review/30856
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-12-01 14:53:42 +00:00
Guy Harris 9cf292a30f Revert "Have find_or_create_conversation() use pinfo->conv_endpoint if present."
This reverts commit ba202ef362.

Creating endpoints, and corresponding conversations, for protocols atop which TCP or UDP runs can potentially cause attempts to look up the conversation to find the conversation for that protocol rather than for TCP/UDP, which can confuse protocols running atop TCP or UDP.

Change-Id: I3ca522e54e67cc4f996d0ee841c6bb40ee6a9976
Reviewed-on: https://code.wireshark.org/review/28912
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-08-01 02:55:18 +00:00
Guy Harris ba202ef362 Have find_or_create_conversation() use pinfo->conv_endpoint if present.
Add conversation_new_pinfo(), which uses the endpoint if present, and
have find_or_create_conversation() use it rather than
conversation_new().

Remove find_or_create_conversation_by_id() - it's no longer needed.

Bug: 15018
Change-Id: Ib13e539751af0f071aede4ee0ed751d0cb72ba3f
Reviewed-on: https://code.wireshark.org/review/28908
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-07-31 22:53:27 +00:00
Guy Harris d950b14f26 For ISDN, don't create an endpoint by ID and then use it.
That isn't working, because it depends on the notion that for every
"endpoint type" there's a "port type" for the packet_info structure;
that's not true for ISDN channels.

The whole point of "use the packet_info structure when trying to find a
conversation and create it if it doesn't exist" is to use address
information *already filled in by somebody for use by other dissectors*;
we don't do that with the ISDN channel number, because there's no *need*
to do so.

So just add a new find_or_create_conversation_by_id() routine, which
passes the packet_info structure to get the frame number, and explicitly
passes the endpoint type and ID.  Use that in the ISDN dissector.

Bug: 15018
Change-Id: Id0e997254b0eaf7cbc9261a2adff639ecbf083c0
Reviewed-on: https://code.wireshark.org/review/28904
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-07-31 21:14:48 +00:00
Guy Harris 83715db4a9 Improve debugging messages.
For various attempted matches, print what we're matching against.

Change-Id: Ib915aa9bc6e6e1ea6cc7a273f261db2a4952c0c4
Reviewed-on: https://code.wireshark.org/review/28900
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-07-31 20:17:14 +00:00
Guy Harris 20a3248ebb Frame numbers are unsigned.
Change-Id: I07641b0a759058fe5111e10c3ccd4c8f69eeccef
Reviewed-on: https://code.wireshark.org/review/28894
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-07-31 19:13:41 +00:00
Guy Harris a9dcc80f1b Clean up white space.
Change-Id: Id1eb5ec743581a0d05b82e94c78f262e7dc33f7b
Reviewed-on: https://code.wireshark.org/review/28892
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-07-31 18:24:44 +00:00
Guy Harris 747793afae Fix debugging code.
Don't show address or ports that aren't provided; this is especially
important for address 1, where its absence is indicated by the pointer
being null, so we can't blithely dereference it.

Show ports as unsigned, because that's what they are.

Change-Id: I162b6f08a3973c0cded0742c267a016dbb5ee31a
Reviewed-on: https://code.wireshark.org/review/28543
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-07-01 02:27:53 +00:00
Robert Jongbloed d16308c89a UDP: Heuristic dissector for conversation taking precedence
When a single UDP port is supporting multiple protocols, for example RTP and
RTCP can share a port, and one of these protocols is detected through a
heuristic before a superior protocol (e.g. SIP/SDP) has established that the
port has multiple protocols, then only the heuristic is used. This is due to
only looking for an exact match with find_conversation() and not going any
further. The superior protocol only adds the dissector by source address/port.
So, to fix, if we do not find the exact match, we continue serching for a
dissector on the partial matches.

Bug: 14370
Change-Id: Icdded9ca1637cd594b920f979f6f0a003bef9aae
Reviewed-on: https://code.wireshark.org/review/25432
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-02-10 20:51:55 +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
Gerald Combs 7e76e5f2c8 Make sure we pass valid addresses to find_conversation.
Pass empty (AT_NONE) addresses to find_conversation and
conversation_create_endpoint instead of NULL, similar to the LBTxx and
other dissectors.

Bug: 14394
Change-Id: Ia4573b276551a9c3d2da155faf786e8d15229100
Reviewed-on: https://code.wireshark.org/review/25620
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-02-06 18:15:18 +00:00
Michael Mann 800b26edbe Remove circuit API
Replace with conversation API that limits the "endpoint" to a single
uint32 value.

The intention is to eventually have "layered" endpoints, because circuit_id
was used in cases where src/dest port have already been populated (and
are used for layers above).  Those src/dest ports should just be treated
as just another endpoint, but we currently only have support for one.

Change-Id: Ic6aa7ef0241275aa4dfde9459194369b48c72960
Reviewed-on: https://code.wireshark.org/review/24369
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-11-13 05:21:36 +00:00
Michael Mann afb252355b ISDN: Convert circuit API to conversation API
Change-Id: I8752123a740c47f9328e0144624d4fbf4e200165
Reviewed-on: https://code.wireshark.org/review/24314
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-11-09 07:50:09 +00:00
Michael Mann 82891e37e9 DVB-CI: Convert circuit API to conversation API
Add the few necessary conversation APIs to make conversion possible.

Change-Id: I775f23005c48cacd2be342bdc704af4738f0789c
Reviewed-on: https://code.wireshark.org/review/24310
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-11-09 07:47:41 +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
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