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
1115 LIBS="$LIBS -ldag -ldagconf"
1116 LDFLAGS="$LDFLAGS -L$dag_lib_dir"
1118 if test "$dag_large_streams" = 1; then
1119 AC_DEFINE(HAVE_DAG_LARGE_STREAMS_API, 1, [define if you have large streams capable DAG API])
1120 AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"])
1121 if test "$ac_dag_have_vdag" = 1; then
1122 AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()])
1123 if test "$ac_lbl_have_pthreads" != "found"; then
1124 AC_MSG_ERROR([DAG requires pthreads, but we didn't find them])
1126 LIBS="$LIBS $PTHREAD_LIBS"
1130 AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
1133 if test "$V_PCAP" = dag; then
1134 # User requested "dag" capture type but we couldn't
1135 # find the DAG API support.
1136 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])
1139 if test "$want_dag" = yes; then
1140 # User wanted DAG support but we couldn't find it.
1141 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])
1147 AC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1149 if test "$withval" = no
1152 elif test "$withval" = yes
1158 septel_root=$withval
1161 if test "$V_PCAP" = septel; then
1162 # User requested Septel-only libpcap, so we'd better have
1165 elif test "xxx_only" = yes; then
1166 # User requested something-else-only pcap, so they don't
1167 # want Septel support.
1171 # Use Septel API if present, otherwise don't
1173 want_septel=ifpresent
1177 ac_cv_lbl_septel_api=no
1178 if test "$with_septel" != no; then
1180 AC_MSG_CHECKING([whether we have Septel API headers])
1182 # If necessary, set default paths for Septel API headers and libraries.
1183 if test -z "$septel_root"; then
1184 septel_root=$srcdir/../septel
1187 septel_tools_dir="$septel_root"
1188 septel_include_dir="$septel_root/INC"
1190 if test -r "$septel_include_dir/msg.h"; then
1191 ac_cv_lbl_septel_api=yes
1194 if test "$ac_cv_lbl_septel_api" = yes; then
1195 AC_MSG_RESULT([yes ($septel_include_dir)])
1197 V_INCLS="$V_INCLS -I$septel_include_dir"
1198 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"
1199 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"
1201 if test "$V_PCAP" != septel ; then
1202 SSRC="$SSRC pcap-septel.c"
1205 AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have the Septel API])
1209 if test "$V_PCAP" = septel; then
1210 # User requested "septel" capture type but
1211 # we couldn't find the Septel API support.
1212 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])
1215 if test "$want_septel" = yes; then
1216 # User wanted Septel support but we couldn't find it.
1217 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])
1222 # Check for Myricom SNF support.
1224 AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1226 if test "$withval" = no
1228 # User explicitly doesn't want SNF
1230 elif test "$withval" = yes
1232 # User wants SNF support but hasn't specified a directory.
1235 # User wants SNF support with a specified directory.
1240 if test "$V_PCAP" = snf; then
1241 # User requested Sniffer-only libpcap, so we'd better have
1244 elif test "xxx_only" = yes; then
1245 # User requested something-else-only pcap, so they don't
1250 # Use Sniffer API if present, otherwise don't
1256 AC_ARG_WITH([snf-includes],
1257 AC_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not DIR/include]),
1259 # User wants SNF with specific header directory
1261 snf_include_dir=$withval
1264 AC_ARG_WITH([snf-libraries],
1265 AC_HELP_STRING([--with-snf-libraries=LDIR],[Myricom SNF library directory, if not DIR/lib]),
1267 # User wants SNF with specific lib directory
1269 snf_lib_dir=$withval
1272 ac_cv_lbl_snf_api=no
1273 if test "$with_snf" != no; then
1275 AC_MSG_CHECKING(whether we have Myricom Sniffer API)
1277 # If necessary, set default paths for Sniffer headers and libraries.
1278 if test -z "$snf_root"; then
1282 if test -z "$snf_include_dir"; then
1283 snf_include_dir="$snf_root/include"
1286 if test -z "$snf_lib_dir"; then
1287 snf_lib_dir="$snf_root/lib"
1290 if test -f "$snf_include_dir/snf.h"; then
1291 # We found a header; make sure we can link with the library
1292 saved_ldflags=$LDFLAGS
1293 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1294 AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"])
1295 LDFLAGS="$saved_ldflags"
1296 if test "$ac_cv_lbl_snf_api" = no; then
1297 AC_MSG_ERROR(SNF API cannot correctly be linked; check config.log)
1301 if test "$ac_cv_lbl_snf_api" = yes; then
1302 AC_MSG_RESULT([yes ($snf_root)])
1304 V_INCLS="$V_INCLS -I$snf_include_dir"
1306 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1308 if test "$V_PCAP" != snf ; then
1309 SSRC="$SSRC pcap-snf.c"
1312 AC_DEFINE(HAVE_SNF_API, 1, [define if you have the Myricom SNF API])
1316 if test "$want_snf" = yes; then
1317 # User requested "snf" capture type but
1318 # we couldn't find the Sniffer API support.
1319 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])
1322 if test "$want_snf" = yes; then
1323 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])
1328 # Check for Riverbed TurboCap support.
1329 AC_ARG_WITH([turbocap],
1330 AC_HELP_STRING([--with-turbocap@<:@=DIR@:>@],[include Riverbed TurboCap support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1332 if test "$withval" = no
1334 # User explicitly doesn't want TurboCap
1336 elif test "$withval" = yes
1338 # User wants TurboCap support but hasn't specified a directory.
1341 # User wants TurboCap support with a specified directory.
1343 turbocap_root=$withval
1346 if test "xxx_only" = yes; then
1347 # User requested something-else-only pcap, so they don't
1348 # want TurboCap support.
1352 # Use TurboCap API if present, otherwise don't
1354 want_turbocap=ifpresent
1358 ac_cv_lbl_turbocap_api=no
1359 if test "$want_turbocap" != no; then
1361 AC_MSG_CHECKING(whether TurboCap is supported)
1363 save_CFLAGS="$CFLAGS"
1365 if test ! -z "$turbocap_root"; then
1366 TURBOCAP_CFLAGS="-I$turbocap_root/include"
1367 TURBOCAP_LIBS="-L$turbocap_root/lib"
1368 CFLAGS="$CFLAGS $TURBOCAP_CFLAGS"
1376 TC_INSTANCE a; TC_PORT b; TC_BOARD c;
1378 (void)TcInstanceCreateByName("foo", &i);
1380 ac_cv_lbl_turbocap_api=yes)
1382 CFLAGS="$save_CFLAGS"
1383 if test $ac_cv_lbl_turbocap_api = yes; then
1386 SSRC="$SSRC pcap-tc.c"
1387 V_INCLS="$V_INCLS $TURBOCAP_CFLAGS"
1388 LIBS="$LIBS $TURBOCAP_LIBS -lTcApi -lpthread -lstdc++"
1390 AC_DEFINE(HAVE_TC_API, 1, [define if you have the TurboCap API])
1394 if test "$want_turbocap" = yes; then
1395 # User wanted Turbo support but we couldn't find it.
1396 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])
1402 dnl Allow the user to enable remote capture.
1403 dnl It's off by default, as that increases the attack surface of
1404 dnl libpcap, exposing it to malicious servers.
1406 AC_MSG_CHECKING([whether to enable remote packet capture])
1407 AC_ARG_ENABLE(remote,
1408 [ --enable-remote enable remote packet capture @<:@default=no@:>@
1409 --disable-remote disable remote packet capture],,
1411 case "$enableval" in
1412 yes) AC_MSG_RESULT(yes)
1413 AC_WARN([Remote packet capture may expose libpcap-based applications])
1414 AC_WARN([to attacks by malicious remote capture servers!])
1416 # rpcapd requires pthreads on UN*X.
1418 if test "$ac_lbl_have_pthreads" != "found"; then
1419 AC_MSG_ERROR([rpcapd requires pthreads, but we didn't find them])
1422 # It also requires crypt().
1423 # Do we have it in the system libraries?
1425 AC_CHECK_FUNC(crypt,,
1428 # No. Do we have it in -lcrypt?
1430 AC_CHECK_LIB(crypt, crypt,
1433 # Yes; add -lcrypt to the libraries for rpcapd.
1435 RPCAPD_LIBS="$RPCAPD_LIBS -lcrypt"
1438 AC_MSG_ERROR([rpcapd requires crypt(), but we didn't find it])
1443 # OK, we have crypt(). Do we have getspnam()?
1445 AC_CHECK_FUNCS(getspnam)
1448 # Check for various members of struct msghdr.
1450 AC_CHECK_MEMBERS([struct msghdr.msg_control],,,
1452 #include "ftmacros.h"
1453 #include <sys/socket.h>
1455 AC_CHECK_MEMBERS([struct msghdr.msg_flags],,,
1457 #include "ftmacros.h"
1458 #include <sys/socket.h>
1461 AC_DEFINE(ENABLE_REMOTE,,
1462 [Define to 1 if remote packet capture is to be supported])
1463 SSRC="$SSRC pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c"
1464 BUILD_RPCAPD=build-rpcapd
1465 INSTALL_RPCAPD=install-rpcapd
1467 *) AC_MSG_RESULT(no)
1471 AC_MSG_CHECKING(whether to build optimizer debugging code)
1472 AC_ARG_ENABLE(optimizer-dbg,
1473 AC_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code]))
1474 if test "$enable_optimizer_dbg" = "yes"; then
1475 AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
1477 AC_MSG_RESULT(${enable_optimizer_dbg-no})
1479 AC_MSG_CHECKING(whether to build parser debugging code)
1480 AC_ARG_ENABLE(yydebug,
1481 AC_HELP_STRING([--enable-yydebug],[build parser debugging code]))
1482 if test "$enable_yydebug" = "yes"; then
1483 AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
1485 AC_MSG_RESULT(${enable_yydebug-no})
1491 if test "$LEX" = ":"; then
1492 AC_MSG_ERROR([Neither flex nor lex was found.])
1496 # Make sure {f}lex supports the -P, --header-file, and --nounput flags
1497 # and supports processing our scanner.l.
1499 AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
1500 if $LEX -P pcap_ --header-file=/dev/null --nounput -t $srcdir/scanner.l > /dev/null 2>&1; then
1501 tcpdump_cv_capable_lex=yes
1503 tcpdump_cv_capable_lex=insufficient
1505 if test $tcpdump_cv_capable_lex = insufficient ; then
1506 AC_MSG_ERROR([$LEX is insufficient to compile libpcap.
1507 libpcap requires Flex 2.5.31 or later, or a compatible version of lex.])
1511 # Look for yacc/bison/byacc.
1516 # Make sure it supports the -p flag and supports processing our
1519 AC_CACHE_CHECK([for capable yacc/bison], tcpdump_cv_capable_yacc,
1520 if $YACC -p pcap_ -o /dev/null $srcdir/grammar.y >/dev/null 2>&1; then
1521 tcpdump_cv_capable_yacc=yes
1523 tcpdump_cv_capable_yacc=insufficient
1525 if test $tcpdump_cv_capable_yacc = insufficient ; then
1526 AC_MSG_ERROR([$YACC is insufficient to compile libpcap.
1527 libpcap requires Bison, Berkeley YACC, or another YACC compatible with them.])
1531 # Do various checks for various OSes and versions of those OSes.
1533 # Assume, by default, no support for shared libraries and V7/BSD
1534 # convention for man pages (file formats in section 5, miscellaneous
1535 # info in section 7, administrative commands and daemons in section 8).
1536 # Individual cases can override this.
1541 MAN_ADMIN_COMMANDS=8
1545 dnl Workaround to enable certain features
1546 AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
1549 # AIX makes it fun to build shared and static libraries,
1550 # because they're *both* ".a" archive libraries. We
1551 # build the static library for the benefit of the traditional
1552 # scheme of building libpcap and tcpdump in subdirectories of
1553 # the same directory, with tcpdump statically linked with the
1554 # libpcap in question, but we also build a shared library as
1555 # "libpcap.shareda" and install *it*, rather than the static
1556 # library, as "libpcap.a".
1564 # If we're using DLPI, applications will need to
1565 # use /lib/pse.exp if present, as we use the
1568 pseexe="/lib/pse.exp"
1569 AC_MSG_CHECKING(for $pseexe)
1570 if test -f $pseexe ; then
1578 # If we're using BPF, we need "-lodm" and "-lcfg", as
1579 # we use them to load the BPF module.
1588 V_CCOPT="$V_CCOPT -fno-common"
1589 AC_ARG_ENABLE(universal,
1590 AC_HELP_STRING([--disable-universal],[don't build universal on macOS]))
1591 if test "$enable_universal" != "no"; then
1596 # Pre-Tiger. Build only for 32-bit PowerPC; no
1597 # need for any special compiler or linker flags.
1603 # Tiger, prior to Intel support. Build for 32-bit
1604 # PowerPC and 64-bit PowerPC, with 32-bit PowerPC
1605 # first. (I'm guessing that's what Apple does.)
1607 V_CCOPT="$V_CCOPT -arch ppc -arch ppc64"
1608 LDFLAGS="$LDFLAGS -arch ppc -arch ppc64"
1613 # Tiger, subsequent to Intel support but prior to
1614 # x86-64 support. Build for 32-bit PowerPC, 64-bit
1615 # PowerPC, and x86, with 32-bit PowerPC first.
1616 # (I'm guessing that's what Apple does.)
1618 V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386"
1619 LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386"
1624 # All other Tiger, so subsequent to x86-64
1625 # support. Build for 32-bit PowerPC, 64-bit
1626 # PowerPC, x86, and x86-64, and with 32-bit PowerPC
1627 # first. (I'm guessing that's what Apple does.)
1629 V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1630 LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1635 # Leopard. Build for 32-bit PowerPC, 64-bit
1636 # PowerPC, x86, and x86-64, with 32-bit PowerPC
1637 # first. (That's what Apple does.)
1639 V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1640 LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386 -arch x86_64"
1645 # Snow Leopard. Build for x86-64, x86, and
1646 # 32-bit PowerPC, with x86-64 first. (That's
1647 # what Apple does, even though Snow Leopard
1648 # doesn't run on PPC, so PPC libpcap runs under
1649 # Rosetta, and Rosetta doesn't support BPF
1650 # ioctls, so PPC programs can't do live
1653 V_CCOPT="$V_CCOPT -arch x86_64 -arch i386 -arch ppc"
1654 LDFLAGS="$LDFLAGS -arch x86_64 -arch i386 -arch ppc"
1659 # Post-Snow Leopard. Build for x86-64 and
1660 # x86, with x86-64 first. (That's probably what
1661 # Apple does, given that Rosetta is gone.)
1662 # XXX - update if and when Apple drops support
1663 # for 32-bit x86 code.
1665 V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
1666 LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
1673 AC_DEFINE(HAVE_HPUX9,1,[on HP-UX 9.x])
1676 # Use System V conventions for man pages.
1678 MAN_ADMIN_COMMANDS=1m
1686 # Use System V conventions for man pages.
1688 MAN_ADMIN_COMMANDS=1m
1696 # Use System V conventions for man pages.
1698 MAN_ADMIN_COMMANDS=1m
1704 dnl HPUX 10.20 and above is similar to HPUX 9, but
1705 dnl not the same....
1707 dnl XXX - DYEXT should be set to "sl" if this is building
1708 dnl for 32-bit PA-RISC, but should be left as "so" for
1709 dnl 64-bit PA-RISC or, I suspect, IA-64.
1710 AC_DEFINE(HAVE_HPUX10_20_OR_LATER,1,[on HP-UX 10.20 or later])
1711 if test "`uname -m`" = "ia64"; then
1718 # "-b" builds a shared library; "+h" sets the soname.
1724 # Use System V conventions for man pages.
1732 # Use IRIX conventions for man pages; they're the same as the
1733 # System V conventions, except that they use section 8 for
1734 # administrative commands and daemons.
1740 linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*)
1744 # Compiler assumed to be GCC; run-time linker may require a -R
1747 if test "$libdir" != "/usr/lib"; then
1748 V_RFLAGS=-Wl,-R$libdir
1756 # DEC OSF/1, a/k/a Digial UNIX, a/k/a Tru64 UNIX.
1757 # Use Tru64 UNIX conventions for man pages; they're the same as
1758 # the System V conventions except that they use section 8 for
1759 # administrative commands and daemons.
1766 AC_MSG_CHECKING(if SINIX compiler defines sinix)
1767 AC_CACHE_VAL(ac_cv_cc_sinix_defined,
1771 ac_cv_cc_sinix_defined=yes,
1772 ac_cv_cc_sinix_defined=no))
1773 AC_MSG_RESULT($ac_cv_cc_sinix_defined)
1774 if test $ac_cv_cc_sinix_defined = no ; then
1775 AC_DEFINE(sinix,1,[on sinix])
1780 AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
1785 # Make sure errno is thread-safe, in case we're called in
1786 # a multithreaded program. We don't guarantee that two
1787 # threads can use the *same* pcap_t safely, but the
1788 # current version does guarantee that you can use different
1789 # pcap_t's in different threads, and even that pcap_compile()
1790 # is thread-safe (it wasn't thread-safe in some older versions).
1792 V_CCOPT="$V_CCOPT -D_TS_ERRNO"
1794 case "`uname -r`" in
1801 # Use System V conventions for man pages.
1803 MAN_ADMIN_COMMANDS=1m
1810 AC_ARG_ENABLE(shared,
1811 AC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@]))
1812 test "x$enable_shared" = "xno" && DYEXT="none"
1815 AC_CHECK_TOOL([AR], [ar])
1820 AC_LBL_DEVEL(V_CCOPT)
1823 # Check to see if the sockaddr struct has the 4.4 BSD sa_len member.
1825 AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,
1827 #include <sys/types.h>
1828 #include <sys/socket.h>
1832 # Check to see if there's a sockaddr_storage structure.
1834 AC_CHECK_TYPES(struct sockaddr_storage,,,
1836 #include <sys/types.h>
1837 #include <sys/socket.h>
1841 # Check to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
1842 # dl_module_id_1 member.
1844 # NOTE: any failure means we conclude that it doesn't have that member,
1845 # so if we don't have DLPI, don't have a <sys/dlpi_ext.h> header, or
1846 # have one that doesn't declare a dl_hp_ppa_info_t type, we conclude
1847 # it doesn't have that member (which is OK, as either we won't be
1848 # using code that would use that member, or we wouldn't compile in
1851 AC_CHECK_MEMBERS([dl_hp_ppa_info_t.dl_module_id_1],,,
1853 #include <sys/types.h>
1854 #include <sys/dlpi.h>
1855 #include <sys/dlpi_ext.h>
1858 AC_LBL_UNALIGNED_ACCESS
1862 AC_SUBST(V_FINDALLDEVS)
1866 AC_SUBST(V_SHLIB_CCOPT)
1867 AC_SUBST(V_SHLIB_CMD)
1868 AC_SUBST(V_SHLIB_OPT)
1869 AC_SUBST(V_SONAME_OPT)
1870 AC_SUBST(V_RPATH_OPT)
1873 AC_SUBST(ADDLARCHIVEOBJS)
1876 AC_SUBST(MAN_FILE_FORMATS)
1877 AC_SUBST(MAN_MISC_INFO)
1878 AC_SUBST(MAN_ADMIN_COMMANDS)
1879 AC_SUBST(PTHREAD_LIBS)
1880 AC_SUBST(BUILD_RPCAPD)
1881 AC_SUBST(INSTALL_RPCAPD)
1882 AC_SUBST(RPCAPD_LIBS)
1883 AC_SUBST(EXTRA_NETWORK_LIBS)
1885 AC_ARG_ENABLE([usb],
1886 [AC_HELP_STRING([--enable-usb],[enable USB capture support @<:@default=yes, if support available@:>@])],
1890 if test "xxx_only" = yes; then
1891 # User requested something-else-only pcap, so they don't
1896 if test "x$enable_usb" != "xno" ; then
1897 dnl check for USB sniffing support
1898 AC_MSG_CHECKING(for USB sniffing support)
1901 AC_DEFINE(PCAP_SUPPORT_USB, 1, [target host supports USB sniffing])
1902 USB_SRC=pcap-usb-linux.c
1904 ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null`
1905 if test $? -ne 0 ; then
1906 ac_usb_dev_name="usbmon"
1908 AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing])
1909 AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name)
1911 # Do we have a version of <linux/compiler.h> available?
1912 # If so, we might need it for <linux/usbdevice_fs.h>.
1914 AC_CHECK_HEADERS(linux/compiler.h)
1915 if test "$ac_cv_header_linux_compiler_h" = yes; then
1917 # Yes - include it when testing for <linux/usbdevice_fs.h>.
1919 AC_CHECK_HEADERS(linux/usbdevice_fs.h,,,[#include <linux/compiler.h>])
1921 AC_CHECK_HEADERS(linux/usbdevice_fs.h)
1923 if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then
1925 # OK, does it define bRequestType? Older versions of the kernel
1926 # define fields with names like "requesttype, "request", and
1927 # "value", rather than "bRequestType", "bRequest", and
1930 AC_CHECK_MEMBERS([struct usbdevfs_ctrltransfer.bRequestType],,,
1933 #ifdef HAVE_LINUX_COMPILER_H
1934 #include <linux/compiler.h>
1936 #include <linux/usbdevice_fs.h>
1942 # This just uses BPF in FreeBSD 8.4 and later; we don't need
1943 # to check for anything special for capturing.
1945 AC_MSG_RESULT([yes, in FreeBSD 8.4 and later])
1953 AC_SUBST(PCAP_SUPPORT_USB)
1956 dnl check for netfilter sniffing support
1957 if test "xxx_only" != yes; then
1958 AC_MSG_CHECKING(whether the platform could support netfilter sniffing)
1963 # Life's too short to deal with trying to get this to compile
1964 # if you don't get the right types defined with
1965 # __KERNEL_STRICT_NAMES getting defined by some other include.
1967 # Check whether the includes Just Work. If not, don't turn on
1968 # netfilter support.
1970 AC_MSG_CHECKING(whether we can compile the netfilter support)
1971 AC_CACHE_VAL(ac_cv_netfilter_can_compile,
1974 #include <sys/socket.h>
1975 #include <netinet/in.h>
1976 #include <linux/types.h>
1978 #include <linux/netlink.h>
1979 #include <linux/netfilter.h>
1980 #include <linux/netfilter/nfnetlink.h>
1981 #include <linux/netfilter/nfnetlink_log.h>
1982 #include <linux/netfilter/nfnetlink_queue.h>],
1984 ac_cv_netfilter_can_compile=yes,
1985 ac_cv_netfilter_can_compile=no))
1986 AC_MSG_RESULT($ac_cv_netfilter_can_compile)
1987 if test $ac_cv_netfilter_can_compile = yes ; then
1988 AC_DEFINE(PCAP_SUPPORT_NETFILTER, 1,
1989 [target host supports netfilter sniffing])
1990 NETFILTER_SRC=pcap-netfilter-linux.c
1998 AC_SUBST(PCAP_SUPPORT_NETFILTER)
1999 AC_SUBST(NETFILTER_SRC)
2001 AC_ARG_ENABLE([netmap],
2002 [AC_HELP_STRING([--enable-netmap],[enable netmap support @<:@default=yes, if support available@:>@])],
2004 [enable_netmap=yes])
2006 if test "x$enable_netmap" != "xno" ; then
2008 # Check whether net/netmap_user.h is usable if NETMAP_WITH_LIBS is
2009 # defined; it's not usable on DragonFly BSD 4.6 if NETMAP_WITH_LIBS
2010 # is defined, for example, as it includes a non-existent malloc.h
2013 AC_MSG_CHECKING(whether we can compile the netmap support)
2014 AC_CACHE_VAL(ac_cv_net_netmap_user_can_compile,
2017 #define NETMAP_WITH_LIBS
2018 #include <net/netmap_user.h>],
2020 ac_cv_net_netmap_user_can_compile=yes,
2021 ac_cv_net_netmap_user_can_compile=no))
2022 AC_MSG_RESULT($ac_cv_net_netmap_user_can_compile)
2023 if test $ac_cv_net_netmap_user_can_compile = yes ; then
2024 AC_DEFINE(PCAP_SUPPORT_NETMAP, 1,
2025 [target host supports netmap])
2026 NETMAP_SRC=pcap-netmap.c
2028 AC_SUBST(PCAP_SUPPORT_NETMAP)
2029 AC_SUBST(NETMAP_SRC)
2033 AC_ARG_ENABLE([bluetooth],
2034 [AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
2036 [enable_bluetooth=ifsupportavailable])
2038 if test "xxx_only" = yes; then
2039 # User requested something-else-only pcap, so they don't
2040 # want Bluetooth support.
2044 if test "x$enable_bluetooth" != "xno" ; then
2045 dnl check for Bluetooth sniffing support
2048 AC_CHECK_HEADER(bluetooth/bluetooth.h,
2051 # We have bluetooth.h, so we support Bluetooth
2054 AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
2055 BT_SRC=pcap-bt-linux.c
2056 AC_MSG_NOTICE(Bluetooth sniffing is supported)
2057 ac_lbl_bluetooth_available=yes
2060 # OK, does struct sockaddr_hci have an hci_channel
2063 AC_CHECK_MEMBERS([struct sockaddr_hci.hci_channel],
2066 # Yes; is HCI_CHANNEL_MONITOR defined?
2068 AC_MSG_CHECKING(if HCI_CHANNEL_MONITOR is defined)
2069 AC_CACHE_VAL(ac_cv_lbl_hci_channel_monitor_is_defined,
2072 #include <bluetooth/bluetooth.h>
2073 #include <bluetooth/hci.h>
2076 u_int i = HCI_CHANNEL_MONITOR;
2080 AC_DEFINE(PCAP_SUPPORT_BT_MONITOR,,
2081 [target host supports Bluetooth Monitor])
2082 BT_MONITOR_SRC=pcap-bt-monitor-linux.c
2089 #include <bluetooth/bluetooth.h>
2090 #include <bluetooth/hci.h>
2095 # We don't have bluetooth.h, so we don't support
2096 # Bluetooth sniffing.
2098 if test "x$enable_bluetooth" = "xyes" ; then
2099 AC_MSG_ERROR(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2101 AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2106 if test "x$enable_bluetooth" = "xyes" ; then
2107 AC_MSG_ERROR(no Bluetooth sniffing support implemented for $host_os)
2109 AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os)
2113 AC_SUBST(PCAP_SUPPORT_BT)
2115 AC_SUBST(BT_MONITOR_SRC)
2118 AC_ARG_ENABLE([dbus],
2119 [AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
2121 [enable_dbus=ifavailable])
2123 if test "xxx_only" = yes; then
2124 # User requested something-else-only pcap, so they don't
2125 # want D-Bus support.
2129 if test "x$enable_dbus" != "xno"; then
2130 if test "x$enable_dbus" = "xyes"; then
2135 # We don't support D-Bus sniffing on macOS; see
2137 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
2139 # The user requested it, so fail.
2141 AC_MSG_ERROR([Due to freedesktop.org bug 74029, D-Bus capture support is not available on macOS])
2148 # We don't support D-Bus sniffing on macOS; see
2150 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
2152 # The user dind't explicitly request it, so just
2153 # silently refuse to enable it.
2161 if test "x$enable_dbus" != "xno"; then
2162 AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no])
2163 if test "x$PKGCONFIG" != "xno"; then
2164 AC_MSG_CHECKING([for D-Bus])
2165 if "$PKGCONFIG" dbus-1; then
2166 AC_MSG_RESULT([yes])
2167 DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
2168 DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
2169 save_CFLAGS="$CFLAGS"
2171 CFLAGS="$CFLAGS $DBUS_CFLAGS"
2172 LIBS="$LIBS $DBUS_LIBS"
2173 AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
2175 [#include <string.h>
2178 #include <sys/time.h>
2180 #include <dbus/dbus.h>],
2181 [return dbus_connection_read_write(NULL, 0);],
2183 AC_MSG_RESULT([yes])
2184 AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
2185 DBUS_SRC=pcap-dbus.c
2186 V_INCLS="$V_INCLS $DBUS_CFLAGS"
2190 if test "x$enable_dbus" = "xyes"; then
2191 AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
2195 CFLAGS="$save_CFLAGS"
2198 if test "x$enable_dbus" = "xyes"; then
2199 AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed])
2203 AC_SUBST(PCAP_SUPPORT_DBUS)
2207 AC_ARG_ENABLE([rdma],
2208 [AC_HELP_STRING([--enable-rdma],[enable RDMA capture support @<:@default=yes, if support available@:>@])],
2210 [enable_rdmasniff=ifavailable])
2212 if test "xxx_only" = yes; then
2213 # User requested something-else-only pcap, so they don't
2214 # want RDMA support.
2218 if test "x$enable_rdmasniff" != "xno"; then
2219 AC_CHECK_LIB(ibverbs, ibv_get_device_list, [
2220 AC_CHECK_HEADER(infiniband/verbs.h, [
2222 # ibv_create_flow may be defined as a static inline
2223 # function in infiniband/verbs.h, so we can't
2226 # Too bad autoconf has no AC_SYMBOL_EXISTS()
2227 # macro that works like CMake's check_symbol_exists()
2228 # function, to check do a compile check like
2229 # this (they do a clever trick to avoid having
2230 # to know the function's signature).
2232 AC_MSG_CHECKING(whether libibverbs defines ibv_create_flow)
2235 #include <infiniband/verbs.h>
2238 (void) ibv_create_flow((struct ibv_qp *) NULL,
2239 (struct ibv_flow_attr *) NULL);
2242 AC_MSG_RESULT([yes])
2243 AC_DEFINE(PCAP_SUPPORT_RDMASNIFF, , [target host supports RDMA sniffing])
2244 RDMA_SRC=pcap-rdmasniff.c
2245 LIBS="-libverbs $LIBS"
2253 AC_SUBST(PCAP_SUPPORT_RDMASNIFF)
2259 AC_CONFIG_HEADER(config.h)
2261 AC_OUTPUT_COMMANDS([if test -f .devel; then
2262 echo timestamp > stamp-h
2263 cat $srcdir/Makefile-devel-adds >> Makefile
2266 AC_OUTPUT(Makefile pcap-filter.manmisc pcap-linktype.manmisc
2267 pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap
2268 pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap
2269 pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap
2270 pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap
2271 pcap_open_offline.3pcap pcap_set_tstamp_precision.3pcap
2272 pcap_set_tstamp_type.3pcap rpcapd/Makefile rpcapd/rpcapd.manadmin