summaryrefslogtreecommitdiff
path: root/epan/dissectors
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2015-02-14 18:01:53 -0500
committerMichael Mann <mmann78@netscape.net>2015-02-22 02:53:48 +0000
commit8d5da72ff9255a3fd494fb2d842a7ecb9d2c7c14 (patch)
tree3e48036d26dedf29361132faec1682c9aa6fb24a /epan/dissectors
parentddafa7e381c188f0f282908003518be44130a3b6 (diff)
downloadwireshark-8d5da72ff9255a3fd494fb2d842a7ecb9d2c7c14.tar.gz
Add tvb_address_with_resolution_to_str.
Convert dissectors to using the API where appropriate. Change-Id: I059582f73a75635d4a0338d02d4c4b212162480b Reviewed-on: https://code.wireshark.org/review/7296 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors')
-rw-r--r--epan/dissectors/packet-bat.c4
-rw-r--r--epan/dissectors/packet-batadv.c61
-rw-r--r--epan/dissectors/packet-ieee8021ah.c15
-rw-r--r--epan/dissectors/packet-ip.c4
-rw-r--r--epan/dissectors/packet-ospf.c6
-rw-r--r--epan/dissectors/packet-radius.c14
-rw-r--r--epan/dissectors/packet-vmlab.c9
7 files changed, 39 insertions, 74 deletions
diff --git a/epan/dissectors/packet-bat.c b/epan/dissectors/packet-bat.c
index dbf7413b02..795f575566 100644
--- a/epan/dissectors/packet-bat.c
+++ b/epan/dissectors/packet-bat.c
@@ -378,8 +378,8 @@ static void dissect_bat_gw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
col_add_fstr(pinfo->cinfo, COL_INFO, "Type=%s",
val_to_str(gw_packeth->type, gw_packettypenames, "Unknown (0x%02x)"));
if (ip != 0) {
- col_append_fstr(pinfo->cinfo, COL_INFO, " IP: %s (%s)",
- get_hostname(ip), tvb_ip_to_str(tvb, ip_pos));
+ col_append_fstr(pinfo->cinfo, COL_INFO, " IP: %s",
+ tvb_address_with_resolution_to_str(wmem_packet_scope(), tvb, AT_IPv4, ip_pos));
}
diff --git a/epan/dissectors/packet-batadv.c b/epan/dissectors/packet-batadv.c
index 127282628b..e5db676896 100644
--- a/epan/dissectors/packet-batadv.c
+++ b/epan/dissectors/packet-batadv.c
@@ -1655,7 +1655,6 @@ static int dissect_batadv_iv_ogm_v15(tvbuff_t *tvb, int offset,
proto_tree *batadv_iv_ogm_tree = NULL;
guint8 type, version;
struct iv_ogm_packet_v15 *iv_ogm_packeth;
- const guint8 *orig_addr;
tvbuff_t *next_tvb;
static const int * flags[] = {
&hf_batadv_iv_ogm_flags_directlink,
@@ -1681,13 +1680,11 @@ static int dissect_batadv_iv_ogm_v15(tvbuff_t *tvb, int offset,
if (tree) {
proto_item *ti;
- orig_addr = tvb_get_ptr(tvb, offset + 8, 6);
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
tvb, offset,
IV_OGM_PACKET_V15_SIZE + iv_ogm_packeth->tvlv_len,
- "B.A.T.M.A.N. IV OGM, Orig: %s (%s)",
- get_ether_name(orig_addr),
- tvb_ether_to_str(tvb, offset + 8));
+ "B.A.T.M.A.N. IV OGM, Orig: %s",
+ tvb_address_with_resolution_to_str(wmem_packet_scope(), tvb, AT_ETHER, offset + 8));
batadv_iv_ogm_tree = proto_item_add_subtree(ti, ett_batadv_iv_ogm);
}
@@ -1771,8 +1768,8 @@ static void dissect_batadv_tt(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
/* Set tree info */
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, 6,
- "B.A.T.M.A.N. TT: %s (%s)",
- get_ether_name(tvb_get_ptr(tvb, 0, 6)), tvb_ether_to_str(tvb, 0));
+ "B.A.T.M.A.N. TT: %s",
+ tvb_address_with_resolution_to_str(wmem_packet_scope(), tvb, AT_ETHER, 0));
batadv_batman_tt_tree = proto_item_add_subtree(ti, ett_batadv_batman_tt);
proto_tree_add_item(batadv_batman_tt_tree, hf_batadv_batman_tt, tvb, 0, 6, ENC_NA);
@@ -2350,7 +2347,6 @@ static void dissect_batadv_icmp_v15(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree)
{
struct icmp_packet_v15 *icmp_packeth;
- const guint8 *dst_addr, *orig_addr;
proto_item *ti;
proto_tree *batadv_icmp_tree = NULL;
@@ -2371,15 +2367,11 @@ static void dissect_batadv_icmp_v15(tvbuff_t *tvb, packet_info *pinfo,
/* Set tree info */
if (tree) {
- dst_addr = tvb_get_ptr(tvb, 4, 6);
- orig_addr = tvb_get_ptr(tvb, 10, 6);
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
tvb, 0, ICMP_PACKET_V14_SIZE,
- "B.A.T.M.A.N. ICMP, Orig: %s (%s), Dst: %s (%s)",
- get_ether_name(orig_addr),
- tvb_ether_to_str(tvb, 10),
- get_ether_name(dst_addr),
- tvb_ether_to_str(tvb, 4));
+ "B.A.T.M.A.N. ICMP, Orig: %s, Dst: %s",
+ tvb_address_with_resolution_to_str(wmem_packet_scope(), tvb, AT_ETHER, 10),
+ tvb_address_with_resolution_to_str(wmem_packet_scope(), tvb, AT_ETHER, 4));
batadv_icmp_tree = proto_item_add_subtree(ti, ett_batadv_icmp);
}
@@ -2946,7 +2938,6 @@ static void dissect_batadv_unicast_frag_v15(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree)
{
struct unicast_frag_packet_v15 *unicast_frag_packeth;
- const guint8 *dest_addr;
gboolean save_fragmented;
fragment_head *frag_msg = NULL;
proto_tree *batadv_unicast_frag_tree = NULL;
@@ -2969,13 +2960,11 @@ static void dissect_batadv_unicast_frag_v15(tvbuff_t *tvb, packet_info *pinfo,
if (tree) {
proto_item *ti;
- dest_addr = tvb_get_ptr(tvb, 4, 6);
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
tvb, 0,
UNICAST_FRAG_PACKET_V15_SIZE,
- "B.A.T.M.A.N. Unicast Fragment, Dst: %s (%s)",
- get_ether_name(dest_addr),
- tvb_ether_to_str(tvb, 4));
+ "B.A.T.M.A.N. Unicast Fragment, Dst: %s",
+ tvb_address_with_resolution_to_str(wmem_packet_scope(), tvb, AT_ETHER, 4));
batadv_unicast_frag_tree = proto_item_add_subtree(ti,
ett_batadv_unicast_frag);
}
@@ -3428,8 +3417,8 @@ static void dissect_vis_entry_v6(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tr
proto_item *ti;
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, VIS_ENTRY_V6_SIZE,
- "VIS Entry: %s (%s)",
- get_ether_name(tvb_get_ptr(tvb, 0, 6)), tvb_ether_to_str(tvb, 0));
+ "VIS Entry: %s",
+ tvb_address_with_resolution_to_str(wmem_packet_scope(), tvb, AT_ETHER, 0));
batadv_vis_entry_tree = proto_item_add_subtree(ti, ett_batadv_vis_entry);
proto_tree_add_item(batadv_vis_entry_tree, hf_batadv_vis_entry_dst, tvb, 0, 6, ENC_NA);
@@ -3442,8 +3431,8 @@ static void dissect_vis_entry_v8(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tr
proto_item *ti;
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, VIS_ENTRY_V8_SIZE,
- "VIS Entry: %s (%s)",
- get_ether_name(tvb_get_ptr(tvb, 6, 6)), tvb_ether_to_str(tvb, 6));
+ "VIS Entry: %s",
+ tvb_address_with_resolution_to_str(wmem_packet_scope(), tvb, AT_ETHER, 6));
batadv_vis_entry_tree = proto_item_add_subtree(ti, ett_batadv_vis_entry);
proto_tree_add_item(batadv_vis_entry_tree, hf_batadv_vis_entry_src, tvb, 0, 6, ENC_NA);
@@ -3592,8 +3581,8 @@ static void dissect_tt_entry_v14(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tr
proto_item *ti;
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin, tvb, 0, TT_ENTRY_V14_SIZE,
- "TT Entry: %s (%s)",
- get_ether_name(tvb_get_ptr(tvb, 1, 6)), tvb_ether_to_str(tvb, 1));
+ "TT Entry: %s",
+ tvb_address_with_resolution_to_str(wmem_packet_scope(), tvb, AT_ETHER, 1));
batadv_tt_entry_tree = proto_item_add_subtree(ti, ett_batadv_tt_entry);
proto_tree_add_bitmask(batadv_tt_entry_tree, tvb, 0, hf_batadv_tt_entry_flags,
@@ -3855,8 +3844,6 @@ static void dissect_batadv_unicast_tvlv_v15(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree)
{
struct unicast_tvlv_packet_v15 *unicast_tvlv_packeth;
- const guint8 *dest_addr;
- const guint8 *src_addr;
tvbuff_t *next_tvb;
int offset = 0;
@@ -3872,17 +3859,13 @@ static void dissect_batadv_unicast_tvlv_v15(tvbuff_t *tvb, packet_info *pinfo,
if (tree) {
proto_item *ti;
- dest_addr = tvb_get_ptr(tvb, 4, 6);
- src_addr = tvb_get_ptr(tvb, 10, 6);
unicast_tvlv_packeth->tvlv_len = tvb_get_ntohs(tvb, 16);
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
tvb, 0,
UNICAST_TVLV_PACKET_V15_SIZE + unicast_tvlv_packeth->tvlv_len,
- "B.A.T.M.A.N. Unicast TVLV, Src: %s (%s) Dst: %s (%s)",
- get_ether_name(src_addr),
- tvb_ether_to_str(tvb, 10),
- get_ether_name(dest_addr),
- tvb_ether_to_str(tvb, 4));
+ "B.A.T.M.A.N. Unicast TVLV, Src: %s Dst: %s",
+ tvb_address_with_resolution_to_str(wmem_packet_scope(), tvb, AT_ETHER, 10),
+ tvb_address_with_resolution_to_str(wmem_packet_scope(), tvb, AT_ETHER, 4));
batadv_unicast_tvlv_tree = proto_item_add_subtree(ti, ett_batadv_unicast_tvlv);
}
@@ -4230,7 +4213,6 @@ static int dissect_batadv_tvlv_v15_tt_change(tvbuff_t *tvb,
proto_tree *tree, int offset)
{
proto_tree *change_tree = NULL;
- const guint8 *addr;
static const int * flags[] = {
&hf_batadv_tvlv_tt_change_flags_del,
&hf_batadv_tvlv_tt_change_flags_roam,
@@ -4244,17 +4226,14 @@ static int dissect_batadv_tvlv_v15_tt_change(tvbuff_t *tvb,
NULL
};
- addr = tvb_get_ptr(tvb, offset + 4, 6);
-
/* Set tree info */
if (tree) {
proto_item *ti;
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
tvb, offset, 12,
- "Entry, %s (%s)",
- get_ether_name(addr),
- tvb_ether_to_str(tvb, offset + 4));
+ "Entry, %s",
+ tvb_address_with_resolution_to_str(wmem_packet_scope(), tvb, AT_ETHER, offset + 4));
change_tree = proto_item_add_subtree(ti, ett_batadv_tvlv_tt_change);
}
diff --git a/epan/dissectors/packet-ieee8021ah.c b/epan/dissectors/packet-ieee8021ah.c
index 3f46760378..7a41e3088e 100644
--- a/epan/dissectors/packet-ieee8021ah.c
+++ b/epan/dissectors/packet-ieee8021ah.c
@@ -232,9 +232,6 @@ dissect_ieee8021ah_common(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *volatile ieee8021ah_tag_tree;
- /* for parsing out ethernet addrs */
- const guint8 *src_addr, *dst_addr;
-
tci = tvb_get_ntohl( tvb, 0 );
col_add_fstr(pinfo->cinfo, COL_INFO,
@@ -266,16 +263,12 @@ dissect_ieee8021ah_common(tvbuff_t *tvb, packet_info *pinfo,
proto_tree_add_item(tree, hf_ieee8021ah_c_daddr, tvb, 4, 6, ENC_NA);
proto_tree_add_item(tree, hf_ieee8021ah_c_saddr, tvb, 10, 6, ENC_NA);
- /* parse out IP addrs */
- dst_addr = tvb_get_ptr(tvb, 4, 6); /* safe to use this function? */
- src_addr = tvb_get_ptr(tvb, 10, 6);
-
/* add text to 802.1ad label */
if (parent) {
- proto_item_append_text(tree, ", I-SID: %d, C-Src: %s (%s), C-Dst: %s (%s)",
- tci & IEEE8021AH_ISIDMASK, get_ether_name(src_addr),
- tvb_ether_to_str(tvb, 10), get_ether_name(dst_addr),
- tvb_ether_to_str(tvb, 4));
+ proto_item_append_text(tree, ", I-SID: %d, C-Src: %s, C-Dst: %s",
+ tci & IEEE8021AH_ISIDMASK,
+ tvb_address_with_resolution_to_str(wmem_packet_scope(), tvb, AT_ETHER, 10),
+ tvb_address_with_resolution_to_str(wmem_packet_scope(), tvb, AT_ETHER, 4));
}
}
diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c
index ffef10eb05..83e1b5fa7e 100644
--- a/epan/dissectors/packet-ip.c
+++ b/epan/dissectors/packet-ip.c
@@ -2303,8 +2303,8 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
cur_rt = tvb_get_ipv4(tvb, offset + 16);
if (ip_summary_in_tree) {
- proto_item_append_text(ti, ", Via: %s (%s)", get_hostname(cur_rt),
- tvb_ip_to_str(tvb, offset + 16));
+ proto_item_append_text(ti, ", Via: %s",
+ tvb_address_with_resolution_to_str(wmem_packet_scope(), tvb, AT_IPv4, offset + 16));
}
proto_tree_add_ipv4(ip_tree, hf_ip_cur_rt, tvb, offset + 16, 4, cur_rt);
item = proto_tree_add_string(ip_tree, hf_ip_cur_rt_host, tvb,
diff --git a/epan/dissectors/packet-ospf.c b/epan/dissectors/packet-ospf.c
index 0863be69fb..e66a2940ad 100644
--- a/epan/dissectors/packet-ospf.c
+++ b/epan/dissectors/packet-ospf.c
@@ -2205,7 +2205,6 @@ static void dissect_ospf_lsa_grace_tlv (tvbuff_t *tvb, int offset,
and length fields and any padding */
guint32 grace_period;
guint8 restart_reason;
- guint32 restart_ip;
proto_tree *tlv_tree;
proto_item *tree_item;
proto_item *grace_tree_item;
@@ -2245,11 +2244,10 @@ static void dissect_ospf_lsa_grace_tlv (tvbuff_t *tvb, int offset,
restart_reason);
break;
case GRACE_TLV_IP:
- restart_ip = tvb_get_ipv4(tvb, offset + 4);
proto_tree_add_item(tlv_tree, hf_ospf_v2_grace_ip, tvb, offset + 4,
tlv_length, ENC_BIG_ENDIAN);
- proto_item_set_text(tree_item, "Restart IP: %s (%s)",
- get_hostname(restart_ip), tvb_ip_to_str(tvb, offset + 4));
+ proto_item_set_text(tree_item, "Restart IP: %s",
+ tvb_address_with_resolution_to_str(wmem_packet_scope(), tvb, AT_IPv4, offset + 4));
break;
default:
proto_item_set_text(tree_item, "Unknown grace-LSA TLV");
diff --git a/epan/dissectors/packet-radius.c b/epan/dissectors/packet-radius.c
index e29a44b615..2f02fa4a09 100644
--- a/epan/dissectors/packet-radius.c
+++ b/epan/dissectors/packet-radius.c
@@ -350,7 +350,7 @@ static const gchar *dissect_framed_ip_address(proto_tree* tree, tvbuff_t* tvb, p
guint32 ip_h;
const gchar *str;
- len = tvb_length(tvb);
+ len = tvb_reported_length(tvb);
if (len != 4)
return "[wrong length for IP address]";
@@ -367,9 +367,8 @@ static const gchar *dissect_framed_ip_address(proto_tree* tree, tvbuff_t* tvb, p
tvb, 0, len, ip, "%s", str);
} else {
str = tvb_ip_to_str(tvb, 0);
- proto_tree_add_ipv4_format_value(tree, hf_radius_framed_ip_address,
- tvb, 0, len, ip, "%s (%s)",
- get_hostname(ip), str);
+ proto_tree_add_item(tree, hf_radius_framed_ip_address,
+ tvb, 0, len, ENC_BIG_ENDIAN);
}
return str;
@@ -381,7 +380,7 @@ static const gchar *dissect_login_ip_host(proto_tree* tree, tvbuff_t* tvb, packe
guint32 ip_h;
const gchar *str;
- len = tvb_length(tvb);
+ len = tvb_reported_length(tvb);
if (len != 4)
return "[wrong length for IP address]";
@@ -398,9 +397,8 @@ static const gchar *dissect_login_ip_host(proto_tree* tree, tvbuff_t* tvb, packe
tvb, 0, len, ip, "%s", str);
} else {
str = tvb_ip_to_str(tvb, 0);
- proto_tree_add_ipv4_format_value(tree, hf_radius_login_ip_host,
- tvb, 0, len, ip, "%s (%s)",
- get_hostname(ip), str);
+ proto_tree_add_item(tree, hf_radius_login_ip_host,
+ tvb, 0, len, ENC_BIG_ENDIAN);
}
return str;
diff --git a/epan/dissectors/packet-vmlab.c b/epan/dissectors/packet-vmlab.c
index 823152f552..fe951a12c9 100644
--- a/epan/dissectors/packet-vmlab.c
+++ b/epan/dissectors/packet-vmlab.c
@@ -79,8 +79,6 @@ dissect_vmlab(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
guint32 offset=0;
- const guint8* src_addr;
- const guint8* dst_addr;
guint8 attributes;
guint8 portgroup;
ethertype_data_t ethertype_data;
@@ -117,17 +115,16 @@ dissect_vmlab(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree_add_item(vmlab_tree, hf_vmlab_eth_addr, tvb, offset, 6, ENC_NA);
offset += 6;
- dst_addr=tvb_get_ptr(tvb, offset, 6);
proto_tree_add_item(vmlab_tree, hf_vmlab_eth_dst, tvb, offset, 6, ENC_NA);
offset += 6;
/* Source MAC*/
- src_addr=tvb_get_ptr(tvb, offset, 6);
proto_tree_add_item(vmlab_tree, hf_vmlab_eth_src, tvb, offset, 6, ENC_NA);
offset += 6;
- proto_item_append_text(ti, ", Src: %s (%s), Dst: %s (%s)",
- get_ether_name(src_addr), tvb_ether_to_str(tvb, offset-6), get_ether_name(dst_addr), tvb_ether_to_str(tvb, offset-12));
+ proto_item_append_text(ti, ", Src: %s, Dst: %s",
+ tvb_address_with_resolution_to_str(wmem_packet_scope(), tvb, AT_ETHER, offset-6),
+ tvb_address_with_resolution_to_str(wmem_packet_scope(), tvb, AT_ETHER, offset-12));
/* Encapsulated Ethertype is also part of the block*/
encap_proto = tvb_get_ntohs(tvb, offset);