*/
-#ifndef lint
-static const char copyright[] _U_ =
- "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
-The Regents of the University of California. All rights reserved.\n";
-#endif
-
/*
* tcpdump - dump traffic on a network
*
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
/*
#endif
#endif
-#include <netdissect-stdinc.h>
+#include "netdissect-stdinc.h"
+
+/*
+ * This must appear after including netdissect-stdinc.h, so that _U_ is
+ * defined.
+ */
+#ifndef lint
+static const char copyright[] _U_ =
+ "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
+The Regents of the University of California. All rights reserved.\n";
+#endif
#include <sys/stat.h>
* only use them for the same purposes that the other versions of tcpdump
* use them:
*
- * OS X tcpdump uses -g to force non--v output for IP to be on one
+ * macOS tcpdump uses -g to force non--v output for IP to be on one
* line, making it more "g"repable;
*
- * OS X tcpdump uses -k to specify that packet comments in pcap-ng files
+ * macOS tcpdump uses -k to specify that packet comments in pcapng files
* should be printed;
*
* OpenBSD tcpdump uses -o to indicate that OS fingerprinting should be done
* for hosts sending TCP SYN packets;
*
- * OS X tcpdump uses -P to indicate that -w should write pcap-ng rather
+ * macOS tcpdump uses -P to indicate that -w should write pcapng rather
* than pcap files.
*
- * OS X tcpdump also uses -Q to specify expressions that match packet
+ * macOS tcpdump also uses -Q to specify expressions that match packet
* metadata, including but not limited to the packet direction.
* The expression syntax is different from a simple "in|out|inout",
- * and those expressions aren't accepted by OS X tcpdump, but the
+ * and those expressions aren't accepted by macOS tcpdump, but the
* equivalents would be "in" = "dir=in", "out" = "dir=out", and
* "inout" = "dir=in or dir=out", and the parser could conceivably
* special-case "in", "out", and "inout" as expressions for backwards
if (cnt == 0 && max_chars == 0)
strncpy(buffer, filename, PATH_MAX + 1);
else
- if (snprintf(buffer, PATH_MAX + 1, "%s%0*d", filename, max_chars, cnt) > PATH_MAX)
+ if (nd_snprintf(buffer, PATH_MAX + 1, "%s%0*d", filename, max_chars, cnt) > PATH_MAX)
/* Report an error if the filename is too large */
error("too many output files or filename is too long (> %d)", PATH_MAX);
free(filename);
* Copy arg vector into a new buffer, concatenating arguments with spaces.
*/
static char *
-copy_argv(register char **argv)
+copy_argv(char **argv)
{
- register char **p;
- register u_int len = 0;
+ char **p;
+ u_int len = 0;
char *buf;
char *src, *dst;
static char *
read_infile(char *fname)
{
- register int i, fd, cc;
- register char *cp;
+ int i, fd, cc;
+ char *cp;
struct stat buf;
fd = open(fname, O_RDONLY|O_BINARY);
/*
* Return an error for our caller to handle.
*/
- snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s: %s\n(%s)",
+ nd_snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s: %s\n(%s)",
device, pcap_statustostr(status), cp);
pcap_close(pc);
return (NULL);
char sysctl[32];
size_t s = sizeof(parent);
- snprintf(sysctl, sizeof(sysctl),
+ nd_snprintf(sysctl, sizeof(sysctl),
"net.wlan.%d.%%parent", atoi(device + 4));
sysctlbyname(sysctl, parent, &s, NULL, 0);
strlcpy(newdev, device, sizeof(newdev));
int
main(int argc, char **argv)
{
- register int cnt, op, i;
+ int cnt, op, i;
bpf_u_int32 localnet = 0, netmask = 0;
int timezone_offset = 0;
- register char *cp, *infile, *cmdbuf, *device, *RFileName, *VFileName, *WFileName;
+ char *cp, *infile, *cmdbuf, *device, *RFileName, *VFileName, *WFileName;
char *endp;
pcap_handler callback;
int dlt;
/*
* Initialize the netdissect code.
*/
- if (nd_init(ebuf, sizeof ebuf) == -1)
+ if (nd_init(ebuf, sizeof(ebuf)) == -1)
error("%s", ebuf);
memset(ndo, 0, sizeof(*ndo));
else
ndo->program_name = program_name = argv[0];
-#ifdef _WIN32
+#if defined(HAVE_PCAP_WSOCKINIT)
if (pcap_wsockinit() != 0)
error("Attempting to initialize Winsock failed");
-#endif /* _WIN32 */
+#elif defined(HAVE_WSOCKINIT)
+ if (wsockinit() != 0)
+ error("Attempting to initialize Winsock failed");
+#endif
/*
* On platforms where the CPU doesn't support unaligned loads,
case 'm':
if (nd_have_smi_support()) {
- if (nd_load_smi_module(optarg, ebuf, sizeof ebuf) == -1)
+ if (nd_load_smi_module(optarg, ebuf, sizeof(ebuf)) == -1)
error("%s", ebuf);
} else {
(void)fprintf(stderr, "%s: ignoring option `-m %s' ",
#endif /* HAVE_FORK && HAVE_VFORK */
static void
-info(register int verbose)
+info(int verbose)
{
struct pcap_stat stats;