configure.ac 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986
  1. dnl $Id$
  2. AC_PREREQ([2.69])
  3. dnl Set version info here!
  4. AC_INIT([tcpreplay],[4.3.3],
  5. [https://github.com/appneta/tcpreplay/issues],
  6. [tcpreplay],
  7. [http://tcpreplay.sourceforge.net/])
  8. AC_CONFIG_SRCDIR([src/tcpreplay.c])
  9. AM_CONFIG_HEADER([src/config.h])
  10. AC_CONFIG_AUX_DIR(config)
  11. AM_MAINTAINER_MODE([enable])
  12. AM_WITH_DMALLOC
  13. dnl People building from GitHub need the same version of Autogen as I'm using
  14. dnl or specify --disable-local-libopts to force using the locally-installed
  15. dnl copy of libopts rather than the source in the `./liopts/` directory.
  16. MAINTAINER_AUTOGEN_VERSION=5.18.12
  17. AC_CONFIG_MACRO_DIR([m4])
  18. TCPREPLAY_VERSION=$PACKAGE_VERSION
  19. dnl Release is only used for the RPM spec file
  20. TCPREPLAY_RELEASE=1
  21. AC_SUBST(TCPREPLAY_VERSION)
  22. AC_SUBST(TCPREPLAY_RELEASE)
  23. dnl Determine OS
  24. AC_CANONICAL_BUILD
  25. AC_CANONICAL_HOST
  26. AC_CANONICAL_TARGET
  27. AC_SUBST(host)
  28. AC_SUBST(build)
  29. AC_SUBST(target)
  30. CROSS_ARCH=
  31. CROSS_LD=
  32. build_arch=$(echo $MACHTYPE | cut -d'-' -f1)
  33. if test "$cross_compiling" = "yes" ; then
  34. CROSS_ARCH="ARCH=$host_cpu"
  35. CROSS_LD="LD=$LD"
  36. fi
  37. AC_SUBST(CROSS_ARCH)
  38. AC_SUBST(CROSS_LD)
  39. dnl ============================================
  40. dnl MacOSX build and runtime environment options
  41. dnl ============================================
  42. AC_ARG_WITH(macosx-sdk,
  43. AS_HELP_STRING([--with-macosx-sdk],
  44. [Use a specific SDK for building.])
  45. [
  46. Usage: --with-macosx-sdk=<version>
  47. e. g.: --with-macosx-sdk=10.8
  48. ],
  49. ,)
  50. dnl ===========================
  51. dnl Check OS X SDK and compiler
  52. dnl ===========================
  53. case "$host_os" in
  54. darwin*) # Mac OS X or iOS
  55. # If no --with-macosx-sdk option is given, look for one
  56. # The intent is that for "most" Mac-based developers, a suitable
  57. # SDK will be found automatically without any configure options.
  58. # For developers with a current Xcode, the lowest-numbered SDK
  59. # higher than or equal to the minimum required should be found.
  60. # To find a list of available version run `xcodebuild -showsdks`
  61. MULTIARCH=${host_cpu}-${host_os}
  62. AC_MSG_CHECKING([what macOS compiler to use])
  63. for _macosx_sdk in $with_macosx_sdk 10.8 10.9 10.10 10.11 10.12 10.13 10.14 10.15 10.16 10.17 10.18 10.19 10.20 11.0 11.1 11.2 11.3 11.4 11.5; do
  64. MACOSX_SDK_PATH=$(xcrun --sdk macosx${_macosx_sdk} --show-sdk-path 2> /dev/null)
  65. if test -d "$MACOSX_SDK_PATH"; then
  66. with_macosx_sdk="${_macosx_sdk}"
  67. break
  68. else
  69. MACOSX_SDK_PATH=$(xcode-select -print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${_macosx_sdk}.sdk
  70. if test -d "$MACOSX_SDK_PATH"; then
  71. with_macosx_sdk="${_macosx_sdk}"
  72. break
  73. fi
  74. fi
  75. done
  76. if test -d "$MACOSX_SDK_PATH"; then
  77. CC="$(xcrun -find clang) -m64 -isysroot $MACOSX_SDK_PATH"
  78. INSTALL_NAME_TOOL=$(xcrun -find install_name_tool)
  79. AR=$(xcrun -find ar)
  80. NM=$(xcrun -find nm)
  81. STRIP=$(xcrun -find strip)
  82. LIBTOOL=$(xcrun -find libtool)
  83. RANLIB=$(xcrun -find ranlib)
  84. AC_MSG_RESULT([$CC])
  85. else
  86. AC_MSG_RESULT([legacy])
  87. fi
  88. ;;
  89. Linux*)
  90. dnl ============================================
  91. dnl Some libraries are in /usr/lib/i386-linux-gnu
  92. dnl but host is i686-linux-gnu
  93. dnl ============================================
  94. MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH) 2> /dev/null || ${host_cpu}-${host_os}
  95. ;;
  96. *)
  97. MULTIARCH=${host_cpu}-${host_os}
  98. ;;
  99. esac
  100. AC_SUBST(MACOSX_SDK_PATH)
  101. AC_SUBST(LIBTOOL) # Note that the OS X libtool command is unrelated to GNU libtool
  102. dnl ============================================
  103. dnl PF_RING library option
  104. dnl ============================================
  105. AC_ARG_WITH(pfring-lib,
  106. AS_HELP_STRING([--with-pfring-lib],
  107. [Use a specific PF_RING static library when using PF_RING libpcap.])
  108. [
  109. Usage: --with-pfring-lib=<library>
  110. e. g.: --with-pfring-lib=/usr/lib/libpfring_zc_x86_64.a
  111. ],
  112. ,)
  113. have_cygwin=no
  114. AC_MSG_CHECKING([for cygwin development environment])
  115. if test $(echo $target | grep -c cygwin) -gt 0 ; then
  116. AC_DEFINE([HAVE_WIN32], [1], [Windows/Cygwin])
  117. AC_MSG_RESULT(yes)
  118. have_cygwin=yes
  119. else
  120. AC_MSG_RESULT(no)
  121. fi
  122. AM_INIT_AUTOMAKE([foreign subdir-objects -Wall -Wno-override])
  123. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  124. dnl Checks for programs.
  125. AM_PROG_AR
  126. AC_PROG_INSTALL
  127. AC_PROG_LIBTOOL
  128. AC_PROG_CC
  129. # for compat with old systems.
  130. # deprecated in favor of AC_PROG_CC since automake 1.14 and is now no-op
  131. AM_PROG_CC_C_O
  132. AC_PROG_CC_STDC
  133. AC_PROG_CXX
  134. AC_PROG_CPP
  135. AC_PROG_LN_S
  136. LT_INIT
  137. AC_PROG_AWK
  138. AC_PROG_SED
  139. AC_PROG_MAKE_SET
  140. AC_EXEEXT
  141. AC_PATH_PROG(PRINTF, printf)
  142. AC_PATH_PROG(ECHO, echo)
  143. AC_PATH_PROG(CUT, cut)
  144. AC_PATH_PROG(AUTOGEN, autogen)
  145. AC_PATH_PROG(GROFF, groff)
  146. AC_PATH_PROG(depmod, depmod, /sbin/depmod, $PATH:/sbin)
  147. AC_PATH_PROG(insmod, insmod, /sbin/insmod, $PATH:/sbin)
  148. AC_PATH_PROG(rmmod, rmmod, /sbin/rmmod, $PATH:/sbin)
  149. dnl tcpreplay has (so far) been relying on leading-edge autogen.
  150. dnl Therefore, by default:
  151. dnl - use the version we ship with
  152. dnl - do not install it
  153. dnl - build a static copy (AC_DISABLE_SHARED - implicitly done earlier)
  154. case "${enable_local_libopts+set}" in
  155. set) ;;
  156. *) enable_local_libopts=yes ;;
  157. esac
  158. case "${enable_libopts_install+set}" in
  159. set) ;;
  160. *) enable_libopts_install=no ;;
  161. esac
  162. dnl check autogen version
  163. AUTOGEN_VERSION="unknown - man pages will not be built"
  164. if test -n "${AUTOGEN}" ; then
  165. AC_MSG_CHECKING(for autogen version >= ${MAINTAINER_AUTOGEN_VERSION})
  166. AUTOGEN_VERSION=$(${AUTOGEN} -v | ${CUT} -d' ' -f 4)
  167. AUTOGEN_MAJOR=$(echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 1)
  168. AUTOGEN_MINOR=$(echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 2)
  169. AUTOGEN_BUILD=$(echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 3)
  170. if test -z "$AUTOGEN_BUILD"; then
  171. AUTOGEN_BUILD=0
  172. fi
  173. if (test ${AUTOGEN_MAJOR} -eq 5 && test ${AUTOGEN_MINOR} -eq 18 && test ${AUTOGEN_BUILD} -lt 4) ||
  174. (test ${AUTOGEN_MAJOR} -eq 5 && test ${AUTOGEN_MINOR} -lt 18) ||
  175. test ${AUTOGEN_MAJOR} -lt 5 ; then
  176. AC_MSG_RESULT(no)
  177. if test "x$enable_local_libopts" == "xno"; then
  178. AC_MSG_ERROR([${AUTOGEN} is too old (${AUTOGEN_VERSION}) for building from source code. Upgrade to 5.18.4 or higher])
  179. fi
  180. AUTOGEN_VERSION="${AUTOGEN_VERSION} - downlevel"
  181. else
  182. AC_MSG_RESULT(yes)
  183. fi
  184. dnl Compare the installed version with the maintainer version if building from GitHub and not using system libopts
  185. if test ! -f src/tcpreplay_opts.c && test "x$enable_local_libopts" = "xyes" ; then
  186. if test $MAINTAINER_AUTOGEN_VERSION != $AUTOGEN_VERSION ; then
  187. AC_MSG_ERROR([Your version of autogen ($AUTOGEN_VERSION) != libopts tear off ($MAINTAINER_AUTOGEN_VERSION) Either install the correct version or specify --disable-local-libopts])
  188. fi
  189. fi
  190. else
  191. if test ! -f src/tcpreplay_opts.c ; then
  192. AC_MSG_ERROR([Please install GNU autogen $MAINTAINER_AUTOGEN_VERSION or higher if you are building from GitHub. To avoid this message download source from http://tcpreplay.appneta.com/wiki/installation.html])
  193. fi
  194. fi
  195. AC_DEFINE([AUTOGEN_VERSION], [${AUTOGEN_VERSION}], [What version of autogen is installed on this system])
  196. if test "x$enable_local_libopts" = "xyes" ; then
  197. AC_MSG_NOTICE([Using included libopts tearoff])
  198. else
  199. AC_MSG_NOTICE([Using system libopts])
  200. fi
  201. AC_HEADER_STDC
  202. AC_HEADER_MAJOR
  203. dnl Checks for typedefs, structures, and compiler characteristics.
  204. AC_CHECK_HEADER_STDBOOL
  205. AC_C_INLINE
  206. AC_TYPE_INT16_T
  207. AC_TYPE_INT32_T
  208. AC_TYPE_INT64_T
  209. AC_TYPE_INT8_T
  210. AC_TYPE_OFF_T
  211. AC_TYPE_PID_T
  212. AC_TYPE_SIZE_T
  213. AC_TYPE_SSIZE_T
  214. AC_TYPE_UINT16_T
  215. AC_TYPE_UINT32_T
  216. AC_TYPE_UINT64_T
  217. AC_TYPE_UINT8_T
  218. AC_HEADER_TIME
  219. AC_C_CONST
  220. AC_C_INLINE
  221. AC_SYS_LARGEFILE
  222. dnl Check for functions
  223. AC_FUNC_FSEEKO
  224. dnl Check for types.
  225. AC_CHECK_TYPE(u_int8_t, uint8_t)
  226. AC_CHECK_TYPE(u_int16_t, uint16_t)
  227. AC_CHECK_TYPE(u_int32_t, uint32_t)
  228. AC_CHECK_TYPE(u_int64_t, uint64_t)
  229. dnl OS X SDK 10.11 throws lots of unnecessary macro warnings
  230. wno_format=""
  231. wno_macro_redefined=""
  232. case $host in
  233. *-apple-darwin*)
  234. AC_MSG_CHECKING(for $CC -Wno-macro-redefined)
  235. OLD_CFLAGS=$CFLAGS
  236. CFLAGS="$CFLAGS -Wno-macro-redefined -Werror"
  237. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
  238. int main(int argc, char *argv[]) { return(0); }]])],
  239. [ AC_MSG_RESULT(yes)
  240. wno_macro_redefined="-Wno-macro-redefined" ],
  241. [ AC_MSG_RESULT(no) ])
  242. CFLAGS="$OLD_CFLAGS $wno_macro_redefined"
  243. CFLAGS="$CFLAGS -Wno-format -Werror"
  244. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
  245. int main(int argc, char *argv[]) { return(0); }]])],
  246. [ AC_MSG_RESULT(yes)
  247. wno_format="-Wno-format" ],
  248. [ AC_MSG_RESULT(no) ])
  249. CFLAGS="$OLD_CFLAGS $wno_format"
  250. ;;
  251. esac
  252. dnl Older versions of GCC don't support these options
  253. AC_MSG_CHECKING(for $CC -Wextra support)
  254. OLD_CFLAGS=$CFLAGS
  255. CFLAGS="$CFLAGS -Wextra -Werror"
  256. wextra=""
  257. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
  258. int main(int argc, char *argv[]) { return(0); }]])],
  259. [ AC_MSG_RESULT(yes)
  260. wextra="-Wextra" ],
  261. [ AC_MSG_RESULT(no) ])
  262. CFLAGS="$OLD_CFLAGS $wextra"
  263. AC_MSG_CHECKING(for $CC -Wno-variadic-macros support)
  264. OLD_CFLAGS=$CFLAGS
  265. CFLAGS="$CFLAGS -Wno-variadic-macros -Werror"
  266. wno_variadic_macros=""
  267. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
  268. int main(int argc, char *argv[]) { return(0); }]])],
  269. [ AC_MSG_RESULT(yes)
  270. wno_variadic_macros="-Wno-variadic-macros" ],
  271. [ AC_MSG_RESULT(no) ])
  272. CFLAGS="$OLD_CFLAGS $wno_variadic_macros"
  273. AC_MSG_CHECKING(for $CC -Wfatal-errors support)
  274. OLD_CFLAGS=$CFLAGS
  275. CFLAGS="$CFLAGS -Wfatal-errors -Werror"
  276. wfatal_errors=""
  277. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
  278. int main(int argc, char *argv[]) { return(0); }]])],
  279. [ AC_MSG_RESULT(yes)
  280. wfatal_errors="-Wfatal-errors" ],
  281. [ AC_MSG_RESULT(no) ])
  282. CFLAGS="$OLD_CFLAGS $wfatal_errors"
  283. AC_MSG_CHECKING(for $CC -Wno-format-contains-nul support)
  284. OLD_CFLAGS=$CFLAGS
  285. CFLAGS="$CFLAGS -Wno-format-contains-nul -Werror"
  286. wno_format_contains_nul=""
  287. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
  288. int main(int argc, char *argv[]) { return(0); }]])],
  289. [ AC_MSG_RESULT(yes)
  290. wno_format_contains_nul="-Wno-format-contains-nul" ],
  291. [ AC_MSG_RESULT(no) ])
  292. CFLAGS="$OLD_CFLAGS $wno_format_contains_nul"
  293. dnl Check for other header files
  294. AC_CHECK_HEADERS([fcntl.h stddef.h sys/socket.h arpa/inet.h sys/time.h])
  295. AC_CHECK_HEADERS([signal.h string.h strings.h sys/types.h stdint.h sys/select.h])
  296. AC_CHECK_HEADERS([netinet/in.h netinet/in_systm.h poll.h sys/poll.h unistd.h sys/param.h])
  297. AC_CHECK_HEADERS([inttypes.h libintl.h sys/file.h sys/ioctl.h sys/systeminfo.h])
  298. AC_CHECK_HEADERS([sys/io.h architecture/i386/pio.h sched.h])
  299. AC_HEADER_STDBOOL
  300. dnl OpenBSD has special requirements
  301. AC_CHECK_HEADERS([sys/sysctl.h net/route.h], [], [], [
  302. [#if HAVE_SYS_PARAM_H
  303. #include <sys/param.h>
  304. #endif
  305. #if HAVE_SYS_TYPES_H
  306. #include <sys/types.h>
  307. #endif
  308. #if HAVE_SYS_SOCKET_H
  309. #include <sys/socket.h>
  310. #endif
  311. ]])
  312. dnl Checks for libraries.
  313. AC_CHECK_LIB(socket, socket)
  314. AC_CHECK_LIB(nsl, gethostbyname)
  315. AC_CHECK_LIB(rt, nanosleep)
  316. AC_CHECK_LIB(resolv, resolv)
  317. dnl Checks for library functions.
  318. AC_FUNC_FORK
  319. AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
  320. AC_FUNC_MEMCMP
  321. AC_TYPE_SIGNAL
  322. AC_FUNC_VPRINTF
  323. AC_FUNC_MKTIME
  324. AC_FUNC_MMAP
  325. AC_FUNC_REALLOC
  326. AC_CHECK_MEMBERS([struct timeval.tv_sec])
  327. AC_CHECK_FUNCS([alarm atexit bzero dup2 gethostbyname getpagesize gettimeofday])
  328. AC_CHECK_FUNCS([ctime inet_ntoa memmove memset munmap pow putenv realpath])
  329. AC_CHECK_FUNCS([regcomp strdup select socket strcasecmp strchr strcspn strdup])
  330. AC_CHECK_FUNCS([strerror strtol strncpy strtoull poll ntohll mmap snprintf])
  331. AC_CHECK_FUNCS([vsnprintf strsignal strpbrk strrchr strspn strstr strtoul])
  332. AC_CHECK_FUNCS([ioperm])
  333. dnl Look for strlcpy since some BSD's have it
  334. AC_CHECK_FUNCS([strlcpy],have_strlcpy=true,have_strlcpy=false)
  335. AM_CONDITIONAL(SYSTEM_STRLCPY, [test x$have_strlcpy = xtrue])
  336. AC_C_BIGENDIAN
  337. AM_CONDITIONAL([WORDS_BIGENDIAN], [ test x$ac_cv_c_bigendian = xyes ])
  338. AC_ARG_ENABLE([asan],
  339. AC_HELP_STRING([--enable-asan], [Enable Address Sanitizer support]))
  340. if test "x$enable_asan" = "xyes"; then
  341. build_asan=yes
  342. AC_CHECK_LIB([asan], [__asan_report_error], ,
  343. [AC_MSG_ERROR([libasan.so not found, this is required for --enable-asan])])
  344. CFLAGS="${CFLAGS} -O1 -g -fsanitize=address -fno-omit-frame-pointer"
  345. dnl -lasan always need to be the first library
  346. LDFLAGS="-lasan ${LDFLAGS}"
  347. else
  348. build_asan=no
  349. fi
  350. AC_SUBST(build_asan)
  351. dnl Enable debugging in code/compiler options
  352. debug=no
  353. debug_flag=NDEBUG
  354. debug_run_time_flag=
  355. AC_ARG_ENABLE(debug,
  356. AC_HELP_STRING([--enable-debug], [Enable debugging code and support for the -d option]),
  357. [ if test x$enableval = xyes; then
  358. debug=yes
  359. dnl replace '-0X' and add '-g' flags
  360. changequote({,})
  361. CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'`
  362. changequote([,])
  363. CFLAGS="${CFLAGS} -g -O0 -Wall $wextra $wfatal_errors $wno_variadic_macros $wno_format_contains_nul $wno_format"
  364. # We may also want to add:
  365. # -Wformat-security -Wswitch-default -Wunused-paramter -Wpadded"
  366. debug_flag=DEBUG
  367. debug_run_time_flag=--dbug=1
  368. AC_DEFINE([DEBUG], [1], [Enable debugging code and support for the -d option])
  369. fi])
  370. AC_SUBST(debug_flag)
  371. AC_SUBST(debug_run_time_flag)
  372. dnl Enable extra debugging in code/compiler options - may slow down performance
  373. extra_debug=no
  374. extra_debug_flag=NEXTRA_DBUG
  375. AC_ARG_ENABLE(extra-debug,
  376. AC_HELP_STRING([--enable-extra-debug], [Enable additional debugging code (may affect performance)]),
  377. [ if test x$enableval = xyes; then
  378. extra_debug=yes
  379. extra_debug_flag=EXTRA_DEBUG
  380. AC_DEFINE([EXTRA_DEBUG], [1], [Enable additional debugging code (may affect performance)])
  381. fi])
  382. AC_SUBST(extra_debug_flag)
  383. dnl Enable timestamp_trace in code/compiler options
  384. timestamp_trace=no
  385. AC_ARG_ENABLE(timestamp-trace,
  386. AC_HELP_STRING([--timestamp-trace], [Enable dumping of trace timestamps at the end of a test]),
  387. [ if test x$enableval = xyes; then
  388. timestamp_trace=yes
  389. CFLAGS="${CFLAGS} -DTIMESTAMP_TRACE"
  390. AC_DEFINE([TIMESTAMP_TRACE], [1], [Enable dumping of trace timestamps at the end of a test])
  391. fi])
  392. AC_SUBST(timestamp_trace_flag)
  393. AC_ARG_ENABLE(dmalloc,
  394. AC_HELP_STRING([--enable-dmalloc], [Enable linking to dmalloc for better memory debugging]),
  395. [ if test x$enableval = xyes ; then
  396. dmalloc=yes
  397. AC_DEFINE([ENABLE_DMALLOC], [1], [Enable dmalloc])
  398. AC_DEFINE([DMALLOC_FUNC_CHECK], [1], [Enable dmalloc function arg checking])
  399. CFLAGS="${CFLAGS} -I/opt/local/include"
  400. DMALLOC_LIB="/opt/local/lib/libdmalloc.a"
  401. AC_SUBST(DMALLOC_LIB)
  402. fi])
  403. AC_ARG_ENABLE(pedantic,
  404. AC_HELP_STRING([--enable-pedantic], [Enable gcc's -pedantic option]),
  405. [ if test x$enableval = xyes; then
  406. CFLAGS="$CFLAGS -pedantic"
  407. fi ])
  408. dnl Enable Efense
  409. AC_ARG_ENABLE(efence,
  410. AC_HELP_STRING([--enable-efence], [Enable Electric Fence memory debugger]),
  411. [ if test x$enableval = xyes; then
  412. CFLAGS="$CFLAGS -lefence"
  413. AC_DEFINE([EFENCE], [1], [Enable Electric Fence memory debugger])
  414. fi])
  415. dnl Enable Gprof
  416. AC_ARG_ENABLE(gprof,
  417. AC_HELP_STRING([--enable-gprof], [Enable GNU Profiler]),
  418. [ if test x$enableval = xyes; then
  419. if test $debug = yes; then
  420. CFLAGS="$CFLAGS -pg"
  421. else
  422. # GPROF requires gdb
  423. CFLAGS="$CFLAGS -ggdb -pg -fprofile-arcs"
  424. fi
  425. AC_DEFINE([GPROF], [1], [Enable GNU Profiler])
  426. fi])
  427. dnl Enable libpcap auto discovery via pcap-config
  428. enable_pcap_config=no
  429. AC_ARG_ENABLE(pcapconfig,
  430. AC_HELP_STRING([--enable-pcapconfig], [Enable automatic libpcap config, reverting to system scanning]),
  431. [
  432. if test $enableval = yes; then
  433. enable_pcap_config=yes
  434. AC_MSG_NOTICE([Enabling libpcap discovery via pcap_config])
  435. else
  436. enable_pcap_config=no
  437. AC_MSG_NOTICE([Disabling libpcap discovery via pcap_config])
  438. fi
  439. ],
  440. [
  441. AC_MSG_NOTICE([Bypassing libpcap discovery via pcap_config])
  442. ])
  443. dnl Use 64bits for packet counters
  444. use64bit_counters=yes
  445. AC_ARG_ENABLE(64bits,
  446. AC_HELP_STRING([--disable-64bits], [Do not use 64bit packet counters]),
  447. [
  448. AC_MSG_NOTICE([Using u_int32_t for packet counters])
  449. ],
  450. [
  451. AC_DEFINE([ENABLE_64BITS], [1], [Use 64bit packet counters])
  452. AC_MSG_NOTICE([Using u_int64_t for packet counters])
  453. ])
  454. # If we're running gcc add '-D_U_="__attribute__((unused))"' to CFLAGS as well,
  455. # so we can use _U_ to flag unused function arguments and not get warnings
  456. # about them. Otherwise, add '-D_U_=""', so that _U_ used to flag an unused
  457. # function argument will compile with non-GCC compilers.
  458. #
  459. if test "x$GCC" = "xyes" ; then
  460. CFLAGS="-D_U_=\"__attribute__((unused))\" $CFLAGS"
  461. else
  462. CFLAGS="-D_U_=\"\" $CFLAGS"
  463. fi
  464. AC_ARG_ENABLE(force-bpf,
  465. AC_HELP_STRING([--enable-force-bpf], [Force using BPF for sending packets]),
  466. [ AC_DEFINE([FORCE_INJECT_BPF], [1], [Force using BPF for sending packet])])
  467. AC_ARG_ENABLE(force-pf,
  468. AC_HELP_STRING([--enable-force-pf], [Force using Linux's PF_PACKET for sending packets]),
  469. [ AC_DEFINE([FORCE_INJECT_PF], [1], [Force using Linux's PF_PACKET for sending packets])])
  470. AC_ARG_ENABLE(force-libdnet,
  471. AC_HELP_STRING([--enable-force-libdnet], [Force using libdnet for sending packets]),
  472. [ AC_DEFINE([FORCE_INJECT_LIBDNET], [1], [Force using libdnet for sending packets])])
  473. AC_ARG_ENABLE(force-inject,
  474. AC_HELP_STRING([--enable-force-inject], [Force using libpcap's pcap_inject() for sending packets]),
  475. [ AC_DEFINE([FORCE_INJECT_PCAP_INJECT],[1], [Force using libpcap's pcap_inject() for sending packets])])
  476. AC_ARG_ENABLE(force-sendpacket,
  477. AC_HELP_STRING([--enable-force-sendpacket], [Force using libpcap's pcap_sendpacket() for sending packets]),
  478. [ AC_DEFINE([FORCE_INJECT_PCAP_SENDPACKET], [1], [Force using libpcap's pcap_sendpacket() for sending packets])])
  479. dnl Static link libraries
  480. static_link=no
  481. dynamic_link=yes
  482. AC_ARG_ENABLE(static-link,
  483. AC_HELP_STRING([--enable-static-link], [Use static libraries ( .a or .A.tbd ) - default no]),
  484. [
  485. if test $enableval = yes; then
  486. static_link=yes
  487. dynamic_link=no
  488. fi
  489. ])
  490. dnl Dynamic link libraries
  491. AC_ARG_ENABLE(dynamic-link,
  492. AC_HELP_STRING([--enable-dynamic-link], [Use shared libraries ( .so .dylib or .tbd ) - default yes]),
  493. [
  494. if test $enableval = no; then
  495. dynamic_link=no
  496. static_link=yes
  497. elif test $static_link = yes; then
  498. AC_MSG_ERROR([Cannot specify both --enable-dynamic-link and --enable-static-link])
  499. fi
  500. ])
  501. if test $static_link = yes; then
  502. AC_DEFINE([ENABLE_STATIC_LINK], [1], [Use static libraries ( .a or .A.tbd )])
  503. else
  504. AC_DEFINE([ENABLE_DYNAMIC_LINK], [1], [Use shared libraries ( .so .dylib or .tbd )])
  505. fi
  506. dnl Check for inet_aton and inet_pton
  507. AC_CHECK_FUNC(inet_aton,
  508. AC_DEFINE([HAVE_INET_ATON], [1], [Do we have inet_aton?])
  509. inet_aton=yes,
  510. inet_aton=no)
  511. AC_CHECK_FUNC(inet_pton,
  512. AC_DEFINE([HAVE_INET_PTON], [1], [Do we have inet_pton?])
  513. inet_pton=yes,
  514. inet_pton=no)
  515. AC_CHECK_FUNC(inet_ntop,
  516. AC_DEFINE([HAVE_INET_NTOP], [1], [Do we have inet_ntop?])
  517. inet_ntop=yes,
  518. inet_ntop=no)
  519. if test "$inet_ntop" = "no" -a "$inet_pton" = "no" ; then
  520. AC_MSG_ERROR([We need either inet_ntop or inet_pton])
  521. fi
  522. AC_CHECK_FUNC(inet_addr,
  523. AC_DEFINE([HAVE_INET_ADDR], [1], [Do we have inet_addr?])
  524. inet_addr=yes,
  525. inet_addr=no)
  526. if test x$inet_addr = no ; then
  527. AC_MSG_ERROR([We need inet_addr. See bug 26])
  528. fi
  529. dnl #####################################################
  530. dnl Checks for tuntap device support
  531. dnl #####################################################
  532. have_tuntap=no
  533. AC_ARG_ENABLE([tuntap],
  534. AS_HELP_STRING([--disable-tuntap], [Disable tuntap support]), [:],
  535. [case "$build_os" in
  536. linux*)
  537. AC_CHECK_HEADER([linux/if_tun.h], [have_tuntap=yes])
  538. ;;
  539. *)
  540. AC_CHECK_HEADER([net/if_tun.h], [have_tuntap=yes])
  541. ;;
  542. esac])
  543. if test $have_tuntap = yes ; then
  544. AC_DEFINE([HAVE_TUNTAP], [1],
  545. [Do we have TUNTAP device support?])
  546. fi
  547. dnl #####################################################
  548. dnl Checks for libpcap
  549. dnl #####################################################
  550. foundpcap=no
  551. pf_ring_found=no
  552. pf_ring_lib=${with_pfring_lib}
  553. using_pcap_config=no
  554. AC_MSG_CHECKING(for libpcap)
  555. AC_ARG_WITH(libpcap,
  556. AC_HELP_STRING([--with-libpcap=DIR],
  557. [Use libpcap in DIR]),
  558. [
  559. testdir=$withval
  560. for incl in ${testdir}/include/pcap.h ${testdir}/pcap.h ${testdir}/pcap/pcap.h; do
  561. if ! test -f "${incl}"; then
  562. continue
  563. fi
  564. LPCAPINC=${incl}
  565. LPCAPINCDIR=${testdir}
  566. if test $dynamic_link = yes; then
  567. for ext in .dylib .so .tbd ; do
  568. for dir in . lib lib64 lib/${host_cpu}-${host_os} ${host_cpu}-${host_os} lib/${MULTIARCH} ${MULTIARCH}; do
  569. sharefile=$(ls ${testdir}/$dir/libpcap${ext}* 2> /dev/null | sort | head -n1)
  570. if test -n "${sharefile}"; then
  571. LPCAPLIB="-L$(dirname ${sharefile}) -lpcap"
  572. foundpcap=$testdir
  573. break
  574. fi
  575. done
  576. if ! test $foundpcap = no; then
  577. break
  578. fi
  579. done
  580. else
  581. dnl
  582. dnl If dynamic library not found, try static
  583. dnl
  584. for ext in ${libext} .a .A.tbd ; do
  585. for dir in . lib lib64 lib/${host_cpu}-${host_os} ${host_cpu}-${host_os} lib/${MULTIARCH} ${MULTIARCH}; do
  586. staticfile=$(ls ${testdir}/$dir/libpcap${ext} 2> /dev/null | sort | head -n1)
  587. if test -n "${staticfile}"; then
  588. LPCAPLIB="${staticfile}"
  589. foundpcap=${testdir}
  590. break
  591. fi
  592. done
  593. if ! test $foundpcap = no; then
  594. ## could be PF_RING
  595. #
  596. # library is static and in PF_RING build tree
  597. #
  598. # Need access to libpfring library
  599. # and must find an associated libpfring.a
  600. if test -n "${with_pfring_lib}"; then
  601. if test -f ${with_pfring_lib}; then
  602. pf_ring_lib=${with_pfring_lib}
  603. pf_ring_found=yes
  604. else
  605. AC_MSG_ERROR(["Unable to find PF_RING library ${with_pfring_lib}"])
  606. fi
  607. else
  608. ## search locally for most likely PF_RING library
  609. for lib in ${foundpcap}/../lib/libs/libpfring_zc_${host_cpu}.a \
  610. ${foundpcap}/../lib/libs/libpfring_dna_${host_cpu}.a \
  611. ${foundpcap}/../lib/libs/libpfring_zero_${host_cpu}.a \
  612. ${foundpcap}/../lib/libs/libpfring_nt_${host_cpu}.a \
  613. ${foundpcap}/../lib/libpfring.a; do
  614. if test -f "${lib}"; then
  615. pf_ring_lib=${lib}
  616. pf_ring_found=yes
  617. break
  618. fi
  619. done
  620. fi
  621. break
  622. fi
  623. done
  624. fi
  625. if test $foundpcap = no; then
  626. AC_ERROR(["Unable to find matching library for header file in ${testdir}"])
  627. fi
  628. break
  629. done
  630. ],[
  631. #
  632. # Look for pcap-config.
  633. #
  634. # I wish this option could be the default, but it is only enabled with --enable-pcapconfig
  635. #
  636. # The issue is that libpcap is one of those libraries that is nearly impossible to set up
  637. # properly across all platforms. The 'pcap-config' script is shipped with new versions of libpcap,
  638. # and was created to address portability issues. Unfortunately, the script is not updated properly
  639. # outside of the base distribution. Examples: PF_RING requires 'pthreads', 'numa' and 'rt', but
  640. # this is not reflect that in the script. OS X Xcode 10.11 SDK creates its own very broken
  641. # 'pcap-config' script that only occasionally works for dynamic definitions, and defintely
  642. # does not work for static.
  643. #
  644. # The ability to enable this script exists for corner cases where libpcap distributions starts
  645. # using even more libraries than I am currently not aware of. Originally, you only had to worry
  646. # about 'nl', but now we have to be prepared to add 'nl-3', 'nl-genl-3' and 'dbus-1' to make
  647. # libpcap fucntional. In the future, there may be more.
  648. #
  649. # (sigh)
  650. #
  651. # So, in the future if libpcap changes and stops working, try setting --enable-pcapconfig. It
  652. # it may work for you.
  653. if test $enable_pcap_config = yes; then
  654. AC_PATH_TOOL(PCAP_CONFIG, pcap-config)
  655. if test -n "$PCAP_CONFIG"; then
  656. #
  657. # Found - use it to get the include flags for
  658. # libpcap and the flags to link with libpcap.
  659. #
  660. # Please read section 11.6 "Shell Substitutions"
  661. # in the autoconf manual before doing anything
  662. # to this that involves quoting. Especially note
  663. # the statement "There is just no portable way to use
  664. # double-quoted strings inside double-quoted back-quoted
  665. # expressions (pfew!)."
  666. #
  667. if test $dynamic_link = yes; then
  668. LPCAPLIB=$($PCAP_CONFIG --libs)
  669. else
  670. LPCAPLIB=$($PCAP_CONFIG --libs --static)
  671. fi
  672. CFLAGS="$CFLAGS $($PCAP_CONFIG --cflags)"
  673. if test -n "$LPCAPLIB"; then
  674. foundpcap=yes
  675. using_pcap_config=yes
  676. else
  677. AC_WARN([Unable to find libpcap using pcap-config])
  678. fi
  679. fi
  680. fi
  681. if test ! $foundpcap = yes; then
  682. #
  683. # Not found; look for pcap.
  684. #
  685. for testdir in /usr/local /opt/local /usr /wpdpack $MACOSX_SDK_PATH/usr /usr/local/opt/libpcap ; do
  686. if test -f "${testdir}/include/pcap.h"; then
  687. LPCAPINC="${testdir}/include/pcap.h"
  688. LPCAPINCDIR="${testdir}/include"
  689. if test $dynamic_link = yes; then
  690. for ext in .dylib .so .tbd; do
  691. for dir in . lib lib64 ${host_cpu} lib/${host_cpu} ${host_cpu}-${host_os} lib/${host_cpu}-${host_os} ${MULTIARCH} lib/${MULTIARCH}; do
  692. sharefile=$(ls "${testdir}/$dir/libpcap${ext}" 2> /dev/null | sort | head -n1)
  693. if test -n "${sharefile}"; then
  694. LPCAPLIB="-L$(dirname ${sharefile}) -lpcap"
  695. foundpcap=$testdir
  696. break
  697. fi
  698. done
  699. if ! test $foundpcap = no; then
  700. break
  701. fi
  702. done
  703. fi
  704. if test $foundpcap = no ; then
  705. dnl
  706. dnl If dynamic library not found, try static
  707. dnl
  708. for ext in ${libext} .a .A.tbd ; do
  709. for dir in . lib lib64 lib/${host_cpu}-${host_os} ${host_cpu}-${host_os} lib/${MULTIARCH} ${MULTIARCH}; do
  710. staticfile=$(ls "${testdir}/$dir/libpcap${ext}" 2> /dev/null | sort | head -n1)
  711. if test -n "${staticfile}"; then
  712. LPCAPLIB="${staticfile}"
  713. foundpcap=$testdir
  714. break
  715. fi
  716. done
  717. if ! test $foundpcap = no; then
  718. break
  719. fi
  720. done
  721. fi
  722. if test $foundpcap = no -a -f "${testdir}/lib/libwpcap.${libext}" ; then
  723. LPCAPLIB="${testdir}/lib/libwpcap.${libext}"
  724. AC_DEFINE([HAVE_WINPCAP], [1], [Do we have WinPcap?])
  725. foundpcap=$testdir
  726. fi
  727. fi
  728. if ! test $foundpcap = no; then
  729. break
  730. fi
  731. done
  732. fi
  733. ])
  734. if test $foundpcap = no ; then
  735. AC_MSG_RESULT(no)
  736. AC_ERROR(libpcap not found)
  737. else
  738. AC_MSG_RESULT($foundpcap)
  739. fi
  740. # libpcap can require libnl
  741. AC_SEARCH_LIBS([nl_handle_alloc], [nl],
  742. [AC_MSG_NOTICE([Unable to find nl library - may be needed by libpcap])])
  743. ##
  744. ## If not automatically configured,
  745. ## check for newer and full-featured libpcap's
  746. ##
  747. if ! test $using_pcap_config = yes; then
  748. ## newer libpcap requires dbus and latest nl (e.g. -lnl-genl-3 -lnl-3 -ldbus-1)
  749. AC_CHECK_LIB(nl, nl_cache_alloc, [nl_found=yes])
  750. AC_CHECK_LIB(nl-genl-3, genl_connect, [nl_genl_3_found=yes])
  751. AC_CHECK_LIB(nl-3, nl_cache_alloc, [nl_3_found=yes])
  752. AC_CHECK_LIB(dbus-1, dbus_malloc, [dbus_1_found=yes])
  753. if test "$nl_found" = "yes"; then
  754. LPCAPLIB="$LPCAPLIB -lnl"
  755. fi
  756. if test "$nl_genl_3_found" = "yes"; then
  757. LPCAPLIB="$LPCAPLIB -lnl-genl-3"
  758. fi
  759. if test "$nl_3_found" = "yes"; then
  760. LPCAPLIB="$LPCAPLIB -lnl-3"
  761. fi
  762. if test "$dbus_1_found" = "yes"; then
  763. LPCAPLIB="$LPCAPLIB -ldbus-1"
  764. fi
  765. ## See if prereqs for PF_RING exist
  766. AC_CHECK_LIB(numa, numa_available, [numa_found=yes])
  767. AC_CHECK_LIB(pthread, pthread_create, [pthread_found=yes])
  768. if test $pf_ring_found = yes; then
  769. if ! test "${numa_found}" = "yes"; then
  770. AC_MSG_ERROR([PF_RING requires libnuma and/or libnuma-dev])
  771. fi
  772. if ! test "${pthread_found}" = "yes"; then
  773. AC_MSG_ERROR([PF_RING requires libpthread])
  774. fi
  775. LPCAPLIB="$LPCAPLIB ${pf_ring_lib} -lnuma -lpthread -lrt"
  776. fi
  777. fi
  778. OLDLIBS="$LIBS"
  779. if test -n "$LPCAPINCDIR"; then
  780. OLDCFLAGS="$CFLAGS -I$LPCAPINCDIR"
  781. CFLAGS="$CFLAGS -I$LPCAPINCDIR"
  782. else
  783. OLDCFLAGS="$CFLAGS"
  784. LPCAPINCDIR=$(echo $CFLAGS | sed -e 's/^\-I//')
  785. LPCAPINC="$LPCAPINCDIR/pcap.h"
  786. fi
  787. LIBS="$LPCAPLIB"
  788. AC_SEARCH_LIBS([pcap_get_pfring_id], [pcap], AC_DEFINE([HAVE_PF_RING_PCAP], [1], [Do we have PF_RING libpcap support?]))
  789. ## Does libpcap work with selected libraries?
  790. AC_SEARCH_LIBS([pcap_close], [pcap],
  791. , AC_ERROR([Unable to link libpcap in ${foundpcap}]),)
  792. AC_SUBST(LPCAPINC)
  793. AC_SUBST(LPCAPLIB)
  794. dnl Check to see what version of libpcap
  795. dnl this code has been reduced a lot, but probably still could be
  796. dnl reduced quite a bit more if we chose too
  797. AC_MSG_CHECKING(for libpcap version)
  798. dnl 0.9.6 (which is still thinks it is 0.9.5 due to a bug) introduces an important
  799. dnl fix for OSX. See: http://tcpreplay.synfin.net/trac/ticket/167
  800. AC_RUN_IFELSE([AC_LANG_PROGRAM([[
  801. #include <string.h>
  802. #include <stdlib.h>
  803. #include <stdio.h>
  804. #include "$LPCAPINC"
  805. #define PCAP_TEST "0.9.6"
  806. ]], [[
  807. /*
  808. * simple proggy to test the version of libpcap
  809. * returns zero if version >= 0.9.6
  810. * or one otherwise
  811. */
  812. if (strncmp(pcap_lib_version(), PCAP_TEST, 3) >= 0)
  813. exit(0);
  814. if (strncmp(pcap_lib_version(), PCAP_TEST, 5) >= 0) {
  815. printf("%s ", pcap_lib_version());
  816. exit(0);
  817. }
  818. exit(1);
  819. ]])],
  820. [libpcap_version_096=yes],
  821. [libpcap_version_096=no],
  822. [libpcap_version_096=yes]
  823. )
  824. AC_RUN_IFELSE([AC_LANG_PROGRAM([[
  825. #include <string.h>
  826. #include <stdlib.h>
  827. #include <stdio.h>
  828. #include "$LPCAPINC"
  829. #define PCAP_TEST "0.8"
  830. ]], [[
  831. /*
  832. * simple proggy to test the version of libpcap
  833. * returns zero if version >= 0.8.0
  834. * or one otherwise
  835. */
  836. if (strncmp(pcap_lib_version(), PCAP_TEST, 3) >= 0)
  837. exit(0);
  838. /* winpcap? */
  839. if (strncmp(pcap_lib_version(), "WinPcap", 7) == 0)
  840. exit(0);
  841. exit(1);
  842. ]])],
  843. [libpcap_ver8=yes],
  844. [libpcap_ver8=no],
  845. [libpcap_ver8=yes]
  846. )
  847. AC_RUN_IFELSE([AC_LANG_PROGRAM([[
  848. #include <string.h>
  849. #include <stdlib.h>
  850. #include <stdio.h>
  851. #include "$LPCAPINC"
  852. #define PCAP_TEST "0.7.2"
  853. extern const char pcap_version[[]]; /* double up since autoconf escapes things */
  854. ]], [[
  855. /*
  856. * simple proggy to test the version of libpcap
  857. * returns zero if version >= 0.7.2
  858. * or one otherwise
  859. */
  860. if (strncmp(pcap_lib_version(), PCAP_TEST, 3) >= 0)
  861. exit(0);
  862. if (strncmp(pcap_version, PCAP_TEST, 5) >= 0)
  863. exit(0);
  864. exit(1);
  865. ]])],
  866. [libpcap_ver7=yes],
  867. [libpcap_ver7=no],
  868. [libpcap_ver7=yes]
  869. )
  870. if test x$libpcap_ver8 = xyes ; then
  871. AC_MSG_RESULT(>= 0.8.0)
  872. elif test x$libpcap_ver7 = xyes ; then
  873. AC_MSG_RESULT(>= 0.7.2)
  874. else
  875. AC_MSG_ERROR([Libpcap versions < 0.7.2 are not supported
  876. Please upgrade to version 0.7.2 or better])
  877. fi
  878. libpcap_version=unknown
  879. if test x$libpcap_version_096 = xyes ; then
  880. libpcap_version=">= 0.9.6"
  881. elif test x$libpcap_ver8 = xyes ; then
  882. libpcap_version=">= 0.8.0"
  883. elif test x$libcap_ver7 = xyes ; then
  884. libpcap_version=">= 0.7.0"
  885. fi
  886. dnl Check for pcap_setnonblock()
  887. AC_MSG_CHECKING(for pcap_setnonblock)
  888. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  889. #include <stdio.h>
  890. #include <stdlib.h>
  891. #include <string.h>
  892. #include "$LPCAPINC"
  893. ]],[[
  894. pcap_t *p;
  895. char *errbuf;
  896. pcap_setnonblock(p, 1, errbuf);
  897. exit(0);
  898. ]])], [
  899. have_pcap_setnonblock=yes
  900. AC_MSG_RESULT(yes)
  901. ], [
  902. have_pcap_setnonblock=no
  903. AC_MSG_RESULT(no)
  904. ])
  905. if test $have_pcap_setnonblock = yes ; then
  906. AC_DEFINE([HAVE_PCAP_SETNONBLOCK], [1],
  907. [Does libpcap have pcap_setnonblock?])
  908. fi
  909. dnl Check to see if we've got pcap_datalink_val_to_name()
  910. AC_MSG_CHECKING(for pcap_datalink_val_to_description)
  911. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  912. #include <stdio.h>
  913. #include <stdlib.h>
  914. #include <string.h>
  915. #include "$LPCAPINC"
  916. ]],[[
  917. if (strcmp(pcap_datalink_val_to_description(1), "Ethernet (10Mb)") == 0)
  918. exit(0);
  919. exit(1);
  920. ]])],[
  921. have_dlt_to_desc=yes
  922. AC_MSG_RESULT(yes)
  923. ], [
  924. have_dlt_to_desc=no
  925. AC_MSG_RESULT(no)
  926. ])
  927. if test $have_dlt_to_desc = yes ; then
  928. AC_DEFINE([HAVE_DLT_VAL_TO_DESC], [1],
  929. [Does libpcap have pcap_datalink_val_to_description?])
  930. fi
  931. dnl Check for pcap_get_selectable_fd()
  932. AC_MSG_CHECKING(for pcap_get_selectable_fd)
  933. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  934. #include <stdio.h>
  935. #include <stdlib.h>
  936. #include <string.h>
  937. #include "$LPCAPINC"
  938. ]], [[
  939. int f;
  940. pcap_t *p;
  941. f = pcap_get_selectable_fd(p);
  942. exit(0);
  943. ]])], [
  944. have_pcap_get_selectable_fd=yes
  945. AC_MSG_RESULT(yes)
  946. ], [
  947. have_pcap_get_selectable_fd=no
  948. AC_MSG_RESULT(no)
  949. ])
  950. if test x$have_pcap_get_selectable_fd = xyes ; then
  951. AC_DEFINE([HAVE_PCAP_GET_SELECTABLE_FD], [1],
  952. [Does libpcap have pcap_get_selectable_fd?])
  953. fi
  954. dnl Important: winpcap apparently defines functions in it's header files
  955. dnl which aren't actually in the library. Totally fucked up. Hence, we
  956. dnl must actually LINK the code, not just compile it.
  957. dnl Check to see if we've got pcap_dump_fopen()
  958. AC_MSG_CHECKING(for pcap_dump_fopen)
  959. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  960. #include <stdio.h>
  961. #include <stdlib.h>
  962. #include <string.h>
  963. #include "$LPCAPINC"
  964. ]],[[
  965. pcap_dumper_t *dump;
  966. pcap_t *pcap;
  967. FILE *foo;
  968. dump = pcap_dump_fopen(pcap, foo);
  969. ]])],[
  970. have_pcap_dump_fopen=yes
  971. AC_MSG_RESULT(yes)
  972. ], [
  973. have_pcap_dump_fopen=no
  974. AC_MSG_RESULT(no)
  975. ])
  976. if test $have_pcap_dump_fopen = yes ; then
  977. AC_DEFINE([HAVE_PCAP_DUMP_FOPEN], [1],
  978. [Does libpcap have pcap_dump_fopen?])
  979. else
  980. AC_MSG_NOTICE([--verbose mode requires libpcap >= 0.9.0])
  981. fi
  982. have_pcap_inject=no
  983. dnl Check to see if we've got pcap_inject()
  984. AC_MSG_CHECKING(for pcap_inject sending support)
  985. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  986. #include <stdio.h>
  987. #include <stdlib.h>
  988. #include <string.h>
  989. #include "$LPCAPINC"
  990. ]],[[
  991. pcap_t *pcap;
  992. char *buf;
  993. pcap_inject(pcap, (void *)buf, 0);
  994. ]])],[
  995. have_pcap_inject=yes
  996. AC_MSG_RESULT(yes)
  997. ], [
  998. have_pcap_inject=no
  999. AC_MSG_RESULT(no)
  1000. ])
  1001. if test $have_pcap_inject = yes ; then
  1002. AC_DEFINE([HAVE_PCAP_INJECT], [1], [Does libpcap have pcap_inject?])
  1003. fi
  1004. have_pcap_sendpacket=no
  1005. dnl Check to see if we've got pcap_sendpacket()
  1006. AC_MSG_CHECKING(for pcap_sendpacket sending support)
  1007. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  1008. #include <stdio.h>
  1009. #include <stdlib.h>
  1010. #include <string.h>
  1011. #include "$LPCAPINC"
  1012. ]],[[
  1013. pcap_t *pcap;
  1014. u_char *buf;
  1015. pcap_sendpacket(pcap, buf, 0);
  1016. ]])],[
  1017. have_pcap_sendpacket=yes
  1018. AC_MSG_RESULT(yes)
  1019. ], [
  1020. have_pcap_sendpacket=no
  1021. AC_MSG_RESULT(no)
  1022. ])
  1023. if test $have_pcap_sendpacket = yes ; then
  1024. AC_DEFINE([HAVE_PCAP_SENDPACKET], [1], [Does libpcap have pcap_sendpacket?])
  1025. fi
  1026. have_pcap_breakloop=no
  1027. AC_MSG_CHECKING(for pcap_breakloop)
  1028. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  1029. #include <stdio.h>
  1030. #include <stdlib.h>
  1031. #include <string.h>
  1032. #include "$LPCAPINC"
  1033. ]],[[
  1034. pcap_t *pcap;
  1035. pcap_sendpacket(pcap);
  1036. ]])],[
  1037. have_pcap_breakloop=yes
  1038. AC_MSG_RESULT(yes)
  1039. ], [
  1040. have_pcap_breakloop=no
  1041. AC_MSG_RESULT(no)
  1042. ])
  1043. if test $have_pcap_breakloop = yes ; then
  1044. AC_DEFINE([HAVE_PCAP_BREAKLOOP], [1], [Does libpcap have pcap_breakloop?])
  1045. fi
  1046. have_pcap_version=no
  1047. dnl Check to see if we have pcap_version[]
  1048. AC_MSG_CHECKING(for pcap_version[])
  1049. AC_TRY_LINK([
  1050. #include <stdio.h>
  1051. #include <stdlib.h>
  1052. #include <string.h>
  1053. #include "$LPCAPINC"
  1054. extern char pcap_version[];
  1055. ],[
  1056. printf("%s", pcap_version);
  1057. ],[
  1058. AC_DEFINE([HAVE_PCAP_VERSION],[1], [Does libpcap have pcap_version[]])
  1059. AC_MSG_RESULT(yes)
  1060. ],[
  1061. AC_MSG_RESULT(no)
  1062. ])
  1063. have_pcap_snapshot=no
  1064. dnl Check for pcap_snapshot()
  1065. AC_MSG_CHECKING(for pcap_snapshot)
  1066. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  1067. #include <stdio.h>
  1068. #include <stdlib.h>
  1069. #include <string.h>
  1070. #include "$LPCAPINC"
  1071. ]],[[
  1072. pcap_t *p;
  1073. int len;
  1074. len = pcap_snapshot(p);
  1075. exit(0);
  1076. ]])], [
  1077. have_pcap_snapshot=yes
  1078. AC_MSG_RESULT(yes)
  1079. ], [
  1080. have_pcap_snapshot=no
  1081. AC_MSG_RESULT(no)
  1082. ])
  1083. if test $have_pcap_snapshot = yes ; then
  1084. AC_DEFINE([HAVE_PCAP_SNAPSHOT], [1],
  1085. [Does libpcap have pcap_snapshot?])
  1086. fi
  1087. # Tcpbridge requires libpcap and pcap_sendpacket()
  1088. enable_tcpbridge=no
  1089. if test x$foundpcap != xno -a x$have_pcap_sendpacket = xyes ; then
  1090. # if we have pcap_sendpacket() then we can build tcpbridge on non-BPF systems
  1091. if test x$have_bpf = xno; then
  1092. AC_DEFINE(ENABLE_TCPBRIDGE, [1], [Compile tcpbridge])
  1093. enable_tcpbridge=yes
  1094. AC_MSG_NOTICE([Building tcpbridge])
  1095. # BPF systems need to also have pcap_setnonblock()
  1096. elif test x$have_pcap_setnonblock = xyes ; then
  1097. AC_DEFINE(ENABLE_TCPBRIDGE, [1], [Compile tcpbridge])
  1098. enable_tcpbridge=yes
  1099. AC_MSG_NOTICE([Building tcpbridge])
  1100. else
  1101. AC_MSG_WARN([Unable to build tcpbridge. Try installing latest libpcap!])
  1102. fi
  1103. fi
  1104. AM_CONDITIONAL(COMPILE_TCPBRIDGE, [test x$enable_tcpbridge = xyes ])
  1105. # tcpliveplay requires linux OS to function properly
  1106. enable_tcpliveplay=no
  1107. case $host in
  1108. *-*-linux*)
  1109. AC_DEFINE(ENABLE_TCPLIVEPLAY, [1], [Compile tcpliveplay])
  1110. enable_tcpliveplay=yes
  1111. AC_MSG_NOTICE([Building tcpliveplay])
  1112. ;;
  1113. *)
  1114. AC_MSG_WARN([Unable to build tcpliveplay. This tool is only enabled on linux environments.])
  1115. ;;
  1116. esac
  1117. AM_CONDITIONAL(COMPILE_TCPLIVEPLAY, [test x$enable_tcpliveplay = xyes ])
  1118. dnl #####################################################
  1119. dnl Check for netmap support
  1120. dnl #####################################################
  1121. have_netmap=no
  1122. enable_netmap=no
  1123. trynetmapdir=
  1124. AC_MSG_CHECKING(for netmap socket sending support)
  1125. AC_ARG_WITH(netmap,
  1126. AC_HELP_STRING([--with-netmap=DIR], [Use netmap in DIR]),
  1127. [trynetmapdir=$withval])
  1128. NETMAP_SEARCH_DIRS=
  1129. if test "$cross_compiling" = yes; then
  1130. if test "x$trynetmapdir" != "x"; then
  1131. NETMAP_SEARCH_DIRS=$trynetmapdir
  1132. fi
  1133. else
  1134. NETMAP_SEARCH_DIRS="$trynetmapdir /opt/netmap /usr/src/netmap-release /usr/src/netmap /usr/local/src/netmap-release /usr/local/src/netmap /usr/include"
  1135. fi
  1136. for testdir in $NETMAP_SEARCH_DIRS; do
  1137. if test -f "${testdir}/sys/net/netmap.h" ; then
  1138. NETMAPINC="${testdir}/sys/net/netmap.h"
  1139. NETMAPUSERINC="${testdir}/sys/net/netmap_user.h"
  1140. NETMAPINCDIR="${testdir}/sys"
  1141. have_netmap="yes $testdir"
  1142. enable_netmap=yes
  1143. else
  1144. if test -f "${testdir}/net/netmap.h" ; then
  1145. NETMAPINC="${testdir}/net/netmap.h"
  1146. NETMAPUSERINC="${testdir}/net/netmap_user.h"
  1147. NETMAPINCDIR="${testdir}"
  1148. have_netmap="yes $testdir"
  1149. enable_netmap=yes
  1150. fi
  1151. fi
  1152. if test "$have_netmap" != no ; then
  1153. NETMAPFLAGS="-DHAVE_NETMAP"
  1154. OLDCFLAGS="$CFLAGS -I$NETMAPINCDIR"
  1155. CFLAGS="$CFLAGS -DNETMAP_WITH_LIBS -DND -I$NETMAPINCDIR"
  1156. AC_SUBST(NETMAPINC)
  1157. AC_SUBST(NETMAPUSERINC)
  1158. AC_SUBST(NETMAPINCDIR)
  1159. AC_SUBST(NETMAPFLAGS)
  1160. AC_DEFINE([HAVE_NETMAP], [1],
  1161. [Do we have netmap support?])
  1162. have_netmap="yes $testdir"
  1163. enable_netmap=yes
  1164. break;
  1165. fi
  1166. done
  1167. AC_MSG_RESULT($have_netmap)
  1168. AM_CONDITIONAL(COMPILE_NETMAP, [test x$enable_netmap = xyes ])
  1169. dnl ###########################################################
  1170. dnl Check for nm_open() function available in netmap version 5
  1171. dnl Also check for other version-specific netmap definitions and structures
  1172. dnl ###########################################################
  1173. if test "x$NETMAPINCDIR" != "x"; then
  1174. OLDCPPFLAGS="$CPPFLAGS"
  1175. CPPFLAGS="$CPPFLAGS -DNETMAP_WITH_LIBS -DND -I$NETMAPINCDIR"
  1176. have_nm_open=no
  1177. have_nm_nr_reg_mask=no
  1178. have_nm_nr_flags=no
  1179. have_nmring_head_tail=no
  1180. if test "$have_netmap" != no ; then
  1181. dnl check for nm_open()
  1182. AC_CHECK_DECL([nm_open],[have_nm_open=yes], , [[
  1183. #include <stdio.h>
  1184. #include "${NETMAPUSERINC}"
  1185. ]])
  1186. dnl check for #define NR_REG_MASK
  1187. AC_MSG_CHECKING(for netmap NR_REG_MASK definition)
  1188. AC_COMPILE_IFELSE(
  1189. [AC_LANG_PROGRAM([[
  1190. #include <stdint.h>
  1191. #include <sys/socket.h>
  1192. #include <net/if.h>
  1193. #include <net/netmap.h>
  1194. ]],
  1195. [[
  1196. #ifdef NR_REG_MASK
  1197. /* OK */
  1198. #else
  1199. # error NR_REG_MASK not found
  1200. #endif
  1201. ]])
  1202. ],
  1203. [have_nm_nr_reg_mask=yes],
  1204. [])
  1205. AC_MSG_RESULT($have_nm_nr_reg_mask)
  1206. dnl check for nr_flags in struct nmreq
  1207. AC_MSG_CHECKING(for netmap nr_flags definition)
  1208. AC_COMPILE_IFELSE(
  1209. [AC_LANG_PROGRAM([[
  1210. #include <stdint.h>
  1211. #include <sys/socket.h>
  1212. #include <net/if.h>
  1213. #include <net/netmap.h>
  1214. ]],
  1215. [[
  1216. struct nmreq nmr;
  1217. nmr.nr_flags = 0;
  1218. ]])
  1219. ],
  1220. [have_nm_nr_flags=yes],
  1221. [])
  1222. AC_MSG_RESULT($have_nm_nr_flags)
  1223. dnl check for head/tail in struct netmap_ring
  1224. AC_MSG_CHECKING(for netmap ring head/tail definitions)
  1225. AC_COMPILE_IFELSE(
  1226. [AC_LANG_PROGRAM([[
  1227. #include <stdint.h>
  1228. #include <sys/socket.h>
  1229. #include <net/if.h>
  1230. #include <net/netmap.h>
  1231. ]],
  1232. [[
  1233. struct netmap_ring r;
  1234. r.head = r.tail = 0;
  1235. ]])
  1236. ],
  1237. [have_nmring_head_tail=yes],
  1238. [])
  1239. AC_MSG_RESULT($have_nmring_head_tail)
  1240. fi
  1241. if test "$have_nm_open" = yes ; then
  1242. AC_DEFINE([HAVE_NETMAP_NM_OPEN], [1], [Does netmap have nm_open function?])
  1243. fi
  1244. if test "$have_nm_nr_reg_mask" = yes ; then
  1245. AC_DEFINE([HAVE_NETMAP_NR_REG], [1], [Does netmap have NR_REG_MASK defined?])
  1246. fi
  1247. if test "$have_nm_nr_flags" = yes ; then
  1248. AC_DEFINE([HAVE_NETMAP_NR_FLAGS], [1], [Does netmap struct nmreq have nr_flags defined?])
  1249. fi
  1250. if test "$have_nmring_head_tail" = yes ; then
  1251. AC_DEFINE([HAVE_NETMAP_RING_HEAD_TAIL], [1], [Does structure netmap_ring have head/tail defined?])
  1252. fi
  1253. CPPFLAGS="$OLDCPPFLAGS"
  1254. fi
  1255. have_pf=no
  1256. dnl Check for linux PF_PACKET support
  1257. AC_MSG_CHECKING(for PF_PACKET socket sending support)
  1258. AC_TRY_COMPILE([
  1259. #include <sys/socket.h>
  1260. #include <netpacket/packet.h>
  1261. #include <net/ethernet.h> /* the L2 protocols */
  1262. #include <netinet/in.h> /* htons */
  1263. ],[
  1264. int pf_socket;
  1265. pf_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
  1266. ],[
  1267. AC_DEFINE([HAVE_PF_PACKET], [1],
  1268. [Do we have Linux PF_PACKET socket support?])
  1269. AC_MSG_RESULT(yes)
  1270. have_pf=yes
  1271. ],[
  1272. AC_MSG_RESULT(no)
  1273. ])
  1274. have_tx_ring=no
  1275. dnl Check for older Linux TX_RING support
  1276. AC_MSG_CHECKING(for TX_RING socket sending support)
  1277. AC_TRY_COMPILE([
  1278. #include <sys/socket.h>
  1279. #include <netpacket/packet.h>
  1280. #include <net/ethernet.h> /* the L2 protocols */
  1281. #include <netinet/in.h> /* htons */
  1282. #include <linux/if_packet.h>
  1283. ],[
  1284. int test;
  1285. test = TP_STATUS_WRONG_FORMAT
  1286. ],[
  1287. AC_DEFINE([HAVE_TX_RING], [1],
  1288. [Do we have Linux TX_RING socket support?])
  1289. AC_MSG_RESULT(yes)
  1290. have_tx_ring=yes
  1291. ],[
  1292. AC_MSG_RESULT(no)
  1293. ])
  1294. AC_CHECK_HEADERS([net/bpf.h], [have_bpf=yes], [have_bpf=no])
  1295. if test $have_bpf = yes ; then
  1296. AC_DEFINE([HAVE_BPF], [1],
  1297. [Do we have BPF device support?])
  1298. fi
  1299. dnl ##################################################
  1300. dnl # Check for libdnet, but only if not Cygwin!
  1301. dnl #
  1302. dnl # if your version of libdnet doesn't compile, try
  1303. dnl # getting it from ...
  1304. dnl # http://libdnet.sourceforge.net/
  1305. dnl # ... or ...
  1306. dnl # https://github.com/jncornett/libdnet
  1307. dnl # ... or ...
  1308. dnl # on Linux try 'apt-get install libdumbnet-dev'
  1309. dnl ##################################################
  1310. founddnet=no
  1311. have_libdnet=no
  1312. libdnet_version=
  1313. enable_fragroute=no
  1314. trydnetdir=/usr/local
  1315. if test $have_cygwin = no ; then
  1316. AC_MSG_CHECKING(for libdnet)
  1317. AC_ARG_WITH(libdnet,
  1318. AC_HELP_STRING([--with-libdnet=DIR], [Use libdnet in DIR]),
  1319. [trydnetdir=$withval])
  1320. case "$build_os" in
  1321. linux*)
  1322. dnl # Debian/Ubuntu already have a package called libdnet
  1323. dnl # so you the package you want to install libdumbnet-dev
  1324. for testdir in $trydnetdir /usr/local /opt/local /usr ; do
  1325. if test -x ${testdir}/bin/dumbnet-config -a $founddnet = no ; then
  1326. LDNETINC="$($testdir/bin/dumbnet-config --cflags)"
  1327. LDNETLIB="$($testdir/bin/dumbnet-config --libs)"
  1328. libdnet_version="$($testdir/bin/dumbnet-config --version) (libdumbnet)"
  1329. founddnet=$testdir
  1330. fi
  1331. done
  1332. ;;
  1333. esac
  1334. if test $founddnet = no ; then
  1335. for testdir in $trydnetdir /usr/local /opt/local $MACOSX_SDK_PATH/usr /usr ; do
  1336. if test -x ${testdir}/bin/dnet-config -a $founddnet = no ; then
  1337. LDNETINC="$($testdir/bin/dnet-config --cflags)"
  1338. LDNETLIB="$($testdir/bin/dnet-config --libs)"
  1339. libdnet_version="$($testdir/bin/dnet-config --version)"
  1340. founddnet=$testdir
  1341. fi
  1342. done
  1343. fi
  1344. if test $founddnet = no ; then
  1345. AC_MSG_RESULT(no)
  1346. AC_MSG_WARN([libdnet not found, disabling fragroute feature])
  1347. else
  1348. AC_MSG_RESULT($founddnet)
  1349. enable_fragroute=yes
  1350. have_libdnet=yes
  1351. AC_DEFINE([HAVE_LIBDNET], [1], [Do we have libdnet?])
  1352. dnl Debian uses dumbnet.h instead of dnet.h due to naming conflict
  1353. old_cflags=$CFLAGS
  1354. CFLAGS=$LDNETINC
  1355. AC_CHECK_HEADERS([dumbnet.h dnet.h])
  1356. CFLAGS=$old_cflags
  1357. fi
  1358. else
  1359. AC_MSG_NOTICE([Skipping libdnet check under Cygwin for compatibility reasons])
  1360. fi
  1361. AC_SUBST(LDNETINC)
  1362. AC_SUBST(LDNETLIB)
  1363. AC_DEFINE_UNQUOTED([LIBDNET_VERSION], "$libdnet_version", [Version of libdnet])
  1364. AM_CONDITIONAL(COMPILE_FRAGROUTE, [test x$founddnet != xno])
  1365. if test x$founddnet != xno ; then
  1366. AC_DEFINE(ENABLE_FRAGROUTE, [1], [Enable fragroute module])
  1367. fi
  1368. dnl Make sure we have a valid packet injection mechanisim
  1369. if test $have_bpf = no -a $have_pcap_inject = no -a $have_pcap_sendpacket = no \
  1370. -a $have_libdnet = no -a $have_pf = no ; then
  1371. AC_MSG_ERROR([Unable to find a supported method to send packets. Please upgrade your libpcap or enable libdnet])
  1372. fi
  1373. dnl Older versions of libpcap are missing some DLT types
  1374. dnl If doesn't exist, we'll define them in src/common/fakepcap.h
  1375. AC_MSG_CHECKING(for DLT_LINUX_SLL in libpcap)
  1376. AC_TRY_COMPILE([#include "$LPCAPINC"],
  1377. [ int foo;
  1378. foo = DLT_LINUX_SLL
  1379. ],
  1380. [ AC_DEFINE([HAVE_DLT_LINUX_SLL], [1],
  1381. [Does pcap.h include a header with DLT_LINUX_SLL?])
  1382. AC_MSG_RESULT(yes)
  1383. ],
  1384. [AC_MSG_RESULT(no)]
  1385. )
  1386. AC_MSG_CHECKING(for DLT_C_HDLC in libpcap)
  1387. AC_TRY_COMPILE([#include "$LPCAPINC"],
  1388. [ int foo;
  1389. foo = DLT_C_HDLC ],
  1390. [ AC_DEFINE([HAVE_DLT_C_HDLC], [1],
  1391. [Does pcap.h include a header with DLT_C_HDLC?])
  1392. AC_MSG_RESULT(yes)
  1393. ],
  1394. AC_MSG_RESULT(no)
  1395. )
  1396. PCAP_BPF_H_FILE="$LPCAPINCDIR/pcap-bpf.h"
  1397. AC_MSG_CHECKING(for $PCAP_BPF_H_FILE)
  1398. AC_TRY_COMPILE([#include <sys/types.h>
  1399. #include <sys/time.h>
  1400. #include <stdint.h>
  1401. #include "$PCAP_BPF_H_FILE"],
  1402. [ int foo;
  1403. foo = BPF_MAJOR_VERSION; ],
  1404. [ AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [1],
  1405. [What is the path (if any) to the pcap-bpf.h
  1406. header?])
  1407. AC_MSG_RESULT(yes)
  1408. AC_SUBST(PCAP_BPF_H_FILE)
  1409. ],
  1410. AC_MSG_RESULT(no)
  1411. )
  1412. foundbpfheader=no
  1413. AC_MSG_CHECKING(for libpcap bpf header)
  1414. for testfile in $LPCAPINCDIR/pcap/bpf.h $LPCAPINCDIR/pcap-bpf.h ; do
  1415. if test -f "${testfile}" -a $foundbpfheader = no ; then
  1416. AC_TRY_COMPILE([
  1417. #include <sys/types.h>
  1418. #include <sys/time.h>
  1419. #include <stdint.h>
  1420. #include "$testfile"],
  1421. [
  1422. int foo;
  1423. foo = BPF_MAJOR_VERSION;
  1424. ],
  1425. [
  1426. foundbpfheader=yes
  1427. PCAP_BPF_H_FILE=$testfile
  1428. AC_SUBST(PCAP_BPF_H_FILE)
  1429. AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [1],
  1430. [What is the path (if any) to the libpcap bpf header file?])
  1431. ]
  1432. )
  1433. fi
  1434. done
  1435. if test $foundbpfheader != no; then
  1436. AC_MSG_RESULT($testfile)
  1437. else
  1438. AC_MSG_RESULT(no)
  1439. fi
  1440. dnl ## Test for netmap-libpcap
  1441. have_pcap_netmap=no
  1442. if test $foundpcap != no ; then
  1443. AC_MSG_CHECKING(for netmap libpcap)
  1444. PCAP_NETMAP_C_FILE="$LPCAPINCDIR/pcap-netmap.c"
  1445. if test -f "${PCAP_NETMAP_C_FILE}" ; then
  1446. AC_DEFINE([HAVE_LIBPCAP_NETMAP], [1],
  1447. [Does this version of libpcap support netmap?])
  1448. have_pcap_netmap=yes
  1449. AC_MSG_RESULT(yes)
  1450. else
  1451. AC_MSG_RESULT(no)
  1452. fi
  1453. fi
  1454. dnl restore LIBS & CFLAGS
  1455. LIBS="$OLDLIBS"
  1456. CFLAGS="$OLDCFLAGS"
  1457. dnl ##################################################
  1458. dnl # Check for pcapnav
  1459. dnl ##################################################
  1460. pcapnav_ver=no
  1461. pcncfg=no
  1462. AC_ARG_WITH(pcapnav-config,
  1463. AC_HELP_STRING([--with-pcapnav-config=FILE], [Use given pcapnav-config]),
  1464. [ AC_MSG_CHECKING(for pcapnav-config)
  1465. if test -x $withval ; then
  1466. pcncfg=$withval
  1467. AC_MSG_RESULT($pcncfg)
  1468. elif test x$withval = xno ; then
  1469. AC_MSG_RESULT(no)
  1470. else
  1471. AC_MSG_RESULT([Can't find pcapnav-config: disabling offset jump feature])
  1472. fi ],
  1473. [ AC_PATH_PROG(pcncfg,[pcapnav-config], [no] ) ]
  1474. )
  1475. if test $pcncfg != no ; then
  1476. LNAVLIB=$($pcncfg --libs)
  1477. LNAV_CFLAGS=$($pcncfg --cflags)
  1478. PCAPNAV_VERSION=$($pcncfg --version)
  1479. AC_SUBST(LNAVLIB)
  1480. AC_SUBST(LNAV_CFLAGS)
  1481. AC_DEFINE_UNQUOTED(PCAPNAV_VERSION, "$PCAPNAV_VERSION",
  1482. [libpcapnav's version?])
  1483. dnl Check to see what version of libpcapnav
  1484. dnl this code has been reduced a lot, but probably still could be
  1485. dnl reduced quite a bit more if we chose too
  1486. AC_MSG_CHECKING(for libpcapnav version)
  1487. AC_TRY_RUN([
  1488. #include <string.h>
  1489. #define PCAPNAV_TEST "0.4"
  1490. /*
  1491. * simple proggy to test the version of libpcapnav
  1492. * returns zero if version >= 0.4
  1493. * or one otherwise
  1494. */
  1495. int
  1496. main (int argc, char *argv[])
  1497. {
  1498. if (strncmp(PCAPNAV_VERSION, PCAPNAV_TEST, 3) >= 0)
  1499. exit(0);
  1500. exit(1);
  1501. } ],
  1502. libpcapnav_ver=yes
  1503. AC_MSG_RESULT(>= 0.4),
  1504. libpcapnav_ver=no
  1505. AC_MSG_RESULT(< 0.4),
  1506. libpcapnav_ver=no
  1507. )
  1508. if test x$libpcapnav_ver = xno ; then
  1509. AC_MSG_WARN([Libpcapnav versions < 0.4 are not supported.
  1510. Please upgrade to version 0.4 or better.
  1511. Disabling offset jump feature.])
  1512. else
  1513. AC_DEFINE([HAVE_PCAPNAV], [1], [Do we have libpcapnav?])
  1514. fi
  1515. fi # checking pcapnav version
  1516. dnl (shamelessly ripped off from libpcap)
  1517. dnl Checks to see if unaligned memory accesses fail
  1518. dnl
  1519. dnl FORCE_ALIGN (DEFINED)
  1520. dnl
  1521. AC_MSG_CHECKING(for requires strict byte alignment)
  1522. AC_CACHE_VAL(unaligned_cv_fail,
  1523. [case "$host_cpu" in
  1524. # XXX: should also check that they don't do weird things (like on arm)
  1525. alpha*|arm*|hp*|mips*|sparc*|ia64)
  1526. unaligned_cv_fail=yes
  1527. ;;
  1528. *)
  1529. cat >conftest.c <<EOF
  1530. #include <sys/types.h>
  1531. #include <sys/wait.h>
  1532. #include <stdio.h>
  1533. unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
  1534. main() {
  1535. unsigned int i;
  1536. pid_t pid;
  1537. int status;
  1538. /* avoid "core dumped" message */
  1539. pid = fork();
  1540. if (pid < 0)
  1541. exit(2);
  1542. if (pid > 0) {
  1543. /* parent */
  1544. pid = waitpid(pid, &status, 0);
  1545. if (pid < 0)
  1546. exit(3);
  1547. exit(!WIFEXITED(status));
  1548. }
  1549. /* child */
  1550. i = *(unsigned int *)&a[[1]];
  1551. printf("%d\n", i);
  1552. exit(0);
  1553. }
  1554. EOF
  1555. ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
  1556. conftest.c $LIBS >/dev/null 2>&1
  1557. if test ! -x conftest ; then
  1558. dnl failed to compile for some reason
  1559. unaligned_cv_fail=yes
  1560. else
  1561. ./conftest >conftest.out
  1562. if test ! -s conftest.out ; then
  1563. unaligned_cv_fail=yes
  1564. else
  1565. unaligned_cv_fail=no
  1566. fi
  1567. fi
  1568. rm -f conftest* core core.conftest
  1569. ;;
  1570. esac
  1571. ])
  1572. AC_MSG_RESULT($unaligned_cv_fail)
  1573. if test $unaligned_cv_fail = yes ; then
  1574. AC_DEFINE([FORCE_ALIGN], [1], [Are we strictly aligned?])
  1575. fi
  1576. dnl ##################################################
  1577. dnl # Check for tcpdump.
  1578. dnl ##################################################
  1579. tcpdump_path=no
  1580. AC_ARG_WITH(tcpdump,
  1581. AC_HELP_STRING([--with-tcpdump=FILE], [Path to tcpdump binary]),
  1582. [ if test -x $withval ; then
  1583. tcpdump_path=$withval
  1584. AC_MSG_RESULT([Using tcpdump in $tcpdump_path])
  1585. else
  1586. AC_MSG_RESULT([Error: $withval does not exist or is not executable])
  1587. fi ],
  1588. [ AC_PATH_PROG(tcpdump_path, tcpdump, "no", [$PATH:/usr/sbin:/sbin:/usr/local/sbin]) ])
  1589. if test "$tcpdump_path" = "no"; then
  1590. AC_MSG_WARN([Unable to find tcpdump. Please specify --with-tcpdump.
  1591. Disabling --verbose])
  1592. else
  1593. AC_DEFINE([HAVE_TCPDUMP], [1], [Do we have tcpdump?])
  1594. AC_DEFINE_UNQUOTED(TCPDUMP_BINARY, "$tcpdump_path", [The tcpdump binary initially used])
  1595. fi
  1596. AM_CONDITIONAL([ENABLE_TCPDUMP], test "$tcpdump_path" != "no" -a x$have_pcap_dump_fopen = xyes)
  1597. if test x$tcpdump_path != xno -a x$have_pcap_dump_fopen = xyes ; then
  1598. AC_DEFINE([ENABLE_VERBOSE], [1], [Do we have tcpdump and pcap_dump_fopen()?])
  1599. else
  1600. AC_MSG_WARN([Your version of libpcap does not support --verbose])
  1601. fi
  1602. dnl No 'make test' when cross compile
  1603. AC_MSG_CHECKING(for 'make test' profile)
  1604. if test "$host" != "$build" ; then
  1605. AC_MSG_WARN(Unable to do tests when cross-compiling)
  1606. fi
  1607. dnl Allows user to choose which nic to use for testing purposes
  1608. AC_ARG_WITH(testnic,
  1609. AC_HELP_STRING([--with-testnic=NIC], [Select which network card to use for testing]),
  1610. [ nic1=$withval
  1611. nic2=$withval
  1612. AC_MSG_RESULT([Using --with-testnic=$withval])],
  1613. [
  1614. case $host in
  1615. *-*-linux*)
  1616. nic1=eth0
  1617. nic2=eth0
  1618. ;;
  1619. *-*-solaris*)
  1620. nic1=hme0
  1621. nic2=hme0
  1622. ;;
  1623. *-*-sunos*)
  1624. nic1=hme0
  1625. nic2=hme0
  1626. ;;
  1627. *-apple-darwin*)
  1628. nic1=en0
  1629. nic2=en0
  1630. ;;
  1631. *-*-openbsd*)
  1632. nic1=xl0
  1633. nic2=xl0
  1634. ;;
  1635. *-*-freebsd*)
  1636. nic1=em0
  1637. nic2=em0
  1638. ;;
  1639. *-*-cygwin)
  1640. nic1=%0
  1641. nic2=%0
  1642. ;;
  1643. *)
  1644. AC_MSG_RESULT([$host is unknown! Using first non-loopback interface])
  1645. nic1=%0
  1646. nic2=%0
  1647. ;;
  1648. esac])
  1649. dnl There's a bug in OS X which causes pcap_findalldevs() to make the wifi NIC to disassociate
  1650. dnl so under OSX we disable the interface list feature
  1651. disable_pcap_findalldevs=no
  1652. osx_frameworks=no
  1653. dnl these need to be dynamic based on OS
  1654. case $host in
  1655. *-*-linux*)
  1656. AC_DEFINE([HAVE_LINUX], [1], [Building Linux])
  1657. AC_MSG_RESULT(Linux)
  1658. ;;
  1659. *-*-solaris*)
  1660. AC_DEFINE([HAVE_SOLARIS], [1], [Building Solaris])
  1661. AC_MSG_RESULT(Solaris)
  1662. ;;
  1663. *-*-sunos*)
  1664. AC_DEFINE([HAVE_SUNOS], [1], [Building SunOS])
  1665. AC_MSG_RESULT(SunOS)
  1666. ;;
  1667. *-apple-darwin*)
  1668. if test x$libpcap_version_096 = xno ; then
  1669. disable_pcap_findalldevs=yes
  1670. fi
  1671. osx_frameworks=yes
  1672. AC_DEFINE([HAVE_DARWIN], [1], [Building Apple/Darwin])
  1673. AC_MSG_RESULT(Apple OS X)
  1674. ;;
  1675. *-*-openbsd*)
  1676. AC_DEFINE([HAVE_OPENBSD], [1], [Building Open BSD])
  1677. AC_MSG_RESULT(OpenBSD)
  1678. ;;
  1679. *-*-freebsd*)
  1680. AC_DEFINE([HAVE_FREEBSD], [1], [Building Free BSD])
  1681. AC_MSG_RESULT(FreeBSD)
  1682. ;;
  1683. *-*-cygwin)
  1684. AC_MSG_RESULT(Win32/Cygwin)
  1685. AC_DEFINE([HAVE_CYGWIN], [1], [Building Cygwin])
  1686. ;;
  1687. *)
  1688. AC_MSG_RESULT([$host is unknown!])
  1689. ;;
  1690. esac
  1691. AM_CONDITIONAL([ENABLE_OSX_FRAMEWORKS], test "$osx_frameworks" = "yes")
  1692. AC_ARG_WITH(testnic2,
  1693. AC_HELP_STRING([--with-testnic2=NIC2], [Select an optional 2nd network card to use for testing]),
  1694. [ nic2=$withval ])
  1695. AC_MSG_NOTICE([Using $nic1 for 1st test network interface card])
  1696. AC_MSG_NOTICE([Using $nic2 for 2nd test network interface card])
  1697. AC_SUBST(nic1)
  1698. AC_SUBST(nic2)
  1699. AC_MSG_CHECKING([if it's ok to use pcap_findalldevs()])
  1700. if test x$disable_pcap_findalldevs = xno ; then
  1701. AC_DEFINE([ENABLE_PCAP_FINDALLDEVS], [1], [Enable use of pcap_findalldevs()])
  1702. AC_MSG_RESULT(yes)
  1703. else
  1704. AC_MSG_RESULT(no)
  1705. fi
  1706. LIBOPTS_CHECK(libopts)
  1707. AC_CONFIG_FILES([Makefile
  1708. doxygen.cfg
  1709. lib/Makefile
  1710. docs/Makefile
  1711. src/Makefile
  1712. src/tcpedit/Makefile
  1713. src/fragroute/Makefile
  1714. src/common/Makefile
  1715. src/defines.h
  1716. test/Makefile
  1717. test/config
  1718. scripts/Makefile])
  1719. AC_OUTPUT
  1720. # Configuration results
  1721. AC_MSG_RESULT([
  1722. ##########################################################################
  1723. TCPREPLAY Suite Configuration Results (${TCPREPLAY_VERSION})
  1724. ##########################################################################
  1725. libpcap: ${foundpcap} (${libpcap_version})
  1726. PF_RING libpcap ${pf_ring_found} ${pf_ring_lib}
  1727. libdnet: ${founddnet} ${libdnet_version}
  1728. autogen: ${AUTOGEN} (${AUTOGEN_VERSION})
  1729. Use libopts tearoff: ${enable_local_libopts}
  1730. 64bit counter support: ${use64bit_counters}
  1731. tcpdump binary path: ${tcpdump_path}
  1732. fragroute support: ${enable_fragroute}
  1733. tcpbridge support: ${enable_tcpbridge}
  1734. tcpliveplay support: ${enable_tcpliveplay}
  1735. Supported Packet Injection Methods (*):
  1736. Linux TX_RING: ${have_tx_ring}
  1737. Linux PF_PACKET: ${have_pf}
  1738. BSD BPF: ${have_bpf}
  1739. libdnet: ${have_libdnet}
  1740. pcap_inject: ${have_pcap_inject}
  1741. pcap_sendpacket: ${have_pcap_sendpacket} **
  1742. pcap_netmap ${have_pcap_netmap}
  1743. Linux/BSD netmap: ${have_netmap}
  1744. Tuntap device support: ${have_tuntap}
  1745. * In order of preference; see configure --help to override
  1746. ** Required for tcpbridge
  1747. ])
  1748. case $host in
  1749. *-*-cygwin)
  1750. AC_MSG_WARN([Windows/Cygwin support is still somewhat experimental.
  1751. Please report any bugs! https://github.com/appneta/tcpreplay/issues])
  1752. ;;
  1753. esac