configure.ac 35 KB

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