From: Michael Richardson Date: Sun, 15 Feb 2015 17:58:20 +0000 (-0500) Subject: Merge branch 'add_with-libnl_switch' of https://github.com/mcr/libpcap into mcr-add_w... X-Git-Tag: libpcap-1.7.2^2~34 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/697bc41cd26cfd8270106cd980a89113ad9e2dc9?hp=-c Merge branch 'add_with-libnl_switch' of https://github.com/mcr/libpcap into mcr-add_with-libnl_switch --- 697bc41cd26cfd8270106cd980a89113ad9e2dc9 diff --combined Makefile.in index b1866e58,d7537b83..755ada0a --- a/Makefile.in +++ b/Makefile.in @@@ -53,8 -53,9 +53,9 @@@ DEFS = @DEFS@ @V_DEFS ADDLOBJS = @ADDLOBJS@ ADDLARCHIVEOBJS = @ADDLARCHIVEOBJS@ LIBS = @LIBS@ - CFLAGS = @CFLAGS@ - LDFLAGS = @LDFLAGS@ + CROSSFLAGS= + CFLAGS = @CFLAGS@ ${CROSSFLAGS} + LDFLAGS = @LDFLAGS@ ${CROSSFLAGS} DYEXT = @DYEXT@ V_RPATH_OPT = @V_RPATH_OPT@ DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@ @@@ -291,6 -292,7 +292,6 @@@ EXTRA_DIST = msdos/pktdrvr.h \ msdos/readme.dos \ org.tcpdump.chmod_bpf.plist \ - packaging/pcap.spec.in \ pcap-bpf.c \ pcap-bt-linux.c \ pcap-bt-linux.h \ @@@ -442,10 -444,8 +443,10 @@@ libpcap.shareda: $(OBJ libpcap.none: scanner.c: $(srcdir)/scanner.l - @rm -f $@ + @rm -f $@ $@.bottom $(srcdir)/runlex.sh $(LEX) -o$@ $< + mv $@ $@.bottom + cat $@.top $@.bottom > $@ scanner.o: scanner.c tokdefs.h $(CC) $(FULL_CFLAGS) -c scanner.c @@@ -732,6 -732,10 +733,6 @@@ distclean: clea tags: $(TAGFILES) ctags -wtd $(TAGFILES) -packaging/pcap.spec: packaging/pcap.spec.in VERSION - RPMVERSION=`cat VERSION | sed s/-.*//g`; \ - sed -e s/@VERSION@/$$RPMVERSION/ -e s/@NAME@/libpcap-`cat VERSION`/ $< > $@ - releasetar: @cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \ mkdir $$name; \ diff --combined configure index 1a800f57,464fd28d..1a391448 --- a/configure +++ b/configure @@@ -745,7 -745,6 +745,7 @@@ with_fle with_bison enable_universal enable_shared +enable_usb enable_bluetooth enable_canusb enable_can @@@ -1381,8 -1380,6 +1381,8 @@@ Optional Features --disable-universal don't build universal on OS X --enable-shared build shared libraries [default=yes, if support available] + --enable-usb enable nusb support [default=yes, if support + available] --enable-bluetooth enable Bluetooth support [default=yes, if support available] --enable-canusb enable canusb support [default=yes, if support @@@ -5515,6 -5512,13 +5515,13 @@@ f if test x$with_libnl != xno ; then have_any_nl="no" + incdir=-I/usr/include/libnl3 + libnldir= + if test x$withval != x ; then + libnldir=-L${withval}/lib/.libs + incdir=-I${withval}/include + fi + # # Try libnl 3.x first. # @@@ -5524,7 -5528,7 +5531,7 @@@ if ${ac_cv_lib_nl_3_nl_socket_alloc+:} $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS - LIBS="-lnl-3 $LIBS" + LIBS="-lnl-3 ${incdir} ${libnldir} -lnl-genl-3 -lnl-3 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@@ -5559,7 -5563,7 +5566,7 @@@ if test "x$ac_cv_lib_nl_3_nl_socket_all # # Yes, we have libnl 3.x. # - LIBS="-lnl-genl-3 -lnl-3 $LIBS" + LIBS="${libnldir} -lnl-genl-3 -lnl-3 $LIBS" $as_echo "#define HAVE_LIBNL 1" >>confdefs.h @@@ -5572,7 -5576,7 +5579,7 @@@ $as_echo "#define HAVE_LIBNL_NLE 1" >>c $as_echo "#define HAVE_LIBNL_SOCKETS 1" >>confdefs.h - V_INCLS="$V_INCLS -I/usr/include/libnl3" + V_INCLS="$V_INCLS ${incdir}" have_any_nl="yes" fi @@@ -5623,7 -5627,7 +5630,7 @@@ if test "x$ac_cv_lib_nl_nl_socket_alloc # # Yes, we have libnl 2.x. # - LIBS="-lnl-genl -lnl $LIBS" + LIBS="${libnldir} -lnl-genl -lnl $LIBS" $as_echo "#define HAVE_LIBNL 1" >>confdefs.h @@@ -5687,7 -5691,7 +5694,7 @@@ if test "x$ac_cv_lib_nl_nl_handle_alloc # # Yes. # - LIBS="-lnl $LIBS" + LIBS="${libnldir} -lnl $LIBS" $as_echo "#define HAVE_LIBNL 1" >>confdefs.h @@@ -7810,19 -7814,10 +7817,19 @@@ ln -s ${srcdir}/bpf/net ne -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for USB sniffing support" >&5 +# Check whether --enable-usb was given. +if test "${enable_usb+set}" = set; then : + enableval=$enable_usb; +else + enable_usb=yes +fi + + +if test "x$enable_usb" != "xno" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for USB sniffing support" >&5 $as_echo_n "checking for USB sniffing support... " >&6; } -case "$host_os" in -linux*) + case "$host_os" in + linux*) $as_echo "#define PCAP_SUPPORT_USB 1" >>confdefs.h @@@ -7935,12 -7930,11 +7942,12 @@@ $as_echo "#define HAVE_USBDEVFS_CTRLTRA fi fi ;; -*) + *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac +fi @@@ -8296,35 -8290,23 +8303,35 @@@ if test "x$enable_dbus" != "xno"; the case "$host_os" in darwin*) + # + # We don't support D-Bus sniffing on OS X; see # # https://bugs.freedesktop.org/show_bug.cgi?id=74029 # + # The user requested it, so fail. + # as_fn_error $? "Due to freedesktop.org bug 74029, D-Bus capture support is not available on OS X" "$LINENO" 5 - ;; esac else case "$host_os" in darwin*) + # + # We don't support D-Bus sniffing on OS X; see # # https://bugs.freedesktop.org/show_bug.cgi?id=74029 # + # The user dind't explicitly request it, so just + # silently refuse to enable it. + # + enable_dbus="no" ;; + esac + fi +fi - *) - # Extract the first word of "pkg-config", so it can be a program name with args. +if test "x$enable_dbus" != "xno"; then + # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } @@@ -8362,28 -8344,28 +8369,28 @@@ $as_echo "no" >&6; fi - if test "x$PKGCONFIG" != "xno"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for D-Bus" >&5 + if test "x$PKGCONFIG" != "xno"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for D-Bus" >&5 $as_echo_n "checking for D-Bus... " >&6; } - if "$PKGCONFIG" dbus-1; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + if "$PKGCONFIG" dbus-1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1` - DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1` - save_CFLAGS="$CFLAGS" - save_LIBS="$LIBS" - CFLAGS="$CFLAGS $DBUS_CFLAGS" - LIBS="$LIBS $DBUS_LIBS" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the D-Bus library defines dbus_connection_read_write" >&5 + DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1` + DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1` + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + CFLAGS="$CFLAGS $DBUS_CFLAGS" + LIBS="$LIBS $DBUS_LIBS" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the D-Bus library defines dbus_connection_read_write" >&5 $as_echo_n "checking whether the D-Bus library defines dbus_connection_read_write... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - #include - #include + #include + #include - #include + #include int main () { @@@ -8394,34 -8376,37 +8401,34 @@@ return dbus_connection_read_write(NULL _ACEOF if ac_fn_c_try_link "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define PCAP_SUPPORT_DBUS 1" >>confdefs.h - DBUS_SRC=pcap-dbus.c - V_INCLS="$V_INCLS $DBUS_CFLAGS" + DBUS_SRC=pcap-dbus.c + V_INCLS="$V_INCLS $DBUS_CFLAGS" else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - if test "x$enable_dbus" = "xyes"; then - as_fn_error $? "--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()" "$LINENO" 5 - fi - LIBS="$save_LIBS" + if test "x$enable_dbus" = "xyes"; then + as_fn_error $? "--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()" "$LINENO" 5 + fi + LIBS="$save_LIBS" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - CFLAGS="$save_CFLAGS" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + CFLAGS="$save_CFLAGS" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - if test "x$enable_dbus" = "xyes"; then - as_fn_error $? "--enable-dbus was given, but the dbus-1 package is not installed" "$LINENO" 5 - fi - fi + if test "x$enable_dbus" = "xyes"; then + as_fn_error $? "--enable-dbus was given, but the dbus-1 package is not installed" "$LINENO" 5 fi - ;; - esac + fi fi diff --combined configure.in index 55cfadae,19b748ec..7ddd7d31 --- a/configure.in +++ b/configure.in @@@ -360,11 -360,11 +360,11 @@@ dlpi # # Checks to see if Solaris has the public libdlpi(3LIB) library. # Note: The existence of /usr/include/libdlpi.h does not mean it is the - # public libdlpi(3LIB) version. Before libdlpi was made public, a - # private version also existed, which did not have the same APIs. + # public libdlpi(3LIB) version. Before libdlpi was made public, a + # private version also existed, which did not have the same APIs. # Due to a gcc bug, the default search path for 32-bit libraries does # not include /lib, we add it explicitly here. - # [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485]. + # [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485]. # Also, due to the bug above applications that link to libpcap with # libdlpi will have to add "-L/lib" option to "configure". # @@@ -446,6 -446,13 +446,13 @@@ linux if test x$with_libnl != xno ; then have_any_nl="no" + incdir=-I/usr/include/libnl3 + libnldir= + if test x$withval != x ; then + libnldir=-L${withval}/lib/.libs + incdir=-I${withval}/include + fi + # # Try libnl 3.x first. # @@@ -454,13 -461,14 +461,14 @@@ # # Yes, we have libnl 3.x. # - LIBS="-lnl-genl-3 -lnl-3 $LIBS" + LIBS="${libnldir} -lnl-genl-3 -lnl-3 $LIBS" AC_DEFINE(HAVE_LIBNL,1,[if libnl exists]) AC_DEFINE(HAVE_LIBNL_3_x,1,[if libnl exists and is version 3.x]) AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE]) AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api]) + V_INCLS="$V_INCLS ${incdir}" have_any_nl="yes" - ]) + ],[], ${incdir} ${libnldir} -lnl-genl-3 -lnl-3 ) if test x$have_any_nl = xno ; then # @@@ -471,7 -479,7 +479,7 @@@ # # Yes, we have libnl 2.x. # - LIBS="-lnl-genl -lnl $LIBS" + LIBS="${libnldir} -lnl-genl -lnl $LIBS" AC_DEFINE(HAVE_LIBNL,1,[if libnl exists]) AC_DEFINE(HAVE_LIBNL_2_x,1,[if libnl exists and is version 2.x]) AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE]) @@@ -489,7 -497,7 +497,7 @@@ # # Yes. # - LIBS="-lnl $LIBS" + LIBS="${libnldir} -lnl $LIBS" AC_DEFINE(HAVE_LIBNL,1,[if libnl exists]) have_any_nl="yes" ]) @@@ -527,7 -535,7 +535,7 @@@ bpf #include #include ], [return (BIOCROTZBUF + BPF_BUFMODE_ZBUF);], - [ + [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_ZEROCOPY_BPF, 1, [define if the system supports zerocopy BPF]) @@@ -775,7 -783,7 +783,7 @@@ if test "$want_dag" != no; the if test -z "$dag_lib_dir"; then dag_lib_dir="$dag_root/lib" fi - + if test -z "$dag_tools_dir"; then dag_tools_dir="$dag_root/tools" fi @@@ -810,7 -818,7 +818,7 @@@ if test $ac_cv_lbl_dag_api = yes; the AC_DEFINE(HAVE_DAG_STREAMS_API, 1, [define if you have streams capable DAG API]) LIBS="$LIBS -ldag" LDFLAGS="$LDFLAGS -L$dag_lib_dir" - + AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"]) if test "$ac_dag_have_vdag" = 1; then AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()]) @@@ -1347,16 -1355,10 +1355,16 @@@ AC_SUBST(DYEXT AC_SUBST(MAN_FILE_FORMATS) AC_SUBST(MAN_MISC_INFO) -dnl check for USB sniffing support -AC_MSG_CHECKING(for USB sniffing support) -case "$host_os" in -linux*) +AC_ARG_ENABLE([usb], +[AC_HELP_STRING([--enable-usb],[enable nusb support @<:@default=yes, if support available@:>@])], + [], + [enable_usb=yes]) + +if test "x$enable_usb" != "xno" ; then + dnl check for USB sniffing support + AC_MSG_CHECKING(for USB sniffing support) + case "$host_os" in + linux*) AC_DEFINE(PCAP_SUPPORT_USB, 1, [target host supports USB sniffing]) USB_SRC=pcap-usb-linux.c AC_MSG_RESULT(yes) @@@ -1407,11 -1409,10 +1415,11 @@@ AC_INCLUDES_DEFAUL fi fi ;; -*) + *) AC_MSG_RESULT(no) ;; esac +fi AC_SUBST(PCAP_SUPPORT_USB) AC_SUBST(USB_SRC) @@@ -1545,7 -1546,7 +1553,7 @@@ AC_ARG_ENABLE([canusb] if test "x$enable_canusb" != "xno" ; then dnl check for canusb support case "$host_os" in - linux*) + linux*|uclinux*) AC_CHECK_HEADER(libusb-1.0/libusb.h, [ AC_CHECK_LIB(usb-1.0, libusb_init, @@@ -1555,8 -1556,7 +1563,8 @@@ LIBS="-lusb-1.0 -lpthread $LIBS" ac_lbl_has_libusb=yes ], - ac_lbl_has_libusb=no + ac_lbl_has_libusb=no, + -lpthread ) ], ac_lbl_has_libusb=no @@@ -1630,74 -1630,65 +1638,74 @@@ if test "x$enable_dbus" != "xno"; the case "$host_os" in darwin*) + # + # We don't support D-Bus sniffing on OS X; see # # https://bugs.freedesktop.org/show_bug.cgi?id=74029 # + # The user requested it, so fail. + # AC_MSG_ERROR([Due to freedesktop.org bug 74029, D-Bus capture support is not available on OS X]) - ;; esac -- else ++ else case "$host_os" in darwin*) + # + # We don't support D-Bus sniffing on OS X; see # # https://bugs.freedesktop.org/show_bug.cgi?id=74029 # + # The user dind't explicitly request it, so just + # silently refuse to enable it. + # + enable_dbus="no" ;; + esac + fi +fi - *) - AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no]) - if test "x$PKGCONFIG" != "xno"; then - AC_MSG_CHECKING([for D-Bus]) - if "$PKGCONFIG" dbus-1; then - AC_MSG_RESULT([yes]) - DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1` - DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1` - save_CFLAGS="$CFLAGS" - save_LIBS="$LIBS" - CFLAGS="$CFLAGS $DBUS_CFLAGS" - LIBS="$LIBS $DBUS_LIBS" - AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write) - AC_TRY_LINK( - [#include - - #include - #include - - #include ], - [return dbus_connection_read_write(NULL, 0);], - [ - AC_MSG_RESULT([yes]) - AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing]) - DBUS_SRC=pcap-dbus.c - V_INCLS="$V_INCLS $DBUS_CFLAGS" - ], - [ - AC_MSG_RESULT([no]) - if test "x$enable_dbus" = "xyes"; then - AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()]) - fi - LIBS="$save_LIBS" - ]) - CFLAGS="$save_CFLAGS" - else - AC_MSG_RESULT([no]) - if test "x$enable_dbus" = "xyes"; then - AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed]) - fi +if test "x$enable_dbus" != "xno"; then + AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no]) + if test "x$PKGCONFIG" != "xno"; then + AC_MSG_CHECKING([for D-Bus]) + if "$PKGCONFIG" dbus-1; then + AC_MSG_RESULT([yes]) + DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1` + DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1` + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + CFLAGS="$CFLAGS $DBUS_CFLAGS" + LIBS="$LIBS $DBUS_LIBS" + AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write) + AC_TRY_LINK( + [#include + + #include + #include + + #include ], + [return dbus_connection_read_write(NULL, 0);], + [ + AC_MSG_RESULT([yes]) + AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing]) + DBUS_SRC=pcap-dbus.c + V_INCLS="$V_INCLS $DBUS_CFLAGS" + ], + [ + AC_MSG_RESULT([no]) + if test "x$enable_dbus" = "xyes"; then + AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()]) fi + LIBS="$save_LIBS" + ]) + CFLAGS="$save_CFLAGS" + else + AC_MSG_RESULT([no]) + if test "x$enable_dbus" = "xyes"; then + AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed]) fi - ;; - esac + fi fi AC_SUBST(PCAP_SUPPORT_DBUS) AC_SUBST(DBUS_SRC) @@@ -1713,24 -1704,6 +1721,24 @@@ linux* ;; esac +dnl The packet ring capture facility of Linux, described in +dnl Documentation/networking/packet_mmap.txt, is not 32/64-bit compatible before +dnl version 2.6.27. A 32-bit kernel requires a 32-bit userland, and likewise for +dnl 64-bit. The effect of this is that a 32-bit libpcap binary will not run +dnl correctly on a 64-bit kernel (the binary will use the wrong offsets into a +dnl kernel struct). This problem was solved in Linux 2.6.27. Use +dnl --disable-packet-ring whenever a 32-bit application must run on a 64-bit +dnl target host, and either the build host or the target host run Linux 2.6.26 +dnl or earlier. +AC_ARG_ENABLE([packet-ring], +[AC_HELP_STRING([--enable-packet-ring],[enable Linux packet ring support @<:@default=yes@:>@])], +,enable_packet_ring=yes) + +if test "x$enable_packet_ring" != "xno" ; then + AC_DEFINE(PCAP_SUPPORT_PACKET_RING, 1, [use Linux packet ring capture if available]) + AC_SUBST(PCAP_SUPPORT_PACKET_RING) +fi + AC_PROG_INSTALL AC_CONFIG_HEADER(config.h)