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