Lines Matching refs:btm_cb

243     if (btm_cb.devcb.id_keys.ir == zero) {  in BTM_SecRegister()
250 btm_cb.api = *p_cb_info; in BTM_SecRegister()
252 btm_cb.api.p_le_callback); in BTM_SecRegister()
271 if (btm_cb.p_rmt_name_callback[i] == NULL) { in BTM_SecAddRmtNameNotifyCallback()
272 btm_cb.p_rmt_name_callback[i] = p_callback; in BTM_SecAddRmtNameNotifyCallback()
294 if (btm_cb.p_rmt_name_callback[i] == p_callback) { in BTM_SecDeleteRmtNameNotifyCallback()
295 btm_cb.p_rmt_name_callback[i] = NULL; in BTM_SecDeleteRmtNameNotifyCallback()
366 if ((btm_cb.cfg.pin_type != pin_type) && in BTM_SetPinType()
371 btm_cb.cfg.pin_type = pin_type; in BTM_SetPinType()
372 btm_cb.cfg.pin_code_len = pin_code_len; in BTM_SetPinType()
373 memcpy(btm_cb.cfg.pin_code, pin_code, pin_code_len); in BTM_SetPinType()
395 btm_cb.pairing_disabled = !allow_pairing; in BTM_SetPairableMode()
396 btm_cb.connect_only_paired = connect_only_paired; in BTM_SetPairableMode()
434 p_srec = &btm_cb.sec_serv_rec[0]; in BTM_SetSecurityLevel()
475 p_srec = &btm_cb.sec_serv_rec[index]; in BTM_SetSecurityLevel()
502 if (btm_cb.security_mode == BTM_SEC_MODE_SP || in BTM_SetSecurityLevel()
503 btm_cb.security_mode == BTM_SEC_MODE_SP_DEBUG || in BTM_SetSecurityLevel()
504 btm_cb.security_mode == BTM_SEC_MODE_SC) { in BTM_SetSecurityLevel()
514 btm_cb.p_out_serv = p_srec; in BTM_SetSecurityLevel()
535 if (btm_cb.security_mode == BTM_SEC_MODE_SP || in BTM_SetSecurityLevel()
536 btm_cb.security_mode == BTM_SEC_MODE_SP_DEBUG || in BTM_SetSecurityLevel()
537 btm_cb.security_mode == BTM_SEC_MODE_SC) { in BTM_SetSecurityLevel()
579 tBTM_SEC_SERV_REC* p_srec = &btm_cb.sec_serv_rec[0]; in BTM_SecClrService()
614 tBTM_SEC_SERV_REC* p_srec = &btm_cb.sec_serv_rec[0]; in btm_sec_clr_service_by_psm()
687 btm_pair_state_descr(btm_cb.pairing_state), btm_cb.pairing_flags, pin_len, in BTM_PINCodeReply()
691 if (btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_LOCAL_PIN) { in BTM_PINCodeReply()
693 btm_cb.pairing_state); in BTM_PINCodeReply()
697 if (bd_addr != btm_cb.pairing_bda) { in BTM_PINCodeReply()
714 if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_PEER_STARTED_DD) || in BTM_PINCodeReply()
715 ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) && in BTM_PINCodeReply()
716 (btm_cb.pairing_flags & BTM_PAIR_FLAGS_DISC_WHEN_DONE))) { in BTM_PINCodeReply()
720 btm_cb.acl_disc_reason = HCI_ERR_HOST_REJECT_SECURITY; in BTM_PINCodeReply()
737 if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) && in BTM_PINCodeReply()
739 (!btm_cb.security_mode_changed)) { in BTM_PINCodeReply()
741 btm_cb.pin_code_len = pin_len; in BTM_PINCodeReply()
742 memcpy(btm_cb.pin_code, p_pin, pin_len); in BTM_PINCodeReply()
744 btm_cb.security_mode_changed = true; in BTM_PINCodeReply()
750 btm_cb.acl_disc_reason = 0xff; in BTM_PINCodeReply()
755 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_REJECTED_CONNECT) { in BTM_PINCodeReply()
774 if (btm_cb.api.p_auth_complete_callback) in BTM_PINCodeReply()
775 (*btm_cb.api.p_auth_complete_callback)( in BTM_PINCodeReply()
783 btm_cb.acl_disc_reason = HCI_SUCCESS; in BTM_PINCodeReply()
816 if (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) { in btm_sec_bond_by_transport()
818 btm_pair_state_descr(btm_cb.pairing_state)); in btm_sec_bond_by_transport()
851 btm_cb.pin_code_len = pin_len; in btm_sec_bond_by_transport()
853 memcpy(btm_cb.pin_code, p_pin, PIN_CODE_LEN); in btm_sec_bond_by_transport()
856 btm_cb.pairing_bda = bd_addr; in btm_sec_bond_by_transport()
858 btm_cb.pairing_flags = BTM_PAIR_FLAGS_WE_STARTED_DD; in btm_sec_bond_by_transport()
870 btm_cb.pairing_flags |= BTM_PAIR_FLAGS_LE_ACTIVE; in btm_sec_bond_by_transport()
876 btm_cb.pairing_flags = 0; in btm_sec_bond_by_transport()
892 (btm_cb.cfg.pin_type != HCI_PIN_TYPE_FIXED)) { in btm_sec_bond_by_transport()
893 btm_cb.pin_type_changed = true; in btm_sec_bond_by_transport()
924 BTM_TRACE_DEBUG("sec mode: %d sm4:x%x", btm_cb.security_mode, p_dev_rec->sm4); in btm_sec_bond_by_transport()
929 if ((btm_cb.security_mode == BTM_SEC_MODE_SP || in btm_sec_bond_by_transport()
930 btm_cb.security_mode == BTM_SEC_MODE_SP_DEBUG || in btm_sec_bond_by_transport()
931 btm_cb.security_mode == BTM_SEC_MODE_SC) && in btm_sec_bond_by_transport()
946 btm_pair_state_descr(btm_cb.pairing_state), p_dev_rec->sm4, in btm_sec_bond_by_transport()
1024 btm_pair_state_descr(btm_cb.pairing_state), in BTM_SecBondCancel()
1025 btm_cb.pairing_flags); in BTM_SecBondCancel()
1027 if (!p_dev_rec || btm_cb.pairing_bda != bd_addr) { in BTM_SecBondCancel()
1031 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_LE_ACTIVE) { in BTM_SecBondCancel()
1043 if (BTM_PAIR_STATE_WAIT_LOCAL_PIN == btm_cb.pairing_state && in BTM_SecBondCancel()
1044 BTM_PAIR_FLAGS_WE_STARTED_DD & btm_cb.pairing_flags) { in BTM_SecBondCancel()
1051 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in BTM_SecBondCancel()
1052 (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD)) { in BTM_SecBondCancel()
1061 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_DISC_WHEN_DONE) in BTM_SecBondCancel()
1071 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_DISC_WHEN_DONE) { in BTM_SecBondCancel()
1075 if (btm_cb.pairing_state == BTM_PAIR_STATE_GET_REM_NAME) { in BTM_SecBondCancel()
1077 btm_cb.pairing_flags |= BTM_PAIR_FLAGS_WE_CANCEL_DD; in BTM_SecBondCancel()
1301 btm_pair_state_descr(btm_cb.pairing_state), res); in BTM_ConfirmReqReply()
1304 if ((btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_NUMERIC_CONFIRM) || in BTM_ConfirmReqReply()
1305 (btm_cb.pairing_bda != bd_addr)) in BTM_ConfirmReqReply()
1311 btm_cb.acl_disc_reason = HCI_SUCCESS; in BTM_ConfirmReqReply()
1325 btm_cb.acl_disc_reason = HCI_ERR_HOST_REJECT_SECURITY; in BTM_ConfirmReqReply()
1349 btm_pair_state_descr(btm_cb.pairing_state), res); in BTM_PasskeyReqReply()
1351 if ((btm_cb.pairing_state == BTM_PAIR_STATE_IDLE) || in BTM_PasskeyReqReply()
1352 (btm_cb.pairing_bda != bd_addr)) { in BTM_PasskeyReqReply()
1357 if ((btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_AUTH_COMPLETE) && in BTM_PasskeyReqReply()
1361 btm_cb.acl_disc_reason = HCI_ERR_HOST_REJECT_SECURITY; in BTM_PasskeyReqReply()
1375 } else if (btm_cb.pairing_state != BTM_PAIR_STATE_KEY_ENTRY) in BTM_PasskeyReqReply()
1385 btm_cb.acl_disc_reason = HCI_ERR_HOST_REJECT_SECURITY; in BTM_PasskeyReqReply()
1388 btm_cb.acl_disc_reason = HCI_SUCCESS; in BTM_PasskeyReqReply()
1411 btm_pair_state_descr(btm_cb.pairing_state), oob, io_cap); in BTM_IoCapRsp()
1413 if ((btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_LOCAL_IOCAPS) || in BTM_IoCapRsp()
1414 (btm_cb.pairing_bda != bd_addr)) in BTM_IoCapRsp()
1418 btm_cb.devcb.loc_auth_req = auth_req; in BTM_IoCapRsp()
1419 btm_cb.devcb.loc_io_caps = io_cap; in BTM_IoCapRsp()
1421 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) in BTM_IoCapRsp()
1453 btm_pair_state_descr(btm_cb.pairing_state), res); in BTM_RemoteOobDataReply()
1456 if (btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_LOCAL_OOB_RSP) return; in BTM_RemoteOobDataReply()
1463 btm_cb.acl_disc_reason = HCI_ERR_HOST_REJECT_SECURITY; in BTM_RemoteOobDataReply()
1466 btm_cb.acl_disc_reason = HCI_SUCCESS; in BTM_RemoteOobDataReply()
1532 tBTM_SEC_SERV_REC* p_serv_rec = &btm_cb.sec_serv_rec[0]; in BTM_SetOutService()
1534 btm_cb.p_out_serv = p_serv_rec; in BTM_SetOutService()
1546 btm_cb.p_out_serv = p_serv_rec; in BTM_SetOutService()
1595 && (btm_sec_io_map[p_dev_rec->rmt_io_caps][btm_cb.devcb.loc_io_caps])) in btm_sec_is_upgrade_possible()
1637 if (btm_cb.api.p_sp_callback) in btm_sec_check_upgrade()
1638 (*btm_cb.api.p_sp_callback)(BTM_SP_UPGRADE_EVT, in btm_sec_check_upgrade()
1710 (!btm_cb.devcb.secure_connections_only)) { in btm_sec_l2cap_access_req()
1714 if (btm_cb.security_mode == BTM_SEC_MODE_SC) { in btm_sec_l2cap_access_req()
1748 (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE)) { in btm_sec_l2cap_access_req()
1750 __func__, psm, btm_pair_state_descr(btm_cb.pairing_state), in btm_sec_l2cap_access_req()
1751 btm_cb.security_mode, p_dev_rec->sm4); in btm_sec_l2cap_access_req()
1755 if ((btm_cb.security_mode == BTM_SEC_MODE_UNDEFINED || in btm_sec_l2cap_access_req()
1756 btm_cb.security_mode == BTM_SEC_MODE_NONE || in btm_sec_l2cap_access_req()
1757 btm_cb.security_mode == BTM_SEC_MODE_SERVICE || in btm_sec_l2cap_access_req()
1758 btm_cb.security_mode == BTM_SEC_MODE_LINK) || in btm_sec_l2cap_access_req()
1823 btm_cb.sec_req_pending = true; in btm_sec_l2cap_access_req()
1831 if (btm_cb.security_mode == BTM_SEC_MODE_SP || in btm_sec_l2cap_access_req()
1832 btm_cb.security_mode == BTM_SEC_MODE_SP_DEBUG || in btm_sec_l2cap_access_req()
1833 btm_cb.security_mode == BTM_SEC_MODE_SC) { in btm_sec_l2cap_access_req()
1893 ((btm_cb.security_mode == BTM_SEC_MODE_UNDEFINED || in btm_sec_l2cap_access_req()
1894 btm_cb.security_mode == BTM_SEC_MODE_NONE || in btm_sec_l2cap_access_req()
1895 btm_cb.security_mode == BTM_SEC_MODE_SERVICE || in btm_sec_l2cap_access_req()
1896 btm_cb.security_mode == BTM_SEC_MODE_LINK) || in btm_sec_l2cap_access_req()
2046 if ((btm_cb.security_mode == BTM_SEC_MODE_SC) && in btm_sec_mx_access_request()
2058 (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE)) { in btm_sec_mx_access_request()
2061 btm_pair_state_descr(btm_cb.pairing_state)); in btm_sec_mx_access_request()
2065 if ((btm_cb.security_mode == BTM_SEC_MODE_UNDEFINED || in btm_sec_mx_access_request()
2066 btm_cb.security_mode == BTM_SEC_MODE_NONE || in btm_sec_mx_access_request()
2067 btm_cb.security_mode == BTM_SEC_MODE_SERVICE || in btm_sec_mx_access_request()
2068 btm_cb.security_mode == BTM_SEC_MODE_LINK) || in btm_sec_mx_access_request()
2154 rc, btm_pair_state_descr(btm_cb.pairing_state)); in btm_sec_mx_access_request()
2159 (btm_cb.security_mode == BTM_SEC_MODE_SC))) { in btm_sec_mx_access_request()
2182 if (btm_cb.security_mode == BTM_SEC_MODE_SP || in btm_sec_mx_access_request()
2183 btm_cb.security_mode == BTM_SEC_MODE_SP_DEBUG || in btm_sec_mx_access_request()
2184 btm_cb.security_mode == BTM_SEC_MODE_SC) { in btm_sec_mx_access_request()
2258 if (btm_cb.connect_only_paired) { in btm_sec_conn_req()
2269 if (btm_cb.btm_inq_vars.discoverable_mode == BTM_NON_DISCOVERABLE) { in btm_sec_conn_req()
2279 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in btm_sec_conn_req()
2280 (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) && in btm_sec_conn_req()
2281 (btm_cb.pairing_bda == bda)) { in btm_sec_conn_req()
2286 btm_cb.pairing_flags |= BTM_PAIR_FLAGS_REJECTED_CONNECT; in btm_sec_conn_req()
2293 btm_cb.connecting_bda = bda; in btm_sec_conn_req()
2294 memcpy(btm_cb.connecting_dc, dc, DEV_CLASS_LEN); in btm_sec_conn_req()
2320 if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_DISC_WHEN_DONE) || in btm_sec_bond_cancel_complete()
2321 (BTM_PAIR_STATE_WAIT_LOCAL_PIN == btm_cb.pairing_state && in btm_sec_bond_cancel_complete()
2322 BTM_PAIR_FLAGS_WE_STARTED_DD & btm_cb.pairing_flags) || in btm_sec_bond_cancel_complete()
2323 (btm_cb.pairing_state == BTM_PAIR_STATE_GET_REM_NAME && in btm_sec_bond_cancel_complete()
2324 BTM_PAIR_FLAGS_WE_CANCEL_DD & btm_cb.pairing_flags)) { in btm_sec_bond_cancel_complete()
2334 p_dev_rec = btm_find_dev(btm_cb.pairing_bda); in btm_sec_bond_cancel_complete()
2339 if (btm_cb.api.p_bond_cancel_cmpl_callback) in btm_sec_bond_cancel_complete()
2340 btm_cb.api.p_bond_cancel_cmpl_callback(BTM_SUCCESS); in btm_sec_bond_cancel_complete()
2361 btm_pair_state_descr(btm_cb.pairing_state), status); in btm_create_conn_cancel_complete()
2381 if (btm_cb.api.p_bond_cancel_cmpl_callback) in btm_create_conn_cancel_complete()
2382 btm_cb.api.p_bond_cancel_cmpl_callback(BTM_ERR_PROCESSING); in btm_create_conn_cancel_complete()
2399 if (btm_cb.pairing_state == BTM_PAIR_STATE_IDLE) { in btm_sec_check_pending_reqs()
2401 if (btm_cb.sec_req_pending) { in btm_sec_check_pending_reqs()
2402 btm_cb.sec_req_pending = false; in btm_sec_check_pending_reqs()
2407 fixed_queue_t* bq = btm_cb.sec_pending_q; in btm_sec_check_pending_reqs()
2409 btm_cb.sec_pending_q = fixed_queue_new(SIZE_MAX); in btm_sec_check_pending_reqs()
2445 btm_cb.security_mode = sec_mode; in btm_sec_init()
2446 btm_cb.pairing_bda = RawAddress::kAny; in btm_sec_init()
2461 btm_pair_state_descr(btm_cb.pairing_state)); in btm_sec_device_down()
2477 btm_cb.devcb.loc_io_caps = btif_storage_get_local_io_caps(); in btm_sec_dev_reset()
2482 btm_cb.security_mode = BTM_SEC_MODE_SERVICE; in btm_sec_dev_reset()
2485 BTM_TRACE_DEBUG("btm_sec_dev_reset sec mode: %d", btm_cb.security_mode); in btm_sec_dev_reset()
2546 btm_cb.pairing_flags |= BTM_PAIR_FLAGS_DISC_WHEN_DONE; in btm_sec_dd_create_conn()
2592 if ((!p_bd_addr && !BTM_ACL_IS_CONNECTED(btm_cb.connecting_bda)) || in btm_sec_rmt_name_request_complete()
2603 list_foreach(btm_cb.sec_dev_rec, is_state_getting_name, NULL); in btm_sec_rmt_name_request_complete()
2620 __func__, btm_pair_state_descr(btm_cb.pairing_state), p_bd_name, status, in btm_sec_rmt_name_request_complete()
2624 btm_pair_state_descr(btm_cb.pairing_state), p_bd_name, in btm_sec_rmt_name_request_complete()
2647 if (btm_cb.p_rmt_name_callback[i] && p_bd_addr) in btm_sec_rmt_name_request_complete()
2648 (*btm_cb.p_rmt_name_callback[i])(*p_bd_addr, p_dev_rec->dev_class, in btm_sec_rmt_name_request_complete()
2659 if (btm_cb.p_rmt_name_callback[i] && p_bd_addr) in btm_sec_rmt_name_request_complete()
2660 (*btm_cb.p_rmt_name_callback[i])(*p_bd_addr, dev_class, (uint8_t*)""); in btm_sec_rmt_name_request_complete()
2668 if ((btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_LOCAL_PIN) && p_bd_addr && in btm_sec_rmt_name_request_complete()
2669 (btm_cb.pairing_bda == *p_bd_addr)) { in btm_sec_rmt_name_request_complete()
2673 __func__, btm_cb.pairing_flags, btm_cb.api.p_pin_callback); in btm_sec_rmt_name_request_complete()
2675 if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_PIN_REQD) == 0 && in btm_sec_rmt_name_request_complete()
2676 btm_cb.api.p_pin_callback) { in btm_sec_rmt_name_request_complete()
2678 btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD; in btm_sec_rmt_name_request_complete()
2679 (*btm_cb.api.p_pin_callback)( in btm_sec_rmt_name_request_complete()
2693 if (btm_cb.pairing_state == BTM_PAIR_STATE_GET_REM_NAME) { in btm_sec_rmt_name_request_complete()
2694 if (p_bd_addr && btm_cb.pairing_bda == *p_bd_addr) { in btm_sec_rmt_name_request_complete()
2697 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_CANCEL_DD) { in btm_sec_rmt_name_request_complete()
2705 if (btm_cb.api.p_auth_complete_callback) in btm_sec_rmt_name_request_complete()
2706 (*btm_cb.api.p_auth_complete_callback)( in btm_sec_rmt_name_request_complete()
2719 btm_cb.pairing_flags); in btm_sec_rmt_name_request_complete()
2720 if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_REJECTED_CONNECT) == 0) in btm_sec_rmt_name_request_complete()
2740 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_REJECTED_CONNECT) { in btm_sec_rmt_name_request_complete()
2751 if (btm_cb.api.p_auth_complete_callback) { in btm_sec_rmt_name_request_complete()
2752 (*btm_cb.api.p_auth_complete_callback)( in btm_sec_rmt_name_request_complete()
2761 if (BTM_ReadRemoteDeviceName(btm_cb.pairing_bda, NULL, in btm_sec_rmt_name_request_complete()
2764 if (btm_cb.api.p_auth_complete_callback) { in btm_sec_rmt_name_request_complete()
2765 (*btm_cb.api.p_auth_complete_callback)( in btm_sec_rmt_name_request_complete()
2788 if (btm_cb.api.p_auth_complete_callback) in btm_sec_rmt_name_request_complete()
2789 (*btm_cb.api.p_auth_complete_callback)( in btm_sec_rmt_name_request_complete()
2796 if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) && in btm_sec_rmt_name_request_complete()
2884 evt_data.io_cap = btm_cb.devcb.loc_io_caps; in btm_io_capabilities_req()
2889 btm_pair_state_descr(btm_cb.pairing_state)); in btm_io_capabilities_req()
2894 __func__, btm_cb.security_mode, p_dev_rec->num_read_pages); in btm_io_capabilities_req()
2896 if ((btm_cb.security_mode == BTM_SEC_MODE_SC) && in btm_io_capabilities_req()
2908 __func__, btm_pair_state_descr(btm_cb.pairing_state), in btm_io_capabilities_req()
2909 btm_cb.pairing_flags, p_dev_rec->p_cur_service); in btm_io_capabilities_req()
2917 switch (btm_cb.pairing_state) { in btm_io_capabilities_req()
2928 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_PEER_STARTED_DD) { in btm_io_capabilities_req()
2937 if (evt_data.bd_addr == btm_cb.pairing_bda) { in btm_io_capabilities_req()
2948 btm_cb.pairing_state); in btm_io_capabilities_req()
2952 if (btm_cb.pairing_disabled) { in btm_io_capabilities_req()
2956 } else if (btm_cb.security_mode == BTM_SEC_MODE_SC) { in btm_io_capabilities_req()
2980 if (!(btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) && in btm_io_capabilities_req()
2983 if (btm_cb.security_mode == BTM_SEC_MODE_SC) { in btm_io_capabilities_req()
2998 btm_cb.pairing_bda = evt_data.bd_addr; in btm_io_capabilities_req()
3000 if (evt_data.bd_addr == btm_cb.connecting_bda) in btm_io_capabilities_req()
3001 memcpy(p_dev_rec->dev_class, btm_cb.connecting_dc, DEV_CLASS_LEN); in btm_io_capabilities_req()
3012 } else if (btm_cb.api.p_sp_callback) { in btm_io_capabilities_req()
3014 callback_rc = (*btm_cb.api.p_sp_callback)(BTM_SP_IO_REQ_EVT, in btm_io_capabilities_req()
3019 if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD)) { in btm_io_capabilities_req()
3024 if (btm_cb.security_mode == BTM_SEC_MODE_SC) { in btm_io_capabilities_req()
3037 btm_cb.devcb.loc_auth_req = evt_data.auth_req; in btm_io_capabilities_req()
3038 btm_cb.devcb.loc_io_caps = evt_data.io_cap; in btm_io_capabilities_req()
3041 __func__, btm_pair_state_descr(btm_cb.pairing_state), in btm_io_capabilities_req()
3072 if (btm_cb.pairing_state == BTM_PAIR_STATE_IDLE) { in btm_io_capabilities_rsp()
3073 btm_cb.pairing_bda = evt_data.bd_addr; in btm_io_capabilities_rsp()
3089 if (evt_data.bd_addr == btm_cb.connecting_bda) in btm_io_capabilities_rsp()
3090 memcpy(p_dev_rec->dev_class, btm_cb.connecting_dc, DEV_CLASS_LEN); in btm_io_capabilities_rsp()
3094 if (btm_cb.pairing_state == in btm_io_capabilities_rsp()
3099 btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PEER_STARTED_DD; in btm_io_capabilities_rsp()
3106 if (btm_cb.api.p_sp_callback) in btm_io_capabilities_rsp()
3107 (*btm_cb.api.p_sp_callback)(BTM_SP_IO_RSP_EVT, in btm_io_capabilities_rsp()
3133 << " State: " << btm_pair_state_descr(btm_cb.pairing_state); in btm_proc_sp_req_evt()
3136 if ((p_dev_rec != NULL) && (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in btm_proc_sp_req_evt()
3137 (btm_cb.pairing_bda == p_bda)) { in btm_proc_sp_req_evt()
3157 if (btm_cb.devcb.loc_io_caps == BTM_IO_CAP_IO) { in btm_proc_sp_req_evt()
3168 (btm_cb.devcb.loc_io_caps == BTM_IO_CAP_IO) && in btm_proc_sp_req_evt()
3170 (btm_cb.devcb.loc_auth_req & BTM_AUTH_SP_YES))) { in btm_proc_sp_req_evt()
3180 evt_data.cfm_req.just_works, btm_cb.devcb.loc_io_caps, in btm_proc_sp_req_evt()
3181 p_dev_rec->rmt_io_caps, btm_cb.devcb.loc_auth_req, in btm_proc_sp_req_evt()
3184 evt_data.cfm_req.loc_auth_req = btm_cb.devcb.loc_auth_req; in btm_proc_sp_req_evt()
3186 evt_data.cfm_req.loc_io_caps = btm_cb.devcb.loc_io_caps; in btm_proc_sp_req_evt()
3200 if (btm_cb.devcb.loc_io_caps != BTM_IO_CAP_NONE) { in btm_proc_sp_req_evt()
3207 if (btm_cb.api.p_sp_callback) { in btm_proc_sp_req_evt()
3208 status = (*btm_cb.api.p_sp_callback)(event, &evt_data); in btm_proc_sp_req_evt()
3222 } else if (btm_cb.devcb.loc_io_caps != BTM_IO_CAP_NONE && in btm_proc_sp_req_evt()
3230 btm_cb.acl_disc_reason = HCI_ERR_HOST_REJECT_SECURITY; in btm_proc_sp_req_evt()
3246 } else if (btm_cb.devcb.loc_io_caps != BTM_IO_CAP_NONE) { in btm_proc_sp_req_evt()
3265 if (btm_cb.api.p_sp_callback) { in btm_keypress_notif_evt()
3271 (*btm_cb.api.p_sp_callback)(BTM_SP_KEYPRESS_EVT, in btm_keypress_notif_evt()
3303 btm_pair_state_descr(btm_cb.pairing_state), status, p_dev_rec->sec_state); in btm_simple_pair_complete()
3315 alarm_set_on_mloop(btm_cb.pairing_timer, BT_1SEC_TIMEOUT_MS, in btm_simple_pair_complete()
3317 } else if (btm_cb.pairing_bda == evt_data.bd_addr) { in btm_simple_pair_complete()
3319 alarm_cancel(btm_cb.pairing_timer); in btm_simple_pair_complete()
3335 if (btm_cb.api.p_sp_callback) in btm_simple_pair_complete()
3336 (*btm_cb.api.p_sp_callback)(BTM_SP_COMPLT_EVT, in btm_simple_pair_complete()
3372 if ((p_dev_rec != NULL) && btm_cb.api.p_sp_callback) { in btm_rem_oob_req()
3379 if ((*btm_cb.api.p_sp_callback)(BTM_SP_RMT_OOB_EVT, in btm_rem_oob_req()
3388 btm_cb.acl_disc_reason = HCI_ERR_HOST_REJECT_SECURITY; in btm_rem_oob_req()
3414 if (btm_cb.api.p_sp_callback) { in btm_read_local_oob_complete()
3417 (*btm_cb.api.p_sp_callback)(BTM_SP_LOC_OOB_EVT, &btm_sp_evt_data); in btm_read_local_oob_complete()
3434 if (!btm_cb.collision_start_time) in btm_sec_auth_collision()
3435 btm_cb.collision_start_time = bluetooth::common::time_get_os_boottime_ms(); in btm_sec_auth_collision()
3438 btm_cb.collision_start_time) < BTM_SEC_MAX_COLLISION_DELAY) { in btm_sec_auth_collision()
3455 btm_cb.p_collided_dev_rec = p_dev_rec; in btm_sec_auth_collision()
3456 alarm_set_on_mloop(btm_cb.sec_collision_timer, BT_1SEC_TIMEOUT_MS, in btm_sec_auth_collision()
3480 if ((btm_cb.pairing_state == BTM_PAIR_STATE_IDLE) && in btm_sec_auth_retry()
3487 btm_cb.collision_start_time = 0; in btm_sec_auth_retry()
3517 tBTM_PAIRING_STATE old_state = btm_cb.pairing_state; in btm_sec_auth_complete()
3524 << btm_pair_state_descr(btm_cb.pairing_state) in btm_sec_auth_complete()
3531 << btm_pair_state_descr(btm_cb.pairing_state) in btm_sec_auth_complete()
3545 btm_cb.collision_start_time = 0; in btm_sec_auth_complete()
3552 if (p_dev_rec && (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) && in btm_sec_auth_complete()
3553 !(btm_cb.pairing_flags & BTM_PAIR_FLAGS_DISC_WHEN_DONE)) { in btm_sec_auth_complete()
3581 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in btm_sec_auth_complete()
3582 (p_dev_rec->bd_addr == btm_cb.pairing_bda)) { in btm_sec_auth_complete()
3583 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) { in btm_sec_auth_complete()
3590 if ((btm_cb.api.p_auth_complete_callback && status != HCI_SUCCESS) && in btm_sec_auth_complete()
3592 (*btm_cb.api.p_auth_complete_callback)(p_dev_rec->bd_addr, in btm_sec_auth_complete()
3601 if (btm_cb.api.p_auth_complete_callback) { in btm_sec_auth_complete()
3604 (*btm_cb.api.p_auth_complete_callback)(p_dev_rec->bd_addr, in btm_sec_auth_complete()
3647 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_DISC_WHEN_DONE) { in btm_sec_auth_complete()
3699 btm_cb.collision_start_time = 0; in btm_sec_encrypt_change()
3729 if (acl_idx != MAX_L2CAP_LINKS) p_acl = &btm_cb.acl_db[acl_idx]; in btm_sec_encrypt_change()
3755 btm_cb.devcb.loc_auth_req == BTM_AUTH_SP_NO) { in btm_sec_encrypt_change()
3835 tBTM_SEC_DEV_REC* p_dev_rec = btm_cb.p_collided_dev_rec; in btm_sec_connect_after_reject_timeout()
3838 btm_cb.p_collided_dev_rec = 0; in btm_sec_connect_after_reject_timeout()
3846 if (btm_cb.api.p_auth_complete_callback) in btm_sec_connect_after_reject_timeout()
3847 (*btm_cb.api.p_auth_complete_callback)( in btm_sec_connect_after_reject_timeout()
3876 << btm_pair_state_descr(btm_cb.pairing_state) in btm_sec_connected()
3882 << btm_pair_state_descr(btm_cb.pairing_state) in btm_sec_connected()
3894 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in btm_sec_connected()
3895 btm_cb.pairing_bda == bda) { in btm_sec_connected()
3906 p_dev_rec->timestamp = btm_cb.dev_rec_count++; in btm_sec_connected()
3909 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in btm_sec_connected()
3910 (btm_cb.pairing_bda == p_dev_rec->bd_addr) && in btm_sec_connected()
3911 (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD)) { in btm_sec_connected()
3916 (btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_PIN_REQ)) { in btm_sec_connected()
3925 btm_cb.p_collided_dev_rec = p_dev_rec; in btm_sec_connected()
3926 alarm_set_on_mloop(btm_cb.sec_collision_timer, 0, in btm_sec_connected()
3958 addr_matched = (btm_cb.pairing_bda == bda); in btm_sec_connected()
3960 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && addr_matched) { in btm_sec_connected()
3963 (btm_cb.pairing_flags & BTM_PAIR_FLAGS_REJECTED_CONNECT)) { in btm_sec_connected()
3967 btm_cb.pairing_flags, p_dev_rec->sm4); in btm_sec_connected()
3969 btm_cb.pairing_flags &= ~BTM_PAIR_FLAGS_REJECTED_CONNECT; in btm_sec_connected()
3982 if (btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_LOCAL_PIN) { in btm_sec_connected()
3985 btm_cb.p_collided_dev_rec = p_dev_rec; in btm_sec_connected()
3986 alarm_set_on_mloop(btm_cb.sec_collision_timer, 0, in btm_sec_connected()
4017 if (btm_cb.api.p_auth_complete_callback) { in btm_sec_connected()
4018 (*btm_cb.api.p_auth_complete_callback)(p_dev_rec->bd_addr, in btm_sec_connected()
4043 if (btm_cb.acl_disc_reason == HCI_ERR_HOST_REJECT_SECURITY) { in btm_sec_connected()
4049 if (btm_cb.api.p_auth_complete_callback) { in btm_sec_connected()
4050 (*btm_cb.api.p_auth_complete_callback)(p_dev_rec->bd_addr, in btm_sec_connected()
4090 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) in btm_sec_connected()
4095 if (btm_cb.api.p_auth_complete_callback) in btm_sec_connected()
4096 (*btm_cb.api.p_auth_complete_callback)( in btm_sec_connected()
4124 btm_set_packet_types(p_acl_cb, btm_cb.btm_acl_pkt_types_supported); in btm_sec_connected()
4126 if (btm_cb.btm_def_link_policy) in btm_sec_connected()
4127 BTM_SetLinkPolicy(p_acl_cb->remote_addr, &btm_cb.btm_def_link_policy); in btm_sec_connected()
4144 if (btm_cb.security_mode == BTM_SEC_MODE_LINK) in btm_sec_connected()
4188 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in btm_sec_disconnect()
4189 (btm_cb.pairing_bda == p_dev_rec->bd_addr) && in btm_sec_disconnect()
4190 (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD)) { in btm_sec_disconnect()
4192 btm_cb.pairing_flags |= BTM_PAIR_FLAGS_DISC_WHEN_DONE; in btm_sec_disconnect()
4211 uint8_t old_pairing_flags = btm_cb.pairing_flags; in btm_sec_disconnected()
4217 btm_cb.discing = false; in btm_sec_disconnected()
4239 << " state: " << btm_pair_state_descr(btm_cb.pairing_state) in btm_sec_disconnected()
4248 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in btm_sec_disconnected()
4249 (btm_cb.pairing_bda == p_dev_rec->bd_addr)) { in btm_sec_disconnected()
4252 if (btm_cb.api.p_auth_complete_callback) { in btm_sec_disconnected()
4262 (*btm_cb.api.p_auth_complete_callback)(p_dev_rec->bd_addr, in btm_sec_disconnected()
4374 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in btm_sec_link_key_notification()
4375 (btm_cb.pairing_bda == p_bda)) { in btm_sec_link_key_notification()
4376 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) in btm_sec_link_key_notification()
4384 if (btm_cb.api.p_link_key_callback) { in btm_sec_link_key_notification()
4387 (*btm_cb.api.p_link_key_callback)(p_bda, p_dev_rec->dev_class, in btm_sec_link_key_notification()
4431 if (btm_cb.api.p_auth_complete_callback) in btm_sec_link_key_notification()
4432 (*btm_cb.api.p_auth_complete_callback)( in btm_sec_link_key_notification()
4443 if (btm_cb.api.p_link_key_callback) { in btm_sec_link_key_notification()
4450 (*btm_cb.api.p_link_key_callback)(p_bda, p_dev_rec->dev_class, in btm_sec_link_key_notification()
4472 if ((btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_PIN_REQ) && in btm_sec_link_key_request()
4473 (btm_cb.collision_start_time != 0) && in btm_sec_link_key_request()
4474 (btm_cb.p_collided_dev_rec->bd_addr == bda)) { in btm_sec_link_key_request()
4478 btm_cb.pairing_state, btm_cb.collision_start_time); in btm_sec_link_key_request()
4505 tBTM_CB* p_cb = &btm_cb; in btm_sec_pairing_timeout()
4507 tBTM_AUTH_REQ auth_req = (btm_cb.devcb.loc_io_caps == BTM_IO_CAP_NONE) in btm_sec_pairing_timeout()
4524 if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_PRE_FETCH_PIN) == 0) in btm_sec_pairing_timeout()
4528 if (btm_cb.api.p_auth_complete_callback) { in btm_sec_pairing_timeout()
4531 (*btm_cb.api.p_auth_complete_callback)(p_cb->pairing_bda, NULL, name, in btm_sec_pairing_timeout()
4534 (*btm_cb.api.p_auth_complete_callback)( in btm_sec_pairing_timeout()
4546 if (btm_cb.devcb.loc_io_caps != BTM_IO_CAP_NONE) { in btm_sec_pairing_timeout()
4554 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) in btm_sec_pairing_timeout()
4557 btsnd_hcic_io_cap_req_reply(p_cb->pairing_bda, btm_cb.devcb.loc_io_caps, in btm_sec_pairing_timeout()
4587 if (btm_cb.api.p_auth_complete_callback) { in btm_sec_pairing_timeout()
4590 (*btm_cb.api.p_auth_complete_callback)(p_cb->pairing_bda, NULL, name, in btm_sec_pairing_timeout()
4593 (*btm_cb.api.p_auth_complete_callback)( in btm_sec_pairing_timeout()
4601 btm_pair_state_descr(btm_cb.pairing_state)); in btm_sec_pairing_timeout()
4618 tBTM_CB* p_cb = &btm_cb; in btm_sec_pin_code_request()
4621 << " state: " << btm_pair_state_descr(btm_cb.pairing_state); in btm_sec_pin_code_request()
4623 if (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) { in btm_sec_pin_code_request()
4624 if ((p_bda == btm_cb.pairing_bda) && in btm_sec_pin_code_request()
4625 (btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_AUTH_COMPLETE)) { in btm_sec_pin_code_request()
4628 } else if ((btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_PIN_REQ) || in btm_sec_pin_code_request()
4629 p_bda != btm_cb.pairing_bda) { in btm_sec_pin_code_request()
4631 btm_pair_state_descr(btm_cb.pairing_state)); in btm_sec_pin_code_request()
4641 if (btm_cb.pairing_state == BTM_PAIR_STATE_IDLE) { in btm_sec_pin_code_request()
4642 btm_cb.pairing_bda = p_bda; in btm_sec_pin_code_request()
4644 btm_cb.pairing_flags = BTM_PAIR_FLAGS_PEER_STARTED_DD; in btm_sec_pin_code_request()
4664 if (btm_cb.pin_code_len != 0) { in btm_sec_pin_code_request()
4666 btsnd_hcic_pin_code_req_reply(p_bda, btm_cb.pin_code_len, p_cb->pin_code); in btm_sec_pin_code_request()
4669 btm_cb.pin_code_len = 0; in btm_sec_pin_code_request()
4717 btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD; in btm_sec_pin_code_request()
4961 if (!btm_cb.api.p_authorize_callback) return (BTM_MODE_UNSUPPORTED); in btm_sec_start_authorization()
4979 result = (*btm_cb.api.p_authorize_callback)( in btm_sec_start_authorization()
5040 tBTM_SEC_SERV_REC* p_serv_rec = &btm_cb.sec_serv_rec[0]; in btm_sec_find_first_serv()
5044 if (is_originator && btm_cb.p_out_serv && btm_cb.p_out_serv->psm == psm) { in btm_sec_find_first_serv()
5047 return btm_cb.p_out_serv; in btm_sec_find_first_serv()
5070 tBTM_SEC_SERV_REC* p_serv_rec = &btm_cb.sec_serv_rec[0]; in btm_sec_find_next_serv()
5098 tBTM_SEC_SERV_REC* p_out_serv = btm_cb.p_out_serv; in btm_sec_find_mx_serv()
5099 tBTM_SEC_SERV_REC* p_serv_rec = &btm_cb.sec_serv_rec[0]; in btm_sec_find_mx_serv()
5108 return btm_cb.p_out_serv; in btm_sec_find_mx_serv()
5136 tBTM_STATUS status = btm_sec_execute_procedure(btm_cb.p_collided_dev_rec); in btm_sec_collision_timeout()
5142 btm_sec_dev_rec_cback_event(btm_cb.p_collided_dev_rec, status, false); in btm_sec_collision_timeout()
5156 if (btm_cb.api.p_link_key_callback) in btm_send_link_key_notif()
5157 (*btm_cb.api.p_link_key_callback)( in btm_send_link_key_notif()
5192 if (btm_cb.security_mode_changed) { in btm_restore_mode()
5193 btm_cb.security_mode_changed = false; in btm_restore_mode()
5195 (btm_cb.security_mode == BTM_SEC_MODE_LINK)); in btm_restore_mode()
5197 (uint8_t)(btm_cb.security_mode == BTM_SEC_MODE_LINK)); in btm_restore_mode()
5200 if (btm_cb.pin_type_changed) { in btm_restore_mode()
5201 btm_cb.pin_type_changed = false; in btm_restore_mode()
5202 btsnd_hcic_write_pin_type(btm_cb.cfg.pin_type); in btm_restore_mode()
5226 list_node_t* n = list_foreach(btm_cb.sec_dev_rec, is_sec_state_equal, &state); in btm_sec_find_dev_by_sec_state()
5240 tBTM_PAIRING_STATE old_state = btm_cb.pairing_state; in btm_sec_change_pairing_state()
5243 btm_pair_state_descr(btm_cb.pairing_state)); in btm_sec_change_pairing_state()
5245 btm_pair_state_descr(new_state), btm_cb.pairing_flags); in btm_sec_change_pairing_state()
5247 btm_cb.pairing_state = new_state; in btm_sec_change_pairing_state()
5250 alarm_cancel(btm_cb.pairing_timer); in btm_sec_change_pairing_state()
5252 btm_cb.pairing_flags = 0; in btm_sec_change_pairing_state()
5253 btm_cb.pin_code_len = 0; in btm_sec_change_pairing_state()
5256 l2cu_update_lcb_4_bonding(btm_cb.pairing_bda, false); in btm_sec_change_pairing_state()
5262 btm_cb.pairing_bda = RawAddress::kAny; in btm_sec_change_pairing_state()
5266 l2cu_update_lcb_4_bonding(btm_cb.pairing_bda, true); in btm_sec_change_pairing_state()
5268 alarm_set_on_mloop(btm_cb.pairing_timer, BTM_SEC_TIMEOUT_VALUE * 1000, in btm_sec_change_pairing_state()
5370 fixed_queue_enqueue(btm_cb.sec_pending_q, p_e); in btm_sec_queue_mx_request()
5388 if (!btm_cb.security_mode_changed) { in btm_sec_check_prefetch_pin()
5389 btm_cb.security_mode_changed = true; in btm_sec_check_prefetch_pin()
5399 if (btm_cb.pin_code_len) { in btm_sec_check_prefetch_pin()
5400 BTM_PINCodeReply(p_dev_rec->bd_addr, BTM_SUCCESS, btm_cb.pin_code_len, in btm_sec_check_prefetch_pin()
5401 btm_cb.pin_code, p_dev_rec->trusted_mask); in btm_sec_check_prefetch_pin()
5404 if (btm_cb.api.p_pin_callback && in btm_sec_check_prefetch_pin()
5405 ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_PIN_REQD) == 0)) { in btm_sec_check_prefetch_pin()
5408 btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD; in btm_sec_check_prefetch_pin()
5409 (btm_cb.api.p_pin_callback)( in btm_sec_check_prefetch_pin()
5468 fixed_queue_enqueue(btm_cb.sec_pending_q, p_e); in btm_sec_queue_encrypt_request()
5485 if ((btm_cb.security_mode == BTM_SEC_MODE_SP || in btm_sec_set_peer_sec_caps()
5486 btm_cb.security_mode == BTM_SEC_MODE_SP_DEBUG || in btm_sec_set_peer_sec_caps()
5487 btm_cb.security_mode == BTM_SEC_MODE_SC) && in btm_sec_set_peer_sec_caps()
5541 if (fixed_queue_is_empty(btm_cb.sec_pending_q)) return; in btm_sec_check_pending_enc_req()
5544 list_t* list = fixed_queue_get_list(btm_cb.sec_pending_q); in btm_sec_check_pending_enc_req()
5559 fixed_queue_try_remove_from_queue(btm_cb.sec_pending_q, (void*)p_e); in btm_sec_check_pending_enc_req()