Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-dxl.c
blob871c892602c09a87bb939d587c10aa90aebad503
1 /* packet-dxl.c
3 * Routines for DXL dissection
4 * Github projects:
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
16 #include "config.h"
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);
25 static int proto_dxl;
27 static int hf_dxl_version;
28 static int hf_dxl_type;
30 static int ett_dxl;
32 static expert_field ei_dxl_unsupported;
34 static dissector_handle_t msgpack_handle;
36 #define DXL_REQUEST 0
37 #define DXL_RESPONSE 1
38 #define DXL_EVENT 2
39 #define DXL_ERROR 3
41 static const value_string dxl_message_types[] = {
42 { DXL_REQUEST, "Request" },
43 { DXL_RESPONSE, "Response" },
44 { DXL_EVENT, "Event" },
45 { DXL_ERROR, "Error" },
46 { 0, NULL }
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_)
80 int offset = 0;
81 proto_item* ti;
82 proto_tree* dxl_tree;
83 uint8_t type;
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);
89 offset += 1;
91 type = tvb_get_uint8(tvb, offset);
93 proto_tree_add_item(dxl_tree, hf_dxl_type, tvb, offset, 1, ENC_NA);
94 offset += 1;
96 switch (type) {
97 case DXL_REQUEST:
98 case DXL_RESPONSE:
99 case DXL_ERROR:
100 expert_add_info_format(pinfo, tree, &ei_dxl_unsupported, "Type 0x%x is unsupported", type);
101 break;
102 case DXL_EVENT:
103 dissect_dxl_event(tvb, pinfo, dxl_tree, &offset);
104 break;
107 return 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[] = {
120 { &hf_dxl_version,
121 { "Version", "dxl.version", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL }
123 { &hf_dxl_type,
124 { "Type", "dxl.type", FT_UINT8, BASE_HEX, VALS(dxl_message_types), 0x00, NULL, HFILL }
128 static int* ett[] = {
129 &ett_dxl
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
149 * Local variables:
150 * c-basic-offset: 8
151 * tab-width: 8
152 * indent-tabs-mode: t
153 * End:
155 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
156 * :indentSize=8:tabSize=8:noTabs=false: