hci.c (24d14ae36e95f1a6b777d41469836b4230ab79cc) | hci.c (db3c1f8953db60524595003c01ae187087b26388) |
---|---|
1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 2555 unchanged lines hidden (view full) --- 2564static void hci_handle_read_encryption_key_size_complete(hci_connection_t * conn, uint8_t encryption_key_size) { 2565 conn->authentication_flags |= AUTH_FLAG_CONNECTION_ENCRYPTED; 2566 conn->encryption_key_size = encryption_key_size; 2567 gap_security_level_t security_level = gap_security_level_for_connection(conn); 2568 2569 // trigger disconnect for dedicated bonding, skip emit security level as disconnect is pending 2570 if ((conn->bonding_flags & BONDING_DEDICATED) != 0){ 2571 conn->bonding_flags &= ~BONDING_DEDICATED; | 1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 2555 unchanged lines hidden (view full) --- 2564static void hci_handle_read_encryption_key_size_complete(hci_connection_t * conn, uint8_t encryption_key_size) { 2565 conn->authentication_flags |= AUTH_FLAG_CONNECTION_ENCRYPTED; 2566 conn->encryption_key_size = encryption_key_size; 2567 gap_security_level_t security_level = gap_security_level_for_connection(conn); 2568 2569 // trigger disconnect for dedicated bonding, skip emit security level as disconnect is pending 2570 if ((conn->bonding_flags & BONDING_DEDICATED) != 0){ 2571 conn->bonding_flags &= ~BONDING_DEDICATED; |
2572 conn->bonding_flags |= BONDING_DISCONNECT_DEDICATED_DONE; | |
2573 conn->bonding_status = security_level == 0 ? ERROR_CODE_INSUFFICIENT_SECURITY : ERROR_CODE_SUCCESS; | 2572 conn->bonding_status = security_level == 0 ? ERROR_CODE_INSUFFICIENT_SECURITY : ERROR_CODE_SUCCESS; |
2573#ifdef ENABLE_EXPLICIT_DEDICATED_BONDING_DISCONNECT 2574 // emit dedicated bonding complete, don't disconnect 2575 hci_emit_dedicated_bonding_result(conn->address, conn->bonding_status); 2576#else 2577 // request disconnect, event is emitted after disconnect 2578 conn->bonding_flags |= BONDING_DISCONNECT_DEDICATED_DONE; |
|
2574 return; | 2579 return; |
2580#endif |
|
2575 } 2576 2577 if ((conn->authentication_flags & AUTH_FLAG_CONNECTION_AUTHENTICATED) != 0) { 2578 conn->requested_security_level = LEVEL_0; 2579 hci_emit_security_level(conn->con_handle, security_level); 2580 return; 2581 } 2582 --- 1214 unchanged lines hidden (view full) --- 3797 break; 3798#endif 3799 3800 case HCI_EVENT_ENCRYPTION_CHANGE: 3801 case HCI_EVENT_ENCRYPTION_CHANGE_V2: 3802 handle = hci_event_encryption_change_get_connection_handle(packet); 3803 conn = hci_connection_for_handle(handle); 3804 if (!conn) break; | 2581 } 2582 2583 if ((conn->authentication_flags & AUTH_FLAG_CONNECTION_AUTHENTICATED) != 0) { 2584 conn->requested_security_level = LEVEL_0; 2585 hci_emit_security_level(conn->con_handle, security_level); 2586 return; 2587 } 2588 --- 1214 unchanged lines hidden (view full) --- 3803 break; 3804#endif 3805 3806 case HCI_EVENT_ENCRYPTION_CHANGE: 3807 case HCI_EVENT_ENCRYPTION_CHANGE_V2: 3808 handle = hci_event_encryption_change_get_connection_handle(packet); 3809 conn = hci_connection_for_handle(handle); 3810 if (!conn) break; |
3805 if (hci_event_encryption_change_get_status(packet) == 0u) { | 3811 if (hci_event_encryption_change_get_status(packet) == ERROR_CODE_SUCCESS) { |
3806 uint8_t encryption_enabled = hci_event_encryption_change_get_encryption_enabled(packet); 3807 if (encryption_enabled){ 3808 if (hci_is_le_connection(conn)){ 3809 // For LE, we accept connection as encrypted 3810 conn->authentication_flags |= AUTH_FLAG_CONNECTION_ENCRYPTED; 3811 } 3812#ifdef ENABLE_CLASSIC 3813 else { --- 6397 unchanged lines hidden --- | 3812 uint8_t encryption_enabled = hci_event_encryption_change_get_encryption_enabled(packet); 3813 if (encryption_enabled){ 3814 if (hci_is_le_connection(conn)){ 3815 // For LE, we accept connection as encrypted 3816 conn->authentication_flags |= AUTH_FLAG_CONNECTION_ENCRYPTED; 3817 } 3818#ifdef ENABLE_CLASSIC 3819 else { --- 6397 unchanged lines hidden --- |