]> The Tcpdump Group git mirrors - tcpdump/blobdiff - addrtoname.c
Translate UDP/1700 as RADIUS
[tcpdump] / addrtoname.c
index 3f04479c491b7f5ea73a8518120cceb4cb94246a..a79aba7da256e34308a88bcfcaadc2b178e40a48 100644 (file)
@@ -59,6 +59,8 @@ extern int ether_ntohost(char *, const struct ether_addr *);
 
 #include "netdissect.h"
 #include "addrtoname.h"
 
 #include "netdissect.h"
 #include "addrtoname.h"
+#include "addrtostr.h"
+#include "ethertype.h"
 #include "llc.h"
 #include "setsignal.h"
 #include "extract.h"
 #include "llc.h"
 #include "setsignal.h"
 #include "extract.h"
@@ -89,7 +91,7 @@ static struct hnamemem eprototable[HASHNAMESIZE];
 static struct hnamemem dnaddrtable[HASHNAMESIZE];
 static struct hnamemem ipxsaptable[HASHNAMESIZE];
 
 static struct hnamemem dnaddrtable[HASHNAMESIZE];
 static struct hnamemem ipxsaptable[HASHNAMESIZE];
 
-#if defined(INET6) && defined(_WIN32)
+#ifdef _WIN32
 /*
  * fake gethostbyaddr for Win2k/XP
  * gethostbyaddr() returns incorrect value when AF_INET6 is passed
 /*
  * fake gethostbyaddr for Win2k/XP
  * gethostbyaddr() returns incorrect value when AF_INET6 is passed
@@ -127,9 +129,8 @@ win32_gethostbyaddr(const char *addr, int len, int type)
        }
 }
 #define gethostbyaddr win32_gethostbyaddr
        }
 }
 #define gethostbyaddr win32_gethostbyaddr
-#endif /* INET6 & _WIN32 */
+#endif /* _WIN32 */
 
 
-#ifdef INET6
 struct h6namemem {
        struct in6_addr addr;
        char *name;
 struct h6namemem {
        struct in6_addr addr;
        char *name;
@@ -137,7 +138,6 @@ struct h6namemem {
 };
 
 static struct h6namemem h6nametable[HASHNAMESIZE];
 };
 
 static struct h6namemem h6nametable[HASHNAMESIZE];
-#endif /* INET6 */
 
 struct enamemem {
        u_short e_addr0;
 
 struct enamemem {
        u_short e_addr0;
@@ -265,7 +265,6 @@ getname(netdissect_options *ndo, const u_char *ap)
        return (p->name);
 }
 
        return (p->name);
 }
 
-#ifdef INET6
 /*
  * Return a name for the IP6 address pointed to by ap.  This address
  * is assumed to be in network byte order.
 /*
  * Return a name for the IP6 address pointed to by ap.  This address
  * is assumed to be in network byte order.
@@ -315,13 +314,12 @@ getname6(netdissect_options *ndo, const u_char *ap)
                        return (p->name);
                }
        }
                        return (p->name);
                }
        }
-       cp = inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf));
+       cp = addrtostr6(ap, ntop_buf, sizeof(ntop_buf));
        p->name = strdup(cp);
        if (p->name == NULL)
                (*ndo->ndo_error)(ndo, "getname6: strdup(cp)");
        return (p->name);
 }
        p->name = strdup(cp);
        if (p->name == NULL)
                (*ndo->ndo_error)(ndo, "getname6: strdup(cp)");
        return (p->name);
 }
-#endif /* INET6 */
 
 static const char hex[] = "0123456789abcdef";
 
 
 static const char hex[] = "0123456789abcdef";
 
@@ -780,16 +778,32 @@ init_servarray(netdissect_options *ndo)
        endservent();
 }
 
        endservent();
 }
 
-/* in libpcap.a (nametoaddr.c) */
-#if defined(_WIN32) && !defined(USE_STATIC_LIBPCAP)
-extern __declspec(dllimport)
-#else
-extern
-#endif
-const struct eproto {
+static const struct eproto {
        const char *s;
        u_short p;
        const char *s;
        u_short p;
-} eproto_db[];
+} eproto_db[] = {
+       { "pup", ETHERTYPE_PUP },
+       { "xns", ETHERTYPE_NS },
+       { "ip", ETHERTYPE_IP },
+       { "ip6", ETHERTYPE_IPV6 },
+       { "arp", ETHERTYPE_ARP },
+       { "rarp", ETHERTYPE_REVARP },
+       { "sprite", ETHERTYPE_SPRITE },
+       { "mopdl", ETHERTYPE_MOPDL },
+       { "moprc", ETHERTYPE_MOPRC },
+       { "decnet", ETHERTYPE_DN },
+       { "lat", ETHERTYPE_LAT },
+       { "sca", ETHERTYPE_SCA },
+       { "lanbridge", ETHERTYPE_LANBRIDGE },
+       { "vexp", ETHERTYPE_VEXP },
+       { "vprod", ETHERTYPE_VPROD },
+       { "atalk", ETHERTYPE_ATALK },
+       { "atalkarp", ETHERTYPE_AARP },
+       { "loopback", ETHERTYPE_LOOPBACK },
+       { "decdts", ETHERTYPE_DECDTS },
+       { "decdns", ETHERTYPE_DECDNS },
+       { (char *)0, 0 }
+};
 
 static void
 init_eprotoarray(netdissect_options *ndo)
 
 static void
 init_eprotoarray(netdissect_options *ndo)
@@ -1225,7 +1239,6 @@ newhnamemem(netdissect_options *ndo)
        return (p);
 }
 
        return (p);
 }
 
-#ifdef INET6
 /* Return a zero'ed h6namemem struct and cuts down on calloc() overhead */
 struct h6namemem *
 newh6namemem(netdissect_options *ndo)
 /* Return a zero'ed h6namemem struct and cuts down on calloc() overhead */
 struct h6namemem *
 newh6namemem(netdissect_options *ndo)
@@ -1244,7 +1257,6 @@ newh6namemem(netdissect_options *ndo)
        p = ptr++;
        return (p);
 }
        p = ptr++;
        return (p);
 }
-#endif /* INET6 */
 
 /* Represent TCI part of the 802.1Q 4-octet tag as text. */
 const char *
 
 /* Represent TCI part of the 802.1Q 4-octet tag as text. */
 const char *