configure.ac 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248
  1. dnl $Id: configure.ac 2050 2008-05-23 05:00: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.2
  11. dnl Set version info here!
  12. MAJOR_VERSION=3
  13. MINOR_VERSION=3
  14. MICRO_VERSION=2
  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_libdnet = 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 libdnet])
  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_libdnet = no -a $have_pf = no ; then
  702. AC_MSG_NOTICE([tcpbridge support disabled without BPF, Libdnet 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. # Configuration results
  1049. AC_MSG_RESULT(
  1050. ##########################################################################
  1051. TCPREPLAY Suite Configuration Results (${TCPREPLAY_VERSION})
  1052. ##########################################################################
  1053. libpcap: ${foundpcap} (${libpcap_version})
  1054. libnet: ${foundnet}
  1055. libdnet: ${founddnet}
  1056. autogen: ${AUTOGEN} (${AUTOGEN_VERSION})
  1057. Use libopts tearoff: ${enable_local_libopts}
  1058. 64bit counter support: ${use64bit_counters}
  1059. tcpdump binary path: ${tcpdump_path}
  1060. tcpreplay edit support: ${tcpreplay_edit}
  1061. tcpbridge support: ${enable_tcpbridge}
  1062. fragroute support: ${enable_fragroute}
  1063. Supported Packet Injection Methods (*):
  1064. Linux PF_PACKET: ${have_pf}
  1065. BSD BPF: ${have_bpf}
  1066. libnet: ${have_libnet}
  1067. pcap_inject: ${have_pcap_inject}
  1068. pcap_sendpacket: ${have_pcap_sendpacket}
  1069. * In order of preference; see configure --help to override
  1070. )
  1071. case $host in
  1072. *-apple-darwin*)
  1073. AC_MSG_WARN([Apple OS X versions prior to 10.5 (Leopard) has a serious problem!
  1074. Please see: http://tcpreplay.synfin.net/trac/ticket/142 for more details])
  1075. ;;
  1076. *-*-cygwin)
  1077. AC_MSG_WARN([Windows/Cygwin support is still somewhat experimental.
  1078. Please report any bugs! http://tcpreplay.synfin.net/trac/newticket])
  1079. ;;
  1080. esac