From daed8070dd87d18abd31ff95aa2abe327ede2af3 Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Sun, 23 Nov 2014 00:12:57 -0500 Subject: Pass FrameID as data to the heuristic table, rather than use pinfo->private_data. Change-Id: Idd5818cbb2b1f8628bb29c2c71dfc6d41df89b5d Reviewed-on: https://code.wireshark.org/review/5448 Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- plugins/profinet/packet-dcerpc-pn-io.c | 8 +++----- plugins/profinet/packet-dcom-cba-acco.c | 8 +++----- plugins/profinet/packet-pn-dcp.c | 8 +++----- plugins/profinet/packet-pn-mrrt.c | 8 +++----- plugins/profinet/packet-pn-ptcp.c | 8 +++----- plugins/profinet/packet-pn-rt.c | 28 +++++++++------------------- 6 files changed, 24 insertions(+), 44 deletions(-) (limited to 'plugins') diff --git a/plugins/profinet/packet-dcerpc-pn-io.c b/plugins/profinet/packet-dcerpc-pn-io.c index e0d110efbf..f9c382b1af 100644 --- a/plugins/profinet/packet-dcerpc-pn-io.c +++ b/plugins/profinet/packet-dcerpc-pn-io.c @@ -9415,12 +9415,13 @@ dissect_PNIO_RTA(tvbuff_t *tvb, int offset, /* possibly dissect a PN-IO related PN-RT packet */ static gboolean dissect_PNIO_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, - void *data _U_) + void *data) { guint8 drep_data = 0; guint8 *drep = &drep_data; guint8 u8CBAVersion; - guint16 u16FrameID; + /* the sub tvb will NOT contain the frame_id here! */ + guint16 u16FrameID = GPOINTER_TO_UINT(data); heur_dtbl_entry_t *hdtbl_entry; /* @@ -9431,9 +9432,6 @@ 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; - /* the sub tvb will NOT contain the frame_id here! */ - u16FrameID = GPOINTER_TO_UINT(pinfo->private_data); - u8CBAVersion = tvb_get_guint8 (tvb, 0); /* is this a (none DFP) PNIO class 3 data packet? */ diff --git a/plugins/profinet/packet-dcom-cba-acco.c b/plugins/profinet/packet-dcom-cba-acco.c index 57cb135daf..28ed2a337d 100644 --- a/plugins/profinet/packet-dcom-cba-acco.c +++ b/plugins/profinet/packet-dcom-cba-acco.c @@ -3148,15 +3148,13 @@ dissect_CBA_Connection_Data(tvbuff_t *tvb, static gboolean dissect_CBA_Connection_Data_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, - void *data _U_) + void *data) { guint8 u8Version; guint8 u8Flags; - guint16 u16FrameID; - cba_frame_t *frame; - /* the tvb will NOT contain the frame_id here! */ - u16FrameID = GPOINTER_TO_UINT(pinfo->private_data); + guint16 u16FrameID = GPOINTER_TO_UINT(data); + cba_frame_t *frame; /* frame id must be in valid range (cyclic Real-Time, class=1 or class=2) */ if (u16FrameID < 0x8000 || u16FrameID >= 0xfb00) { diff --git a/plugins/profinet/packet-pn-dcp.c b/plugins/profinet/packet-pn-dcp.c index 01e05f6169..72e0a4e6a0 100644 --- a/plugins/profinet/packet-pn-dcp.c +++ b/plugins/profinet/packet-pn-dcp.c @@ -1009,16 +1009,14 @@ dissect_PNDCP_PDU(tvbuff_t *tvb, /* possibly dissect a PN-RT packet (frame ID must be in the appropriate range) */ static gboolean dissect_PNDCP_Data_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, - void *data _U_) + void *data) { - guint16 u16FrameID; + /* the tvb will NOT contain the frame_id here, so get it from dissection data! */ + guint16 u16FrameID = GPOINTER_TO_UINT(data); proto_item *item; proto_tree *dcp_tree; - /* 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 (acyclic Real-Time, DCP) */ if (u16FrameID < FRAME_ID_DCP_HELLO || u16FrameID > FRAME_ID_DCP_IDENT_RES) { /* we are not interested in this packet */ diff --git a/plugins/profinet/packet-pn-mrrt.c b/plugins/profinet/packet-pn-mrrt.c index 6649ecbd3f..6cb38e3d7a 100644 --- a/plugins/profinet/packet-pn-mrrt.c +++ b/plugins/profinet/packet-pn-mrrt.c @@ -160,18 +160,16 @@ dissect_PNMRRT_PDU(tvbuff_t *tvb, int 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, - void *data _U_) + void *data) { - guint16 u16FrameID; + /* the tvb will NOT contain the frame_id here, so get it from dissector data! */ + guint16 u16FrameID = GPOINTER_TO_UINT(data); proto_item *item; proto_tree *mrrt_tree; 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 */ diff --git a/plugins/profinet/packet-pn-ptcp.c b/plugins/profinet/packet-pn-ptcp.c index dfe155ebcf..a52a47fbe3 100644 --- a/plugins/profinet/packet-pn-ptcp.c +++ b/plugins/profinet/packet-pn-ptcp.c @@ -774,18 +774,16 @@ dissect_PNPTCP_DelayPDU(tvbuff_t *tvb, int offset, /* possibly dissect a PN-RT packet (frame ID must be in the appropriate range) */ static gboolean -dissect_PNPTCP_Data_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) +dissect_PNPTCP_Data_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { - guint16 u16FrameID; + /* the tvb will NOT contain the frame_id here, so get it from dissector data! */ + guint16 u16FrameID = GPOINTER_TO_UINT(data); proto_item *item; proto_tree *ptcp_tree; 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 (acyclic Real-Time, PTCP) */ /* 0x0000 - 0x007F: RTSyncPDU (with follow up) */ /* 0x0080 - 0x00FF: RTSyncPDU (without follow up) */ diff --git a/plugins/profinet/packet-pn-rt.c b/plugins/profinet/packet-pn-rt.c index 86ff4e1333..f0a359ed29 100644 --- a/plugins/profinet/packet-pn-rt.c +++ b/plugins/profinet/packet-pn-rt.c @@ -154,7 +154,7 @@ dissect_DataStatus(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 u8DataSta static gboolean -IsDFP_Frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +IsDFP_Frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 u16FrameID) { guint16 u16SFCRC16; guint8 u8SFPosition; @@ -164,10 +164,6 @@ IsDFP_Frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint16 crc; gint tvb_len = 0; unsigned char virtualFramebuffer[16]; - guint16 u16FrameID; - - /* the sub tvb will NOT contain the frame_id here! */ - u16FrameID = GPOINTER_TO_UINT(pinfo->private_data); /* try to build a temporaray buffer for generating this CRC */ if (!pinfo->src.data || !pinfo->dst.data || @@ -240,9 +236,10 @@ IsDFP_Frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* possibly dissect a CSF_SDU related PN-RT packet */ gboolean -dissect_CSF_SDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) +dissect_CSF_SDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { - guint16 u16FrameID; + /* the sub tvb will NOT contain the frame_id here! */ + guint16 u16FrameID = GPOINTER_TO_UINT(data); guint16 u16SFCRC16; guint8 u8SFPosition; guint8 u8SFDataLength = 255; @@ -256,13 +253,10 @@ dissect_CSF_SDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * guint16 crc; - /* the sub tvb will NOT contain the frame_id here! */ - u16FrameID = GPOINTER_TO_UINT(pinfo->private_data); - /* possible FrameID ranges for DFP */ if ((u16FrameID < 0x100) || (u16FrameID > 0x0FFF)) return (FALSE); - if (IsDFP_Frame(tvb, pinfo, tree)) { + if (IsDFP_Frame(tvb, pinfo, tree, u16FrameID)) { /* can't check this CRC, as the checked data bytes are not available */ u16SFCRC16 = tvb_get_letohs(tvb, offset); if (u16SFCRC16 != 0) @@ -370,15 +364,13 @@ pnio_defragment_init(void) /* possibly dissect a FRAG_PDU related PN-RT packet */ static gboolean -dissect_FRAG_PDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) +dissect_FRAG_PDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { - guint16 u16FrameID; + /* the sub tvb will NOT contain the frame_id here! */ + guint16 u16FrameID = GPOINTER_TO_UINT(data); int offset = 0; - /* the sub tvb will NOT contain the frame_id here! */ - u16FrameID = GPOINTER_TO_UINT(pinfo->private_data); - /* possible FrameID ranges for FRAG_PDU */ if (u16FrameID >= 0xFF80 && u16FrameID <= 0xFF8F) { proto_item *sub_item; @@ -801,13 +793,11 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_add_str(pinfo->cinfo, COL_INFO, szFieldSummary); col_set_str(pinfo->cinfo, COL_PROTOCOL, pszProtShort); - pinfo->private_data = GUINT_TO_POINTER( (guint32) u16FrameID); - /* get frame user data tvb (without header and footer) */ next_tvb = tvb_new_subset_length(tvb, 2, data_len); /* ask heuristics, if some sub-dissector is interested in this packet payload */ - if (!dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, tree, &hdtbl_entry, NULL)) { + if (!dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, tree, &hdtbl_entry, GUINT_TO_POINTER( (guint32) u16FrameID))) { /*col_set_str(pinfo->cinfo, COL_INFO, "Unknown");*/ /* Oh, well, we don't know this; dissect it as data. */ -- cgit v1.2.3