1335640Shselaskydnl
2335640Shselaskydnl Copyright (c) 1994, 1995, 1996, 1997
3335640Shselaskydnl	The Regents of the University of California.  All rights reserved.
4335640Shselaskydnl
5335640Shselaskydnl Process this file with autoconf to produce a configure script.
6335640Shselaskydnl
7335640Shselasky
8335640Shselasky#
9335640Shselasky# See
10335640Shselasky#
11335640Shselasky#	http://ftp.gnu.org/gnu/config/README
12335640Shselasky#
13335640Shselasky# for the URLs to use to fetch new versions of config.guess and
14335640Shselasky# config.sub.
15335640Shselasky#
16335640Shselasky
17335640ShselaskyAC_PREREQ(2.64)
18335640Shselasky
19335640ShselaskyAC_INIT(pcap, m4_esyscmd_s([cat VERSION]))
20335640ShselaskyAC_CONFIG_SRCDIR(pcap.c)
21335640ShselaskyAC_SUBST(PACKAGE_NAME)
22335640Shselasky
23335640ShselaskyAC_CANONICAL_SYSTEM
24335640Shselasky
25335640ShselaskyAC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS)
26335640Shselasky#
27335640Shselasky# Try to enable as many C99 features as we can.
28335640Shselasky# At minimum, we want C++/C99-style // comments.
29335640Shselasky#
30335640ShselaskyAC_PROG_CC_C99
31356341Scyif test "$ac_cv_prog_cc_c99" = "no"; then
32356341Scy	AC_MSG_WARN([The C compiler does not support C99; there may be compiler errors])
33356341Scyfi
34335640ShselaskyAC_LBL_C_INIT(V_CCOPT, V_INCLS)
35335640ShselaskyAC_LBL_SHLIBS_INIT
36335640ShselaskyAC_LBL_C_INLINE
37335640Shselasky
38335640Shselasky#
39335640Shselasky# Try to arrange for large file support.
40335640Shselasky#
41335640ShselaskyAC_SYS_LARGEFILE
42335640ShselaskyAC_FUNC_FSEEKO
43335640Shselasky
44335640Shselaskydnl
45335640Shselaskydnl Even if <net/bpf.h> were, on all OSes that support BPF, fixed to
46335640Shselaskydnl include <sys/ioccom.h>, and we were to drop support for older
47335640Shselaskydnl releases without that fix, so that pcap-bpf.c doesn't need to
48335640Shselaskydnl include <sys/ioccom.h>, the test program in "AC_LBL_FIXINCLUDES"
49335640Shselaskydnl in "aclocal.m4" uses it, so we would still have to test for it
50335640Shselaskydnl and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
51335640Shselaskydnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris.
52335640Shselaskydnl
53335640ShselaskyAC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h limits.h)
54335640ShselaskyAC_CHECK_HEADERS(netpacket/packet.h)
55335640ShselaskyAC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
56335640Shselasky#include <sys/socket.h>
57335640Shselasky#include <net/if.h>])
58335640Shselaskyif test "$ac_cv_header_net_pfvar_h" = yes; then
59335640Shselasky	#
60335640Shselasky	# Check for various PF actions.
61335640Shselasky	#
62335640Shselasky	AC_MSG_CHECKING(whether net/pfvar.h defines PF_NAT through PF_NORDR)
63335640Shselasky	AC_TRY_COMPILE(
64335640Shselasky	    [#include <sys/types.h>
65335640Shselasky	    #include <sys/socket.h>
66335640Shselasky	    #include <net/if.h>
67335640Shselasky	    #include <net/pfvar.h>],
68335640Shselasky	    [return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR;],
69335640Shselasky	    [
70335640Shselasky		AC_MSG_RESULT(yes)
71335640Shselasky		AC_DEFINE(HAVE_PF_NAT_THROUGH_PF_NORDR, 1,
72335640Shselasky		    [define if net/pfvar.h defines PF_NAT through PF_NORDR])
73335640Shselasky	    ],
74335640Shselasky	    AC_MSG_RESULT(no))
75335640Shselaskyfi
76335640Shselasky
77335640Shselaskycase "$host_os" in
78335640Shselaskylinux*|uclinux*)
79335640Shselasky	AC_CHECK_HEADERS(linux/sockios.h linux/if_bonding.h,,,
80335640Shselasky	[
81335640Shselasky#include <sys/socket.h>
82335640Shselasky#include <linux/if.h>
83335640Shselasky	])
84335640Shselasky	;;
85335640Shselaskyesac
86335640Shselasky
87335640ShselaskyAC_LBL_FIXINCLUDES
88335640Shselasky
89356341ScyAC_CHECK_FUNCS(strerror)
90356341ScyAC_CHECK_FUNC(strerror_r,
91356341Scy    [
92356341Scy	#
93356341Scy	# We have strerror_r; if we define _GNU_SOURCE, is it a
94356341Scy	# POSIX-compliant strerror_r() or a GNU strerror_r()?
95356341Scy	#
96356341Scy	AC_MSG_CHECKING(whether strerror_r is GNU-style)
97356341Scy	AC_COMPILE_IFELSE(
98356341Scy	    [
99356341Scy		AC_LANG_SOURCE(
100356341Scy#define _GNU_SOURCE
101356341Scy#include <string.h>
102335640Shselasky
103356341Scy/* Define it GNU-style; that will cause an error if it's not GNU-style */
104356341Scyextern char *strerror_r(int, char *, size_t);
105356341Scy
106356341Scyint
107356341Scymain(void)
108356341Scy{
109356341Scy	return 0;
110356341Scy}
111356341Scy)
112356341Scy	    ],
113356341Scy	    [
114356341Scy	        # GNU-style
115356341Scy		AC_MSG_RESULT(yes)
116356341Scy		AC_DEFINE(HAVE_GNU_STRERROR_R,,
117356341Scy		    [Define to 1 if you have a GNU-style `strerror_r' function.])
118356341Scy	    ],
119356341Scy	    [
120356341Scy		AC_MSG_RESULT(no)
121356341Scy		AC_DEFINE(HAVE_POSIX_STRERROR_R,,
122356341Scy		    [Define to 1 if you have a POSIX-style `strerror_r' function.])
123356341Scy	    ])
124356341Scy    ],
125356341Scy    [
126356341Scy	#
127356341Scy	# We don't have strerror_r; do we have strerror_s?
128356341Scy	#
129356341Scy	AC_CHECK_FUNCS(strerror_s)
130356341Scy    ])
131356341Scy
132356341Scy#
133356341Scy# Thanks, IBM, for not providing vsyslog() in AIX!
134356341Scy#
135356341ScyAC_CHECK_FUNCS(vsyslog)
136356341Scy
137356341Scy#
138356341Scy# Either:
139356341Scy#
140356341Scy#	we have snprintf() and vsnprintf(), and have asprintf() and
141356341Scy#	vasprintf();
142356341Scy#
143356341Scy#	we have snprintf() and vsnprintf(), but don't have asprintf()
144356341Scy#	or vasprintf();
145356341Scy#
146356341Scy#	we have neither snprintf() nor vsnprintf(), and don't have
147356341Scy#	asprintf() or vasprintf(), either.
148356341Scy#
149356341Scy# We assume that if we have asprintf() we have vasprintf(), as well
150356341Scy# as snprintf() and vsnprintf(), and that if we have snprintf() we
151356341Scy# have vsnprintf().
152356341Scy#
153356341Scy# For the first case, we don't need any replacement routines.
154356341Scy# For the second case, we need replacement asprintf()/vasprintf()
155356341Scy# routines.
156356341Scy# For the third case, we need replacement snprintf()/vsnprintf() and
157356341Scy# asprintf()/vasprintf() routines.
158356341Scy#
159335640Shselaskyneedsnprintf=no
160335640ShselaskyAC_CHECK_FUNCS(vsnprintf snprintf,,
161335640Shselasky	[needsnprintf=yes])
162356341Scyneedasprintf=no
163356341ScyAC_CHECK_FUNCS(vasprintf asprintf,,
164356341Scy	[needasprintf=yes])
165335640Shselaskyif test $needsnprintf = yes; then
166356341Scy	#
167356341Scy	# We assume we have none of them; missing/snprintf.c supplies
168356341Scy	# all of them.
169356341Scy	#
170335640Shselasky	AC_LIBOBJ([snprintf])
171356341Scyelif test $needasprintf = yes; then
172356341Scy	#
173356341Scy	# We assume we have snprintf()/vsnprintf() but lack
174356341Scy	# asprintf()/vasprintf(); missing/asprintf.c supplies
175356341Scy	# the latter (using vsnprintf()).
176356341Scy	#
177356341Scy	AC_LIBOBJ([asprintf])
178335640Shselaskyfi
179335640Shselasky
180356341Scyneedstrlcat=no
181356341ScyAC_CHECK_FUNCS(strlcat,,
182356341Scy	[needstrlcat=yes])
183356341Scyif test $needstrlcat = yes; then
184356341Scy	AC_LIBOBJ([strlcat])
185356341Scyfi
186356341Scy
187356341Scyneedstrlcpy=no
188356341ScyAC_CHECK_FUNCS(strlcpy,,
189356341Scy	[needstrlcpy=yes])
190356341Scyif test $needstrlcpy = yes; then
191356341Scy	AC_LIBOBJ([strlcpy])
192356341Scyfi
193356341Scy
194335640Shselaskyneedstrtok_r=no
195335640ShselaskyAC_CHECK_FUNCS(strtok_r,,
196335640Shselasky	[needstrtok_r=yes])
197335640Shselaskyif test $needstrtok_r = yes; then
198335640Shselasky	AC_LIBOBJ([strtok_r])
199335640Shselaskyfi
200335640Shselasky
201335640Shselasky#
202335640Shselasky# Do we have ffs(), and is it declared in <strings.h>?
203335640Shselasky#
204335640ShselaskyAC_CHECK_FUNCS(ffs)
205335640Shselaskyif test "$ac_cv_func_ffs" = yes; then
206335640Shselasky	#
207335640Shselasky	# We have ffs(); is it declared in <strings.h>?
208335640Shselasky	#
209335640Shselasky	# This test fails if we don't have <strings.h> or if we do
210335640Shselasky	# but it doesn't declare ffs().
211335640Shselasky	#
212335640Shselasky	AC_CHECK_DECL(ffs,
213335640Shselasky	    [
214335640Shselasky		AC_DEFINE(STRINGS_H_DECLARES_FFS,,
215335640Shselasky		    [Define to 1 if strings.h declares `ffs'])
216335640Shselasky	    ],,
217335640Shselasky	    [
218335640Shselasky#include <strings.h>
219335640Shselasky	    ])
220335640Shselaskyfi
221335640Shselasky
222335640Shselasky#
223335640Shselasky# Do this before checking for ether_hostton(), as it's a
224335640Shselasky# "getaddrinfo()-ish function".
225335640Shselasky#
226335640ShselaskyAC_LBL_LIBRARY_NET
227335640Shselasky
228335640Shselasky#
229335640Shselasky# Check for reentrant versions of getnetbyname_r(), as provided by
230335640Shselasky# Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!).
231335640Shselasky# If we don't find one, we just use getnetbyname(), which uses
232335640Shselasky# thread-specific data on many platforms, but doesn't use it on
233335640Shselasky# NetBSD or OpenBSD, and may not use it on older versions of other
234335640Shselasky# platforms.
235335640Shselasky#
236335640Shselasky# Only do the check if we have a declaration of getnetbyname_r();
237335640Shselasky# without it, we can't check which API it has.  (We assume that
238335640Shselasky# if there's a declaration, it has a prototype, so that the API
239335640Shselasky# can be checked.)
240335640Shselasky#
241335640ShselaskyAC_CHECK_DECL(getnetbyname_r,
242335640Shselasky    [
243335640Shselasky	AC_MSG_CHECKING([for the Linux getnetbyname_r()])
244335640Shselasky	AC_TRY_LINK(
245335640Shselasky	    [#include <netdb.h>],
246335640Shselasky	    [
247335640Shselasky		struct netent netent_buf;
248335640Shselasky		char buf[1024];
249335640Shselasky		struct netent *resultp;
250335640Shselasky		int h_errnoval;
251335640Shselasky
252335640Shselasky		return getnetbyname_r((const char *)0, &netent_buf, buf, sizeof buf, &resultp, &h_errnoval);
253335640Shselasky	    ],
254335640Shselasky	    [
255335640Shselasky		AC_MSG_RESULT(yes)
256335640Shselasky		AC_DEFINE(HAVE_LINUX_GETNETBYNAME_R, 1,
257335640Shselasky		    [define if we have the Linux getnetbyname_r()])
258335640Shselasky	    ],
259335640Shselasky	    [
260335640Shselasky		AC_MSG_RESULT(no)
261335640Shselasky
262335640Shselasky		AC_MSG_CHECKING([for Solaris/IRIX getnetbyname_r()])
263335640Shselasky		AC_TRY_LINK(
264335640Shselasky		    [#include <netdb.h>],
265335640Shselasky		    [
266335640Shselasky			struct netent netent_buf;
267335640Shselasky			char buf[1024];
268335640Shselasky
269335640Shselasky			return getnetbyname_r((const char *)0, &netent_buf, buf, (int)sizeof buf) != NULL;
270335640Shselasky		    ],
271335640Shselasky		    [
272335640Shselasky			AC_MSG_RESULT(yes)
273335640Shselasky			AC_DEFINE(HAVE_SOLARIS_IRIX_GETNETBYNAME_R, 1,
274335640Shselasky			    [define if we have the Solaris/IRIX getnetbyname_r()])
275335640Shselasky		    ],
276335640Shselasky		    [
277335640Shselasky			AC_MSG_RESULT(no)
278335640Shselasky
279335640Shselasky			AC_MSG_CHECKING([for AIX getnetbyname_r()])
280335640Shselasky			AC_TRY_LINK(
281335640Shselasky			    [#include <netdb.h>],
282335640Shselasky			    [
283335640Shselasky				struct netent netent_buf;
284335640Shselasky				struct netent_data net_data;
285335640Shselasky
286335640Shselasky				return getnetbyname_r((const char *)0, &netent_buf, &net_data);
287335640Shselasky			    ],
288335640Shselasky			    [
289335640Shselasky				AC_MSG_RESULT(yes)
290335640Shselasky				AC_DEFINE(HAVE_AIX_GETNETBYNAME_R, 1,
291335640Shselasky				    [define if we have the AIX getnetbyname_r()])
292335640Shselasky			    ],
293335640Shselasky			    [
294335640Shselasky				AC_MSG_RESULT(no)
295335640Shselasky			    ])
296335640Shselasky		    ])
297335640Shselasky	    ])
298335640Shselasky    ],,[#include <netdb.h>])
299335640Shselasky
300335640Shselasky#
301335640Shselasky# Check for reentrant versions of getprotobyname_r(), as provided by
302335640Shselasky# Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!).
303335640Shselasky# If we don't find one, we just use getprotobyname(), which uses
304335640Shselasky# thread-specific data on many platforms, but doesn't use it on
305335640Shselasky# NetBSD or OpenBSD, and may not use it on older versions of other
306335640Shselasky# platforms.
307335640Shselasky#
308335640Shselasky# Only do the check if we have a declaration of getprotobyname_r();
309335640Shselasky# without it, we can't check which API it has.  (We assume that
310335640Shselasky# if there's a declaration, it has a prototype, so that the API
311335640Shselasky# can be checked.)
312335640Shselasky#
313335640ShselaskyAC_CHECK_DECL(getprotobyname_r,
314335640Shselasky    [
315335640Shselasky	AC_MSG_CHECKING([for the Linux getprotobyname_r()])
316335640Shselasky	AC_TRY_LINK(
317335640Shselasky	    [#include <netdb.h>],
318335640Shselasky	    [
319335640Shselasky		struct protoent protoent_buf;
320335640Shselasky		char buf[1024];
321335640Shselasky		struct protoent *resultp;
322335640Shselasky
323335640Shselasky		return getprotobyname_r((const char *)0, &protoent_buf, buf, sizeof buf, &resultp);
324335640Shselasky	    ],
325335640Shselasky	    [
326335640Shselasky		AC_MSG_RESULT(yes)
327335640Shselasky		AC_DEFINE(HAVE_LINUX_GETPROTOBYNAME_R, 1,
328335640Shselasky		    [define if we have the Linux getprotobyname_r()])
329335640Shselasky	    ],
330335640Shselasky	    [
331335640Shselasky		AC_MSG_RESULT(no)
332335640Shselasky
333335640Shselasky		AC_MSG_CHECKING([for Solaris/IRIX getprotobyname_r()])
334335640Shselasky		AC_TRY_LINK(
335335640Shselasky		    [#include <netdb.h>],
336335640Shselasky		    [
337335640Shselasky			struct protoent protoent_buf;
338335640Shselasky			char buf[1024];
339335640Shselasky
340335640Shselasky			return getprotobyname_r((const char *)0, &protoent_buf, buf, (int)sizeof buf) != NULL;
341335640Shselasky		    ],
342335640Shselasky		    [
343335640Shselasky			AC_MSG_RESULT(yes)
344335640Shselasky			AC_DEFINE(HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R, 1,
345335640Shselasky			    [define if we have the Solaris/IRIX getprotobyname_r()])
346335640Shselasky		    ],
347335640Shselasky		    [
348335640Shselasky			AC_MSG_RESULT(no)
349335640Shselasky
350335640Shselasky			AC_MSG_CHECKING([for AIX getprotobyname_r()])
351335640Shselasky			AC_TRY_LINK(
352335640Shselasky			    [#include <netdb.h>],
353335640Shselasky			    [
354335640Shselasky				struct protoent protoent_buf;
355335640Shselasky				struct protoent_data proto_data;
356335640Shselasky
357335640Shselasky				return getprotobyname_r((const char *)0, &protoent_buf, &proto_data);
358335640Shselasky			    ],
359335640Shselasky			    [
360335640Shselasky				AC_MSG_RESULT(yes)
361335640Shselasky				AC_DEFINE(HAVE_AIX_GETPROTOBYNAME_R, 1,
362335640Shselasky				    [define if we have the AIX getprotobyname_r()])
363335640Shselasky			    ],
364335640Shselasky			    [
365335640Shselasky				AC_MSG_RESULT(no)
366335640Shselasky			    ])
367335640Shselasky		    ])
368335640Shselasky	    ])
369335640Shselasky    ],,[#include <netdb.h>])
370335640Shselasky
371335640Shselasky#
372335640Shselasky# You are in a twisty little maze of UN*Xes, all different.
373335640Shselasky# Some might not have ether_hostton().
374335640Shselasky# Some might have it and declare it in <net/ethernet.h>.
375335640Shselasky# Some might have it and declare it in <netinet/ether.h>
376335640Shselasky# Some might have it and declare it in <sys/ethernet.h>.
377335640Shselasky# Some might have it and declare it in <arpa/inet.h>.
378335640Shselasky# Some might have it and declare it in <netinet/if_ether.h>.
379335640Shselasky# Some might have it and not declare it in any header file.
380335640Shselasky#
381335640Shselasky# Before you is a C compiler.
382335640Shselasky#
383335640ShselaskyAC_CHECK_FUNCS(ether_hostton)
384335640Shselaskyif test "$ac_cv_func_ether_hostton" = yes; then
385335640Shselasky	#
386335640Shselasky	# OK, we have ether_hostton().  Is it declared in <net/ethernet.h>?
387335640Shselasky	#
388335640Shselasky	# This test fails if we don't have <net/ethernet.h> or if we do
389335640Shselasky	# but it doesn't declare ether_hostton().
390335640Shselasky	#
391335640Shselasky	AC_CHECK_DECL(ether_hostton,
392335640Shselasky	    [
393335640Shselasky		AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_HOSTTON,,
394335640Shselasky		    [Define to 1 if net/ethernet.h declares `ether_hostton'])
395335640Shselasky	    ],,
396335640Shselasky	    [
397335640Shselasky#include <net/ethernet.h>
398335640Shselasky	    ])
399335640Shselasky	#
400335640Shselasky	# Did that succeed?
401335640Shselasky	#
402335640Shselasky	if test "$ac_cv_have_decl_ether_hostton" != yes; then
403335640Shselasky		#
404335640Shselasky		# No, how about <netinet/ether.h>, as on Linux?
405335640Shselasky		#
406335640Shselasky		# This test fails if we don't have <netinet/ether.h>
407335640Shselasky		# or if we do but it doesn't declare ether_hostton().
408335640Shselasky		#
409335640Shselasky		# Unset ac_cv_have_decl_ether_hostton so we don't
410335640Shselasky		# treat the previous failure as a cached value and
411335640Shselasky		# suppress the next test.
412335640Shselasky		#
413335640Shselasky		unset ac_cv_have_decl_ether_hostton
414335640Shselasky		AC_CHECK_DECL(ether_hostton,
415335640Shselasky		    [
416335640Shselasky			AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON,,
417335640Shselasky			    [Define to 1 if netinet/ether.h declares `ether_hostton'])
418335640Shselasky		    ],,
419335640Shselasky		    [
420335640Shselasky#include <netinet/ether.h>
421335640Shselasky		    ])
422335640Shselasky	fi
423335640Shselasky	#
424335640Shselasky	# Did that succeed?
425335640Shselasky	#
426335640Shselasky	if test "$ac_cv_have_decl_ether_hostton" != yes; then
427335640Shselasky		#
428335640Shselasky		# No, how about <sys/ethernet.h>, as on Solaris 10
429335640Shselasky		# and later?
430335640Shselasky		#
431335640Shselasky		# This test fails if we don't have <sys/ethernet.h>
432335640Shselasky		# or if we do but it doesn't declare ether_hostton().
433335640Shselasky		#
434335640Shselasky		# Unset ac_cv_have_decl_ether_hostton so we don't
435335640Shselasky		# treat the previous failure as a cached value and
436335640Shselasky		# suppress the next test.
437335640Shselasky		#
438335640Shselasky		unset ac_cv_have_decl_ether_hostton
439335640Shselasky		AC_CHECK_DECL(ether_hostton,
440335640Shselasky		    [
441335640Shselasky			AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON,,
442335640Shselasky			    [Define to 1 if sys/ethernet.h declares `ether_hostton'])
443335640Shselasky		    ],,
444335640Shselasky		    [
445335640Shselasky#include <sys/ethernet.h>
446335640Shselasky		    ])
447335640Shselasky	fi
448335640Shselasky	#
449335640Shselasky	# Did that succeed?
450335640Shselasky	#
451335640Shselasky	if test "$ac_cv_have_decl_ether_hostton" != yes; then
452335640Shselasky		#
453335640Shselasky		# No, how about <arpa/inet.h>, as in AIX?
454335640Shselasky		#
455335640Shselasky		# This test fails if we don't have <arpa/inet.h>
456335640Shselasky		# (if we have ether_hostton(), we should have
457335640Shselasky		# networking, and if we have networking, we should
458335640Shselasky		# have <arapa/inet.h>) or if we do but it doesn't
459335640Shselasky		# declare ether_hostton().
460335640Shselasky		#
461335640Shselasky		# Unset ac_cv_have_decl_ether_hostton so we don't
462335640Shselasky		# treat the previous failure as a cached value and
463335640Shselasky		# suppress the next test.
464335640Shselasky		#
465335640Shselasky		unset ac_cv_have_decl_ether_hostton
466335640Shselasky		AC_CHECK_DECL(ether_hostton,
467335640Shselasky		    [
468335640Shselasky			AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_HOSTTON,,
469335640Shselasky			    [Define to 1 if arpa/inet.h declares `ether_hostton'])
470335640Shselasky		    ],,
471335640Shselasky		    [
472335640Shselasky#include <arpa/inet.h>
473335640Shselasky		    ])
474335640Shselasky	fi
475335640Shselasky	#
476335640Shselasky	# Did that succeed?
477335640Shselasky	#
478335640Shselasky	if test "$ac_cv_have_decl_ether_hostton" != yes; then
479335640Shselasky		#
480335640Shselasky		# No, how about <netinet/if_ether.h>?
481335640Shselasky		# On some platforms, it requires <net/if.h> and
482335640Shselasky		# <netinet/in.h>, and we always include it with
483335640Shselasky		# both of them, so test it with both of them.
484335640Shselasky		#
485335640Shselasky		# This test fails if we don't have <netinet/if_ether.h>
486335640Shselasky		# and the headers we include before it, or if we do but
487335640Shselasky		# <netinet/if_ether.h> doesn't declare ether_hostton().
488335640Shselasky		#
489335640Shselasky		# Unset ac_cv_have_decl_ether_hostton so we don't
490335640Shselasky		# treat the previous failure as a cached value and
491335640Shselasky		# suppress the next test.
492335640Shselasky		#
493335640Shselasky		unset ac_cv_have_decl_ether_hostton
494335640Shselasky		AC_CHECK_DECL(ether_hostton,
495335640Shselasky		    [
496335640Shselasky			AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON,,
497335640Shselasky			    [Define to 1 if netinet/if_ether.h declares `ether_hostton'])
498335640Shselasky		    ],,
499335640Shselasky		    [
500335640Shselasky#include <sys/types.h>
501335640Shselasky#include <sys/socket.h>
502335640Shselasky#include <net/if.h>
503335640Shselasky#include <netinet/in.h>
504335640Shselasky#include <netinet/if_ether.h>
505335640Shselasky		    ])
506335640Shselasky	fi
507335640Shselasky	#
508335640Shselasky	# After all that, is ether_hostton() declared?
509335640Shselasky	#
510335640Shselasky	if test "$ac_cv_have_decl_ether_hostton" = yes; then
511335640Shselasky		#
512335640Shselasky		# Yes.
513335640Shselasky		#
514335640Shselasky		AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1,
515335640Shselasky		    [Define to 1 if you have the declaration of `ether_hostton'])
516335640Shselasky        else
517335640Shselasky		#
518335640Shselasky		# No, we'll have to declare it ourselves.
519335640Shselasky		# Do we have "struct ether_addr" if we include
520335640Shselasky		# <netinet/if_ether.h>?
521335640Shselasky		#
522335640Shselasky		AC_CHECK_TYPES(struct ether_addr,,,
523335640Shselasky		    [
524335640Shselasky			#include <sys/types.h>
525335640Shselasky			#include <sys/socket.h>
526335640Shselasky			#include <net/if.h>
527335640Shselasky			#include <netinet/in.h>
528335640Shselasky			#include <netinet/if_ether.h>
529335640Shselasky		    ])
530335640Shselasky	fi
531335640Shselaskyfi
532335640Shselasky
533335640Shselasky#
534335640Shselasky# For various things that might use pthreads.
535335640Shselasky#
536335640ShselaskyAC_CHECK_HEADER(pthread.h,
537335640Shselasky    [
538335640Shselasky	#
539335640Shselasky	# OK, we have pthread.h.  Do we have pthread_create in the
540335640Shselasky	# system libraries?
541335640Shselasky	#
542335640Shselasky	AC_CHECK_FUNC(pthread_create,
543335640Shselasky	    [
544335640Shselasky		#
545335640Shselasky		# Yes.
546335640Shselasky		#
547335640Shselasky		ac_lbl_have_pthreads="found"
548335640Shselasky	    ],
549335640Shselasky	    [
550335640Shselasky		#
551335640Shselasky		# No - do we have it in -lpthreads?
552335640Shselasky		#
553335640Shselasky		AC_CHECK_LIB(pthreads, pthread_create,
554335640Shselasky		    [
555335640Shselasky			#
556335640Shselasky			# Yes - add -lpthreads.
557335640Shselasky			#
558335640Shselasky			ac_lbl_have_pthreads="found"
559335640Shselasky			PTHREAD_LIBS="$PTHREAD_LIBS -lpthreads"
560335640Shselasky		    ],
561335640Shselasky		    [
562335640Shselasky			#
563335640Shselasky			# No - do we have it in -lpthread?
564335640Shselasky			#
565335640Shselasky			AC_CHECK_LIB(pthread, pthread_create,
566335640Shselasky			    [
567335640Shselasky				#
568335640Shselasky				# Yes - add -lpthread.
569335640Shselasky				#
570335640Shselasky                                ac_lbl_have_pthreads="found"
571335640Shselasky				PTHREAD_LIBS="$PTHREAD_LIBS -lpthread"
572335640Shselasky			    ],
573335640Shselasky			    [
574335640Shselasky				#
575335640Shselasky				# No.
576335640Shselasky				#
577335640Shselasky				ac_lbl_have_pthreads="not found"
578335640Shselasky			    ])
579335640Shselasky		    ])
580335640Shselasky	    ])
581335640Shselasky    ],
582335640Shselasky    [
583335640Shselasky	#
584335640Shselasky	# We didn't find pthread.h.
585335640Shselasky	#
586335640Shselasky	ac_lbl_have_pthreads="not found"
587335640Shselasky    ]
588335640Shselasky)
589335640Shselasky
590335640Shselaskydnl to pacify those who hate protochain insn
591335640ShselaskyAC_MSG_CHECKING(if --disable-protochain option is specified)
592335640ShselaskyAC_ARG_ENABLE(protochain,
593335640ShselaskyAC_HELP_STRING([--disable-protochain],[disable \"protochain\" insn]))
594335640Shselaskycase "x$enable_protochain" in
595335640Shselaskyxyes)	enable_protochain=enabled	;;
596335640Shselaskyxno)	enable_protochain=disabled	;;
597335640Shselaskyx)	enable_protochain=enabled	;;
598335640Shselaskyesac
599335640Shselasky
600335640Shselaskyif test "$enable_protochain" = "disabled"; then
601335640Shselasky	AC_DEFINE(NO_PROTOCHAIN,1,[do not use protochain])
602335640Shselaskyfi
603335640ShselaskyAC_MSG_RESULT(${enable_protochain})
604335640Shselasky
605335640Shselasky#
606335640Shselasky# valgrindtest directly uses the native capture mechanism, but
607335640Shselasky# only tests with BPF and PF_PACKET sockets; only enable it if
608335640Shselasky# we have BPF or PF_PACKET sockets.
609335640Shselasky#
610335640ShselaskyVALGRINDTEST_SRC=
611335640Shselasky
612335640Shselasky#
613335640Shselasky# SITA support is mutually exclusive with native capture support;
614335640Shselasky# "--with-sita" selects SITA support.
615335640Shselasky#
616335640ShselaskyAC_ARG_WITH(sita,
617335640ShselaskyAC_HELP_STRING([--with-sita],[include SITA support]),
618335640Shselasky[
619335640Shselasky	if test ! "x$withval" = "xno" ; then
620335640Shselasky		AC_DEFINE(SITA,1,[include ACN support])
621335640Shselasky		AC_MSG_NOTICE(Enabling SITA ACN support)
622335640Shselasky		V_PCAP=sita
623335640Shselasky	fi
624335640Shselasky],
625335640Shselasky[
626335640ShselaskyAC_ARG_WITH(pcap,
627335640ShselaskyAC_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE]))
628335640Shselaskyif test ! -z "$with_pcap" ; then
629335640Shselasky	V_PCAP="$withval"
630335640Shselaskyelse
631335640Shselasky	#
632335640Shselasky	# Check for a bunch of headers for various packet
633335640Shselasky	# capture mechanisms.
634335640Shselasky	#
635335640Shselasky	AC_CHECK_HEADERS(net/bpf.h)
636335640Shselasky	if test "$ac_cv_header_net_bpf_h" = yes; then
637335640Shselasky		#
638335640Shselasky		# Does it define BIOCSETIF?
639335640Shselasky		# I.e., is it a header for an LBL/BSD-style capture
640335640Shselasky		# mechanism, or is it just a header for a BPF filter
641335640Shselasky		# engine?  Some versions of Arch Linux, for example,
642335640Shselasky		# have a net/bpf.h that doesn't define BIOCSETIF;
643335640Shselasky		# as it's a Linux, it should use packet sockets,
644335640Shselasky		# instead.
645335640Shselasky		#
646335640Shselasky		# We need:
647335640Shselasky		#
648335640Shselasky		#  sys/types.h, because FreeBSD 10's net/bpf.h
649335640Shselasky		#  requires that various BSD-style integer types
650335640Shselasky		#  be defined;
651335640Shselasky		#
652356341Scy		#  sys/time.h, because AIX 5.2 and 5.3's net/bpf.h
653356341Scy		#  doesn't include it but does use struct timeval
654356341Scy		#  in ioctl definitions;
655356341Scy		#
656335640Shselasky		#  sys/ioctl.h and, if we have it, sys/ioccom.h,
657335640Shselasky		#  because net/bpf.h defines ioctls;
658335640Shselasky		#
659335640Shselasky		#  net/if.h, because it defines some structures
660335640Shselasky		#  used in ioctls defined by net/bpf.h;
661335640Shselasky		#
662335640Shselasky		#  sys/socket.h, because OpenBSD 5.9's net/bpf.h
663335640Shselasky		#  defines some structure fields as being
664335640Shselasky		#  struct sockaddrs;
665335640Shselasky		#
666335640Shselasky		# and net/bpf.h doesn't necessarily include all
667335640Shselasky		# of those headers itself.
668335640Shselasky		#
669335640Shselasky		AC_MSG_CHECKING(if net/bpf.h defines BIOCSETIF)
670335640Shselasky		AC_CACHE_VAL(ac_cv_lbl_bpf_h_defines_biocsetif,
671335640Shselasky			AC_TRY_COMPILE(
672335640Shselasky[
673335640Shselasky#include <sys/types.h>
674356341Scy#include <sys/time.h>
675335640Shselasky#include <sys/ioctl.h>
676335640Shselasky#include <sys/socket.h>
677335640Shselasky#ifdef HAVE_SYS_IOCCOM_H
678335640Shselasky#include <sys/ioccom.h>
679335640Shselasky#endif
680335640Shselasky#include <net/bpf.h>
681335640Shselasky#include <net/if.h>
682335640Shselasky],
683335640Shselasky			[u_int i = BIOCSETIF;],
684335640Shselasky			ac_cv_lbl_bpf_h_defines_biocsetif=yes,
685335640Shselasky			ac_cv_lbl_bpf_h_defines_biocsetif=no))
686335640Shselasky		AC_MSG_RESULT($ac_cv_lbl_bpf_h_defines_biocsetif)
687335640Shselasky	fi
688335640Shselasky	AC_CHECK_HEADERS(net/pfilt.h net/enet.h)
689335640Shselasky	AC_CHECK_HEADERS(net/nit.h sys/net/nit.h)
690335640Shselasky	AC_CHECK_HEADERS(linux/socket.h net/raw.h sys/dlpi.h)
691335640Shselasky
692335640Shselasky	if test "$ac_cv_lbl_bpf_h_defines_biocsetif" = yes; then
693335640Shselasky		#
694335640Shselasky		# BPF.
695335640Shselasky		# Check this before DLPI, so that we pick BPF on
696335640Shselasky		# Solaris 11 and later.
697335640Shselasky		#
698335640Shselasky		V_PCAP=bpf
699335640Shselasky
700335640Shselasky		#
701335640Shselasky		# We have BPF, so build valgrindtest with "make test"
702335640Shselasky		# on macOS and FreeBSD (add your OS once there's a
703335640Shselasky		# valgrind for it).
704335640Shselasky		#
705335640Shselasky		case "$host_os" in
706335640Shselasky
707335640Shselasky		freebsd*|darwin*|linux*)
708335640Shselasky			VALGRINDTEST_SRC=valgrindtest.c
709335640Shselasky			;;
710335640Shselasky		esac
711335640Shselasky	elif test "$ac_cv_header_linux_socket_h" = yes; then
712335640Shselasky		#
713335640Shselasky		# No prizes for guessing this one.
714335640Shselasky		#
715335640Shselasky		V_PCAP=linux
716335640Shselasky
717335640Shselasky		#
718335640Shselasky		# XXX - this won't work with older kernels that have
719335640Shselasky		# SOCK_PACKET sockets but not PF_PACKET sockets.
720335640Shselasky		#
721335640Shselasky		VALGRINDTEST_SRC=valgrindtest.c
722335640Shselasky	elif test "$ac_cv_header_net_pfilt_h" = yes; then
723335640Shselasky	        #
724335640Shselasky	        # DEC OSF/1, Digital UNIX, Tru64 UNIX
725335640Shselasky        	#
726335640Shselasky		V_PCAP=pf
727335640Shselasky	elif test "$ac_cv_header_net_enet_h" = yes; then
728335640Shselasky		#
729335640Shselasky		# Stanford Enetfilter.
730335640Shselasky		#
731335640Shselasky		V_PCAP=enet
732335640Shselasky	elif test "$ac_cv_header_net_nit_h" = yes; then
733335640Shselasky		#
734335640Shselasky		# SunOS 4.x STREAMS NIT.
735335640Shselasky		#
736335640Shselasky		V_PCAP=snit
737335640Shselasky	elif test "$ac_cv_header_sys_net_nit_h" = yes; then
738335640Shselasky		#
739335640Shselasky		# Pre-SunOS 4.x non-STREAMS NIT.
740335640Shselasky		#
741335640Shselasky		V_PCAP=nit
742335640Shselasky	elif test "$ac_cv_header_net_raw_h" = yes; then
743335640Shselasky		#
744335640Shselasky		# IRIX snoop.
745335640Shselasky		#
746335640Shselasky		V_PCAP=snoop
747335640Shselasky	elif test "$ac_cv_header_sys_dlpi_h" = yes; then
748335640Shselasky		#
749335640Shselasky		# DLPI on pre-Solaris 11 SunOS 5, HP-UX, possibly others.
750335640Shselasky		#
751335640Shselasky		V_PCAP=dlpi
752335640Shselasky	else
753335640Shselasky		#
754335640Shselasky		# Nothing we support.
755335640Shselasky		#
756335640Shselasky		V_PCAP=null
757335640Shselasky		AC_MSG_WARN(cannot determine packet capture interface)
758335640Shselasky		AC_MSG_WARN((see the INSTALL doc for more info))
759335640Shselasky	fi
760335640Shselaskyfi
761335640ShselaskyAC_MSG_CHECKING(packet capture type)
762335640ShselaskyAC_MSG_RESULT($V_PCAP)
763335640ShselaskyAC_SUBST(VALGRINDTEST_SRC)
764335640Shselasky
765335640Shselasky#
766335640Shselasky# Do capture-mechanism-dependent tests.
767335640Shselasky#
768335640Shselaskycase "$V_PCAP" in
769335640Shselaskydlpi)
770335640Shselasky	#
771335640Shselasky	# Needed for common functions used by pcap-[dlpi,libdlpi].c
772335640Shselasky	#
773335640Shselasky 	SSRC="dlpisubs.c"
774335640Shselasky
775335640Shselasky	#
776335640Shselasky	# Checks for some header files.
777335640Shselasky	#
778335640Shselasky	AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
779335640Shselasky
780335640Shselasky	#
781335640Shselasky	# Checks to see if Solaris has the public libdlpi(3LIB) library.
782335640Shselasky	# Note: The existence of /usr/include/libdlpi.h does not mean it is the
783335640Shselasky	# public libdlpi(3LIB) version. Before libdlpi was made public, a
784335640Shselasky	# private version also existed, which did not have the same APIs.
785335640Shselasky	# Due to a gcc bug, the default search path for 32-bit libraries does
786335640Shselasky	# not include /lib, we add it explicitly here.
787335640Shselasky	# [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485].
788335640Shselasky	# Also, due to the bug above applications that link to libpcap with
789335640Shselasky	# libdlpi will have to add "-L/lib" option to "configure".
790335640Shselasky	#
791335640Shselasky	saved_ldflags=$LDFLAGS
792335640Shselasky	LDFLAGS="$LIBS -L/lib"
793335640Shselasky	AC_CHECK_LIB(dlpi, dlpi_walk,
794335640Shselasky		[
795335640Shselasky			LIBS="-ldlpi $LIBS"
796335640Shselasky			V_PCAP=libdlpi
797335640Shselasky			AC_DEFINE(HAVE_LIBDLPI,1,[if libdlpi exists])
798335640Shselasky		],
799335640Shselasky		V_PCAP=dlpi)
800335640Shselasky	LDFLAGS=$saved_ldflags
801335640Shselasky
802335640Shselasky	#
803335640Shselasky	# Checks whether <sys/dlpi.h> is usable, to catch weird SCO
804335640Shselasky	# versions of DLPI.
805335640Shselasky	#
806335640Shselasky	AC_MSG_CHECKING(whether <sys/dlpi.h> is usable)
807335640Shselasky	AC_CACHE_VAL(ac_cv_sys_dlpi_usable,
808335640Shselasky		AC_TRY_COMPILE(
809335640Shselasky		    [
810335640Shselasky			#include <sys/types.h>
811335640Shselasky			#include <sys/time.h>
812335640Shselasky			#include <sys/dlpi.h>
813335640Shselasky		    ],
814335640Shselasky		    [int i = DL_PROMISC_PHYS;],
815335640Shselasky		    ac_cv_sys_dlpi_usable=yes,
816335640Shselasky		    ac_cv_sys_dlpi_usable=no))
817335640Shselasky	AC_MSG_RESULT($ac_cv_sys_dlpi_usable)
818335640Shselasky	if test $ac_cv_sys_dlpi_usable = no ; then
819335640Shselasky		AC_MSG_ERROR(<sys/dlpi.h> is not usable on this system; it probably has a non-standard DLPI)
820335640Shselasky	fi
821335640Shselasky
822335640Shselasky	#
823335640Shselasky	# Check to see if Solaris has the dl_passive_req_t struct defined
824335640Shselasky	# in <sys/dlpi.h>.
825335640Shselasky	# This check is for DLPI support for passive modes.
826335640Shselasky	# See dlpi(7P) for more details.
827335640Shselasky	#
828335640Shselasky	AC_CHECK_TYPES(dl_passive_req_t,,,
829335640Shselasky	    [
830335640Shselasky		#include <sys/types.h>
831335640Shselasky		#include <sys/dlpi.h>
832335640Shselasky	    ])
833335640Shselasky	;;
834335640Shselasky
835335640Shselaskylinux)
836335640Shselasky	#
837335640Shselasky	# Do we have the wireless extensions?
838335640Shselasky	#
839335640Shselasky	AC_CHECK_HEADERS(linux/wireless.h, [], [],
840335640Shselasky	[
841335640Shselasky#include <sys/socket.h>
842335640Shselasky#include <linux/if.h>
843335640Shselasky#include <linux/types.h>
844335640Shselasky	])
845335640Shselasky
846335640Shselasky	#
847335640Shselasky	# Do we have libnl?
848335640Shselasky	#
849335640Shselasky	AC_ARG_WITH(libnl,
850335640Shselasky	AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]),
851335640Shselasky		with_libnl=$withval,with_libnl=if_available)
852335640Shselasky
853335640Shselasky	if test x$with_libnl != xno ; then
854335640Shselasky		have_any_nl="no"
855335640Shselasky
856335640Shselasky                incdir=-I/usr/include/libnl3
857335640Shselasky                libnldir=
858335640Shselasky                case "$with_libnl" in
859335640Shselasky
860335640Shselasky                yes|if_available)
861335640Shselasky                  ;;
862335640Shselasky
863335640Shselasky                *)
864335640Shselasky                  if test -d $withval; then
865335640Shselasky                    libnldir=-L${withval}/lib/.libs
866335640Shselasky                    incdir=-I${withval}/include
867335640Shselasky                  fi
868335640Shselasky                  ;;
869335640Shselasky                esac
870335640Shselasky
871335640Shselasky		#
872335640Shselasky		# Try libnl 3.x first.
873335640Shselasky		#
874335640Shselasky		AC_CHECK_LIB(nl-3, nl_socket_alloc,
875335640Shselasky		[
876335640Shselasky			#
877335640Shselasky			# Yes, we have libnl 3.x.
878335640Shselasky			#
879335640Shselasky			LIBS="${libnldir} -lnl-genl-3 -lnl-3 $LIBS"
880335640Shselasky			AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
881335640Shselasky			AC_DEFINE(HAVE_LIBNL_3_x,1,[if libnl exists and is version 3.x])
882335640Shselasky			AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
883335640Shselasky			AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
884335640Shselasky			V_INCLS="$V_INCLS ${incdir}"
885335640Shselasky			have_any_nl="yes"
886335640Shselasky		],[], ${incdir} ${libnldir} -lnl-genl-3 -lnl-3 )
887335640Shselasky
888335640Shselasky		if test x$have_any_nl = xno ; then
889335640Shselasky			#
890335640Shselasky			# Try libnl 2.x
891335640Shselasky			#
892335640Shselasky			AC_CHECK_LIB(nl, nl_socket_alloc,
893335640Shselasky			[
894335640Shselasky				#
895335640Shselasky				# Yes, we have libnl 2.x.
896335640Shselasky				#
897335640Shselasky				LIBS="${libnldir} -lnl-genl -lnl $LIBS"
898335640Shselasky				AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
899335640Shselasky				AC_DEFINE(HAVE_LIBNL_2_x,1,[if libnl exists and is version 2.x])
900335640Shselasky				AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
901335640Shselasky				AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
902335640Shselasky				have_any_nl="yes"
903335640Shselasky			])
904335640Shselasky		fi
905335640Shselasky
906335640Shselasky		if test x$have_any_nl = xno ; then
907335640Shselasky			#
908335640Shselasky			# No, we don't; do we have libnl 1.x?
909335640Shselasky			#
910335640Shselasky			AC_CHECK_LIB(nl, nl_handle_alloc,
911335640Shselasky			[
912335640Shselasky				#
913335640Shselasky				# Yes.
914335640Shselasky				#
915335640Shselasky				LIBS="${libnldir} -lnl $LIBS"
916335640Shselasky				AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
917335640Shselasky				have_any_nl="yes"
918335640Shselasky			])
919335640Shselasky		fi
920335640Shselasky
921335640Shselasky		if test x$have_any_nl = xno ; then
922335640Shselasky			#
923335640Shselasky			# No, we don't have libnl at all.
924335640Shselasky			#
925335640Shselasky			if test x$with_libnl = xyes ; then
926335640Shselasky				AC_MSG_ERROR([libnl support requested but libnl not found])
927335640Shselasky			fi
928335640Shselasky		fi
929335640Shselasky	fi
930335640Shselasky
931335640Shselasky	AC_CHECK_HEADERS(linux/ethtool.h,,,
932335640Shselasky	    [
933335640ShselaskyAC_INCLUDES_DEFAULT
934335640Shselasky#include <linux/types.h>
935335640Shselasky	    ])
936335640Shselasky
937335640Shselasky	#
938335640Shselasky	# Check to see if struct tpacket_stats is defined in
939335640Shselasky	# <linux/if_packet.h>.  If so, then pcap-linux.c can use this
940335640Shselasky	# to report proper statistics.
941335640Shselasky	#
942335640Shselasky	# -Scott Barron
943335640Shselasky	#
944335640Shselasky	AC_CHECK_TYPES(struct tpacket_stats,,,
945335640Shselasky	    [
946335640Shselasky		#include <linux/if_packet.h>
947335640Shselasky	    ])
948335640Shselasky
949335640Shselasky	#
950335640Shselasky	# Check to see if the tpacket_auxdata struct has a tp_vlan_tci member.
951335640Shselasky	#
952335640Shselasky	# NOTE: any failure means we conclude that it doesn't have that
953335640Shselasky	# member, so if we don't have tpacket_auxdata, we conclude it
954335640Shselasky	# doesn't have that member (which is OK, as either we won't be
955335640Shselasky	# using code that would use that member, or we wouldn't compile
956335640Shselasky	# in any case).
957335640Shselasky	AC_CHECK_MEMBERS([struct tpacket_auxdata.tp_vlan_tci],,,
958335640Shselasky	    [
959335640Shselasky		#include <sys/types.h>
960335640Shselasky		#include <linux/if_packet.h>
961335640Shselasky	    ])
962335640Shselasky	;;
963335640Shselasky
964335640Shselaskybpf)
965335640Shselasky	#
966335640Shselasky	# Check whether we have the *BSD-style ioctls.
967335640Shselasky	#
968335640Shselasky	AC_CHECK_HEADERS(net/if_media.h)
969335640Shselasky
970335640Shselasky	#
971335640Shselasky	# Check whether we have struct BPF_TIMEVAL.
972335640Shselasky	#
973335640Shselasky	AC_CHECK_TYPES(struct BPF_TIMEVAL,,,
974335640Shselasky	    [
975335640Shselasky		#include <sys/types.h>
976335640Shselasky		#include <sys/ioctl.h>
977335640Shselasky		#ifdef HAVE_SYS_IOCCOM_H
978335640Shselasky		#include <sys/ioccom.h>
979335640Shselasky		#endif
980335640Shselasky		#include <net/bpf.h>
981335640Shselasky	    ])
982335640Shselasky	;;
983335640Shselasky
984335640Shselaskydag)
985335640Shselasky	#
986335640Shselasky	# --with-pcap=dag is the only way to get here, and it means
987335640Shselasky	# "DAG support but nothing else"
988335640Shselasky	#
989335640Shselasky	V_DEFS="$V_DEFS -DDAG_ONLY"
990335640Shselasky	xxx_only=yes
991335640Shselasky	;;
992335640Shselasky
993335640Shselaskyseptel)
994335640Shselasky	#
995335640Shselasky	# --with-pcap=septel is the only way to get here, and it means
996335640Shselasky	# "Septel support but nothing else"
997335640Shselasky	#
998335640Shselasky	V_DEFS="$V_DEFS -DSEPTEL_ONLY"
999335640Shselasky	xxx_only=yes
1000335640Shselasky	;;
1001335640Shselasky
1002335640Shselaskysnf)
1003335640Shselasky	#
1004335640Shselasky	# --with-pcap=snf is the only way to get here, and it means
1005335640Shselasky	# "SNF support but nothing else"
1006335640Shselasky	#
1007335640Shselasky	V_DEFS="$V_DEFS -DSNF_ONLY"
1008335640Shselasky	xxx_only=yes
1009335640Shselasky	;;
1010335640Shselasky
1011335640Shselaskynull)
1012335640Shselasky	;;
1013335640Shselasky
1014335640Shselasky*)
1015335640Shselasky	AC_MSG_ERROR($V_PCAP is not a valid pcap type)
1016335640Shselasky	;;
1017335640Shselaskyesac
1018335640Shselasky
1019335640Shselaskydnl
1020335640Shselaskydnl Now figure out how we get a list of interfaces and addresses,
1021335640Shselaskydnl if we support capturing.  Don't bother if we don't support
1022335640Shselaskydnl capturing.
1023335640Shselaskydnl
1024335640Shselaskyif test "$V_PCAP" != null
1025335640Shselaskythen
1026335640Shselasky	AC_CHECK_FUNC(getifaddrs,[
1027335640Shselasky		#
1028335640Shselasky		# We have "getifaddrs()"; make sure we have <ifaddrs.h>
1029335640Shselasky		# as well, just in case some platform is really weird.
1030335640Shselasky		#
1031335640Shselasky		AC_CHECK_HEADER(ifaddrs.h,[
1032335640Shselasky		    #
1033335640Shselasky		    # We have the header, so we use "getifaddrs()" to
1034335640Shselasky		    # get the list of interfaces.
1035335640Shselasky		    #
1036335640Shselasky		    V_FINDALLDEVS=fad-getad.c
1037335640Shselasky		],[
1038335640Shselasky		    #
1039335640Shselasky		    # We don't have the header - give up.
1040335640Shselasky		    # XXX - we could also fall back on some other
1041335640Shselasky		    # mechanism, but, for now, this'll catch this
1042335640Shselasky		    # problem so that we can at least try to figure
1043335640Shselasky		    # out something to do on systems with "getifaddrs()"
1044335640Shselasky		    # but without "ifaddrs.h", if there is something
1045335640Shselasky		    # we can do on those systems.
1046335640Shselasky		    #
1047335640Shselasky		    AC_MSG_ERROR([Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>.])
1048335640Shselasky		])
1049335640Shselasky	],[
1050335640Shselasky		#
1051335640Shselasky		# Well, we don't have "getifaddrs()", at least not with the
1052335640Shselasky		# libraries with which we've decided we need to link
1053335640Shselasky		# libpcap with, so we have to use some other mechanism.
1054335640Shselasky		#
1055335640Shselasky		# Note that this may happen on Solaris, which has
1056335640Shselasky		# getifaddrs(), but in -lsocket, not in -lxnet, so we
1057335640Shselasky		# won't find it if we link with -lxnet, which we want
1058335640Shselasky		# to do for other reasons.
1059335640Shselasky		#
1060335640Shselasky		# For now, we use either the SIOCGIFCONF ioctl or the
1061335640Shselasky		# SIOCGLIFCONF ioctl, preferring the latter if we have
1062335640Shselasky		# it; the latter is a Solarisism that first appeared
1063335640Shselasky		# in Solaris 8.  (Solaris's getifaddrs() appears to
1064335640Shselasky		# be built atop SIOCGLIFCONF; using it directly
1065335640Shselasky		# avoids a not-all-that-useful middleman.)
1066335640Shselasky		#
1067335640Shselasky		AC_MSG_CHECKING(whether we have SIOCGLIFCONF)
1068335640Shselasky		AC_CACHE_VAL(ac_cv_lbl_have_siocglifconf,
1069335640Shselasky		    AC_TRY_COMPILE(
1070335640Shselasky			[#include <sys/param.h>
1071335640Shselasky			#include <sys/file.h>
1072335640Shselasky			#include <sys/ioctl.h>
1073335640Shselasky			#include <sys/socket.h>
1074335640Shselasky			#include <sys/sockio.h>],
1075335640Shselasky			[ioctl(0, SIOCGLIFCONF, (char *)0);],
1076335640Shselasky			ac_cv_lbl_have_siocglifconf=yes,
1077335640Shselasky			ac_cv_lbl_have_siocglifconf=no))
1078335640Shselasky		AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
1079335640Shselasky		if test $ac_cv_lbl_have_siocglifconf = yes ; then
1080335640Shselasky			V_FINDALLDEVS=fad-glifc.c
1081335640Shselasky		else
1082335640Shselasky			V_FINDALLDEVS=fad-gifc.c
1083335640Shselasky		fi
1084335640Shselasky	])
1085335640Shselaskyfi
1086335640Shselasky])
1087335640Shselasky
1088335640Shselaskydnl check for hardware timestamp support
1089335640Shselaskycase "$host_os" in
1090335640Shselaskylinux*)
1091335640Shselasky	AC_CHECK_HEADERS([linux/net_tstamp.h])
1092335640Shselasky	;;
1093335640Shselasky*)
1094335640Shselasky	AC_MSG_NOTICE(no hardware timestamp support implemented for $host_os)
1095335640Shselasky	;;
1096335640Shselaskyesac
1097335640Shselasky
1098335640ShselaskyAC_ARG_ENABLE([packet-ring],
1099335640Shselasky[AC_HELP_STRING([--enable-packet-ring],[enable packet ring support on Linux @<:@default=yes@:>@])],
1100335640Shselasky,enable_packet_ring=yes)
1101335640Shselasky
1102335640Shselaskyif test "x$enable_packet_ring" != "xno" ; then
1103335640Shselasky	AC_DEFINE(PCAP_SUPPORT_PACKET_RING, 1, [use packet ring capture support on Linux if available])
1104335640Shselasky	AC_SUBST(PCAP_SUPPORT_PACKET_RING)
1105335640Shselaskyfi
1106335640Shselasky
1107335640Shselasky#
1108335640Shselasky# Check for socklen_t.
1109335640Shselasky#
1110335640ShselaskyAC_CHECK_TYPES(socklen_t,,,
1111335640Shselasky    [
1112335640Shselasky	#include <sys/types.h>
1113335640Shselasky	#include <sys/socket.h>
1114335640Shselasky    ])
1115335640Shselasky
1116335640ShselaskyAC_ARG_ENABLE(ipv6,
1117335640ShselaskyAC_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes@:>@]),
1118335640Shselasky    [],
1119335640Shselasky    [enable_ipv6=yes])
1120335640Shselaskyif test "$enable_ipv6" != "no"; then
1121335640Shselasky	#
1122335640Shselasky	# We've already made sure we have getaddrinfo above in
1123335640Shselasky	# AC_LBL_LIBRARY_NET.
1124335640Shselasky	#
1125335640Shselasky	AC_DEFINE(INET6,1,[IPv6])
1126335640Shselaskyfi
1127335640Shselasky
1128335640Shselasky# Check for Endace DAG card support.
1129335640ShselaskyAC_ARG_WITH([dag],
1130335640ShselaskyAC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support (located in directory DIR, if supplied).  @<:@default=yes, if present@:>@]),
1131335640Shselasky[
1132335640Shselasky	if test "$withval" = no
1133335640Shselasky	then
1134335640Shselasky		# User doesn't want DAG support.
1135335640Shselasky		want_dag=no
1136335640Shselasky	elif test "$withval" = yes
1137335640Shselasky	then
1138335640Shselasky		# User wants DAG support but hasn't specified a directory.
1139335640Shselasky		want_dag=yes
1140335640Shselasky	else
1141335640Shselasky		# User wants DAG support and has specified a directory, so use the provided value.
1142335640Shselasky		want_dag=yes
1143335640Shselasky		dag_root=$withval
1144335640Shselasky	fi
1145335640Shselasky],[
1146335640Shselasky	if test "$V_PCAP" = dag; then
1147335640Shselasky		# User requested DAG-only libpcap, so we'd better have
1148335640Shselasky		# the DAG API.
1149335640Shselasky		want_dag=yes
1150335640Shselasky	elif test "xxx_only" = yes; then
1151335640Shselasky		# User requested something-else-only pcap, so they don't
1152335640Shselasky		# want DAG support.
1153335640Shselasky		want_dag=no
1154335640Shselasky	else
1155335640Shselasky		#
1156335640Shselasky		# Use DAG API if present, otherwise don't
1157335640Shselasky		#
1158335640Shselasky		want_dag=ifpresent
1159335640Shselasky	fi
1160335640Shselasky])
1161335640Shselasky
1162335640ShselaskyAC_ARG_WITH([dag-includes],
1163335640ShselaskyAC_HELP_STRING([--with-dag-includes=IDIR],[Endace DAG include directory, if not DIR/include]),
1164335640Shselasky[
1165335640Shselasky	# User wants DAG support and has specified a header directory, so use the provided value.
1166335640Shselasky	want_dag=yes
1167335640Shselasky	dag_include_dir=$withval
1168335640Shselasky],[])
1169335640Shselasky
1170335640ShselaskyAC_ARG_WITH([dag-libraries],
1171335640ShselaskyAC_HELP_STRING([--with-dag-libraries=LDIR],[Endace DAG library directory, if not DIR/lib]),
1172335640Shselasky[
1173335640Shselasky	# User wants DAG support and has specified a library directory, so use the provided value.
1174335640Shselasky	want_dag=yes
1175335640Shselasky	dag_lib_dir=$withval
1176335640Shselasky],[])
1177335640Shselasky
1178335640Shselaskyif test "$want_dag" != no; then
1179335640Shselasky
1180335640Shselasky	# If necessary, set default paths for DAG API headers and libraries.
1181335640Shselasky	if test -z "$dag_root"; then
1182335640Shselasky		dag_root=/usr/local
1183335640Shselasky	fi
1184335640Shselasky
1185335640Shselasky	if test -z "$dag_include_dir"; then
1186335640Shselasky		dag_include_dir="$dag_root/include"
1187335640Shselasky	fi
1188335640Shselasky
1189335640Shselasky	if test -z "$dag_lib_dir"; then
1190335640Shselasky		dag_lib_dir="$dag_root/lib"
1191335640Shselasky	fi
1192335640Shselasky
1193335640Shselasky	V_INCLS="$V_INCLS -I$dag_include_dir"
1194335640Shselasky
1195335640Shselasky	AC_CHECK_HEADERS([dagapi.h])
1196335640Shselasky
1197335640Shselasky	if test "$ac_cv_header_dagapi_h" = yes; then
1198335640Shselasky
1199335640Shselasky		if test $V_PCAP != dag ; then
1200335640Shselasky			 SSRC="$SSRC pcap-dag.c"
1201335640Shselasky		fi
1202335640Shselasky
1203335640Shselasky		# Check for various DAG API functions.
1204335640Shselasky		# Don't need to save and restore LIBS to prevent -ldag being
1205335640Shselasky		# included if there's a found-action (arg 3).
1206335640Shselasky		saved_ldflags=$LDFLAGS
1207335640Shselasky		LDFLAGS="-L$dag_lib_dir"
1208335640Shselasky		AC_CHECK_LIB([dag], [dag_attach_stream],
1209335640Shselasky		    [],
1210335640Shselasky		    [AC_MSG_ERROR(DAG library lacks streams support)])
1211335640Shselasky		AC_CHECK_LIB([dag], [dag_attach_stream64], [dag_large_streams="1"], [dag_large_streams="0"])
1212335640Shselasky		AC_CHECK_LIB([dag],[dag_get_erf_types], [
1213335640Shselasky			AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])])
1214335640Shselasky		AC_CHECK_LIB([dag],[dag_get_stream_erf_types], [
1215335640Shselasky			AC_DEFINE(HAVE_DAG_GET_STREAM_ERF_TYPES, 1, [define if you have dag_get_stream_erf_types()])])
1216335640Shselasky
1217335640Shselasky		LDFLAGS=$saved_ldflags
1218335640Shselasky
1219335640Shselasky		#
1220335640Shselasky		# We assume that if we have libdag we have libdagconf,
1221335640Shselasky		# as they're installed at the same time from the same
1222335640Shselasky		# package.
1223335640Shselasky		#
1224335640Shselasky		LIBS="$LIBS -ldag -ldagconf"
1225335640Shselasky		LDFLAGS="$LDFLAGS -L$dag_lib_dir"
1226335640Shselasky
1227335640Shselasky		if test "$dag_large_streams" = 1; then
1228335640Shselasky			AC_DEFINE(HAVE_DAG_LARGE_STREAMS_API, 1, [define if you have large streams capable DAG API])
1229335640Shselasky			AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"])
1230335640Shselasky			if test "$ac_dag_have_vdag" = 1; then
1231335640Shselasky				AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()])
1232335640Shselasky				if test "$ac_lbl_have_pthreads" != "found"; then
1233335640Shselasky					AC_MSG_ERROR([DAG requires pthreads, but we didn't find them])
1234335640Shselasky				fi
1235335640Shselasky				LIBS="$LIBS $PTHREAD_LIBS"
1236335640Shselasky			fi
1237335640Shselasky		fi
1238335640Shselasky
1239335640Shselasky		AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
1240335640Shselasky	else
1241335640Shselasky
1242335640Shselasky		if test "$V_PCAP" = dag; then
1243335640Shselasky			# User requested "dag" capture type but we couldn't
1244335640Shselasky			# find the DAG API support.
1245335640Shselasky			AC_MSG_ERROR([DAG support requested with --with-pcap=dag, but the DAG headers weren't found at $dag_include_dir: make sure the DAG support is installed, specify a different path or paths if necessary, or don't request DAG support])
1246335640Shselasky		fi
1247335640Shselasky
1248335640Shselasky		if test "$want_dag" = yes; then
1249335640Shselasky	        	# User wanted DAG support but we couldn't find it.
1250335640Shselasky			AC_MSG_ERROR([DAG support requested with --with-dag, but the DAG headers weren't found at $dag_include_dir: make sure the DAG support is installed, specify a different path or paths if necessary, or don't request DAG support])
1251335640Shselasky		fi
1252335640Shselasky	fi
1253335640Shselaskyfi
1254335640Shselasky
1255335640ShselaskyAC_ARG_WITH(septel,
1256335640ShselaskyAC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied).  @<:@default=yes, if present@:>@]),
1257335640Shselasky[
1258335640Shselasky	if test "$withval" = no
1259335640Shselasky	then
1260335640Shselasky		want_septel=no
1261335640Shselasky	elif test "$withval" = yes
1262335640Shselasky	then
1263335640Shselasky		want_septel=yes
1264335640Shselasky		septel_root=
1265335640Shselasky	else
1266335640Shselasky		want_septel=yes
1267335640Shselasky		septel_root=$withval
1268335640Shselasky	fi
1269335640Shselasky],[
1270335640Shselasky	if test "$V_PCAP" = septel; then
1271335640Shselasky		# User requested Septel-only libpcap, so we'd better have
1272335640Shselasky		# the Septel API.
1273335640Shselasky		want_septel=yes
1274335640Shselasky	elif test "xxx_only" = yes; then
1275335640Shselasky		# User requested something-else-only pcap, so they don't
1276335640Shselasky		# want Septel support.
1277335640Shselasky		want_septel=no
1278335640Shselasky	else
1279335640Shselasky		#
1280335640Shselasky		# Use Septel API if present, otherwise don't
1281335640Shselasky		#
1282335640Shselasky		want_septel=ifpresent
1283335640Shselasky	fi
1284335640Shselasky])
1285335640Shselasky
1286335640Shselaskyac_cv_lbl_septel_api=no
1287335640Shselaskyif test "$with_septel" != no; then
1288335640Shselasky
1289335640Shselasky	AC_MSG_CHECKING([whether we have Septel API headers])
1290335640Shselasky
1291335640Shselasky	# If necessary, set default paths for Septel API headers and libraries.
1292335640Shselasky	if test -z "$septel_root"; then
1293335640Shselasky		septel_root=$srcdir/../septel
1294335640Shselasky	fi
1295335640Shselasky
1296335640Shselasky	septel_tools_dir="$septel_root"
1297335640Shselasky	septel_include_dir="$septel_root/INC"
1298335640Shselasky
1299335640Shselasky	if test -r "$septel_include_dir/msg.h"; then
1300335640Shselasky		ac_cv_lbl_septel_api=yes
1301335640Shselasky	fi
1302335640Shselasky
1303335640Shselasky	if test "$ac_cv_lbl_septel_api" = yes; then
1304335640Shselasky		AC_MSG_RESULT([yes ($septel_include_dir)])
1305335640Shselasky
1306335640Shselasky		V_INCLS="$V_INCLS -I$septel_include_dir"
1307335640Shselasky		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"
1308335640Shselasky		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"
1309335640Shselasky
1310335640Shselasky		if test "$V_PCAP" != septel ; then
1311335640Shselasky			 SSRC="$SSRC pcap-septel.c"
1312335640Shselasky		fi
1313335640Shselasky
1314335640Shselasky		AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have the Septel API])
1315335640Shselasky	else
1316335640Shselasky		AC_MSG_RESULT(no)
1317335640Shselasky
1318335640Shselasky		if test "$V_PCAP" = septel; then
1319335640Shselasky			# User requested "septel" capture type but
1320335640Shselasky			# we couldn't find the Septel API support.
1321335640Shselasky			AC_MSG_ERROR([Septel support requested with --with-pcap=septel, but the Septel headers weren't found at $septel_include_dir: make sure the Septel support is installed, specify a different path or paths if necessary, or don't request Septel support])
1322335640Shselasky		fi
1323335640Shselasky
1324335640Shselasky		if test "$want_septel" = yes; then
1325335640Shselasky	        	# User wanted Septel support but we couldn't find it.
1326335640Shselasky			AC_MSG_ERROR([Septel support requested with --with-septel, but the Septel headers weren't found at $septel_include_dir: make sure the Septel support is installed, specify a different path or paths if necessary, or don't request Septel support])
1327335640Shselasky		fi
1328335640Shselasky	fi
1329335640Shselaskyfi
1330335640Shselasky
1331335640Shselasky# Check for Myricom SNF support.
1332335640ShselaskyAC_ARG_WITH([snf],
1333335640ShselaskyAC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in directory DIR, if supplied).  @<:@default=yes, if present@:>@]),
1334335640Shselasky[
1335335640Shselasky	if test "$withval" = no
1336335640Shselasky	then
1337335640Shselasky		# User explicitly doesn't want SNF
1338335640Shselasky		want_snf=no
1339335640Shselasky	elif test "$withval" = yes
1340335640Shselasky	then
1341335640Shselasky		# User wants SNF support but hasn't specified a directory.
1342335640Shselasky		want_snf=yes
1343335640Shselasky	else
1344335640Shselasky		# User wants SNF support with a specified directory.
1345335640Shselasky		want_snf=yes
1346335640Shselasky		snf_root=$withval
1347335640Shselasky	fi
1348335640Shselasky],[
1349335640Shselasky	if test "$V_PCAP" = snf; then
1350335640Shselasky		# User requested Sniffer-only libpcap, so we'd better have
1351335640Shselasky		# the Sniffer API.
1352335640Shselasky		want_snf=yes
1353335640Shselasky	elif test "xxx_only" = yes; then
1354335640Shselasky		# User requested something-else-only pcap, so they don't
1355335640Shselasky		# want SNF support.
1356335640Shselasky		want_snf=no
1357335640Shselasky	else
1358335640Shselasky		#
1359335640Shselasky		# Use Sniffer API if present, otherwise don't
1360335640Shselasky		#
1361335640Shselasky		want_snf=ifpresent
1362335640Shselasky	fi
1363335640Shselasky])
1364335640Shselasky
1365335640ShselaskyAC_ARG_WITH([snf-includes],
1366335640ShselaskyAC_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not DIR/include]),
1367335640Shselasky[
1368335640Shselasky	# User wants SNF with specific header directory
1369335640Shselasky	want_snf=yes
1370335640Shselasky	snf_include_dir=$withval
1371335640Shselasky],[])
1372335640Shselasky
1373335640ShselaskyAC_ARG_WITH([snf-libraries],
1374335640ShselaskyAC_HELP_STRING([--with-snf-libraries=LDIR],[Myricom SNF library directory, if not DIR/lib]),
1375335640Shselasky[
1376335640Shselasky	# User wants SNF with specific lib directory
1377335640Shselasky	want_snf=yes
1378335640Shselasky	snf_lib_dir=$withval
1379335640Shselasky],[])
1380335640Shselasky
1381335640Shselaskyac_cv_lbl_snf_api=no
1382335640Shselaskyif test "$with_snf" != no; then
1383335640Shselasky
1384335640Shselasky	AC_MSG_CHECKING(whether we have Myricom Sniffer API)
1385335640Shselasky
1386335640Shselasky	# If necessary, set default paths for Sniffer headers and libraries.
1387335640Shselasky	if test -z "$snf_root"; then
1388335640Shselasky		snf_root=/opt/snf
1389335640Shselasky	fi
1390335640Shselasky
1391335640Shselasky	if test -z "$snf_include_dir"; then
1392335640Shselasky		snf_include_dir="$snf_root/include"
1393335640Shselasky	fi
1394335640Shselasky
1395335640Shselasky	if test -z "$snf_lib_dir"; then
1396335640Shselasky		snf_lib_dir="$snf_root/lib"
1397335640Shselasky	fi
1398335640Shselasky
1399335640Shselasky	if test -f "$snf_include_dir/snf.h"; then
1400335640Shselasky		# We found a header; make sure we can link with the library
1401335640Shselasky		saved_ldflags=$LDFLAGS
1402335640Shselasky		LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1403335640Shselasky		AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"])
1404335640Shselasky		LDFLAGS="$saved_ldflags"
1405335640Shselasky		if test "$ac_cv_lbl_snf_api" = no; then
1406335640Shselasky			AC_MSG_ERROR(SNF API cannot correctly be linked; check config.log)
1407335640Shselasky		fi
1408335640Shselasky	fi
1409335640Shselasky
1410335640Shselasky	if test "$ac_cv_lbl_snf_api" = yes; then
1411335640Shselasky		AC_MSG_RESULT([yes ($snf_root)])
1412335640Shselasky
1413335640Shselasky		V_INCLS="$V_INCLS -I$snf_include_dir"
1414335640Shselasky		LIBS="$LIBS -lsnf"
1415335640Shselasky		LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1416335640Shselasky
1417335640Shselasky		if test "$V_PCAP" != snf ; then
1418335640Shselasky			SSRC="$SSRC pcap-snf.c"
1419335640Shselasky		fi
1420335640Shselasky
1421335640Shselasky		AC_DEFINE(HAVE_SNF_API, 1, [define if you have the Myricom SNF API])
1422335640Shselasky	else
1423335640Shselasky		AC_MSG_RESULT(no)
1424335640Shselasky
1425335640Shselasky		if test "$want_snf" = yes; then
1426335640Shselasky			# User requested "snf" capture type but
1427335640Shselasky			# we couldn't find the Sniffer API support.
1428335640Shselasky			AC_MSG_ERROR([Myricom Sniffer support requested with --with-pcap=snf, but the Sniffer headers weren't found at $snf_include_dir: make sure the Sniffer support is installed, specify a different path or paths if necessary, or don't request Sniffer support])
1429335640Shselasky		fi
1430335640Shselasky
1431335640Shselasky		if test "$want_snf" = yes; then
1432335640Shselasky			AC_MSG_ERROR([Myricom Sniffer support requested with --with-snf, but the Sniffer headers weren't found at $snf_include_dir: make sure the Sniffer support is installed, specify a different path or paths if necessary, or don't request Sniffer support])
1433335640Shselasky		fi
1434335640Shselasky	fi
1435335640Shselaskyfi
1436335640Shselasky
1437335640Shselasky# Check for Riverbed TurboCap support.
1438335640ShselaskyAC_ARG_WITH([turbocap],
1439335640ShselaskyAC_HELP_STRING([--with-turbocap@<:@=DIR@:>@],[include Riverbed TurboCap support (located in directory DIR, if supplied).  @<:@default=yes, if present@:>@]),
1440335640Shselasky[
1441335640Shselasky	if test "$withval" = no
1442335640Shselasky	then
1443335640Shselasky		# User explicitly doesn't want TurboCap
1444335640Shselasky		want_turbocap=no
1445335640Shselasky	elif test "$withval" = yes
1446335640Shselasky	then
1447335640Shselasky		# User wants TurboCap support but hasn't specified a directory.
1448335640Shselasky		want_turbocap=yes
1449335640Shselasky	else
1450335640Shselasky		# User wants TurboCap support with a specified directory.
1451335640Shselasky		want_turbocap=yes
1452335640Shselasky		turbocap_root=$withval
1453335640Shselasky	fi
1454335640Shselasky],[
1455335640Shselasky	if test "xxx_only" = yes; then
1456335640Shselasky		# User requested something-else-only pcap, so they don't
1457335640Shselasky		# want TurboCap support.
1458335640Shselasky		want_turbocap=no
1459335640Shselasky	else
1460335640Shselasky		#
1461335640Shselasky		# Use TurboCap API if present, otherwise don't
1462335640Shselasky		#
1463335640Shselasky		want_turbocap=ifpresent
1464335640Shselasky	fi
1465335640Shselasky])
1466335640Shselasky
1467335640Shselaskyac_cv_lbl_turbocap_api=no
1468335640Shselaskyif test "$want_turbocap" != no; then
1469335640Shselasky
1470335640Shselasky	AC_MSG_CHECKING(whether TurboCap is supported)
1471335640Shselasky
1472335640Shselasky	save_CFLAGS="$CFLAGS"
1473335640Shselasky	save_LIBS="$LIBS"
1474335640Shselasky	if test ! -z "$turbocap_root"; then
1475335640Shselasky		TURBOCAP_CFLAGS="-I$turbocap_root/include"
1476335640Shselasky		TURBOCAP_LIBS="-L$turbocap_root/lib"
1477335640Shselasky		CFLAGS="$CFLAGS $TURBOCAP_CFLAGS"
1478335640Shselasky	fi
1479335640Shselasky
1480335640Shselasky	AC_TRY_COMPILE(
1481335640Shselasky	[
1482335640Shselasky	    #include <TcApi.h>
1483335640Shselasky	],
1484335640Shselasky	[
1485335640Shselasky	    TC_INSTANCE a; TC_PORT b; TC_BOARD c;
1486335640Shselasky	    TC_INSTANCE i;
1487335640Shselasky	    (void)TcInstanceCreateByName("foo", &i);
1488335640Shselasky	],
1489335640Shselasky	ac_cv_lbl_turbocap_api=yes)
1490335640Shselasky
1491335640Shselasky	CFLAGS="$save_CFLAGS"
1492335640Shselasky	if test $ac_cv_lbl_turbocap_api = yes; then
1493335640Shselasky		AC_MSG_RESULT(yes)
1494335640Shselasky
1495335640Shselasky		SSRC="$SSRC pcap-tc.c"
1496335640Shselasky		V_INCLS="$V_INCLS $TURBOCAP_CFLAGS"
1497335640Shselasky		LIBS="$LIBS $TURBOCAP_LIBS -lTcApi -lpthread -lstdc++"
1498335640Shselasky
1499335640Shselasky		AC_DEFINE(HAVE_TC_API, 1, [define if you have the TurboCap API])
1500335640Shselasky	else
1501335640Shselasky		AC_MSG_RESULT(no)
1502335640Shselasky
1503335640Shselasky		if test "$want_turbocap" = yes; then
1504335640Shselasky	        	# User wanted Turbo support but we couldn't find it.
1505335640Shselasky			AC_MSG_ERROR([TurboCap support requested with --with-turbocap, but the TurboCap headers weren't found: make sure the TurboCap support is installed or don't request TurboCap support])
1506335640Shselasky		fi
1507335640Shselasky	fi
1508335640Shselaskyfi
1509335640Shselasky
1510335640Shselaskydnl
1511335640Shselaskydnl Allow the user to enable remote capture.
1512335640Shselaskydnl It's off by default, as that increases the attack surface of
1513335640Shselaskydnl libpcap, exposing it to malicious servers.
1514335640Shselaskydnl
1515335640ShselaskyAC_MSG_CHECKING([whether to enable remote packet capture])
1516335640ShselaskyAC_ARG_ENABLE(remote,
1517335640Shselasky[  --enable-remote         enable remote packet capture @<:@default=no@:>@
1518335640Shselasky  --disable-remote        disable remote packet capture],,
1519335640Shselasky   enableval=no)
1520335640Shselaskycase "$enableval" in
1521335640Shselaskyyes)	AC_MSG_RESULT(yes)
1522335640Shselasky	AC_WARN([Remote packet capture may expose libpcap-based applications])
1523335640Shselasky	AC_WARN([to attacks by malicious remote capture servers!])
1524335640Shselasky	#
1525335640Shselasky	# rpcapd requires pthreads on UN*X.
1526335640Shselasky	#
1527335640Shselasky	if test "$ac_lbl_have_pthreads" != "found"; then
1528335640Shselasky		AC_MSG_ERROR([rpcapd requires pthreads, but we didn't find them])
1529335640Shselasky	fi
1530335640Shselasky	#
1531335640Shselasky	# It also requires crypt().
1532335640Shselasky	# Do we have it in the system libraries?
1533335640Shselasky	#
1534335640Shselasky	AC_CHECK_FUNC(crypt,,
1535335640Shselasky	    [
1536335640Shselasky		#
1537335640Shselasky		# No.  Do we have it in -lcrypt?
1538335640Shselasky		#
1539335640Shselasky		AC_CHECK_LIB(crypt, crypt,
1540335640Shselasky		    [
1541335640Shselasky			#
1542335640Shselasky			# Yes; add -lcrypt to the libraries for rpcapd.
1543335640Shselasky			#
1544335640Shselasky			RPCAPD_LIBS="$RPCAPD_LIBS -lcrypt"
1545335640Shselasky		    ],
1546335640Shselasky		    [
1547335640Shselasky			AC_MSG_ERROR([rpcapd requires crypt(), but we didn't find it])
1548335640Shselasky		    ])
1549335640Shselasky	    ])
1550335640Shselasky
1551335640Shselasky	#
1552335640Shselasky	# OK, we have crypt().  Do we have getspnam()?
1553335640Shselasky	#
1554335640Shselasky	AC_CHECK_FUNCS(getspnam)
1555335640Shselasky
1556335640Shselasky	#
1557335640Shselasky	# Check for various members of struct msghdr.
1558335640Shselasky	#
1559335640Shselasky	AC_CHECK_MEMBERS([struct msghdr.msg_control],,,
1560335640Shselasky	    [
1561335640Shselasky		#include "ftmacros.h"
1562335640Shselasky		#include <sys/socket.h>
1563335640Shselasky	    ])
1564335640Shselasky	AC_CHECK_MEMBERS([struct msghdr.msg_flags],,,
1565335640Shselasky	    [
1566335640Shselasky		#include "ftmacros.h"
1567335640Shselasky		#include <sys/socket.h>
1568335640Shselasky	    ])
1569335640Shselasky
1570335640Shselasky	AC_DEFINE(ENABLE_REMOTE,,
1571335640Shselasky	    [Define to 1 if remote packet capture is to be supported])
1572335640Shselasky	SSRC="$SSRC pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c"
1573335640Shselasky	BUILD_RPCAPD=build-rpcapd
1574335640Shselasky	INSTALL_RPCAPD=install-rpcapd
1575335640Shselasky	;;
1576335640Shselasky*)	AC_MSG_RESULT(no)
1577335640Shselasky	;;
1578335640Shselaskyesac
1579335640Shselasky
1580335640ShselaskyAC_MSG_CHECKING(whether to build optimizer debugging code)
1581335640ShselaskyAC_ARG_ENABLE(optimizer-dbg,
1582335640ShselaskyAC_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code]))
1583335640Shselaskyif test "$enable_optimizer_dbg" = "yes"; then
1584335640Shselasky	AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
1585335640Shselaskyfi
1586335640ShselaskyAC_MSG_RESULT(${enable_optimizer_dbg-no})
1587335640Shselasky
1588335640ShselaskyAC_MSG_CHECKING(whether to build parser debugging code)
1589335640ShselaskyAC_ARG_ENABLE(yydebug,
1590335640ShselaskyAC_HELP_STRING([--enable-yydebug],[build parser debugging code]))
1591335640Shselaskyif test "$enable_yydebug" = "yes"; then
1592335640Shselasky	AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
1593335640Shselaskyfi
1594335640ShselaskyAC_MSG_RESULT(${enable_yydebug-no})
1595335640Shselasky
1596335640Shselasky#
1597335640Shselasky# Look for {f}lex.
1598335640Shselasky#
1599335640ShselaskyAC_PROG_LEX
1600335640Shselaskyif test "$LEX" = ":"; then
1601335640Shselasky	AC_MSG_ERROR([Neither flex nor lex was found.])
1602335640Shselaskyfi
1603335640Shselasky
1604335640Shselasky#
1605335640Shselasky# Make sure {f}lex supports the -P, --header-file, and --nounput flags
1606335640Shselasky# and supports processing our scanner.l.
1607335640Shselasky#
1608335640ShselaskyAC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
1609335640Shselasky	if $LEX -P pcap_ --header-file=/dev/null --nounput -t $srcdir/scanner.l > /dev/null 2>&1; then
1610335640Shselasky	    tcpdump_cv_capable_lex=yes
1611335640Shselasky	else
1612335640Shselasky	    tcpdump_cv_capable_lex=insufficient
1613335640Shselasky	fi)
1614335640Shselaskyif test $tcpdump_cv_capable_lex = insufficient ; then
1615335640Shselasky	AC_MSG_ERROR([$LEX is insufficient to compile libpcap.
1616335640Shselasky libpcap requires Flex 2.5.31 or later, or a compatible version of lex.])
1617335640Shselaskyfi
1618335640Shselasky
1619335640Shselasky#
1620335640Shselasky# Look for yacc/bison/byacc.
1621335640Shselasky#
1622335640ShselaskyAC_PROG_YACC
1623335640Shselasky
1624335640Shselasky#
1625335640Shselasky# Make sure it supports the -p flag and supports processing our
1626335640Shselasky# grammar.y.
1627335640Shselasky#
1628335640ShselaskyAC_CACHE_CHECK([for capable yacc/bison], tcpdump_cv_capable_yacc,
1629335640Shselasky	if $YACC -p pcap_ -o /dev/null $srcdir/grammar.y >/dev/null 2>&1; then
1630335640Shselasky	    tcpdump_cv_capable_yacc=yes
1631335640Shselasky	else
1632335640Shselasky	    tcpdump_cv_capable_yacc=insufficient
1633335640Shselasky	fi)
1634335640Shselaskyif test $tcpdump_cv_capable_yacc = insufficient ; then
1635335640Shselasky	AC_MSG_ERROR([$YACC is insufficient to compile libpcap.
1636356341Scy libpcap requires Bison, a newer version of Berkeley YACC with support
1637356341Scy for reentrant parsers, or another YACC compatible with them.])
1638335640Shselaskyfi
1639335640Shselasky
1640335640Shselasky#
1641335640Shselasky# Do various checks for various OSes and versions of those OSes.
1642335640Shselasky#
1643335640Shselasky# Assume, by default, no support for shared libraries and V7/BSD
1644356341Scy# convention for man pages (devices in section 4, file formats in
1645356341Scy# section 5, miscellaneous info in section 7, administrative commands
1646356341Scy# and daemons in section 8).  Individual cases can override this.
1647335640Shselasky#
1648335640ShselaskyDYEXT="none"
1649356341ScyMAN_DEVICES=4
1650335640ShselaskyMAN_FILE_FORMATS=5
1651335640ShselaskyMAN_MISC_INFO=7
1652335640ShselaskyMAN_ADMIN_COMMANDS=8
1653335640Shselaskycase "$host_os" in
1654335640Shselasky
1655335640Shselaskyaix*)
1656335640Shselasky	dnl Workaround to enable certain features
1657335640Shselasky	AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
1658335640Shselasky
1659335640Shselasky	#
1660335640Shselasky	# AIX makes it fun to build shared and static libraries,
1661335640Shselasky	# because they're *both* ".a" archive libraries.  We
1662335640Shselasky	# build the static library for the benefit of the traditional
1663335640Shselasky	# scheme of building libpcap and tcpdump in subdirectories of
1664335640Shselasky	# the same directory, with tcpdump statically linked with the
1665335640Shselasky	# libpcap in question, but we also build a shared library as
1666335640Shselasky	# "libpcap.shareda" and install *it*, rather than the static
1667335640Shselasky	# library, as "libpcap.a".
1668335640Shselasky	#
1669335640Shselasky	DYEXT="shareda"
1670335640Shselasky
1671335640Shselasky	case "$V_PCAP" in
1672335640Shselasky
1673335640Shselasky	dlpi)
1674335640Shselasky		#
1675335640Shselasky		# If we're using DLPI, applications will need to
1676335640Shselasky		# use /lib/pse.exp if present, as we use the
1677335640Shselasky		# STREAMS routines.
1678335640Shselasky		#
1679335640Shselasky		pseexe="/lib/pse.exp"
1680335640Shselasky		AC_MSG_CHECKING(for $pseexe)
1681335640Shselasky		if test -f $pseexe ; then
1682335640Shselasky			AC_MSG_RESULT(yes)
1683335640Shselasky			LIBS="-I:$pseexe"
1684335640Shselasky		fi
1685335640Shselasky		;;
1686335640Shselasky
1687335640Shselasky	bpf)
1688335640Shselasky		#
1689335640Shselasky		# If we're using BPF, we need "-lodm" and "-lcfg", as
1690335640Shselasky		# we use them to load the BPF module.
1691335640Shselasky		#
1692335640Shselasky		LIBS="-lodm -lcfg"
1693335640Shselasky		;;
1694335640Shselasky	esac
1695335640Shselasky	;;
1696335640Shselasky
1697335640Shselaskydarwin*)
1698335640Shselasky	DYEXT="dylib"
1699335640Shselasky	V_CCOPT="$V_CCOPT -fno-common"
1700335640Shselasky	AC_ARG_ENABLE(universal,
1701335640Shselasky	AC_HELP_STRING([--disable-universal],[don't build universal on macOS]))
1702335640Shselasky	if test "$enable_universal" != "no"; then
1703335640Shselasky		case "$host_os" in
1704335640Shselasky
1705356341Scy		darwin[[0-7]].*)
1706335640Shselasky			#
1707335640Shselasky			# Pre-Tiger.  Build only for 32-bit PowerPC; no
1708335640Shselasky			# need for any special compiler or linker flags.
1709335640Shselasky			#
1710335640Shselasky			;;
1711335640Shselasky
1712356341Scy		darwin8.[[0123]]|darwin8.[[0123]].*)
1713335640Shselasky			#
1714356341Scy			# Tiger, prior to Intel support.  Build
1715356341Scy			# libraries and executables for 32-bit PowerPC
1716356341Scy			# and 64-bit PowerPC, with 32-bit PowerPC first.
1717356341Scy			# (I'm guessing that's what Apple does.)
1718335640Shselasky			#
1719356341Scy			# (The double brackets are needed because
1720356341Scy			# autotools/m4 use brackets as a quoting
1721356341Scy			# character; the double brackets turn into
1722356341Scy			# single brackets in the generated configure
1723356341Scy			# file.)
1724356341Scy			#
1725356341Scy			V_LIB_CCOPT_FAT="-arch ppc -arch ppc64"
1726356341Scy			V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64"
1727356341Scy			V_PROG_CCOPT_FAT="-arch ppc -arch ppc64"
1728356341Scy			V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64"
1729335640Shselasky			;;
1730335640Shselasky
1731356341Scy		darwin8.[[456]]|darwin.[[456]].*)
1732335640Shselasky			#
1733356341Scy			# Tiger, subsequent to Intel support but prior
1734356341Scy			# to x86-64 support.  Build libraries and
1735356341Scy			# executables for 32-bit PowerPC, 64-bit
1736356341Scy			# PowerPC, and 32-bit x86, with 32-bit PowerPC
1737356341Scy			# first.  (I'm guessing that's what Apple does.)
1738335640Shselasky			#
1739356341Scy			# (The double brackets are needed because
1740356341Scy			# autotools/m4 use brackets as a quoting
1741356341Scy			# character; the double brackets turn into
1742356341Scy			# single brackets in the generated configure
1743356341Scy			# file.)
1744356341Scy			#
1745356341Scy			V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
1746356341Scy			V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
1747356341Scy			V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
1748356341Scy			V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
1749335640Shselasky			;;
1750335640Shselasky
1751335640Shselasky		darwin8.*)
1752335640Shselasky			#
1753335640Shselasky			# All other Tiger, so subsequent to x86-64
1754356341Scy			# support.  Build libraries and executables for
1755356341Scy			# 32-bit PowerPC, 64-bit PowerPC, 32-bit x86,
1756356341Scy			# and x86-64, with 32-bit PowerPC first.  (I'm
1757356341Scy			# guessing that's what Apple does.)
1758335640Shselasky			#
1759356341Scy			V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1760356341Scy			V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1761356341Scy			V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1762356341Scy			V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1763335640Shselasky			;;
1764335640Shselasky
1765335640Shselasky		darwin9.*)
1766335640Shselasky			#
1767356341Scy			# Leopard.  Build libraries for 32-bit PowerPC,
1768356341Scy			# 64-bit PowerPC, 32-bit x86, and x86-64, with
1769356341Scy			# 32-bit PowerPC first, and build executables
1770356341Scy			# for 32-bit x86 and 32-bit PowerPC, with 32-bit
1771356341Scy			# x86 first.  (That's what Apple does.)
1772335640Shselasky			#
1773356341Scy			V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1774356341Scy			V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1775356341Scy			V_PROG_CCOPT_FAT="-arch i386 -arch ppc"
1776356341Scy			V_PROG_LDFLAGS_FAT="-arch i386 -arch ppc"
1777335640Shselasky			;;
1778335640Shselasky
1779335640Shselasky		darwin10.*)
1780335640Shselasky			#
1781356341Scy			# Snow Leopard.  Build libraries for x86-64,
1782356341Scy			# 32-bit x86, and 32-bit PowerPC, with x86-64
1783356341Scy			# first, and build executables for x86-64 and
1784356341Scy			# 32-bit x86, with x86-64 first.  (That's what
1785356341Scy			# Apple does, even though Snow Leopard doesn't
1786356341Scy			# run on PPC, so PPC libpcap runs under Rosetta,
1787356341Scy			# and Rosetta doesn't support BPF ioctls, so PPC
1788356341Scy			# programs can't do live captures.)
1789335640Shselasky			#
1790356341Scy			V_LIB_CCOPT_FAT="-arch x86_64 -arch i386 -arch ppc"
1791356341Scy			V_LIB_LDFLAGS_FAT="-arch x86_64 -arch i386 -arch ppc"
1792356341Scy			V_PROG_CCOPT_FAT="-arch x86_64 -arch i386"
1793356341Scy			V_PROG_LDFLAGS_FAT="-arch x86_64 -arch i386"
1794335640Shselasky			;;
1795335640Shselasky
1796335640Shselasky		darwin*)
1797335640Shselasky			#
1798356341Scy			# Post-Snow Leopard.  Build libraries for x86-64
1799356341Scy			# and 32-bit x86, with x86-64 first, and build
1800356341Scy			# executables only for x86-64.  (That's what
1801356341Scy			# Apple does.)  This requires no special flags
1802356341Scy			# for programs.
1803335640Shselasky			# XXX - update if and when Apple drops support
1804356341Scy			# for 32-bit x86 code and if and when Apple adds
1805356341Scy			# ARM-based Macs.  (You're on your own for iOS
1806356341Scy			# etc.)
1807335640Shselasky			#
1808356341Scy			# XXX - check whether we *can* build for
1809356341Scy			# i386 and, if not, suggest that the user
1810356341Scy			# install the /usr/include headers if they
1811356341Scy			# want to build fat.
1812356341Scy			#
1813356341Scy			AC_MSG_CHECKING(whether building for 32-bit x86 is supported)
1814356341Scy			save_CFLAGS="$CFLAGS"
1815356341Scy			CFLAGS="$CFLAGS -arch i386"
1816356341Scy			AC_TRY_COMPILE(
1817356341Scy			    [],
1818356341Scy			    [return 0;],
1819356341Scy			    [
1820356341Scy				AC_MSG_RESULT(yes)
1821356341Scy				V_LIB_CCOPT_FAT="-arch x86_64 -arch i386"
1822356341Scy				V_LIB_LDFLAGS_FAT="-arch x86_64 -arch i386"
1823356341Scy			    ],
1824356341Scy			    [
1825356341Scy				AC_MSG_RESULT(no)
1826356341Scy				V_LIB_CCOPT_FAT="-arch x86_64"
1827356341Scy				V_LIB_LDFLAGS_FAT="-arch x86_64"
1828356341Scy				case "$host_os" in
1829356341Scy
1830356341Scy				darwin18.*)
1831356341Scy					#
1832356341Scy					# Mojave; you need to install the
1833356341Scy					# /usr/include headers to get
1834356341Scy					# 32-bit x86 builds to work.
1835356341Scy					#
1836356341Scy					AC_MSG_WARN([Compiling for 32-bit x86 gives an error; try installing the command-line tools and, after that, installing the /usr/include headers from the /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg package])
1837356341Scy					;;
1838356341Scy
1839356341Scy				*)
1840356341Scy					#
1841356341Scy					# Pre-Mojave; the command-line
1842356341Scy					# tools should be sufficient to
1843356341Scy					# enable 32-bit x86 builds.
1844356341Scy					#
1845356341Scy					AC_MSG_WARN([Compiling for 32-bit x86 gives an error; try installing the command-line tools])
1846356341Scy					;;
1847356341Scy				esac
1848356341Scy			    ])
1849356341Scy			CFLAGS="$save_CFLAGS"
1850335640Shselasky			;;
1851335640Shselasky		esac
1852335640Shselasky	fi
1853335640Shselasky	;;
1854335640Shselasky
1855335640Shselaskyhpux9*)
1856335640Shselasky	AC_DEFINE(HAVE_HPUX9,1,[on HP-UX 9.x])
1857335640Shselasky
1858335640Shselasky	#
1859335640Shselasky	# Use System V conventions for man pages.
1860335640Shselasky	#
1861335640Shselasky	MAN_ADMIN_COMMANDS=1m
1862335640Shselasky	MAN_FILE_FORMATS=4
1863335640Shselasky	MAN_MISC_INFO=5
1864335640Shselasky	;;
1865335640Shselasky
1866335640Shselaskyhpux10.0*)
1867335640Shselasky
1868335640Shselasky	#
1869335640Shselasky	# Use System V conventions for man pages.
1870335640Shselasky	#
1871335640Shselasky	MAN_ADMIN_COMMANDS=1m
1872335640Shselasky	MAN_FILE_FORMATS=4
1873335640Shselasky	MAN_MISC_INFO=5
1874335640Shselasky	;;
1875335640Shselasky
1876335640Shselaskyhpux10.1*)
1877335640Shselasky
1878335640Shselasky	#
1879335640Shselasky	# Use System V conventions for man pages.
1880335640Shselasky	#
1881335640Shselasky	MAN_ADMIN_COMMANDS=1m
1882335640Shselasky	MAN_FILE_FORMATS=4
1883335640Shselasky	MAN_MISC_INFO=5
1884335640Shselasky	;;
1885335640Shselasky
1886335640Shselaskyhpux*)
1887335640Shselasky	dnl HPUX 10.20 and above is similar to HPUX 9, but
1888335640Shselasky	dnl not the same....
1889335640Shselasky	dnl
1890335640Shselasky	dnl XXX - DYEXT should be set to "sl" if this is building
1891335640Shselasky	dnl for 32-bit PA-RISC, but should be left as "so" for
1892335640Shselasky	dnl 64-bit PA-RISC or, I suspect, IA-64.
1893335640Shselasky	AC_DEFINE(HAVE_HPUX10_20_OR_LATER,1,[on HP-UX 10.20 or later])
1894335640Shselasky	if test "`uname -m`" = "ia64"; then
1895335640Shselasky		DYEXT="so"
1896335640Shselasky	else
1897335640Shselasky		DYEXT="sl"
1898335640Shselasky	fi
1899335640Shselasky
1900335640Shselasky	#
1901335640Shselasky	# "-b" builds a shared library; "+h" sets the soname.
1902335640Shselasky	#
1903335640Shselasky	SHLIB_OPT="-b"
1904335640Shselasky	SONAME_OPT="+h"
1905335640Shselasky
1906335640Shselasky	#
1907335640Shselasky	# Use System V conventions for man pages.
1908335640Shselasky	#
1909335640Shselasky	MAN_FILE_FORMATS=4
1910335640Shselasky	MAN_MISC_INFO=5
1911335640Shselasky	;;
1912335640Shselasky
1913335640Shselaskyirix*)
1914335640Shselasky	#
1915335640Shselasky	# Use IRIX conventions for man pages; they're the same as the
1916335640Shselasky	# System V conventions, except that they use section 8 for
1917335640Shselasky	# administrative commands and daemons.
1918335640Shselasky	#
1919335640Shselasky	MAN_FILE_FORMATS=4
1920335640Shselasky	MAN_MISC_INFO=5
1921335640Shselasky	;;
1922335640Shselasky
1923356341Scylinux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*|midipix*)
1924335640Shselasky	DYEXT="so"
1925335640Shselasky
1926335640Shselasky	#
1927335640Shselasky	# Compiler assumed to be GCC; run-time linker may require a -R
1928335640Shselasky	# flag.
1929335640Shselasky	#
1930335640Shselasky	if test "$libdir" != "/usr/lib"; then
1931335640Shselasky		V_RFLAGS=-Wl,-R$libdir
1932335640Shselasky	fi
1933335640Shselasky	;;
1934335640Shselasky
1935335640Shselaskyosf*)
1936335640Shselasky	DYEXT="so"
1937335640Shselasky
1938335640Shselasky	#
1939335640Shselasky	# DEC OSF/1, a/k/a Digial UNIX, a/k/a Tru64 UNIX.
1940335640Shselasky	# Use Tru64 UNIX conventions for man pages; they're the same as
1941335640Shselasky	# the System V conventions except that they use section 8 for
1942335640Shselasky	# administrative commands and daemons.
1943335640Shselasky	#
1944335640Shselasky	MAN_FILE_FORMATS=4
1945335640Shselasky	MAN_MISC_INFO=5
1946356341Scy	MAN_DEVICES=7
1947335640Shselasky	;;
1948335640Shselasky
1949335640Shselaskysinix*)
1950335640Shselasky	AC_MSG_CHECKING(if SINIX compiler defines sinix)
1951335640Shselasky	AC_CACHE_VAL(ac_cv_cc_sinix_defined,
1952335640Shselasky		AC_TRY_COMPILE(
1953335640Shselasky		    [],
1954335640Shselasky		    [int i = sinix;],
1955335640Shselasky		    ac_cv_cc_sinix_defined=yes,
1956335640Shselasky		    ac_cv_cc_sinix_defined=no))
1957335640Shselasky	    AC_MSG_RESULT($ac_cv_cc_sinix_defined)
1958335640Shselasky	    if test $ac_cv_cc_sinix_defined = no ; then
1959335640Shselasky		    AC_DEFINE(sinix,1,[on sinix])
1960335640Shselasky	    fi
1961335640Shselasky	;;
1962335640Shselasky
1963335640Shselaskysolaris*)
1964335640Shselasky	AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
1965335640Shselasky
1966335640Shselasky	DYEXT="so"
1967335640Shselasky
1968335640Shselasky	#
1969335640Shselasky	# Make sure errno is thread-safe, in case we're called in
1970335640Shselasky	# a multithreaded program.  We don't guarantee that two
1971335640Shselasky	# threads can use the *same* pcap_t safely, but the
1972335640Shselasky	# current version does guarantee that you can use different
1973335640Shselasky	# pcap_t's in different threads, and even that pcap_compile()
1974335640Shselasky	# is thread-safe (it wasn't thread-safe in some older versions).
1975335640Shselasky	#
1976335640Shselasky	V_CCOPT="$V_CCOPT -D_TS_ERRNO"
1977335640Shselasky
1978335640Shselasky	case "`uname -r`" in
1979335640Shselasky
1980335640Shselasky	5.12)
1981335640Shselasky		;;
1982335640Shselasky
1983335640Shselasky	*)
1984335640Shselasky		#
1985335640Shselasky		# Use System V conventions for man pages.
1986335640Shselasky		#
1987335640Shselasky		MAN_ADMIN_COMMANDS=1m
1988335640Shselasky		MAN_FILE_FORMATS=4
1989335640Shselasky		MAN_MISC_INFO=5
1990356341Scy		MAN_DEVICES=7D
1991335640Shselasky	esac
1992335640Shselasky	;;
1993335640Shselaskyesac
1994335640Shselasky
1995335640ShselaskyAC_ARG_ENABLE(shared,
1996335640ShselaskyAC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@]))
1997335640Shselaskytest "x$enable_shared" = "xno" && DYEXT="none"
1998335640Shselasky
1999335640ShselaskyAC_PROG_RANLIB
2000335640ShselaskyAC_CHECK_TOOL([AR], [ar])
2001335640Shselasky
2002335640ShselaskyAC_PROG_LN_S
2003335640ShselaskyAC_SUBST(LN_S)
2004335640Shselasky
2005335640ShselaskyAC_LBL_DEVEL(V_CCOPT)
2006335640Shselasky
2007335640Shselasky#
2008335640Shselasky# Check to see if the sockaddr struct has the 4.4 BSD sa_len member.
2009335640Shselasky#
2010335640ShselaskyAC_CHECK_MEMBERS([struct sockaddr.sa_len],,,
2011335640Shselasky    [
2012335640Shselasky	#include <sys/types.h>
2013335640Shselasky	#include <sys/socket.h>
2014335640Shselasky    ])
2015335640Shselasky
2016335640Shselasky#
2017335640Shselasky# Check to see if there's a sockaddr_storage structure.
2018335640Shselasky#
2019335640ShselaskyAC_CHECK_TYPES(struct sockaddr_storage,,,
2020335640Shselasky    [
2021335640Shselasky	#include <sys/types.h>
2022335640Shselasky	#include <sys/socket.h>
2023335640Shselasky    ])
2024335640Shselasky
2025335640Shselasky#
2026335640Shselasky# Check to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
2027335640Shselasky# dl_module_id_1 member.
2028335640Shselasky#
2029335640Shselasky# NOTE: any failure means we conclude that it doesn't have that member,
2030335640Shselasky# so if we don't have DLPI, don't have a <sys/dlpi_ext.h> header, or
2031335640Shselasky# have one that doesn't declare a dl_hp_ppa_info_t type, we conclude
2032335640Shselasky# it doesn't have that member (which is OK, as either we won't be
2033335640Shselasky# using code that would use that member, or we wouldn't compile in
2034335640Shselasky# any case).
2035335640Shselasky#
2036335640ShselaskyAC_CHECK_MEMBERS([dl_hp_ppa_info_t.dl_module_id_1],,,
2037335640Shselasky    [
2038335640Shselasky	#include <sys/types.h>
2039335640Shselasky	#include <sys/dlpi.h>
2040335640Shselasky	#include <sys/dlpi_ext.h>
2041335640Shselasky    ])
2042335640Shselasky
2043335640ShselaskyAC_LBL_UNALIGNED_ACCESS
2044335640Shselasky
2045335640ShselaskyAC_SUBST(V_CCOPT)
2046356341ScyAC_SUBST(V_LIB_CCOPT_FAT)
2047356341ScyAC_SUBST(V_LIB_LDFLAGS_FAT)
2048356341ScyAC_SUBST(V_PROG_CCOPT_FAT)
2049356341ScyAC_SUBST(V_PROG_LDFLAGS_FAT)
2050335640ShselaskyAC_SUBST(V_DEFS)
2051335640ShselaskyAC_SUBST(V_FINDALLDEVS)
2052335640ShselaskyAC_SUBST(V_INCLS)
2053335640ShselaskyAC_SUBST(V_LEX)
2054335640ShselaskyAC_SUBST(V_PCAP)
2055335640ShselaskyAC_SUBST(V_SHLIB_CCOPT)
2056335640ShselaskyAC_SUBST(V_SHLIB_CMD)
2057335640ShselaskyAC_SUBST(V_SHLIB_OPT)
2058335640ShselaskyAC_SUBST(V_SONAME_OPT)
2059335640ShselaskyAC_SUBST(V_RPATH_OPT)
2060335640ShselaskyAC_SUBST(V_YACC)
2061335640ShselaskyAC_SUBST(ADDLOBJS)
2062335640ShselaskyAC_SUBST(ADDLARCHIVEOBJS)
2063335640ShselaskyAC_SUBST(SSRC)
2064335640ShselaskyAC_SUBST(DYEXT)
2065356341ScyAC_SUBST(MAN_DEVICES)
2066335640ShselaskyAC_SUBST(MAN_FILE_FORMATS)
2067335640ShselaskyAC_SUBST(MAN_MISC_INFO)
2068335640ShselaskyAC_SUBST(MAN_ADMIN_COMMANDS)
2069335640ShselaskyAC_SUBST(PTHREAD_LIBS)
2070335640ShselaskyAC_SUBST(BUILD_RPCAPD)
2071335640ShselaskyAC_SUBST(INSTALL_RPCAPD)
2072335640ShselaskyAC_SUBST(RPCAPD_LIBS)
2073335640ShselaskyAC_SUBST(EXTRA_NETWORK_LIBS)
2074335640Shselasky
2075335640ShselaskyAC_ARG_ENABLE([usb],
2076335640Shselasky[AC_HELP_STRING([--enable-usb],[enable USB capture support @<:@default=yes, if support available@:>@])],
2077335640Shselasky    [],
2078335640Shselasky    [enable_usb=yes])
2079335640Shselasky
2080335640Shselaskyif test "xxx_only" = yes; then
2081335640Shselasky	# User requested something-else-only pcap, so they don't
2082335640Shselasky	# want USB support.
2083335640Shselasky	enable_usb=no
2084335640Shselaskyfi
2085335640Shselasky
2086335640Shselaskyif test "x$enable_usb" != "xno" ; then
2087335640Shselasky   dnl check for USB sniffing support
2088335640Shselasky   AC_MSG_CHECKING(for USB sniffing support)
2089335640Shselasky   case "$host_os" in
2090335640Shselasky   linux*)
2091335640Shselasky	AC_DEFINE(PCAP_SUPPORT_USB, 1, [target host supports USB sniffing])
2092335640Shselasky	USB_SRC=pcap-usb-linux.c
2093335640Shselasky	AC_MSG_RESULT(yes)
2094335640Shselasky	ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null`
2095335640Shselasky	if test $? -ne 0 ; then
2096335640Shselasky	  ac_usb_dev_name="usbmon"
2097335640Shselasky	fi
2098335640Shselasky	AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing])
2099335640Shselasky	AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name)
2100335640Shselasky	#
2101335640Shselasky	# Do we have a version of <linux/compiler.h> available?
2102335640Shselasky	# If so, we might need it for <linux/usbdevice_fs.h>.
2103335640Shselasky	#
2104335640Shselasky	AC_CHECK_HEADERS(linux/compiler.h)
2105335640Shselasky	if test "$ac_cv_header_linux_compiler_h" = yes; then
2106335640Shselasky	  #
2107335640Shselasky	  # Yes - include it when testing for <linux/usbdevice_fs.h>.
2108335640Shselasky	  #
2109335640Shselasky	  AC_CHECK_HEADERS(linux/usbdevice_fs.h,,,[#include <linux/compiler.h>])
2110335640Shselasky	else
2111335640Shselasky	  AC_CHECK_HEADERS(linux/usbdevice_fs.h)
2112335640Shselasky	fi
2113335640Shselasky	if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then
2114335640Shselasky	  #
2115335640Shselasky	  # OK, does it define bRequestType?  Older versions of the kernel
2116335640Shselasky	  # define fields with names like "requesttype, "request", and
2117335640Shselasky	  # "value", rather than "bRequestType", "bRequest", and
2118335640Shselasky	  # "wValue".
2119335640Shselasky	  #
2120335640Shselasky	  AC_CHECK_MEMBERS([struct usbdevfs_ctrltransfer.bRequestType],,,
2121335640Shselasky	      [
2122335640Shselasky		  AC_INCLUDES_DEFAULT
2123335640Shselasky		  #ifdef HAVE_LINUX_COMPILER_H
2124335640Shselasky		  #include <linux/compiler.h>
2125335640Shselasky		  #endif
2126335640Shselasky		  #include <linux/usbdevice_fs.h>
2127335640Shselasky	      ])
2128335640Shselasky	fi
2129335640Shselasky	;;
2130335640Shselasky    freebsd*)
2131335640Shselasky	#
2132335640Shselasky	# This just uses BPF in FreeBSD 8.4 and later; we don't need
2133335640Shselasky	# to check for anything special for capturing.
2134335640Shselasky	#
2135335640Shselasky	AC_MSG_RESULT([yes, in FreeBSD 8.4 and later])
2136335640Shselasky	;;
2137335640Shselasky
2138335640Shselasky    *)
2139335640Shselasky	AC_MSG_RESULT(no)
2140335640Shselasky	;;
2141335640Shselaskyesac
2142335640Shselaskyfi
2143335640ShselaskyAC_SUBST(PCAP_SUPPORT_USB)
2144335640ShselaskyAC_SUBST(USB_SRC)
2145335640Shselasky
2146335640Shselaskydnl check for netfilter sniffing support
2147335640Shselaskyif test "xxx_only" != yes; then
2148335640Shselasky	AC_MSG_CHECKING(whether the platform could support netfilter sniffing)
2149335640Shselasky	case "$host_os" in
2150335640Shselasky	linux*)
2151335640Shselasky		AC_MSG_RESULT(yes)
2152335640Shselasky		#
2153335640Shselasky		# Life's too short to deal with trying to get this to compile
2154335640Shselasky		# if you don't get the right types defined with
2155335640Shselasky		# __KERNEL_STRICT_NAMES getting defined by some other include.
2156335640Shselasky		#
2157335640Shselasky		# Check whether the includes Just Work.  If not, don't turn on
2158335640Shselasky		# netfilter support.
2159335640Shselasky		#
2160335640Shselasky		AC_MSG_CHECKING(whether we can compile the netfilter support)
2161335640Shselasky		AC_CACHE_VAL(ac_cv_netfilter_can_compile,
2162335640Shselasky		  AC_TRY_COMPILE([
2163335640ShselaskyAC_INCLUDES_DEFAULT
2164335640Shselasky#include <sys/socket.h>
2165335640Shselasky#include <netinet/in.h>
2166335640Shselasky#include <linux/types.h>
2167335640Shselasky
2168335640Shselasky#include <linux/netlink.h>
2169335640Shselasky#include <linux/netfilter.h>
2170335640Shselasky#include <linux/netfilter/nfnetlink.h>
2171335640Shselasky#include <linux/netfilter/nfnetlink_log.h>
2172335640Shselasky#include <linux/netfilter/nfnetlink_queue.h>],
2173335640Shselasky		    [],
2174335640Shselasky		    ac_cv_netfilter_can_compile=yes,
2175335640Shselasky		    ac_cv_netfilter_can_compile=no))
2176335640Shselasky		AC_MSG_RESULT($ac_cv_netfilter_can_compile)
2177335640Shselasky		if test $ac_cv_netfilter_can_compile = yes ; then
2178335640Shselasky		  AC_DEFINE(PCAP_SUPPORT_NETFILTER, 1,
2179335640Shselasky		    [target host supports netfilter sniffing])
2180335640Shselasky		  NETFILTER_SRC=pcap-netfilter-linux.c
2181335640Shselasky		fi
2182335640Shselasky		;;
2183335640Shselasky	*)
2184335640Shselasky		AC_MSG_RESULT(no)
2185335640Shselasky		;;
2186335640Shselasky	esac
2187335640Shselaskyfi
2188335640ShselaskyAC_SUBST(PCAP_SUPPORT_NETFILTER)
2189335640ShselaskyAC_SUBST(NETFILTER_SRC)
2190335640Shselasky
2191335640ShselaskyAC_ARG_ENABLE([netmap],
2192335640Shselasky[AC_HELP_STRING([--enable-netmap],[enable netmap support @<:@default=yes, if support available@:>@])],
2193335640Shselasky    [],
2194335640Shselasky    [enable_netmap=yes])
2195335640Shselasky
2196335640Shselaskyif test "x$enable_netmap" != "xno" ; then
2197335640Shselasky	#
2198335640Shselasky	# Check whether net/netmap_user.h is usable if NETMAP_WITH_LIBS is
2199335640Shselasky	# defined; it's not usable on DragonFly BSD 4.6 if NETMAP_WITH_LIBS
2200335640Shselasky	# is defined, for example, as it includes a non-existent malloc.h
2201335640Shselasky	# header.
2202335640Shselasky	#
2203335640Shselasky	AC_MSG_CHECKING(whether we can compile the netmap support)
2204335640Shselasky	AC_CACHE_VAL(ac_cv_net_netmap_user_can_compile,
2205335640Shselasky	  AC_TRY_COMPILE([
2206335640ShselaskyAC_INCLUDES_DEFAULT
2207335640Shselasky#define NETMAP_WITH_LIBS
2208335640Shselasky#include <net/netmap_user.h>],
2209335640Shselasky	    [],
2210335640Shselasky	    ac_cv_net_netmap_user_can_compile=yes,
2211335640Shselasky	    ac_cv_net_netmap_user_can_compile=no))
2212335640Shselasky	AC_MSG_RESULT($ac_cv_net_netmap_user_can_compile)
2213335640Shselasky	if test $ac_cv_net_netmap_user_can_compile = yes ; then
2214335640Shselasky	  AC_DEFINE(PCAP_SUPPORT_NETMAP, 1,
2215335640Shselasky	    [target host supports netmap])
2216335640Shselasky	    NETMAP_SRC=pcap-netmap.c
2217335640Shselasky	fi
2218335640Shselasky	AC_SUBST(PCAP_SUPPORT_NETMAP)
2219335640Shselasky	AC_SUBST(NETMAP_SRC)
2220335640Shselaskyfi
2221335640Shselasky
2222335640Shselasky
2223335640ShselaskyAC_ARG_ENABLE([bluetooth],
2224335640Shselasky[AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
2225335640Shselasky    [],
2226335640Shselasky    [enable_bluetooth=ifsupportavailable])
2227335640Shselasky
2228335640Shselaskyif test "xxx_only" = yes; then
2229335640Shselasky	# User requested something-else-only pcap, so they don't
2230335640Shselasky	# want Bluetooth support.
2231335640Shselasky	enable_bluetooth=no
2232335640Shselaskyfi
2233335640Shselasky
2234335640Shselaskyif test "x$enable_bluetooth" != "xno" ; then
2235335640Shselasky	dnl check for Bluetooth sniffing support
2236335640Shselasky	case "$host_os" in
2237335640Shselasky	linux*)
2238335640Shselasky		AC_CHECK_HEADER(bluetooth/bluetooth.h,
2239335640Shselasky		    [
2240335640Shselasky			#
2241335640Shselasky			# We have bluetooth.h, so we support Bluetooth
2242335640Shselasky			# sniffing.
2243335640Shselasky			#
2244335640Shselasky			AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
2245335640Shselasky			BT_SRC=pcap-bt-linux.c
2246335640Shselasky			AC_MSG_NOTICE(Bluetooth sniffing is supported)
2247335640Shselasky			ac_lbl_bluetooth_available=yes
2248335640Shselasky
2249335640Shselasky			#
2250335640Shselasky			# OK, does struct sockaddr_hci have an hci_channel
2251335640Shselasky			# member?
2252335640Shselasky			#
2253335640Shselasky			AC_CHECK_MEMBERS([struct sockaddr_hci.hci_channel],
2254335640Shselasky			    [
2255335640Shselasky				#
2256335640Shselasky				# Yes; is HCI_CHANNEL_MONITOR defined?
2257335640Shselasky				#
2258335640Shselasky				AC_MSG_CHECKING(if HCI_CHANNEL_MONITOR is defined)
2259335640Shselasky				AC_CACHE_VAL(ac_cv_lbl_hci_channel_monitor_is_defined,
2260335640Shselasky				    AC_TRY_COMPILE(
2261335640Shselasky					[
2262335640Shselasky					    #include <bluetooth/bluetooth.h>
2263335640Shselasky					    #include <bluetooth/hci.h>
2264335640Shselasky					],
2265335640Shselasky					[
2266335640Shselasky					    u_int i = HCI_CHANNEL_MONITOR;
2267335640Shselasky					],
2268335640Shselasky					[
2269335640Shselasky					    AC_MSG_RESULT(yes)
2270335640Shselasky					    AC_DEFINE(PCAP_SUPPORT_BT_MONITOR,,
2271335640Shselasky					      [target host supports Bluetooth Monitor])
2272335640Shselasky					    BT_MONITOR_SRC=pcap-bt-monitor-linux.c
2273335640Shselasky					],
2274335640Shselasky					[
2275335640Shselasky					    AC_MSG_RESULT(no)
2276335640Shselasky					]))
2277335640Shselasky			    ],,
2278335640Shselasky			    [
2279335640Shselasky				#include <bluetooth/bluetooth.h>
2280335640Shselasky				#include <bluetooth/hci.h>
2281335640Shselasky			    ])
2282335640Shselasky		    ],
2283335640Shselasky		    [
2284335640Shselasky			#
2285335640Shselasky			# We don't have bluetooth.h, so we don't support
2286335640Shselasky			# Bluetooth sniffing.
2287335640Shselasky			#
2288335640Shselasky			if test "x$enable_bluetooth" = "xyes" ; then
2289335640Shselasky				AC_MSG_ERROR(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2290335640Shselasky			else
2291335640Shselasky				AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2292335640Shselasky			fi
2293335640Shselasky		    ])
2294335640Shselasky		;;
2295335640Shselasky	*)
2296335640Shselasky		if test "x$enable_bluetooth" = "xyes" ; then
2297335640Shselasky			AC_MSG_ERROR(no Bluetooth sniffing support implemented for $host_os)
2298335640Shselasky		else
2299335640Shselasky			AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os)
2300335640Shselasky		fi
2301335640Shselasky		;;
2302335640Shselasky	esac
2303335640Shselasky	AC_SUBST(PCAP_SUPPORT_BT)
2304335640Shselasky	AC_SUBST(BT_SRC)
2305335640Shselasky	AC_SUBST(BT_MONITOR_SRC)
2306335640Shselaskyfi
2307335640Shselasky
2308335640ShselaskyAC_ARG_ENABLE([dbus],
2309335640Shselasky[AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
2310335640Shselasky    [],
2311335640Shselasky    [enable_dbus=ifavailable])
2312335640Shselasky
2313335640Shselaskyif test "xxx_only" = yes; then
2314335640Shselasky	# User requested something-else-only pcap, so they don't
2315335640Shselasky	# want D-Bus support.
2316335640Shselasky	enable_dbus=no
2317335640Shselaskyfi
2318335640Shselasky
2319335640Shselaskyif test "x$enable_dbus" != "xno"; then
2320335640Shselasky	if test "x$enable_dbus" = "xyes"; then
2321335640Shselasky		case "$host_os" in
2322335640Shselasky
2323335640Shselasky		darwin*)
2324335640Shselasky			#
2325335640Shselasky			# We don't support D-Bus sniffing on macOS; see
2326335640Shselasky			#
2327335640Shselasky			# https://bugs.freedesktop.org/show_bug.cgi?id=74029
2328335640Shselasky			#
2329335640Shselasky			# The user requested it, so fail.
2330335640Shselasky			#
2331335640Shselasky			AC_MSG_ERROR([Due to freedesktop.org bug 74029, D-Bus capture support is not available on macOS])
2332335640Shselasky		esac
2333335640Shselasky	else
2334335640Shselasky		case "$host_os" in
2335335640Shselasky
2336335640Shselasky		darwin*)
2337335640Shselasky			#
2338335640Shselasky			# We don't support D-Bus sniffing on macOS; see
2339335640Shselasky			#
2340335640Shselasky			# https://bugs.freedesktop.org/show_bug.cgi?id=74029
2341335640Shselasky			#
2342335640Shselasky			# The user dind't explicitly request it, so just
2343335640Shselasky			# silently refuse to enable it.
2344335640Shselasky			#
2345335640Shselasky			enable_dbus="no"
2346335640Shselasky			;;
2347335640Shselasky		esac
2348335640Shselasky	fi
2349335640Shselaskyfi
2350335640Shselasky
2351335640Shselaskyif test "x$enable_dbus" != "xno"; then
2352335640Shselasky	AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no])
2353335640Shselasky	if test "x$PKGCONFIG" != "xno"; then
2354335640Shselasky		AC_MSG_CHECKING([for D-Bus])
2355335640Shselasky		if "$PKGCONFIG" dbus-1; then
2356335640Shselasky			AC_MSG_RESULT([yes])
2357335640Shselasky			DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
2358335640Shselasky			DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
2359335640Shselasky			save_CFLAGS="$CFLAGS"
2360335640Shselasky			save_LIBS="$LIBS"
2361335640Shselasky			CFLAGS="$CFLAGS $DBUS_CFLAGS"
2362335640Shselasky			LIBS="$LIBS $DBUS_LIBS"
2363335640Shselasky			AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
2364335640Shselasky			AC_TRY_LINK(
2365335640Shselasky			    [#include <string.h>
2366335640Shselasky
2367335640Shselasky			     #include <time.h>
2368335640Shselasky			     #include <sys/time.h>
2369335640Shselasky
2370335640Shselasky			     #include <dbus/dbus.h>],
2371335640Shselasky			    [return dbus_connection_read_write(NULL, 0);],
2372335640Shselasky			    [
2373335640Shselasky				AC_MSG_RESULT([yes])
2374335640Shselasky				AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
2375335640Shselasky				DBUS_SRC=pcap-dbus.c
2376335640Shselasky				V_INCLS="$V_INCLS $DBUS_CFLAGS"
2377335640Shselasky			    ],
2378335640Shselasky			    [
2379335640Shselasky				AC_MSG_RESULT([no])
2380335640Shselasky				if test "x$enable_dbus" = "xyes"; then
2381335640Shselasky				    AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
2382335640Shselasky				fi
2383335640Shselasky				LIBS="$save_LIBS"
2384335640Shselasky			     ])
2385335640Shselasky			CFLAGS="$save_CFLAGS"
2386335640Shselasky		else
2387335640Shselasky			AC_MSG_RESULT([no])
2388335640Shselasky			if test "x$enable_dbus" = "xyes"; then
2389335640Shselasky				AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed])
2390335640Shselasky			fi
2391335640Shselasky		fi
2392335640Shselasky	fi
2393335640Shselasky	AC_SUBST(PCAP_SUPPORT_DBUS)
2394335640Shselasky	AC_SUBST(DBUS_SRC)
2395335640Shselaskyfi
2396335640Shselasky
2397335640ShselaskyAC_ARG_ENABLE([rdma],
2398335640Shselasky[AC_HELP_STRING([--enable-rdma],[enable RDMA capture support @<:@default=yes, if support available@:>@])],
2399335640Shselasky    [],
2400356341Scy    [enable_rdma=ifavailable])
2401335640Shselasky
2402335640Shselaskyif test "xxx_only" = yes; then
2403335640Shselasky	# User requested something-else-only pcap, so they don't
2404335640Shselasky	# want RDMA support.
2405356341Scy	enable_rdma=no
2406335640Shselaskyfi
2407335640Shselasky
2408356341Scyif test "x$enable_rdma" != "xno"; then
2409335640Shselasky	AC_CHECK_LIB(ibverbs, ibv_get_device_list, [
2410335640Shselasky		AC_CHECK_HEADER(infiniband/verbs.h, [
2411335640Shselasky			#
2412335640Shselasky			# ibv_create_flow may be defined as a static inline
2413335640Shselasky			# function in infiniband/verbs.h, so we can't
2414335640Shselasky			# use AC_CHECK_LIB.
2415335640Shselasky			#
2416335640Shselasky			# Too bad autoconf has no AC_SYMBOL_EXISTS()
2417335640Shselasky			# macro that works like CMake's check_symbol_exists()
2418335640Shselasky			# function, to check do a compile check like
2419335640Shselasky			# this (they do a clever trick to avoid having
2420335640Shselasky			# to know the function's signature).
2421335640Shselasky			#
2422335640Shselasky			AC_MSG_CHECKING(whether libibverbs defines ibv_create_flow)
2423335640Shselasky			AC_TRY_LINK(
2424335640Shselasky				[
2425335640Shselasky					#include <infiniband/verbs.h>
2426335640Shselasky				],
2427335640Shselasky				[
2428335640Shselasky					(void) ibv_create_flow((struct ibv_qp *) NULL,
2429335640Shselasky							       (struct ibv_flow_attr *) NULL);
2430335640Shselasky				],
2431335640Shselasky				[
2432335640Shselasky					AC_MSG_RESULT([yes])
2433335640Shselasky					AC_DEFINE(PCAP_SUPPORT_RDMASNIFF, , [target host supports RDMA sniffing])
2434335640Shselasky					RDMA_SRC=pcap-rdmasniff.c
2435335640Shselasky					LIBS="-libverbs $LIBS"
2436335640Shselasky				],
2437335640Shselasky				[
2438335640Shselasky					AC_MSG_RESULT([no])
2439335640Shselasky				]
2440335640Shselasky			)
2441335640Shselasky		])
2442335640Shselasky	])
2443335640Shselasky	AC_SUBST(PCAP_SUPPORT_RDMASNIFF)
2444335640Shselasky	AC_SUBST(RDMA_SRC)
2445335640Shselaskyfi
2446335640Shselasky
2447335640ShselaskyAC_PROG_INSTALL
2448335640Shselasky
2449335640ShselaskyAC_CONFIG_HEADER(config.h)
2450335640Shselasky
2451335640ShselaskyAC_OUTPUT_COMMANDS([if test -f .devel; then
2452335640Shselasky	echo timestamp > stamp-h
2453335640Shselasky	cat $srcdir/Makefile-devel-adds >> Makefile
2454335640Shselasky	make depend
2455335640Shselaskyfi])
2456335640ShselaskyAC_OUTPUT(Makefile pcap-filter.manmisc pcap-linktype.manmisc
2457335640Shselasky	pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap
2458335640Shselasky	pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap
2459335640Shselasky	pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap
2460335640Shselasky	pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap
2461356341Scy	pcap_open_offline.3pcap pcap_set_immediate_mode.3pcap
2462356341Scy	pcap_set_tstamp_precision.3pcap pcap_set_tstamp_type.3pcap
2463356341Scy	rpcapd/Makefile rpcapd/rpcapd.manadmin rpcapd/rpcapd-config.manfile
2464335640Shselasky	testprogs/Makefile)
2465335640Shselaskyexit 0
2466