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