From a614212aa80a831f91ec3a2b17760d4f2c02bdeb Mon Sep 17 00:00:00 2001 From: Pascal Quantin Date: Thu, 29 Jan 2015 23:06:37 +0100 Subject: SDP: add ability to display port as a string Bug: 10898 Change-Id: Ib1b5698c85cd568b8874b44690cafe391eea28f3 Reviewed-on: https://code.wireshark.org/review/6849 Reviewed-by: Pascal Quantin Petri-Dish: Pascal Quantin Tested-by: Petri Dish Buildbot Reviewed-by: Alexis La Goutte --- epan/dissectors/packet-sdp.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'epan/dissectors/packet-sdp.c') diff --git a/epan/dissectors/packet-sdp.c b/epan/dissectors/packet-sdp.c index 73697ae6a5..d0fb766c92 100644 --- a/epan/dissectors/packet-sdp.c +++ b/epan/dissectors/packet-sdp.c @@ -139,6 +139,7 @@ static int hf_session_attribute_value = -1; /* hf_media subfields */ static int hf_media_media = -1; static int hf_media_port = -1; +static int hf_media_port_string = -1; static int hf_media_portcount = -1; static int hf_media_proto = -1; static int hf_media_format = -1; @@ -868,6 +869,7 @@ dissect_sdp_media(tvbuff_t *tvb, proto_item *ti, gint offset, next_offset, tokenlen, idx; guint8 *media_format; gboolean optional = FALSE; + proto_item *it; offset = 0; @@ -905,8 +907,13 @@ dissect_sdp_media(tvbuff_t *tvb, proto_item *ti, media_info->media_port[media_info->media_count], media_info->media_count)); - proto_tree_add_uint(sdp_media_tree, hf_media_port, tvb, offset, tokenlen, - atoi((char*)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tokenlen, ENC_UTF_8|ENC_NA))); + it = proto_tree_add_string(sdp_media_tree, hf_media_port_string, tvb, offset, tokenlen, + media_info->media_port[media_info->media_count]); + if (g_ascii_isdigit(media_info->media_port[media_info->media_count][0])) { + PROTO_ITEM_SET_HIDDEN(it); + proto_tree_add_uint(sdp_media_tree, hf_media_port, tvb, offset, tokenlen, + atoi(media_info->media_port[media_info->media_count])); + } offset = next_offset + 1; tokenlen = find_next_token_in_line(tvb, sdp_media_tree, &offset, &next_offset); @@ -929,8 +936,13 @@ dissect_sdp_media(tvbuff_t *tvb, proto_item *ti, media_info->media_port[media_info->media_count], media_info->media_count)); /* XXX Remember Port */ - proto_tree_add_uint(sdp_media_tree, hf_media_port, tvb, offset, tokenlen, - atoi((char*)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tokenlen, ENC_UTF_8|ENC_NA))); + it = proto_tree_add_string(sdp_media_tree, hf_media_port_string, tvb, offset, tokenlen, + media_info->media_port[media_info->media_count]); + if (g_ascii_isdigit(media_info->media_port[media_info->media_count][0])) { + PROTO_ITEM_SET_HIDDEN(it); + proto_tree_add_uint(sdp_media_tree, hf_media_port, tvb, offset, tokenlen, + atoi(media_info->media_port[media_info->media_count])); + } offset = next_offset + 1; } @@ -2850,6 +2862,11 @@ proto_register_sdp(void) FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } }, + { &hf_media_port_string, + { "Media Port", "sdp.media.port_string", + FT_STRING, BASE_NONE, NULL, 0x0, + NULL, HFILL } + }, { &hf_media_portcount, { "Media Port Count", "sdp.media.portcount", FT_STRING, BASE_NONE, NULL, 0x0, -- cgit v1.2.3