Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-cimetrics.c
blobfcb3069c21387fe7e4433c2921d0378cb11829b0
1 /* packet-cimetrics.c
2 * Routines for Cimetrics LLC OUI dissection
3 * Copyright 2008 Steve Karg <skarg@users.sourceforge.net> Alabama
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include "config.h"
14 #include <epan/packet.h>
15 #include "packet-llc.h"
16 #include <epan/oui.h>
17 #include "packet-mstp.h"
19 void proto_register_cimetrics(void);
20 void proto_reg_handoff_cimetrics(void);
22 /* Probably should be a preference, but here for now */
23 #define BACNET_MSTP_SUMMARY_IN_TREE
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 }
31 static int proto_cimetrics_mstp;
32 static int hf_llc_cimetrics_pid;
33 static int ett_cimetrics_mstp;
35 static int hf_cimetrics_mstp_timer;
36 static int hf_cimetrics_mstp_value;
38 static dissector_handle_t cimetric_handle;
40 static int
41 dissect_cimetrics_mstp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
43 proto_item *ti;
44 proto_tree *subtree;
45 int offset = 0;
46 #ifdef BACNET_MSTP_SUMMARY_IN_TREE
47 uint8_t mstp_frame_type = 0;
48 uint8_t mstp_frame_source = 0;
49 uint8_t mstp_frame_destination = 0;
50 #endif
52 #ifdef BACNET_MSTP_SUMMARY_IN_TREE
53 mstp_frame_type = tvb_get_uint8(tvb, offset+3);
54 mstp_frame_destination = tvb_get_uint8(tvb, offset+4);
55 mstp_frame_source = tvb_get_uint8(tvb, offset+5);
56 ti = proto_tree_add_protocol_format(tree,
57 proto_cimetrics_mstp, tvb, offset, 9,
58 "BACnet MS/TP, Src (%u), Dst (%u), %s",
59 mstp_frame_source, mstp_frame_destination,
60 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 subtree = proto_item_add_subtree(ti, ett_cimetrics_mstp);
65 proto_tree_add_item(subtree, hf_cimetrics_mstp_timer, tvb,
66 offset++, 2, ENC_LITTLE_ENDIAN);
67 offset++;
68 proto_tree_add_item(subtree, hf_cimetrics_mstp_value, tvb,
69 offset++, 1, ENC_LITTLE_ENDIAN);
70 dissect_mstp(tvb, pinfo, tree, subtree, offset);
71 return tvb_captured_length(tvb);
74 void
75 proto_register_cimetrics(void)
77 static hf_register_info hf[] = {
78 { &hf_cimetrics_mstp_timer,
79 { "Delta Time", "cimetrics.mstp_timer",
80 FT_UINT16, BASE_DEC, NULL, 0,
81 "Milliseconds", HFILL }
83 { &hf_cimetrics_mstp_value,
84 { "8-bit value", "cimetrics.mstp_value",
85 FT_UINT8, BASE_DEC, NULL, 0,
86 NULL, HFILL }
89 static hf_register_info hf2[] = {
90 { &hf_llc_cimetrics_pid,
91 { "PID", "llc.cimetrics_pid",
92 FT_UINT16, BASE_HEX, VALS(cimetrics_pid_vals), 0,
93 NULL, HFILL }
96 static int *ett[] = {
97 &ett_cimetrics_mstp
100 proto_cimetrics_mstp = proto_register_protocol("Cimetrics MS/TP",
101 "Cimetrics MS/TP", "cimetrics");
103 proto_register_field_array(proto_cimetrics_mstp, hf, array_length(hf));
104 proto_register_subtree_array(ett, array_length(ett));
106 cimetric_handle = register_dissector("cimetrics", dissect_cimetrics_mstp, proto_cimetrics_mstp);
108 llc_add_oui(OUI_CIMETRICS, "llc.cimetrics_pid",
109 "LLC Cimetrics OUI PID", hf2, proto_cimetrics_mstp);
112 void
113 proto_reg_handoff_cimetrics(void)
115 dissector_add_uint("llc.cimetrics_pid", 1, cimetric_handle);
119 * Editor modelines - https://www.wireshark.org/tools/modelines.html
121 * Local variables:
122 * c-basic-offset: 8
123 * tab-width: 8
124 * indent-tabs-mode: t
125 * End:
127 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
128 * :indentSize=8:tabSize=8:noTabs=false: