summaryrefslogtreecommitdiff
path: root/addrtoname.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-01-22 02:34:31 -0800
committerGuy Harris <guy@alum.mit.edu>2018-01-22 02:34:31 -0800
commit0c216561500e3279c806ee72c25ca47c3abee36c (patch)
tree01ac787ce0d1283e30464860048fc1791cd7a0d1 /addrtoname.c
parent7094894ebcbf3e7ea78a558c63045445488e346d (diff)
downloadtcpdump-0c216561500e3279c806ee72c25ca47c3abee36c.tar.gz
Configure for ether_ntohost() as libpcap does it for ether_hostton().
Check for the same header files that declare it, and handle the results of those checks in a similar fashion.
Diffstat (limited to 'addrtoname.c')
-rw-r--r--addrtoname.c78
1 files changed, 57 insertions, 21 deletions
diff --git a/addrtoname.c b/addrtoname.c
index 621021f1..f4d05e97 100644
--- a/addrtoname.c
+++ b/addrtoname.c
@@ -40,27 +40,63 @@
#define HTONS(x) (x) = htons(x)
#endif
-#ifdef USE_ETHER_NTOHOST
-#ifdef HAVE_NETINET_IF_ETHER_H
-struct mbuf; /* Squelch compiler warnings on some platforms for */
-struct rtentry; /* declarations in <net/if.h> */
-#include <net/if.h> /* for "struct ifnet" in "struct arpcom" on Solaris */
-#include <netinet/if_ether.h>
-#endif /* HAVE_NETINET_IF_ETHER_H */
-#ifdef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST
-#include <netinet/ether.h>
-#endif /* NETINET_ETHER_H_DECLARES_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 */
+#ifndef _WIN32
+ #ifdef USE_ETHER_NTOHOST
+ #if defined(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST)
+ /*
+ * OK, just include <net/ethernet.h>.
+ */
+ #include <net/ethernet.h>
+ #elif defined(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST)
+ /*
+ * OK, just include <netinet/ether.h>
+ */
+ #include <netinet/ether.h>
+ #elif defined(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST)
+ /*
+ * OK, just include <sys/ethernet.h>
+ */
+ #include <sys/ethernet.h>
+ #elif defined(ARPA_INET_H_DECLARES_ETHER_NTOHOST)
+ /*
+ * OK, just include <arpa/inet.h>
+ */
+ #include <arpa/inet.h>
+ #elif defined(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST)
+ /*
+ * OK, include <netinet/if_ether.h>, after all the other stuff we
+ * need to include or define for its benefit.
+ */
+ #define NEED_NETINET_IF_ETHER_H
+ #else
+ /*
+ * We'll have to declare it ourselves.
+ * If <netinet/if_ether.h> defines struct ether_addr, include
+ * it. Otherwise, define it ourselves.
+ */
+ #ifdef HAVE_STRUCT_ETHER_ADDR
+ #define NEED_NETINET_IF_ETHER_H
+ #else /* HAVE_STRUCT_ETHER_ADDR */
+ struct ether_addr {
+ unsigned char ether_addr_octet[6];
+ };
+ #endif /* HAVE_STRUCT_ETHER_ADDR */
+ #endif /* what declares ether_ntohost() */
+
+ #ifdef NEED_NETINET_IF_ETHER_H
+ #include <net/if.h> /* Needed on some platforms */
+ #include <netinet/in.h> /* Needed on some platforms */
+ #include <netinet/if_ether.h>
+ #endif /* NEED_NETINET_IF_ETHER_H */
+
+ #ifndef HAVE_DECL_ETHER_NTOHOST
+ /*
+ * No header declares it, so declare it ourselves.
+ */
+ extern int ether_ntohost(char *, const struct ether_addr *);
+ #endif /* !defined(HAVE_DECL_ETHER_NTOHOST) */
+ #endif /* USER_ETHER_NTOHOST */
+#endif /* _WIN32 */
#include <pcap.h>
#include <pcap-namedb.h>