Bluetooth: BR/EDR: Add pairing mode flag
Since right now the stack supports as acceptor pre-2.1 devices pairing, start set the state pairing flag in legacy PIN request handler and resets it on Encryption Changed event. When connection is 'in-pairing' mode disallow of local user to trigger change security level on link. > HCI Event: Command Status (0x0f) plen 4 Accept Connection Request (0x01|0x0009) ncmd 1 Status: Success (0x00) > HCI Event: PIN Code Request (0x16) plen 6 Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd) < HCI Command: PIN Code Request Reply (0x01|0x000d) plen 23 Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd) PIN length: 4 PIN code: 1234 > HCI Event: Command Complete (0x0e) plen 10 PIN Code Request Reply (0x01|0x000d) ncmd 1 Status: Success (0x00) Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd) > HCI Event: Link Key Notification (0x18) plen 23 Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd) Link key: 2a4eae1018ed248064166e765d946313 Key type: Combination key (0x00) > HCI Event: Connect Complete (0x03) plen 11 Status: Success (0x00) Handle: 12 Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd) Link type: ACL (0x01) Encryption: Disabled (0x00) > ACL Data RX: Handle 12 flags 0x02 dlen 10 L2CAP: Information Request (0x0a) ident 1 len 2 Type: Extended features supported (0x0002) < HCI Command: Host Number of Completed Packets (0x03|0x0035) plen 5 Num handles: 1 Handle: 12 Count: 1 > HCI Event: Encryption Change (0x08) plen 4 Status: Success (0x00) Handle: 12 Encryption: Enabled with E0 (0x01) Change-Id: I5cbdaab1d6d52197795bfffd465ba59216afee00 Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
parent
52b499fd1f
commit
dcd04f2a68
3 changed files with 13 additions and 0 deletions
|
@ -180,6 +180,16 @@ void bt_conn_security_changed(struct bt_conn *conn)
|
||||||
|
|
||||||
static int start_security(struct bt_conn *conn)
|
static int start_security(struct bt_conn *conn)
|
||||||
{
|
{
|
||||||
|
#if defined(CONFIG_BLUETOOTH_BREDR)
|
||||||
|
if (conn->type == BT_CONN_TYPE_BR) {
|
||||||
|
if (atomic_test_bit(conn->flags, BT_CONN_BR_PAIRING)) {
|
||||||
|
return -EBUSY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -EPERM;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_BLUETOOTH_BREDR */
|
||||||
|
|
||||||
switch (conn->role) {
|
switch (conn->role) {
|
||||||
#if defined(CONFIG_BLUETOOTH_CENTRAL) && defined(CONFIG_BLUETOOTH_SMP)
|
#if defined(CONFIG_BLUETOOTH_CENTRAL) && defined(CONFIG_BLUETOOTH_SMP)
|
||||||
case BT_HCI_ROLE_MASTER:
|
case BT_HCI_ROLE_MASTER:
|
||||||
|
@ -1153,6 +1163,7 @@ void bt_conn_pin_code_req(struct bt_conn *conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_set_bit(conn->flags, BT_CONN_USER);
|
atomic_set_bit(conn->flags, BT_CONN_USER);
|
||||||
|
atomic_set_bit(conn->flags, BT_CONN_BR_PAIRING);
|
||||||
bt_auth->pincode_entry(conn, secure);
|
bt_auth->pincode_entry(conn, secure);
|
||||||
} else {
|
} else {
|
||||||
pin_code_neg_reply(&conn->br.dst);
|
pin_code_neg_reply(&conn->br.dst);
|
||||||
|
|
|
@ -31,6 +31,7 @@ enum {
|
||||||
BT_CONN_AUTO_CONNECT,
|
BT_CONN_AUTO_CONNECT,
|
||||||
BT_CONN_BR_LEGACY_SECURE, /* 16 digits legacy PIN tracker */
|
BT_CONN_BR_LEGACY_SECURE, /* 16 digits legacy PIN tracker */
|
||||||
BT_CONN_USER, /* user I/O when pairing */
|
BT_CONN_USER, /* user I/O when pairing */
|
||||||
|
BT_CONN_BR_PAIRING, /* BR connection in pairing context */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bt_conn_le {
|
struct bt_conn_le {
|
||||||
|
|
|
@ -1242,6 +1242,7 @@ static void hci_encrypt_change(struct net_buf *buf)
|
||||||
#if defined(CONFIG_BLUETOOTH_BREDR)
|
#if defined(CONFIG_BLUETOOTH_BREDR)
|
||||||
} else {
|
} else {
|
||||||
update_sec_level_br(conn);
|
update_sec_level_br(conn);
|
||||||
|
atomic_clear_bit(conn->flags, BT_CONN_BR_PAIRING);
|
||||||
#endif /* CONFIG_BLUETOOTH_BREDR */
|
#endif /* CONFIG_BLUETOOTH_BREDR */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue