From d4e385dd0e633525666bf95c56a2045bacc2a485 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Tue, 9 Jul 2013 20:16:40 +0200 Subject: configure: fix multiple issues in build configuration This patch is a bundle of multiple fixes. 1) Fix compilation of astraceroute when HAVE_LIBPCAP=1: astraceroute doesn't need libpcap, so add an additional guard/define to bpf.h and bpf_comp.c and netsniff-ng.c. Also since we generate a config.h file, we do not need to have this additional compile flag anymore. 2) Fix tstamping.{h,c} to use the configure script instead of the Makefile. For doing this, also fix the object inclusion in netsniff-ng/Makefile. Last but not least, rename __WITH_... into HAVE_... as this is more clean. Signed-off-by: Daniel Borkmann --- configure | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) (limited to 'configure') diff --git a/configure b/configure index 7998572..120d5bf 100755 --- a/configure +++ b/configure @@ -12,6 +12,9 @@ MISSING_NACL=0 TOOLS="netsniff-ng trafgen astraceroute flowtop ifpps bpfc curvetun mausezahn" TOOLS_NOBUILD="" +HAVE_LIBPCAP=0 +HAVE_HWTSTAMP=0 + [ -z $CC ] && CC=cc TMPDIR=$(mktemp -d config.XXXXXX) @@ -369,6 +372,55 @@ EOF else echo "[YES]" echo "CONFIG_LIBPCAP=1" >> Config + HAVE_LIBPCAP=1 + fi +} + +check_hwtstamp() +{ + echo -n "[*] Checking hw timestamping ... " + + cat > $TMPDIR/hwtstest.c << EOF +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void main(void) +{ + int timesource = SOF_TIMESTAMPING_RAW_HARDWARE, ret; + int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); + struct hwtstamp_config hwconfig; + struct ifreq ifr; + + memset(&hwconfig, 0, sizeof(hwconfig)); + hwconfig.tx_type = HWTSTAMP_TX_OFF; + hwconfig.rx_filter = HWTSTAMP_FILTER_ALL; + + memset(&ifr, 0, sizeof(ifr)); + strncpy(ifr.ifr_name, "lo", sizeof(ifr.ifr_name)); + ifr.ifr_data = &hwconfig; + + ioctl(sock, SIOCSHWTSTAMP, &ifr); + setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, ×ource, + sizeof(timesource)); +} +EOF + + $CC -o $TMPDIR/hwtstest $TMPDIR/hwtstest.c >> $TMPDIR/config.log 2>&1 + if [ ! -x $TMPDIR/hwtstest ] ; then + echo "[NO]" + echo "CONFIG_HWTSTAMP=0" >> Config + else + echo "[YES]" + echo "CONFIG_HWTSTAMP=1" >> Config + HAVE_HWTSTAMP=1 fi } @@ -422,8 +474,19 @@ EOF gen_config_hdr() { local _version="`git describe --always`" + local _have_libpcap="" + local _have_hwts="" + echo "[*] Generating config.h ... " + if [ "$HAVE_LIBPCAP" == "1" ] ; then + _have_libpcap="#define HAVE_TCPDUMP_LIKE_FILTER 1" + fi + + if [ "$HAVE_HWTSTAMP" == "1" ] ; then + _have_hwts="#define HAVE_HARDWARE_TIMESTAMPING 1" + fi + cat > config.h << EOF #ifndef CONFIG_H #define CONFIG_H @@ -433,6 +496,8 @@ gen_config_hdr() #define FILE_PUBKEY ".curvetun/pub.key" #define FILE_USERNAM ".curvetun/username" #define GITVERSION "$_version" +$_have_libpcap +$_have_hwts #endif /* CONFIG_H */ EOF } @@ -456,7 +521,7 @@ check_libgeoip check_zlib check_urcu check_libpcap -# mausezahn dependencies +check_hwtstamp check_libcli check_libnet -- cgit v1.2.3-54-g00ecf