diff --git a/drivers/nble/gap.c b/drivers/nble/gap.c index 471451412cf..fe89cee2fe9 100644 --- a/drivers/nble/gap.c +++ b/drivers/nble/gap.c @@ -56,14 +56,17 @@ int bt_auth_cb_register(const struct bt_auth_cb *cb) return -ENOSYS; } -void bt_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey) +int bt_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey) { + return -ENOSYS; } -void bt_auth_cancel(struct bt_conn *conn) +int bt_auth_cancel(struct bt_conn *conn) { + return -ENOSYS; } -void bt_auth_passkey_confirm(struct bt_conn *conn, bool match) +int bt_auth_passkey_confirm(struct bt_conn *conn, bool match) { + return -ENOSYS; } diff --git a/include/bluetooth/bluetooth.h b/include/bluetooth/bluetooth.h index 457657d1739..00054842ca0 100644 --- a/include/bluetooth/bluetooth.h +++ b/include/bluetooth/bluetooth.h @@ -272,16 +272,20 @@ int bt_auth_cb_register(const struct bt_auth_cb *cb); * * @param conn Connection object. * @param passkey Entered passkey. + * + * @return Zero on success or negative error code otherwise */ -void bt_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey); +int bt_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey); /** @brief Cancel ongoing authenticated pairing. * * This function allows to cancel ongoing authenticated pairing. * * @param conn Connection object. + * + * @return Zero on success or negative error code otherwise */ -void bt_auth_cancel(struct bt_conn *conn); +int bt_auth_cancel(struct bt_conn *conn); /** @brief Reply if passkey was confirmed by user. * @@ -291,8 +295,10 @@ void bt_auth_cancel(struct bt_conn *conn); * * @param conn Connection object. * @param match True if passkey was confirmed to match, false otherwise. + * + * @return Zero on success or negative error code otherwise */ -void bt_auth_passkey_confirm(struct bt_conn *conn, bool match); +int bt_auth_passkey_confirm(struct bt_conn *conn, bool match); #if defined(CONFIG_BLUETOOTH_BREDR) /** @brief Reply with entered PIN code. @@ -302,8 +308,10 @@ void bt_auth_passkey_confirm(struct bt_conn *conn, bool match); * * @param conn Connection object. * @param pin Entered PIN code. + * + * @return Zero on success or negative error code otherwise */ -void bt_auth_pincode_entry(struct bt_conn *conn, const char *pin); +int bt_auth_pincode_entry(struct bt_conn *conn, const char *pin); #endif /* CONFIG_BLUETOOTH_BREDR */ #endif /* CONFIG_BLUETOOTH_SMP || CONFIG_BLUETOOTH_BREDR */ diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 05ecc2195cb..1babe2026a1 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2670,75 +2670,80 @@ int bt_auth_cb_register(const struct bt_auth_cb *cb) return 0; } -void bt_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey) +int bt_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey) { if (!bt_auth) { - return; + return -EINVAL; } #if defined(CONFIG_BLUETOOTH_SMP) if (conn->type == BT_CONN_TYPE_LE) { bt_smp_auth_passkey_entry(conn, passkey); + return 0; } #endif /* CONFIG_BLUETOOTH_SMP */ + + return -EINVAL; } -void bt_auth_passkey_confirm(struct bt_conn *conn, bool match) +int bt_auth_passkey_confirm(struct bt_conn *conn, bool match) { if (!bt_auth) { - return; + return -EINVAL; }; #if defined(CONFIG_BLUETOOTH_SMP) if (conn->type == BT_CONN_TYPE_LE) { bt_smp_auth_passkey_confirm(conn, match); } #endif /* CONFIG_BLUETOOTH_SMP */ + + return -EINVAL; } -void bt_auth_cancel(struct bt_conn *conn) +int bt_auth_cancel(struct bt_conn *conn) { if (!bt_auth) { - return; + return -EINVAL; } #if defined(CONFIG_BLUETOOTH_SMP) if (conn->type == BT_CONN_TYPE_LE) { bt_smp_auth_cancel(conn); - return; + return 0; } #endif /* CONFIG_BLUETOOTH_SMP */ #if defined(CONFIG_BLUETOOTH_BREDR) if (conn->type == BT_CONN_TYPE_BR) { - pin_code_neg_reply(&conn->br.dst); + return pin_code_neg_reply(&conn->br.dst); } #endif /* CONFIG_BLUETOOTH_BREDR */ + + return -EINVAL; } #if defined(CONFIG_BLUETOOTH_BREDR) -void bt_auth_pincode_entry(struct bt_conn *conn, const char *pin) +int bt_auth_pincode_entry(struct bt_conn *conn, const char *pin) { size_t len; if (!bt_auth) { - return; + return -EINVAL; } if (conn->type != BT_CONN_TYPE_BR) { - return; + return -EINVAL; } len = strlen(pin); if (len > 16) { - pin_code_neg_reply(&conn->br.dst); - return; + return -EINVAL; } if (conn->required_sec_level == BT_SECURITY_HIGH && len < 16) { BT_WARN("PIN code for %s is not 16 bytes wide", bt_addr_str(&conn->br.dst)); - pin_code_neg_reply(&conn->br.dst); - return; + return -EPERM; } - pin_code_reply(conn, pin, len); + return pin_code_reply(conn, pin, len); } #endif #endif /* CONFIG_BLUETOOTH_SMP || CONFIG_BLUETOOTH_BREDR */