diff options
author | Pascal Quantin <pascal@wireshark.org> | 2020-01-20 22:23:43 +0100 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2020-01-21 22:09:51 +0000 |
commit | 75e1b69e88bb6856bbae443aa64efdceb3e39117 (patch) | |
tree | b9c90799b090374a5fdcca99803258b5f9f4fa6f /epan | |
parent | 3442c76bc5a5f294342b6ceb62153be47447c0bc (diff) |
CoAP: change detection logic for CoAP over TCP or TLS
Do not assume that having a TCP port means that CoAP is running directly
over TCP: this is not the case with MQTT for example (see bug 14591 for
a capture). Instead explicitly check that the parent dissector is TCP or
TLS.
Bug: 15910
Change-Id: Ib4880623b8525fe6be52a685397005eac86da135
Reviewed-on: https://code.wireshark.org/review/35879
Petri-Dish: Pascal Quantin <pascal@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-coap.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/epan/dissectors/packet-coap.c b/epan/dissectors/packet-coap.c index bf31b5bf7c..2ce996609b 100644 --- a/epan/dissectors/packet-coap.c +++ b/epan/dissectors/packet-coap.c @@ -1384,14 +1384,25 @@ dissect_coap_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, static int dissect_coap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - if (pinfo->ptype != PT_TCP) { - /* Assume UDP */ - return dissect_coap_message(tvb, pinfo, tree, FALSE, FALSE); - } else if (proto_is_frame_protocol(pinfo->layers, "websocket")) { + wmem_list_frame_t *prev_layer; + const char *name; + + /* retrieve parent protocol */ + prev_layer = wmem_list_frame_prev(wmem_list_tail(pinfo->layers)); + if (prev_layer) { + name = proto_get_protocol_filter_name(GPOINTER_TO_INT(wmem_list_frame_data(prev_layer))); + } else { + name = NULL; + } + if (proto_is_frame_protocol(pinfo->layers, "websocket")) { /* WebSockets */ return dissect_coap_message(tvb, pinfo, tree, TRUE, TRUE); - } else { + } else if (!g_strcmp0(name, "tcp") || !g_strcmp0(name, "tls")) { + /* TCP */ return dissect_coap_message(tvb, pinfo, tree, TRUE, FALSE); + } else { + /* Assume UDP */ + return dissect_coap_message(tvb, pinfo, tree, FALSE, FALSE); } } |