diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2015-07-15 14:47:39 +0200 |
---|---|---|
committer | Pascal Quantin <pascal.quantin@gmail.com> | 2015-07-15 18:30:57 +0000 |
commit | 79774329d7cc324b3d7c3a5a013abea85a20885e (patch) | |
tree | a2d17c007f62c070d39ca59aa06e96207128a293 | |
parent | 52e2908729c0d0d45df572ff3aaf3e41258c2d4e (diff) |
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>
-rw-r--r-- | debian/libwireshark0.symbols | 1 | ||||
-rw-r--r-- | epan/dissectors/packet-dtls.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-exported_pdu.c | 14 | ||||
-rw-r--r-- | epan/dissectors/packet-ssl.c | 4 | ||||
-rw-r--r-- | epan/exported_pdu.h | 4 | ||||
-rw-r--r-- | epan/packet.c | 17 | ||||
-rw-r--r-- | epan/packet.h | 9 |
7 files changed, 8 insertions, 45 deletions
diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols index f67bb255a0..63464be1dd 100644 --- a/debian/libwireshark0.symbols +++ b/debian/libwireshark0.symbols @@ -526,7 +526,6 @@ libwireshark.so.0 libwireshark0 #MINVER# find_conversation@Base 1.9.1 find_dissector@Base 1.9.1 find_dissector_table@Base 1.9.1 - find_heur_dissector_by_short_name@Base 1.99.8 find_heur_dissector_by_unique_short_name@Base 1.99.8 find_heur_dissector_list@Base 1.99.2 find_or_create_conversation@Base 1.9.1 diff --git a/epan/dissectors/packet-dtls.c b/epan/dissectors/packet-dtls.c index 7c357dca61..ea11d6f313 100644 --- a/epan/dissectors/packet-dtls.c +++ b/epan/dissectors/packet-dtls.c @@ -962,9 +962,7 @@ dissect_dtls_record(tvbuff_t *tvb, packet_info *pinfo, /* try heuristic subdissectors */ dissected = dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, top_tree, &hdtbl_entry, NULL); if (dissected && have_tap_listener(exported_pdu_tap)) { - gchar *name = wmem_strconcat(wmem_packet_scope(), hdtbl_entry->list_name, "##", - proto_get_protocol_short_name(hdtbl_entry->protocol), NULL); - export_pdu_packet(next_tvb, pinfo, EXP_PDU_TAG_HEUR_PROTO_NAME, name); + export_pdu_packet(next_tvb, pinfo, EXP_PDU_TAG_HEUR_PROTO_NAME, hdtbl_entry->short_name); } } pinfo->match_uint = saved_match_port; diff --git a/epan/dissectors/packet-exported_pdu.c b/epan/dissectors/packet-exported_pdu.c index a08c48a120..3bf022d215 100644 --- a/epan/dissectors/packet-exported_pdu.c +++ b/epan/dissectors/packet-exported_pdu.c @@ -211,16 +211,10 @@ dissect_exported_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) break; case EXPORTED_PDU_NEXT_HEUR_PROTO_STR: { - gchar **heur_proto_str = wmem_strsplit(wmem_packet_scope(), proto_name, "##", 2); - if (heur_proto_str && heur_proto_str[0] && heur_proto_str[1]) { - heur_dissector_list_t heur_list = find_heur_dissector_list(heur_proto_str[0]); - if (heur_list) { - heur_dtbl_entry_t *heur_diss = find_heur_dissector_by_short_name(heur_list, heur_proto_str[1]); - if (heur_diss) { - col_clear(pinfo->cinfo, COL_PROTOCOL); - call_heur_dissector_direct(heur_diss, payload_tvb, pinfo, tree, NULL); - } - } + heur_dtbl_entry_t *heur_diss = find_heur_dissector_by_unique_short_name(proto_name); + if (heur_diss) { + col_clear(pinfo->cinfo, COL_PROTOCOL); + call_heur_dissector_direct(heur_diss, payload_tvb, pinfo, tree, NULL); } break; } diff --git a/epan/dissectors/packet-ssl.c b/epan/dissectors/packet-ssl.c index 25389627e3..7699d7e6e8 100644 --- a/epan/dissectors/packet-ssl.c +++ b/epan/dissectors/packet-ssl.c @@ -1325,9 +1325,7 @@ process_ssl_payload(tvbuff_t *tvb, volatile int offset, packet_info *pinfo, if (dissector_try_heuristic(ssl_heur_subdissector_list, next_tvb, pinfo, proto_tree_get_root(tree), &hdtbl_entry, NULL)) { if (have_tap_listener(exported_pdu_tap)) { - gchar *name = wmem_strconcat(wmem_packet_scope(), hdtbl_entry->list_name, "##", - proto_get_protocol_short_name(hdtbl_entry->protocol), NULL); - export_pdu_packet(next_tvb, pinfo, EXP_PDU_TAG_HEUR_PROTO_NAME, name); + export_pdu_packet(next_tvb, pinfo, EXP_PDU_TAG_HEUR_PROTO_NAME, hdtbl_entry->short_name); } } else { if (have_tap_listener(exported_pdu_tap)) { diff --git a/epan/exported_pdu.h b/epan/exported_pdu.h index 5750be8396..377e0433e1 100644 --- a/epan/exported_pdu.h +++ b/epan/exported_pdu.h @@ -89,8 +89,8 @@ WS_DLL_PUBLIC GSList *get_export_pdu_tap_list(void); * Will be used to call the next dissector. */ #define EXP_PDU_TAG_HEUR_PROTO_NAME 13 /**< The value part should be an ASCII non NULL terminated string - * composed of the heuristic table name followed by "##" followed - * by protocol short name of the used heuristic dissector e.g "ssl##HTTP2" + * containing the heuristic unique short protocol name given + * during registration, e.g "sip_udp" * Will be used to call the next dissector. */ /* Add protocol type related tags here. diff --git a/epan/packet.c b/epan/packet.c index 2a8cb0ede2..18e61d337f 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -1964,23 +1964,6 @@ has_heur_dissector_list(const gchar *name) { } -static int -find_matching_heur_dissector_by_short_name(gconstpointer a, gconstpointer b) { - const gchar *str_a = proto_get_protocol_short_name(((const heur_dtbl_entry_t *)a)->protocol); - const gchar *str_b = (const gchar*)b; - - return strcmp(str_a, str_b); -} - -heur_dtbl_entry_t* -find_heur_dissector_by_short_name(heur_dissector_list_t heur_list, const char *short_name) -{ - GSList *found_entry = g_slist_find_custom(heur_list->dissectors, - (gpointer) short_name, - find_matching_heur_dissector_by_short_name); - return found_entry ? (heur_dtbl_entry_t *)(found_entry->data) : NULL; -} - heur_dtbl_entry_t* find_heur_dissector_by_unique_short_name(const char *short_name) { return (heur_dtbl_entry_t*)g_hash_table_lookup(heuristic_short_names, (gpointer)short_name); diff --git a/epan/packet.h b/epan/packet.h index bf2598402d..0fecba3182 100644 --- a/epan/packet.h +++ b/epan/packet.h @@ -439,15 +439,6 @@ WS_DLL_PUBLIC gboolean dissector_try_heuristic(heur_dissector_list_t sub_dissect */ WS_DLL_PUBLIC heur_dissector_list_t find_heur_dissector_list(const char *name); -/** Find a heuristic dissector by short protocol name in a heuristic table. - * - * @param heur_list heuristic dissector table - * @param short_name short name of the protocol to look at - * @return pointer to the heuristic dissector entry, NULL if not such dissector exists - */ -WS_DLL_PUBLIC heur_dtbl_entry_t* find_heur_dissector_by_short_name(heur_dissector_list_t heur_list, - const char *short_name); - /** Find a heuristic dissector by the unique short protocol name provided during registration. * * @param short_name short name of the protocol to look at |