Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-drb.c
blob82e5aaa97c52116a1926988142aee777339afd87
1 /* packet-drb.c
3 * Routines for Ruby Marshal Object
5 * Copyright 2018, Dario Lombardo (lomato@gmail.com)
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include "config.h"
15 #include <epan/packet.h>
16 #include <file-rbm.h>
18 static dissector_handle_t drb_handle;
20 static int proto_drb;
22 static int hf_drb_len;
24 static int ett_drb;
25 static int ett_ref;
27 void proto_register_drb(void);
28 void proto_reg_handoff_drb(void);
30 static void dissect_drb_object(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, unsigned* offset, const char* label)
32 uint32_t len;
33 proto_tree* obj_tree;
34 char* type;
35 char* value;
37 len = tvb_get_uint32(tvb, *offset, ENC_BIG_ENDIAN);
38 obj_tree = proto_tree_add_subtree(tree, tvb, *offset, 4 + len, ett_ref, NULL, label);
39 proto_tree_add_item(obj_tree, hf_drb_len, tvb, *offset, 4, ENC_NA);
40 *offset += 4;
41 dissect_rbm_inline(tvb, pinfo, obj_tree, offset, &type, &value);
42 if (type)
43 proto_item_append_text(obj_tree, "Type: %s", type);
44 if (value)
45 proto_item_append_text(obj_tree, "Value: %s", value);
48 static void dissect_drb_response(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, unsigned* offset)
50 col_append_str(pinfo->cinfo, COL_INFO, " (response)");
51 dissect_drb_object(tvb, pinfo, tree, offset, "Success");
52 dissect_drb_object(tvb, pinfo, tree, offset, "Response");
55 static void dissect_drb_request(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, unsigned* offset)
57 int32_t nargs;
58 int32_t i;
59 int len;
60 char* loop_label;
62 col_append_str(pinfo->cinfo, COL_INFO, " (request)");
63 dissect_drb_object(tvb, pinfo, tree, offset, "Ref");
64 dissect_drb_object(tvb, pinfo, tree, offset, "Msg ID");
65 get_rbm_integer(tvb, *offset + 4 + 3, &nargs, &len);
66 dissect_drb_object(tvb, pinfo, tree, offset, "Arg length");
67 for (i = 0; i < nargs; i++) {
68 loop_label = wmem_strdup_printf(pinfo->pool, "Arg %d", i + 1);
69 dissect_drb_object(tvb, pinfo, tree, offset, loop_label);
71 dissect_drb_object(tvb, pinfo, tree, offset, "Block");
74 static int dissect_drb(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_)
76 unsigned offset = 0;
77 proto_tree* ti;
78 proto_tree* drb_tree;
79 uint8_t type;
81 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DRb");
82 col_clear(pinfo->cinfo, COL_INFO);
83 col_set_str(pinfo->cinfo, COL_INFO, "Distributed Ruby");
85 ti = proto_tree_add_item(tree, proto_drb, tvb, 0, -1, ENC_NA);
86 drb_tree = proto_item_add_subtree(ti, ett_drb);
88 type = tvb_get_uint8(tvb, 6);
89 if (type == 'T' || type == 'F') {
90 dissect_drb_response(tvb, pinfo, drb_tree, &offset);
91 } else {
92 dissect_drb_request(tvb, pinfo, drb_tree, &offset);
95 return offset;
98 void proto_register_drb(void)
100 static hf_register_info hf[] = {
101 { &hf_drb_len,
102 { "Length", "drb.length", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }
106 /* Setup protocol subtree array */
107 static int* ett[] = {
108 &ett_drb,
109 &ett_ref
112 proto_drb = proto_register_protocol("Distributed Ruby", "DRb", "drb");
113 drb_handle = register_dissector("drb", dissect_drb, proto_drb);
115 proto_register_field_array(proto_drb, hf, array_length(hf));
116 proto_register_subtree_array(ett, array_length(ett));
119 void proto_reg_handoff_drb(void)
121 dissector_add_for_decode_as_with_preference("tcp.port", drb_handle);
125 * Editor modelines - https://www.wireshark.org/tools/modelines.html
127 * Local variables:
128 * c-basic-offset: 8
129 * tab-width: 8
130 * indent-tabs-mode: t
131 * End:
133 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
134 * :indentSize=8:tabSize=8:noTabs=false: