]> The Tcpdump Group git mirrors - libpcap/blob - configure.ac
Make sure no read routine process more than INT_MAX packets.
[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 # https://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 # We require C99 or later.
28 # Try to get it, which may involve adding compiler flags;
29 # if that fails, give up.
30 #
31 AC_PROG_CC_C99
32 if test "$ac_cv_prog_cc_c99" = "no"; then
33 AC_MSG_ERROR([The C compiler does not support C99])
34 fi
35 case "$host_os" in
36 haiku*)
37 #
38 # Haiku's platform file is in C++.
39 #
40 AC_PROG_CXX
41 ;;
42 esac
43
44 AC_LBL_C_INIT(V_CCOPT, V_INCLS)
45 AC_LBL_SHLIBS_INIT
46 AC_LBL_C_INLINE
47 AC_PCAP_C___ATOMICS
48
49 #
50 # Try to arrange for large file support.
51 #
52 AC_SYS_LARGEFILE
53 AC_FUNC_FSEEKO
54
55 dnl
56 dnl Even if <net/bpf.h> were, on all OSes that support BPF, fixed to
57 dnl include <sys/ioccom.h>, and we were to drop support for older
58 dnl releases without that fix, so that pcap-bpf.c doesn't need to
59 dnl include <sys/ioccom.h>, the test program in "AC_LBL_FIXINCLUDES"
60 dnl in "aclocal.m4" uses it, so we would still have to test for it
61 dnl and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
62 dnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris.
63 dnl
64 AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h)
65 AC_CHECK_HEADERS(netpacket/packet.h)
66 AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
67 #include <sys/socket.h>
68 #include <net/if.h>])
69 if test "$ac_cv_header_net_pfvar_h" = yes; then
70 #
71 # Check for various PF actions.
72 #
73 AC_MSG_CHECKING(whether net/pfvar.h defines PF_NAT through PF_NORDR)
74 AC_TRY_COMPILE(
75 [#include <sys/types.h>
76 #include <sys/socket.h>
77 #include <net/if.h>
78 #include <net/pfvar.h>],
79 [return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR;],
80 [
81 AC_MSG_RESULT(yes)
82 AC_DEFINE(HAVE_PF_NAT_THROUGH_PF_NORDR, 1,
83 [define if net/pfvar.h defines PF_NAT through PF_NORDR])
84 ],
85 AC_MSG_RESULT(no))
86 fi
87
88 case "$host_os" in
89 haiku*)
90 #
91 # Haiku needs _BSD_SOURCE for the _IO* macros because it doesn't use them.
92 #
93 CFLAGS="$CFLAGS -D_BSD_SOURCE"
94 ;;
95 esac
96
97 AC_LBL_FIXINCLUDES
98
99 AC_CHECK_FUNCS(strerror)
100 AC_CHECK_FUNC(strerror_r,
101 [
102 #
103 # We have strerror_r; if we define _GNU_SOURCE, is it a
104 # POSIX-compliant strerror_r() or a GNU strerror_r()?
105 #
106 AC_MSG_CHECKING(whether strerror_r is GNU-style)
107 AC_COMPILE_IFELSE(
108 [
109 AC_LANG_SOURCE(
110 #define _GNU_SOURCE
111 #include <string.h>
112
113 /* Define it GNU-style; that will cause an error if it's not GNU-style */
114 extern char *strerror_r(int, char *, size_t);
115
116 int
117 main(void)
118 {
119 return 0;
120 }
121 )
122 ],
123 [
124 # GNU-style
125 AC_MSG_RESULT(yes)
126 AC_DEFINE(HAVE_GNU_STRERROR_R,,
127 [Define to 1 if you have a GNU-style `strerror_r' function.])
128 ],
129 [
130 AC_MSG_RESULT(no)
131 AC_DEFINE(HAVE_POSIX_STRERROR_R,,
132 [Define to 1 if you have a POSIX-style `strerror_r' function.])
133 ])
134 ],
135 [
136 #
137 # We don't have strerror_r; do we have _wcserror_s?
138 #
139 AC_CHECK_FUNCS(_wcserror_s)
140 ])
141
142 #
143 # Thanks, IBM, for not providing vsyslog() in AIX!
144 #
145 AC_CHECK_FUNCS(vsyslog)
146
147 #
148 # Make sure we have vsnprintf() and snprintf(); we require them.
149 #
150 AC_CHECK_FUNC(vsnprintf,,
151 AC_MSG_ERROR([vsnprintf() is required but wasn't found]))
152 AC_CHECK_FUNC(snprintf,,
153 AC_MSG_ERROR([snprintf() is required but wasn't found]))
154
155 needasprintf=no
156 AC_CHECK_FUNCS(vasprintf asprintf,,
157 [needasprintf=yes])
158 if test $needasprintf = yes; then
159 AC_LIBOBJ([asprintf])
160 fi
161
162 needstrlcat=no
163 AC_CHECK_FUNCS(strlcat,,
164 [needstrlcat=yes])
165 if test $needstrlcat = yes; then
166 AC_LIBOBJ([strlcat])
167 fi
168
169 needstrlcpy=no
170 AC_CHECK_FUNCS(strlcpy,,
171 [needstrlcpy=yes])
172 if test $needstrlcpy = yes; then
173 AC_LIBOBJ([strlcpy])
174 fi
175
176 needstrtok_r=no
177 AC_CHECK_FUNCS(strtok_r,,
178 [needstrtok_r=yes])
179 if test $needstrtok_r = yes; then
180 AC_LIBOBJ([strtok_r])
181 fi
182
183 #
184 # Do we have ffs(), and is it declared in <strings.h>?
185 #
186 AC_CHECK_FUNCS(ffs)
187 if test "$ac_cv_func_ffs" = yes; then
188 #
189 # We have ffs(); is it declared in <strings.h>?
190 #
191 # This test fails if we don't have <strings.h> or if we do
192 # but it doesn't declare ffs().
193 #
194 AC_CHECK_DECL(ffs,
195 [
196 AC_DEFINE(STRINGS_H_DECLARES_FFS,,
197 [Define to 1 if strings.h declares `ffs'])
198 ],,
199 [
200 #include <strings.h>
201 ])
202 fi
203
204 #
205 # Do this before checking for ether_hostton(), as it's a
206 # "getaddrinfo()-ish function".
207 #
208 AC_LBL_LIBRARY_NET
209
210 #
211 # Check for reentrant versions of getnetbyname_r(), as provided by
212 # Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!).
213 # If we don't find one, we just use getnetbyname(), which uses
214 # thread-specific data on many platforms, but doesn't use it on
215 # NetBSD or OpenBSD, and may not use it on older versions of other
216 # platforms.
217 #
218 # Only do the check if we have a declaration of getnetbyname_r();
219 # without it, we can't check which API it has. (We assume that
220 # if there's a declaration, it has a prototype, so that the API
221 # can be checked.)
222 #
223 AC_CHECK_DECL(getnetbyname_r,
224 [
225 AC_MSG_CHECKING([for the Linux getnetbyname_r()])
226 AC_TRY_LINK(
227 [#include <netdb.h>],
228 [
229 struct netent netent_buf;
230 char buf[1024];
231 struct netent *resultp;
232 int h_errnoval;
233
234 return getnetbyname_r((const char *)0, &netent_buf, buf, sizeof buf, &resultp, &h_errnoval);
235 ],
236 [
237 AC_MSG_RESULT(yes)
238 AC_DEFINE(HAVE_LINUX_GETNETBYNAME_R, 1,
239 [define if we have the Linux getnetbyname_r()])
240 ],
241 [
242 AC_MSG_RESULT(no)
243
244 AC_MSG_CHECKING([for Solaris/IRIX getnetbyname_r()])
245 AC_TRY_LINK(
246 [#include <netdb.h>],
247 [
248 struct netent netent_buf;
249 char buf[1024];
250
251 return getnetbyname_r((const char *)0, &netent_buf, buf, (int)sizeof buf) != NULL;
252 ],
253 [
254 AC_MSG_RESULT(yes)
255 AC_DEFINE(HAVE_SOLARIS_IRIX_GETNETBYNAME_R, 1,
256 [define if we have the Solaris/IRIX getnetbyname_r()])
257 ],
258 [
259 AC_MSG_RESULT(no)
260
261 AC_MSG_CHECKING([for AIX getnetbyname_r()])
262 AC_TRY_LINK(
263 [#include <netdb.h>],
264 [
265 struct netent netent_buf;
266 struct netent_data net_data;
267
268 return getnetbyname_r((const char *)0, &netent_buf, &net_data);
269 ],
270 [
271 AC_MSG_RESULT(yes)
272 AC_DEFINE(HAVE_AIX_GETNETBYNAME_R, 1,
273 [define if we have the AIX getnetbyname_r()])
274 ],
275 [
276 AC_MSG_RESULT(no)
277 ])
278 ])
279 ])
280 ],,[#include <netdb.h>])
281
282 #
283 # Check for reentrant versions of getprotobyname_r(), as provided by
284 # Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!).
285 # If we don't find one, we just use getprotobyname(), which uses
286 # thread-specific data on many platforms, but doesn't use it on
287 # NetBSD or OpenBSD, and may not use it on older versions of other
288 # platforms.
289 #
290 # Only do the check if we have a declaration of getprotobyname_r();
291 # without it, we can't check which API it has. (We assume that
292 # if there's a declaration, it has a prototype, so that the API
293 # can be checked.)
294 #
295 AC_CHECK_DECL(getprotobyname_r,
296 [
297 AC_MSG_CHECKING([for the Linux getprotobyname_r()])
298 AC_TRY_LINK(
299 [#include <netdb.h>],
300 [
301 struct protoent protoent_buf;
302 char buf[1024];
303 struct protoent *resultp;
304
305 return getprotobyname_r((const char *)0, &protoent_buf, buf, sizeof buf, &resultp);
306 ],
307 [
308 AC_MSG_RESULT(yes)
309 AC_DEFINE(HAVE_LINUX_GETPROTOBYNAME_R, 1,
310 [define if we have the Linux getprotobyname_r()])
311 ],
312 [
313 AC_MSG_RESULT(no)
314
315 AC_MSG_CHECKING([for Solaris/IRIX getprotobyname_r()])
316 AC_TRY_LINK(
317 [#include <netdb.h>],
318 [
319 struct protoent protoent_buf;
320 char buf[1024];
321
322 return getprotobyname_r((const char *)0, &protoent_buf, buf, (int)sizeof buf) != NULL;
323 ],
324 [
325 AC_MSG_RESULT(yes)
326 AC_DEFINE(HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R, 1,
327 [define if we have the Solaris/IRIX getprotobyname_r()])
328 ],
329 [
330 AC_MSG_RESULT(no)
331
332 AC_MSG_CHECKING([for AIX getprotobyname_r()])
333 AC_TRY_LINK(
334 [#include <netdb.h>],
335 [
336 struct protoent protoent_buf;
337 struct protoent_data proto_data;
338
339 return getprotobyname_r((const char *)0, &protoent_buf, &proto_data);
340 ],
341 [
342 AC_MSG_RESULT(yes)
343 AC_DEFINE(HAVE_AIX_GETPROTOBYNAME_R, 1,
344 [define if we have the AIX getprotobyname_r()])
345 ],
346 [
347 AC_MSG_RESULT(no)
348 ])
349 ])
350 ])
351 ],,[#include <netdb.h>])
352
353 #
354 # You are in a twisty little maze of UN*Xes, all different.
355 # Some might not have ether_hostton().
356 # Some might have it and declare it in <net/ethernet.h>.
357 # Some might have it and declare it in <netinet/ether.h>
358 # Some might have it and declare it in <sys/ethernet.h>.
359 # Some might have it and declare it in <arpa/inet.h>.
360 # Some might have it and declare it in <netinet/if_ether.h>.
361 # Some might have it and not declare it in any header file.
362 #
363 # Before you is a C compiler.
364 #
365 AC_CHECK_FUNCS(ether_hostton)
366 if test "$ac_cv_func_ether_hostton" = yes; then
367 #
368 # OK, we have ether_hostton(). Is it declared in <net/ethernet.h>?
369 #
370 # This test fails if we don't have <net/ethernet.h> or if we do
371 # but it doesn't declare ether_hostton().
372 #
373 AC_CHECK_DECL(ether_hostton,
374 [
375 AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_HOSTTON,,
376 [Define to 1 if net/ethernet.h declares `ether_hostton'])
377 ],,
378 [
379 #include <net/ethernet.h>
380 ])
381 #
382 # Did that succeed?
383 #
384 if test "$ac_cv_have_decl_ether_hostton" != yes; then
385 #
386 # No, how about <netinet/ether.h>, as on Linux?
387 #
388 # This test fails if we don't have <netinet/ether.h>
389 # or if we do but it doesn't declare ether_hostton().
390 #
391 # Unset ac_cv_have_decl_ether_hostton so we don't
392 # treat the previous failure as a cached value and
393 # suppress the next test.
394 #
395 unset ac_cv_have_decl_ether_hostton
396 AC_CHECK_DECL(ether_hostton,
397 [
398 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON,,
399 [Define to 1 if netinet/ether.h declares `ether_hostton'])
400 ],,
401 [
402 #include <netinet/ether.h>
403 ])
404 fi
405 #
406 # Did that succeed?
407 #
408 if test "$ac_cv_have_decl_ether_hostton" != yes; then
409 #
410 # No, how about <sys/ethernet.h>, as on Solaris 10
411 # and later?
412 #
413 # This test fails if we don't have <sys/ethernet.h>
414 # or if we do but it doesn't declare ether_hostton().
415 #
416 # Unset ac_cv_have_decl_ether_hostton so we don't
417 # treat the previous failure as a cached value and
418 # suppress the next test.
419 #
420 unset ac_cv_have_decl_ether_hostton
421 AC_CHECK_DECL(ether_hostton,
422 [
423 AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON,,
424 [Define to 1 if sys/ethernet.h declares `ether_hostton'])
425 ],,
426 [
427 #include <sys/ethernet.h>
428 ])
429 fi
430 #
431 # Did that succeed?
432 #
433 if test "$ac_cv_have_decl_ether_hostton" != yes; then
434 #
435 # No, how about <arpa/inet.h>, as in AIX?
436 #
437 # This test fails if we don't have <arpa/inet.h>
438 # (if we have ether_hostton(), we should have
439 # networking, and if we have networking, we should
440 # have <arapa/inet.h>) or if we do but it doesn't
441 # declare ether_hostton().
442 #
443 # Unset ac_cv_have_decl_ether_hostton so we don't
444 # treat the previous failure as a cached value and
445 # suppress the next test.
446 #
447 unset ac_cv_have_decl_ether_hostton
448 AC_CHECK_DECL(ether_hostton,
449 [
450 AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_HOSTTON,,
451 [Define to 1 if arpa/inet.h declares `ether_hostton'])
452 ],,
453 [
454 #include <arpa/inet.h>
455 ])
456 fi
457 #
458 # Did that succeed?
459 #
460 if test "$ac_cv_have_decl_ether_hostton" != yes; then
461 #
462 # No, how about <netinet/if_ether.h>?
463 # On some platforms, it requires <net/if.h> and
464 # <netinet/in.h>, and we always include it with
465 # both of them, so test it with both of them.
466 #
467 # This test fails if we don't have <netinet/if_ether.h>
468 # and the headers we include before it, or if we do but
469 # <netinet/if_ether.h> doesn't declare ether_hostton().
470 #
471 # Unset ac_cv_have_decl_ether_hostton so we don't
472 # treat the previous failure as a cached value and
473 # suppress the next test.
474 #
475 unset ac_cv_have_decl_ether_hostton
476 AC_CHECK_DECL(ether_hostton,
477 [
478 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON,,
479 [Define to 1 if netinet/if_ether.h declares `ether_hostton'])
480 ],,
481 [
482 #include <sys/types.h>
483 #include <sys/socket.h>
484 #include <net/if.h>
485 #include <netinet/in.h>
486 #include <netinet/if_ether.h>
487 ])
488 fi
489 #
490 # After all that, is ether_hostton() declared?
491 #
492 if test "$ac_cv_have_decl_ether_hostton" = yes; then
493 #
494 # Yes.
495 #
496 AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1,
497 [Define to 1 if you have the declaration of `ether_hostton'])
498 else
499 #
500 # No, we'll have to declare it ourselves.
501 # Do we have "struct ether_addr" if we include
502 # <netinet/if_ether.h>?
503 #
504 AC_CHECK_TYPES(struct ether_addr,,,
505 [
506 #include <sys/types.h>
507 #include <sys/socket.h>
508 #include <net/if.h>
509 #include <netinet/in.h>
510 #include <netinet/if_ether.h>
511 ])
512 fi
513 fi
514
515 #
516 # For various things that might use pthreads.
517 #
518 AC_CHECK_HEADER(pthread.h,
519 [
520 #
521 # OK, we have pthread.h. Do we have pthread_create in the
522 # system libraries?
523 #
524 AC_CHECK_FUNC(pthread_create,
525 [
526 #
527 # Yes.
528 #
529 ac_lbl_have_pthreads="found"
530 ],
531 [
532 #
533 # No - do we have it in -lpthreads?
534 #
535 AC_CHECK_LIB(pthreads, pthread_create,
536 [
537 #
538 # Yes - add -lpthreads.
539 #
540 ac_lbl_have_pthreads="found"
541 PTHREAD_LIBS="$PTHREAD_LIBS -lpthreads"
542 ],
543 [
544 #
545 # No - do we have it in -lpthread?
546 #
547 AC_CHECK_LIB(pthread, pthread_create,
548 [
549 #
550 # Yes - add -lpthread.
551 #
552 ac_lbl_have_pthreads="found"
553 PTHREAD_LIBS="$PTHREAD_LIBS -lpthread"
554 ],
555 [
556 #
557 # No.
558 #
559 ac_lbl_have_pthreads="not found"
560 ])
561 ])
562 ])
563 ],
564 [
565 #
566 # We didn't find pthread.h.
567 #
568 ac_lbl_have_pthreads="not found"
569 ]
570 )
571
572 dnl to pacify those who hate protochain insn
573 AC_MSG_CHECKING(if --disable-protochain option is specified)
574 AC_ARG_ENABLE(protochain,
575 AS_HELP_STRING([--disable-protochain],[disable \"protochain\" insn]))
576 case "x$enable_protochain" in
577 xyes) enable_protochain=enabled ;;
578 xno) enable_protochain=disabled ;;
579 x) enable_protochain=enabled ;;
580 esac
581
582 if test "$enable_protochain" = "disabled"; then
583 AC_DEFINE(NO_PROTOCHAIN,1,[do not use protochain])
584 fi
585 AC_MSG_RESULT(${enable_protochain})
586
587 #
588 # valgrindtest directly uses the native capture mechanism, but
589 # only tests with BPF and PF_PACKET sockets; only enable it if
590 # we have BPF or PF_PACKET sockets.
591 #
592 VALGRINDTEST_SRC=
593
594 AC_ARG_WITH(pcap,
595 AS_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE]))
596 if test ! -z "$with_pcap" ; then
597 V_PCAP="$withval"
598 else
599 #
600 # Check for a bunch of headers for various packet
601 # capture mechanisms.
602 #
603 AC_CHECK_HEADERS(net/bpf.h)
604 if test "$ac_cv_header_net_bpf_h" = yes; then
605 #
606 # Does it define BIOCSETIF?
607 # I.e., is it a header for an LBL/BSD-style capture
608 # mechanism, or is it just a header for a BPF filter
609 # engine? Some versions of Arch Linux, for example,
610 # have a net/bpf.h that doesn't define BIOCSETIF;
611 # as it's a Linux, it should use packet sockets,
612 # instead.
613 #
614 # We need:
615 #
616 # sys/types.h, because FreeBSD 10's net/bpf.h
617 # requires that various BSD-style integer types
618 # be defined;
619 #
620 # sys/time.h, because AIX 5.2 and 5.3's net/bpf.h
621 # doesn't include it but does use struct timeval
622 # in ioctl definitions;
623 #
624 # sys/ioctl.h and, if we have it, sys/ioccom.h,
625 # because net/bpf.h defines ioctls;
626 #
627 # net/if.h, because it defines some structures
628 # used in ioctls defined by net/bpf.h;
629 #
630 # sys/socket.h, because OpenBSD 5.9's net/bpf.h
631 # defines some structure fields as being
632 # struct sockaddrs;
633 #
634 # and net/bpf.h doesn't necessarily include all
635 # of those headers itself.
636 #
637 AC_MSG_CHECKING(if net/bpf.h defines BIOCSETIF)
638 AC_CACHE_VAL(ac_cv_lbl_bpf_h_defines_biocsetif,
639 AC_TRY_COMPILE(
640 [
641 #include <sys/types.h>
642 #include <sys/time.h>
643 #include <sys/ioctl.h>
644 #include <sys/socket.h>
645 #ifdef HAVE_SYS_IOCCOM_H
646 #include <sys/ioccom.h>
647 #endif
648 #include <net/bpf.h>
649 #include <net/if.h>
650 ],
651 [u_int i = BIOCSETIF;],
652 ac_cv_lbl_bpf_h_defines_biocsetif=yes,
653 ac_cv_lbl_bpf_h_defines_biocsetif=no))
654 AC_MSG_RESULT($ac_cv_lbl_bpf_h_defines_biocsetif)
655 fi
656 AC_CHECK_HEADERS(net/pfilt.h net/enet.h)
657 AC_CHECK_HEADERS(net/nit.h sys/net/nit.h)
658 AC_CHECK_HEADERS(linux/socket.h net/raw.h sys/dlpi.h)
659 AC_CHECK_HEADERS(config/HaikuConfig.h)
660
661 if test "$ac_cv_lbl_bpf_h_defines_biocsetif" = yes; then
662 #
663 # BPF.
664 # Check this before DLPI, so that we pick BPF on
665 # Solaris 11 and later.
666 #
667 V_PCAP=bpf
668
669 #
670 # We have BPF, so build valgrindtest with "make test"
671 # on macOS and FreeBSD (add your OS once there's a
672 # valgrind for it).
673 #
674 case "$host_os" in
675
676 freebsd*|darwin*|linux*)
677 VALGRINDTEST_SRC=valgrindtest.c
678 ;;
679 esac
680 elif test "$ac_cv_header_linux_socket_h" = yes; then
681 #
682 # No prizes for guessing this one.
683 #
684 V_PCAP=linux
685 VALGRINDTEST_SRC=valgrindtest.c
686 elif test "$ac_cv_header_net_pfilt_h" = yes; then
687 #
688 # DEC OSF/1, Digital UNIX, Tru64 UNIX
689 #
690 V_PCAP=pf
691 elif test "$ac_cv_header_net_enet_h" = yes; then
692 #
693 # Stanford Enetfilter.
694 #
695 V_PCAP=enet
696 elif test "$ac_cv_header_net_nit_h" = yes; then
697 #
698 # SunOS 4.x STREAMS NIT.
699 #
700 V_PCAP=snit
701 elif test "$ac_cv_header_sys_net_nit_h" = yes; then
702 #
703 # Pre-SunOS 4.x non-STREAMS NIT.
704 #
705 V_PCAP=nit
706 elif test "$ac_cv_header_net_raw_h" = yes; then
707 #
708 # IRIX snoop.
709 #
710 V_PCAP=snoop
711 elif test "$ac_cv_header_sys_dlpi_h" = yes; then
712 #
713 # DLPI on pre-Solaris 11 SunOS 5, HP-UX, possibly others.
714 #
715 V_PCAP=dlpi
716 elif test "$ac_cv_header_config_HaikuConfig_h" = yes; then
717 #
718 # Haiku.
719 #
720 V_PCAP=haiku
721 else
722 #
723 # Nothing we support.
724 #
725 V_PCAP=null
726 AC_MSG_WARN(cannot determine packet capture interface)
727 AC_MSG_WARN((see the INSTALL doc for more info))
728 fi
729 fi
730 AC_MSG_CHECKING(packet capture type)
731 AC_MSG_RESULT($V_PCAP)
732 AC_SUBST(VALGRINDTEST_SRC)
733
734 #
735 # Do we have pkg-config?
736 #
737 AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no])
738
739 #
740 # Handle each capture type.
741 #
742 case "$V_PCAP" in
743 dlpi)
744 #
745 # Checks for some header files.
746 #
747 AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
748
749 #
750 # Checks to see if Solaris has the public libdlpi(3LIB) library.
751 # Note: The existence of /usr/include/libdlpi.h does not mean it is the
752 # public libdlpi(3LIB) version. Before libdlpi was made public, a
753 # private version also existed, which did not have the same APIs.
754 # Due to a gcc bug, the default search path for 32-bit libraries does
755 # not include /lib, we add it explicitly here.
756 # [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485].
757 # Also, due to the bug above applications that link to libpcap with
758 # libdlpi will have to add "-L/lib" option to "configure".
759 #
760 save_LDFLAGS="$LDFLAGS"
761 LDFLAGS="$LIBS -L/lib"
762 AC_CHECK_LIB(dlpi, dlpi_walk,
763 [
764 LIBS="-ldlpi $LIBS"
765 V_PCAP=libdlpi
766
767 #
768 # Capture module plus common code needed for
769 # common functions used by pcap-[dlpi,libdlpi].c
770 #
771 PLATFORM_C_SRC="pcap-libdlpi.c dlpisubs.c"
772 AC_DEFINE(HAVE_LIBDLPI,1,[if libdlpi exists])
773 ],
774 [
775 V_PCAP=dlpi
776
777 #
778 # Capture module plus common code needed for
779 # common functions used by pcap-[dlpi,libdlpi].c
780 #
781 PLATFORM_C_SRC="pcap-dlpi.c dlpisubs.c"
782 ])
783 LDFLAGS="$save_LDFLAGS"
784
785 #
786 # Checks whether <sys/dlpi.h> is usable, to catch weird SCO
787 # versions of DLPI.
788 #
789 AC_MSG_CHECKING(whether <sys/dlpi.h> is usable)
790 AC_CACHE_VAL(ac_cv_sys_dlpi_usable,
791 AC_TRY_COMPILE(
792 [
793 #include <sys/types.h>
794 #include <sys/time.h>
795 #include <sys/dlpi.h>
796 ],
797 [int i = DL_PROMISC_PHYS;],
798 ac_cv_sys_dlpi_usable=yes,
799 ac_cv_sys_dlpi_usable=no))
800 AC_MSG_RESULT($ac_cv_sys_dlpi_usable)
801 if test $ac_cv_sys_dlpi_usable = no ; then
802 AC_MSG_ERROR(<sys/dlpi.h> is not usable on this system; it probably has a non-standard DLPI)
803 fi
804
805 #
806 # Check to see if Solaris has the dl_passive_req_t struct defined
807 # in <sys/dlpi.h>.
808 # This check is for DLPI support for passive modes.
809 # See dlpi(7P) for more details.
810 #
811 AC_CHECK_TYPES(dl_passive_req_t,,,
812 [
813 #include <sys/types.h>
814 #include <sys/dlpi.h>
815 ])
816 ;;
817
818 enet)
819 #
820 # Capture module
821 #
822 PLATFORM_C_SRC="pcap-enet.c"
823 ;;
824
825 haiku)
826 #
827 # Capture module
828 #
829 PLATFORM_CXX_SRC="pcap-haiku.cpp"
830
831 #
832 # Just for the sake of it.
833 #
834 AC_CHECK_HEADERS(net/if.h net/if_dl.h net/if_types.h)
835 ;;
836
837 linux)
838 #
839 # Capture module
840 #
841 PLATFORM_C_SRC="pcap-linux.c"
842
843 #
844 # Do we have the wireless extensions?
845 #
846 AC_CHECK_HEADERS(linux/wireless.h, [], [],
847 [
848 #include <sys/socket.h>
849 #include <linux/if.h>
850 #include <linux/types.h>
851 ])
852
853 #
854 # Do we have libnl?
855 # We only want version 3. Version 2 was, apparently,
856 # short-lived, and version 1 is source and binary
857 # incompatible with version 3, and it appears that,
858 # these days, everybody's using version 3. We're
859 # not supporting older versions of the Linux kernel;
860 # let's drop support for older versions of libnl, too.
861 #
862 AC_ARG_WITH(libnl,
863 AS_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]),
864 with_libnl=$withval,with_libnl=if_available)
865
866 if test x$with_libnl != xno ; then
867 if test "x$PKGCONFIG" != "xno"; then
868 #
869 # We have pkg-config; see if we have libnl-genl-3.0
870 # as a package.
871 #
872 AC_MSG_CHECKING([for libnl-genl-3.0 with pkg-config])
873 if "$PKGCONFIG" libnl-genl-3.0; then
874 AC_MSG_RESULT([found])
875 pkg_config_found_libnl=yes
876 libnl_genl_cflags=`"$PKGCONFIG" --cflags libnl-genl-3.0`
877 V_INCLS="$V_INCLS ${libnl_genl_cflags}"
878 libnl_genl_libs=`"$PKGCONFIG" --libs libnl-genl-3.0`
879 LIBS="${libnl_genl_libs} $LIBS"
880 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
881 else
882 AC_MSG_RESULT([not found])
883 fi
884 fi
885
886 if test x$pkg_config_found_libnl != xyes; then
887 #
888 # OK, either we don't have pkg-config or there
889 # wasn't a .pc file for it; Check for it directly.
890 #
891 case "$with_libnl" in
892
893 yes|if_available)
894 incdir=-I/usr/include/libnl3
895 libnldir=
896 ;;
897
898 *)
899 if test -d $withval; then
900 libnldir=-L${withval}/lib
901 incdir=-I${withval}/include
902 fi
903 ;;
904 esac
905
906 AC_CHECK_LIB(nl-3, nl_socket_alloc,
907 [
908 #
909 # Yes, we have libnl 3.x.
910 #
911 LIBS="${libnldir} -lnl-genl-3 -lnl-3 $LIBS"
912 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
913 V_INCLS="$V_INCLS ${incdir}"
914 ],[
915 #
916 # No, we don't have libnl at all.
917 # Fail if the user explicitly requested
918 # it.
919 #
920 if test x$with_libnl = xyes ; then
921 AC_MSG_ERROR([libnl support requested but libnl not found])
922 fi
923 ], ${incdir} ${libnldir} -lnl-genl-3 -lnl-3 )
924 fi
925 fi
926
927 #
928 # Check to see if the tpacket_auxdata struct has a tp_vlan_tci member.
929 #
930 # NOTE: any failure means we conclude that it doesn't have that
931 # member, so if we don't have tpacket_auxdata, we conclude it
932 # doesn't have that member (which is OK, as either we won't be
933 # using code that would use that member, or we wouldn't compile
934 # in any case).
935 AC_CHECK_MEMBERS([struct tpacket_auxdata.tp_vlan_tci],,,
936 [
937 #include <sys/types.h>
938 #include <linux/if_packet.h>
939 ])
940 ;;
941
942 bpf)
943 #
944 # Capture module
945 #
946 PLATFORM_C_SRC="pcap-bpf.c"
947
948 #
949 # Check whether we have the *BSD-style ioctls.
950 #
951 AC_CHECK_HEADERS(net/if_media.h)
952
953 #
954 # Check whether we have struct BPF_TIMEVAL.
955 #
956 AC_CHECK_TYPES(struct BPF_TIMEVAL,,,
957 [
958 #include <sys/types.h>
959 #include <sys/ioctl.h>
960 #ifdef HAVE_SYS_IOCCOM_H
961 #include <sys/ioccom.h>
962 #endif
963 #include <net/bpf.h>
964 ])
965 ;;
966
967 pf)
968 #
969 # Capture module
970 #
971 PLATFORM_C_SRC="pcap-pf.c"
972 ;;
973
974 snit)
975 #
976 # Capture module
977 #
978 PLATFORM_C_SRC="pcap-snit.c"
979 ;;
980
981 snoop)
982 #
983 # Capture module
984 #
985 PLATFORM_C_SRC="pcap-snoop.c"
986 ;;
987
988 dag)
989 #
990 # --with-pcap=dag is the only way to get here, and it means
991 # "DAG support but nothing else"
992 #
993 V_DEFS="$V_DEFS -DDAG_ONLY"
994 PLATFORM_C_SRC="pcap-dag.c"
995 xxx_only=yes
996 ;;
997
998 dpdk)
999 #
1000 # --with-pcap=dpdk is the only way to get here, and it means
1001 # "DPDK support but nothing else"
1002 #
1003 V_DEFS="$V_DEFS -DDPDK_ONLY"
1004 PLATFORM_C_SRC="pcap-dpdk.c"
1005 xxx_only=yes
1006 ;;
1007
1008 septel)
1009 #
1010 # --with-pcap=septel is the only way to get here, and it means
1011 # "Septel support but nothing else"
1012 #
1013 V_DEFS="$V_DEFS -DSEPTEL_ONLY"
1014 PLATFORM_C_SRC="pcap-septel.c"
1015 xxx_only=yes
1016 ;;
1017
1018 snf)
1019 #
1020 # --with-pcap=snf is the only way to get here, and it means
1021 # "SNF support but nothing else"
1022 #
1023 V_DEFS="$V_DEFS -DSNF_ONLY"
1024 PLATFORM_C_SRC="pcap-snf.c"
1025 xxx_only=yes
1026 ;;
1027
1028 null)
1029 #
1030 # Capture module
1031 #
1032 PLATFORM_C_SRC="pcap-null.c"
1033 ;;
1034
1035 *)
1036 AC_MSG_ERROR($V_PCAP is not a valid pcap type)
1037 ;;
1038 esac
1039
1040 dnl
1041 dnl Now figure out how we get a list of interfaces and addresses,
1042 dnl if we support capturing. Don't bother if we don't support
1043 dnl capturing.
1044 dnl
1045 if test "$V_PCAP" != null
1046 then
1047 AC_CHECK_FUNC(getifaddrs,[
1048 #
1049 # We have "getifaddrs()"; make sure we have <ifaddrs.h>
1050 # as well, just in case some platform is really weird.
1051 #
1052 AC_CHECK_HEADER(ifaddrs.h,[
1053 #
1054 # We have the header, so we use "getifaddrs()" to
1055 # get the list of interfaces.
1056 #
1057 PLATFORM_C_SRC="$PLATFORM_C_SRC fad-getad.c"
1058 ],[
1059 #
1060 # We don't have the header - give up.
1061 # XXX - we could also fall back on some other
1062 # mechanism, but, for now, this'll catch this
1063 # problem so that we can at least try to figure
1064 # out something to do on systems with "getifaddrs()"
1065 # but without "ifaddrs.h", if there is something
1066 # we can do on those systems.
1067 #
1068 AC_MSG_ERROR([Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>.])
1069 ])
1070 ],[
1071 #
1072 # Well, we don't have "getifaddrs()", at least not with the
1073 # libraries with which we've decided we need to link
1074 # libpcap with, so we have to use some other mechanism.
1075 #
1076 # Note that this may happen on Solaris, which has
1077 # getifaddrs(), but in -lsocket, not in -lxnet, so we
1078 # won't find it if we link with -lxnet, which we want
1079 # to do for other reasons.
1080 #
1081 # For now, we use either the SIOCGIFCONF ioctl or the
1082 # SIOCGLIFCONF ioctl, preferring the latter if we have
1083 # it; the latter is a Solarisism that first appeared
1084 # in Solaris 8. (Solaris's getifaddrs() appears to
1085 # be built atop SIOCGLIFCONF; using it directly
1086 # avoids a not-all-that-useful middleman.)
1087 #
1088 AC_MSG_CHECKING(whether we have SIOCGLIFCONF)
1089 AC_CACHE_VAL(ac_cv_lbl_have_siocglifconf,
1090 AC_TRY_COMPILE(
1091 [#include <sys/param.h>
1092 #include <sys/file.h>
1093 #include <sys/ioctl.h>
1094 #include <sys/socket.h>
1095 #include <sys/sockio.h>],
1096 [ioctl(0, SIOCGLIFCONF, (char *)0);],
1097 ac_cv_lbl_have_siocglifconf=yes,
1098 ac_cv_lbl_have_siocglifconf=no))
1099 AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
1100 if test $ac_cv_lbl_have_siocglifconf = yes ; then
1101 PLATFORM_C_SRC="$PLATFORM_C_SRC fad-glifc.c"
1102 else
1103 PLATFORM_C_SRC="$PLATFORM_C_SRC fad-gifc.c"
1104 fi
1105 ])
1106 fi
1107
1108 dnl check for hardware timestamp support
1109 case "$host_os" in
1110 linux*)
1111 AC_CHECK_HEADERS([linux/net_tstamp.h])
1112 ;;
1113 *)
1114 AC_MSG_NOTICE(no hardware timestamp support implemented for $host_os)
1115 ;;
1116 esac
1117
1118 #
1119 # Check for socklen_t.
1120 #
1121 AC_CHECK_TYPES(socklen_t,,,
1122 [
1123 #include <sys/types.h>
1124 #include <sys/socket.h>
1125 ])
1126
1127 AC_ARG_ENABLE(ipv6,
1128 AS_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes@:>@]),
1129 [],
1130 [enable_ipv6=yes])
1131 if test "$enable_ipv6" != "no"; then
1132 #
1133 # We've already made sure we have getaddrinfo above in
1134 # AC_LBL_LIBRARY_NET.
1135 #
1136 AC_DEFINE(INET6,1,[IPv6])
1137 fi
1138
1139 # Check for Endace DAG card support.
1140 AC_ARG_WITH([dag],
1141 AS_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1142 [
1143 if test "$withval" = no
1144 then
1145 # User doesn't want DAG support.
1146 want_dag=no
1147 elif test "$withval" = yes
1148 then
1149 # User wants DAG support but hasn't specified a directory.
1150 want_dag=yes
1151 else
1152 # User wants DAG support and has specified a directory, so use the provided value.
1153 want_dag=yes
1154 dag_root=$withval
1155 fi
1156 ],[
1157 if test "$V_PCAP" = dag; then
1158 # User requested DAG-only libpcap, so we'd better have
1159 # the DAG API.
1160 want_dag=yes
1161 elif test "xxx_only" = yes; then
1162 # User requested something-else-only pcap, so they don't
1163 # want DAG support.
1164 want_dag=no
1165 else
1166 #
1167 # Use DAG API if present, otherwise don't
1168 #
1169 want_dag=ifpresent
1170 fi
1171 ])
1172
1173 AC_ARG_WITH([dag-includes],
1174 AS_HELP_STRING([--with-dag-includes=IDIR],[Endace DAG include directory, if not DIR/include]),
1175 [
1176 # User wants DAG support and has specified a header directory, so use the provided value.
1177 want_dag=yes
1178 dag_include_dir=$withval
1179 ],[])
1180
1181 AC_ARG_WITH([dag-libraries],
1182 AS_HELP_STRING([--with-dag-libraries=LDIR],[Endace DAG library directory, if not DIR/lib]),
1183 [
1184 # User wants DAG support and has specified a library directory, so use the provided value.
1185 want_dag=yes
1186 dag_lib_dir=$withval
1187 ],[])
1188
1189 if test "$want_dag" != no; then
1190
1191 # If necessary, set default paths for DAG API headers and libraries.
1192 if test -z "$dag_root"; then
1193 dag_root=/usr/local
1194 fi
1195
1196 if test -z "$dag_include_dir"; then
1197 dag_include_dir="$dag_root/include"
1198 fi
1199
1200 if test -z "$dag_lib_dir"; then
1201 dag_lib_dir="$dag_root/lib"
1202 #
1203 # Handle multiarch systems.
1204 #
1205 if test -d "$dag_lib_dir/$host"
1206 then
1207 dag_lib_dir="$dag_lib_dir/$host"
1208 fi
1209 fi
1210
1211 save_CFLAGS="$CFLAGS"
1212 CFLAGS="$CFLAGS -I$dag_include_dir"
1213 AC_CHECK_HEADERS([dagapi.h])
1214
1215 if test "$ac_cv_header_dagapi_h" = yes; then
1216
1217 V_INCLS="$V_INCLS -I$dag_include_dir"
1218
1219 if test $V_PCAP != dag ; then
1220 MODULE_C_SRC="$MODULE_C_SRC pcap-dag.c"
1221 fi
1222
1223 # Check for various DAG API functions.
1224 # Don't need to save and restore LIBS to prevent -ldag being
1225 # included if there's a found-action (arg 3).
1226 save_LDFLAGS="$LDFLAGS"
1227 LDFLAGS="-L$dag_lib_dir"
1228 AC_CHECK_LIB([dag], [dag_attach_stream],
1229 [],
1230 [AC_MSG_ERROR(DAG library lacks streams support)])
1231 AC_CHECK_LIB([dag], [dag_attach_stream64], [dag_large_streams="1"], [dag_large_streams="0"])
1232 AC_CHECK_LIB([dag],[dag_get_erf_types], [
1233 AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])])
1234 AC_CHECK_LIB([dag],[dag_get_stream_erf_types], [
1235 AC_DEFINE(HAVE_DAG_GET_STREAM_ERF_TYPES, 1, [define if you have dag_get_stream_erf_types()])])
1236
1237 LDFLAGS="$save_LDFLAGS"
1238
1239 #
1240 # We assume that if we have libdag we have libdagconf,
1241 # as they're installed at the same time from the same
1242 # package.
1243 #
1244 LIBS="$LIBS -ldag -ldagconf"
1245 LDFLAGS="$LDFLAGS -L$dag_lib_dir"
1246
1247 if test "$dag_large_streams" = 1; then
1248 AC_DEFINE(HAVE_DAG_LARGE_STREAMS_API, 1, [define if you have large streams capable DAG API])
1249 AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"])
1250 if test "$ac_dag_have_vdag" = 1; then
1251 AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()])
1252 if test "$ac_lbl_have_pthreads" != "found"; then
1253 AC_MSG_ERROR([DAG requires pthreads, but we didn't find them])
1254 fi
1255 LIBS="$LIBS $PTHREAD_LIBS"
1256 fi
1257 fi
1258
1259 AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
1260 else
1261
1262 if test "$V_PCAP" = dag; then
1263 # User requested "dag" capture type but we couldn't
1264 # find the DAG API support.
1265 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])
1266 fi
1267
1268 if test "$want_dag" = yes; then
1269 # User wanted DAG support but we couldn't find it.
1270 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])
1271 fi
1272 fi
1273 CFLAGS="$save_CFLAGS"
1274 fi
1275
1276 AC_ARG_WITH(septel,
1277 AS_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1278 [
1279 if test "$withval" = no
1280 then
1281 want_septel=no
1282 elif test "$withval" = yes
1283 then
1284 want_septel=yes
1285 septel_root=
1286 else
1287 want_septel=yes
1288 septel_root=$withval
1289 fi
1290 ],[
1291 if test "$V_PCAP" = septel; then
1292 # User requested Septel-only libpcap, so we'd better have
1293 # the Septel API.
1294 want_septel=yes
1295 elif test "xxx_only" = yes; then
1296 # User requested something-else-only pcap, so they don't
1297 # want Septel support.
1298 want_septel=no
1299 else
1300 #
1301 # Use Septel API if present, otherwise don't
1302 #
1303 want_septel=ifpresent
1304 fi
1305 ])
1306
1307 ac_cv_lbl_septel_api=no
1308 if test "$with_septel" != no; then
1309
1310 AC_MSG_CHECKING([whether we have Septel API headers])
1311
1312 # If necessary, set default paths for Septel API headers and libraries.
1313 if test -z "$septel_root"; then
1314 septel_root=$srcdir/../septel
1315 fi
1316
1317 septel_tools_dir="$septel_root"
1318 septel_include_dir="$septel_root/INC"
1319
1320 if test -r "$septel_include_dir/msg.h"; then
1321 ac_cv_lbl_septel_api=yes
1322 fi
1323
1324 if test "$ac_cv_lbl_septel_api" = yes; then
1325 AC_MSG_RESULT([yes ($septel_include_dir)])
1326
1327 V_INCLS="$V_INCLS -I$septel_include_dir"
1328 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"
1329 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"
1330
1331 if test "$V_PCAP" != septel ; then
1332 MODULE_C_SRC="$MODULE_C_SRC pcap-septel.c"
1333 fi
1334
1335 AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have the Septel API])
1336 else
1337 AC_MSG_RESULT(no)
1338
1339 if test "$V_PCAP" = septel; then
1340 # User requested "septel" capture type but
1341 # we couldn't find the Septel API support.
1342 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])
1343 fi
1344
1345 if test "$want_septel" = yes; then
1346 # User wanted Septel support but we couldn't find it.
1347 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])
1348 fi
1349 fi
1350 fi
1351
1352 # Check for Myricom SNF support.
1353 AC_ARG_WITH([snf],
1354 AS_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1355 [
1356 if test "$withval" = no
1357 then
1358 # User explicitly doesn't want SNF
1359 want_snf=no
1360 elif test "$withval" = yes
1361 then
1362 # User wants SNF support but hasn't specified a directory.
1363 want_snf=yes
1364 else
1365 # User wants SNF support with a specified directory.
1366 want_snf=yes
1367 snf_root=$withval
1368 fi
1369 ],[
1370 if test "$V_PCAP" = snf; then
1371 # User requested Sniffer-only libpcap, so we'd better have
1372 # the Sniffer API.
1373 want_snf=yes
1374 elif test "xxx_only" = yes; then
1375 # User requested something-else-only pcap, so they don't
1376 # want SNF support.
1377 want_snf=no
1378 else
1379 #
1380 # Use Sniffer API if present, otherwise don't
1381 #
1382 want_snf=ifpresent
1383 fi
1384 ])
1385
1386 AC_ARG_WITH([snf-includes],
1387 AS_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not DIR/include]),
1388 [
1389 # User wants SNF with specific header directory
1390 want_snf=yes
1391 snf_include_dir=$withval
1392 ],[])
1393
1394 AC_ARG_WITH([snf-libraries],
1395 AS_HELP_STRING([--with-snf-libraries=LDIR],[Myricom SNF library directory, if not DIR/lib]),
1396 [
1397 # User wants SNF with specific lib directory
1398 want_snf=yes
1399 snf_lib_dir=$withval
1400 ],[])
1401
1402 ac_cv_lbl_snf_api=no
1403 if test "$with_snf" != no; then
1404
1405 AC_MSG_CHECKING(whether we have Myricom Sniffer API)
1406
1407 # If necessary, set default paths for Sniffer headers and libraries.
1408 if test -z "$snf_root"; then
1409 snf_root=/opt/snf
1410 fi
1411
1412 if test -z "$snf_include_dir"; then
1413 snf_include_dir="$snf_root/include"
1414 fi
1415
1416 if test -z "$snf_lib_dir"; then
1417 snf_lib_dir="$snf_root/lib"
1418 #
1419 # Handle multiarch systems.
1420 #
1421 if test -d "$snf_lib_dir/$host"
1422 then
1423 snf_lib_dir="$snf_lib_dir/$host"
1424 fi
1425 fi
1426
1427 if test -f "$snf_include_dir/snf.h"; then
1428 # We found a header; make sure we can link with the library
1429 save_LDFLAGS="$LDFLAGS"
1430 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1431 AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"])
1432 LDFLAGS="$save_LDFLAGS"
1433 if test "$ac_cv_lbl_snf_api" = no; then
1434 AC_MSG_ERROR(SNF API cannot correctly be linked; check config.log)
1435 fi
1436 fi
1437
1438 if test "$ac_cv_lbl_snf_api" = yes; then
1439 AC_MSG_RESULT([yes ($snf_root)])
1440
1441 V_INCLS="$V_INCLS -I$snf_include_dir"
1442 LIBS="$LIBS -lsnf"
1443 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1444
1445 if test "$V_PCAP" != snf ; then
1446 MODULE_C_SRC="$MODULE_C_SRC pcap-snf.c"
1447 fi
1448
1449 AC_DEFINE(HAVE_SNF_API, 1, [define if you have the Myricom SNF API])
1450 else
1451 AC_MSG_RESULT(no)
1452
1453 if test "$want_snf" = yes; then
1454 # User requested "snf" capture type but
1455 # we couldn't find the Sniffer API support.
1456 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])
1457 fi
1458
1459 if test "$want_snf" = yes; then
1460 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])
1461 fi
1462 fi
1463 fi
1464
1465 # Check for Riverbed TurboCap support.
1466 AC_ARG_WITH([turbocap],
1467 AS_HELP_STRING([--with-turbocap@<:@=DIR@:>@],[include Riverbed TurboCap support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1468 [
1469 if test "$withval" = no
1470 then
1471 # User explicitly doesn't want TurboCap
1472 want_turbocap=no
1473 elif test "$withval" = yes
1474 then
1475 # User wants TurboCap support but hasn't specified a directory.
1476 want_turbocap=yes
1477 else
1478 # User wants TurboCap support with a specified directory.
1479 want_turbocap=yes
1480 turbocap_root=$withval
1481 fi
1482 ],[
1483 if test "xxx_only" = yes; then
1484 # User requested something-else-only pcap, so they don't
1485 # want TurboCap support.
1486 want_turbocap=no
1487 else
1488 #
1489 # Use TurboCap API if present, otherwise don't
1490 #
1491 want_turbocap=ifpresent
1492 fi
1493 ])
1494
1495 ac_cv_lbl_turbocap_api=no
1496 if test "$want_turbocap" != no; then
1497
1498 AC_MSG_CHECKING(whether TurboCap is supported)
1499
1500 save_CFLAGS="$CFLAGS"
1501 save_LIBS="$LIBS"
1502 if test ! -z "$turbocap_root"; then
1503 TURBOCAP_CFLAGS="-I$turbocap_root/include"
1504 TURBOCAP_LIBS="-L$turbocap_root/lib"
1505 CFLAGS="$CFLAGS $TURBOCAP_CFLAGS"
1506 fi
1507
1508 AC_TRY_COMPILE(
1509 [
1510 #include <TcApi.h>
1511 ],
1512 [
1513 TC_INSTANCE a; TC_PORT b; TC_BOARD c;
1514 TC_INSTANCE i;
1515 (void)TcInstanceCreateByName("foo", &i);
1516 ],
1517 ac_cv_lbl_turbocap_api=yes)
1518
1519 CFLAGS="$save_CFLAGS"
1520 if test $ac_cv_lbl_turbocap_api = yes; then
1521 AC_MSG_RESULT(yes)
1522
1523 MODULE_C_SRC="$MODULE_C_SRC pcap-tc.c"
1524 V_INCLS="$V_INCLS $TURBOCAP_CFLAGS"
1525 LIBS="$LIBS $TURBOCAP_LIBS -lTcApi -lpthread -lstdc++"
1526
1527 AC_DEFINE(HAVE_TC_API, 1, [define if you have the TurboCap API])
1528 else
1529 AC_MSG_RESULT(no)
1530
1531 if test "$want_turbocap" = yes; then
1532 # User wanted Turbo support but we couldn't find it.
1533 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])
1534 fi
1535 fi
1536 fi
1537
1538 dnl
1539 dnl Allow the user to enable remote capture.
1540 dnl It's off by default, as that increases the attack surface of
1541 dnl libpcap, exposing it to malicious servers.
1542 dnl
1543 AC_MSG_CHECKING([whether to enable remote packet capture])
1544 AC_ARG_ENABLE(remote,
1545 [ --enable-remote enable remote packet capture @<:@default=no@:>@
1546 --disable-remote disable remote packet capture],,
1547 enableval=no)
1548 case "$enableval" in
1549 yes) AC_MSG_RESULT(yes)
1550 AC_WARN([Remote packet capture may expose libpcap-based applications])
1551 AC_WARN([to attacks by malicious remote capture servers!])
1552 #
1553 # rpcapd requires pthreads on UN*X.
1554 #
1555 if test "$ac_lbl_have_pthreads" != "found"; then
1556 AC_MSG_ERROR([rpcapd requires pthreads, but we didn't find them])
1557 fi
1558 #
1559 # It also requires crypt().
1560 # Do we have it in the system libraries?
1561 #
1562 AC_CHECK_FUNC(crypt,,
1563 [
1564 #
1565 # No. Do we have it in -lcrypt?
1566 #
1567 AC_CHECK_LIB(crypt, crypt,
1568 [
1569 #
1570 # Yes; add -lcrypt to the libraries for rpcapd.
1571 #
1572 RPCAPD_LIBS="$RPCAPD_LIBS -lcrypt"
1573 ],
1574 [
1575 AC_MSG_ERROR([rpcapd requires crypt(), but we didn't find it])
1576 ])
1577 ])
1578
1579 #
1580 # OK, we have crypt(). Do we have getspnam()?
1581 #
1582 AC_CHECK_FUNCS(getspnam)
1583
1584 #
1585 # Check for various members of struct msghdr.
1586 #
1587 AC_CHECK_MEMBERS([struct msghdr.msg_control],,,
1588 [
1589 #include "ftmacros.h"
1590 #include <sys/socket.h>
1591 ])
1592 AC_CHECK_MEMBERS([struct msghdr.msg_flags],,,
1593 [
1594 #include "ftmacros.h"
1595 #include <sys/socket.h>
1596 ])
1597
1598 #
1599 # Optionally, we may want to support SSL.
1600 # Check for OpenSSL/libressl.
1601 #
1602 # First, try looking for it as a regular system library.
1603 # Make sure we can find SSL_library_init() using the
1604 # standard headers, just in case we're running a version
1605 # of macOS that ships with the OpenSSL library but not
1606 # the OpenSSL headers, and have also installed another
1607 # version of OpenSSL with headers.
1608 #
1609 save_LIBS="$LIBS"
1610 LIBS="-lssl -lcrypto"
1611 AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
1612 AC_TRY_LINK(
1613 [
1614 #include <openssl/ssl.h>
1615 ],
1616 [
1617 SSL_library_init();
1618 return 0;
1619 ],
1620 [
1621 AC_MSG_RESULT(yes)
1622 HAVE_OPENSSL=yes
1623 OPENSSL_LIBS="-lssl -lcrypto"
1624 ],
1625 AC_MSG_RESULT(no))
1626 LIBS="$save_LIBS"
1627
1628 #
1629 # If we didn't find it, check for it with pkg-config.
1630 #
1631 if test "x$HAVE_OPENSSL" != "xyes"; then
1632 if test "x$PKGCONFIG" != "xno"; then
1633 #
1634 # We have pkg-config; see if we have OpenSSL/
1635 # libressl installed as a package.
1636 #
1637 AC_MSG_CHECKING([for OpenSSL/libressl with pkg-config])
1638 if "$PKGCONFIG" openssl; then
1639 AC_MSG_RESULT([found])
1640 HAVE_OPENSSL=yes
1641 OPENSSL_CFLAGS=`"$PKGCONFIG" --cflags openssl`
1642 OPENSSL_LIBS=`"$PKGCONFIG" --libs openssl`
1643 else
1644 AC_MSG_RESULT([not found])
1645 fi
1646 fi
1647 fi
1648
1649 #
1650 # If we didn't find it, check for it under /usr/local/opt/openssl;
1651 # that's where Homebrew puts it on macOS. Feel free to add other
1652 # -L directories as necessary; the "system library" check should
1653 # also handle "add-on library under /usr/local", so that shouldn't
1654 # be necessary here.
1655 #
1656 if test "x$HAVE_OPENSSL" != "xyes"; then
1657 save_CFLAGS="$CFLAGS"
1658 save_LIBS="$LIBS"
1659 CFLAGS="$CFLAGS -L/usr/local/opt/openssl/include"
1660 LIBS="$LIBS -L/usr/local/opt/openssl/lib -lssl -lcrypto"
1661 AC_MSG_CHECKING(whether we have OpenSSL/libressl in /usr/local/opt that we can use)
1662 AC_TRY_LINK(
1663 [
1664 #include <openssl/ssl.h>
1665 ],
1666 [
1667 SSL_library_init();
1668 return 0;
1669 ],
1670 [
1671 AC_MSG_RESULT(yes)
1672 HAVE_OPENSSL=yes
1673 OPENSSL_CFLAGS="-I/usr/local/opt/openssl/include"
1674 OPENSSL_LIBS="-L/usr/local/opt/openssl/lib -lssl -lcrypto"
1675 ],
1676 AC_MSG_RESULT(no))
1677 CFLAGS="$save_CFLAGS"
1678 LIBS="$save_LIBS"
1679 fi
1680
1681 #
1682 # OK, did we find it?
1683 #
1684 if test "x$HAVE_OPENSSL" = "xyes"; then
1685 AC_DEFINE([HAVE_OPENSSL], [1], [Use OpenSSL])
1686 CFLAGS="$CFLAGS $OPENSSL_CFLAGS"
1687 LIBS="$LIBS $OPENSSL_LIBS"
1688 else
1689 AC_MSG_NOTICE(OpenSSL not found)
1690 fi
1691
1692 AC_DEFINE(ENABLE_REMOTE,,
1693 [Define to 1 if remote packet capture is to be supported])
1694 REMOTE_C_SRC="$REMOTE_C_SRC pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c sslutils.c"
1695 BUILD_RPCAPD=build-rpcapd
1696 INSTALL_RPCAPD=install-rpcapd
1697 ;;
1698 *) AC_MSG_RESULT(no)
1699 ;;
1700 esac
1701
1702 AC_MSG_CHECKING(whether to build optimizer debugging code)
1703 AC_ARG_ENABLE(optimizer-dbg,
1704 AS_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code]))
1705 if test "$enable_optimizer_dbg" = "yes"; then
1706 AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
1707 fi
1708 AC_MSG_RESULT(${enable_optimizer_dbg-no})
1709
1710 AC_MSG_CHECKING(whether to build parser debugging code)
1711 AC_ARG_ENABLE(yydebug,
1712 AS_HELP_STRING([--enable-yydebug],[build parser debugging code]))
1713 if test "$enable_yydebug" = "yes"; then
1714 AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
1715 fi
1716 AC_MSG_RESULT(${enable_yydebug-no})
1717
1718 #
1719 # Look for {f}lex.
1720 #
1721 AC_PROG_LEX
1722 if test "$LEX" = ":"; then
1723 AC_MSG_ERROR([Neither flex nor lex was found.])
1724 fi
1725
1726 #
1727 # Make sure {f}lex supports the -P, --header-file, and --nounput flags
1728 # and supports processing our scanner.l.
1729 #
1730 AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
1731 if $LEX -P pcap_ --header-file=/dev/null --nounput -t $srcdir/scanner.l > /dev/null 2>&1; then
1732 tcpdump_cv_capable_lex=yes
1733 else
1734 tcpdump_cv_capable_lex=insufficient
1735 fi)
1736 if test $tcpdump_cv_capable_lex = insufficient ; then
1737 AC_MSG_ERROR([$LEX is insufficient to compile libpcap.
1738 libpcap requires Flex 2.5.31 or later, or a compatible version of lex.
1739 If a suitable version of Lex/Flex is available as a non-standard command
1740 and/or not in the PATH, you can specify it using the LEX environment
1741 variable. That said, on some systems the error can mean that Flex/Lex is
1742 actually acceptable, but m4 is not. Likewise, if a suitable version of
1743 m4 (such as GNU M4) is available but has not been detected, you can
1744 specify it using the M4 environment variable.])
1745 fi
1746
1747 #
1748 # Look for yacc/bison/byacc.
1749 # If it's Bison, we do not want -y, as 1) we will be using -o to cause
1750 # the output for XXX.y to be written to XXX.c and 2) we don't want
1751 # it to issue warnings about stuff not supported by POSIX YACC - we
1752 # want to use that stuff, and don't care whether plain YACC supports
1753 # it or not, we require either Bison or Berkeley YACC.
1754 #
1755 BISON_BYACC=""
1756 #
1757 # Look for Bison.
1758 #
1759 AC_CHECK_PROGS(BISON_BYACC, bison)
1760 if test x"$BISON_BYACC" != x; then
1761 #
1762 # We found Bison.
1763 #
1764 # Bison prior to 2.4(.1) doesn't support "%define api.pure", so use
1765 # "%pure-parser".
1766 #
1767 bison_major_version=`$BISON_BYACC -V | sed -n 's/.* \(@<:@1-9@:>@@<:@0-9@:>@*\)\.@<:@0-9@:>@@<:@0-9.@:>@*/\1/p'`
1768 bison_minor_version=`$BISON_BYACC -V | sed -n 's/.* @<:@1-9@:>@@<:@0-9@:>@*\.\(@<:@0-9@:>@+\).*/\1/p'`
1769 if test "$bison_major_version" -lt 2 -o \
1770 \( "$bison_major_version" -eq 2 -a "$bison_major_version" -lt 4 \)
1771 then
1772 REENTRANT_PARSER="%pure-parser"
1773 else
1774 REENTRANT_PARSER="%define api.pure"
1775 fi
1776 else
1777 #
1778 # We didn't find Bison; check for Berkeley YACC, under the
1779 # names byacc and yacc.
1780 #
1781 AC_CHECK_PROGS(BISON_BYACC, byacc yacc)
1782 if test x"$BISON_BYACC" != x; then
1783 #
1784 # Make sure this is Berkeley YACC, not AT&T YACC;
1785 # the latter doesn't support reentrant parsers.
1786 # Run it with "-V"; that succeeds and reports the
1787 # version number with Berkeley YACC, but will
1788 # (probably) fail with various vendor flavors
1789 # of AT&T YACC.
1790 #
1791 # Hopefully this also eliminates any versions
1792 # of Berkeley YACC that don't support reentrant
1793 # parsers, if there are any.
1794 #
1795 AC_CACHE_CHECK([for capable yacc], tcpdump_cv_capable_yacc,
1796 if $BISON_BYACC -V >/dev/null 2>&1; then
1797 tcpdump_cv_capable_yacc=yes
1798 else
1799 tcpdump_cv_capable_yacc=insufficient
1800 fi)
1801 if test $tcpdump_cv_capable_yacc = insufficient ; then
1802 AC_MSG_ERROR([$BISON_BYACC is insufficient to compile libpcap.
1803 libpcap requires Bison, a newer version of Berkeley YACC with support
1804 for reentrant parsers, or another YACC compatible with them.])
1805 fi
1806 else
1807 #
1808 # OK, we found neither byacc nor yacc.
1809 #
1810 AC_MSG_ERROR([Neither bison, byacc, nor yacc was found.
1811 libpcap requires Bison, a newer version of Berkeley YACC with support
1812 for reentrant parsers, or another YACC compatible with them.])
1813 fi
1814
1815 #
1816 # Berkeley YACC doesn't support "%define api.pure", so use
1817 # "%pure-parser".
1818 #
1819 REENTRANT_PARSER="%pure-parser"
1820 fi
1821 AC_SUBST(BISON_BYACC)
1822 AC_SUBST(REENTRANT_PARSER)
1823
1824 #
1825 # Do various checks for various OSes and versions of those OSes.
1826 #
1827 # Assume, by default, no support for shared libraries and V7/BSD
1828 # convention for man pages (devices in section 4, file formats in
1829 # section 5, miscellaneous info in section 7, administrative commands
1830 # and daemons in section 8). Individual cases can override this.
1831 #
1832 DYEXT="none"
1833 MAN_DEVICES=4
1834 MAN_FILE_FORMATS=5
1835 MAN_MISC_INFO=7
1836 MAN_ADMIN_COMMANDS=8
1837 case "$host_os" in
1838
1839 aix*)
1840 dnl Workaround to enable certain features
1841 AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
1842
1843 #
1844 # AIX makes it fun to build shared and static libraries,
1845 # because they're *both* ".a" archive libraries. We
1846 # build the static library for the benefit of the traditional
1847 # scheme of building libpcap and tcpdump in subdirectories of
1848 # the same directory, with tcpdump statically linked with the
1849 # libpcap in question, but we also build a shared library as
1850 # "libpcap.shareda" and install *it*, rather than the static
1851 # library, as "libpcap.a".
1852 #
1853 DYEXT="shareda"
1854
1855 case "$V_PCAP" in
1856
1857 dlpi)
1858 #
1859 # If we're using DLPI, applications will need to
1860 # use /lib/pse.exp if present, as we use the
1861 # STREAMS routines.
1862 #
1863 pseexe="/lib/pse.exp"
1864 AC_MSG_CHECKING(for $pseexe)
1865 if test -f $pseexe ; then
1866 AC_MSG_RESULT(yes)
1867 LIBS="-I:$pseexe"
1868 fi
1869 ;;
1870
1871 bpf)
1872 #
1873 # If we're using BPF, we need "-lodm" and "-lcfg", as
1874 # we use them to load the BPF module.
1875 #
1876 LIBS="-lodm -lcfg"
1877 ;;
1878 esac
1879 ;;
1880
1881 darwin*)
1882 DYEXT="dylib"
1883 V_CCOPT="$V_CCOPT -fno-common"
1884 AC_ARG_ENABLE(universal,
1885 AS_HELP_STRING([--disable-universal],[don't build universal on macOS]))
1886 if test "$enable_universal" != "no"; then
1887 case "$host_os" in
1888
1889 darwin[[0-7]].*)
1890 #
1891 # Pre-Tiger. Build only for 32-bit PowerPC; no
1892 # need for any special compiler or linker flags.
1893 #
1894 ;;
1895
1896 darwin8.[[0123]]|darwin8.[[0123]].*)
1897 #
1898 # Tiger, prior to Intel support. Build
1899 # libraries and executables for 32-bit PowerPC
1900 # and 64-bit PowerPC, with 32-bit PowerPC first.
1901 # (I'm guessing that's what Apple does.)
1902 #
1903 # (The double brackets are needed because
1904 # autotools/m4 use brackets as a quoting
1905 # character; the double brackets turn into
1906 # single brackets in the generated configure
1907 # file.)
1908 #
1909 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64"
1910 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64"
1911 V_PROG_CCOPT_FAT="-arch ppc -arch ppc64"
1912 V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64"
1913 ;;
1914
1915 darwin8.[[456]]|darwin.[[456]].*)
1916 #
1917 # Tiger, subsequent to Intel support but prior
1918 # to x86-64 support. Build libraries and
1919 # executables for 32-bit PowerPC, 64-bit
1920 # PowerPC, and 32-bit x86, with 32-bit PowerPC
1921 # first. (I'm guessing that's what Apple does.)
1922 #
1923 # (The double brackets are needed because
1924 # autotools/m4 use brackets as a quoting
1925 # character; the double brackets turn into
1926 # single brackets in the generated configure
1927 # file.)
1928 #
1929 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
1930 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
1931 V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
1932 V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
1933 ;;
1934
1935 darwin8.*)
1936 #
1937 # All other Tiger, so subsequent to x86-64
1938 # support. Build libraries and executables for
1939 # 32-bit PowerPC, 64-bit PowerPC, 32-bit x86,
1940 # and x86-64, with 32-bit PowerPC first. (I'm
1941 # guessing that's what Apple does.)
1942 #
1943 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1944 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1945 V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1946 V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1947 ;;
1948
1949 darwin9.*)
1950 #
1951 # Leopard. Build libraries for 32-bit PowerPC,
1952 # 64-bit PowerPC, 32-bit x86, and x86-64, with
1953 # 32-bit PowerPC first, and build executables
1954 # for 32-bit x86 and 32-bit PowerPC, with 32-bit
1955 # x86 first. (That's what Apple does.)
1956 #
1957 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1958 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1959 V_PROG_CCOPT_FAT="-arch i386 -arch ppc"
1960 V_PROG_LDFLAGS_FAT="-arch i386 -arch ppc"
1961 ;;
1962
1963 darwin10.*)
1964 #
1965 # Snow Leopard. Build libraries for x86-64,
1966 # 32-bit x86, and 32-bit PowerPC, with x86-64
1967 # first, and build executables for x86-64 and
1968 # 32-bit x86, with x86-64 first. (That's what
1969 # Apple does, even though Snow Leopard doesn't
1970 # run on PPC, so PPC libpcap runs under Rosetta,
1971 # and Rosetta doesn't support BPF ioctls, so PPC
1972 # programs can't do live captures.)
1973 #
1974 V_LIB_CCOPT_FAT="-arch x86_64 -arch i386 -arch ppc"
1975 V_LIB_LDFLAGS_FAT="-arch x86_64 -arch i386 -arch ppc"
1976 V_PROG_CCOPT_FAT="-arch x86_64 -arch i386"
1977 V_PROG_LDFLAGS_FAT="-arch x86_64 -arch i386"
1978 ;;
1979
1980 darwin*)
1981 #
1982 # Post-Snow Leopard. Build libraries for x86-64
1983 # and 32-bit x86, with x86-64 first, and build
1984 # executables only for x86-64. (That's what
1985 # Apple does.) This requires no special flags
1986 # for programs.
1987 # XXX - update if and when Apple drops support
1988 # for 32-bit x86 code and if and when Apple adds
1989 # ARM-based Macs. (You're on your own for iOS
1990 # etc.)
1991 #
1992 # XXX - check whether we *can* build for
1993 # i386 and, if not, suggest that the user
1994 # install the /usr/include headers if they
1995 # want to build fat.
1996 #
1997 AC_MSG_CHECKING(whether building for 32-bit x86 is supported)
1998 save_CFLAGS="$CFLAGS"
1999 CFLAGS="$CFLAGS -arch i386"
2000 AC_TRY_LINK(
2001 [],
2002 [return 0;],
2003 [
2004 AC_MSG_RESULT(yes)
2005 V_LIB_CCOPT_FAT="-arch x86_64"
2006 V_LIB_LDFLAGS_FAT="-arch x86_64"
2007
2008 #
2009 # OpenSSL installation on macOS seems
2010 # to install only the libs for 64-bit
2011 # x86 - at least that's what Brew does:
2012 # only configure 32-bit builds if we
2013 # don't have OpenSSL.
2014 #
2015 if test "$HAVE_OPENSSL" != yes; then
2016 V_LIB_CCOPT_FAT="$V_LIB_CCOPT_FAT -arch i386"
2017 V_LIB_LDFLAGS_FAT="$V_LIB_LDFLAGS_FAT -arch i386"
2018 fi
2019 ],
2020 [
2021 AC_MSG_RESULT(no)
2022 V_LIB_CCOPT_FAT="-arch x86_64"
2023 V_LIB_LDFLAGS_FAT="-arch x86_64"
2024 case "$host_os" in
2025
2026 darwin18.*)
2027 #
2028 # Mojave; you need to install the
2029 # /usr/include headers to get
2030 # 32-bit x86 builds to work.
2031 #
2032 AC_MSG_WARN([Compiling for 32-bit x86 gives an error; try installing the command-line tools and, after that, installing the /usr/include headers from the /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg package])
2033 ;;
2034
2035 *)
2036 #
2037 # Pre-Mojave; the command-line
2038 # tools should be sufficient to
2039 # enable 32-bit x86 builds.
2040 #
2041 AC_MSG_WARN([Compiling for 32-bit x86 gives an error; try installing the command-line tools])
2042 ;;
2043 esac
2044 ])
2045 CFLAGS="$save_CFLAGS"
2046 ;;
2047 esac
2048 fi
2049 ;;
2050
2051 hpux9*)
2052 AC_DEFINE(HAVE_HPUX9,1,[on HP-UX 9.x])
2053
2054 #
2055 # Use System V conventions for man pages.
2056 #
2057 MAN_ADMIN_COMMANDS=1m
2058 MAN_FILE_FORMATS=4
2059 MAN_MISC_INFO=5
2060 ;;
2061
2062 hpux10.0*)
2063
2064 #
2065 # Use System V conventions for man pages.
2066 #
2067 MAN_ADMIN_COMMANDS=1m
2068 MAN_FILE_FORMATS=4
2069 MAN_MISC_INFO=5
2070 ;;
2071
2072 hpux10.1*)
2073
2074 #
2075 # Use System V conventions for man pages.
2076 #
2077 MAN_ADMIN_COMMANDS=1m
2078 MAN_FILE_FORMATS=4
2079 MAN_MISC_INFO=5
2080 ;;
2081
2082 hpux*)
2083 dnl HPUX 10.20 and above is similar to HPUX 9, but
2084 dnl not the same....
2085 dnl
2086 dnl XXX - DYEXT should be set to "sl" if this is building
2087 dnl for 32-bit PA-RISC, but should be left as "so" for
2088 dnl 64-bit PA-RISC or, I suspect, IA-64.
2089 AC_DEFINE(HAVE_HPUX10_20_OR_LATER,1,[on HP-UX 10.20 or later])
2090 if test "`uname -m`" = "ia64"; then
2091 DYEXT="so"
2092 else
2093 DYEXT="sl"
2094 fi
2095
2096 #
2097 # "-b" builds a shared library; "+h" sets the soname.
2098 #
2099 SHLIB_OPT="-b"
2100 SONAME_OPT="+h"
2101
2102 #
2103 # Use System V conventions for man pages.
2104 #
2105 MAN_FILE_FORMATS=4
2106 MAN_MISC_INFO=5
2107 ;;
2108
2109 irix*)
2110 #
2111 # Use IRIX conventions for man pages; they're the same as the
2112 # System V conventions, except that they use section 8 for
2113 # administrative commands and daemons.
2114 #
2115 MAN_FILE_FORMATS=4
2116 MAN_MISC_INFO=5
2117 ;;
2118
2119 linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*|haiku*|midipix*)
2120 DYEXT="so"
2121
2122 #
2123 # Compiler assumed to be GCC; run-time linker may require a -R
2124 # flag.
2125 #
2126 if test "$libdir" != "/usr/lib"; then
2127 V_RFLAGS=-Wl,-R$libdir
2128 fi
2129 ;;
2130
2131 osf*)
2132 DYEXT="so"
2133
2134 #
2135 # DEC OSF/1, a/k/a Digial UNIX, a/k/a Tru64 UNIX.
2136 # Use Tru64 UNIX conventions for man pages; they're the same as
2137 # the System V conventions except that they use section 8 for
2138 # administrative commands and daemons.
2139 #
2140 MAN_FILE_FORMATS=4
2141 MAN_MISC_INFO=5
2142 MAN_DEVICES=7
2143 ;;
2144
2145 sinix*)
2146 AC_MSG_CHECKING(if SINIX compiler defines sinix)
2147 AC_CACHE_VAL(ac_cv_cc_sinix_defined,
2148 AC_TRY_COMPILE(
2149 [],
2150 [int i = sinix;],
2151 ac_cv_cc_sinix_defined=yes,
2152 ac_cv_cc_sinix_defined=no))
2153 AC_MSG_RESULT($ac_cv_cc_sinix_defined)
2154 if test $ac_cv_cc_sinix_defined = no ; then
2155 AC_DEFINE(sinix,1,[on sinix])
2156 fi
2157 ;;
2158
2159 solaris*)
2160 AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
2161
2162 DYEXT="so"
2163
2164 #
2165 # Make sure errno is thread-safe, in case we're called in
2166 # a multithreaded program. We don't guarantee that two
2167 # threads can use the *same* pcap_t safely, but the
2168 # current version does guarantee that you can use different
2169 # pcap_t's in different threads, and even that pcap_compile()
2170 # is thread-safe (it wasn't thread-safe in some older versions).
2171 #
2172 V_CCOPT="$V_CCOPT -D_TS_ERRNO"
2173
2174 case "`uname -r`" in
2175
2176 5.12)
2177 ;;
2178
2179 *)
2180 #
2181 # Use System V conventions for man pages.
2182 #
2183 MAN_ADMIN_COMMANDS=1m
2184 MAN_FILE_FORMATS=4
2185 MAN_MISC_INFO=5
2186 MAN_DEVICES=7D
2187 esac
2188 ;;
2189 esac
2190
2191 AC_ARG_ENABLE(shared,
2192 AS_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@]))
2193 test "x$enable_shared" = "xno" && DYEXT="none"
2194
2195 AC_PROG_RANLIB
2196 AC_CHECK_TOOL([AR], [ar])
2197
2198 AC_PROG_LN_S
2199 AC_SUBST(LN_S)
2200
2201 AC_LBL_DEVEL(V_CCOPT)
2202
2203 #
2204 # Check to see if the sockaddr struct has the 4.4 BSD sa_len member.
2205 #
2206 AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,
2207 [
2208 #include <sys/types.h>
2209 #include <sys/socket.h>
2210 ])
2211
2212 #
2213 # Check to see if there's a sockaddr_storage structure.
2214 #
2215 AC_CHECK_TYPES(struct sockaddr_storage,,,
2216 [
2217 #include <sys/types.h>
2218 #include <sys/socket.h>
2219 ])
2220
2221 #
2222 # Check to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
2223 # dl_module_id_1 member.
2224 #
2225 # NOTE: any failure means we conclude that it doesn't have that member,
2226 # so if we don't have DLPI, don't have a <sys/dlpi_ext.h> header, or
2227 # have one that doesn't declare a dl_hp_ppa_info_t type, we conclude
2228 # it doesn't have that member (which is OK, as either we won't be
2229 # using code that would use that member, or we wouldn't compile in
2230 # any case).
2231 #
2232 AC_CHECK_MEMBERS([dl_hp_ppa_info_t.dl_module_id_1],,,
2233 [
2234 #include <sys/types.h>
2235 #include <sys/dlpi.h>
2236 #include <sys/dlpi_ext.h>
2237 ])
2238
2239 AC_SUBST(V_CCOPT)
2240 AC_SUBST(V_LIB_CCOPT_FAT)
2241 AC_SUBST(V_LIB_LDFLAGS_FAT)
2242 AC_SUBST(V_PROG_CCOPT_FAT)
2243 AC_SUBST(V_PROG_LDFLAGS_FAT)
2244 AC_SUBST(V_DEFS)
2245 AC_SUBST(V_INCLS)
2246 AC_SUBST(V_LEX)
2247 AC_SUBST(V_SHLIB_CCOPT)
2248 AC_SUBST(V_SHLIB_CMD)
2249 AC_SUBST(V_SHLIB_OPT)
2250 AC_SUBST(V_SONAME_OPT)
2251 AC_SUBST(V_RPATH_OPT)
2252 AC_SUBST(V_YACC)
2253 AC_SUBST(ADDLOBJS)
2254 AC_SUBST(ADDLARCHIVEOBJS)
2255 AC_SUBST(PLATFORM_C_SRC)
2256 AC_SUBST(PLATFORM_CXX_SRC)
2257 AC_SUBST(MODULE_C_SRC)
2258 AC_SUBST(REMOTE_C_SRC)
2259 AC_SUBST(DYEXT)
2260 AC_SUBST(MAN_DEVICES)
2261 AC_SUBST(MAN_FILE_FORMATS)
2262 AC_SUBST(MAN_MISC_INFO)
2263 AC_SUBST(MAN_ADMIN_COMMANDS)
2264 AC_SUBST(PTHREAD_LIBS)
2265 AC_SUBST(BUILD_RPCAPD)
2266 AC_SUBST(INSTALL_RPCAPD)
2267 AC_SUBST(RPCAPD_LIBS)
2268 AC_SUBST(EXTRA_NETWORK_LIBS)
2269
2270 #
2271 # Various Linux-specific mechanisms.
2272 #
2273 AC_ARG_ENABLE([usb],
2274 [AS_HELP_STRING([--enable-usb],[enable Linux usbmon USB capture support @<:@default=yes, if support available@:>@])],
2275 [],
2276 [enable_usb=yes])
2277
2278 #
2279 # If somebody requested an XXX-only pcap, that doesn't include
2280 # additional mechanisms.
2281 #
2282 if test "xxx_only" != yes; then
2283 case "$host_os" in
2284 linux*)
2285 dnl check for USB sniffing support
2286 AC_MSG_CHECKING(for Linux usbmon USB sniffing support)
2287 if test "x$enable_usb" != "xno" ; then
2288 AC_DEFINE(PCAP_SUPPORT_LINUX_USBMON, 1, [target host supports Linux usbmon for USB sniffing])
2289 MODULE_C_SRC="$MODULE_C_SRC pcap-usb-linux.c"
2290 AC_MSG_RESULT(yes)
2291 ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null`
2292 if test $? -ne 0 ; then
2293 ac_usb_dev_name="usbmon"
2294 fi
2295 AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing])
2296 AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name)
2297 #
2298 # Do we have a version of <linux/compiler.h> available?
2299 # If so, we might need it for <linux/usbdevice_fs.h>.
2300 #
2301 AC_CHECK_HEADERS(linux/compiler.h)
2302 if test "$ac_cv_header_linux_compiler_h" = yes; then
2303 #
2304 # Yes - include it when testing for <linux/usbdevice_fs.h>.
2305 #
2306 AC_CHECK_HEADERS(linux/usbdevice_fs.h,,,[#include <linux/compiler.h>])
2307 else
2308 AC_CHECK_HEADERS(linux/usbdevice_fs.h)
2309 fi
2310 if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then
2311 #
2312 # OK, does it define bRequestType? Older versions of the kernel
2313 # define fields with names like "requesttype, "request", and
2314 # "value", rather than "bRequestType", "bRequest", and
2315 # "wValue".
2316 #
2317 AC_CHECK_MEMBERS([struct usbdevfs_ctrltransfer.bRequestType],,,
2318 [
2319 AC_INCLUDES_DEFAULT
2320 #ifdef HAVE_LINUX_COMPILER_H
2321 #include <linux/compiler.h>
2322 #endif
2323 #include <linux/usbdevice_fs.h>
2324 ])
2325 fi
2326 else
2327 AC_MSG_RESULT(no)
2328 fi
2329
2330 #
2331 # Life's too short to deal with trying to get this to compile
2332 # if you don't get the right types defined with
2333 # __KERNEL_STRICT_NAMES getting defined by some other include.
2334 #
2335 # Check whether the includes Just Work. If not, don't turn on
2336 # netfilter support.
2337 #
2338 AC_MSG_CHECKING(whether we can compile the netfilter support)
2339 AC_CACHE_VAL(ac_cv_netfilter_can_compile,
2340 AC_TRY_COMPILE([
2341 AC_INCLUDES_DEFAULT
2342 #include <sys/socket.h>
2343 #include <netinet/in.h>
2344 #include <linux/types.h>
2345
2346 #include <linux/netlink.h>
2347 #include <linux/netfilter.h>
2348 #include <linux/netfilter/nfnetlink.h>
2349 #include <linux/netfilter/nfnetlink_log.h>
2350 #include <linux/netfilter/nfnetlink_queue.h>],
2351 [],
2352 ac_cv_netfilter_can_compile=yes,
2353 ac_cv_netfilter_can_compile=no))
2354 AC_MSG_RESULT($ac_cv_netfilter_can_compile)
2355 if test $ac_cv_netfilter_can_compile = yes ; then
2356 AC_DEFINE(PCAP_SUPPORT_NETFILTER, 1,
2357 [target host supports netfilter sniffing])
2358 MODULE_C_SRC="$MODULE_C_SRC pcap-netfilter-linux.c"
2359 fi
2360 ;;
2361 esac
2362 fi
2363 AC_SUBST(PCAP_SUPPORT_LINUX_USBMON)
2364 AC_SUBST(PCAP_SUPPORT_NETFILTER)
2365
2366 AC_ARG_ENABLE([netmap],
2367 [AS_HELP_STRING([--enable-netmap],[enable netmap support @<:@default=yes, if support available@:>@])],
2368 [],
2369 [enable_netmap=yes])
2370
2371 if test "x$enable_netmap" != "xno" ; then
2372 #
2373 # Check whether net/netmap_user.h is usable if NETMAP_WITH_LIBS is
2374 # defined; it's not usable on DragonFly BSD 4.6 if NETMAP_WITH_LIBS
2375 # is defined, for example, as it includes a non-existent malloc.h
2376 # header.
2377 #
2378 AC_MSG_CHECKING(whether we can compile the netmap support)
2379 AC_CACHE_VAL(ac_cv_net_netmap_user_can_compile,
2380 AC_TRY_COMPILE([
2381 AC_INCLUDES_DEFAULT
2382 #define NETMAP_WITH_LIBS
2383 #include <net/netmap_user.h>],
2384 [],
2385 ac_cv_net_netmap_user_can_compile=yes,
2386 ac_cv_net_netmap_user_can_compile=no))
2387 AC_MSG_RESULT($ac_cv_net_netmap_user_can_compile)
2388 if test $ac_cv_net_netmap_user_can_compile = yes ; then
2389 AC_DEFINE(PCAP_SUPPORT_NETMAP, 1,
2390 [target host supports netmap])
2391 MODULE_C_SRC="$MODULE_C_SRC pcap-netmap.c"
2392 fi
2393 AC_SUBST(PCAP_SUPPORT_NETMAP)
2394 fi
2395
2396 # Check for DPDK support.
2397 AC_ARG_WITH([dpdk],
2398 AS_HELP_STRING([--with-dpdk@<:@=DIR@:>@],[include DPDK support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
2399 [
2400 if test "$withval" = no
2401 then
2402 # User doesn't want DPDK support.
2403 want_dpdk=no
2404 elif test "$withval" = yes
2405 then
2406 # User wants DPDK support but hasn't specified a directory.
2407 want_dpdk=yes
2408 else
2409 # User wants DPDK support and has specified a directory,
2410 # so use the provided value.
2411 want_dpdk=yes
2412 dpdk_dir=$withval
2413 fi
2414 ],[
2415 if test "$V_PCAP" = dpdk; then
2416 # User requested DPDK-only libpcap, so we'd better have
2417 # the DPDK API.
2418 want_dpdk=yes
2419 elif test "xxx_only" = yes; then
2420 # User requested something-else-only pcap, so they don't
2421 # want DPDK support.
2422 want_dpdk=no
2423 else
2424 #
2425 # Use DPDK API if present, otherwise don't
2426 #
2427 want_dpdk=ifpresent
2428 fi
2429 ])
2430
2431 if test "$want_dpdk" != no; then
2432 if test "x$PKGCONFIG" != "xno"
2433 then
2434 #
2435 # We have pkg-config; see if we have DPDK installed
2436 # as a package.
2437 #
2438 AC_MSG_CHECKING([for DPDK with pkg-config])
2439 if "$PKGCONFIG" libdpdk
2440 then
2441 AC_MSG_RESULT([found])
2442 found_dpdk_with_pkg_config=yes
2443 DPDK_CFLAGS=`"$PKGCONFIG" --cflags libdpdk`
2444 DPDK_LDFLAGS=`"$PKGCONFIG" --libs libdpdk`
2445 else
2446 AC_MSG_RESULT([not found])
2447 fi
2448 fi
2449
2450 #
2451 # If we didn't find it with pkg-config, try checking for
2452 # it manually.
2453 #
2454 if test "x$found_dpdk_with_pkg_config" != "xyes"
2455 then
2456 if test -z "$dpdk_dir"; then
2457 #
2458 # The user didn't specify a directory containing
2459 # the DPDK headers and libraries. If we find
2460 # a /usr/local/include/dpdk directory, assume
2461 # it's /usr/local, otherwise assume it's /usr.
2462 #
2463 if test -d "/usr/local/include/dpdk"; then
2464 dpdk_dir="/usr/local"
2465 else
2466 dpdk_dir="/usr"
2467 fi
2468 fi
2469 #
2470 # The convention appears to be that 1) there's a "dpdk"
2471 # subdirectory of the include directory, containing DPDK
2472 # headers (at least in the installation on Ubuntu with
2473 # the system DPDK packages) and 2) includes of DPDK
2474 # headers don't use "dpdk/{header}" (at least from the
2475 # way the DPDK documentation is written).
2476 #
2477 # So we add "/dpdk" to the include directory, and always
2478 # add that to the list of include directories to search.
2479 #
2480 dpdk_inc_dir="$dpdk_dir/include/dpdk"
2481 dpdk_inc_flags="-I$dpdk_inc_dir"
2482 dpdk_lib_dir="$dpdk_dir/lib"
2483 #
2484 # Handle multiarch systems.
2485 #
2486 # Step 1: run the C compiler with the -dumpmachine option;
2487 # if it succeeds, the output would be the multiarch directory
2488 # name if your system has multiarch directories.
2489 #
2490 multiarch_dir=`$CC -dumpmachine 2>/dev/null`
2491 if test ! -z "$multiarch_dir"
2492 then
2493 #
2494 # OK, we have a multiarch directory.
2495 #
2496 # Now deal with includes. On Ubuntu 20.04, for
2497 # example, we have /usr/include/dpdk *and*
2498 # /usr/include/$multiarch_dir/dpdk, and must
2499 # search both.
2500 #
2501 if test -d "$dpdk_dir/include/$multiarch_dir/dpdk"
2502 then
2503 dpdk_inc_flags="-I$dpdk_dir/include/$multiarch_dir/dpdk $dpdk_inc_flags"
2504 fi
2505
2506 #
2507 # Now deal with libraries.
2508 #
2509 if test -d "$dpdk_lib_dir/$multiarch_dir"
2510 then
2511 dpdk_lib_dir="$dpdk_lib_dir/$multiarch_dir"
2512 fi
2513 fi
2514 DPDK_MACHINE_CFLAGS="-march=native"
2515 DPDK_CFLAGS="$DPDK_MACHINE_CFLAGS $dpdk_inc_flags"
2516 DPDK_LDFLAGS="-L$dpdk_lib_dir -ldpdk -lrt -lm -lnuma -ldl -pthread"
2517 fi
2518
2519 save_CFLAGS="$CFLAGS"
2520 save_LIBS="$LIBS"
2521 save_LDFLAGS="$LDFLAGS"
2522 CFLAGS="$CFLAGS $DPDK_CFLAGS"
2523 LIBS="$LIBS $DPDK_LDFLAGS"
2524 LDFLAGS="$LDFLAGS $DPDK_LDFLAGS"
2525
2526 AC_MSG_CHECKING(whether we can compile the DPDK support)
2527 AC_CACHE_VAL(ac_cv_dpdk_can_compile,
2528 AC_TRY_COMPILE([
2529 AC_INCLUDES_DEFAULT
2530 #include <rte_common.h>],
2531 [],
2532 ac_cv_dpdk_can_compile=yes,
2533 ac_cv_dpdk_can_compile=no))
2534 AC_MSG_RESULT($ac_cv_dpdk_can_compile)
2535
2536 #
2537 # We include rte_bus.h, and older versions of DPDK
2538 # didn't have it, so check for it.
2539 #
2540 if test "$ac_cv_dpdk_can_compile" = yes; then
2541 #
2542 # This runs the preprocessor, so make sure it
2543 # looks in the DPDK directories. Instead of
2544 # including dpdk/XXX.h, we include just XXX.h
2545 # and assume DPDK_CFLAGS is the directory
2546 # containing the DPDK headers (that's how
2547 # pkg-config sets it, at least on Ubuntu),
2548 # so just looking under /usr/include won't
2549 # find it.
2550 #
2551 save_CPPFLAGS="$CPPFLAGS"
2552 CPPFLAGS="$CPPFLAGS $DPDK_CFLAGS"
2553 AC_CHECK_HEADER(rte_bus.h)
2554 CPPFLAGS="$save_CPPFLAGS"
2555 fi
2556
2557 #
2558 # We call rte_eth_dev_count_avail(), and older versions
2559 # of DPDK didn't have it, so check for it.
2560 #
2561 if test "$ac_cv_header_rte_bus_h" = yes; then
2562 AC_CHECK_FUNC(rte_eth_dev_count_avail)
2563 fi
2564
2565 CFLAGS="$save_CFLAGS"
2566 LIBS="$save_LIBS"
2567 LDFLAGS="$save_LDFLAGS"
2568
2569 if test "$ac_cv_func_rte_eth_dev_count_avail" = yes; then
2570 CFLAGS="$CFLAGS $DPDK_CFLAGS"
2571 LIBS="$LIBS $DPDK_LDFLAGS"
2572 LDFLAGS="$LDFLAGS $DPDK_LDFLAGS"
2573 V_INCLS="$V_INCLS $DPDK_CFLAGS"
2574 AC_DEFINE(PCAP_SUPPORT_DPDK, 1, [target host supports DPDK])
2575 if test $V_PCAP != dpdk ; then
2576 MODULE_C_SRC="$MODULE_C_SRC pcap-dpdk.c"
2577 fi
2578
2579 #
2580 # Check whether the rte_ether.h file defines
2581 # struct ether_addr or struct rte_ether_addr.
2582 #
2583 # ("API compatibility? That's for losers!")
2584 #
2585 AC_CHECK_TYPES(struct rte_ether_addr,,,
2586 [
2587 #include <rte_ether.h>
2588 ])
2589 else
2590 if test "$V_PCAP" = dpdk; then
2591 # User requested DPDK-only capture support, but
2592 # we couldn't the DPDK API support at all, or we
2593 # found it but it wasn't a sufficiently recent
2594 # version.
2595 if test "$ac_cv_dpdk_can_compile" != yes; then
2596 #
2597 # Couldn't even find the headers.
2598 #
2599 AC_MSG_ERROR([DPDK support requested with --with-pcap=dpdk, but the DPDK headers weren't found at $dpdk_inc_dir: make sure the DPDK support is installed, specify a different path or paths if necessary, or don't request DPDK support])
2600 else
2601 #
2602 # Found the headers, but we couldn't find
2603 # rte_bus.h or rte_eth_dev_count_avail(),
2604 # we don't have a sufficiently recent
2605 # version of DPDK.
2606 #
2607 AC_MSG_ERROR([DPDK support requested with --with-pcap=dpdk, but we require DPDK 18.x or later; install a newer version of DPDK, or don't request DPDK support])
2608 fi
2609 fi
2610
2611 if test "$want_dpdk" = yes; then
2612 # User requested DPDK-only capture support, but
2613 # we couldn't the DPDK API support at all, or we
2614 # found it but it wasn't a sufficiently recent
2615 # version.
2616 if test "$ac_cv_dpdk_can_compile" != yes; then
2617 #
2618 # Couldn't even find the headers.
2619 #
2620 AC_MSG_ERROR([DPDK support requested with --with-pcap=dpdk, but the DPDK headers weren't found at $dpdk_inc_dir: make sure the DPDK support is installed, specify a different path or paths if necessary, or don't request DPDK support])
2621 else
2622 #
2623 # Found the headers, but we couldn't find
2624 # rte_bus.h or rte_eth_dev_count_avail(),
2625 # we don't have a sufficiently recent
2626 # version of DPDK.
2627 #
2628 AC_MSG_ERROR([DPDK support requested with --with-pcap=dpdk, but we require DPDK 18.x or later: install a newer version of DPDK, or don't request DPDK support])
2629 fi
2630 fi
2631 fi
2632 fi
2633 AC_SUBST(PCAP_SUPPORT_DPDK)
2634
2635 AC_ARG_ENABLE([bluetooth],
2636 [AS_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
2637 [],
2638 [enable_bluetooth=ifsupportavailable])
2639
2640 if test "xxx_only" = yes; then
2641 # User requested something-else-only pcap, so they don't
2642 # want Bluetooth support.
2643 enable_bluetooth=no
2644 fi
2645
2646 if test "x$enable_bluetooth" != "xno" ; then
2647 dnl check for Bluetooth sniffing support
2648 case "$host_os" in
2649 linux*)
2650 AC_CHECK_HEADER(bluetooth/bluetooth.h,
2651 [
2652 #
2653 # We have bluetooth.h, so we support Bluetooth
2654 # sniffing.
2655 #
2656 AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
2657 MODULE_C_SRC="$MODULE_C_SRC pcap-bt-linux.c"
2658 AC_MSG_NOTICE(Bluetooth sniffing is supported)
2659 ac_lbl_bluetooth_available=yes
2660
2661 #
2662 # OK, does struct sockaddr_hci have an hci_channel
2663 # member?
2664 #
2665 AC_CHECK_MEMBERS([struct sockaddr_hci.hci_channel],
2666 [
2667 #
2668 # Yes; is HCI_CHANNEL_MONITOR defined?
2669 #
2670 AC_MSG_CHECKING(if HCI_CHANNEL_MONITOR is defined)
2671 AC_CACHE_VAL(ac_cv_lbl_hci_channel_monitor_is_defined,
2672 AC_TRY_COMPILE(
2673 [
2674 #include <bluetooth/bluetooth.h>
2675 #include <bluetooth/hci.h>
2676 ],
2677 [
2678 u_int i = HCI_CHANNEL_MONITOR;
2679 ],
2680 [
2681 AC_MSG_RESULT(yes)
2682 AC_DEFINE(PCAP_SUPPORT_BT_MONITOR,,
2683 [target host supports Bluetooth Monitor])
2684 MODULE_C_SRC="$MODULE_C_SRC pcap-bt-monitor-linux.c"
2685 ],
2686 [
2687 AC_MSG_RESULT(no)
2688 ]))
2689 ],,
2690 [
2691 #include <bluetooth/bluetooth.h>
2692 #include <bluetooth/hci.h>
2693 ])
2694 ],
2695 [
2696 #
2697 # We don't have bluetooth.h, so we don't support
2698 # Bluetooth sniffing.
2699 #
2700 if test "x$enable_bluetooth" = "xyes" ; then
2701 AC_MSG_ERROR(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2702 else
2703 AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2704 fi
2705 ])
2706 ;;
2707 *)
2708 if test "x$enable_bluetooth" = "xyes" ; then
2709 AC_MSG_ERROR(no Bluetooth sniffing support implemented for $host_os)
2710 else
2711 AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os)
2712 fi
2713 ;;
2714 esac
2715 AC_SUBST(PCAP_SUPPORT_BT)
2716 fi
2717
2718 AC_ARG_ENABLE([dbus],
2719 [AS_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
2720 [],
2721 [enable_dbus=ifavailable])
2722
2723 if test "xxx_only" = yes; then
2724 # User requested something-else-only pcap, so they don't
2725 # want D-Bus support.
2726 enable_dbus=no
2727 fi
2728
2729 if test "x$enable_dbus" != "xno"; then
2730 if test "x$enable_dbus" = "xyes"; then
2731 case "$host_os" in
2732
2733 darwin*)
2734 #
2735 # We don't support D-Bus sniffing on macOS; see
2736 #
2737 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
2738 #
2739 # The user requested it, so fail.
2740 #
2741 AC_MSG_ERROR([Due to freedesktop.org bug 74029, D-Bus capture support is not available on macOS])
2742 esac
2743 else
2744 case "$host_os" in
2745
2746 darwin*)
2747 #
2748 # We don't support D-Bus sniffing on macOS; see
2749 #
2750 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
2751 #
2752 # The user dind't explicitly request it, so just
2753 # silently refuse to enable it.
2754 #
2755 enable_dbus="no"
2756 ;;
2757 esac
2758 fi
2759 fi
2760
2761 if test "x$enable_dbus" != "xno"; then
2762 if test "x$PKGCONFIG" != "xno"; then
2763 AC_MSG_CHECKING([for D-Bus])
2764 if "$PKGCONFIG" dbus-1; then
2765 AC_MSG_RESULT([yes])
2766 DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
2767 DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
2768 save_CFLAGS="$CFLAGS"
2769 save_LIBS="$LIBS"
2770 CFLAGS="$CFLAGS $DBUS_CFLAGS"
2771 LIBS="$LIBS $DBUS_LIBS"
2772 AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
2773 AC_TRY_LINK(
2774 [#include <string.h>
2775
2776 #include <time.h>
2777 #include <sys/time.h>
2778
2779 #include <dbus/dbus.h>],
2780 [return dbus_connection_read_write(NULL, 0);],
2781 [
2782 AC_MSG_RESULT([yes])
2783 AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
2784 MODULE_C_SRC="$MODULE_C_SRC pcap-dbus.c"
2785 V_INCLS="$V_INCLS $DBUS_CFLAGS"
2786 ],
2787 [
2788 AC_MSG_RESULT([no])
2789 if test "x$enable_dbus" = "xyes"; then
2790 AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
2791 fi
2792 LIBS="$save_LIBS"
2793 ])
2794 CFLAGS="$save_CFLAGS"
2795 else
2796 AC_MSG_RESULT([no])
2797 if test "x$enable_dbus" = "xyes"; then
2798 AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed])
2799 fi
2800 fi
2801 fi
2802 AC_SUBST(PCAP_SUPPORT_DBUS)
2803 fi
2804
2805 AC_ARG_ENABLE([rdma],
2806 [AS_HELP_STRING([--enable-rdma],[enable RDMA capture support @<:@default=yes, if support available@:>@])],
2807 [],
2808 [enable_rdma=ifavailable])
2809
2810 if test "xxx_only" = yes; then
2811 # User requested something-else-only pcap, so they don't
2812 # want RDMA support.
2813 enable_rdma=no
2814 fi
2815
2816 if test "x$enable_rdma" != "xno"; then
2817 AC_CHECK_LIB(ibverbs, ibv_get_device_list, [
2818 AC_CHECK_HEADER(infiniband/verbs.h, [
2819 #
2820 # ibv_create_flow may be defined as a static inline
2821 # function in infiniband/verbs.h, so we can't
2822 # use AC_CHECK_LIB.
2823 #
2824 # Too bad autoconf has no AC_SYMBOL_EXISTS()
2825 # macro that works like CMake's check_symbol_exists()
2826 # function, to check do a compile check like
2827 # this (they do a clever trick to avoid having
2828 # to know the function's signature).
2829 #
2830 AC_MSG_CHECKING(whether libibverbs defines ibv_create_flow)
2831 AC_TRY_LINK(
2832 [
2833 #include <infiniband/verbs.h>
2834 ],
2835 [
2836 (void) ibv_create_flow((struct ibv_qp *) NULL,
2837 (struct ibv_flow_attr *) NULL);
2838 ],
2839 [
2840 AC_MSG_RESULT([yes])
2841 AC_DEFINE(PCAP_SUPPORT_RDMASNIFF, , [target host supports RDMA sniffing])
2842 MODULE_C_SRC="$MODULE_C_SRC pcap-rdmasniff.c"
2843 LIBS="-libverbs $LIBS"
2844 ],
2845 [
2846 AC_MSG_RESULT([no])
2847 ]
2848 )
2849 ])
2850 ])
2851 AC_SUBST(PCAP_SUPPORT_RDMASNIFF)
2852 fi
2853
2854 AC_PROG_INSTALL
2855
2856 AC_CONFIG_HEADER(config.h)
2857
2858 AC_OUTPUT_COMMANDS([if test -f .devel; then
2859 echo timestamp > stamp-h
2860 cat $srcdir/Makefile-devel-adds >> Makefile
2861 make depend || exit 1
2862 fi])
2863 AC_OUTPUT(Makefile grammar.y pcap-filter.manmisc pcap-linktype.manmisc
2864 pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap
2865 pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap
2866 pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap
2867 pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap
2868 pcap_open_offline.3pcap pcap_set_immediate_mode.3pcap
2869 pcap_set_tstamp_precision.3pcap pcap_set_tstamp_type.3pcap
2870 rpcapd/Makefile rpcapd/rpcapd.manadmin rpcapd/rpcapd-config.manfile
2871 testprogs/Makefile)
2872 exit 0