configure.ac 61 KB

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