Unix Technical Forum

[patch] tcpdump: leading zeros in MAC address parts

This is a discussion on [patch] tcpdump: leading zeros in MAC address parts within the mailing.openbsd.tech forums, part of the OpenBSD category; --> Hello. This trivial patch keeps leading zeros in MAC address bytes, so that they had a fixed length. Sample ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > mailing.openbsd.tech

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-18-2008, 09:26 AM
Stanislav Kruchinin
 
Posts: n/a
Default [patch] tcpdump: leading zeros in MAC address parts

Hello.

This trivial patch keeps leading zeros in MAC address bytes, so that they had
a fixed length.

Sample of tcpdump output
before:
18:08:24.293100 0:e0:4c:a0:a5:56 ff:ff:ff:ff:ff:ff
18:08:24.293665 0:e0:4c:a0:a5:8 ff:ff:ff:ff:ff:ff

after:
18:08:24.293100 00:e0:4c:a0:a5:56 ff:ff:ff:ff:ff:ff
18:08:24.293665 00:e0:4c:a0:a5:08 ff:ff:ff:ff:ff:ff


================================================== =================
RCS file: /cvs/src/usr.sbin/tcpdump/addrtoname.c,v
retrieving revision 1.28
diff -u -p -r1.28 addrtoname.c
--- addrtoname.c 26 Feb 2006 21:10:54 -0000 1.28
+++ addrtoname.c 18 Jun 2007 02:24:12 -0000
@@ -474,13 +474,13 @@ etheraddr_string(register const u_char *
}
#endif
cp = buf;
- if ((j = *ep >> 4) != 0)
- *cp++ = hex[j];
+ j = *ep >> 4;
+ *cp++ = hex[j];
*cp++ = hex[*ep++ & 0xf];
for (i = 5; (int)--i >= 0 {
*cp++ = ':';
- if ((j = *ep >> 4) != 0)
- *cp++ = hex[j];
+ j = *ep >> 4;
+ *cp++ = hex[j];
*cp++ = hex[*ep++ & 0xf];
}
*cp = '\0';

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:52 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com