aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-tpncp.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2014-09-06 18:04:28 -0400
committerEvan Huus <eapache@gmail.com>2014-09-08 15:46:05 +0000
commitcf8f11f67876462510cc4254b845063c6cc047de (patch)
treec9fc47b3795bbb7bbb88c22a7c4014978342bd69 /epan/dissectors/packet-tpncp.c
parent433a444d148f86f2562f804d25a57d00dc277cc0 (diff)
Eliminate proto_tree_add_text from some of the dissectors.
Other minor cleanups while in the area. Change-Id: I623d941e53128f169e55dfc629547b4221fa72fc Reviewed-on: https://code.wireshark.org/review/4021 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: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-tpncp.c')
-rw-r--r--epan/dissectors/packet-tpncp.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/epan/dissectors/packet-tpncp.c b/epan/dissectors/packet-tpncp.c
index f75cbf6a50..b9a93072be 100644
--- a/epan/dissectors/packet-tpncp.c
+++ b/epan/dissectors/packet-tpncp.c
@@ -135,9 +135,8 @@ static hf_register_info *hf = NULL;
/*-------------------------------------------------------------------------------------------------------------------------------------------*/
-static void dissect_tpncp_data(gint data_id, tvbuff_t *tvb, proto_item *item,
+static void dissect_tpncp_data(gint data_id, tvbuff_t *tvb, proto_tree *ltree,
gint *offset, tpncp_data_field_info *data_fields_info) {
- proto_tree *ltree = NULL;
proto_item *pi = NULL;
gint32 g_int;
gint16 g_short;
@@ -147,7 +146,6 @@ static void dissect_tpncp_data(gint data_id, tvbuff_t *tvb, proto_item *item,
gint g_str_len, counter, bitshift, bitmask;
tpncp_data_field_info *current_tpncp_data_field_info = NULL;
- ltree = proto_item_add_subtree(item, ett_tpncp_body);
current_tpncp_data_field_info = &data_fields_info[data_id];
while (current_tpncp_data_field_info) {
@@ -229,11 +227,11 @@ static void dissect_tpncp_data(gint data_id, tvbuff_t *tvb, proto_item *item,
/*-------------------------------------------------------------------------------------------------------------------------------------------*/
static void dissect_tpncp_event(gint event_id, tvbuff_t *tvb,
- proto_item *item, gint *offset) {
+ proto_tree *tree, gint *offset) {
switch (event_id) {
/* Place non-standard events here. */
default:
- dissect_tpncp_data(event_id, tvb, item, offset, tpncp_events_info_db);
+ dissect_tpncp_data(event_id, tvb, tree, offset, tpncp_events_info_db);
break;
}
}
@@ -241,11 +239,11 @@ static void dissect_tpncp_event(gint event_id, tvbuff_t *tvb,
/*-------------------------------------------------------------------------------------------------------------------------------------------*/
static void dissect_tpncp_command(gint command_id, tvbuff_t *tvb,
- proto_item *item, gint *offset) {
+ proto_tree *tree, gint *offset) {
switch (command_id) {
/* Place non-standard commands here. */
default:
- dissect_tpncp_data(command_id, tvb, item, offset, tpncp_commands_info_db);
+ dissect_tpncp_data(command_id, tvb, tree, offset, tpncp_commands_info_db);
break;
}
}
@@ -253,12 +251,11 @@ static void dissect_tpncp_command(gint command_id, tvbuff_t *tvb,
/*-------------------------------------------------------------------------------------------------------------------------------------------*/
static int dissect_tpncp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) {
- proto_item *item = NULL, *tpncp_item = NULL;
- proto_tree *tpncp_tree = NULL;
+ proto_item *item = NULL;
+ proto_tree *tpncp_tree = NULL, *event_tree, *command_tree;
gint offset = 0;
guint32 id, cid = 0;
guint16 seq_number, len, ver, reserved;
- gchar *tpncp_header;
ver = tvb_get_ntohs(tvb, 0);
len = tvb_get_ntohs(tvb, 2);
@@ -298,10 +295,9 @@ static int dissect_tpncp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo
proto_tree_add_int(tpncp_tree, hf_tpncp_cid, tvb, 12, 4, cid);
offset += 16;
if (tpncp_events_info_db[id].tpncp_data_field_size) {
- tpncp_header = wmem_strdup_printf(wmem_packet_scope(), "TPNCP Event: %s (%d)",
+ event_tree = proto_tree_add_subtree_format(tree, tvb, offset, -1, ett_tpncp_body, NULL, "TPNCP Event: %s (%d)",
val_to_str_const(id, tpncp_events_id_vals, "Unknown"), id);
- tpncp_item = proto_tree_add_text(tree, tvb, offset, -1, "%s", tpncp_header);
- dissect_tpncp_event(id, tvb, tpncp_item, &offset);
+ dissect_tpncp_event(id, tvb, event_tree, &offset);
}
}
}
@@ -310,10 +306,9 @@ static int dissect_tpncp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo
proto_tree_add_uint(tpncp_tree, hf_tpncp_command_id, tvb, 8, 4, id);
offset += 12;
if (tpncp_commands_info_db[id].tpncp_data_field_size) {
- tpncp_header = wmem_strdup_printf(wmem_packet_scope(), "TPNCP Command: %s (%d)",
+ command_tree = proto_tree_add_subtree_format(tree, tvb, offset, -1, ett_tpncp_body, NULL, "TPNCP Command: %s (%d)",
val_to_str_const(id, tpncp_commands_id_vals, "Unknown"), id);
- tpncp_item = proto_tree_add_text(tree, tvb, offset, -1, "%s", tpncp_header);
- dissect_tpncp_command(id, tvb, tpncp_item, &offset);
+ dissect_tpncp_command(id, tvb, command_tree, &offset);
}
}
}