configure.ac 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225
  1. dnl $Id: configure.ac 2371 2009-06-23 15:54:04Z aturner $
  2. AC_INIT(tcpreplay)
  3. AC_CONFIG_SRCDIR(src/tcpreplay.c)
  4. AM_CONFIG_HEADER(src/config.h)
  5. AC_CONFIG_AUX_DIR(config)
  6. AM_MAINTAINER_MODE
  7. AM_WITH_DMALLOC
  8. dnl People building from SVN need the same version of Autogen as I'm using
  9. dnl or specify --disable-local-libopts
  10. MAINTAINER_AUTOGEN_VERSION=5.9.7
  11. AC_CONFIG_MACRO_DIR([m4])
  12. dnl Set version info here!
  13. MAJOR_VERSION=3
  14. MINOR_VERSION=4
  15. MICRO_VERSION=3
  16. TCPREPLAY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
  17. dnl Release is only used for the RPM spec file
  18. TCPREPLAY_RELEASE=1
  19. AC_DEFINE(PACKAGE, [tcpreplay], [This is our package name])
  20. AC_DEFINE_UNQUOTED(VERSION, "$TCPREPLAY_VERSION", [What is our version?])
  21. AC_SUBST(TCPREPLAY_VERSION)
  22. AC_SUBST(TCPREPLAY_RELEASE)
  23. USER_CFLAGS=$CFLAGS
  24. CFLAGS="${CFLAGS} -Wall -O3 -std=gnu99"
  25. dnl Determine OS
  26. AC_CANONICAL_BUILD
  27. AC_CANONICAL_HOST
  28. AC_CANONICAL_TARGET
  29. AC_SUBST(host)
  30. AC_SUBST(build)
  31. AC_SUBST(target)
  32. have_cygwin=no
  33. AC_MSG_CHECKING([for cygwin development environment])
  34. if test `echo $target | grep -c cygwin` -gt 0 ; then
  35. AC_DEFINE([HAVE_WIN32], [1], [Windows/Cygwin])
  36. AC_MSG_RESULT(yes)
  37. have_cygwin=yes
  38. else
  39. AC_MSG_RESULT(no)
  40. fi
  41. AM_INIT_AUTOMAKE(tcpreplay, $TCPREPLAY_VERSION, nodefine)
  42. dnl Checks for programs.
  43. AC_PROG_INSTALL
  44. AC_PROG_LIBTOOL
  45. AM_PROG_CC_C_O
  46. AC_PROG_CC_STDC
  47. AC_PROG_CXX
  48. AC_PROG_CPP
  49. AC_PROG_LN_S
  50. LT_INIT
  51. AC_PROG_AWK
  52. AC_PROG_SED
  53. AC_PROG_MAKE_SET
  54. AC_EXEEXT
  55. AC_PATH_PROG(PRINTF, printf)
  56. AC_PATH_PROG(ECHO, echo)
  57. AC_PATH_PROG(CUT, cut)
  58. AC_PATH_PROG(AUTOGEN, autogen)
  59. AC_PATH_PROG(GROFF, groff)
  60. dnl check autogen version
  61. AUTOGEN_VERSION=unknown
  62. if test -n "${AUTOGEN}" ; then
  63. AC_MSG_CHECKING(for autogen version >= 5.9.x)
  64. ${AUTOGEN} -v >autogen.version
  65. AUTOGEN_VERSION=`cat autogen.version | ${SED} 's|.*\([[0-9\.]]\{5,\}\).*|\1|'`
  66. AUTOGEN_MAJOR=`echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 1`
  67. AUTOGEN_MINOR=`echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 2`
  68. if ( test ${AUTOGEN_MAJOR} -eq 5 && test ${AUTOGEN_MINOR} -lt 9 ) || test ${AUTOGEN_MAJOR} -lt 5 ; then
  69. AC_MSG_RESULT(no)
  70. AC_MSG_WARN([${AUTOGEN} is too old (${AUTOGEN_VERSION}) for building from SVN. Please upgrade to 5.9.x)])
  71. else
  72. AC_MSG_RESULT(yes)
  73. fi
  74. rm -f autogen.version
  75. dnl Compare the installed version with the maintainer version if building from SVN and not using system libopts
  76. if test ! -f src/tcpreplay_opts.c && test "x$enable_local_libopts" = "xyes" ; then
  77. if test $MAINTAINER_AUTOGEN_VERSION != $AUTOGEN_VERSION ; then
  78. 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])
  79. fi
  80. fi
  81. else
  82. if test ! -f src/tcpreplay_opts.c ; then
  83. AC_MSG_ERROR([Please install GNU autogen >= 5.9.x if you are building from SVN])
  84. fi
  85. fi
  86. AC_DEFINE([AUTOGEN_VERSION], [${AUTOGEN_VERSION}], [What version of autogen is installed on this system])
  87. if test "x$enable_local_libopts" = "xyes" ; then
  88. AC_MSG_NOTICE([Using included libopts tearoff])
  89. else
  90. AC_MSG_NOTICE([Using system libopts])
  91. fi
  92. AC_HEADER_STDC
  93. AC_HEADER_MAJOR
  94. dnl Checks for typedefs, structures, and compiler characteristics.
  95. AC_TYPE_SIZE_T
  96. AC_HEADER_TIME
  97. AC_C_CONST
  98. AC_C_INLINE
  99. AC_SYS_LARGEFILE
  100. dnl Check for functions
  101. AC_FUNC_FSEEKO
  102. dnl Check for types.
  103. AC_CHECK_TYPE(u_int8_t, uint8_t)
  104. AC_CHECK_TYPE(u_int16_t, uint16_t)
  105. AC_CHECK_TYPE(u_int32_t, uint32_t)
  106. AC_CHECK_TYPE(u_int64_t, uint64_t)
  107. dnl Older versions of GCC don't support these options
  108. AC_MSG_CHECKING(for $CC -Wextra support)
  109. OLD_CFLAGS=$CFLAGS
  110. CFLAGS="$CFLAGS -Wextra"
  111. wextra=""
  112. AC_COMPILE_IFELSE([#include <stdlib.h>
  113. int main(int argc, char *argv[]) { return(0); }],
  114. [ AC_MSG_RESULT(yes)
  115. wextra="-Wextra" ],
  116. [ AC_MSG_RESULT(no) ])
  117. CFLAGS="$OLD_CFLAGS $wextra"
  118. AC_MSG_CHECKING(for $CC -Wno-variadic-macros support)
  119. OLD_CFLAGS=$CFLAGS
  120. CFLAGS="$CFLAGS -Wno-variadic-macros"
  121. wno_variadic_macros=""
  122. AC_COMPILE_IFELSE([#include <stdlib.h>
  123. int main(int argc, char *argv[]) { return(0); }],
  124. [ AC_MSG_RESULT(yes)
  125. wno_variadic_macros="-Wno-variadic-macros" ],
  126. [ AC_MSG_RESULT(no) ])
  127. CFLAGS="$OLD_CFLAGS $wno_variadic_macros"
  128. AC_MSG_CHECKING(for $CC -Wfatal-errors support)
  129. OLD_CFLAGS=$CFLAGS
  130. CFLAGS="$CFLAGS -Wfatal-errors"
  131. wfatal_errors=""
  132. AC_COMPILE_IFELSE([#include <stdlib.h>
  133. int main(int argc, char *argv[]) { return(0); }],
  134. [ AC_MSG_RESULT(yes)
  135. wfatal_errors="-Wfatal-errors" ],
  136. [ AC_MSG_RESULT(no) ])
  137. CFLAGS="$OLD_CFLAGS $wfatal_errors"
  138. dnl Check for other header files
  139. 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 poll.h sys/poll.h unistd.h sys/param.h])
  140. dnl OpenBSD has special requirements
  141. AC_CHECK_HEADERS([sys/sysctl.h net/route.h], [], [], [
  142. [#if HAVE_SYS_PARAM_H
  143. #include <sys/param.h>
  144. #endif
  145. #if HAVE_SYS_TYPES_H
  146. #include <sys/types.h>
  147. #endif
  148. #if HAVE_SYS_SOCKET_H
  149. #include <sys/socket.h>
  150. #endif
  151. ]])
  152. dnl Checks for libraries.
  153. AC_CHECK_LIB(socket, socket)
  154. AC_CHECK_LIB(nsl, gethostbyname)
  155. AC_CHECK_LIB(rt, nanosleep)
  156. AC_CHECK_LIB(resolv, resolv)
  157. dnl Checks for library functions.
  158. AC_FUNC_MALLOC
  159. AC_FUNC_MEMCMP
  160. AC_TYPE_SIGNAL
  161. AC_FUNC_VPRINTF
  162. AC_CHECK_MEMBERS([struct timeval.tv_sec])
  163. AC_CHECK_FUNCS([gettimeofday ctime memset regcomp strdup strchr strerror strtol strncpy strtoull poll ntohll mmap snprintf vsnprintf strsignal])
  164. dnl Look for strlcpy since some BSD's have it
  165. AC_CHECK_FUNCS([strlcpy],have_strlcpy=true,have_strlcpy=false)
  166. AM_CONDITIONAL(SYSTEM_STRLCPY, [test x$have_strlcpy = xtrue])
  167. AC_C_BIGENDIAN
  168. AM_CONDITIONAL([WORDS_BIGENDIAN], [ test x$ac_cv_c_bigendian = xyes ])
  169. dnl Enable debugging in code/compiler options
  170. debug=no
  171. AC_ARG_ENABLE(debug,
  172. AC_HELP_STRING([--enable-debug], [Enable debugging code and support for the -d option]),
  173. [ if test x$enableval = xyes; then
  174. debug=yes
  175. CFLAGS="${USER_CFLAGS} -ggdb -std=gnu99 -Wall $wextra $wfatal_errors $wno_variadic_macros"
  176. # We may also want to add:
  177. # -Wformat-security -Wswitch-default -Wunused-paramter -Wpadded"
  178. AC_SUBST(debug_flag)
  179. AC_DEFINE([DEBUG], [1], [Enable debuging code and support for the -d option])
  180. fi])
  181. AC_ARG_ENABLE(dmalloc,
  182. AC_HELP_STRING([--enable-dmalloc], [Enable linking to dmalloc for better memory debugging]),
  183. [ if test x$enableval = xyes ; then
  184. dmalloc=yes
  185. AC_DEFINE([ENABLE_DMALLOC], [1], [Enable dmalloc])
  186. AC_DEFINE([DMALLOC_FUNC_CHECK], [1], [Enable dmalloc function arg checking])
  187. CFLAGS="${CFLAGS} -I/opt/local/include"
  188. DMALLOC_LIB="/opt/local/lib/libdmalloc.a"
  189. AC_SUBST(DMALLOC_LIB)
  190. fi])
  191. AC_ARG_ENABLE(pedantic,
  192. AC_HELP_STRING([--enable-pedantic], [Enable gcc's -pedantic option]),
  193. [ if test x$enableval = xyes; then
  194. CFLAGS="$CFLAGS -pedantic"
  195. fi ])
  196. dnl Enable Efense
  197. AC_ARG_ENABLE(efence,
  198. AC_HELP_STRING([--enable-efence], [Enable Electric Fence memory debugger]),
  199. [ if test x$enableval = xyes; then
  200. CFLAGS="$CFLAGS -lefence"
  201. AC_DEFINE([EFENCE], [1], [Enable Electric Fence memory debugger])
  202. fi])
  203. dnl Enable Gprof
  204. AC_ARG_ENABLE(gprof,
  205. AC_HELP_STRING([--enable-gprof], [Enable GNU Profiler]),
  206. [ if test x$enableval = xyes; then
  207. if test $debug = yes; then
  208. CFLAGS="$CFLAGS -pg"
  209. else
  210. # GPROF requires gdb
  211. CFLAGS="$CFLAGS -ggdb -pg -fprofile-arcs"
  212. fi
  213. AC_DEFINE([GPROF], [1], [Enable GNU Profiler])
  214. fi])
  215. dnl Use 64bits for packet counters
  216. use64bit_counters=yes
  217. AC_ARG_ENABLE(64bits,
  218. AC_HELP_STRING([--disable-64bits], [Do not use 64bit packet counters]),
  219. [
  220. AC_MSG_NOTICE([Using u_int32_t for packet counters])
  221. ],
  222. [
  223. AC_DEFINE([ENABLE_64BITS], [1], [Use 64bit packet counters])
  224. AC_MSG_NOTICE([Using u_int64_t for packet counters])
  225. ])
  226. # If we're running gcc add '-D_U_="__attribute__((unused))"' to CFLAGS as well,
  227. # so we can use _U_ to flag unused function arguments and not get warnings
  228. # about them. Otherwise, add '-D_U_=""', so that _U_ used to flag an unused
  229. # function argument will compile with non-GCC compilers.
  230. #
  231. if test "x$GCC" = "xyes" ; then
  232. CFLAGS="-D_U_=\"__attribute__((unused))\" $CFLAGS"
  233. else
  234. CFLAGS="-D_U_=\"\" $CFLAGS"
  235. fi
  236. AC_ARG_ENABLE(force-bpf,
  237. AC_HELP_STRING([--enable-force-bpf], [Force using BPF for sending packets]),
  238. [ AC_DEFINE([FORCE_INJECT_BPF], [1], [Force using BPF for sending packet])])
  239. AC_ARG_ENABLE(force-pf,
  240. AC_HELP_STRING([--enable-force-pf], [Force using Linux's PF_PACKET for sending packets]),
  241. [ AC_DEFINE([FORCE_INJECT_PF], [1], [Force using Linux's PF_PACKET for sending packets])])
  242. AC_ARG_ENABLE(force-libdnet,
  243. AC_HELP_STRING([--enable-force-libdnet], [Force using libdnet for sending packets]),
  244. [ AC_DEFINE([FORCE_INJECT_LIBDNET], [1], [Force using libdnet for sending packets])])
  245. AC_ARG_ENABLE(force-inject,
  246. AC_HELP_STRING([--enable-force-inject], [Force using libpcap's pcap_inject() for sending packets]),
  247. [ AC_DEFINE([FORCE_INJECT_PCAP_INJECT],[1], [Force using libpcap's pcap_inject() for sending packets])])
  248. AC_ARG_ENABLE(force-sendpacket,
  249. AC_HELP_STRING([--enable-force-sendpacket], [Force using libpcap's pcap_sendpacket() for sending packets]),
  250. [ AC_DEFINE([FORCE_INJECT_PCAP_SENDPACKET], [1], [Force using libpcap's pcap_sendpacket() for sending packets])])
  251. dnl Dynamic link libraries
  252. dynamic_link=no
  253. AC_ARG_ENABLE(dynamic-link,
  254. AC_HELP_STRING([--enable-dynamic-link], [Dynamically link libraries]),
  255. [ if test x$enableval = xyes; then
  256. AC_DEFINE([ENABLE_DYNAMIC_LINK], [1], [Enable dynamically linking libs])
  257. dynamic_link=yes
  258. fi
  259. ])
  260. dnl Check for inet_aton and inet_pton
  261. AC_CHECK_FUNC(inet_aton,
  262. AC_DEFINE([HAVE_INET_ATON], [1], [Do we have inet_aton?])
  263. inet_aton=yes,
  264. inet_aton=no)
  265. AC_CHECK_FUNC(inet_pton,
  266. AC_DEFINE([HAVE_INET_PTON], [1], [Do we have inet_pton?])
  267. inet_pton=yes,
  268. inet_pton=no)
  269. AC_CHECK_FUNC(inet_ntop,
  270. AC_DEFINE([HAVE_INET_NTOP], [1], [Do we have inet_ntop?])
  271. inet_ntop=yes,
  272. inet_ntop=no)
  273. if test "$inet_ntop" = "no" -a "$inet_pton" = "no" ; then
  274. AC_MSG_ERROR([We need either inet_ntop or inet_pton])
  275. fi
  276. AC_CHECK_FUNC(inet_addr,
  277. AC_DEFINE([HAVE_INET_ADDR], [1], [Do we have inet_addr?])
  278. inet_addr=yes,
  279. inet_addr=no)
  280. if test x$inet_addr = no ; then
  281. AC_MSG_ERROR([We need inet_addr. See bug 26])
  282. fi
  283. dnl #####################################################
  284. dnl Checks for libpcap
  285. dnl #####################################################
  286. foundpcap=no
  287. trypcapdir=/usr/local
  288. AC_MSG_CHECKING(for libpcap)
  289. AC_ARG_WITH(libpcap,
  290. AC_HELP_STRING([--with-libpcap=DIR], [Use libpcap in DIR]),
  291. [trypcapdir=$withval])
  292. for testdir in $trypcapdir /usr/local /opt/local /usr /wpdpack ; do
  293. if test -f "${testdir}/include/pcap.h" -a $foundpcap = no ; then
  294. LPCAPINC="${testdir}/include/pcap.h"
  295. LPCAPINCDIR="${testdir}/include"
  296. if test $dynamic_link = yes; then
  297. if test -f "${testdir}/lib64/libpcap${shrext_cmds}" ; then
  298. LPCAPLIB="-L${testdir}/lib64 -lpcap"
  299. elif test -f "${testdir}/lib/libpcap${shrext_cmds}" ; then
  300. LPCAPLIB="-L${testdir}/lib -lpcap"
  301. else
  302. AC_ERROR([Unable to find libpcap in ${testdir}])
  303. fi
  304. elif test -f "${testdir}/lib64/libpcap.${libext}" ; then
  305. LPCAPLIB="${testdir}/lib64/libpcap.${libext}"
  306. elif test -f "${testdir}/lib/libpcap.${libext}" ; then
  307. LPCAPLIB="${testdir}/lib/libpcap.${libext}"
  308. elif test -f "${testdir}/lib/libwpcap.${libext}" ; then
  309. LPCAPLIB="${testdir}/lib/libwpcap.${libext}"
  310. AC_DEFINE([HAVE_WINPCAP], [1], [Do we have WinPcap?])
  311. else
  312. AC_ERROR([Unable to find matching library for header file in ${testdir}])
  313. fi
  314. foundpcap=$testdir
  315. fi
  316. done
  317. if test $foundpcap = no ; then
  318. AC_MSG_RESULT(no)
  319. AC_ERROR(libpcap not found)
  320. else
  321. AC_MSG_RESULT($foundpcap)
  322. fi
  323. dnl Checks to see what version of libpcap we've got
  324. OLDLIBS="$LIBS"
  325. OLDCFLAGS="$CFLAGS -I$LPCAPINCDIR"
  326. LIBS="$LPCAPLIB"
  327. CFLAGS="$CFLAGS -I$LPCAPINCDIR"
  328. # Does libpcap require libnl?
  329. AC_SEARCH_LIBS([pcap_close], [pcap],
  330. LPCAPLIB="$LIBS",
  331. AC_ERROR([Unable to link libpcap in ${foundpcap}]),
  332. -lnl)
  333. AC_SUBST(LPCAPINC)
  334. AC_SUBST(LPCAPLIB)
  335. dnl Check to see what version of libpcap
  336. dnl this code has been reduced a lot, but probably still could be
  337. dnl reduced quite a bit more if we chose too
  338. AC_MSG_CHECKING(for libpcap version)
  339. dnl 0.9.6 (which is still thinks it is 0.9.5 due to a bug) introduces an important
  340. dnl fix for OSX. See: http://tcpreplay.synfin.net/trac/ticket/167
  341. libpcap_version_096=no
  342. AC_RUN_IFELSE(AC_LANG_PROGRAM([[
  343. #include <string.h>
  344. #include <stdlib.h>
  345. #include <stdio.h>
  346. #include "$LPCAPINC"
  347. #define PCAP_TEST "0.9.6"
  348. ]], [[
  349. /*
  350. * simple proggy to test the version of libpcap
  351. * returns zero if version >= 0.9.6
  352. * or one otherwise
  353. */
  354. if (strncmp(pcap_lib_version(), PCAP_TEST, 5) >= 0)
  355. exit(0);
  356. exit(1);
  357. ]]), [
  358. libpcap_version_096=yes
  359. ])
  360. libpcap_ver8=no
  361. AC_RUN_IFELSE(AC_LANG_PROGRAM([[
  362. #include <string.h>
  363. #include <stdlib.h>
  364. #include <stdio.h>
  365. #include "$LPCAPINC"
  366. #define PCAP_TEST "0.8"
  367. ]], [[
  368. /*
  369. * simple proggy to test the version of libpcap
  370. * returns zero if version >= 0.8.0
  371. * or one otherwise
  372. */
  373. if (strncmp(pcap_lib_version(), PCAP_TEST, 3) >= 0)
  374. exit(0);
  375. /* winpcap? */
  376. if (strncmp(pcap_lib_version(), "WinPcap", 7) == 0)
  377. exit(0);
  378. exit(1);
  379. ]]), [
  380. libpcap_ver8=yes
  381. ], [
  382. libpcap_ver8=no
  383. ])
  384. libpcap_ver7=no
  385. AC_RUN_IFELSE(AC_LANG_PROGRAM([[
  386. #include <string.h>
  387. #include <stdlib.h>
  388. #include <stdio.h>
  389. #include "$LPCAPINC"
  390. #define PCAP_TEST "0.7.2"
  391. extern const char pcap_version[[]]; /* double up since autoconf escapes things */
  392. ]], [[
  393. /*
  394. * simple proggy to test the version of libpcap
  395. * returns zero if version >= 0.7.2
  396. * or one otherwise
  397. */
  398. if (strncmp(pcap_version, PCAP_TEST, 5) >= 0)
  399. exit(0);
  400. exit(1);
  401. ]]), [
  402. libpcap_ver7=yes
  403. ], [
  404. libpcap_ver7=no
  405. ])
  406. if test x$libpcap_ver8 = xyes ; then
  407. AC_MSG_RESULT(>= 0.8.0)
  408. elif test x$libpcap_ver7 = xyes ; then
  409. AC_MSG_RESULT(>= 0.7.2)
  410. else
  411. AC_MSG_ERROR([Libpcap versions < 0.7.2 are not supported
  412. Please upgrade to version 0.7.2 or better])
  413. fi
  414. libpcap_version=unknown
  415. if test x$libpcap_version_096 = xyes ; then
  416. libpcap_version=">= 0.9.6"
  417. elif test x$libpcap_ver8 = xyes ; then
  418. libpcap_version=">= 0.8.0"
  419. elif test x$libcap_ver7 = xyes ; then
  420. libpcap_version=">= 0.7.0"
  421. fi
  422. dnl Check for pcap_setnonblock()
  423. AC_MSG_CHECKING(for pcap_setnonblock)
  424. AC_LINK_IFELSE(AC_LANG_PROGRAM([[
  425. #include <stdio.h>
  426. #include <stdlib.h>
  427. #include <string.h>
  428. #include "$LPCAPINC"
  429. ]],[[
  430. pcap_t *p;
  431. char *errbuf;
  432. pcap_setnonblock(p, 1, errbuf);
  433. exit(0);
  434. ]]), [
  435. have_pcap_setnonblock=yes
  436. AC_MSG_RESULT(yes)
  437. ], [
  438. have_pcap_setnonblock=no
  439. AC_MSG_RESULT(no)
  440. ])
  441. if test $have_pcap_setnonblock = yes ; then
  442. AC_DEFINE([HAVE_PCAP_SETNONBLOCK], [1],
  443. [Does libpcap have pcap_setnonblock?])
  444. fi
  445. dnl Check to see if we've got pcap_datalink_val_to_name()
  446. AC_MSG_CHECKING(for pcap_datalink_val_to_description)
  447. AC_LINK_IFELSE(AC_LANG_PROGRAM([[
  448. #include <stdio.h>
  449. #include <stdlib.h>
  450. #include <string.h>
  451. #include "$LPCAPINC"
  452. ]],[[
  453. if (strcmp(pcap_datalink_val_to_description(1), "Ethernet (10Mb)") == 0)
  454. exit(0);
  455. exit(1);
  456. ]]),[
  457. have_dlt_to_desc=yes
  458. AC_MSG_RESULT(yes)
  459. ], [
  460. have_dlt_to_desc=no
  461. AC_MSG_RESULT(no)
  462. ])
  463. if test $have_dlt_to_desc = yes ; then
  464. AC_DEFINE([HAVE_DLT_VAL_TO_DESC], [1],
  465. [Does libpcap have pcap_datalink_val_to_description?])
  466. fi
  467. dnl Check for pcap_get_selectable_fd()
  468. AC_MSG_CHECKING(for pcap_get_selectable_fd)
  469. AC_LINK_IFELSE(AC_LANG_PROGRAM([[
  470. #include <stdio.h>
  471. #include <stdlib.h>
  472. #include <string.h>
  473. #include "$LPCAPINC"
  474. ]], [[
  475. int f;
  476. pcap_t *p;
  477. f = pcap_get_selectable_fd(p);
  478. exit(0);
  479. ]]), [
  480. have_pcap_get_selectable_fd=yes
  481. AC_MSG_RESULT(yes)
  482. ], [
  483. have_pcap_get_selectable_fd=no
  484. AC_MSG_RESULT(no)
  485. ])
  486. if test x$have_pcap_get_selectable_fd = xyes ; then
  487. AC_DEFINE([HAVE_PCAP_GET_SELECTABLE_FD], [1],
  488. [Does libpcap have pcap_get_selectable_fd?])
  489. fi
  490. dnl Important: winpcap apparently defines functions in it's header files
  491. dnl which aren't actually in the library. Totally fucked up. Hence, we
  492. dnl must actually LINK the code, not just compile it.
  493. dnl Check to see if we've got pcap_dump_fopen()
  494. AC_MSG_CHECKING(for pcap_dump_fopen)
  495. AC_LINK_IFELSE(AC_LANG_PROGRAM([[
  496. #include <stdio.h>
  497. #include <stdlib.h>
  498. #include <string.h>
  499. #include "$LPCAPINC"
  500. ]],[[
  501. pcap_dumper_t *dump;
  502. pcap_t *pcap;
  503. FILE *foo;
  504. dump = pcap_dump_fopen(pcap, foo);
  505. ]]),[
  506. have_pcap_dump_fopen=yes
  507. AC_MSG_RESULT(yes)
  508. ], [
  509. have_pcap_dump_fopen=no
  510. AC_MSG_RESULT(no)
  511. ])
  512. if test $have_pcap_dump_fopen = yes ; then
  513. AC_DEFINE([HAVE_PCAP_DUMP_FOPEN], [1],
  514. [Does libpcap have pcap_dump_fopen?])
  515. else
  516. AC_MSG_NOTICE([--verbose mode requires libpcap >= 0.9.0])
  517. fi
  518. have_pcap_inject=no
  519. dnl Check to see if we've got pcap_inject()
  520. AC_MSG_CHECKING(for pcap_inject sending support)
  521. AC_LINK_IFELSE(AC_LANG_PROGRAM([[
  522. #include <stdio.h>
  523. #include <stdlib.h>
  524. #include <string.h>
  525. #include "$LPCAPINC"
  526. ]],[[
  527. pcap_t *pcap;
  528. char *buf;
  529. pcap_inject(pcap, (void *)buf, 0);
  530. ]]),[
  531. have_pcap_inject=yes
  532. AC_MSG_RESULT(yes)
  533. ], [
  534. have_pcap_inject=no
  535. AC_MSG_RESULT(no)
  536. ])
  537. if test $have_pcap_inject = yes ; then
  538. AC_DEFINE([HAVE_PCAP_INJECT], [1], [Does libpcap have pcap_inject?])
  539. fi
  540. have_pcap_sendpacket=no
  541. dnl Check to see if we've got pcap_sendpacket()
  542. AC_MSG_CHECKING(for pcap_sendpacket sending support)
  543. AC_LINK_IFELSE(AC_LANG_PROGRAM([[
  544. #include <stdio.h>
  545. #include <stdlib.h>
  546. #include <string.h>
  547. #include "$LPCAPINC"
  548. ]],[[
  549. pcap_t *pcap;
  550. u_char *buf;
  551. pcap_sendpacket(pcap, buf, 0);
  552. ]]),[
  553. have_pcap_sendpacket=yes
  554. AC_MSG_RESULT(yes)
  555. ], [
  556. have_pcap_sendpacket=no
  557. AC_MSG_RESULT(no)
  558. ])
  559. if test $have_pcap_sendpacket = yes ; then
  560. AC_DEFINE([HAVE_PCAP_SENDPACKET], [1], [Does libpcap have pcap_sendpacket?])
  561. fi
  562. have_pcap_breakloop=no
  563. AC_MSG_CHECKING(for pcap_breakloop)
  564. AC_LINK_IFELSE(AC_LANG_PROGRAM([[
  565. #include <stdio.h>
  566. #include <stdlib.h>
  567. #include <string.h>
  568. #include "$LPCAPINC"
  569. ]],[[
  570. pcap_t *pcap;
  571. pcap_sendpacket(pcap);
  572. ]]),[
  573. have_pcap_breakloop=yes
  574. AC_MSG_RESULT(yes)
  575. ], [
  576. have_pcap_breakloop=no
  577. AC_MSG_RESULT(no)
  578. ])
  579. if test $have_pcap_breakloop = yes ; then
  580. AC_DEFINE([HAVE_PCAP_BREAKLOOP], [1], [Does libpcap have pcap_breakloop?])
  581. fi
  582. have_pcap_version=no
  583. dnl Check to see if we have pcap_version[]
  584. AC_MSG_CHECKING(for pcap_version[])
  585. AC_TRY_COMPILE([
  586. #include <stdio.h>
  587. #include <stdlib.h>
  588. #include <string.h>
  589. #include "$LPCAPINC"
  590. extern char pcap_version[];
  591. ],[
  592. printf("%s", pcap_version);
  593. ],[
  594. AC_DEFINE([HAVE_PCAP_VERSION],[1], [Does libpcap have pcap_version[]])
  595. AC_MSG_RESULT(yes)
  596. ],[
  597. AC_MSG_RESULT(no)
  598. ])
  599. # Tcpbridge requires libpcap and pcap_sendpacket()
  600. enable_tcpbridge=no
  601. if test x$foundpcap != xno -a x$have_pcap_sendpacket = xyes ; then
  602. # if we have pcap_sendpacket() then we can build tcpbridge on non-BPF systems
  603. if test x$have_bpf = xno; then
  604. AC_DEFINE(ENABLE_TCPBRIDGE, [1], [Compile tcpbridge])
  605. enable_tcpbridge=yes
  606. AC_MSG_NOTICE([Building tcpbridge])
  607. # BPF systems need to also have pcap_setnonblock()
  608. elif test x$have_pcap_setnonblock = xyes ; then
  609. AC_DEFINE(ENABLE_TCPBRIDGE, [1], [Compile tcpbridge])
  610. enable_tcpbridge=yes
  611. AC_MSG_NOTICE([Building tcpbridge])
  612. else
  613. AC_MSG_WARN([Unable to build tcpbridge. Try installing latest libpcap!])
  614. fi
  615. fi
  616. AM_CONDITIONAL(COMPILE_TCPBRIDGE, [test x$enable_tcpbridge = xyes ])
  617. have_pf=no
  618. dnl Check for linux PF_PACKET support
  619. AC_MSG_CHECKING(for PF_PACKET socket sending support)
  620. AC_TRY_COMPILE([
  621. #include <sys/socket.h>
  622. #include <netpacket/packet.h>
  623. #include <net/ethernet.h> /* the L2 protocols */
  624. #include <netinet/in.h> /* htons */
  625. ],[
  626. int pf_socket;
  627. pf_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
  628. ],[
  629. AC_DEFINE([HAVE_PF_PACKET], [1],
  630. [Do we have Linux PF_PACKET socket support?])
  631. AC_MSG_RESULT(yes)
  632. have_pf=yes
  633. ],[
  634. AC_MSG_RESULT(no)
  635. ])
  636. have_bpf=no
  637. dnl Check for BSD's BPF
  638. AC_MSG_CHECKING(for BPF device sending support)
  639. AC_TRY_RUN([
  640. #include <stdio.h>
  641. #include <stdlib.h>
  642. #include <sys/types.h>
  643. #include <sys/socket.h>
  644. #include <fcntl.h>
  645. #include <sys/time.h>
  646. #include <sys/ioctl.h>
  647. #include <stdint.h>
  648. #include <net/bpf.h>
  649. #include <errno.h>
  650. int
  651. main(int argc, char *argv[]) {
  652. int fd;
  653. fd = open("/dev/bpf0", O_RDONLY, 0);
  654. /* if we opened it, we're good */
  655. if (fd > 1)
  656. exit(0);
  657. /* if we got EBUSY or permission denied it exists, so we're good */
  658. if (fd < 0 && (errno == EBUSY || errno == 13))
  659. exit(0);
  660. /* else suck, no good */
  661. exit(-1);
  662. }],
  663. [
  664. AC_DEFINE([HAVE_BPF], [1],
  665. [Do we have BPF device support?])
  666. AC_MSG_RESULT(yes)
  667. have_bpf=yes
  668. ],[
  669. AC_MSG_RESULT(no)
  670. ])
  671. dnl ##################################################
  672. dnl # Check for libdnet, but only if not Cygwin!
  673. dnl ##################################################
  674. founddnet=no
  675. have_libdnet=no
  676. libdnet_version=
  677. enable_fragroute=no
  678. trydnetdir=/usr/local
  679. if test $have_cygwin == no ; then
  680. AC_MSG_CHECKING(for libdnet)
  681. AC_ARG_WITH(libdnet,
  682. AC_HELP_STRING([--with-libdnet=DIR], [Use libdnet in DIR]),
  683. [trydnetdir=$withval])
  684. for testdir in $trydnetdir /usr/local /opt/local /usr ; do
  685. if test -x ${testdir}/bin/dnet-config -a $founddnet = no ; then
  686. LDNETINC="`$testdir/bin/dnet-config --cflags`"
  687. LDNETLIB="`$testdir/bin/dnet-config --libs`"
  688. libdnet_version="`$testdir/bin/dnet-config --version`"
  689. founddnet=$testdir
  690. fi
  691. done
  692. if test $founddnet = no ; then
  693. AC_MSG_RESULT(no)
  694. AC_MSG_WARN([libdnet not found, disabling fragroute feature])
  695. else
  696. AC_MSG_RESULT($founddnet)
  697. enable_fragroute=yes
  698. have_libdnet=yes
  699. AC_DEFINE([HAVE_LIBDNET], [1], [Do we have libdnet?])
  700. fi
  701. else
  702. AC_MSG_NOTICE([Skipping libdnet check under Cygwin for compatibility reasons])
  703. fi
  704. AC_SUBST(LDNETINC)
  705. AC_SUBST(LDNETLIB)
  706. AC_DEFINE_UNQUOTED([LIBDNET_VERSION], "$libdnet_version", [Version of libdnet])
  707. AM_CONDITIONAL(COMPILE_FRAGROUTE, [test x$founddnet != xno])
  708. if test x$founddnet != xno ; then
  709. AC_DEFINE(ENABLE_FRAGROUTE, [1], [Enable fragroute module])
  710. fi
  711. dnl Make sure we have a valid packet injection mechanisim
  712. if test $have_bpf = no -a $have_pcap_inject = no -a $have_pcap_sendpacket = no \
  713. -a $have_libdnet = no -a $have_pf = no ; then
  714. AC_MSG_ERROR([Unable to find a supported method to send packets. Please upgrade your libpcap or enable libdnet])
  715. fi
  716. dnl Older versions of libpcap are missing some DLT types
  717. dnl If doesn't exist, we'll define them in src/common/fakepcap.h
  718. AC_MSG_CHECKING(for DLT_LINUX_SLL in libpcap)
  719. AC_TRY_COMPILE([#include "$LPCAPINC"],
  720. [ int foo;
  721. foo = DLT_LINUX_SLL ],
  722. [ AC_DEFINE([HAVE_DLT_LINUX_SLL], [1],
  723. [Does pcap.h include a header with DLT_LINUX_SLL?])
  724. AC_MSG_RESULT(yes)
  725. ],
  726. AC_MSG_RESULT(no)
  727. )
  728. AC_MSG_CHECKING(for DLT_C_HDLC in libpcap)
  729. AC_TRY_COMPILE([#include "$LPCAPINC"],
  730. [ int foo;
  731. foo = DLT_C_HDLC ],
  732. [ AC_DEFINE([HAVE_DLT_C_HDLC], [1],
  733. [Does pcap.h include a header with DLT_C_HDLC?])
  734. AC_MSG_RESULT(yes)
  735. ],
  736. AC_MSG_RESULT(no)
  737. )
  738. PCAP_BPF_H_FILE="$LPCAPINCDIR/pcap-bpf.h"
  739. AC_MSG_CHECKING(for $PCAP_BPF_H_FILE)
  740. AC_TRY_COMPILE([#include <sys/types.h>
  741. #include <sys/time.h>
  742. #include <stdint.h>
  743. #include "$PCAP_BPF_H_FILE"],
  744. [ int foo;
  745. foo = BPF_MAJOR_VERSION; ],
  746. [ AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [1],
  747. [What is the path (if any) to the pcap-bpf.h
  748. header?])
  749. AC_MSG_RESULT(yes)
  750. AC_SUBST(PCAP_BPF_H_FILE)
  751. ],
  752. AC_MSG_RESULT(no)
  753. )
  754. foundbpfheader=no
  755. AC_MSG_CHECKING(for libpcap bpf header)
  756. for testfile in $LPCAPINCDIR/pcap/bpf.h $LPCAPINCDIR/pcap-bpf.h ; do
  757. if test -f "${testfile}" -a $foundbpfheader = no ; then
  758. AC_TRY_COMPILE([
  759. #include <sys/types.h>
  760. #include <sys/time.h>
  761. #include <stdint.h>
  762. #include "$testfile"],
  763. [
  764. int foo;
  765. foo = BPF_MAJOR_VERSION;
  766. ],
  767. [
  768. foundbpfheader=yes
  769. PCAP_BPF_H_FILE=$testfile
  770. AC_SUBST(PCAP_BPF_H_FILE)
  771. AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [1],
  772. [What is the path (if any) to the libpcap bpf header file?])
  773. AC_MSG_RESULT($testfile)
  774. ],
  775. AC_MSG_RESULT(no)
  776. )
  777. fi
  778. done
  779. dnl restore LIBS & CFLAGS
  780. LIBS="$OLDLIBS"
  781. CFLAGS="$OLDCFLAGS"
  782. dnl ##################################################
  783. dnl # Check for pcapnav
  784. dnl ##################################################
  785. pcapnav_ver=no
  786. pcncfg=no
  787. AC_ARG_WITH(pcapnav-config,
  788. AC_HELP_STRING([--with-pcapnav-config=FILE], [Use given pcapnav-config]),
  789. [ AC_MSG_CHECKING(for pcapnav-config)
  790. if test -x $withval ; then
  791. pcncfg=$withval
  792. AC_MSG_RESULT($pcncfg)
  793. elif test x$withval = xno ; then
  794. AC_MSG_RESULT(no)
  795. else
  796. AC_MSG_RESULT([Can't find pcapnav-config: disabling offset jump feature])
  797. fi ],
  798. [ AC_PATH_PROG(pcncfg,[pcapnav-config], [no] ) ]
  799. )
  800. if test $pcncfg != no ; then
  801. LNAVLIB=`$pcncfg --libs`
  802. LNAV_CFLAGS=`$pcncfg --cflags`
  803. PCAPNAV_VERSION=`$pcncfg --version`
  804. AC_SUBST(LNAVLIB)
  805. AC_SUBST(LNAV_CFLAGS)
  806. AC_DEFINE_UNQUOTED(PCAPNAV_VERSION, "$PCAPNAV_VERSION",
  807. [libpcapnav's version?])
  808. dnl Check to see what version of libpcapnav
  809. dnl this code has been reduced a lot, but probably still could be
  810. dnl reduced quite a bit more if we chose too
  811. AC_MSG_CHECKING(for libpcapnav version)
  812. AC_TRY_RUN([
  813. #include <string.h>
  814. #define PCAPNAV_TEST "0.4"
  815. /*
  816. * simple proggy to test the version of libpcapnav
  817. * returns zero if version >= 0.4
  818. * or one otherwise
  819. */
  820. int
  821. main (int argc, char *argv[])
  822. {
  823. if (strncmp(PCAPNAV_VERSION, PCAPNAV_TEST, 3) >= 0)
  824. exit(0);
  825. exit(1);
  826. } ],
  827. libpcapnav_ver=yes
  828. AC_MSG_RESULT(>= 0.4),
  829. libpcapnav_ver=no
  830. AC_MSG_RESULT(< 0.4),
  831. libpcapnav_ver=no
  832. )
  833. if test x$libpcapnav_ver = xno ; then
  834. AC_MSG_WARN([Libpcapnav versions < 0.4 are not supported.
  835. Please upgrade to version 0.4 or better.
  836. Disabling offset jump feature.])
  837. else
  838. AC_DEFINE([HAVE_PCAPNAV], [1], [Do we have libpcapnav?])
  839. fi
  840. fi # checking pcapnav version
  841. dnl (shamelessly ripped off from libpcap)
  842. dnl Checks to see if unaligned memory accesses fail
  843. dnl
  844. dnl FORCE_ALIGN (DEFINED)
  845. dnl
  846. AC_MSG_CHECKING(for requires strict byte alignment)
  847. AC_CACHE_VAL(unaligned_cv_fail,
  848. [case "$host_cpu" in
  849. # XXX: should also check that they don't do weird things (like on arm)
  850. alpha*|arm*|hp*|mips*|sparc*|ia64)
  851. unaligned_cv_fail=yes
  852. ;;
  853. *)
  854. cat >conftest.c <<EOF
  855. #include <sys/types.h>
  856. #include <sys/wait.h>
  857. #include <stdio.h>
  858. unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
  859. main() {
  860. unsigned int i;
  861. pid_t pid;
  862. int status;
  863. /* avoid "core dumped" message */
  864. pid = fork();
  865. if (pid < 0)
  866. exit(2);
  867. if (pid > 0) {
  868. /* parent */
  869. pid = waitpid(pid, &status, 0);
  870. if (pid < 0)
  871. exit(3);
  872. exit(!WIFEXITED(status));
  873. }
  874. /* child */
  875. i = *(unsigned int *)&a[[1]];
  876. printf("%d\n", i);
  877. exit(0);
  878. }
  879. EOF
  880. ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
  881. conftest.c $LIBS >/dev/null 2>&1
  882. if test ! -x conftest ; then
  883. dnl failed to compile for some reason
  884. unaligned_cv_fail=yes
  885. else
  886. ./conftest >conftest.out
  887. if test ! -s conftest.out ; then
  888. unaligned_cv_fail=yes
  889. else
  890. unaligned_cv_fail=no
  891. fi
  892. fi
  893. rm -f conftest* core core.conftest
  894. ;;
  895. esac
  896. ])
  897. AC_MSG_RESULT($unaligned_cv_fail)
  898. if test $unaligned_cv_fail = yes ; then
  899. AC_DEFINE([FORCE_ALIGN], [1], [Are we strictly aligned?])
  900. fi
  901. dnl ##################################################
  902. dnl # Check for tcpdump.
  903. dnl ##################################################
  904. tcpdump_path=no
  905. AC_ARG_WITH(tcpdump,
  906. AC_HELP_STRING([--with-tcpdump=FILE], [Path to tcpdump binary]),
  907. [ if test -x $withval ; then
  908. tcpdump_path=$withval
  909. AC_MSG_RESULT([Using tcpdump in $tcpdump_path])
  910. else
  911. AC_MSG_RESULT([Error: $withval does not exist or is not executable])
  912. fi ],
  913. [ AC_PATH_PROG(tcpdump_path, tcpdump, "no", [$PATH:/usr/sbin:/sbin:/usr/local/sbin]) ])
  914. if test "$tcpdump_path" = "no"; then
  915. AC_MSG_WARN([Unable to find tcpdump. Please specify --with-tcpdump.
  916. Disabling --verbose])
  917. else
  918. AC_DEFINE([HAVE_TCPDUMP], [1], [Do we have tcpdump?])
  919. AC_DEFINE_UNQUOTED(TCPDUMP_BINARY, "$tcpdump_path", [The tcpdump binary initially used])
  920. fi
  921. AM_CONDITIONAL([ENABLE_TCPDUMP], test "$tcpdump_path" != "no" -a x$have_pcap_dump_fopen = xyes)
  922. if test x$tcpdump_path != xno -a x$have_pcap_dump_fopen = xyes ; then
  923. AC_DEFINE([ENABLE_VERBOSE], [1], [Do we have tcpdump and pcap_dump_fopen()?])
  924. else
  925. AC_MSG_WARN([Your version of libpcap is too old for --verbose support])
  926. fi
  927. dnl No 'make test' when cross compile
  928. AC_MSG_CHECKING(for 'make test' profile)
  929. if test "$host" != "$build" ; then
  930. AC_MSG_WARN(Unable to do tests when cross-compiling)
  931. fi
  932. dnl Allows user to choose which nic to use for testing purposes
  933. AC_ARG_WITH(testnic,
  934. AC_HELP_STRING([--with-testnic=NIC], [Select which network card to use for testing]),
  935. [ nic1=$withval
  936. nic2=$withval
  937. AC_MSG_RESULT([Using --with-testnic=$withval])],
  938. [
  939. dnl There's a bug in OS X which causes pcap_findalldevs() to make the wifi NIC to disassociate
  940. dnl so under OSX we disable the interface list feature
  941. disable_pcap_findalldevs=no
  942. osx_frameworks=no
  943. dnl these need to be dynamic based on OS
  944. case $host in
  945. *-*-linux*)
  946. nic1=eth0
  947. nic2=eth0
  948. AC_MSG_RESULT(Linux)
  949. ;;
  950. *-*-solaris*)
  951. nic1=hme0
  952. nic2=hme0
  953. AC_MSG_RESULT(Solaris)
  954. ;;
  955. *-*-sunos*)
  956. nic1=hme0
  957. nic2=hme0
  958. AC_MSG_RESULT(SunOS)
  959. ;;
  960. *-apple-darwin*)
  961. nic1=en0
  962. nic2=en0
  963. if test x$libpcap_version_096 = xno ; then
  964. disable_pcap_findalldevs=yes
  965. fi
  966. AC_DEFINE([HAVE_ABSOLUTE_TIME], [1], [Have OS X UpTime()/AbsoluteTime high-precision timing])
  967. osx_frameworks=yes
  968. AC_DEFINE([HAVE_DARWIN], [1], [Building Apple/Darwin])
  969. AC_MSG_RESULT(Apple OS X)
  970. ;;
  971. *-*-openbsd*)
  972. nic1=xl0
  973. nic2=xl0
  974. AC_MSG_RESULT(OpenBSD)
  975. ;;
  976. *-*-cygwin)
  977. AC_MSG_RESULT(Win32/Cygwin)
  978. nic1=%0
  979. nic2=%0
  980. ;;
  981. *)
  982. AC_MSG_RESULT([$host is unknown! Using first non-loopback interface])
  983. nic1=%0
  984. nic2=%0
  985. ;;
  986. esac])
  987. AM_CONDITIONAL([ENABLE_OSX_FRAMEWORKS], test "$osx_frameworks" == "yes")
  988. AC_ARG_WITH(testnic2,
  989. AC_HELP_STRING([--with-testnic2=NIC2], [Select an optional 2nd network card to use for testing]),
  990. [ nic2=$withval ])
  991. AC_MSG_NOTICE([Using $nic1 for 1st test network interface card])
  992. AC_MSG_NOTICE([Using $nic2 for 2nd test network interface card])
  993. AC_SUBST(nic1)
  994. AC_SUBST(nic2)
  995. AC_MSG_CHECKING([if it's ok to use pcap_findalldevs()])
  996. if test x$disable_pcap_findalldevs = xno ; then
  997. AC_DEFINE([ENABLE_PCAP_FINDALLDEVS], [1], [Enable use of pcap_findalldevs()])
  998. AC_MSG_RESULT(yes)
  999. else
  1000. AC_MSG_RESULT(no)
  1001. fi
  1002. dnl tcpreplay has (so far) been relying on leading-edge autogen.
  1003. dnl Therefore, by default:
  1004. dnl - use the version we ship with
  1005. dnl - do not install it
  1006. dnl - build a static copy (AC_DISABLE_SHARED - implicitly done earlier)
  1007. case "${enable_local_libopts+set}" in
  1008. set) ;;
  1009. *) enable_local_libopts=yes ;;
  1010. esac
  1011. case "${enable_libopts_install+set}" in
  1012. set) ;;
  1013. *) enable_libopts_install=no ;;
  1014. esac
  1015. LIBOPTS_CHECK(libopts)
  1016. AC_OUTPUT([Makefile
  1017. doxygen.cfg
  1018. lib/Makefile
  1019. docs/Makefile
  1020. src/Makefile
  1021. src/common/Makefile
  1022. src/tcpedit/Makefile
  1023. src/fragroute/Makefile
  1024. src/defines.h
  1025. test/Makefile
  1026. test/config
  1027. scripts/Makefile])
  1028. # Configuration results
  1029. AC_MSG_RESULT(
  1030. ##########################################################################
  1031. TCPREPLAY Suite Configuration Results (${TCPREPLAY_VERSION})
  1032. ##########################################################################
  1033. libpcap: ${foundpcap} (${libpcap_version})
  1034. libdnet: ${founddnet} (${libdnet_version})
  1035. autogen: ${AUTOGEN} (${AUTOGEN_VERSION})
  1036. Use libopts tearoff: ${enable_local_libopts}
  1037. 64bit counter support: ${use64bit_counters}
  1038. tcpdump binary path: ${tcpdump_path}
  1039. tcpreplay edit support: ${tcpreplay_edit}
  1040. fragroute support: ${enable_fragroute}
  1041. tcpbridge support: ${enable_tcpbridge}
  1042. Supported Packet Injection Methods (*):
  1043. Linux PF_PACKET: ${have_pf}
  1044. BSD BPF: ${have_bpf}
  1045. libdnet: ${have_libdnet}
  1046. pcap_inject: ${have_pcap_inject}
  1047. pcap_sendpacket: ${have_pcap_sendpacket} **
  1048. * In order of preference; see configure --help to override
  1049. ** Required for tcpbridge
  1050. )
  1051. case $host in
  1052. *-apple-darwin*)
  1053. AC_MSG_WARN([Apple OS X versions prior to 10.5 (Leopard) has a serious problem!
  1054. Please see: http://tcpreplay.synfin.net/trac/ticket/142 for more details])
  1055. ;;
  1056. *-*-cygwin)
  1057. AC_MSG_WARN([Windows/Cygwin support is still somewhat experimental.
  1058. Please report any bugs! http://tcpreplay.synfin.net/trac/newticket])
  1059. ;;
  1060. esac