Fix the configuration check for remote-capture support in libpcap.

In autotools, if we find pcap_open(), define HAVE_PCAP_REMOTE, so we
build the remote capture support.

In both autotools and CMake, only check for pcap_setsampling() if we
have pcap_open(), as the compile fails if we have pcap_setsampling() but
don't have remote capture.

Change-Id: I0e7b78a2d372ea658a19ed2f6493532928c36872
Reviewed-on: https://code.wireshark.org/review/24680
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2017-12-02 22:23:39 -08:00
parent 0455040c0e
commit 40fc796818
2 changed files with 48 additions and 2 deletions

View File

@ -309,7 +309,34 @@ and did you also install that package?]])
# Check whether various variables and functions are defined by
# libpcap.
#
AC_CHECK_FUNCS(pcap_open_dead pcap_freecode pcap_open pcap_setsampling)
AC_CHECK_FUNCS(pcap_open_dead pcap_freecode)
AC_CHECK_FUNCS(pcap_open)
if test $ac_cv_func_pcap_open = "yes" ; then
AC_DEFINE(HAVE_PCAP_REMOTE, 1,
[Define to 1 if you have libpcap/WinPcap remote capturing support])
#
# XXX - this *should* be checked for independently of checking
# for pcap_open(), as you might have pcap_setsampling() without
# remote capture support.
#
# However, 1) the sampling options are treated as remote options
# in the GUI and and 2) having pcap_setsampling() doesn't mean
# you have sampling support. libpcap needs a way to indicate
# whether a given device supports sampling, and the GUI should
# be changed to decouple them.
#
# (Actually, libpcap needs a general mechanism to offer options
# for particular devices, and Wireshark needs to use that
# mechanism. The former is a work in progress.)
#
# (Note: another work in progress is support for remote
# capturing using pcap_create()/pcap_activate(), which we
# also need to support once it's available.)
#
AC_CHECK_FUNCS(pcap_setsampling)
fi
#
# pcap_breakloop may be present in the library but not declared
# in the pcap.h header file. If it's not declared in the header

View File

@ -83,13 +83,32 @@ if( PCAP_FOUND )
check_function_exists( "pcap_list_datalinks" HAVE_PCAP_LIST_DATALINKS )
check_function_exists( "pcap_set_datalink" HAVE_PCAP_SET_DATALINK )
check_function_exists( "bpf_image" HAVE_BPF_IMAGE )
check_function_exists( "pcap_setsampling" HAVE_PCAP_SETSAMPLING )
check_function_exists( "pcap_set_tstamp_precision" HAVE_PCAP_SET_TSTAMP_PRECISION )
check_function_exists( "pcap_set_tstamp_type" HAVE_PCAP_SET_TSTAMP_TYPE )
# Remote pcap checks
check_function_exists( "pcap_open" HAVE_PCAP_OPEN )
if( HAVE_PCAP_OPEN )
set( HAVE_PCAP_REMOTE 1 )
#
# XXX - this *should* be checked for independently of checking
# for pcap_open(), as you might have pcap_setsampling() without
# remote capture support.
#
# However, 1) the sampling options are treated as remote options
# in the GUI and and 2) having pcap_setsampling() doesn't mean
# you have sampling support. libpcap needs a way to indicate
# whether a given device supports sampling, and the GUI should
# be changed to decouple them.
#
# (Actually, libpcap needs a general mechanism to offer options
# for particular devices, and Wireshark needs to use that
# mechanism. The former is a work in progress.)
#
# (Note: another work in progress is support for remote
# capturing using pcap_create()/pcap_activate(), which we
# also need to support once it's available.)
#
check_function_exists( "pcap_setsampling" HAVE_PCAP_SETSAMPLING )
endif()
cmake_pop_check_state()