Use "ip_to_str()" and "ether_to_str()" to extract IP and MAC addresses

from a packet and turn them into character strings in dotted-quad or
colonized-sextet form.

svn path=/trunk/; revision=57
This commit is contained in:
Guy Harris 1998-10-14 22:37:02 +00:00
parent ca377bf6cd
commit 02fdc292b1
2 changed files with 10 additions and 11 deletions

View File

@ -1,7 +1,7 @@
/* packet-dns.c
* Routines for DNS packet disassembly
*
* $Id: packet-dns.c,v 1.5 1998/10/14 19:34:58 guy Exp $
* $Id: packet-dns.c,v 1.6 1998/10/14 22:37:01 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -351,14 +351,14 @@ dissect_dns_answer(const u_char *dns_data_ptr, const u_char *pd, int offset,
switch (type) {
case T_A: /* "A" record */
trr = add_item_to_tree(dns_tree, offset, (dptr - data_start) + data_len,
"%s: type %s, class %s, addr %d.%d.%d.%d",
"%s: type %s, class %s, addr %s",
name, type_name, class_name,
*dptr, *(dptr+1), *(dptr+2), *(dptr+3));
ip_to_str((guint8 *)dptr));
rr_tree = add_rr_to_tree(trr, ETT_DNS_RR, offset, name, name_len, type_name,
class_name, ttl, data_len);
offset += (dptr - data_start);
add_item_to_tree(rr_tree, offset, 4, "Addr: %d.%d.%d.%d",
*dptr, *(dptr+1), *(dptr+2), *(dptr+3));
add_item_to_tree(rr_tree, offset, 4, "Addr: %s",
ip_to_str((guint8 *)dptr));
break;
case T_NS: /* "NS" record */

View File

@ -3,7 +3,7 @@
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
* Much stuff added by Guy Harris <guy@netapp.com>
*
* $Id: packet-nbns.c,v 1.2 1998/10/14 19:34:59 guy Exp $
* $Id: packet-nbns.c,v 1.3 1998/10/14 22:37:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -329,8 +329,8 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
break;
}
add_item_to_tree(rr_tree, offset, 4,
"Addr: %d.%d.%d.%d",
*dptr, *(dptr+1), *(dptr+2), *(dptr+3));
"Addr: %s",
ip_to_str((guint8 *)dptr));
dptr += 4;
offset += 4;
data_len -= 4;
@ -397,9 +397,8 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
break;
}
add_item_to_tree(rr_tree, offset, 6,
"Unit ID: %02x:%02x:%02x:%02x:%02x:%02x",
*dptr, *(dptr + 1), *(dptr + 2),
*(dptr + 3), *(dptr + 4), *(dptr + 5));
"Unit ID: %s",
ether_to_str((guint8 *)dptr));
dptr += 6;
offset += 6;
data_len -= 6;