From: Guy Harris Date: Wed, 4 Oct 2017 01:22:29 +0000 (-0700) Subject: Call the flag to enable remote capture ENABLE_REMOTE. X-Git-Tag: libpcap-1.9-bp~544 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/b486381387dd0ebc800fac5a8ed6676d6103ed82 Call the flag to enable remote capture ENABLE_REMOTE. HAVE_REMOTE implies that there's some feature in our build environment that we have, but this is a flag that controls what the user specified at configuration time. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 80f1736b..9b7db9c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,9 +49,9 @@ set(PCAP_TYPE "" CACHE STRING "Packet capture type") # not having it on UN*X. # if(WIN32) - option(HAVE_REMOTE "Enable remote capture" ON) + option(ENABLE_REMOTE "Enable remote capture" ON) else() - option(HAVE_REMOTE "Enable remote capture" OFF) + option(ENABLE_REMOTE "Enable remote capture" OFF) endif(WIN32) if(CMAKE_SYSTEM_NAME STREQUAL "Linux") @@ -477,10 +477,10 @@ else() endif(NOT HAVE_STRTOK_R) endif(WIN32) -if(HAVE_REMOTE) +if(ENABLE_REMOTE) set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c) -endif(HAVE_REMOTE) +endif(ENABLE_REMOTE) # # Determine the main pcap-XXX.c file to use, and the libraries with diff --git a/Win32/Prj/wpcap.vcxproj b/Win32/Prj/wpcap.vcxproj index 061ff591..2bd30a5f 100644 --- a/Win32/Prj/wpcap.vcxproj +++ b/Win32/Prj/wpcap.vcxproj @@ -100,7 +100,7 @@ true Level3 ../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories) - HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) + HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) 0x0409 @@ -125,7 +125,7 @@ win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.ytrue Level3 ../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories) - HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) + HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) 0x0409 @@ -151,7 +151,7 @@ win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.ytrue EditAndContinue ../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories) - HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;_DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) + HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;_DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) EnableFastChecks @@ -177,7 +177,7 @@ win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.yLevel3 ProgramDatabase ../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories) - HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;_DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) + HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;_DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) EnableFastChecks @@ -230,4 +230,4 @@ win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y - \ No newline at end of file + diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in index bbae90d1..830c6aec 100644 --- a/cmakeconfig.h.in +++ b/cmakeconfig.h.in @@ -130,7 +130,7 @@ #cmakedefine HAVE_PF_NAT_THROUGH_PF_NORDR 1 /* Define to 1 if remote packet capture is to be supported */ -#cmakedefine HAVE_REMOTE 1 +#cmakedefine ENABLE_REMOTE 1 /* define if you have the Septel API */ #cmakedefine HAVE_SEPTEL_API 1 diff --git a/config.h.in b/config.h.in index 2101737b..827e55b7 100644 --- a/config.h.in +++ b/config.h.in @@ -6,6 +6,9 @@ /* Enable optimizer debugging */ #undef BDEBUG +/* Define to 1 if remote packet capture is to be supported */ +#undef ENABLE_REMOTE + /* define if you have the DAG API */ #undef HAVE_DAG_API @@ -132,9 +135,6 @@ /* define if net/pfvar.h defines PF_NAT through PF_NORDR */ #undef HAVE_PF_NAT_THROUGH_PF_NORDR -/* Define to 1 if remote packet capture is to be supported */ -#undef HAVE_REMOTE - /* define if you have the Septel API */ #undef HAVE_SEPTEL_API diff --git a/configure b/configure index 7de59d30..f256ddd4 100755 --- a/configure +++ b/configure @@ -7237,7 +7237,7 @@ $as_echo "$as_me: WARNING: Remote packet capture may expose libpcap-based applic { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: to attacks by malicious remote capture servers!" >&5 $as_echo "$as_me: WARNING: to attacks by malicious remote capture servers!" >&2;} -$as_echo "#define HAVE_REMOTE /**/" >>confdefs.h +$as_echo "#define ENABLE_REMOTE /**/" >>confdefs.h SSRC="$SSRC pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c" RPCAPD=rpcapd diff --git a/configure.ac b/configure.ac index 0c2b87e8..3e7b67fc 100644 --- a/configure.ac +++ b/configure.ac @@ -1224,7 +1224,7 @@ case "$enableval" in yes) AC_MSG_RESULT(yes) AC_WARN([Remote packet capture may expose libpcap-based applications]) AC_WARN([to attacks by malicious remote capture servers!]) - AC_DEFINE(HAVE_REMOTE,, + AC_DEFINE(ENABLE_REMOTE,, [Define to 1 if remote packet capture is to be supported]) SSRC="$SSRC pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c" RPCAPD=rpcapd diff --git a/gencode.c b/gencode.c index a3dc35a2..8aa69cf4 100644 --- a/gencode.c +++ b/gencode.c @@ -683,7 +683,7 @@ pcap_compile(pcap_t *p, struct bpf_program *program, done = 1; #endif -#ifdef HAVE_REMOTE +#ifdef ENABLE_REMOTE /* * If the device on which we're capturing need to be notified * that a new filter is being compiled, do so. diff --git a/pcap-int.h b/pcap-int.h index 6406aa65..9e8283e9 100644 --- a/pcap-int.h +++ b/pcap-int.h @@ -165,7 +165,7 @@ struct pcap { void *priv; /* private data for methods */ -#ifdef HAVE_REMOTE +#ifdef ENABLE_REMOTE struct pcap_samp rmt_samp; /* parameters related to the sampling process. */ #endif diff --git a/pcap-npf.c b/pcap-npf.c index 520d61f5..8ade6f1b 100644 --- a/pcap-npf.c +++ b/pcap-npf.c @@ -78,7 +78,7 @@ struct pcap_win { int dag_fcs_bits; /* Number of checksum bits from link layer */ #endif -#ifdef HAVE_REMOTE +#ifdef ENABLE_REMOTE int samp_npkt; /* parameter needed for sampling, with '1 out of N' method has been requested */ struct timeval samp_time; /* parameter needed for sampling, with '1 every N ms' method has been requested */ #endif @@ -210,7 +210,7 @@ pcap_stats_ex_win32(pcap_t *p, int *pcap_stat_size) p->stat.ps_recv = bstats.bs_recv; p->stat.ps_drop = bstats.bs_drop; p->stat.ps_ifdrop = bstats.ps_ifdrop; -#ifdef HAVE_REMOTE +#ifdef ENABLE_REMOTE p->stat.ps_capt = bstats.bs_capt; #endif return (&p->stat); @@ -565,7 +565,7 @@ pcap_read_win32_npf(pcap_t *p, int cnt, pcap_handler callback, u_char *user) if (pw->filtering_in_kernel || p->fcode.bf_insns == NULL || bpf_filter(p->fcode.bf_insns, datap, bhp->bh_datalen, caplen)) { -#ifdef HAVE_REMOTE +#ifdef ENABLE_REMOTE switch (p->rmt_samp.method) { case PCAP_SAMP_1_EVERY_N: @@ -604,7 +604,7 @@ pcap_read_win32_npf(pcap_t *p, int cnt, pcap_handler callback, u_char *user) } } } -#endif /* HAVE_REMOTE */ +#endif /* ENABLE_REMOTE */ /* * XXX A bpf_hdr matches a pcap_pkthdr. diff --git a/pcap-rpcap.c b/pcap-rpcap.c index 5aa699c7..3f5076c7 100644 --- a/pcap-rpcap.c +++ b/pcap-rpcap.c @@ -734,14 +734,14 @@ static struct pcap_stat *rpcap_stats_rpcap(pcap_t *p, struct pcap_stat *ps, int ps->ps_drop = 0; ps->ps_ifdrop = 0; ps->ps_recv = 0; -#if defined(_WIN32) && defined(HAVE_REMOTE) +#if defined(_WIN32) && defined(ENABLE_REMOTE) if (mode == PCAP_STATS_EX) { ps->ps_capt = 0; ps->ps_sent = 0; ps->ps_netdrop = 0; } -#endif /* _WIN32 && HAVE_REMOTE */ +#endif /* _WIN32 && ENABLE_REMOTE */ return ps; } @@ -791,14 +791,14 @@ static struct pcap_stat *rpcap_stats_rpcap(pcap_t *p, struct pcap_stat *ps, int ps->ps_drop = ntohl(netstats.krnldrop); ps->ps_ifdrop = ntohl(netstats.ifdrop); ps->ps_recv = ntohl(netstats.ifrecv); -#if defined(_WIN32) && defined(HAVE_REMOTE) +#if defined(_WIN32) && defined(ENABLE_REMOTE) if (mode == PCAP_STATS_EX) { ps->ps_capt = pr->TotCapt; ps->ps_netdrop = pr->TotNetDrops; ps->ps_sent = ntohl(netstats.svrcapt); } -#endif /* _WIN32 && HAVE_REMOTE */ +#endif /* _WIN32 && ENABLE_REMOTE */ /* Checks if all the data has been read; if not, discard the data in excess */ if (totread != ntohl(header.plen)) diff --git a/pcap-tc.c b/pcap-tc.c index db91e579..67584efa 100644 --- a/pcap-tc.c +++ b/pcap-tc.c @@ -1106,7 +1106,7 @@ TcStats(pcap_t *p, struct pcap_stat *ps) s.ps_drop = 0xFFFFFFFF; } -#if defined(_WIN32) && defined(HAVE_REMOTE) +#if defined(_WIN32) && defined(ENABLE_REMOTE) s.ps_capt = pt->TcAcceptedCount; #endif *ps = s; @@ -1191,7 +1191,7 @@ TcStatsEx(pcap_t *p, int *pcap_stat_size) p->stat.ps_drop = 0xFFFFFFFF; } -#if defined(_WIN32) && defined(HAVE_REMOTE) +#if defined(_WIN32) && defined(ENABLE_REMOTE) p->stat.ps_capt = pt->TcAcceptedCount; #endif diff --git a/pcap.c b/pcap.c index bddb36fd..fb65c9db 100644 --- a/pcap.c +++ b/pcap.c @@ -1334,7 +1334,7 @@ pcap_lookupnet(device, netp, maskp, errbuf) } #endif /* !defined(_WIN32) && !defined(MSDOS) */ -#ifdef HAVE_REMOTE +#ifdef ENABLE_REMOTE #include "pcap-rpcap.h" /* @@ -2355,7 +2355,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, char *er { pcap_t *p; int status; -#ifdef HAVE_REMOTE +#ifdef ENABLE_REMOTE char host[PCAP_BUF_SIZE + 1]; char port[PCAP_BUF_SIZE + 1]; char name[PCAP_BUF_SIZE + 1]; @@ -2401,7 +2401,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, char *er device += strlen(PCAP_SRC_IF_STRING); } } -#endif /* HAVE_REMOTE */ +#endif /* ENABLE_REMOTE */ p = pcap_create(device, errbuf); if (p == NULL) diff --git a/tests/findalldevstest.c b/tests/findalldevstest.c index e7f3caab..2e79fcc6 100644 --- a/tests/findalldevstest.c +++ b/tests/findalldevstest.c @@ -103,14 +103,14 @@ int main(int argc, char **argv) bpf_u_int32 net, mask; int exit_status = 0; char errbuf[PCAP_ERRBUF_SIZE+1]; -#ifdef HAVE_REMOTE +#ifdef ENABLE_REMOTE struct pcap_rmtauth auth; char username[128+1]; char *p; char *password; #endif -#ifdef HAVE_REMOTE +#ifdef ENABLE_REMOTE if (argc >= 2) { if (pcap_findalldevs_ex(argv[1], NULL, &alldevs, errbuf) == -1)