Skip to content

Commit

Permalink
Bluetooth: Host: Rename API function to initiate bluetooth security.
Browse files Browse the repository at this point in the history
Rename bt_conn_security to bt_conn_set_security, this makes the API
naming more consistent.

Signed-off-by: Joakim Andersson <[email protected]>
  • Loading branch information
joerchan authored and carlescufi committed Aug 27, 2019
1 parent 1c48757 commit 3e98881
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 15 deletions.
8 changes: 7 additions & 1 deletion include/bluetooth/conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,13 @@ typedef enum __packed {
*
* @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.
*
Expand Down
2 changes: 1 addition & 1 deletion samples/bluetooth/peripheral_hids/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static void connected(struct bt_conn *conn, u8_t err)

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");
}
}
Expand Down
2 changes: 1 addition & 1 deletion samples/bluetooth/peripheral_sc_only/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static void connected(struct bt_conn *conn, u8_t err)

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");
}
}
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/host/att.c
Original file line number Diff line number Diff line change
Expand Up @@ -1639,7 +1639,7 @@ static int att_change_security(struct bt_conn *conn, u8_t err)
return -EINVAL;
}

return bt_conn_security(conn, sec);
return bt_conn_set_security(conn, sec);
}
#endif /* CONFIG_BT_SMP */

Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/host/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion subsys/bluetooth/host/l2cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,8 @@ static int l2cap_change_security(struct bt_l2cap_le_chan *chan, u16_t err)
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,
Expand Down
8 changes: 4 additions & 4 deletions subsys/bluetooth/host/l2cap_br.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ enum l2cap_br_conn_security_result {
* - channel connection process is on hold since there were valid security
* conditions triggering authentication indirectly in subcall.
* 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
Expand Down Expand Up @@ -595,13 +595,13 @@ l2cap_br_conn_security(struct bt_l2cap_chan *chan, const u16_t psm)
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
* channel (service) security requirements against link security and
* bt_conn_security API returns 0 what implies also there was no need to
* trigger authentication.
* bt_conn_set_security API returns 0 what implies also there was no
* need to trigger authentication.
*/
if (check == 0 &&
chan->conn->sec_level >= chan->required_sec_level) {
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/host/rfcomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ static enum security_result rfcomm_dlc_security(struct bt_rfcomm_dlc *dlc)
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 */
return RFCOMM_SECURITY_PENDING;
}
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/shell/bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
shell_error(shell, "Setting security failed (err %d)", err);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/bluetooth/bsim_bt/bsim_test_app/src/test_connect1.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ static void connected(struct bt_conn *conn, u8_t conn_err)
if (encrypt_link) {
k_sleep(500);
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) {
FAIL("bt_conn_security failed (err %d)\n", err);
FAIL("bt_conn_set_security failed (err %d)\n", err);
return;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/bluetooth/tester/src/gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ static void pair(const u8_t *data, u16_t len)
goto rsp;
}

if (bt_conn_security(conn, BT_SECURITY_L2)) {
if (bt_conn_set_security(conn, BT_SECURITY_L2)) {
status = BTP_STATUS_FAILED;
bt_conn_unref(conn);
goto rsp;
Expand Down

0 comments on commit 3e98881

Please sign in to comment.