diff options
Diffstat (limited to 'contrib/tcpdump/addrtoname.c')
-rw-r--r-- | contrib/tcpdump/addrtoname.c | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/contrib/tcpdump/addrtoname.c b/contrib/tcpdump/addrtoname.c index 852c89a..648a823 100644 --- a/contrib/tcpdump/addrtoname.c +++ b/contrib/tcpdump/addrtoname.c @@ -23,7 +23,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.108 2005/03/27 22:38:09 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.108.2.5 2005/04/25 08:43:05 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -42,12 +42,18 @@ struct rtentry; /* declarations in <net/if.h> */ #ifdef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST #include <netinet/ether.h> #endif /* NETINET_ETHER_H_DECLARES_ETHER_NTOHOST */ -#endif /* USE_ETHER_NTOHOST */ #if !defined(HAVE_DECL_ETHER_NTOHOST) || !HAVE_DECL_ETHER_NTOHOST +#ifndef HAVE_STRUCT_ETHER_ADDR +struct ether_addr { + unsigned char ether_addr_octet[6]; +}; +#endif extern int ether_ntohost(char *, const struct ether_addr *); #endif +#endif /* USE_ETHER_NTOHOST */ + #include <pcap.h> #include <pcap-namedb.h> #include <signal.h> @@ -59,6 +65,8 @@ extern int ether_ntohost(char *, const struct ether_addr *); #include "addrtoname.h" #include "llc.h" #include "setsignal.h" +#include "extract.h" +#include "oui.h" /* * hash tables for whatever-to-name translations @@ -67,6 +75,7 @@ extern int ether_ntohost(char *, const struct ether_addr *); */ #define HASHNAMESIZE 4096 +#define BUFSIZE 128 struct hnamemem { u_int32_t addr; @@ -167,7 +176,7 @@ intoa(u_int32_t addr) static char buf[sizeof(".xxx.xxx.xxx.xxx")]; NTOHL(addr); - cp = &buf[sizeof buf]; + cp = buf + sizeof(buf); *--cp = '\0'; n = 4; @@ -452,17 +461,17 @@ lookup_protoid(const u_char *pi) const char * etheraddr_string(register const u_char *ep) { - register u_int i; + register u_int i, oui; register char *cp; register struct enamemem *tp; - char buf[sizeof("00:00:00:00:00:00")]; + char buf[BUFSIZE]; tp = lookup_emem(ep); if (tp->e_name) return (tp->e_name); #ifdef USE_ETHER_NTOHOST if (!nflag) { - char buf2[128]; + char buf2[BUFSIZE]; /* * We don't cast it to "const struct ether_addr *" @@ -477,14 +486,20 @@ etheraddr_string(register const u_char *ep) } #endif cp = buf; + oui=EXTRACT_24BITS(ep); *cp++ = hex[*ep >> 4 ]; *cp++ = hex[*ep++ & 0xf]; - for (i = 5; (int)--i >= 0;) { - *cp++ = ':'; - *cp++ = hex[*ep >> 4 ]; - *cp++ = hex[*ep++ & 0xf]; - } - *cp = '\0'; + for (i = 5; (int)--i >= 0;) { + *cp++ = ':'; + *cp++ = hex[*ep >> 4 ]; + *cp++ = hex[*ep++ & 0xf]; + } + + if (!nflag) { + snprintf(cp,BUFSIZE," (oui %s)", + tok2str(oui_values,"Unknown",oui)); + } else + *cp = '\0'; tp->e_name = strdup(buf); return (tp->e_name); } @@ -598,7 +613,7 @@ isonsap_string(const u_char *nsap, register u_int nsap_length) register struct enamemem *tp; if (nsap_length < 1 || nsap_length > ISONSAP_MAX_LENGTH) - error("isonsap_string: illegal length"); + return ("isonsap_string: illegal length"); tp = lookup_nsap(nsap); if (tp->e_name) |