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