It's _WIN32, with a leading underscore, not WIN32. See, for example:
https://sourceforge.net/p/predef/wiki/OperatingSystems/
and
https://msdn.microsoft.com/en-us/library/b0084kay.aspx
*Some* environments may also define WIN32, but we shouldn't depend on
that.
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)
+#if defined(INET6) && defined(_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
}
}
#define gethostbyaddr win32_gethostbyaddr
}
}
#define gethostbyaddr win32_gethostbyaddr
-#endif /* INET6 & WIN32 */
+#endif /* INET6 & _WIN32 */
#ifdef INET6
struct h6namemem {
#ifdef INET6
struct h6namemem {
}
/* in libpcap.a (nametoaddr.c) */
}
/* in libpcap.a (nametoaddr.c) */
-#if defined(WIN32) && !defined(USE_STATIC_LIBPCAP)
+#if defined(_WIN32) && !defined(USE_STATIC_LIBPCAP)
extern __declspec(dllimport)
#else
extern
extern __declspec(dllimport)
#else
extern
static const char tstr[] = "[|decnet]";
static const char tstr[] = "[|decnet]";
typedef uint8_t byte[1]; /* single byte field */
#else
/*
typedef uint8_t byte[1]; /* single byte field */
#else
/*
*/
typedef unsigned char Byte[1]; /* single byte field */
#define byte Byte
*/
typedef unsigned char Byte[1]; /* single byte field */
#define byte Byte
typedef uint8_t word[2]; /* 2 byte field */
typedef uint8_t longword[4]; /* 4 bytes field */
typedef uint8_t word[2]; /* 2 byte field */
typedef uint8_t longword[4]; /* 4 bytes field */
#include <stdint.h>
#include <stdio.h>
#include <stdint.h>
#include <stdio.h>
#define vsnprintf _vsnprintf
#define RETSIGTYPE void
#define vsnprintf _vsnprintf
#define RETSIGTYPE void
#include <ctype.h>
#include <unistd.h>
#include <ctype.h>
#include <unistd.h>
#ifndef HAVE___ATTRIBUTE__
#define __attribute__(x)
#ifndef HAVE___ATTRIBUTE__
#define __attribute__(x)
#define UNALIGNED __attribute__((packed))
#endif
#define UNALIGNED __attribute__((packed))
#endif
-#if defined(WIN32) || defined(MSDOS)
+#if defined(_WIN32) || defined(MSDOS)
#define FOPEN_READ_TXT "rt"
#define FOPEN_READ_BIN "rb"
#define FOPEN_WRITE_TXT "wt"
#define FOPEN_READ_TXT "rt"
#define FOPEN_READ_BIN "rb"
#define FOPEN_WRITE_TXT "wt"
#include <tcpdump-stdinc.h>
#include <tcpdump-stdinc.h>
#include "w32_fzs.h"
extern int strcasecmp (const char *__s1, const char *__s2);
extern int SIZE_BUF;
#define off_t long
#define uint UINT
#include "w32_fzs.h"
extern int strcasecmp (const char *__s1, const char *__s2);
extern int SIZE_BUF;
#define off_t long
#define uint UINT
#ifdef USE_LIBSMI
#include <smi.h>
#ifdef USE_LIBSMI
#include <smi.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <sys/wait.h>
#include <sys/resource.h>
#include <pwd.h>
#include <grp.h>
#include <sys/wait.h>
#include <sys/resource.h>
#include <pwd.h>
#include <grp.h>
/* capabilities convenience library */
/* If a code depends on HAVE_LIBCAP_NG, it depends also on HAVE_CAP_NG_H.
/* capabilities convenience library */
/* If a code depends on HAVE_LIBCAP_NG, it depends also on HAVE_CAP_NG_H.
* Set up flags that might or might not be supported depending on the
* version of libpcap we're using.
*/
* Set up flags that might or might not be supported depending on the
* version of libpcap we're using.
*/
-#if defined(HAVE_PCAP_CREATE) || defined(WIN32)
+#if defined(HAVE_PCAP_CREATE) || defined(_WIN32)
#define B_FLAG "B:"
#define B_FLAG_USAGE " [ -B size ]"
#define B_FLAG "B:"
#define B_FLAG_USAGE " [ -B size ]"
-#else /* defined(HAVE_PCAP_CREATE) || defined(WIN32) */
+#else /* defined(HAVE_PCAP_CREATE) || defined(_WIN32) */
#define B_FLAG
#define B_FLAG_USAGE
#define B_FLAG
#define B_FLAG_USAGE
-#endif /* defined(HAVE_PCAP_CREATE) || defined(WIN32) */
+#endif /* defined(HAVE_PCAP_CREATE) || defined(_WIN32) */
#ifdef HAVE_PCAP_CREATE
#define I_FLAG "I"
#ifdef HAVE_PCAP_CREATE
#define I_FLAG "I"
#define OPTION_IMMEDIATE_MODE 130
static const struct option longopts[] = {
#define OPTION_IMMEDIATE_MODE 130
static const struct option longopts[] = {
-#if defined(HAVE_PCAP_CREATE) || defined(WIN32)
+#if defined(HAVE_PCAP_CREATE) || defined(_WIN32)
{ "buffer-size", required_argument, NULL, 'B' },
#endif
{ "list-interfaces", no_argument, NULL, 'D' },
{ "buffer-size", required_argument, NULL, 'B' },
#endif
{ "list-interfaces", no_argument, NULL, 'D' },
/* Drop root privileges and chroot if necessary */
static void
droproot(const char *username, const char *chroot_dir)
/* Drop root privileges and chroot if necessary */
static void
droproot(const char *username, const char *chroot_dir)
#endif /* HAVE_LIBCAP_NG */
}
#endif /* HAVE_LIBCAP_NG */
}
static int
getWflagChars(int x)
static int
getWflagChars(int x)
int new_dlt;
const char *dlt_name;
struct bpf_program fcode;
int new_dlt;
const char *dlt_name;
struct bpf_program fcode;
RETSIGTYPE (*oldhandler)(int);
#endif
struct print_info printinfo;
RETSIGTYPE (*oldhandler)(int);
#endif
struct print_info printinfo;
int cansandbox;
#endif /* HAVE_CAPSICUM */
int cansandbox;
#endif /* HAVE_CAPSICUM */
if(wsockinit() != 0) return 1;
if(wsockinit() != 0) return 1;
jflag=-1; /* not set */
gndo->ndo_Oflag=1;
jflag=-1; /* not set */
gndo->ndo_Oflag=1;
-#if defined(HAVE_PCAP_CREATE) || defined(WIN32)
+#if defined(HAVE_PCAP_CREATE) || defined(_WIN32)
case 'B':
Bflag = atoi(optarg)*1024;
if (Bflag <= 0)
error("invalid packet buffer size %s", optarg);
break;
case 'B':
Bflag = atoi(optarg)*1024;
if (Bflag <= 0)
error("invalid packet buffer size %s", optarg);
break;
-#endif /* defined(HAVE_PCAP_CREATE) || defined(WIN32) */
+#endif /* defined(HAVE_PCAP_CREATE) || defined(_WIN32) */
case 'c':
cnt = atoi(optarg);
case 'c':
cnt = atoi(optarg);
/*
* _IOLBF is the same as _IOFBF in Microsoft's C
* libraries; the only alternative they offer
* is _IONBF.
*
* XXX - this should really be checking for MSVC++,
/*
* _IOLBF is the same as _IOFBF in Microsoft's C
* libraries; the only alternative they offer
* is _IONBF.
*
* XXX - this should really be checking for MSVC++,
- * not WIN32, if, for example, MinGW has its own
+ * not _WIN32, if, for example, MinGW has its own
* C library that is more UNIX-compatible.
*/
setvbuf(stdout, NULL, _IONBF, 0);
* C library that is more UNIX-compatible.
*/
setvbuf(stdout, NULL, _IONBF, 0);
#ifdef HAVE_SETLINEBUF
setlinebuf(stdout);
#else
setvbuf(stdout, NULL, _IOLBF, 0);
#endif
#ifdef HAVE_SETLINEBUF
setlinebuf(stdout);
#else
setvbuf(stdout, NULL, _IOLBF, 0);
#endif
* In either case, we're reading a savefile, not doing
* a live capture.
*/
* In either case, we're reading a savefile, not doing
* a live capture.
*/
/*
* We don't need network access, so relinquish any set-UID
* or set-GID privileges we have (if any).
/*
* We don't need network access, so relinquish any set-UID
* or set-GID privileges we have (if any).
*/
if (setgid(getgid()) != 0 || setuid(getuid()) != 0 )
fprintf(stderr, "Warning: setgid/setuid failed !\n");
*/
if (setgid(getgid()) != 0 || setuid(getuid()) != 0 )
fprintf(stderr, "Warning: setgid/setuid failed !\n");
if (VFileName != NULL) {
if (VFileName[0] == '-' && VFileName[1] == '\0')
VFile = stdin;
if (VFileName != NULL) {
if (VFileName[0] == '-' && VFileName[1] == '\0')
VFile = stdin;
if (device == NULL)
error("%s", ebuf);
}
if (device == NULL)
error("%s", ebuf);
}
/*
* Print a message to the standard error on Windows.
* XXX - why do it here, with a different message?
/*
* Print a message to the standard error on Windows.
* XXX - why do it here, with a different message?
#ifdef HAVE_PCAP_CREATE
pd = pcap_create(device, ebuf);
if (pd == NULL)
#ifdef HAVE_PCAP_CREATE
pd = pcap_create(device, ebuf);
if (pd == NULL)
/*
* Let user own process after socket has been opened.
*/
/*
* Let user own process after socket has been opened.
*/
if (setgid(getgid()) != 0 || setuid(getuid()) != 0)
fprintf(stderr, "Warning: setgid/setuid failed !\n");
if (setgid(getgid()) != 0 || setuid(getuid()) != 0)
fprintf(stderr, "Warning: setgid/setuid failed !\n");
-#endif /* WIN32 */
-#if !defined(HAVE_PCAP_CREATE) && defined(WIN32)
+#endif /* _WIN32 */
+#if !defined(HAVE_PCAP_CREATE) && defined(_WIN32)
if(Bflag != 0)
if(pcap_setbuff(pd, Bflag)==-1){
error("%s", pcap_geterr(pd));
}
if(Bflag != 0)
if(pcap_setbuff(pd, Bflag)==-1){
error("%s", pcap_geterr(pd));
}
-#endif /* !defined(HAVE_PCAP_CREATE) && defined(WIN32) */
+#endif /* !defined(HAVE_PCAP_CREATE) && defined(_WIN32) */
if (Lflag)
show_dlts_and_exit(device, pd);
if (gndo->ndo_dlt >= 0) {
if (Lflag)
show_dlts_and_exit(device, pd);
if (gndo->ndo_dlt >= 0) {
init_addrtoname(gndo, localnet, netmask);
init_checksum();
init_addrtoname(gndo, localnet, netmask);
init_checksum();
(void)setsignal(SIGPIPE, cleanup);
(void)setsignal(SIGTERM, cleanup);
(void)setsignal(SIGINT, cleanup);
(void)setsignal(SIGPIPE, cleanup);
(void)setsignal(SIGTERM, cleanup);
(void)setsignal(SIGINT, cleanup);
#if defined(HAVE_FORK) || defined(HAVE_VFORK)
(void)setsignal(SIGCHLD, child_cleanup);
#endif
/* Cooperate with nohup(1) */
#if defined(HAVE_FORK) || defined(HAVE_VFORK)
(void)setsignal(SIGCHLD, child_cleanup);
#endif
/* Cooperate with nohup(1) */
if ((oldhandler = setsignal(SIGHUP, cleanup)) != SIG_DFL)
(void)setsignal(SIGHUP, oldhandler);
if ((oldhandler = setsignal(SIGHUP, cleanup)) != SIG_DFL)
(void)setsignal(SIGHUP, oldhandler);
/*
* If a user name was specified with "-Z", attempt to switch to
* that user's UID. This would probably be used with sudo,
/*
* If a user name was specified with "-Z", attempt to switch to
* that user's UID. This would probably be used with sudo,
droproot(username, chroot_dir);
}
droproot(username, chroot_dir);
}
if (pcap_setfilter(pd, &fcode) < 0)
error("%s", pcap_geterr(pd));
if (pcap_setfilter(pd, &fcode) < 0)
error("%s", pcap_geterr(pd));
if (RFileName == NULL) {
/*
* Live capture (if -V was specified, we set RFileName
if (RFileName == NULL) {
/*
* Live capture (if -V was specified, we set RFileName
}
(void)fflush(stderr);
}
}
(void)fflush(stderr);
}
#ifdef HAVE_CAPSICUM
cansandbox = (nflag && VFileName == NULL && zflag == NULL);
#ifdef HAVE_CAPSICUM
cansandbox = (nflag && VFileName == NULL && zflag == NULL);
/*
* XXX - there should really be libpcap calls to get the version
* number as a string (the string would be generated from #defines
/*
* XXX - there should really be libpcap calls to get the version
* number as a string (the string would be generated from #defines
{
extern char version[];
#ifndef HAVE_PCAP_LIB_VERSION
{
extern char version[];
#ifndef HAVE_PCAP_LIB_VERSION
-#if defined(WIN32) || defined(HAVE_PCAP_VERSION)
+#if defined(_WIN32) || defined(HAVE_PCAP_VERSION)
extern char pcap_version[];
extern char pcap_version[];
-#else /* defined(WIN32) || defined(HAVE_PCAP_VERSION) */
+#else /* defined(_WIN32) || defined(HAVE_PCAP_VERSION) */
static char pcap_version[] = "unknown";
static char pcap_version[] = "unknown";
-#endif /* defined(WIN32) || defined(HAVE_PCAP_VERSION) */
+#endif /* defined(_WIN32) || defined(HAVE_PCAP_VERSION) */
#endif /* HAVE_PCAP_LIB_VERSION */
#ifdef HAVE_PCAP_LIB_VERSION
#endif /* HAVE_PCAP_LIB_VERSION */
#ifdef HAVE_PCAP_LIB_VERSION
(void)fprintf(stderr, "%s version %s, based on tcpdump version %s\n", program_name, WDversion, version);
(void)fprintf(stderr, "%s version %s, based on tcpdump version %s\n", program_name, WDversion, version);
(void)fprintf(stderr, "%s version %s\n", program_name, version);
(void)fprintf(stderr, "%s version %s\n", program_name, version);
(void)fprintf(stderr, "%s\n",pcap_lib_version());
#else /* HAVE_PCAP_LIB_VERSION */
(void)fprintf(stderr, "%s\n",pcap_lib_version());
#else /* HAVE_PCAP_LIB_VERSION */
(void)fprintf(stderr, "%s version %s, based on tcpdump version %s\n", program_name, WDversion, version);
(void)fprintf(stderr, "WinPcap version %s, based on libpcap version %s\n",Wpcap_version, pcap_version);
(void)fprintf(stderr, "%s version %s, based on tcpdump version %s\n", program_name, WDversion, version);
(void)fprintf(stderr, "WinPcap version %s, based on libpcap version %s\n",Wpcap_version, pcap_version);
(void)fprintf(stderr, "%s version %s\n", program_name, version);
(void)fprintf(stderr, "libpcap version %s\n", pcap_version);
(void)fprintf(stderr, "%s version %s\n", program_name, version);
(void)fprintf(stderr, "libpcap version %s\n", pcap_version);
#endif /* HAVE_PCAP_LIB_VERSION */
#if defined(HAVE_LIBCRYPTO) && defined(SSLEAY_VERSION)
#endif /* HAVE_PCAP_LIB_VERSION */
#if defined(HAVE_LIBCRYPTO) && defined(SSLEAY_VERSION)