Introduce, and start using, tvb_eth_to_str().

Export tvb_*_to_str() and put them in alphabetical order.

svn path=/trunk/; revision=35602
This commit is contained in:
Jeff Morriss 2011-01-21 02:48:55 +00:00
parent 03066d0820
commit 6e0fcb7ab5
15 changed files with 51 additions and 41 deletions

View File

@ -91,6 +91,12 @@ ether_to_str(const guint8 *ad)
return bytestring_to_str(ad, 6, ':');
}
gchar *
tvb_ether_to_str(tvbuff_t *tvb, const gint offset)
{
return bytestring_to_str(tvb_get_ptr(tvb, offset, 6), 6, ':');
}
/*
This function is very fast and this function is called a lot.
XXX update the ep_address_to_str stuff to use this function.

View File

@ -220,7 +220,7 @@ dissect_lan_destination(tvbuff_t *tvb, int offset, const char *type, proto_tree
case TAG_MAC_ADDRESS:
proto_tree_add_text(dest_tree, tvb, offset, 6, "MAC address: %s",
ether_to_str(tvb_get_ptr(tvb, offset, 6)));
tvb_ether_to_str(tvb, offset));
break;
case TAG_ROUTE_DESCRIPTOR:

View File

@ -501,10 +501,10 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
tvb_get_guint8(tvb, offset+20));
proto_tree_add_text(tlv_tree, tvb, offset+21, 6,
"Cluster Commander MAC: %s",
ether_to_str(tvb_get_ptr(tvb, offset+21, 6)));
tvb_ether_to_str(tvb, offset+21));
proto_tree_add_text(tlv_tree, tvb, offset+27, 6,
"Switch's MAC: %s",
ether_to_str(tvb_get_ptr(tvb, offset+27, 6)));
tvb_ether_to_str(tvb, offset+27));
proto_tree_add_text(tlv_tree, tvb, offset+33, 1,
"UNKNOWN: 0x%02X",
tvb_get_guint8(tvb, offset+33));
@ -893,7 +893,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
case TYPE_SPARE_POE:
if (tree) {
tlvi = proto_tree_add_text(cdp_tree, tvb, offset, length,
tlvi = proto_tree_add_text(cdp_tree, tvb, offset, length,
"Spare Pair PoE");
tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv);
@ -1176,8 +1176,8 @@ dissect_nrgyz_tlv(tvbuff_t *tvb, int offset, guint16 length, guint16 num,
}
static void
dissect_spare_poe_tlv(tvbuff_t *tvb, int offset, int length,
proto_tree *tree)
dissect_spare_poe_tlv(tvbuff_t *tvb, int offset, int length,
proto_tree *tree)
{
proto_item *ti;
proto_tree *tlv_tree;
@ -1188,7 +1188,7 @@ dissect_spare_poe_tlv(tvbuff_t *tvb, int offset, int length,
}
tlv_data = tvb_get_guint8(tvb, offset);
ti = proto_tree_add_text(tree, tvb, offset, length,
ti = proto_tree_add_text(tree, tvb, offset, length,
"Spare Pair PoE: 0x%02x", tlv_data);
tlv_tree = proto_item_add_subtree(ti, ett_cdp_spare_poe_tlv);

View File

@ -1266,7 +1266,7 @@ dissect_ipxsap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree_add_text(s_tree, tvb, cursor+50, 4, "Network: %s",
ipxnet_to_string(tvb_get_ptr(tvb, cursor+50, 4)));
proto_tree_add_text(s_tree, tvb, cursor+54, 6, "Node: %s",
ether_to_str(tvb_get_ptr(tvb, cursor+54, 6)));
tvb_ether_to_str(tvb, cursor+54));
server_port = tvb_get_ntohs(tvb, cursor+60);
proto_tree_add_text(s_tree, tvb, cursor+60, 2, "Socket: %s (0x%04x)",
socket_text(server_port),

View File

@ -260,7 +260,7 @@ dissect_ismp_edp(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *ismp
col_add_fstr(pinfo->cinfo, COL_INFO, "MIP %s, MMAC %s, ifIdx %d",
tvb_ip_to_str(tvb, offset+2),
ether_to_str(tvb_get_ptr(tvb, offset+6, 6)),
tvb_ether_to_str(tvb, offset+6),
tvb_get_ntohl(tvb, offset+12));
proto_tree_add_item(edp_tree, hf_ismp_edp_version, tvb, offset, 2, FALSE);

View File

@ -125,8 +125,8 @@ dissect_mactelnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
type = tvb_get_guint8(tvb, 1);
col_add_fstr(pinfo->cinfo, COL_INFO, "%s > %s Type: %s",
ether_to_str(tvb_get_ptr(tvb, 2, 6)),
ether_to_str(tvb_get_ptr(tvb, 8, 6)),
tvb_ether_to_str(tvb, 2),
tvb_ether_to_str(tvb, 8),
val_to_str(type, packettypenames, "Unknown Type:0x%02x"));
if (tree) {

View File

@ -775,7 +775,7 @@ dissect_nbns_answer(tvbuff_t *tvb, int offset, int nbns_data_offset,
}
proto_tree_add_text(rr_tree, tvb, cur_offset, 6,
"Unit ID: %s",
ether_to_str(tvb_get_ptr(tvb, cur_offset, 6)));
tvb_ether_to_str(tvb, cur_offset));
cur_offset += 6;
data_len -= 6;

View File

@ -686,7 +686,7 @@ dissect_netb_datagram( tvbuff_t *tvb, int offset, proto_tree *tree)
if (tvb_memeql(tvb, offset + NB_SENDER_NAME, zeroes, 10) == 0) {
proto_tree_add_text( tree, tvb, offset + NB_SENDER_NAME + 10, 6,
"Sender's MAC Address: %s",
ether_to_str( tvb_get_ptr( tvb,offset + NB_SENDER_NAME + 10, 6)));
tvb_ether_to_str(tvb, offset + NB_SENDER_NAME + 10));
} else {
netbios_add_name("Sender's Name", tvb, offset + NB_SENDER_NAME,
tree);
@ -705,7 +705,7 @@ dissect_netb_datagram_bcast( tvbuff_t *tvb, int offset, proto_tree *tree)
if (tvb_memeql(tvb, offset + NB_SENDER_NAME, zeroes, 10) == 0) {
proto_tree_add_text( tree, tvb, offset + NB_SENDER_NAME + 10, 6,
"Sender's Node Address: %s",
ether_to_str( tvb_get_ptr( tvb,offset + NB_SENDER_NAME + 10, 6)));
tvb_ether_to_str(tvb, offset + NB_SENDER_NAME + 10));
} else {
netbios_add_name("Sender's Name", tvb, offset + NB_SENDER_NAME,
tree);

View File

@ -307,7 +307,7 @@ dissect_neighbor_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
if (tree) {
proto_tree_add_text(tree, tvb, offset, 6,
"Neighbor: %s",
ether_to_str(tvb_get_ptr(tvb, offset, 6)));
tvb_ether_to_str(tvb, offset));
}
offset += 6;
length -= 6;
@ -441,11 +441,11 @@ nlsp_dissect_nlsp_hello(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if (tree) {
proto_tree_add_text(tree, tvb, offset, 6,
"Sending Router System ID: %s",
ether_to_str(tvb_get_ptr(tvb, offset, 6)));
tvb_ether_to_str(tvb, offset));
}
if (check_col(pinfo->cinfo, COL_INFO)) {
col_append_fstr(pinfo->cinfo, COL_INFO, ", System ID: %s",
ether_to_str(tvb_get_ptr(tvb, offset, 6)));
tvb_ether_to_str(tvb, offset));
}
offset += 6;
@ -481,7 +481,7 @@ nlsp_dissect_nlsp_hello(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if (tree) {
proto_tree_add_text(tree, tvb, offset, 6,
"Designated Router System ID: %s",
ether_to_str(tvb_get_ptr(tvb, offset, 6)));
tvb_ether_to_str(tvb, offset));
proto_tree_add_text(tree, tvb, offset+6, 1,
"Designated Router Pseudonode ID: %u",
tvb_get_guint8(tvb, offset+6));
@ -547,7 +547,7 @@ dissect_lsp_mgt_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
if (tree) {
proto_tree_add_text(tree, tvb, offset, 6,
"Node number: %s",
ether_to_str(tvb_get_ptr(tvb, offset, 6)));
tvb_ether_to_str(tvb, offset));
}
offset += 6;
length -= 6;
@ -696,7 +696,7 @@ dissect_lsp_link_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
if (tree) {
proto_tree_add_text(tree, tvb, offset, 6,
"Router System ID: %s",
ether_to_str(tvb_get_ptr(tvb, offset, 6)));
tvb_ether_to_str(tvb, offset));
proto_tree_add_text(tree, tvb, offset+6, 1,
"Router Pseudonode ID: %u",
tvb_get_guint8(tvb, offset+6));
@ -811,7 +811,7 @@ dissect_lsp_svcs_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
if (tree) {
proto_tree_add_text(tree, tvb, offset, 6,
"Node number: %s",
ether_to_str(tvb_get_ptr(tvb, offset, 6)));
tvb_ether_to_str(tvb, offset));
}
offset += 6;
length -= 6;
@ -1013,12 +1013,12 @@ nlsp_dissect_nlsp_lsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if (check_col(pinfo->cinfo, COL_INFO)) {
col_append_fstr(pinfo->cinfo, COL_INFO, ", LSP ID: %s",
ether_to_str(tvb_get_ptr(tvb, offset, 6)));
tvb_ether_to_str(tvb, offset));
}
if (tree) {
proto_tree_add_text(tree, tvb, offset, 6,
"LSP ID system ID: %s",
ether_to_str(tvb_get_ptr(tvb, offset, 6)));
tvb_ether_to_str(tvb, offset));
}
offset += 6;
/* XXX - append the pseudonode ID */
@ -1117,7 +1117,7 @@ dissect_csnp_lsp_entries(tvbuff_t *tvb, proto_tree *tree, int offset,
ti = proto_tree_add_text(tree, tvb, offset, 16,
"LSP-ID: %s, Sequence: 0x%08x, Lifetime: %5us, Checksum: 0x%04x",
ether_to_str(tvb_get_ptr(tvb, offset+2, 6)), /* XXX - rest of system ID */
tvb_ether_to_str(tvb, offset+2), /* XXX - rest of system ID */
tvb_get_ntohl(tvb, offset+10),
tvb_get_ntohs(tvb, offset),
tvb_get_ntohs(tvb, offset+14));
@ -1126,7 +1126,7 @@ dissect_csnp_lsp_entries(tvbuff_t *tvb, proto_tree *tree, int offset,
proto_tree_add_text(subtree, tvb, offset+2, 6,
"LSP ID source ID: %s",
ether_to_str(tvb_get_ptr(tvb, offset+2, 6)));
tvb_ether_to_str(tvb, offset+2));
proto_tree_add_text(subtree, tvb, offset+8, 1,
"LSP ID pseudonode ID: %u",
tvb_get_guint8(tvb, offset+8));
@ -1166,7 +1166,7 @@ dissect_psnp_lsp_entries(tvbuff_t *tvb, proto_tree *tree, int offset,
ti = proto_tree_add_text(tree, tvb, offset, 16,
"LSP-ID: %s, Sequence: 0x%08x, Lifetime: %5us, Checksum: 0x%04x",
ether_to_str(tvb_get_ptr(tvb, offset+2, 6)), /* XXX - rest of system ID */
tvb_ether_to_str(tvb, offset+2), /* XXX - rest of system ID */
tvb_get_ntohl(tvb, offset+10),
tvb_get_ntohs(tvb, offset),
tvb_get_ntohs(tvb, offset+14));
@ -1175,7 +1175,7 @@ dissect_psnp_lsp_entries(tvbuff_t *tvb, proto_tree *tree, int offset,
proto_tree_add_text(subtree, tvb, offset+2, 6,
"LSP ID source ID: %s",
ether_to_str(tvb_get_ptr(tvb, offset+2, 6)));
tvb_ether_to_str(tvb, offset+2));
proto_tree_add_text(subtree, tvb, offset+8, 1,
"LSP ID pseudonode ID: %u",
tvb_get_guint8(tvb, offset+8));
@ -1248,12 +1248,12 @@ nlsp_dissect_nlsp_csnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if (check_col(pinfo->cinfo, COL_INFO)) {
col_append_fstr(pinfo->cinfo, COL_INFO, ", Source ID: %s",
ether_to_str(tvb_get_ptr(tvb, offset, 6)));
tvb_ether_to_str(tvb, offset));
}
if (tree) {
proto_tree_add_text(tree, tvb, offset, 6,
"Source ID system ID: %s",
ether_to_str(tvb_get_ptr(tvb, offset, 6)));
tvb_ether_to_str(tvb, offset));
}
offset += 6;
/* XXX - add the pseudonode ID */
@ -1266,12 +1266,12 @@ nlsp_dissect_nlsp_csnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if (check_col(pinfo->cinfo, COL_INFO)) {
col_append_fstr(pinfo->cinfo, COL_INFO, ", Start LSP ID: %s",
ether_to_str(tvb_get_ptr(tvb, offset, 6)));
tvb_ether_to_str(tvb, offset));
}
if (tree) {
proto_tree_add_text(tree, tvb, offset, 6,
"Start LSP ID source ID: %s",
ether_to_str(tvb_get_ptr(tvb, offset, 6)));
tvb_ether_to_str(tvb, offset));
}
offset += 6;
/* XXX - append the pseudonode ID */
@ -1290,12 +1290,12 @@ nlsp_dissect_nlsp_csnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if (check_col(pinfo->cinfo, COL_INFO)) {
col_append_fstr(pinfo->cinfo, COL_INFO, ", End LSP ID: %s",
ether_to_str(tvb_get_ptr(tvb, offset, 6)));
tvb_ether_to_str(tvb, offset));
}
if (tree) {
proto_tree_add_text(tree, tvb, offset, 6,
"End LSP ID source ID: %s",
ether_to_str(tvb_get_ptr(tvb, offset, 6)));
tvb_ether_to_str(tvb, offset));
}
offset += 6;
/* XXX - append the pseudonode ID */
@ -1369,12 +1369,12 @@ nlsp_dissect_nlsp_psnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if (check_col(pinfo->cinfo, COL_INFO)) {
col_append_fstr(pinfo->cinfo, COL_INFO, ", Source ID: %s",
ether_to_str(tvb_get_ptr(tvb, offset, 6)));
tvb_ether_to_str(tvb, offset));
}
if (tree) {
proto_tree_add_text(tree, tvb, offset, 6,
"Source ID system ID: %s",
ether_to_str(tvb_get_ptr(tvb, offset, 6)));
tvb_ether_to_str(tvb, offset));
}
offset += 6;
/* XXX - add the pseudonode ID */

View File

@ -2121,7 +2121,7 @@ dissect_lcp_multilink_ep_disc_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
length, plurality(length, "", "s"));
} else {
proto_tree_add_text(field_tree, tvb, offset, length,
"Address: %s", ether_to_str(tvb_get_ptr(tvb, offset, 6)));
"Address: %s", tvb_ether_to_str(tvb, offset));
}
break;

View File

@ -724,7 +724,7 @@ void radius_ether(radius_attr_info_t* a, proto_tree* tree, packet_info *pinfo _U
}
proto_tree_add_item(tree, a->hf, tvb, offset, len, FALSE);
proto_item_append_text(avp_item, "%s", ether_to_str(tvb_get_ptr(tvb, offset, len)));
proto_item_append_text(avp_item, "%s", tvb_ether_to_str(tvb, offset));
}
void radius_ifid(radius_attr_info_t* a, proto_tree* tree, packet_info *pinfo _U_, tvbuff_t* tvb, int offset, int len, proto_item* avp_item) {

View File

@ -181,7 +181,7 @@ sv_text(tvbuff_t *tvb, int svoff, proto_tree *tree)
case 0x0A: /* Address of last neighbor notification */
proto_tree_add_text(tree, tvb, svoff+1, sv_length-1,
"Address of Last Neighbor Notification: %s",
ether_to_str(tvb_get_ptr(tvb, svoff+2, 6)));
tvb_ether_to_str(tvb, svoff+2));
break;
case 0x0B: /* Physical Location */

View File

@ -1478,7 +1478,7 @@ rtp_show_gateway_info(proto_tree *tree, tvbuff_t *tvb, int offset,
proto_tree_add_text(tree, tvb, offset, link_addr_length,
"Preferred Gateway Data Link Address: %s",
link_addr_length == 6 ?
ether_to_str(tvb_get_ptr(tvb, offset, link_addr_length)) :
tvb_ether_to_str(tvb, offset) :
tvb_bytes_to_str(tvb, offset, link_addr_length));
offset += link_addr_length;
}

View File

@ -614,10 +614,8 @@ InfoRequestNakReason_vals DATA
init_dissection
init_progfile_dir
ip6_to_str
tvb_ip6_to_str
in_cksum
ip_to_str
tvb_ip_to_str
ipprotostr
ipv4_get_net_order_addr
is_big_endian
@ -1033,7 +1031,10 @@ tvb_bytes_to_str
tvb_bytes_to_str_punct
tvb_ensure_bytes_exist
tvb_ensure_length_remaining
tvb_eth_to_str
tvb_fake_unicode
tvb_fc_to_str
tvb_fcwwm_to_str
tvb_find_guint8
tvb_find_line_end
tvb_find_line_end_unquoted
@ -1077,6 +1078,8 @@ tvb_get_ntohs
tvb_get_ptr
tvb_get_string
tvb_get_stringz
tvb_ip6_to_str
tvb_ip_to_str
tvb_length
tvb_length_remaining
tvb_memcpy

View File

@ -49,6 +49,7 @@ extern gchar* se_address_to_str(const address *);
extern void address_to_str_buf(const address *addr, gchar *buf, int buf_len);
extern gchar* bytestring_to_str(const guint8 *, const guint32, const char);
extern gchar* ether_to_str(const guint8 *);
extern gchar* tvb_ether_to_str(tvbuff_t *tvb, const gint offset);
extern const gchar* ip_to_str(const guint8 *);
extern const gchar* tvb_ip_to_str(tvbuff_t *tvb, const gint offset);
extern void ip_to_str_buf(const guint8 *ad, gchar *buf, const int buf_len);