]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
Bluetooth: Add discovering event to the Management interface
authorJohan Hedberg <johan.hedberg@nokia.com>
Wed, 27 Apr 2011 14:29:57 +0000 (10:29 -0400)
committerGustavo F. Padovan <padovan@profusion.mobi>
Thu, 28 Apr 2011 04:10:04 +0000 (01:10 -0300)
This patch adds a new event to the Management interface to track when
local adapters are discovering remote devices. For now this only tracks
BR/EDR discovery procedures.

Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
Signed-off-by: Anderson Briglia <anderson.briglia@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
include/net/bluetooth/hci_core.h
include/net/bluetooth/mgmt.h
net/bluetooth/hci_event.c
net/bluetooth/mgmt.c

index 4093133c1283f28285559fd674773ae9336620ce..69967e540c96187971b6372c562744843c6112ce 100644 (file)
@@ -790,6 +790,7 @@ int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer,
 int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi,
                                                                u8 *eir);
 int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name);
+int mgmt_discovering(u16 index, u8 discovering);
 
 /* HCI info for socket */
 #define hci_pi(sk) ((struct hci_pinfo *) sk)
index be93dd0eb962e31149e8795e906c6c18db0478ff..7434406153498518530ba9280dd8e5a237c48fbc 100644 (file)
@@ -285,3 +285,5 @@ struct mgmt_ev_remote_name {
        bdaddr_t bdaddr;
        __u8 name[MGMT_MAX_NAME_LENGTH];
 } __packed;
+
+#define MGMT_EV_DISCOVERING            0x0014
index cb25628c0583fc35e55fb351143724b8354cb462..e64a3de70d777e0e6e026961436cce511d2ef491 100644 (file)
@@ -56,7 +56,9 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb)
        if (status)
                return;
 
-       clear_bit(HCI_INQUIRY, &hdev->flags);
+       if (test_bit(HCI_MGMT, &hdev->flags) &&
+                               test_and_clear_bit(HCI_INQUIRY, &hdev->flags))
+               mgmt_discovering(hdev->id, 0);
 
        hci_req_complete(hdev, HCI_OP_INQUIRY_CANCEL, status);
 
@@ -72,7 +74,9 @@ static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
        if (status)
                return;
 
-       clear_bit(HCI_INQUIRY, &hdev->flags);
+       if (test_bit(HCI_MGMT, &hdev->flags) &&
+                               test_and_clear_bit(HCI_INQUIRY, &hdev->flags))
+               mgmt_discovering(hdev->id, 0);
 
        hci_conn_check_pending(hdev);
 }
@@ -841,10 +845,14 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
 
        if (status) {
                hci_req_complete(hdev, HCI_OP_INQUIRY, status);
-
                hci_conn_check_pending(hdev);
-       } else
-               set_bit(HCI_INQUIRY, &hdev->flags);
+               return;
+       }
+
+       if (test_bit(HCI_MGMT, &hdev->flags) &&
+                                       !test_and_set_bit(HCI_INQUIRY,
+                                                       &hdev->flags))
+               mgmt_discovering(hdev->id, 1);
 }
 
 static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status)
@@ -1208,7 +1216,9 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff
 
        BT_DBG("%s status %d", hdev->name, status);
 
-       clear_bit(HCI_INQUIRY, &hdev->flags);
+       if (test_bit(HCI_MGMT, &hdev->flags) &&
+                               test_and_clear_bit(HCI_INQUIRY, &hdev->flags))
+               mgmt_discovering(hdev->id, 0);
 
        hci_req_complete(hdev, HCI_OP_INQUIRY, status);
 
@@ -1228,6 +1238,12 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *
 
        hci_dev_lock(hdev);
 
+       if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags)) {
+
+               if (test_bit(HCI_MGMT, &hdev->flags))
+                       mgmt_discovering(hdev->id, 1);
+       }
+
        for (; num_rsp; num_rsp--, info++) {
                bacpy(&data.bdaddr, &info->bdaddr);
                data.pscan_rep_mode     = info->pscan_rep_mode;
@@ -2158,6 +2174,12 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct
 
        hci_dev_lock(hdev);
 
+       if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags)) {
+
+               if (test_bit(HCI_MGMT, &hdev->flags))
+                       mgmt_discovering(hdev->id, 1);
+       }
+
        if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) {
                struct inquiry_info_with_rssi_and_pscan_mode *info;
                info = (void *) (skb->data + 1);
@@ -2320,6 +2342,12 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct
        if (!num_rsp)
                return;
 
+       if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags)) {
+
+               if (test_bit(HCI_MGMT, &hdev->flags))
+                       mgmt_discovering(hdev->id, 1);
+       }
+
        hci_dev_lock(hdev);
 
        for (; num_rsp; num_rsp--, info++) {
index dbc248f27b1b95de7291697f2514d82f879a7435..4542396fc856e269017dfa53fe7da66c3e829285 100644 (file)
@@ -2149,3 +2149,9 @@ int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name)
 
        return mgmt_event(MGMT_EV_REMOTE_NAME, index, &ev, sizeof(ev), NULL);
 }
+
+int mgmt_discovering(u16 index, u8 discovering)
+{
+       return mgmt_event(MGMT_EV_DISCOVERING, index, &discovering,
+                                               sizeof(discovering), NULL);
+}