(on behalf of the PROFIBUS Nutzerorganisation e.V. Deutschland):

add Media Redundancy and Media Redundancy Realtime Protocol dissectors (PN-MRP and PN-MRRT)

svn path=/trunk/; revision=18454
This commit is contained in:
Ulf Lamping 2006-06-13 18:26:49 +00:00
parent aa748fc102
commit f1f0e294b4
6 changed files with 744 additions and 2 deletions

View File

@ -298,7 +298,7 @@
#endif /* http://tipc.sourceforge.net/) Ericsson Research Canada Inc */
#ifndef ETHERTYPE_LLDP
#define ETHERTYPE_LLDP 0x88cc /* IEEE 802.1 Link Layer Discovery Protocol (LLDP) */
#define ETHERTYPE_LLDP 0x88cc /* IEEE 802.1AB Link Layer Discovery Protocol (LLDP) */
#endif
#ifndef ETHERTYPE_3GPP2
@ -306,6 +306,10 @@
#endif /* Specification (IOS) for cdma2000 Access Network Interfaces (document numbers A.S0011-B */
/* through A.S0017-B v1.0). This document already uses the Ether type 8881 */
#ifndef ETHERTYPE_MRP
#define ETHERTYPE_MRP 0x88e3 /* IEC 61158-6-10 Media Redundancy Protocol (MRP) */
#endif
#ifndef ETHERTYPE_LOOP
#define ETHERTYPE_LOOP 0x9000 /* used for layer 2 testing (do i see my own frames on the wire) */
#endif

View File

@ -26,3 +26,6 @@ Version 0.2.0:
* PN-PTCP: add whole new Precision Time Control Protocol dissector
Version 0.2.1:
* PN-MRP and PN-MRRT: add new Media Redundancy Protocol and Media Redundacy for RealTime Protocol dissector

View File

@ -30,4 +30,6 @@ PLUGIN_NAME = profinet
DISSECTOR_SRC = \
packet-dcerpc-pn-io.c \
packet-pn-dcp.c \
packet-pn-mrp.c \
packet-pn-mrrt.c \
packet-pn-ptcp.c

View File

@ -13,5 +13,5 @@
#endif
/* Version number of package */
#define VERSION "0.2.0"
#define VERSION "0.2.1"

View File

@ -0,0 +1,451 @@
/* packet-pn-mrp.c
* Routines for PN-MRP (PROFINET Media Redundancy Protocol)
* packet dissection.
*
* $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <string.h>
#include <glib.h>
#include <epan/packet.h>
#include <epan/dissectors/packet-dcerpc.h>
#include <epan/oui.h>
#include <epan/etypes.h>
static int proto_pn_mrp = -1;
static int hf_pn_mrp_type = -1;
static int hf_pn_mrp_length = -1;
static int hf_pn_mrp_version = -1;
static int hf_pn_mrp_sequence_id = -1;
static int hf_pn_mrp_sa = -1;
static int hf_pn_mrp_prio = -1;
static int hf_pn_mrp_port_role = -1;
static int hf_pn_mrp_ring_state = -1;
static int hf_pn_mrp_interval = -1;
static int hf_pn_mrp_transition = -1;
static int hf_pn_mrp_time_stamp = -1;
static int hf_pn_mrp_blocked = -1;
static int hf_pn_mrp_manufacturer_oui = -1;
static int hf_pn_mrp_domain_uuid = -1;
static int hf_pn_mrp_data = -1;
static gint ett_pn_mrp = -1;
static const value_string pn_mrp_block_type_vals[] = {
{ 0x00, "End" },
{ 0x01, "Common" },
{ 0x02, "Test" },
{ 0x03, "TopologyChange" },
{ 0x04, "LinkDown" },
{ 0x05, "LinkUp" },
/*0x06 - 0x7E Reserved */
{ 0x7F, "Organizationally Specific"},
{ 0, NULL },
};
static const value_string pn_mrp_oui_vals[] = {
{ OUI_PROFINET, "PROFINET" },
{ 0, NULL }
};
static const value_string pn_mrp_port_role_vals[] = {
{ 0x0000, "Primary ring port" },
{ 0x0001, "Secondary ring port"},
/*0x0002 - 0xFFFF Reserved */
{ 0, NULL }
};
static const value_string pn_mrp_ring_state_vals[] = {
{ 0x0000, "Ring open" },
{ 0x0001, "Ring closed"},
/*0x0002 - 0xFFFF Reserved */
{ 0, NULL }
};
static const value_string pn_mrp_prio_vals[] = {
{ 0x8000, "Default priority for redundancy manager" },
{ 0, NULL }
};
/* XXX - use include file instead for these helpers */
extern int dissect_pn_uint8(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, int hfindex, guint8 *pdata);
extern int dissect_pn_uint16(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, int hfindex, guint16 *pdata);
extern int dissect_pn_uint32(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, int hfindex, guint32 *pdata);
extern int dissect_pn_int16(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
proto_tree *tree, int hfindex, gint16 *pdata);
extern int dissect_pn_oid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
proto_tree *tree, int hfindex, guint32 *pdata);
extern int dissect_pn_mac(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
proto_tree *tree, int hfindex, guint8 *pdata);
extern int dissect_pn_uuid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
proto_tree *tree, int hfindex, e_uuid_t *uuid);
static int
dissect_PNMRP_Common(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, proto_item *item, guint8 length)
{
guint16 sequence_id;
e_uuid_t uuid;
/* MRP_SequenceID */
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_sequence_id, &sequence_id);
/* MRP_DomainUUID */
offset = dissect_pn_uuid(tvb, offset, pinfo, tree, hf_pn_mrp_domain_uuid, &uuid);
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "Common");
proto_item_append_text(item, "Common");
return offset;
}
static int
dissect_PNMRP_LinkUp(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, proto_item *item, guint8 length)
{
guint16 port_role;
guint16 interval;
guint16 blocked;
/* MRP_PortRole */
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_port_role, &port_role);
/* MRP_Interval */
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_interval, &interval);
/* MRP_Blocked */
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_blocked, &blocked);
/* Padding */
if (offset % 4) {
offset += 4 - (offset % 4);
}
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "LinkUp");
proto_item_append_text(item, "LinkUp");
return offset;
}
static int
dissect_PNMRP_LinkDown(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, proto_item *item, guint8 length)
{
guint16 port_role;
guint16 interval;
guint16 blocked;
/* MRP_PortRole */
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_port_role, &port_role);
/* MRP_Interval */
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_interval, &interval);
/* MRP_Blocked */
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_blocked, &blocked);
/* Padding */
if (offset % 4) {
offset += 4 - (offset % 4);
}
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "LinkDown");
proto_item_append_text(item, "LinkDown");
return offset;
}
static int
dissect_PNMRP_Test(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, proto_item *item, guint8 length)
{
guint16 prio;
guint8 mac[6];
guint16 port_role;
guint16 ring_state;
guint16 transition;
guint16 time_stamp;
/* MRP_Prio */
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_prio, &prio);
/* MRP_SA */
offset = dissect_pn_mac(tvb, offset, pinfo, tree, hf_pn_mrp_sa, mac);
/* MRP_PortRole */
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_port_role, &port_role);
/* MRP_RingState */
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_ring_state, &ring_state);
/* MRP_Transition */
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_transition, &transition);
/* MRP_TimeStamp */
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_time_stamp, &time_stamp);
/* Padding */
if (offset % 4) {
offset += 4 - (offset % 4);
}
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "Test");
proto_item_append_text(item, "Test");
return offset;
}
static int
dissect_PNMRP_TopologyChange(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, proto_item *item, guint8 length)
{
guint16 prio;
guint8 mac[6];
guint16 interval;
/* MRP_Prio */
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_prio, &prio);
/* MRP_SA */
offset = dissect_pn_mac(tvb, offset, pinfo, tree, hf_pn_mrp_sa, mac);
/* MRP_Interval */
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_interval, &interval);
/* Padding */
/*if (offset % 4) {
offset += 4 - (offset % 4);
}*/
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "TopologyChange");
proto_item_append_text(item, "TopologyChange");
return offset;
}
static int
dissect_PNMRP_PDU(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, proto_item *item)
{
guint16 version;
guint8 type;
guint8 length;
gint i = 0;
/* MRP_Version */
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_version, &version);
while(tvb_length_remaining(tvb, offset) > 0) {
/* MRP_TLVHeader.Type */
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_mrp_type, &type);
/* MRP_TLVHeader.Length */
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_mrp_length, &length);
if(i != 0) {
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, ", ");
proto_item_append_text(item, ", ");
}
i++;
switch(type) {
case(0x00):
/* no content */
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "End");
proto_item_append_text(item, "End");
return offset;
break;
case(0x01):
offset = dissect_PNMRP_Common(tvb, offset, pinfo, tree, item, length);
break;
case(0x02):
offset = dissect_PNMRP_Test(tvb, offset, pinfo, tree, item, length);
break;
case(0x03):
offset = dissect_PNMRP_TopologyChange(tvb, offset, pinfo, tree, item, length);
break;
case(0x04):
offset = dissect_PNMRP_LinkDown(tvb, offset, pinfo, tree, item, length);
break;
case(0x05):
offset = dissect_PNMRP_LinkUp(tvb, offset, pinfo, tree, item, length);
break;
default:
proto_tree_add_string_format(tree, hf_pn_mrp_data, tvb, offset, length, "data",
"PN-MRP Unknown TLVType 0x%x, Data: %d bytes", type, length);
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "Unknown TLVType 0x%x", type);
proto_item_append_text(item, "Unknown TLVType 0x%x", type);
offset += length;
}
}
/* will never be reached */
return offset;
}
/* Dissect MRP packets */
static void
dissect_PNMRP(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *ti;
proto_tree *mrp_tree = NULL;
guint32 offset = 0;
if (check_col(pinfo->cinfo, COL_PROTOCOL))
col_set_str(pinfo->cinfo, COL_PROTOCOL, "PN-MRP");
/* Clear the information column on summary display */
if (check_col(pinfo->cinfo, COL_INFO)) {
col_clear(pinfo->cinfo, COL_INFO);
}
if (tree)
{
ti = proto_tree_add_item(tree, proto_pn_mrp, tvb, offset, -1, FALSE);
mrp_tree = proto_item_add_subtree(ti, ett_pn_mrp);
}
dissect_PNMRP_PDU(tvb, offset, pinfo, mrp_tree, ti);
}
void
proto_register_pn_mrp (void)
{
static hf_register_info hf[] = {
{ &hf_pn_mrp_data,
{ "Undecoded Data", "pn_mrp.data", FT_STRING, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_pn_mrp_type,
{ "Type", "pn_mrp.type", FT_UINT8, BASE_HEX, VALS(pn_mrp_block_type_vals), 0x0, "", HFILL }},
{ &hf_pn_mrp_length,
{ "Length", "pn_mrp.length", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_pn_mrp_version,
{ "Version", "pn_mrp.version", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_pn_mrp_sequence_id,
{ "SequenceID", "pn_mrp.sequence_id", FT_UINT16, BASE_HEX, NULL, 0x0, "Unique sequence number to each outstanding service request", HFILL }},
{ &hf_pn_mrp_sa,
{ "SA", "pn_mrp.sa", FT_ETHER, BASE_HEX, 0x0, 0x0, "", HFILL }},
{ &hf_pn_mrp_prio,
{ "Prio", "pn_mrp.prio", FT_UINT16, BASE_HEX, VALS(pn_mrp_prio_vals), 0x0, "", HFILL }},
{ &hf_pn_mrp_port_role,
{ "PortRole", "pn_mrp.port_role", FT_UINT16, BASE_HEX, VALS(pn_mrp_port_role_vals), 0x0, "", HFILL }},
{ &hf_pn_mrp_ring_state,
{ "RingState", "pn_mrp.ring_state", FT_UINT16, BASE_HEX, VALS(pn_mrp_ring_state_vals), 0x0, "", HFILL }},
{ &hf_pn_mrp_interval,
{ "Interval", "pn_mrp.interval", FT_UINT16, BASE_DEC, NULL, 0x0, "Interval for next topologie change event (in ms)", HFILL }},
{ &hf_pn_mrp_transition,
{ "Transition", "pn_mrp.transition", FT_UINT16, BASE_HEX, NULL, 0x0, "Number of transitions between media redundancy lost and ok states", HFILL }},
{ &hf_pn_mrp_time_stamp,
{ "TimeStamp", "pn_mrp.time_stamp", FT_UINT16, BASE_HEX, NULL, 0x0, "Actual counter value of 1ms counter", HFILL }},
{ &hf_pn_mrp_blocked,
{ "Blocked", "pn_mrp.blocked", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }},
{ &hf_pn_mrp_manufacturer_oui,
{ "ManufacturerOUI", "pn_mrp.manufacturer_oui", FT_UINT24, BASE_HEX, VALS(pn_mrp_oui_vals), 0x0, "", HFILL }},
{ &hf_pn_mrp_domain_uuid,
{ "DomainUUID", "pn_mrp.domain_uuid", FT_GUID, BASE_NONE, NULL, 0x0, "", HFILL }},
};
static gint *ett[] = {
&ett_pn_mrp
};
proto_pn_mrp = proto_register_protocol ("PROFINET MRP", "PN-MRP", "pn_mrp");
proto_register_field_array (proto_pn_mrp, hf, array_length (hf));
proto_register_subtree_array (ett, array_length (ett));
}
void
proto_reg_handoff_pn_mrp (void)
{
dissector_handle_t mrp_handle;
mrp_handle = create_dissector_handle(dissect_PNMRP,proto_pn_mrp);
dissector_add("ethertype", ETHERTYPE_MRP, mrp_handle);
}

View File

@ -0,0 +1,282 @@
/* packet-pn-mrrt.c
* Routines for PN-MRRT (PROFINET Media Redundancy for cyclic realtime data)
* packet dissection.
*
* $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <string.h>
#include <glib.h>
#include <epan/packet.h>
#include <epan/dissectors/packet-dcerpc.h>
#include <epan/oui.h>
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 int hf_pn_mrrt_data = -1;
static gint ett_pn_mrrt = -1;
static const value_string pn_mrrt_block_type_vals[] = {
{ 0x00, "End" },
{ 0x01, "Common" },
{ 0x02, "Test" },
/*0x03 - 0x7E Reserved */
{ 0x7F, "Organizationally Specific"},
{ 0, NULL },
};
static const value_string pn_mrrt_oui_vals[] = {
{ OUI_PROFINET, "PROFINET" },
{ 0, NULL }
};
/* XXX - use include file instead for these helpers */
extern int dissect_pn_uint8(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, int hfindex, guint8 *pdata);
extern int dissect_pn_uint16(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, int hfindex, guint16 *pdata);
extern int dissect_pn_uint32(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, int hfindex, guint32 *pdata);
extern int dissect_pn_int16(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
proto_tree *tree, int hfindex, gint16 *pdata);
extern int dissect_pn_oid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
proto_tree *tree, int hfindex, guint32 *pdata);
extern int dissect_pn_mac(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
proto_tree *tree, int hfindex, guint8 *pdata);
extern int dissect_pn_uuid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
proto_tree *tree, int hfindex, e_uuid_t *uuid);
static int
dissect_PNMRRT_Common(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, proto_item *item, guint8 length)
{
guint16 sequence_id;
e_uuid_t uuid;
/* 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);
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "Common");
proto_item_append_text(item, "Common");
return offset;
}
static int
dissect_PNMRRT_Test(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, proto_item *item, guint8 length)
{
guint8 mac[6];
/* MRRT_SA */
offset = dissect_pn_mac(tvb, offset, pinfo, tree, hf_pn_mrrt_sa, mac);
/* Padding */
if (offset % 4) {
offset += 4 - (offset % 4);
}
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "Test");
proto_item_append_text(item, "Test");
return offset;
}
static int
dissect_PNMRRT_PDU(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, proto_item *item)
{
guint16 version;
guint8 type;
guint8 length;
gint i =0;
/* MRRT_Version */
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrrt_version, &version);
while(tvb_length_remaining(tvb, offset) > 0) {
/* 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);
if(i != 0) {
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, ", ");
proto_item_append_text(item, ", ");
}
i++;
switch(type) {
case(0x00):
/* no content */
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "End");
proto_item_append_text(item, "End");
return offset;
break;
case(0x01):
offset = dissect_PNMRRT_Common(tvb, offset, pinfo, tree, item, length);
break;
case(0x02):
offset = dissect_PNMRRT_Test(tvb, offset, pinfo, tree, item, length);
break;
default:
proto_tree_add_string_format(tree, hf_pn_mrrt_data, tvb, offset, length, "data",
"PN-MRRT Unknown TLVType 0x%x, Data: %d bytes", type, length);
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "Unknown TLVType 0x%x", type);
proto_item_append_text(item, "Unknown TLVType 0x%x", type);
offset += length;
}
}
/* will never be reached */
return offset;
}
/* possibly dissect a PN-RT packet (frame ID must be in the appropriate range) */
static gboolean
dissect_PNMRRT_Data_heur(tvbuff_t *tvb,
packet_info *pinfo, proto_tree *tree)
{
guint16 u16FrameID;
proto_item *item = NULL;
proto_tree *mrrt_tree = NULL;
int offset = 0;
guint32 u32SubStart;
/* the tvb will NOT contain the frame_id here, so get it from our private data! */
u16FrameID = GPOINTER_TO_UINT(pinfo->private_data);
/* frame id must be in valid range (MRRT) */
if (u16FrameID != 0xFF60) {
/* we are not interested in this packet */
return FALSE;
}
if (check_col(pinfo->cinfo, COL_PROTOCOL))
col_add_str(pinfo->cinfo, COL_PROTOCOL, "PN-MRRT");
if (check_col(pinfo->cinfo, COL_INFO))
col_add_str(pinfo->cinfo, COL_INFO, "");
/* subtree for MRRT */
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);
u32SubStart = offset;
offset = dissect_PNMRRT_PDU(tvb, offset, pinfo, mrrt_tree, item);
proto_item_set_len(item, offset - u32SubStart);
return TRUE;
}
void
proto_register_pn_mrrt (void)
{
static hf_register_info hf[] = {
{ &hf_pn_mrrt_data,
{ "Undecoded Data", "pn_mrrt.data", FT_STRING, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_pn_mrrt_type,
{ "Type", "pn_mrrt.type", FT_UINT8, BASE_HEX, VALS(pn_mrrt_block_type_vals), 0x0, "", HFILL }},
{ &hf_pn_mrrt_length,
{ "Length", "pn_mrrt.length", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_pn_mrrt_version,
{ "Version", "pn_mrrt.version", FT_UINT16, BASE_DEC, NULL, 0x0, "", 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_HEX, 0x0, 0x0, "", HFILL }},
{ &hf_pn_mrrt_domain_uuid,
{ "DomainUUID", "pn_mrrt.domain_uuid", FT_GUID, BASE_NONE, NULL, 0x0, "", HFILL }},
};
static gint *ett[] = {
&ett_pn_mrrt
};
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));
}
void
proto_reg_handoff_pn_mrrt (void)
{
/* register ourself as an heuristic pn-rt payload dissector */
heur_dissector_add("pn_rt", dissect_PNMRRT_Data_heur, proto_pn_mrrt);
}