Coverage Report

Created: 2025-02-15 06:25

/src/wireshark/epan/dissectors/packet-cimetrics.c
Line
Count
Source (jump to first uncovered line)
1
/* packet-cimetrics.c
2
 * Routines for Cimetrics LLC OUI dissection
3
 * Copyright 2008 Steve Karg <skarg@users.sourceforge.net> Alabama
4
 *
5
 * Wireshark - Network traffic analyzer
6
 * By Gerald Combs <gerald@wireshark.org>
7
 * Copyright 1998 Gerald Combs
8
 *
9
 * SPDX-License-Identifier: GPL-2.0-or-later
10
 */
11
12
#include "config.h"
13
14
#include <epan/packet.h>
15
#include "packet-llc.h"
16
#include <epan/oui.h>
17
#include "packet-mstp.h"
18
19
void proto_register_cimetrics(void);
20
void proto_reg_handoff_cimetrics(void);
21
22
/* Probably should be a preference, but here for now */
23
#define BACNET_MSTP_SUMMARY_IN_TREE
24
25
/* the U+4 device does MS/TP, uLAN, Modbus */
26
static const value_string cimetrics_pid_vals[] = {
27
  { 0x0001, "U+4 MS/TP" },
28
  { 0,    NULL }
29
};
30
31
static int proto_cimetrics_mstp;
32
static int hf_llc_cimetrics_pid;
33
static int ett_cimetrics_mstp;
34
35
static int hf_cimetrics_mstp_timer;
36
static int hf_cimetrics_mstp_value;
37
38
static dissector_handle_t cimetric_handle;
39
40
static int
41
dissect_cimetrics_mstp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
42
0
{
43
0
  proto_item *ti;
44
0
  proto_tree *subtree;
45
0
  int offset = 0;
46
0
#ifdef BACNET_MSTP_SUMMARY_IN_TREE
47
0
  uint8_t mstp_frame_type = 0;
48
0
  uint8_t mstp_frame_source = 0;
49
0
  uint8_t mstp_frame_destination = 0;
50
0
#endif
51
52
0
#ifdef BACNET_MSTP_SUMMARY_IN_TREE
53
0
  mstp_frame_type = tvb_get_uint8(tvb, offset+3);
54
0
  mstp_frame_destination = tvb_get_uint8(tvb, offset+4);
55
0
  mstp_frame_source = tvb_get_uint8(tvb, offset+5);
56
0
  ti = proto_tree_add_protocol_format(tree,
57
0
    proto_cimetrics_mstp, tvb, offset, 9,
58
0
    "BACnet MS/TP, Src (%u), Dst (%u), %s",
59
0
    mstp_frame_source, mstp_frame_destination,
60
0
    mstp_frame_type_text(mstp_frame_type));
61
#else
62
  ti = proto_tree_add_item(tree, proto_cimetrics_mstp, tvb, offset, 9, ENC_NA);
63
#endif
64
0
  subtree = proto_item_add_subtree(ti, ett_cimetrics_mstp);
65
0
  proto_tree_add_item(subtree, hf_cimetrics_mstp_timer, tvb,
66
0
      offset++, 2, ENC_LITTLE_ENDIAN);
67
0
  offset++;
68
0
  proto_tree_add_item(subtree, hf_cimetrics_mstp_value, tvb,
69
0
      offset++, 1, ENC_LITTLE_ENDIAN);
70
0
  dissect_mstp(tvb, pinfo, tree, subtree, offset);
71
0
  return tvb_captured_length(tvb);
72
0
}
73
74
void
75
proto_register_cimetrics(void)
76
14
{
77
14
  static hf_register_info hf[] = {
78
14
    { &hf_cimetrics_mstp_timer,
79
14
      { "Delta Time", "cimetrics.mstp_timer",
80
14
        FT_UINT16, BASE_DEC, NULL, 0,
81
14
        "Milliseconds", HFILL }
82
14
    },
83
14
    { &hf_cimetrics_mstp_value,
84
14
      { "8-bit value", "cimetrics.mstp_value",
85
14
        FT_UINT8, BASE_DEC, NULL, 0,
86
14
        NULL, HFILL }
87
14
    }
88
14
  };
89
14
  static hf_register_info hf2[] = {
90
14
    { &hf_llc_cimetrics_pid,
91
14
      { "PID", "llc.cimetrics_pid",
92
14
        FT_UINT16, BASE_HEX, VALS(cimetrics_pid_vals), 0,
93
14
        NULL, HFILL }
94
14
    }
95
14
  };
96
14
  static int *ett[] = {
97
14
    &ett_cimetrics_mstp
98
14
  };
99
100
14
  proto_cimetrics_mstp = proto_register_protocol("Cimetrics MS/TP",
101
14
                   "Cimetrics MS/TP", "cimetrics");
102
103
14
  proto_register_field_array(proto_cimetrics_mstp, hf, array_length(hf));
104
14
  proto_register_subtree_array(ett, array_length(ett));
105
106
14
  cimetric_handle = register_dissector("cimetrics", dissect_cimetrics_mstp, proto_cimetrics_mstp);
107
108
14
  llc_add_oui(OUI_CIMETRICS, "llc.cimetrics_pid",
109
14
        "LLC Cimetrics OUI PID", hf2, proto_cimetrics_mstp);
110
14
}
111
112
void
113
proto_reg_handoff_cimetrics(void)
114
14
{
115
14
  dissector_add_uint("llc.cimetrics_pid", 1, cimetric_handle);
116
14
}
117
118
/*
119
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
120
 *
121
 * Local variables:
122
 * c-basic-offset: 8
123
 * tab-width: 8
124
 * indent-tabs-mode: t
125
 * End:
126
 *
127
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
128
 * :indentSize=8:tabSize=8:noTabs=false:
129
 */