• Home
  • Raw
  • Download

Lines Matching refs:p_cb

80 static BOOLEAN smp_parameter_unconditionally_valid(tSMP_CB *p_cb);
81 static BOOLEAN smp_parameter_unconditionally_invalid(tSMP_CB *p_cb);
84 typedef BOOLEAN (*tSMP_CMD_LEN_VALID)(tSMP_CB *p_cb);
86 static BOOLEAN smp_command_has_valid_fixed_length(tSMP_CB *p_cb);
109 typedef BOOLEAN (*tSMP_CMD_PARAM_RANGES_VALID)(tSMP_CB *p_cb);
111 static BOOLEAN smp_pairing_request_response_parameters_are_valid(tSMP_CB *p_cb);
112 static BOOLEAN smp_pairing_keypress_notification_is_valid(tSMP_CB *p_cb);
135 typedef BT_HDR * (*tSMP_CMD_ACT)(UINT8 cmd_code, tSMP_CB *p_cb);
137 static BT_HDR *smp_build_pairing_cmd(UINT8 cmd_code, tSMP_CB *p_cb);
138 static BT_HDR *smp_build_confirm_cmd(UINT8 cmd_code, tSMP_CB *p_cb);
139 static BT_HDR *smp_build_rand_cmd(UINT8 cmd_code, tSMP_CB *p_cb);
140 static BT_HDR *smp_build_pairing_fail(UINT8 cmd_code, tSMP_CB *p_cb);
141 static BT_HDR *smp_build_identity_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb);
142 static BT_HDR *smp_build_encrypt_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb);
143 static BT_HDR *smp_build_security_request(UINT8 cmd_code, tSMP_CB *p_cb);
144 static BT_HDR *smp_build_signing_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb);
145 static BT_HDR *smp_build_master_id_cmd(UINT8 cmd_code, tSMP_CB *p_cb);
146 static BT_HDR *smp_build_id_addr_cmd(UINT8 cmd_code, tSMP_CB *p_cb);
147 static BT_HDR *smp_build_pair_public_key_cmd(UINT8 cmd_code, tSMP_CB *p_cb);
148 static BT_HDR *smp_build_pairing_commitment_cmd(UINT8 cmd_code, tSMP_CB *p_cb);
149 static BT_HDR *smp_build_pair_dhkey_check_cmd(UINT8 cmd_code, tSMP_CB *p_cb);
150 static BT_HDR *smp_build_pairing_keypress_notification_cmd(UINT8 cmd_code, tSMP_CB *p_cb);
274 static tSMP_ASSO_MODEL smp_select_legacy_association_model(tSMP_CB *p_cb);
275 static tSMP_ASSO_MODEL smp_select_association_model_secure_connections(tSMP_CB *p_cb);
315 BOOLEAN smp_send_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_send_cmd() argument
324 p_buf = (*smp_cmd_build_act[cmd_code])(cmd_code, p_cb); in smp_send_cmd()
327 smp_send_msg_to_L2CAP(p_cb->pairing_bda, p_buf)) in smp_send_cmd()
330 alarm_set_on_queue(p_cb->smp_rsp_timer_ent, in smp_send_cmd()
338 if (p_cb->smp_over_br) in smp_send_cmd()
340 smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &failure); in smp_send_cmd()
344 smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &failure); in smp_send_cmd()
361 tSMP_CB *p_cb = &smp_cb; in smp_rsp_timeout() local
364 SMP_TRACE_EVENT("%s state:%d br_state:%d", __FUNCTION__, p_cb->state, p_cb->br_state); in smp_rsp_timeout()
366 if (p_cb->smp_over_br) in smp_rsp_timeout()
368 smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &failure); in smp_rsp_timeout()
372 smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &failure); in smp_rsp_timeout()
383 BT_HDR * smp_build_pairing_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_pairing_cmd() argument
393 UINT8_TO_STREAM(p, p_cb->local_io_capability); in smp_build_pairing_cmd()
394 UINT8_TO_STREAM(p, p_cb->loc_oob_flag); in smp_build_pairing_cmd()
395 UINT8_TO_STREAM(p, p_cb->loc_auth_req); in smp_build_pairing_cmd()
396 UINT8_TO_STREAM(p, p_cb->loc_enc_size); in smp_build_pairing_cmd()
397 UINT8_TO_STREAM(p, p_cb->local_i_key); in smp_build_pairing_cmd()
398 UINT8_TO_STREAM(p, p_cb->local_r_key); in smp_build_pairing_cmd()
414 static BT_HDR * smp_build_confirm_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_confirm_cmd() argument
426 ARRAY_TO_STREAM(p, p_cb->confirm, BT_OCTET16_LEN); in smp_build_confirm_cmd()
441 static BT_HDR * smp_build_rand_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_rand_cmd() argument
452 ARRAY_TO_STREAM(p, p_cb->rand, BT_OCTET16_LEN); in smp_build_rand_cmd()
467 static BT_HDR * smp_build_encrypt_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_encrypt_info_cmd() argument
478 ARRAY_TO_STREAM(p, p_cb->ltk, BT_OCTET16_LEN); in smp_build_encrypt_info_cmd()
493 static BT_HDR * smp_build_master_id_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_master_id_cmd() argument
504 UINT16_TO_STREAM(p, p_cb->ediv); in smp_build_master_id_cmd()
505 ARRAY_TO_STREAM(p, p_cb->enc_rand, BT_OCTET8_LEN); in smp_build_master_id_cmd()
520 static BT_HDR * smp_build_identity_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_identity_info_cmd() argument
528 UNUSED(p_cb); in smp_build_identity_info_cmd()
551 static BT_HDR * smp_build_id_addr_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_id_addr_cmd() argument
558 UNUSED(p_cb); in smp_build_id_addr_cmd()
579 static BT_HDR * smp_build_signing_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_signing_info_cmd() argument
590 ARRAY_TO_STREAM(p, p_cb->csrk, BT_OCTET16_LEN); in smp_build_signing_info_cmd()
605 static BT_HDR * smp_build_pairing_fail(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_pairing_fail() argument
616 UINT8_TO_STREAM(p, p_cb->failure); in smp_build_pairing_fail()
631 static BT_HDR *smp_build_security_request(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_security_request() argument
642 UINT8_TO_STREAM(p, p_cb->loc_auth_req); in smp_build_security_request()
647 SMP_TRACE_EVENT("opcode=%d auth_req=0x%x",SMP_OPCODE_SEC_REQ, p_cb->loc_auth_req ); in smp_build_security_request()
659 static BT_HDR *smp_build_pair_public_key_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_pair_public_key_cmd() argument
670 memcpy(p_publ_key, p_cb->loc_publ_key.x, BT_OCTET32_LEN); in smp_build_pair_public_key_cmd()
671 memcpy(p_publ_key + BT_OCTET32_LEN, p_cb->loc_publ_key.y, BT_OCTET32_LEN); in smp_build_pair_public_key_cmd()
690 static BT_HDR *smp_build_pairing_commitment_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_pairing_commitment_cmd() argument
701 ARRAY_TO_STREAM(p, p_cb->commitment, BT_OCTET16_LEN); in smp_build_pairing_commitment_cmd()
716 static BT_HDR *smp_build_pair_dhkey_check_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_pair_dhkey_check_cmd() argument
727 ARRAY_TO_STREAM(p, p_cb->dhkey_check, BT_OCTET16_LEN); in smp_build_pair_dhkey_check_cmd()
742 static BT_HDR * smp_build_pairing_keypress_notification_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_pairing_keypress_notification_cmd() argument
753 UINT8_TO_STREAM(p, p_cb->local_keypress_notification); in smp_build_pairing_keypress_notification_cmd()
837 void smp_cb_cleanup(tSMP_CB *p_cb) in smp_cb_cleanup() argument
839 tSMP_CALLBACK *p_callback = p_cb->p_callback; in smp_cb_cleanup()
840 UINT8 trace_level = p_cb->trace_level; in smp_cb_cleanup()
844 alarm_free(p_cb->smp_rsp_timer_ent); in smp_cb_cleanup()
845 memset(p_cb, 0, sizeof(tSMP_CB)); in smp_cb_cleanup()
846 p_cb->p_callback = p_callback; in smp_cb_cleanup()
847 p_cb->trace_level = trace_level; in smp_cb_cleanup()
848 p_cb->smp_rsp_timer_ent = alarm_new("smp.smp_rsp_timer_ent"); in smp_cb_cleanup()
860 void smp_remove_fixed_channel(tSMP_CB *p_cb) in smp_remove_fixed_channel() argument
864 if (p_cb->smp_over_br) in smp_remove_fixed_channel()
865 L2CA_RemoveFixedChnl (L2CAP_SMP_BR_CID, p_cb->pairing_bda); in smp_remove_fixed_channel()
867 L2CA_RemoveFixedChnl (L2CAP_SMP_CID, p_cb->pairing_bda); in smp_remove_fixed_channel()
881 void smp_reset_control_value(tSMP_CB *p_cb) in smp_reset_control_value() argument
885 alarm_cancel(p_cb->smp_rsp_timer_ent); in smp_reset_control_value()
886 p_cb->flags = 0; in smp_reset_control_value()
891 L2CA_SetIdleTimeoutByBdAddr(p_cb->pairing_bda, SMP_LINK_TOUT_MIN, BT_TRANSPORT_LE); in smp_reset_control_value()
894 smp_remove_fixed_channel(p_cb); in smp_reset_control_value()
895 smp_cb_cleanup(p_cb); in smp_reset_control_value()
908 void smp_proc_pairing_cmpl(tSMP_CB *p_cb) in smp_proc_pairing_cmpl() argument
911 tSMP_CALLBACK *p_callback = p_cb->p_callback; in smp_proc_pairing_cmpl()
916 evt_data.cmplt.reason = p_cb->status; in smp_proc_pairing_cmpl()
917 evt_data.cmplt.smp_over_br = p_cb->smp_over_br; in smp_proc_pairing_cmpl()
919 if (p_cb->status == SMP_SUCCESS) in smp_proc_pairing_cmpl()
920 evt_data.cmplt.sec_level = p_cb->sec_level; in smp_proc_pairing_cmpl()
924 if (p_cb->is_pair_cancel) in smp_proc_pairing_cmpl()
932 memcpy (pairing_bda, p_cb->pairing_bda, BD_ADDR_LEN); in smp_proc_pairing_cmpl()
934 smp_reset_control_value(p_cb); in smp_proc_pairing_cmpl()
952 BOOLEAN smp_command_has_invalid_parameters(tSMP_CB *p_cb) in smp_command_has_invalid_parameters() argument
954 UINT8 cmd_code = p_cb->rcvd_cmd_code; in smp_command_has_invalid_parameters()
965 if (!(*smp_cmd_len_is_valid[cmd_code])(p_cb)) in smp_command_has_invalid_parameters()
968 if (!(*smp_cmd_param_ranges_are_valid[cmd_code])(p_cb)) in smp_command_has_invalid_parameters()
985 BOOLEAN smp_command_has_valid_fixed_length(tSMP_CB *p_cb) in smp_command_has_valid_fixed_length() argument
987 UINT8 cmd_code = p_cb->rcvd_cmd_code; in smp_command_has_valid_fixed_length()
991 if (p_cb->rcvd_cmd_len != smp_cmd_size_per_spec[cmd_code]) in smp_command_has_valid_fixed_length()
995 cmd_code, p_cb->rcvd_cmd_len, smp_cmd_size_per_spec[cmd_code]); in smp_command_has_valid_fixed_length()
1016 BOOLEAN smp_pairing_request_response_parameters_are_valid(tSMP_CB *p_cb) in smp_pairing_request_response_parameters_are_valid() argument
1018 UINT8 io_caps = p_cb->peer_io_caps; in smp_pairing_request_response_parameters_are_valid()
1019 UINT8 oob_flag = p_cb->peer_oob_flag; in smp_pairing_request_response_parameters_are_valid()
1020 UINT8 bond_flag = p_cb->peer_auth_req & 0x03; //0x03 is gen bond with appropriate mask in smp_pairing_request_response_parameters_are_valid()
1021 UINT8 enc_size = p_cb->peer_enc_size; in smp_pairing_request_response_parameters_are_valid()
1023 SMP_TRACE_DEBUG("%s for cmd code 0x%02x", __func__, p_cb->rcvd_cmd_code); in smp_pairing_request_response_parameters_are_valid()
1029 p_cb->rcvd_cmd_code, io_caps); in smp_pairing_request_response_parameters_are_valid()
1037 p_cb->rcvd_cmd_code, oob_flag); in smp_pairing_request_response_parameters_are_valid()
1045 p_cb->rcvd_cmd_code, bond_flag); in smp_pairing_request_response_parameters_are_valid()
1053 p_cb->rcvd_cmd_code, enc_size); in smp_pairing_request_response_parameters_are_valid()
1069 BOOLEAN smp_pairing_keypress_notification_is_valid(tSMP_CB *p_cb) in smp_pairing_keypress_notification_is_valid() argument
1071 tBTM_SP_KEY_TYPE keypress_notification = p_cb->peer_keypress_notification; in smp_pairing_keypress_notification_is_valid()
1073 SMP_TRACE_DEBUG("%s for cmd code 0x%02x", __func__, p_cb->rcvd_cmd_code); in smp_pairing_keypress_notification_is_valid()
1079 p_cb->rcvd_cmd_code, keypress_notification); in smp_pairing_keypress_notification_is_valid()
1093 BOOLEAN smp_parameter_unconditionally_valid(UNUSED_ATTR tSMP_CB *p_cb) in smp_parameter_unconditionally_valid() argument
1105 BOOLEAN smp_parameter_unconditionally_invalid(UNUSED_ATTR tSMP_CB *p_cb) in smp_parameter_unconditionally_invalid() argument
1154 tSMP_ASSO_MODEL smp_select_association_model(tSMP_CB *p_cb) in smp_select_association_model() argument
1157 p_cb->le_secure_connections_mode_is_used = FALSE; in smp_select_association_model()
1161 __FUNCTION__, p_cb->peer_io_caps, p_cb->local_io_capability); in smp_select_association_model()
1163 __FUNCTION__, p_cb->peer_oob_flag, p_cb->loc_oob_flag); in smp_select_association_model()
1165 __FUNCTION__, p_cb->peer_auth_req, p_cb->loc_auth_req); in smp_select_association_model()
1167 __FUNCTION__, p_cb->secure_connections_only_mode_required ? in smp_select_association_model()
1170 if ((p_cb->peer_auth_req & SMP_SC_SUPPORT_BIT) && (p_cb->loc_auth_req & SMP_SC_SUPPORT_BIT)) in smp_select_association_model()
1172 p_cb->le_secure_connections_mode_is_used = TRUE; in smp_select_association_model()
1175 SMP_TRACE_DEBUG("use_sc_process = %d", p_cb->le_secure_connections_mode_is_used); in smp_select_association_model()
1177 if (p_cb->le_secure_connections_mode_is_used) in smp_select_association_model()
1179 model = smp_select_association_model_secure_connections(p_cb); in smp_select_association_model()
1183 model = smp_select_legacy_association_model(p_cb); in smp_select_association_model()
1195 tSMP_ASSO_MODEL smp_select_legacy_association_model(tSMP_CB *p_cb) in smp_select_legacy_association_model() argument
1201 if (p_cb->peer_oob_flag == SMP_OOB_PRESENT && p_cb->loc_oob_flag == SMP_OOB_PRESENT) in smp_select_legacy_association_model()
1205 if (SMP_NO_MITM_REQUIRED (p_cb->peer_auth_req) && SMP_NO_MITM_REQUIRED(p_cb->loc_auth_req)) in smp_select_legacy_association_model()
1209 if (p_cb->peer_io_caps < SMP_IO_CAP_MAX && p_cb->local_io_capability < SMP_IO_CAP_MAX) in smp_select_legacy_association_model()
1211 if (p_cb->role == HCI_ROLE_MASTER) in smp_select_legacy_association_model()
1213 model = smp_association_table[p_cb->role][p_cb->peer_io_caps] in smp_select_legacy_association_model()
1214 [p_cb->local_io_capability]; in smp_select_legacy_association_model()
1218 model = smp_association_table[p_cb->role][p_cb->local_io_capability] in smp_select_legacy_association_model()
1219 [p_cb->peer_io_caps]; in smp_select_legacy_association_model()
1233 tSMP_ASSO_MODEL smp_select_association_model_secure_connections(tSMP_CB *p_cb) in smp_select_association_model_secure_connections() argument
1239 if (p_cb->peer_oob_flag == SMP_OOB_PRESENT || p_cb->loc_oob_flag == SMP_OOB_PRESENT) in smp_select_association_model_secure_connections()
1243 if (SMP_NO_MITM_REQUIRED (p_cb->peer_auth_req) && SMP_NO_MITM_REQUIRED(p_cb->loc_auth_req)) in smp_select_association_model_secure_connections()
1247 if (p_cb->peer_io_caps < SMP_IO_CAP_MAX && p_cb->local_io_capability < SMP_IO_CAP_MAX) in smp_select_association_model_secure_connections()
1249 if (p_cb->role == HCI_ROLE_MASTER) in smp_select_association_model_secure_connections()
1251 model = smp_association_table_sc[p_cb->role][p_cb->peer_io_caps] in smp_select_association_model_secure_connections()
1252 [p_cb->local_io_capability]; in smp_select_association_model_secure_connections()
1256 model = smp_association_table_sc[p_cb->role][p_cb->local_io_capability] in smp_select_association_model_secure_connections()
1257 [p_cb->peer_io_caps]; in smp_select_association_model_secure_connections()
1316 void smp_collect_local_io_capabilities(UINT8 *iocap, tSMP_CB *p_cb) in smp_collect_local_io_capabilities() argument
1320 iocap[0] = p_cb->local_io_capability; in smp_collect_local_io_capabilities()
1321 iocap[1] = p_cb->loc_oob_flag; in smp_collect_local_io_capabilities()
1322 iocap[2] = p_cb->loc_auth_req; in smp_collect_local_io_capabilities()
1334 void smp_collect_peer_io_capabilities(UINT8 *iocap, tSMP_CB *p_cb) in smp_collect_peer_io_capabilities() argument
1338 iocap[0] = p_cb->peer_io_caps; in smp_collect_peer_io_capabilities()
1339 iocap[1] = p_cb->peer_oob_flag; in smp_collect_peer_io_capabilities()
1340 iocap[2] = p_cb->peer_auth_req; in smp_collect_peer_io_capabilities()
1353 void smp_collect_local_ble_address(UINT8 *le_addr, tSMP_CB *p_cb) in smp_collect_local_ble_address() argument
1361 BTM_ReadConnectionAddr( p_cb->pairing_bda, bda, &addr_type); in smp_collect_local_ble_address()
1376 void smp_collect_peer_ble_address(UINT8 *le_addr, tSMP_CB *p_cb) in smp_collect_peer_ble_address() argument
1384 if (!BTM_ReadRemoteConnectionAddr(p_cb->pairing_bda, bda, &addr_type)) in smp_collect_peer_ble_address()
1405 BOOLEAN smp_check_commitment(tSMP_CB *p_cb) in smp_check_commitment() argument
1411 smp_calculate_peer_commitment(p_cb, expected); in smp_check_commitment()
1413 print128(p_cb->remote_commitment, (const UINT8 *)"received peer commitment"); in smp_check_commitment()
1415 if (memcmp(p_cb->remote_commitment, expected, BT_OCTET16_LEN)) in smp_check_commitment()
1435 void smp_save_secure_connections_long_term_key(tSMP_CB *p_cb) in smp_save_secure_connections_long_term_key() argument
1441 memcpy(lle_key.ltk, p_cb->ltk, BT_OCTET16_LEN); in smp_save_secure_connections_long_term_key()
1443 lle_key.key_size = p_cb->loc_enc_size; in smp_save_secure_connections_long_term_key()
1444 lle_key.sec_level = p_cb->sec_level; in smp_save_secure_connections_long_term_key()
1445 btm_sec_save_le_key(p_cb->pairing_bda, BTM_LE_KEY_LENC, (tBTM_LE_KEY_VALUE *)&lle_key, TRUE); in smp_save_secure_connections_long_term_key()
1450 memcpy(ple_key.ltk, p_cb->ltk, BT_OCTET16_LEN); in smp_save_secure_connections_long_term_key()
1451 ple_key.sec_level = p_cb->sec_level; in smp_save_secure_connections_long_term_key()
1452 ple_key.key_size = p_cb->loc_enc_size; in smp_save_secure_connections_long_term_key()
1453 btm_sec_save_le_key(p_cb->pairing_bda, BTM_LE_KEY_PENC, (tBTM_LE_KEY_VALUE *)&ple_key, TRUE); in smp_save_secure_connections_long_term_key()
1468 BOOLEAN smp_calculate_f5_mackey_and_long_term_key(tSMP_CB *p_cb) in smp_calculate_f5_mackey_and_long_term_key() argument
1477 if (p_cb->role == HCI_ROLE_MASTER) in smp_calculate_f5_mackey_and_long_term_key()
1479 smp_collect_local_ble_address(a, p_cb); in smp_calculate_f5_mackey_and_long_term_key()
1480 smp_collect_peer_ble_address(b, p_cb); in smp_calculate_f5_mackey_and_long_term_key()
1481 p_na = p_cb->rand; in smp_calculate_f5_mackey_and_long_term_key()
1482 p_nb = p_cb->rrand; in smp_calculate_f5_mackey_and_long_term_key()
1486 smp_collect_local_ble_address(b, p_cb); in smp_calculate_f5_mackey_and_long_term_key()
1487 smp_collect_peer_ble_address(a, p_cb); in smp_calculate_f5_mackey_and_long_term_key()
1488 p_na = p_cb->rrand; in smp_calculate_f5_mackey_and_long_term_key()
1489 p_nb = p_cb->rand; in smp_calculate_f5_mackey_and_long_term_key()
1492 if(!smp_calculate_f5(p_cb->dhkey, p_na, p_nb, a, b, p_cb->mac_key, p_cb->ltk)) in smp_calculate_f5_mackey_and_long_term_key()
1512 BOOLEAN smp_request_oob_data(tSMP_CB *p_cb) in smp_request_oob_data() argument
1518 if (p_cb->peer_oob_flag == SMP_OOB_PRESENT && p_cb->loc_oob_flag == SMP_OOB_PRESENT) in smp_request_oob_data()
1523 else if (p_cb->peer_oob_flag == SMP_OOB_PRESENT) in smp_request_oob_data()
1528 else if (p_cb->loc_oob_flag == SMP_OOB_PRESENT) in smp_request_oob_data()
1538 p_cb->req_oob_type = req_oob_type; in smp_request_oob_data()
1539 p_cb->cb_evt = SMP_SC_OOB_REQ_EVT; in smp_request_oob_data()
1540 smp_sm_event(p_cb, SMP_TK_REQ_EVT, &req_oob_type); in smp_request_oob_data()