sm.c (94cfa0e86e95652b966d128417b9e2b3c8d91cad) | sm.c (b15d5cea352319fdf3b15b46b4ab21d01e83091d) |
---|---|
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 --- 4649 unchanged lines hidden (view full) --- 4658#endif 4659 4660int gap_reconnect_security_setup_active(hci_con_handle_t con_handle){ 4661 sm_connection_t * sm_conn = sm_get_connection_for_handle(con_handle); 4662 // wrong connection 4663 if (!sm_conn) return 0; 4664 // already encrypted 4665 if (sm_conn->sm_connection_encrypted) return 0; | 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 --- 4649 unchanged lines hidden (view full) --- 4658#endif 4659 4660int gap_reconnect_security_setup_active(hci_con_handle_t con_handle){ 4661 sm_connection_t * sm_conn = sm_get_connection_for_handle(con_handle); 4662 // wrong connection 4663 if (!sm_conn) return 0; 4664 // already encrypted 4665 if (sm_conn->sm_connection_encrypted) return 0; |
4666 // only central can re-encrypt 4667 if (sm_conn->sm_role == HCI_ROLE_SLAVE) return 0; | |
4668 // irk status? 4669 switch(sm_conn->sm_irk_lookup_state){ 4670 case IRK_LOOKUP_FAILED: 4671 // done, cannot setup encryption 4672 return 0; 4673 case IRK_LOOKUP_SUCCEEDED: 4674 break; 4675 default: 4676 // IR Lookup pending 4677 return 1; 4678 } 4679 // IRK Lookup Succeeded, re-encryption should be initiated. When done, state gets reset | 4666 // irk status? 4667 switch(sm_conn->sm_irk_lookup_state){ 4668 case IRK_LOOKUP_FAILED: 4669 // done, cannot setup encryption 4670 return 0; 4671 case IRK_LOOKUP_SUCCEEDED: 4672 break; 4673 default: 4674 // IR Lookup pending 4675 return 1; 4676 } 4677 // IRK Lookup Succeeded, re-encryption should be initiated. When done, state gets reset |
4680 return sm_conn->sm_engine_state != SM_INITIATOR_CONNECTED; | 4678 if (sm_conn->sm_role){ 4679 return sm_conn->sm_engine_state != SM_RESPONDER_IDLE; 4680 } else { 4681 return sm_conn->sm_engine_state != SM_INITIATOR_CONNECTED; 4682 } |
4681} 4682 4683void sm_set_secure_connections_only_mode(bool enable){ 4684#ifdef ENABLE_LE_SECURE_CONNECTIONS 4685 sm_sc_only_mode = enable; 4686#else 4687 // SC Only mode not possible without support for SC 4688 btstack_assert(enable == false); 4689#endif 4690} 4691 4692const uint8_t * gap_get_persistent_irk(void){ 4693 return sm_persistent_irk; 4694} | 4683} 4684 4685void sm_set_secure_connections_only_mode(bool enable){ 4686#ifdef ENABLE_LE_SECURE_CONNECTIONS 4687 sm_sc_only_mode = enable; 4688#else 4689 // SC Only mode not possible without support for SC 4690 btstack_assert(enable == false); 4691#endif 4692} 4693 4694const uint8_t * gap_get_persistent_irk(void){ 4695 return sm_persistent_irk; 4696} |