1214518Srpaulodnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.168 2008-12-23 20:49:26 guy Exp $ (LBL)
217683Spstdnl
339291Sfennerdnl Copyright (c) 1994, 1995, 1996, 1997
417683Spstdnl	The Regents of the University of California.  All rights reserved.
517683Spstdnl
617683Spstdnl Process this file with autoconf to produce a configure script.
717683Spstdnl
817683Spst
9214518Srpaulo#
10214518Srpaulo# See
11214518Srpaulo#
12214518Srpaulo#	http://ftp.gnu.org/gnu/config/README
13214518Srpaulo#
14214518Srpaulo# for the URLs to use to fetch new versions of config.guess and
15214518Srpaulo# config.sub.
16214518Srpaulo#
17214518Srpaulo
18214518SrpauloAC_REVISION($Revision: 1.168 $)
19127664SbmsAC_PREREQ(2.50)
2017683SpstAC_INIT(pcap.c)
2117683Spst
2217683SpstAC_CANONICAL_SYSTEM
2317683Spst
24214518SrpauloAC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS)
25214518SrpauloAC_PROG_CC
26214518SrpauloAC_LBL_C_INIT(V_CCOPT, V_INCLS)
27214518SrpauloAC_LBL_SHLIBS_INIT
28127664SbmsAC_LBL_C_INLINE
2975107SfennerAC_C___ATTRIBUTE__
3017683Spst
31214518SrpauloAC_CHECK_HEADERS(sys/bitypes.h)
3217683Spst
33214518SrpauloAC_CHECK_TYPE([int8_t], ,
34214518Srpaulo	[AC_DEFINE([int8_t], [signed char],
35214518Srpaulo	[Define to `signed char' if int8_t not defined.])],
36214518Srpaulo	[AC_INCLUDES_DEFAULT
37214518Srpaulo#ifdef HAVE_SYS_BITYPES_H
38214518Srpaulo#include <sys/bitypes.h>
39214518Srpaulo#endif])
40214518SrpauloAC_CHECK_TYPE([u_int8_t], ,
41214518Srpaulo	[AC_DEFINE([u_int8_t], [unsigned char],
42214518Srpaulo	[Define to `unsigned char' if u_int8_t not defined.])],
43214518Srpaulo	[AC_INCLUDES_DEFAULT
44214518Srpaulo#ifdef HAVE_SYS_BITYPES_H
45214518Srpaulo#include <sys/bitypes.h>
46214518Srpaulo#endif])
47214518SrpauloAC_CHECK_TYPE([int16_t], ,
48214518Srpaulo	[AC_DEFINE([int16_t], [short],
49214518Srpaulo	[Define to `short' if int16_t not defined.])]
50214518Srpaulo	[AC_INCLUDES_DEFAULT
51214518Srpaulo#ifdef HAVE_SYS_BITYPES_H
52214518Srpaulo#include <sys/bitypes.h>
53214518Srpaulo#endif])
54214518SrpauloAC_CHECK_TYPE([u_int16_t], ,
55214518Srpaulo	[AC_DEFINE([u_int16_t], [unsigned short],
56214518Srpaulo	[Define to `unsigned short' if u_int16_t not defined.])],
57214518Srpaulo	[AC_INCLUDES_DEFAULT
58214518Srpaulo#ifdef HAVE_SYS_BITYPES_H
59214518Srpaulo#include <sys/bitypes.h>
60214518Srpaulo#endif])
61214518SrpauloAC_CHECK_TYPE([int32_t], ,
62214518Srpaulo	[AC_DEFINE([int32_t], [int],
63214518Srpaulo	[Define to `int' if int32_t not defined.])],
64214518Srpaulo	[AC_INCLUDES_DEFAULT
65214518Srpaulo#ifdef HAVE_SYS_BITYPES_H
66214518Srpaulo#include <sys/bitypes.h>
67214518Srpaulo#endif])
68214518SrpauloAC_CHECK_TYPE([u_int32_t], ,
69214518Srpaulo	[AC_DEFINE([u_int32_t], [unsigned int],
70214518Srpaulo	[Define to `unsigned int' if u_int32_t not defined.])],
71214518Srpaulo	[AC_INCLUDES_DEFAULT
72214518Srpaulo#ifdef HAVE_SYS_BITYPES_H
73214518Srpaulo#include <sys/bitypes.h>
74214518Srpaulo#endif])
75214518SrpauloAC_CHECK_TYPE([int64_t], ,
76214518Srpaulo	[AC_DEFINE([int64_t], [long long],
77214518Srpaulo	[Define to `long long' if int64_t not defined.])],
78214518Srpaulo	[AC_INCLUDES_DEFAULT
79214518Srpaulo#ifdef HAVE_SYS_BITYPES_H
80214518Srpaulo#include <sys/bitypes.h>
81214518Srpaulo#endif])
82214518SrpauloAC_CHECK_TYPE([u_int64_t], ,
83214518Srpaulo	[AC_DEFINE([u_int64_t], [unsigned long long],
84214518Srpaulo	[Define to `unsigned long long' if u_int64_t not defined.])],
85214518Srpaulo	[AC_INCLUDES_DEFAULT
86214518Srpaulo#ifdef HAVE_SYS_BITYPES_H
87214518Srpaulo#include <sys/bitypes.h>
88214518Srpaulo#endif])
89214518Srpaulo
90190225Srpaulo#
91190225Srpaulo# Try to arrange for large file support.
92190225Srpaulo#
93190225SrpauloAC_SYS_LARGEFILE
94190225SrpauloAC_FUNC_FSEEKO
95190225Srpaulo
9675107Sfennerdnl
97214518Srpaulodnl Even if <net/bpf.h> were, on all OSes that support BPF, fixed to
98214518Srpaulodnl include <sys/ioccom.h>, and we were to drop support for older
99214518Srpaulodnl releases without that fix, so that pcap-bpf.c doesn't need to
100214518Srpaulodnl include <sys/ioccom.h>, the test program in "AC_LBL_FIXINCLUDES"
101214518Srpaulodnl in "aclocal.m4" uses it, so we would still have to test for it
102214518Srpaulodnl and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
103214518Srpaulodnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris.
10475107Sfennerdnl
105172677SmlaierAC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h limits.h paths.h)
106235426SdelphijAC_CHECK_HEADERS(linux/types.h)
107235426SdelphijAC_CHECK_HEADERS(linux/if_packet.h netpacket/packet.h netpacket/if_packet.h)
108172677SmlaierAC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
109172677Smlaier#include <sys/socket.h>
110172677Smlaier#include <net/if.h>])
111190225Srpauloif test "$ac_cv_header_net_pfvar_h" = yes; then
112190225Srpaulo	#
113190225Srpaulo	# Check for various PF actions.
114190225Srpaulo	#
115190225Srpaulo	AC_MSG_CHECKING(whether net/pfvar.h defines PF_NAT through PF_NORDR)
116190225Srpaulo	AC_TRY_COMPILE(
117190225Srpaulo	    [#include <sys/types.h>
118190225Srpaulo	    #include <sys/socket.h>
119190225Srpaulo	    #include <net/if.h>
120190225Srpaulo	    #include <net/pfvar.h>],
121190225Srpaulo	    [return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR;],
122190225Srpaulo	    [
123190225Srpaulo		AC_MSG_RESULT(yes)
124190225Srpaulo		AC_DEFINE(HAVE_PF_NAT_THROUGH_PF_NORDR, 1,
125190225Srpaulo		    [define if net/pfvar.h defines PF_NAT through PF_NORDR])
126190225Srpaulo	    ],
127190225Srpaulo	    AC_MSG_RESULT(no))
128190225Srpaulofi
129127664SbmsAC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
130127664Sbms#include <sys/socket.h>])
131146768Ssamif test "$ac_cv_header_netinet_if_ether_h" != yes; then
132146768Ssam	#
133146768Ssam	# The simple test didn't work.
134146768Ssam	# Do we need to include <net/if.h> first?
135146768Ssam	# Unset ac_cv_header_netinet_if_ether_h so we don't
136146768Ssam	# treat the previous failure as a cached value and
137146768Ssam	# suppress the next test.
138146768Ssam	#
139146768Ssam	AC_MSG_NOTICE([Rechecking with some additional includes])
140146768Ssam	unset ac_cv_header_netinet_if_ether_h
141146768Ssam	AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
142146768Ssam#include <sys/socket.h>
143146768Ssam#include <netinet/in.h>
144146768Ssamstruct mbuf;
145146768Ssamstruct rtentry;
146146768Ssam#include <net/if.h>])
147146768Ssamfi
14817683Spst
14917683SpstAC_LBL_FIXINCLUDES
15017683Spst
151146768SsamAC_CHECK_FUNCS(strerror strlcpy)
15217683Spst
153127664Sbmsneedsnprintf=no
154127664SbmsAC_CHECK_FUNCS(vsnprintf snprintf,,
155127664Sbms	[needsnprintf=yes])
156127664Sbmsif test $needsnprintf = yes; then
157235426Sdelphij	AC_LIBOBJ([snprintf])
158127664Sbmsfi
159127664Sbms
160146768Ssam#
161146768Ssam# Do this before checking for ether_hostton(), as it's a
162146768Ssam# "gethostbyname() -ish function".
163146768Ssam#
164146768SsamAC_LBL_LIBRARY_NET
165146768Ssam
166146768Ssam#
167146768Ssam# You are in a twisty little maze of UN*Xes, all different.
168146768Ssam# Some might not have ether_hostton().
169146768Ssam# Some might have it, but not declare it in any header file.
170146768Ssam# Some might have it, but declare it in <netinet/if_ether.h>.
171146768Ssam# Some might have it, but declare it in <netinet/ether.h>
172146768Ssam# (And some might have it but document it as something declared in
173146768Ssam# <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.)
174146768Ssam#
175146768Ssam# Before you is a C compiler.
176146768Ssam#
177146768SsamAC_CHECK_FUNCS(ether_hostton)
178146768Ssamif test "$ac_cv_func_ether_hostton" = yes; then
179146768Ssam	#
180146768Ssam	# OK, we have ether_hostton().  Do we have <netinet/if_ether.h>?
181146768Ssam	#
182146768Ssam	if test "$ac_cv_header_netinet_if_ether_h" = yes; then
183146768Ssam		#
184146768Ssam		# Yes.  Does it declare ether_hostton()?
185146768Ssam		#
186147894Ssam		AC_CHECK_DECL(ether_hostton,
187146768Ssam		    [
188146768Ssam			AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON,,
189146768Ssam			    [Define to 1 if netinet/if_ether.h declares `ether_hostton'])
190146768Ssam		    ],,
191146768Ssam		    [
192146768Ssam#include <sys/types.h>
193146768Ssam#include <sys/socket.h>
194146768Ssam#include <netinet/in.h>
195147894Ssam#include <arpa/inet.h>
196146768Ssamstruct mbuf;
197146768Ssamstruct rtentry;
198146768Ssam#include <net/if.h>
199146768Ssam#include <netinet/if_ether.h>
200146768Ssam		    ])
201146768Ssam	fi
202146768Ssam	#
203146768Ssam	# Did that succeed?
204146768Ssam	#
205146768Ssam	if test "$ac_cv_have_decl_ether_hostton" != yes; then
206146768Ssam		#
207146768Ssam		# No, how about <netinet/ether.h>, as on Linux?
208146768Ssam		#
209146768Ssam		AC_CHECK_HEADERS(netinet/ether.h)
210146768Ssam		if test "$ac_cv_header_netinet_ether_h" = yes; then
211146768Ssam			#
212146768Ssam			# We have it - does it declare ether_hostton()?
213146768Ssam			# Unset ac_cv_have_decl_ether_hostton so we don't
214146768Ssam			# treat the previous failure as a cached value and
215146768Ssam			# suppress the next test.
216146768Ssam			#
217146768Ssam			unset ac_cv_have_decl_ether_hostton
218147894Ssam			AC_CHECK_DECL(ether_hostton,
219146768Ssam			    [
220146768Ssam				AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON,,
221146768Ssam				    [Define to 1 if netinet/ether.h declares `ether_hostton'])
222146768Ssam			    ],,
223146768Ssam			    [
224146768Ssam#include <netinet/ether.h>
225146768Ssam			    ])
226146768Ssam		fi
227146768Ssam	fi
228147894Ssam	#
229147894Ssam	# Is ether_hostton() declared?
230147894Ssam	#
231147894Ssam	if test "$ac_cv_have_decl_ether_hostton" != yes; then
232147894Ssam		#
233147894Ssam		# No, we'll have to declare it ourselves.
234147894Ssam		# Do we have "struct ether_addr"?
235147894Ssam		#
236147894Ssam		AC_CHECK_TYPES(struct ether_addr,,,
237147894Ssam		    [
238147894Ssam#include <sys/types.h>
239147894Ssam#include <sys/socket.h>
240147894Ssam#include <netinet/in.h>
241147894Ssam#include <arpa/inet.h>
242147894Ssamstruct mbuf;
243147894Ssamstruct rtentry;
244147894Ssam#include <net/if.h>
245147894Ssam#include <netinet/if_ether.h>
246147894Ssam		    ])
247147894Ssam		AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 0,
248147894Ssam		    [Define to 1 if you have the declaration of `ether_hostton', and to 0 if you
249147894Ssamdon't.])
250147894Ssam	else
251147894Ssam		AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1,
252147894Ssam		    [Define to 1 if you have the declaration of `ether_hostton', and to 0 if you
253147894Ssamdon't.])
254147894Ssam	fi
255146768Ssamfi
256146768Ssam
25756889Sfennerdnl to pacify those who hate protochain insn
25856889SfennerAC_MSG_CHECKING(if --disable-protochain option is specified)
259214518SrpauloAC_ARG_ENABLE(protochain,
260214518SrpauloAC_HELP_STRING([--disable-protochain],[disable \"protochain\" insn]))
26156889Sfennercase "x$enable_protochain" in
26256889Sfennerxyes)	enable_protochain=enabled	;;
26356889Sfennerxno)	enable_protochain=disabled	;;
26456889Sfennerx)	enable_protochain=enabled	;;
26556889Sfenneresac
26656889Sfenner
26756889Sfennerif test "$enable_protochain" = "disabled"; then
26875107Sfenner	AC_DEFINE(NO_PROTOCHAIN,1,[do not use protochain])
26956889Sfennerfi
27056889SfennerAC_MSG_RESULT(${enable_protochain})
27156889Sfenner
272190225Srpaulo#
273190225Srpaulo# SITA support is mutually exclusive with native capture support;
274190225Srpaulo# "--with-sita" selects SITA support.
275190225Srpaulo#
276214518SrpauloAC_ARG_WITH(sita,
277214518SrpauloAC_HELP_STRING([--with-sita],[include SITA support]),
278190225Srpaulo[
279214518Srpaulo	if test ! "x$withval" = "xno" ; then
280214518Srpaulo		AC_DEFINE(SITA,1,[include ACN support])
281214518Srpaulo		AC_MSG_NOTICE(Enabling SITA ACN support)
282214518Srpaulo		V_PCAP=sita
283214518Srpaulo		V_FINDALLDEVS=sita
284214518Srpaulo	fi
285190225Srpaulo],
286190225Srpaulo[
28717683Spstdnl
28817683Spstdnl Not all versions of test support -c (character special) but it's a
28917683Spstdnl better way of testing since the device might be protected. So we
29017683Spstdnl check in our normal order using -r and then check the for the /dev
29117683Spstdnl guys again using -c.
29217683Spstdnl
29375107Sfennerdnl XXX This could be done for cross-compiling, but for now it's not.
29475107Sfennerdnl
29575107Sfennerif test -z "$with_pcap" && test "$cross_compiling" = yes; then
29675107Sfenner	AC_MSG_ERROR(pcap type not determined when cross-compiling; use --with-pcap=...)
29775107Sfennerfi
298214518SrpauloAC_ARG_WITH(pcap,
299214518SrpauloAC_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE]))
30017683SpstAC_MSG_CHECKING(packet capture type)
30139291Sfennerif test ! -z "$with_pcap" ; then
30239291Sfenner	V_PCAP="$withval"
303214518Srpauloelif test -r /dev/bpf -o -h /dev/bpf ; then
304172677Smlaier	#
305172677Smlaier	# Cloning BPF device.
306172677Smlaier	#
307172677Smlaier	V_PCAP=bpf
308172677Smlaier	AC_DEFINE(HAVE_CLONING_BPF,1,[define if you have a cloning BPF device])
30939291Sfennerelif test -r /dev/bpf0 ; then
31017683Spst	V_PCAP=bpf
31117683Spstelif test -r /usr/include/net/pfilt.h ; then
31217683Spst	V_PCAP=pf
31317683Spstelif test -r /dev/enet ; then
31417683Spst	V_PCAP=enet
31517683Spstelif test -r /dev/nit ; then
31617683Spst	V_PCAP=snit
31717683Spstelif test -r /usr/include/sys/net/nit.h ; then
31817683Spst	V_PCAP=nit
319127664Sbmselif test -r /usr/include/linux/socket.h ; then
320127664Sbms	V_PCAP=linux
32117683Spstelif test -r /usr/include/net/raw.h ; then
32217683Spst	V_PCAP=snoop
323127664Sbmselif test -r /usr/include/odmi.h ; then
324127664Sbms	#
325127664Sbms	# On AIX, the BPF devices might not yet be present - they're
326127664Sbms	# created the first time libpcap runs after booting.
327127664Sbms	# We check for odmi.h instead.
328127664Sbms	#
329127664Sbms	V_PCAP=bpf
330214518Srpauloelif test -c /dev/bpf0 ; then		# check again in case not readable
331214518Srpaulo	V_PCAP=bpf
33217683Spstelif test -r /usr/include/sys/dlpi.h ; then
33317683Spst	V_PCAP=dlpi
33417683Spstelif test -c /dev/enet ; then		# check again in case not readable
33517683Spst	V_PCAP=enet
33617683Spstelif test -c /dev/nit ; then		# check again in case not readable
33717683Spst	V_PCAP=snit
33817683Spstelse
33917683Spst	V_PCAP=null
34017683Spstfi
34117683SpstAC_MSG_RESULT($V_PCAP)
34217683Spst
343190225Srpaulo#
344190225Srpaulo# Do capture-mechanism-dependent tests.
345190225Srpaulo#
346190225Srpaulocase "$V_PCAP" in
347190225Srpaulodlpi)
348190225Srpaulo	#
349190225Srpaulo	# Checks to see if Solaris has the public libdlpi(3LIB) library.
350190225Srpaulo	# Note: The existence of /usr/include/libdlpi.h does not mean it is the
351190225Srpaulo	# public libdlpi(3LIB) version. Before libdlpi was made public, a 
352190225Srpaulo	# private version also existed, which did not have the same APIs. 
353190225Srpaulo	# Due to a gcc bug, the default search path for 32-bit libraries does
354190225Srpaulo	# not include /lib, we add it explicitly here.
355190225Srpaulo	# [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485]. 
356190225Srpaulo	# Also, due to the bug above applications that link to libpcap with
357190225Srpaulo	# libdlpi will have to add "-L/lib" option to "configure".
358190225Srpaulo	#
359190225Srpaulo	saved_ldflags=$LDFLAGS
360190225Srpaulo	LDFLAGS="$LIBS -L/lib"
361190225Srpaulo	AC_CHECK_LIB(dlpi, dlpi_walk,
362190225Srpaulo		LIBS="-ldlpi $LIBS"
363190225Srpaulo		V_PCAP=libdlpi
364190225Srpaulo		AC_DEFINE(HAVE_LIBDLPI,1,[if libdlpi exists]),
365190225Srpaulo		V_PCAP=dlpi)
366190225Srpaulo	LDFLAGS=$saved_ldflags
367190225Srpaulo
368190225Srpaulo	#
369190225Srpaulo	# Checks whether <sys/dlpi.h> is usable, to catch weird SCO
370190225Srpaulo	# versions of DLPI.
371190225Srpaulo	#
372190225Srpaulo	AC_MSG_CHECKING(whether <sys/dlpi.h> is usable)
373190225Srpaulo	AC_CACHE_VAL(ac_cv_sys_dlpi_usable,
374190225Srpaulo		AC_TRY_COMPILE(
375190225Srpaulo		    [
376190225Srpaulo			#include <sys/types.h>
377190225Srpaulo			#include <sys/time.h>
378190225Srpaulo			#include <sys/dlpi.h>
379190225Srpaulo		    ],
380190225Srpaulo		    [int i = DL_PROMISC_PHYS;],
381190225Srpaulo		    ac_cv_sys_dlpi_usable=yes,
382190225Srpaulo		    ac_cv_sys_dlpi_usable=no))
383190225Srpaulo	AC_MSG_RESULT($ac_cv_sys_dlpi_usable)
384190225Srpaulo	if test $ac_cv_sys_dlpi_usable = no ; then
385190225Srpaulo		AC_MSG_ERROR(<sys/dlpi.h> is not usable on this system; it probably has a non-standard DLPI)
386190225Srpaulo	fi
387190225Srpaulo
388190225Srpaulo	#
389190225Srpaulo	# Check whether we have a /dev/dlpi device or have multiple devices.
390190225Srpaulo	#
391190225Srpaulo	AC_MSG_CHECKING(for /dev/dlpi device)
392190225Srpaulo	if test -c /dev/dlpi ; then
393190225Srpaulo		AC_MSG_RESULT(yes)
394190225Srpaulo		AC_DEFINE(HAVE_DEV_DLPI, 1, [define if you have a /dev/dlpi])
395190225Srpaulo	else
396190225Srpaulo		AC_MSG_RESULT(no)
397190225Srpaulo		dir="/dev/dlpi"
398190225Srpaulo		AC_MSG_CHECKING(for $dir directory)
399190225Srpaulo		if test -d $dir ; then
400190225Srpaulo			AC_MSG_RESULT(yes)
401190225Srpaulo			AC_DEFINE_UNQUOTED(PCAP_DEV_PREFIX, "$dir", [/dev/dlpi directory])
402190225Srpaulo		else
403190225Srpaulo			AC_MSG_RESULT(no)
404190225Srpaulo		fi
405190225Srpaulo	fi
406190225Srpaulo
407190225Srpaulo	#
408190225Srpaulo	# This check is for Solaris with DLPI support for passive modes.
409190225Srpaulo	# See dlpi(7P) for more details.
410190225Srpaulo	#
411190225Srpaulo	AC_LBL_DL_PASSIVE_REQ_T
412190225Srpaulo	;;
413190225Srpaulo
414190225Srpaulolinux)
415214518Srpaulo	#
416214518Srpaulo	# Do we have the wireless extensions?
417214518Srpaulo	#
418190225Srpaulo	AC_CHECK_HEADERS(linux/wireless.h, [], [],
419190225Srpaulo	[
420190225Srpaulo#include <sys/socket.h>
421214518Srpaulo#include <linux/if.h>
422190225Srpaulo#include <linux/types.h>
423190225Srpaulo	])
424214518Srpaulo
425214518Srpaulo	#
426214518Srpaulo	# Do we have libnl?
427214518Srpaulo	#
428214518Srpaulo	AC_ARG_WITH(libnl,
429214518Srpaulo	AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]),
430214518Srpaulo		with_libnl=$withval,,)
431214518Srpaulo
432214518Srpaulo	if test x$with_libnl != xno ; then
433251129Sdelphij		have_any_nl="no"
434251129Sdelphij
435235426Sdelphij		#
436251129Sdelphij		# Try libnl 3.x first.
437235426Sdelphij		#
438251129Sdelphij		AC_CHECK_LIB(nl-3, nl_socket_alloc,
439235426Sdelphij		[
440235426Sdelphij			#
441251129Sdelphij			# Yes, we have libnl 3.x.
442235426Sdelphij			#
443251129Sdelphij			LIBS="-lnl-genl-3 -lnl-3 $LIBS"
444235426Sdelphij			AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
445251129Sdelphij			AC_DEFINE(HAVE_LIBNL_3_x,1,[if libnl exists and is version 3.x])
446251129Sdelphij			AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
447251129Sdelphij			AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
448251129Sdelphij			V_INCLS="$V_INCLS -I/usr/include/libnl3"
449251129Sdelphij			have_any_nl="yes"
450251129Sdelphij		])
451251129Sdelphij
452251129Sdelphij		if test x$have_any_nl = xno ; then
453235426Sdelphij			#
454251129Sdelphij			# Try libnl 2.x
455251129Sdelphij			#
456251129Sdelphij			AC_CHECK_LIB(nl, nl_socket_alloc,
457251129Sdelphij			[
458251129Sdelphij				#
459251129Sdelphij				# Yes, we have libnl 2.x.
460251129Sdelphij				#
461251129Sdelphij				LIBS="-lnl-genl -lnl $LIBS"
462251129Sdelphij				AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
463251129Sdelphij				AC_DEFINE(HAVE_LIBNL_2_x,1,[if libnl exists and is version 2.x])
464251129Sdelphij				AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
465251129Sdelphij				AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
466251129Sdelphij				have_any_nl="yes"
467251129Sdelphij			])
468251129Sdelphij		fi
469251129Sdelphij
470251129Sdelphij		if test x$have_any_nl = xno ; then
471251129Sdelphij			#
472235426Sdelphij			# No, we don't; do we have libnl 1.x?
473235426Sdelphij			#
474235426Sdelphij			AC_CHECK_LIB(nl, nl_handle_alloc,
475235426Sdelphij			[
476235426Sdelphij				#
477235426Sdelphij				# Yes.
478235426Sdelphij				#
479235426Sdelphij				LIBS="-lnl $LIBS"
480235426Sdelphij				AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
481251129Sdelphij				have_any_nl="yes"
482235426Sdelphij			])
483251129Sdelphij		fi
484251129Sdelphij
485251129Sdelphij		if test x$have_any_nl = xno ; then
486251129Sdelphij			#
487251129Sdelphij			# No, we don't have libnl at all.
488251129Sdelphij			#
489251129Sdelphij			if test x$with_libnl = xyes ; then
490251129Sdelphij				AC_MSG_ERROR([libnl support requested but libnl not found])
491251129Sdelphij			fi
492251129Sdelphij		fi
493214518Srpaulo	fi
494214518Srpaulo
495235426Sdelphij	AC_CHECK_HEADERS(linux/ethtool.h,,,
496235426Sdelphij	    [
497235426SdelphijAC_INCLUDES_DEFAULT
498235426Sdelphij#include <linux/types.h>
499235426Sdelphij	    ])
500190225Srpaulo	AC_LBL_TPACKET_STATS
501190225Srpaulo	AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI
502190225Srpaulo	;;
503190225Srpaulo
504190225Srpaulobpf)
505190225Srpaulo	#
506190225Srpaulo	# Check whether we have the *BSD-style ioctls.
507190225Srpaulo	#
508190225Srpaulo	AC_CHECK_HEADERS(net/if_media.h)
509190225Srpaulo
510190225Srpaulo	AC_MSG_CHECKING(whether the system supports zerocopy BPF)
511190225Srpaulo	AC_TRY_COMPILE(
512190225Srpaulo	    [#include <sys/socket.h>
513190225Srpaulo	    #include <sys/ioctl.h>
514190225Srpaulo	    #include <net/if.h>
515190225Srpaulo	    #include <net/bpf.h>],
516190225Srpaulo	    [return (BIOCROTZBUF + BPF_BUFMODE_ZBUF);],
517190225Srpaulo	    [  
518190225Srpaulo		AC_MSG_RESULT(yes)
519190225Srpaulo		AC_DEFINE(HAVE_ZEROCOPY_BPF, 1,
520190225Srpaulo		[define if the system supports zerocopy BPF])
521190225Srpaulo	    ],
522190225Srpaulo	    AC_MSG_RESULT(no))
523214518Srpaulo
524214518Srpaulo	    #
525214518Srpaulo	    # Check whether we have struct BPF_TIMEVAL.
526214518Srpaulo	    #
527214518Srpaulo	    AC_CHECK_TYPES(struct BPF_TIMEVAL,,,
528214518Srpaulo		[
529214518Srpaulo#include <sys/types.h>
530214518Srpaulo#include <sys/ioctl.h>
531214518Srpaulo#ifdef HAVE_SYS_IOCCOM_H
532214518Srpaulo#include <sys/ioccom.h>
533214518Srpaulo#endif
534214518Srpaulo#include <net/bpf.h>
535214518Srpaulo		    ])
536190225Srpaulo	;;
537190225Srpaulo
538190225Srpaulodag)
539190225Srpaulo	V_DEFS="$V_DEFS -DDAG_ONLY"
540190225Srpaulo	;;
541190225Srpaulo
542190225Srpauloseptel)
543190225Srpaulo	V_DEFS="$V_DEFS -DSEPTEL_ONLY"
544190225Srpaulo	;;
545190225Srpaulo
546214518Srpaulosnf)
547214518Srpaulo	V_DEFS="$V_DEFS -DSNF_ONLY"
548214518Srpaulo	;;
549214518Srpaulo
550190225Srpaulonull)
551190225Srpaulo	AC_MSG_WARN(cannot determine packet capture interface)
552190225Srpaulo	AC_MSG_WARN((see the INSTALL doc for more info))
553190225Srpaulo	;;
554190225Srpauloesac
555190225Srpaulo
556127664Sbmsdnl
557146768Ssamdnl Now figure out how we get a list of interfaces and addresses,
558146768Ssamdnl if we support capturing.  Don't bother if we don't support
559146768Ssamdnl capturing.
560127664Sbmsdnl
561146768Ssamif test "$V_PCAP" = null
562146768Ssamthen
563127664Sbms	#
564146768Ssam	# We can't capture, so we can't open any capture
565146768Ssam	# devices, so we won't return any interfaces.
566127664Sbms	#
567146768Ssam	V_FINDALLDEVS=null
568146768Ssamelse
569146768Ssam	AC_CHECK_FUNC(getifaddrs,[
570127664Sbms		#
571146768Ssam		# We have "getifaddrs()"; make sure we have <ifaddrs.h>
572146768Ssam		# as well, just in case some platform is really weird.
573127664Sbms		#
574146768Ssam		AC_CHECK_HEADER(ifaddrs.h,[
575146768Ssam		    #
576146768Ssam		    # We have the header, so we use "getifaddrs()" to
577146768Ssam		    # get the list of interfaces.
578146768Ssam		    #
579146768Ssam		    V_FINDALLDEVS=getad
580146768Ssam		],[
581146768Ssam		    #
582146768Ssam		    # We don't have the header - give up.
583146768Ssam		    # XXX - we could also fall back on some other
584146768Ssam		    # mechanism, but, for now, this'll catch this
585146768Ssam		    # problem so that we can at least try to figure
586146768Ssam		    # out something to do on systems with "getifaddrs()"
587146768Ssam		    # but without "ifaddrs.h", if there is something
588146768Ssam		    # we can do on those systems.
589146768Ssam		    #
590146768Ssam		    AC_MSG_ERROR([Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>.])
591146768Ssam		])
592146768Ssam	],[
593127664Sbms		#
594146768Ssam		# Well, we don't have "getifaddrs()", so we have to use
595146768Ssam		# some other mechanism; determine what that mechanism is.
596127664Sbms		#
597146768Ssam		# The first thing we use is the type of capture mechanism,
598146768Ssam		# which is somewhat of a proxy for the OS we're using.
599127664Sbms		#
600146768Ssam		case "$V_PCAP" in
601127664Sbms
602190225Srpaulo		dlpi|libdlpi)
603190225Srpaulo			AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
604146768Ssam			#
605146768Ssam			# This might be Solaris 8 or later, with
606146768Ssam			# SIOCGLIFCONF, or it might be some other OS
607146768Ssam			# or some older version of Solaris, with
608146768Ssam			# just SIOCGIFCONF.
609146768Ssam			#
610146768Ssam			AC_MSG_CHECKING(whether we have SIOCGLIFCONF)
611146768Ssam			AC_CACHE_VAL(ac_cv_lbl_have_siocglifconf,
612146768Ssam			    AC_TRY_COMPILE(
613146768Ssam				[#include <sys/param.h>
614146768Ssam				#include <sys/file.h>
615146768Ssam				#include <sys/ioctl.h>
616146768Ssam				#include <sys/socket.h>
617146768Ssam				#include <sys/sockio.h>],
618146768Ssam				[ioctl(0, SIOCGLIFCONF, (char *)0);],
619146768Ssam				ac_cv_lbl_have_siocglifconf=yes,
620146768Ssam				ac_cv_lbl_have_siocglifconf=no))
621146768Ssam			AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
622146768Ssam			if test $ac_cv_lbl_have_siocglifconf = yes ; then
623146768Ssam				V_FINDALLDEVS=glifc
624146768Ssam			else
625146768Ssam				V_FINDALLDEVS=gifc
626146768Ssam			fi
627190225Srpaulo			#
628190225Srpaulo			# Needed for common functions used by pcap-[dlpi,libdlpi].c
629190225Srpaulo			#
630190225Srpaulo		 	SSRC="dlpisubs.c"
631146768Ssam			;;
632146768Ssam
633146768Ssam		*)
634146768Ssam			#
635146768Ssam			# Assume we just have SIOCGIFCONF.
636146768Ssam			# (XXX - on at least later Linux kernels, there's
637146768Ssam			# another mechanism, and we should be using that
638146768Ssam			# instead.)
639146768Ssam			#
640146768Ssam			V_FINDALLDEVS=gifc
641146768Ssam			;;
642146768Ssam		esac])
643146768Ssamfi
644190225Srpaulo])
645146768Ssam
646190225SrpauloAC_MSG_CHECKING(for socklen_t)
647190225SrpauloAC_TRY_COMPILE([
648190225Srpaulo	#include <sys/types.h>
649190225Srpaulo	#include <sys/socket.h>
650190225Srpaulo	],
651190225Srpaulo	[ socklen_t x; ],
652190225Srpaulo	have_socklen_t=yes,
653190225Srpaulo	have_socklen_t=no)
654190225Srpauloif test "x$have_socklen_t" = "xyes"; then
655190225Srpaulo	AC_DEFINE(HAVE_SOCKLEN_T, 1, [define if socklen_t is defined])
65656889Sfennerfi
657190225SrpauloAC_MSG_RESULT($have_socklen_t)
65856889Sfenner
659214518SrpauloAC_ARG_ENABLE(ipv6,
660214518SrpauloAC_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes, if getaddrinfo available@:>@]),
661190225Srpaulo    [],
662190225Srpaulo    [enable_ipv6=ifavailable])
663190225Srpauloif test "$enable_ipv6" != "no"; then
664190225Srpaulo	AC_CHECK_FUNC(getaddrinfo,
665190225Srpaulo	    [
666190225Srpaulo		AC_DEFINE(INET6,1,[IPv6])
667190225Srpaulo	    ],
668190225Srpaulo	    [
669190225Srpaulo		if test "$enable_ipv6" != "ifavailable"; then
670190225Srpaulo			AC_MSG_FAILURE([--enable-ipv6 was given, but getaddrinfo isn't available])
671190225Srpaulo		fi
672190225Srpaulo	    ])
673190225Srpaulofi
674190225Srpaulo
67598530SfennerAC_MSG_CHECKING(whether to build optimizer debugging code)
676214518SrpauloAC_ARG_ENABLE(optimizer-dbg,
677214518SrpauloAC_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code]))
67898530Sfennerif test "$enable_optimizer_dbg" = "yes"; then
67998530Sfenner	AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
68098530Sfennerfi
68198530SfennerAC_MSG_RESULT(${enable_optimizer_dbg-no})
68298530Sfenner
68398530SfennerAC_MSG_CHECKING(whether to build parser debugging code)
684214518SrpauloAC_ARG_ENABLE(yydebug,
685214518SrpauloAC_HELP_STRING([--enable-yydebug],[build parser debugging code]))
68698530Sfennerif test "$enable_yydebug" = "yes"; then
68798530Sfenner	AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
68898530Sfennerfi
68998530SfennerAC_MSG_RESULT(${enable_yydebug-no})
69098530Sfenner
691146768Ssam# Check for Endace DAG card support.
692214518SrpauloAC_ARG_WITH([dag],
693214518SrpauloAC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support @<:@"yes", "no" or DIR; default="yes" on BSD and Linux if present@:>@]),
694127664Sbms[
695127664Sbms	if test "$withval" = no
696127664Sbms	then
697146768Ssam		# User doesn't want DAG support.
698127664Sbms		want_dag=no
699127664Sbms	elif test "$withval" = yes
700127664Sbms	then
701146768Ssam		# User wants DAG support but hasn't specified a directory.
702127664Sbms		want_dag=yes
703127664Sbms	else
704146768Ssam		# User wants DAG support and has specified a directory, so use the provided value.
705127664Sbms		want_dag=yes
706127664Sbms		dag_root=$withval
707127664Sbms	fi
708127664Sbms],[
709127664Sbms	#
710127664Sbms	# Use DAG API if present, otherwise don't
711127664Sbms	#
712127664Sbms	want_dag=ifpresent
713127664Sbms])
714146768Ssam
715214518SrpauloAC_ARG_WITH([dag-includes],
716214518SrpauloAC_HELP_STRING([--with-dag-includes=DIR],[Endace DAG include directory]),
717146768Ssam[
718146768Ssam	# User wants DAG support and has specified a header directory, so use the provided value.
719146768Ssam	want_dag=yes
720146768Ssam	dag_include_dir=$withval
721146768Ssam],[])
722146768Ssam
723214518SrpauloAC_ARG_WITH([dag-libraries],
724214518SrpauloAC_HELP_STRING([--with-dag-libraries=DIR],[Endace DAG library directory]),
725146768Ssam[
726146768Ssam	# User wants DAG support and has specified a library directory, so use the provided value.
727146768Ssam	want_dag=yes
728146768Ssam	dag_lib_dir=$withval
729146768Ssam],[])
730146768Ssam
731127664Sbmscase "$V_PCAP" in
732127664Sbmslinux|bpf|dag)
733127664Sbms	#
734147894Ssam	# We support the DAG API if we're on Linux or BSD, or if we're
735147894Ssam	# building a DAG-only libpcap.
736127664Sbms	#
737127664Sbms	;;
738127664Sbms*)
739127664Sbms	#
740127664Sbms	# If the user explicitly requested DAG, tell them it's not
741127664Sbms	# supported.
742127664Sbms	#
743127664Sbms	# If they expressed no preference, don't include it.
744127664Sbms	#
745127664Sbms	if test $want_dag = yes; then
746146768Ssam		AC_MSG_ERROR([DAG support is only available with 'linux' 'bpf' and 'dag' packet capture types])
747127664Sbms	elif test $want_dag = yes; then
748127664Sbms		want_dag=no
749127664Sbms	fi
750127664Sbms	;;
751127664Sbmsesac
752127664Sbms
753146768Ssamac_cv_lbl_dag_api=no
754146768Ssamif test "$want_dag" != no; then
755127664Sbms
756146768Ssam	AC_MSG_CHECKING([whether we have DAG API headers])
757146768Ssam
758147894Ssam	# If necessary, set default paths for DAG API headers and libraries.
759127664Sbms	if test -z "$dag_root"; then
760146768Ssam	    dag_root=/usr/local
761127664Sbms	fi
762127664Sbms
763146768Ssam	if test -z "$dag_include_dir"; then
764127664Sbms		dag_include_dir="$dag_root/include"
765127664Sbms	fi
766127664Sbms
767146768Ssam	if test -z "$dag_lib_dir"; then
768146768Ssam	    dag_lib_dir="$dag_root/lib"
769146768Ssam	fi
770146768Ssam	
771146768Ssam	if test -z "$dag_tools_dir"; then
772146768Ssam	    dag_tools_dir="$dag_root/tools"
773235426Sdelphij	fi
774146768Ssam
775146768Ssam	if test -r $dag_include_dir/dagapi.h; then
776127664Sbms		ac_cv_lbl_dag_api=yes
777127664Sbms	fi
778147894Ssam	AC_MSG_RESULT([$ac_cv_lbl_dag_api ($dag_include_dir)])
779146768Ssamfi
780146768Ssam
781146768Ssamif test $ac_cv_lbl_dag_api = yes; then
782235426Sdelphij	V_INCLS="$V_INCLS -I$dag_include_dir"
783146768Ssam
784146768Ssam	if test $V_PCAP != dag ; then
785146768Ssam		 SSRC="pcap-dag.c"
786146768Ssam	fi
787146768Ssam
788146768Ssam	# See if we can find a general version string.
789147894Ssam	# Don't need to save and restore LIBS to prevent -ldag being
790147894Ssam	# included if there's a found-action (arg 3).
791146768Ssam	saved_ldflags=$LDFLAGS
792146768Ssam	LDFLAGS="-L$dag_lib_dir"
793190225Srpaulo	AC_CHECK_LIB([dag], [dag_attach_stream], [dag_streams="1"], [dag_streams="0"])
794172677Smlaier	AC_CHECK_LIB([dag],[dag_get_erf_types], [
795190225Srpaulo		AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])])
796190225Srpaulo	AC_CHECK_LIB([dag],[dag_get_stream_erf_types], [
797190225Srpaulo		AC_DEFINE(HAVE_DAG_GET_STREAM_ERF_TYPES, 1, [define if you have dag_get_stream_erf_types()])])
798235426Sdelphij
799146768Ssam	LDFLAGS=$saved_ldflags
800146768Ssam
801190225Srpaulo	if test "$dag_streams" = 1; then
802162012Ssam		AC_DEFINE(HAVE_DAG_STREAMS_API, 1, [define if you have streams capable DAG API])
803214518Srpaulo		LIBS="$LIBS -ldag"
804235426Sdelphij		LDFLAGS="$LDFLAGS -L$dag_lib_dir"
805235426Sdelphij		
806235426Sdelphij		AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"])
807235426Sdelphij		if test "$ac_dag_have_vdag" = 1; then
808235426Sdelphij			AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()])
809235426Sdelphij			LIBS="$LIBS -lpthread"
810235426Sdelphij		fi
811162012Ssam	fi
812162012Ssam
813146768Ssam	AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
814127664Sbmsfi
815127664Sbms
816190225SrpauloAC_MSG_CHECKING(whether we have the DAG API)
817190225Srpaulo
818146768Ssamif test $ac_cv_lbl_dag_api = no; then
819190225Srpaulo	AC_MSG_RESULT(no)
820146768Ssam	if test "$want_dag" = yes; then
821147894Ssam        	# User wanted DAG support but we couldn't find it.
822146768Ssam		AC_MSG_ERROR([DAG API requested, but not found at $dag_root: use --without-dag])
823146768Ssam	fi
824127664Sbms
825147894Ssam	if test "$V_PCAP" = dag; then
826147894Ssam		# User requested "dag" capture type but the DAG API wasn't
827147894Ssam		# found.
828147894Ssam		AC_MSG_ERROR([Specifying the capture type as "dag" requires the DAG API to be present; use the --with-dag options to specify the location. (Try "./configure --help" for more information.)])
829147894Ssam	fi
830190225Srpauloelse
831190225Srpaulo	AC_MSG_RESULT(yes)
832146768Ssamfi
833146768Ssam
834214518SrpauloAC_ARG_WITH(septel,
835214518SrpauloAC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied).  @<:@default=yes, on Linux, if present@:>@]),
836147894Ssam[
837147894Ssam	if test "$withval" = no
838147894Ssam	then
839147894Ssam		want_septel=no
840147894Ssam	elif test "$withval" = yes
841147894Ssam	then
842147894Ssam		want_septel=yes
843147894Ssam		septel_root=
844147894Ssam	else
845147894Ssam		want_septel=yes
846147894Ssam		septel_root=$withval
847147894Ssam	fi
848147894Ssam],[
849147894Ssam	#
850147894Ssam	# Use Septel API if present, otherwise don't
851147894Ssam	#
852147894Ssam	want_septel=ifpresent
853147894Ssam	septel_root=./../septel
854147894Ssam])
855147894Ssamac_cv_lbl_septel_api=no
856147894Ssamcase "$V_PCAP" in
857147894Ssamlinux|septel)
858147894Ssam	#
859147894Ssam	# We support the Septel API if we're on Linux, or if we're building
860147894Ssam	# a Septel-only libpcap.
861147894Ssam	#
862147894Ssam	;;
863147894Ssam*)
864147894Ssam	#
865147894Ssam	# If the user explicitly requested Septel, tell them it's not
866147894Ssam	# supported.
867147894Ssam	#
868147894Ssam	# If they expressed no preference, don't include it.
869147894Ssam	#
870147894Ssam	if test $want_septel = yes; then
871147894Ssam		AC_MSG_ERROR(Septel support only available with 'linux' and 'septel' packet capture types)
872147894Ssam	elif test $want_septel = yes; then
873147894Ssam		want_septel=no
874147894Ssam	fi
875147894Ssam	;;
876147894Ssamesac
877146768Ssam
878147894Ssamif test "$with_septel" != no; then
879147894Ssam	AC_MSG_CHECKING(whether we have Septel API)
880147894Ssam
881147894Ssam	if test -z "$septel_root"; then
882147894Ssam		septel_root=$srcdir/../septel
883147894Ssam	fi
884147894Ssam
885147894Ssam	septel_tools_dir="$septel_root"
886147894Ssam	septel_include_dir="$septel_root/INC"
887147894Ssam
888147894Ssam	ac_cv_lbl_septel_api=no
889147894Ssam	if test -r "$septel_include_dir/msg.h"; then
890147894Ssam		V_INCLS="$V_INCLS -I$septel_include_dir"
891214518Srpaulo		ADDLOBJS="$ADDLOBJS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o"
892214518Srpaulo		ADDLARCHIVEOBJS="$ADDLARCHIVEOBJS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o"
893147894Ssam
894147894Ssam		if test "$V_PCAP" != septel ; then
895147894Ssam			 SSRC="pcap-septel.c"
896147894Ssam		fi
897147894Ssam		ac_cv_lbl_septel_api=yes
898147894Ssam	fi
899147894Ssam
900147894Ssam	AC_MSG_RESULT($ac_cv_lbl_septel_api)
901147894Ssam	if test $ac_cv_lbl_septel_api = no; then
902147894Ssam		if test "$want_septel" = yes; then
903147894Ssam			AC_MSG_ERROR(Septel API not found under directory $septel_root; use --without-septel)
904147894Ssam		fi
905147894Ssam	else
906147894Ssam		AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have a Septel API])
907147894Ssam	fi
908147894Ssamfi
909147894Ssam
910147894Ssamif test "$V_PCAP" = septel -a "$ac_cv_lbl_septel_api" = no; then
911147894Ssam	AC_MSG_ERROR(Specifying the capture type as 'septel' requires the Septel API to be present; use --with-septel=DIR)
912147894Ssamfi
913147894Ssam
914214518Srpaulo# Check for Myricom SNF support.
915214518SrpauloAC_ARG_WITH([snf],
916214518SrpauloAC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support @<:@"yes", "no" or DIR; default="yes" on BSD and Linux if present@:>@]),
917214518Srpaulo[
918214518Srpaulo	if test "$withval" = no
919214518Srpaulo	then
920214518Srpaulo		# User explicitly doesn't want SNF
921214518Srpaulo		want_snf=no
922214518Srpaulo	elif test "$withval" = yes
923214518Srpaulo	then
924214518Srpaulo		# User wants SNF support but hasn't specific a directory.
925214518Srpaulo		want_snf=yes
926214518Srpaulo	else
927214518Srpaulo		# User wants SNF support with a specified directory.
928214518Srpaulo		want_snf=yes
929214518Srpaulo		snf_root=$withval
930214518Srpaulo	fi
931214518Srpaulo],[
932214518Srpaulo	#
933214518Srpaulo	# Use Sniffer API if present, otherwise don't
934214518Srpaulo	#
935214518Srpaulo	want_snf=ifpresent
936214518Srpaulo])
937147894Ssam
938214518SrpauloAC_ARG_WITH([snf-includes],
939214518SrpauloAC_HELP_STRING([--with-snf-includes=DIR],[Myricom SNF include directory]),
940214518Srpaulo[
941214518Srpaulo	# User wants SNF with specific header directory
942214518Srpaulo	want_snf=yes
943214518Srpaulo	snf_include_dir=$withval
944214518Srpaulo],[])
945214518Srpaulo
946214518SrpauloAC_ARG_WITH([snf-libraries],
947214518SrpauloAC_HELP_STRING([--with-snf-libraries=DIR],[Myricom SNF library directory]),
948214518Srpaulo[
949214518Srpaulo	# User wants SNF with specific lib directory
950214518Srpaulo	want_snf=yes
951214518Srpaulo	snf_lib_dir=$withval
952214518Srpaulo],[])
953214518Srpaulo
954214518Srpaulocase "$V_PCAP" in
955214518Srpaulobpf|linux|snf)
956214518Srpaulo	#
957214518Srpaulo	# We support the Sniffer API if we're on BSD, Linux, or if we're
958214518Srpaulo	# building a Sniffer-only libpcap.
959214518Srpaulo	#
960214518Srpaulo	;;
961214518Srpaulo*)
962214518Srpaulo	#
963214518Srpaulo	# If the user explicitly requested Sniffer, tell them it's not
964214518Srpaulo	# supported.
965214518Srpaulo	#
966214518Srpaulo	# If they expressed no preference, don't include it.
967214518Srpaulo	#
968214518Srpaulo	if test $want_snf = yes; then
969214518Srpaulo		AC_MSG_ERROR(Myricom SNF support only available with 'bpf' 'linux' and 'snf' packet capture types)
970214518Srpaulo	elif test $want_snf = yes; then
971214518Srpaulo		want_snf=no
972214518Srpaulo	fi
973214518Srpaulo	;;
974214518Srpauloesac
975214518Srpaulo
976214518Srpauloac_cv_lbl_snf_api=no
977214518Srpauloif test "$with_snf" != no; then
978214518Srpaulo
979214518Srpaulo	AC_MSG_CHECKING(whether we have Myricom Sniffer API)
980214518Srpaulo
981214518Srpaulo	if test -z "$snf_root"; then
982214518Srpaulo		snf_root=/opt/snf
983214518Srpaulo	fi
984214518Srpaulo
985214518Srpaulo	if test -z "$snf_include_dir"; then
986214518Srpaulo		snf_include_dir="$snf_root/include"
987214518Srpaulo	fi
988214518Srpaulo
989214518Srpaulo	if test -z "$snf_lib_dir"; then
990214518Srpaulo		snf_lib_dir="$snf_root/lib"
991214518Srpaulo	fi
992214518Srpaulo
993214518Srpaulo	if test -f "$snf_include_dir/snf.h"; then
994214518Srpaulo		ac_cv_lbl_snf_api=yes
995214518Srpaulo	fi
996214518Srpaulo	AC_MSG_RESULT([$ac_cv_lbl_snf_api ($snf_root)])
997214518Srpaulo
998214518Srpaulo	if test $ac_cv_lbl_snf_api = no; then
999214518Srpaulo		if test "$want_snf" = yes; then
1000214518Srpaulo			AC_MSG_ERROR(SNF API headers not found under $snf_include_dir; use --without-snf)
1001214518Srpaulo		fi
1002214518Srpaulo	else
1003214518Srpaulo		saved_ldflags=$LDFLAGS
1004214518Srpaulo		LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1005214518Srpaulo		AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"], [ac_cv_lbl_snf_api="no"])
1006214518Srpaulo		LDFLAGS="$saved_ldflags"
1007214518Srpaulo
1008214518Srpaulo		if test $ac_cv_lbl_snf_api = no; then
1009214518Srpaulo			if test "$want_snf" = yes; then
1010214518Srpaulo				AC_MSG_ERROR(SNF API cannot correctly be linked check config.log; use --without-snf)
1011214518Srpaulo			fi
1012214518Srpaulo		else
1013214518Srpaulo			V_INCLS="$V_INCLS -I$snf_include_dir"
1014214518Srpaulo			LIBS="$LIBS -lsnf"
1015214518Srpaulo			LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1016214518Srpaulo			if test "$V_PCAP" != snf ; then
1017214518Srpaulo				SSRC="pcap-snf.c"
1018214518Srpaulo			fi
1019214518Srpaulo			AC_DEFINE(HAVE_SNF_API, 1, [define if you have Myricom SNF API])
1020214518Srpaulo		fi
1021214518Srpaulo	fi
1022214518Srpaulofi
1023214518Srpaulo
1024214518Srpauloif test "$V_PCAP" = snf -a "$ac_cv_lbl_snf_api" = no; then
1025214518Srpaulo	AC_MSG_ERROR(Specifying the capture type as 'snf' requires the Myricom Sniffer API to be present; use --with-snf=DIR)
1026214518Srpaulofi
1027214518Srpaulo
102817683SpstAC_LBL_LEX_AND_YACC(V_LEX, V_YACC, pcap_)
102975107Sfennerif test "$V_LEX" = lex ; then
103075107Sfenner# Some versions of lex can't handle the definitions section of scanner.l .
103175107Sfenner# Try lexing it and complain if it can't deal.
103275107Sfenner	AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
103375107Sfenner		if lex -t scanner.l > /dev/null 2>&1; then
103475107Sfenner			tcpdump_cv_capable_lex=yes
103575107Sfenner		else
103675107Sfenner			tcpdump_cv_capable_lex=insufficient
103775107Sfenner		fi)
103875107Sfenner	if test $tcpdump_cv_capable_lex = insufficient ; then
103975107Sfenner		AC_MSG_ERROR([Your operating system's lex is insufficient to compile
104075107Sfenner libpcap.  flex is a lex replacement that has many advantages, including
104175107Sfenner being able to compile libpcap.  For more information, see
104275107Sfenner http://www.gnu.org/software/flex/flex.html .])
104375107Sfenner	fi
104475107Sfennerfi
104517683Spst
1046190225Srpaulo#
1047214518Srpaulo# Assume, by default, no support for shared libraries and V7/BSD convention
1048214518Srpaulo# for man pages (file formats in section 5, miscellaneous info in section 7).
1049214518Srpaulo# Individual cases can override this.
1050190225Srpaulo#
1051214518SrpauloDYEXT="none"
1052190225SrpauloMAN_FILE_FORMATS=5
1053190225SrpauloMAN_MISC_INFO=7
105498530Sfennercase "$host_os" in
105517683Spst
105617683Spstaix*)
105717683Spst	dnl Workaround to enable certain features
105875107Sfenner	AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
1059190225Srpaulo
1060214518Srpaulo	#
1061214518Srpaulo	# AIX makes it fun to build shared and static libraries,
1062214518Srpaulo	# because they're *both* ".a" archive libraries.  We
1063214518Srpaulo	# build the static library for the benefit of the traditional
1064214518Srpaulo	# scheme of building libpcap and tcpdump in subdirectories of
1065214518Srpaulo	# the same directory, with tcpdump statically linked with the
1066214518Srpaulo	# libpcap in question, but we also build a shared library as
1067214518Srpaulo	# "libpcap.shareda" and install *it*, rather than the static
1068214518Srpaulo	# library, as "libpcap.a".
1069214518Srpaulo	#
1070214518Srpaulo	DYEXT="shareda"
1071214518Srpaulo
1072214518Srpaulo	case "$V_PCAP" in
1073214518Srpaulo
1074214518Srpaulo	dlpi)
1075214518Srpaulo		#
1076214518Srpaulo		# If we're using DLPI, applications will need to
1077214518Srpaulo		# use /lib/pse.exp if present, as we use the
1078214518Srpaulo		# STREAMS routines.
1079214518Srpaulo		#
1080214518Srpaulo		pseexe="/lib/pse.exp"
1081214518Srpaulo		AC_MSG_CHECKING(for $pseexe)
1082214518Srpaulo		if test -f $pseexe ; then
1083214518Srpaulo			AC_MSG_RESULT(yes)
1084214518Srpaulo			LIBS="-I:$pseexe"
1085214518Srpaulo		fi
1086214518Srpaulo		;;
1087214518Srpaulo
1088214518Srpaulo	bpf)
1089214518Srpaulo		#
1090214518Srpaulo		# If we're using BPF, we need "-lodm" and "-lcfg", as
1091214518Srpaulo		# we use them to load the BPF module.
1092214518Srpaulo		#
1093214518Srpaulo		LIBS="-lodm -lcfg"
1094214518Srpaulo		;;
1095214518Srpaulo	esac
109617683Spst	;;
109717683Spst
1098190225Srpaulodarwin*)
1099190225Srpaulo	DYEXT="dylib"
1100190225Srpaulo	V_CCOPT="$V_CCOPT -fno-common"
1101235426Sdelphij	AC_ARG_ENABLE(universal,
1102235426Sdelphij	AC_HELP_STRING([--disable-universal],[don't build universal on OS X]))
1103235426Sdelphij	if test "$enable_universal" != "no"; then
1104235426Sdelphij		case "$host_os" in
1105235426Sdelphij
1106235426Sdelphij		darwin9.*)
1107235426Sdelphij			#
1108235426Sdelphij			# Leopard.  Build for 32-bit PowerPC, 64-bit
1109235426Sdelphij			# PowerPC, x86, and x86-64, with 32-bit PowerPC
1110235426Sdelphij			# first.  (That's what Apple does.)
1111235426Sdelphij			#
1112235426Sdelphij			V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1113235426Sdelphij			LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1114235426Sdelphij			;;
1115235426Sdelphij
1116235426Sdelphij		darwin10.*)
1117235426Sdelphij			#
1118235426Sdelphij			# Snow Leopard.  Build for x86-64, x86, and
1119235426Sdelphij			# 32-bit PowerPC, with x86-64 first.  (That's
1120235426Sdelphij			# what Apple does, even though Snow Leopard
1121235426Sdelphij			# doesn't run on PPC, so PPC libpcap runs under
1122235426Sdelphij			# Rosetta, and Rosetta doesn't support BPF
1123235426Sdelphij			# ioctls, so PPC programs can't do live
1124235426Sdelphij			# captures.)
1125235426Sdelphij			#
1126235426Sdelphij			V_CCOPT="$V_CCOPT -arch x86_64 -arch i386 -arch ppc"
1127235426Sdelphij			LDFLAGS="$LDFLAGS -arch x86_64 -arch i386 -arch ppc"
1128235426Sdelphij			;;
1129235426Sdelphij
1130235426Sdelphij		darwin11.*)
1131235426Sdelphij			#
1132235426Sdelphij			# Lion.  Build for x86-64 and x86, with x86-64
1133235426Sdelphij			# first.  (That's probably what Apple does,
1134235426Sdelphij			# given that Rosetta is gone.)
1135235426Sdelphij			#
1136235426Sdelphij			V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
1137235426Sdelphij			LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
1138235426Sdelphij			;;
1139235426Sdelphij		esac
1140235426Sdelphij	fi
1141190225Srpaulo	;;
1142190225Srpaulo
114326175Sfennerhpux9*)
114475107Sfenner	AC_DEFINE(HAVE_HPUX9,1,[on HP-UX 9.x])
1145190225Srpaulo
1146190225Srpaulo	#
1147190225Srpaulo	# Use System V conventions for man pages.
1148190225Srpaulo	#
1149190225Srpaulo	MAN_FILE_FORMATS=4
1150190225Srpaulo	MAN_MISC_INFO=5
115126175Sfenner	;;
115226175Sfenner
115339291Sfennerhpux10.0*)
1154190225Srpaulo
1155190225Srpaulo	#
1156190225Srpaulo	# Use System V conventions for man pages.
1157190225Srpaulo	#
1158190225Srpaulo	MAN_FILE_FORMATS=4
1159190225Srpaulo	MAN_MISC_INFO=5
116039291Sfenner	;;
116139291Sfenner
116239291Sfennerhpux10.1*)
1163190225Srpaulo
1164190225Srpaulo	#
1165190225Srpaulo	# Use System V conventions for man pages.
1166190225Srpaulo	#
1167190225Srpaulo	MAN_FILE_FORMATS=4
1168190225Srpaulo	MAN_MISC_INFO=5
116939291Sfenner	;;
117039291Sfenner
117139291Sfennerhpux*)
1172146768Ssam	dnl HPUX 10.20 and above is similar to HPUX 9, but
1173146768Ssam	dnl not the same....
1174146768Ssam	dnl
1175146768Ssam	dnl XXX - DYEXT should be set to "sl" if this is building
1176146768Ssam	dnl for 32-bit PA-RISC, but should be left as "so" for
1177146768Ssam	dnl 64-bit PA-RISC or, I suspect, IA-64.
1178147894Ssam	AC_DEFINE(HAVE_HPUX10_20_OR_LATER,1,[on HP-UX 10.20 or later])
1179214518Srpaulo	if test "`uname -m`" = "ia64"; then
1180214518Srpaulo		DYEXT="so"
1181214518Srpaulo	else
1182214518Srpaulo		DYEXT="sl"
1183214518Srpaulo	fi
1184190225Srpaulo
1185190225Srpaulo	#
1186214518Srpaulo	# "-b" builds a shared library; "+h" sets the soname.
1187214518Srpaulo	#
1188214518Srpaulo	SHLIB_OPT="-b"
1189214518Srpaulo	SONAME_OPT="+h"
1190214518Srpaulo
1191214518Srpaulo	#
1192190225Srpaulo	# Use System V conventions for man pages.
1193190225Srpaulo	#
1194190225Srpaulo	MAN_FILE_FORMATS=4
1195190225Srpaulo	MAN_MISC_INFO=5
119639291Sfenner	;;
119739291Sfenner
1198190225Srpauloirix*)
1199190225Srpaulo	#
1200190225Srpaulo	# Use System V conventions for man pages.
1201190225Srpaulo	#
1202190225Srpaulo	MAN_FILE_FORMATS=4
1203190225Srpaulo	MAN_MISC_INFO=5
1204190225Srpaulo	;;
1205190225Srpaulo
1206235426Sdelphijlinux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*)
1207214518Srpaulo	DYEXT="so"
1208214518Srpaulo
1209214518Srpaulo	#
1210214518Srpaulo	# Compiler assumed to be GCC; run-time linker may require a -R
1211214518Srpaulo	# flag.
1212214518Srpaulo	#
1213214518Srpaulo	if test "$libdir" != "/usr/lib"; then
1214214518Srpaulo		V_RFLAGS=-Wl,-R$libdir
1215214518Srpaulo	fi
1216190225Srpaulo	;;
1217190225Srpaulo
1218190225Srpauloosf*)
1219214518Srpaulo	DYEXT="so"
1220214518Srpaulo
1221190225Srpaulo	#
1222190225Srpaulo	# Use System V conventions for man pages.
1223190225Srpaulo	#
1224190225Srpaulo	MAN_FILE_FORMATS=4
1225190225Srpaulo	MAN_MISC_INFO=5
1226190225Srpaulo	;;
1227190225Srpaulo
122826175Sfennersinix*)
122926175Sfenner	AC_MSG_CHECKING(if SINIX compiler defines sinix)
123026175Sfenner	AC_CACHE_VAL(ac_cv_cc_sinix_defined,
123126175Sfenner		AC_TRY_COMPILE(
123226175Sfenner		    [],
123326175Sfenner		    [int i = sinix;],
123426175Sfenner		    ac_cv_cc_sinix_defined=yes,
123526175Sfenner		    ac_cv_cc_sinix_defined=no))
123626175Sfenner	    AC_MSG_RESULT($ac_cv_cc_sinix_defined)
123726175Sfenner	    if test $ac_cv_cc_sinix_defined = no ; then
123875107Sfenner		    AC_DEFINE(sinix,1,[on sinix])
123926175Sfenner	    fi
124026175Sfenner	;;
124126175Sfenner
124217683Spstsolaris*)
124375107Sfenner	AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
1244146768Ssam
1245214518Srpaulo	DYEXT="so"
1246190225Srpaulo	#
1247190225Srpaulo	# Use System V conventions for man pages.
1248190225Srpaulo	#
1249190225Srpaulo	MAN_FILE_FORMATS=4
1250190225Srpaulo	MAN_MISC_INFO=5
1251146768Ssam	;;
125217683Spstesac
125317683Spst
1254241231SdelphijAC_ARG_ENABLE(shared,
1255241231SdelphijAC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@]))
1256241231Sdelphijtest "x$enable_shared" = "xno" && DYEXT="none"
1257241231Sdelphij
125875107SfennerAC_PROG_RANLIB
1259235426SdelphijAC_CHECK_TOOL([AR], [ar])
126017683Spst
126117683SpstAC_LBL_DEVEL(V_CCOPT)
126217683Spst
126317683SpstAC_LBL_SOCKADDR_SA_LEN
126417683Spst
1265127664SbmsAC_LBL_SOCKADDR_STORAGE
1266127664Sbms
126775107SfennerAC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
126875107Sfenner
126917683SpstAC_LBL_UNALIGNED_ACCESS
127017683Spst
1271146768Ssam#
1272146768Ssam# Makefile.in includes rules to generate version.h, so we assume
1273146768Ssam# that it will be generated if autoconf is used.
1274146768Ssam#
1275146768SsamAC_DEFINE(HAVE_VERSION_H, 1, [define if version.h is generated in the build procedure])
1276146768Ssam
127717683Spstrm -f net
127856889Sfennerln -s ${srcdir}/bpf/net net
127917683Spst
128017683SpstAC_SUBST(V_CCOPT)
1281127664SbmsAC_SUBST(V_DEFS)
1282214518SrpauloAC_SUBST(V_FINDALLDEVS)
128317683SpstAC_SUBST(V_INCLS)
128417683SpstAC_SUBST(V_LEX)
128517683SpstAC_SUBST(V_PCAP)
1286214518SrpauloAC_SUBST(V_SHLIB_CMD)
1287214518SrpauloAC_SUBST(V_SHLIB_OPT)
1288214518SrpauloAC_SUBST(V_SONAME_OPT)
1289214518SrpauloAC_SUBST(V_RPATH_OPT)
129017683SpstAC_SUBST(V_YACC)
1291214518SrpauloAC_SUBST(ADDLOBJS)
1292214518SrpauloAC_SUBST(ADDLARCHIVEOBJS)
1293127664SbmsAC_SUBST(SSRC)
1294146768SsamAC_SUBST(DYEXT)
1295190225SrpauloAC_SUBST(MAN_FILE_FORMATS)
1296190225SrpauloAC_SUBST(MAN_MISC_INFO)
129717683Spst
1298190225Srpaulodnl check for USB sniffing support
1299190225SrpauloAC_MSG_CHECKING(for USB sniffing support)
1300190225Srpaulocase "$host_os" in
1301190225Srpaulolinux*)
1302235426Sdelphij	AC_DEFINE(PCAP_SUPPORT_USB, 1, [target host supports USB sniffing])
1303235426Sdelphij	USB_SRC=pcap-usb-linux.c
1304235426Sdelphij	AC_MSG_RESULT(yes)
1305235426Sdelphij	ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null`
1306235426Sdelphij	if test $? -ne 0 ; then
1307235426Sdelphij	  ac_usb_dev_name="usbmon"
1308235426Sdelphij	fi
1309235426Sdelphij	AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing])
1310235426Sdelphij	AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name)
1311235426Sdelphij	#
1312235426Sdelphij	# Do we have a version of <linux/compiler.h> available?
1313235426Sdelphij	# If so, we might need it for <linux/usbdevice_fs.h>.
1314235426Sdelphij	#
1315235426Sdelphij	AC_CHECK_HEADERS(linux/compiler.h)
1316235426Sdelphij	if test "$ac_cv_header_linux_compiler_h" = yes; then
1317235426Sdelphij	  #
1318235426Sdelphij	  # Yes - include it when testing for <linux/usbdevice_fs.h>.
1319235426Sdelphij	  #
1320235426Sdelphij	  AC_CHECK_HEADERS(linux/usbdevice_fs.h,,,[#include <linux/compiler.h>])
1321235426Sdelphij	else
1322235426Sdelphij	  AC_CHECK_HEADERS(linux/usbdevice_fs.h)
1323235426Sdelphij	fi
1324235426Sdelphij	if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then
1325235426Sdelphij	  #
1326235426Sdelphij	  # OK, does it define bRequestType?  Older versions of the kernel
1327235426Sdelphij	  # define fields with names like "requesttype, "request", and
1328235426Sdelphij	  # "value", rather than "bRequestType", "bRequest", and
1329235426Sdelphij	  # "wValue".
1330235426Sdelphij	  #
1331235426Sdelphij	  AC_MSG_CHECKING(if usbdevfs_ctrltransfer struct has bRequestType member)
1332235426Sdelphij	  AC_CACHE_VAL(ac_cv_usbdevfs_ctrltransfer_has_bRequestType,
1333235426Sdelphij	    AC_TRY_COMPILE([
1334214518SrpauloAC_INCLUDES_DEFAULT
1335214518Srpaulo#ifdef HAVE_SYS_BITYPES_H
1336214518Srpaulo#include <sys/bitypes.h>
1337214518Srpaulo#endif
1338235426Sdelphij#ifdef HAVE_LINUX_COMPILER_H
1339235426Sdelphij#include <linux/compiler.h>
1340235426Sdelphij#endif
1341235426Sdelphij#include <linux/usbdevice_fs.h>],
1342235426Sdelphij	      [u_int i = sizeof(((struct usbdevfs_ctrltransfer *)0)->bRequestType)],
1343235426Sdelphij	      ac_cv_usbdevfs_ctrltransfer_has_bRequestType=yes,
1344235426Sdelphij	      ac_cv_usbdevfs_ctrltransfer_has_bRequestType=no))
1345235426Sdelphij	    AC_MSG_RESULT($ac_cv_usbdevfs_ctrltransfer_has_bRequestType)
1346235426Sdelphij	    if test $ac_cv_usbdevfs_ctrltransfer_has_bRequestType = yes ; then
1347235426Sdelphij	      AC_DEFINE(HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE,1,
1348235426Sdelphij	        [if struct usbdevfs_ctrltransfer has bRequestType])
1349235426Sdelphij	    fi
1350235426Sdelphij	fi
1351235426Sdelphij	;;
1352190225Srpaulo*)
1353235426Sdelphij	AC_MSG_RESULT(no)
1354235426Sdelphij	;;
1355190225Srpauloesac
1356190225SrpauloAC_SUBST(PCAP_SUPPORT_USB)
1357190225SrpauloAC_SUBST(USB_SRC)
1358190225Srpaulo
1359235426Sdelphijdnl check for netfilter sniffing support
1360235426SdelphijAC_MSG_CHECKING(whether the platform could support netfilter sniffing)
1361235426Sdelphijcase "$host_os" in
1362235426Sdelphijlinux*)
1363235426Sdelphij	AC_MSG_RESULT(yes)
1364235426Sdelphij	#
1365235426Sdelphij	# Life's too short to deal with trying to get this to compile
1366235426Sdelphij	# if you don't get the right types defined with
1367235426Sdelphij	# __KERNEL_STRICT_NAMES getting defined by some other include.
1368235426Sdelphij	#
1369235426Sdelphij	# Check whether the includes Just Work.  If not, don't turn on
1370235426Sdelphij	# netfilter support.
1371235426Sdelphij	#
1372235426Sdelphij	AC_MSG_CHECKING(whether we can compile the netfilter support)
1373235426Sdelphij	AC_CACHE_VAL(ac_cv_netfilter_can_compile,
1374235426Sdelphij	  AC_TRY_COMPILE([
1375235426SdelphijAC_INCLUDES_DEFAULT
1376235426Sdelphij#include <sys/socket.h>
1377251129Sdelphij#include <netinet/in.h>
1378235426Sdelphij#include <linux/types.h>
1379235426Sdelphij
1380235426Sdelphij#include <linux/netlink.h>
1381251129Sdelphij#include <linux/netfilter.h>
1382235426Sdelphij#include <linux/netfilter/nfnetlink.h>
1383251129Sdelphij#include <linux/netfilter/nfnetlink_log.h>
1384251129Sdelphij#include <linux/netfilter/nfnetlink_queue.h>],
1385235426Sdelphij	    [],
1386235426Sdelphij	    ac_cv_netfilter_can_compile=yes,
1387235426Sdelphij	    ac_cv_netfilter_can_compile=no))
1388235426Sdelphij	AC_MSG_RESULT($ac_cv_netfilter_can_compile)
1389235426Sdelphij	if test $ac_cv_netfilter_can_compile = yes ; then
1390235426Sdelphij	  AC_DEFINE(PCAP_SUPPORT_NETFILTER, 1,
1391235426Sdelphij	    [target host supports netfilter sniffing])
1392235426Sdelphij	  NETFILTER_SRC=pcap-netfilter-linux.c
1393235426Sdelphij	fi
1394235426Sdelphij	;;
1395235426Sdelphij*)
1396235426Sdelphij	AC_MSG_RESULT(no)
1397235426Sdelphij	;;
1398235426Sdelphijesac
1399235426SdelphijAC_SUBST(PCAP_SUPPORT_NETFILTER)
1400235426SdelphijAC_SUBST(NETFILTER_SRC)
1401235426Sdelphij
1402214518SrpauloAC_ARG_ENABLE([bluetooth],
1403214518Srpaulo[AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
1404251129Sdelphij    [],
1405251129Sdelphij    [enable_bluetooth=yes])
1406190225Srpaulo
1407214518Srpauloif test "x$enable_bluetooth" != "xno" ; then
1408214518Srpaulo	dnl check for Bluetooth sniffing support
1409214518Srpaulo	case "$host_os" in
1410214518Srpaulo	linux*)
1411235426Sdelphij		AC_CHECK_HEADER(bluetooth/bluetooth.h,
1412235426Sdelphij		[
1413214518Srpaulo		  AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
1414235426Sdelphij		  BT_SRC=pcap-bt-linux.c
1415235426Sdelphij		  AC_MSG_NOTICE(Bluetooth sniffing is supported)
1416251129Sdelphij
1417251129Sdelphij		  #
1418251129Sdelphij		  # OK, does struct sockaddr_hci have an hci_channel
1419251129Sdelphij		  # member?
1420251129Sdelphij		  #
1421251129Sdelphij		  AC_MSG_CHECKING(if struct sockaddr_hci has hci_channel member)
1422251129Sdelphij		  AC_CACHE_VAL(ac_cv_lbl_sockaddr_hci_has_hci_channel,
1423251129Sdelphij		    AC_TRY_COMPILE(
1424251129Sdelphij[
1425251129Sdelphij#include <bluetooth/bluetooth.h>
1426251129Sdelphij#include <bluetooth/hci.h>
1427251129Sdelphij],
1428251129Sdelphij		      [u_int i = sizeof(((struct sockaddr_hci *)0)->hci_channel)],
1429251129Sdelphij		      ac_cv_lbl_sockaddr_hci_has_hci_channel=yes,
1430251129Sdelphij		      ac_cv_lbl_sockaddr_hci_has_hci_channel=no))
1431251129Sdelphij		    AC_MSG_RESULT($ac_cv_lbl_sockaddr_hci_has_hci_channel)
1432251129Sdelphij		    if test $ac_cv_lbl_sockaddr_hci_has_hci_channel = yes ; then
1433251129Sdelphij		      AC_DEFINE(SOCKADDR_HCI_HAS_HCI_CHANNEL,,
1434251129Sdelphij			[if struct sockaddr_hci has hci_channel member])
1435251129Sdelphij		    fi
1436214518Srpaulo		],
1437214518Srpaulo		AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
1438235426Sdelphij		)
1439235426Sdelphij		;;
1440214518Srpaulo	*)
1441235426Sdelphij		AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os)
1442235426Sdelphij		;;
1443214518Srpaulo	esac
1444214518Srpaulo	AC_SUBST(PCAP_SUPPORT_BT)
1445214518Srpaulo	AC_SUBST(BT_SRC)
1446214518Srpaulofi
1447214518Srpaulo
1448241231SdelphijAC_ARG_ENABLE([canusb],
1449251129Sdelphij[AC_HELP_STRING([--enable-canusb],[enable canusb support @<:@default=yes, if support available@:>@])],
1450251129Sdelphij    [],
1451251129Sdelphij    [enable_canusb=yes])
1452241231Sdelphij
1453241231Sdelphijif test "x$enable_canusb" != "xno" ; then
1454241231Sdelphij	dnl check for canusb support
1455241231Sdelphij	case "$host_os" in
1456241231Sdelphij	linux*)
1457241231Sdelphij		AC_CHECK_HEADER(libusb-1.0/libusb.h,
1458241231Sdelphij		[
1459241231Sdelphij		    AC_DEFINE(PCAP_SUPPORT_CANUSB, 1, [target host supports canusb])
1460241231Sdelphij		    CANUSB_SRC=pcap-canusb-linux.c
1461251129Sdelphij		    LIBS="-lusb-1.0 -lpthread $LIBS"
1462241231Sdelphij		    AC_MSG_NOTICE(canusb sniffing is supported)
1463241231Sdelphij		],
1464241231Sdelphij		AC_MSG_NOTICE(canusb sniffing is not supported; install libusb1.0 lib devel to enable it)
1465241231Sdelphij		)
1466241231Sdelphij		;;
1467241231Sdelphij	*)
1468241231Sdelphij		AC_MSG_NOTICE(no canusb support implemented for $host_os)
1469241231Sdelphij		;;
1470241231Sdelphij	esac
1471241231Sdelphij	AC_SUBST(PCAP_SUPPORT_CANUSB)
1472241231Sdelphij	AC_SUBST(CANUSB_SRC)
1473241231Sdelphijfi
1474241231Sdelphij
1475214518SrpauloAC_ARG_ENABLE([can],
1476214518Srpaulo[AC_HELP_STRING([--enable-can],[enable CAN support @<:@default=yes, if support available@:>@])],
1477251129Sdelphij    [],
1478251129Sdelphij    [enable_can=yes])
1479214518Srpaulo
1480214518Srpauloif test "x$enable_can" != "xno" ; then
1481214518Srpaulo	dnl check for CAN sniffing support
1482214518Srpaulo	case "$host_os" in
1483214518Srpaulo	linux*)
1484214518Srpaulo		AC_CHECK_HEADER(linux/can.h,
1485214518Srpaulo			[ AC_DEFINE(PCAP_SUPPORT_CAN, 1, [target host supports CAN sniffing])
1486214518Srpaulo			CAN_SRC=pcap-can-linux.c
1487214518Srpaulo			AC_MSG_NOTICE(CAN sniffing is supported)],
1488214518Srpaulo			AC_MSG_NOTICE(CAN sniffing is not supported),
1489214518Srpaulo			[#include <sys/socket.h>]
1490214518Srpaulo		   )
1491214518Srpaulo		;;
1492214518Srpaulo	*)
1493214518Srpaulo		AC_MSG_NOTICE(no CAN sniffing support implemented for $host_os)
1494214518Srpaulo		;;
1495214518Srpaulo	esac
1496214518Srpaulo	AC_SUBST(PCAP_SUPPORT_CAN)
1497214518Srpaulo	AC_SUBST(CAN_SRC)
1498214518Srpaulofi
1499214518Srpaulo
1500235426Sdelphijdnl check for hardware timestamp support
1501235426Sdelphijcase "$host_os" in
1502235426Sdelphijlinux*)
1503235426Sdelphij	AC_CHECK_HEADERS([linux/net_tstamp.h])
1504235426Sdelphij	;;
1505235426Sdelphij*)
1506235426Sdelphij	AC_MSG_NOTICE(no hardware timestamp support implemented for $host_os)
1507235426Sdelphij	;;
1508235426Sdelphijesac
1509235426Sdelphij
151017683SpstAC_PROG_INSTALL
151117683Spst
151275107SfennerAC_CONFIG_HEADER(config.h)
151375107Sfenner
1514190225SrpauloAC_OUTPUT(Makefile pcap-filter.manmisc pcap-linktype.manmisc
1515235426Sdelphij	pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap
1516235426Sdelphij	pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap
1517235426Sdelphij	pcap_list_datalinks.3pcap pcap_list_tstamp_types.3pcap
1518235426Sdelphij	pcap_open_dead.3pcap pcap_open_offline.3pcap
1519235426Sdelphij	pcap_set_tstamp_type.3pcap)
152017683Spst
152117683Spstif test -f .devel ; then
152217683Spst	make depend
152317683Spstfi
152417683Spstexit 0
1525