X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/99c91c3aec40b691641374f58e798bd8d6b657bd..refs/pull/494/head:/netdissect-stdinc.h diff --git a/netdissect-stdinc.h b/netdissect-stdinc.h old mode 100644 new mode 100755 index 093fc092..e201afa4 --- a/netdissect-stdinc.h +++ b/netdissect-stdinc.h @@ -43,17 +43,19 @@ #ifdef _WIN32 +/* + * Includes and definitions for Windows. + */ + #include #include #include #include -#include "bittypes.h" /* in wpcap's Win32/include */ #include #include #include #include #include -#include /* in wpcap's Win32/include */ #ifndef uint8_t #define uint8_t unsigned char @@ -133,6 +135,17 @@ #endif /* _MSC_EXTENSIONS */ +/* + * Suppress definition of intN_t in bittypes.h, as included by + * on Windows. + * (Yes, HAVE_U_INTn_T, as the definition guards are UN*X-oriented, and + * we check for u_intN_t in the UN*X configure script.) + */ +#define HAVE_U_INT8_T +#define HAVE_U_INT16_T +#define HAVE_U_INT32_T +#define HAVE_U_INT64_T + #ifdef _MSC_VER #define stat _stat #define open _open @@ -142,13 +155,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); - /* * With MSVC, for C, __inline is used to make a function an inline. */ @@ -156,6 +162,10 @@ extern int inet_aton (const char *cp, struct in_addr *addr); #define inline __inline #endif +#ifdef AF_INET6 +#define HAVE_OS_IPV6_SUPPORT +#endif + #ifndef INET6_ADDRSTRLEN #define INET6_ADDRSTRLEN 46 #endif @@ -171,13 +181,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 +254,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 +269,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 +310,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