Bluetooth: Add mgmt_remote_name event
authorJohan Hedberg <johan.hedberg@nokia.com>
Wed, 30 Mar 2011 10:18:12 +0000 (13:18 +0300)
committerGustavo F. Padovan <padovan@profusion.mobi>
Mon, 4 Apr 2011 21:47:38 +0000 (18:47 -0300)
This patch adds a new remote_name event to the Management interface
which is sent every time the name of a remote device is resolved (over
BR/EDR).

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 2a88fc82429b4b03774b8086de3bfc494f5648b3..4093133c1283f28285559fd674773ae9336620ce 100644 (file)
@@ -789,6 +789,7 @@ int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer,
                                                                u8 status);
 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);
 
 /* HCI info for socket */
 #define hci_pi(sk) ((struct hci_pinfo *) sk)
index 864d0cbd2d574966142da9ee9d603f05521c3aa5..6b6ff92ab499d9656283b0f8cb993d22eec9c158 100644 (file)
@@ -275,3 +275,9 @@ struct mgmt_ev_device_found {
        __s8 rssi;
        __u8 eir[HCI_MAX_EIR_LENGTH];
 } __packed;
+
+#define MGMT_EV_REMOTE_NAME            0x0013
+struct mgmt_ev_remote_name {
+       bdaddr_t bdaddr;
+       __u8 name[MGMT_MAX_NAME_LENGTH];
+} __packed;
index d04011c06be006a3c9c2a321b78c7cbfbbb0eb35..7a3398d9cd65d45ec99a3e31b564e9c15145d39d 100644 (file)
@@ -1497,6 +1497,9 @@ static inline void hci_remote_name_evt(struct hci_dev *hdev, struct sk_buff *skb
 
        hci_dev_lock(hdev);
 
+       if (ev->status == 0 && test_bit(HCI_MGMT, &hdev->flags))
+               mgmt_remote_name(hdev->id, &ev->bdaddr, ev->name);
+
        conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
        if (conn && hci_outgoing_auth_needed(hdev, conn)) {
                struct hci_cp_auth_requested cp;
index 86fb502154852a190dbac5015ef0f5e5648fd4ed..9a61320c5f2e191fd2124c96d13b1b4de44414d6 100644 (file)
@@ -2063,3 +2063,15 @@ int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi,
 
        return mgmt_event(MGMT_EV_DEVICE_FOUND, index, &ev, sizeof(ev), NULL);
 }
+
+int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name)
+{
+       struct mgmt_ev_remote_name ev;
+
+       memset(&ev, 0, sizeof(ev));
+
+       bacpy(&ev.bdaddr, bdaddr);
+       memcpy(ev.name, name, HCI_MAX_NAME_LENGTH);
+
+       return mgmt_event(MGMT_EV_REMOTE_NAME, index, &ev, sizeof(ev), NULL);
+}