diff options
author | Martin Kaiser <wireshark@kaiser.cx> | 2017-06-07 07:06:50 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-06-07 08:01:18 +0000 |
commit | 4291968f2a3f94595bfb312f4b99396b7aa9bd0b (patch) | |
tree | 42c25f6c1e607ba1cb566bb4f5fec80d1d0baf6c /plugins/profinet | |
parent | 9cfdece0c1e6ff16c1152f95cb3d4a2554728ca6 (diff) | |
download | wireshark-4291968f2a3f94595bfb312f4b99396b7aa9bd0b.tar.gz |
profinet: use proto_tree_add_item_ret_(u)int directly
Profinet defined functions to add 32bit integers to the tree and get their
value. This is equivalent to proto_tree_add_item_ret_(u)int. Call those
functions directly and remove the now obsolete Profinet functions.
In some cases, the returned 32bit value is discarded. Use
proto_tree_add_item then.
Change-Id: I7744fab2f27b8ae8e681a36e4e96eb2f8be87bd6
Reviewed-on: https://code.wireshark.org/review/21989
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'plugins/profinet')
-rw-r--r-- | plugins/profinet/packet-pn-dcp.c | 3 | ||||
-rw-r--r-- | plugins/profinet/packet-pn-mrp.c | 3 | ||||
-rw-r--r-- | plugins/profinet/packet-pn-ptcp.c | 35 | ||||
-rw-r--r-- | plugins/profinet/packet-pn.c | 22 | ||||
-rw-r--r-- | plugins/profinet/packet-pn.h | 6 |
5 files changed, 26 insertions, 43 deletions
diff --git a/plugins/profinet/packet-pn-dcp.c b/plugins/profinet/packet-pn-dcp.c index 75c47e0e6a..3e3b58a7aa 100644 --- a/plugins/profinet/packet-pn-dcp.c +++ b/plugins/profinet/packet-pn-dcp.c @@ -1036,7 +1036,8 @@ dissect_PNDCP_PDU(tvbuff_t *tvb, offset = dissect_pn_uint8 (tvb, offset, pinfo, tree, hf_pn_dcp_service_id, &service_id); offset = dissect_pn_uint8 (tvb, offset, pinfo, tree, hf_pn_dcp_service_type, &service_type); - offset = dissect_pn_uint32(tvb, offset, pinfo, tree, hf_pn_dcp_xid, &xid); + proto_tree_add_item_ret_uint(tree, hf_pn_dcp_xid, tvb, offset, 4, ENC_BIG_ENDIAN, &xid); + offset += 4; if (service_id == PNDCP_SERVICE_ID_IDENTIFY && service_type == PNDCP_SERVICE_TYPE_REQUEST) { /* multicast header */ offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_response_delay, &response_delay); diff --git a/plugins/profinet/packet-pn-mrp.c b/plugins/profinet/packet-pn-mrp.c index 253627b12a..7aa57c0ab5 100644 --- a/plugins/profinet/packet-pn-mrp.c +++ b/plugins/profinet/packet-pn-mrp.c @@ -249,7 +249,8 @@ dissect_PNMRP_Test(tvbuff_t *tvb, int offset, offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_transition, &transition); /* MRP_TimeStamp */ - offset = dissect_pn_uint32(tvb, offset, pinfo, tree, hf_pn_mrp_time_stamp, &time_stamp); + proto_tree_add_item_ret_uint(tree, hf_pn_mrp_time_stamp, tvb, offset, 4, ENC_BIG_ENDIAN, &time_stamp); + offset += 4; /* Padding */ offset = dissect_pn_align4(tvb, offset, pinfo, tree); diff --git a/plugins/profinet/packet-pn-ptcp.c b/plugins/profinet/packet-pn-ptcp.c index 0c642bc8a3..d7771f3d06 100644 --- a/plugins/profinet/packet-pn-ptcp.c +++ b/plugins/profinet/packet-pn-ptcp.c @@ -257,10 +257,12 @@ dissect_PNPTCP_Time(tvbuff_t *tvb, int offset, offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_ptcp_epoch_number, &EpochNumber); /* Seconds */ - offset = dissect_pn_uint32(tvb, offset, pinfo, tree, hf_pn_ptcp_seconds, &Seconds); + proto_tree_add_item_ret_uint(tree, hf_pn_ptcp_seconds, tvb, offset, 4, ENC_BIG_ENDIAN, &Seconds); + offset += 4; /* NanoSeconds */ - offset = dissect_pn_uint32(tvb, offset, pinfo, tree, hf_pn_ptcp_nanoseconds, &NanoSeconds); + proto_tree_add_item_ret_uint(tree, hf_pn_ptcp_nanoseconds, tvb, offset, 4, ENC_BIG_ENDIAN, &NanoSeconds); + offset += 4; proto_item_append_text(item, ": Seconds=%u NanoSeconds=%u EpochNumber=%u", Seconds, NanoSeconds, EpochNumber); @@ -369,10 +371,12 @@ dissect_PNPTCP_PortParameter(tvbuff_t *tvb, int offset, offset = dissect_pn_align4(tvb, offset, pinfo, tree); /* T2PortRxDelay */ - offset = dissect_pn_uint32(tvb, offset, pinfo, tree, hf_pn_ptcp_t2portrxdelay, &t2portrxdelay); + proto_tree_add_item_ret_uint(tree, hf_pn_ptcp_t2portrxdelay, tvb, offset, 4, ENC_BIG_ENDIAN, &t2portrxdelay); + offset += 4; /* T3PortTxDelay */ - offset = dissect_pn_uint32(tvb, offset, pinfo, tree, hf_pn_ptcp_t3porttxdelay, &t3porttxdelay); + proto_tree_add_item_ret_uint(tree, hf_pn_ptcp_t3porttxdelay, tvb, offset, 4, ENC_BIG_ENDIAN, &t3porttxdelay); + offset += 4; proto_item_append_text(item, ": T2PortRxDelay=%uns, T3PortTxDelay=%uns", t2portrxdelay, t3porttxdelay); @@ -419,7 +423,8 @@ dissect_PNPTCP_PortTime(tvbuff_t *tvb, int offset, offset = dissect_pn_align4(tvb, offset, pinfo, tree); /* T2TimeStamp */ - offset = dissect_pn_uint32(tvb, offset, pinfo, tree, hf_pn_ptcp_t2timestamp, &t2timestamp); + proto_tree_add_item_ret_uint(tree, hf_pn_ptcp_t2timestamp, tvb, offset, 4, ENC_BIG_ENDIAN, &t2timestamp); + offset += 4; proto_item_append_text(item, ": T2TimeStamp=%uns", t2timestamp); @@ -613,7 +618,8 @@ dissect_PNPTCP_FollowUpPDU(tvbuff_t *tvb, int offset, offset = dissect_pn_align4(tvb, offset, pinfo, header_tree); /* Delay1ns_FUP */ - offset = dissect_pn_int32(tvb, offset, pinfo, header_tree, hf_pn_ptcp_delay1ns_fup, &delay1ns_fup); + proto_tree_add_item_ret_int(header_tree, hf_pn_ptcp_delay1ns_fup, tvb, offset, 4, ENC_BIG_ENDIAN, &delay1ns_fup); + offset += 4; col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq=%3u, Delay=%11dns", name, seq_id, delay1ns_fup); proto_item_append_text(item, "%s: Sequence=%u, Delay=%dns", name_short, seq_id, delay1ns_fup); @@ -634,8 +640,6 @@ dissect_PNPTCP_RTSyncPDU(tvbuff_t *tvb, int offset, { proto_item *header_item; proto_tree *header_tree; - guint32 res_1; - guint32 res_2; guint32 delay10ns; guint16 seq_id; guint8 delay1ns_8; @@ -648,13 +652,16 @@ dissect_PNPTCP_RTSyncPDU(tvbuff_t *tvb, int offset, header_tree = proto_item_add_subtree(header_item, ett_pn_ptcp_header); /* Reserved_1 */ - offset = dissect_pn_uint32(tvb, offset, pinfo, header_tree, hf_pn_ptcp_res1, &res_1); + proto_tree_add_item(tree, hf_pn_ptcp_res1, tvb, offset, 4, ENC_BIG_ENDIAN); + offset += 4; /* Reserved_2 */ - offset = dissect_pn_uint32(tvb, offset, pinfo, header_tree, hf_pn_ptcp_res2, &res_2); + proto_tree_add_item(tree, hf_pn_ptcp_res2, tvb, offset, 4, ENC_BIG_ENDIAN); + offset += 4; /* Delay10ns */ - offset = dissect_pn_uint32(tvb, offset, pinfo, header_tree, hf_pn_ptcp_delay10ns, &delay10ns); + proto_tree_add_item_ret_uint(tree, hf_pn_ptcp_delay10ns, tvb, offset, 4, ENC_BIG_ENDIAN, &delay10ns); + offset += 4; /* SequenceID */ offset = dissect_pn_uint16(tvb, offset, pinfo, header_tree, hf_pn_ptcp_seq_id, &seq_id); @@ -666,7 +673,8 @@ dissect_PNPTCP_RTSyncPDU(tvbuff_t *tvb, int offset, offset = dissect_pn_align4(tvb, offset, pinfo, header_tree); /* Delay1ns */ - offset = dissect_pn_uint32(tvb, offset, pinfo, header_tree, hf_pn_ptcp_delay1ns, &delay1ns_32); + proto_tree_add_item_ret_uint(tree, hf_pn_ptcp_delay1ns, tvb, offset, 4, ENC_BIG_ENDIAN, &delay1ns_32); + offset += 4; /* Padding */ offset = dissect_pn_align4(tvb, offset, pinfo, tree); @@ -756,7 +764,8 @@ dissect_PNPTCP_DelayPDU(tvbuff_t *tvb, int offset, offset = dissect_pn_align4(tvb, offset, pinfo, header_tree); /* Delay1ns_FUP */ - offset = dissect_pn_uint32(tvb, offset, pinfo, header_tree, hf_pn_ptcp_delay1ns, &delay1ns); + proto_tree_add_item_ret_uint(tree, hf_pn_ptcp_delay1ns, tvb, offset, 4, ENC_BIG_ENDIAN, &delay1ns); + offset += 4; col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq=%3u, Delay=%11uns", name, seq_id, delay1ns); proto_item_append_text(item, "%s: Sequence=%u, Delay=%uns", name_short, seq_id, delay1ns); diff --git a/plugins/profinet/packet-pn.c b/plugins/profinet/packet-pn.c index 0399cf9253..de7c4aada5 100644 --- a/plugins/profinet/packet-pn.c +++ b/plugins/profinet/packet-pn.c @@ -100,17 +100,6 @@ dissect_pn_uint16(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, return offset + 2; } -/* dissect a 32 bit unsigned integer */ -int -dissect_pn_uint32(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, - proto_tree *tree, int hfindex, guint32 *pdata) -{ - proto_tree_add_item_ret_uint(tree, hfindex, - tvb, offset, 4, ENC_BIG_ENDIAN, pdata); - - return offset+4; -} - /* dissect a 16 bit signed integer */ int dissect_pn_int16(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, @@ -126,17 +115,6 @@ dissect_pn_int16(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, return offset + 2; } -/* dissect a 32 bit signed integer */ -int -dissect_pn_int32(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, - proto_tree *tree, int hfindex, gint32 *pdata) -{ - proto_tree_add_item_ret_int(tree, hfindex, - tvb, offset, 4, ENC_BIG_ENDIAN, pdata); - - return offset + 4; -} - /* dissect a 24bit OUI (IEC organizational unique id) */ int dissect_pn_oid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, diff --git a/plugins/profinet/packet-pn.h b/plugins/profinet/packet-pn.h index b13f814296..77cd635348 100644 --- a/plugins/profinet/packet-pn.h +++ b/plugins/profinet/packet-pn.h @@ -125,15 +125,9 @@ extern int dissect_pn_uint16_ret_item(tvbuff_t *tvb, gint offset, packet_info *p 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, proto_tree *tree, int hfindex, gint16 *pdata); -extern int dissect_pn_int32(tvbuff_t *tvb, gint offset, packet_info *pinfo, - proto_tree *tree, int hfindex, gint32 *pdata); - extern int dissect_pn_oid(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, int hfindex, guint32 *pdata); |