Bluetooth: Fix missing negative PIN reply
If connection was not found or PIN handler is not present legacy pairing should be terminatde with negative PIN reply. Change-Id: I8a8658f6eb28173537f39226c3792957a28aa7b2 Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This commit is contained in:
parent
64450f1933
commit
76079bc53a
1 changed files with 29 additions and 26 deletions
|
@ -1540,32 +1540,6 @@ static void conn_complete(struct net_buf *buf)
|
||||||
bt_conn_unref(conn);
|
bt_conn_unref(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pin_code_req(struct net_buf *buf)
|
|
||||||
{
|
|
||||||
struct bt_hci_evt_pin_code_req *evt = (void *)buf->data;
|
|
||||||
struct bt_conn *conn;
|
|
||||||
|
|
||||||
BT_DBG("");
|
|
||||||
|
|
||||||
conn = bt_conn_lookup_addr_br(&evt->bdaddr);
|
|
||||||
if (!conn) {
|
|
||||||
BT_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bt_auth && bt_auth->pincode_entry) {
|
|
||||||
bool secure = false;
|
|
||||||
|
|
||||||
if (conn->required_sec_level == BT_SECURITY_HIGH) {
|
|
||||||
secure = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bt_auth->pincode_entry(conn, secure);
|
|
||||||
}
|
|
||||||
|
|
||||||
bt_conn_unref(conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int pin_code_neg_reply(const bt_addr_t *bdaddr)
|
static int pin_code_neg_reply(const bt_addr_t *bdaddr)
|
||||||
{
|
{
|
||||||
struct bt_hci_cp_pin_code_neg_reply *cp;
|
struct bt_hci_cp_pin_code_neg_reply *cp;
|
||||||
|
@ -1605,6 +1579,35 @@ static int pin_code_reply(struct bt_conn *conn, const char *pin, uint8_t len)
|
||||||
return bt_hci_cmd_send_sync(BT_HCI_OP_PIN_CODE_REPLY, buf, NULL);
|
return bt_hci_cmd_send_sync(BT_HCI_OP_PIN_CODE_REPLY, buf, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void pin_code_req(struct net_buf *buf)
|
||||||
|
{
|
||||||
|
struct bt_hci_evt_pin_code_req *evt = (void *)buf->data;
|
||||||
|
struct bt_conn *conn;
|
||||||
|
|
||||||
|
BT_DBG("");
|
||||||
|
|
||||||
|
conn = bt_conn_lookup_addr_br(&evt->bdaddr);
|
||||||
|
if (!conn) {
|
||||||
|
BT_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr));
|
||||||
|
pin_code_neg_reply(&evt->bdaddr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bt_auth && bt_auth->pincode_entry) {
|
||||||
|
bool secure = false;
|
||||||
|
|
||||||
|
if (conn->required_sec_level == BT_SECURITY_HIGH) {
|
||||||
|
secure = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bt_auth->pincode_entry(conn, secure);
|
||||||
|
} else {
|
||||||
|
pin_code_neg_reply(&evt->bdaddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
bt_conn_unref(conn);
|
||||||
|
}
|
||||||
|
|
||||||
static void link_key_notify(struct net_buf *buf)
|
static void link_key_notify(struct net_buf *buf)
|
||||||
{
|
{
|
||||||
struct bt_hci_ev_link_key_notify *evt = (void *)buf->data;
|
struct bt_hci_ev_link_key_notify *evt = (void *)buf->data;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue