From 11f73ad248fa22461ca040baa8dc94b864509efa Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Thu, 17 Sep 2015 14:56:44 -0700 Subject: Don't require IPv6 library support in order to support IPv6 addresses. Have our own routines to convert between IPv4/IPv6 addresses and strings; that helps if, for example, we want to build binary versions of tcpdump for Windows that can run both on NT 5 (W2K/WXP), which doesn't have inet_ntop() or inet_pton(), and NT 6 (Vista/7/8/10), which do. It also means that we don't require IPv6 library support on UN*X to print addresses (if somebody wants to build tcpdump for older UN*Xes lacking IPv6 support in the system library or in add-on libraries). Get rid of files in the missing directory that we don't need, and various no-longer-necessary autoconf tests. --- netdissect-stdinc.h | 51 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) (limited to 'netdissect-stdinc.h') diff --git a/netdissect-stdinc.h b/netdissect-stdinc.h index 093fc092..44967852 100644 --- a/netdissect-stdinc.h +++ b/netdissect-stdinc.h @@ -43,6 +43,10 @@ #ifdef _WIN32 +/* + * Includes and definitions for Windows. + */ + #include #include #include @@ -142,11 +146,6 @@ #define O_RDONLY _O_RDONLY #endif /* _MSC_VER */ -/* Protos for missing/x.c functions (ideally - * should be used, but it clashes with ). - */ -extern const char *inet_ntop (int, const void *, char *, size_t); -extern int inet_pton (int, const char *, void *); extern int inet_aton (const char *cp, struct in_addr *addr); /* @@ -171,13 +170,16 @@ typedef char* caddr_t; #endif /* caddr_t */ #define MAXHOSTNAMELEN 64 -#define NI_MAXHOST 1025 #define snprintf _snprintf #define vsnprintf _vsnprintf #define RETSIGTYPE void #else /* _WIN32 */ +/* + * Includes and definitions for various flavors of UN*X. + */ + #include #include #include @@ -241,6 +243,9 @@ typedef char* caddr_t; #define UNALIGNED __attribute__((packed)) #endif +/* + * fopen() read and write modes for text files and binary files. + */ #if defined(_WIN32) || defined(MSDOS) #define FOPEN_READ_TXT "rt" #define FOPEN_READ_BIN "rb" @@ -253,6 +258,16 @@ typedef char* caddr_t; #define FOPEN_WRITE_BIN FOPEN_WRITE_TXT #endif +/* + * Inline x86 assembler-language versions of ntoh[ls]() and hton[ls](), + * defined if the OS doesn't provide them. These assume no more than + * an 80386, so, for example, it avoids the bswap instruction added in + * the 80486. + * + * (We don't use them on OS X; Apple provides their own, which *doesn't* + * avoid the bswap instruction, as OS X only supports machines that + * have it.) + */ #if defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) && !defined(__ntohl) #undef ntohl #undef ntohs @@ -284,6 +299,30 @@ typedef char* caddr_t; } #endif +/* + * If the OS doesn't define AF_INET6 and struct in6_addr: + * + * define AF_INET6, so we can use it internally as a "this is an + * IPv6 address" indication; + * + * define struct in6_addr so that we can use it for IPv6 addresses. + */ +#ifndef HAVE_OS_IPV6_SUPPORT +#define AF_INET6 24 + +struct in6_addr { + union { + __uint8_t __u6_addr8[16]; + __uint16_t __u6_addr16[8]; + __uint32_t __u6_addr32[4]; + } __u6_addr; /* 128-bit IP6 address */ +}; +#endif + +#ifndef NI_MAXHOST +#define NI_MAXHOST 1025 +#endif + #ifndef INET_ADDRSTRLEN #define INET_ADDRSTRLEN 16 #endif -- cgit v1.2.1