aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2017-11-25 15:57:57 +0100
committerAnders Broman <a.broman58@gmail.com>2017-12-14 06:10:33 +0000
commita9821caab8a1f2c6e265bd5b63a060f1f241c704 (patch)
tree822726533d0a1bb7399f5ad8782334e39dea4760
parent862a0b6472529ef6676c8bc56dd8f0be5166fd7c (diff)
Add dissector for ActiveMQ Artemis Core Protocol
So far decode just packet headers Change-Id: I7a01f3c83b97882f4c669122ad94b2bdab0ab251 Signed-off-by: Pavel Moravec <pmoravec@redhat.com> Reviewed-on: https://code.wireshark.org/review/24583 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--docbook/release-notes.asciidoc1
-rw-r--r--epan/dissectors/CMakeLists.txt1
-rw-r--r--epan/dissectors/Makefile.am1
-rw-r--r--epan/dissectors/packet-artemis.c154
4 files changed, 157 insertions, 0 deletions
diff --git a/docbook/release-notes.asciidoc b/docbook/release-notes.asciidoc
index 3758f6a4a6..873f84dd48 100644
--- a/docbook/release-notes.asciidoc
+++ b/docbook/release-notes.asciidoc
@@ -88,6 +88,7 @@ Network Functional Application Platform Interface (NFAPI) Protocol
IEEE 1905.1a
Bluetooth Mesh
TWAMP and OWAMP
+ActiveMQ Artemis Core Protocol
--sort-and-group--
=== Updated Protocol Support
diff --git a/epan/dissectors/CMakeLists.txt b/epan/dissectors/CMakeLists.txt
index e120443ba9..c0ae2ff396 100644
--- a/epan/dissectors/CMakeLists.txt
+++ b/epan/dissectors/CMakeLists.txt
@@ -659,6 +659,7 @@ set(DISSECTOR_SRC
${CMAKE_CURRENT_SOURCE_DIR}/packet-arcnet.c
${CMAKE_CURRENT_SOURCE_DIR}/packet-armagetronad.c
${CMAKE_CURRENT_SOURCE_DIR}/packet-arp.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/packet-artemis.c
${CMAKE_CURRENT_SOURCE_DIR}/packet-artnet.c
${CMAKE_CURRENT_SOURCE_DIR}/packet-aruba-adp.c
${CMAKE_CURRENT_SOURCE_DIR}/packet-aruba-erm.c
diff --git a/epan/dissectors/Makefile.am b/epan/dissectors/Makefile.am
index 974e37877b..40331aeb6f 100644
--- a/epan/dissectors/Makefile.am
+++ b/epan/dissectors/Makefile.am
@@ -285,6 +285,7 @@ DISSECTOR_SRC = \
packet-arcnet.c \
packet-armagetronad.c \
packet-arp.c \
+ packet-artemis.c \
packet-artnet.c \
packet-aruba-adp.c \
packet-aruba-erm.c \
diff --git a/epan/dissectors/packet-artemis.c b/epan/dissectors/packet-artemis.c
new file mode 100644
index 0000000000..6b14187b09
--- /dev/null
+++ b/epan/dissectors/packet-artemis.c
@@ -0,0 +1,154 @@
+/* packet-artemis.c
+ * Dissector of ActiveMQ Artemis Core Protocol, so far just the message headers
+ * Implemented: 2017, Pavel Moravec, Red Hat <pmoravec@redhat.com>
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ * Protocol information:
+ * https://github.com/apache/activemq-artemis/blob/master/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketImpl.java#L309-L326
+ */
+
+#include "config.h"
+
+#include <epan/packet.h>
+#include <epan/expert.h>
+#include "packet-tcp.h"
+#include "stdio.h"
+
+#define ARTEMIS_PORT 5445 /* Not IANA registered */
+
+static int proto_artemis = -1;
+
+/* handles */
+static int hf_artemis_len = -1;
+static int hf_artemis_type = -1;
+static int hf_artemis_channel = -1;
+static int hf_artemis_buffer = -1;
+
+static gint ett_artemis = -1;
+
+static expert_field ei_artemis_len_short = EI_INIT;
+
+
+static dissector_handle_t artemis_tcp_handle = NULL;
+
+void proto_register_artemis(void);
+void proto_reg_handoff_artemis(void);
+static int dissect_artemis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, void *data _U_);
+
+static guint
+get_artemis_message_len(packet_info *pinfo _U_, tvbuff_t *tvb,
+ int offset, void *data _U_)
+{
+ /* The 4bytes length doesn't include the actual length byte, that's why the "+4" */
+ return (guint) tvb_get_ntohl(tvb, offset) + 4;
+}
+
+static int
+dissect_artemis_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
+{
+
+ proto_item *ti, *len_item;
+ proto_tree *artemis_tree;
+ guint32 length;
+
+ ti = proto_tree_add_item(tree, proto_artemis, tvb, 0, -1, ENC_NA);
+ artemis_tree = proto_item_add_subtree(ti, ett_artemis);
+
+ len_item = proto_tree_add_item_ret_uint(artemis_tree, hf_artemis_len, tvb, 0, 4, ENC_BIG_ENDIAN, &length);
+ if (length < 9) { /* 9 = 1(type) + channel(8), if length is smaller, we cant read even type+channel */
+ expert_add_info(pinfo, len_item, &ei_artemis_len_short);
+ return tvb_captured_length(tvb);
+ }
+
+ proto_tree_add_item(artemis_tree, hf_artemis_type, tvb, 4, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(artemis_tree, hf_artemis_channel, tvb, 5, 8, ENC_BIG_ENDIAN);
+ proto_tree_add_item(artemis_tree, hf_artemis_buffer, tvb, 13, length-9, ENC_NA);
+
+ return tvb_captured_length(tvb);
+}
+
+static int
+dissect_artemis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, void *data _U_)
+{
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "ARTEMIS");
+ /* Clear out stuff in the info column */
+ col_clear(pinfo->cinfo, COL_INFO);
+
+ /* fixed_len = 4(len) + 1(type) + 8(channel) */
+ tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 4, get_artemis_message_len,
+ dissect_artemis_frame, data);
+
+ return tvb_captured_length(tvb);
+}
+
+void
+proto_register_artemis(void)
+{
+ static hf_register_info hf[] = {
+ {&hf_artemis_len, {
+ "Length", "artemis.length",
+ FT_UINT32, BASE_DEC, NULL, 0x0,
+ "Length of the frame", HFILL}},
+ {&hf_artemis_type, {
+ "Type", "artemis.type",
+ FT_UINT8, BASE_DEC, NULL, 0x0,
+ "Type of the frame", HFILL}},
+ {&hf_artemis_channel, {
+ "Channel", "artemis.channel",
+ FT_UINT64, BASE_DEC, NULL, 0x0,
+ "Channel ID of the frame", HFILL}},
+ {&hf_artemis_buffer, {
+ "Buffer", "artemis.buffer",
+ FT_BYTES, BASE_NONE, NULL, 0,
+ "Binary buffer", HFILL}}
+ };
+
+ static gint *ett [] = {
+ &ett_artemis
+ };
+
+ static ei_register_info ei[] = {
+ { &ei_artemis_len_short, { "artemis.len_short", PI_PROTOCOL, PI_ERROR, "Frame length is too short", EXPFILL }}
+ };
+
+ expert_module_t* expert_artemis;
+
+ proto_artemis = proto_register_protocol ( "Artemis Core Protocol", "Artemis", "artemis" );
+
+ artemis_tcp_handle = register_dissector("artemis", dissect_artemis, proto_artemis);
+ proto_register_field_array(proto_artemis, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
+
+ expert_artemis = expert_register_protocol(proto_artemis);
+ expert_register_field_array(expert_artemis, ei, array_length(ei));
+}
+
+void
+proto_reg_handoff_artemis(void)
+{
+ static gboolean initialize = FALSE;
+
+ if (!initialize) {
+ /* Register TCP port for dissection */
+ dissector_add_uint_with_preference("tcp.port", ARTEMIS_PORT, artemis_tcp_handle);
+ initialize = TRUE;
+ }
+}
+
+/*
+ * Editor modelines - https://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */