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