aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2021-10-09 09:05:54 -0400
committerWireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2021-10-10 11:31:06 +0000
commit35d09a7854059b223db428a0e9f136b54c253856 (patch)
treea86af60bd7e8f62b83281a22bb32be32bf06e2b8 /epan
parentfaf6fabfe350c4e1cdb4a38c620c977c77190d51 (diff)
BT-DHT, BT-uTP: Use conversation_set_dissector_from_frame_number
Since the UDP connection switches back and forth between DHT and uTP, use conversation_set_dissector_from_frame_number so that the dissector called by try_conversation_dissector in packet-udp.c doesn't change for a given frame based on the last packet clicked in the GUI. Split out a heuristic dissector from uTP so that conversation_set_dissector is only called from the heuristic dissector. This doesn't make a difference when the heuristics are accurate but might in some edge cases.
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-bt-dht.c2
-rw-r--r--epan/dissectors/packet-bt-utp.c26
2 files changed, 22 insertions, 6 deletions
diff --git a/epan/dissectors/packet-bt-dht.c b/epan/dissectors/packet-bt-dht.c
index b53f89f67a..b5d059a455 100644
--- a/epan/dissectors/packet-bt-dht.c
+++ b/epan/dissectors/packet-bt-dht.c
@@ -608,7 +608,7 @@ gboolean dissect_bt_dht_heur (tvbuff_t *tvb, packet_info *pinfo,
}
conversation = find_or_create_conversation(pinfo);
- conversation_set_dissector(conversation, bt_dht_handle);
+ conversation_set_dissector_from_frame_number(conversation, pinfo->num, bt_dht_handle);
dissect_bt_dht(tvb, pinfo, tree, NULL);
return TRUE;
diff --git a/epan/dissectors/packet-bt-utp.c b/epan/dissectors/packet-bt-utp.c
index 79477bfb95..b231c7087c 100644
--- a/epan/dissectors/packet-bt-utp.c
+++ b/epan/dissectors/packet-bt-utp.c
@@ -354,16 +354,12 @@ dissect_bt_utp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
/* try dissecting */
if (version >= 0)
{
- conversation_t *conversation;
guint len_tvb;
proto_tree *sub_tree = NULL;
proto_item *ti;
gint offset = 0;
guint8 extension_type;
- conversation = find_or_create_conversation(pinfo);
- conversation_set_dissector(conversation, bt_utp_handle);
-
/* set the protocol column */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "BT-uTP");
/* set the info column */
@@ -395,6 +391,26 @@ dissect_bt_utp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
return 0;
}
+static gboolean
+dissect_bt_utp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
+{
+ gint version;
+ version = get_utp_version(tvb);
+
+ if (version >= 0)
+ {
+ conversation_t *conversation;
+
+ conversation = find_or_create_conversation(pinfo);
+ conversation_set_dissector_from_frame_number(conversation, pinfo->num, bt_utp_handle);
+
+ dissect_bt_utp(tvb, pinfo, tree, data);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
void
proto_register_bt_utp(void)
{
@@ -529,7 +545,7 @@ proto_reg_handoff_bt_utp(void)
* on packets with lots of zero bytes. Needs more testing before enabling
* by default.
*/
- heur_dissector_add("udp", dissect_bt_utp, "BitTorrent UTP over UDP", "bt_utp_udp", proto_bt_utp, HEURISTIC_DISABLE);
+ heur_dissector_add("udp", dissect_bt_utp_heur, "BitTorrent UTP over UDP", "bt_utp_udp", proto_bt_utp, HEURISTIC_DISABLE);
bt_utp_handle = create_dissector_handle(dissect_bt_utp, proto_bt_utp);
dissector_add_for_decode_as_with_preference("udp.port", bt_utp_handle);