2 * Dissector of ActiveMQ Artemis Core Protocol, so far just the message headers
3 * Implemented: 2017, Pavel Moravec, Red Hat <pmoravec@redhat.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
11 * Protocol information:
12 * 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
17 #include <epan/packet.h>
18 #include <epan/expert.h>
19 #include "packet-tcp.h"
22 #define ARTEMIS_PORT 5445 /* Not IANA registered */
24 static int proto_artemis
;
27 static int hf_artemis_len
;
28 static int hf_artemis_type
;
29 static int hf_artemis_channel
;
30 static int hf_artemis_buffer
;
32 static int ett_artemis
;
34 static expert_field ei_artemis_len_short
;
37 static dissector_handle_t artemis_tcp_handle
;
39 void proto_register_artemis(void);
40 void proto_reg_handoff_artemis(void);
41 static int dissect_artemis(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree _U_
, void *data _U_
);
44 get_artemis_message_len(packet_info
*pinfo _U_
, tvbuff_t
*tvb
,
45 int offset
, void *data _U_
)
47 /* The 4bytes length doesn't include the actual length byte, that's why the "+4" */
48 return (unsigned) tvb_get_ntohl(tvb
, offset
) + 4;
52 dissect_artemis_frame(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
55 proto_item
*ti
, *len_item
;
56 proto_tree
*artemis_tree
;
59 ti
= proto_tree_add_item(tree
, proto_artemis
, tvb
, 0, -1, ENC_NA
);
60 artemis_tree
= proto_item_add_subtree(ti
, ett_artemis
);
62 len_item
= proto_tree_add_item_ret_uint(artemis_tree
, hf_artemis_len
, tvb
, 0, 4, ENC_BIG_ENDIAN
, &length
);
63 if (length
< 9) { /* 9 = 1(type) + channel(8), if length is smaller, we cant read even type+channel */
64 expert_add_info(pinfo
, len_item
, &ei_artemis_len_short
);
65 return tvb_captured_length(tvb
);
68 proto_tree_add_item(artemis_tree
, hf_artemis_type
, tvb
, 4, 1, ENC_BIG_ENDIAN
);
69 proto_tree_add_item(artemis_tree
, hf_artemis_channel
, tvb
, 5, 8, ENC_BIG_ENDIAN
);
70 proto_tree_add_item(artemis_tree
, hf_artemis_buffer
, tvb
, 13, length
-9, ENC_NA
);
72 return tvb_captured_length(tvb
);
76 dissect_artemis(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree _U_
, void *data _U_
)
78 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "ARTEMIS");
79 /* Clear out stuff in the info column */
80 col_clear(pinfo
->cinfo
, COL_INFO
);
82 /* fixed_len = 4(len) + 1(type) + 8(channel) */
83 tcp_dissect_pdus(tvb
, pinfo
, tree
, true, 4, get_artemis_message_len
,
84 dissect_artemis_frame
, data
);
86 return tvb_captured_length(tvb
);
90 proto_register_artemis(void)
92 static hf_register_info hf
[] = {
94 "Length", "artemis.length",
95 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
96 "Length of the frame", HFILL
}},
98 "Type", "artemis.type",
99 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
100 "Type of the frame", HFILL
}},
101 {&hf_artemis_channel
, {
102 "Channel", "artemis.channel",
103 FT_UINT64
, BASE_DEC
, NULL
, 0x0,
104 "Channel ID of the frame", HFILL
}},
105 {&hf_artemis_buffer
, {
106 "Buffer", "artemis.buffer",
107 FT_BYTES
, BASE_NONE
, NULL
, 0,
108 "Binary buffer", HFILL
}}
111 static int *ett
[] = {
115 static ei_register_info ei
[] = {
116 { &ei_artemis_len_short
, { "artemis.len_short", PI_PROTOCOL
, PI_ERROR
, "Frame length is too short", EXPFILL
}}
119 expert_module_t
* expert_artemis
;
121 proto_artemis
= proto_register_protocol ( "Artemis Core Protocol", "Artemis", "artemis" );
123 artemis_tcp_handle
= register_dissector("artemis", dissect_artemis
, proto_artemis
);
124 proto_register_field_array(proto_artemis
, hf
, array_length(hf
));
125 proto_register_subtree_array(ett
, array_length(ett
));
127 expert_artemis
= expert_register_protocol(proto_artemis
);
128 expert_register_field_array(expert_artemis
, ei
, array_length(ei
));
132 proto_reg_handoff_artemis(void)
134 static bool initialize
= false;
137 /* Register TCP port for dissection */
138 dissector_add_uint_with_preference("tcp.port", ARTEMIS_PORT
, artemis_tcp_handle
);
144 * Editor modelines - https://www.wireshark.org/tools/modelines.html
149 * indent-tabs-mode: nil
152 * vi: set shiftwidth=4 tabstop=8 expandtab:
153 * :indentSize=4:tabSize=8:noTabs=true: