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 # https://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 # We require C99 or later.
28 # Try to get it, which may involve adding compiler flags;
29 # if that fails, give up.
32 if test "$ac_cv_prog_cc_c99" = "no"; then
33 AC_MSG_ERROR([The C compiler does not support C99])
38 # Haiku's platform file is in C++.
44 AC_LBL_C_INIT(V_CCOPT, V_INCLS)
50 # Try to arrange for large file support.
56 dnl Even if <net/bpf.h> were, on all OSes that support BPF, fixed to
57 dnl include <sys/ioccom.h>, and we were to drop support for older
58 dnl releases without that fix, so that pcap-bpf.c doesn't need to
59 dnl include <sys/ioccom.h>, the test program in "AC_LBL_FIXINCLUDES"
60 dnl in "aclocal.m4" uses it, so we would still have to test for it
61 dnl and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
62 dnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris.
64 AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h)
65 AC_CHECK_HEADERS(netpacket/packet.h)
70 # Haiku needs _BSD_SOURCE for the _IO* macros because it doesn't use them.
72 CFLAGS="$CFLAGS -D_BSD_SOURCE"
78 AC_CHECK_FUNCS(strerror)
79 AC_CHECK_FUNC(strerror_r,
82 # We have strerror_r; if we define _GNU_SOURCE, is it a
83 # POSIX-compliant strerror_r() or a GNU strerror_r()?
85 AC_MSG_CHECKING(whether strerror_r is GNU-style)
92 /* Define it GNU-style; that will cause an error if it's not GNU-style */
93 extern char *strerror_r(int, char *, size_t);
105 AC_DEFINE(HAVE_GNU_STRERROR_R,,
106 [Define to 1 if you have a GNU-style `strerror_r' function.])
110 AC_DEFINE(HAVE_POSIX_STRERROR_R,,
111 [Define to 1 if you have a POSIX-style `strerror_r' function.])
116 # We don't have strerror_r; do we have _wcserror_s?
118 AC_CHECK_FUNCS(_wcserror_s)
122 # Thanks, IBM, for not providing vsyslog() in AIX!
124 AC_CHECK_FUNCS(vsyslog)
127 # Make sure we have vsnprintf() and snprintf(); we require them.
129 AC_CHECK_FUNC(vsnprintf,,
130 AC_MSG_ERROR([vsnprintf() is required but wasn't found]))
131 AC_CHECK_FUNC(snprintf,,
132 AC_MSG_ERROR([snprintf() is required but wasn't found]))
135 AC_CHECK_FUNCS(vasprintf asprintf,,
137 if test $needasprintf = yes; then
138 AC_LIBOBJ([asprintf])
142 AC_CHECK_FUNCS(strlcat,,
144 if test $needstrlcat = yes; then
149 AC_CHECK_FUNCS(strlcpy,,
151 if test $needstrlcpy = yes; then
156 AC_CHECK_FUNCS(strtok_r,,
158 if test $needstrtok_r = yes; then
159 AC_LIBOBJ([strtok_r])
163 # Do we have ffs(), and is it declared in <strings.h>?
166 if test "$ac_cv_func_ffs" = yes; then
168 # We have ffs(); is it declared in <strings.h>?
170 # This test fails if we don't have <strings.h> or if we do
171 # but it doesn't declare ffs().
175 AC_DEFINE(STRINGS_H_DECLARES_FFS,,
176 [Define to 1 if strings.h declares `ffs'])
184 # Do this before checking for ether_hostton(), as it's a
185 # "getaddrinfo()-ish function".
190 # Check for reentrant versions of getnetbyname_r(), as provided by
191 # Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!).
192 # If we don't find one, we just use getnetbyname(), which uses
193 # thread-specific data on many platforms, but doesn't use it on
194 # NetBSD or OpenBSD, and may not use it on older versions of other
197 # Only do the check if we have a declaration of getnetbyname_r();
198 # without it, we can't check which API it has. (We assume that
199 # if there's a declaration, it has a prototype, so that the API
202 AC_CHECK_DECL(getnetbyname_r,
204 AC_MSG_CHECKING([for the Linux getnetbyname_r()])
206 [#include <netdb.h>],
208 struct netent netent_buf;
210 struct netent *resultp;
213 return getnetbyname_r((const char *)0, &netent_buf, buf, sizeof buf, &resultp, &h_errnoval);
217 AC_DEFINE(HAVE_LINUX_GETNETBYNAME_R, 1,
218 [define if we have the Linux getnetbyname_r()])
223 AC_MSG_CHECKING([for Solaris/IRIX getnetbyname_r()])
225 [#include <netdb.h>],
227 struct netent netent_buf;
230 return getnetbyname_r((const char *)0, &netent_buf, buf, (int)sizeof buf) != NULL;
234 AC_DEFINE(HAVE_SOLARIS_IRIX_GETNETBYNAME_R, 1,
235 [define if we have the Solaris/IRIX getnetbyname_r()])
240 AC_MSG_CHECKING([for AIX getnetbyname_r()])
242 [#include <netdb.h>],
244 struct netent netent_buf;
245 struct netent_data net_data;
247 return getnetbyname_r((const char *)0, &netent_buf, &net_data);
251 AC_DEFINE(HAVE_AIX_GETNETBYNAME_R, 1,
252 [define if we have the AIX getnetbyname_r()])
259 ],,[#include <netdb.h>])
262 # Check for reentrant versions of getprotobyname_r(), as provided by
263 # Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!).
264 # If we don't find one, we just use getprotobyname(), which uses
265 # thread-specific data on many platforms, but doesn't use it on
266 # NetBSD or OpenBSD, and may not use it on older versions of other
269 # Only do the check if we have a declaration of getprotobyname_r();
270 # without it, we can't check which API it has. (We assume that
271 # if there's a declaration, it has a prototype, so that the API
274 AC_CHECK_DECL(getprotobyname_r,
276 AC_MSG_CHECKING([for the Linux getprotobyname_r()])
278 [#include <netdb.h>],
280 struct protoent protoent_buf;
282 struct protoent *resultp;
284 return getprotobyname_r((const char *)0, &protoent_buf, buf, sizeof buf, &resultp);
288 AC_DEFINE(HAVE_LINUX_GETPROTOBYNAME_R, 1,
289 [define if we have the Linux getprotobyname_r()])
294 AC_MSG_CHECKING([for Solaris/IRIX getprotobyname_r()])
296 [#include <netdb.h>],
298 struct protoent protoent_buf;
301 return getprotobyname_r((const char *)0, &protoent_buf, buf, (int)sizeof buf) != NULL;
305 AC_DEFINE(HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R, 1,
306 [define if we have the Solaris/IRIX getprotobyname_r()])
311 AC_MSG_CHECKING([for AIX getprotobyname_r()])
313 [#include <netdb.h>],
315 struct protoent protoent_buf;
316 struct protoent_data proto_data;
318 return getprotobyname_r((const char *)0, &protoent_buf, &proto_data);
322 AC_DEFINE(HAVE_AIX_GETPROTOBYNAME_R, 1,
323 [define if we have the AIX getprotobyname_r()])
330 ],,[#include <netdb.h>])
333 # You are in a twisty little maze of UN*Xes, all different.
334 # Some might not have ether_hostton().
335 # Some might have it and declare it in <net/ethernet.h>.
336 # Some might have it and declare it in <netinet/ether.h>
337 # Some might have it and declare it in <sys/ethernet.h>.
338 # Some might have it and declare it in <arpa/inet.h>.
339 # Some might have it and declare it in <netinet/if_ether.h>.
340 # Some might have it and not declare it in any header file.
342 # Before you is a C compiler.
344 AC_CHECK_FUNCS(ether_hostton)
345 if test "$ac_cv_func_ether_hostton" = yes; then
347 # OK, we have ether_hostton(). Is it declared in <net/ethernet.h>?
349 # This test fails if we don't have <net/ethernet.h> or if we do
350 # but it doesn't declare ether_hostton().
352 AC_CHECK_DECL(ether_hostton,
354 AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_HOSTTON,,
355 [Define to 1 if net/ethernet.h declares `ether_hostton'])
358 #include <net/ethernet.h>
363 if test "$ac_cv_have_decl_ether_hostton" != yes; then
365 # No, how about <netinet/ether.h>, as on Linux?
367 # This test fails if we don't have <netinet/ether.h>
368 # or if we do but it doesn't declare ether_hostton().
370 # Unset ac_cv_have_decl_ether_hostton so we don't
371 # treat the previous failure as a cached value and
372 # suppress the next test.
374 unset ac_cv_have_decl_ether_hostton
375 AC_CHECK_DECL(ether_hostton,
377 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON,,
378 [Define to 1 if netinet/ether.h declares `ether_hostton'])
381 #include <netinet/ether.h>
387 if test "$ac_cv_have_decl_ether_hostton" != yes; then
389 # No, how about <sys/ethernet.h>, as on Solaris 10
392 # This test fails if we don't have <sys/ethernet.h>
393 # or if we do but it doesn't declare ether_hostton().
395 # Unset ac_cv_have_decl_ether_hostton so we don't
396 # treat the previous failure as a cached value and
397 # suppress the next test.
399 unset ac_cv_have_decl_ether_hostton
400 AC_CHECK_DECL(ether_hostton,
402 AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON,,
403 [Define to 1 if sys/ethernet.h declares `ether_hostton'])
406 #include <sys/ethernet.h>
412 if test "$ac_cv_have_decl_ether_hostton" != yes; then
414 # No, how about <arpa/inet.h>, as in AIX?
416 # This test fails if we don't have <arpa/inet.h>
417 # (if we have ether_hostton(), we should have
418 # networking, and if we have networking, we should
419 # have <arapa/inet.h>) or if we do but it doesn't
420 # declare ether_hostton().
422 # Unset ac_cv_have_decl_ether_hostton so we don't
423 # treat the previous failure as a cached value and
424 # suppress the next test.
426 unset ac_cv_have_decl_ether_hostton
427 AC_CHECK_DECL(ether_hostton,
429 AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_HOSTTON,,
430 [Define to 1 if arpa/inet.h declares `ether_hostton'])
433 #include <arpa/inet.h>
439 if test "$ac_cv_have_decl_ether_hostton" != yes; then
441 # No, how about <netinet/if_ether.h>?
442 # On some platforms, it requires <net/if.h> and
443 # <netinet/in.h>, and we always include it with
444 # both of them, so test it with both of them.
446 # This test fails if we don't have <netinet/if_ether.h>
447 # and the headers we include before it, or if we do but
448 # <netinet/if_ether.h> doesn't declare ether_hostton().
450 # Unset ac_cv_have_decl_ether_hostton so we don't
451 # treat the previous failure as a cached value and
452 # suppress the next test.
454 unset ac_cv_have_decl_ether_hostton
455 AC_CHECK_DECL(ether_hostton,
457 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON,,
458 [Define to 1 if netinet/if_ether.h declares `ether_hostton'])
461 #include <sys/types.h>
462 #include <sys/socket.h>
464 #include <netinet/in.h>
465 #include <netinet/if_ether.h>
469 # After all that, is ether_hostton() declared?
471 if test "$ac_cv_have_decl_ether_hostton" = yes; then
475 AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1,
476 [Define to 1 if you have the declaration of `ether_hostton'])
479 # No, we'll have to declare it ourselves.
480 # Do we have "struct ether_addr" if we include
481 # <netinet/if_ether.h>?
483 AC_CHECK_TYPES(struct ether_addr,,,
485 #include <sys/types.h>
486 #include <sys/socket.h>
488 #include <netinet/in.h>
489 #include <netinet/if_ether.h>
495 # For various things that might use pthreads.
497 AC_CHECK_HEADER(pthread.h,
500 # OK, we have pthread.h. Do we have pthread_create in the
503 AC_CHECK_FUNC(pthread_create,
508 ac_lbl_have_pthreads="found"
512 # No - do we have it in -lpthreads?
514 AC_CHECK_LIB(pthreads, pthread_create,
517 # Yes - add -lpthreads.
519 ac_lbl_have_pthreads="found"
520 PTHREAD_LIBS="$PTHREAD_LIBS -lpthreads"
524 # No - do we have it in -lpthread?
526 AC_CHECK_LIB(pthread, pthread_create,
529 # Yes - add -lpthread.
531 ac_lbl_have_pthreads="found"
532 PTHREAD_LIBS="$PTHREAD_LIBS -lpthread"
538 ac_lbl_have_pthreads="not found"
545 # We didn't find pthread.h.
547 ac_lbl_have_pthreads="not found"
551 dnl to pacify those who hate protochain insn
552 AC_MSG_CHECKING(if --disable-protochain option is specified)
553 AC_ARG_ENABLE(protochain,
554 AS_HELP_STRING([--disable-protochain],[disable \"protochain\" insn]))
555 case "x$enable_protochain" in
556 xyes) enable_protochain=enabled ;;
557 xno) enable_protochain=disabled ;;
558 x) enable_protochain=enabled ;;
561 if test "$enable_protochain" = "disabled"; then
562 AC_DEFINE(NO_PROTOCHAIN,1,[do not use protochain])
564 AC_MSG_RESULT(${enable_protochain})
567 # valgrindtest directly uses the native capture mechanism, but
568 # only tests with BPF and PF_PACKET sockets; only enable it if
569 # we have BPF or PF_PACKET sockets.
574 AS_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE]))
575 if test ! -z "$with_pcap" ; then
579 # Check for a bunch of headers for various packet
580 # capture mechanisms.
582 AC_CHECK_HEADERS(net/bpf.h)
583 if test "$ac_cv_header_net_bpf_h" = yes; then
585 # Does it define BIOCSETIF?
586 # I.e., is it a header for an LBL/BSD-style capture
587 # mechanism, or is it just a header for a BPF filter
588 # engine? Some versions of Arch Linux, for example,
589 # have a net/bpf.h that doesn't define BIOCSETIF;
590 # as it's a Linux, it should use packet sockets,
595 # sys/types.h, because FreeBSD 10's net/bpf.h
596 # requires that various BSD-style integer types
599 # sys/time.h, because AIX 5.2 and 5.3's net/bpf.h
600 # doesn't include it but does use struct timeval
601 # in ioctl definitions;
603 # sys/ioctl.h and, if we have it, sys/ioccom.h,
604 # because net/bpf.h defines ioctls;
606 # net/if.h, because it defines some structures
607 # used in ioctls defined by net/bpf.h;
609 # sys/socket.h, because OpenBSD 5.9's net/bpf.h
610 # defines some structure fields as being
613 # and net/bpf.h doesn't necessarily include all
614 # of those headers itself.
616 AC_MSG_CHECKING(if net/bpf.h defines BIOCSETIF)
617 AC_CACHE_VAL(ac_cv_lbl_bpf_h_defines_biocsetif,
620 #include <sys/types.h>
621 #include <sys/time.h>
622 #include <sys/ioctl.h>
623 #include <sys/socket.h>
624 #ifdef HAVE_SYS_IOCCOM_H
625 #include <sys/ioccom.h>
630 [u_int i = BIOCSETIF;],
631 ac_cv_lbl_bpf_h_defines_biocsetif=yes,
632 ac_cv_lbl_bpf_h_defines_biocsetif=no))
633 AC_MSG_RESULT($ac_cv_lbl_bpf_h_defines_biocsetif)
635 AC_CHECK_HEADERS(net/pfilt.h net/enet.h)
636 AC_CHECK_HEADERS(net/nit.h sys/net/nit.h)
637 AC_CHECK_HEADERS(linux/socket.h net/raw.h sys/dlpi.h)
638 AC_CHECK_HEADERS(config/HaikuConfig.h)
640 if test "$ac_cv_lbl_bpf_h_defines_biocsetif" = yes; then
643 # Check this before DLPI, so that we pick BPF on
644 # Solaris 11 and later.
649 # We have BPF, so build valgrindtest with "make test"
650 # on macOS and FreeBSD (add your OS once there's a
655 freebsd*|darwin*|linux*)
656 VALGRINDTEST_SRC=valgrindtest.c
659 elif test "$ac_cv_header_linux_socket_h" = yes; then
661 # No prizes for guessing this one.
664 VALGRINDTEST_SRC=valgrindtest.c
665 elif test "$ac_cv_header_net_pfilt_h" = yes; then
667 # DEC OSF/1, Digital UNIX, Tru64 UNIX
670 elif test "$ac_cv_header_net_enet_h" = yes; then
672 # Stanford Enetfilter.
675 elif test "$ac_cv_header_net_nit_h" = yes; then
677 # SunOS 4.x STREAMS NIT.
680 elif test "$ac_cv_header_sys_net_nit_h" = yes; then
682 # Pre-SunOS 4.x non-STREAMS NIT.
685 elif test "$ac_cv_header_net_raw_h" = yes; then
690 elif test "$ac_cv_header_sys_dlpi_h" = yes; then
692 # DLPI on pre-Solaris 11 SunOS 5, HP-UX, possibly others.
695 elif test "$ac_cv_header_config_HaikuConfig_h" = yes; then
702 # Nothing we support.
705 AC_MSG_WARN(cannot determine packet capture interface)
706 AC_MSG_WARN((see the INSTALL doc for more info))
709 AC_MSG_CHECKING(packet capture type)
710 AC_MSG_RESULT($V_PCAP)
711 AC_SUBST(VALGRINDTEST_SRC)
714 # Do we have pkg-config?
719 # Do we have the brew command from Homebrew?
721 AC_PATH_PROG([BREW], [brew])
724 # Handle each capture type.
729 # Checks for some header files.
731 AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
734 # Checks to see if Solaris has the public libdlpi(3LIB) library.
735 # Note: The existence of /usr/include/libdlpi.h does not mean it is the
736 # public libdlpi(3LIB) version. Before libdlpi was made public, a
737 # private version also existed, which did not have the same APIs.
738 # Due to a gcc bug, the default search path for 32-bit libraries does
739 # not include /lib, we add it explicitly here.
740 # [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485].
741 # Also, due to the bug above applications that link to libpcap with
742 # libdlpi will have to add "-L/lib" option to "configure".
744 save_LDFLAGS="$LDFLAGS"
745 LDFLAGS="$LIBS -L/lib"
746 AC_CHECK_LIB(dlpi, dlpi_walk,
752 # Capture module plus common code needed for
753 # common functions used by pcap-[dlpi,libdlpi].c
755 PLATFORM_C_SRC="pcap-libdlpi.c dlpisubs.c"
756 AC_DEFINE(HAVE_LIBDLPI,1,[if libdlpi exists])
762 # Capture module plus common code needed for
763 # common functions used by pcap-[dlpi,libdlpi].c
765 PLATFORM_C_SRC="pcap-dlpi.c dlpisubs.c"
767 LDFLAGS="$save_LDFLAGS"
770 # Checks whether <sys/dlpi.h> is usable, to catch weird SCO
773 AC_MSG_CHECKING(whether <sys/dlpi.h> is usable)
774 AC_CACHE_VAL(ac_cv_sys_dlpi_usable,
777 #include <sys/types.h>
778 #include <sys/time.h>
779 #include <sys/dlpi.h>
781 [int i = DL_PROMISC_PHYS;],
782 ac_cv_sys_dlpi_usable=yes,
783 ac_cv_sys_dlpi_usable=no))
784 AC_MSG_RESULT($ac_cv_sys_dlpi_usable)
785 if test $ac_cv_sys_dlpi_usable = no ; then
786 AC_MSG_ERROR(<sys/dlpi.h> is not usable on this system; it probably has a non-standard DLPI)
790 # Check to see if Solaris has the dl_passive_req_t struct defined
792 # This check is for DLPI support for passive modes.
793 # See dlpi(7P) for more details.
795 AC_CHECK_TYPES(dl_passive_req_t,,,
797 #include <sys/types.h>
798 #include <sys/dlpi.h>
806 PLATFORM_C_SRC="pcap-enet.c"
813 PLATFORM_CXX_SRC="pcap-haiku.cpp"
816 # Just for the sake of it.
818 AC_CHECK_HEADERS(net/if.h net/if_dl.h net/if_types.h)
825 PLATFORM_C_SRC="pcap-linux.c"
828 # Do we have the wireless extensions?
830 AC_CHECK_HEADERS(linux/wireless.h, [], [],
832 #include <sys/socket.h>
833 #include <linux/if.h>
834 #include <linux/types.h>
839 # We only want version 3. Version 2 was, apparently,
840 # short-lived, and version 1 is source and binary
841 # incompatible with version 3, and it appears that,
842 # these days, everybody's using version 3. We're
843 # not supporting older versions of the Linux kernel;
844 # let's drop support for older versions of libnl, too.
847 AS_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]),
848 with_libnl=$withval,with_libnl=if_available)
850 if test x$with_libnl != xno ; then
852 # Check for libnl-genl-3.0 with pkg-config.
854 PKG_CHECK_MODULES(LIBNL, libnl-genl-3.0,
856 pkg_config_found_libnl=yes
857 V_INCLS="$V_INCLS $LIBNL_CFLAGS"
858 LIBS="$LIBNL_LIBS $LIBS"
859 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
862 if test x$pkg_config_found_libnl != xyes; then
864 # OK, either we don't have pkg-config or there
865 # wasn't a .pc file for it; Check for it directly.
867 case "$with_libnl" in
870 incdir=-I/usr/include/libnl3
875 if test -d $withval; then
876 libnldir=-L${withval}/lib
877 incdir=-I${withval}/include
882 AC_CHECK_LIB(nl-3, nl_socket_alloc,
885 # Yes, we have libnl 3.x.
887 LIBS="${libnldir} -lnl-genl-3 -lnl-3 $LIBS"
888 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
889 V_INCLS="$V_INCLS ${incdir}"
892 # No, we don't have libnl at all.
893 # Fail if the user explicitly requested
896 if test x$with_libnl = xyes ; then
897 AC_MSG_ERROR([libnl support requested but libnl not found])
899 ], ${incdir} ${libnldir} -lnl-genl-3 -lnl-3 )
904 # Check to see if the tpacket_auxdata struct has a tp_vlan_tci member.
906 # NOTE: any failure means we conclude that it doesn't have that
907 # member, so if we don't have tpacket_auxdata, we conclude it
908 # doesn't have that member (which is OK, as either we won't be
909 # using code that would use that member, or we wouldn't compile
911 AC_CHECK_MEMBERS([struct tpacket_auxdata.tp_vlan_tci],,,
913 #include <sys/types.h>
914 #include <linux/if_packet.h>
922 PLATFORM_C_SRC="pcap-bpf.c"
925 # Check whether we have the *BSD-style ioctls.
927 AC_CHECK_HEADERS(net/if_media.h)
930 # Check whether we have struct BPF_TIMEVAL.
932 AC_CHECK_TYPES(struct BPF_TIMEVAL,,,
934 #include <sys/types.h>
935 #include <sys/ioctl.h>
936 #ifdef HAVE_SYS_IOCCOM_H
937 #include <sys/ioccom.h>
947 PLATFORM_C_SRC="pcap-pf.c"
954 PLATFORM_C_SRC="pcap-snit.c"
961 PLATFORM_C_SRC="pcap-snoop.c"
966 # --with-pcap=dag is the only way to get here, and it means
967 # "DAG support but nothing else"
969 V_DEFS="$V_DEFS -DDAG_ONLY"
970 PLATFORM_C_SRC="pcap-dag.c"
976 # --with-pcap=dpdk is the only way to get here, and it means
977 # "DPDK support but nothing else"
979 V_DEFS="$V_DEFS -DDPDK_ONLY"
980 PLATFORM_C_SRC="pcap-dpdk.c"
986 # --with-pcap=septel is the only way to get here, and it means
987 # "Septel support but nothing else"
989 V_DEFS="$V_DEFS -DSEPTEL_ONLY"
990 PLATFORM_C_SRC="pcap-septel.c"
996 # --with-pcap=snf is the only way to get here, and it means
997 # "SNF support but nothing else"
999 V_DEFS="$V_DEFS -DSNF_ONLY"
1000 PLATFORM_C_SRC="pcap-snf.c"
1008 PLATFORM_C_SRC="pcap-null.c"
1012 AC_MSG_ERROR($V_PCAP is not a valid pcap type)
1017 dnl Now figure out how we get a list of interfaces and addresses,
1018 dnl if we support capturing. Don't bother if we don't support
1021 if test "$V_PCAP" != null
1023 AC_CHECK_FUNC(getifaddrs,[
1025 # We have "getifaddrs()"; make sure we have <ifaddrs.h>
1026 # as well, just in case some platform is really weird.
1028 AC_CHECK_HEADER(ifaddrs.h,[
1030 # We have the header, so we use "getifaddrs()" to
1031 # get the list of interfaces.
1033 PLATFORM_C_SRC="$PLATFORM_C_SRC fad-getad.c"
1036 # We don't have the header - give up.
1037 # XXX - we could also fall back on some other
1038 # mechanism, but, for now, this'll catch this
1039 # problem so that we can at least try to figure
1040 # out something to do on systems with "getifaddrs()"
1041 # but without "ifaddrs.h", if there is something
1042 # we can do on those systems.
1044 AC_MSG_ERROR([Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>.])
1048 # Well, we don't have "getifaddrs()", at least not with the
1049 # libraries with which we've decided we need to link
1050 # libpcap with, so we have to use some other mechanism.
1052 # Note that this may happen on Solaris, which has
1053 # getifaddrs(), but in -lsocket, not in -lxnet, so we
1054 # won't find it if we link with -lxnet, which we want
1055 # to do for other reasons.
1057 # For now, we use either the SIOCGIFCONF ioctl or the
1058 # SIOCGLIFCONF ioctl, preferring the latter if we have
1059 # it; the latter is a Solarisism that first appeared
1060 # in Solaris 8. (Solaris's getifaddrs() appears to
1061 # be built atop SIOCGLIFCONF; using it directly
1062 # avoids a not-all-that-useful middleman.)
1064 AC_MSG_CHECKING(whether we have SIOCGLIFCONF)
1065 AC_CACHE_VAL(ac_cv_lbl_have_siocglifconf,
1067 [#include <sys/param.h>
1068 #include <sys/file.h>
1069 #include <sys/ioctl.h>
1070 #include <sys/socket.h>
1071 #include <sys/sockio.h>],
1072 [ioctl(0, SIOCGLIFCONF, (char *)0);],
1073 ac_cv_lbl_have_siocglifconf=yes,
1074 ac_cv_lbl_have_siocglifconf=no))
1075 AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
1076 if test $ac_cv_lbl_have_siocglifconf = yes ; then
1077 PLATFORM_C_SRC="$PLATFORM_C_SRC fad-glifc.c"
1079 PLATFORM_C_SRC="$PLATFORM_C_SRC fad-gifc.c"
1084 dnl check for hardware timestamp support
1087 AC_CHECK_HEADERS([linux/net_tstamp.h])
1090 AC_MSG_NOTICE(no hardware timestamp support implemented for $host_os)
1095 # Check for socklen_t.
1097 AC_CHECK_TYPES(socklen_t,,,
1099 #include <sys/types.h>
1100 #include <sys/socket.h>
1104 AS_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes@:>@]),
1107 if test "$enable_ipv6" != "no"; then
1109 # We've already made sure we have getaddrinfo above in
1110 # AC_LBL_LIBRARY_NET.
1112 AC_DEFINE(INET6,1,[IPv6])
1115 # Check for Endace DAG card support.
1117 AS_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1119 if test "$withval" = no
1121 # User doesn't want DAG support.
1123 elif test "$withval" = yes
1125 # User wants DAG support but hasn't specified a directory.
1128 # User wants DAG support and has specified a directory, so use the provided value.
1133 if test "$V_PCAP" = dag; then
1134 # User requested DAG-only libpcap, so we'd better have
1137 elif test "xxx_only" = yes; then
1138 # User requested something-else-only pcap, so they don't
1143 # Use DAG API if present, otherwise don't
1149 AC_ARG_WITH([dag-includes],
1150 AS_HELP_STRING([--with-dag-includes=IDIR],[Endace DAG include directory, if not DIR/include]),
1152 # User wants DAG support and has specified a header directory, so use the provided value.
1154 dag_include_dir=$withval
1157 AC_ARG_WITH([dag-libraries],
1158 AS_HELP_STRING([--with-dag-libraries=LDIR],[Endace DAG library directory, if not DIR/lib]),
1160 # User wants DAG support and has specified a library directory, so use the provided value.
1162 dag_lib_dir=$withval
1165 if test "$want_dag" != no; then
1167 # If necessary, set default paths for DAG API headers and libraries.
1168 if test -z "$dag_root"; then
1172 if test -z "$dag_include_dir"; then
1173 dag_include_dir="$dag_root/include"
1176 if test -z "$dag_lib_dir"; then
1177 dag_lib_dir="$dag_root/lib"
1179 # Handle multiarch systems.
1181 if test -d "$dag_lib_dir/$host"
1183 dag_lib_dir="$dag_lib_dir/$host"
1187 save_CFLAGS="$CFLAGS"
1188 CFLAGS="$CFLAGS -I$dag_include_dir"
1189 AC_CHECK_HEADERS([dagapi.h])
1191 if test "$ac_cv_header_dagapi_h" = yes; then
1193 V_INCLS="$V_INCLS -I$dag_include_dir"
1195 if test $V_PCAP != dag ; then
1196 MODULE_C_SRC="$MODULE_C_SRC pcap-dag.c"
1199 # Check for various DAG API functions.
1200 # Don't need to save and restore LIBS to prevent -ldag being
1201 # included if there's a found-action (arg 3).
1202 save_LDFLAGS="$LDFLAGS"
1203 LDFLAGS="-L$dag_lib_dir"
1204 AC_CHECK_LIB([dag], [dag_attach_stream],
1206 [AC_MSG_ERROR(DAG library lacks streams support)])
1207 AC_CHECK_LIB([dag], [dag_attach_stream64], [dag_large_streams="1"], [dag_large_streams="0"])
1208 AC_CHECK_LIB([dag],[dag_get_erf_types], [
1209 AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])])
1210 AC_CHECK_LIB([dag],[dag_get_stream_erf_types], [
1211 AC_DEFINE(HAVE_DAG_GET_STREAM_ERF_TYPES, 1, [define if you have dag_get_stream_erf_types()])])
1213 LDFLAGS="$save_LDFLAGS"
1216 # We assume that if we have libdag we have libdagconf,
1217 # as they're installed at the same time from the same
1220 LIBS="$LIBS -ldag -ldagconf"
1221 LDFLAGS="$LDFLAGS -L$dag_lib_dir"
1223 if test "$dag_large_streams" = 1; then
1224 AC_DEFINE(HAVE_DAG_LARGE_STREAMS_API, 1, [define if you have large streams capable DAG API])
1225 AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"])
1226 if test "$ac_dag_have_vdag" = 1; then
1227 AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()])
1228 if test "$ac_lbl_have_pthreads" != "found"; then
1229 AC_MSG_ERROR([DAG requires pthreads, but we didn't find them])
1231 LIBS="$LIBS $PTHREAD_LIBS"
1235 AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
1238 if test "$V_PCAP" = dag; then
1239 # User requested "dag" capture type but we couldn't
1240 # find the DAG API support.
1241 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])
1244 if test "$want_dag" = yes; then
1245 # User wanted DAG support but we couldn't find it.
1246 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])
1249 CFLAGS="$save_CFLAGS"
1253 AS_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1255 if test "$withval" = no
1258 elif test "$withval" = yes
1264 septel_root=$withval
1267 if test "$V_PCAP" = septel; then
1268 # User requested Septel-only libpcap, so we'd better have
1271 elif test "xxx_only" = yes; then
1272 # User requested something-else-only pcap, so they don't
1273 # want Septel support.
1277 # Use Septel API if present, otherwise don't
1279 want_septel=ifpresent
1283 ac_cv_lbl_septel_api=no
1284 if test "$with_septel" != no; then
1286 AC_MSG_CHECKING([whether we have Septel API headers])
1288 # If necessary, set default paths for Septel API headers and libraries.
1289 if test -z "$septel_root"; then
1290 septel_root=$srcdir/../septel
1293 septel_tools_dir="$septel_root"
1294 septel_include_dir="$septel_root/INC"
1296 if test -r "$septel_include_dir/msg.h"; then
1297 ac_cv_lbl_septel_api=yes
1300 if test "$ac_cv_lbl_septel_api" = yes; then
1301 AC_MSG_RESULT([yes ($septel_include_dir)])
1303 V_INCLS="$V_INCLS -I$septel_include_dir"
1304 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"
1305 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"
1307 if test "$V_PCAP" != septel ; then
1308 MODULE_C_SRC="$MODULE_C_SRC pcap-septel.c"
1311 AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have the Septel API])
1315 if test "$V_PCAP" = septel; then
1316 # User requested "septel" capture type but
1317 # we couldn't find the Septel API support.
1318 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])
1321 if test "$want_septel" = yes; then
1322 # User wanted Septel support but we couldn't find it.
1323 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])
1328 # Check for Myricom SNF support.
1330 AS_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1332 if test "$withval" = no
1334 # User explicitly doesn't want SNF
1336 elif test "$withval" = yes
1338 # User wants SNF support but hasn't specified a directory.
1341 # User wants SNF support with a specified directory.
1346 if test "$V_PCAP" = snf; then
1347 # User requested Sniffer-only libpcap, so we'd better have
1350 elif test "xxx_only" = yes; then
1351 # User requested something-else-only pcap, so they don't
1356 # Use Sniffer API if present, otherwise don't
1362 AC_ARG_WITH([snf-includes],
1363 AS_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not DIR/include]),
1365 # User wants SNF with specific header directory
1367 snf_include_dir=$withval
1370 AC_ARG_WITH([snf-libraries],
1371 AS_HELP_STRING([--with-snf-libraries=LDIR],[Myricom SNF library directory, if not DIR/lib]),
1373 # User wants SNF with specific lib directory
1375 snf_lib_dir=$withval
1378 ac_cv_lbl_snf_api=no
1379 if test "$with_snf" != no; then
1381 AC_MSG_CHECKING(whether we have Myricom Sniffer API)
1383 # If necessary, set default paths for Sniffer headers and libraries.
1384 if test -z "$snf_root"; then
1388 if test -z "$snf_include_dir"; then
1389 snf_include_dir="$snf_root/include"
1392 if test -z "$snf_lib_dir"; then
1393 snf_lib_dir="$snf_root/lib"
1395 # Handle multiarch systems.
1397 if test -d "$snf_lib_dir/$host"
1399 snf_lib_dir="$snf_lib_dir/$host"
1403 if test -f "$snf_include_dir/snf.h"; then
1404 # We found a header; make sure we can link with the library
1405 save_LDFLAGS="$LDFLAGS"
1406 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1407 AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"])
1408 LDFLAGS="$save_LDFLAGS"
1409 if test "$ac_cv_lbl_snf_api" = no; then
1410 AC_MSG_ERROR(SNF API cannot correctly be linked; check config.log)
1414 if test "$ac_cv_lbl_snf_api" = yes; then
1415 AC_MSG_RESULT([yes ($snf_root)])
1417 V_INCLS="$V_INCLS -I$snf_include_dir"
1419 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1421 if test "$V_PCAP" != snf ; then
1422 MODULE_C_SRC="$MODULE_C_SRC pcap-snf.c"
1425 AC_DEFINE(HAVE_SNF_API, 1, [define if you have the Myricom SNF API])
1429 if test "$want_snf" = yes; then
1430 # User requested "snf" capture type but
1431 # we couldn't find the Sniffer API support.
1432 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])
1435 if test "$want_snf" = yes; then
1436 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])
1441 # Check for Riverbed TurboCap support.
1442 AC_ARG_WITH([turbocap],
1443 AS_HELP_STRING([--with-turbocap@<:@=DIR@:>@],[include Riverbed TurboCap support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1445 if test "$withval" = no
1447 # User explicitly doesn't want TurboCap
1449 elif test "$withval" = yes
1451 # User wants TurboCap support but hasn't specified a directory.
1454 # User wants TurboCap support with a specified directory.
1456 turbocap_root=$withval
1459 if test "xxx_only" = yes; then
1460 # User requested something-else-only pcap, so they don't
1461 # want TurboCap support.
1465 # Use TurboCap API if present, otherwise don't
1467 want_turbocap=ifpresent
1471 ac_cv_lbl_turbocap_api=no
1472 if test "$want_turbocap" != no; then
1474 AC_MSG_CHECKING(whether TurboCap is supported)
1476 save_CFLAGS="$CFLAGS"
1478 if test ! -z "$turbocap_root"; then
1479 TURBOCAP_CFLAGS="-I$turbocap_root/include"
1480 TURBOCAP_LIBS="-L$turbocap_root/lib"
1481 CFLAGS="$CFLAGS $TURBOCAP_CFLAGS"
1489 TC_INSTANCE a; TC_PORT b; TC_BOARD c;
1491 (void)TcInstanceCreateByName("foo", &i);
1493 ac_cv_lbl_turbocap_api=yes)
1495 CFLAGS="$save_CFLAGS"
1496 if test $ac_cv_lbl_turbocap_api = yes; then
1499 MODULE_C_SRC="$MODULE_C_SRC pcap-tc.c"
1500 V_INCLS="$V_INCLS $TURBOCAP_CFLAGS"
1501 LIBS="$LIBS $TURBOCAP_LIBS -lTcApi -lpthread -lstdc++"
1503 AC_DEFINE(HAVE_TC_API, 1, [define if you have the TurboCap API])
1507 if test "$want_turbocap" = yes; then
1508 # User wanted Turbo support but we couldn't find it.
1509 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])
1515 dnl Allow the user to enable remote capture.
1516 dnl It's off by default, as that increases the attack surface of
1517 dnl libpcap, exposing it to malicious servers.
1519 AC_MSG_CHECKING([whether to enable remote packet capture])
1520 AC_ARG_ENABLE([remote],
1521 [AS_HELP_STRING([--enable-remote],
1522 [enable remote packet capture @<:@default=no@:>@])],
1525 case "$enableval" in
1526 yes) AC_MSG_RESULT(yes)
1527 AC_WARN([Remote packet capture may expose libpcap-based applications])
1528 AC_WARN([to attacks by malicious remote capture servers!])
1530 # rpcapd requires pthreads on UN*X.
1532 if test "$ac_lbl_have_pthreads" != "found"; then
1533 AC_MSG_ERROR([rpcapd requires pthreads, but we didn't find them])
1536 # It also requires crypt().
1537 # Do we have it in the system libraries?
1539 AC_CHECK_FUNC(crypt,,
1542 # No. Do we have it in -lcrypt?
1544 AC_CHECK_LIB(crypt, crypt,
1547 # Yes; add -lcrypt to the libraries for rpcapd.
1549 RPCAPD_LIBS="$RPCAPD_LIBS -lcrypt"
1552 AC_MSG_ERROR([rpcapd requires crypt(), but we didn't find it])
1557 # OK, we have crypt(). Do we have getspnam()?
1559 AC_CHECK_FUNCS(getspnam)
1562 # Check for various members of struct msghdr.
1564 AC_CHECK_MEMBERS([struct msghdr.msg_control],,,
1566 #include "ftmacros.h"
1567 #include <sys/socket.h>
1569 AC_CHECK_MEMBERS([struct msghdr.msg_flags],,,
1571 #include "ftmacros.h"
1572 #include <sys/socket.h>
1576 # Optionally, we may want to support SSL.
1577 # Check for OpenSSL/libressl.
1579 # First, try looking for it with pkg-config, if we have it.
1581 # Homebrew's pkg-config does not, by default, look for
1582 # pkg-config files for packages it has installed.
1583 # Furthermore, at least for OpenSSL, they appear to be
1584 # dumped in package-specific directories whose paths are
1585 # not only package-specific but package-version-specific.
1587 # So the only way to find openssl is to get the value of
1588 # PKG_CONFIG_PATH from "brew --env openssl" and add that
1589 # to PKG_CONFIG_PATH. (No, we can't just assume it's under
1590 # /usr/local; Homebrew have conveniently chosen to put it
1591 # under /opt/homebrew on ARM.)
1593 # That's the nice thing about Homebrew - it makes things easier!
1596 save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
1597 if test -n "$BREW"; then
1598 openssl_pkgconfig_dir=`$BREW --env --plain openssl | sed -n 's/PKG_CONFIG_PATH: //p'`
1599 PKG_CONFIG_PATH="$openssl_pkgconfig_dir:$PKG_CONFIG_PATH"
1601 PKG_CHECK_MODULES(OPENSSL, openssl,
1604 # We found OpenSSL/libressl.
1608 PKG_CONFIG_PATH="$save_PKG_CONFIG_PATH"
1611 # If it wasn't found, and we have Homebrew installed, see
1612 # if it's in Homebrew.
1614 if test "x$HAVE_OPENSSL" != "xyes" -a -n "$BREW"; then
1615 AC_MSG_CHECKING(for openssl in Homebrew)
1617 # The brew man page lies when it speaks of
1618 # $BREW --prefix --installed <formula>
1619 # outputting nothing. In Homebrew 3.3.16,
1620 # it produces output regardless of whether
1621 # the formula is installed or not, so we
1622 # send the standard output and error to
1625 if $BREW --prefix --installed openssl >/dev/null 2>&1; then
1627 # Yes. Get the include directory and library
1628 # directory. (No, we can't just assume it's
1629 # under /usr/local; Homebrew have conveniently
1630 # chosen to put it under /opt/homebrew on ARM.)
1634 openssl_path=`$BREW --prefix openssl`
1635 OPENSSL_CFLAGS="-I$openssl_path/include"
1636 OPENSSL_LIBS="-L$openssl_path/lib -lssl -lcrypto"
1643 # If it wasn't found, and /usr/local/include and /usr/local/lib
1644 # exist, check if it's in /usr/local. (We check whether they
1645 # exist because, if they don't exist, the compiler will warn
1646 # about that and then ignore the argument, so they test
1647 # using just the system header files and libraries.)
1649 # We include the standard include file to 1) make sure that
1650 # it's installed (if it's just a shared library for the
1651 # benefit of existing programs, that's not useful) and 2)
1652 # because SSL_library_init() is a library routine in some
1653 # versions and a #defined wrapper around OPENSSL_init_ssl()
1656 if test "x$HAVE_OPENSSL" != "xyes" -a -d "/usr/local/include" -a -d "/usr/local/lib"; then
1657 save_CFLAGS="$CFLAGS"
1659 CFLAGS="$CFLAGS -I/usr/local/include"
1660 LIBS="$LIBS -L/usr/local/lib -lssl -lcrypto"
1661 AC_MSG_CHECKING(whether we have OpenSSL/libressl in /usr/local that we can use)
1664 #include <openssl/ssl.h>
1673 OPENSSL_CFLAGS="-I/usr/local/include"
1674 OPENSSL_LIBS="-L/usr/local/lib -lssl -lcrypto"
1677 CFLAGS="$save_CFLAGS"
1682 # If it wasn't found, check if it's a system library.
1684 # We include the standard include file to 1) make sure that
1685 # it's installed (if it's just a shared library for the
1686 # benefit of existing programs, that's not useful) and 2)
1687 # because SSL_library_init() is a library routine in some
1688 # versions and a #defined wrapper around OPENSSL_init_ssl()
1691 if test "x$HAVE_OPENSSL" != "xyes"; then
1693 LIBS="$LIBS -lssl -lcrypto"
1694 AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
1697 #include <openssl/ssl.h>
1706 OPENSSL_LIBS="-lssl -lcrypto"
1713 # OK, did we find it?
1715 if test "x$HAVE_OPENSSL" = "xyes"; then
1716 AC_DEFINE([HAVE_OPENSSL], [1], [Use OpenSSL])
1717 CFLAGS="$CFLAGS $OPENSSL_CFLAGS"
1718 LIBS="$LIBS $OPENSSL_LIBS"
1720 AC_MSG_NOTICE(OpenSSL not found)
1723 AC_DEFINE(ENABLE_REMOTE,,
1724 [Define to 1 if remote packet capture is to be supported])
1725 REMOTE_C_SRC="$REMOTE_C_SRC pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c sslutils.c"
1726 BUILD_RPCAPD=build-rpcapd
1727 INSTALL_RPCAPD=install-rpcapd
1729 *) AC_MSG_RESULT(no)
1733 AC_MSG_CHECKING(whether to build optimizer debugging code)
1734 AC_ARG_ENABLE(optimizer-dbg,
1735 AS_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code]))
1736 if test "$enable_optimizer_dbg" = "yes"; then
1737 AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
1739 AC_MSG_RESULT(${enable_optimizer_dbg-no})
1741 AC_MSG_CHECKING(whether to build parser debugging code)
1742 AC_ARG_ENABLE(yydebug,
1743 AS_HELP_STRING([--enable-yydebug],[build parser debugging code]))
1744 if test "$enable_yydebug" = "yes"; then
1745 AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
1747 AC_MSG_RESULT(${enable_yydebug-no})
1753 if test "$LEX" = ":"; then
1754 AC_MSG_ERROR([Neither flex nor lex was found.])
1758 # Make sure {f}lex supports the -P, --header-file, and --nounput flags
1759 # and supports processing our scanner.l.
1761 AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
1762 if $LEX -P pcap_ --header-file=/dev/null --nounput -t $srcdir/scanner.l > /dev/null 2>&1; then
1763 tcpdump_cv_capable_lex=yes
1765 tcpdump_cv_capable_lex=insufficient
1767 if test $tcpdump_cv_capable_lex = insufficient ; then
1768 AC_MSG_ERROR([$LEX is insufficient to compile libpcap.
1769 libpcap requires Flex 2.5.31 or later, or a compatible version of lex.
1770 If a suitable version of Lex/Flex is available as a non-standard command
1771 and/or not in the PATH, you can specify it using the LEX environment
1772 variable. That said, on some systems the error can mean that Flex/Lex is
1773 actually acceptable, but m4 is not. Likewise, if a suitable version of
1774 m4 (such as GNU M4) is available but has not been detected, you can
1775 specify it using the M4 environment variable.])
1779 # Look for yacc/bison/byacc.
1780 # If it's Bison, we do not want -y, as 1) we will be using -o to cause
1781 # the output for XXX.y to be written to XXX.c and 2) we don't want
1782 # it to issue warnings about stuff not supported by POSIX YACC - we
1783 # want to use that stuff, and don't care whether plain YACC supports
1784 # it or not, we require either Bison or Berkeley YACC.
1790 AC_CHECK_PROGS(BISON_BYACC, bison)
1791 if test x"$BISON_BYACC" != x; then
1795 # Bison prior to 2.4(.1) doesn't support "%define api.pure", so use
1798 bison_major_version=`$BISON_BYACC -V | sed -n 's/.* \(@<:@1-9@:>@@<:@0-9@:>@*\)\.@<:@0-9@:>@@<:@0-9.@:>@*/\1/p'`
1799 bison_minor_version=`$BISON_BYACC -V | sed -n 's/.* @<:@1-9@:>@@<:@0-9@:>@*\.\(@<:@0-9@:>@+\).*/\1/p'`
1800 if test "$bison_major_version" -lt 2 -o \
1801 \( "$bison_major_version" -eq 2 -a "$bison_major_version" -lt 4 \)
1803 REENTRANT_PARSER="%pure-parser"
1805 REENTRANT_PARSER="%define api.pure"
1809 # We didn't find Bison; check for Berkeley YACC, under the
1810 # names byacc and yacc.
1812 AC_CHECK_PROGS(BISON_BYACC, byacc yacc)
1813 if test x"$BISON_BYACC" != x; then
1815 # Make sure this is Berkeley YACC, not AT&T YACC;
1816 # the latter doesn't support reentrant parsers.
1817 # Run it with "-V"; that succeeds and reports the
1818 # version number with Berkeley YACC, but will
1819 # (probably) fail with various vendor flavors
1822 # Hopefully this also eliminates any versions
1823 # of Berkeley YACC that don't support reentrant
1824 # parsers, if there are any.
1826 AC_CACHE_CHECK([for capable yacc], tcpdump_cv_capable_yacc,
1827 if $BISON_BYACC -V >/dev/null 2>&1; then
1828 tcpdump_cv_capable_yacc=yes
1830 tcpdump_cv_capable_yacc=insufficient
1832 if test $tcpdump_cv_capable_yacc = insufficient ; then
1833 AC_MSG_ERROR([$BISON_BYACC is insufficient to compile libpcap.
1834 libpcap requires Bison, a newer version of Berkeley YACC with support
1835 for reentrant parsers, or another YACC compatible with them.])
1839 # OK, we found neither byacc nor yacc.
1841 AC_MSG_ERROR([Neither bison, byacc, nor yacc was found.
1842 libpcap requires Bison, a newer version of Berkeley YACC with support
1843 for reentrant parsers, or another YACC compatible with them.])
1847 # Berkeley YACC doesn't support "%define api.pure", so use
1850 REENTRANT_PARSER="%pure-parser"
1852 AC_SUBST(BISON_BYACC)
1853 AC_SUBST(REENTRANT_PARSER)
1856 # Do various checks for various OSes and versions of those OSes.
1858 # Assume, by default, no support for shared libraries and V7/BSD
1859 # convention for man pages (devices in section 4, file formats in
1860 # section 5, miscellaneous info in section 7, administrative commands
1861 # and daemons in section 8). Individual cases can override this.
1867 MAN_ADMIN_COMMANDS=8
1871 dnl Workaround to enable certain features
1872 AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
1875 # AIX makes it fun to build shared and static libraries,
1876 # because they're *both* ".a" archive libraries. We
1877 # build the static library for the benefit of the traditional
1878 # scheme of building libpcap and tcpdump in subdirectories of
1879 # the same directory, with tcpdump statically linked with the
1880 # libpcap in question, but we also build a shared library as
1881 # "libpcap.shareda" and install *it*, rather than the static
1882 # library, as "libpcap.a".
1890 # If we're using DLPI, applications will need to
1891 # use /lib/pse.exp if present, as we use the
1894 pseexe="/lib/pse.exp"
1895 AC_MSG_CHECKING(for $pseexe)
1896 if test -f $pseexe ; then
1904 # If we're using BPF, we need "-lodm" and "-lcfg", as
1905 # we use them to load the BPF module.
1914 V_CCOPT="$V_CCOPT -fno-common"
1915 AC_ARG_ENABLE(universal,
1916 AS_HELP_STRING([--disable-universal],[don't build universal on macOS]))
1917 if test "$enable_universal" != "no"; then
1922 # Pre-Tiger. Build only for 32-bit PowerPC; no
1923 # need for any special compiler or linker flags.
1927 darwin8.[[0123]]|darwin8.[[0123]].*)
1929 # Tiger, prior to Intel support. Build
1930 # libraries and executables for 32-bit PowerPC
1931 # and 64-bit PowerPC, with 32-bit PowerPC first.
1932 # (I'm guessing that's what Apple does.)
1934 # (The double brackets are needed because
1935 # autotools/m4 use brackets as a quoting
1936 # character; the double brackets turn into
1937 # single brackets in the generated configure
1940 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64"
1941 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64"
1942 V_PROG_CCOPT_FAT="-arch ppc -arch ppc64"
1943 V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64"
1946 darwin8.[[456]]|darwin8.[[456]].*)
1948 # Tiger, subsequent to Intel support but prior
1949 # to x86-64 support. Build libraries and
1950 # executables for 32-bit PowerPC, 64-bit
1951 # PowerPC, and 32-bit x86, with 32-bit PowerPC
1952 # first. (I'm guessing that's what Apple does.)
1954 # (The double brackets are needed because
1955 # autotools/m4 use brackets as a quoting
1956 # character; the double brackets turn into
1957 # single brackets in the generated configure
1960 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
1961 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
1962 V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
1963 V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
1968 # All other Tiger, so subsequent to x86-64
1969 # support. Build libraries and executables for
1970 # 32-bit PowerPC, 64-bit PowerPC, 32-bit x86,
1971 # and x86-64, with 32-bit PowerPC first. (I'm
1972 # guessing that's what Apple does.)
1974 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1975 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1976 V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1977 V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1982 # Leopard. Build libraries for 32-bit PowerPC,
1983 # 64-bit PowerPC, 32-bit x86, and x86-64, with
1984 # 32-bit PowerPC first, and build executables
1985 # for 32-bit x86 and 32-bit PowerPC, with 32-bit
1986 # x86 first. (That's what Apple does.)
1988 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1989 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1990 V_PROG_CCOPT_FAT="-arch i386 -arch ppc"
1991 V_PROG_LDFLAGS_FAT="-arch i386 -arch ppc"
1996 # Snow Leopard. Build libraries for x86-64,
1997 # 32-bit x86, and 32-bit PowerPC, with x86-64
1998 # first, and build executables for x86-64 and
1999 # 32-bit x86, with x86-64 first. (That's what
2000 # Apple does, even though Snow Leopard doesn't
2001 # run on PPC, so PPC libpcap runs under Rosetta,
2002 # and Rosetta doesn't support BPF ioctls, so PPC
2003 # programs can't do live captures.)
2005 V_LIB_CCOPT_FAT="-arch x86_64 -arch i386 -arch ppc"
2006 V_LIB_LDFLAGS_FAT="-arch x86_64 -arch i386 -arch ppc"
2007 V_PROG_CCOPT_FAT="-arch x86_64 -arch i386"
2008 V_PROG_LDFLAGS_FAT="-arch x86_64 -arch i386"
2013 # Post-Snow Leopard, pre-Catalina. Build
2014 # libraries for x86-64 and 32-bit x86, with
2015 # x86-64 first, and build executables only for
2016 # x86-64. (That's what Apple does.) This
2017 # requires no special flags for programs.
2019 # We check whether we *can* build for i386 and,
2020 # if not, suggest that the user install the
2021 # /usr/include headers if they want to build
2024 AC_MSG_CHECKING(whether building for 32-bit x86 is supported)
2025 save_CFLAGS="$CFLAGS"
2026 CFLAGS="$CFLAGS -arch i386"
2032 V_LIB_CCOPT_FAT="-arch x86_64"
2033 V_LIB_LDFLAGS_FAT="-arch x86_64"
2036 # OpenSSL installation on macOS seems
2037 # to install only the libs for 64-bit
2038 # x86 - at least that's what Brew does:
2039 # only configure 32-bit builds if we
2040 # don't have OpenSSL.
2042 if test "$HAVE_OPENSSL" != yes; then
2043 V_LIB_CCOPT_FAT="$V_LIB_CCOPT_FAT -arch i386"
2044 V_LIB_LDFLAGS_FAT="$V_LIB_LDFLAGS_FAT -arch i386"
2049 V_LIB_CCOPT_FAT="-arch x86_64"
2050 V_LIB_LDFLAGS_FAT="-arch x86_64"
2055 # Mojave; you need to install the
2056 # /usr/include headers to get
2057 # 32-bit x86 builds to work.
2059 AC_MSG_WARN([Compiling for 32-bit x86 gives an error; try installing the command-line tools and, after that, installing the /usr/include headers from the /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg package])
2064 # Pre-Mojave; the command-line
2065 # tools should be sufficient to
2066 # enable 32-bit x86 builds.
2068 AC_MSG_WARN([Compiling for 32-bit x86 gives an error; try installing the command-line tools])
2072 CFLAGS="$save_CFLAGS"
2077 # Catalina. Build libraries and executables
2078 # only for x86-64. (That's what Apple does;
2079 # 32-bit x86 binaries are not supported on
2082 V_LIB_CCOPT_FAT="-arch x86_64"
2083 V_LIB_LDFLAGS_FAT="-arch x86_64"
2084 V_PROG_CCOPT_FAT="-arch x86_64"
2085 V_PROG_LDFLAGS_FAT="-arch x86_64"
2090 # Post-Catalina. Build libraries and
2091 # executables for x86-64 and ARM64.
2092 # (That's what Apple does, except they
2093 # build for arm64e, which may include
2094 # some of the pointer-checking extensions.)
2096 # If we're building with libssl, make sure
2097 # we can build fat with it (i.e., that it
2098 # was built fat); if we can't, don't set
2099 # the target architectures, and just
2100 # build for the host we're on.
2102 # Otherwise, just add both of them.
2104 if test "$HAVE_OPENSSL" = yes; then
2105 AC_MSG_CHECKING(whether building fat with libssl is supported)
2106 save_CFLAGS="$CFLAGS"
2107 save_LDFLAGS="$LDFLAGS"
2108 CFLAGS="$CFLAGS -arch x86_64 -arch arm64"
2109 LDFLAGS="$LDFLAGS $OPENSSL_LIBS"
2112 #include <openssl/ssl.h>
2120 V_LIB_CCOPT_FAT="-arch x86_64 -arch arm64"
2121 V_LIB_LDFLAGS_FAT="-arch x86_64 -arch arm64"
2122 V_PROG_CCOPT_FAT="-arch x86_64 -arch arm64"
2123 V_PROG_LDFLAGS_FAT="-arch x86_64 -arch arm64"
2127 CFLAGS="$save_CFLAGS"
2128 LDFLAGS="$save_LDFLAGS"
2130 V_LIB_CCOPT_FAT="-arch x86_64 -arch arm64"
2131 V_LIB_LDFLAGS_FAT="-arch x86_64 -arch arm64"
2132 V_PROG_CCOPT_FAT="-arch x86_64 -arch arm64"
2133 V_PROG_LDFLAGS_FAT="-arch x86_64 -arch arm64"
2141 AC_DEFINE(HAVE_HPUX9,1,[on HP-UX 9.x])
2144 # Use System V conventions for man pages.
2146 MAN_ADMIN_COMMANDS=1m
2154 # Use System V conventions for man pages.
2156 MAN_ADMIN_COMMANDS=1m
2164 # Use System V conventions for man pages.
2166 MAN_ADMIN_COMMANDS=1m
2172 dnl HPUX 10.20 and above is similar to HPUX 9, but
2173 dnl not the same....
2175 dnl XXX - DYEXT should be set to "sl" if this is building
2176 dnl for 32-bit PA-RISC, but should be left as "so" for
2177 dnl 64-bit PA-RISC or, I suspect, IA-64.
2178 AC_DEFINE(HAVE_HPUX10_20_OR_LATER,1,[on HP-UX 10.20 or later])
2179 if test "`uname -m`" = "ia64"; then
2186 # "-b" builds a shared library; "+h" sets the soname.
2192 # Use System V conventions for man pages.
2200 # Use IRIX conventions for man pages; they're the same as the
2201 # System V conventions, except that they use section 8 for
2202 # administrative commands and daemons.
2208 linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*|haiku*|midipix*)
2212 # Compiler assumed to be GCC; run-time linker may require a -R
2215 if test "$libdir" != "/usr/lib"; then
2216 V_RFLAGS=-Wl,-R$libdir
2224 # DEC OSF/1, a/k/a Digial UNIX, a/k/a Tru64 UNIX.
2225 # Use Tru64 UNIX conventions for man pages; they're the same as
2226 # the System V conventions except that they use section 8 for
2227 # administrative commands and daemons.
2235 AC_MSG_CHECKING(if SINIX compiler defines sinix)
2236 AC_CACHE_VAL(ac_cv_cc_sinix_defined,
2240 ac_cv_cc_sinix_defined=yes,
2241 ac_cv_cc_sinix_defined=no))
2242 AC_MSG_RESULT($ac_cv_cc_sinix_defined)
2243 if test $ac_cv_cc_sinix_defined = no ; then
2244 AC_DEFINE(sinix,1,[on sinix])
2249 AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
2254 # Make sure errno is thread-safe, in case we're called in
2255 # a multithreaded program. We don't guarantee that two
2256 # threads can use the *same* pcap_t safely, but the
2257 # current version does guarantee that you can use different
2258 # pcap_t's in different threads, and even that pcap_compile()
2259 # is thread-safe (it wasn't thread-safe in some older versions).
2261 V_CCOPT="$V_CCOPT -D_TS_ERRNO"
2263 case "`uname -r`" in
2270 # Use System V conventions for man pages.
2272 MAN_ADMIN_COMMANDS=1m
2280 AC_ARG_ENABLE(shared,
2281 AS_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@]))
2282 test "x$enable_shared" = "xno" && DYEXT="none"
2285 AC_CHECK_TOOL([AR], [ar])
2290 AC_LBL_DEVEL(V_CCOPT)
2293 # Check to see if the sockaddr struct has the 4.4 BSD sa_len member.
2295 AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,
2297 #include <sys/types.h>
2298 #include <sys/socket.h>
2302 # Check to see if there's a sockaddr_storage structure.
2304 AC_CHECK_TYPES(struct sockaddr_storage,,,
2306 #include <sys/types.h>
2307 #include <sys/socket.h>
2311 # Check to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
2312 # dl_module_id_1 member.
2314 # NOTE: any failure means we conclude that it doesn't have that member,
2315 # so if we don't have DLPI, don't have a <sys/dlpi_ext.h> header, or
2316 # have one that doesn't declare a dl_hp_ppa_info_t type, we conclude
2317 # it doesn't have that member (which is OK, as either we won't be
2318 # using code that would use that member, or we wouldn't compile in
2321 AC_CHECK_MEMBERS([dl_hp_ppa_info_t.dl_module_id_1],,,
2323 #include <sys/types.h>
2324 #include <sys/dlpi.h>
2325 #include <sys/dlpi_ext.h>
2329 AC_SUBST(V_LIB_CCOPT_FAT)
2330 AC_SUBST(V_LIB_LDFLAGS_FAT)
2331 AC_SUBST(V_PROG_CCOPT_FAT)
2332 AC_SUBST(V_PROG_LDFLAGS_FAT)
2336 AC_SUBST(V_SHLIB_CCOPT)
2337 AC_SUBST(V_SHLIB_CMD)
2338 AC_SUBST(V_SHLIB_OPT)
2339 AC_SUBST(V_SONAME_OPT)
2340 AC_SUBST(V_RPATH_OPT)
2343 AC_SUBST(ADDLARCHIVEOBJS)
2344 AC_SUBST(PLATFORM_C_SRC)
2345 AC_SUBST(PLATFORM_CXX_SRC)
2346 AC_SUBST(MODULE_C_SRC)
2347 AC_SUBST(REMOTE_C_SRC)
2349 AC_SUBST(MAN_DEVICES)
2350 AC_SUBST(MAN_FILE_FORMATS)
2351 AC_SUBST(MAN_MISC_INFO)
2352 AC_SUBST(MAN_ADMIN_COMMANDS)
2353 AC_SUBST(PTHREAD_LIBS)
2354 AC_SUBST(BUILD_RPCAPD)
2355 AC_SUBST(INSTALL_RPCAPD)
2356 AC_SUBST(RPCAPD_LIBS)
2357 AC_SUBST(EXTRA_NETWORK_LIBS)
2360 # Various Linux-specific mechanisms.
2362 AC_ARG_ENABLE([usb],
2363 [AS_HELP_STRING([--enable-usb],[enable Linux usbmon USB capture support @<:@default=yes, if support available@:>@])],
2368 # If somebody requested an XXX-only pcap, that doesn't include
2369 # additional mechanisms.
2371 if test "xxx_only" != yes; then
2374 dnl check for USB sniffing support
2375 AC_MSG_CHECKING(for Linux usbmon USB sniffing support)
2376 if test "x$enable_usb" != "xno" ; then
2377 AC_DEFINE(PCAP_SUPPORT_LINUX_USBMON, 1, [target host supports Linux usbmon for USB sniffing])
2378 MODULE_C_SRC="$MODULE_C_SRC pcap-usb-linux.c"
2380 ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null`
2381 if test $? -ne 0 ; then
2382 ac_usb_dev_name="usbmon"
2384 AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing])
2385 AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name)
2387 # Do we have a version of <linux/compiler.h> available?
2388 # If so, we might need it for <linux/usbdevice_fs.h>.
2390 AC_CHECK_HEADERS(linux/compiler.h)
2391 if test "$ac_cv_header_linux_compiler_h" = yes; then
2393 # Yes - include it when testing for <linux/usbdevice_fs.h>.
2395 AC_CHECK_HEADERS(linux/usbdevice_fs.h,,,[#include <linux/compiler.h>])
2397 AC_CHECK_HEADERS(linux/usbdevice_fs.h)
2399 if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then
2401 # OK, does it define bRequestType? Older versions of the kernel
2402 # define fields with names like "requesttype, "request", and
2403 # "value", rather than "bRequestType", "bRequest", and
2406 AC_CHECK_MEMBERS([struct usbdevfs_ctrltransfer.bRequestType],,,
2409 #ifdef HAVE_LINUX_COMPILER_H
2410 #include <linux/compiler.h>
2412 #include <linux/usbdevice_fs.h>
2420 # Life's too short to deal with trying to get this to compile
2421 # if you don't get the right types defined with
2422 # __KERNEL_STRICT_NAMES getting defined by some other include.
2424 # Check whether the includes Just Work. If not, don't turn on
2425 # netfilter support.
2427 AC_MSG_CHECKING(whether we can compile the netfilter support)
2428 AC_CACHE_VAL(ac_cv_netfilter_can_compile,
2431 #include <sys/socket.h>
2432 #include <netinet/in.h>
2433 #include <linux/types.h>
2435 #include <linux/netlink.h>
2436 #include <linux/netfilter.h>
2437 #include <linux/netfilter/nfnetlink.h>
2438 #include <linux/netfilter/nfnetlink_log.h>
2439 #include <linux/netfilter/nfnetlink_queue.h>],
2441 ac_cv_netfilter_can_compile=yes,
2442 ac_cv_netfilter_can_compile=no))
2443 AC_MSG_RESULT($ac_cv_netfilter_can_compile)
2444 if test $ac_cv_netfilter_can_compile = yes ; then
2445 AC_DEFINE(PCAP_SUPPORT_NETFILTER, 1,
2446 [target host supports netfilter sniffing])
2447 MODULE_C_SRC="$MODULE_C_SRC pcap-netfilter-linux.c"
2452 AC_SUBST(PCAP_SUPPORT_LINUX_USBMON)
2453 AC_SUBST(PCAP_SUPPORT_NETFILTER)
2455 AC_ARG_ENABLE([netmap],
2456 [AS_HELP_STRING([--enable-netmap],[enable netmap support @<:@default=yes, if support available@:>@])],
2458 [enable_netmap=yes])
2460 if test "x$enable_netmap" != "xno" ; then
2462 # Check whether net/netmap_user.h is usable if NETMAP_WITH_LIBS is
2463 # defined; it's not usable on DragonFly BSD 4.6 if NETMAP_WITH_LIBS
2464 # is defined, for example, as it includes a non-existent malloc.h
2467 AC_MSG_CHECKING(whether we can compile the netmap support)
2468 AC_CACHE_VAL(ac_cv_net_netmap_user_can_compile,
2471 #define NETMAP_WITH_LIBS
2472 #include <net/netmap_user.h>],
2474 ac_cv_net_netmap_user_can_compile=yes,
2475 ac_cv_net_netmap_user_can_compile=no))
2476 AC_MSG_RESULT($ac_cv_net_netmap_user_can_compile)
2477 if test $ac_cv_net_netmap_user_can_compile = yes ; then
2478 AC_DEFINE(PCAP_SUPPORT_NETMAP, 1,
2479 [target host supports netmap])
2480 MODULE_C_SRC="$MODULE_C_SRC pcap-netmap.c"
2482 AC_SUBST(PCAP_SUPPORT_NETMAP)
2485 # Check for DPDK support.
2487 AS_HELP_STRING([--with-dpdk@<:@=DIR@:>@],[include DPDK support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
2489 if test "$withval" = no
2491 # User doesn't want DPDK support.
2493 elif test "$withval" = yes
2495 # User wants DPDK support but hasn't specified a directory.
2498 # User wants DPDK support and has specified a directory,
2499 # so use the provided value.
2504 if test "$V_PCAP" = dpdk; then
2505 # User requested DPDK-only libpcap, so we'd better have
2508 elif test "xxx_only" = yes; then
2509 # User requested something-else-only pcap, so they don't
2510 # want DPDK support.
2514 # Use DPDK API if present, otherwise don't
2520 if test "$want_dpdk" != no; then
2521 PKG_CHECK_MODULES(DPDK, libdpdk,
2523 found_dpdk_with_pkg_config=yes
2527 # If we didn't find it with pkg-config, try checking for
2530 if test "x$found_dpdk_with_pkg_config" != "xyes"
2532 if test -z "$dpdk_dir"; then
2534 # The user didn't specify a directory containing
2535 # the DPDK headers and libraries. If we find
2536 # a /usr/local/include/dpdk directory, assume
2537 # it's /usr/local, otherwise assume it's /usr.
2539 if test -d "/usr/local/include/dpdk"; then
2540 dpdk_dir="/usr/local"
2546 # The convention appears to be that 1) there's a "dpdk"
2547 # subdirectory of the include directory, containing DPDK
2548 # headers (at least in the installation on Ubuntu with
2549 # the system DPDK packages) and 2) includes of DPDK
2550 # headers don't use "dpdk/{header}" (at least from the
2551 # way the DPDK documentation is written).
2553 # So we add "/dpdk" to the include directory, and always
2554 # add that to the list of include directories to search.
2556 dpdk_inc_dir="$dpdk_dir/include/dpdk"
2557 dpdk_inc_flags="-I$dpdk_inc_dir"
2558 dpdk_lib_dir="$dpdk_dir/lib"
2560 # Handle multiarch systems.
2562 # Step 1: run the C compiler with the -dumpmachine option;
2563 # if it succeeds, the output would be the multiarch directory
2564 # name if your system has multiarch directories.
2566 multiarch_dir=`$CC -dumpmachine 2>/dev/null`
2567 if test ! -z "$multiarch_dir"
2570 # OK, we have a multiarch directory.
2572 # Now deal with includes. On Ubuntu 20.04, for
2573 # example, we have /usr/include/dpdk *and*
2574 # /usr/include/$multiarch_dir/dpdk, and must
2577 if test -d "$dpdk_dir/include/$multiarch_dir/dpdk"
2579 dpdk_inc_flags="-I$dpdk_dir/include/$multiarch_dir/dpdk $dpdk_inc_flags"
2583 # Now deal with libraries.
2585 if test -d "$dpdk_lib_dir/$multiarch_dir"
2587 dpdk_lib_dir="$dpdk_lib_dir/$multiarch_dir"
2590 DPDK_MACHINE_CFLAGS="-march=native"
2591 DPDK_CFLAGS="$DPDK_MACHINE_CFLAGS $dpdk_inc_flags"
2592 DPDK_LDFLAGS="-L$dpdk_lib_dir -ldpdk -lrt -lm -lnuma -ldl -pthread"
2595 save_CFLAGS="$CFLAGS"
2597 save_LDFLAGS="$LDFLAGS"
2598 CFLAGS="$CFLAGS $DPDK_CFLAGS"
2599 LIBS="$LIBS $DPDK_LDFLAGS"
2600 LDFLAGS="$LDFLAGS $DPDK_LDFLAGS"
2602 AC_MSG_CHECKING(whether we can compile the DPDK support)
2603 AC_CACHE_VAL(ac_cv_dpdk_can_compile,
2606 #include <rte_common.h>],
2608 ac_cv_dpdk_can_compile=yes,
2609 ac_cv_dpdk_can_compile=no))
2610 AC_MSG_RESULT($ac_cv_dpdk_can_compile)
2613 # We include rte_bus.h, and older versions of DPDK
2614 # didn't have it, so check for it.
2616 if test "$ac_cv_dpdk_can_compile" = yes; then
2618 # This runs the preprocessor, so make sure it
2619 # looks in the DPDK directories. Instead of
2620 # including dpdk/XXX.h, we include just XXX.h
2621 # and assume DPDK_CFLAGS is the directory
2622 # containing the DPDK headers (that's how
2623 # pkg-config sets it, at least on Ubuntu),
2624 # so just looking under /usr/include won't
2627 save_CPPFLAGS="$CPPFLAGS"
2628 CPPFLAGS="$CPPFLAGS $DPDK_CFLAGS"
2629 AC_CHECK_HEADER(rte_bus.h)
2630 CPPFLAGS="$save_CPPFLAGS"
2634 # We call rte_eth_dev_count_avail(), and older versions
2635 # of DPDK didn't have it, so check for it.
2637 if test "$ac_cv_header_rte_bus_h" = yes; then
2638 AC_CHECK_FUNC(rte_eth_dev_count_avail)
2641 CFLAGS="$save_CFLAGS"
2643 LDFLAGS="$save_LDFLAGS"
2645 if test "$ac_cv_func_rte_eth_dev_count_avail" = yes; then
2646 CFLAGS="$CFLAGS $DPDK_CFLAGS"
2647 LIBS="$LIBS $DPDK_LDFLAGS"
2648 LDFLAGS="$LDFLAGS $DPDK_LDFLAGS"
2649 V_INCLS="$V_INCLS $DPDK_CFLAGS"
2650 AC_DEFINE(PCAP_SUPPORT_DPDK, 1, [target host supports DPDK])
2651 if test $V_PCAP != dpdk ; then
2652 MODULE_C_SRC="$MODULE_C_SRC pcap-dpdk.c"
2656 # Check whether the rte_ether.h file defines
2657 # struct ether_addr or struct rte_ether_addr.
2659 # ("API compatibility? That's for losers!")
2661 AC_CHECK_TYPES(struct rte_ether_addr,,,
2663 #include <rte_ether.h>
2666 if test "$V_PCAP" = dpdk; then
2667 # User requested DPDK-only capture support, but
2668 # we couldn't the DPDK API support at all, or we
2669 # found it but it wasn't a sufficiently recent
2671 if test "$ac_cv_dpdk_can_compile" != yes; then
2673 # Couldn't even find the headers.
2675 AC_MSG_ERROR([DPDK support requested with --with-pcap=dpdk, but the DPDK headers weren't found at $dpdk_inc_dir: make sure the DPDK support is installed, specify a different path or paths if necessary, or don't request DPDK support])
2678 # Found the headers, but we couldn't find
2679 # rte_bus.h or rte_eth_dev_count_avail(),
2680 # we don't have a sufficiently recent
2683 AC_MSG_ERROR([DPDK support requested with --with-pcap=dpdk, but we require DPDK 18.x or later; install a newer version of DPDK, or don't request DPDK support])
2687 if test "$want_dpdk" = yes; then
2688 # User requested DPDK-only capture support, but
2689 # we couldn't the DPDK API support at all, or we
2690 # found it but it wasn't a sufficiently recent
2692 if test "$ac_cv_dpdk_can_compile" != yes; then
2694 # Couldn't even find the headers.
2696 AC_MSG_ERROR([DPDK support requested with --with-pcap=dpdk, but the DPDK headers weren't found at $dpdk_inc_dir: make sure the DPDK support is installed, specify a different path or paths if necessary, or don't request DPDK support])
2699 # Found the headers, but we couldn't find
2700 # rte_bus.h or rte_eth_dev_count_avail(),
2701 # we don't have a sufficiently recent
2704 AC_MSG_ERROR([DPDK support requested with --with-pcap=dpdk, but we require DPDK 18.x or later: install a newer version of DPDK, or don't request DPDK support])
2709 AC_SUBST(PCAP_SUPPORT_DPDK)
2711 AC_ARG_ENABLE([bluetooth],
2712 [AS_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
2714 [enable_bluetooth=ifsupportavailable])
2716 if test "xxx_only" = yes; then
2717 # User requested something-else-only pcap, so they don't
2718 # want Bluetooth support.
2722 if test "x$enable_bluetooth" != "xno" ; then
2723 dnl check for Bluetooth sniffing support
2726 AC_CHECK_HEADER(bluetooth/bluetooth.h,
2729 # We have bluetooth.h, so we support Bluetooth
2732 AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
2733 MODULE_C_SRC="$MODULE_C_SRC pcap-bt-linux.c"
2734 AC_MSG_NOTICE(Bluetooth sniffing is supported)
2735 ac_lbl_bluetooth_available=yes
2738 # OK, does struct sockaddr_hci have an hci_channel
2741 AC_CHECK_MEMBERS([struct sockaddr_hci.hci_channel],
2744 # Yes; is HCI_CHANNEL_MONITOR defined?
2746 AC_MSG_CHECKING(if HCI_CHANNEL_MONITOR is defined)
2747 AC_CACHE_VAL(ac_cv_lbl_hci_channel_monitor_is_defined,
2750 #include <bluetooth/bluetooth.h>
2751 #include <bluetooth/hci.h>
2754 u_int i = HCI_CHANNEL_MONITOR;
2758 AC_DEFINE(PCAP_SUPPORT_BT_MONITOR,,
2759 [target host supports Bluetooth Monitor])
2760 MODULE_C_SRC="$MODULE_C_SRC pcap-bt-monitor-linux.c"
2767 #include <bluetooth/bluetooth.h>
2768 #include <bluetooth/hci.h>
2773 # We don't have bluetooth.h, so we don't support
2774 # Bluetooth sniffing.
2776 if test "x$enable_bluetooth" = "xyes" ; then
2777 AC_MSG_ERROR(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2779 AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2784 if test "x$enable_bluetooth" = "xyes" ; then
2785 AC_MSG_ERROR(no Bluetooth sniffing support implemented for $host_os)
2787 AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os)
2791 AC_SUBST(PCAP_SUPPORT_BT)
2794 AC_ARG_ENABLE([dbus],
2795 [AS_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
2797 [enable_dbus=ifavailable])
2799 if test "xxx_only" = yes; then
2800 # User requested something-else-only pcap, so they don't
2801 # want D-Bus support.
2805 if test "x$enable_dbus" != "xno"; then
2806 if test "x$enable_dbus" = "xyes"; then
2811 # We don't support D-Bus sniffing on macOS; see
2813 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
2815 # The user requested it, so fail.
2817 AC_MSG_ERROR([Due to freedesktop.org bug 74029, D-Bus capture support is not available on macOS])
2824 # We don't support D-Bus sniffing on macOS; see
2826 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
2828 # The user dind't explicitly request it, so just
2829 # silently refuse to enable it.
2837 if test "x$enable_dbus" != "xno"; then
2838 PKG_CHECK_MODULES(DBUS, dbus-1,
2840 save_CFLAGS="$CFLAGS"
2842 CFLAGS="$CFLAGS $DBUS_CFLAGS"
2843 LIBS="$LIBS $DBUS_LIBS"
2844 AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
2846 [#include <string.h>
2849 #include <sys/time.h>
2851 #include <dbus/dbus.h>],
2852 [return dbus_connection_read_write(NULL, 0);],
2854 AC_MSG_RESULT([yes])
2855 AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
2856 MODULE_C_SRC="$MODULE_C_SRC pcap-dbus.c"
2857 V_INCLS="$V_INCLS $DBUS_CFLAGS"
2861 if test "x$enable_dbus" = "xyes"; then
2862 AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
2866 CFLAGS="$save_CFLAGS"
2869 if test "x$enable_dbus" = "xyes"; then
2870 AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed])
2873 AC_SUBST(PCAP_SUPPORT_DBUS)
2876 AC_ARG_ENABLE([rdma],
2877 [AS_HELP_STRING([--enable-rdma],[enable RDMA capture support @<:@default=yes, if support available@:>@])],
2879 [enable_rdma=ifavailable])
2881 if test "xxx_only" = yes; then
2882 # User requested something-else-only pcap, so they don't
2883 # want RDMA support.
2887 if test "x$enable_rdma" != "xno"; then
2888 AC_CHECK_LIB(ibverbs, ibv_get_device_list, [
2889 AC_CHECK_HEADER(infiniband/verbs.h, [
2891 # ibv_create_flow may be defined as a static inline
2892 # function in infiniband/verbs.h, so we can't
2895 # Too bad autoconf has no AC_SYMBOL_EXISTS()
2896 # macro that works like CMake's check_symbol_exists()
2897 # function, to check do a compile check like
2898 # this (they do a clever trick to avoid having
2899 # to know the function's signature).
2901 AC_MSG_CHECKING(whether libibverbs defines ibv_create_flow)
2904 #include <infiniband/verbs.h>
2907 (void) ibv_create_flow((struct ibv_qp *) NULL,
2908 (struct ibv_flow_attr *) NULL);
2911 AC_MSG_RESULT([yes])
2912 AC_DEFINE(PCAP_SUPPORT_RDMASNIFF, , [target host supports RDMA sniffing])
2913 MODULE_C_SRC="$MODULE_C_SRC pcap-rdmasniff.c"
2914 LIBS="-libverbs $LIBS"
2922 AC_SUBST(PCAP_SUPPORT_RDMASNIFF)
2927 AC_CONFIG_HEADER(config.h)
2929 AC_OUTPUT_COMMANDS([if test -f .devel; then
2930 echo timestamp > stamp-h
2931 cat $srcdir/Makefile-devel-adds >> Makefile
2932 make depend || exit 1
2934 AC_OUTPUT(Makefile grammar.y pcap-filter.manmisc pcap-linktype.manmisc
2935 pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap
2936 pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap
2937 pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap
2938 pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap
2939 pcap_open_offline.3pcap pcap_set_immediate_mode.3pcap
2940 pcap_set_tstamp_precision.3pcap pcap_set_tstamp_type.3pcap
2941 rpcapd/Makefile rpcapd/rpcapd.manadmin rpcapd/rpcapd-config.manfile