Coverage Report

Created: 2025-12-27 06:52

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