summaryrefslogtreecommitdiffstats
path: root/contrib/tcpdump/tcpdump.c
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2016-06-14 14:40:19 -0500
committerRenato Botelho <renato@netgate.com>2016-06-14 14:40:19 -0500
commit20a32898b6944f9ebcdbb846253d812943036066 (patch)
tree2d3bb1c4acf6d65a66c132d4c59643a3e99dfe34 /contrib/tcpdump/tcpdump.c
parent4fdb7654ef71cc3e4f0353cc46f28f652cd35605 (diff)
parenta048478c507785f68e86db1a32431aa36773ee06 (diff)
downloadFreeBSD-src-20a32898b6944f9ebcdbb846253d812943036066.zip
FreeBSD-src-20a32898b6944f9ebcdbb846253d812943036066.tar.gz
Merge remote-tracking branch 'origin/master' into devel-11
Diffstat (limited to 'contrib/tcpdump/tcpdump.c')
-rw-r--r--contrib/tcpdump/tcpdump.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/contrib/tcpdump/tcpdump.c b/contrib/tcpdump/tcpdump.c
index ce88d59..0939896 100644
--- a/contrib/tcpdump/tcpdump.c
+++ b/contrib/tcpdump/tcpdump.c
@@ -86,8 +86,9 @@ extern int SIZE_BUF;
#ifdef __FreeBSD__
#include <sys/capsicum.h>
#include <sys/sysctl.h>
+#include <libgen.h>
#endif /* __FreeBSD__ */
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
#include <libcasper.h>
#include <casper/cap_dns.h>
#include <sys/nv.h>
@@ -95,8 +96,7 @@ extern int SIZE_BUF;
#include <sys/ioccom.h>
#include <net/bpf.h>
#include <fcntl.h>
-#include <libgen.h>
-#endif /* HAVE_CAPSPER */
+#endif /* HAVE_CASPER */
#include <pcap.h>
#include <signal.h>
#include <stdio.h>
@@ -160,7 +160,7 @@ static int infoprint;
char *program_name;
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
cap_channel_t *capdns;
#endif
@@ -487,7 +487,7 @@ struct dump_info {
char *CurrentFileName;
pcap_t *pd;
pcap_dumper_t *p;
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
int dirfd;
#endif
};
@@ -911,7 +911,7 @@ get_next_file(FILE *VFile, char *ptr)
return ret;
}
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
static cap_channel_t *
capdns_setup(void)
{
@@ -938,7 +938,7 @@ capdns_setup(void)
return (capdnsloc);
}
-#endif /* HAVE_CAPSPER */
+#endif /* HAVE_CASPER */
#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
static int
@@ -970,7 +970,7 @@ tstamp_precision_to_string(int precision)
}
#endif
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
/*
* Ensure that, on a dump file's descriptor, we have all the rights
* necessary to make the standard I/O library work with an fdopen()ed
@@ -1070,9 +1070,9 @@ main(int argc, char **argv)
#endif
int status;
FILE *VFile;
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
cap_rights_t rights;
-#endif /* HAVE_CAPSPER */
+#endif /* !__FreeBSD__ */
int cansandbox;
#ifdef WIN32
@@ -1613,7 +1613,7 @@ main(int argc, char **argv)
if (pd == NULL)
error("%s", ebuf);
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
cap_rights_init(&rights, CAP_READ);
if (cap_rights_limit(fileno(pcap_file(pd)), &rights) < 0 &&
errno != ENOSYS) {
@@ -1850,10 +1850,10 @@ main(int argc, char **argv)
exit(0);
}
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
if (!nflag)
capdns = capdns_setup();
-#endif /* HAVE_CAPSPER */
+#endif /* HAVE_CASPER */
init_addrtoname(gndo, localnet, netmask);
init_checksum();
@@ -1921,7 +1921,7 @@ main(int argc, char **argv)
if (pcap_setfilter(pd, &fcode) < 0)
error("%s", pcap_geterr(pd));
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
if (RFileName == NULL && VFileName == NULL) {
static const unsigned long cmds[] = { BIOCGSTATS };
@@ -1971,11 +1971,11 @@ main(int argc, char **argv)
#endif /* HAVE_LIBCAP_NG */
if (p == NULL)
error("%s", pcap_geterr(pd));
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
set_dumper_capsicum_rights(p);
#endif
if (Cflag != 0 || Gflag != 0) {
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
dumpinfo.WFileName = strdup(basename(WFileName));
dumpinfo.dirfd = open(dirname(WFileName),
O_DIRECTORY | O_RDONLY);
@@ -1993,7 +1993,7 @@ main(int argc, char **argv)
errno != ENOSYS) {
error("unable to limit dump descriptor fcntls");
}
-#else /* !HAVE_CAPSPER */
+#else /* !__FreeBSD__ */
dumpinfo.WFileName = WFileName;
#endif
callback = dump_packet_and_trunc;
@@ -2069,7 +2069,7 @@ main(int argc, char **argv)
#ifdef __FreeBSD__
cansandbox = (VFileName == NULL && zflag == NULL);
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
cansandbox = (cansandbox && (nflag || capdns != NULL));
#else
cansandbox = (cansandbox && nflag);
@@ -2125,7 +2125,7 @@ main(int argc, char **argv)
pd = pcap_open_offline(RFileName, ebuf);
if (pd == NULL)
error("%s", ebuf);
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
cap_rights_init(&rights, CAP_READ);
if (cap_rights_limit(fileno(pcap_file(pd)),
&rights) < 0 && errno != ENOSYS) {
@@ -2328,7 +2328,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
/* If the time is greater than the specified window, rotate */
if (t - Gflag_time >= Gflag) {
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
FILE *fp;
int fd;
#endif
@@ -2386,7 +2386,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
capng_apply(CAPNG_SELECT_BOTH);
#endif /* HAVE_LIBCAP_NG */
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
fd = openat(dump_info->dirfd,
dump_info->CurrentFileName,
O_CREAT | O_WRONLY | O_TRUNC, 0644);
@@ -2400,7 +2400,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
dump_info->CurrentFileName);
}
dump_info->p = pcap_dump_fopen(dump_info->pd, fp);
-#else /* !HAVE_CAPSPER */
+#else /* !__FreeBSD__ */
dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName);
#endif
#ifdef HAVE_LIBCAP_NG
@@ -2409,7 +2409,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
#endif /* HAVE_LIBCAP_NG */
if (dump_info->p == NULL)
error("%s", pcap_geterr(pd));
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
set_dumper_capsicum_rights(dump_info->p);
#endif
}
@@ -2426,7 +2426,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
if (size == -1)
error("ftell fails on output file");
if (size > Cflag) {
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
FILE *fp;
int fd;
#endif
@@ -2458,7 +2458,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
capng_apply(CAPNG_SELECT_BOTH);
#endif /* HAVE_LIBCAP_NG */
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
fd = openat(dump_info->dirfd, dump_info->CurrentFileName,
O_CREAT | O_WRONLY | O_TRUNC, 0644);
if (fd < 0) {
@@ -2471,7 +2471,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
dump_info->CurrentFileName);
}
dump_info->p = pcap_dump_fopen(dump_info->pd, fp);
-#else /* !HAVE_CAPSPER */
+#else /* !__FreeBSD__ */
dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName);
#endif
#ifdef HAVE_LIBCAP_NG
@@ -2480,7 +2480,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
#endif /* HAVE_LIBCAP_NG */
if (dump_info->p == NULL)
error("%s", pcap_geterr(pd));
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
set_dumper_capsicum_rights(dump_info->p);
#endif
}
OpenPOWER on IntegriCloud