• Home
  • Raw
  • Download

Lines Matching refs:btm_cb

246     if (btm_cb.devcb.id_keys.ir == zero) {  in BTM_SecRegister()
253 btm_cb.api = *p_cb_info; in BTM_SecRegister()
255 btm_cb.api.p_le_callback); in BTM_SecRegister()
273 btm_cb.api.p_link_key_callback = p_callback; in BTM_SecRegisterLinkKeyNotificationCallback()
291 if (btm_cb.p_rmt_name_callback[i] == NULL) { in BTM_SecAddRmtNameNotifyCallback()
292 btm_cb.p_rmt_name_callback[i] = p_callback; in BTM_SecAddRmtNameNotifyCallback()
314 if (btm_cb.p_rmt_name_callback[i] == p_callback) { in BTM_SecDeleteRmtNameNotifyCallback()
315 btm_cb.p_rmt_name_callback[i] = NULL; in BTM_SecDeleteRmtNameNotifyCallback()
386 if ((btm_cb.cfg.pin_type != pin_type) && in BTM_SetPinType()
391 btm_cb.cfg.pin_type = pin_type; in BTM_SetPinType()
392 btm_cb.cfg.pin_code_len = pin_code_len; in BTM_SetPinType()
393 memcpy(btm_cb.cfg.pin_code, pin_code, pin_code_len); in BTM_SetPinType()
415 btm_cb.pairing_disabled = !allow_pairing; in BTM_SetPairableMode()
416 btm_cb.connect_only_paired = connect_only_paired; in BTM_SetPairableMode()
438 btm_cb.devcb.secure_connections_only = secure_connections_only_mode; in BTM_SetSecureConnectionsOnly()
439 btm_cb.security_mode = BTM_SEC_MODE_SC; in BTM_SetSecureConnectionsOnly()
507 p_srec = &btm_cb.sec_serv_rec[0]; in btm_sec_set_security_level()
548 p_srec = &btm_cb.sec_serv_rec[index]; in btm_sec_set_security_level()
575 if (btm_cb.security_mode == BTM_SEC_MODE_SP || in btm_sec_set_security_level()
576 btm_cb.security_mode == BTM_SEC_MODE_SP_DEBUG || in btm_sec_set_security_level()
577 btm_cb.security_mode == BTM_SEC_MODE_SC) { in btm_sec_set_security_level()
587 btm_cb.p_out_serv = p_srec; in btm_sec_set_security_level()
608 if (btm_cb.security_mode == BTM_SEC_MODE_SP || in btm_sec_set_security_level()
609 btm_cb.security_mode == BTM_SEC_MODE_SP_DEBUG || in btm_sec_set_security_level()
610 btm_cb.security_mode == BTM_SEC_MODE_SC) { in btm_sec_set_security_level()
652 tBTM_SEC_SERV_REC* p_srec = &btm_cb.sec_serv_rec[0]; in BTM_SecClrService()
687 tBTM_SEC_SERV_REC* p_srec = &btm_cb.sec_serv_rec[0]; in btm_sec_clr_service_by_psm()
760 btm_pair_state_descr(btm_cb.pairing_state), btm_cb.pairing_flags, pin_len, in BTM_PINCodeReply()
764 if (btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_LOCAL_PIN) { in BTM_PINCodeReply()
766 btm_cb.pairing_state); in BTM_PINCodeReply()
770 if (bd_addr != btm_cb.pairing_bda) { in BTM_PINCodeReply()
787 if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_PEER_STARTED_DD) || in BTM_PINCodeReply()
788 ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) && in BTM_PINCodeReply()
789 (btm_cb.pairing_flags & BTM_PAIR_FLAGS_DISC_WHEN_DONE))) { in BTM_PINCodeReply()
793 btm_cb.acl_disc_reason = HCI_ERR_HOST_REJECT_SECURITY; in BTM_PINCodeReply()
810 if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) && in BTM_PINCodeReply()
812 (!btm_cb.security_mode_changed)) { in BTM_PINCodeReply()
814 btm_cb.pin_code_len = pin_len; in BTM_PINCodeReply()
815 memcpy(btm_cb.pin_code, p_pin, pin_len); in BTM_PINCodeReply()
817 btm_cb.security_mode_changed = true; in BTM_PINCodeReply()
823 btm_cb.acl_disc_reason = 0xff; in BTM_PINCodeReply()
828 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_REJECTED_CONNECT) { in BTM_PINCodeReply()
847 if (btm_cb.api.p_auth_complete_callback) in BTM_PINCodeReply()
848 (*btm_cb.api.p_auth_complete_callback)( in BTM_PINCodeReply()
856 btm_cb.acl_disc_reason = HCI_SUCCESS; in BTM_PINCodeReply()
889 if (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) { in btm_sec_bond_by_transport()
891 btm_pair_state_descr(btm_cb.pairing_state)); in btm_sec_bond_by_transport()
924 btm_cb.pin_code_len = pin_len; in btm_sec_bond_by_transport()
926 memcpy(btm_cb.pin_code, p_pin, PIN_CODE_LEN); in btm_sec_bond_by_transport()
929 btm_cb.pairing_bda = bd_addr; in btm_sec_bond_by_transport()
931 btm_cb.pairing_flags = BTM_PAIR_FLAGS_WE_STARTED_DD; in btm_sec_bond_by_transport()
943 btm_cb.pairing_flags |= BTM_PAIR_FLAGS_LE_ACTIVE; in btm_sec_bond_by_transport()
949 btm_cb.pairing_flags = 0; in btm_sec_bond_by_transport()
965 (btm_cb.cfg.pin_type != HCI_PIN_TYPE_FIXED)) { in btm_sec_bond_by_transport()
966 btm_cb.pin_type_changed = true; in btm_sec_bond_by_transport()
997 BTM_TRACE_DEBUG("sec mode: %d sm4:x%x", btm_cb.security_mode, p_dev_rec->sm4); in btm_sec_bond_by_transport()
1002 if ((btm_cb.security_mode == BTM_SEC_MODE_SP || in btm_sec_bond_by_transport()
1003 btm_cb.security_mode == BTM_SEC_MODE_SP_DEBUG || in btm_sec_bond_by_transport()
1004 btm_cb.security_mode == BTM_SEC_MODE_SC) && in btm_sec_bond_by_transport()
1019 btm_pair_state_descr(btm_cb.pairing_state), p_dev_rec->sm4, in btm_sec_bond_by_transport()
1108 btm_pair_state_descr(btm_cb.pairing_state), in BTM_SecBondCancel()
1109 btm_cb.pairing_flags); in BTM_SecBondCancel()
1111 if (!p_dev_rec || btm_cb.pairing_bda != bd_addr) { in BTM_SecBondCancel()
1115 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_LE_ACTIVE) { in BTM_SecBondCancel()
1127 if (BTM_PAIR_STATE_WAIT_LOCAL_PIN == btm_cb.pairing_state && in BTM_SecBondCancel()
1128 BTM_PAIR_FLAGS_WE_STARTED_DD & btm_cb.pairing_flags) { in BTM_SecBondCancel()
1135 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in BTM_SecBondCancel()
1136 (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD)) { in BTM_SecBondCancel()
1145 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_DISC_WHEN_DONE) in BTM_SecBondCancel()
1155 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_DISC_WHEN_DONE) { in BTM_SecBondCancel()
1159 if (btm_cb.pairing_state == BTM_PAIR_STATE_GET_REM_NAME) { in BTM_SecBondCancel()
1161 btm_cb.pairing_flags |= BTM_PAIR_FLAGS_WE_CANCEL_DD; in BTM_SecBondCancel()
1402 btm_pair_state_descr(btm_cb.pairing_state), res); in BTM_ConfirmReqReply()
1405 if ((btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_NUMERIC_CONFIRM) || in BTM_ConfirmReqReply()
1406 (btm_cb.pairing_bda != bd_addr)) in BTM_ConfirmReqReply()
1412 btm_cb.acl_disc_reason = HCI_SUCCESS; in BTM_ConfirmReqReply()
1426 btm_cb.acl_disc_reason = HCI_ERR_HOST_REJECT_SECURITY; in BTM_ConfirmReqReply()
1448 btm_pair_state_descr(btm_cb.pairing_state), res); in BTM_PasskeyReqReply()
1450 if ((btm_cb.pairing_state == BTM_PAIR_STATE_IDLE) || in BTM_PasskeyReqReply()
1451 (btm_cb.pairing_bda != bd_addr)) { in BTM_PasskeyReqReply()
1456 if ((btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_AUTH_COMPLETE) && in BTM_PasskeyReqReply()
1460 btm_cb.acl_disc_reason = HCI_ERR_HOST_REJECT_SECURITY; in BTM_PasskeyReqReply()
1474 } else if (btm_cb.pairing_state != BTM_PAIR_STATE_KEY_ENTRY) in BTM_PasskeyReqReply()
1484 btm_cb.acl_disc_reason = HCI_ERR_HOST_REJECT_SECURITY; in BTM_PasskeyReqReply()
1487 btm_cb.acl_disc_reason = HCI_SUCCESS; in BTM_PasskeyReqReply()
1508 if (btm_cb.pairing_state == BTM_PAIR_STATE_KEY_ENTRY) in BTM_SendKeypressNotif()
1530 btm_pair_state_descr(btm_cb.pairing_state), oob, io_cap); in BTM_IoCapRsp()
1532 if ((btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_LOCAL_IOCAPS) || in BTM_IoCapRsp()
1533 (btm_cb.pairing_bda != bd_addr)) in BTM_IoCapRsp()
1537 btm_cb.devcb.loc_auth_req = auth_req; in BTM_IoCapRsp()
1538 btm_cb.devcb.loc_io_caps = io_cap; in BTM_IoCapRsp()
1540 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) in BTM_IoCapRsp()
1572 btm_pair_state_descr(btm_cb.pairing_state), res); in BTM_RemoteOobDataReply()
1575 if (btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_LOCAL_OOB_RSP) return; in BTM_RemoteOobDataReply()
1582 btm_cb.acl_disc_reason = HCI_ERR_HOST_REJECT_SECURITY; in BTM_RemoteOobDataReply()
1585 btm_cb.acl_disc_reason = HCI_SUCCESS; in BTM_RemoteOobDataReply()
1650 DEVCLASS_TO_STREAM(p, btm_cb.devcb.dev_class); in BTM_BuildOobData()
1655 if (name_size > strlen(btm_cb.cfg.bd_name)) { in BTM_BuildOobData()
1657 name_size = (uint16_t)strlen(btm_cb.cfg.bd_name); in BTM_BuildOobData()
1663 ARRAY_TO_STREAM(p, btm_cb.cfg.bd_name, name_size); in BTM_BuildOobData()
1793 tBTM_SEC_SERV_REC* p_serv_rec = &btm_cb.sec_serv_rec[0]; in BTM_SetOutService()
1795 btm_cb.p_out_serv = p_serv_rec; in BTM_SetOutService()
1807 btm_cb.p_out_serv = p_serv_rec; in BTM_SetOutService()
1856 && (btm_sec_io_map[p_dev_rec->rmt_io_caps][btm_cb.devcb.loc_io_caps])) in btm_sec_is_upgrade_possible()
1898 if (btm_cb.api.p_sp_callback) in btm_sec_check_upgrade()
1899 (*btm_cb.api.p_sp_callback)(BTM_SP_UPGRADE_EVT, in btm_sec_check_upgrade()
1973 (!btm_cb.devcb.secure_connections_only)) { in btm_sec_l2cap_access_req()
1977 if (btm_cb.security_mode == BTM_SEC_MODE_SC) { in btm_sec_l2cap_access_req()
2011 (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE)) { in btm_sec_l2cap_access_req()
2013 __func__, psm, btm_pair_state_descr(btm_cb.pairing_state), in btm_sec_l2cap_access_req()
2014 btm_cb.security_mode, p_dev_rec->sm4); in btm_sec_l2cap_access_req()
2018 if ((btm_cb.security_mode == BTM_SEC_MODE_UNDEFINED || in btm_sec_l2cap_access_req()
2019 btm_cb.security_mode == BTM_SEC_MODE_NONE || in btm_sec_l2cap_access_req()
2020 btm_cb.security_mode == BTM_SEC_MODE_SERVICE || in btm_sec_l2cap_access_req()
2021 btm_cb.security_mode == BTM_SEC_MODE_LINK) || in btm_sec_l2cap_access_req()
2086 btm_cb.sec_req_pending = true; in btm_sec_l2cap_access_req()
2094 if (btm_cb.security_mode == BTM_SEC_MODE_SP || in btm_sec_l2cap_access_req()
2095 btm_cb.security_mode == BTM_SEC_MODE_SP_DEBUG || in btm_sec_l2cap_access_req()
2096 btm_cb.security_mode == BTM_SEC_MODE_SC) { in btm_sec_l2cap_access_req()
2156 ((btm_cb.security_mode == BTM_SEC_MODE_UNDEFINED || in btm_sec_l2cap_access_req()
2157 btm_cb.security_mode == BTM_SEC_MODE_NONE || in btm_sec_l2cap_access_req()
2158 btm_cb.security_mode == BTM_SEC_MODE_SERVICE || in btm_sec_l2cap_access_req()
2159 btm_cb.security_mode == BTM_SEC_MODE_LINK) || in btm_sec_l2cap_access_req()
2304 if ((btm_cb.security_mode == BTM_SEC_MODE_SC) && in btm_sec_mx_access_request()
2316 (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE)) { in btm_sec_mx_access_request()
2319 btm_pair_state_descr(btm_cb.pairing_state)); in btm_sec_mx_access_request()
2323 if ((btm_cb.security_mode == BTM_SEC_MODE_UNDEFINED || in btm_sec_mx_access_request()
2324 btm_cb.security_mode == BTM_SEC_MODE_NONE || in btm_sec_mx_access_request()
2325 btm_cb.security_mode == BTM_SEC_MODE_SERVICE || in btm_sec_mx_access_request()
2326 btm_cb.security_mode == BTM_SEC_MODE_LINK) || in btm_sec_mx_access_request()
2412 rc, btm_pair_state_descr(btm_cb.pairing_state)); in btm_sec_mx_access_request()
2417 (btm_cb.security_mode == BTM_SEC_MODE_SC))) { in btm_sec_mx_access_request()
2440 if (btm_cb.security_mode == BTM_SEC_MODE_SP || in btm_sec_mx_access_request()
2441 btm_cb.security_mode == BTM_SEC_MODE_SP_DEBUG || in btm_sec_mx_access_request()
2442 btm_cb.security_mode == BTM_SEC_MODE_SC) { in btm_sec_mx_access_request()
2516 if (btm_cb.connect_only_paired) { in btm_sec_conn_req()
2527 if (btm_cb.btm_inq_vars.discoverable_mode == BTM_NON_DISCOVERABLE) { in btm_sec_conn_req()
2537 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in btm_sec_conn_req()
2538 (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) && in btm_sec_conn_req()
2539 (btm_cb.pairing_bda == bda)) { in btm_sec_conn_req()
2544 btm_cb.pairing_flags |= BTM_PAIR_FLAGS_REJECTED_CONNECT; in btm_sec_conn_req()
2551 btm_cb.connecting_bda = bda; in btm_sec_conn_req()
2552 memcpy(btm_cb.connecting_dc, dc, DEV_CLASS_LEN); in btm_sec_conn_req()
2578 if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_DISC_WHEN_DONE) || in btm_sec_bond_cancel_complete()
2579 (BTM_PAIR_STATE_WAIT_LOCAL_PIN == btm_cb.pairing_state && in btm_sec_bond_cancel_complete()
2580 BTM_PAIR_FLAGS_WE_STARTED_DD & btm_cb.pairing_flags) || in btm_sec_bond_cancel_complete()
2581 (btm_cb.pairing_state == BTM_PAIR_STATE_GET_REM_NAME && in btm_sec_bond_cancel_complete()
2582 BTM_PAIR_FLAGS_WE_CANCEL_DD & btm_cb.pairing_flags)) { in btm_sec_bond_cancel_complete()
2592 p_dev_rec = btm_find_dev(btm_cb.pairing_bda); in btm_sec_bond_cancel_complete()
2597 if (btm_cb.api.p_bond_cancel_cmpl_callback) in btm_sec_bond_cancel_complete()
2598 btm_cb.api.p_bond_cancel_cmpl_callback(BTM_SUCCESS); in btm_sec_bond_cancel_complete()
2619 btm_pair_state_descr(btm_cb.pairing_state), status); in btm_create_conn_cancel_complete()
2639 if (btm_cb.api.p_bond_cancel_cmpl_callback) in btm_create_conn_cancel_complete()
2640 btm_cb.api.p_bond_cancel_cmpl_callback(BTM_ERR_PROCESSING); in btm_create_conn_cancel_complete()
2657 if (btm_cb.pairing_state == BTM_PAIR_STATE_IDLE) { in btm_sec_check_pending_reqs()
2659 if (btm_cb.sec_req_pending) { in btm_sec_check_pending_reqs()
2660 btm_cb.sec_req_pending = false; in btm_sec_check_pending_reqs()
2665 fixed_queue_t* bq = btm_cb.sec_pending_q; in btm_sec_check_pending_reqs()
2667 btm_cb.sec_pending_q = fixed_queue_new(SIZE_MAX); in btm_sec_check_pending_reqs()
2703 btm_cb.security_mode = sec_mode; in btm_sec_init()
2704 btm_cb.pairing_bda = RawAddress::kAny; in btm_sec_init()
2719 btm_pair_state_descr(btm_cb.pairing_state)); in btm_sec_device_down()
2735 btm_cb.devcb.loc_io_caps = btif_storage_get_local_io_caps(); in btm_sec_dev_reset()
2740 btm_cb.security_mode = BTM_SEC_MODE_SERVICE; in btm_sec_dev_reset()
2743 BTM_TRACE_DEBUG("btm_sec_dev_reset sec mode: %d", btm_cb.security_mode); in btm_sec_dev_reset()
2804 btm_cb.pairing_flags |= BTM_PAIR_FLAGS_DISC_WHEN_DONE; in btm_sec_dd_create_conn()
2850 if ((!p_bd_addr && !BTM_ACL_IS_CONNECTED(btm_cb.connecting_bda)) || in btm_sec_rmt_name_request_complete()
2861 list_foreach(btm_cb.sec_dev_rec, is_state_getting_name, NULL); in btm_sec_rmt_name_request_complete()
2878 __func__, btm_pair_state_descr(btm_cb.pairing_state), p_bd_name, status, in btm_sec_rmt_name_request_complete()
2882 btm_pair_state_descr(btm_cb.pairing_state), p_bd_name, in btm_sec_rmt_name_request_complete()
2905 if (btm_cb.p_rmt_name_callback[i] && p_bd_addr) in btm_sec_rmt_name_request_complete()
2906 (*btm_cb.p_rmt_name_callback[i])(*p_bd_addr, p_dev_rec->dev_class, in btm_sec_rmt_name_request_complete()
2917 if (btm_cb.p_rmt_name_callback[i] && p_bd_addr) in btm_sec_rmt_name_request_complete()
2918 (*btm_cb.p_rmt_name_callback[i])(*p_bd_addr, dev_class, (uint8_t*)""); in btm_sec_rmt_name_request_complete()
2926 if ((btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_LOCAL_PIN) && p_bd_addr && in btm_sec_rmt_name_request_complete()
2927 (btm_cb.pairing_bda == *p_bd_addr)) { in btm_sec_rmt_name_request_complete()
2931 __func__, btm_cb.pairing_flags, btm_cb.api.p_pin_callback); in btm_sec_rmt_name_request_complete()
2933 if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_PIN_REQD) == 0 && in btm_sec_rmt_name_request_complete()
2934 btm_cb.api.p_pin_callback) { in btm_sec_rmt_name_request_complete()
2936 btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD; in btm_sec_rmt_name_request_complete()
2937 (*btm_cb.api.p_pin_callback)( in btm_sec_rmt_name_request_complete()
2951 if (btm_cb.pairing_state == BTM_PAIR_STATE_GET_REM_NAME) { in btm_sec_rmt_name_request_complete()
2952 if (p_bd_addr && btm_cb.pairing_bda == *p_bd_addr) { in btm_sec_rmt_name_request_complete()
2955 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_CANCEL_DD) { in btm_sec_rmt_name_request_complete()
2963 if (btm_cb.api.p_auth_complete_callback) in btm_sec_rmt_name_request_complete()
2964 (*btm_cb.api.p_auth_complete_callback)( in btm_sec_rmt_name_request_complete()
2977 btm_cb.pairing_flags); in btm_sec_rmt_name_request_complete()
2978 if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_REJECTED_CONNECT) == 0) in btm_sec_rmt_name_request_complete()
2998 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_REJECTED_CONNECT) { in btm_sec_rmt_name_request_complete()
3009 if (btm_cb.api.p_auth_complete_callback) { in btm_sec_rmt_name_request_complete()
3010 (*btm_cb.api.p_auth_complete_callback)( in btm_sec_rmt_name_request_complete()
3019 if (BTM_ReadRemoteDeviceName(btm_cb.pairing_bda, NULL, in btm_sec_rmt_name_request_complete()
3022 if (btm_cb.api.p_auth_complete_callback) { in btm_sec_rmt_name_request_complete()
3023 (*btm_cb.api.p_auth_complete_callback)( in btm_sec_rmt_name_request_complete()
3046 if (btm_cb.api.p_auth_complete_callback) in btm_sec_rmt_name_request_complete()
3047 (*btm_cb.api.p_auth_complete_callback)( in btm_sec_rmt_name_request_complete()
3054 if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) && in btm_sec_rmt_name_request_complete()
3142 evt_data.io_cap = btm_cb.devcb.loc_io_caps; in btm_io_capabilities_req()
3147 btm_pair_state_descr(btm_cb.pairing_state)); in btm_io_capabilities_req()
3159 __func__, btm_cb.security_mode, p_dev_rec->num_read_pages); in btm_io_capabilities_req()
3161 if ((btm_cb.security_mode == BTM_SEC_MODE_SC) && in btm_io_capabilities_req()
3173 __func__, btm_pair_state_descr(btm_cb.pairing_state), in btm_io_capabilities_req()
3174 btm_cb.pairing_flags, p_dev_rec->p_cur_service); in btm_io_capabilities_req()
3182 switch (btm_cb.pairing_state) { in btm_io_capabilities_req()
3193 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_PEER_STARTED_DD) { in btm_io_capabilities_req()
3202 if (evt_data.bd_addr == btm_cb.pairing_bda) { in btm_io_capabilities_req()
3213 btm_cb.pairing_state); in btm_io_capabilities_req()
3217 if (btm_cb.pairing_disabled) { in btm_io_capabilities_req()
3221 } else if (btm_cb.security_mode == BTM_SEC_MODE_SC) { in btm_io_capabilities_req()
3245 if (!(btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) && in btm_io_capabilities_req()
3248 if (btm_cb.security_mode == BTM_SEC_MODE_SC) { in btm_io_capabilities_req()
3263 btm_cb.pairing_bda = evt_data.bd_addr; in btm_io_capabilities_req()
3265 if (evt_data.bd_addr == btm_cb.connecting_bda) in btm_io_capabilities_req()
3266 memcpy(p_dev_rec->dev_class, btm_cb.connecting_dc, DEV_CLASS_LEN); in btm_io_capabilities_req()
3277 } else if (btm_cb.api.p_sp_callback) { in btm_io_capabilities_req()
3279 callback_rc = (*btm_cb.api.p_sp_callback)(BTM_SP_IO_REQ_EVT, in btm_io_capabilities_req()
3284 if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD)) { in btm_io_capabilities_req()
3289 if (btm_cb.security_mode == BTM_SEC_MODE_SC) { in btm_io_capabilities_req()
3302 btm_cb.devcb.loc_auth_req = evt_data.auth_req; in btm_io_capabilities_req()
3303 btm_cb.devcb.loc_io_caps = evt_data.io_cap; in btm_io_capabilities_req()
3306 __func__, btm_pair_state_descr(btm_cb.pairing_state), in btm_io_capabilities_req()
3337 if (btm_cb.pairing_state == BTM_PAIR_STATE_IDLE) { in btm_io_capabilities_rsp()
3338 btm_cb.pairing_bda = evt_data.bd_addr; in btm_io_capabilities_rsp()
3354 if (evt_data.bd_addr == btm_cb.connecting_bda) in btm_io_capabilities_rsp()
3355 memcpy(p_dev_rec->dev_class, btm_cb.connecting_dc, DEV_CLASS_LEN); in btm_io_capabilities_rsp()
3359 if (btm_cb.pairing_state == in btm_io_capabilities_rsp()
3364 btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PEER_STARTED_DD; in btm_io_capabilities_rsp()
3371 if (btm_cb.api.p_sp_callback) in btm_io_capabilities_rsp()
3372 (*btm_cb.api.p_sp_callback)(BTM_SP_IO_RSP_EVT, in btm_io_capabilities_rsp()
3398 << " State: " << btm_pair_state_descr(btm_cb.pairing_state); in btm_proc_sp_req_evt()
3401 if ((p_dev_rec != NULL) && (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in btm_proc_sp_req_evt()
3402 (btm_cb.pairing_bda == p_bda)) { in btm_proc_sp_req_evt()
3422 if (btm_cb.devcb.loc_io_caps == BTM_IO_CAP_IO) { in btm_proc_sp_req_evt()
3433 (btm_cb.devcb.loc_io_caps == BTM_IO_CAP_IO) && in btm_proc_sp_req_evt()
3435 (btm_cb.devcb.loc_auth_req & BTM_AUTH_SP_YES))) { in btm_proc_sp_req_evt()
3445 evt_data.cfm_req.just_works, btm_cb.devcb.loc_io_caps, in btm_proc_sp_req_evt()
3446 p_dev_rec->rmt_io_caps, btm_cb.devcb.loc_auth_req, in btm_proc_sp_req_evt()
3449 evt_data.cfm_req.loc_auth_req = btm_cb.devcb.loc_auth_req; in btm_proc_sp_req_evt()
3451 evt_data.cfm_req.loc_io_caps = btm_cb.devcb.loc_io_caps; in btm_proc_sp_req_evt()
3465 if (btm_cb.devcb.loc_io_caps != BTM_IO_CAP_NONE) { in btm_proc_sp_req_evt()
3472 if (btm_cb.api.p_sp_callback) { in btm_proc_sp_req_evt()
3473 status = (*btm_cb.api.p_sp_callback)(event, &evt_data); in btm_proc_sp_req_evt()
3487 } else if (btm_cb.devcb.loc_io_caps != BTM_IO_CAP_NONE && in btm_proc_sp_req_evt()
3495 btm_cb.acl_disc_reason = HCI_ERR_HOST_REJECT_SECURITY; in btm_proc_sp_req_evt()
3511 } else if (btm_cb.devcb.loc_io_caps != BTM_IO_CAP_NONE) { in btm_proc_sp_req_evt()
3530 if (btm_cb.api.p_sp_callback) { in btm_keypress_notif_evt()
3536 (*btm_cb.api.p_sp_callback)(BTM_SP_KEYPRESS_EVT, in btm_keypress_notif_evt()
3568 btm_pair_state_descr(btm_cb.pairing_state), status, p_dev_rec->sec_state); in btm_simple_pair_complete()
3580 alarm_set_on_mloop(btm_cb.pairing_timer, BT_1SEC_TIMEOUT_MS, in btm_simple_pair_complete()
3582 } else if (btm_cb.pairing_bda == evt_data.bd_addr) { in btm_simple_pair_complete()
3584 alarm_cancel(btm_cb.pairing_timer); in btm_simple_pair_complete()
3600 if (btm_cb.api.p_sp_callback) in btm_simple_pair_complete()
3601 (*btm_cb.api.p_sp_callback)(BTM_SP_COMPLT_EVT, in btm_simple_pair_complete()
3637 if ((p_dev_rec != NULL) && btm_cb.api.p_sp_callback) { in btm_rem_oob_req()
3644 if ((*btm_cb.api.p_sp_callback)(BTM_SP_RMT_OOB_EVT, in btm_rem_oob_req()
3653 btm_cb.acl_disc_reason = HCI_ERR_HOST_REJECT_SECURITY; in btm_rem_oob_req()
3679 if (btm_cb.api.p_sp_callback) { in btm_read_local_oob_complete()
3682 (*btm_cb.api.p_sp_callback)(BTM_SP_LOC_OOB_EVT, &btm_sp_evt_data); in btm_read_local_oob_complete()
3699 if (!btm_cb.collision_start_time) in btm_sec_auth_collision()
3700 btm_cb.collision_start_time = bluetooth::common::time_get_os_boottime_ms(); in btm_sec_auth_collision()
3703 btm_cb.collision_start_time) < BTM_SEC_MAX_COLLISION_DELAY) { in btm_sec_auth_collision()
3720 btm_cb.p_collided_dev_rec = p_dev_rec; in btm_sec_auth_collision()
3721 alarm_set_on_mloop(btm_cb.sec_collision_timer, BT_1SEC_TIMEOUT_MS, in btm_sec_auth_collision()
3745 if ((btm_cb.pairing_state == BTM_PAIR_STATE_IDLE) && in btm_sec_auth_retry()
3752 btm_cb.collision_start_time = 0; in btm_sec_auth_retry()
3782 tBTM_PAIRING_STATE old_state = btm_cb.pairing_state; in btm_sec_auth_complete()
3788 << btm_pair_state_descr(btm_cb.pairing_state) in btm_sec_auth_complete()
3795 << btm_pair_state_descr(btm_cb.pairing_state) in btm_sec_auth_complete()
3809 btm_cb.collision_start_time = 0; in btm_sec_auth_complete()
3816 if (p_dev_rec && (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) && in btm_sec_auth_complete()
3817 !(btm_cb.pairing_flags & BTM_PAIR_FLAGS_DISC_WHEN_DONE)) { in btm_sec_auth_complete()
3825 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in btm_sec_auth_complete()
3826 (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) && in btm_sec_auth_complete()
3827 (p_dev_rec->bd_addr == btm_cb.pairing_bda)) in btm_sec_auth_complete()
3830 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in btm_sec_auth_complete()
3831 (p_dev_rec->bd_addr == btm_cb.pairing_bda)) in btm_sec_auth_complete()
3835 if ((btm_cb.api.p_auth_complete_callback && status != HCI_SUCCESS) && in btm_sec_auth_complete()
3837 (*btm_cb.api.p_auth_complete_callback)(p_dev_rec->bd_addr, in btm_sec_auth_complete()
3857 if (btm_cb.api.p_auth_complete_callback) { in btm_sec_auth_complete()
3860 (*btm_cb.api.p_auth_complete_callback)(p_dev_rec->bd_addr, in btm_sec_auth_complete()
3905 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_DISC_WHEN_DONE) { in btm_sec_auth_complete()
3959 btm_cb.collision_start_time = 0; in btm_sec_encrypt_change()
3989 if (acl_idx != MAX_L2CAP_LINKS) p_acl = &btm_cb.acl_db[acl_idx]; in btm_sec_encrypt_change()
4015 btm_cb.devcb.loc_auth_req == BTM_AUTH_SP_NO) { in btm_sec_encrypt_change()
4095 tBTM_SEC_DEV_REC* p_dev_rec = btm_cb.p_collided_dev_rec; in btm_sec_connect_after_reject_timeout()
4098 btm_cb.p_collided_dev_rec = 0; in btm_sec_connect_after_reject_timeout()
4106 if (btm_cb.api.p_auth_complete_callback) in btm_sec_connect_after_reject_timeout()
4107 (*btm_cb.api.p_auth_complete_callback)( in btm_sec_connect_after_reject_timeout()
4136 << btm_pair_state_descr(btm_cb.pairing_state) in btm_sec_connected()
4142 << btm_pair_state_descr(btm_cb.pairing_state) in btm_sec_connected()
4154 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in btm_sec_connected()
4155 btm_cb.pairing_bda == bda) { in btm_sec_connected()
4166 p_dev_rec->timestamp = btm_cb.dev_rec_count++; in btm_sec_connected()
4169 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in btm_sec_connected()
4170 (btm_cb.pairing_bda == p_dev_rec->bd_addr) && in btm_sec_connected()
4171 (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD)) { in btm_sec_connected()
4176 (btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_PIN_REQ)) { in btm_sec_connected()
4185 btm_cb.p_collided_dev_rec = p_dev_rec; in btm_sec_connected()
4186 alarm_set_on_mloop(btm_cb.sec_collision_timer, 0, in btm_sec_connected()
4218 addr_matched = (btm_cb.pairing_bda == bda); in btm_sec_connected()
4220 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && addr_matched) { in btm_sec_connected()
4223 (btm_cb.pairing_flags & BTM_PAIR_FLAGS_REJECTED_CONNECT)) { in btm_sec_connected()
4227 btm_cb.pairing_flags, p_dev_rec->sm4); in btm_sec_connected()
4229 btm_cb.pairing_flags &= ~BTM_PAIR_FLAGS_REJECTED_CONNECT; in btm_sec_connected()
4242 if (btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_LOCAL_PIN) { in btm_sec_connected()
4245 btm_cb.p_collided_dev_rec = p_dev_rec; in btm_sec_connected()
4246 alarm_set_on_mloop(btm_cb.sec_collision_timer, 0, in btm_sec_connected()
4277 if (btm_cb.api.p_auth_complete_callback) { in btm_sec_connected()
4278 (*btm_cb.api.p_auth_complete_callback)(p_dev_rec->bd_addr, in btm_sec_connected()
4303 if (btm_cb.acl_disc_reason == HCI_ERR_HOST_REJECT_SECURITY) { in btm_sec_connected()
4309 if (btm_cb.api.p_auth_complete_callback) { in btm_sec_connected()
4310 (*btm_cb.api.p_auth_complete_callback)(p_dev_rec->bd_addr, in btm_sec_connected()
4320 << ": Different mac addresses: pairing_bda=" << btm_cb.pairing_bda in btm_sec_connected()
4347 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) in btm_sec_connected()
4352 if (btm_cb.api.p_auth_complete_callback) in btm_sec_connected()
4353 (*btm_cb.api.p_auth_complete_callback)( in btm_sec_connected()
4381 btm_set_packet_types(p_acl_cb, btm_cb.btm_acl_pkt_types_supported); in btm_sec_connected()
4383 if (btm_cb.btm_def_link_policy) in btm_sec_connected()
4384 BTM_SetLinkPolicy(p_acl_cb->remote_addr, &btm_cb.btm_def_link_policy); in btm_sec_connected()
4401 if (btm_cb.security_mode == BTM_SEC_MODE_LINK) in btm_sec_connected()
4445 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in btm_sec_disconnect()
4446 (btm_cb.pairing_bda == p_dev_rec->bd_addr) && in btm_sec_disconnect()
4447 (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD)) { in btm_sec_disconnect()
4449 btm_cb.pairing_flags |= BTM_PAIR_FLAGS_DISC_WHEN_DONE; in btm_sec_disconnect()
4468 uint8_t old_pairing_flags = btm_cb.pairing_flags; in btm_sec_disconnected()
4474 btm_cb.discing = false; in btm_sec_disconnected()
4496 << " state: " << btm_pair_state_descr(btm_cb.pairing_state) in btm_sec_disconnected()
4505 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in btm_sec_disconnected()
4506 (btm_cb.pairing_bda == p_dev_rec->bd_addr)) { in btm_sec_disconnected()
4509 if (btm_cb.api.p_auth_complete_callback) { in btm_sec_disconnected()
4519 (*btm_cb.api.p_auth_complete_callback)(p_dev_rec->bd_addr, in btm_sec_disconnected()
4631 if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) && in btm_sec_link_key_notification()
4632 (btm_cb.pairing_bda == p_bda)) { in btm_sec_link_key_notification()
4633 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) in btm_sec_link_key_notification()
4641 if (btm_cb.api.p_link_key_callback) { in btm_sec_link_key_notification()
4644 (*btm_cb.api.p_link_key_callback)(p_bda, p_dev_rec->dev_class, in btm_sec_link_key_notification()
4689 if (btm_cb.api.p_auth_complete_callback) in btm_sec_link_key_notification()
4690 (*btm_cb.api.p_auth_complete_callback)( in btm_sec_link_key_notification()
4701 if (btm_cb.api.p_link_key_callback) { in btm_sec_link_key_notification()
4708 (*btm_cb.api.p_link_key_callback)(p_bda, p_dev_rec->dev_class, in btm_sec_link_key_notification()
4730 if ((btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_PIN_REQ) && in btm_sec_link_key_request()
4731 (btm_cb.collision_start_time != 0) && in btm_sec_link_key_request()
4732 (btm_cb.p_collided_dev_rec->bd_addr == bda)) { in btm_sec_link_key_request()
4736 btm_cb.pairing_state, btm_cb.collision_start_time); in btm_sec_link_key_request()
4763 tBTM_CB* p_cb = &btm_cb; in btm_sec_pairing_timeout()
4765 tBTM_AUTH_REQ auth_req = (btm_cb.devcb.loc_io_caps == BTM_IO_CAP_NONE) in btm_sec_pairing_timeout()
4782 if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_PRE_FETCH_PIN) == 0) in btm_sec_pairing_timeout()
4786 if (btm_cb.api.p_auth_complete_callback) { in btm_sec_pairing_timeout()
4789 (*btm_cb.api.p_auth_complete_callback)(p_cb->pairing_bda, NULL, name, in btm_sec_pairing_timeout()
4792 (*btm_cb.api.p_auth_complete_callback)( in btm_sec_pairing_timeout()
4804 if (btm_cb.devcb.loc_io_caps != BTM_IO_CAP_NONE) { in btm_sec_pairing_timeout()
4812 if (btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) in btm_sec_pairing_timeout()
4815 btsnd_hcic_io_cap_req_reply(p_cb->pairing_bda, btm_cb.devcb.loc_io_caps, in btm_sec_pairing_timeout()
4845 if (btm_cb.api.p_auth_complete_callback) { in btm_sec_pairing_timeout()
4848 (*btm_cb.api.p_auth_complete_callback)(p_cb->pairing_bda, NULL, name, in btm_sec_pairing_timeout()
4851 (*btm_cb.api.p_auth_complete_callback)( in btm_sec_pairing_timeout()
4859 btm_pair_state_descr(btm_cb.pairing_state)); in btm_sec_pairing_timeout()
4876 tBTM_CB* p_cb = &btm_cb; in btm_sec_pin_code_request()
4879 << " state: " << btm_pair_state_descr(btm_cb.pairing_state); in btm_sec_pin_code_request()
4881 if (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) { in btm_sec_pin_code_request()
4882 if ((p_bda == btm_cb.pairing_bda) && in btm_sec_pin_code_request()
4883 (btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_AUTH_COMPLETE)) { in btm_sec_pin_code_request()
4886 } else if ((btm_cb.pairing_state != BTM_PAIR_STATE_WAIT_PIN_REQ) || in btm_sec_pin_code_request()
4887 p_bda != btm_cb.pairing_bda) { in btm_sec_pin_code_request()
4889 btm_pair_state_descr(btm_cb.pairing_state)); in btm_sec_pin_code_request()
4899 if (btm_cb.pairing_state == BTM_PAIR_STATE_IDLE) { in btm_sec_pin_code_request()
4900 btm_cb.pairing_bda = p_bda; in btm_sec_pin_code_request()
4902 btm_cb.pairing_flags = BTM_PAIR_FLAGS_PEER_STARTED_DD; in btm_sec_pin_code_request()
4922 if (btm_cb.pin_code_len != 0) { in btm_sec_pin_code_request()
4924 btsnd_hcic_pin_code_req_reply(p_bda, btm_cb.pin_code_len, p_cb->pin_code); in btm_sec_pin_code_request()
4927 btm_cb.pin_code_len = 0; in btm_sec_pin_code_request()
4975 btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD; in btm_sec_pin_code_request()
5225 if (!btm_cb.api.p_authorize_callback) return (BTM_MODE_UNSUPPORTED); in btm_sec_start_authorization()
5243 result = (*btm_cb.api.p_authorize_callback)( in btm_sec_start_authorization()
5304 tBTM_SEC_SERV_REC* p_serv_rec = &btm_cb.sec_serv_rec[0]; in btm_sec_find_first_serv()
5308 if (is_originator && btm_cb.p_out_serv && btm_cb.p_out_serv->psm == psm) { in btm_sec_find_first_serv()
5311 return btm_cb.p_out_serv; in btm_sec_find_first_serv()
5334 tBTM_SEC_SERV_REC* p_serv_rec = &btm_cb.sec_serv_rec[0]; in btm_sec_find_next_serv()
5362 tBTM_SEC_SERV_REC* p_out_serv = btm_cb.p_out_serv; in btm_sec_find_mx_serv()
5363 tBTM_SEC_SERV_REC* p_serv_rec = &btm_cb.sec_serv_rec[0]; in btm_sec_find_mx_serv()
5372 return btm_cb.p_out_serv; in btm_sec_find_mx_serv()
5400 tBTM_STATUS status = btm_sec_execute_procedure(btm_cb.p_collided_dev_rec); in btm_sec_collision_timeout()
5406 btm_sec_dev_rec_cback_event(btm_cb.p_collided_dev_rec, status, false); in btm_sec_collision_timeout()
5420 if (btm_cb.api.p_link_key_callback) in btm_send_link_key_notif()
5421 (*btm_cb.api.p_link_key_callback)( in btm_send_link_key_notif()
5456 if (btm_cb.security_mode_changed) { in btm_restore_mode()
5457 btm_cb.security_mode_changed = false; in btm_restore_mode()
5459 (btm_cb.security_mode == BTM_SEC_MODE_LINK)); in btm_restore_mode()
5461 (uint8_t)(btm_cb.security_mode == BTM_SEC_MODE_LINK)); in btm_restore_mode()
5464 if (btm_cb.pin_type_changed) { in btm_restore_mode()
5465 btm_cb.pin_type_changed = false; in btm_restore_mode()
5466 btsnd_hcic_write_pin_type(btm_cb.cfg.pin_type); in btm_restore_mode()
5490 list_node_t* n = list_foreach(btm_cb.sec_dev_rec, is_sec_state_equal, &state); in btm_sec_find_dev_by_sec_state()
5504 tBTM_PAIRING_STATE old_state = btm_cb.pairing_state; in btm_sec_change_pairing_state()
5507 btm_pair_state_descr(btm_cb.pairing_state)); in btm_sec_change_pairing_state()
5509 btm_pair_state_descr(new_state), btm_cb.pairing_flags); in btm_sec_change_pairing_state()
5511 btm_cb.pairing_state = new_state; in btm_sec_change_pairing_state()
5514 alarm_cancel(btm_cb.pairing_timer); in btm_sec_change_pairing_state()
5516 btm_cb.pairing_flags = 0; in btm_sec_change_pairing_state()
5517 btm_cb.pin_code_len = 0; in btm_sec_change_pairing_state()
5520 l2cu_update_lcb_4_bonding(btm_cb.pairing_bda, false); in btm_sec_change_pairing_state()
5526 btm_cb.pairing_bda = RawAddress::kAny; in btm_sec_change_pairing_state()
5530 l2cu_update_lcb_4_bonding(btm_cb.pairing_bda, true); in btm_sec_change_pairing_state()
5532 alarm_set_on_mloop(btm_cb.pairing_timer, BTM_SEC_TIMEOUT_VALUE * 1000, in btm_sec_change_pairing_state()
5634 fixed_queue_enqueue(btm_cb.sec_pending_q, p_e); in btm_sec_queue_mx_request()
5652 if (!btm_cb.security_mode_changed) { in btm_sec_check_prefetch_pin()
5653 btm_cb.security_mode_changed = true; in btm_sec_check_prefetch_pin()
5663 if (btm_cb.pin_code_len) { in btm_sec_check_prefetch_pin()
5664 BTM_PINCodeReply(p_dev_rec->bd_addr, BTM_SUCCESS, btm_cb.pin_code_len, in btm_sec_check_prefetch_pin()
5665 btm_cb.pin_code, p_dev_rec->trusted_mask); in btm_sec_check_prefetch_pin()
5668 if (btm_cb.api.p_pin_callback && in btm_sec_check_prefetch_pin()
5669 ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_PIN_REQD) == 0)) { in btm_sec_check_prefetch_pin()
5672 btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD; in btm_sec_check_prefetch_pin()
5673 (btm_cb.api.p_pin_callback)( in btm_sec_check_prefetch_pin()
5732 fixed_queue_enqueue(btm_cb.sec_pending_q, p_e); in btm_sec_queue_encrypt_request()
5749 if ((btm_cb.security_mode == BTM_SEC_MODE_SP || in btm_sec_set_peer_sec_caps()
5750 btm_cb.security_mode == BTM_SEC_MODE_SP_DEBUG || in btm_sec_set_peer_sec_caps()
5751 btm_cb.security_mode == BTM_SEC_MODE_SC) && in btm_sec_set_peer_sec_caps()
5805 if (fixed_queue_is_empty(btm_cb.sec_pending_q)) return; in btm_sec_check_pending_enc_req()
5808 list_t* list = fixed_queue_get_list(btm_cb.sec_pending_q); in btm_sec_check_pending_enc_req()
5823 fixed_queue_try_remove_from_queue(btm_cb.sec_pending_q, (void*)p_e); in btm_sec_check_pending_enc_req()