PROFINET: TimeAware Dissection and RSI FREQ block fix

TimeAware bit dissected for ARProperties
and cyclic frames updated accordingly.
Also small length problem fixed in RSI FREQ block dissection.
This commit is contained in:
Vahap Emin Agaogullari 2022-01-23 23:50:40 -08:00 committed by A Wireshark GitLab Utility
parent 2724806e50
commit 7f2e996193
4 changed files with 167 additions and 55 deletions

View File

@ -90,6 +90,7 @@ static int proto_pn_io_supervisor = -1;
static int proto_pn_io_parameterserver = -1;
static int proto_pn_io_implicitar = -1;
int proto_pn_io_apdu_status = -1;
int proto_pn_io_time_aware_status = -1;
static int hf_pn_io_opnum = -1;
static int hf_pn_io_reserved16 = -1;
@ -119,6 +120,7 @@ static int hf_pn_io_ar_properties_device_access = -1;
static int hf_pn_io_ar_properties_companion_ar = -1;
static int hf_pn_io_ar_properties_achnowledge_companion_ar = -1;
static int hf_pn_io_ar_properties_reserved = -1;
static int hf_pn_io_ar_properties_time_aware_system = -1;
static int hf_pn_io_ar_properties_combined_object_container_with_legacy_startupmode = -1;
static int hf_pn_io_ar_properties_combined_object_container_with_advanced_startupmode = -1;
static int hf_pn_io_ar_properties_pull_module_alarm_allowed = -1;
@ -864,6 +866,7 @@ gboolean pnio_ps_selection = TRUE;
static const char *pnio_ps_networkpath = "";
wmem_list_t *aruuid_frame_setup_list = NULL;
static wmem_map_t *pnio_time_aware_frame_map = NULL;
/* Allow heuristic dissection */
@ -1262,6 +1265,13 @@ static const value_string pn_io_arproperties_acknowldege_companion_ar[] = {
{ 0, NULL }
};
/* Bit 28 */
static const value_string pn_io_arproperties_time_aware_system[] = {
{ 0x00000000, "NonTimeAware" },
{ 0x00000001, "TimeAware" },
{ 0, NULL }
};
/* bit 29 for legacy startup mode*/
static const value_string pn_io_arproperties_combined_object_container_with_legacy_startupmode[] = {
{ 0x00000000, "CombinedObjectContainer not used" },
@ -2793,7 +2803,7 @@ dissect_profidrive_value(tvbuff_t *tvb, gint offset, packet_info *pinfo,
{
gint sLen;
sLen = (gint)tvb_strnlen( tvb, offset, -1);
proto_tree_add_item(tree, hf_pn_io_profidrive_param_value_string, tvb, offset, sLen, ENC_ASCII|ENC_NA);
proto_tree_add_item(tree, hf_pn_io_profidrive_param_value_string, tvb, offset, sLen, ENC_ASCII);
offset = (offset + sLen);
break;
}
@ -3200,11 +3210,11 @@ dissect_RS_IdentificationInfo(tvbuff_t *tvb, int offset,
hf_pn_io_am_device_identification_organization, &u64AM_DeviceIdentificationOrganization);
/* IM_Tag_Function [32] */
proto_tree_add_item(tree, hf_pn_io_im_tag_function, tvb, offset, 32, ENC_ASCII|ENC_NA);
proto_tree_add_item(tree, hf_pn_io_im_tag_function, tvb, offset, 32, ENC_ASCII);
offset += 32;
/* IM_Tag_Location [22] */
proto_tree_add_item(tree, hf_pn_io_im_tag_location, tvb, offset, 22, ENC_ASCII|ENC_NA);
proto_tree_add_item(tree, hf_pn_io_im_tag_location, tvb, offset, 22, ENC_ASCII);
offset += 22;
return offset;
@ -3676,11 +3686,11 @@ dissect_IandM0_block(tvbuff_t *tvb, int offset,
offset = dissect_dcerpc_uint8(tvb, offset, pinfo, tree, drep,
hf_pn_io_vendor_id_low, &u8VendorIDLow);
/* c8[20] OrderID */
proto_tree_add_item (tree, hf_pn_io_order_id, tvb, offset, 20, ENC_ASCII|ENC_NA);
proto_tree_add_item (tree, hf_pn_io_order_id, tvb, offset, 20, ENC_ASCII);
offset += 20;
/* c8[16] IM_Serial_Number */
proto_tree_add_item (tree, hf_pn_io_im_serial_number, tvb, offset, 16, ENC_ASCII|ENC_NA);
proto_tree_add_item (tree, hf_pn_io_im_serial_number, tvb, offset, 16, ENC_ASCII);
offset += 16;
/* x16 IM_Hardware_Revision */
@ -3921,11 +3931,11 @@ dissect_IandM5Data_block(tvbuff_t *tvb, int offset,
guint8 u8IMSWRevisionInternalChange;
/* c8[64] IM Annotation */
proto_tree_add_item(tree, hf_pn_io_im_annotation, tvb, offset, 64, ENC_ASCII|ENC_NA);
proto_tree_add_item(tree, hf_pn_io_im_annotation, tvb, offset, 64, ENC_ASCII);
offset += 64;
/* c8[64] IM Order ID */
proto_tree_add_item(tree, hf_pn_io_im_order_id, tvb, offset, 64, ENC_ASCII|ENC_NA);
proto_tree_add_item(tree, hf_pn_io_im_order_id, tvb, offset, 64, ENC_ASCII);
offset += 64;
/* x8 VendorIDHigh */
@ -3936,7 +3946,7 @@ dissect_IandM5Data_block(tvbuff_t *tvb, int offset,
hf_pn_io_vendor_id_low, &u8VendorIDLow);
/* c8[16] IM Serial Number */
proto_tree_add_item(tree, hf_pn_io_im_serial_number, tvb, offset, 16, ENC_ASCII|ENC_NA);
proto_tree_add_item(tree, hf_pn_io_im_serial_number, tvb, offset, 16, ENC_ASCII);
offset += 16;
/* x16 IM_Hardware_Revision */
@ -4170,23 +4180,23 @@ guint8 u8BlockVersionHigh, guint8 u8BlockVersionLow)
offset = dissect_AM_Location(tvb, offset, pinfo, tree, drep);
/* IM_Annotation */
proto_tree_add_item(tree, hf_pn_io_im_annotation, tvb, offset, 64, ENC_ASCII|ENC_NA);
proto_tree_add_item(tree, hf_pn_io_im_annotation, tvb, offset, 64, ENC_ASCII);
offset += 64;
/* IM_OrderID */
proto_tree_add_item(tree, hf_pn_io_im_order_id, tvb, offset, 64, ENC_ASCII|ENC_NA);
proto_tree_add_item(tree, hf_pn_io_im_order_id, tvb, offset, 64, ENC_ASCII);
offset += 64;
/* AM_SoftwareRevision */
proto_tree_add_item(tree, hf_pn_io_am_software_revision, tvb, offset, 64, ENC_ASCII|ENC_NA);
proto_tree_add_item(tree, hf_pn_io_am_software_revision, tvb, offset, 64, ENC_ASCII);
offset += 64;
/* AM_HardwareRevision */
proto_tree_add_item(tree, hf_pn_io_am_hardware_revision, tvb, offset, 64, ENC_ASCII|ENC_NA);
proto_tree_add_item(tree, hf_pn_io_am_hardware_revision, tvb, offset, 64, ENC_ASCII);
offset += 64;
/* IM_Serial_Number */
proto_tree_add_item(tree, hf_pn_io_im_serial_number, tvb, offset, 16, ENC_ASCII|ENC_NA);
proto_tree_add_item(tree, hf_pn_io_im_serial_number, tvb, offset, 16, ENC_ASCII);
offset += 16;
/* IM_Software_Revision */
@ -5316,6 +5326,7 @@ dissect_PDPortDataReal_block(tvbuff_t *tvb, int offset,
/* PeerPortID */
proto_tree_add_item_ret_display_string (sub_tree, hf_pn_io_peer_port_id, tvb, offset, u8LengthPeerPortID,
ENC_ASCII|ENC_NA, pinfo->pool, &pPeerPortId);
offset += u8LengthPeerPortID;
/* LengthPeerChassisID */
@ -5324,6 +5335,7 @@ dissect_PDPortDataReal_block(tvbuff_t *tvb, int offset,
/* PeerChassisID */
proto_tree_add_item_ret_display_string (sub_tree, hf_pn_io_peer_chassis_id, tvb, offset, u8LengthPeerChassisID,
ENC_ASCII|ENC_NA, pinfo->pool, &pPeerChassisId);
offset += u8LengthPeerChassisID;
/* Padding */
@ -5466,7 +5478,7 @@ dissect_PDInterfaceMrpDataAdjust_block(tvbuff_t *tvb, int offset,
with the labels being counted strings; does that mean that this
is just an ASCII string to be interpreted as a Punycode Unicode
domain name? */
proto_tree_add_item (tree, hf_pn_io_mrp_domain_name, tvb, offset, u8LengthDomainName, ENC_ASCII|ENC_NA);
proto_tree_add_item (tree, hf_pn_io_mrp_domain_name, tvb, offset, u8LengthDomainName, ENC_ASCII);
offset += u8LengthDomainName;
/* Padding */
@ -5537,7 +5549,7 @@ dissect_PDInterfaceMrpDataReal_block(tvbuff_t *tvb, int offset,
hf_pn_io_mrp_length_domain_name, &u8LengthDomainName);
/* MRP_DomainName */
/* XXX - see comment earlier about MRP_DomainName */
proto_tree_add_item (tree, hf_pn_io_mrp_domain_name, tvb, offset, u8LengthDomainName, ENC_ASCII|ENC_NA);
proto_tree_add_item (tree, hf_pn_io_mrp_domain_name, tvb, offset, u8LengthDomainName, ENC_ASCII);
offset += u8LengthDomainName;
if (u8BlockVersionLow == 0) {
@ -6111,14 +6123,14 @@ dissect_CheckPeers_block(tvbuff_t *tvb, int offset,
offset = dissect_dcerpc_uint8(tvb, offset, pinfo, tree, drep,
hf_pn_io_length_peer_port_id, &u8LengthPeerPortID);
/* PeerPortID */
proto_tree_add_item (tree, hf_pn_io_peer_port_id, tvb, offset, u8LengthPeerPortID, ENC_ASCII|ENC_NA);
proto_tree_add_item (tree, hf_pn_io_peer_port_id, tvb, offset, u8LengthPeerPortID, ENC_ASCII);
offset += u8LengthPeerPortID;
/* LengthPeerChassisID */
offset = dissect_dcerpc_uint8(tvb, offset, pinfo, tree, drep,
hf_pn_io_length_peer_chassis_id, &u8LengthPeerChassisID);
/* PeerChassisID */
proto_tree_add_item (tree, hf_pn_io_peer_chassis_id, tvb, offset, u8LengthPeerChassisID, ENC_ASCII|ENC_NA);
proto_tree_add_item (tree, hf_pn_io_peer_chassis_id, tvb, offset, u8LengthPeerChassisID, ENC_ASCII);
offset += u8LengthPeerChassisID;
}
@ -6491,7 +6503,7 @@ dissect_MrpInstanceDataAdjust_block(tvbuff_t *tvb, int offset,
hf_pn_io_mrp_length_domain_name, &u8LengthDomainName);
/* MRP_DomainName */
/* XXX - see comment earlier about MRP_DomainName */
proto_tree_add_item (tree, hf_pn_io_mrp_domain_name, tvb, offset, u8LengthDomainName, ENC_ASCII|ENC_NA);
proto_tree_add_item (tree, hf_pn_io_mrp_domain_name, tvb, offset, u8LengthDomainName, ENC_ASCII);
offset += u8LengthDomainName;
/* Padding */
offset = dissect_pn_align4(tvb, offset, pinfo, tree);
@ -6538,7 +6550,7 @@ dissect_MrpInstanceDataReal_block(tvbuff_t *tvb, int offset,
hf_pn_io_mrp_length_domain_name, &u8LengthDomainName);
/* MRP_DomainName */
/* XXX - see comment earlier about MRP_DomainName */
proto_tree_add_item (tree, hf_pn_io_mrp_domain_name, tvb, offset, u8LengthDomainName, ENC_ASCII|ENC_NA);
proto_tree_add_item (tree, hf_pn_io_mrp_domain_name, tvb, offset, u8LengthDomainName, ENC_ASCII);
offset += u8LengthDomainName;
/* Padding */
offset = dissect_pn_align4(tvb, offset, pinfo, tree);
@ -6851,7 +6863,7 @@ dissect_PDInterfaceDataReal_block(tvbuff_t *tvb, int offset,
offset = dissect_dcerpc_uint8(tvb, offset, pinfo, tree, drep,
hf_pn_io_length_own_chassis_id, &u8LengthOwnChassisID);
/* OwnChassisID */
proto_tree_add_item (tree, hf_pn_io_own_chassis_id, tvb, offset, u8LengthOwnChassisID, ENC_ASCII|ENC_NA);
proto_tree_add_item (tree, hf_pn_io_own_chassis_id, tvb, offset, u8LengthOwnChassisID, ENC_ASCII);
offset += u8LengthOwnChassisID;
/* Padding */
@ -6996,7 +7008,7 @@ dissect_PDSyncData_block(tvbuff_t *tvb, int offset,
hf_pn_io_ptcp_length_subdomain_name, &u8LengthSubdomainName);
/* PTCPSubdomainName */
/* XXX - another Punycode string */
proto_tree_add_item (tree, hf_pn_io_ptcp_subdomain_name, tvb, offset, u8LengthSubdomainName, ENC_ASCII|ENC_NA);
proto_tree_add_item (tree, hf_pn_io_ptcp_subdomain_name, tvb, offset, u8LengthSubdomainName, ENC_ASCII);
offset += u8LengthSubdomainName;
/* Padding */
@ -7505,6 +7517,7 @@ dissect_ARProperties(tvbuff_t *tvb, int offset,
proto_tree *sub_tree;
guint32 u32ARProperties;
guint8 startupMode;
guint8 isTimeAware;
sub_item = proto_tree_add_item(tree, hf_pn_io_ar_properties, tvb, offset, 4, ENC_BIG_ENDIAN);
sub_tree = proto_item_add_subtree(sub_item, ett_pn_io_ar_properties);
@ -7525,6 +7538,13 @@ dissect_ARProperties(tvbuff_t *tvb, int offset,
dissect_dcerpc_uint32(tvb, offset, pinfo, sub_tree, drep,
hf_pn_io_ar_properties_combined_object_container_with_legacy_startupmode, &u32ARProperties);
}
dissect_dcerpc_uint32(tvb, offset, pinfo, sub_tree, drep,
hf_pn_io_ar_properties_time_aware_system, &u32ARProperties);
isTimeAware = (guint8)((u32ARProperties >> 28) & 0x01);
wmem_map_insert(pnio_time_aware_frame_map, GUINT_TO_POINTER(pinfo->num), GUINT_TO_POINTER(isTimeAware));
dissect_dcerpc_uint32(tvb, offset, pinfo, sub_tree, drep,
hf_pn_io_ar_properties_reserved, &u32ARProperties);
dissect_dcerpc_uint32(tvb, offset, pinfo, sub_tree, drep,
@ -7549,7 +7569,6 @@ dissect_ARProperties(tvbuff_t *tvb, int offset,
return offset;
}
/* dissect the IOCRProperties */
static int
dissect_IOCRProperties(tvbuff_t *tvb, int offset,
@ -7645,7 +7664,7 @@ dissect_ARData_block(tvbuff_t *tvb, int offset,
hf_pn_io_cminitiator_objectuuid, &uuid);
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, ar_tree, drep,
hf_pn_io_station_name_length, &u16NameLength);
proto_tree_add_item (ar_tree, hf_pn_io_cminitiator_station_name, tvb, offset, u16NameLength, ENC_ASCII|ENC_NA);
proto_tree_add_item (ar_tree, hf_pn_io_cminitiator_station_name, tvb, offset, u16NameLength, ENC_ASCII);
offset += u16NameLength;
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, ar_tree, drep,
@ -7728,7 +7747,7 @@ dissect_ARData_block(tvbuff_t *tvb, int offset,
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, ar_tree, drep,
hf_pn_io_station_name_length, &u16NameLength);
/* ParameterServerStationName */
proto_tree_add_item (ar_tree, hf_pn_io_parameter_server_station_name, tvb, offset, u16NameLength, ENC_ASCII|ENC_NA);
proto_tree_add_item (ar_tree, hf_pn_io_parameter_server_station_name, tvb, offset, u16NameLength, ENC_ASCII);
offset += u16NameLength;
/* NumberOfAPIs */
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, ar_tree, drep,
@ -7775,7 +7794,7 @@ dissect_ARData_block(tvbuff_t *tvb, int offset,
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, ar_tree, drep, hf_pn_io_cmresponder_udprtport, &u16UDPRTPort);
/* CMInitiatorStationName*/
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, ar_tree, drep, hf_pn_io_station_name_length, &u16NameLength);
proto_tree_add_item (ar_tree, hf_pn_io_cminitiator_station_name, tvb, offset, u16NameLength, ENC_ASCII|ENC_NA);
proto_tree_add_item (ar_tree, hf_pn_io_cminitiator_station_name, tvb, offset, u16NameLength, ENC_ASCII);
offset += u16NameLength;
/** align padding! **/
offset = dissect_pn_align4(tvb, offset, pinfo, ar_tree);
@ -7784,7 +7803,7 @@ dissect_ARData_block(tvbuff_t *tvb, int offset,
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, ar_tree, drep, hf_pn_io_station_name_length, &u16NameLength);
if (u16NameLength != 0) {
/* ParameterServerStationName */
proto_tree_add_item (ar_tree, hf_pn_io_parameter_server_station_name, tvb, offset, u16NameLength, ENC_ASCII|ENC_NA);
proto_tree_add_item (ar_tree, hf_pn_io_parameter_server_station_name, tvb, offset, u16NameLength, ENC_ASCII);
offset += u16NameLength;
}
else
@ -8584,6 +8603,7 @@ dissect_IOCRBlockReq_block(tvbuff_t *tvb, int offset,
guint32 u32SubStart;
conversation_t *conversation;
conversation_t *conversation_time_aware;
stationInfo *station_info = NULL;
iocsObject *iocs_object;
iocsObject *cmp_iocs_object;
@ -8633,6 +8653,25 @@ dissect_IOCRBlockReq_block(tvbuff_t *tvb, int offset,
offset = dissect_pn_mac(tvb, offset, pinfo, tree,
hf_pn_io_iocr_multicast_mac_add, mac);
if (wmem_map_contains(pnio_time_aware_frame_map, GUINT_TO_POINTER(pinfo->num)))
{
address cyclic_mac_addr;
address iocr_mac_addr;
set_address(&cyclic_mac_addr, AT_ETHER, 6, mac);
iocr_mac_addr = (u16IOCRType == PN_INPUT_CR) ? pinfo->dl_dst : pinfo->dl_src;
/* Get current conversation endpoints using MAC addresses */
conversation_time_aware = find_conversation(pinfo->num, &cyclic_mac_addr, &iocr_mac_addr, ENDPOINT_NONE, 0, 0, 0);
if (conversation_time_aware == NULL) {
conversation_time_aware = conversation_new(pinfo->num, &iocr_mac_addr, &cyclic_mac_addr, ENDPOINT_NONE, 0, 0, 0);
}
conversation_add_proto_data(conversation_time_aware, proto_pn_io_time_aware_status, wmem_map_lookup(pnio_time_aware_frame_map, GUINT_TO_POINTER(pinfo->num)));
}
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
hf_pn_io_number_of_apis, &u16NumberOfAPIs);
@ -8964,7 +9003,7 @@ dissect_ARServerBlock(tvbuff_t *tvb, int offset,
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
hf_pn_io_station_name_length, &u16NameLength);
proto_tree_add_item (tree, hf_pn_io_cminitiator_station_name, tvb, offset, u16NameLength, ENC_ASCII|ENC_NA);
proto_tree_add_item (tree, hf_pn_io_cminitiator_station_name, tvb, offset, u16NameLength, ENC_ASCII);
offset += u16NameLength;
/* Padding to next 4 byte alignment in this block */
u16padding = u16BodyLength - (2 + u16NameLength);
@ -12194,6 +12233,8 @@ dissect_PNIO_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* the sub tvb will NOT contain the frame_id here! */
guint16 u16FrameID = GPOINTER_TO_UINT(data);
heur_dtbl_entry_t *hdtbl_entry;
conversation_t* conversation;
guint8 isTimeAware = FALSE;
/*
* In case the packet is a protocol encoded in the basic PNIO transport stream,
@ -12203,10 +12244,27 @@ dissect_PNIO_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if (dissector_try_heuristic(heur_pn_subdissector_list, tvb, pinfo, tree, &hdtbl_entry, NULL))
return TRUE;
/* TimeAwareness Information needed for dissecting RTC3 - RTSteam frames */
conversation = find_conversation(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
if (conversation != NULL) {
isTimeAware = GPOINTER_TO_UINT(conversation_get_proto_data(conversation, proto_pn_io_time_aware_status));
}
/* is this a (none DFP) PNIO class 3 data packet? */
/* frame id must be in valid range (cyclic Real-Time, class=3) */
if ((u16FrameID >= 0x0100 && u16FrameID <= 0x06FF) || /* RTC3 non redundant */
(u16FrameID >= 0x700 && u16FrameID <= 0x0fff)) { /* RTC3 redundant */
if (((u16FrameID >= 0x0100 && u16FrameID <= 0x06FF) || /* RTC3 non redundant */
(u16FrameID >= 0x0700 && u16FrameID <= 0x0fff)) && /* RTC3 redundant */
!isTimeAware) {
dissect_CSF_SDU_heur(tvb, pinfo, tree, data);
return TRUE;
}
/* is this a PNIO class stream data packet? */
/* frame id must be in valid range (cyclic Real-Time, class=Stream) */
if (((u16FrameID >= 0x1000 && u16FrameID <= 0x2FFF) ||
(u16FrameID >= 0x3800 && u16FrameID <= 0x3FFF)) &&
isTimeAware) {
dissect_CSF_SDU_heur(tvb, pinfo, tree, data);
return TRUE;
}
@ -12214,7 +12272,7 @@ dissect_PNIO_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* The following range is reserved for following developments */
/* frame id must be in valid range (Reserved) and
* first byte (CBA version field) has to be != 0x11 */
if (u16FrameID >= 0x1000 && u16FrameID <= 0x7fff) {
if (u16FrameID >= 0x4000 && u16FrameID <= 0x7fff) {
dissect_PNIO_C_SDU(tvb, 0, pinfo, tree, drep);
return TRUE;
}
@ -12367,6 +12425,7 @@ pnio_cleanup(void) {
static void
pnio_setup(void) {
aruuid_frame_setup_list = wmem_list_new(wmem_file_scope());
pnio_time_aware_frame_map = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal);
}
@ -12476,7 +12535,12 @@ proto_register_pn_io (void)
},
{ &hf_pn_io_ar_properties_reserved,
{ "Reserved", "pn_io.ar_properties.reserved",
FT_UINT32, BASE_HEX, NULL, 0x1FFFF000,
FT_UINT32, BASE_HEX, NULL, 0x0FFFF000,
NULL, HFILL }
},
{ &hf_pn_io_ar_properties_time_aware_system,
{ "TimeAwareSystem", "pn_io.ar_properties.time_aware_system",
FT_UINT32, BASE_HEX, VALS(pn_io_arproperties_time_aware_system), 0x10000000,
NULL, HFILL }
},
{ &hf_pn_io_ar_properties_combined_object_container_with_legacy_startupmode,
@ -15314,6 +15378,7 @@ proto_register_pn_io (void)
proto_pn_io_parameterserver = proto_register_protocol_in_name_only("PROFINET IO (Parameter Server)", "PNIO (Parameter Server Interface)", "pn_io_parameterserver", proto_pn_io, FT_PROTOCOL);
proto_pn_io_implicitar = proto_register_protocol_in_name_only("PROFINET IO (Implicit Ar)", "PNIO (Implicit Ar)", "pn_io_implicitar", proto_pn_io, FT_PROTOCOL);
proto_pn_io_apdu_status = proto_register_protocol_in_name_only("PROFINET IO (Apdu Status)", "PNIO (Apdu Status)", "pn_io_apdu_status", proto_pn_io, FT_PROTOCOL);
proto_pn_io_time_aware_status = proto_register_protocol_in_name_only("PROFINET IO (Time Aware Status)", "PNIO (Time Aware Status)", "pn_io_time_aware_status", proto_pn_io, FT_PROTOCOL);
proto_register_field_array (proto_pn_io, hf, array_length (hf));
proto_register_subtree_array (ett, array_length (ett));

View File

@ -381,15 +381,20 @@ dissect_pn_rta_remaining_user_data_bytes(tvbuff_t *tvb, int offset, packet_info
/* dissect a PN-IO RSI SVCS block (on top of PN-RT protocol) */
static int
dissect_RSI_SVCS_block(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, guint8 *drep, guint8 u8MoreFrag, guint32 u32FOpnumOffsetOffset, guint32 u32FOpnumOffsetOpnum)
packet_info *pinfo, proto_tree *tree, guint8 *drep, guint16 u16VarPartLen, guint8 u8MoreFrag, guint32 u32FOpnumOffsetOffset, guint32 u32FOpnumOffsetOpnum)
{
proto_item *sub_item;
proto_item* sub_item;
proto_tree *sub_tree;
guint32 u32RspMaxLength;
guint32 u32RsiHeaderSize = 4;
guint32 u32RspMaxLength;
// PDU.FOpnumOffset.Offset + PDU.VarPartLen - 4 - RsiHeaderSize
gint32 length = u32FOpnumOffsetOffset + u16VarPartLen - 4 - u32RsiHeaderSize;
sub_item = proto_tree_add_item(tree, hf_pn_rsi_svcs_block, tvb, offset, 0, ENC_NA);
sub_tree = proto_item_add_subtree(sub_item, ett_pn_rsi_svcs_block);
if (u32FOpnumOffsetOffset == 0)
{
offset = dissect_dcerpc_uint32(tvb, offset, pinfo, sub_tree, drep,
@ -400,15 +405,17 @@ dissect_RSI_SVCS_block(tvbuff_t *tvb, int offset,
proto_item_append_text(sub_item, ", RSI Header of SVCS is at first segment");
}
offset = dissect_pn_rta_remaining_user_data_bytes(tvb, offset, pinfo, sub_tree, drep,
tvb_captured_length_remaining(tvb, offset), u8MoreFrag, u32FOpnumOffsetOpnum, PDU_TYPE_REQ);
if (length > 0) {
offset = dissect_pn_rta_remaining_user_data_bytes(tvb, offset, pinfo, sub_tree, drep,
tvb_captured_length_remaining(tvb, offset), u8MoreFrag, u32FOpnumOffsetOpnum, PDU_TYPE_REQ);
}
return offset;
}
/* dissect a PN-IO RSI CONN block (on top of PN-RT protocol) */
static int
dissect_RSI_CONN_block(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, guint8 *drep, guint8 u8MoreFrag, guint32 u32FOpnumOffsetOffset, guint32 u32FOpnumOffsetOpnum)
packet_info *pinfo, proto_tree *tree, guint8 *drep, guint16 u16VarPartLen, guint8 u8MoreFrag, guint32 u32FOpnumOffsetOffset, guint32 u32FOpnumOffsetOpnum)
{
proto_item *sub_item;
proto_tree *sub_tree;
@ -418,6 +425,10 @@ dissect_RSI_CONN_block(tvbuff_t *tvb, int offset,
guint16 u16DeviceId;
guint16 u16InstanceId;
guint8 u8RsiInterface;
guint32 u32RsiHeaderSize = 4;
// PDU.FOpnumOffset.Offset + PDU.VarPartLen - 4 - RsiHeaderSize
gint32 length = u32FOpnumOffsetOffset + u16VarPartLen - 4 - u32RsiHeaderSize;
sub_item = proto_tree_add_item(tree, hf_pn_rsi_conn_block, tvb, offset, 0, ENC_NA);
sub_tree = proto_item_add_subtree(sub_item, ett_pn_rsi_conn_block);
@ -442,8 +453,10 @@ dissect_RSI_CONN_block(tvbuff_t *tvb, int offset,
proto_item_append_text(sub_item, ", RSI Header of CONN is at first segment");
}
offset = dissect_pn_rta_remaining_user_data_bytes(tvb, offset, pinfo, sub_tree, drep,
tvb_captured_length_remaining(tvb, offset), u8MoreFrag, u32FOpnumOffsetOpnum, PDU_TYPE_REQ);
if (length > 0) {
offset = dissect_pn_rta_remaining_user_data_bytes(tvb, offset, pinfo, sub_tree, drep,
tvb_captured_length_remaining(tvb, offset), u8MoreFrag, u32FOpnumOffsetOpnum, PDU_TYPE_REQ);
}
return offset;
}
@ -451,7 +464,7 @@ dissect_RSI_CONN_block(tvbuff_t *tvb, int offset,
/* dissect a PN-IO RSI FREQ RTA PDU (on top of PN-RT protocol) */
static int
dissect_FREQ_RTA_block(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, guint8 *drep, guint8 u8MoreFrag)
packet_info *pinfo, proto_tree *tree, guint8 *drep, guint16 u16VarPartLen, guint8 u8MoreFrag)
{
guint32 u32FOpnumOffset;
guint32 u32FOpnumOffsetOpnum;
@ -462,7 +475,7 @@ dissect_FREQ_RTA_block(tvbuff_t *tvb, int offset,
switch (u32FOpnumOffsetOpnum) {
case(0x0): /* RSI-CONN-PDU */
col_append_str(pinfo->cinfo, COL_INFO, "Connect request");
offset = dissect_RSI_CONN_block(tvb, offset, pinfo, tree, drep, u8MoreFrag, u32FOpnumOffsetOffset, u32FOpnumOffsetOpnum);
offset = dissect_RSI_CONN_block(tvb, offset, pinfo, tree, drep, u16VarPartLen, u8MoreFrag, u32FOpnumOffsetOffset, u32FOpnumOffsetOpnum);
break;
case(0x1): /* Reserved */
col_append_str(pinfo->cinfo, COL_INFO, "Reserved");
@ -470,35 +483,35 @@ dissect_FREQ_RTA_block(tvbuff_t *tvb, int offset,
break;
case(0x2): /* RSI-SVCS-PDU (Only valid with ARUUID<>0) */
col_append_str(pinfo->cinfo, COL_INFO, "Read request");
offset = dissect_RSI_SVCS_block(tvb, offset, pinfo, tree, drep, u8MoreFrag, u32FOpnumOffsetOffset, u32FOpnumOffsetOpnum);
offset = dissect_RSI_SVCS_block(tvb, offset, pinfo, tree, drep, u16VarPartLen, u8MoreFrag, u32FOpnumOffsetOffset, u32FOpnumOffsetOpnum);
break;
case(0x3): /* RSI-SVCS-PDU */
col_append_str(pinfo->cinfo, COL_INFO, "Write request");
offset = dissect_RSI_SVCS_block(tvb, offset, pinfo, tree, drep, u8MoreFrag, u32FOpnumOffsetOffset, u32FOpnumOffsetOpnum);
offset = dissect_RSI_SVCS_block(tvb, offset, pinfo, tree, drep, u16VarPartLen, u8MoreFrag, u32FOpnumOffsetOffset, u32FOpnumOffsetOpnum);
break;
case(0x4): /* RSI-SVCS-PDU */
col_append_str(pinfo->cinfo, COL_INFO, "Control request");
offset = dissect_RSI_SVCS_block(tvb, offset, pinfo, tree, drep, u8MoreFrag, u32FOpnumOffsetOffset, u32FOpnumOffsetOpnum);
offset = dissect_RSI_SVCS_block(tvb, offset, pinfo, tree, drep, u16VarPartLen, u8MoreFrag, u32FOpnumOffsetOffset, u32FOpnumOffsetOpnum);
break;
case(0x5): /* RSI-CONN-PDU (Only valid with ARUUID=0) */
col_append_str(pinfo->cinfo, COL_INFO, "ReadImplicit request");
offset = dissect_RSI_CONN_block(tvb, offset, pinfo, tree, drep, u8MoreFrag, u32FOpnumOffsetOffset, u32FOpnumOffsetOpnum);
offset = dissect_RSI_CONN_block(tvb, offset, pinfo, tree, drep, u16VarPartLen, u8MoreFrag, u32FOpnumOffsetOffset, u32FOpnumOffsetOpnum);
break;
case(0x6): /* RSI-CONN-PDU (Only valid with ARUUID<>0) */
col_append_str(pinfo->cinfo, COL_INFO, "ReadConnectionless request");
offset = dissect_RSI_CONN_block(tvb, offset, pinfo, tree, drep, u8MoreFrag, u32FOpnumOffsetOffset, u32FOpnumOffsetOpnum);
offset = dissect_RSI_CONN_block(tvb, offset, pinfo, tree, drep, u16VarPartLen, u8MoreFrag, u32FOpnumOffsetOffset, u32FOpnumOffsetOpnum);
break;
case(0x7): /* RSI-SVCS-PDU */
col_append_str(pinfo->cinfo, COL_INFO, "ReadNotification request");
offset = dissect_RSI_SVCS_block(tvb, offset, pinfo, tree, drep, u8MoreFrag, u32FOpnumOffsetOffset, u32FOpnumOffsetOpnum);
offset = dissect_RSI_SVCS_block(tvb, offset, pinfo, tree, drep, u16VarPartLen, u8MoreFrag, u32FOpnumOffsetOffset, u32FOpnumOffsetOpnum);
break;
case(0x8): /* RSI-SVCS-PDU */
col_append_str(pinfo->cinfo, COL_INFO, "PrmWriteMore request");
offset = dissect_RSI_SVCS_block(tvb, offset, pinfo, tree, drep, u8MoreFrag, u32FOpnumOffsetOffset, u32FOpnumOffsetOpnum);
offset = dissect_RSI_SVCS_block(tvb, offset, pinfo, tree, drep, u16VarPartLen, u8MoreFrag, u32FOpnumOffsetOffset, u32FOpnumOffsetOpnum);
break;
case(0x9) : /* RSI-SVCS-PDU */
col_append_str(pinfo->cinfo, COL_INFO, "PrmWriteEnd request");
offset = dissect_RSI_SVCS_block(tvb, offset, pinfo, tree, drep, u8MoreFrag, u32FOpnumOffsetOffset, u32FOpnumOffsetOpnum);
offset = dissect_RSI_SVCS_block(tvb, offset, pinfo, tree, drep, u16VarPartLen, u8MoreFrag, u32FOpnumOffsetOffset, u32FOpnumOffsetOpnum);
break;
default:
col_append_str(pinfo->cinfo, COL_INFO, "Reserved");
@ -701,7 +714,7 @@ dissect_PNIO_RSI(tvbuff_t *tvb, int offset,
offset = dissect_PNIO_status(tvb, offset, pinfo, rta_tree, drep);
break;
case(5): /* FREQ-RTA */
offset = dissect_FREQ_RTA_block(tvb, offset, pinfo, rta_tree, drep, u8MoreFrag);
offset = dissect_FREQ_RTA_block(tvb, offset, pinfo, rta_tree, drep, u16VarPartLen, u8MoreFrag);
break;
case(6): /* FRSP-RTA */
offset = dissect_FRSP_RTA_block(tvb, offset, pinfo, rta_tree, drep, u16VarPartLen, u8MoreFrag);

View File

@ -365,7 +365,7 @@ dissect_CSF_SDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
/* possible FrameID ranges for DFP */
if ((u16FrameID < 0x100) || (u16FrameID > 0x0FFF))
if ((u16FrameID < 0x0100) || (u16FrameID > 0x3FFF))
return (FALSE);
if (IsDFP_Frame(tvb, pinfo, u16FrameID)) {
/* can't check this CRC, as the checked data bytes are not available */
@ -597,7 +597,8 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
tvbuff_t *next_tvb;
gboolean bCyclic;
heur_dtbl_entry_t *hdtbl_entry;
conversation_t* conversation;
guint8 isTimeAware = FALSE;
/* If the link-layer dissector for the protocol above us knows whether
* the packet, as handed to it, includes a link-layer FCS, what it
@ -638,6 +639,13 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
return 0;
}
/* TimeAwareness Information needed for differentiating RTC3 - RTSteam frames */
conversation = find_conversation(pinfo->num, &pinfo->dl_src, &pinfo->dl_dst, ENDPOINT_NONE, 0, 0, 0);
if (conversation != NULL) {
isTimeAware = GPOINTER_TO_UINT(conversation_get_proto_data(conversation, proto_pn_io_time_aware_status));
}
/* build some "raw" data */
u16FrameID = tvb_get_ntohs(tvb, 0);
if (u16FrameID <= 0x001F) {
@ -670,24 +678,48 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
pszProtSummary = "Real-Time";
pszProtComment = "0x0082-0x00FF: Reserved ID";
bCyclic = FALSE;
} else if (u16FrameID <= 0x6FF) {
} else if (u16FrameID <= 0x6FF && !isTimeAware) {
pszProtShort = "PN-RTC3";
pszProtAddInfo = "RTC3, ";
pszProtSummary = "Isochronous-Real-Time";
pszProtComment = "0x0100-0x06FF: RED: Real-Time(class=3): non redundant, normal or DFP";
bCyclic = TRUE;
} else if (u16FrameID <= 0x0FFF) {
} else if (u16FrameID <= 0x0FFF && !isTimeAware) {
pszProtShort = "PN-RTC3";
pszProtAddInfo = "RTC3, ";
pszProtSummary = "Isochronous-Real-Time";
pszProtComment = "0x0700-0x0FFF: RED: Real-Time(class=3): redundant, normal or DFP";
bCyclic = TRUE;
} else if (u16FrameID <= 0x7FFF) {
} else if (u16FrameID <= 0x7FFF && !isTimeAware) {
pszProtShort = "PN-RT";
pszProtAddInfo = "reserved, ";
pszProtSummary = "Real-Time";
pszProtComment = "0x1000-0x7FFF: Reserved ID";
bCyclic = FALSE;
} else if (u16FrameID <= 0x0FFF && isTimeAware) {
pszProtShort = "PN-RT";
pszProtAddInfo = "reserved, ";
pszProtSummary = "Real-Time";
pszProtComment = "0x0100-0x0FFF: Reserved ID";
bCyclic = FALSE;
} else if (u16FrameID <= 0x2FFF && isTimeAware) {
pszProtShort = "PN-RTCS";
pszProtAddInfo = "RT_STREAM, ";
pszProtSummary = "Real-Time";
pszProtComment = "0x1000-0x2FFF: RT_CLASS_STREAM";
bCyclic = TRUE;
} else if (u16FrameID <= 0x37FF && isTimeAware) {
pszProtShort = "PN-RT";
pszProtAddInfo = "reserved, ";
pszProtSummary = "Real-Time";
pszProtComment = "0x3000-0x37FF: Reserved ID";
bCyclic = FALSE;
} else if (u16FrameID <= 0x3FFF && isTimeAware) {
pszProtShort = "PN-RTCS";
pszProtAddInfo = "RT_STREAM, ";
pszProtSummary = "Real-Time";
pszProtComment = "0x3800-0x3FFF: RT_CLASS_STREAM";
bCyclic = TRUE;
} else if (u16FrameID <= 0xBBFF) {
pszProtShort = "PN-RTC1";
pszProtAddInfo = "RTC1, ";

View File

@ -26,6 +26,8 @@
/* ---- Structures for pnio_rtc1 ---- */
extern int proto_pn_dcp;
extern int proto_pn_io_apdu_status;
extern int proto_pn_io_time_aware_status;
extern gboolean pnio_ps_selection; /* given by pnio preferences */
/* Structure for general station information */