Use "ip_to_str()" and "ether_to_str()" to extract IP and MAC addresses
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 14 Oct 1998 22:37:02 +0000 (22:37 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 14 Oct 1998 22:37:02 +0000 (22:37 +0000)
from a packet and turn them into character strings in dotted-quad or
colonized-sextet form.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@57 f5534014-38df-0310-8fa8-9805f1628bb7

packet-dns.c
packet-nbns.c

index ad8e475617b54c8cf5280015992d569c217e9fb2..767b061648945143d2a9502da4b0d7af334a1170 100644 (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 */
index 90dbda7ee3db5b72c5145ef67544206f2e1b30a5..6492941ee307196e139aa87c13b5c92ad52b6c48 100644 (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;