configure.in 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046
  1. dnl $Id: configure.in 1808 2007-04-15 01:46:13Z 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=RC1
  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"
  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. AC_MSG_CHECKING([for cygwin development environment])
  29. if test `echo $target | grep -c cygwin` -gt 0 ; then
  30. AC_DEFINE([HAVE_WIN32], [1], [Windows/Cygwin])
  31. AC_MSG_RESULT(yes)
  32. else
  33. AC_MSG_RESULT(no)
  34. fi
  35. AM_INIT_AUTOMAKE(tcpreplay, $TCPREPLAY_VERSION, nodefine)
  36. dnl Checks for programs.
  37. AC_PROG_INSTALL
  38. AC_PROG_LIBTOOL
  39. AC_PROG_CC
  40. AC_PROG_CC_STDC
  41. AC_PROG_CXX
  42. AC_PROG_CPP
  43. AC_PROG_LN_S
  44. AC_PROG_RANLIB
  45. AC_PROG_AWK
  46. AC_PROG_MAKE_SET
  47. AC_EXEEXT
  48. AC_PATH_PROG(PRINTF, printf)
  49. AC_PATH_PROG(AUTOGEN, autogen)
  50. AC_HEADER_STDC
  51. AC_HEADER_MAJOR
  52. dnl Checks for typedefs, structures, and compiler characteristics.
  53. AC_TYPE_SIZE_T
  54. AC_HEADER_TIME
  55. AC_C_CONST
  56. AC_C_INLINE
  57. AC_SYS_LARGEFILE
  58. dnl Check for functions
  59. AC_FUNC_FSEEKO
  60. dnl Check for types.
  61. AC_CHECK_TYPE(u_int8_t, uint8_t)
  62. AC_CHECK_TYPE(u_int16_t, uint16_t)
  63. AC_CHECK_TYPE(u_int32_t, uint32_t)
  64. AC_CHECK_TYPE(u_int64_t, uint64_t)
  65. dnl Older versions of GCC don't support these options
  66. AC_MSG_CHECKING(for $CC -Wextra support)
  67. OLD_CFLAGS=$CFLAGS
  68. CFLAGS="$CFLAGS -Wextra"
  69. wextra=""
  70. AC_COMPILE_IFELSE([#include <stdlib.h>
  71. int main(int argc, char *argv[]) { return(0); }],
  72. [ AC_MSG_RESULT(yes)
  73. wextra="-Wextra" ],
  74. [ AC_MSG_RESULT(no) ])
  75. CFLAGS="$OLD_CFLAGS $wextra"
  76. AC_MSG_CHECKING(for $CC -Wno-variadic-macros support)
  77. OLD_CFLAGS=$CFLAGS
  78. CFLAGS="$CFLAGS -Wno-variadic-macros"
  79. wno_variadic_macros=""
  80. AC_COMPILE_IFELSE([#include <stdlib.h>
  81. int main(int argc, char *argv[]) { return(0); }],
  82. [ AC_MSG_RESULT(yes)
  83. wno_variadic_macros="-Wno-variadic-macros" ],
  84. [ AC_MSG_RESULT(no) ])
  85. CFLAGS="$OLD_CFLAGS $wno_variadic_macros"
  86. AC_MSG_CHECKING(for $CC -Wfatal-errors support)
  87. OLD_CFLAGS=$CFLAGS
  88. CFLAGS="$CFLAGS -Wfatal-errors"
  89. wfatal_errors=""
  90. AC_COMPILE_IFELSE([#include <stdlib.h>
  91. int main(int argc, char *argv[]) { return(0); }],
  92. [ AC_MSG_RESULT(yes)
  93. wfatal_errors="-Wfatal-errors" ],
  94. [ AC_MSG_RESULT(no) ])
  95. CFLAGS="$OLD_CFLAGS $wfatal_errors"
  96. dnl Check for other header files
  97. 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 sys/param.h])
  98. dnl OpenBSD has special requirements
  99. AC_CHECK_HEADERS([sys/sysctl.h net/route.h], [], [], [
  100. [#if HAVE_SYS_PARAM_H
  101. #include <sys/param.h>
  102. #endif
  103. #if HAVE_SYS_TYPES_H
  104. #include <sys/types.h>
  105. #endif
  106. #if HAVE_SYS_SOCKET_H
  107. #include <sys/socket.h>
  108. #endif
  109. ]])
  110. dnl Checks for libraries.
  111. AC_CHECK_LIB(socket, socket)
  112. AC_CHECK_LIB(nsl, gethostbyname)
  113. AC_CHECK_LIB(rt, nanosleep)
  114. dnl Checks for library functions.
  115. AC_FUNC_MALLOC
  116. AC_FUNC_MEMCMP
  117. AC_TYPE_SIGNAL
  118. AC_FUNC_VPRINTF
  119. AC_CHECK_MEMBERS([struct timeval.tv_sec])
  120. AC_CHECK_FUNCS([gettimeofday ctime memset regcomp strdup strchr strerror strtol strncpy strtoull poll ntohll mmap snprintf vsnprintf])
  121. dnl Look for strlcpy since some BSD's have it
  122. AC_CHECK_FUNCS([strlcpy],have_strlcpy=true,have_strlcpy=false)
  123. AM_CONDITIONAL(SYSTEM_STRLCPY, [test x$have_strlcpy = xtrue])
  124. AC_C_BIGENDIAN
  125. AM_CONDITIONAL([WORDS_BIGENDIAN], [ test x$ac_cv_c_bigendian = xyes ])
  126. dnl Enable debugging in code/compiler options
  127. debug=no
  128. AC_ARG_ENABLE(debug,
  129. AC_HELP_STRING([--enable-debug], [Enable debugging code and support for the -d option]),
  130. [ if test x$enableval = xyes; then
  131. debug=yes
  132. CFLAGS="-ggdb -std=gnu99 -Wall $wextra $wfatal_errors $wno_variadic_macros"
  133. # We may also want to add:
  134. # -Wformat-security -Wswitch-default -Wunused-paramter -Wpadded"
  135. AC_SUBST(debug_flag)
  136. AC_DEFINE([DEBUG], [1], [Enable debuging code and support for the -d option])
  137. fi])
  138. AC_ARG_ENABLE(pedantic,
  139. AC_HELP_STRING([--enable-pedantic], [Enable gcc's -pedantic option]),
  140. [ if test x$enableval = xyes; then
  141. CFLAGS="$CFLAGS -pedantic"
  142. fi ])
  143. dnl Enable Efense
  144. AC_ARG_ENABLE(efence,
  145. AC_HELP_STRING([--enable-efence], [Enable Electric Fence memory debugger]),
  146. [ if test x$enableval = xyes; then
  147. CFLAGS="$CFLAGS -lefence"
  148. AC_DEFINE([EFENCE], [1], [Enable Electric Fence memory debugger])
  149. fi])
  150. dnl Enable Gprof
  151. AC_ARG_ENABLE(gprof,
  152. AC_HELP_STRING([--enable-gprof], [Enable GNU Profiler]),
  153. [ if test x$enableval = xyes; then
  154. if test $debug = yes; then
  155. CFLAGS="$CFLAGS -pg"
  156. else
  157. # GPROF requires gdb
  158. CFLAGS="$CFLAGS -ggdb -pg -fprofile-arcs"
  159. fi
  160. AC_DEFINE([GPROF], [1], [Enable GNU Profiler])
  161. fi])
  162. dnl Use 64bits for packet counters
  163. AC_ARG_ENABLE(64bits,
  164. AC_HELP_STRING([--enable-64bits], [Use 64bit packet counters]),
  165. [ if test x$enableval = xyes; then
  166. AC_DEFINE([ENABLE_64BITS], [1], [Use 64bit packet counters])
  167. AC_MSG_NOTICE([Using u_int64_t for packet counters])
  168. else
  169. AC_MSG_NOTICE([Using u_int32_t for packet counters])
  170. fi
  171. ])
  172. AC_ARG_ENABLE(force-bpf,
  173. AC_HELP_STRING([--enable-force-bpf], [Force using BPF for sending packets]),
  174. [ AC_DEFINE([FORCE_INJECT_BPF], [1], [Force using BPF for sending packet])])
  175. AC_ARG_ENABLE(force-pf,
  176. AC_HELP_STRING([--enable-force-pf], [Force using Linux's PF_PACKET for sending packets]),
  177. [ AC_DEFINE([FORCE_INJECT_PF], [1], [Force using Linux's PF_PACKET for sending packets])])
  178. AC_ARG_ENABLE(force-libnet,
  179. AC_HELP_STRING([--enable-force-libnet], [Force using libnet for sending packets]),
  180. [ AC_DEFINE([FORCE_INJECT_LIBNET], [1], [Force using libnet for sending packets])])
  181. AC_ARG_ENABLE(force-inject,
  182. AC_HELP_STRING([--enable-force-inject], [Force using libpcap's pcap_inject() for sending packets]),
  183. [ AC_DEFINE([FORCE_INJECT_PCAP_INJECT],[1], [Force using libpcap's pcap_inject() for sending packets])])
  184. AC_ARG_ENABLE(force-sendpacket,
  185. AC_HELP_STRING([--enable-force-sendpacket], [Force using libpcap's pcap_sendpacket() for sending packets]),
  186. [ AC_DEFINE([FORCE_INJECT_PCAP_SENDPACKET], [1], [Force using libpcap's pcap_sendpacket() for sending packets])])
  187. tcpreplay_edit=no
  188. AC_ARG_ENABLE(tcpreplay-edit,
  189. AC_HELP_STRING([--enable-tcpreplay-edit], [Link packet editing code with tcpreplay]),
  190. [ AC_DEFINE([TCPREPLAY_EDIT], [1], [Link packet editing code with tcpreplay])
  191. tcpreplay_edit=yes
  192. ])
  193. AM_CONDITIONAL([ENABLE_TCPREPLAY_EDIT], [test x$tcpreplay_edit = xyes])
  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. trynetdir=/usr/local
  243. AC_MSG_CHECKING(for libnet)
  244. AC_ARG_WITH(libnet,
  245. AC_HELP_STRING([--with-libnet=DIR], [Use libnet in DIR]),
  246. [trynetdir=$withval])
  247. for testdir in $trynetdir /usr/local /opt/local /usr ; do
  248. if test -f "${testdir}/include/libnet.h" -a $foundnet = no ; then
  249. LNETINC="${testdir}/include/libnet.h"
  250. LNETINCDIR="$testdir/include"
  251. if test $dynamic_link = yes; then
  252. LNETLIB="-L${testdir}/lib -lnet"
  253. elif test -f "${testdir}/lib64/libnet.a" ; then
  254. LNETLIB="${testdir}/lib64/libnet.a"
  255. else
  256. LNETLIB="${testdir}/lib/libnet.a"
  257. fi
  258. foundnet=$testdir
  259. fi
  260. done
  261. if test $foundnet = no ; then
  262. AC_MSG_RESULT(no)
  263. else
  264. AC_MSG_RESULT($foundnet)
  265. AC_DEFINE([HAVE_LIBNET], [1], [Enable libnet support])
  266. fi
  267. AC_SUBST(LNETINC)
  268. AC_SUBST(LNETLIB)
  269. if test $foundnet = yes ; then
  270. OLDLIBS="$LIBS"
  271. OLDCFLAGS="$CFLAGS"
  272. LIBS="$LNETLIB"
  273. CFLAGS="$CFLAGS -I$LNETINCDIR"
  274. dnl Check to see what version of libnet
  275. dnl this code has been reduced a lot, but probably still could be
  276. dnl reduced quite a bit more if we chose too
  277. AC_MSG_CHECKING(for libnet version)
  278. AC_TRY_RUN([
  279. #include <string.h>
  280. #define LIBNET_LIL_ENDIAN 1
  281. #include "$LNETINC"
  282. #define LIB_TEST "1.0"
  283. /*
  284. * simple proggy to test the version of libnet
  285. * returns zero if it's 1.0.x
  286. * or one otherwise
  287. */
  288. int
  289. main (int argc, char *argv[])
  290. {
  291. if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0)
  292. exit(0);
  293. exit(1);
  294. }],
  295. libnet_ver_10=yes
  296. AC_MSG_RESULT(1.0.x),
  297. libnet_ver_10=no,
  298. libnet_ver_10=no
  299. )
  300. AC_TRY_RUN([
  301. #include <string.h>
  302. #include "$LNETINC"
  303. #define LIB_TEST "1.1"
  304. /*
  305. * simple proggy to test the version of libnet
  306. * returns zero if it's 1.0.x
  307. * or one otherwise
  308. */
  309. int
  310. main (int argc, char *argv[])
  311. {
  312. if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0)
  313. exit(0);
  314. exit(1);
  315. }],
  316. libnet_ver_11=yes
  317. AC_MSG_RESULT(1.1.x),
  318. libnet_ver_11=no,
  319. libnet_ver_11=no
  320. )
  321. if test $libnet_ver_10 = no -a $libnet_ver_11 = no ; then
  322. AC_MSG_RESULT(unknown)
  323. AC_MSG_ERROR(Unable to determine version of libnet)
  324. fi
  325. if test $libnet_ver_10 = yes ; then
  326. AC_MSG_ERROR(Libnet version 1.0.x is no longer supported.
  327. Please upgrade to 1.1.0 or better)
  328. fi
  329. dnl restore LIBS & CFLAGS
  330. LIBS="$OLDLIBS"
  331. CFLAGS="$OLDCFLAGS"
  332. fi
  333. dnl END OF if test $foundnet = yes
  334. dnl #####################################################
  335. dnl Checks for libpcap
  336. dnl #####################################################
  337. foundpcap=no
  338. trypcapdir=/usr/local
  339. AC_MSG_CHECKING(for libpcap)
  340. AC_ARG_WITH(libpcap,
  341. AC_HELP_STRING([--with-libpcap=DIR], [Use libpcap in DIR]),
  342. [trypcapdir=$withval])
  343. for testdir in $trypcapdir /usr/local /opt/local /usr ; do
  344. if test -f "${testdir}/include/pcap.h" -a $foundpcap = no ; then
  345. LPCAPINC="${testdir}/include/pcap.h"
  346. LPCAPINCDIR="${testdir}/include"
  347. if test $dynamic_link = yes; then
  348. if test -f "${testdir}/lib/libpcap.a" ; then
  349. LPCAPLIB="-L${testdir}/lib -lpcap"
  350. elif test -f "${testdir}/lib64/libpcap.a" ; then
  351. LPCAPLIB="-L${testdir}/lib64 -lpcap"
  352. else
  353. AC_ERROR([Unable to find libpcap in ${testdir}])
  354. fi
  355. elif test -f "${testdir}/lib64/libpcap.a" ; then
  356. LPCAPLIB="${testdir}/lib64/libpcap.a"
  357. elif test -f "${testdir}/lib/libpcap.a" ; then
  358. LPCAPLIB="${testdir}/lib/libpcap.a"
  359. elif test -f "${testdir}/lib/libwpcap.a" ; then
  360. LPCAPLIB="${testdir}/lib/libwpcap.a"
  361. AC_DEFINE([HAVE_WINPCAP], [1], [Do we have WinPcap?])
  362. else
  363. AC_ERROR([Unable to find matching library for header file in ${testdir}])
  364. fi
  365. foundpcap=$testdir
  366. fi
  367. done
  368. if test $foundpcap = no ; then
  369. AC_MSG_RESULT(no)
  370. AC_ERROR(libpcap not found)
  371. else
  372. AC_MSG_RESULT($foundpcap)
  373. fi
  374. AC_SUBST(LPCAPINC)
  375. AC_SUBST(LPCAPLIB)
  376. dnl Checks to see what version of libpcap we've got
  377. OLDLIBS="$LIBS"
  378. OLDCFLAGS="$CFLAGS -I$LPCAPINCDIR"
  379. LIBS="$LPCAPLIB"
  380. CFLAGS="$CFLAGS -I$LPCAPINCDIR"
  381. have_libnet=no
  382. dnl Check to see what version of libpcap
  383. dnl this code has been reduced a lot, but probably still could be
  384. dnl reduced quite a bit more if we chose too
  385. AC_MSG_CHECKING(for libpcap version)
  386. AC_RUN_IFELSE(AC_LANG_PROGRAM([[
  387. #include <string.h>
  388. #include <stdlib.h>
  389. #include <stdio.h>
  390. #include "$LPCAPINC"
  391. #define PCAP_TEST "0.8"
  392. ]], [[
  393. /*
  394. * simple proggy to test the version of libpcap
  395. * returns zero if version >= 0.8.0
  396. * or one otherwise
  397. */
  398. if (strncmp(pcap_lib_version(), PCAP_TEST, 3) >= 0)
  399. exit(0);
  400. /* winpcap? */
  401. if (strncmp(pcap_lib_version(), "WinPcap", 7) == 0)
  402. exit(0);
  403. exit(1);
  404. ]]), [
  405. libpcap_ver8=yes
  406. ], [
  407. libpcap_ver8=no
  408. ])
  409. AC_RUN_IFELSE(AC_LANG_PROGRAM([[
  410. #include <string.h>
  411. #include <stdlib.h>
  412. #include <stdio.h>
  413. #include "$LPCAPINC"
  414. #define PCAP_TEST "0.7.2"
  415. extern const char pcap_version[[]]; /* double up since autoconf escapes things */
  416. ]], [[
  417. /*
  418. * simple proggy to test the version of libpcap
  419. * returns zero if version >= 0.7.2
  420. * or one otherwise
  421. */
  422. if (strncmp(pcap_version, PCAP_TEST, 5) >= 0)
  423. exit(0);
  424. exit(1);
  425. ]]), [
  426. libpcap_ver7=yes
  427. ], [
  428. libpcap_ver7=no
  429. ])
  430. if test $libpcap_ver8 = yes ; then
  431. AC_MSG_RESULT(>= 0.8.0)
  432. elif test $libpcap_ver7 = yes ; then
  433. AC_MSG_RESULT(>= 0.7.2)
  434. else
  435. AC_MSG_ERROR([Libpcap versions < 0.7.2 are not supported
  436. Please upgrade to version 0.7.2 or better])
  437. fi
  438. dnl Check to see if we've got pcap_datalink_val_to_name()
  439. AC_MSG_CHECKING(for pcap_datalink_val_to_description)
  440. AC_LINK_IFELSE(AC_LANG_PROGRAM([[
  441. #include <stdio.h>
  442. #include <stdlib.h>
  443. #include <string.h>
  444. #include "$LPCAPINC"
  445. ]],[[
  446. if (strcmp(pcap_datalink_val_to_description(1), "Ethernet (10Mb)") == 0)
  447. exit(0);
  448. exit(1);
  449. ]]),[
  450. have_dlt_to_desc=yes
  451. AC_MSG_RESULT(yes)
  452. ], [
  453. have_dlt_to_desc=no
  454. AC_MSG_RESULT(no)
  455. ])
  456. if test $have_dlt_to_desc = yes ; then
  457. AC_DEFINE([HAVE_DLT_VAL_TO_DESC], [1],
  458. [Does libpcap have dlt_val_to_desc?])
  459. fi
  460. dnl Check to see if we've got pcap_dump_fopen()
  461. AC_MSG_CHECKING(for pcap_dump_fopen)
  462. AC_LINK_IFELSE(AC_LANG_PROGRAM([[
  463. #include <stdio.h>
  464. #include <stdlib.h>
  465. #include <string.h>
  466. #include "$LPCAPINC"
  467. ]],[[
  468. pcap_dumper_t *dump;
  469. pcap_t *pcap;
  470. FILE *foo;
  471. dump = pcap_dump_fopen(pcap, foo);
  472. ]]),[
  473. have_pcap_dump_fopen=yes
  474. AC_MSG_RESULT(yes)
  475. ], [
  476. have_pcap_dump_fopen=no
  477. AC_MSG_RESULT(no)
  478. ])
  479. if test $have_pcap_dump_fopen = yes ; then
  480. AC_DEFINE([HAVE_PCAP_DUMP_FOPEN], [1],
  481. [Does libpcap have pcap_dump_fopen?])
  482. else
  483. AC_MSG_NOTICE([--verbose mode requires libpcap >= 0.9.0])
  484. fi
  485. dnl Check to see if we've got pcap_snapshot_override()
  486. AC_MSG_CHECKING(for pcap_snapshot_override)
  487. AC_LINK_IFELSE(AC_LANG_PROGRAM([[
  488. #include <stdio.h>
  489. #include <stdlib.h>
  490. #include <string.h>
  491. #include "$LPCAPINC"
  492. ]],[[
  493. pcap_t *pcap;
  494. pcap_snapshot_override(pcap, 1);
  495. exit(0);
  496. ]]),[
  497. have_pcap_snapshot_override=yes
  498. AC_MSG_RESULT(yes)
  499. ], [
  500. have_pcap_snapshot_override=no
  501. AC_MSG_RESULT(no)
  502. ])
  503. if test $have_pcap_snapshot_override = yes ; then
  504. AC_DEFINE([HAVE_PCAP_SNAPSHOT_OVERRIDE], [1],
  505. [Does libpcap have pcap_snapshot_override()?])
  506. fi
  507. have_pcap_inject=no
  508. dnl Check to see if we've got pcap_inject()
  509. AC_MSG_CHECKING(for pcap_inject sending support)
  510. AC_TRY_COMPILE([
  511. #include <stdio.h>
  512. #include <stdlib.h>
  513. #include <string.h>
  514. #include "$LPCAPINC"
  515. ],[
  516. pcap_t *pcap;
  517. char *buf;
  518. pcap_inject(pcap, (void *)buf, 0);
  519. ],[
  520. AC_DEFINE([HAVE_PCAP_INJECT], [1],
  521. [Does libpcap have pcap_inject?])
  522. AC_MSG_RESULT(yes)
  523. have_pcap_inject=yes
  524. ],[
  525. AC_MSG_RESULT(no)
  526. ])
  527. have_pcap_version=no
  528. dnl Check to see if we have pcap_version[]
  529. AC_MSG_CHECKING(for pcap_version[])
  530. AC_TRY_COMPILE([
  531. #include <stdio.h>
  532. #include <stdlib.h>
  533. #include <string.h>
  534. #include "$LPCAPINC"
  535. extern char pcap_version[];
  536. ],[
  537. printf("%s", pcap_version);
  538. ],[
  539. AC_DEFINE([HAVE_PCAP_VERSION],[1], [Does libpcap have pcap_version[]])
  540. AC_MSG_RESULT(yes)
  541. ],[
  542. AC_MSG_RESULT(no)
  543. ])
  544. have_pcap_sendpacket=no
  545. dnl Check to see if we've got pcap_sendpacket()
  546. AC_MSG_CHECKING(for pcap_sendpacket sending support)
  547. AC_TRY_COMPILE([
  548. #include <stdio.h>
  549. #include <stdlib.h>
  550. #include <string.h>
  551. #include "$LPCAPINC"
  552. ],[
  553. pcap_t *pcap;
  554. u_char *buf;
  555. pcap_sendpacket(pcap, buf, 0);
  556. ],[
  557. AC_DEFINE([HAVE_PCAP_SENDPACKET], [1],
  558. [Does libpcap have pcap_sendpacket?])
  559. AC_MSG_RESULT(yes)
  560. have_pcap_sendpacket=yes
  561. ],[
  562. AC_MSG_RESULT(no)
  563. ])
  564. have_pf=no
  565. dnl Check for linux PF_PACKET support
  566. AC_MSG_CHECKING(for PF_PACKET socket sending support)
  567. AC_TRY_COMPILE([
  568. #include <sys/socket.h>
  569. #include <netpacket/packet.h>
  570. #include <net/ethernet.h> /* the L2 protocols */
  571. #include <netinet/in.h> /* htons */
  572. ],[
  573. int pf_socket;
  574. pf_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
  575. ],[
  576. AC_DEFINE([HAVE_PF_PACKET], [1],
  577. [Do we have Linux PF_PACKET socket support?])
  578. AC_MSG_RESULT(yes)
  579. have_pf=yes
  580. ],[
  581. AC_MSG_RESULT(no)
  582. ])
  583. have_bpf=no
  584. dnl Check for BSD's BPF
  585. AC_MSG_CHECKING(for BPF device sending support)
  586. AC_TRY_RUN([
  587. #include <stdio.h>
  588. #include <stdlib.h>
  589. #include <net/bpf.h>
  590. #include <sys/types.h>
  591. #include <sys/socket.h>
  592. #include <fcntl.h>
  593. #include <sys/time.h>
  594. #include <sys/ioctl.h>
  595. #include <net/bpf.h>
  596. #include <errno.h>
  597. int
  598. main(int argc, char *argv[]) {
  599. int fd;
  600. fd = open("/dev/bpf0", O_RDONLY, 0);
  601. /* if we opened it, we're good */
  602. if (fd > 1)
  603. exit(0);
  604. /* if we got EBUSY or permission denied it exists, so we're good */
  605. if (fd < 0 && (errno == EBUSY || errno == 13))
  606. exit(0);
  607. /* else suck, no good */
  608. exit(-1);
  609. }],
  610. [
  611. AC_DEFINE([HAVE_BPF], [1],
  612. [Do we have BPF device support?])
  613. AC_MSG_RESULT(yes)
  614. have_bpf=yes
  615. ])
  616. dnl Make sure we have a valid packet injection mechanisim
  617. if test $have_bpf = no -a $have_pcap_inject = no -a $have_pcap_sendpacket = no \
  618. -a $have_libnet = no -a $have_pf = no ; then
  619. AC_MSG_ERROR([Unable to find a supported method to send packets])
  620. fi
  621. dnl Libpcap support doesn't give us a method to get the hardware address of the
  622. dnl interfaces which prevents us from doing proper filtering to prevent bridging loops
  623. enable_tcpbridge=yes
  624. if test $have_bpf = no -a $have_libnet = no -a $have_pf = no ; then
  625. AC_MSG_NOTICE([tcpbridge support disabled without BPF, Libnet or Linux PF_PACKET])
  626. enable_tcpbridge=no
  627. fi
  628. # ADT: Commented for now
  629. # AM_CONDITIONAL(ENABLE_TCPBRIDGE, [test $enable_tcpbridge = yes])
  630. dnl Older versions of libpcap are missing some DLT types
  631. dnl If doesn't exist, we'll define them in src/common/fakepcap.h
  632. AC_MSG_CHECKING(for DLT_LINUX_SLL in libpcap)
  633. AC_TRY_COMPILE([#include "$LPCAPINC"],
  634. [ int foo;
  635. foo = DLT_LINUX_SLL ],
  636. [ AC_DEFINE([HAVE_DLT_LINUX_SLL], [1],
  637. [Does pcap.h include a header with DLT_LINUX_SLL?])
  638. AC_MSG_RESULT(yes)
  639. ],
  640. AC_MSG_RESULT(no)
  641. )
  642. AC_MSG_CHECKING(for DLT_C_HDLC in libpcap)
  643. AC_TRY_COMPILE([#include "$LPCAPINC"],
  644. [ int foo;
  645. foo = DLT_C_HDLC ],
  646. [ AC_DEFINE([HAVE_DLT_C_HDLC], [1],
  647. [Does pcap.h include a header with DLT_C_HDLC?])
  648. AC_MSG_RESULT(yes)
  649. ],
  650. AC_MSG_RESULT(no)
  651. )
  652. PCAP_BPF_H_FILE="$LPCAPINCDIR/pcap-bpf.h"
  653. AC_MSG_CHECKING(for $PCAP_BPF_H_FILE)
  654. AC_TRY_COMPILE([#include <sys/types.h>
  655. #include <sys/time.h>
  656. #include "$PCAP_BPF_H_FILE"],
  657. [ int foo;
  658. foo = BPF_MAJOR_VERSION; ],
  659. [ AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [1],
  660. [What is the path (if any) to the pcap-bpf.h
  661. header?])
  662. AC_MSG_RESULT(yes)
  663. AC_SUBST(PCAP_BPF_H_FILE)
  664. ],
  665. AC_MSG_RESULT(no)
  666. )
  667. foundbpfheader=no
  668. AC_MSG_CHECKING(for libpcap bpf header)
  669. for testfile in $LPCAPINCDIR/pcap/bpf.h $LPCAPINCDIR/pcap-bpf.h ; do
  670. if test -f "${testfile}" -a $foundbpfheader = no ; then
  671. AC_TRY_COMPILE([
  672. #include <sys/types.h>
  673. #include <sys/time.h>
  674. #include "$testfile"],
  675. [
  676. int foo;
  677. foo = BPF_MAJOR_VERSION;
  678. ],
  679. [
  680. foundbpfheader=yes
  681. PCAP_BPF_H_FILE=$testfile
  682. AC_SUBST(PCAP_BPF_H_FILE)
  683. AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [1],
  684. [What is the path (if any) to the libpcap bpf header file?])
  685. AC_MSG_RESULT($testfile)
  686. ],
  687. AC_MSG_RESULT(no)
  688. )
  689. fi
  690. done
  691. dnl restore LIBS & CFLAGS
  692. LIBS="$OLDLIBS"
  693. CFLAGS="$OLDCFLAGS"
  694. dnl ##################################################
  695. dnl # Check for pcapnav
  696. dnl ##################################################
  697. pcapnav_ver=no
  698. pcncfg=no
  699. AC_ARG_WITH(pcapnav-config,
  700. AC_HELP_STRING([--with-pcapnav-config=FILE], [Use given pcapnav-config]),
  701. [ AC_MSG_CHECKING(for pcapnav-config)
  702. if test -x $withval ; then
  703. pcncfg=$withval
  704. AC_MSG_RESULT($pcncfg)
  705. elif test x$withval = xno ; then
  706. AC_MSG_RESULT(no)
  707. else
  708. AC_MSG_RESULT([Can't find pcapnav-config: disabling offset jump feature])
  709. fi ],
  710. [ AC_PATH_PROG(pcncfg,[pcapnav-config], [no] ) ]
  711. )
  712. if test $pcncfg != no ; then
  713. LNAVLIB=`$pcncfg --libs`
  714. LNAV_CFLAGS=`$pcncfg --cflags`
  715. PCAPNAV_VERSION=`$pcncfg --version`
  716. AC_SUBST(LNAVLIB)
  717. AC_SUBST(LNAV_CFLAGS)
  718. AC_DEFINE_UNQUOTED(PCAPNAV_VERSION, "$PCAPNAV_VERSION",
  719. [libpcapnav's version?])
  720. dnl Check to see what version of libpcapnav
  721. dnl this code has been reduced a lot, but probably still could be
  722. dnl reduced quite a bit more if we chose too
  723. AC_MSG_CHECKING(for libpcapnav version)
  724. AC_TRY_RUN([
  725. #include <string.h>
  726. #define PCAPNAV_TEST "0.4"
  727. /*
  728. * simple proggy to test the version of libpcapnav
  729. * returns zero if version >= 0.4
  730. * or one otherwise
  731. */
  732. int
  733. main (int argc, char *argv[])
  734. {
  735. if (strncmp(PCAPNAV_VERSION, PCAPNAV_TEST, 3) >= 0)
  736. exit(0);
  737. exit(1);
  738. }],
  739. libpcapnav_ver=yes
  740. AC_MSG_RESULT(>= 0.4),
  741. libpcapnav_ver=no
  742. AC_MSG_RESULT(< 0.4),
  743. libpcapnav_ver=no
  744. )
  745. if test x$libpcapnav_ver = xno ; then
  746. AC_MSG_WARN([Libpcapnav versions < 0.4 are not supported.
  747. Please upgrade to version 0.4 or better.
  748. Disabling offset jump feature.])
  749. else
  750. AC_DEFINE([HAVE_PCAPNAV], [1], [Do we have libpcapnav?])
  751. fi
  752. fi # checking pcapnav version
  753. dnl (shamelessly ripped off from libpcap)
  754. dnl Checks to see if unaligned memory accesses fail
  755. dnl
  756. dnl FORCE_ALIGN (DEFINED)
  757. dnl
  758. AC_MSG_CHECKING(for requires strict byte alignment)
  759. AC_CACHE_VAL(unaligned_fail,
  760. [case "$host_cpu" in
  761. # XXX: should also check that they don't do weird things (like on arm)
  762. alpha*|arm*|hp*|mips*|sparc*|ia64)
  763. unaligned_fail=yes
  764. ;;
  765. *)
  766. cat >conftest.c <<EOF
  767. #include <sys/types.h>
  768. #include <sys/wait.h>
  769. #include <stdio.h>
  770. unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
  771. main() {
  772. unsigned int i;
  773. pid_t pid;
  774. int status;
  775. /* avoid "core dumped" message */
  776. pid = fork();
  777. if (pid < 0)
  778. exit(2);
  779. if (pid > 0) {
  780. /* parent */
  781. pid = waitpid(pid, &status, 0);
  782. if (pid < 0)
  783. exit(3);
  784. exit(!WIFEXITED(status));
  785. }
  786. /* child */
  787. i = *(unsigned int *)&a[[1]];
  788. printf("%d\n", i);
  789. exit(0);
  790. }
  791. EOF
  792. ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
  793. conftest.c $LIBS >/dev/null 2>&1
  794. if test ! -x conftest ; then
  795. dnl failed to compile for some reason
  796. unaligned_fail=yes
  797. else
  798. ./conftest >conftest.out
  799. if test ! -s conftest.out ; then
  800. unaligned_fail=yes
  801. else
  802. unaligned_fail=no
  803. fi
  804. fi
  805. rm -f conftest* core core.conftest
  806. ;;
  807. esac])
  808. AC_MSG_RESULT($unaligned_fail)
  809. if test $unaligned_fail = yes ; then
  810. AC_DEFINE([FORCE_ALIGN],[1],[Are we strictly aligned?])
  811. fi
  812. dnl ##################################################
  813. dnl # Check for tcpdump.
  814. dnl ##################################################
  815. td=no
  816. AC_ARG_WITH(tcpdump,
  817. AC_HELP_STRING([--with-tcpdump=FILE], [Path to tcpdump binary]),
  818. [ if test -x $withval ; then
  819. td=$withval
  820. AC_MSG_RESULT([Using tcpdump in $td])
  821. else
  822. AC_MSG_RESULT([Error: $withval does not exist or is not executable])
  823. fi ],
  824. [ AC_PATH_PROG(td, tcpdump, "no", [$PATH:/usr/sbin:/sbin:/usr/local/sbin]) ])
  825. if test "$td" = "no"; then
  826. AC_MSG_WARN([Unable to find tcpdump. Please specify --with-tcpdump.
  827. Disabling --verbose])
  828. else
  829. AC_DEFINE([HAVE_TCPDUMP], [1], [Do we have tcpdump?])
  830. AC_DEFINE_UNQUOTED(TCPDUMP_BINARY, "$td", [The tcpdump binary initially used])
  831. fi
  832. AM_CONDITIONAL([ENABLE_TCPDUMP], test "$td" != "no" -a x$have_pcap_dump_fopen = xyes)
  833. if test x$td != xno -a x$have_pcap_dump_fopen = xyes ; then
  834. AC_DEFINE([ENABLE_VERBOSE], [1], [Do we have tcpdump and pcap_dump_fopen()?])
  835. else
  836. AC_MSG_WARN([Your version of libpcap is too old for --verbose support])
  837. fi
  838. dnl No 'make test' when cross compile
  839. AC_MSG_CHECKING( for 'make test' profile)
  840. if test "$host" != "$build" ; then
  841. AC_MSG_WARN(Unable to do tests when cross-compiling)
  842. fi
  843. dnl Allows user to choose which nic to use for testing purposes
  844. AC_ARG_WITH(testnic,
  845. AC_HELP_STRING([--with-testnic=NIC], [Select which network card to use for testing]),
  846. [ nic1=$withval
  847. nic2=$withval
  848. AC_MSG_RESULT([Using --with-testnic=$withval])],
  849. [
  850. dnl these need to be dynamic based on OS
  851. case $host in
  852. *-*-linux*)
  853. nic1=eth0
  854. nic2=eth0
  855. AC_MSG_RESULT(Linux)
  856. ;;
  857. *-*-solaris*)
  858. nic1=hme0
  859. nic2=hme0
  860. AC_MSG_RESULT(Solaris)
  861. ;;
  862. *-*-sunos*)
  863. nic1=hme0
  864. nic2=hme0
  865. AC_MSG_RESULT(SunOS)
  866. ;;
  867. *-apple-darwin*)
  868. nic1=en0
  869. nic2=en0
  870. AC_MSG_RESULT(Apple OS X)
  871. ;;
  872. *-*-openbsd*)
  873. nic1=xl0
  874. nic2=xl0
  875. AC_MSG_RESULT(OpenBSD)
  876. ;;
  877. *-*-cygwin)
  878. AC_MSG_RESULT(Win32/Cygwin)
  879. nic1=%0
  880. nic2=%0
  881. ;;
  882. *)
  883. AC_MSG_RESULT([$host is unknown! Using first non-loopback interface])
  884. nic1=%0
  885. nic2=%0
  886. ;;
  887. esac])
  888. AC_ARG_WITH(testnic2,
  889. AC_HELP_STRING([--with-testnic2=NIC2], [Select an optional 2nd network card to use for testing]),
  890. [ nic2=$withval ])
  891. AC_MSG_NOTICE([Using $nic1 for 1st test network interface card])
  892. AC_MSG_NOTICE([Using $nic2 for 2nd test network interface card])
  893. AC_SUBST(nic1)
  894. AC_SUBST(nic2)
  895. LIBOPTS_CHECK
  896. AC_OUTPUT([Makefile
  897. doxygen.cfg
  898. lib/Makefile
  899. docs/Makefile
  900. src/Makefile
  901. src/common/Makefile
  902. src/tcpedit/Makefile
  903. src/flow/Makefile
  904. src/defines.h
  905. test/Makefile
  906. test/config
  907. scripts/Makefile
  908. tcpreplay.spec])