diff options
author | Michael Mann <mmann78@netscape.net> | 2015-05-25 14:58:05 -0400 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2015-05-26 15:20:46 +0000 |
commit | a25c46bc7b3d2ba2a3674cdcf9cfc1cc79bfc022 (patch) | |
tree | 3a4345ecffb89b5314692937199cc3653b69b47b /epan/dissectors/packet-glusterfs.c | |
parent | c6b0a61ab3c6b41c9d7da2cf986b503b6f3e99b7 (diff) |
Remove proto_tree_add_text from some dissectors.
Change-Id: Id7ef95a56d9d8cc01f9a1a4556ad056b8bb7f8bc
Reviewed-on: https://code.wireshark.org/review/8654
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-glusterfs.c')
-rw-r--r-- | epan/dissectors/packet-glusterfs.c | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/epan/dissectors/packet-glusterfs.c b/epan/dissectors/packet-glusterfs.c index f2c74a35fe..a064b03910 100644 --- a/epan/dissectors/packet-glusterfs.c +++ b/epan/dissectors/packet-glusterfs.c @@ -196,6 +196,13 @@ static gint hf_glusterfs_fsync_flag_unknown = -1; /* for entrylk */ static gint hf_glusterfs_entrylk_namelen = -1; +static gint hf_gluster_dict_size = -1; +static gint hf_gluster_num_dict_items = -1; +static gint hf_gluster_rpc_roundup_bytes = -1; +static gint hf_gluster_trusted_afr_key = -1; +static gint hf_gluster_dict_value = -1; + + /* Initialize the subtree pointers */ static gint ett_glusterfs = -1; static gint ett_glusterfs_flags = -1; @@ -478,10 +485,11 @@ gluster_rpc_dissect_dict(proto_tree *tree, tvbuff_t *tvb, int hfindex, int offse { gchar *key, *value; const gchar *name; - gint items, i, len, roundup, value_len, key_len; + gint roundup, value_len, key_len; + guint32 i, items, len; int start_offset, start_offset2; - proto_item *subtree_item; + proto_item *subtree_item, *ti; proto_tree *subtree; proto_item *dict_item = NULL; @@ -498,7 +506,9 @@ gluster_rpc_dissect_dict(proto_tree *tree, tvbuff_t *tvb, int hfindex, int offse len = tvb_get_ntohl(tvb, offset); roundup = rpc_roundup(len) - len; - proto_tree_add_text(subtree, tvb, offset, 4, "[Size: %d (%d bytes inc. RPC-roundup)]", len, rpc_roundup(len)); + ti = proto_tree_add_item_ret_uint(subtree, hf_gluster_dict_size, tvb, offset, 4, ENC_BIG_ENDIAN, &len); + proto_item_append_text(ti, " (%d bytes inc. RPC-roundup)", rpc_roundup(len)); + PROTO_ITEM_SET_GENERATED(ti); offset += 4; if (len == 0) @@ -511,7 +521,7 @@ gluster_rpc_dissect_dict(proto_tree *tree, tvbuff_t *tvb, int hfindex, int offse if (len == 0) return offset; - proto_tree_add_text(subtree, tvb, offset, 4, "Items: %d", items); + proto_tree_add_uint(subtree, hf_gluster_num_dict_items, tvb, offset, 4, items); offset += 4; for (i = 0; i < items; i++) { @@ -544,14 +554,14 @@ gluster_rpc_dissect_dict(proto_tree *tree, tvbuff_t *tvb, int hfindex, int offse "%s: %s", key, gfid_s); /* this is a changelog in binary format */ } else if (value_len == 12 && !strncmp("trusted.afr.", key, 12)) { - dict_item = proto_tree_add_text(subtree, tvb, offset, -1, - "%s: 0x%.8x%.8x%.8x", key, + dict_item = proto_tree_add_bytes_format(subtree, hf_gluster_trusted_afr_key, tvb, offset, 12, + NULL, "%s: 0x%.8x%.8x%.8x", key, tvb_get_letohl(tvb, offset + 0), tvb_get_letohl(tvb, offset + 4), tvb_get_letohl(tvb, offset + 8)); } else { value = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, value_len, ENC_ASCII); - dict_item = proto_tree_add_text(subtree, tvb, offset, -1, "%s: %s", + dict_item = proto_tree_add_string_format(subtree, hf_gluster_dict_value, tvb, offset, value_len, value, "%s: %s", key, value); } } @@ -561,8 +571,8 @@ gluster_rpc_dissect_dict(proto_tree *tree, tvbuff_t *tvb, int hfindex, int offse } if (roundup) { - if (tree) - proto_tree_add_text(subtree, tvb, offset, -1, "[RPC-roundup bytes: %d]", roundup); + ti = proto_tree_add_item(subtree, hf_gluster_rpc_roundup_bytes, tvb, offset, -1, ENC_NA); + PROTO_ITEM_SET_GENERATED(ti); offset += roundup; } @@ -2650,6 +2660,26 @@ proto_register_glusterfs(void) { "File Descriptor", "glusterfs.entrylk.namelen", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } }, + { &hf_gluster_dict_size, + { "Size", "glusterfs.dict_size", FT_UINT32, BASE_DEC, + NULL, 0, NULL, HFILL } + }, + { &hf_gluster_num_dict_items, + { "Items", "glusterfs.num_dict_items", FT_UINT32, BASE_DEC, + NULL, 0, NULL, HFILL } + }, + { &hf_gluster_rpc_roundup_bytes, + { "RPC-roundup bytes", "glusterfs.rpc_roundup_bytes", FT_BYTES, BASE_NONE, + NULL, 0, NULL, HFILL } + }, + { &hf_gluster_trusted_afr_key, + { "Key", "glusterfs.trusted_afr_key", FT_BYTES, BASE_NONE, + NULL, 0, NULL, HFILL } + }, + { &hf_gluster_dict_value, + { "Value", "glusterfs.dict_value", FT_STRING, BASE_NONE, + NULL, 0, NULL, HFILL } + }, }; /* Setup protocol subtree array */ |