X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/10b807441e79f9c9e557bbb44ae0ecfe01ed5151..refs/heads/master:/addrtoname.c diff --git a/addrtoname.c b/addrtoname.c index b83d1ee2..43bfc47d 100644 --- a/addrtoname.c +++ b/addrtoname.c @@ -22,9 +22,7 @@ * and address to string conversion routines */ -#ifdef HAVE_CONFIG_H #include -#endif #ifdef HAVE_CASPER #include @@ -71,17 +69,12 @@ #else /* HAVE_STRUCT_ETHER_ADDR */ struct ether_addr { /* Beware FreeBSD calls this "octet". */ - unsigned char ether_addr_octet[MAC_ADDR_LEN]; + unsigned char ether_addr_octet[MAC48_LEN]; }; #endif /* HAVE_STRUCT_ETHER_ADDR */ #endif /* what declares ether_ntohost() */ #ifdef NEED_NETINET_IF_ETHER_H - /* - * Include diag-control.h before , which too defines a macro - * named ND_UNREACHABLE. - */ - #include "diag-control.h" #include /* Needed on some platforms */ #include /* Needed on some platforms */ #include @@ -297,6 +290,7 @@ ipaddr_string(netdissect_options *ndo, const u_char *ap) * (2) Address is foreign and -f was given. (If -f was not * given, f_netmask and f_localnet are 0 and the test * evaluates to true) + * Both addr and f_netmask and f_localnet are in network byte order. */ if (!ndo->ndo_nflag && (addr & f_netmask) == f_localnet) { @@ -531,8 +525,7 @@ lookup_nsap(netdissect_options *ndo, const u_char *nsap, k = (ensap[0] << 8) | ensap[1]; j = (ensap[2] << 8) | ensap[3]; i = (ensap[4] << 8) | ensap[5]; - } - else + } else i = j = k = 0; tp = &nsaptable[(i ^ j) & (HASHNAMESIZE-1)]; @@ -590,7 +583,7 @@ lookup_protoid(netdissect_options *ndo, const u_char *pi) } const char * -etheraddr_string(netdissect_options *ndo, const uint8_t *ep) +mac48_string(netdissect_options *ndo, const uint8_t *ep) { int i; char *cp; @@ -611,7 +604,7 @@ etheraddr_string(netdissect_options *ndo, const uint8_t *ep) */ struct ether_addr ea; - memcpy (&ea, ep, MAC_ADDR_LEN); + memcpy (&ea, ep, MAC48_LEN); if (ether_ntohost(buf2, &ea) == 0) { tp->e_name = strdup(buf2); if (tp->e_name == NULL) @@ -642,7 +635,16 @@ etheraddr_string(netdissect_options *ndo, const uint8_t *ep) } const char * -le64addr_string(netdissect_options *ndo, const uint8_t *ep) +eui64_string(netdissect_options *ndo, const uint8_t *ep) +{ + return (linkaddr_string(ndo, ep, LINKADDR_EUI64, EUI64_LEN)); +} + +/* + * EUI-64 with the rightmost octet first. + */ +const char * +eui64le_string(netdissect_options *ndo, const uint8_t *ep) { const unsigned int len = 8; u_int i; @@ -682,8 +684,8 @@ linkaddr_string(netdissect_options *ndo, const uint8_t *ep, if (len == 0) return (""); - if (type == LINKADDR_ETHER && len == MAC_ADDR_LEN) - return (etheraddr_string(ndo, ep)); + if (type == LINKADDR_MAC48 && len == MAC48_LEN) + return (mac48_string(ndo, ep)); if (type == LINKADDR_FRELAY) return (q922_string(ndo, ep, len)); @@ -930,7 +932,7 @@ init_protoidarray(netdissect_options *ndo) } static const struct etherlist { - const nd_mac_addr addr; + const nd_mac48 addr; const char *name; } etherlist[] = { {{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, "Broadcast" }, @@ -941,7 +943,7 @@ static const struct etherlist { * Initialize the ethers hash table. We take two different approaches * depending on whether or not the system provides the ethers name * service. If it does, we just wire in a few names at startup, - * and etheraddr_string() fills in the table on demand. If it doesn't, + * and mac48_string() fills in the table on demand. If it doesn't, * then we suck in the entire /etc/ethers file at startup. The idea * is that parsing the local file will be fast, but spinning through * all the ethers entries via NIS & next_etherent might be very slow. @@ -987,9 +989,9 @@ init_etherarray(netdissect_options *ndo) /* * Use YP/NIS version of name if available. */ - /* Same workaround as in etheraddr_string(). */ + /* Same workaround as in mac48_string(). */ struct ether_addr ea; - memcpy (&ea, el->addr, MAC_ADDR_LEN); + memcpy (&ea, el->addr, MAC48_LEN); if (ether_ntohost(name, &ea) == 0) { tp->e_name = strdup(name); if (tp->e_name == NULL) @@ -1121,7 +1123,7 @@ static const struct ipxsap_ent { { 0x030a, "GalacticommWorldgroupServer" }, { 0x030c, "IntelNetport2/HP JetDirect/HP Quicksilver" }, { 0x0320, "AttachmateGateway" }, - { 0x0327, "MicrosoftDiagnostiocs" }, + { 0x0327, "MicrosoftDiagnostics" }, { 0x0328, "WATCOM SQL Server" }, { 0x0335, "MultiTechSystems MultisynchCommServer" }, { 0x0343, "Xylogics RemoteAccessServer/LANModem" }, @@ -1243,7 +1245,7 @@ init_ipxsaparray(netdissect_options *ndo) * Initialize the address to name translation machinery. We map all * non-local IP addresses to numeric addresses if ndo->ndo_fflag is true * (i.e., to prevent blocking on the nameserver). localnet is the IP address - * of the local network. mask is its subnet mask. + * of the local network, mask is its subnet mask, both in network byte order. */ void init_addrtoname(netdissect_options *ndo, uint32_t localnet, uint32_t mask)