1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168 |
- dnl $Id: configure.ac 1954 2008-01-17 06:10:31Z aturner $
- AC_INIT(tcpreplay)
- AC_CONFIG_SRCDIR(src/tcpreplay.c)
- AM_CONFIG_HEADER(src/config.h)
- AC_CONFIG_AUX_DIR(config)
- AM_MAINTAINER_MODE
- AM_WITH_DMALLOC
- dnl Set version info here!
- MAJOR_VERSION=3
- MINOR_VERSION=2
- MICRO_VERSION=4
- TCPREPLAY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
- dnl Release is only used for the RPM spec file
- TCPREPLAY_RELEASE=1
- AC_DEFINE(PACKAGE, [tcpreplay], [This is our package name])
- AC_DEFINE_UNQUOTED(VERSION, "$TCPREPLAY_VERSION", [What is our version?])
- AC_SUBST(TCPREPLAY_VERSION)
- AC_SUBST(TCPREPLAY_RELEASE)
- USER_CFLAGS=$CFLAGS
- CFLAGS="${CFLAGS} -Wall -O3 -std=gnu99"
- dnl Determine OS
- AC_CANONICAL_BUILD
- AC_CANONICAL_HOST
- AC_CANONICAL_TARGET
- AC_SUBST(host)
- AC_SUBST(build)
- AC_SUBST(target)
- AC_MSG_CHECKING([for cygwin development environment])
- if test `echo $target | grep -c cygwin` -gt 0 ; then
- AC_DEFINE([HAVE_WIN32], [1], [Windows/Cygwin])
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
- AM_INIT_AUTOMAKE(tcpreplay, $TCPREPLAY_VERSION, nodefine)
- dnl Checks for programs.
- AC_PROG_INSTALL
- AC_PROG_LIBTOOL
- AC_PROG_CC
- AC_PROG_CC_STDC
- AC_PROG_CXX
- AC_PROG_CPP
- AC_PROG_LN_S
- AC_PROG_RANLIB
- AC_PROG_AWK
- AC_PROG_SED
- AC_PROG_MAKE_SET
- AC_EXEEXT
- AC_PATH_PROG(PRINTF, printf)
- AC_PATH_PROG(AUTOGEN, autogen)
- AC_PATH_PROG(ECHO, echo)
- dnl check autogen version
- if test -n "${AUTOGEN}" ; then
- AC_MSG_CHECKING(for autogen version >= 5.9)
- AUTOGEN_VERSION=`${AUTOGEN} -v | ${SED} 's|.*\([[0-9\.]]\{3,\}\)$|\1|'`
- AUTOGEN_MAJOR=`echo ${AUTOGEN_VERSION} | ${SED} 's|^\([[0-9]]\)\.[[0-9]]|\1|'`
- AUTOGEN_MINOR=`echo ${AUTOGEN_VERSION} | ${SED} 's|^\([[0-9]]\)\.\([[0-9]]\)|\2|'`
- if test ${AUTOGEN_MAJOR} -le 5 && test ${AUTOGEN_MINOR} -lt 9 || test ${AUTOGEN_MAJOR} -lt 5 ; then
- AC_MSG_RESULT(no)
- AC_MSG_WARN([${AUTOGEN} is too old (${AUTOGEN_VERSION}) for building from SVN. Please upgrade to 5.9)])
- else
- AC_MSG_RESULT(yes)
- fi
- else
- AC_MSG_WARN([Please install autogen >= 5.9 if you are building from SVN])
- fi
- AC_HEADER_STDC
- AC_HEADER_MAJOR
- dnl Checks for typedefs, structures, and compiler characteristics.
- AC_TYPE_SIZE_T
- AC_HEADER_TIME
- AC_C_CONST
- AC_C_INLINE
- AC_SYS_LARGEFILE
- dnl Check for functions
- AC_FUNC_FSEEKO
- dnl Check for types.
- AC_CHECK_TYPE(u_int8_t, uint8_t)
- AC_CHECK_TYPE(u_int16_t, uint16_t)
- AC_CHECK_TYPE(u_int32_t, uint32_t)
- AC_CHECK_TYPE(u_int64_t, uint64_t)
- dnl Older versions of GCC don't support these options
- AC_MSG_CHECKING(for $CC -Wextra support)
- OLD_CFLAGS=$CFLAGS
- CFLAGS="$CFLAGS -Wextra"
- wextra=""
- AC_COMPILE_IFELSE([#include <stdlib.h>
- int main(int argc, char *argv[]) { return(0); }],
- [ AC_MSG_RESULT(yes)
- wextra="-Wextra" ],
- [ AC_MSG_RESULT(no) ])
- CFLAGS="$OLD_CFLAGS $wextra"
- AC_MSG_CHECKING(for $CC -Wno-variadic-macros support)
- OLD_CFLAGS=$CFLAGS
- CFLAGS="$CFLAGS -Wno-variadic-macros"
- wno_variadic_macros=""
- AC_COMPILE_IFELSE([#include <stdlib.h>
- int main(int argc, char *argv[]) { return(0); }],
- [ AC_MSG_RESULT(yes)
- wno_variadic_macros="-Wno-variadic-macros" ],
- [ AC_MSG_RESULT(no) ])
- CFLAGS="$OLD_CFLAGS $wno_variadic_macros"
- AC_MSG_CHECKING(for $CC -Wfatal-errors support)
- OLD_CFLAGS=$CFLAGS
- CFLAGS="$CFLAGS -Wfatal-errors"
- wfatal_errors=""
- AC_COMPILE_IFELSE([#include <stdlib.h>
- int main(int argc, char *argv[]) { return(0); }],
- [ AC_MSG_RESULT(yes)
- wfatal_errors="-Wfatal-errors" ],
- [ AC_MSG_RESULT(no) ])
- CFLAGS="$OLD_CFLAGS $wfatal_errors"
- dnl Check for other header files
- AC_CHECK_HEADERS([fcntl.h stddef.h sys/socket.h arpa/inet.h sys/time.h signal.h string.h strings.h sys/types.h sys/select.h netinet/in.h poll.h sys/poll.h unistd.h sys/param.h])
- dnl OpenBSD has special requirements
- AC_CHECK_HEADERS([sys/sysctl.h net/route.h], [], [], [
- [#if HAVE_SYS_PARAM_H
- #include <sys/param.h>
- #endif
- #if HAVE_SYS_TYPES_H
- #include <sys/types.h>
- #endif
- #if HAVE_SYS_SOCKET_H
- #include <sys/socket.h>
- #endif
- ]])
- dnl Checks for libraries.
- AC_CHECK_LIB(socket, socket)
- AC_CHECK_LIB(nsl, gethostbyname)
- AC_CHECK_LIB(rt, nanosleep)
- AC_CHECK_LIB(resolv, resolv)
- dnl Checks for library functions.
- AC_FUNC_MALLOC
- AC_FUNC_MEMCMP
- AC_TYPE_SIGNAL
- AC_FUNC_VPRINTF
- AC_CHECK_MEMBERS([struct timeval.tv_sec])
- AC_CHECK_FUNCS([gettimeofday ctime memset regcomp strdup strchr strerror strtol strncpy strtoull poll ntohll mmap snprintf vsnprintf strsignal])
- dnl Look for strlcpy since some BSD's have it
- AC_CHECK_FUNCS([strlcpy],have_strlcpy=true,have_strlcpy=false)
- AM_CONDITIONAL(SYSTEM_STRLCPY, [test x$have_strlcpy = xtrue])
- AC_C_BIGENDIAN
- AM_CONDITIONAL([WORDS_BIGENDIAN], [ test x$ac_cv_c_bigendian = xyes ])
- dnl Enable debugging in code/compiler options
- debug=no
- AC_ARG_ENABLE(debug,
- AC_HELP_STRING([--enable-debug], [Enable debugging code and support for the -d option]),
- [ if test x$enableval = xyes; then
- debug=yes
- CFLAGS="${USER_CFLAGS} -ggdb -std=gnu99 -Wall $wextra $wfatal_errors $wno_variadic_macros"
- # We may also want to add:
- # -Wformat-security -Wswitch-default -Wunused-paramter -Wpadded"
- AC_SUBST(debug_flag)
- AC_DEFINE([DEBUG], [1], [Enable debuging code and support for the -d option])
- fi])
- AC_ARG_ENABLE(pedantic,
- AC_HELP_STRING([--enable-pedantic], [Enable gcc's -pedantic option]),
- [ if test x$enableval = xyes; then
- CFLAGS="$CFLAGS -pedantic"
- fi ])
- dnl Enable Efense
- AC_ARG_ENABLE(efence,
- AC_HELP_STRING([--enable-efence], [Enable Electric Fence memory debugger]),
- [ if test x$enableval = xyes; then
- CFLAGS="$CFLAGS -lefence"
- AC_DEFINE([EFENCE], [1], [Enable Electric Fence memory debugger])
- fi])
- dnl Enable Gprof
- AC_ARG_ENABLE(gprof,
- AC_HELP_STRING([--enable-gprof], [Enable GNU Profiler]),
- [ if test x$enableval = xyes; then
- if test $debug = yes; then
- CFLAGS="$CFLAGS -pg"
- else
- # GPROF requires gdb
- CFLAGS="$CFLAGS -ggdb -pg -fprofile-arcs"
- fi
- AC_DEFINE([GPROF], [1], [Enable GNU Profiler])
- fi])
- dnl Use 64bits for packet counters
- use64bit_counters=yes
- AC_ARG_ENABLE(64bits,
- AC_HELP_STRING([--disable-64bits], [Do not use 64bit packet counters]),
- [
- AC_MSG_NOTICE([Using u_int32_t for packet counters])
- ],
- [
- AC_DEFINE([ENABLE_64BITS], [1], [Use 64bit packet counters])
- AC_MSG_NOTICE([Using u_int64_t for packet counters])
- ])
- # If we're running gcc add '-D_U_="__attribute__((unused))"' to CFLAGS as well,
- # so we can use _U_ to flag unused function arguments and not get warnings
- # about them. Otherwise, add '-D_U_=""', so that _U_ used to flag an unused
- # function argument will compile with non-GCC compilers.
- #
- if test "x$GCC" = "xyes" ; then
- CFLAGS="-D_U_=\"__attribute__((unused))\" $CFLAGS"
- else
- CFLAGS="-D_U_=\"\" $CFLAGS"
- fi
- AC_ARG_ENABLE(force-bpf,
- AC_HELP_STRING([--enable-force-bpf], [Force using BPF for sending packets]),
- [ AC_DEFINE([FORCE_INJECT_BPF], [1], [Force using BPF for sending packet])])
- AC_ARG_ENABLE(force-pf,
- AC_HELP_STRING([--enable-force-pf], [Force using Linux's PF_PACKET for sending packets]),
- [ AC_DEFINE([FORCE_INJECT_PF], [1], [Force using Linux's PF_PACKET for sending packets])])
- AC_ARG_ENABLE(force-libnet,
- AC_HELP_STRING([--enable-force-libnet], [Force using libnet for sending packets]),
- [ AC_DEFINE([FORCE_INJECT_LIBNET], [1], [Force using libnet for sending packets])])
-
- AC_ARG_ENABLE(force-inject,
- AC_HELP_STRING([--enable-force-inject], [Force using libpcap's pcap_inject() for sending packets]),
- [ AC_DEFINE([FORCE_INJECT_PCAP_INJECT],[1], [Force using libpcap's pcap_inject() for sending packets])])
- AC_ARG_ENABLE(force-sendpacket,
- AC_HELP_STRING([--enable-force-sendpacket], [Force using libpcap's pcap_sendpacket() for sending packets]),
- [ AC_DEFINE([FORCE_INJECT_PCAP_SENDPACKET], [1], [Force using libpcap's pcap_sendpacket() for sending packets])])
- tcpreplay_edit=no
- AC_ARG_ENABLE(tcpreplay-edit,
- AC_HELP_STRING([--enable-tcpreplay-edit], [Link packet editing code with tcpreplay]),
- [ AC_DEFINE([TCPREPLAY_EDIT], [1], [Link packet editing code with tcpreplay])
- tcpreplay_edit=yes
- ])
- AM_CONDITIONAL([ENABLE_TCPREPLAY_EDIT], [test x$tcpreplay_edit = xyes])
- dnl Dynamic link libraries
- dynamic_link=no
- AC_ARG_ENABLE(dynamic-link,
- AC_HELP_STRING([--enable-dynamic-link], [Dynamically link libraries]),
- [ if test x$enableval = xyes; then
- AC_DEFINE([ENABLE_DYNAMIC_LINK], [1], [Enable dynamically linking libs])
- dynamic_link=yes
- fi
- ])
- dnl Check for inet_aton and inet_pton
- AC_CHECK_FUNC(inet_aton,
- AC_DEFINE([HAVE_INET_ATON], [1], [Do we have inet_aton?])
- inet_aton=yes,
- inet_aton=no)
- AC_CHECK_FUNC(inet_pton,
- AC_DEFINE([HAVE_INET_PTON], [1], [Do we have inet_pton?])
- inet_pton=yes,
- inet_pton=no)
- AC_CHECK_FUNC(inet_ntop,
- AC_DEFINE([HAVE_INET_NTOP], [1], [Do we have inet_ntop?])
- inet_ntop=yes,
- inet_ntop=no)
- if test "$inet_ntop" = "no" -a "$inet_pton" = "no" ; then
- AC_MSG_ERROR([We need either inet_ntop or inet_pton])
- fi
- AC_CHECK_FUNC(inet_addr,
- AC_DEFINE([HAVE_INET_ADDR], [1], [Do we have inet_addr?])
- inet_addr=yes,
- inet_addr=no)
- if test x$inet_addr = no ; then
- AC_MSG_ERROR([We need inet_addr. See bug 26])
- fi
- dnl ##################################################
- dnl Checks for libnet IFF you specify --enable-libnet.
- dnl We no longer by default use libnet unless you tell me to.
- dnl ##################################################
- foundnet=no
- trynetdir=no
- have_libnet=no
- use_libnet=no
- AC_ARG_ENABLE(libnet,
- AC_HELP_STRING([--enable-libnet], [Enable using the libnet 1.1.x library (deprecated)]),
- [ if test x$enableval = xyes; then
- use_libnet=yes
- AC_MSG_WARN([Due to bugs in libnet, it is no longer officially supported])
- fi]
- )
- AC_ARG_WITH(libnet,
- AC_HELP_STRING([--with-libnet=DIR], [Use libnet in DIR]),
- [trynetdir=$withval])
- if test x$use_libnet = xyes ; then
- AC_MSG_CHECKING(for libnet)
- for testdir in $trynetdir /usr/local /opt/local /usr ; do
- if test -f "${testdir}/include/libnet.h" -a $foundnet = no ; then
- LNETINC="${testdir}/include/libnet.h"
- LNETINCDIR="${testdir}/include"
- if test $dynamic_link = yes; then
- if test -f "${testdir}/lib64/libnet${shrext_cmds}" ; then
- LNETLIB="-L${testdir}/lib64 -lnet"
- elif test -f "${testdir}/lib/libnet${shrext_cmds}" ; then
- LNETLIB="-L${testdir}/lib -lnet"
- else
- AC_ERROR([Unable to find libnet in ${testdir}])
- fi
- elif test -f "${testdir}/lib64/libnet.${libext}" ; then
- LNETLIB="${testdir}/lib64/libnet.${libext}"
- elif test -f "${testdir}/lib/libnet.${libext}" ; then
- LNETLIB="${testdir}/lib/libnet.${libext}"
- else
- AC_ERROR([Unable to find matching library for header file in ${testdir}])
- fi
- foundnet=$testdir
- fi
- done
-
- if test x$foundnet = xno ; then
- AC_MSG_RESULT(no)
- else
- AC_MSG_RESULT($foundnet)
- have_libnet=yes
- AC_DEFINE([HAVE_LIBNET], [1], [Enable libnet support])
- fi
- fi
- AC_SUBST(LNETINC)
- AC_SUBST(LNETLIB)
- if test $foundnet != no ; then
- OLDLIBS="$LIBS"
- OLDCFLAGS="$CFLAGS"
- LIBS="$LNETLIB"
- CFLAGS="$CFLAGS -I$LNETINCDIR"
- dnl Check to see what version of libnet
- dnl this code has been reduced a lot, but probably still could be
- dnl reduced quite a bit more if we chose too
- AC_MSG_CHECKING(for libnet version)
- AC_TRY_RUN([
- #include <string.h>
- #define LIBNET_LIL_ENDIAN 1
- #include "$LNETINC"
- #define LIB_TEST "1.0"
- /*
- * simple proggy to test the version of libnet
- * returns zero if it's 1.0.x
- * or one otherwise
- */
- int
- main (int argc, char *argv[])
- {
- if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0)
- exit(0);
- exit(1);
- }],
- libnet_ver_10=yes
- AC_MSG_RESULT(1.0.x),
- libnet_ver_10=no,
- libnet_ver_10=no
- )
- AC_TRY_RUN([
- #include <string.h>
- #include "$LNETINC"
- #define LIB_TEST "1.1"
- /*
- * simple proggy to test the version of libnet
- * returns zero if it's 1.0.x
- * or one otherwise
- */
- int
- main (int argc, char *argv[])
- {
- if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0)
- exit(0);
- exit(1);
- }],
- libnet_ver_11=yes
- AC_MSG_RESULT(1.1.x),
- libnet_ver_11=no,
- libnet_ver_11=no
- )
- if test $libnet_ver_10 = no -a $libnet_ver_11 = no ; then
- AC_MSG_RESULT(unknown)
- AC_MSG_ERROR(Unable to determine version of libnet)
- fi
- if test $libnet_ver_10 = yes ; then
- AC_MSG_ERROR(Libnet version 1.0.x is no longer supported.
- Please upgrade to 1.1.0 or better)
- fi
- dnl restore LIBS & CFLAGS
- LIBS="$OLDLIBS"
- CFLAGS="$OLDCFLAGS"
- fi
- dnl END OF if test $foundnet = yes
- dnl #####################################################
- dnl Checks for libpcap
- dnl #####################################################
- foundpcap=no
- trypcapdir=/usr/local
- AC_MSG_CHECKING(for libpcap)
- AC_ARG_WITH(libpcap,
- AC_HELP_STRING([--with-libpcap=DIR], [Use libpcap in DIR]),
- [trypcapdir=$withval])
- for testdir in $trypcapdir /usr/local /opt/local /usr ; do
- if test -f "${testdir}/include/pcap.h" -a $foundpcap = no ; then
- LPCAPINC="${testdir}/include/pcap.h"
- LPCAPINCDIR="${testdir}/include"
- if test $dynamic_link = yes; then
- if test -f "${testdir}/lib64/libpcap${shrext_cmds}" ; then
- LPCAPLIB="-L${testdir}/lib64 -lpcap"
- elif test -f "${testdir}/lib/libpcap${shrext_cmds}" ; then
- LPCAPLIB="-L${testdir}/lib -lpcap"
- else
- AC_ERROR([Unable to find libpcap in ${testdir}])
- fi
- elif test -f "${testdir}/lib64/libpcap.${libext}" ; then
- LPCAPLIB="${testdir}/lib64/libpcap.${libext}"
- elif test -f "${testdir}/lib/libpcap.${libext}" ; then
- LPCAPLIB="${testdir}/lib/libpcap.${libext}"
- elif test -f "${testdir}/lib/libwpcap.${libext}" ; then
- LPCAPLIB="${testdir}/lib/libwpcap.${libext}"
- AC_DEFINE([HAVE_WINPCAP], [1], [Do we have WinPcap?])
- else
- AC_ERROR([Unable to find matching library for header file in ${testdir}])
- fi
- foundpcap=$testdir
- fi
- done
- if test $foundpcap = no ; then
- AC_MSG_RESULT(no)
- AC_ERROR(libpcap not found)
- else
- AC_MSG_RESULT($foundpcap)
- fi
- AC_SUBST(LPCAPINC)
- AC_SUBST(LPCAPLIB)
- dnl Checks to see what version of libpcap we've got
- OLDLIBS="$LIBS"
- OLDCFLAGS="$CFLAGS -I$LPCAPINCDIR"
- LIBS="$LPCAPLIB"
- CFLAGS="$CFLAGS -I$LPCAPINCDIR"
- dnl Check to see what version of libpcap
- dnl this code has been reduced a lot, but probably still could be
- dnl reduced quite a bit more if we chose too
- AC_MSG_CHECKING(for libpcap version)
- dnl 0.9.6 (which is still thinks it is 0.9.5 due to a bug) introduces an important
- dnl fix for OSX. See: http://tcpreplay.synfin.net/trac/ticket/167
- libpcap_version_096=no
- AC_RUN_IFELSE(AC_LANG_PROGRAM([[
- #include <string.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include "$LPCAPINC"
- #define PCAP_TEST "0.9.6"
- ]], [[
- /*
- * simple proggy to test the version of libpcap
- * returns zero if version >= 0.9.6
- * or one otherwise
- */
- if (strncmp(pcap_lib_version(), PCAP_TEST, 5) >= 0)
- exit(0);
- exit(1);
- ]]), [
- libpcap_version_096=yes
- ])
- AC_RUN_IFELSE(AC_LANG_PROGRAM([[
- #include <string.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include "$LPCAPINC"
- #define PCAP_TEST "0.8"
- ]], [[
- /*
- * simple proggy to test the version of libpcap
- * returns zero if version >= 0.8.0
- * or one otherwise
- */
- if (strncmp(pcap_lib_version(), PCAP_TEST, 3) >= 0)
- exit(0);
- /* winpcap? */
- if (strncmp(pcap_lib_version(), "WinPcap", 7) == 0)
- exit(0);
- exit(1);
- ]]), [
- libpcap_ver8=yes
- ], [
- libpcap_ver8=no
- ])
- AC_RUN_IFELSE(AC_LANG_PROGRAM([[
- #include <string.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include "$LPCAPINC"
- #define PCAP_TEST "0.7.2"
- extern const char pcap_version[[]]; /* double up since autoconf escapes things */
- ]], [[
- /*
- * simple proggy to test the version of libpcap
- * returns zero if version >= 0.7.2
- * or one otherwise
- */
- if (strncmp(pcap_version, PCAP_TEST, 5) >= 0)
- exit(0);
-
- exit(1);
- ]]), [
- libpcap_ver7=yes
- ], [
- libpcap_ver7=no
- ])
- if test $libpcap_ver8 = yes ; then
- AC_MSG_RESULT(>= 0.8.0)
- elif test $libpcap_ver7 = yes ; then
- AC_MSG_RESULT(>= 0.7.2)
- else
- AC_MSG_ERROR([Libpcap versions < 0.7.2 are not supported
- Please upgrade to version 0.7.2 or better])
- fi
- libpcap_version=unknown
- if test $libpcap_version_096 = yes ; then
- libpcap_version=">= 0.9.6"
- elif test $libpcap_ver8 = yes ; then
- libpcap_version=">= 0.8.0"
- elif test $libcap_ver7 = yes ; then
- libpcap_version=">= 0.7.0"
- fi
- dnl Check to see if we've got pcap_datalink_val_to_name()
- AC_MSG_CHECKING(for pcap_datalink_val_to_description)
- AC_LINK_IFELSE(AC_LANG_PROGRAM([[
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "$LPCAPINC"
- ]],[[
- if (strcmp(pcap_datalink_val_to_description(1), "Ethernet (10Mb)") == 0)
- exit(0);
- exit(1);
- ]]),[
- have_dlt_to_desc=yes
- AC_MSG_RESULT(yes)
- ], [
- have_dlt_to_desc=no
- AC_MSG_RESULT(no)
- ])
- if test $have_dlt_to_desc = yes ; then
- AC_DEFINE([HAVE_DLT_VAL_TO_DESC], [1],
- [Does libpcap have dlt_val_to_desc?])
- fi
- dnl Check to see if we've got pcap_dump_fopen()
- AC_MSG_CHECKING(for pcap_dump_fopen)
- AC_LINK_IFELSE(AC_LANG_PROGRAM([[
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "$LPCAPINC"
- ]],[[
- pcap_dumper_t *dump;
- pcap_t *pcap;
- FILE *foo;
- dump = pcap_dump_fopen(pcap, foo);
- ]]),[
- have_pcap_dump_fopen=yes
- AC_MSG_RESULT(yes)
- ], [
- have_pcap_dump_fopen=no
- AC_MSG_RESULT(no)
- ])
- if test $have_pcap_dump_fopen = yes ; then
- AC_DEFINE([HAVE_PCAP_DUMP_FOPEN], [1],
- [Does libpcap have pcap_dump_fopen?])
- else
- AC_MSG_NOTICE([--verbose mode requires libpcap >= 0.9.0])
- fi
- have_pcap_inject=no
- dnl Check to see if we've got pcap_inject()
- AC_MSG_CHECKING(for pcap_inject sending support)
- AC_TRY_COMPILE([
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "$LPCAPINC"
- ],[
- pcap_t *pcap;
- char *buf;
- pcap_inject(pcap, (void *)buf, 0);
- ],[
- AC_DEFINE([HAVE_PCAP_INJECT], [1],
- [Does libpcap have pcap_inject?])
- AC_MSG_RESULT(yes)
- have_pcap_inject=yes
- ],[
- AC_MSG_RESULT(no)
- ])
- have_pcap_version=no
- dnl Check to see if we have pcap_version[]
- AC_MSG_CHECKING(for pcap_version[])
- AC_TRY_COMPILE([
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "$LPCAPINC"
- extern char pcap_version[];
- ],[
- printf("%s", pcap_version);
- ],[
- AC_DEFINE([HAVE_PCAP_VERSION],[1], [Does libpcap have pcap_version[]])
- AC_MSG_RESULT(yes)
- ],[
- AC_MSG_RESULT(no)
- ])
- have_pcap_sendpacket=no
- dnl Check to see if we've got pcap_sendpacket()
- AC_MSG_CHECKING(for pcap_sendpacket sending support)
- AC_TRY_COMPILE([
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "$LPCAPINC"
- ],[
- pcap_t *pcap;
- u_char *buf;
- pcap_sendpacket(pcap, buf, 0);
- ],[
- AC_DEFINE([HAVE_PCAP_SENDPACKET], [1],
- [Does libpcap have pcap_sendpacket?])
- AC_MSG_RESULT(yes)
- have_pcap_sendpacket=yes
- ],[
- AC_MSG_RESULT(no)
- ])
- have_pf=no
- dnl Check for linux PF_PACKET support
- AC_MSG_CHECKING(for PF_PACKET socket sending support)
- AC_TRY_COMPILE([
- #include <sys/socket.h>
- #include <netpacket/packet.h>
- #include <net/ethernet.h> /* the L2 protocols */
- #include <netinet/in.h> /* htons */
- ],[
- int pf_socket;
- pf_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
- ],[
- AC_DEFINE([HAVE_PF_PACKET], [1],
- [Do we have Linux PF_PACKET socket support?])
- AC_MSG_RESULT(yes)
- have_pf=yes
- ],[
- AC_MSG_RESULT(no)
- ])
- have_bpf=no
- dnl Check for BSD's BPF
- AC_MSG_CHECKING(for BPF device sending support)
- AC_TRY_RUN([
- #include <stdio.h>
- #include <stdlib.h>
- #include <net/bpf.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <fcntl.h>
- #include <sys/time.h>
- #include <sys/ioctl.h>
- #include <net/bpf.h>
- #include <errno.h>
- int
- main(int argc, char *argv[]) {
- int fd;
-
- fd = open("/dev/bpf0", O_RDONLY, 0);
-
- /* if we opened it, we're good */
- if (fd > 1)
- exit(0);
-
- /* if we got EBUSY or permission denied it exists, so we're good */
- if (fd < 0 && (errno == EBUSY || errno == 13))
- exit(0);
-
- /* else suck, no good */
- exit(-1);
- }],
- [
- AC_DEFINE([HAVE_BPF], [1],
- [Do we have BPF device support?])
- AC_MSG_RESULT(yes)
- have_bpf=yes
- ],[
- AC_MSG_RESULT(no)
- ])
- dnl Make sure we have a valid packet injection mechanisim
- if test $have_bpf = no -a $have_pcap_inject = no -a $have_pcap_sendpacket = no \
- -a $have_libnet = no -a $have_pf = no ; then
- AC_MSG_ERROR([Unable to find a supported method to send packets. Please upgrade your libpcap or enable libnet])
- fi
- dnl Libpcap support doesn't give us a method to get the hardware address of the
- dnl interfaces which prevents us from doing proper filtering to prevent bridging loops
- enable_tcpbridge=yes
- if test $have_bpf = no -a $have_libnet = no -a $have_pf = no ; then
- AC_MSG_NOTICE([tcpbridge support disabled without BPF, Libnet or Linux PF_PACKET])
- enable_tcpbridge=no
- fi
- # ADT: Commented for now
- # AM_CONDITIONAL(ENABLE_TCPBRIDGE, [test $enable_tcpbridge = yes])
- dnl Older versions of libpcap are missing some DLT types
- dnl If doesn't exist, we'll define them in src/common/fakepcap.h
- AC_MSG_CHECKING(for DLT_LINUX_SLL in libpcap)
- AC_TRY_COMPILE([#include "$LPCAPINC"],
- [ int foo;
- foo = DLT_LINUX_SLL ],
- [ AC_DEFINE([HAVE_DLT_LINUX_SLL], [1],
- [Does pcap.h include a header with DLT_LINUX_SLL?])
- AC_MSG_RESULT(yes)
- ],
- AC_MSG_RESULT(no)
- )
- AC_MSG_CHECKING(for DLT_C_HDLC in libpcap)
- AC_TRY_COMPILE([#include "$LPCAPINC"],
- [ int foo;
- foo = DLT_C_HDLC ],
- [ AC_DEFINE([HAVE_DLT_C_HDLC], [1],
- [Does pcap.h include a header with DLT_C_HDLC?])
- AC_MSG_RESULT(yes)
- ],
- AC_MSG_RESULT(no)
- )
- PCAP_BPF_H_FILE="$LPCAPINCDIR/pcap-bpf.h"
- AC_MSG_CHECKING(for $PCAP_BPF_H_FILE)
- AC_TRY_COMPILE([#include <sys/types.h>
- #include <sys/time.h>
- #include "$PCAP_BPF_H_FILE"],
- [ int foo;
- foo = BPF_MAJOR_VERSION; ],
- [ AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [1],
- [What is the path (if any) to the pcap-bpf.h
- header?])
- AC_MSG_RESULT(yes)
- AC_SUBST(PCAP_BPF_H_FILE)
- ],
- AC_MSG_RESULT(no)
- )
- foundbpfheader=no
- AC_MSG_CHECKING(for libpcap bpf header)
- for testfile in $LPCAPINCDIR/pcap/bpf.h $LPCAPINCDIR/pcap-bpf.h ; do
- if test -f "${testfile}" -a $foundbpfheader = no ; then
- AC_TRY_COMPILE([
- #include <sys/types.h>
- #include <sys/time.h>
- #include "$testfile"],
- [
- int foo;
- foo = BPF_MAJOR_VERSION;
- ],
- [
- foundbpfheader=yes
- PCAP_BPF_H_FILE=$testfile
- AC_SUBST(PCAP_BPF_H_FILE)
- AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [1],
- [What is the path (if any) to the libpcap bpf header file?])
- AC_MSG_RESULT($testfile)
- ],
- AC_MSG_RESULT(no)
- )
- fi
- done
- dnl restore LIBS & CFLAGS
- LIBS="$OLDLIBS"
- CFLAGS="$OLDCFLAGS"
- dnl ##################################################
- dnl # Check for pcapnav
- dnl ##################################################
- pcapnav_ver=no
- pcncfg=no
- AC_ARG_WITH(pcapnav-config,
- AC_HELP_STRING([--with-pcapnav-config=FILE], [Use given pcapnav-config]),
- [ AC_MSG_CHECKING(for pcapnav-config)
- if test -x $withval ; then
- pcncfg=$withval
- AC_MSG_RESULT($pcncfg)
- elif test x$withval = xno ; then
- AC_MSG_RESULT(no)
- else
- AC_MSG_RESULT([Can't find pcapnav-config: disabling offset jump feature])
- fi ],
- [ AC_PATH_PROG(pcncfg,[pcapnav-config], [no] ) ]
- )
- if test $pcncfg != no ; then
- LNAVLIB=`$pcncfg --libs`
- LNAV_CFLAGS=`$pcncfg --cflags`
- PCAPNAV_VERSION=`$pcncfg --version`
- AC_SUBST(LNAVLIB)
- AC_SUBST(LNAV_CFLAGS)
- AC_DEFINE_UNQUOTED(PCAPNAV_VERSION, "$PCAPNAV_VERSION",
- [libpcapnav's version?])
- dnl Check to see what version of libpcapnav
- dnl this code has been reduced a lot, but probably still could be
- dnl reduced quite a bit more if we chose too
- AC_MSG_CHECKING(for libpcapnav version)
- AC_TRY_RUN([
- #include <string.h>
- #define PCAPNAV_TEST "0.4"
- /*
- * simple proggy to test the version of libpcapnav
- * returns zero if version >= 0.4
- * or one otherwise
- */
- int
- main (int argc, char *argv[])
- {
- if (strncmp(PCAPNAV_VERSION, PCAPNAV_TEST, 3) >= 0)
- exit(0);
- exit(1);
- }],
- libpcapnav_ver=yes
- AC_MSG_RESULT(>= 0.4),
- libpcapnav_ver=no
- AC_MSG_RESULT(< 0.4),
- libpcapnav_ver=no
- )
- if test x$libpcapnav_ver = xno ; then
- AC_MSG_WARN([Libpcapnav versions < 0.4 are not supported.
- Please upgrade to version 0.4 or better.
- Disabling offset jump feature.])
- else
- AC_DEFINE([HAVE_PCAPNAV], [1], [Do we have libpcapnav?])
- fi
- fi # checking pcapnav version
- dnl (shamelessly ripped off from libpcap)
- dnl Checks to see if unaligned memory accesses fail
- dnl
- dnl FORCE_ALIGN (DEFINED)
- dnl
- AC_MSG_CHECKING(for requires strict byte alignment)
- AC_CACHE_VAL(unaligned_fail,
- [case "$host_cpu" in
- # XXX: should also check that they don't do weird things (like on arm)
- alpha*|arm*|hp*|mips*|sparc*|ia64)
- unaligned_fail=yes
- ;;
- *)
- cat >conftest.c <<EOF
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <stdio.h>
- unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
- main() {
- unsigned int i;
- pid_t pid;
- int status;
- /* avoid "core dumped" message */
- pid = fork();
- if (pid < 0)
- exit(2);
- if (pid > 0) {
- /* parent */
- pid = waitpid(pid, &status, 0);
- if (pid < 0)
- exit(3);
- exit(!WIFEXITED(status));
- }
- /* child */
- i = *(unsigned int *)&a[[1]];
- printf("%d\n", i);
- exit(0);
- }
- EOF
- ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
- conftest.c $LIBS >/dev/null 2>&1
- if test ! -x conftest ; then
- dnl failed to compile for some reason
- unaligned_fail=yes
- else
- ./conftest >conftest.out
- if test ! -s conftest.out ; then
- unaligned_fail=yes
- else
- unaligned_fail=no
- fi
- fi
- rm -f conftest* core core.conftest
- ;;
- esac])
- AC_MSG_RESULT($unaligned_fail)
- if test $unaligned_fail = yes ; then
- AC_DEFINE([FORCE_ALIGN],[1],[Are we strictly aligned?])
- fi
- dnl ##################################################
- dnl # Check for tcpdump.
- dnl ##################################################
- tcpdump_path=no
- AC_ARG_WITH(tcpdump,
- AC_HELP_STRING([--with-tcpdump=FILE], [Path to tcpdump binary]),
- [ if test -x $withval ; then
- tcpdump_path=$withval
- AC_MSG_RESULT([Using tcpdump in $tcpdump_path])
- else
- AC_MSG_RESULT([Error: $withval does not exist or is not executable])
- fi ],
- [ AC_PATH_PROG(tcpdump_path, tcpdump, "no", [$PATH:/usr/sbin:/sbin:/usr/local/sbin]) ])
-
- if test "$tcpdump_path" = "no"; then
- AC_MSG_WARN([Unable to find tcpdump. Please specify --with-tcpdump.
- Disabling --verbose])
- else
- AC_DEFINE([HAVE_TCPDUMP], [1], [Do we have tcpdump?])
- AC_DEFINE_UNQUOTED(TCPDUMP_BINARY, "$tcpdump_path", [The tcpdump binary initially used])
- fi
- AM_CONDITIONAL([ENABLE_TCPDUMP], test "$tcpdump_path" != "no" -a x$have_pcap_dump_fopen = xyes)
- if test x$tcpdump_path != xno -a x$have_pcap_dump_fopen = xyes ; then
- AC_DEFINE([ENABLE_VERBOSE], [1], [Do we have tcpdump and pcap_dump_fopen()?])
- else
- AC_MSG_WARN([Your version of libpcap is too old for --verbose support])
- fi
- dnl No 'make test' when cross compile
- AC_MSG_CHECKING(for 'make test' profile)
- if test "$host" != "$build" ; then
- AC_MSG_WARN(Unable to do tests when cross-compiling)
- fi
- dnl Allows user to choose which nic to use for testing purposes
- AC_ARG_WITH(testnic,
- AC_HELP_STRING([--with-testnic=NIC], [Select which network card to use for testing]),
- [ nic1=$withval
- nic2=$withval
- AC_MSG_RESULT([Using --with-testnic=$withval])],
- [
- dnl There's a bug in OS X which causes pcap_findalldevs() to make the wifi NIC to disassociate
- dnl so under OSX we disable the interface list feature
- disable_pcap_findalldevs=no
- dnl these need to be dynamic based on OS
- case $host in
- *-*-linux*)
- nic1=eth0
- nic2=eth0
- AC_MSG_RESULT(Linux)
- ;;
- *-*-solaris*)
- nic1=hme0
- nic2=hme0
- AC_MSG_RESULT(Solaris)
- ;;
- *-*-sunos*)
- nic1=hme0
- nic2=hme0
- AC_MSG_RESULT(SunOS)
- ;;
- *-apple-darwin*)
- nic1=en0
- nic2=en0
- if test x$libpcap_version_096 = xno ; then
- disable_pcap_findalldevs=yes
- fi
- AC_MSG_RESULT(Apple OS X)
- ;;
- *-*-openbsd*)
- nic1=xl0
- nic2=xl0
- AC_MSG_RESULT(OpenBSD)
- ;;
- *-*-cygwin)
- AC_MSG_RESULT(Win32/Cygwin)
- nic1=%0
- nic2=%0
- ;;
-
- *)
- AC_MSG_RESULT([$host is unknown! Using first non-loopback interface])
- nic1=%0
- nic2=%0
- ;;
- esac])
- AC_ARG_WITH(testnic2,
- AC_HELP_STRING([--with-testnic2=NIC2], [Select an optional 2nd network card to use for testing]),
- [ nic2=$withval ])
- AC_MSG_NOTICE([Using $nic1 for 1st test network interface card])
- AC_MSG_NOTICE([Using $nic2 for 2nd test network interface card])
- AC_SUBST(nic1)
- AC_SUBST(nic2)
- AC_MSG_CHECKING([if it's ok to use pcap_findalldevs()])
- if test x$disable_pcap_findalldevs = xno ; then
- AC_DEFINE([ENABLE_PCAP_FINDALLDEVS], [1], [Enable use of pcap_findalldevs()])
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
- dnl tcpreplay has (so far) been relying on leading-edge autogen.
- dnl Therefore, by default:
- dnl - use the version we ship with
- dnl - do not install it
- dnl - build a static copy (AC_DISABLE_SHARED - implicitly done earlier)
- case "${enable_local_libopts+set}" in
- set) ;;
- *) enable_local_libopts=yes ;;
- esac
- case "${enable_libopts_install+set}" in
- set) ;;
- *) enable_libopts_install=no ;;
- esac
- LIBOPTS_CHECK(libopts)
- AC_OUTPUT([Makefile
- doxygen.cfg
- lib/Makefile
- docs/Makefile
- src/Makefile
- src/common/Makefile
- src/tcpedit/Makefile
- src/defines.h
- test/Makefile
- test/config
- scripts/Makefile
- tcpreplay.spec])
- # Configuration results
- AC_MSG_RESULT(
- ##########################################################################
- TCPREPLAY Suite Configuration Results (${TCPREPLAY_VERSION})
- ##########################################################################
- libpcap: ${foundpcap} (${libpcap_version})
- libnet: ${foundnet}
- autogen: ${AUTOGEN}
- 64bit counter support: ${use64bit_counters}
- tcpdump binary path: ${tcpdump_path}
- tcpreplay edit support: ${tcpreplay_edit}
- tcpbridge support: ${enable_tcpbridge}
- Supported Packet Injection Methods (*):
- Linux PF_PACKET: ${have_pf}
- BSD BPF: ${have_bpf}
- libnet: ${have_libnet}
- pcap_inject: ${have_pcap_inject}
- pcap_sendpacket: ${have_pcap_sendpacket}
- * In order of preference; see configure --help to override
- )
- case $host in
- *-apple-darwin*)
- AC_MSG_WARN([Apple OS X versions prior to 10.5 (Leopard) has a serious problem!
- Please see: http://tcpreplay.synfin.net/trac/ticket/142 for more details])
- ;;
-
- *-*-cygwin)
- AC_MSG_WARN([Windows/Cygwin support is still somewhat experimental. Please report any bugs!
- http://tcpreplay.synfin.net/trac/newticket])
- ;;
- esac
|