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
15 #include <epan/packet.h>
18 static dissector_handle_t drb_handle
;
22 static int hf_drb_len
;
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
)
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
);
41 dissect_rbm_inline(tvb
, pinfo
, obj_tree
, offset
, &type
, &value
);
43 proto_item_append_text(obj_tree
, "Type: %s", type
);
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
)
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_
)
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
);
92 dissect_drb_request(tvb
, pinfo
, drb_tree
, &offset
);
98 void proto_register_drb(void)
100 static hf_register_info hf
[] = {
102 { "Length", "drb.length", FT_UINT32
, BASE_DEC
, NULL
, 0x00, NULL
, HFILL
}
106 /* Setup protocol subtree array */
107 static int* ett
[] = {
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
130 * indent-tabs-mode: t
133 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
134 * :indentSize=8:tabSize=8:noTabs=false: