From 3e9888105e380cb2b3b66053409d1606fdd3c1a0 Mon Sep 17 00:00:00 2001 From: Joakim Andersson Date: Mon, 26 Aug 2019 15:53:20 +0200 Subject: [PATCH] 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 --- include/bluetooth/conn.h | 8 +++++++- samples/bluetooth/peripheral_hids/src/main.c | 2 +- samples/bluetooth/peripheral_sc_only/src/main.c | 2 +- subsys/bluetooth/host/att.c | 2 +- subsys/bluetooth/host/conn.c | 2 +- subsys/bluetooth/host/l2cap.c | 3 ++- subsys/bluetooth/host/l2cap_br.c | 8 ++++---- subsys/bluetooth/host/rfcomm.c | 2 +- subsys/bluetooth/shell/bt.c | 2 +- tests/bluetooth/bsim_bt/bsim_test_app/src/test_connect1.c | 4 ++-- tests/bluetooth/tester/src/gap.c | 2 +- 11 files changed, 22 insertions(+), 15 deletions(-) diff --git a/include/bluetooth/conn.h b/include/bluetooth/conn.h index edcf93716c15..80167c670cdc 100644 --- a/include/bluetooth/conn.h +++ b/include/bluetooth/conn.h @@ -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. * diff --git a/samples/bluetooth/peripheral_hids/src/main.c b/samples/bluetooth/peripheral_hids/src/main.c index c4e0ba58e9fc..bdb7f7fd8a7f 100644 --- a/samples/bluetooth/peripheral_hids/src/main.c +++ b/samples/bluetooth/peripheral_hids/src/main.c @@ -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"); } } diff --git a/samples/bluetooth/peripheral_sc_only/src/main.c b/samples/bluetooth/peripheral_sc_only/src/main.c index 4eade53e8aac..b6a8325ecec0 100644 --- a/samples/bluetooth/peripheral_sc_only/src/main.c +++ b/samples/bluetooth/peripheral_sc_only/src/main.c @@ -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"); } } diff --git a/subsys/bluetooth/host/att.c b/subsys/bluetooth/host/att.c index f9459dda31fb..8b2abc10b8e6 100644 --- a/subsys/bluetooth/host/att.c +++ b/subsys/bluetooth/host/att.c @@ -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 */ diff --git a/subsys/bluetooth/host/conn.c b/subsys/bluetooth/host/conn.c index 58313dee38dc..858372f43732 100644 --- a/subsys/bluetooth/host/conn.c +++ b/subsys/bluetooth/host/conn.c @@ -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; diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index 34b8bac8f5fa..215e20377a6b 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -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, diff --git a/subsys/bluetooth/host/l2cap_br.c b/subsys/bluetooth/host/l2cap_br.c index bb697e4ffdf3..2bd53006eff2 100644 --- a/subsys/bluetooth/host/l2cap_br.c +++ b/subsys/bluetooth/host/l2cap_br.c @@ -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 @@ -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) { diff --git a/subsys/bluetooth/host/rfcomm.c b/subsys/bluetooth/host/rfcomm.c index 1e5c03dedb06..3931f02eef80 100644 --- a/subsys/bluetooth/host/rfcomm.c +++ b/subsys/bluetooth/host/rfcomm.c @@ -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; } diff --git a/subsys/bluetooth/shell/bt.c b/subsys/bluetooth/shell/bt.c index 3bf7e65921ef..39d1db5e9408 100644 --- a/subsys/bluetooth/shell/bt.c +++ b/subsys/bluetooth/shell/bt.c @@ -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); } diff --git a/tests/bluetooth/bsim_bt/bsim_test_app/src/test_connect1.c b/tests/bluetooth/bsim_bt/bsim_test_app/src/test_connect1.c index 4a7b1597db5f..262bf2016094 100644 --- a/tests/bluetooth/bsim_bt/bsim_test_app/src/test_connect1.c +++ b/tests/bluetooth/bsim_bt/bsim_test_app/src/test_connect1.c @@ -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 { diff --git a/tests/bluetooth/tester/src/gap.c b/tests/bluetooth/tester/src/gap.c index 03cd387e8e51..4544e91bf186 100644 --- a/tests/bluetooth/tester/src/gap.c +++ b/tests/bluetooth/tester/src/gap.c @@ -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;