configure.in 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930
  1. dnl $Id: configure.in 1578 2006-08-08 04:02:14Z 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. AC_PROG_LIBTOOL
  9. dnl Set version info here!
  10. MAJOR_VERSION=3
  11. MINOR_VERSION=0
  12. MICRO_VERSION=beta11
  13. TCPREPLAY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
  14. dnl Release is only used for the RPM spec file
  15. TCPREPLAY_RELEASE=1
  16. AC_DEFINE(PACKAGE, [tcpreplay], [This is our package name])
  17. AC_DEFINE_UNQUOTED(VERSION, "$TCPREPLAY_VERSION", [What is our version?])
  18. AC_SUBST(TCPREPLAY_VERSION)
  19. AC_SUBST(TCPREPLAY_RELEASE)
  20. CFLAGS="$CFLAGS -Wall -O2 -funroll-loops -std=gnu99" # -std=c99 -Wno-variadic-macros"
  21. dnl Determine OS
  22. AC_CANONICAL_BUILD
  23. AC_CANONICAL_HOST
  24. AC_CANONICAL_TARGET
  25. AC_SUBST(host)
  26. AC_SUBST(build)
  27. AC_SUBST(target)
  28. AM_INIT_AUTOMAKE(tcpreplay, $TCPREPLAY_VERSION, nodefine)
  29. dnl Checks for programs.
  30. AC_PROG_INSTALL
  31. AC_PROG_LIBTOOL
  32. AC_PROG_CC
  33. AC_PROG_CC_STDC
  34. AC_PROG_CXX
  35. AC_PROG_CPP
  36. AC_PROG_LN_S
  37. AC_PROG_RANLIB
  38. AC_PROG_AWK
  39. AC_PROG_MAKE_SET
  40. AC_EXEEXT
  41. AC_PATH_PROG(PRINTF, printf)
  42. AC_PATH_PROG(FIG2DEV, fig2dev)
  43. dnl Look for lyx in the normal locations
  44. dnl The OS X installer puts Lyx at /Applications/Lyx.app/Contents/MacOS/LyX
  45. AC_ARG_WITH(lyx,
  46. AC_HELP_STRING([--with-lyx=FILE], [Path to Lyx binary]),
  47. [ AC_MSG_CHECKING(for lyx)
  48. if test -x $withval ; then
  49. td=$withval
  50. AC_MSG_RESULT($td)
  51. else
  52. AC_MSG_RESULT([Error: $withval does not exist or is not executable])
  53. fi ],
  54. [
  55. case $host in
  56. powerpc-apple-darwin*)
  57. lyx=/Applications/Lyx.app/Contents/MacOS/LyX
  58. if test -x $lyx ; then
  59. AC_MSG_CHECKING(for lyx)
  60. AC_SUBST(LYX, $lyx)
  61. AC_MSG_RESULT($lyx)
  62. else
  63. AC_PATH_PROG(LYX, lyx)
  64. fi
  65. ;;
  66. *)
  67. AC_PATH_PROG(LYX, lyx)
  68. ;;
  69. esac
  70. ])
  71. AC_PATH_PROG(DVIPS, dvips)
  72. AC_PATH_PROG(TEXI2DVI, texi2dvi)
  73. AC_PATH_PROG(LATEX2HTML, latex2html)
  74. AC_PATH_PROG(DVIPDFM, dvipdfm)
  75. AC_PATH_PROG(AUTOGEN, autogen)
  76. AC_HEADER_STDC
  77. AC_HEADER_MAJOR
  78. dnl Checks for typedefs, structures, and compiler characteristics.
  79. AC_TYPE_SIZE_T
  80. AC_HEADER_TIME
  81. AC_C_CONST
  82. AC_C_INLINE
  83. AC_SYS_LARGEFILE
  84. dnl Check for functions
  85. AC_FUNC_FSEEKO
  86. dnl Check for types.
  87. AC_CHECK_TYPE(u_int8_t, uint8_t)
  88. AC_CHECK_TYPE(u_int16_t, uint16_t)
  89. AC_CHECK_TYPE(u_int32_t, uint32_t)
  90. AC_CHECK_TYPE(u_int64_t, uint64_t)
  91. dnl Check for other header files
  92. 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 sys/select.h netinet/in.h poll.h sys/poll.h unistd.h])
  93. dnl Checks for libraries.
  94. AC_CHECK_LIB(socket, socket)
  95. AC_CHECK_LIB(nsl, gethostbyname)
  96. AC_CHECK_LIB(rt, nanosleep)
  97. dnl Checks for library functions.
  98. AC_FUNC_MALLOC
  99. AC_FUNC_MEMCMP
  100. AC_TYPE_SIGNAL
  101. AC_FUNC_VPRINTF
  102. AC_CHECK_FUNCS([gettimeofday ctime memset regcomp strdup strerror strtol strncpy strtoull poll ntohll mmap snprintf vsnprintf])
  103. dnl Look for strlcpy since some BSD's have it
  104. AC_CHECK_FUNCS([strlcpy],have_strlcpy=true,have_strlcpy=false)
  105. AM_CONDITIONAL(SYSTEM_STRLCPY, [test x$have_strlcpy = xtrue])
  106. AC_CHECK_MEMBERS([struct timeval.tv_sec])
  107. AC_C_BIGENDIAN
  108. doctools=no
  109. if test -n "$FIG2DEV" -a -n "$LYX" -a -n "$DVIPS" -a -n "$TEXI2DVI" \
  110. -a -n "$LATEX2HTML" -a -n "$DVIPDFM" ; then
  111. doctools=yes
  112. fi
  113. AM_CONDITIONAL(HAVE_DOCTOOLS, test $doctools = yes)
  114. dnl Enable debugging in code/compiler options
  115. debug=no
  116. AC_ARG_ENABLE(debug,
  117. AC_HELP_STRING([--enable-debug], [Enable debugging code and support for the -d option]),
  118. [ if test x$enableval = xyes; then
  119. debug=yes
  120. # check for gcc 4.0 flags -Wfatal-errors & -Wno-variadic-macros support
  121. CFLAGS="-ggdb -std=gnu99 -Wall -Wextra -Wfatal-errors -Wno-variadic-macros"
  122. AC_COMPILE_IFELSE([#include <stdlib.h>
  123. int main(int argc, char *argv[]) { return(0); }],
  124. [CFLAGS="-ggdb -std=gnu99 -Wall -Wextra -Wfatal-errors -Wno-variadic-macros"],
  125. [CFLAGS="-ggdb -std=gnu99 -Wall -Wextra"])
  126. # We may also want to add:
  127. # -Wformat-security -Wswitch-default -Wunused-paramter -Wpadded"
  128. AC_SUBST(debug_flag)
  129. AC_DEFINE([DEBUG], [1], [Enable debuging code and support for the -d option])
  130. fi])
  131. AC_ARG_ENABLE(pedantic,
  132. AC_HELP_STRING([--enable-pedantic], [Enable gcc's -pedantic option]),
  133. [ if test x$enableval = xyes; then
  134. CFLAGS="$CFLAGS -pedantic"
  135. fi ])
  136. dnl Enable Efense
  137. AC_ARG_ENABLE(efence,
  138. AC_HELP_STRING([--enable-efence], [Enable Electric Fence memory debugger]),
  139. [ if test x$enableval = xyes; then
  140. CFLAGS="$CFLAGS -lefence"
  141. AC_DEFINE([EFENCE], [1], [Enable Electric Fence memory debugger])
  142. fi])
  143. dnl Enable Gprof
  144. AC_ARG_ENABLE(gprof,
  145. AC_HELP_STRING([--enable-gprof], [Enable GNU Profiler]),
  146. [ if test x$enableval = xyes; then
  147. if test $debug = yes; then
  148. CFLAGS="$CFLAGS -pg"
  149. else
  150. # GPROF requires gdb
  151. CFLAGS="$CFLAGS -ggdb -pg -fprofile-arcs"
  152. fi
  153. AC_DEFINE([GPROF], [1], [Enable GNU Profiler])
  154. fi])
  155. dnl Use 64bits for packet counters
  156. AC_ARG_ENABLE(64bits,
  157. AC_HELP_STRING([--enable-64bits], [Use 64bit packet counters]),
  158. [ if test x$enableval = xyes; then
  159. AC_DEFINE([ENABLE_64BITS], [1], [Use 64bit packet counters])
  160. AC_MSG_NOTICE([Using u_int64_t for packet counters])
  161. else
  162. AC_MSG_NOTICE([Using u_int32_t for packet counters])
  163. fi
  164. ])
  165. disable_bpf=no
  166. dnl Turn off *BSD's BPF
  167. AC_ARG_ENABLE(bpf,
  168. AC_HELP_STRING([--disable-bpf], [Disable BPF for sending packets]),
  169. [ disable_bpf=yes ])
  170. disable_pf=no
  171. dnl Turn off Linux's PF_PACKET
  172. AC_ARG_ENABLE(pf,
  173. AC_HELP_STRING([--disable-pf], [Disable Linux PF_PACKET for sending packets]),
  174. [ if test x$enableval = xno ; then
  175. disable_pf=yes
  176. fi
  177. ])
  178. disable_libnet=no
  179. dnl Turn of Libnet
  180. AC_ARG_ENABLE(libnet,
  181. AC_HELP_STRING([--disable-libnet], [Disable Libnet for sending packets]),
  182. [ if test x$enableval = xno ; then
  183. disable_libnet=yes
  184. fi
  185. ])
  186. disable_pcap=no
  187. dnl Turn off pcap for sending
  188. AC_ARG_ENABLE(pcap,
  189. AC_HELP_STRING([--disable-pcap], [Disable Libpcap for sending packets]),
  190. [ if test x$enableval = xno ; then
  191. disable_pcap=yes
  192. fi
  193. ])
  194. dnl Dynamic link libraries
  195. dynamic_link=no
  196. AC_ARG_ENABLE(dynamic-link,
  197. AC_HELP_STRING([--enable-dynamic-link], [Dynamically link libraries]),
  198. [ if test x$enableval = xyes; then
  199. AC_DEFINE([ENABLE_DYNAMIC_LINK], [1], [Enable dynamically linking libs])
  200. dynamic_link=yes
  201. fi
  202. ])
  203. dnl Check for inet_aton and inet_pton
  204. AC_CHECK_FUNC(inet_aton,
  205. AC_DEFINE([HAVE_INET_ATON], [1], [Do we have inet_aton?])
  206. inet_aton=yes,
  207. inet_aton=no)
  208. AC_CHECK_FUNC(inet_pton,
  209. AC_DEFINE([HAVE_INET_PTON], [1], [Do we have inet_pton?])
  210. inet_pton=yes,
  211. inet_pton=no)
  212. AC_CHECK_FUNC(inet_ntop,
  213. AC_DEFINE([HAVE_INET_NTOP], [1], [Do we have inet_ntop?])
  214. inet_ntop=yes,
  215. inet_ntop=no)
  216. if test "$inet_ntop" = "no" -a "$inet_pton" = "no" ; then
  217. AC_MSG_ERROR([We need either inet_ntop or inet_pton])
  218. fi
  219. if test "$inet_aton" = "no" ; then
  220. AC_MSG_ERROR([We need inet_aton])
  221. fi
  222. AC_CHECK_FUNC(inet_addr,
  223. AC_DEFINE([HAVE_INET_ADDR], [1], [Do we have inet_addr?])
  224. inet_addr=yes,
  225. inet_addr=no)
  226. if test x$inet_addr = no ; then
  227. AC_MSG_ERROR([We need inet_addr. See bug 26])
  228. fi
  229. dnl Enable flowreplay
  230. flowreplay=no
  231. AC_ARG_ENABLE(flowreplay,
  232. AC_HELP_STRING([--enable-flowreplay], [Enable building flowreplay (alpha)]),
  233. [ if test x$enableval = xyes; then
  234. flowreplay=yes
  235. AC_DEFINE([ENABLE_FLOWREPLAY], [1], [Enable building flowreplay (alpha)])
  236. fi])
  237. AM_CONDITIONAL(ENABLE_FLOWREPLAY, [test x$flowreplay = xyes])
  238. dnl ##################################################
  239. dnl Checks for libnet (shamelessly horked from dsniff)
  240. dnl ##################################################
  241. foundnet=no
  242. if test $disable_libnet = no ; then
  243. trynetdir=/usr/local
  244. AC_MSG_CHECKING(for libnet)
  245. AC_ARG_WITH(libnet,
  246. AC_HELP_STRING([--with-libnet=DIR], [Use libnet in DIR]),
  247. [trynetdir=$withval])
  248. for testdir in $trynetdir /usr/local /usr ; do
  249. if test -f "${testdir}/include/libnet.h" -a $foundnet = no ; then
  250. LNETINC="${testdir}/include/libnet.h"
  251. LNETINCDIR="$testdir/include"
  252. if test $dynamic_link = yes; then
  253. LNETLIB="-L${testdir}/lib -lnet"
  254. elif test -f "${testdir}/lib64/libnet.a" ; then
  255. LNETLIB="${testdir}/lib64/libnet.a"
  256. else
  257. LNETLIB="${testdir}/lib/libnet.a"
  258. fi
  259. foundnet=$testdir
  260. fi
  261. done
  262. if test $foundnet = no ; then
  263. AC_MSG_RESULT(no)
  264. else
  265. AC_MSG_RESULT($foundnet)
  266. AC_DEFINE([HAVE_LIBNET], [1], [Enable libnet support])
  267. fi
  268. AC_SUBST(LNETINC)
  269. AC_SUBST(LNETLIB)
  270. fi
  271. dnl END OF if $disable_libnet = no ; then
  272. if test $foundnet = yes ; then
  273. OLDLIBS="$LIBS"
  274. OLDCFLAGS="$CFLAGS"
  275. LIBS="$LNETLIB"
  276. CFLAGS="$CFLAGS -I$LNETINCDIR"
  277. dnl Check to see what version of libnet
  278. dnl this code has been reduced a lot, but probably still could be
  279. dnl reduced quite a bit more if we chose too
  280. AC_MSG_CHECKING(for libnet version)
  281. AC_TRY_RUN([
  282. #include <string.h>
  283. #define LIBNET_LIL_ENDIAN 1
  284. #include "$LNETINC"
  285. #define LIB_TEST "1.0"
  286. /*
  287. * simple proggy to test the version of libnet
  288. * returns zero if it's 1.0.x
  289. * or one otherwise
  290. */
  291. int
  292. main (int argc, char *argv[])
  293. {
  294. if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0)
  295. exit(0);
  296. exit(1);
  297. }],
  298. libnet_ver_10=yes
  299. AC_MSG_RESULT(1.0.x),
  300. libnet_ver_10=no,
  301. libnet_ver_10=no
  302. )
  303. AC_TRY_RUN([
  304. #include <string.h>
  305. #include "$LNETINC"
  306. #define LIB_TEST "1.1"
  307. /*
  308. * simple proggy to test the version of libnet
  309. * returns zero if it's 1.0.x
  310. * or one otherwise
  311. */
  312. int
  313. main (int argc, char *argv[])
  314. {
  315. if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0)
  316. exit(0);
  317. exit(1);
  318. }],
  319. libnet_ver_11=yes
  320. AC_MSG_RESULT(1.1.x),
  321. libnet_ver_11=no,
  322. libnet_ver_11=no
  323. )
  324. if test $libnet_ver_10 = no -a $libnet_ver_11 = no ; then
  325. AC_MSG_RESULT(unknown)
  326. AC_MSG_ERROR(Unable to determine version of libnet)
  327. fi
  328. if test $libnet_ver_10 = yes ; then
  329. AC_MSG_ERROR(Libnet version 1.0.x is no longer supported.
  330. Please upgrade to 1.1.0 or better)
  331. fi
  332. dnl restore LIBS & CFLAGS
  333. LIBS="$OLDLIBS"
  334. CFLAGS="$OLDCFLAGS"
  335. fi
  336. dnl END OF if test $foundnet = yes
  337. dnl #####################################################
  338. dnl Checks for libpcap
  339. dnl #####################################################
  340. foundpcap=no
  341. trypcapdir=/usr/local
  342. AC_MSG_CHECKING(for libpcap)
  343. AC_ARG_WITH(libpcap,
  344. AC_HELP_STRING([--with-libpcap=DIR], [Use libpcap in DIR]),
  345. [trypcapdir=$withval])
  346. for testdir in $trypcapdir /usr/local /usr ; do
  347. if test -f "${testdir}/include/pcap.h" -a $foundpcap = no ; then
  348. LPCAPINC="${testdir}/include/pcap.h"
  349. LPCAPINCDIR="${testdir}/include"
  350. if test $dynamic_link = yes; then
  351. LPCAPLIB="-L${testdir}/lib -lpcap"
  352. elif test -f "${testdir}/lib64/libpcap.a" ; then
  353. LPCAPLIB="${testdir}/lib64/libpcap.a"
  354. else
  355. LPCAPLIB="${testdir}/lib/libpcap.a"
  356. fi
  357. foundpcap=$testdir
  358. fi
  359. done
  360. if test $foundpcap = no ; then
  361. AC_MSG_RESULT(no)
  362. AC_ERROR(libpcap not found)
  363. else
  364. AC_MSG_RESULT($foundpcap)
  365. fi
  366. AC_SUBST(LPCAPINC)
  367. AC_SUBST(LPCAPLIB)
  368. dnl Checks to see what version of libpcap we've got
  369. OLDLIBS="$LIBS"
  370. OLDCFLAGS="$CFLAGS"
  371. LIBS="$LPCAPLIB"
  372. CFLAGS="$CFLAGS -I$LPCAPINCDIR"
  373. have_libnet=no
  374. dnl Check to see what version of libpcap
  375. dnl this code has been reduced a lot, but probably still could be
  376. dnl reduced quite a bit more if we chose too
  377. AC_MSG_CHECKING(for libpcap version)
  378. AC_TRY_RUN([
  379. #include <string.h>
  380. #include <stdlib.h>
  381. #include <stdio.h>
  382. #include "$LPCAPINC"
  383. #define PCAP_TEST "0.5"
  384. /*
  385. * simple proggy to test the version of libpcap
  386. * returns zero if version >= 0.5
  387. * or one otherwise
  388. */
  389. extern char pcap_version[];
  390. int
  391. main (int argc, char *argv[])
  392. {
  393. if (strncmp(pcap_version, PCAP_TEST, 3) >= 0)
  394. exit(0);
  395. exit(1);
  396. }],
  397. libpcap_ver=yes
  398. AC_MSG_RESULT(>= 0.5),
  399. libpcap_ver=no
  400. AC_MSG_RESULT(< 0.5),
  401. libpcap_ver=no
  402. AC_MSG_RESULT(< 0.5)
  403. )
  404. if test $libpcap_ver = no ; then
  405. AC_MSG_ERROR(Libpcap versions < 0.5 are not supported.
  406. Please upgrade to version 0.5 or better)
  407. fi
  408. dnl Check to see if we've got pcap_datalink_val_to_name()
  409. AC_MSG_CHECKING(for pcap_datalink_val_to_description)
  410. AC_TRY_RUN([
  411. #include <stdio.h>
  412. #include <stdlib.h>
  413. #include <string.h>
  414. #include "$LPCAPINC"
  415. int
  416. main(int argc, char *argv[]) {
  417. pcap_datalink_val_to_description(1);
  418. exit(0);
  419. }],
  420. have_dlt_to_desc=yes
  421. AC_MSG_RESULT(yes),
  422. have_dlt_to_desc=no
  423. AC_MSG_RESULT(no),
  424. have_dlt_to_desc=no
  425. AC_MSG_RESULT(no)
  426. )
  427. if test $have_dlt_to_desc = yes ; then
  428. AC_DEFINE([HAVE_DLT_VAL_TO_DESC], [1],
  429. [Does libpcap have dlt_val_to_desc?])
  430. fi
  431. dnl This message is placed here for continuity purposes
  432. dnl but things are really set above in the libnet section
  433. AC_MSG_CHECKING(for libnet packet sending support)
  434. if test $disable_libnet = no -a $foundnet != no ; then
  435. AC_MSG_RESULT(yes)
  436. AC_DEFINE([HAVE_LIBNET], [1], [Do we support libnet for sending packets?])
  437. have_libnet=yes
  438. else
  439. AC_MSG_RESULT(no)
  440. fi
  441. have_pcap_inject=no
  442. dnl Check to see if we've got pcap_inject()
  443. AC_MSG_CHECKING(for pcap_inject sending support)
  444. AC_TRY_COMPILE([
  445. #include <stdio.h>
  446. #include <stdlib.h>
  447. #include <string.h>
  448. #include "$LPCAPINC"
  449. ],[
  450. pcap_t *pcap;
  451. char *buf;
  452. pcap_inject(pcap, (void *)buf, 0);
  453. ],[
  454. if test $disable_pcap = no ; then
  455. AC_DEFINE([HAVE_PCAP_INJECT], [1],
  456. [Does libpcap have pcap_inject?])
  457. AC_MSG_RESULT(yes)
  458. have_pcap_inject=yes
  459. else
  460. AC_MSG_RESULT(no)
  461. fi
  462. ],[
  463. AC_MSG_RESULT(no)
  464. ])
  465. have_pcap_sendpacket=no
  466. dnl Check to see if we've got pcap_sendpacket()
  467. AC_MSG_CHECKING(for pcap_sendpacket sending support)
  468. AC_TRY_COMPILE([
  469. #include <stdio.h>
  470. #include <stdlib.h>
  471. #include <string.h>
  472. #include "$LPCAPINC"
  473. ],[
  474. pcap_t *pcap;
  475. u_char *buf;
  476. pcap_sendpacket(pcap, buf, 0);
  477. ],[
  478. if test $disable_pcap = no ; then
  479. AC_DEFINE([HAVE_PCAP_SENDPACKET], [1],
  480. [Does libpcap have pcap_sendpacket?])
  481. AC_MSG_RESULT(yes)
  482. have_pcap_sendpacket=yes
  483. else
  484. AC_MSG_RESULT(no)
  485. fi
  486. ],[
  487. AC_MSG_RESULT(no)
  488. ])
  489. have_pf=no
  490. dnl Check for linux PF_PACKET support
  491. AC_MSG_CHECKING(for PF_PACKET socket sending support)
  492. AC_TRY_COMPILE([
  493. #include <sys/socket.h>
  494. #include <netpacket/packet.h>
  495. #include <net/ethernet.h> /* the L2 protocols */
  496. #include <netinet/in.h> /* htons */
  497. ],[
  498. int pf_socket;
  499. pf_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
  500. ],[
  501. if test $disable_pf = no ; then
  502. AC_DEFINE([HAVE_PF_PACKET], [1],
  503. [Do we have Linux PF_PACKET socket support?])
  504. AC_MSG_RESULT(yes)
  505. have_pf=yes
  506. else
  507. AC_MSG_RESULT(no)
  508. fi
  509. ],[
  510. AC_MSG_RESULT(no)
  511. ])
  512. have_bpf=no
  513. dnl Check for BSD's BPF
  514. AC_MSG_CHECKING(for BPF device sending support)
  515. AC_TRY_RUN([
  516. #include <stdio.h>
  517. #include <stdlib.h>
  518. #include <net/bpf.h>
  519. #include <sys/types.h>
  520. #include <sys/socket.h>
  521. #include <fcntl.h>
  522. #include <sys/time.h>
  523. #include <sys/ioctl.h>
  524. #include <net/bpf.h>
  525. #include <errno.h>
  526. int
  527. main(int argc, char *argv[]) {
  528. int fd;
  529. fd = open("/dev/bpf0", O_RDONLY, 0);
  530. /* if we opened it, we're good */
  531. if (fd > 1)
  532. exit(0);
  533. /* if we got EBUSY or permission denied it exists, so we're good */
  534. if (fd < 0 && (errno == EBUSY || errno == 13))
  535. exit(0);
  536. /* else suck, no good */
  537. exit(-1);
  538. }],
  539. [
  540. if test $disable_bpf = no ; then
  541. AC_DEFINE([HAVE_BPF], [1],
  542. [Do we have BPF device support?])
  543. AC_MSG_RESULT(yes)
  544. have_bpf=yes
  545. else
  546. AC_MSG_RESULT(no)
  547. fi
  548. ])
  549. dnl Make sure we have a valid packet injection mechanisim
  550. if test $have_bpf = no -a $have_pcap_inject = no -a $have_pcap_sendpacket = no \
  551. -a $have_libnet = no -a $have_pf = no ; then
  552. AC_MSG_ERROR([Unable to find a supported method to send packets])
  553. fi
  554. dnl Libpcap support doesn't give us a method to get the hardware address of the
  555. dnl interfaces which prevents us from doing proper filtering to prevent bridging loops
  556. enable_tcpbridge=yes
  557. if test $have_bpf = no -a $have_libnet = no -a $have_pf = no ; then
  558. AC_MSG_NOTICE([tcpbridge support disabled without BPF, Libnet or Linux PF_PACKET])
  559. enable_tcpbridge=no
  560. fi
  561. AM_CONDITIONAL(ENABLE_TCPBRIDGE, [test $enable_tcpbridge = yes])
  562. dnl Older versions of libpcap are missing some DLT types
  563. dnl If doesn't exist, we'll define them in src/common/fakepcap.h
  564. AC_MSG_CHECKING(for DLT_LINUX_SLL in libpcap)
  565. AC_TRY_COMPILE([#include "$LPCAPINC"],
  566. [ int foo;
  567. foo = DLT_LINUX_SLL ],
  568. [ AC_DEFINE([HAVE_DLT_LINUX_SLL], [1],
  569. [Does pcap.h include a header with DLT_LINUX_SLL?])
  570. AC_MSG_RESULT(yes)
  571. ],
  572. AC_MSG_RESULT(no)
  573. )
  574. AC_MSG_CHECKING(for DLT_C_HDLC in libpcap)
  575. AC_TRY_COMPILE([#include "$LPCAPINC"],
  576. [ int foo;
  577. foo = DLT_C_HDLC ],
  578. [ AC_DEFINE([HAVE_DLT_C_HDLC], [1],
  579. [Does pcap.h include a header with DLT_C_HDLC?])
  580. AC_MSG_RESULT(yes)
  581. ],
  582. AC_MSG_RESULT(no)
  583. )
  584. PCAP_BPF_H_FILE="$LPCAPINCDIR/pcap-bpf.h"
  585. AC_MSG_CHECKING(for $PCAP_BPF_H_FILE)
  586. AC_TRY_COMPILE([#include <sys/types.h>
  587. #include <sys/time.h>
  588. #include "$PCAP_BPF_H_FILE"],
  589. [ int foo;
  590. foo = BPF_MAJOR_VERSION; ],
  591. [ AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [1],
  592. [What is the path (if any) to the pcap-bpf.h
  593. header?])
  594. AC_MSG_RESULT(yes)
  595. AC_SUBST(PCAP_BPF_H_FILE)
  596. ],
  597. AC_MSG_RESULT(no)
  598. )
  599. dnl restore LIBS & CFLAGS
  600. LIBS="$OLDLIBS"
  601. CFLAGS="$OLDCFLAGS"
  602. dnl ##################################################
  603. dnl # Check for pcapnav
  604. dnl ##################################################
  605. pcapnav_ver=no
  606. pcncfg=no
  607. AC_ARG_WITH(pcapnav-config,
  608. AC_HELP_STRING([--with-pcapnav-config=FILE], [Use given pcapnav-config]),
  609. [ AC_MSG_CHECKING(for pcapnav-config)
  610. if test -x $withval ; then
  611. pcncfg=$withval
  612. AC_MSG_RESULT($pcncfg)
  613. elif test x$withval = xno ; then
  614. AC_MSG_RESULT(no)
  615. else
  616. AC_MSG_RESULT([Can't find pcapnav-config: disabling offset jump feature])
  617. fi ],
  618. [ AC_PATH_PROG(pcncfg,[pcapnav-config], [no] ) ]
  619. )
  620. if test $pcncfg != no ; then
  621. LNAVLIB=`$pcncfg --libs`
  622. LNAV_CFLAGS=`$pcncfg --cflags`
  623. PCAPNAV_VERSION=`$pcncfg --version`
  624. AC_SUBST(LNAVLIB)
  625. AC_SUBST(LNAV_CFLAGS)
  626. AC_DEFINE_UNQUOTED(PCAPNAV_VERSION, "$PCAPNAV_VERSION",
  627. [libpcapnav's version?])
  628. dnl Check to see what version of libpcapnav
  629. dnl this code has been reduced a lot, but probably still could be
  630. dnl reduced quite a bit more if we chose too
  631. AC_MSG_CHECKING(for libpcapnav version)
  632. AC_TRY_RUN([
  633. #include <string.h>
  634. #define PCAPNAV_TEST "0.4"
  635. /*
  636. * simple proggy to test the version of libpcapnav
  637. * returns zero if version >= 0.4
  638. * or one otherwise
  639. */
  640. int
  641. main (int argc, char *argv[])
  642. {
  643. if (strncmp(PCAPNAV_VERSION, PCAPNAV_TEST, 3) >= 0)
  644. exit(0);
  645. exit(1);
  646. }],
  647. libpcapnav_ver=yes
  648. AC_MSG_RESULT(>= 0.4),
  649. libpcapnav_ver=no
  650. AC_MSG_RESULT(< 0.4),
  651. libpcapnav_ver=no
  652. )
  653. if test x$libpcapnav_ver = xno ; then
  654. AC_MSG_WARN([Libpcapnav versions < 0.4 are not supported.
  655. Please upgrade to version 0.4 or better.
  656. Disabling offset jump feature.])
  657. else
  658. AC_DEFINE([HAVE_PCAPNAV], [1], [Do we have libpcapnav?])
  659. fi
  660. fi # checking pcapnav version
  661. dnl (shamelessly ripped off from libpcap)
  662. dnl Checks to see if unaligned memory accesses fail
  663. dnl
  664. dnl FORCE_ALIGN (DEFINED)
  665. dnl
  666. AC_MSG_CHECKING(for requires strict byte alignment)
  667. AC_CACHE_VAL(unaligned_fail,
  668. [case "$host_cpu" in
  669. # XXX: should also check that they don't do weird things (like on arm)
  670. alpha*|arm*|hp*|mips*|sparc*|ia64)
  671. unaligned_fail=yes
  672. ;;
  673. *)
  674. cat >conftest.c <<EOF
  675. #include <sys/types.h>
  676. #include <sys/wait.h>
  677. #include <stdio.h>
  678. unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
  679. main() {
  680. unsigned int i;
  681. pid_t pid;
  682. int status;
  683. /* avoid "core dumped" message */
  684. pid = fork();
  685. if (pid < 0)
  686. exit(2);
  687. if (pid > 0) {
  688. /* parent */
  689. pid = waitpid(pid, &status, 0);
  690. if (pid < 0)
  691. exit(3);
  692. exit(!WIFEXITED(status));
  693. }
  694. /* child */
  695. i = *(unsigned int *)&a[[1]];
  696. printf("%d\n", i);
  697. exit(0);
  698. }
  699. EOF
  700. ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
  701. conftest.c $LIBS >/dev/null 2>&1
  702. if test ! -x conftest ; then
  703. dnl failed to compile for some reason
  704. unaligned_fail=yes
  705. else
  706. ./conftest >conftest.out
  707. if test ! -s conftest.out ; then
  708. unaligned_fail=yes
  709. else
  710. unaligned_fail=no
  711. fi
  712. fi
  713. rm -f conftest* core core.conftest
  714. ;;
  715. esac])
  716. AC_MSG_RESULT($unaligned_fail)
  717. if test $unaligned_fail = yes ; then
  718. AC_DEFINE([FORCE_ALIGN],[1],[Are we strictly aligned?])
  719. fi
  720. dnl ##################################################
  721. dnl # Check for tcpdump.
  722. dnl ##################################################
  723. td=no
  724. AC_ARG_WITH(tcpdump,
  725. AC_HELP_STRING([--with-tcpdump=FILE], [Path to tcpdump binary]),
  726. [ if test -x $withval ; then
  727. td=$withval
  728. AC_MSG_RESULT([Using tcpdump in $td])
  729. else
  730. AC_MSG_RESULT([Error: $withval does not exist or is not executable])
  731. fi ],
  732. [ AC_PATH_PROG(td, tcpdump, "no", [$PATH:/usr/sbin:/sbin:/usr/local/sbin]) ])
  733. if test "$td" = "no"; then
  734. AC_MSG_WARN([Unable to find tcpdump. Please specify --with-tcpdump.
  735. Disabling verbose reporting.])
  736. else
  737. AC_DEFINE([HAVE_TCPDUMP], [1], [Do we have tcpdump?])
  738. AC_DEFINE_UNQUOTED(TCPDUMP_BINARY, "$td", [The tcpdump binary initially used])
  739. fi
  740. dnl No 'make test' when cross compile
  741. AC_MSG_CHECKING( for 'make test' profile)
  742. if test "$host" != "$build" ; then
  743. AC_MSG_WARN(Unable to do tests when cross-compiling)
  744. fi
  745. dnl Allows user to choose which nic to use for testing purposes
  746. AC_ARG_WITH(testnic,
  747. AC_HELP_STRING([--with-testnic=NIC], [Select which network card to use for testing]),
  748. [ nic1=$withval
  749. nic2=$withval
  750. AC_MSG_RESULT([Using --with-testnic=$withval])],
  751. [
  752. dnl these need to be dynamic based on OS
  753. case $host in
  754. *-*-linux*)
  755. nic1=eth0
  756. nic2=eth0
  757. AC_MSG_RESULT(Linux)
  758. ;;
  759. *-*-solaris*)
  760. nic1=hme0
  761. nic2=hme0
  762. AC_MSG_RESULT(Solaris)
  763. ;;
  764. *-*-sunos*)
  765. nic1=hme0
  766. nic2=hme0
  767. AC_MSG_RESULT(SunOS)
  768. ;;
  769. powerpc-apple-darwin*)
  770. nic1=en0
  771. nic2=en0
  772. AC_MSG_RESULT(Apple OS X)
  773. ;;
  774. *-*-openbsd*)
  775. nic1=xl0
  776. nic2=xl0
  777. AC_MSG_RESULT(OpenBSD)
  778. ;;
  779. *)
  780. AC_MSG_RESULT([$host is unknown!
  781. Please use --with-nictest to select an interface for 'make test'])
  782. ;;
  783. esac])
  784. AC_ARG_WITH(testnic2,
  785. AC_HELP_STRING([--with-testnic2=NIC2], [Select an optional 2nd network card to use for testing]),
  786. [ nic2=$withval ])
  787. AC_MSG_NOTICE([Using $nic1 for 1st test network interface card])
  788. AC_MSG_NOTICE([Using $nic2 for 2nd test network interface card])
  789. AC_SUBST(nic1)
  790. AC_SUBST(nic2)
  791. LIBOPTS_CHECK
  792. AC_OUTPUT([Makefile
  793. doxygen.cfg
  794. lib/Makefile
  795. docs/Makefile
  796. src/Makefile
  797. src/common/Makefile
  798. src/tcpedit/Makefile
  799. src/flow/Makefile
  800. src/defines.h
  801. test/Makefile
  802. test/config
  803. scripts/Makefile
  804. tcpreplay.spec])
  805. if test $doctools = no; then
  806. AC_MSG_NOTICE([One or more tool for creating documentation is unavailable.])
  807. AC_MSG_NOTICE([This is only an issue for developers, so don't worry.])
  808. fi