]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
Bluetooth: Add store_hint parameter to mgmt_new_key
authorJohan Hedberg <johan.hedberg@nokia.com>
Thu, 28 Apr 2011 18:29:03 +0000 (11:29 -0700)
committerGustavo F. Padovan <padovan@profusion.mobi>
Thu, 28 Apr 2011 19:14:43 +0000 (16:14 -0300)
Even for keys that shouldn't be stored some use cases require the
knowledge of a new key having been created so that the conclusion of a
successful pairing can be made. Therefore, always send the mgmt_new_key
event but add a store_hint parameter to it to indicate to user space
whether the key should be stored or not.

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_core.c
net/bluetooth/mgmt.c

index 88c2cd92eaeae85c0d573f0a91f4d86a068862fa..14cc3249c1eb04725f7820c32a5dae0c2565b317 100644 (file)
@@ -775,7 +775,7 @@ int mgmt_index_removed(u16 index);
 int mgmt_powered(u16 index, u8 powered);
 int mgmt_discoverable(u16 index, u8 discoverable);
 int mgmt_connectable(u16 index, u8 connectable);
-int mgmt_new_key(u16 index, struct link_key *key);
+int mgmt_new_key(u16 index, struct link_key *key, u8 persistent);
 int mgmt_connected(u16 index, bdaddr_t *bdaddr);
 int mgmt_disconnected(u16 index, bdaddr_t *bdaddr);
 int mgmt_disconnect_failed(u16 index);
index 353a85dc2de0d5088086fe01742fafd87b7978bb..4899286ed4e4a4ff9e20180675d618de8e0f7d62 100644 (file)
@@ -230,6 +230,7 @@ struct mgmt_ev_controller_error {
 
 #define MGMT_EV_NEW_KEY                        0x000A
 struct mgmt_ev_new_key {
+       __u8 store_hint;
        struct mgmt_key_info key;
 } __packed;
 
index 60260cae3a04edae4b5ff5a35a0e7cfa231718b7..b6bda3fac10e2a0f821e37a76d60b509e770cf59 100644 (file)
@@ -1062,7 +1062,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
                                bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len)
 {
        struct link_key *key, *old_key;
-       u8 old_key_type;
+       u8 old_key_type, persistent;
 
        old_key = hci_find_link_key(hdev, bdaddr);
        if (old_key) {
@@ -1089,12 +1089,6 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
                        conn->key_type = type;
        }
 
-       if (new_key && !hci_persistent_key(hdev, conn, type, old_key_type)) {
-               list_del(&key->list);
-               kfree(key);
-               return 0;
-       }
-
        bacpy(&key->bdaddr, bdaddr);
        memcpy(key->val, val, 16);
        key->pin_len = pin_len;
@@ -1104,8 +1098,17 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
        else
                key->type = type;
 
-       if (new_key)
-               mgmt_new_key(hdev->id, key);
+       if (!new_key)
+               return 0;
+
+       persistent = hci_persistent_key(hdev, conn, type, old_key_type);
+
+       mgmt_new_key(hdev->id, key, persistent);
+
+       if (!persistent) {
+               list_del(&key->list);
+               kfree(key);
+       }
 
        return 0;
 }
index 232ea8bfff19f771b9ec4df93120c665df8419b6..2481d257ed98058c644f5553bf41132a5793dba7 100644 (file)
@@ -1858,12 +1858,13 @@ int mgmt_connectable(u16 index, u8 connectable)
        return ret;
 }
 
-int mgmt_new_key(u16 index, struct link_key *key)
+int mgmt_new_key(u16 index, struct link_key *key, u8 persistent)
 {
        struct mgmt_ev_new_key ev;
 
        memset(&ev, 0, sizeof(ev));
 
+       ev.store_hint = persistent;
        bacpy(&ev.key.bdaddr, &key->bdaddr);
        ev.key.type = key->type;
        memcpy(ev.key.val, key->val, 16);