2 dnl Copyright (c) 1994, 1995, 1996, 1997
3 dnl The Regents of the University of California. All rights reserved.
5 dnl Process this file with autoconf to produce a configure script.
11 # http://ftp.gnu.org/gnu/config/README
13 # for the URLs to use to fetch new versions of config.guess and
19 AC_INIT(pcap, m4_esyscmd_s([cat VERSION]))
20 AC_CONFIG_SRCDIR(pcap.c)
21 AC_SUBST(PACKAGE_NAME)
25 AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS)
27 # Try to enable as many C99 features as we can.
28 # At minimum, we want C++/C99-style // comments.
31 if test "$ac_cv_prog_cc_c99" = "no"; then
32 AC_MSG_WARN([The C compiler does not support C99; there may be compiler errors])
34 AC_LBL_C_INIT(V_CCOPT, V_INCLS)
39 # Try to arrange for large file support.
45 dnl Even if <net/bpf.h> were, on all OSes that support BPF, fixed to
46 dnl include <sys/ioccom.h>, and we were to drop support for older
47 dnl releases without that fix, so that pcap-bpf.c doesn't need to
48 dnl include <sys/ioccom.h>, the test program in "AC_LBL_FIXINCLUDES"
49 dnl in "aclocal.m4" uses it, so we would still have to test for it
50 dnl and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
51 dnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris.
53 AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h)
54 AC_CHECK_HEADERS(netpacket/packet.h)
55 AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
56 #include <sys/socket.h>
58 if test "$ac_cv_header_net_pfvar_h" = yes; then
60 # Check for various PF actions.
62 AC_MSG_CHECKING(whether net/pfvar.h defines PF_NAT through PF_NORDR)
64 [#include <sys/types.h>
65 #include <sys/socket.h>
67 #include <net/pfvar.h>],
68 [return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR;],
71 AC_DEFINE(HAVE_PF_NAT_THROUGH_PF_NORDR, 1,
72 [define if net/pfvar.h defines PF_NAT through PF_NORDR])
80 # linux/if_bonding.h requires sys/socket.h.
82 AC_CHECK_HEADERS(linux/sockios.h linux/if_bonding.h,,,
84 #include <sys/socket.h>
89 # Check for the eventfd header.
91 AC_CHECK_HEADERS(sys/eventfd.h)
97 AC_CHECK_FUNCS(strerror strerror_r strerror_s)
100 AC_CHECK_FUNCS(vsnprintf snprintf,,
102 if test $needsnprintf = yes; then
103 AC_LIBOBJ([snprintf])
107 AC_CHECK_FUNCS(strlcat,,
109 if test $needstrlcat = yes; then
114 AC_CHECK_FUNCS(strlcpy,,
116 if test $needstrlcpy = yes; then
121 AC_CHECK_FUNCS(strtok_r,,
123 if test $needstrtok_r = yes; then
124 AC_LIBOBJ([strtok_r])
128 # Do we have ffs(), and is it declared in <strings.h>?
131 if test "$ac_cv_func_ffs" = yes; then
133 # We have ffs(); is it declared in <strings.h>?
135 # This test fails if we don't have <strings.h> or if we do
136 # but it doesn't declare ffs().
140 AC_DEFINE(STRINGS_H_DECLARES_FFS,,
141 [Define to 1 if strings.h declares `ffs'])
149 # Do this before checking for ether_hostton(), as it's a
150 # "getaddrinfo()-ish function".
155 # Check for reentrant versions of getnetbyname_r(), as provided by
156 # Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!).
157 # If we don't find one, we just use getnetbyname(), which uses
158 # thread-specific data on many platforms, but doesn't use it on
159 # NetBSD or OpenBSD, and may not use it on older versions of other
162 # Only do the check if we have a declaration of getnetbyname_r();
163 # without it, we can't check which API it has. (We assume that
164 # if there's a declaration, it has a prototype, so that the API
167 AC_CHECK_DECL(getnetbyname_r,
169 AC_MSG_CHECKING([for the Linux getnetbyname_r()])
171 [#include <netdb.h>],
173 struct netent netent_buf;
175 struct netent *resultp;
178 return getnetbyname_r((const char *)0, &netent_buf, buf, sizeof buf, &resultp, &h_errnoval);
182 AC_DEFINE(HAVE_LINUX_GETNETBYNAME_R, 1,
183 [define if we have the Linux getnetbyname_r()])
188 AC_MSG_CHECKING([for Solaris/IRIX getnetbyname_r()])
190 [#include <netdb.h>],
192 struct netent netent_buf;
195 return getnetbyname_r((const char *)0, &netent_buf, buf, (int)sizeof buf) != NULL;
199 AC_DEFINE(HAVE_SOLARIS_IRIX_GETNETBYNAME_R, 1,
200 [define if we have the Solaris/IRIX getnetbyname_r()])
205 AC_MSG_CHECKING([for AIX getnetbyname_r()])
207 [#include <netdb.h>],
209 struct netent netent_buf;
210 struct netent_data net_data;
212 return getnetbyname_r((const char *)0, &netent_buf, &net_data);
216 AC_DEFINE(HAVE_AIX_GETNETBYNAME_R, 1,
217 [define if we have the AIX getnetbyname_r()])
224 ],,[#include <netdb.h>])
227 # Check for reentrant versions of getprotobyname_r(), as provided by
228 # Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!).
229 # If we don't find one, we just use getprotobyname(), which uses
230 # thread-specific data on many platforms, but doesn't use it on
231 # NetBSD or OpenBSD, and may not use it on older versions of other
234 # Only do the check if we have a declaration of getprotobyname_r();
235 # without it, we can't check which API it has. (We assume that
236 # if there's a declaration, it has a prototype, so that the API
239 AC_CHECK_DECL(getprotobyname_r,
241 AC_MSG_CHECKING([for the Linux getprotobyname_r()])
243 [#include <netdb.h>],
245 struct protoent protoent_buf;
247 struct protoent *resultp;
249 return getprotobyname_r((const char *)0, &protoent_buf, buf, sizeof buf, &resultp);
253 AC_DEFINE(HAVE_LINUX_GETPROTOBYNAME_R, 1,
254 [define if we have the Linux getprotobyname_r()])
259 AC_MSG_CHECKING([for Solaris/IRIX getprotobyname_r()])
261 [#include <netdb.h>],
263 struct protoent protoent_buf;
266 return getprotobyname_r((const char *)0, &protoent_buf, buf, (int)sizeof buf) != NULL;
270 AC_DEFINE(HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R, 1,
271 [define if we have the Solaris/IRIX getprotobyname_r()])
276 AC_MSG_CHECKING([for AIX getprotobyname_r()])
278 [#include <netdb.h>],
280 struct protoent protoent_buf;
281 struct protoent_data proto_data;
283 return getprotobyname_r((const char *)0, &protoent_buf, &proto_data);
287 AC_DEFINE(HAVE_AIX_GETPROTOBYNAME_R, 1,
288 [define if we have the AIX getprotobyname_r()])
295 ],,[#include <netdb.h>])
298 # You are in a twisty little maze of UN*Xes, all different.
299 # Some might not have ether_hostton().
300 # Some might have it and declare it in <net/ethernet.h>.
301 # Some might have it and declare it in <netinet/ether.h>
302 # Some might have it and declare it in <sys/ethernet.h>.
303 # Some might have it and declare it in <arpa/inet.h>.
304 # Some might have it and declare it in <netinet/if_ether.h>.
305 # Some might have it and not declare it in any header file.
307 # Before you is a C compiler.
309 AC_CHECK_FUNCS(ether_hostton)
310 if test "$ac_cv_func_ether_hostton" = yes; then
312 # OK, we have ether_hostton(). Is it declared in <net/ethernet.h>?
314 # This test fails if we don't have <net/ethernet.h> or if we do
315 # but it doesn't declare ether_hostton().
317 AC_CHECK_DECL(ether_hostton,
319 AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_HOSTTON,,
320 [Define to 1 if net/ethernet.h declares `ether_hostton'])
323 #include <net/ethernet.h>
328 if test "$ac_cv_have_decl_ether_hostton" != yes; then
330 # No, how about <netinet/ether.h>, as on Linux?
332 # This test fails if we don't have <netinet/ether.h>
333 # or if we do but it doesn't declare ether_hostton().
335 # Unset ac_cv_have_decl_ether_hostton so we don't
336 # treat the previous failure as a cached value and
337 # suppress the next test.
339 unset ac_cv_have_decl_ether_hostton
340 AC_CHECK_DECL(ether_hostton,
342 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON,,
343 [Define to 1 if netinet/ether.h declares `ether_hostton'])
346 #include <netinet/ether.h>
352 if test "$ac_cv_have_decl_ether_hostton" != yes; then
354 # No, how about <sys/ethernet.h>, as on Solaris 10
357 # This test fails if we don't have <sys/ethernet.h>
358 # or if we do but it doesn't declare ether_hostton().
360 # Unset ac_cv_have_decl_ether_hostton so we don't
361 # treat the previous failure as a cached value and
362 # suppress the next test.
364 unset ac_cv_have_decl_ether_hostton
365 AC_CHECK_DECL(ether_hostton,
367 AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON,,
368 [Define to 1 if sys/ethernet.h declares `ether_hostton'])
371 #include <sys/ethernet.h>
377 if test "$ac_cv_have_decl_ether_hostton" != yes; then
379 # No, how about <arpa/inet.h>, as in AIX?
381 # This test fails if we don't have <arpa/inet.h>
382 # (if we have ether_hostton(), we should have
383 # networking, and if we have networking, we should
384 # have <arapa/inet.h>) or if we do but it doesn't
385 # declare ether_hostton().
387 # Unset ac_cv_have_decl_ether_hostton so we don't
388 # treat the previous failure as a cached value and
389 # suppress the next test.
391 unset ac_cv_have_decl_ether_hostton
392 AC_CHECK_DECL(ether_hostton,
394 AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_HOSTTON,,
395 [Define to 1 if arpa/inet.h declares `ether_hostton'])
398 #include <arpa/inet.h>
404 if test "$ac_cv_have_decl_ether_hostton" != yes; then
406 # No, how about <netinet/if_ether.h>?
407 # On some platforms, it requires <net/if.h> and
408 # <netinet/in.h>, and we always include it with
409 # both of them, so test it with both of them.
411 # This test fails if we don't have <netinet/if_ether.h>
412 # and the headers we include before it, or if we do but
413 # <netinet/if_ether.h> doesn't declare ether_hostton().
415 # Unset ac_cv_have_decl_ether_hostton so we don't
416 # treat the previous failure as a cached value and
417 # suppress the next test.
419 unset ac_cv_have_decl_ether_hostton
420 AC_CHECK_DECL(ether_hostton,
422 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON,,
423 [Define to 1 if netinet/if_ether.h declares `ether_hostton'])
426 #include <sys/types.h>
427 #include <sys/socket.h>
429 #include <netinet/in.h>
430 #include <netinet/if_ether.h>
434 # After all that, is ether_hostton() declared?
436 if test "$ac_cv_have_decl_ether_hostton" = yes; then
440 AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1,
441 [Define to 1 if you have the declaration of `ether_hostton'])
444 # No, we'll have to declare it ourselves.
445 # Do we have "struct ether_addr" if we include
446 # <netinet/if_ether.h>?
448 AC_CHECK_TYPES(struct ether_addr,,,
450 #include <sys/types.h>
451 #include <sys/socket.h>
453 #include <netinet/in.h>
454 #include <netinet/if_ether.h>
460 # For various things that might use pthreads.
462 AC_CHECK_HEADER(pthread.h,
465 # OK, we have pthread.h. Do we have pthread_create in the
468 AC_CHECK_FUNC(pthread_create,
473 ac_lbl_have_pthreads="found"
477 # No - do we have it in -lpthreads?
479 AC_CHECK_LIB(pthreads, pthread_create,
482 # Yes - add -lpthreads.
484 ac_lbl_have_pthreads="found"
485 PTHREAD_LIBS="$PTHREAD_LIBS -lpthreads"
489 # No - do we have it in -lpthread?
491 AC_CHECK_LIB(pthread, pthread_create,
494 # Yes - add -lpthread.
496 ac_lbl_have_pthreads="found"
497 PTHREAD_LIBS="$PTHREAD_LIBS -lpthread"
503 ac_lbl_have_pthreads="not found"
510 # We didn't find pthread.h.
512 ac_lbl_have_pthreads="not found"
516 dnl to pacify those who hate protochain insn
517 AC_MSG_CHECKING(if --disable-protochain option is specified)
518 AC_ARG_ENABLE(protochain,
519 AC_HELP_STRING([--disable-protochain],[disable \"protochain\" insn]))
520 case "x$enable_protochain" in
521 xyes) enable_protochain=enabled ;;
522 xno) enable_protochain=disabled ;;
523 x) enable_protochain=enabled ;;
526 if test "$enable_protochain" = "disabled"; then
527 AC_DEFINE(NO_PROTOCHAIN,1,[do not use protochain])
529 AC_MSG_RESULT(${enable_protochain})
532 # valgrindtest directly uses the native capture mechanism, but
533 # only tests with BPF and PF_PACKET sockets; only enable it if
534 # we have BPF or PF_PACKET sockets.
539 AC_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE]))
540 if test ! -z "$with_pcap" ; then
544 # Check for a bunch of headers for various packet
545 # capture mechanisms.
547 AC_CHECK_HEADERS(net/bpf.h)
548 if test "$ac_cv_header_net_bpf_h" = yes; then
550 # Does it define BIOCSETIF?
551 # I.e., is it a header for an LBL/BSD-style capture
552 # mechanism, or is it just a header for a BPF filter
553 # engine? Some versions of Arch Linux, for example,
554 # have a net/bpf.h that doesn't define BIOCSETIF;
555 # as it's a Linux, it should use packet sockets,
560 # sys/types.h, because FreeBSD 10's net/bpf.h
561 # requires that various BSD-style integer types
564 # sys/time.h, because AIX 5.2 and 5.3's net/bpf.h
565 # doesn't include it but does use struct timeval
566 # in ioctl definitions;
568 # sys/ioctl.h and, if we have it, sys/ioccom.h,
569 # because net/bpf.h defines ioctls;
571 # net/if.h, because it defines some structures
572 # used in ioctls defined by net/bpf.h;
574 # sys/socket.h, because OpenBSD 5.9's net/bpf.h
575 # defines some structure fields as being
578 # and net/bpf.h doesn't necessarily include all
579 # of those headers itself.
581 AC_MSG_CHECKING(if net/bpf.h defines BIOCSETIF)
582 AC_CACHE_VAL(ac_cv_lbl_bpf_h_defines_biocsetif,
585 #include <sys/types.h>
586 #include <sys/time.h>
587 #include <sys/ioctl.h>
588 #include <sys/socket.h>
589 #ifdef HAVE_SYS_IOCCOM_H
590 #include <sys/ioccom.h>
595 [u_int i = BIOCSETIF;],
596 ac_cv_lbl_bpf_h_defines_biocsetif=yes,
597 ac_cv_lbl_bpf_h_defines_biocsetif=no))
598 AC_MSG_RESULT($ac_cv_lbl_bpf_h_defines_biocsetif)
600 AC_CHECK_HEADERS(net/pfilt.h net/enet.h)
601 AC_CHECK_HEADERS(net/nit.h sys/net/nit.h)
602 AC_CHECK_HEADERS(linux/socket.h net/raw.h sys/dlpi.h)
604 if test "$ac_cv_lbl_bpf_h_defines_biocsetif" = yes; then
607 # Check this before DLPI, so that we pick BPF on
608 # Solaris 11 and later.
613 # We have BPF, so build valgrindtest with "make test"
614 # on macOS and FreeBSD (add your OS once there's a
619 freebsd*|darwin*|linux*)
620 VALGRINDTEST_SRC=valgrindtest.c
623 elif test "$ac_cv_header_linux_socket_h" = yes; then
625 # No prizes for guessing this one.
630 # XXX - this won't work with older kernels that have
631 # SOCK_PACKET sockets but not PF_PACKET sockets.
633 VALGRINDTEST_SRC=valgrindtest.c
634 elif test "$ac_cv_header_net_pfilt_h" = yes; then
636 # DEC OSF/1, Digital UNIX, Tru64 UNIX
639 elif test "$ac_cv_header_net_enet_h" = yes; then
641 # Stanford Enetfilter.
644 elif test "$ac_cv_header_net_nit_h" = yes; then
646 # SunOS 4.x STREAMS NIT.
649 elif test "$ac_cv_header_sys_net_nit_h" = yes; then
651 # Pre-SunOS 4.x non-STREAMS NIT.
654 elif test "$ac_cv_header_net_raw_h" = yes; then
659 elif test "$ac_cv_header_sys_dlpi_h" = yes; then
661 # DLPI on pre-Solaris 11 SunOS 5, HP-UX, possibly others.
666 # Nothing we support.
669 AC_MSG_WARN(cannot determine packet capture interface)
670 AC_MSG_WARN((see the INSTALL doc for more info))
673 AC_MSG_CHECKING(packet capture type)
674 AC_MSG_RESULT($V_PCAP)
675 AC_SUBST(VALGRINDTEST_SRC)
678 # Do capture-mechanism-dependent tests.
683 # Needed for common functions used by pcap-[dlpi,libdlpi].c
688 # Checks for some header files.
690 AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
693 # Checks to see if Solaris has the public libdlpi(3LIB) library.
694 # Note: The existence of /usr/include/libdlpi.h does not mean it is the
695 # public libdlpi(3LIB) version. Before libdlpi was made public, a
696 # private version also existed, which did not have the same APIs.
697 # Due to a gcc bug, the default search path for 32-bit libraries does
698 # not include /lib, we add it explicitly here.
699 # [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485].
700 # Also, due to the bug above applications that link to libpcap with
701 # libdlpi will have to add "-L/lib" option to "configure".
703 saved_ldflags=$LDFLAGS
704 LDFLAGS="$LIBS -L/lib"
705 AC_CHECK_LIB(dlpi, dlpi_walk,
709 AC_DEFINE(HAVE_LIBDLPI,1,[if libdlpi exists])
712 LDFLAGS=$saved_ldflags
715 # Checks whether <sys/dlpi.h> is usable, to catch weird SCO
718 AC_MSG_CHECKING(whether <sys/dlpi.h> is usable)
719 AC_CACHE_VAL(ac_cv_sys_dlpi_usable,
722 #include <sys/types.h>
723 #include <sys/time.h>
724 #include <sys/dlpi.h>
726 [int i = DL_PROMISC_PHYS;],
727 ac_cv_sys_dlpi_usable=yes,
728 ac_cv_sys_dlpi_usable=no))
729 AC_MSG_RESULT($ac_cv_sys_dlpi_usable)
730 if test $ac_cv_sys_dlpi_usable = no ; then
731 AC_MSG_ERROR(<sys/dlpi.h> is not usable on this system; it probably has a non-standard DLPI)
735 # Check to see if Solaris has the dl_passive_req_t struct defined
737 # This check is for DLPI support for passive modes.
738 # See dlpi(7P) for more details.
740 AC_CHECK_TYPES(dl_passive_req_t,,,
742 #include <sys/types.h>
743 #include <sys/dlpi.h>
749 # Do we have the wireless extensions?
751 AC_CHECK_HEADERS(linux/wireless.h, [], [],
753 #include <sys/socket.h>
754 #include <linux/if.h>
755 #include <linux/types.h>
762 AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]),
763 with_libnl=$withval,with_libnl=if_available)
765 if test x$with_libnl != xno ; then
768 incdir=-I/usr/include/libnl3
770 case "$with_libnl" in
776 if test -d $withval; then
777 libnldir=-L${withval}/lib/.libs
778 incdir=-I${withval}/include
784 # Try libnl 3.x first.
786 AC_CHECK_LIB(nl-3, nl_socket_alloc,
789 # Yes, we have libnl 3.x.
791 LIBS="${libnldir} -lnl-genl-3 -lnl-3 $LIBS"
792 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
793 AC_DEFINE(HAVE_LIBNL_3_x,1,[if libnl exists and is version 3.x])
794 AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
795 AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
796 V_INCLS="$V_INCLS ${incdir}"
798 ],[], ${incdir} ${libnldir} -lnl-genl-3 -lnl-3 )
800 if test x$have_any_nl = xno ; then
804 AC_CHECK_LIB(nl, nl_socket_alloc,
807 # Yes, we have libnl 2.x.
809 LIBS="${libnldir} -lnl-genl -lnl $LIBS"
810 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
811 AC_DEFINE(HAVE_LIBNL_2_x,1,[if libnl exists and is version 2.x])
812 AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
813 AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
818 if test x$have_any_nl = xno ; then
820 # No, we don't; do we have libnl 1.x?
822 AC_CHECK_LIB(nl, nl_handle_alloc,
827 LIBS="${libnldir} -lnl $LIBS"
828 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
833 if test x$have_any_nl = xno ; then
835 # No, we don't have libnl at all.
837 if test x$with_libnl = xyes ; then
838 AC_MSG_ERROR([libnl support requested but libnl not found])
843 AC_CHECK_HEADERS(linux/ethtool.h,,,
846 #include <linux/types.h>
850 # Check to see if struct tpacket_stats is defined in
851 # <linux/if_packet.h>. If so, then pcap-linux.c can use this
852 # to report proper statistics.
856 AC_CHECK_TYPES(struct tpacket_stats,,,
858 #include <linux/if_packet.h>
862 # Check to see if the tpacket_auxdata struct has a tp_vlan_tci member.
864 # NOTE: any failure means we conclude that it doesn't have that
865 # member, so if we don't have tpacket_auxdata, we conclude it
866 # doesn't have that member (which is OK, as either we won't be
867 # using code that would use that member, or we wouldn't compile
869 AC_CHECK_MEMBERS([struct tpacket_auxdata.tp_vlan_tci],,,
871 #include <sys/types.h>
872 #include <linux/if_packet.h>
878 # Check whether we have the *BSD-style ioctls.
880 AC_CHECK_HEADERS(net/if_media.h)
883 # Check whether we have struct BPF_TIMEVAL.
885 AC_CHECK_TYPES(struct BPF_TIMEVAL,,,
887 #include <sys/types.h>
888 #include <sys/ioctl.h>
889 #ifdef HAVE_SYS_IOCCOM_H
890 #include <sys/ioccom.h>
898 # --with-pcap=dag is the only way to get here, and it means
899 # "DAG support but nothing else"
901 V_DEFS="$V_DEFS -DDAG_ONLY"
907 # --with-pcap=septel is the only way to get here, and it means
908 # "Septel support but nothing else"
910 V_DEFS="$V_DEFS -DSEPTEL_ONLY"
916 # --with-pcap=snf is the only way to get here, and it means
917 # "SNF support but nothing else"
919 V_DEFS="$V_DEFS -DSNF_ONLY"
927 AC_MSG_ERROR($V_PCAP is not a valid pcap type)
932 dnl Now figure out how we get a list of interfaces and addresses,
933 dnl if we support capturing. Don't bother if we don't support
936 if test "$V_PCAP" != null
938 AC_CHECK_FUNC(getifaddrs,[
940 # We have "getifaddrs()"; make sure we have <ifaddrs.h>
941 # as well, just in case some platform is really weird.
943 AC_CHECK_HEADER(ifaddrs.h,[
945 # We have the header, so we use "getifaddrs()" to
946 # get the list of interfaces.
948 V_FINDALLDEVS=fad-getad.c
951 # We don't have the header - give up.
952 # XXX - we could also fall back on some other
953 # mechanism, but, for now, this'll catch this
954 # problem so that we can at least try to figure
955 # out something to do on systems with "getifaddrs()"
956 # but without "ifaddrs.h", if there is something
957 # we can do on those systems.
959 AC_MSG_ERROR([Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>.])
963 # Well, we don't have "getifaddrs()", at least not with the
964 # libraries with which we've decided we need to link
965 # libpcap with, so we have to use some other mechanism.
967 # Note that this may happen on Solaris, which has
968 # getifaddrs(), but in -lsocket, not in -lxnet, so we
969 # won't find it if we link with -lxnet, which we want
970 # to do for other reasons.
972 # For now, we use either the SIOCGIFCONF ioctl or the
973 # SIOCGLIFCONF ioctl, preferring the latter if we have
974 # it; the latter is a Solarisism that first appeared
975 # in Solaris 8. (Solaris's getifaddrs() appears to
976 # be built atop SIOCGLIFCONF; using it directly
977 # avoids a not-all-that-useful middleman.)
979 AC_MSG_CHECKING(whether we have SIOCGLIFCONF)
980 AC_CACHE_VAL(ac_cv_lbl_have_siocglifconf,
982 [#include <sys/param.h>
983 #include <sys/file.h>
984 #include <sys/ioctl.h>
985 #include <sys/socket.h>
986 #include <sys/sockio.h>],
987 [ioctl(0, SIOCGLIFCONF, (char *)0);],
988 ac_cv_lbl_have_siocglifconf=yes,
989 ac_cv_lbl_have_siocglifconf=no))
990 AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
991 if test $ac_cv_lbl_have_siocglifconf = yes ; then
992 V_FINDALLDEVS=fad-glifc.c
994 V_FINDALLDEVS=fad-gifc.c
999 dnl check for hardware timestamp support
1002 AC_CHECK_HEADERS([linux/net_tstamp.h])
1005 AC_MSG_NOTICE(no hardware timestamp support implemented for $host_os)
1009 AC_ARG_ENABLE([packet-ring],
1010 [AC_HELP_STRING([--enable-packet-ring],[enable packet ring support on Linux @<:@default=yes@:>@])],
1011 ,enable_packet_ring=yes)
1013 if test "x$enable_packet_ring" != "xno" ; then
1014 AC_DEFINE(PCAP_SUPPORT_PACKET_RING, 1, [use packet ring capture support on Linux if available])
1015 AC_SUBST(PCAP_SUPPORT_PACKET_RING)
1019 # Check for socklen_t.
1021 AC_CHECK_TYPES(socklen_t,,,
1023 #include <sys/types.h>
1024 #include <sys/socket.h>
1028 AC_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes@:>@]),
1031 if test "$enable_ipv6" != "no"; then
1033 # We've already made sure we have getaddrinfo above in
1034 # AC_LBL_LIBRARY_NET.
1036 AC_DEFINE(INET6,1,[IPv6])
1039 # Check for Endace DAG card support.
1041 AC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1043 if test "$withval" = no
1045 # User doesn't want DAG support.
1047 elif test "$withval" = yes
1049 # User wants DAG support but hasn't specified a directory.
1052 # User wants DAG support and has specified a directory, so use the provided value.
1057 if test "$V_PCAP" = dag; then
1058 # User requested DAG-only libpcap, so we'd better have
1061 elif test "xxx_only" = yes; then
1062 # User requested something-else-only pcap, so they don't
1067 # Use DAG API if present, otherwise don't
1073 AC_ARG_WITH([dag-includes],
1074 AC_HELP_STRING([--with-dag-includes=IDIR],[Endace DAG include directory, if not DIR/include]),
1076 # User wants DAG support and has specified a header directory, so use the provided value.
1078 dag_include_dir=$withval
1081 AC_ARG_WITH([dag-libraries],
1082 AC_HELP_STRING([--with-dag-libraries=LDIR],[Endace DAG library directory, if not DIR/lib]),
1084 # User wants DAG support and has specified a library directory, so use the provided value.
1086 dag_lib_dir=$withval
1089 if test "$want_dag" != no; then
1091 # If necessary, set default paths for DAG API headers and libraries.
1092 if test -z "$dag_root"; then
1096 if test -z "$dag_include_dir"; then
1097 dag_include_dir="$dag_root/include"
1100 if test -z "$dag_lib_dir"; then
1101 dag_lib_dir="$dag_root/lib"
1104 V_INCLS="$V_INCLS -I$dag_include_dir"
1106 AC_CHECK_HEADERS([dagapi.h])
1108 if test "$ac_cv_header_dagapi_h" = yes; then
1110 if test $V_PCAP != dag ; then
1111 SSRC="$SSRC pcap-dag.c"
1114 # Check for various DAG API functions.
1115 # Don't need to save and restore LIBS to prevent -ldag being
1116 # included if there's a found-action (arg 3).
1117 saved_ldflags=$LDFLAGS
1118 LDFLAGS="-L$dag_lib_dir"
1119 AC_CHECK_LIB([dag], [dag_attach_stream],
1121 [AC_MSG_ERROR(DAG library lacks streams support)])
1122 AC_CHECK_LIB([dag], [dag_attach_stream64], [dag_large_streams="1"], [dag_large_streams="0"])
1123 AC_CHECK_LIB([dag],[dag_get_erf_types], [
1124 AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])])
1125 AC_CHECK_LIB([dag],[dag_get_stream_erf_types], [
1126 AC_DEFINE(HAVE_DAG_GET_STREAM_ERF_TYPES, 1, [define if you have dag_get_stream_erf_types()])])
1128 LDFLAGS=$saved_ldflags
1131 # We assume that if we have libdag we have libdagconf,
1132 # as they're installed at the same time from the same
1135 LIBS="$LIBS -ldag -ldagconf"
1136 LDFLAGS="$LDFLAGS -L$dag_lib_dir"
1138 if test "$dag_large_streams" = 1; then
1139 AC_DEFINE(HAVE_DAG_LARGE_STREAMS_API, 1, [define if you have large streams capable DAG API])
1140 AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"])
1141 if test "$ac_dag_have_vdag" = 1; then
1142 AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()])
1143 if test "$ac_lbl_have_pthreads" != "found"; then
1144 AC_MSG_ERROR([DAG requires pthreads, but we didn't find them])
1146 LIBS="$LIBS $PTHREAD_LIBS"
1150 AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
1153 if test "$V_PCAP" = dag; then
1154 # User requested "dag" capture type but we couldn't
1155 # find the DAG API support.
1156 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])
1159 if test "$want_dag" = yes; then
1160 # User wanted DAG support but we couldn't find it.
1161 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])
1167 AC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1169 if test "$withval" = no
1172 elif test "$withval" = yes
1178 septel_root=$withval
1181 if test "$V_PCAP" = septel; then
1182 # User requested Septel-only libpcap, so we'd better have
1185 elif test "xxx_only" = yes; then
1186 # User requested something-else-only pcap, so they don't
1187 # want Septel support.
1191 # Use Septel API if present, otherwise don't
1193 want_septel=ifpresent
1197 ac_cv_lbl_septel_api=no
1198 if test "$with_septel" != no; then
1200 AC_MSG_CHECKING([whether we have Septel API headers])
1202 # If necessary, set default paths for Septel API headers and libraries.
1203 if test -z "$septel_root"; then
1204 septel_root=$srcdir/../septel
1207 septel_tools_dir="$septel_root"
1208 septel_include_dir="$septel_root/INC"
1210 if test -r "$septel_include_dir/msg.h"; then
1211 ac_cv_lbl_septel_api=yes
1214 if test "$ac_cv_lbl_septel_api" = yes; then
1215 AC_MSG_RESULT([yes ($septel_include_dir)])
1217 V_INCLS="$V_INCLS -I$septel_include_dir"
1218 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"
1219 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"
1221 if test "$V_PCAP" != septel ; then
1222 SSRC="$SSRC pcap-septel.c"
1225 AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have the Septel API])
1229 if test "$V_PCAP" = septel; then
1230 # User requested "septel" capture type but
1231 # we couldn't find the Septel API support.
1232 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])
1235 if test "$want_septel" = yes; then
1236 # User wanted Septel support but we couldn't find it.
1237 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])
1242 # Check for Myricom SNF support.
1244 AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1246 if test "$withval" = no
1248 # User explicitly doesn't want SNF
1250 elif test "$withval" = yes
1252 # User wants SNF support but hasn't specified a directory.
1255 # User wants SNF support with a specified directory.
1260 if test "$V_PCAP" = snf; then
1261 # User requested Sniffer-only libpcap, so we'd better have
1264 elif test "xxx_only" = yes; then
1265 # User requested something-else-only pcap, so they don't
1270 # Use Sniffer API if present, otherwise don't
1276 AC_ARG_WITH([snf-includes],
1277 AC_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not DIR/include]),
1279 # User wants SNF with specific header directory
1281 snf_include_dir=$withval
1284 AC_ARG_WITH([snf-libraries],
1285 AC_HELP_STRING([--with-snf-libraries=LDIR],[Myricom SNF library directory, if not DIR/lib]),
1287 # User wants SNF with specific lib directory
1289 snf_lib_dir=$withval
1292 ac_cv_lbl_snf_api=no
1293 if test "$with_snf" != no; then
1295 AC_MSG_CHECKING(whether we have Myricom Sniffer API)
1297 # If necessary, set default paths for Sniffer headers and libraries.
1298 if test -z "$snf_root"; then
1302 if test -z "$snf_include_dir"; then
1303 snf_include_dir="$snf_root/include"
1306 if test -z "$snf_lib_dir"; then
1307 snf_lib_dir="$snf_root/lib"
1310 if test -f "$snf_include_dir/snf.h"; then
1311 # We found a header; make sure we can link with the library
1312 saved_ldflags=$LDFLAGS
1313 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1314 AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"])
1315 LDFLAGS="$saved_ldflags"
1316 if test "$ac_cv_lbl_snf_api" = no; then
1317 AC_MSG_ERROR(SNF API cannot correctly be linked; check config.log)
1321 if test "$ac_cv_lbl_snf_api" = yes; then
1322 AC_MSG_RESULT([yes ($snf_root)])
1324 V_INCLS="$V_INCLS -I$snf_include_dir"
1326 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1328 if test "$V_PCAP" != snf ; then
1329 SSRC="$SSRC pcap-snf.c"
1332 AC_DEFINE(HAVE_SNF_API, 1, [define if you have the Myricom SNF API])
1336 if test "$want_snf" = yes; then
1337 # User requested "snf" capture type but
1338 # we couldn't find the Sniffer API support.
1339 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])
1342 if test "$want_snf" = yes; then
1343 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])
1348 # Check for Riverbed TurboCap support.
1349 AC_ARG_WITH([turbocap],
1350 AC_HELP_STRING([--with-turbocap@<:@=DIR@:>@],[include Riverbed TurboCap support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1352 if test "$withval" = no
1354 # User explicitly doesn't want TurboCap
1356 elif test "$withval" = yes
1358 # User wants TurboCap support but hasn't specified a directory.
1361 # User wants TurboCap support with a specified directory.
1363 turbocap_root=$withval
1366 if test "xxx_only" = yes; then
1367 # User requested something-else-only pcap, so they don't
1368 # want TurboCap support.
1372 # Use TurboCap API if present, otherwise don't
1374 want_turbocap=ifpresent
1378 ac_cv_lbl_turbocap_api=no
1379 if test "$want_turbocap" != no; then
1381 AC_MSG_CHECKING(whether TurboCap is supported)
1383 save_CFLAGS="$CFLAGS"
1385 if test ! -z "$turbocap_root"; then
1386 TURBOCAP_CFLAGS="-I$turbocap_root/include"
1387 TURBOCAP_LIBS="-L$turbocap_root/lib"
1388 CFLAGS="$CFLAGS $TURBOCAP_CFLAGS"
1396 TC_INSTANCE a; TC_PORT b; TC_BOARD c;
1398 (void)TcInstanceCreateByName("foo", &i);
1400 ac_cv_lbl_turbocap_api=yes)
1402 CFLAGS="$save_CFLAGS"
1403 if test $ac_cv_lbl_turbocap_api = yes; then
1406 SSRC="$SSRC pcap-tc.c"
1407 V_INCLS="$V_INCLS $TURBOCAP_CFLAGS"
1408 LIBS="$LIBS $TURBOCAP_LIBS -lTcApi -lpthread -lstdc++"
1410 AC_DEFINE(HAVE_TC_API, 1, [define if you have the TurboCap API])
1414 if test "$want_turbocap" = yes; then
1415 # User wanted Turbo support but we couldn't find it.
1416 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])
1422 dnl Allow the user to enable remote capture.
1423 dnl It's off by default, as that increases the attack surface of
1424 dnl libpcap, exposing it to malicious servers.
1426 AC_MSG_CHECKING([whether to enable remote packet capture])
1427 AC_ARG_ENABLE(remote,
1428 [ --enable-remote enable remote packet capture @<:@default=no@:>@
1429 --disable-remote disable remote packet capture],,
1431 case "$enableval" in
1432 yes) AC_MSG_RESULT(yes)
1433 AC_WARN([Remote packet capture may expose libpcap-based applications])
1434 AC_WARN([to attacks by malicious remote capture servers!])
1436 # rpcapd requires pthreads on UN*X.
1438 if test "$ac_lbl_have_pthreads" != "found"; then
1439 AC_MSG_ERROR([rpcapd requires pthreads, but we didn't find them])
1442 # It also requires crypt().
1443 # Do we have it in the system libraries?
1445 AC_CHECK_FUNC(crypt,,
1448 # No. Do we have it in -lcrypt?
1450 AC_CHECK_LIB(crypt, crypt,
1453 # Yes; add -lcrypt to the libraries for rpcapd.
1455 RPCAPD_LIBS="$RPCAPD_LIBS -lcrypt"
1458 AC_MSG_ERROR([rpcapd requires crypt(), but we didn't find it])
1463 # OK, we have crypt(). Do we have getspnam()?
1465 AC_CHECK_FUNCS(getspnam)
1468 # Check for various members of struct msghdr.
1470 AC_CHECK_MEMBERS([struct msghdr.msg_control],,,
1472 #include "ftmacros.h"
1473 #include <sys/socket.h>
1475 AC_CHECK_MEMBERS([struct msghdr.msg_flags],,,
1477 #include "ftmacros.h"
1478 #include <sys/socket.h>
1481 AC_DEFINE(ENABLE_REMOTE,,
1482 [Define to 1 if remote packet capture is to be supported])
1483 SSRC="$SSRC pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c"
1484 BUILD_RPCAPD=build-rpcapd
1485 INSTALL_RPCAPD=install-rpcapd
1487 *) AC_MSG_RESULT(no)
1491 AC_MSG_CHECKING(whether to build optimizer debugging code)
1492 AC_ARG_ENABLE(optimizer-dbg,
1493 AC_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code]))
1494 if test "$enable_optimizer_dbg" = "yes"; then
1495 AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
1497 AC_MSG_RESULT(${enable_optimizer_dbg-no})
1499 AC_MSG_CHECKING(whether to build parser debugging code)
1500 AC_ARG_ENABLE(yydebug,
1501 AC_HELP_STRING([--enable-yydebug],[build parser debugging code]))
1502 if test "$enable_yydebug" = "yes"; then
1503 AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
1505 AC_MSG_RESULT(${enable_yydebug-no})
1511 if test "$LEX" = ":"; then
1512 AC_MSG_ERROR([Neither flex nor lex was found.])
1516 # Make sure {f}lex supports the -P, --header-file, and --nounput flags
1517 # and supports processing our scanner.l.
1519 AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
1520 if $LEX -P pcap_ --header-file=/dev/null --nounput -t $srcdir/scanner.l > /dev/null 2>&1; then
1521 tcpdump_cv_capable_lex=yes
1523 tcpdump_cv_capable_lex=insufficient
1525 if test $tcpdump_cv_capable_lex = insufficient ; then
1526 AC_MSG_ERROR([$LEX is insufficient to compile libpcap.
1527 libpcap requires Flex 2.5.31 or later, or a compatible version of lex.])
1531 # Look for yacc/bison/byacc.
1536 # Make sure it supports the -p flag and supports processing our
1539 AC_CACHE_CHECK([for capable yacc/bison], tcpdump_cv_capable_yacc,
1540 if $YACC -p pcap_ -o /dev/null $srcdir/grammar.y >/dev/null 2>&1; then
1541 tcpdump_cv_capable_yacc=yes
1543 tcpdump_cv_capable_yacc=insufficient
1545 if test $tcpdump_cv_capable_yacc = insufficient ; then
1546 AC_MSG_ERROR([$YACC is insufficient to compile libpcap.
1547 libpcap requires Bison, a newer version of Berkeley YACC with support
1548 for reentrant parsers, or another YACC compatible with them.])
1552 # Do various checks for various OSes and versions of those OSes.
1554 # Assume, by default, no support for shared libraries and V7/BSD
1555 # convention for man pages (devices in section 4, file formats in
1556 # section 5, miscellaneous info in section 7, administrative commands
1557 # and daemons in section 8). Individual cases can override this.
1563 MAN_ADMIN_COMMANDS=8
1567 dnl Workaround to enable certain features
1568 AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
1571 # AIX makes it fun to build shared and static libraries,
1572 # because they're *both* ".a" archive libraries. We
1573 # build the static library for the benefit of the traditional
1574 # scheme of building libpcap and tcpdump in subdirectories of
1575 # the same directory, with tcpdump statically linked with the
1576 # libpcap in question, but we also build a shared library as
1577 # "libpcap.shareda" and install *it*, rather than the static
1578 # library, as "libpcap.a".
1586 # If we're using DLPI, applications will need to
1587 # use /lib/pse.exp if present, as we use the
1590 pseexe="/lib/pse.exp"
1591 AC_MSG_CHECKING(for $pseexe)
1592 if test -f $pseexe ; then
1600 # If we're using BPF, we need "-lodm" and "-lcfg", as
1601 # we use them to load the BPF module.
1610 V_CCOPT="$V_CCOPT -fno-common"
1611 AC_ARG_ENABLE(universal,
1612 AC_HELP_STRING([--disable-universal],[don't build universal on macOS]))
1613 if test "$enable_universal" != "no"; then
1618 # Pre-Tiger. Build only for 32-bit PowerPC; no
1619 # need for any special compiler or linker flags.
1623 darwin8.[[0123]]|darwin8.[[0123]].*)
1625 # Tiger, prior to Intel support. Build
1626 # libraries and executables for 32-bit PowerPC
1627 # and 64-bit PowerPC, with 32-bit PowerPC first.
1628 # (I'm guessing that's what Apple does.)
1630 # (The double brackets are needed because
1631 # autotools/m4 use brackets as a quoting
1632 # character; the double brackets turn into
1633 # single brackets in the generated configure
1636 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64"
1637 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64"
1638 V_PROG_CCOPT_FAT="-arch ppc -arch ppc64"
1639 V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64"
1642 darwin8.[[456]]|darwin.[[456]].*)
1644 # Tiger, subsequent to Intel support but prior
1645 # to x86-64 support. Build libraries and
1646 # executables for 32-bit PowerPC, 64-bit
1647 # PowerPC, and 32-bit x86, with 32-bit PowerPC
1648 # first. (I'm guessing that's what Apple does.)
1650 # (The double brackets are needed because
1651 # autotools/m4 use brackets as a quoting
1652 # character; the double brackets turn into
1653 # single brackets in the generated configure
1656 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
1657 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
1658 V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
1659 V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
1664 # All other Tiger, so subsequent to x86-64
1665 # support. Build libraries and executables for
1666 # 32-bit PowerPC, 64-bit PowerPC, 32-bit x86,
1667 # and x86-64, with 32-bit PowerPC first. (I'm
1668 # guessing that's what Apple does.)
1670 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1671 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1672 V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1673 V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1678 # Leopard. Build libraries for 32-bit PowerPC,
1679 # 64-bit PowerPC, 32-bit x86, and x86-64, with
1680 # 32-bit PowerPC first, and build executables
1681 # for 32-bit x86 and 32-bit PowerPC, with 32-bit
1682 # x86 first. (That's what Apple does.)
1684 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1685 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1686 V_PROG_CCOPT_FAT="-arch i386 -arch ppc"
1687 V_PROG_LDFLAGS_FAT="-arch i386 -arch ppc"
1692 # Snow Leopard. Build libraries for x86-64,
1693 # 32-bit x86, and 32-bit PowerPC, with x86-64
1694 # first, and build executables for x86-64 and
1695 # 32-bit x86, with x86-64 first. (That's what
1696 # Apple does, even though Snow Leopard doesn't
1697 # run on PPC, so PPC libpcap runs under Rosetta,
1698 # and Rosetta doesn't support BPF ioctls, so PPC
1699 # programs can't do live captures.)
1701 V_LIB_CCOPT_FAT="-arch x86_64 -arch i386 -arch ppc"
1702 V_LIB_LDFLAGS_FAT="-arch x86_64 -arch i386 -arch ppc"
1703 V_PROG_CCOPT_FAT="-arch x86_64 -arch i386"
1704 V_PROG_LDFLAGS_FAT="-arch x86_64 -arch i386"
1709 # Post-Snow Leopard. Build libraries for x86-64
1710 # and 32-bit x86, with x86-64 first, and build
1711 # executables only for x86-64. (That's what
1712 # Apple does.) This requires no special flags
1714 # XXX - update if and when Apple drops support
1715 # for 32-bit x86 code and if and when Apple adds
1716 # ARM-based Macs. (You're on your own for iOS
1719 V_LIB_CCOPT_FAT="-arch x86_64 -arch i386"
1720 V_LIB_LDFLAGS_FAT="-arch x86_64 -arch i386"
1727 AC_DEFINE(HAVE_HPUX9,1,[on HP-UX 9.x])
1730 # Use System V conventions for man pages.
1732 MAN_ADMIN_COMMANDS=1m
1740 # Use System V conventions for man pages.
1742 MAN_ADMIN_COMMANDS=1m
1750 # Use System V conventions for man pages.
1752 MAN_ADMIN_COMMANDS=1m
1758 dnl HPUX 10.20 and above is similar to HPUX 9, but
1759 dnl not the same....
1761 dnl XXX - DYEXT should be set to "sl" if this is building
1762 dnl for 32-bit PA-RISC, but should be left as "so" for
1763 dnl 64-bit PA-RISC or, I suspect, IA-64.
1764 AC_DEFINE(HAVE_HPUX10_20_OR_LATER,1,[on HP-UX 10.20 or later])
1765 if test "`uname -m`" = "ia64"; then
1772 # "-b" builds a shared library; "+h" sets the soname.
1778 # Use System V conventions for man pages.
1786 # Use IRIX conventions for man pages; they're the same as the
1787 # System V conventions, except that they use section 8 for
1788 # administrative commands and daemons.
1794 linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*)
1798 # Compiler assumed to be GCC; run-time linker may require a -R
1801 if test "$libdir" != "/usr/lib"; then
1802 V_RFLAGS=-Wl,-R$libdir
1810 # DEC OSF/1, a/k/a Digial UNIX, a/k/a Tru64 UNIX.
1811 # Use Tru64 UNIX conventions for man pages; they're the same as
1812 # the System V conventions except that they use section 8 for
1813 # administrative commands and daemons.
1821 AC_MSG_CHECKING(if SINIX compiler defines sinix)
1822 AC_CACHE_VAL(ac_cv_cc_sinix_defined,
1826 ac_cv_cc_sinix_defined=yes,
1827 ac_cv_cc_sinix_defined=no))
1828 AC_MSG_RESULT($ac_cv_cc_sinix_defined)
1829 if test $ac_cv_cc_sinix_defined = no ; then
1830 AC_DEFINE(sinix,1,[on sinix])
1835 AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
1840 # Make sure errno is thread-safe, in case we're called in
1841 # a multithreaded program. We don't guarantee that two
1842 # threads can use the *same* pcap_t safely, but the
1843 # current version does guarantee that you can use different
1844 # pcap_t's in different threads, and even that pcap_compile()
1845 # is thread-safe (it wasn't thread-safe in some older versions).
1847 V_CCOPT="$V_CCOPT -D_TS_ERRNO"
1849 case "`uname -r`" in
1856 # Use System V conventions for man pages.
1858 MAN_ADMIN_COMMANDS=1m
1866 AC_ARG_ENABLE(shared,
1867 AC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@]))
1868 test "x$enable_shared" = "xno" && DYEXT="none"
1871 AC_CHECK_TOOL([AR], [ar])
1876 AC_LBL_DEVEL(V_CCOPT)
1879 # Check to see if the sockaddr struct has the 4.4 BSD sa_len member.
1881 AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,
1883 #include <sys/types.h>
1884 #include <sys/socket.h>
1888 # Check to see if there's a sockaddr_storage structure.
1890 AC_CHECK_TYPES(struct sockaddr_storage,,,
1892 #include <sys/types.h>
1893 #include <sys/socket.h>
1897 # Check to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
1898 # dl_module_id_1 member.
1900 # NOTE: any failure means we conclude that it doesn't have that member,
1901 # so if we don't have DLPI, don't have a <sys/dlpi_ext.h> header, or
1902 # have one that doesn't declare a dl_hp_ppa_info_t type, we conclude
1903 # it doesn't have that member (which is OK, as either we won't be
1904 # using code that would use that member, or we wouldn't compile in
1907 AC_CHECK_MEMBERS([dl_hp_ppa_info_t.dl_module_id_1],,,
1909 #include <sys/types.h>
1910 #include <sys/dlpi.h>
1911 #include <sys/dlpi_ext.h>
1915 AC_SUBST(V_LIB_CCOPT_FAT)
1916 AC_SUBST(V_LIB_LDFLAGS_FAT)
1917 AC_SUBST(V_PROG_CCOPT_FAT)
1918 AC_SUBST(V_PROG_LDFLAGS_FAT)
1920 AC_SUBST(V_FINDALLDEVS)
1924 AC_SUBST(V_SHLIB_CCOPT)
1925 AC_SUBST(V_SHLIB_CMD)
1926 AC_SUBST(V_SHLIB_OPT)
1927 AC_SUBST(V_SONAME_OPT)
1928 AC_SUBST(V_RPATH_OPT)
1931 AC_SUBST(ADDLARCHIVEOBJS)
1934 AC_SUBST(MAN_DEVICES)
1935 AC_SUBST(MAN_FILE_FORMATS)
1936 AC_SUBST(MAN_MISC_INFO)
1937 AC_SUBST(MAN_ADMIN_COMMANDS)
1938 AC_SUBST(PTHREAD_LIBS)
1939 AC_SUBST(BUILD_RPCAPD)
1940 AC_SUBST(INSTALL_RPCAPD)
1941 AC_SUBST(RPCAPD_LIBS)
1942 AC_SUBST(EXTRA_NETWORK_LIBS)
1944 AC_ARG_ENABLE([usb],
1945 [AC_HELP_STRING([--enable-usb],[enable USB capture support @<:@default=yes, if support available@:>@])],
1949 if test "xxx_only" = yes; then
1950 # User requested something-else-only pcap, so they don't
1955 if test "x$enable_usb" != "xno" ; then
1956 dnl check for USB sniffing support
1957 AC_MSG_CHECKING(for USB sniffing support)
1960 AC_DEFINE(PCAP_SUPPORT_USB, 1, [target host supports USB sniffing])
1961 USB_SRC=pcap-usb-linux.c
1963 ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null`
1964 if test $? -ne 0 ; then
1965 ac_usb_dev_name="usbmon"
1967 AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing])
1968 AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name)
1970 # Do we have a version of <linux/compiler.h> available?
1971 # If so, we might need it for <linux/usbdevice_fs.h>.
1973 AC_CHECK_HEADERS(linux/compiler.h)
1974 if test "$ac_cv_header_linux_compiler_h" = yes; then
1976 # Yes - include it when testing for <linux/usbdevice_fs.h>.
1978 AC_CHECK_HEADERS(linux/usbdevice_fs.h,,,[#include <linux/compiler.h>])
1980 AC_CHECK_HEADERS(linux/usbdevice_fs.h)
1982 if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then
1984 # OK, does it define bRequestType? Older versions of the kernel
1985 # define fields with names like "requesttype, "request", and
1986 # "value", rather than "bRequestType", "bRequest", and
1989 AC_CHECK_MEMBERS([struct usbdevfs_ctrltransfer.bRequestType],,,
1992 #ifdef HAVE_LINUX_COMPILER_H
1993 #include <linux/compiler.h>
1995 #include <linux/usbdevice_fs.h>
2001 # This just uses BPF in FreeBSD 8.4 and later; we don't need
2002 # to check for anything special for capturing.
2004 AC_MSG_RESULT([yes, in FreeBSD 8.4 and later])
2012 AC_SUBST(PCAP_SUPPORT_USB)
2015 dnl check for netfilter sniffing support
2016 if test "xxx_only" != yes; then
2017 AC_MSG_CHECKING(whether the platform could support netfilter sniffing)
2022 # Life's too short to deal with trying to get this to compile
2023 # if you don't get the right types defined with
2024 # __KERNEL_STRICT_NAMES getting defined by some other include.
2026 # Check whether the includes Just Work. If not, don't turn on
2027 # netfilter support.
2029 AC_MSG_CHECKING(whether we can compile the netfilter support)
2030 AC_CACHE_VAL(ac_cv_netfilter_can_compile,
2033 #include <sys/socket.h>
2034 #include <netinet/in.h>
2035 #include <linux/types.h>
2037 #include <linux/netlink.h>
2038 #include <linux/netfilter.h>
2039 #include <linux/netfilter/nfnetlink.h>
2040 #include <linux/netfilter/nfnetlink_log.h>
2041 #include <linux/netfilter/nfnetlink_queue.h>],
2043 ac_cv_netfilter_can_compile=yes,
2044 ac_cv_netfilter_can_compile=no))
2045 AC_MSG_RESULT($ac_cv_netfilter_can_compile)
2046 if test $ac_cv_netfilter_can_compile = yes ; then
2047 AC_DEFINE(PCAP_SUPPORT_NETFILTER, 1,
2048 [target host supports netfilter sniffing])
2049 NETFILTER_SRC=pcap-netfilter-linux.c
2057 AC_SUBST(PCAP_SUPPORT_NETFILTER)
2058 AC_SUBST(NETFILTER_SRC)
2060 AC_ARG_ENABLE([netmap],
2061 [AC_HELP_STRING([--enable-netmap],[enable netmap support @<:@default=yes, if support available@:>@])],
2063 [enable_netmap=yes])
2065 if test "x$enable_netmap" != "xno" ; then
2067 # Check whether net/netmap_user.h is usable if NETMAP_WITH_LIBS is
2068 # defined; it's not usable on DragonFly BSD 4.6 if NETMAP_WITH_LIBS
2069 # is defined, for example, as it includes a non-existent malloc.h
2072 AC_MSG_CHECKING(whether we can compile the netmap support)
2073 AC_CACHE_VAL(ac_cv_net_netmap_user_can_compile,
2076 #define NETMAP_WITH_LIBS
2077 #include <net/netmap_user.h>],
2079 ac_cv_net_netmap_user_can_compile=yes,
2080 ac_cv_net_netmap_user_can_compile=no))
2081 AC_MSG_RESULT($ac_cv_net_netmap_user_can_compile)
2082 if test $ac_cv_net_netmap_user_can_compile = yes ; then
2083 AC_DEFINE(PCAP_SUPPORT_NETMAP, 1,
2084 [target host supports netmap])
2085 NETMAP_SRC=pcap-netmap.c
2087 AC_SUBST(PCAP_SUPPORT_NETMAP)
2088 AC_SUBST(NETMAP_SRC)
2092 AC_ARG_ENABLE([bluetooth],
2093 [AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
2095 [enable_bluetooth=ifsupportavailable])
2097 if test "xxx_only" = yes; then
2098 # User requested something-else-only pcap, so they don't
2099 # want Bluetooth support.
2103 if test "x$enable_bluetooth" != "xno" ; then
2104 dnl check for Bluetooth sniffing support
2107 AC_CHECK_HEADER(bluetooth/bluetooth.h,
2110 # We have bluetooth.h, so we support Bluetooth
2113 AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
2114 BT_SRC=pcap-bt-linux.c
2115 AC_MSG_NOTICE(Bluetooth sniffing is supported)
2116 ac_lbl_bluetooth_available=yes
2119 # OK, does struct sockaddr_hci have an hci_channel
2122 AC_CHECK_MEMBERS([struct sockaddr_hci.hci_channel],
2125 # Yes; is HCI_CHANNEL_MONITOR defined?
2127 AC_MSG_CHECKING(if HCI_CHANNEL_MONITOR is defined)
2128 AC_CACHE_VAL(ac_cv_lbl_hci_channel_monitor_is_defined,
2131 #include <bluetooth/bluetooth.h>
2132 #include <bluetooth/hci.h>
2135 u_int i = HCI_CHANNEL_MONITOR;
2139 AC_DEFINE(PCAP_SUPPORT_BT_MONITOR,,
2140 [target host supports Bluetooth Monitor])
2141 BT_MONITOR_SRC=pcap-bt-monitor-linux.c
2148 #include <bluetooth/bluetooth.h>
2149 #include <bluetooth/hci.h>
2154 # We don't have bluetooth.h, so we don't support
2155 # Bluetooth sniffing.
2157 if test "x$enable_bluetooth" = "xyes" ; then
2158 AC_MSG_ERROR(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2160 AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2165 if test "x$enable_bluetooth" = "xyes" ; then
2166 AC_MSG_ERROR(no Bluetooth sniffing support implemented for $host_os)
2168 AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os)
2172 AC_SUBST(PCAP_SUPPORT_BT)
2174 AC_SUBST(BT_MONITOR_SRC)
2177 AC_ARG_ENABLE([dbus],
2178 [AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
2180 [enable_dbus=ifavailable])
2182 if test "xxx_only" = yes; then
2183 # User requested something-else-only pcap, so they don't
2184 # want D-Bus support.
2188 if test "x$enable_dbus" != "xno"; then
2189 if test "x$enable_dbus" = "xyes"; then
2194 # We don't support D-Bus sniffing on macOS; see
2196 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
2198 # The user requested it, so fail.
2200 AC_MSG_ERROR([Due to freedesktop.org bug 74029, D-Bus capture support is not available on macOS])
2207 # We don't support D-Bus sniffing on macOS; see
2209 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
2211 # The user dind't explicitly request it, so just
2212 # silently refuse to enable it.
2220 if test "x$enable_dbus" != "xno"; then
2221 AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no])
2222 if test "x$PKGCONFIG" != "xno"; then
2223 AC_MSG_CHECKING([for D-Bus])
2224 if "$PKGCONFIG" dbus-1; then
2225 AC_MSG_RESULT([yes])
2226 DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
2227 DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
2228 save_CFLAGS="$CFLAGS"
2230 CFLAGS="$CFLAGS $DBUS_CFLAGS"
2231 LIBS="$LIBS $DBUS_LIBS"
2232 AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
2234 [#include <string.h>
2237 #include <sys/time.h>
2239 #include <dbus/dbus.h>],
2240 [return dbus_connection_read_write(NULL, 0);],
2242 AC_MSG_RESULT([yes])
2243 AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
2244 DBUS_SRC=pcap-dbus.c
2245 V_INCLS="$V_INCLS $DBUS_CFLAGS"
2249 if test "x$enable_dbus" = "xyes"; then
2250 AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
2254 CFLAGS="$save_CFLAGS"
2257 if test "x$enable_dbus" = "xyes"; then
2258 AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed])
2262 AC_SUBST(PCAP_SUPPORT_DBUS)
2266 AC_ARG_ENABLE([rdma],
2267 [AC_HELP_STRING([--enable-rdma],[enable RDMA capture support @<:@default=yes, if support available@:>@])],
2269 [enable_rdmasniff=ifavailable])
2271 if test "xxx_only" = yes; then
2272 # User requested something-else-only pcap, so they don't
2273 # want RDMA support.
2277 if test "x$enable_rdmasniff" != "xno"; then
2278 AC_CHECK_LIB(ibverbs, ibv_get_device_list, [
2279 AC_CHECK_HEADER(infiniband/verbs.h, [
2281 # ibv_create_flow may be defined as a static inline
2282 # function in infiniband/verbs.h, so we can't
2285 # Too bad autoconf has no AC_SYMBOL_EXISTS()
2286 # macro that works like CMake's check_symbol_exists()
2287 # function, to check do a compile check like
2288 # this (they do a clever trick to avoid having
2289 # to know the function's signature).
2291 AC_MSG_CHECKING(whether libibverbs defines ibv_create_flow)
2294 #include <infiniband/verbs.h>
2297 (void) ibv_create_flow((struct ibv_qp *) NULL,
2298 (struct ibv_flow_attr *) NULL);
2301 AC_MSG_RESULT([yes])
2302 AC_DEFINE(PCAP_SUPPORT_RDMASNIFF, , [target host supports RDMA sniffing])
2303 RDMA_SRC=pcap-rdmasniff.c
2304 LIBS="-libverbs $LIBS"
2312 AC_SUBST(PCAP_SUPPORT_RDMASNIFF)
2318 AC_CONFIG_HEADER(config.h)
2320 AC_OUTPUT_COMMANDS([if test -f .devel; then
2321 echo timestamp > stamp-h
2322 cat $srcdir/Makefile-devel-adds >> Makefile
2325 AC_OUTPUT(Makefile pcap-filter.manmisc pcap-linktype.manmisc
2326 pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap
2327 pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap
2328 pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap
2329 pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap
2330 pcap_open_offline.3pcap pcap_set_immediate_mode.3pcap
2331 pcap_set_tstamp_precision.3pcap pcap_set_tstamp_type.3pcap
2332 rpcapd/Makefile rpcapd/rpcapd.manadmin testprogs/Makefile)