From 5493fe01671f7f293eb87edb780019c889859153 Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Mon, 2 May 2016 21:44:48 -0400 Subject: Convert ftype-tvbuff.c to ftype-protocol.c As noted in https://www.wireshark.org/lists/wireshark-dev/201604/msg00103.html a protocol field isn't really a tv_buff, so allow for the possibility of a NULL tv_buff in a "protocol type". If the tvb is NULL, use the string of the protocol field for comparison Bug: 12335 Change-Id: Ie12a5f7b31c7293c61006b0f70135d100a97c4e0 Reviewed-on: https://code.wireshark.org/review/15261 Petri-Dish: Michael Mann Reviewed-by: Alexis La Goutte Reviewed-by: Michael Mann --- epan/proto.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'epan/proto.c') diff --git a/epan/proto.c b/epan/proto.c index 2a1d142b57..e2038c7bb5 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -215,7 +215,7 @@ static void proto_tree_set_representation(proto_item *pi, const char *format, va_list ap); static void -proto_tree_set_protocol_tvb(field_info *fi, tvbuff_t *tvb); +proto_tree_set_protocol_tvb(field_info *fi, tvbuff_t *tvb, const char* field_data); static void proto_tree_set_bytes(field_info *fi, const guint8* start_ptr, gint length); static void @@ -1831,7 +1831,7 @@ proto_tree_new_item(field_info *new_fi, proto_tree *tree, break; case FT_PROTOCOL: - proto_tree_set_protocol_tvb(new_fi, tvb); + proto_tree_set_protocol_tvb(new_fi, tvb, new_fi->hfinfo->name); break; case FT_BYTES: @@ -2803,9 +2803,9 @@ ptvcursor_advance(ptvcursor_t* ptvc, gint length) static void -proto_tree_set_protocol_tvb(field_info *fi, tvbuff_t *tvb) +proto_tree_set_protocol_tvb(field_info *fi, tvbuff_t *tvb, const char* field_data) { - fvalue_set_tvbuff(&fi->value, tvb); + fvalue_set_protocol(&fi->value, tvb, field_data); } /* Add a FT_PROTOCOL to a proto_tree */ @@ -2816,6 +2816,7 @@ proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, proto_item *pi; va_list ap; header_field_info *hfinfo; + gchar* protocol_rep; CHECK_FOR_NULL_TREE(tree); @@ -2825,7 +2826,11 @@ proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, pi = proto_tree_add_pi(tree, hfinfo, tvb, start, &length); - proto_tree_set_protocol_tvb(PNODE_FINFO(pi), (start == 0 ? tvb : tvb_new_subset_length(tvb, start, length))); + va_start(ap, format); + protocol_rep = g_strdup_vprintf(format, ap); + proto_tree_set_protocol_tvb(PNODE_FINFO(pi), (start == 0 ? tvb : tvb_new_subset_length(tvb, start, length)), protocol_rep); + g_free(protocol_rep); + va_end(ap); TRY_TO_FAKE_THIS_REPR(pi); -- cgit v1.2.3