mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-25 09:02:30 +00:00
track legacy and ssp pairing, new implementation for hci_authentication_active_for_handle based on that
This commit is contained in:
parent
899283eaa9
commit
6724cd9e0e
33
src/hci.c
33
src/hci.c
@ -182,10 +182,9 @@ static void hci_add_connection_flags_for_flipped_bd_addr(uint8_t *bd_addr, hci_a
|
|||||||
int hci_authentication_active_for_handle(hci_con_handle_t handle){
|
int hci_authentication_active_for_handle(hci_con_handle_t handle){
|
||||||
hci_connection_t * conn = hci_connection_for_handle(handle);
|
hci_connection_t * conn = hci_connection_for_handle(handle);
|
||||||
if (!conn) return 0;
|
if (!conn) return 0;
|
||||||
if (!conn->authentication_flags) return 0;
|
if (conn->authentication_flags & LEGACY_PAIRING_ACTIVE) return 1;
|
||||||
if (conn->authentication_flags & SENT_LINK_KEY_REPLY) return 0;
|
if (conn->authentication_flags & SSP_PAIRING_ACTIVE) return 1;
|
||||||
if (conn->authentication_flags & RECV_LINK_KEY_NOTIFICATION) return 0;
|
return 0;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void hci_drop_link_key_for_bd_addr(bd_addr_t *addr){
|
void hci_drop_link_key_for_bd_addr(bd_addr_t *addr){
|
||||||
@ -664,7 +663,7 @@ static void event_handler(uint8_t *packet, int size){
|
|||||||
}
|
}
|
||||||
|
|
||||||
case HCI_EVENT_PIN_CODE_REQUEST:
|
case HCI_EVENT_PIN_CODE_REQUEST:
|
||||||
hci_add_connection_flags_for_flipped_bd_addr(&packet[2], RECV_PIN_CODE_REQUEST);
|
hci_add_connection_flags_for_flipped_bd_addr(&packet[2], LEGACY_PAIRING_ACTIVE);
|
||||||
// non-bondable mode: pin code negative reply will be sent
|
// non-bondable mode: pin code negative reply will be sent
|
||||||
if (!hci_stack.bondable){
|
if (!hci_stack.bondable){
|
||||||
hci_add_connection_flags_for_flipped_bd_addr(&packet[2], DENY_PIN_CODE_REQUEST);
|
hci_add_connection_flags_for_flipped_bd_addr(&packet[2], DENY_PIN_CODE_REQUEST);
|
||||||
@ -683,13 +682,13 @@ static void event_handler(uint8_t *packet, int size){
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_USER_CONFIRMATION_REQUEST:
|
case HCI_EVENT_USER_CONFIRMATION_REQUEST:
|
||||||
hci_add_connection_flags_for_flipped_bd_addr(&packet[2], RECV_USER_CONFIRM_REQUEST);
|
hci_add_connection_flags_for_flipped_bd_addr(&packet[2], SSP_PAIRING_ACTIVE);
|
||||||
if (!hci_stack.ssp_auto_accept) break;
|
if (!hci_stack.ssp_auto_accept) break;
|
||||||
hci_add_connection_flags_for_flipped_bd_addr(&packet[2], SEND_USER_CONFIRM_REPLY);
|
hci_add_connection_flags_for_flipped_bd_addr(&packet[2], SEND_USER_CONFIRM_REPLY);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_USER_PASSKEY_REQUEST:
|
case HCI_EVENT_USER_PASSKEY_REQUEST:
|
||||||
hci_add_connection_flags_for_flipped_bd_addr(&packet[2], RECV_USER_PASSKEY_REQUEST);
|
hci_add_connection_flags_for_flipped_bd_addr(&packet[2], SSP_PAIRING_ACTIVE);
|
||||||
if (!hci_stack.ssp_auto_accept) break;
|
if (!hci_stack.ssp_auto_accept) break;
|
||||||
hci_add_connection_flags_for_flipped_bd_addr(&packet[2], SEND_USER_PASSKEY_REPLY);
|
hci_add_connection_flags_for_flipped_bd_addr(&packet[2], SEND_USER_PASSKEY_REPLY);
|
||||||
break;
|
break;
|
||||||
@ -1573,6 +1572,26 @@ int hci_send_cmd_packet(uint8_t *packet, int size){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IS_COMMAND(packet, hci_pin_code_request_negative_reply)
|
||||||
|
|| IS_COMMAND(packet, hci_pin_code_request_reply)){
|
||||||
|
bt_flip_addr(addr, &packet[3]);
|
||||||
|
conn = connection_for_address(addr);
|
||||||
|
if (conn){
|
||||||
|
connectionClearAuthenticationFlags(conn, LEGACY_PAIRING_ACTIVE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IS_COMMAND(packet, hci_user_confirmation_request_negative_reply)
|
||||||
|
|| IS_COMMAND(packet, hci_user_confirmation_request_reply)
|
||||||
|
|| IS_COMMAND(packet, hci_user_passkey_request_negative_reply)
|
||||||
|
|| IS_COMMAND(packet, hci_user_passkey_request_reply)) {
|
||||||
|
bt_flip_addr(addr, &packet[3]);
|
||||||
|
conn = connection_for_address(addr);
|
||||||
|
if (conn){
|
||||||
|
connectionClearAuthenticationFlags(conn, SSP_PAIRING_ACTIVE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_BLE
|
#ifdef HAVE_BLE
|
||||||
if (IS_COMMAND(packet, hci_le_set_advertising_parameters)){
|
if (IS_COMMAND(packet, hci_le_set_advertising_parameters)){
|
||||||
hci_stack.adv_addr_type = packet[8];
|
hci_stack.adv_addr_type = packet[8];
|
||||||
|
18
src/hci.h
18
src/hci.h
@ -205,22 +205,18 @@ typedef enum {
|
|||||||
SENT_LINK_KEY_REPLY = 0x0004,
|
SENT_LINK_KEY_REPLY = 0x0004,
|
||||||
SENT_LINK_KEY_NEGATIVE_REQUEST = 0x0008,
|
SENT_LINK_KEY_NEGATIVE_REQUEST = 0x0008,
|
||||||
RECV_LINK_KEY_NOTIFICATION = 0x0010,
|
RECV_LINK_KEY_NOTIFICATION = 0x0010,
|
||||||
RECV_PIN_CODE_REQUEST = 0x0020,
|
|
||||||
DENY_PIN_CODE_REQUEST = 0x0040,
|
DENY_PIN_CODE_REQUEST = 0x0040,
|
||||||
// SSP
|
|
||||||
RECV_IO_CAPABILITIES_REQUEST = 0x0080,
|
RECV_IO_CAPABILITIES_REQUEST = 0x0080,
|
||||||
SEND_IO_CAPABILITIES_REPLY = 0x0100,
|
SEND_IO_CAPABILITIES_REPLY = 0x0100,
|
||||||
RECV_USER_CONFIRM_REQUEST = 0x0200,
|
SEND_USER_CONFIRM_REPLY = 0x0200,
|
||||||
SEND_USER_CONFIRM_REPLY = 0x0400,
|
SEND_USER_PASSKEY_REPLY = 0x0400,
|
||||||
RECV_USER_PASSKEY_REQUEST = 0x0800,
|
|
||||||
SEND_USER_PASSKEY_REPLY = 0x1000,
|
// pairing status
|
||||||
|
LEGACY_PAIRING_ACTIVE = 0x2000,
|
||||||
|
SSP_PAIRING_ACTIVE = 0x4000,
|
||||||
|
|
||||||
// connection status
|
// connection status
|
||||||
CONNECTION_ENCRYPTED = 0x2000,
|
CONNECTION_ENCRYPTED = 0x8000,
|
||||||
|
|
||||||
// SENT_PIN_CODE_REPLY = 0x0080,
|
|
||||||
// SENT_PIN_CODE_NEGATIVE_REPLY = 0x0100,
|
|
||||||
|
|
||||||
} hci_authentication_flags_t;
|
} hci_authentication_flags_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user