diff options
author | Peter Wu <peter@lekensteyn.nl> | 2019-08-15 01:30:00 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2019-08-15 04:04:16 +0000 |
commit | ede7be3440689cee51489361934704467f2b2ffb (patch) | |
tree | 55ce9191e3c82fbbfb7ea5fc4833f60fe9ec9b0f /epan/dissectors/packet-tls.c | |
parent | 05dc3bf2ce02e4ca165058cce122acebd95c514f (diff) |
TLS: allow dissectors to set the appdata protocol via the data param
For use by EAP-TTLS which knows the next protocol that must be set.
Similar to the ssl_starttls functions, but simpler as the caller does
not switch the transport protocol to TLS.
Change-Id: Idadb6f33e5e1182bf7b3b0b5134df9af2717a592
Reviewed-on: https://code.wireshark.org/review/34293
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-tls.c')
-rw-r--r-- | epan/dissectors/packet-tls.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/epan/dissectors/packet-tls.c b/epan/dissectors/packet-tls.c index f33822622b..8142a14472 100644 --- a/epan/dissectors/packet-tls.c +++ b/epan/dissectors/packet-tls.c @@ -583,9 +583,9 @@ static gint ssl_looks_like_valid_v2_handshake(tvbuff_t *tvb, * Code to actually dissect the packets */ static int -dissect_ssl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) +dissect_tls(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { - + const char *appdata_dissector_name = (const char *)data; conversation_t *conversation; proto_item *ti; proto_tree *ssl_tree; @@ -645,6 +645,16 @@ dissect_ssl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) return 0; } + /* If the subdissector is provided by the caller, remember it. */ + if (appdata_dissector_name && !session->app_handle) { + session->app_handle = find_dissector(appdata_dissector_name); + if (!session->app_handle) { + ssl_debug_printf("Requested appdata dissector \"%s\" not found!\n", appdata_dissector_name); + } else { + ssl_debug_printf("Setting appdata dissector to \"%s\"\n", appdata_dissector_name); + } + } + /* try decryption only the first time we see this packet * (to keep cipher synchronized) */ if (pinfo->fd->visited) @@ -961,7 +971,7 @@ is_sslv2_clienthello(tvbuff_t *tvb) } static int -dissect_ssl_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) +dissect_ssl_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { conversation_t *conversation; @@ -971,7 +981,7 @@ dissect_ssl_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data conversation = find_or_create_conversation(pinfo); conversation_set_dissector(conversation, tls_handle); - return dissect_ssl(tvb, pinfo, tree, data); + return dissect_tls(tvb, pinfo, tree, NULL); } static void @@ -4526,7 +4536,7 @@ proto_register_tls(void) "SSL/TLS Application-Layer Protocol Negotiation (ALPN) Protocol IDs", proto_tls); - tls_handle = register_dissector("tls", dissect_ssl, proto_tls); + tls_handle = register_dissector("tls", dissect_tls, proto_tls); register_dissector("tls13-handshake", dissect_tls13_handshake, proto_tls); register_init_routine(ssl_init); |