2006-06-13 18:26:49 +00:00
|
|
|
/* packet-pn-mrrt.c
|
2012-12-13 18:17:47 +00:00
|
|
|
* Routines for PN-MRRT (PROFINET Media Redundancy for cyclic realtime data)
|
2006-06-13 18:26:49 +00:00
|
|
|
* packet dissection.
|
|
|
|
*
|
2006-06-17 12:07:49 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2006-06-13 18:26:49 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2012-12-13 18:17:47 +00:00
|
|
|
*
|
2018-02-09 08:52:20 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2006-06-13 18:26:49 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
2014-12-22 04:54:35 +00:00
|
|
|
#include <epan/dissectors/packet-dcerpc.h>
|
2007-02-16 21:53:36 +00:00
|
|
|
|
|
|
|
#include "packet-pn.h"
|
2006-06-13 18:26:49 +00:00
|
|
|
|
2014-01-01 12:17:57 +00:00
|
|
|
void proto_register_pn_mrrt(void);
|
|
|
|
void proto_reg_handoff_pn_mrrt(void);
|
|
|
|
|
2006-06-13 18:26:49 +00:00
|
|
|
static int proto_pn_mrrt = -1;
|
|
|
|
|
|
|
|
static int hf_pn_mrrt_sequence_id = -1;
|
|
|
|
static int hf_pn_mrrt_domain_uuid = -1;
|
|
|
|
static int hf_pn_mrrt_type = -1;
|
|
|
|
static int hf_pn_mrrt_length = -1;
|
|
|
|
static int hf_pn_mrrt_version = -1;
|
|
|
|
static int hf_pn_mrrt_sa = -1;
|
|
|
|
|
|
|
|
|
|
|
|
static gint ett_pn_mrrt = -1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const value_string pn_mrrt_block_type_vals[] = {
|
2012-12-13 18:17:47 +00:00
|
|
|
{ 0x00, "End" },
|
|
|
|
{ 0x01, "Common" },
|
|
|
|
{ 0x02, "Test" },
|
2006-06-13 18:26:49 +00:00
|
|
|
/*0x03 - 0x7E Reserved */
|
2012-12-13 18:17:47 +00:00
|
|
|
{ 0x7F, "Organizationally Specific"},
|
|
|
|
{ 0, NULL },
|
2006-06-13 18:26:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2012-12-13 18:17:47 +00:00
|
|
|
dissect_PNMRRT_Common(tvbuff_t *tvb, int offset,
|
|
|
|
packet_info *pinfo, proto_tree *tree, proto_item *item, guint8 length _U_)
|
2006-06-13 18:26:49 +00:00
|
|
|
{
|
2012-12-13 18:17:47 +00:00
|
|
|
guint16 sequence_id;
|
2015-03-03 10:47:53 +00:00
|
|
|
e_guid_t uuid;
|
2006-06-13 18:26:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* MRRT_SequenceID */
|
|
|
|
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrrt_sequence_id, &sequence_id);
|
|
|
|
|
|
|
|
/* MRRT_DomainUUID */
|
|
|
|
offset = dissect_pn_uuid(tvb, offset, pinfo, tree, hf_pn_mrrt_domain_uuid, &uuid);
|
|
|
|
|
2009-09-24 20:21:23 +00:00
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, "Common");
|
2006-06-13 18:26:49 +00:00
|
|
|
|
|
|
|
proto_item_append_text(item, "Common");
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2012-12-13 18:17:47 +00:00
|
|
|
dissect_PNMRRT_Test(tvbuff_t *tvb, int offset,
|
|
|
|
packet_info *pinfo, proto_tree *tree, proto_item *item, guint8 length _U_)
|
2006-06-13 18:26:49 +00:00
|
|
|
{
|
|
|
|
guint8 mac[6];
|
|
|
|
|
|
|
|
|
|
|
|
/* MRRT_SA */
|
|
|
|
offset = dissect_pn_mac(tvb, offset, pinfo, tree, hf_pn_mrrt_sa, mac);
|
|
|
|
|
|
|
|
/* Padding */
|
2007-02-16 21:53:36 +00:00
|
|
|
offset = dissect_pn_align4(tvb, offset, pinfo, tree);
|
2006-06-13 18:26:49 +00:00
|
|
|
|
2009-09-24 20:21:23 +00:00
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, "Test");
|
2006-06-13 18:26:49 +00:00
|
|
|
|
|
|
|
proto_item_append_text(item, "Test");
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-12-13 18:17:47 +00:00
|
|
|
dissect_PNMRRT_PDU(tvbuff_t *tvb, int offset,
|
|
|
|
packet_info *pinfo, proto_tree *tree, proto_item *item)
|
2006-06-13 18:26:49 +00:00
|
|
|
{
|
|
|
|
guint16 version;
|
2012-12-13 18:17:47 +00:00
|
|
|
guint8 type;
|
|
|
|
guint8 length;
|
|
|
|
gint i = 0;
|
2006-06-13 18:26:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* MRRT_Version */
|
|
|
|
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrrt_version, &version);
|
|
|
|
|
2015-04-06 01:21:51 +00:00
|
|
|
while (tvb_reported_length_remaining(tvb, offset) > 0) {
|
2006-06-13 18:26:49 +00:00
|
|
|
/* MRRT_TLVHeader.Type */
|
|
|
|
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_mrrt_type, &type);
|
|
|
|
|
|
|
|
/* MRRT_TLVHeader.Length */
|
|
|
|
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_mrrt_length, &length);
|
|
|
|
|
|
|
|
|
2012-12-13 18:17:47 +00:00
|
|
|
if (i != 0) {
|
2009-09-24 20:21:23 +00:00
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, ", ");
|
2006-06-13 18:26:49 +00:00
|
|
|
|
|
|
|
proto_item_append_text(item, ", ");
|
|
|
|
}
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
switch(type) {
|
2012-12-13 18:17:47 +00:00
|
|
|
case 0x00:
|
2006-06-13 18:26:49 +00:00
|
|
|
/* no content */
|
2009-09-24 20:21:23 +00:00
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, "End");
|
2006-06-13 18:26:49 +00:00
|
|
|
proto_item_append_text(item, "End");
|
|
|
|
return offset;
|
|
|
|
break;
|
2012-12-13 18:17:47 +00:00
|
|
|
case 0x01:
|
2006-06-13 18:26:49 +00:00
|
|
|
offset = dissect_PNMRRT_Common(tvb, offset, pinfo, tree, item, length);
|
|
|
|
break;
|
2012-12-13 18:17:47 +00:00
|
|
|
case 0x02:
|
2006-06-13 18:26:49 +00:00
|
|
|
offset = dissect_PNMRRT_Test(tvb, offset, pinfo, tree, item, length);
|
|
|
|
break;
|
|
|
|
default:
|
2007-02-16 21:53:36 +00:00
|
|
|
offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, length);
|
2006-06-13 18:26:49 +00:00
|
|
|
|
2012-12-13 18:17:47 +00:00
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, "Unknown TLVType 0x%x", type);
|
|
|
|
proto_item_append_text(item, "Unknown TLVType 0x%x", type);
|
|
|
|
break;
|
2006-06-13 18:26:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* possibly dissect a PN-RT packet (frame ID must be in the appropriate range) */
|
|
|
|
static gboolean
|
2012-09-10 21:40:21 +00:00
|
|
|
dissect_PNMRRT_Data_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
2014-11-23 05:12:57 +00:00
|
|
|
void *data)
|
2006-06-13 18:26:49 +00:00
|
|
|
{
|
2014-11-23 05:12:57 +00:00
|
|
|
/* the tvb will NOT contain the frame_id here, so get it from dissector data! */
|
|
|
|
guint16 u16FrameID = GPOINTER_TO_UINT(data);
|
2012-12-13 18:17:47 +00:00
|
|
|
proto_item *item;
|
|
|
|
proto_tree *mrrt_tree;
|
|
|
|
int offset = 0;
|
|
|
|
guint32 u32SubStart;
|
2006-06-13 18:26:49 +00:00
|
|
|
|
|
|
|
|
2012-12-13 18:17:47 +00:00
|
|
|
/* frame id must be in valid range (MRRT) */
|
|
|
|
if (u16FrameID != 0xFF60) {
|
2006-06-13 18:26:49 +00:00
|
|
|
/* we are not interested in this packet */
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-12-13 18:17:47 +00:00
|
|
|
|
2010-01-13 20:32:01 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "PN-MRRT");
|
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2006-06-13 18:26:49 +00:00
|
|
|
|
|
|
|
/* subtree for MRRT */
|
2012-12-13 18:17:47 +00:00
|
|
|
item = proto_tree_add_protocol_format(tree, proto_pn_mrrt, tvb, 0, 0, "PROFINET MRRT, ");
|
|
|
|
mrrt_tree = proto_item_add_subtree(item, ett_pn_mrrt);
|
2006-06-13 18:26:49 +00:00
|
|
|
u32SubStart = offset;
|
|
|
|
|
|
|
|
offset = dissect_PNMRRT_PDU(tvb, offset, pinfo, mrrt_tree, item);
|
|
|
|
|
2012-12-13 18:17:47 +00:00
|
|
|
proto_item_set_len(item, offset - u32SubStart);
|
2006-06-13 18:26:49 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_pn_mrrt (void)
|
|
|
|
{
|
2012-12-13 18:17:47 +00:00
|
|
|
static hf_register_info hf[] = {
|
|
|
|
|
|
|
|
{ &hf_pn_mrrt_type,
|
|
|
|
{ "Type", "pn_mrrt.type",
|
|
|
|
FT_UINT8, BASE_HEX, VALS(pn_mrrt_block_type_vals), 0x0,
|
|
|
|
NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pn_mrrt_length,
|
|
|
|
{ "Length", "pn_mrrt.length",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
|
|
|
NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pn_mrrt_version,
|
|
|
|
{ "Version", "pn_mrrt.version",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pn_mrrt_sequence_id,
|
|
|
|
{ "SequenceID", "pn_mrrt.sequence_id",
|
|
|
|
FT_UINT16, BASE_HEX, NULL, 0x0,
|
|
|
|
"Unique sequence number to each outstanding service request", HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pn_mrrt_sa,
|
|
|
|
{ "SA", "pn_mrrt.sa",
|
|
|
|
FT_ETHER, BASE_NONE, 0x0, 0x0,
|
|
|
|
NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pn_mrrt_domain_uuid,
|
|
|
|
{ "DomainUUID", "pn_mrrt.domain_uuid",
|
|
|
|
FT_GUID, BASE_NONE, NULL, 0x0,
|
|
|
|
NULL, HFILL }},
|
|
|
|
|
2006-06-13 18:26:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-12-13 18:17:47 +00:00
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_pn_mrrt
|
2006-06-13 18:26:49 +00:00
|
|
|
};
|
|
|
|
|
2012-12-13 18:17:47 +00:00
|
|
|
proto_pn_mrrt = proto_register_protocol ("PROFINET MRRT", "PN-MRRT", "pn_mrrt");
|
|
|
|
proto_register_field_array (proto_pn_mrrt, hf, array_length (hf));
|
|
|
|
proto_register_subtree_array (ett, array_length (ett));
|
2006-06-13 18:26:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_pn_mrrt (void)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* register ourself as an heuristic pn-rt payload dissector */
|
2015-07-13 00:40:31 +00:00
|
|
|
heur_dissector_add("pn_rt", dissect_PNMRRT_Data_heur, "PROFINET MRRT IO", "pn_mrrt_pn_rt", proto_pn_mrrt, HEURISTIC_ENABLE);
|
2006-06-13 18:26:49 +00:00
|
|
|
}
|
2014-10-06 01:34:19 +00:00
|
|
|
|
|
|
|
/*
|
2019-07-26 18:43:17 +00:00
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
2014-10-06 01:34:19 +00:00
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|