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 AC_LBL_C_INIT(V_CCOPT, V_INCLS)
36 # Try to arrange for large file support.
42 dnl Even if <net/bpf.h> were, on all OSes that support BPF, fixed to
43 dnl include <sys/ioccom.h>, and we were to drop support for older
44 dnl releases without that fix, so that pcap-bpf.c doesn't need to
45 dnl include <sys/ioccom.h>, the test program in "AC_LBL_FIXINCLUDES"
46 dnl in "aclocal.m4" uses it, so we would still have to test for it
47 dnl and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
48 dnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris.
50 AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h limits.h)
51 AC_CHECK_HEADERS(netpacket/packet.h)
52 AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
53 #include <sys/socket.h>
55 if test "$ac_cv_header_net_pfvar_h" = yes; then
57 # Check for various PF actions.
59 AC_MSG_CHECKING(whether net/pfvar.h defines PF_NAT through PF_NORDR)
61 [#include <sys/types.h>
62 #include <sys/socket.h>
64 #include <net/pfvar.h>],
65 [return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR;],
68 AC_DEFINE(HAVE_PF_NAT_THROUGH_PF_NORDR, 1,
69 [define if net/pfvar.h defines PF_NAT through PF_NORDR])
76 AC_CHECK_HEADERS(linux/sockios.h linux/if_bonding.h,,,
78 #include <sys/socket.h>
86 AC_CHECK_FUNCS(strerror strerror_r strerror_s strlcpy strlcat)
89 AC_CHECK_FUNCS(vsnprintf snprintf,,
91 if test $needsnprintf = yes; then
96 AC_CHECK_FUNCS(strtok_r,,
98 if test $needstrtok_r = yes; then
103 # Do we have ffs(), and is it declared in <strings.h>?
106 if test "$ac_cv_func_ffs" = yes; then
108 # We have ffs(); is it declared in <strings.h>?
110 # This test fails if we don't have <strings.h> or if we do
111 # but it doesn't declare ffs().
115 AC_DEFINE(STRINGS_H_DECLARES_FFS,,
116 [Define to 1 if strings.h declares `ffs'])
124 # Do this before checking for ether_hostton(), as it's a
125 # "getaddrinfo()-ish function".
130 # Check for reentrant versions of getnetbyname_r(), as provided by
131 # Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!).
132 # If we don't find one, we just use getnetbyname(), which uses
133 # thread-specific data on many platforms, but doesn't use it on
134 # NetBSD or OpenBSD, and may not use it on older versions of other
137 # Only do the check if we have a declaration of getnetbyname_r();
138 # without it, we can't check which API it has. (We assume that
139 # if there's a declaration, it has a prototype, so that the API
142 AC_CHECK_DECL(getnetbyname_r,
144 AC_MSG_CHECKING([for the Linux getnetbyname_r()])
146 [#include <netdb.h>],
148 struct netent netent_buf;
150 struct netent *resultp;
153 return getnetbyname_r((const char *)0, &netent_buf, buf, sizeof buf, &resultp, &h_errnoval);
157 AC_DEFINE(HAVE_LINUX_GETNETBYNAME_R, 1,
158 [define if we have the Linux getnetbyname_r()])
163 AC_MSG_CHECKING([for Solaris/IRIX getnetbyname_r()])
165 [#include <netdb.h>],
167 struct netent netent_buf;
170 return getnetbyname_r((const char *)0, &netent_buf, buf, (int)sizeof buf) != NULL;
174 AC_DEFINE(HAVE_SOLARIS_IRIX_GETNETBYNAME_R, 1,
175 [define if we have the Solaris/IRIX getnetbyname_r()])
180 AC_MSG_CHECKING([for AIX getnetbyname_r()])
182 [#include <netdb.h>],
184 struct netent netent_buf;
185 struct netent_data net_data;
187 return getnetbyname_r((const char *)0, &netent_buf, &net_data);
191 AC_DEFINE(HAVE_AIX_GETNETBYNAME_R, 1,
192 [define if we have the AIX getnetbyname_r()])
199 ],,[#include <netdb.h>])
202 # Check for reentrant versions of getprotobyname_r(), as provided by
203 # Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!).
204 # If we don't find one, we just use getprotobyname(), which uses
205 # thread-specific data on many platforms, but doesn't use it on
206 # NetBSD or OpenBSD, and may not use it on older versions of other
209 # Only do the check if we have a declaration of getprotobyname_r();
210 # without it, we can't check which API it has. (We assume that
211 # if there's a declaration, it has a prototype, so that the API
214 AC_CHECK_DECL(getprotobyname_r,
216 AC_MSG_CHECKING([for the Linux getprotobyname_r()])
218 [#include <netdb.h>],
220 struct protoent protoent_buf;
222 struct protoent *resultp;
224 return getprotobyname_r((const char *)0, &protoent_buf, buf, sizeof buf, &resultp);
228 AC_DEFINE(HAVE_LINUX_GETPROTOBYNAME_R, 1,
229 [define if we have the Linux getprotobyname_r()])
234 AC_MSG_CHECKING([for Solaris/IRIX getprotobyname_r()])
236 [#include <netdb.h>],
238 struct protoent protoent_buf;
241 return getprotobyname_r((const char *)0, &protoent_buf, buf, (int)sizeof buf) != NULL;
245 AC_DEFINE(HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R, 1,
246 [define if we have the Solaris/IRIX getprotobyname_r()])
251 AC_MSG_CHECKING([for AIX getprotobyname_r()])
253 [#include <netdb.h>],
255 struct protoent protoent_buf;
256 struct protoent_data proto_data;
258 return getprotobyname_r((const char *)0, &protoent_buf, &proto_data);
262 AC_DEFINE(HAVE_AIX_GETPROTOBYNAME_R, 1,
263 [define if we have the AIX getprotobyname_r()])
270 ],,[#include <netdb.h>])
273 # You are in a twisty little maze of UN*Xes, all different.
274 # Some might not have ether_hostton().
275 # Some might have it and declare it in <net/ethernet.h>.
276 # Some might have it and declare it in <netinet/ether.h>
277 # Some might have it and declare it in <sys/ethernet.h>.
278 # Some might have it and declare it in <arpa/inet.h>.
279 # Some might have it and declare it in <netinet/if_ether.h>.
280 # Some might have it and not declare it in any header file.
282 # Before you is a C compiler.
284 AC_CHECK_FUNCS(ether_hostton)
285 if test "$ac_cv_func_ether_hostton" = yes; then
287 # OK, we have ether_hostton(). Is it declared in <net/ethernet.h>?
289 # This test fails if we don't have <net/ethernet.h> or if we do
290 # but it doesn't declare ether_hostton().
292 AC_CHECK_DECL(ether_hostton,
294 AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_HOSTTON,,
295 [Define to 1 if net/ethernet.h declares `ether_hostton'])
298 #include <net/ethernet.h>
303 if test "$ac_cv_have_decl_ether_hostton" != yes; then
305 # No, how about <netinet/ether.h>, as on Linux?
307 # This test fails if we don't have <netinet/ether.h>
308 # or if we do but it doesn't declare ether_hostton().
310 # Unset ac_cv_have_decl_ether_hostton so we don't
311 # treat the previous failure as a cached value and
312 # suppress the next test.
314 unset ac_cv_have_decl_ether_hostton
315 AC_CHECK_DECL(ether_hostton,
317 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON,,
318 [Define to 1 if netinet/ether.h declares `ether_hostton'])
321 #include <netinet/ether.h>
327 if test "$ac_cv_have_decl_ether_hostton" != yes; then
329 # No, how about <sys/ethernet.h>, as on Solaris 10
332 # This test fails if we don't have <sys/ethernet.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(SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON,,
343 [Define to 1 if sys/ethernet.h declares `ether_hostton'])
346 #include <sys/ethernet.h>
352 if test "$ac_cv_have_decl_ether_hostton" != yes; then
354 # No, how about <arpa/inet.h>, as in AIX?
356 # This test fails if we don't have <arpa/inet.h>
357 # (if we have ether_hostton(), we should have
358 # networking, and if we have networking, we should
359 # have <arapa/inet.h>) or if we do but it doesn't
360 # declare ether_hostton().
362 # Unset ac_cv_have_decl_ether_hostton so we don't
363 # treat the previous failure as a cached value and
364 # suppress the next test.
366 unset ac_cv_have_decl_ether_hostton
367 AC_CHECK_DECL(ether_hostton,
369 AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_HOSTTON,,
370 [Define to 1 if arpa/inet.h declares `ether_hostton'])
373 #include <arpa/inet.h>
379 if test "$ac_cv_have_decl_ether_hostton" != yes; then
381 # No, how about <netinet/if_ether.h>?
382 # On some platforms, it requires <net/if.h> and
383 # <netinet/in.h>, and we always include it with
384 # both of them, so test it with both of them.
386 # This test fails if we don't have <netinet/if_ether.h>
387 # and the headers we include before it, or if we do but
388 # <netinet/if_ether.h> doesn't declare ether_hostton().
390 # Unset ac_cv_have_decl_ether_hostton so we don't
391 # treat the previous failure as a cached value and
392 # suppress the next test.
394 unset ac_cv_have_decl_ether_hostton
395 AC_CHECK_DECL(ether_hostton,
397 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON,,
398 [Define to 1 if netinet/if_ether.h declares `ether_hostton'])
401 #include <sys/types.h>
402 #include <sys/socket.h>
404 #include <netinet/in.h>
405 #include <netinet/if_ether.h>
409 # After all that, is ether_hostton() declared?
411 if test "$ac_cv_have_decl_ether_hostton" = yes; then
415 AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1,
416 [Define to 1 if you have the declaration of `ether_hostton'])
419 # No, we'll have to declare it ourselves.
420 # Do we have "struct ether_addr" if we include
421 # <netinet/if_ether.h>?
423 AC_CHECK_TYPES(struct ether_addr,,,
425 #include <sys/types.h>
426 #include <sys/socket.h>
428 #include <netinet/in.h>
429 #include <netinet/if_ether.h>
435 # For various things that might use pthreads.
437 AC_CHECK_HEADER(pthread.h,
440 # OK, we have pthread.h. Do we have pthread_create in the
443 AC_CHECK_FUNC(pthread_create,
448 ac_lbl_have_pthreads="found"
452 # No - do we have it in -lpthreads?
454 AC_CHECK_LIB(pthreads, pthread_create,
457 # Yes - add -lpthreads.
459 ac_lbl_have_pthreads="found"
460 PTHREAD_LIBS="$PTHREAD_LIBS -lpthreads"
464 # No - do we have it in -lpthread?
466 AC_CHECK_LIB(pthread, pthread_create,
469 # Yes - add -lpthread.
471 ac_lbl_have_pthreads="found"
472 PTHREAD_LIBS="$PTHREAD_LIBS -lpthread"
478 ac_lbl_have_pthreads="not found"
485 # We didn't find pthread.h.
487 ac_lbl_have_pthreads="not found"
491 dnl to pacify those who hate protochain insn
492 AC_MSG_CHECKING(if --disable-protochain option is specified)
493 AC_ARG_ENABLE(protochain,
494 AC_HELP_STRING([--disable-protochain],[disable \"protochain\" insn]))
495 case "x$enable_protochain" in
496 xyes) enable_protochain=enabled ;;
497 xno) enable_protochain=disabled ;;
498 x) enable_protochain=enabled ;;
501 if test "$enable_protochain" = "disabled"; then
502 AC_DEFINE(NO_PROTOCHAIN,1,[do not use protochain])
504 AC_MSG_RESULT(${enable_protochain})
507 # valgrindtest directly uses the native capture mechanism, but
508 # only tests with BPF and PF_PACKET sockets; only enable it if
509 # we have BPF or PF_PACKET sockets.
514 # SITA support is mutually exclusive with native capture support;
515 # "--with-sita" selects SITA support.
518 AC_HELP_STRING([--with-sita],[include SITA support]),
520 if test ! "x$withval" = "xno" ; then
521 AC_DEFINE(SITA,1,[include ACN support])
522 AC_MSG_NOTICE(Enabling SITA ACN support)
528 AC_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE]))
529 if test ! -z "$with_pcap" ; then
533 # Check for a bunch of headers for various packet
534 # capture mechanisms.
536 AC_CHECK_HEADERS(net/bpf.h)
537 if test "$ac_cv_header_net_bpf_h" = yes; then
539 # Does it define BIOCSETIF?
540 # I.e., is it a header for an LBL/BSD-style capture
541 # mechanism, or is it just a header for a BPF filter
542 # engine? Some versions of Arch Linux, for example,
543 # have a net/bpf.h that doesn't define BIOCSETIF;
544 # as it's a Linux, it should use packet sockets,
549 # sys/types.h, because FreeBSD 10's net/bpf.h
550 # requires that various BSD-style integer types
553 # sys/ioctl.h and, if we have it, sys/ioccom.h,
554 # because net/bpf.h defines ioctls;
556 # net/if.h, because it defines some structures
557 # used in ioctls defined by net/bpf.h;
559 # sys/socket.h, because OpenBSD 5.9's net/bpf.h
560 # defines some structure fields as being
563 # and net/bpf.h doesn't necessarily include all
564 # of those headers itself.
566 AC_MSG_CHECKING(if net/bpf.h defines BIOCSETIF)
567 AC_CACHE_VAL(ac_cv_lbl_bpf_h_defines_biocsetif,
570 #include <sys/types.h>
571 #include <sys/ioctl.h>
572 #include <sys/socket.h>
573 #ifdef HAVE_SYS_IOCCOM_H
574 #include <sys/ioccom.h>
579 [u_int i = BIOCSETIF;],
580 ac_cv_lbl_bpf_h_defines_biocsetif=yes,
581 ac_cv_lbl_bpf_h_defines_biocsetif=no))
582 AC_MSG_RESULT($ac_cv_lbl_bpf_h_defines_biocsetif)
584 AC_CHECK_HEADERS(net/pfilt.h net/enet.h)
585 AC_CHECK_HEADERS(net/nit.h sys/net/nit.h)
586 AC_CHECK_HEADERS(linux/socket.h net/raw.h sys/dlpi.h)
588 if test "$ac_cv_lbl_bpf_h_defines_biocsetif" = yes; then
591 # Check this before DLPI, so that we pick BPF on
592 # Solaris 11 and later.
597 # We have BPF, so build valgrindtest with "make test"
598 # on macOS and FreeBSD (add your OS once there's a
603 freebsd*|darwin*|linux*)
604 VALGRINDTEST_SRC=valgrindtest.c
607 elif test "$ac_cv_header_linux_socket_h" = yes; then
609 # No prizes for guessing this one.
614 # XXX - this won't work with older kernels that have
615 # SOCK_PACKET sockets but not PF_PACKET sockets.
617 VALGRINDTEST_SRC=valgrindtest.c
618 elif test "$ac_cv_header_net_pfilt_h" = yes; then
620 # DEC OSF/1, Digital UNIX, Tru64 UNIX
623 elif test "$ac_cv_header_net_enet_h" = yes; then
625 # Stanford Enetfilter.
628 elif test "$ac_cv_header_net_nit_h" = yes; then
630 # SunOS 4.x STREAMS NIT.
633 elif test "$ac_cv_header_sys_net_nit_h" = yes; then
635 # Pre-SunOS 4.x non-STREAMS NIT.
638 elif test "$ac_cv_header_net_raw_h" = yes; then
643 elif test "$ac_cv_header_sys_dlpi_h" = yes; then
645 # DLPI on pre-Solaris 11 SunOS 5, HP-UX, possibly others.
650 # Nothing we support.
653 AC_MSG_WARN(cannot determine packet capture interface)
654 AC_MSG_WARN((see the INSTALL doc for more info))
657 AC_MSG_CHECKING(packet capture type)
658 AC_MSG_RESULT($V_PCAP)
659 AC_SUBST(VALGRINDTEST_SRC)
662 # Do capture-mechanism-dependent tests.
667 # Needed for common functions used by pcap-[dlpi,libdlpi].c
672 # Checks for some header files.
674 AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
677 # Checks to see if Solaris has the public libdlpi(3LIB) library.
678 # Note: The existence of /usr/include/libdlpi.h does not mean it is the
679 # public libdlpi(3LIB) version. Before libdlpi was made public, a
680 # private version also existed, which did not have the same APIs.
681 # Due to a gcc bug, the default search path for 32-bit libraries does
682 # not include /lib, we add it explicitly here.
683 # [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485].
684 # Also, due to the bug above applications that link to libpcap with
685 # libdlpi will have to add "-L/lib" option to "configure".
687 saved_ldflags=$LDFLAGS
688 LDFLAGS="$LIBS -L/lib"
689 AC_CHECK_LIB(dlpi, dlpi_walk,
693 AC_DEFINE(HAVE_LIBDLPI,1,[if libdlpi exists])
696 LDFLAGS=$saved_ldflags
699 # Checks whether <sys/dlpi.h> is usable, to catch weird SCO
702 AC_MSG_CHECKING(whether <sys/dlpi.h> is usable)
703 AC_CACHE_VAL(ac_cv_sys_dlpi_usable,
706 #include <sys/types.h>
707 #include <sys/time.h>
708 #include <sys/dlpi.h>
710 [int i = DL_PROMISC_PHYS;],
711 ac_cv_sys_dlpi_usable=yes,
712 ac_cv_sys_dlpi_usable=no))
713 AC_MSG_RESULT($ac_cv_sys_dlpi_usable)
714 if test $ac_cv_sys_dlpi_usable = no ; then
715 AC_MSG_ERROR(<sys/dlpi.h> is not usable on this system; it probably has a non-standard DLPI)
719 # Check to see if Solaris has the dl_passive_req_t struct defined
721 # This check is for DLPI support for passive modes.
722 # See dlpi(7P) for more details.
724 AC_CHECK_TYPES(dl_passive_req_t,,,
726 #include <sys/types.h>
727 #include <sys/dlpi.h>
733 # Do we have the wireless extensions?
735 AC_CHECK_HEADERS(linux/wireless.h, [], [],
737 #include <sys/socket.h>
738 #include <linux/if.h>
739 #include <linux/types.h>
746 AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]),
747 with_libnl=$withval,with_libnl=if_available)
749 if test x$with_libnl != xno ; then
752 incdir=-I/usr/include/libnl3
754 case "$with_libnl" in
760 if test -d $withval; then
761 libnldir=-L${withval}/lib/.libs
762 incdir=-I${withval}/include
768 # Try libnl 3.x first.
770 AC_CHECK_LIB(nl-3, nl_socket_alloc,
773 # Yes, we have libnl 3.x.
775 LIBS="${libnldir} -lnl-genl-3 -lnl-3 $LIBS"
776 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
777 AC_DEFINE(HAVE_LIBNL_3_x,1,[if libnl exists and is version 3.x])
778 AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
779 AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
780 V_INCLS="$V_INCLS ${incdir}"
782 ],[], ${incdir} ${libnldir} -lnl-genl-3 -lnl-3 )
784 if test x$have_any_nl = xno ; then
788 AC_CHECK_LIB(nl, nl_socket_alloc,
791 # Yes, we have libnl 2.x.
793 LIBS="${libnldir} -lnl-genl -lnl $LIBS"
794 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
795 AC_DEFINE(HAVE_LIBNL_2_x,1,[if libnl exists and is version 2.x])
796 AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
797 AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
802 if test x$have_any_nl = xno ; then
804 # No, we don't; do we have libnl 1.x?
806 AC_CHECK_LIB(nl, nl_handle_alloc,
811 LIBS="${libnldir} -lnl $LIBS"
812 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
817 if test x$have_any_nl = xno ; then
819 # No, we don't have libnl at all.
821 if test x$with_libnl = xyes ; then
822 AC_MSG_ERROR([libnl support requested but libnl not found])
827 AC_CHECK_HEADERS(linux/ethtool.h,,,
830 #include <linux/types.h>
834 # Check to see if struct tpacket_stats is defined in
835 # <linux/if_packet.h>. If so, then pcap-linux.c can use this
836 # to report proper statistics.
840 AC_CHECK_TYPES(struct tpacket_stats,,,
842 #include <linux/if_packet.h>
846 # Check to see if the tpacket_auxdata struct has a tp_vlan_tci member.
848 # NOTE: any failure means we conclude that it doesn't have that
849 # member, so if we don't have tpacket_auxdata, we conclude it
850 # doesn't have that member (which is OK, as either we won't be
851 # using code that would use that member, or we wouldn't compile
853 AC_CHECK_MEMBERS([struct tpacket_auxdata.tp_vlan_tci],,,
855 #include <sys/types.h>
856 #include <linux/if_packet.h>
862 # Check whether we have the *BSD-style ioctls.
864 AC_CHECK_HEADERS(net/if_media.h)
867 # Check whether we have struct BPF_TIMEVAL.
869 AC_CHECK_TYPES(struct BPF_TIMEVAL,,,
871 #include <sys/types.h>
872 #include <sys/ioctl.h>
873 #ifdef HAVE_SYS_IOCCOM_H
874 #include <sys/ioccom.h>
882 # --with-pcap=dag is the only way to get here, and it means
883 # "DAG support but nothing else"
885 V_DEFS="$V_DEFS -DDAG_ONLY"
891 # --with-pcap=septel is the only way to get here, and it means
892 # "Septel support but nothing else"
894 V_DEFS="$V_DEFS -DSEPTEL_ONLY"
900 # --with-pcap=snf is the only way to get here, and it means
901 # "SNF support but nothing else"
903 V_DEFS="$V_DEFS -DSNF_ONLY"
911 AC_MSG_ERROR($V_PCAP is not a valid pcap type)
916 dnl Now figure out how we get a list of interfaces and addresses,
917 dnl if we support capturing. Don't bother if we don't support
920 if test "$V_PCAP" != null
922 AC_CHECK_FUNC(getifaddrs,[
924 # We have "getifaddrs()"; make sure we have <ifaddrs.h>
925 # as well, just in case some platform is really weird.
927 AC_CHECK_HEADER(ifaddrs.h,[
929 # We have the header, so we use "getifaddrs()" to
930 # get the list of interfaces.
932 V_FINDALLDEVS=fad-getad.c
935 # We don't have the header - give up.
936 # XXX - we could also fall back on some other
937 # mechanism, but, for now, this'll catch this
938 # problem so that we can at least try to figure
939 # out something to do on systems with "getifaddrs()"
940 # but without "ifaddrs.h", if there is something
941 # we can do on those systems.
943 AC_MSG_ERROR([Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>.])
947 # Well, we don't have "getifaddrs()", at least not with the
948 # libraries with which we've decided we need to link
949 # libpcap with, so we have to use some other mechanism.
951 # Note that this may happen on Solaris, which has
952 # getifaddrs(), but in -lsocket, not in -lxnet, so we
953 # won't find it if we link with -lxnet, which we want
954 # to do for other reasons.
956 # For now, we use either the SIOCGIFCONF ioctl or the
957 # SIOCGLIFCONF ioctl, preferring the latter if we have
958 # it; the latter is a Solarisism that first appeared
959 # in Solaris 8. (Solaris's getifaddrs() appears to
960 # be built atop SIOCGLIFCONF; using it directly
961 # avoids a not-all-that-useful middleman.)
963 AC_MSG_CHECKING(whether we have SIOCGLIFCONF)
964 AC_CACHE_VAL(ac_cv_lbl_have_siocglifconf,
966 [#include <sys/param.h>
967 #include <sys/file.h>
968 #include <sys/ioctl.h>
969 #include <sys/socket.h>
970 #include <sys/sockio.h>],
971 [ioctl(0, SIOCGLIFCONF, (char *)0);],
972 ac_cv_lbl_have_siocglifconf=yes,
973 ac_cv_lbl_have_siocglifconf=no))
974 AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
975 if test $ac_cv_lbl_have_siocglifconf = yes ; then
976 V_FINDALLDEVS=fad-glifc.c
978 V_FINDALLDEVS=fad-gifc.c
984 dnl check for hardware timestamp support
987 AC_CHECK_HEADERS([linux/net_tstamp.h])
990 AC_MSG_NOTICE(no hardware timestamp support implemented for $host_os)
994 AC_ARG_ENABLE([packet-ring],
995 [AC_HELP_STRING([--enable-packet-ring],[enable packet ring support on Linux @<:@default=yes@:>@])],
996 ,enable_packet_ring=yes)
998 if test "x$enable_packet_ring" != "xno" ; then
999 AC_DEFINE(PCAP_SUPPORT_PACKET_RING, 1, [use packet ring capture support on Linux if available])
1000 AC_SUBST(PCAP_SUPPORT_PACKET_RING)
1004 # Check for socklen_t.
1006 AC_CHECK_TYPES(socklen_t,,,
1008 #include <sys/types.h>
1009 #include <sys/socket.h>
1013 AC_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes@:>@]),
1016 if test "$enable_ipv6" != "no"; then
1018 # We've already made sure we have getaddrinfo above in
1019 # AC_LBL_LIBRARY_NET.
1021 AC_DEFINE(INET6,1,[IPv6])
1024 # Check for Endace DAG card support.
1026 AC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1028 if test "$withval" = no
1030 # User doesn't want DAG support.
1032 elif test "$withval" = yes
1034 # User wants DAG support but hasn't specified a directory.
1037 # User wants DAG support and has specified a directory, so use the provided value.
1042 if test "$V_PCAP" = dag; then
1043 # User requested DAG-only libpcap, so we'd better have
1046 elif test "xxx_only" = yes; then
1047 # User requested something-else-only pcap, so they don't
1052 # Use DAG API if present, otherwise don't
1058 AC_ARG_WITH([dag-includes],
1059 AC_HELP_STRING([--with-dag-includes=IDIR],[Endace DAG include directory, if not DIR/include]),
1061 # User wants DAG support and has specified a header directory, so use the provided value.
1063 dag_include_dir=$withval
1066 AC_ARG_WITH([dag-libraries],
1067 AC_HELP_STRING([--with-dag-libraries=LDIR],[Endace DAG library directory, if not DIR/lib]),
1069 # User wants DAG support and has specified a library directory, so use the provided value.
1071 dag_lib_dir=$withval
1074 if test "$want_dag" != no; then
1076 # If necessary, set default paths for DAG API headers and libraries.
1077 if test -z "$dag_root"; then
1081 if test -z "$dag_include_dir"; then
1082 dag_include_dir="$dag_root/include"
1085 if test -z "$dag_lib_dir"; then
1086 dag_lib_dir="$dag_root/lib"
1089 V_INCLS="$V_INCLS -I$dag_include_dir"
1091 AC_CHECK_HEADERS([dagapi.h])
1093 if test "$ac_cv_header_dagapi_h" = yes; then
1095 if test $V_PCAP != dag ; then
1096 SSRC="$SSRC pcap-dag.c"
1099 # Check for various DAG API functions.
1100 # Don't need to save and restore LIBS to prevent -ldag being
1101 # included if there's a found-action (arg 3).
1102 saved_ldflags=$LDFLAGS
1103 LDFLAGS="-L$dag_lib_dir"
1104 AC_CHECK_LIB([dag], [dag_attach_stream],
1106 [AC_MSG_ERROR(DAG library lacks streams support)])
1107 AC_CHECK_LIB([dag], [dag_attach_stream64], [dag_large_streams="1"], [dag_large_streams="0"])
1108 AC_CHECK_LIB([dag],[dag_get_erf_types], [
1109 AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])])
1110 AC_CHECK_LIB([dag],[dag_get_stream_erf_types], [
1111 AC_DEFINE(HAVE_DAG_GET_STREAM_ERF_TYPES, 1, [define if you have dag_get_stream_erf_types()])])
1113 LDFLAGS=$saved_ldflags
1116 # We assume that if we have libdag we have libdagconf,
1117 # as they're installed at the same time from the same
1120 LIBS="$LIBS -ldag -ldagconf"
1121 LDFLAGS="$LDFLAGS -L$dag_lib_dir"
1123 if test "$dag_large_streams" = 1; then
1124 AC_DEFINE(HAVE_DAG_LARGE_STREAMS_API, 1, [define if you have large streams capable DAG API])
1125 AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"])
1126 if test "$ac_dag_have_vdag" = 1; then
1127 AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()])
1128 if test "$ac_lbl_have_pthreads" != "found"; then
1129 AC_MSG_ERROR([DAG requires pthreads, but we didn't find them])
1131 LIBS="$LIBS $PTHREAD_LIBS"
1135 AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
1138 if test "$V_PCAP" = dag; then
1139 # User requested "dag" capture type but we couldn't
1140 # find the DAG API support.
1141 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])
1144 if test "$want_dag" = yes; then
1145 # User wanted DAG support but we couldn't find it.
1146 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])
1152 AC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1154 if test "$withval" = no
1157 elif test "$withval" = yes
1163 septel_root=$withval
1166 if test "$V_PCAP" = septel; then
1167 # User requested Septel-only libpcap, so we'd better have
1170 elif test "xxx_only" = yes; then
1171 # User requested something-else-only pcap, so they don't
1172 # want Septel support.
1176 # Use Septel API if present, otherwise don't
1178 want_septel=ifpresent
1182 ac_cv_lbl_septel_api=no
1183 if test "$with_septel" != no; then
1185 AC_MSG_CHECKING([whether we have Septel API headers])
1187 # If necessary, set default paths for Septel API headers and libraries.
1188 if test -z "$septel_root"; then
1189 septel_root=$srcdir/../septel
1192 septel_tools_dir="$septel_root"
1193 septel_include_dir="$septel_root/INC"
1195 if test -r "$septel_include_dir/msg.h"; then
1196 ac_cv_lbl_septel_api=yes
1199 if test "$ac_cv_lbl_septel_api" = yes; then
1200 AC_MSG_RESULT([yes ($septel_include_dir)])
1202 V_INCLS="$V_INCLS -I$septel_include_dir"
1203 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"
1204 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"
1206 if test "$V_PCAP" != septel ; then
1207 SSRC="$SSRC pcap-septel.c"
1210 AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have the Septel API])
1214 if test "$V_PCAP" = septel; then
1215 # User requested "septel" capture type but
1216 # we couldn't find the Septel API support.
1217 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])
1220 if test "$want_septel" = yes; then
1221 # User wanted Septel support but we couldn't find it.
1222 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])
1227 # Check for Myricom SNF support.
1229 AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1231 if test "$withval" = no
1233 # User explicitly doesn't want SNF
1235 elif test "$withval" = yes
1237 # User wants SNF support but hasn't specified a directory.
1240 # User wants SNF support with a specified directory.
1245 if test "$V_PCAP" = snf; then
1246 # User requested Sniffer-only libpcap, so we'd better have
1249 elif test "xxx_only" = yes; then
1250 # User requested something-else-only pcap, so they don't
1255 # Use Sniffer API if present, otherwise don't
1261 AC_ARG_WITH([snf-includes],
1262 AC_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not DIR/include]),
1264 # User wants SNF with specific header directory
1266 snf_include_dir=$withval
1269 AC_ARG_WITH([snf-libraries],
1270 AC_HELP_STRING([--with-snf-libraries=LDIR],[Myricom SNF library directory, if not DIR/lib]),
1272 # User wants SNF with specific lib directory
1274 snf_lib_dir=$withval
1277 ac_cv_lbl_snf_api=no
1278 if test "$with_snf" != no; then
1280 AC_MSG_CHECKING(whether we have Myricom Sniffer API)
1282 # If necessary, set default paths for Sniffer headers and libraries.
1283 if test -z "$snf_root"; then
1287 if test -z "$snf_include_dir"; then
1288 snf_include_dir="$snf_root/include"
1291 if test -z "$snf_lib_dir"; then
1292 snf_lib_dir="$snf_root/lib"
1295 if test -f "$snf_include_dir/snf.h"; then
1296 # We found a header; make sure we can link with the library
1297 saved_ldflags=$LDFLAGS
1298 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1299 AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"])
1300 LDFLAGS="$saved_ldflags"
1301 if test "$ac_cv_lbl_snf_api" = no; then
1302 AC_MSG_ERROR(SNF API cannot correctly be linked; check config.log)
1306 if test "$ac_cv_lbl_snf_api" = yes; then
1307 AC_MSG_RESULT([yes ($snf_root)])
1309 V_INCLS="$V_INCLS -I$snf_include_dir"
1311 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1313 if test "$V_PCAP" != snf ; then
1314 SSRC="$SSRC pcap-snf.c"
1317 AC_DEFINE(HAVE_SNF_API, 1, [define if you have the Myricom SNF API])
1321 if test "$want_snf" = yes; then
1322 # User requested "snf" capture type but
1323 # we couldn't find the Sniffer API support.
1324 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])
1327 if test "$want_snf" = yes; then
1328 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])
1333 # Check for Riverbed TurboCap support.
1334 AC_ARG_WITH([turbocap],
1335 AC_HELP_STRING([--with-turbocap@<:@=DIR@:>@],[include Riverbed TurboCap support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1337 if test "$withval" = no
1339 # User explicitly doesn't want TurboCap
1341 elif test "$withval" = yes
1343 # User wants TurboCap support but hasn't specified a directory.
1346 # User wants TurboCap support with a specified directory.
1348 turbocap_root=$withval
1351 if test "xxx_only" = yes; then
1352 # User requested something-else-only pcap, so they don't
1353 # want TurboCap support.
1357 # Use TurboCap API if present, otherwise don't
1359 want_turbocap=ifpresent
1363 ac_cv_lbl_turbocap_api=no
1364 if test "$want_turbocap" != no; then
1366 AC_MSG_CHECKING(whether TurboCap is supported)
1368 save_CFLAGS="$CFLAGS"
1370 if test ! -z "$turbocap_root"; then
1371 TURBOCAP_CFLAGS="-I$turbocap_root/include"
1372 TURBOCAP_LIBS="-L$turbocap_root/lib"
1373 CFLAGS="$CFLAGS $TURBOCAP_CFLAGS"
1381 TC_INSTANCE a; TC_PORT b; TC_BOARD c;
1383 (void)TcInstanceCreateByName("foo", &i);
1385 ac_cv_lbl_turbocap_api=yes)
1387 CFLAGS="$save_CFLAGS"
1388 if test $ac_cv_lbl_turbocap_api = yes; then
1391 SSRC="$SSRC pcap-tc.c"
1392 V_INCLS="$V_INCLS $TURBOCAP_CFLAGS"
1393 LIBS="$LIBS $TURBOCAP_LIBS -lTcApi -lpthread -lstdc++"
1395 AC_DEFINE(HAVE_TC_API, 1, [define if you have the TurboCap API])
1399 if test "$want_turbocap" = yes; then
1400 # User wanted Turbo support but we couldn't find it.
1401 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])
1407 dnl Allow the user to enable remote capture.
1408 dnl It's off by default, as that increases the attack surface of
1409 dnl libpcap, exposing it to malicious servers.
1411 AC_MSG_CHECKING([whether to enable remote packet capture])
1412 AC_ARG_ENABLE(remote,
1413 [ --enable-remote enable remote packet capture @<:@default=no@:>@
1414 --disable-remote disable remote packet capture],,
1416 case "$enableval" in
1417 yes) AC_MSG_RESULT(yes)
1418 AC_WARN([Remote packet capture may expose libpcap-based applications])
1419 AC_WARN([to attacks by malicious remote capture servers!])
1421 # rpcapd requires pthreads on UN*X.
1423 if test "$ac_lbl_have_pthreads" != "found"; then
1424 AC_MSG_ERROR([rpcapd requires pthreads, but we didn't find them])
1427 # It also requires crypt().
1428 # Do we have it in the system libraries?
1430 AC_CHECK_FUNC(crypt,,
1433 # No. Do we have it in -lcrypt?
1435 AC_CHECK_LIB(crypt, crypt,
1438 # Yes; add -lcrypt to the libraries for rpcapd.
1440 RPCAPD_LIBS="$RPCAPD_LIBS -lcrypt"
1443 AC_MSG_ERROR([rpcapd requires crypt(), but we didn't find it])
1448 # OK, we have crypt(). Do we have getspnam()?
1450 AC_CHECK_FUNCS(getspnam)
1453 # Check for various members of struct msghdr.
1455 AC_CHECK_MEMBERS([struct msghdr.msg_control],,,
1457 #include "ftmacros.h"
1458 #include <sys/socket.h>
1460 AC_CHECK_MEMBERS([struct msghdr.msg_flags],,,
1462 #include "ftmacros.h"
1463 #include <sys/socket.h>
1466 AC_DEFINE(ENABLE_REMOTE,,
1467 [Define to 1 if remote packet capture is to be supported])
1468 SSRC="$SSRC pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c"
1469 BUILD_RPCAPD=build-rpcapd
1470 INSTALL_RPCAPD=install-rpcapd
1472 *) AC_MSG_RESULT(no)
1476 AC_MSG_CHECKING(whether to build optimizer debugging code)
1477 AC_ARG_ENABLE(optimizer-dbg,
1478 AC_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code]))
1479 if test "$enable_optimizer_dbg" = "yes"; then
1480 AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
1482 AC_MSG_RESULT(${enable_optimizer_dbg-no})
1484 AC_MSG_CHECKING(whether to build parser debugging code)
1485 AC_ARG_ENABLE(yydebug,
1486 AC_HELP_STRING([--enable-yydebug],[build parser debugging code]))
1487 if test "$enable_yydebug" = "yes"; then
1488 AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
1490 AC_MSG_RESULT(${enable_yydebug-no})
1496 if test "$LEX" = ":"; then
1497 AC_MSG_ERROR([Neither flex nor lex was found.])
1501 # Make sure {f}lex supports the -P, --header-file, and --nounput flags
1502 # and supports processing our scanner.l.
1504 AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
1505 if $LEX -P pcap_ --header-file=/dev/null --nounput -t $srcdir/scanner.l > /dev/null 2>&1; then
1506 tcpdump_cv_capable_lex=yes
1508 tcpdump_cv_capable_lex=insufficient
1510 if test $tcpdump_cv_capable_lex = insufficient ; then
1511 AC_MSG_ERROR([$LEX is insufficient to compile libpcap.
1512 libpcap requires Flex 2.5.31 or later, or a compatible version of lex.])
1516 # Look for yacc/bison/byacc.
1521 # Make sure it supports the -p flag and supports processing our
1524 AC_CACHE_CHECK([for capable yacc/bison], tcpdump_cv_capable_yacc,
1525 if $YACC -p pcap_ -o /dev/null $srcdir/grammar.y >/dev/null 2>&1; then
1526 tcpdump_cv_capable_yacc=yes
1528 tcpdump_cv_capable_yacc=insufficient
1530 if test $tcpdump_cv_capable_yacc = insufficient ; then
1531 AC_MSG_ERROR([$YACC is insufficient to compile libpcap.
1532 libpcap requires Bison, Berkeley YACC, or another YACC compatible with them.])
1536 # Do various checks for various OSes and versions of those OSes.
1538 # Assume, by default, no support for shared libraries and V7/BSD
1539 # convention for man pages (file formats in section 5, miscellaneous
1540 # info in section 7, administrative commands and daemons in section 8).
1541 # Individual cases can override this.
1546 MAN_ADMIN_COMMANDS=8
1550 dnl Workaround to enable certain features
1551 AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
1554 # AIX makes it fun to build shared and static libraries,
1555 # because they're *both* ".a" archive libraries. We
1556 # build the static library for the benefit of the traditional
1557 # scheme of building libpcap and tcpdump in subdirectories of
1558 # the same directory, with tcpdump statically linked with the
1559 # libpcap in question, but we also build a shared library as
1560 # "libpcap.shareda" and install *it*, rather than the static
1561 # library, as "libpcap.a".
1569 # If we're using DLPI, applications will need to
1570 # use /lib/pse.exp if present, as we use the
1573 pseexe="/lib/pse.exp"
1574 AC_MSG_CHECKING(for $pseexe)
1575 if test -f $pseexe ; then
1583 # If we're using BPF, we need "-lodm" and "-lcfg", as
1584 # we use them to load the BPF module.
1593 V_CCOPT="$V_CCOPT -fno-common"
1594 AC_ARG_ENABLE(universal,
1595 AC_HELP_STRING([--disable-universal],[don't build universal on macOS]))
1596 if test "$enable_universal" != "no"; then
1601 # Pre-Tiger. Build only for 32-bit PowerPC; no
1602 # need for any special compiler or linker flags.
1608 # Tiger, prior to Intel support. Build for 32-bit
1609 # PowerPC and 64-bit PowerPC, with 32-bit PowerPC
1610 # first. (I'm guessing that's what Apple does.)
1612 V_CCOPT="$V_CCOPT -arch ppc -arch ppc64"
1613 LDFLAGS="$LDFLAGS -arch ppc -arch ppc64"
1618 # Tiger, subsequent to Intel support but prior to
1619 # x86-64 support. Build for 32-bit PowerPC, 64-bit
1620 # PowerPC, and x86, with 32-bit PowerPC first.
1621 # (I'm guessing that's what Apple does.)
1623 V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386"
1624 LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386"
1629 # All other Tiger, so subsequent to x86-64
1630 # support. Build for 32-bit PowerPC, 64-bit
1631 # PowerPC, x86, and x86-64, and with 32-bit PowerPC
1632 # first. (I'm guessing that's what Apple does.)
1634 V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1635 LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1640 # Leopard. Build for 32-bit PowerPC, 64-bit
1641 # PowerPC, x86, and x86-64, with 32-bit PowerPC
1642 # first. (That's what Apple does.)
1644 V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1645 LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1650 # Snow Leopard. Build for x86-64, x86, and
1651 # 32-bit PowerPC, with x86-64 first. (That's
1652 # what Apple does, even though Snow Leopard
1653 # doesn't run on PPC, so PPC libpcap runs under
1654 # Rosetta, and Rosetta doesn't support BPF
1655 # ioctls, so PPC programs can't do live
1658 V_CCOPT="$V_CCOPT -arch x86_64 -arch i386 -arch ppc"
1659 LDFLAGS="$LDFLAGS -arch x86_64 -arch i386 -arch ppc"
1664 # Post-Snow Leopard. Build for x86-64 and
1665 # x86, with x86-64 first. (That's probably what
1666 # Apple does, given that Rosetta is gone.)
1667 # XXX - update if and when Apple drops support
1668 # for 32-bit x86 code.
1670 V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
1671 LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
1678 AC_DEFINE(HAVE_HPUX9,1,[on HP-UX 9.x])
1681 # Use System V conventions for man pages.
1683 MAN_ADMIN_COMMANDS=1m
1691 # Use System V conventions for man pages.
1693 MAN_ADMIN_COMMANDS=1m
1701 # Use System V conventions for man pages.
1703 MAN_ADMIN_COMMANDS=1m
1709 dnl HPUX 10.20 and above is similar to HPUX 9, but
1710 dnl not the same....
1712 dnl XXX - DYEXT should be set to "sl" if this is building
1713 dnl for 32-bit PA-RISC, but should be left as "so" for
1714 dnl 64-bit PA-RISC or, I suspect, IA-64.
1715 AC_DEFINE(HAVE_HPUX10_20_OR_LATER,1,[on HP-UX 10.20 or later])
1716 if test "`uname -m`" = "ia64"; then
1723 # "-b" builds a shared library; "+h" sets the soname.
1729 # Use System V conventions for man pages.
1737 # Use IRIX conventions for man pages; they're the same as the
1738 # System V conventions, except that they use section 8 for
1739 # administrative commands and daemons.
1745 linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*)
1749 # Compiler assumed to be GCC; run-time linker may require a -R
1752 if test "$libdir" != "/usr/lib"; then
1753 V_RFLAGS=-Wl,-R$libdir
1761 # DEC OSF/1, a/k/a Digial UNIX, a/k/a Tru64 UNIX.
1762 # Use Tru64 UNIX conventions for man pages; they're the same as
1763 # the System V conventions except that they use section 8 for
1764 # administrative commands and daemons.
1771 AC_MSG_CHECKING(if SINIX compiler defines sinix)
1772 AC_CACHE_VAL(ac_cv_cc_sinix_defined,
1776 ac_cv_cc_sinix_defined=yes,
1777 ac_cv_cc_sinix_defined=no))
1778 AC_MSG_RESULT($ac_cv_cc_sinix_defined)
1779 if test $ac_cv_cc_sinix_defined = no ; then
1780 AC_DEFINE(sinix,1,[on sinix])
1785 AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
1790 # Make sure errno is thread-safe, in case we're called in
1791 # a multithreaded program. We don't guarantee that two
1792 # threads can use the *same* pcap_t safely, but the
1793 # current version does guarantee that you can use different
1794 # pcap_t's in different threads, and even that pcap_compile()
1795 # is thread-safe (it wasn't thread-safe in some older versions).
1797 V_CCOPT="$V_CCOPT -D_TS_ERRNO"
1799 case "`uname -r`" in
1806 # Use System V conventions for man pages.
1808 MAN_ADMIN_COMMANDS=1m
1815 AC_ARG_ENABLE(shared,
1816 AC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@]))
1817 test "x$enable_shared" = "xno" && DYEXT="none"
1820 AC_CHECK_TOOL([AR], [ar])
1825 AC_LBL_DEVEL(V_CCOPT)
1828 # Check to see if the sockaddr struct has the 4.4 BSD sa_len member.
1830 AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,
1832 #include <sys/types.h>
1833 #include <sys/socket.h>
1837 # Check to see if there's a sockaddr_storage structure.
1839 AC_CHECK_TYPES(struct sockaddr_storage,,,
1841 #include <sys/types.h>
1842 #include <sys/socket.h>
1846 # Check to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
1847 # dl_module_id_1 member.
1849 # NOTE: any failure means we conclude that it doesn't have that member,
1850 # so if we don't have DLPI, don't have a <sys/dlpi_ext.h> header, or
1851 # have one that doesn't declare a dl_hp_ppa_info_t type, we conclude
1852 # it doesn't have that member (which is OK, as either we won't be
1853 # using code that would use that member, or we wouldn't compile in
1856 AC_CHECK_MEMBERS([dl_hp_ppa_info_t.dl_module_id_1],,,
1858 #include <sys/types.h>
1859 #include <sys/dlpi.h>
1860 #include <sys/dlpi_ext.h>
1863 AC_LBL_UNALIGNED_ACCESS
1867 AC_SUBST(V_FINDALLDEVS)
1871 AC_SUBST(V_SHLIB_CCOPT)
1872 AC_SUBST(V_SHLIB_CMD)
1873 AC_SUBST(V_SHLIB_OPT)
1874 AC_SUBST(V_SONAME_OPT)
1875 AC_SUBST(V_RPATH_OPT)
1878 AC_SUBST(ADDLARCHIVEOBJS)
1881 AC_SUBST(MAN_FILE_FORMATS)
1882 AC_SUBST(MAN_MISC_INFO)
1883 AC_SUBST(MAN_ADMIN_COMMANDS)
1884 AC_SUBST(PTHREAD_LIBS)
1885 AC_SUBST(BUILD_RPCAPD)
1886 AC_SUBST(INSTALL_RPCAPD)
1887 AC_SUBST(RPCAPD_LIBS)
1888 AC_SUBST(EXTRA_NETWORK_LIBS)
1890 AC_ARG_ENABLE([usb],
1891 [AC_HELP_STRING([--enable-usb],[enable USB capture support @<:@default=yes, if support available@:>@])],
1895 if test "xxx_only" = yes; then
1896 # User requested something-else-only pcap, so they don't
1901 if test "x$enable_usb" != "xno" ; then
1902 dnl check for USB sniffing support
1903 AC_MSG_CHECKING(for USB sniffing support)
1906 AC_DEFINE(PCAP_SUPPORT_USB, 1, [target host supports USB sniffing])
1907 USB_SRC=pcap-usb-linux.c
1909 ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null`
1910 if test $? -ne 0 ; then
1911 ac_usb_dev_name="usbmon"
1913 AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing])
1914 AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name)
1916 # Do we have a version of <linux/compiler.h> available?
1917 # If so, we might need it for <linux/usbdevice_fs.h>.
1919 AC_CHECK_HEADERS(linux/compiler.h)
1920 if test "$ac_cv_header_linux_compiler_h" = yes; then
1922 # Yes - include it when testing for <linux/usbdevice_fs.h>.
1924 AC_CHECK_HEADERS(linux/usbdevice_fs.h,,,[#include <linux/compiler.h>])
1926 AC_CHECK_HEADERS(linux/usbdevice_fs.h)
1928 if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then
1930 # OK, does it define bRequestType? Older versions of the kernel
1931 # define fields with names like "requesttype, "request", and
1932 # "value", rather than "bRequestType", "bRequest", and
1935 AC_CHECK_MEMBERS([struct usbdevfs_ctrltransfer.bRequestType],,,
1938 #ifdef HAVE_LINUX_COMPILER_H
1939 #include <linux/compiler.h>
1941 #include <linux/usbdevice_fs.h>
1947 # This just uses BPF in FreeBSD 8.4 and later; we don't need
1948 # to check for anything special for capturing.
1950 AC_MSG_RESULT([yes, in FreeBSD 8.4 and later])
1958 AC_SUBST(PCAP_SUPPORT_USB)
1961 dnl check for netfilter sniffing support
1962 if test "xxx_only" != yes; then
1963 AC_MSG_CHECKING(whether the platform could support netfilter sniffing)
1968 # Life's too short to deal with trying to get this to compile
1969 # if you don't get the right types defined with
1970 # __KERNEL_STRICT_NAMES getting defined by some other include.
1972 # Check whether the includes Just Work. If not, don't turn on
1973 # netfilter support.
1975 AC_MSG_CHECKING(whether we can compile the netfilter support)
1976 AC_CACHE_VAL(ac_cv_netfilter_can_compile,
1979 #include <sys/socket.h>
1980 #include <netinet/in.h>
1981 #include <linux/types.h>
1983 #include <linux/netlink.h>
1984 #include <linux/netfilter.h>
1985 #include <linux/netfilter/nfnetlink.h>
1986 #include <linux/netfilter/nfnetlink_log.h>
1987 #include <linux/netfilter/nfnetlink_queue.h>],
1989 ac_cv_netfilter_can_compile=yes,
1990 ac_cv_netfilter_can_compile=no))
1991 AC_MSG_RESULT($ac_cv_netfilter_can_compile)
1992 if test $ac_cv_netfilter_can_compile = yes ; then
1993 AC_DEFINE(PCAP_SUPPORT_NETFILTER, 1,
1994 [target host supports netfilter sniffing])
1995 NETFILTER_SRC=pcap-netfilter-linux.c
2003 AC_SUBST(PCAP_SUPPORT_NETFILTER)
2004 AC_SUBST(NETFILTER_SRC)
2006 AC_ARG_ENABLE([netmap],
2007 [AC_HELP_STRING([--enable-netmap],[enable netmap support @<:@default=yes, if support available@:>@])],
2009 [enable_netmap=yes])
2011 if test "x$enable_netmap" != "xno" ; then
2013 # Check whether net/netmap_user.h is usable if NETMAP_WITH_LIBS is
2014 # defined; it's not usable on DragonFly BSD 4.6 if NETMAP_WITH_LIBS
2015 # is defined, for example, as it includes a non-existent malloc.h
2018 AC_MSG_CHECKING(whether we can compile the netmap support)
2019 AC_CACHE_VAL(ac_cv_net_netmap_user_can_compile,
2022 #define NETMAP_WITH_LIBS
2023 #include <net/netmap_user.h>],
2025 ac_cv_net_netmap_user_can_compile=yes,
2026 ac_cv_net_netmap_user_can_compile=no))
2027 AC_MSG_RESULT($ac_cv_net_netmap_user_can_compile)
2028 if test $ac_cv_net_netmap_user_can_compile = yes ; then
2029 AC_DEFINE(PCAP_SUPPORT_NETMAP, 1,
2030 [target host supports netmap])
2031 NETMAP_SRC=pcap-netmap.c
2033 AC_SUBST(PCAP_SUPPORT_NETMAP)
2034 AC_SUBST(NETMAP_SRC)
2038 AC_ARG_ENABLE([bluetooth],
2039 [AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
2041 [enable_bluetooth=ifsupportavailable])
2043 if test "xxx_only" = yes; then
2044 # User requested something-else-only pcap, so they don't
2045 # want Bluetooth support.
2049 if test "x$enable_bluetooth" != "xno" ; then
2050 dnl check for Bluetooth sniffing support
2053 AC_CHECK_HEADER(bluetooth/bluetooth.h,
2056 # We have bluetooth.h, so we support Bluetooth
2059 AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
2060 BT_SRC=pcap-bt-linux.c
2061 AC_MSG_NOTICE(Bluetooth sniffing is supported)
2062 ac_lbl_bluetooth_available=yes
2065 # OK, does struct sockaddr_hci have an hci_channel
2068 AC_CHECK_MEMBERS([struct sockaddr_hci.hci_channel],
2071 # Yes; is HCI_CHANNEL_MONITOR defined?
2073 AC_MSG_CHECKING(if HCI_CHANNEL_MONITOR is defined)
2074 AC_CACHE_VAL(ac_cv_lbl_hci_channel_monitor_is_defined,
2077 #include <bluetooth/bluetooth.h>
2078 #include <bluetooth/hci.h>
2081 u_int i = HCI_CHANNEL_MONITOR;
2085 AC_DEFINE(PCAP_SUPPORT_BT_MONITOR,,
2086 [target host supports Bluetooth Monitor])
2087 BT_MONITOR_SRC=pcap-bt-monitor-linux.c
2094 #include <bluetooth/bluetooth.h>
2095 #include <bluetooth/hci.h>
2100 # We don't have bluetooth.h, so we don't support
2101 # Bluetooth sniffing.
2103 if test "x$enable_bluetooth" = "xyes" ; then
2104 AC_MSG_ERROR(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2106 AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2111 if test "x$enable_bluetooth" = "xyes" ; then
2112 AC_MSG_ERROR(no Bluetooth sniffing support implemented for $host_os)
2114 AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os)
2118 AC_SUBST(PCAP_SUPPORT_BT)
2120 AC_SUBST(BT_MONITOR_SRC)
2123 AC_ARG_ENABLE([dbus],
2124 [AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
2126 [enable_dbus=ifavailable])
2128 if test "xxx_only" = yes; then
2129 # User requested something-else-only pcap, so they don't
2130 # want D-Bus support.
2134 if test "x$enable_dbus" != "xno"; then
2135 if test "x$enable_dbus" = "xyes"; then
2140 # We don't support D-Bus sniffing on macOS; see
2142 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
2144 # The user requested it, so fail.
2146 AC_MSG_ERROR([Due to freedesktop.org bug 74029, D-Bus capture support is not available on macOS])
2153 # We don't support D-Bus sniffing on macOS; see
2155 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
2157 # The user dind't explicitly request it, so just
2158 # silently refuse to enable it.
2166 if test "x$enable_dbus" != "xno"; then
2167 AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no])
2168 if test "x$PKGCONFIG" != "xno"; then
2169 AC_MSG_CHECKING([for D-Bus])
2170 if "$PKGCONFIG" dbus-1; then
2171 AC_MSG_RESULT([yes])
2172 DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
2173 DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
2174 save_CFLAGS="$CFLAGS"
2176 CFLAGS="$CFLAGS $DBUS_CFLAGS"
2177 LIBS="$LIBS $DBUS_LIBS"
2178 AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
2180 [#include <string.h>
2183 #include <sys/time.h>
2185 #include <dbus/dbus.h>],
2186 [return dbus_connection_read_write(NULL, 0);],
2188 AC_MSG_RESULT([yes])
2189 AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
2190 DBUS_SRC=pcap-dbus.c
2191 V_INCLS="$V_INCLS $DBUS_CFLAGS"
2195 if test "x$enable_dbus" = "xyes"; then
2196 AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
2200 CFLAGS="$save_CFLAGS"
2203 if test "x$enable_dbus" = "xyes"; then
2204 AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed])
2208 AC_SUBST(PCAP_SUPPORT_DBUS)
2212 AC_ARG_ENABLE([rdma],
2213 [AC_HELP_STRING([--enable-rdma],[enable RDMA capture support @<:@default=yes, if support available@:>@])],
2215 [enable_rdmasniff=ifavailable])
2217 if test "xxx_only" = yes; then
2218 # User requested something-else-only pcap, so they don't
2219 # want RDMA support.
2223 if test "x$enable_rdmasniff" != "xno"; then
2224 AC_CHECK_LIB(ibverbs, ibv_get_device_list, [
2225 AC_CHECK_HEADER(infiniband/verbs.h, [
2227 # ibv_create_flow may be defined as a static inline
2228 # function in infiniband/verbs.h, so we can't
2231 # Too bad autoconf has no AC_SYMBOL_EXISTS()
2232 # macro that works like CMake's check_symbol_exists()
2233 # function, to check do a compile check like
2234 # this (they do a clever trick to avoid having
2235 # to know the function's signature).
2237 AC_MSG_CHECKING(whether libibverbs defines ibv_create_flow)
2240 #include <infiniband/verbs.h>
2243 (void) ibv_create_flow((struct ibv_qp *) NULL,
2244 (struct ibv_flow_attr *) NULL);
2247 AC_MSG_RESULT([yes])
2248 AC_DEFINE(PCAP_SUPPORT_RDMASNIFF, , [target host supports RDMA sniffing])
2249 RDMA_SRC=pcap-rdmasniff.c
2250 LIBS="-libverbs $LIBS"
2258 AC_SUBST(PCAP_SUPPORT_RDMASNIFF)
2264 AC_CONFIG_HEADER(config.h)
2266 AC_OUTPUT_COMMANDS([if test -f .devel; then
2267 echo timestamp > stamp-h
2268 cat $srcdir/Makefile-devel-adds >> Makefile
2271 AC_OUTPUT(Makefile pcap-filter.manmisc pcap-linktype.manmisc
2272 pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap
2273 pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap
2274 pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap
2275 pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap
2276 pcap_open_offline.3pcap pcap_set_tstamp_precision.3pcap
2277 pcap_set_tstamp_type.3pcap rpcapd/Makefile rpcapd/rpcapd.manadmin