3 * Routines for DXL dissection
5 * https://github.com/opendxl
7 * Copyright 2018, Dario Lombardo <lomato@gmail.com>
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * SPDX-License-Identifier: GPL-2.0-or-later
18 #include <epan/packet.h>
19 #include <epan/tvbuff.h>
20 #include <epan/expert.h>
22 void proto_register_dxl(void);
23 void proto_reg_handoff_dxl(void);
27 static int hf_dxl_version
;
28 static int hf_dxl_type
;
32 static expert_field ei_dxl_unsupported
;
34 static dissector_handle_t msgpack_handle
;
37 #define DXL_RESPONSE 1
41 static const value_string dxl_message_types
[] = {
42 { DXL_REQUEST
, "Request" },
43 { DXL_RESPONSE
, "Response" },
44 { DXL_EVENT
, "Event" },
45 { DXL_ERROR
, "Error" },
49 static void dissect_dxl_event(tvbuff_t
* tvb
, packet_info
* pinfo
, proto_tree
* dxl_tree
, int* offset
)
51 tvbuff_t
* tvb_msgpack
;
53 tvb_msgpack
= tvb_new_subset_remaining(tvb
, *offset
);
54 *offset
= call_dissector_with_data(msgpack_handle
, tvb_msgpack
, pinfo
, dxl_tree
, "Message ID");
56 tvb_msgpack
= tvb_new_subset_remaining(tvb_msgpack
, *offset
);
57 *offset
= call_dissector_with_data(msgpack_handle
, tvb_msgpack
, pinfo
, dxl_tree
, "Client ID");
59 tvb_msgpack
= tvb_new_subset_remaining(tvb_msgpack
, *offset
);
60 *offset
= call_dissector_with_data(msgpack_handle
, tvb_msgpack
, pinfo
, dxl_tree
, "Source Broker ID");
62 tvb_msgpack
= tvb_new_subset_remaining(tvb_msgpack
, *offset
);
63 *offset
= call_dissector_with_data(msgpack_handle
, tvb_msgpack
, pinfo
, dxl_tree
, "Broker IDs");
65 tvb_msgpack
= tvb_new_subset_remaining(tvb_msgpack
, *offset
);
66 *offset
= call_dissector_with_data(msgpack_handle
, tvb_msgpack
, pinfo
, dxl_tree
, "Client IDs");
68 tvb_msgpack
= tvb_new_subset_remaining(tvb_msgpack
, *offset
);
69 *offset
= call_dissector_with_data(msgpack_handle
, tvb_msgpack
, pinfo
, dxl_tree
, "Payload");
71 tvb_msgpack
= tvb_new_subset_remaining(tvb_msgpack
, *offset
);
72 *offset
= call_dissector_with_data(msgpack_handle
, tvb_msgpack
, pinfo
, dxl_tree
, "Reply to topic");
74 tvb_msgpack
= tvb_new_subset_remaining(tvb_msgpack
, *offset
);
75 *offset
= call_dissector_with_data(msgpack_handle
, tvb_msgpack
, pinfo
, dxl_tree
, "Service ID");
78 static int dissect_dxl(tvbuff_t
* tvb
, packet_info
* pinfo
, proto_tree
* tree
, void* data _U_
)
85 ti
= proto_tree_add_item(tree
, proto_dxl
, tvb
, 0, -1, ENC_NA
);
86 dxl_tree
= proto_item_add_subtree(ti
, ett_dxl
);
88 proto_tree_add_item(dxl_tree
, hf_dxl_version
, tvb
, offset
, 1, ENC_NA
);
91 type
= tvb_get_uint8(tvb
, offset
);
93 proto_tree_add_item(dxl_tree
, hf_dxl_type
, tvb
, offset
, 1, ENC_NA
);
100 expert_add_info_format(pinfo
, tree
, &ei_dxl_unsupported
, "Type 0x%x is unsupported", type
);
103 dissect_dxl_event(tvb
, pinfo
, dxl_tree
, &offset
);
110 void proto_reg_handoff_dxl(void)
112 msgpack_handle
= find_dissector("msgpack");
115 void proto_register_dxl(void)
117 expert_module_t
* expert_dxl
;
119 static hf_register_info hf
[] = {
121 { "Version", "dxl.version", FT_UINT8
, BASE_DEC
, NULL
, 0x00, NULL
, HFILL
}
124 { "Type", "dxl.type", FT_UINT8
, BASE_HEX
, VALS(dxl_message_types
), 0x00, NULL
, HFILL
}
128 static int* ett
[] = {
132 proto_dxl
= proto_register_protocol("Data Exchange Layer", "DXL", "dxl");
133 register_dissector("dxl", dissect_dxl
, proto_dxl
);
135 proto_register_field_array(proto_dxl
, hf
, array_length(hf
));
136 proto_register_subtree_array(ett
, array_length(ett
));
138 static ei_register_info ei
[] = {
139 { &ei_dxl_unsupported
, { "dxl.type.unsupported", PI_UNDECODED
, PI_WARN
, "Unsupported DXL message", EXPFILL
}}
142 expert_dxl
= expert_register_protocol(proto_dxl
);
143 expert_register_field_array(expert_dxl
, ei
, array_length(ei
));
147 * Editor modelines - https://www.wireshark.org/tools/modelines.html
152 * indent-tabs-mode: t
155 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
156 * :indentSize=8:tabSize=8:noTabs=false: