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.
This commit is contained in:
John Thacker 2021-10-09 09:05:54 -04:00 committed by Wireshark GitLab Utility
parent faf6fabfe3
commit 35d09a7854
2 changed files with 22 additions and 6 deletions

View File

@ -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;

View File

@ -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);