]> The Tcpdump Group git mirrors - libpcap/commitdiff
Check for HCI_CHANNEL_MONITOR for Linux Bluetooth Monitor support.
authorGuy Harris <[email protected]>
Tue, 18 Feb 2014 23:46:51 +0000 (15:46 -0800)
committerGuy Harris <[email protected]>
Tue, 18 Feb 2014 23:46:51 +0000 (15:46 -0800)
Support the Linux Bluetooth Monitor mechanism if:

we support Linux Bluetooth;

struct sockaddr_hci includes an hci_channel field;

HCI_CHANNEL_MONITOR is defined by the Bluetooth headers;

as there are some 3.x kernel versions in which struct sockaddr_hci
includes an hci_channel field but in which HCI_CHANNEL_MONITOR is not
defined.

config.h.in
configure
configure.in
pcap-bt-monitor-linux.c
pcap.c

index c6bc68eb2a6f030fbe45204d6c87f623a344ff29..4bbb491ec1680c6943507274f371672ba45667b8 100644 (file)
 /* target host supports Bluetooth sniffing */
 #undef PCAP_SUPPORT_BT
 
+/* target host supports Bluetooth Monitor */
+#undef PCAP_SUPPORT_BT_MONITOR
+
 /* target host supports CAN sniffing */
 #undef PCAP_SUPPORT_CAN
 
index 559b7f27a24857a467518f0fea683f047c71b6bb..d4b054d5d58366cdbd621dfe05f63b4c23ef7515 100755 (executable)
--- a/configure
+++ b/configure
@@ -8014,7 +8014,6 @@ if test "x$ac_cv_header_bluetooth_bluetooth_h" = xyes; then :
 $as_echo "#define PCAP_SUPPORT_BT 1" >>confdefs.h
 
                  BT_SRC=pcap-bt-linux.c
-                 BT_MONITOR_SRC=pcap-bt-monitor-linux.c
                  { $as_echo "$as_me:${as_lineno-$LINENO}: Bluetooth sniffing is supported" >&5
 $as_echo "$as_me: Bluetooth sniffing is supported" >&6;}
 
@@ -8055,6 +8054,45 @@ $as_echo "$ac_cv_lbl_sockaddr_hci_has_hci_channel" >&6; }
 
 $as_echo "#define SOCKADDR_HCI_HAS_HCI_CHANNEL /**/" >>confdefs.h
 
+
+                     #
+                     # OK, is HCI_CHANNEL_MONITOR defined?
+                     #
+                     { $as_echo "$as_me:${as_lineno-$LINENO}: checking if HCI_CHANNEL_MONITOR is defined" >&5
+$as_echo_n "checking if HCI_CHANNEL_MONITOR is defined... " >&6; }
+                     if ${ac_cv_lbl_hci_channel_monitor_is_defined+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/hci.h>
+
+int
+main ()
+{
+u_int i = HCI_CHANNEL_MONITOR
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_lbl_hci_channel_monitor_is_defined=yes
+else
+  ac_cv_lbl_hci_channel_monitor_is_defined=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+                     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_hci_channel_monitor_is_defined" >&5
+$as_echo "$ac_cv_lbl_hci_channel_monitor_is_defined" >&6; }
+                     if test $ac_cv_lbl_hci_channel_monitor_is_defined = yes ; then
+
+$as_echo "#define PCAP_SUPPORT_BT_MONITOR /**/" >>confdefs.h
+
+                       BT_MONITOR_SRC=pcap-bt-monitor-linux.c
+                     fi
                    fi
 
 else
index 78ae5625d73b5850942904df377a9df65f7bcaf0..670ba26badd0ea223b8d10b1f2069b54308f9f9c 100644 (file)
@@ -1465,7 +1465,6 @@ if test "x$enable_bluetooth" != "xno" ; then
                [
                  AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
                  BT_SRC=pcap-bt-linux.c
-                 BT_MONITOR_SRC=pcap-bt-monitor-linux.c
                  AC_MSG_NOTICE(Bluetooth sniffing is supported)
 
                  #
@@ -1486,6 +1485,26 @@ if test "x$enable_bluetooth" != "xno" ; then
                    if test $ac_cv_lbl_sockaddr_hci_has_hci_channel = yes ; then
                      AC_DEFINE(SOCKADDR_HCI_HAS_HCI_CHANNEL,,
                        [if struct sockaddr_hci has hci_channel member])
+
+                     #
+                     # OK, is HCI_CHANNEL_MONITOR defined?
+                     #
+                     AC_MSG_CHECKING(if HCI_CHANNEL_MONITOR is defined)
+                     AC_CACHE_VAL(ac_cv_lbl_hci_channel_monitor_is_defined,
+                     AC_TRY_COMPILE(
+[
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/hci.h>
+],
+                       [u_int i = HCI_CHANNEL_MONITOR],
+                       ac_cv_lbl_hci_channel_monitor_is_defined=yes,
+                       ac_cv_lbl_hci_channel_monitor_is_defined=no))
+                     AC_MSG_RESULT($ac_cv_lbl_hci_channel_monitor_is_defined)
+                     if test $ac_cv_lbl_hci_channel_monitor_is_defined = yes ; then
+                       AC_DEFINE(PCAP_SUPPORT_BT_MONITOR,,
+                         [target host supports Bluetooth Monitor])
+                       BT_MONITOR_SRC=pcap-bt-monitor-linux.c
+                     fi
                    fi
                ],
                AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
index c96378d0b249f33f14d84b3f0745b4ac51739c68..76c9ee34a4e1d89dfcd05cf262070111805bfc9b 100644 (file)
@@ -33,8 +33,6 @@
 #include "config.h"
 #endif
 
-#ifdef SOCKADDR_HCI_HAS_HCI_CHANNEL
-
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
@@ -241,4 +239,3 @@ bt_monitor_create(const char *device, char *ebuf, int *is_ours)
 
     return p;
 }
-#endif /* SOCKADDR_HCI_HAS_HCI_CHANNEL */
\ No newline at end of file
diff --git a/pcap.c b/pcap.c
index 9010d34c52039ec2efd891ccb0530737037419d1..f8292895ae6d8e6ef10074f4f3a97fee0c2c126d 100644 (file)
--- a/pcap.c
+++ b/pcap.c
 
 #ifdef PCAP_SUPPORT_BT
 #include "pcap-bt-linux.h"
+#endif
 
-#ifdef SOCKADDR_HCI_HAS_HCI_CHANNEL
+#ifdef PCAP_SUPPORT_BT_MONITOR
 #include "pcap-bt-monitor-linux.h"
 #endif
 
-#endif /* PCAP_SUPPORT_BT */
-
 #ifdef PCAP_SUPPORT_CAN
 #include "pcap-can-linux.h"
 #endif
@@ -323,10 +322,10 @@ struct capture_source_type {
 #endif
 #ifdef PCAP_SUPPORT_BT
        { bt_findalldevs, bt_create },
-#ifdef SOCKADDR_HCI_HAS_HCI_CHANNEL
+#endif
+#ifdef PCAP_SUPPORT_BT_MONITOR
        { bt_monitor_findalldevs, bt_monitor_create },
 #endif
-#endif /* PCAP_SUPPORT_BT */
 #if PCAP_SUPPORT_CANUSB
        { canusb_findalldevs, canusb_create },
 #endif