Bluetooth: Host: Rename API function to initiate bluetooth security.

Rename bt_conn_security to bt_conn_set_security, this makes the API
naming more consistent.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2019-08-26 15:53:20 +02:00 committed by Carles Cufí
commit 3e9888105e
11 changed files with 22 additions and 15 deletions

View file

@ -321,7 +321,13 @@ typedef enum __packed {
* *
* @return 0 on success or negative error * @return 0 on success or negative error
*/ */
int bt_conn_security(struct bt_conn *conn, bt_security_t sec); int bt_conn_set_security(struct bt_conn *conn, bt_security_t sec);
static inline int __deprecated bt_conn_security(struct bt_conn *conn,
bt_security_t sec)
{
return bt_conn_set_security(conn, sec);
}
/** @brief Get encryption key size. /** @brief Get encryption key size.
* *

View file

@ -44,7 +44,7 @@ static void connected(struct bt_conn *conn, u8_t err)
printk("Connected %s\n", addr); printk("Connected %s\n", addr);
if (bt_conn_security(conn, BT_SECURITY_L2)) { if (bt_conn_set_security(conn, BT_SECURITY_L2)) {
printk("Failed to set security\n"); printk("Failed to set security\n");
} }
} }

View file

@ -37,7 +37,7 @@ static void connected(struct bt_conn *conn, u8_t err)
printk("Connected %s\n", addr); printk("Connected %s\n", addr);
if (bt_conn_security(conn, BT_SECURITY_L4)) { if (bt_conn_set_security(conn, BT_SECURITY_L4)) {
printk("Failed to set security\n"); printk("Failed to set security\n");
} }
} }

View file

@ -1639,7 +1639,7 @@ static int att_change_security(struct bt_conn *conn, u8_t err)
return -EINVAL; return -EINVAL;
} }
return bt_conn_security(conn, sec); return bt_conn_set_security(conn, sec);
} }
#endif /* CONFIG_BT_SMP */ #endif /* CONFIG_BT_SMP */

View file

@ -1040,7 +1040,7 @@ static int start_security(struct bt_conn *conn)
} }
} }
int bt_conn_security(struct bt_conn *conn, bt_security_t sec) int bt_conn_set_security(struct bt_conn *conn, bt_security_t sec)
{ {
int err; int err;

View file

@ -967,7 +967,8 @@ static int l2cap_change_security(struct bt_l2cap_le_chan *chan, u16_t err)
return -EINVAL; return -EINVAL;
} }
return bt_conn_security(chan->chan.conn, chan->chan.required_sec_level); return bt_conn_set_security(chan->chan.conn,
chan->chan.required_sec_level);
} }
static void le_conn_rsp(struct bt_l2cap *l2cap, u8_t ident, static void le_conn_rsp(struct bt_l2cap *l2cap, u8_t ident,

View file

@ -555,7 +555,7 @@ enum l2cap_br_conn_security_result {
* - channel connection process is on hold since there were valid security * - channel connection process is on hold since there were valid security
* conditions triggering authentication indirectly in subcall. * conditions triggering authentication indirectly in subcall.
* Returns L2CAP_CONN_SECURITY_REJECT if: * Returns L2CAP_CONN_SECURITY_REJECT if:
* - bt_conn_security API returns < 0. * - bt_conn_set_security API returns < 0.
*/ */
static enum l2cap_br_conn_security_result static enum l2cap_br_conn_security_result
@ -595,13 +595,13 @@ l2cap_br_conn_security(struct bt_l2cap_chan *chan, const u16_t psm)
break; break;
} }
check = bt_conn_security(chan->conn, chan->required_sec_level); check = bt_conn_set_security(chan->conn, chan->required_sec_level);
/* /*
* Check case when on existing connection security level already covers * Check case when on existing connection security level already covers
* channel (service) security requirements against link security and * channel (service) security requirements against link security and
* bt_conn_security API returns 0 what implies also there was no need to * bt_conn_set_security API returns 0 what implies also there was no
* trigger authentication. * need to trigger authentication.
*/ */
if (check == 0 && if (check == 0 &&
chan->conn->sec_level >= chan->required_sec_level) { chan->conn->sec_level >= chan->required_sec_level) {

View file

@ -785,7 +785,7 @@ static enum security_result rfcomm_dlc_security(struct bt_rfcomm_dlc *dlc)
return RFCOMM_SECURITY_PASSED; return RFCOMM_SECURITY_PASSED;
} }
if (!bt_conn_security(conn, dlc->required_sec_level)) { if (!bt_conn_set_security(conn, dlc->required_sec_level)) {
/* If Security elevation is initiated or in progress */ /* If Security elevation is initiated or in progress */
return RFCOMM_SECURITY_PENDING; return RFCOMM_SECURITY_PENDING;
} }

View file

@ -1096,7 +1096,7 @@ static int cmd_security(const struct shell *shell, size_t argc, char *argv[])
} }
} }
err = bt_conn_security(default_conn, sec); err = bt_conn_set_security(default_conn, sec);
if (err) { if (err) {
shell_error(shell, "Setting security failed (err %d)", err); shell_error(shell, "Setting security failed (err %d)", err);
} }

View file

@ -225,9 +225,9 @@ static void connected(struct bt_conn *conn, u8_t conn_err)
if (encrypt_link) { if (encrypt_link) {
k_sleep(500); k_sleep(500);
bt_conn_auth_cb_register(&auth_cb_success); bt_conn_auth_cb_register(&auth_cb_success);
err = bt_conn_security(conn, BT_SECURITY_L2); err = bt_conn_set_security(conn, BT_SECURITY_L2);
if (err) { if (err) {
FAIL("bt_conn_security failed (err %d)\n", err); FAIL("bt_conn_set_security failed (err %d)\n", err);
return; return;
} }
} else { } else {

View file

@ -596,7 +596,7 @@ static void pair(const u8_t *data, u16_t len)
goto rsp; goto rsp;
} }
if (bt_conn_security(conn, BT_SECURITY_L2)) { if (bt_conn_set_security(conn, BT_SECURITY_L2)) {
status = BTP_STATUS_FAILED; status = BTP_STATUS_FAILED;
bt_conn_unref(conn); bt_conn_unref(conn);
goto rsp; goto rsp;