diff options
author | Ray Lai <ray@cvs.openbsd.org> | 2007-06-21 03:13:15 +0000 |
---|---|---|
committer | Ray Lai <ray@cvs.openbsd.org> | 2007-06-21 03:13:15 +0000 |
commit | a25346361a07d79ee61cfa9f2128efbacfc6ca14 (patch) | |
tree | 5b21d3bc4874d7f2fc3fb0ab797bcfe46dc6404e /usr.sbin/tcpdump | |
parent | 3bad81b942c62fe39379af41a7e9b71e6a2927fe (diff) |
Print leading zeros in MAC addresses. Initial diff from Stanislav
Kruchinin, idea to use ether_ntoa from Claudio Jeker.
OK canacar, idea OK henning, jasper, and tedu.
Diffstat (limited to 'usr.sbin/tcpdump')
-rw-r--r-- | usr.sbin/tcpdump/addrtoname.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/usr.sbin/tcpdump/addrtoname.c b/usr.sbin/tcpdump/addrtoname.c index ab80561a375..eea5e37899e 100644 --- a/usr.sbin/tcpdump/addrtoname.c +++ b/usr.sbin/tcpdump/addrtoname.c @@ -1,4 +1,4 @@ -/* $OpenBSD: addrtoname.c,v 1.28 2006/02/26 21:10:54 otto Exp $ */ +/* $OpenBSD: addrtoname.c,v 1.29 2007/06/21 03:13:14 ray Exp $ */ /* * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -25,12 +25,13 @@ */ #ifndef lint static const char rcsid[] = - "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/addrtoname.c,v 1.28 2006/02/26 21:10:54 otto Exp $ (LBL)"; + "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/addrtoname.c,v 1.29 2007/06/21 03:13:14 ray Exp $ (LBL)"; #endif #include <sys/param.h> #include <sys/socket.h> #include <sys/time.h> +#include <sys/types.h> struct mbuf; struct rtentry; @@ -455,10 +456,8 @@ lookup_protoid(const u_char *pi) char * etheraddr_string(register const u_char *ep) { - register u_int i, j; - register char *cp; register struct enamemem *tp; - char buf[sizeof("00:00:00:00:00:00")]; + struct ether_addr e; tp = lookup_emem(ep); if (tp->e_name) @@ -473,18 +472,8 @@ etheraddr_string(register const u_char *ep) } } #endif - cp = buf; - if ((j = *ep >> 4) != 0) - *cp++ = hex[j]; - *cp++ = hex[*ep++ & 0xf]; - for (i = 5; (int)--i >= 0;) { - *cp++ = ':'; - if ((j = *ep >> 4) != 0) - *cp++ = hex[j]; - *cp++ = hex[*ep++ & 0xf]; - } - *cp = '\0'; - tp->e_name = savestr(buf); + memcpy(e.ether_addr_octet, ep, sizeof(e.ether_addr_octet)); + tp->e_name = savestr(ether_ntoa(&e)); return (tp->e_name); } |