diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-02-18 15:46:51 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-02-18 15:46:51 -0800 |
commit | 2e6705b7b7fb136baff1dc67bfb18c567fc2011c (patch) | |
tree | aaf80d5a718032023b1a0206d25bce54ffe6909e | |
parent | 46d4fb19ef6ef55d80cb92428951011bd41add32 (diff) |
Check for HCI_CHANNEL_MONITOR for Linux Bluetooth Monitor support.
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.
-rw-r--r-- | config.h.in | 3 | ||||
-rwxr-xr-x | configure | 40 | ||||
-rw-r--r-- | configure.in | 21 | ||||
-rw-r--r-- | pcap-bt-monitor-linux.c | 3 | ||||
-rw-r--r-- | pcap.c | 9 |
5 files changed, 66 insertions, 10 deletions
diff --git a/config.h.in b/config.h.in index c6bc68eb..4bbb491e 100644 --- a/config.h.in +++ b/config.h.in @@ -256,6 +256,9 @@ /* 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 @@ -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 diff --git a/configure.in b/configure.in index 78ae5625..670ba26b 100644 --- a/configure.in +++ b/configure.in @@ -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) diff --git a/pcap-bt-monitor-linux.c b/pcap-bt-monitor-linux.c index c96378d0..76c9ee34 100644 --- a/pcap-bt-monitor-linux.c +++ b/pcap-bt-monitor-linux.c @@ -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 @@ -86,13 +86,12 @@ #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 |