]> The Tcpdump Group git mirrors - tcpdump/blobdiff - addrtoname.c
Introduce --time-stamp-precision
[tcpdump] / addrtoname.c
index ba0397c2325d238ec6b729e6eb59014afc48da0f..eb0b2aeefe1f7c423a1bf43c6277c6ce592f660e 100644 (file)
@@ -22,6 +22,7 @@
  *  and address to string conversion routines
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -77,7 +78,7 @@ extern int ether_ntohost(char *, const struct ether_addr *);
 #define HASHNAMESIZE 4096
 
 struct hnamemem {
-       u_int32_t addr;
+       uint32_t addr;
        const char *name;
        struct hnamemem *nxt;
 };
@@ -154,7 +155,7 @@ static struct enamemem nsaptable[HASHNAMESIZE];
 static struct enamemem bytestringtable[HASHNAMESIZE];
 
 struct protoidmem {
-       u_int32_t p_oui;
+       uint32_t p_oui;
        u_short p_proto;
        const char *p_name;
        struct protoidmem *p_nxt;
@@ -166,7 +167,7 @@ static struct protoidmem protoidtable[HASHNAMESIZE];
  * A faster replacement for inet_ntoa().
  */
 const char *
-intoa(u_int32_t addr)
+intoa(uint32_t addr)
 {
        register char *cp;
        register u_int byte;
@@ -195,8 +196,8 @@ intoa(u_int32_t addr)
        return cp + 1;
 }
 
-static u_int32_t f_netmask;
-static u_int32_t f_localnet;
+static uint32_t f_netmask;
+static uint32_t f_localnet;
 
 /*
  * Return a name for the IP address pointed to by ap.  This address
@@ -221,7 +222,7 @@ const char *
 getname(netdissect_options *ndo, const u_char *ap)
 {
        register struct hostent *hp;
-       u_int32_t addr;
+       uint32_t addr;
        static struct hnamemem *p;              /* static for longjmp() */
 
        memcpy(&addr, ap, sizeof(addr));
@@ -247,7 +248,7 @@ getname(netdissect_options *ndo, const u_char *ap)
                        char *dotp;
 
                        p->name = strdup(hp->h_name);
-                       if (Nflag) {
+                       if (ndo->ndo_Nflag) {
                                /* Remove domain qualifications */
                                dotp = strchr(p->name, '.');
                                if (dotp)
@@ -273,7 +274,7 @@ getname6(netdissect_options *ndo, const u_char *ap)
                struct in6_addr addr;
                struct for_hash_addr {
                        char fill[14];
-                       u_int16_t d;
+                       uint16_t d;
                } addra;
        } addr;
        static struct h6namemem *p;             /* static for longjmp() */
@@ -298,7 +299,7 @@ getname6(netdissect_options *ndo, const u_char *ap)
                        char *dotp;
 
                        p->name = strdup(hp->h_name);
-                       if (Nflag) {
+                       if (ndo->ndo_Nflag) {
                                /* Remove domain qualifications */
                                dotp = strchr(p->name, '.');
                                if (dotp)
@@ -579,7 +580,7 @@ etherproto_string(u_short port)
 {
        register char *cp;
        register struct hnamemem *tp;
-       register u_int32_t i = port;
+       register uint32_t i = port;
        char buf[sizeof("0000")];
 
        for (tp = &eprototable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@@ -662,7 +663,7 @@ const char *
 tcpport_string(u_short port)
 {
        register struct hnamemem *tp;
-       register u_int32_t i = port;
+       register uint32_t i = port;
        char buf[sizeof("00000")];
 
        for (tp = &tporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@@ -681,7 +682,7 @@ const char *
 udpport_string(register u_short port)
 {
        register struct hnamemem *tp;
-       register u_int32_t i = port;
+       register uint32_t i = port;
        char buf[sizeof("00000")];
 
        for (tp = &uporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@@ -701,7 +702,7 @@ ipxsap_string(u_short port)
 {
        register char *cp;
        register struct hnamemem *tp;
-       register u_int32_t i = port;
+       register uint32_t i = port;
        char buf[sizeof("0000")];
 
        for (tp = &ipxsaptable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@@ -755,7 +756,7 @@ init_servarray(netdissect_options *ndo)
 
 /* in libpcap.a (nametoaddr.c) */
 #if defined(WIN32) && !defined(USE_STATIC_LIBPCAP)
-__declspec(dllimport)
+extern __declspec(dllimport)
 #else
 extern
 #endif
@@ -1131,14 +1132,14 @@ init_ipxsaparray(void)
 
 /*
  * Initialize the address to name translation machinery.  We map all
- * non-local IP addresses to numeric addresses if fflag is true (i.e.,
- * to prevent blocking on the nameserver).  localnet is the IP address
+ * 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.
  */
 void
-init_addrtoname(netdissect_options *ndo, u_int32_t localnet, u_int32_t mask)
+init_addrtoname(netdissect_options *ndo, uint32_t localnet, uint32_t mask)
 {
-       if (fflag) {
+       if (ndo->ndo_fflag) {
                f_localnet = localnet;
                f_netmask = mask;
        }