]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
Bluetooth: Add support for connect failed management event
authorJohan Hedberg <johan.hedberg@nokia.com>
Sat, 22 Jan 2011 04:09:08 +0000 (06:09 +0200)
committerGustavo F. Padovan <padovan@profusion.mobi>
Tue, 8 Feb 2011 03:40:07 +0000 (01:40 -0200)
This patch add a new connect failed management event to track failures
in connecting to remote devices. It is particularly useful for security
mode 3 scenarios when we don't have a connected state while pairing but
still need to detect when the connect attempt failed.

Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
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 2197a099a2b7e282e2a616e093b65d69b187823f..45caae62cb8e8e077d6941389cce72672e1bef17 100644 (file)
@@ -717,6 +717,7 @@ int mgmt_new_key(u16 index, struct link_key *key, u8 old_key_type);
 int mgmt_connected(u16 index, bdaddr_t *bdaddr);
 int mgmt_disconnected(u16 index, bdaddr_t *bdaddr);
 int mgmt_disconnect_failed(u16 index);
+int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status);
 
 /* HCI info for socket */
 #define hci_pi(sk) ((struct hci_pinfo *) sk)
index 2c47601b6e63c4e1bd5c21d60073caf92d57c8d1..1d822f2c0f1a8bdb5e803f20330f014a3b62f4cf 100644 (file)
@@ -184,3 +184,10 @@ struct mgmt_ev_disconnected {
        __le16 index;
        bdaddr_t bdaddr;
 } __packed;
+
+#define MGMT_EV_CONNECT_FAILED         0x000D
+struct mgmt_ev_connect_failed {
+       __le16 index;
+       bdaddr_t bdaddr;
+       __u8 status;
+} __packed;
index 335c60bad96c24055d2ab0439e1ccc59121cf9fa..995ae6c17f119708465549471fac6e42d9d1eeee 100644 (file)
@@ -1166,8 +1166,11 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
                        hci_send_cmd(hdev, HCI_OP_CHANGE_CONN_PTYPE,
                                                        sizeof(cp), &cp);
                }
-       } else
+       } else {
                conn->state = BT_CLOSED;
+               if (conn->type == ACL_LINK)
+                       mgmt_connect_failed(hdev->id, &ev->bdaddr, ev->status);
+       }
 
        if (conn->type == ACL_LINK)
                hci_sco_setup(conn, ev->status);
index 48f266a64caf9edc3d1e938380cc7223e9b3b460..9fb989f4216ee88326a65c59972ded8166846b92 100644 (file)
@@ -1227,3 +1227,14 @@ int mgmt_disconnect_failed(u16 index)
 
        return err;
 }
+
+int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status)
+{
+       struct mgmt_ev_connect_failed ev;
+
+       put_unaligned_le16(index, &ev.index);
+       bacpy(&ev.bdaddr, bdaddr);
+       ev.status = status;
+
+       return mgmt_event(MGMT_EV_CONNECT_FAILED, &ev, sizeof(ev), NULL);
+}