configure.ac 57 KB

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