]> The Tcpdump Group git mirrors - libpcap/blob - configure.ac
Expand a comment.
[libpcap] / configure.ac
1 dnl
2 dnl Copyright (c) 1994, 1995, 1996, 1997
3 dnl The Regents of the University of California. All rights reserved.
4 dnl
5 dnl Process this file with autoconf to produce a configure script.
6 dnl
7
8 #
9 # See
10 #
11 # http://ftp.gnu.org/gnu/config/README
12 #
13 # for the URLs to use to fetch new versions of config.guess and
14 # config.sub.
15 #
16
17 AC_PREREQ(2.64)
18
19 AC_INIT(pcap, m4_esyscmd_s([cat VERSION]))
20 AC_CONFIG_SRCDIR(pcap.c)
21 AC_SUBST(PACKAGE_NAME)
22
23 AC_CANONICAL_SYSTEM
24
25 AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS)
26 #
27 # Try to enable as many C99 features as we can.
28 # At minimum, we want C++/C99-style // comments.
29 #
30 AC_PROG_CC_C99
31 AC_LBL_C_INIT(V_CCOPT, V_INCLS)
32 AC_LBL_SHLIBS_INIT
33 AC_LBL_C_INLINE
34 AC_C___ATTRIBUTE__
35
36 #
37 # Try to arrange for large file support.
38 #
39 AC_SYS_LARGEFILE
40 AC_FUNC_FSEEKO
41
42 dnl
43 dnl Even if <net/bpf.h> were, on all OSes that support BPF, fixed to
44 dnl include <sys/ioccom.h>, and we were to drop support for older
45 dnl releases without that fix, so that pcap-bpf.c doesn't need to
46 dnl include <sys/ioccom.h>, the test program in "AC_LBL_FIXINCLUDES"
47 dnl in "aclocal.m4" uses it, so we would still have to test for it
48 dnl and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
49 dnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris.
50 dnl
51 AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h limits.h)
52 AC_CHECK_HEADERS(netpacket/packet.h)
53 AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
54 #include <sys/socket.h>
55 #include <net/if.h>])
56 if test "$ac_cv_header_net_pfvar_h" = yes; then
57 #
58 # Check for various PF actions.
59 #
60 AC_MSG_CHECKING(whether net/pfvar.h defines PF_NAT through PF_NORDR)
61 AC_TRY_COMPILE(
62 [#include <sys/types.h>
63 #include <sys/socket.h>
64 #include <net/if.h>
65 #include <net/pfvar.h>],
66 [return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR;],
67 [
68 AC_MSG_RESULT(yes)
69 AC_DEFINE(HAVE_PF_NAT_THROUGH_PF_NORDR, 1,
70 [define if net/pfvar.h defines PF_NAT through PF_NORDR])
71 ],
72 AC_MSG_RESULT(no))
73 fi
74
75 case "$host_os" in
76 linux*|uclinux*)
77 AC_CHECK_HEADERS(linux/sockios.h linux/if_bonding.h,,,
78 [
79 #include <sys/socket.h>
80 #include <linux/if.h>
81 ])
82 ;;
83 esac
84
85 AC_LBL_FIXINCLUDES
86
87 AC_CHECK_FUNCS(strerror strerror_r strlcpy strlcat)
88
89 needsnprintf=no
90 AC_CHECK_FUNCS(vsnprintf snprintf,,
91 [needsnprintf=yes])
92 if test $needsnprintf = yes; then
93 AC_LIBOBJ([snprintf])
94 fi
95
96 needstrtok_r=no
97 AC_CHECK_FUNCS(strtok_r,,
98 [needstrtok_r=yes])
99 if test $needstrtok_r = yes; then
100 AC_LIBOBJ([strtok_r])
101 fi
102
103 #
104 # Do we have ffs(), and is it declared in <strings.h>?
105 #
106 AC_CHECK_FUNCS(ffs)
107 if test "$ac_cv_func_ffs" = yes; then
108 #
109 # We have ffs(); is it declared in <strings.h>?
110 #
111 # This test fails if we don't have <strings.h> or if we do
112 # but it doesn't declare ffs().
113 #
114 AC_CHECK_DECL(ffs,
115 [
116 AC_DEFINE(STRINGS_H_DECLARES_FFS,,
117 [Define to 1 if strings.h declares `ffs'])
118 ],,
119 [
120 #include <strings.h>
121 ])
122 fi
123
124 #
125 # Do this before checking for ether_hostton(), as it's a
126 # "gethostbyname() -ish function".
127 #
128 AC_LBL_LIBRARY_NET
129
130 #
131 # You are in a twisty little maze of UN*Xes, all different.
132 # Some might not have ether_hostton().
133 # Some might have it and declare it in <net/ethernet.h>.
134 # Some might have it and declare it in <netinet/ether.h>
135 # Some might have it and declare it in <sys/ethernet.h>.
136 # Some might have it and declare it in <arpa/inet.h>.
137 # Some might have it and declare it in <netinet/if_ether.h>.
138 # Some might have it and not declare it in any header file.
139 #
140 # Before you is a C compiler.
141 #
142 AC_CHECK_FUNCS(ether_hostton)
143 if test "$ac_cv_func_ether_hostton" = yes; then
144 #
145 # OK, we have ether_hostton(). Is it declared in <net/ethernet.h>?
146 #
147 # This test fails if we don't have <net/ethernet.h> or if we do
148 # but it doesn't declare ether_hostton().
149 #
150 AC_CHECK_DECL(ether_hostton,
151 [
152 AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_HOSTTON,,
153 [Define to 1 if net/ethernet.h declares `ether_hostton'])
154 ],,
155 [
156 #include <net/ethernet.h>
157 ])
158 #
159 # Did that succeed?
160 #
161 if test "$ac_cv_have_decl_ether_hostton" != yes; then
162 #
163 # No, how about <netinet/ether.h>, as on Linux?
164 #
165 # This test fails if we don't have <netinet/ether.h>
166 # or if we do but it doesn't declare ether_hostton().
167 #
168 # Unset ac_cv_have_decl_ether_hostton so we don't
169 # treat the previous failure as a cached value and
170 # suppress the next test.
171 #
172 unset ac_cv_have_decl_ether_hostton
173 AC_CHECK_DECL(ether_hostton,
174 [
175 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON,,
176 [Define to 1 if netinet/ether.h declares `ether_hostton'])
177 ],,
178 [
179 #include <netinet/ether.h>
180 ])
181 fi
182 #
183 # Did that succeed?
184 #
185 if test "$ac_cv_have_decl_ether_hostton" != yes; then
186 #
187 # No, how about <sys/ethernet.h>, as on Solaris 10
188 # and later?
189 #
190 # This test fails if we don't have <sys/ethernet.h>
191 # or if we do but it doesn't declare ether_hostton().
192 #
193 # Unset ac_cv_have_decl_ether_hostton so we don't
194 # treat the previous failure as a cached value and
195 # suppress the next test.
196 #
197 unset ac_cv_have_decl_ether_hostton
198 AC_CHECK_DECL(ether_hostton,
199 [
200 AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON,,
201 [Define to 1 if sys/ethernet.h declares `ether_hostton'])
202 ],,
203 [
204 #include <sys/ethernet.h>
205 ])
206 fi
207 #
208 # Did that succeed?
209 #
210 if test "$ac_cv_have_decl_ether_hostton" != yes; then
211 #
212 # No, how about <arpa/inet.h>, as in AIX?
213 #
214 # This test fails if we don't have <arpa/inet.h>
215 # (if we have ether_hostton(), we should have
216 # networking, and if we have networking, we should
217 # have <arapa/inet.h>) or if we do but it doesn't
218 # declare ether_hostton().
219 #
220 # Unset ac_cv_have_decl_ether_hostton so we don't
221 # treat the previous failure as a cached value and
222 # suppress the next test.
223 #
224 unset ac_cv_have_decl_ether_hostton
225 AC_CHECK_DECL(ether_hostton,
226 [
227 AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_HOSTTON,,
228 [Define to 1 if arpa/inet.h declares `ether_hostton'])
229 ],,
230 [
231 #include <arpa/inet.h>
232 ])
233 fi
234 #
235 # Did that succeed?
236 #
237 if test "$ac_cv_have_decl_ether_hostton" != yes; then
238 #
239 # No, how about <netinet/if_ether.h>?
240 # On some platforms, it requires <net/if.h> and
241 # <netinet/in.h>, and we always include it with
242 # both of them, so test it with both of them.
243 #
244 # This test fails if we don't have <netinet/if_ether.h>
245 # and the headers we include before it, or if we do but
246 # <netinet/if_ether.h> doesn't declare ether_hostton().
247 #
248 # Unset ac_cv_have_decl_ether_hostton so we don't
249 # treat the previous failure as a cached value and
250 # suppress the next test.
251 #
252 unset ac_cv_have_decl_ether_hostton
253 AC_CHECK_DECL(ether_hostton,
254 [
255 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON,,
256 [Define to 1 if netinet/if_ether.h declares `ether_hostton'])
257 ],,
258 [
259 #include <sys/types.h>
260 #include <sys/socket.h>
261 #include <net/if.h>
262 #include <netinet/in.h>
263 #include <netinet/if_ether.h>
264 ])
265 fi
266 #
267 # After all that, is ether_hostton() declared?
268 #
269 if test "$ac_cv_have_decl_ether_hostton" = yes; then
270 #
271 # Yes.
272 #
273 AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1,
274 [Define to 1 if you have the declaration of `ether_hostton'])
275 else
276 #
277 # No, we'll have to declare it ourselves.
278 # Do we have "struct ether_addr" if we include
279 # <netinet/if_ether.h>?
280 #
281 AC_CHECK_TYPES(struct ether_addr,,,
282 [
283 #include <sys/types.h>
284 #include <sys/socket.h>
285 #include <net/if.h>
286 #include <netinet/in.h>
287 #include <netinet/if_ether.h>
288 ])
289 fi
290 fi
291
292 #
293 # For various things that might use pthreads.
294 #
295 AC_CHECK_HEADER(pthread.h,
296 [
297 #
298 # OK, we have pthread.h. Do we have pthread_create in the
299 # system libraries?
300 #
301 AC_CHECK_FUNC(pthread_create,
302 [
303 #
304 # Yes.
305 #
306 ac_lbl_have_pthreads="found"
307 ],
308 [
309 #
310 # No - do we have it in -lpthreads?
311 #
312 AC_CHECK_LIB(pthreads, pthread_create,
313 [
314 #
315 # Yes - add -lpthreads.
316 #
317 ac_lbl_have_pthreads="found"
318 PTHREAD_LIBS="$PTHREAD_LIBS -lpthreads"
319 ],
320 [
321 #
322 # No - do we have it in -lpthread?
323 #
324 AC_CHECK_LIB(pthread, pthread_create,
325 [
326 #
327 # Yes - add -lpthread.
328 #
329 ac_lbl_have_pthreads="found"
330 PTHREAD_LIBS="$PTHREAD_LIBS -lpthread"
331 ],
332 [
333 #
334 # No.
335 #
336 ac_lbl_have_pthreads="not found"
337 ])
338 ])
339 ])
340 ],
341 [
342 #
343 # We didn't find pthread.h.
344 #
345 ac_lbl_have_pthreads="not found"
346 ]
347 )
348
349 dnl to pacify those who hate protochain insn
350 AC_MSG_CHECKING(if --disable-protochain option is specified)
351 AC_ARG_ENABLE(protochain,
352 AC_HELP_STRING([--disable-protochain],[disable \"protochain\" insn]))
353 case "x$enable_protochain" in
354 xyes) enable_protochain=enabled ;;
355 xno) enable_protochain=disabled ;;
356 x) enable_protochain=enabled ;;
357 esac
358
359 if test "$enable_protochain" = "disabled"; then
360 AC_DEFINE(NO_PROTOCHAIN,1,[do not use protochain])
361 fi
362 AC_MSG_RESULT(${enable_protochain})
363
364 #
365 # valgrindtest directly uses the native capture mechanism, but
366 # only tests with BPF and PF_PACKET sockets; only enable it if
367 # we have BPF or PF_PACKET sockets.
368 #
369 VALGRINDTEST=
370
371 #
372 # SITA support is mutually exclusive with native capture support;
373 # "--with-sita" selects SITA support.
374 #
375 AC_ARG_WITH(sita,
376 AC_HELP_STRING([--with-sita],[include SITA support]),
377 [
378 if test ! "x$withval" = "xno" ; then
379 AC_DEFINE(SITA,1,[include ACN support])
380 AC_MSG_NOTICE(Enabling SITA ACN support)
381 V_PCAP=sita
382 fi
383 ],
384 [
385 AC_ARG_WITH(pcap,
386 AC_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE]))
387 if test ! -z "$with_pcap" ; then
388 V_PCAP="$withval"
389 else
390 #
391 # Check for a bunch of headers for various packet
392 # capture mechanisms.
393 #
394 AC_CHECK_HEADERS(net/bpf.h)
395 if test "$ac_cv_header_net_bpf_h" = yes; then
396 #
397 # Does it define BIOCSETIF?
398 # I.e., is it a header for an LBL/BSD-style capture
399 # mechanism, or is it just a header for a BPF filter
400 # engine? Some versions of Arch Linux, for example,
401 # have a net/bpf.h that doesn't define BIOCSETIF;
402 # as it's a Linux, it should use packet sockets,
403 # instead.
404 #
405 # We need:
406 #
407 # sys/types.h, because FreeBSD 10's net/bpf.h
408 # requires that various BSD-style integer types
409 # be defined;
410 #
411 # sys/ioctl.h and, if we have it, sys/ioccom.h,
412 # because net/bpf.h defines ioctls;
413 #
414 # net/if.h, because it defines some structures
415 # used in ioctls defined by net/bpf.h;
416 #
417 # sys/socket.h, because OpenBSD 5.9's net/bpf.h
418 # defines some structure fields as being
419 # struct sockaddrs;
420 #
421 # and net/bpf.h doesn't necessarily include all
422 # of those headers itself.
423 #
424 AC_MSG_CHECKING(if net/bpf.h defines BIOCSETIF)
425 AC_CACHE_VAL(ac_cv_lbl_bpf_h_defines_biocsetif,
426 AC_TRY_COMPILE(
427 [
428 #include <sys/types.h>
429 #include <sys/ioctl.h>
430 #include <sys/socket.h>
431 #ifdef HAVE_SYS_IOCCOM_H
432 #include <sys/ioccom.h>
433 #endif
434 #include <net/bpf.h>
435 #include <net/if.h>
436 ],
437 [u_int i = BIOCSETIF;],
438 ac_cv_lbl_bpf_h_defines_biocsetif=yes,
439 ac_cv_lbl_bpf_h_defines_biocsetif=no))
440 AC_MSG_RESULT($ac_cv_lbl_bpf_h_defines_biocsetif)
441 fi
442 AC_CHECK_HEADERS(net/pfilt.h net/enet.h)
443 AC_CHECK_HEADERS(net/nit.h sys/net/nit.h)
444 AC_CHECK_HEADERS(linux/socket.h net/raw.h sys/dlpi.h)
445
446 if test "$ac_cv_lbl_bpf_h_defines_biocsetif" = yes; then
447 #
448 # BPF.
449 # Check this before DLPI, so that we pick BPF on
450 # Solaris 11 and later.
451 #
452 V_PCAP=bpf
453
454 #
455 # We have BPF, so build valgrindtest with "make test"
456 # on macOS, FreeBSD, and Linux (add your OS once
457 # there's a valgrind for it).
458 #
459 case "$host_os" in
460
461 freebsd*|darwin*|linux*)
462 VALGRINDTEST=valgrindtest
463 ;;
464 esac
465 elif test "$ac_cv_header_linux_socket_h" = yes; then
466 #
467 # No prizes for guessing this one.
468 #
469 V_PCAP=linux
470
471 #
472 # XXX - this won't work with older kernels that have
473 # SOCK_PACKET sockets but not PF_PACKET sockets.
474 #
475 VALGRINDTEST=valgrindtest
476 elif test "$ac_cv_header_net_pfilt_h" = yes; then
477 #
478 # DEC OSF/1, Digital UNIX, Tru64 UNIX
479 #
480 V_PCAP=pf
481 elif test "$ac_cv_header_net_enet_h" = yes; then
482 #
483 # Stanford Enetfilter.
484 #
485 V_PCAP=enet
486 elif test "$ac_cv_header_net_nit_h" = yes; then
487 #
488 # SunOS 4.x STREAMS NIT.
489 #
490 V_PCAP=snit
491 elif test "$ac_cv_header_sys_net_nit_h" = yes; then
492 #
493 # Pre-SunOS 4.x non-STREAMS NIT.
494 #
495 V_PCAP=nit
496 elif test "$ac_cv_header_net_raw_h" = yes; then
497 #
498 # IRIX snoop.
499 #
500 V_PCAP=snoop
501 elif test "$ac_cv_header_sys_dlpi_h" = yes; then
502 #
503 # DLPI on pre-Solaris 11 SunOS 5, HP-UX, possibly others.
504 #
505 V_PCAP=dlpi
506 else
507 #
508 # Nothing we support.
509 #
510 V_PCAP=null
511 AC_MSG_WARN(cannot determine packet capture interface)
512 AC_MSG_WARN((see the INSTALL doc for more info))
513 fi
514 fi
515 AC_MSG_CHECKING(packet capture type)
516 AC_MSG_RESULT($V_PCAP)
517 AC_SUBST(VALGRINDTEST)
518
519 #
520 # Do capture-mechanism-dependent tests.
521 #
522 case "$V_PCAP" in
523 dlpi)
524 #
525 # Needed for common functions used by pcap-[dlpi,libdlpi].c
526 #
527 SSRC="dlpisubs.c"
528
529 #
530 # Checks for some header files.
531 #
532 AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
533
534 #
535 # Checks to see if Solaris has the public libdlpi(3LIB) library.
536 # Note: The existence of /usr/include/libdlpi.h does not mean it is the
537 # public libdlpi(3LIB) version. Before libdlpi was made public, a
538 # private version also existed, which did not have the same APIs.
539 # Due to a gcc bug, the default search path for 32-bit libraries does
540 # not include /lib, we add it explicitly here.
541 # [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485].
542 # Also, due to the bug above applications that link to libpcap with
543 # libdlpi will have to add "-L/lib" option to "configure".
544 #
545 saved_ldflags=$LDFLAGS
546 LDFLAGS="$LIBS -L/lib"
547 AC_CHECK_LIB(dlpi, dlpi_walk,
548 [
549 LIBS="-ldlpi $LIBS"
550 V_PCAP=libdlpi
551 AC_DEFINE(HAVE_LIBDLPI,1,[if libdlpi exists])
552 ],
553 V_PCAP=dlpi)
554 LDFLAGS=$saved_ldflags
555
556 #
557 # Checks whether <sys/dlpi.h> is usable, to catch weird SCO
558 # versions of DLPI.
559 #
560 AC_MSG_CHECKING(whether <sys/dlpi.h> is usable)
561 AC_CACHE_VAL(ac_cv_sys_dlpi_usable,
562 AC_TRY_COMPILE(
563 [
564 #include <sys/types.h>
565 #include <sys/time.h>
566 #include <sys/dlpi.h>
567 ],
568 [int i = DL_PROMISC_PHYS;],
569 ac_cv_sys_dlpi_usable=yes,
570 ac_cv_sys_dlpi_usable=no))
571 AC_MSG_RESULT($ac_cv_sys_dlpi_usable)
572 if test $ac_cv_sys_dlpi_usable = no ; then
573 AC_MSG_ERROR(<sys/dlpi.h> is not usable on this system; it probably has a non-standard DLPI)
574 fi
575
576 #
577 # This check is for Solaris with DLPI support for passive modes.
578 # See dlpi(7P) for more details.
579 #
580 AC_LBL_DL_PASSIVE_REQ_T
581 ;;
582
583 linux)
584 #
585 # Do we have the wireless extensions?
586 #
587 AC_CHECK_HEADERS(linux/wireless.h, [], [],
588 [
589 #include <sys/socket.h>
590 #include <linux/if.h>
591 #include <linux/types.h>
592 ])
593
594 #
595 # Do we have libnl?
596 #
597 AC_ARG_WITH(libnl,
598 AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]),
599 with_libnl=$withval,with_libnl=if_available)
600
601 if test x$with_libnl != xno ; then
602 have_any_nl="no"
603
604 incdir=-I/usr/include/libnl3
605 libnldir=
606 case "$with_libnl" in
607
608 yes|if_available)
609 ;;
610
611 *)
612 if test -d $withval; then
613 libnldir=-L${withval}/lib/.libs
614 incdir=-I${withval}/include
615 fi
616 ;;
617 esac
618
619 #
620 # Try libnl 3.x first.
621 #
622 AC_CHECK_LIB(nl-3, nl_socket_alloc,
623 [
624 #
625 # Yes, we have libnl 3.x.
626 #
627 LIBS="${libnldir} -lnl-genl-3 -lnl-3 $LIBS"
628 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
629 AC_DEFINE(HAVE_LIBNL_3_x,1,[if libnl exists and is version 3.x])
630 AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
631 AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
632 V_INCLS="$V_INCLS ${incdir}"
633 have_any_nl="yes"
634 ],[], ${incdir} ${libnldir} -lnl-genl-3 -lnl-3 )
635
636 if test x$have_any_nl = xno ; then
637 #
638 # Try libnl 2.x
639 #
640 AC_CHECK_LIB(nl, nl_socket_alloc,
641 [
642 #
643 # Yes, we have libnl 2.x.
644 #
645 LIBS="${libnldir} -lnl-genl -lnl $LIBS"
646 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
647 AC_DEFINE(HAVE_LIBNL_2_x,1,[if libnl exists and is version 2.x])
648 AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
649 AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
650 have_any_nl="yes"
651 ])
652 fi
653
654 if test x$have_any_nl = xno ; then
655 #
656 # No, we don't; do we have libnl 1.x?
657 #
658 AC_CHECK_LIB(nl, nl_handle_alloc,
659 [
660 #
661 # Yes.
662 #
663 LIBS="${libnldir} -lnl $LIBS"
664 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
665 have_any_nl="yes"
666 ])
667 fi
668
669 if test x$have_any_nl = xno ; then
670 #
671 # No, we don't have libnl at all.
672 #
673 if test x$with_libnl = xyes ; then
674 AC_MSG_ERROR([libnl support requested but libnl not found])
675 fi
676 fi
677 fi
678
679 AC_CHECK_HEADERS(linux/ethtool.h,,,
680 [
681 AC_INCLUDES_DEFAULT
682 #include <linux/types.h>
683 ])
684 AC_LBL_TPACKET_STATS
685 AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI
686 ;;
687
688 bpf)
689 #
690 # Check whether we have the *BSD-style ioctls.
691 #
692 AC_CHECK_HEADERS(net/if_media.h)
693
694 #
695 # Check whether we have struct BPF_TIMEVAL.
696 #
697 AC_CHECK_TYPES(struct BPF_TIMEVAL,,,
698 [
699 #include <sys/types.h>
700 #include <sys/ioctl.h>
701 #ifdef HAVE_SYS_IOCCOM_H
702 #include <sys/ioccom.h>
703 #endif
704 #include <net/bpf.h>
705 ])
706 ;;
707
708 dag)
709 #
710 # --with-pcap=dag is the only way to get here, and it means
711 # "DAG support but nothing else"
712 #
713 V_DEFS="$V_DEFS -DDAG_ONLY"
714 xxx_only=yes
715 ;;
716
717 septel)
718 #
719 # --with-pcap=septel is the only way to get here, and it means
720 # "Septel support but nothing else"
721 #
722 V_DEFS="$V_DEFS -DSEPTEL_ONLY"
723 xxx_only=yes
724 ;;
725
726 snf)
727 #
728 # --with-pcap=snf is the only way to get here, and it means
729 # "SNF support but nothing else"
730 #
731 V_DEFS="$V_DEFS -DSNF_ONLY"
732 xxx_only=yes
733 ;;
734
735 null)
736 ;;
737
738 *)
739 AC_MSG_ERROR($V_PCAP is not a valid pcap type)
740 ;;
741 esac
742
743 dnl
744 dnl Now figure out how we get a list of interfaces and addresses,
745 dnl if we support capturing. Don't bother if we don't support
746 dnl capturing.
747 dnl
748 if test "$V_PCAP" != null
749 then
750 AC_CHECK_FUNC(getifaddrs,[
751 #
752 # We have "getifaddrs()"; make sure we have <ifaddrs.h>
753 # as well, just in case some platform is really weird.
754 #
755 AC_CHECK_HEADER(ifaddrs.h,[
756 #
757 # We have the header, so we use "getifaddrs()" to
758 # get the list of interfaces.
759 #
760 V_FINDALLDEVS=fad-getad.c
761 ],[
762 #
763 # We don't have the header - give up.
764 # XXX - we could also fall back on some other
765 # mechanism, but, for now, this'll catch this
766 # problem so that we can at least try to figure
767 # out something to do on systems with "getifaddrs()"
768 # but without "ifaddrs.h", if there is something
769 # we can do on those systems.
770 #
771 AC_MSG_ERROR([Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>.])
772 ])
773 ],[
774 #
775 # Well, we don't have "getifaddrs()", at least not with the
776 # libraries with which we've decided we need to link
777 # libpcap with, so we have to use some other mechanism.
778 #
779 # Note that this may happen on Solaris, which has
780 # getifaddrs(), but in -lsocket, not in -lxnet, so we
781 # won't find it if we link with -lxnet, which we want
782 # to do for other reasons.
783 #
784 # For now, we use either the SIOCGIFCONF ioctl or the
785 # SIOCGLIFCONF ioctl, preferring the latter if we have
786 # it; the latter is a Solarisism that first appeared
787 # in Solaris 8. (Solaris's getifaddrs() appears to
788 # be built atop SIOCGLIFCONF; using it directly
789 # avoids a not-all-that-useful middleman.)
790 #
791 AC_MSG_CHECKING(whether we have SIOCGLIFCONF)
792 AC_CACHE_VAL(ac_cv_lbl_have_siocglifconf,
793 AC_TRY_COMPILE(
794 [#include <sys/param.h>
795 #include <sys/file.h>
796 #include <sys/ioctl.h>
797 #include <sys/socket.h>
798 #include <sys/sockio.h>],
799 [ioctl(0, SIOCGLIFCONF, (char *)0);],
800 ac_cv_lbl_have_siocglifconf=yes,
801 ac_cv_lbl_have_siocglifconf=no))
802 AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
803 if test $ac_cv_lbl_have_siocglifconf = yes ; then
804 V_FINDALLDEVS=fad-glifc.c
805 else
806 V_FINDALLDEVS=fad-gifc.c
807 fi
808 ])
809 fi
810 ])
811
812 dnl check for hardware timestamp support
813 case "$host_os" in
814 linux*)
815 AC_CHECK_HEADERS([linux/net_tstamp.h])
816 ;;
817 *)
818 AC_MSG_NOTICE(no hardware timestamp support implemented for $host_os)
819 ;;
820 esac
821
822 AC_ARG_ENABLE([packet-ring],
823 [AC_HELP_STRING([--enable-packet-ring],[enable Linux packet ring support @<:@default=yes@:>@])],
824 ,enable_packet_ring=yes)
825
826 if test "x$enable_packet_ring" != "xno" ; then
827 AC_DEFINE(PCAP_SUPPORT_PACKET_RING, 1, [use Linux packet ring capture if available])
828 AC_SUBST(PCAP_SUPPORT_PACKET_RING)
829 fi
830
831 AC_MSG_CHECKING(for socklen_t)
832 AC_TRY_COMPILE([
833 #include <sys/types.h>
834 #include <sys/socket.h>
835 ],
836 [ socklen_t x; ],
837 have_socklen_t=yes,
838 have_socklen_t=no)
839 if test "x$have_socklen_t" = "xyes"; then
840 AC_DEFINE(HAVE_SOCKLEN_T, 1, [define if socklen_t is defined])
841 fi
842 AC_MSG_RESULT($have_socklen_t)
843
844 AC_ARG_ENABLE(ipv6,
845 AC_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes, if getaddrinfo available@:>@]),
846 [],
847 [enable_ipv6=ifavailable])
848 if test "$enable_ipv6" != "no"; then
849 AC_CHECK_FUNC(getaddrinfo,
850 [
851 AC_DEFINE(INET6,1,[IPv6])
852 ],
853 [
854 if test "$enable_ipv6" != "ifavailable"; then
855 AC_MSG_FAILURE([--enable-ipv6 was given, but getaddrinfo isn't available])
856 fi
857 ])
858 fi
859
860 # Check for Endace DAG card support.
861 AC_ARG_WITH([dag],
862 AC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
863 [
864 if test "$withval" = no
865 then
866 # User doesn't want DAG support.
867 want_dag=no
868 elif test "$withval" = yes
869 then
870 # User wants DAG support but hasn't specified a directory.
871 want_dag=yes
872 else
873 # User wants DAG support and has specified a directory, so use the provided value.
874 want_dag=yes
875 dag_root=$withval
876 fi
877 ],[
878 if test "$V_PCAP" = dag; then
879 # User requested DAG-only libpcap, so we'd better have
880 # the DAG API.
881 want_dag=yes
882 elif test "xxx_only" = yes; then
883 # User requested something-else-only pcap, so they don't
884 # want DAG support.
885 want_dag=no
886 else
887 #
888 # Use DAG API if present, otherwise don't
889 #
890 want_dag=ifpresent
891 fi
892 ])
893
894 AC_ARG_WITH([dag-includes],
895 AC_HELP_STRING([--with-dag-includes=IDIR],[Endace DAG include directory, if not DIR/include]),
896 [
897 # User wants DAG support and has specified a header directory, so use the provided value.
898 want_dag=yes
899 dag_include_dir=$withval
900 ],[])
901
902 AC_ARG_WITH([dag-libraries],
903 AC_HELP_STRING([--with-dag-libraries=LDIR],[Endace DAG library directory, if not DIR/lib]),
904 [
905 # User wants DAG support and has specified a library directory, so use the provided value.
906 want_dag=yes
907 dag_lib_dir=$withval
908 ],[])
909
910 ac_cv_lbl_dag_api=no
911 if test "$want_dag" != no; then
912
913 AC_MSG_CHECKING([whether we have DAG API headers])
914
915 # If necessary, set default paths for DAG API headers and libraries.
916 if test -z "$dag_root"; then
917 dag_root=/usr/local
918 fi
919
920 if test -z "$dag_include_dir"; then
921 dag_include_dir="$dag_root/include"
922 fi
923
924 if test -z "$dag_lib_dir"; then
925 dag_lib_dir="$dag_root/lib"
926 fi
927
928 if test -z "$dag_tools_dir"; then
929 dag_tools_dir="$dag_root/tools"
930 fi
931
932 if test -r $dag_include_dir/dagapi.h; then
933 ac_cv_lbl_dag_api=yes
934 fi
935
936 if test "$ac_cv_lbl_dag_api" = yes; then
937 AC_MSG_RESULT([yes ($dag_include_dir)])
938
939 V_INCLS="$V_INCLS -I$dag_include_dir"
940
941 if test $V_PCAP != dag ; then
942 SSRC="$SSRC pcap-dag.c"
943 fi
944
945 # Check for various DAG API functions.
946 # Don't need to save and restore LIBS to prevent -ldag being
947 # included if there's a found-action (arg 3).
948 saved_ldflags=$LDFLAGS
949 LDFLAGS="-L$dag_lib_dir"
950 AC_CHECK_LIB([dag], [dag_attach_stream],
951 [],
952 [AC_MSG_ERROR(DAG library lacks streams support)])
953 AC_CHECK_LIB([dag], [dag_attach_stream64], [dag_large_streams="1"], [dag_large_streams="0"])
954 AC_CHECK_LIB([dag],[dag_get_erf_types], [
955 AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])])
956 AC_CHECK_LIB([dag],[dag_get_stream_erf_types], [
957 AC_DEFINE(HAVE_DAG_GET_STREAM_ERF_TYPES, 1, [define if you have dag_get_stream_erf_types()])])
958
959 LDFLAGS=$saved_ldflags
960
961 LIBS="$LIBS -ldag"
962 LDFLAGS="$LDFLAGS -L$dag_lib_dir"
963
964 if test "$dag_large_streams" = 1; then
965 AC_DEFINE(HAVE_DAG_LARGE_STREAMS_API, 1, [define if you have large streams capable DAG API])
966 AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"])
967 if test "$ac_dag_have_vdag" = 1; then
968 AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()])
969 if test "$ac_lbl_have_pthreads" != "found"; then
970 AC_MSG_ERROR([DAG requires pthreads, but we didn't find them])
971 fi
972 LIBS="$LIBS $PTHREAD_LIBS"
973 fi
974 fi
975
976 AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
977 else
978 AC_MSG_RESULT(no)
979
980 if test "$V_PCAP" = dag; then
981 # User requested "dag" capture type but we couldn't
982 # find the DAG API support.
983 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])
984 fi
985
986 if test "$want_dag" = yes; then
987 # User wanted DAG support but we couldn't find it.
988 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])
989 fi
990 fi
991 fi
992
993 AC_ARG_WITH(septel,
994 AC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
995 [
996 if test "$withval" = no
997 then
998 want_septel=no
999 elif test "$withval" = yes
1000 then
1001 want_septel=yes
1002 septel_root=
1003 else
1004 want_septel=yes
1005 septel_root=$withval
1006 fi
1007 ],[
1008 if test "$V_PCAP" = septel; then
1009 # User requested Septel-only libpcap, so we'd better have
1010 # the Septel API.
1011 want_septel=yes
1012 elif test "xxx_only" = yes; then
1013 # User requested something-else-only pcap, so they don't
1014 # want Septel support.
1015 want_septel=no
1016 else
1017 #
1018 # Use Septel API if present, otherwise don't
1019 #
1020 want_septel=ifpresent
1021 fi
1022 ])
1023
1024 ac_cv_lbl_septel_api=no
1025 if test "$with_septel" != no; then
1026
1027 AC_MSG_CHECKING([whether we have Septel API headers])
1028
1029 # If necessary, set default paths for Septel API headers and libraries.
1030 if test -z "$septel_root"; then
1031 septel_root=$srcdir/../septel
1032 fi
1033
1034 septel_tools_dir="$septel_root"
1035 septel_include_dir="$septel_root/INC"
1036
1037 if test -r "$septel_include_dir/msg.h"; then
1038 ac_cv_lbl_septel_api=yes
1039 fi
1040
1041 if test "$ac_cv_lbl_septel_api" = yes; then
1042 AC_MSG_RESULT([yes ($septel_include_dir)])
1043
1044 V_INCLS="$V_INCLS -I$septel_include_dir"
1045 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"
1046 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"
1047
1048 if test "$V_PCAP" != septel ; then
1049 SSRC="$SSRC pcap-septel.c"
1050 fi
1051
1052 AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have the Septel API])
1053 else
1054 AC_MSG_RESULT(no)
1055
1056 if test "$V_PCAP" = septel; then
1057 # User requested "septel" capture type but
1058 # we couldn't find the Septel API support.
1059 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])
1060 fi
1061
1062 if test "$want_septel" = yes; then
1063 # User wanted Septel support but we couldn't find it.
1064 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])
1065 fi
1066 fi
1067 fi
1068
1069 # Check for Myricom SNF support.
1070 AC_ARG_WITH([snf],
1071 AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1072 [
1073 if test "$withval" = no
1074 then
1075 # User explicitly doesn't want SNF
1076 want_snf=no
1077 elif test "$withval" = yes
1078 then
1079 # User wants SNF support but hasn't specified a directory.
1080 want_snf=yes
1081 else
1082 # User wants SNF support with a specified directory.
1083 want_snf=yes
1084 snf_root=$withval
1085 fi
1086 ],[
1087 if test "$V_PCAP" = snf; then
1088 # User requested Sniffer-only libpcap, so we'd better have
1089 # the Sniffer API.
1090 want_snf=yes
1091 elif test "xxx_only" = yes; then
1092 # User requested something-else-only pcap, so they don't
1093 # want SNF support.
1094 want_snf=no
1095 else
1096 #
1097 # Use Sniffer API if present, otherwise don't
1098 #
1099 want_snf=ifpresent
1100 fi
1101 ])
1102
1103 AC_ARG_WITH([snf-includes],
1104 AC_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not DIR/include]),
1105 [
1106 # User wants SNF with specific header directory
1107 want_snf=yes
1108 snf_include_dir=$withval
1109 ],[])
1110
1111 AC_ARG_WITH([snf-libraries],
1112 AC_HELP_STRING([--with-snf-libraries=LDIR],[Myricom SNF library directory, if not DIR/lib]),
1113 [
1114 # User wants SNF with specific lib directory
1115 want_snf=yes
1116 snf_lib_dir=$withval
1117 ],[])
1118
1119 ac_cv_lbl_snf_api=no
1120 if test "$with_snf" != no; then
1121
1122 AC_MSG_CHECKING(whether we have Myricom Sniffer API)
1123
1124 # If necessary, set default paths for Sniffer headers and libraries.
1125 if test -z "$snf_root"; then
1126 snf_root=/opt/snf
1127 fi
1128
1129 if test -z "$snf_include_dir"; then
1130 snf_include_dir="$snf_root/include"
1131 fi
1132
1133 if test -z "$snf_lib_dir"; then
1134 snf_lib_dir="$snf_root/lib"
1135 fi
1136
1137 if test -f "$snf_include_dir/snf.h"; then
1138 # We found a header; make sure we can link with the library
1139 saved_ldflags=$LDFLAGS
1140 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1141 AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"])
1142 LDFLAGS="$saved_ldflags"
1143 if test "$ac_cv_lbl_snf_api" = no; then
1144 AC_MSG_ERROR(SNF API cannot correctly be linked; check config.log)
1145 fi
1146 fi
1147
1148 if test "$ac_cv_lbl_snf_api" = yes; then
1149 AC_MSG_RESULT([yes ($snf_root)])
1150
1151 V_INCLS="$V_INCLS -I$snf_include_dir"
1152 LIBS="$LIBS -lsnf"
1153 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1154
1155 if test "$V_PCAP" != snf ; then
1156 SSRC="$SSRC pcap-snf.c"
1157 fi
1158
1159 AC_DEFINE(HAVE_SNF_API, 1, [define if you have the Myricom SNF API])
1160 else
1161 AC_MSG_RESULT(no)
1162
1163 if test "$want_snf" = yes; then
1164 # User requested "snf" capture type but
1165 # we couldn't find the Sniffer API support.
1166 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])
1167 fi
1168
1169 if test "$want_snf" = yes; then
1170 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])
1171 fi
1172 fi
1173 fi
1174
1175 # Check for Riverbed TurboCap support.
1176 AC_ARG_WITH([turbocap],
1177 AC_HELP_STRING([--with-turbocap@<:@=DIR@:>@],[include Riverbed TurboCap support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1178 [
1179 if test "$withval" = no
1180 then
1181 # User explicitly doesn't want TurboCap
1182 want_turbocap=no
1183 elif test "$withval" = yes
1184 then
1185 # User wants TurboCap support but hasn't specified a directory.
1186 want_turbocap=yes
1187 else
1188 # User wants TurboCap support with a specified directory.
1189 want_turbocap=yes
1190 turbocap_root=$withval
1191 fi
1192 ],[
1193 if test "xxx_only" = yes; then
1194 # User requested something-else-only pcap, so they don't
1195 # want TurboCap support.
1196 want_turbocap=no
1197 else
1198 #
1199 # Use TurboCap API if present, otherwise don't
1200 #
1201 want_turbocap=ifpresent
1202 fi
1203 ])
1204
1205 ac_cv_lbl_turbocap_api=no
1206 if test "$want_turbocap" != no; then
1207
1208 AC_MSG_CHECKING(whether TurboCap is supported)
1209
1210 save_CFLAGS="$CFLAGS"
1211 save_LIBS="$LIBS"
1212 if test ! -z "$turbocap_root"; then
1213 TURBOCAP_CFLAGS="-I$turbocap_root/include"
1214 TURBOCAP_LIBS="-L$turbocap_root/lib"
1215 CFLAGS="$CFLAGS $TURBOCAP_CFLAGS"
1216 fi
1217
1218 AC_TRY_COMPILE(
1219 [
1220 #include <TcApi.h>
1221 ],
1222 [
1223 TC_INSTANCE a; TC_PORT b; TC_BOARD c;
1224 TC_INSTANCE i;
1225 (void)TcInstanceCreateByName("foo", &i);
1226 ],
1227 ac_cv_lbl_turbocap_api=yes)
1228
1229 CFLAGS="$save_CFLAGS"
1230 if test $ac_cv_lbl_turbocap_api = yes; then
1231 AC_MSG_RESULT(yes)
1232
1233 SSRC="$SSRC pcap-tc.c"
1234 V_INCLS="$V_INCLS $TURBOCAP_CFLAGS"
1235 LIBS="$LIBS $TURBOCAP_LIBS -lTcApi -lpthread -lstdc++"
1236
1237 AC_DEFINE(HAVE_TC_API, 1, [define if you have the TurboCap API])
1238 else
1239 AC_MSG_RESULT(no)
1240
1241 if test "$want_turbocap" = yes; then
1242 # User wanted Turbo support but we couldn't find it.
1243 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])
1244 fi
1245 fi
1246 fi
1247
1248 dnl
1249 dnl Allow the user to enable remote capture.
1250 dnl It's off by default, as that increases the attack surface of
1251 dnl libpcap, exposing it to malicious servers.
1252 dnl
1253 AC_MSG_CHECKING([whether to enable remote packet capture])
1254 AC_ARG_ENABLE(remote,
1255 [ --enable-remote enable remote packet capture @<:@default=no@:>@
1256 --disable-remote disable remote packet capture],,
1257 enableval=no)
1258 case "$enableval" in
1259 yes) AC_MSG_RESULT(yes)
1260 AC_WARN([Remote packet capture may expose libpcap-based applications])
1261 AC_WARN([to attacks by malicious remote capture servers!])
1262 #
1263 # rpcapd requires pthreads on UN*X.
1264 #
1265 if test "$ac_lbl_have_pthreads" != "found"; then
1266 AC_MSG_ERROR([rpcapd requires pthreads, but we didn't find them])
1267 fi
1268 #
1269 # It also requires crypt().
1270 # Do we have it in the system libraries?
1271 #
1272 AC_CHECK_FUNC(crypt,,
1273 [
1274 #
1275 # No. Do we have it in -lcrypt?
1276 #
1277 AC_CHECK_LIB(crypt, crypt,
1278 [
1279 #
1280 # Yes; add -lcrypt to the libraries for rpcapd.
1281 #
1282 RPCAPD_LIBS="$RPCAPD_LIBS -lcrypt"
1283 ],
1284 [
1285 AC_MSG_ERROR([rpcapd requires crypt(), but we didn't find it])
1286 ])
1287 ])
1288
1289 #
1290 # OK, we have crypt(). Do we have getspnam()?
1291 #
1292 AC_CHECK_FUNCS(getspnam)
1293
1294 #
1295 # Check for various members of struct msghdr.
1296 #
1297 AC_MSG_CHECKING(if struct msghdr has a msg_control member)
1298 AC_CACHE_VAL(ac_cv_lbl_struct_msghdr_has_msg_control,
1299 AC_TRY_COMPILE([
1300 # include "ftmacros.h"
1301 # include <sys/socket.h>],
1302 [u_int i = sizeof(((struct msghdr *)0)->msg_control)],
1303 ac_cv_lbl_struct_msghdr_has_msg_control=yes,
1304 ac_cv_lbl_struct_msghdr_has_msg_control=no))
1305 AC_MSG_RESULT($ac_cv_lbl_struct_msghdr_has_msg_control)
1306 if test $ac_cv_lbl_struct_msghdr_has_msg_control = yes ; then
1307 AC_DEFINE(STRUCT_MSGHDR_HAS_MSG_CONTROL,1,[if struct msghdr has a msg_control member])
1308 fi
1309 AC_MSG_CHECKING(if struct msghdr has a msg_flags member)
1310 AC_CACHE_VAL(ac_cv_lbl_struct_msghdr_has_msg_flags,
1311 AC_TRY_COMPILE([
1312 # include "ftmacros.h"
1313 # include <sys/socket.h>],
1314 [u_int i = sizeof(((struct msghdr *)0)->msg_flags)],
1315 ac_cv_lbl_struct_msghdr_has_msg_flags=yes,
1316 ac_cv_lbl_struct_msghdr_has_msg_flags=no))
1317 AC_MSG_RESULT($ac_cv_lbl_struct_msghdr_has_msg_flags)
1318 if test $ac_cv_lbl_struct_msghdr_has_msg_flags = yes ; then
1319 AC_DEFINE(STRUCT_MSGHDR_HAS_MSG_FLAGS,1,[if struct msghdr has a msg_flags member])
1320 fi
1321
1322 AC_DEFINE(ENABLE_REMOTE,,
1323 [Define to 1 if remote packet capture is to be supported])
1324 SSRC="$SSRC pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c"
1325 BUILD_RPCAPD=build-rpcapd
1326 INSTALL_RPCAPD=install-rpcapd
1327 ;;
1328 *) AC_MSG_RESULT(no)
1329 ;;
1330 esac
1331
1332 AC_MSG_CHECKING(whether to build optimizer debugging code)
1333 AC_ARG_ENABLE(optimizer-dbg,
1334 AC_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code]))
1335 if test "$enable_optimizer_dbg" = "yes"; then
1336 AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
1337 fi
1338 AC_MSG_RESULT(${enable_optimizer_dbg-no})
1339
1340 AC_MSG_CHECKING(whether to build parser debugging code)
1341 AC_ARG_ENABLE(yydebug,
1342 AC_HELP_STRING([--enable-yydebug],[build parser debugging code]))
1343 if test "$enable_yydebug" = "yes"; then
1344 AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
1345 fi
1346 AC_MSG_RESULT(${enable_yydebug-no})
1347
1348 #
1349 # Look for {f}lex.
1350 #
1351 AC_PROG_LEX
1352 if test "$LEX" = ":"; then
1353 AC_MSG_ERROR([Neither flex nor lex was found.])
1354 fi
1355
1356 #
1357 # Make sure {f}lex supports the -P, --header-file, and --nounput flags
1358 # and supports processing our scanner.l.
1359 #
1360 AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
1361 if $LEX -P pcap_ --header-file=/dev/null --nounput -t $srcdir/scanner.l > /dev/null 2>&1; then
1362 tcpdump_cv_capable_lex=yes
1363 else
1364 tcpdump_cv_capable_lex=insufficient
1365 fi)
1366 if test $tcpdump_cv_capable_lex = insufficient ; then
1367 AC_MSG_ERROR([$LEX is insufficient to compile libpcap.
1368 libpcap requires Flex 2.5.31 or later, or a compatible version of lex.])
1369 fi
1370
1371 #
1372 # Look for yacc/bison/byacc.
1373 #
1374 AC_PROG_YACC
1375
1376 #
1377 # Make sure it supports the -p flag and supports processing our
1378 # grammar.y.
1379 #
1380 AC_CACHE_CHECK([for capable yacc/bison], tcpdump_cv_capable_yacc,
1381 if $YACC -p pcap_ -o /dev/null $srcdir/grammar.y >/dev/null 2>&1; then
1382 tcpdump_cv_capable_yacc=yes
1383 else
1384 tcpdump_cv_capable_yacc=insufficient
1385 fi)
1386 if test $tcpdump_cv_capable_yacc = insufficient ; then
1387 AC_MSG_ERROR([$YACC is insufficient to compile libpcap.
1388 libpcap requires Bison, Berkeley YACC, or another YACC compatible with them.])
1389 fi
1390
1391 #
1392 # Do various checks for various OSes and versions of those OSes.
1393 #
1394 # Assume, by default, no support for shared libraries and V7/BSD convention
1395 # for man pages (file formats in section 5, miscellaneous info in section 7).
1396 # Individual cases can override this.
1397 #
1398 DYEXT="none"
1399 MAN_FILE_FORMATS=5
1400 MAN_MISC_INFO=7
1401 MAN_USERMOD_SECTION=8
1402 case "$host_os" in
1403
1404 aix*)
1405 dnl Workaround to enable certain features
1406 AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
1407
1408 #
1409 # AIX makes it fun to build shared and static libraries,
1410 # because they're *both* ".a" archive libraries. We
1411 # build the static library for the benefit of the traditional
1412 # scheme of building libpcap and tcpdump in subdirectories of
1413 # the same directory, with tcpdump statically linked with the
1414 # libpcap in question, but we also build a shared library as
1415 # "libpcap.shareda" and install *it*, rather than the static
1416 # library, as "libpcap.a".
1417 #
1418 DYEXT="shareda"
1419
1420 case "$V_PCAP" in
1421
1422 dlpi)
1423 #
1424 # If we're using DLPI, applications will need to
1425 # use /lib/pse.exp if present, as we use the
1426 # STREAMS routines.
1427 #
1428 pseexe="/lib/pse.exp"
1429 AC_MSG_CHECKING(for $pseexe)
1430 if test -f $pseexe ; then
1431 AC_MSG_RESULT(yes)
1432 LIBS="-I:$pseexe"
1433 fi
1434 ;;
1435
1436 bpf)
1437 #
1438 # If we're using BPF, we need "-lodm" and "-lcfg", as
1439 # we use them to load the BPF module.
1440 #
1441 LIBS="-lodm -lcfg"
1442 ;;
1443 esac
1444 ;;
1445
1446 darwin*)
1447 DYEXT="dylib"
1448 V_CCOPT="$V_CCOPT -fno-common"
1449 AC_ARG_ENABLE(universal,
1450 AC_HELP_STRING([--disable-universal],[don't build universal on macOS]))
1451 if test "$enable_universal" != "no"; then
1452 case "$host_os" in
1453
1454 darwin[0-7].*)
1455 #
1456 # Pre-Tiger. Build only for 32-bit PowerPC; no
1457 # need for any special compiler or linker flags.
1458 #
1459 ;;
1460
1461 darwin8.[0123]*)
1462 #
1463 # Tiger, prior to Intel support. Build for 32-bit
1464 # PowerPC and 64-bit PowerPC, with 32-bit PowerPC
1465 # first. (I'm guessing that's what Apple does.)
1466 #
1467 V_CCOPT="$V_CCOPT -arch ppc -arch ppc64"
1468 LDFLAGS="$LDFLAGS -arch ppc -arch ppc64"
1469 ;;
1470
1471 darwin8.[456]*)
1472 #
1473 # Tiger, subsequent to Intel support but prior to
1474 # x86-64 support. Build for 32-bit PowerPC, 64-bit
1475 # PowerPC, and x86, with 32-bit PowerPC first.
1476 # (I'm guessing that's what Apple does.)
1477 #
1478 V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386"
1479 LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386"
1480 ;;
1481
1482 darwin8.*)
1483 #
1484 # All other Tiger, so subsequent to x86-64
1485 # support. Build for 32-bit PowerPC, 64-bit
1486 # PowerPC, x86, and x86-64, and with 32-bit PowerPC
1487 # first. (I'm guessing that's what Apple does.)
1488 #
1489 V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1490 LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1491 ;;
1492
1493 darwin9.*)
1494 #
1495 # Leopard. Build for 32-bit PowerPC, 64-bit
1496 # PowerPC, x86, and x86-64, with 32-bit PowerPC
1497 # first. (That's what Apple does.)
1498 #
1499 V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1500 LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1501 ;;
1502
1503 darwin10.*)
1504 #
1505 # Snow Leopard. Build for x86-64, x86, and
1506 # 32-bit PowerPC, with x86-64 first. (That's
1507 # what Apple does, even though Snow Leopard
1508 # doesn't run on PPC, so PPC libpcap runs under
1509 # Rosetta, and Rosetta doesn't support BPF
1510 # ioctls, so PPC programs can't do live
1511 # captures.)
1512 #
1513 V_CCOPT="$V_CCOPT -arch x86_64 -arch i386 -arch ppc"
1514 LDFLAGS="$LDFLAGS -arch x86_64 -arch i386 -arch ppc"
1515 ;;
1516
1517 darwin*)
1518 #
1519 # Post-Snow Leopard. Build for x86-64 and
1520 # x86, with x86-64 first. (That's probably what
1521 # Apple does, given that Rosetta is gone.)
1522 # XXX - update if and when Apple drops support
1523 # for 32-bit x86 code.
1524 #
1525 V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
1526 LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
1527 ;;
1528 esac
1529 fi
1530 ;;
1531
1532 hpux9*)
1533 AC_DEFINE(HAVE_HPUX9,1,[on HP-UX 9.x])
1534
1535 #
1536 # Use System V conventions for man pages.
1537 #
1538 MAN_FILE_FORMATS=4
1539 MAN_MISC_INFO=5
1540 ;;
1541
1542 hpux10.0*)
1543
1544 #
1545 # Use System V conventions for man pages.
1546 #
1547 MAN_FILE_FORMATS=4
1548 MAN_MISC_INFO=5
1549 ;;
1550
1551 hpux10.1*)
1552
1553 #
1554 # Use System V conventions for man pages.
1555 #
1556 MAN_FILE_FORMATS=4
1557 MAN_MISC_INFO=5
1558 ;;
1559
1560 hpux*)
1561 dnl HPUX 10.20 and above is similar to HPUX 9, but
1562 dnl not the same....
1563 dnl
1564 dnl XXX - DYEXT should be set to "sl" if this is building
1565 dnl for 32-bit PA-RISC, but should be left as "so" for
1566 dnl 64-bit PA-RISC or, I suspect, IA-64.
1567 AC_DEFINE(HAVE_HPUX10_20_OR_LATER,1,[on HP-UX 10.20 or later])
1568 if test "`uname -m`" = "ia64"; then
1569 DYEXT="so"
1570 else
1571 DYEXT="sl"
1572 fi
1573
1574 #
1575 # "-b" builds a shared library; "+h" sets the soname.
1576 #
1577 SHLIB_OPT="-b"
1578 SONAME_OPT="+h"
1579
1580 #
1581 # Use System V conventions for man pages.
1582 #
1583 MAN_FILE_FORMATS=4
1584 MAN_MISC_INFO=5
1585 ;;
1586
1587 irix*)
1588 #
1589 # Use System V conventions for man pages.
1590 #
1591 MAN_FILE_FORMATS=4
1592 MAN_MISC_INFO=5
1593 ;;
1594
1595 linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*)
1596 DYEXT="so"
1597
1598 #
1599 # Compiler assumed to be GCC; run-time linker may require a -R
1600 # flag.
1601 #
1602 if test "$libdir" != "/usr/lib"; then
1603 V_RFLAGS=-Wl,-R$libdir
1604 fi
1605 ;;
1606
1607 osf*)
1608 DYEXT="so"
1609
1610 #
1611 # Use System V conventions for man pages.
1612 #
1613 MAN_FILE_FORMATS=4
1614 MAN_MISC_INFO=5
1615 ;;
1616
1617 sinix*)
1618 AC_MSG_CHECKING(if SINIX compiler defines sinix)
1619 AC_CACHE_VAL(ac_cv_cc_sinix_defined,
1620 AC_TRY_COMPILE(
1621 [],
1622 [int i = sinix;],
1623 ac_cv_cc_sinix_defined=yes,
1624 ac_cv_cc_sinix_defined=no))
1625 AC_MSG_RESULT($ac_cv_cc_sinix_defined)
1626 if test $ac_cv_cc_sinix_defined = no ; then
1627 AC_DEFINE(sinix,1,[on sinix])
1628 fi
1629 ;;
1630
1631 solaris*)
1632 AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
1633
1634 DYEXT="so"
1635
1636 #
1637 # Make sure errno is thread-safe, in case we're called in
1638 # a multithreaded program. We don't guarantee that two
1639 # threads can use the *same* pcap_t safely, but the
1640 # current version does guarantee that you can use different
1641 # pcap_t's in different threads, and even that pcap_compile()
1642 # is thread-safe (it wasn't thread-safe in some older versions).
1643 #
1644 V_CCOPT="$V_CCOPT -D_TS_ERRNO"
1645
1646 case "`uname -r`" in
1647
1648 5.12)
1649 ;;
1650
1651 *)
1652 #
1653 # Use System V conventions for man pages.
1654 #
1655 MAN_USERMOD_SECTION=1m
1656 MAN_FILE_FORMATS=4
1657 MAN_MISC_INFO=5
1658 esac
1659 ;;
1660 esac
1661
1662 AC_ARG_ENABLE(shared,
1663 AC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@]))
1664 test "x$enable_shared" = "xno" && DYEXT="none"
1665
1666 AC_PROG_RANLIB
1667 AC_CHECK_TOOL([AR], [ar])
1668
1669 AC_PROG_LN_S
1670 AC_SUBST(LN_S)
1671
1672 AC_LBL_DEVEL(V_CCOPT)
1673
1674 AC_LBL_SOCKADDR_SA_LEN
1675
1676 AC_LBL_SOCKADDR_STORAGE
1677
1678 AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
1679
1680 AC_LBL_UNALIGNED_ACCESS
1681
1682 #
1683 # Find out whether we need to link with -lsocket to get inet_ntop();
1684 # libpcap and rpcapd don't use inet_ntop(), but findalldevstest does,
1685 # and the libraries libpcap uses might not have it (e.g., in some
1686 # versions of Solaris, we link with -lxnet, to get the version of
1687 # recvmsg() that returns a "truncated datagram" indication, but
1688 # -lxnet doesn't have inet_ntop(), and you have to link with -lsocket
1689 # to get it.
1690 #
1691 # We assume inet_ntop() and inet_pton() are in the same libraries;
1692 # filtertest.c uses inet_pton(), so we need those libraries for it
1693 # as well.
1694 #
1695 AC_MSG_CHECKING(for additional libraries needed for inet_ntop)
1696 AC_LINK_IFELSE([AC_LANG_CALL([], [inet_ntop])],
1697 [
1698 #
1699 # Found - no additional libraries are needed.
1700 #
1701 AC_MSG_RESULT(none)
1702 ],
1703 [
1704 #
1705 # Not found.
1706 # Try with -lsocket.
1707 #
1708 save_LIBS="$LIBS"
1709 LIBS="-lsocket $LIBS"
1710 AC_LINK_IFELSE([AC_LANG_CALL([], [inet_ntop])],
1711 [
1712 #
1713 # Found - link findalldevstest with -lsocket.
1714 #
1715 EXTRA_NETWORK_LIBS="-lsocket"
1716 AC_MSG_RESULT(-lsocket)
1717 ],
1718 [
1719 #
1720 # Not found - try with -lsocket -lnsl.
1721 #
1722 LIBS="-lsocket -lnsl $save_LIBS"
1723 AC_LINK_IFELSE([AC_LANG_CALL([], [inet_ntop])],
1724 [
1725 #
1726 # Found - link findalldevstest with -lsocket.
1727 #
1728 EXTRA_NETWORK_LIBS="-lsocket -lnsl"
1729 AC_MSG_RESULT(-lsocket -lnsl)
1730 ],
1731 [
1732 #
1733 # Not found - suppress build of findalldevstest?
1734 #
1735 AC_MSG_RESULT(good question!)
1736 ])
1737 ])
1738 LIBS="$save_LIBS"
1739 ])
1740
1741
1742 rm -f net
1743 ln -s ${srcdir}/bpf/net net
1744
1745 AC_SUBST(V_CCOPT)
1746 AC_SUBST(V_DEFS)
1747 AC_SUBST(V_FINDALLDEVS)
1748 AC_SUBST(V_INCLS)
1749 AC_SUBST(V_LEX)
1750 AC_SUBST(V_PCAP)
1751 AC_SUBST(V_SHLIB_CCOPT)
1752 AC_SUBST(V_SHLIB_CMD)
1753 AC_SUBST(V_SHLIB_OPT)
1754 AC_SUBST(V_SONAME_OPT)
1755 AC_SUBST(V_RPATH_OPT)
1756 AC_SUBST(V_YACC)
1757 AC_SUBST(ADDLOBJS)
1758 AC_SUBST(ADDLARCHIVEOBJS)
1759 AC_SUBST(SSRC)
1760 AC_SUBST(DYEXT)
1761 AC_SUBST(MAN_FILE_FORMATS)
1762 AC_SUBST(MAN_MISC_INFO)
1763 AC_SUBST(MAN_USERMOD_SECTION)
1764 AC_SUBST(PTHREAD_LIBS)
1765 AC_SUBST(BUILD_RPCAPD)
1766 AC_SUBST(INSTALL_RPCAPD)
1767 AC_SUBST(RPCAPD_LIBS)
1768 AC_SUBST(EXTRA_NETWORK_LIBS)
1769
1770 AC_ARG_ENABLE([usb],
1771 [AC_HELP_STRING([--enable-usb],[enable USB capture support @<:@default=yes, if support available@:>@])],
1772 [],
1773 [enable_usb=yes])
1774
1775 if test "xxx_only" = yes; then
1776 # User requested something-else-only pcap, so they don't
1777 # want USB support.
1778 enable_usb=no
1779 fi
1780
1781 if test "x$enable_usb" != "xno" ; then
1782 dnl check for USB sniffing support
1783 AC_MSG_CHECKING(for USB sniffing support)
1784 case "$host_os" in
1785 linux*)
1786 AC_DEFINE(PCAP_SUPPORT_USB, 1, [target host supports USB sniffing])
1787 USB_SRC=pcap-usb-linux.c
1788 AC_MSG_RESULT(yes)
1789 ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null`
1790 if test $? -ne 0 ; then
1791 ac_usb_dev_name="usbmon"
1792 fi
1793 AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing])
1794 AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name)
1795 #
1796 # Do we have a version of <linux/compiler.h> available?
1797 # If so, we might need it for <linux/usbdevice_fs.h>.
1798 #
1799 AC_CHECK_HEADERS(linux/compiler.h)
1800 if test "$ac_cv_header_linux_compiler_h" = yes; then
1801 #
1802 # Yes - include it when testing for <linux/usbdevice_fs.h>.
1803 #
1804 AC_CHECK_HEADERS(linux/usbdevice_fs.h,,,[#include <linux/compiler.h>])
1805 else
1806 AC_CHECK_HEADERS(linux/usbdevice_fs.h)
1807 fi
1808 if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then
1809 #
1810 # OK, does it define bRequestType? Older versions of the kernel
1811 # define fields with names like "requesttype, "request", and
1812 # "value", rather than "bRequestType", "bRequest", and
1813 # "wValue".
1814 #
1815 AC_MSG_CHECKING(if usbdevfs_ctrltransfer struct has bRequestType member)
1816 AC_CACHE_VAL(ac_cv_usbdevfs_ctrltransfer_has_bRequestType,
1817 AC_TRY_COMPILE([
1818 AC_INCLUDES_DEFAULT
1819 #ifdef HAVE_LINUX_COMPILER_H
1820 #include <linux/compiler.h>
1821 #endif
1822 #include <linux/usbdevice_fs.h>],
1823 [u_int i = sizeof(((struct usbdevfs_ctrltransfer *)0)->bRequestType)],
1824 ac_cv_usbdevfs_ctrltransfer_has_bRequestType=yes,
1825 ac_cv_usbdevfs_ctrltransfer_has_bRequestType=no))
1826 AC_MSG_RESULT($ac_cv_usbdevfs_ctrltransfer_has_bRequestType)
1827 if test $ac_cv_usbdevfs_ctrltransfer_has_bRequestType = yes ; then
1828 AC_DEFINE(HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE,1,
1829 [if struct usbdevfs_ctrltransfer has bRequestType])
1830 fi
1831 fi
1832 ;;
1833 freebsd*)
1834 #
1835 # This just uses BPF in FreeBSD 8.4 and later; we don't need
1836 # to check for anything special for capturing.
1837 #
1838 AC_MSG_RESULT([yes, in FreeBSD 8.4 and later])
1839 ;;
1840
1841 *)
1842 AC_MSG_RESULT(no)
1843 ;;
1844 esac
1845 fi
1846 AC_SUBST(PCAP_SUPPORT_USB)
1847 AC_SUBST(USB_SRC)
1848
1849 dnl check for netfilter sniffing support
1850 if test "xxx_only" != yes; then
1851 AC_MSG_CHECKING(whether the platform could support netfilter sniffing)
1852 case "$host_os" in
1853 linux*)
1854 AC_MSG_RESULT(yes)
1855 #
1856 # Life's too short to deal with trying to get this to compile
1857 # if you don't get the right types defined with
1858 # __KERNEL_STRICT_NAMES getting defined by some other include.
1859 #
1860 # Check whether the includes Just Work. If not, don't turn on
1861 # netfilter support.
1862 #
1863 AC_MSG_CHECKING(whether we can compile the netfilter support)
1864 AC_CACHE_VAL(ac_cv_netfilter_can_compile,
1865 AC_TRY_COMPILE([
1866 AC_INCLUDES_DEFAULT
1867 #include <sys/socket.h>
1868 #include <netinet/in.h>
1869 #include <linux/types.h>
1870
1871 #include <linux/netlink.h>
1872 #include <linux/netfilter.h>
1873 #include <linux/netfilter/nfnetlink.h>
1874 #include <linux/netfilter/nfnetlink_log.h>
1875 #include <linux/netfilter/nfnetlink_queue.h>],
1876 [],
1877 ac_cv_netfilter_can_compile=yes,
1878 ac_cv_netfilter_can_compile=no))
1879 AC_MSG_RESULT($ac_cv_netfilter_can_compile)
1880 if test $ac_cv_netfilter_can_compile = yes ; then
1881 AC_DEFINE(PCAP_SUPPORT_NETFILTER, 1,
1882 [target host supports netfilter sniffing])
1883 NETFILTER_SRC=pcap-netfilter-linux.c
1884 fi
1885 ;;
1886 *)
1887 AC_MSG_RESULT(no)
1888 ;;
1889 esac
1890 fi
1891 AC_SUBST(PCAP_SUPPORT_NETFILTER)
1892 AC_SUBST(NETFILTER_SRC)
1893
1894 AC_ARG_ENABLE([netmap],
1895 [AC_HELP_STRING([--enable-netmap],[enable netmap support @<:@default=yes, if support available@:>@])],
1896 [],
1897 [enable_netmap=yes])
1898
1899 if test "x$enable_netmap" != "xno" ; then
1900 #
1901 # Check whether net/netmap_user.h is usable if NETMAP_WITH_LIBS is
1902 # defined; it's not usable on DragonFly BSD 4.6 if NETMAP_WITH_LIBS
1903 # is defined, for example, as it includes a non-existent malloc.h
1904 # header.
1905 #
1906 AC_MSG_CHECKING(whether we can compile the netmap support)
1907 AC_CACHE_VAL(ac_cv_net_netmap_user_can_compile,
1908 AC_TRY_COMPILE([
1909 AC_INCLUDES_DEFAULT
1910 #define NETMAP_WITH_LIBS
1911 #include <net/netmap_user.h>],
1912 [],
1913 ac_cv_net_netmap_user_can_compile=yes,
1914 ac_cv_net_netmap_user_can_compile=no))
1915 AC_MSG_RESULT($ac_cv_net_netmap_user_can_compile)
1916 if test $ac_cv_net_netmap_user_can_compile = yes ; then
1917 AC_DEFINE(PCAP_SUPPORT_NETMAP, 1,
1918 [target host supports netmap])
1919 NETMAP_SRC=pcap-netmap.c
1920 fi
1921 AC_SUBST(PCAP_SUPPORT_NETMAP)
1922 AC_SUBST(NETMAP_SRC)
1923 fi
1924
1925
1926 AC_ARG_ENABLE([bluetooth],
1927 [AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
1928 [],
1929 [enable_bluetooth=ifsupportavailable])
1930
1931 if test "xxx_only" = yes; then
1932 # User requested something-else-only pcap, so they don't
1933 # want Bluetooth support.
1934 enable_bluetooth=no
1935 fi
1936
1937 if test "x$enable_bluetooth" != "xno" ; then
1938 dnl check for Bluetooth sniffing support
1939 case "$host_os" in
1940 linux*)
1941 AC_CHECK_HEADER(bluetooth/bluetooth.h,
1942 [
1943 AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
1944 BT_SRC=pcap-bt-linux.c
1945 AC_MSG_NOTICE(Bluetooth sniffing is supported)
1946
1947 #
1948 # OK, does struct sockaddr_hci have an hci_channel
1949 # member?
1950 #
1951 AC_MSG_CHECKING(if struct sockaddr_hci has hci_channel member)
1952 AC_CACHE_VAL(ac_cv_lbl_sockaddr_hci_has_hci_channel,
1953 AC_TRY_COMPILE(
1954 [
1955 #include <bluetooth/bluetooth.h>
1956 #include <bluetooth/hci.h>
1957 ],
1958 [u_int i = sizeof(((struct sockaddr_hci *)0)->hci_channel)],
1959 ac_cv_lbl_sockaddr_hci_has_hci_channel=yes,
1960 ac_cv_lbl_sockaddr_hci_has_hci_channel=no))
1961 AC_MSG_RESULT($ac_cv_lbl_sockaddr_hci_has_hci_channel)
1962 if test $ac_cv_lbl_sockaddr_hci_has_hci_channel = yes ; then
1963 AC_DEFINE(SOCKADDR_HCI_HAS_HCI_CHANNEL,,
1964 [if struct sockaddr_hci has hci_channel member])
1965
1966 #
1967 # OK, is HCI_CHANNEL_MONITOR defined?
1968 #
1969 AC_MSG_CHECKING(if HCI_CHANNEL_MONITOR is defined)
1970 AC_CACHE_VAL(ac_cv_lbl_hci_channel_monitor_is_defined,
1971 AC_TRY_COMPILE(
1972 [
1973 #include <bluetooth/bluetooth.h>
1974 #include <bluetooth/hci.h>
1975 ],
1976 [u_int i = HCI_CHANNEL_MONITOR],
1977 ac_cv_lbl_hci_channel_monitor_is_defined=yes,
1978 ac_cv_lbl_hci_channel_monitor_is_defined=no))
1979 AC_MSG_RESULT($ac_cv_lbl_hci_channel_monitor_is_defined)
1980 if test $ac_cv_lbl_hci_channel_monitor_is_defined = yes ; then
1981 AC_DEFINE(PCAP_SUPPORT_BT_MONITOR,,
1982 [target host supports Bluetooth Monitor])
1983 BT_MONITOR_SRC=pcap-bt-monitor-linux.c
1984 fi
1985 fi
1986 ac_lbl_bluetooth_available=yes
1987 ],
1988 ac_lbl_bluetooth_available=no
1989 )
1990 if test "x$ac_lbl_bluetooth_available" == "xno" ; then
1991 if test "x$enable_bluetooth" = "xyes" ; then
1992 AC_MSG_ERROR(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
1993 else
1994 AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
1995 fi
1996 fi
1997 ;;
1998 *)
1999 if test "x$enable_bluetooth" = "xyes" ; then
2000 AC_MSG_ERROR(no Bluetooth sniffing support implemented for $host_os)
2001 else
2002 AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os)
2003 fi
2004 ;;
2005 esac
2006 AC_SUBST(PCAP_SUPPORT_BT)
2007 AC_SUBST(BT_SRC)
2008 AC_SUBST(BT_MONITOR_SRC)
2009 fi
2010
2011 AC_ARG_ENABLE([dbus],
2012 [AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
2013 [],
2014 [enable_dbus=ifavailable])
2015
2016 if test "xxx_only" = yes; then
2017 # User requested something-else-only pcap, so they don't
2018 # want D-Bus support.
2019 enable_dbus=no
2020 fi
2021
2022 if test "x$enable_dbus" != "xno"; then
2023 if test "x$enable_dbus" = "xyes"; then
2024 case "$host_os" in
2025
2026 darwin*)
2027 #
2028 # We don't support D-Bus sniffing on macOS; see
2029 #
2030 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
2031 #
2032 # The user requested it, so fail.
2033 #
2034 AC_MSG_ERROR([Due to freedesktop.org bug 74029, D-Bus capture support is not available on macOS])
2035 esac
2036 else
2037 case "$host_os" in
2038
2039 darwin*)
2040 #
2041 # We don't support D-Bus sniffing on macOS; see
2042 #
2043 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
2044 #
2045 # The user dind't explicitly request it, so just
2046 # silently refuse to enable it.
2047 #
2048 enable_dbus="no"
2049 ;;
2050 esac
2051 fi
2052 fi
2053
2054 if test "x$enable_dbus" != "xno"; then
2055 AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no])
2056 if test "x$PKGCONFIG" != "xno"; then
2057 AC_MSG_CHECKING([for D-Bus])
2058 if "$PKGCONFIG" dbus-1; then
2059 AC_MSG_RESULT([yes])
2060 DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
2061 DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
2062 save_CFLAGS="$CFLAGS"
2063 save_LIBS="$LIBS"
2064 CFLAGS="$CFLAGS $DBUS_CFLAGS"
2065 LIBS="$LIBS $DBUS_LIBS"
2066 AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
2067 AC_TRY_LINK(
2068 [#include <string.h>
2069
2070 #include <time.h>
2071 #include <sys/time.h>
2072
2073 #include <dbus/dbus.h>],
2074 [return dbus_connection_read_write(NULL, 0);],
2075 [
2076 AC_MSG_RESULT([yes])
2077 AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
2078 DBUS_SRC=pcap-dbus.c
2079 V_INCLS="$V_INCLS $DBUS_CFLAGS"
2080 ],
2081 [
2082 AC_MSG_RESULT([no])
2083 if test "x$enable_dbus" = "xyes"; then
2084 AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
2085 fi
2086 LIBS="$save_LIBS"
2087 ])
2088 CFLAGS="$save_CFLAGS"
2089 else
2090 AC_MSG_RESULT([no])
2091 if test "x$enable_dbus" = "xyes"; then
2092 AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed])
2093 fi
2094 fi
2095 fi
2096 AC_SUBST(PCAP_SUPPORT_DBUS)
2097 AC_SUBST(DBUS_SRC)
2098 fi
2099
2100 AC_ARG_ENABLE([rdma],
2101 [AC_HELP_STRING([--enable-rdma],[enable RDMA capture support @<:@default=yes, if support available@:>@])],
2102 [],
2103 [enable_rdmasniff=ifavailable])
2104
2105 if test "xxx_only" = yes; then
2106 # User requested something-else-only pcap, so they don't
2107 # want RDMA support.
2108 enable_rdmasniff=no
2109 fi
2110
2111 if test "x$enable_rdmasniff" != "xno"; then
2112 AC_CHECK_LIB(ibverbs, ibv_get_device_list, [
2113 AC_CHECK_HEADER(infiniband/verbs.h, [
2114 #
2115 # ibv_create_flow may be defined as a static inline
2116 # function in infiniband/verbs.h, so we can't
2117 # use AC_CHECK_LIB.
2118 #
2119 # Too bad autoconf has no AC_SYMBOL_EXISTS()
2120 # macro that works like CMake's check_symbol_exists()
2121 # function, to check do a compile check like
2122 # this (they do a clever trick to avoid having
2123 # to know the function's signature).
2124 #
2125 AC_MSG_CHECKING(whether libibverbs defines ibv_create_flow)
2126 AC_TRY_LINK(
2127 [
2128 #include <infiniband/verbs.h>
2129 ],
2130 [
2131 (void) ibv_create_flow((struct ibv_qp *) NULL,
2132 (struct ibv_flow_attr *) NULL);
2133 ],
2134 [
2135 AC_MSG_RESULT([yes])
2136 AC_DEFINE(PCAP_SUPPORT_RDMASNIFF, , [target host supports RDMA sniffing])
2137 RDMA_SRC=pcap-rdmasniff.c
2138 LIBS="-libverbs $LIBS"
2139 ],
2140 [
2141 AC_MSG_RESULT([no])
2142 ]
2143 )
2144 ])
2145 ])
2146 AC_SUBST(PCAP_SUPPORT_RDMASNIFF)
2147 AC_SUBST(RDMA_SRC)
2148 fi
2149
2150 AC_PROG_INSTALL
2151
2152 AC_CONFIG_HEADER(config.h)
2153
2154 AC_OUTPUT_COMMANDS([if test -f .devel; then
2155 echo timestamp > stamp-h
2156 cat Makefile-devel-adds >> Makefile
2157 make depend
2158 fi])
2159 AC_OUTPUT(Makefile pcap-filter.manmisc pcap-linktype.manmisc
2160 pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap
2161 pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap
2162 pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap
2163 pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap
2164 pcap_open_offline.3pcap pcap_set_tstamp_precision.3pcap
2165 pcap_set_tstamp_type.3pcap rpcapd/Makefile tests/Makefile)
2166 exit 0