]> gitweb.fperrin.net Git - iftop.git/commitdiff
Use ether_ntoa (would be better to use struct ether_addr)
authorFrédéric Perrin <fperrin@brocade.com>
Thu, 2 Apr 2015 15:31:54 +0000 (16:31 +0100)
committerFrédéric Perrin <fperrin@brocasde.com>
Thu, 23 Apr 2015 09:49:05 +0000 (09:49 +0000)
ether.h
iftop-dump.c
iftop.c

diff --git a/ether.h b/ether.h
index cc0b3f2db0f3ef367d95a89be7614a179b3882b3..ca8c1b98b0ea3487f821a167bd0d8ffc6d952e11 100644 (file)
--- a/ether.h
+++ b/ether.h
@@ -14,6 +14,7 @@ struct        ether_header {
        u_int16_t       ether_type;
 } __attribute__((packed));
 
+char *ether_ntoa(const char *addr);
 
 struct vlan_8021q_header {
        u_int16_t       priority_cfi_vid;
index 070f5bb866edb461936bad5134d1a970e5e7b391..7e438d7f33ef54aa0fa8577d1022a69e3df7a198 100644 (file)
@@ -419,10 +419,7 @@ void packet_init() {
     }
 
     if(have_hw_addr) {
-      fprintf(stderr, "MAC address is:");
-      for (i = 0; i < 6; ++i)
-       fprintf(stderr, "%c%02x", i ? ':' : ' ', (unsigned int)if_hw_addr[i]);
-      fprintf(stderr, "\n");
+      fprintf(stderr, "MAC address is: %s\n", ether_ntoa(if_hw_addr));
     }
     
     //    exit(0);
diff --git a/iftop.c b/iftop.c
index 562a45bd33b719b9a5b77e85fa3001748c2c558a..59857a5dde8c7921ac2814421f046b6abc23d0ae 100644 (file)
--- a/iftop.c
+++ b/iftop.c
@@ -706,7 +706,6 @@ char *set_filter_code(const char *filter) {
 void packet_init() {
     char errbuf[PCAP_ERRBUF_SIZE];
     char *m;
-    int i;
     int dlt;
     int result;
 
@@ -737,10 +736,7 @@ void packet_init() {
     }
 
     if(have_hw_addr) {
-      fprintf(stderr, "MAC address is:");
-      for (i = 0; i < 6; ++i)
-       fprintf(stderr, "%c%02x", i ? ':' : ' ', (unsigned int)if_hw_addr[i]);
-      fprintf(stderr, "\n");
+      fprintf(stderr, "MAC address is: %s\n", ether_ntoa(if_hw_addr));
     }
     
     //    exit(0);