From: Frédéric Perrin Date: Thu, 2 Apr 2015 15:31:54 +0000 (+0100) Subject: Use ether_ntoa (would be better to use struct ether_addr) X-Git-Url: http://gitweb.fperrin.net/?p=iftop.git;a=commitdiff_plain;h=b6b95194149a60a20b3b2ccac1412791a1dc1fc2 Use ether_ntoa (would be better to use struct ether_addr) --- diff --git a/ether.h b/ether.h index cc0b3f2..ca8c1b9 100644 --- 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; diff --git a/iftop-dump.c b/iftop-dump.c index 070f5bb..7e438d7 100644 --- a/iftop-dump.c +++ b/iftop-dump.c @@ -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 562a45b..59857a5 100644 --- 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);