From 78827c8752f198e55b9a0300aee5b3868e6f28f7 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Tue, 5 Feb 2019 14:13:29 +0100 Subject: [PATCH] Accept protocol aliases in Decode As (-d tcp.port==4433,ssl) Change-Id: Idb2e4f9964cf0b5c1237a0d4b5e0954adfd5e6b6 Reviewed-on: https://code.wireshark.org/review/31895 Petri-Dish: Peter Wu Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu --- test/suite_decryption.py | 2 ++ ui/decode_as_utils.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/suite_decryption.py b/test/suite_decryption.py index 50692ea5ba..113096584a 100644 --- a/test/suite_decryption.py +++ b/test/suite_decryption.py @@ -208,9 +208,11 @@ class case_decrypt_tls(subprocesstest.SubprocessTestCase): if not features.have_gnutls: self.skipTest('Requires GnuTLS.') key_file = os.path.join(dirs.key_dir, 'rsasnakeoil2.key') + # Test protocol alias while at it (ssl -> tls) self.assertRun((cmd_tshark, '-r', capture_file('tls-renegotiation.pcap'), '-o', 'tls.keys_list:0.0.0.0,4433,http,{}'.format(key_file), + '-d', 'tcp.port==4433,ssl', '-Tfields', '-e', 'http.content_length', '-Y', 'http', diff --git a/ui/decode_as_utils.c b/ui/decode_as_utils.c index 30ca1096e1..32c8347bd5 100644 --- a/ui/decode_as_utils.c +++ b/ui/decode_as_utils.c @@ -118,7 +118,7 @@ fprint_all_protocols_for_layer_types(FILE *output, gchar *table_name) * to pass parameters and store results */ struct protocol_name_search{ - gchar *searched_name; /* Protocol filter name we are looking for */ + const char *searched_name; /* Protocol filter name we are looking for */ dissector_handle_t matched_handle; /* Handle for a dissector whose protocol has the specified filter name */ guint nb_match; /* How many dissectors matched searched_name */ }; @@ -387,8 +387,14 @@ gboolean decode_as_command_option(const gchar *cl_param) cmdarg_err("No protocol name specified"); /* Note, we don't exit here, but dissector_matching will remain NULL, so we exit below */ } else { + header_field_info *hfi = proto_registrar_get_byalias(dissector_str); + user_protocol_name.nb_match = 0; - user_protocol_name.searched_name = dissector_str; + if (hfi) { + user_protocol_name.searched_name = hfi->abbrev; + } else { + user_protocol_name.searched_name = dissector_str; + } user_protocol_name.matched_handle = NULL; dissector_table_foreach_handle(table_name, find_protocol_name_func, &user_protocol_name); /* Go and perform the search for this dissector in the this table's dissectors' names and shortnames */