diff options
author | Jeff Morriss <jeff.morriss@ulticom.com> | 2011-02-11 03:33:11 +0000 |
---|---|---|
committer | Jeff Morriss <jeff.morriss@ulticom.com> | 2011-02-11 03:33:11 +0000 |
commit | be81bc949a8d0e111b4d8e176963a234b38bf223 (patch) | |
tree | 17f4b141df07d882fa98dcee57fa873bb259ed5b /epan | |
parent | 0f59bc7c4521cc6139dfe44d9775d06d99b8a583 (diff) |
Rename arphrdaddr_to_str() to tvb_arphrdaddr_to_str() and make it take a pointer a TVB
and an offset instead of (generally) a pointer into a TVB.
svn path=/trunk/; revision=35913
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-arp.c | 20 | ||||
-rw-r--r-- | epan/dissectors/packet-arp.h | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-bootp.c | 24 | ||||
-rw-r--r-- | epan/dissectors/packet-dhcp-failover.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-dhcpv6.c | 12 |
5 files changed, 24 insertions, 38 deletions
diff --git a/epan/dissectors/packet-arp.c b/epan/dissectors/packet-arp.c index a3d93d4e79..13b9b4bab7 100644 --- a/epan/dissectors/packet-arp.c +++ b/epan/dissectors/packet-arp.c @@ -188,16 +188,16 @@ static const value_string atmop_vals[] = { ((ar_pro) == ETHERTYPE_IP && (ar_pln) == 4) const gchar * -arphrdaddr_to_str(const guint8 *ad, int ad_len, guint16 type) +tvb_arphrdaddr_to_str(tvbuff_t *tvb, gint offset, int ad_len, guint16 type) { if (ad_len == 0) return "<No address>"; if (ARP_HW_IS_ETHER(type, ad_len)) { /* Ethernet address (or IEEE 802.x address, which is the same type of address). */ - return ether_to_str(ad); + return tvb_ether_to_str(tvb, offset); } - return bytes_to_str(ad, ad_len); + return tvb_bytes_to_str(tvb, offset, ad_len); } static const gchar * @@ -873,7 +873,7 @@ dissect_arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item *ti, *item; const gchar *op_str; int sha_offset, spa_offset, tha_offset, tpa_offset; - const guint8 *sha_val, *spa_val, *tha_val, *tpa_val; + const guint8 *spa_val, *tpa_val; gboolean is_gratuitous; gboolean duplicate_detected = FALSE; guint32 duplicate_ip = 0; @@ -997,9 +997,7 @@ dissect_arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) return; } - sha_val = tvb_get_ptr(tvb, sha_offset, ar_hln); spa_val = tvb_get_ptr(tvb, spa_offset, ar_pln); - tha_val = tvb_get_ptr(tvb, tha_offset, ar_hln); tpa_val = tvb_get_ptr(tvb, tpa_offset, ar_pln); /* ARP requests/replies with the same sender and target protocol @@ -1032,22 +1030,22 @@ dissect_arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) else col_add_fstr(pinfo->cinfo, COL_INFO, "%s is at %s", arpproaddr_to_str(spa_val, ar_pln, ar_pro), - arphrdaddr_to_str(sha_val, ar_hln, ar_hrd)); + tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd)); break; case ARPOP_RREQUEST: case ARPOP_IREQUEST: col_add_fstr(pinfo->cinfo, COL_INFO, "Who is %s? Tell %s", - arphrdaddr_to_str(tha_val, ar_hln, ar_hrd), - arphrdaddr_to_str(sha_val, ar_hln, ar_hrd)); + tvb_arphrdaddr_to_str(tvb, tha_offset, ar_hln, ar_hrd), + tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd)); break; case ARPOP_RREPLY: col_add_fstr(pinfo->cinfo, COL_INFO, "%s is at %s", - arphrdaddr_to_str(tha_val, ar_hln, ar_hrd), + tvb_arphrdaddr_to_str(tvb, tha_offset, ar_hln, ar_hrd), arpproaddr_to_str(tpa_val, ar_pln, ar_pro)); break; case ARPOP_IREPLY: col_add_fstr(pinfo->cinfo, COL_INFO, "%s is at %s", - arphrdaddr_to_str(sha_val, ar_hln, ar_hrd), + tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd), arpproaddr_to_str(spa_val, ar_pln, ar_pro)); break; default: diff --git a/epan/dissectors/packet-arp.h b/epan/dissectors/packet-arp.h index 793d2a44cd..230cde7742 100644 --- a/epan/dissectors/packet-arp.h +++ b/epan/dissectors/packet-arp.h @@ -26,7 +26,7 @@ #ifndef __PACKET_ARP_H__ #define __PACKET_ARP_H__ -const gchar *arphrdaddr_to_str(const guint8 *ad, int ad_len, guint16 type); +const gchar *tvb_arphrdaddr_to_str(tvbuff_t *tvb, gint offset, int ad_len, guint16 type); const gchar *arphrdtype_to_str(guint16 hwtype, const char *fmt); void dissect_atm_nsap(tvbuff_t *tvb, int offset, int len, proto_tree *tree); diff --git a/epan/dissectors/packet-bootp.c b/epan/dissectors/packet-bootp.c index a3d79c6188..d57ce612a6 100644 --- a/epan/dissectors/packet-bootp.c +++ b/epan/dissectors/packet-bootp.c @@ -1212,8 +1212,7 @@ bootp_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, int voff, else proto_tree_add_text(v_tree, tvb, optoff+1, 6, "Client hardware address: %s", - arphrdaddr_to_str(tvb_get_ptr(tvb, optoff+1, 6), - 6, byte)); + tvb_arphrdaddr_to_str(tvb, optoff+1, 6, byte)); } else if (optlen == 17 && byte == 0) { /* Identifier is a UUID */ proto_tree_add_item(v_tree, hf_bootp_client_identifier_uuid, @@ -1232,8 +1231,7 @@ bootp_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, int voff, an opaque 32-bit quantity */ proto_tree_add_text(v_tree, tvb, optoff+1, 4, "IAID: %s", - arphrdaddr_to_str(tvb_get_ptr(tvb, optoff+1, 4), - 4, byte)); + tvb_arphrdaddr_to_str(tvb, optoff+1, 4, byte)); optoff = optoff + 5; duidtype = tvb_get_ntohs(tvb, optoff); proto_tree_add_text(v_tree, tvb, optoff, 2, @@ -1258,7 +1256,7 @@ bootp_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, int voff, if (optlen > 8) { proto_tree_add_text(v_tree, tvb, optoff + 8, optlen - 13, "Link-layer address: %s", - arphrdaddr_to_str(tvb_get_ptr(tvb, optoff+8, optlen-13), optlen-13, hwtype)); + tvb_arphrdaddr_to_str(tvb, optoff+8, optlen-13, hwtype)); } break; case DUID_EN: @@ -1292,7 +1290,7 @@ bootp_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, int voff, if (optlen > 4) { proto_tree_add_text(v_tree, tvb, optoff + 4, optlen - 9, "Link-layer address: %s", - arphrdaddr_to_str(tvb_get_ptr(tvb, optoff+4, optlen-9), optlen-9, hwtype)); + tvb_arphrdaddr_to_str(tvb, optoff+4, optlen-9, hwtype)); } break; } @@ -1328,8 +1326,7 @@ bootp_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, int voff, else proto_tree_add_text(v_tree, tvb, optoff+1, 6, "Client hardware address: %s", - arphrdaddr_to_str(tvb_get_ptr(tvb, optoff+1, 6), - 6, byte)); + tvb_arphrdaddr_to_str(tvb, optoff+1, 6, byte)); } else if (optlen == 17 && byte == 0) { /* Identifier is a UUID */ proto_tree_add_item(v_tree, hf_bootp_client_identifier_uuid, @@ -4472,7 +4469,6 @@ dissect_bootp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item *fi, *hidden_item; guint8 op; guint8 htype, hlen; - const guint8 *haddr; int voff, eoff, tmpvoff; /* vendor offset, end offset */ guint32 ip_addr; gboolean at_end; @@ -4498,16 +4494,14 @@ dissect_bootp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) && hlen == 6) { if (check_col(pinfo->cinfo, COL_INFO)) { col_add_fstr(pinfo->cinfo, COL_INFO, "Boot Request from %s (%s)", - arphrdaddr_to_str(tvb_get_ptr(tvb, 28, hlen), - hlen, htype), + tvb_arphrdaddr_to_str(tvb, 28, hlen, htype), get_ether_name(tvb_get_ptr(tvb, 28, hlen))); } } else { if (check_col(pinfo->cinfo, COL_INFO)) { col_add_fstr(pinfo->cinfo, COL_INFO, "Boot Request from %s", - arphrdaddr_to_str(tvb_get_ptr(tvb, 28, hlen), - hlen, htype)); + tvb_arphrdaddr_to_str(tvb, 28, hlen, htype)); } } break; @@ -4621,7 +4615,6 @@ dissect_bootp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) 24, 4, FALSE); if (hlen > 0 && hlen <= 16) { - haddr = tvb_get_ptr(tvb, 28, hlen); if ((htype == ARPHRD_ETHER || htype == ARPHRD_IEEE802) && hlen == 6) proto_tree_add_item(bp_tree, hf_bootp_hw_ether_addr, tvb, 28, 6, FALSE); @@ -4629,8 +4622,7 @@ dissect_bootp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* The chaddr element is 16 bytes in length, although only the first hlen bytes are used */ proto_tree_add_bytes_format_value(bp_tree, hf_bootp_hw_addr, tvb, 28, 16, - haddr, - "%s", arphrdaddr_to_str(haddr, hlen, htype)); + NULL, "%s", tvb_arphrdaddr_to_str(tvb, 28, hlen, htype)); if ((16 - hlen) > 0) proto_tree_add_item(bp_tree, hf_bootp_hw_addr_padding, tvb, 28+hlen, 16-hlen, FALSE); } else { diff --git a/epan/dissectors/packet-dhcp-failover.c b/epan/dissectors/packet-dhcp-failover.c index 6f155f6ef2..c5ff494f1d 100644 --- a/epan/dissectors/packet-dhcp-failover.c +++ b/epan/dissectors/packet-dhcp-failover.c @@ -360,7 +360,6 @@ dissect_dhcpfo_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint16 opcode; guint16 option_length; guint8 htype, reject_reason, message_digest_type; - const guint8 *chaddr; guint8 binding_status; const gchar *assigned_ip_address_str, *sending_server_ip_address_str; guint32 addresses_transferred; @@ -587,9 +586,8 @@ dissect_dhcpfo_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) break; } htype = tvb_get_guint8(tvb, offset); - chaddr = tvb_get_ptr(tvb, offset+1, option_length-1); htype_str = arphrdtype_to_str(htype, "Unknown (0x%02x)"); - chaddr_str = arphrdaddr_to_str(chaddr, option_length-1, + chaddr_str = tvb_arphrdaddr_to_str(tvb, offset+1, option_length-1, htype); proto_item_append_text(oi, ", %s, %s", htype_str, diff --git a/epan/dissectors/packet-dhcpv6.c b/epan/dissectors/packet-dhcpv6.c index 5cfff0aa68..5bf95704cd 100644 --- a/epan/dissectors/packet-dhcpv6.c +++ b/epan/dissectors/packet-dhcpv6.c @@ -1143,7 +1143,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, if (optlen > 8) { proto_tree_add_text(subtree, tvb, off + 8, optlen - 8, "Link-layer address: %s", - arphrdaddr_to_str(tvb_get_ptr(tvb, off+8, optlen-8), optlen-8, hwtype)); + tvb_arphrdaddr_to_str(tvb, off+8, optlen-8, hwtype)); } break; case DUID_EN: @@ -1174,7 +1174,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, if (optlen > 4) { proto_tree_add_text(subtree, tvb, off + 4, optlen - 4, "Link-layer address: %s", - arphrdaddr_to_str(tvb_get_ptr(tvb, off+4, optlen-4), optlen-4, hwtype)); + tvb_arphrdaddr_to_str(tvb, off+4, optlen-4, hwtype)); } break; } @@ -1192,8 +1192,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, } proto_tree_add_text(subtree, tvb, off, 4, "IAID: %s", - arphrdaddr_to_str(tvb_get_ptr(tvb, off, 4), - 4, opttype)); + tvb_arphrdaddr_to_str(tvb, off, 4, opttype)); if (tvb_get_ntohl(tvb, off+4) == DHCPV6_LEASEDURATION_INFINITY) { proto_tree_add_text(subtree, tvb, off+4, 4, "T1: infinity"); @@ -1228,8 +1227,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, } proto_tree_add_text(subtree, tvb, off, 4, "IAID: %s", - arphrdaddr_to_str(tvb_get_ptr(tvb, off, 4), - 4, opttype)); + tvb_arphrdaddr_to_str(tvb, off, 4, opttype)); temp_optlen = 4; while ((optlen - temp_optlen) > 0) { temp_optlen += dhcpv6_option(tvb, pinfo, subtree, downstream, @@ -1447,7 +1445,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, if (temp_optlen >= 6) proto_tree_add_text(subtree, tvb, off, temp_optlen, "Link-layer address: %s", - arphrdaddr_to_str(tvb_get_ptr(tvb, off, 6), 6, ARPHRD_ETHER)); + tvb_arphrdaddr_to_str(tvb, off, 6, ARPHRD_ETHER)); } } break; |