[Iftop-users] [PATCH] Display MAC Address in better format

Xiaoguang Sun sun.xiaoguang at yoyosys.com
Mon, 3 Mar 2014 12:58:41 +0800


--Apple-Mail=_C16D1A6C-1636-432C-9CE8-AD9FC2B05631
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=us-ascii

Before this patch:
root@57:~/iftop-1.0pre4# ./iftop 
interface: eth0
IP address is: 192.168.1.57
MAC address is: ffffffbc:ffffffee:7b:ffffffdb:0b:ffffffd4

With this patch
root@57:~/iftop-1.0pre4# ./iftop 
interface: eth0
IP address is: 192.168.1.57
MAC address is: bc:ee:7b:db:0b:d4


--Apple-Mail=_C16D1A6C-1636-432C-9CE8-AD9FC2B05631
Content-Type: multipart/mixed;
	boundary="Apple-Mail=_F79AA045-DC59-401C-9E48-E323CE3FA86A"


--Apple-Mail=_F79AA045-DC59-401C-9E48-E323CE3FA86A
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=us-ascii

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html =
charset=3Dus-ascii"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space;"><div>Before this patch:</div><div><div =
style=3D"margin: 0px; font-size: 10px; font-family: Monaco; color: =
rgb(245, 245, 245); background-color: rgb(0, 0, =
0);">root@57:~/iftop-1.0pre4# ./iftop&nbsp;</div><div style=3D"margin: =
0px; font-size: 10px; font-family: Monaco; color: rgb(245, 245, 245); =
background-color: rgb(0, 0, 0);">interface: eth0</div><div =
style=3D"margin: 0px; font-size: 10px; font-family: Monaco; color: =
rgb(245, 245, 245); background-color: rgb(0, 0, 0);">IP address is: =
192.168.1.57</div><div style=3D"margin: 0px; font-size: 10px; =
font-family: Monaco; color: rgb(245, 245, 245); background-color: rgb(0, =
0, 0);">MAC address is: =
ffffffbc:ffffffee:7b:ffffffdb:0b:ffffffd4</div></div><div><br></div><div>W=
ith this patch</div><div><div style=3D"margin: 0px; font-size: 10px; =
font-family: Monaco; color: rgb(245, 245, 245); background-color: rgb(0, =
0, 0);">root@57:~/iftop-1.0pre4# ./iftop&nbsp;</div><div style=3D"margin: =
0px; font-size: 10px; font-family: Monaco; color: rgb(245, 245, 245); =
background-color: rgb(0, 0, 0);">interface: eth0</div><div =
style=3D"margin: 0px; font-size: 10px; font-family: Monaco; color: =
rgb(245, 245, 245); background-color: rgb(0, 0, 0);">IP address is: =
192.168.1.57</div><div style=3D"margin: 0px; font-size: 10px; =
font-family: Monaco; color: rgb(245, 245, 245); background-color: rgb(0, =
0, 0);">MAC address is: =
bc:ee:7b:db:0b:d4</div></div><div><br></div></body></html>=

--Apple-Mail=_F79AA045-DC59-401C-9E48-E323CE3FA86A
Content-Disposition: attachment;
	filename=iftop-mac-address.patch
Content-Type: application/octet-stream;
	name="iftop-mac-address.patch"
Content-Transfer-Encoding: 7bit

--- iftop.c.old 2014-01-20 04:21:19.000000000 +0800
+++ iftop.c 2014-03-03 12:49:57.383335066 +0800
@@ -713,7 +713,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, "%c%02x", i ? ':' : ' ', (unsigned char)if_hw_addr[i]);
       fprintf(stderr, "\n");
     }

--Apple-Mail=_F79AA045-DC59-401C-9E48-E323CE3FA86A
Content-Transfer-Encoding: 7bit
Content-Type: text/html;
	charset=us-ascii

<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"></body></html>
--Apple-Mail=_F79AA045-DC59-401C-9E48-E323CE3FA86A--

--Apple-Mail=_C16D1A6C-1636-432C-9CE8-AD9FC2B05631--