From 06369068809ec11522ede5fa318aa995a9ff0c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dr=2E=20Lars=20V=C3=B6lker?= Date: Thu, 14 Jan 2021 00:10:58 +0100 Subject: [PATCH] CAN: fixed heuristics of CAN This patch adds heuristics support for regular CAN-IDs. Until now, only extended CAN-IDs were support. That did not make sense. Fixes #17128. --- epan/dissectors/packet-socketcan.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/epan/dissectors/packet-socketcan.c b/epan/dissectors/packet-socketcan.c index 60fc0ea51c..b793cab6ee 100644 --- a/epan/dissectors/packet-socketcan.c +++ b/epan/dissectors/packet-socketcan.c @@ -316,9 +316,26 @@ dissect_socketcan_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, } next_tvb = tvb_new_subset_length(tvb, CAN_DATA_OFFSET, can_info.len); - if (!dissector_try_payload_new(subdissector_table, next_tvb, pinfo, tree, TRUE, &can_info)) + + if (!heuristic_first) { - call_data_dissector(next_tvb, pinfo, tree); + if (!dissector_try_payload_new(subdissector_table, next_tvb, pinfo, tree, TRUE, &can_info)) + { + if (!dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, tree, &heur_dtbl_entry, &can_info)) + { + call_data_dissector(next_tvb, pinfo, tree); + } + } + } + else + { + if (!dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, tree, &heur_dtbl_entry, &can_info)) + { + if (!dissector_try_payload_new(subdissector_table, next_tvb, pinfo, tree, FALSE, &can_info)) + { + call_data_dissector(next_tvb, pinfo, tree); + } + } } }