DLEP: Desegment messages over TCP

Handle multiple message PDUs in a single TCP segment, and DLEP messages
split across multiple segments. Fix #17669.
This commit is contained in:
John Thacker 2021-11-10 06:56:22 -05:00 committed by Wireshark GitLab Utility
parent 4c75a78f26
commit 139c04f40a
1 changed files with 32 additions and 1 deletions

View File

@ -30,6 +30,8 @@
#include <epan/tfs.h>
#include <glib.h>
#include "packet-tcp.h"
/* Section 13: DLEP Data Items */
/* DLEP Data Item Lengths (bytes) */
@ -189,6 +191,10 @@
/* Section 15.16: DLEP IPv6 Link-Local Multicast Address */
#define DLEP_IPV6_ADDR "FF02:0:0:0:0:0:1:7"
#define DLEP_MSG_HEADER_LEN 4
static gboolean dlep_desegment = TRUE;
static dissector_handle_t dlep_msg_handle;
static dissector_handle_t dlep_sig_handle;
@ -1050,6 +1056,16 @@ decode_signal_header(tvbuff_t *tvb, int offset, proto_item* pi, proto_tree *pt,
}
/* Section 11.2: DLEP Message Header */
static guint
get_dlep_message_header_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
{
guint message_length;
message_length = tvb_get_guint16(tvb, offset+2, ENC_BIG_ENDIAN);
return message_length + DLEP_MSG_HEADER_LEN;
}
static int
decode_message_header(tvbuff_t *tvb, int offset, proto_item* pi, proto_tree *pt, packet_info *pinfo)
{
@ -1124,9 +1140,17 @@ dissect_dlep_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pt, void *data _
return tvb_captured_length(tvb);
}
static gboolean
dissect_dlep_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
tcp_dissect_pdus(tvb, pinfo, tree, dlep_desegment, DLEP_MSG_HEADER_LEN, get_dlep_message_header_len, dissect_dlep_msg, data);
return tvb_reported_length(tvb);
}
void
proto_register_dlep(void)
{
module_t* dlep_module;
expert_module_t* dlep_expert_module;
static hf_register_info hf[] = {
@ -1354,12 +1378,19 @@ proto_register_dlep(void)
};
proto_dlep = proto_register_protocol("Dynamic Link Exchange Protocol", "DLEP", "dlep");
dlep_msg_handle = register_dissector ("dlep.tcp", dissect_dlep_msg, proto_dlep);
dlep_msg_handle = register_dissector ("dlep.tcp", dissect_dlep_tcp, proto_dlep);
dlep_sig_handle = register_dissector ("dlep.udp", dissect_dlep_sig, proto_dlep);
proto_register_field_array(proto_dlep, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
dlep_module = prefs_register_protocol(proto_dlep, NULL);
prefs_register_bool_preference(dlep_module, "desegment",
"Reassemble DLEP messages spanning multiple TCP segments",
"Whether the DLEP dissector should reassemble messages spanning multiple TCP segments."
" To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
&dlep_desegment);
dlep_expert_module = expert_register_protocol(proto_dlep);
expert_register_field_array(dlep_expert_module, ei, array_length(ei));
}