2018-05-25 09:13:42 +00:00
|
|
|
/* packet-drb.c
|
|
|
|
*
|
|
|
|
* Routines for Ruby Marshal Object
|
|
|
|
*
|
|
|
|
* Copyright 2018, Dario Lombardo (lomato@gmail.com)
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <file-rbm.h>
|
|
|
|
|
|
|
|
static int proto_drb = -1;
|
|
|
|
|
|
|
|
static int hf_drb_len = -1;
|
|
|
|
|
|
|
|
static gint ett_drb = -1;
|
|
|
|
static gint ett_ref = -1;
|
|
|
|
|
2018-06-22 11:50:40 +00:00
|
|
|
void proto_register_drb(void);
|
|
|
|
void proto_reg_handoff_drb(void);
|
|
|
|
|
drb: fix compiler warnings.
[1/1] Building C object epan/dissectors/CMakeFiles/dissectors.dir/packet-drb.c.o
../epan/dissectors/packet-drb.c: In function ‘dissect_drb_object’:
../epan/dissectors/packet-drb.c:39:43: warning: pointer targets in passing argument 4 of ‘dissect_rbm_inline’ differ in signedness [-Wpointer-sign]
39 | dissect_rbm_inline(tvb, pinfo, obj_tree, offset, &type, &value);
| ^~~~~~
| |
| gint * {aka int *}
In file included from ../epan/dissectors/packet-drb.c:16:
../epan/dissectors/file-rbm.h:15:85: note: expected ‘guint *’ {aka ‘unsigned int *’} but argument is of type ‘gint *’ {aka ‘int *’}
15 | void dissect_rbm_inline(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, guint* offset, gchar** type, gchar** value);
| ~~~~~~~^~~~~~
2020-12-31 17:55:02 +00:00
|
|
|
static void dissect_drb_object(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, guint* offset, const gchar* label)
|
2018-05-25 09:13:42 +00:00
|
|
|
{
|
|
|
|
guint32 len;
|
|
|
|
proto_tree* obj_tree;
|
2018-06-13 12:44:25 +00:00
|
|
|
gchar* type;
|
2018-05-25 09:13:42 +00:00
|
|
|
gchar* value;
|
|
|
|
|
|
|
|
len = tvb_get_guint32(tvb, *offset, ENC_BIG_ENDIAN);
|
|
|
|
obj_tree = proto_tree_add_subtree(tree, tvb, *offset, 4 + len, ett_ref, NULL, label);
|
|
|
|
proto_tree_add_item(obj_tree, hf_drb_len, tvb, *offset, 4, ENC_NA);
|
|
|
|
*offset += 4;
|
2018-06-13 12:44:25 +00:00
|
|
|
dissect_rbm_inline(tvb, pinfo, obj_tree, offset, &type, &value);
|
|
|
|
if (type)
|
|
|
|
proto_item_append_text(obj_tree, "Type: %s", type);
|
|
|
|
if (value)
|
|
|
|
proto_item_append_text(obj_tree, "Value: %s", value);
|
2018-05-25 09:13:42 +00:00
|
|
|
}
|
|
|
|
|
drb: fix compiler warnings.
[1/1] Building C object epan/dissectors/CMakeFiles/dissectors.dir/packet-drb.c.o
../epan/dissectors/packet-drb.c: In function ‘dissect_drb_object’:
../epan/dissectors/packet-drb.c:39:43: warning: pointer targets in passing argument 4 of ‘dissect_rbm_inline’ differ in signedness [-Wpointer-sign]
39 | dissect_rbm_inline(tvb, pinfo, obj_tree, offset, &type, &value);
| ^~~~~~
| |
| gint * {aka int *}
In file included from ../epan/dissectors/packet-drb.c:16:
../epan/dissectors/file-rbm.h:15:85: note: expected ‘guint *’ {aka ‘unsigned int *’} but argument is of type ‘gint *’ {aka ‘int *’}
15 | void dissect_rbm_inline(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, guint* offset, gchar** type, gchar** value);
| ~~~~~~~^~~~~~
2020-12-31 17:55:02 +00:00
|
|
|
static void dissect_drb_response(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, guint* offset)
|
2018-05-25 09:13:42 +00:00
|
|
|
{
|
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, " (response)");
|
|
|
|
dissect_drb_object(tvb, pinfo, tree, offset, "Success");
|
|
|
|
dissect_drb_object(tvb, pinfo, tree, offset, "Response");
|
|
|
|
}
|
|
|
|
|
drb: fix compiler warnings.
[1/1] Building C object epan/dissectors/CMakeFiles/dissectors.dir/packet-drb.c.o
../epan/dissectors/packet-drb.c: In function ‘dissect_drb_object’:
../epan/dissectors/packet-drb.c:39:43: warning: pointer targets in passing argument 4 of ‘dissect_rbm_inline’ differ in signedness [-Wpointer-sign]
39 | dissect_rbm_inline(tvb, pinfo, obj_tree, offset, &type, &value);
| ^~~~~~
| |
| gint * {aka int *}
In file included from ../epan/dissectors/packet-drb.c:16:
../epan/dissectors/file-rbm.h:15:85: note: expected ‘guint *’ {aka ‘unsigned int *’} but argument is of type ‘gint *’ {aka ‘int *’}
15 | void dissect_rbm_inline(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, guint* offset, gchar** type, gchar** value);
| ~~~~~~~^~~~~~
2020-12-31 17:55:02 +00:00
|
|
|
static void dissect_drb_request(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, guint* offset)
|
2018-05-25 09:13:42 +00:00
|
|
|
{
|
|
|
|
gint32 nargs;
|
|
|
|
gint32 i;
|
2020-07-07 07:03:18 +00:00
|
|
|
gint len;
|
2018-05-25 09:13:42 +00:00
|
|
|
gchar* loop_label;
|
|
|
|
|
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, " (request)");
|
|
|
|
dissect_drb_object(tvb, pinfo, tree, offset, "Ref");
|
|
|
|
dissect_drb_object(tvb, pinfo, tree, offset, "Msg ID");
|
|
|
|
get_rbm_integer(tvb, *offset + 4 + 3, &nargs, &len);
|
|
|
|
dissect_drb_object(tvb, pinfo, tree, offset, "Arg length");
|
|
|
|
for (i = 0; i < nargs; i++) {
|
|
|
|
loop_label = wmem_strdup_printf(wmem_packet_scope(), "Arg %d", i + 1);
|
|
|
|
dissect_drb_object(tvb, pinfo, tree, offset, loop_label);
|
|
|
|
}
|
|
|
|
dissect_drb_object(tvb, pinfo, tree, offset, "Block");
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dissect_drb(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_)
|
|
|
|
{
|
drb: fix compiler warnings.
[1/1] Building C object epan/dissectors/CMakeFiles/dissectors.dir/packet-drb.c.o
../epan/dissectors/packet-drb.c: In function ‘dissect_drb_object’:
../epan/dissectors/packet-drb.c:39:43: warning: pointer targets in passing argument 4 of ‘dissect_rbm_inline’ differ in signedness [-Wpointer-sign]
39 | dissect_rbm_inline(tvb, pinfo, obj_tree, offset, &type, &value);
| ^~~~~~
| |
| gint * {aka int *}
In file included from ../epan/dissectors/packet-drb.c:16:
../epan/dissectors/file-rbm.h:15:85: note: expected ‘guint *’ {aka ‘unsigned int *’} but argument is of type ‘gint *’ {aka ‘int *’}
15 | void dissect_rbm_inline(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, guint* offset, gchar** type, gchar** value);
| ~~~~~~~^~~~~~
2020-12-31 17:55:02 +00:00
|
|
|
guint offset = 0;
|
2018-05-25 09:13:42 +00:00
|
|
|
proto_tree* ti;
|
|
|
|
proto_tree* drb_tree;
|
|
|
|
guint8 type;
|
|
|
|
|
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "DRb");
|
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "Distributed Ruby");
|
|
|
|
|
|
|
|
ti = proto_tree_add_item(tree, proto_drb, tvb, 0, -1, ENC_NA);
|
|
|
|
drb_tree = proto_item_add_subtree(ti, ett_drb);
|
|
|
|
|
|
|
|
type = tvb_get_guint8(tvb, 6);
|
|
|
|
if (type == 'T' || type == 'F') {
|
|
|
|
dissect_drb_response(tvb, pinfo, drb_tree, &offset);
|
|
|
|
} else {
|
|
|
|
dissect_drb_request(tvb, pinfo, drb_tree, &offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void proto_register_drb(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_drb_len,
|
|
|
|
{ "Length", "drb.length", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Setup protocol subtree array */
|
|
|
|
static gint* ett[] = {
|
|
|
|
&ett_drb,
|
|
|
|
&ett_ref
|
|
|
|
};
|
|
|
|
|
|
|
|
proto_drb = proto_register_protocol("Distributed Ruby", "DRb", "drb");
|
|
|
|
|
|
|
|
proto_register_field_array(proto_drb, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
}
|
|
|
|
|
|
|
|
void proto_reg_handoff_drb(void)
|
|
|
|
{
|
2018-06-25 17:21:13 +00:00
|
|
|
dissector_handle_t drb_handle;
|
2018-05-25 09:13:42 +00:00
|
|
|
|
2018-06-25 17:21:13 +00:00
|
|
|
drb_handle = create_dissector_handle(dissect_drb, proto_drb);
|
|
|
|
dissector_add_for_decode_as_with_preference("tcp.port", drb_handle);
|
2018-05-25 09:13:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2019-07-26 18:43:17 +00:00
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
2018-05-25 09:13:42 +00:00
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
* :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
*/
|