2 * Routines for PN-MRRT (PROFINET Media Redundancy for cyclic realtime data)
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
14 #include <epan/packet.h>
15 #include <epan/dissectors/packet-dcerpc.h>
17 #include "packet-pn.h"
19 void proto_register_pn_mrrt(void);
20 void proto_reg_handoff_pn_mrrt(void);
22 static int proto_pn_mrrt
;
24 static int hf_pn_mrrt_sequence_id
;
25 static int hf_pn_mrrt_domain_uuid
;
26 static int hf_pn_mrrt_type
;
27 static int hf_pn_mrrt_length
;
28 static int hf_pn_mrrt_version
;
29 static int hf_pn_mrrt_sa
;
32 static int ett_pn_mrrt
;
36 static const value_string pn_mrrt_block_type_vals
[] = {
40 /*0x03 - 0x7E Reserved */
41 { 0x7F, "Organizationally Specific"},
49 dissect_PNMRRT_Common(tvbuff_t
*tvb
, int offset
,
50 packet_info
*pinfo
, proto_tree
*tree
, proto_item
*item
, uint8_t length _U_
)
57 offset
= dissect_pn_uint16(tvb
, offset
, pinfo
, tree
, hf_pn_mrrt_sequence_id
, &sequence_id
);
60 offset
= dissect_pn_uuid(tvb
, offset
, pinfo
, tree
, hf_pn_mrrt_domain_uuid
, &uuid
);
62 col_append_str(pinfo
->cinfo
, COL_INFO
, "Common");
64 proto_item_append_text(item
, "Common");
71 dissect_PNMRRT_Test(tvbuff_t
*tvb
, int offset
,
72 packet_info
*pinfo
, proto_tree
*tree
, proto_item
*item
, uint8_t length _U_
)
78 offset
= dissect_pn_mac(tvb
, offset
, pinfo
, tree
, hf_pn_mrrt_sa
, mac
);
81 offset
= dissect_pn_align4(tvb
, offset
, pinfo
, tree
);
83 col_append_str(pinfo
->cinfo
, COL_INFO
, "Test");
85 proto_item_append_text(item
, "Test");
91 dissect_PNMRRT_PDU(tvbuff_t
*tvb
, int offset
,
92 packet_info
*pinfo
, proto_tree
*tree
, proto_item
*item
)
101 offset
= dissect_pn_uint16(tvb
, offset
, pinfo
, tree
, hf_pn_mrrt_version
, &version
);
103 while (tvb_reported_length_remaining(tvb
, offset
) > 0) {
104 /* MRRT_TLVHeader.Type */
105 offset
= dissect_pn_uint8(tvb
, offset
, pinfo
, tree
, hf_pn_mrrt_type
, &type
);
107 /* MRRT_TLVHeader.Length */
108 offset
= dissect_pn_uint8(tvb
, offset
, pinfo
, tree
, hf_pn_mrrt_length
, &length
);
112 col_append_str(pinfo
->cinfo
, COL_INFO
, ", ");
114 proto_item_append_text(item
, ", ");
122 col_append_str(pinfo
->cinfo
, COL_INFO
, "End");
123 proto_item_append_text(item
, "End");
126 offset
= dissect_PNMRRT_Common(tvb
, offset
, pinfo
, tree
, item
, length
);
129 offset
= dissect_PNMRRT_Test(tvb
, offset
, pinfo
, tree
, item
, length
);
132 offset
= dissect_pn_undecoded(tvb
, offset
, pinfo
, tree
, length
);
134 col_append_fstr(pinfo
->cinfo
, COL_INFO
, "Unknown TLVType 0x%x", type
);
135 proto_item_append_text(item
, "Unknown TLVType 0x%x", type
);
144 /* possibly dissect a PN-RT packet (frame ID must be in the appropriate range) */
146 dissect_PNMRRT_Data_heur(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
,
149 /* the tvb will NOT contain the frame_id here, so get it from dissector data! */
150 uint16_t u16FrameID
= GPOINTER_TO_UINT(data
);
152 proto_tree
*mrrt_tree
;
154 uint32_t u32SubStart
;
157 /* frame id must be in valid range (MRRT) */
158 if (u16FrameID
!= 0xFF60) {
159 /* we are not interested in this packet */
163 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "PN-MRRT");
164 col_clear(pinfo
->cinfo
, COL_INFO
);
166 /* subtree for MRRT */
167 item
= proto_tree_add_protocol_format(tree
, proto_pn_mrrt
, tvb
, 0, 0, "PROFINET MRRT, ");
168 mrrt_tree
= proto_item_add_subtree(item
, ett_pn_mrrt
);
169 u32SubStart
= offset
;
171 offset
= dissect_PNMRRT_PDU(tvb
, offset
, pinfo
, mrrt_tree
, item
);
173 proto_item_set_len(item
, offset
- u32SubStart
);
180 proto_register_pn_mrrt (void)
182 static hf_register_info hf
[] = {
185 { "Type", "pn_mrrt.type",
186 FT_UINT8
, BASE_HEX
, VALS(pn_mrrt_block_type_vals
), 0x0,
189 { &hf_pn_mrrt_length
,
190 { "Length", "pn_mrrt.length",
191 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
194 { &hf_pn_mrrt_version
,
195 { "Version", "pn_mrrt.version",
196 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
199 { &hf_pn_mrrt_sequence_id
,
200 { "SequenceID", "pn_mrrt.sequence_id",
201 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
202 "Unique sequence number to each outstanding service request", HFILL
}},
205 { "SA", "pn_mrrt.sa",
206 FT_ETHER
, BASE_NONE
, 0x0, 0x0,
209 { &hf_pn_mrrt_domain_uuid
,
210 { "DomainUUID", "pn_mrrt.domain_uuid",
211 FT_GUID
, BASE_NONE
, NULL
, 0x0,
217 static int *ett
[] = {
221 proto_pn_mrrt
= proto_register_protocol ("PROFINET MRRT", "PN-MRRT", "pn_mrrt");
222 proto_register_field_array (proto_pn_mrrt
, hf
, array_length (hf
));
223 proto_register_subtree_array (ett
, array_length (ett
));
228 proto_reg_handoff_pn_mrrt (void)
231 /* register ourself as an heuristic pn-rt payload dissector */
232 heur_dissector_add("pn_rt", dissect_PNMRRT_Data_heur
, "PROFINET MRRT IO", "pn_mrrt_pn_rt", proto_pn_mrrt
, HEURISTIC_ENABLE
);
236 * Editor modelines - https://www.wireshark.org/tools/modelines.html
241 * indent-tabs-mode: nil
244 * vi: set shiftwidth=4 tabstop=8 expandtab:
245 * :indentSize=4:tabSize=8:noTabs=true: