diff options
author | Michael Mann <mmann78@netscape.net> | 2017-05-16 14:48:34 -0400 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-05-17 15:16:42 +0000 |
commit | 99b76a5bc3db9579351c0fc7251086660f4f003f (patch) | |
tree | 362629bf932645e3742cf8dd32d1355b97604dac /epan/dissectors/packet-ax4000.c | |
parent | 3b7790004a3e8df79fc313143b582a552081ed29 (diff) |
Use proto_tree_add_item instead of proto_tree_add_xxx.
It's a little more efficient to use proto_tree_add_item, than
proto_tree_add_xxx, passing it the returned tvb_get_xxx value.
Change-Id: I22ddd7ab36e1ee5aae78fc693d7dbac4b4f802f2
Reviewed-on: https://code.wireshark.org/review/21691
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-ax4000.c')
-rw-r--r-- | epan/dissectors/packet-ax4000.c | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/epan/dissectors/packet-ax4000.c b/epan/dissectors/packet-ax4000.c index 8b2f35c72e..017b5b3df0 100644 --- a/epan/dissectors/packet-ax4000.c +++ b/epan/dissectors/packet-ax4000.c @@ -49,48 +49,29 @@ dissect_ax4000(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _ proto_item *ti; proto_tree *ax4000_tree; - guint8 ax_port; - guint8 ax_chassis; - guint16 ax_index; - guint32 ax_seq; - guint32 ax_timestamp; + guint32 ax_port, ax_chassis, ax_index, ax_seq, ax_timestamp; /* Make entries in Protocol column and Info column on summary display */ col_set_str(pinfo->cinfo, COL_PROTOCOL, "AX4000"); col_clear(pinfo->cinfo, COL_INFO); - ax_port = tvb_get_guint8(tvb, 0); - ax_chassis = tvb_get_guint8(tvb, 1); - ax_index = tvb_get_ntohs(tvb, 2) & 0x0FFF; - ax_timestamp = tvb_get_letohl(tvb, 6); - ax_seq = tvb_get_letohl(tvb, 10); + /* create display subtree for the protocol */ + ti = proto_tree_add_item(tree, proto_ax4000, tvb, 0, -1, ENC_NA); + + ax4000_tree = proto_item_add_subtree(ti, ett_ax4000); + + proto_tree_add_item_ret_uint(ax4000_tree, hf_ax4000_port, tvb, 0, 1, ENC_LITTLE_ENDIAN, &ax_port); + proto_tree_add_item_ret_uint(ax4000_tree, hf_ax4000_chassis, tvb, 1, 1, ENC_LITTLE_ENDIAN, &ax_chassis); + proto_tree_add_item(ax4000_tree, hf_ax4000_fill, tvb, 2, 1, ENC_BIG_ENDIAN); + proto_tree_add_item_ret_uint(ax4000_tree, hf_ax4000_index, tvb, 2, 2, ENC_BIG_ENDIAN, &ax_index); + proto_tree_add_item_ret_uint(ax4000_tree, hf_ax4000_timestamp, tvb, 6, 4, ENC_LITTLE_ENDIAN, &ax_timestamp); + proto_tree_add_item_ret_uint(ax4000_tree, hf_ax4000_seq, tvb, 10, 4, ENC_LITTLE_ENDIAN, &ax_seq); + proto_tree_add_item(ax4000_tree, hf_ax4000_crc, tvb, 14, 2, ENC_LITTLE_ENDIAN); col_append_fstr(pinfo->cinfo, COL_INFO, "Chss:%u Prt:%u Idx:%u Seq:0x%08x TS:%.6f[msec]", ax_chassis, ax_port, ax_index, ax_seq, ax_timestamp*1e-5); - if (tree) { - /* create display subtree for the protocol */ - ti = proto_tree_add_item(tree, proto_ax4000, tvb, 0, -1, ENC_NA); - - ax4000_tree = proto_item_add_subtree(ti, ett_ax4000); - - proto_tree_add_uint(ax4000_tree, - hf_ax4000_port, tvb, 0, 1, ax_port); - proto_tree_add_uint(ax4000_tree, - hf_ax4000_chassis, tvb, 1, 1, ax_chassis); - proto_tree_add_item(ax4000_tree, - hf_ax4000_fill, tvb, 2, 1, ENC_BIG_ENDIAN); - proto_tree_add_uint(ax4000_tree, - hf_ax4000_index, tvb, 2, 2, ax_index); - proto_tree_add_uint(ax4000_tree, - hf_ax4000_timestamp, tvb, 6, 4, ax_timestamp); - proto_tree_add_uint(ax4000_tree, - hf_ax4000_seq, tvb, 10, 4, ax_seq); - proto_tree_add_uint(ax4000_tree, - hf_ax4000_crc, tvb, 14, 2, tvb_get_letohs(tvb, 14)); - } - return tvb_captured_length(tvb); } |