提交 745c0ce3 编写于 作者: V Vishal Agarwal 提交者: Johan Hedberg

Bluetooth: hci_persistent_key should return bool

This patch changes the return type of function hci_persistent_key
from int to bool because it makes more sense to return information
whether a key is persistent or not as a bool.
Signed-off-by: NVishal Agarwal <vishal.agarwal@stericsson.com>
Acked-by: NMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
上级 87522a43
...@@ -980,7 +980,7 @@ int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable); ...@@ -980,7 +980,7 @@ int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable);
int mgmt_connectable(struct hci_dev *hdev, u8 connectable); int mgmt_connectable(struct hci_dev *hdev, u8 connectable);
int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status); int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status);
int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key,
u8 persistent); bool persistent);
int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
u8 addr_type, u32 flags, u8 *name, u8 name_len, u8 addr_type, u32 flags, u8 *name, u8 name_len,
u8 *dev_class); u8 *dev_class);
......
...@@ -1216,40 +1216,40 @@ struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr) ...@@ -1216,40 +1216,40 @@ struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr)
return NULL; return NULL;
} }
static int hci_persistent_key(struct hci_dev *hdev, struct hci_conn *conn, static bool hci_persistent_key(struct hci_dev *hdev, struct hci_conn *conn,
u8 key_type, u8 old_key_type) u8 key_type, u8 old_key_type)
{ {
/* Legacy key */ /* Legacy key */
if (key_type < 0x03) if (key_type < 0x03)
return 1; return true;
/* Debug keys are insecure so don't store them persistently */ /* Debug keys are insecure so don't store them persistently */
if (key_type == HCI_LK_DEBUG_COMBINATION) if (key_type == HCI_LK_DEBUG_COMBINATION)
return 0; return false;
/* Changed combination key and there's no previous one */ /* Changed combination key and there's no previous one */
if (key_type == HCI_LK_CHANGED_COMBINATION && old_key_type == 0xff) if (key_type == HCI_LK_CHANGED_COMBINATION && old_key_type == 0xff)
return 0; return false;
/* Security mode 3 case */ /* Security mode 3 case */
if (!conn) if (!conn)
return 1; return true;
/* Neither local nor remote side had no-bonding as requirement */ /* Neither local nor remote side had no-bonding as requirement */
if (conn->auth_type > 0x01 && conn->remote_auth > 0x01) if (conn->auth_type > 0x01 && conn->remote_auth > 0x01)
return 1; return true;
/* Local side had dedicated bonding as requirement */ /* Local side had dedicated bonding as requirement */
if (conn->auth_type == 0x02 || conn->auth_type == 0x03) if (conn->auth_type == 0x02 || conn->auth_type == 0x03)
return 1; return true;
/* Remote side had dedicated bonding as requirement */ /* Remote side had dedicated bonding as requirement */
if (conn->remote_auth == 0x02 || conn->remote_auth == 0x03) if (conn->remote_auth == 0x02 || conn->remote_auth == 0x03)
return 1; return true;
/* If none of the above criteria match, then don't store the key /* If none of the above criteria match, then don't store the key
* persistently */ * persistently */
return 0; return false;
} }
struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]) struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8])
...@@ -1286,7 +1286,8 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, ...@@ -1286,7 +1286,8 @@ 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) bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len)
{ {
struct link_key *key, *old_key; struct link_key *key, *old_key;
u8 old_key_type, persistent; u8 old_key_type;
bool persistent;
old_key = hci_find_link_key(hdev, bdaddr); old_key = hci_find_link_key(hdev, bdaddr);
if (old_key) { if (old_key) {
......
...@@ -2884,7 +2884,7 @@ int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status) ...@@ -2884,7 +2884,7 @@ int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status)
return 0; return 0;
} }
int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, u8 persistent) int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, bool persistent)
{ {
struct mgmt_ev_new_link_key ev; struct mgmt_ev_new_link_key ev;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册