• 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()
407 BT_HDR * smp_build_pairing_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_pairing_cmd() argument
417 UINT8_TO_STREAM(p, p_cb->local_io_capability); in smp_build_pairing_cmd()
418 UINT8_TO_STREAM(p, p_cb->loc_oob_flag); in smp_build_pairing_cmd()
419 UINT8_TO_STREAM(p, p_cb->loc_auth_req); in smp_build_pairing_cmd()
420 UINT8_TO_STREAM(p, p_cb->loc_enc_size); in smp_build_pairing_cmd()
421 UINT8_TO_STREAM(p, p_cb->local_i_key); in smp_build_pairing_cmd()
422 UINT8_TO_STREAM(p, p_cb->local_r_key); in smp_build_pairing_cmd()
438 static BT_HDR * smp_build_confirm_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_confirm_cmd() argument
450 ARRAY_TO_STREAM(p, p_cb->confirm, BT_OCTET16_LEN); in smp_build_confirm_cmd()
465 static BT_HDR * smp_build_rand_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_rand_cmd() argument
476 ARRAY_TO_STREAM(p, p_cb->rand, BT_OCTET16_LEN); in smp_build_rand_cmd()
491 static BT_HDR * smp_build_encrypt_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_encrypt_info_cmd() argument
502 ARRAY_TO_STREAM(p, p_cb->ltk, BT_OCTET16_LEN); in smp_build_encrypt_info_cmd()
517 static BT_HDR * smp_build_master_id_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_master_id_cmd() argument
528 UINT16_TO_STREAM(p, p_cb->ediv); in smp_build_master_id_cmd()
529 ARRAY_TO_STREAM(p, p_cb->enc_rand, BT_OCTET8_LEN); in smp_build_master_id_cmd()
544 static BT_HDR * smp_build_identity_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_identity_info_cmd() argument
552 UNUSED(p_cb); in smp_build_identity_info_cmd()
575 static BT_HDR * smp_build_id_addr_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_id_addr_cmd() argument
582 UNUSED(p_cb); in smp_build_id_addr_cmd()
603 static BT_HDR * smp_build_signing_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_signing_info_cmd() argument
614 ARRAY_TO_STREAM(p, p_cb->csrk, BT_OCTET16_LEN); in smp_build_signing_info_cmd()
629 static BT_HDR * smp_build_pairing_fail(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_pairing_fail() argument
640 UINT8_TO_STREAM(p, p_cb->failure); in smp_build_pairing_fail()
655 static BT_HDR *smp_build_security_request(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_security_request() argument
666 UINT8_TO_STREAM(p, p_cb->loc_auth_req); in smp_build_security_request()
671 SMP_TRACE_EVENT("opcode=%d auth_req=0x%x",SMP_OPCODE_SEC_REQ, p_cb->loc_auth_req ); in smp_build_security_request()
683 static BT_HDR *smp_build_pair_public_key_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_pair_public_key_cmd() argument
694 memcpy(p_publ_key, p_cb->loc_publ_key.x, BT_OCTET32_LEN); in smp_build_pair_public_key_cmd()
695 memcpy(p_publ_key + BT_OCTET32_LEN, p_cb->loc_publ_key.y, BT_OCTET32_LEN); in smp_build_pair_public_key_cmd()
714 static BT_HDR *smp_build_pairing_commitment_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_pairing_commitment_cmd() argument
725 ARRAY_TO_STREAM(p, p_cb->commitment, BT_OCTET16_LEN); in smp_build_pairing_commitment_cmd()
740 static BT_HDR *smp_build_pair_dhkey_check_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_pair_dhkey_check_cmd() argument
751 ARRAY_TO_STREAM(p, p_cb->dhkey_check, BT_OCTET16_LEN); in smp_build_pair_dhkey_check_cmd()
766 static BT_HDR * smp_build_pairing_keypress_notification_cmd(UINT8 cmd_code, tSMP_CB *p_cb) in smp_build_pairing_keypress_notification_cmd() argument
777 UINT8_TO_STREAM(p, p_cb->local_keypress_notification); in smp_build_pairing_keypress_notification_cmd()
861 void smp_cb_cleanup(tSMP_CB *p_cb) in smp_cb_cleanup() argument
863 tSMP_CALLBACK *p_callback = p_cb->p_callback; in smp_cb_cleanup()
864 UINT8 trace_level = p_cb->trace_level; in smp_cb_cleanup()
868 alarm_free(p_cb->smp_rsp_timer_ent); in smp_cb_cleanup()
869 alarm_free(p_cb->delayed_auth_timer_ent); in smp_cb_cleanup()
870 memset(p_cb, 0, sizeof(tSMP_CB)); in smp_cb_cleanup()
871 p_cb->p_callback = p_callback; in smp_cb_cleanup()
872 p_cb->trace_level = trace_level; in smp_cb_cleanup()
873 p_cb->smp_rsp_timer_ent = alarm_new("smp.smp_rsp_timer_ent"); in smp_cb_cleanup()
874 p_cb->delayed_auth_timer_ent = alarm_new("smp.delayed_auth_timer_ent"); in smp_cb_cleanup()
886 void smp_remove_fixed_channel(tSMP_CB *p_cb) in smp_remove_fixed_channel() argument
890 if (p_cb->smp_over_br) in smp_remove_fixed_channel()
891 L2CA_RemoveFixedChnl (L2CAP_SMP_BR_CID, p_cb->pairing_bda); in smp_remove_fixed_channel()
893 L2CA_RemoveFixedChnl (L2CAP_SMP_CID, p_cb->pairing_bda); in smp_remove_fixed_channel()
907 void smp_reset_control_value(tSMP_CB *p_cb) in smp_reset_control_value() argument
911 alarm_cancel(p_cb->smp_rsp_timer_ent); in smp_reset_control_value()
912 p_cb->flags = 0; in smp_reset_control_value()
917 L2CA_SetIdleTimeoutByBdAddr(p_cb->pairing_bda, SMP_LINK_TOUT_MIN, BT_TRANSPORT_LE); in smp_reset_control_value()
920 smp_remove_fixed_channel(p_cb); in smp_reset_control_value()
921 smp_cb_cleanup(p_cb); in smp_reset_control_value()
934 void smp_proc_pairing_cmpl(tSMP_CB *p_cb) in smp_proc_pairing_cmpl() argument
937 tSMP_CALLBACK *p_callback = p_cb->p_callback; in smp_proc_pairing_cmpl()
942 evt_data.cmplt.reason = p_cb->status; in smp_proc_pairing_cmpl()
943 evt_data.cmplt.smp_over_br = p_cb->smp_over_br; in smp_proc_pairing_cmpl()
945 if (p_cb->status == SMP_SUCCESS) in smp_proc_pairing_cmpl()
946 evt_data.cmplt.sec_level = p_cb->sec_level; in smp_proc_pairing_cmpl()
950 if (p_cb->is_pair_cancel) in smp_proc_pairing_cmpl()
958 memcpy (pairing_bda, p_cb->pairing_bda, BD_ADDR_LEN); in smp_proc_pairing_cmpl()
960 smp_reset_control_value(p_cb); in smp_proc_pairing_cmpl()
978 BOOLEAN smp_command_has_invalid_parameters(tSMP_CB *p_cb) in smp_command_has_invalid_parameters() argument
980 UINT8 cmd_code = p_cb->rcvd_cmd_code; in smp_command_has_invalid_parameters()
991 if (!(*smp_cmd_len_is_valid[cmd_code])(p_cb)) in smp_command_has_invalid_parameters()
994 if (!(*smp_cmd_param_ranges_are_valid[cmd_code])(p_cb)) in smp_command_has_invalid_parameters()
1011 BOOLEAN smp_command_has_valid_fixed_length(tSMP_CB *p_cb) in smp_command_has_valid_fixed_length() argument
1013 UINT8 cmd_code = p_cb->rcvd_cmd_code; in smp_command_has_valid_fixed_length()
1017 if (p_cb->rcvd_cmd_len != smp_cmd_size_per_spec[cmd_code]) in smp_command_has_valid_fixed_length()
1021 cmd_code, p_cb->rcvd_cmd_len, smp_cmd_size_per_spec[cmd_code]); in smp_command_has_valid_fixed_length()
1042 BOOLEAN smp_pairing_request_response_parameters_are_valid(tSMP_CB *p_cb) in smp_pairing_request_response_parameters_are_valid() argument
1044 UINT8 io_caps = p_cb->peer_io_caps; in smp_pairing_request_response_parameters_are_valid()
1045 UINT8 oob_flag = p_cb->peer_oob_flag; in smp_pairing_request_response_parameters_are_valid()
1046 UINT8 bond_flag = p_cb->peer_auth_req & 0x03; //0x03 is gen bond with appropriate mask in smp_pairing_request_response_parameters_are_valid()
1047 UINT8 enc_size = p_cb->peer_enc_size; in smp_pairing_request_response_parameters_are_valid()
1049 SMP_TRACE_DEBUG("%s for cmd code 0x%02x", __func__, p_cb->rcvd_cmd_code); in smp_pairing_request_response_parameters_are_valid()
1055 p_cb->rcvd_cmd_code, io_caps); in smp_pairing_request_response_parameters_are_valid()
1063 p_cb->rcvd_cmd_code, oob_flag); in smp_pairing_request_response_parameters_are_valid()
1071 p_cb->rcvd_cmd_code, bond_flag); in smp_pairing_request_response_parameters_are_valid()
1079 p_cb->rcvd_cmd_code, enc_size); in smp_pairing_request_response_parameters_are_valid()
1095 BOOLEAN smp_pairing_keypress_notification_is_valid(tSMP_CB *p_cb) in smp_pairing_keypress_notification_is_valid() argument
1097 tBTM_SP_KEY_TYPE keypress_notification = p_cb->peer_keypress_notification; in smp_pairing_keypress_notification_is_valid()
1099 SMP_TRACE_DEBUG("%s for cmd code 0x%02x", __func__, p_cb->rcvd_cmd_code); in smp_pairing_keypress_notification_is_valid()
1105 p_cb->rcvd_cmd_code, keypress_notification); in smp_pairing_keypress_notification_is_valid()
1119 BOOLEAN smp_parameter_unconditionally_valid(UNUSED_ATTR tSMP_CB *p_cb) in smp_parameter_unconditionally_valid() argument
1131 BOOLEAN smp_parameter_unconditionally_invalid(UNUSED_ATTR tSMP_CB *p_cb) in smp_parameter_unconditionally_invalid() argument
1180 tSMP_ASSO_MODEL smp_select_association_model(tSMP_CB *p_cb) in smp_select_association_model() argument
1183 p_cb->le_secure_connections_mode_is_used = FALSE; in smp_select_association_model()
1187 __FUNCTION__, p_cb->peer_io_caps, p_cb->local_io_capability); in smp_select_association_model()
1189 __FUNCTION__, p_cb->peer_oob_flag, p_cb->loc_oob_flag); in smp_select_association_model()
1191 __FUNCTION__, p_cb->peer_auth_req, p_cb->loc_auth_req); in smp_select_association_model()
1193 __FUNCTION__, p_cb->secure_connections_only_mode_required ? in smp_select_association_model()
1196 if ((p_cb->peer_auth_req & SMP_SC_SUPPORT_BIT) && (p_cb->loc_auth_req & SMP_SC_SUPPORT_BIT)) in smp_select_association_model()
1198 p_cb->le_secure_connections_mode_is_used = TRUE; in smp_select_association_model()
1201 SMP_TRACE_DEBUG("use_sc_process = %d", p_cb->le_secure_connections_mode_is_used); in smp_select_association_model()
1203 if (p_cb->le_secure_connections_mode_is_used) in smp_select_association_model()
1205 model = smp_select_association_model_secure_connections(p_cb); in smp_select_association_model()
1209 model = smp_select_legacy_association_model(p_cb); in smp_select_association_model()
1221 tSMP_ASSO_MODEL smp_select_legacy_association_model(tSMP_CB *p_cb) in smp_select_legacy_association_model() argument
1227 if (p_cb->peer_oob_flag == SMP_OOB_PRESENT && p_cb->loc_oob_flag == SMP_OOB_PRESENT) in smp_select_legacy_association_model()
1231 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()
1235 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()
1237 if (p_cb->role == HCI_ROLE_MASTER) in smp_select_legacy_association_model()
1239 model = smp_association_table[p_cb->role][p_cb->peer_io_caps] in smp_select_legacy_association_model()
1240 [p_cb->local_io_capability]; in smp_select_legacy_association_model()
1244 model = smp_association_table[p_cb->role][p_cb->local_io_capability] in smp_select_legacy_association_model()
1245 [p_cb->peer_io_caps]; in smp_select_legacy_association_model()
1259 tSMP_ASSO_MODEL smp_select_association_model_secure_connections(tSMP_CB *p_cb) in smp_select_association_model_secure_connections() argument
1265 if (p_cb->peer_oob_flag == SMP_OOB_PRESENT || p_cb->loc_oob_flag == SMP_OOB_PRESENT) in smp_select_association_model_secure_connections()
1269 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()
1273 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()
1275 if (p_cb->role == HCI_ROLE_MASTER) in smp_select_association_model_secure_connections()
1277 model = smp_association_table_sc[p_cb->role][p_cb->peer_io_caps] in smp_select_association_model_secure_connections()
1278 [p_cb->local_io_capability]; in smp_select_association_model_secure_connections()
1282 model = smp_association_table_sc[p_cb->role][p_cb->local_io_capability] in smp_select_association_model_secure_connections()
1283 [p_cb->peer_io_caps]; in smp_select_association_model_secure_connections()
1342 void smp_collect_local_io_capabilities(UINT8 *iocap, tSMP_CB *p_cb) in smp_collect_local_io_capabilities() argument
1346 iocap[0] = p_cb->local_io_capability; in smp_collect_local_io_capabilities()
1347 iocap[1] = p_cb->loc_oob_flag; in smp_collect_local_io_capabilities()
1348 iocap[2] = p_cb->loc_auth_req; in smp_collect_local_io_capabilities()
1360 void smp_collect_peer_io_capabilities(UINT8 *iocap, tSMP_CB *p_cb) in smp_collect_peer_io_capabilities() argument
1364 iocap[0] = p_cb->peer_io_caps; in smp_collect_peer_io_capabilities()
1365 iocap[1] = p_cb->peer_oob_flag; in smp_collect_peer_io_capabilities()
1366 iocap[2] = p_cb->peer_auth_req; in smp_collect_peer_io_capabilities()
1379 void smp_collect_local_ble_address(UINT8 *le_addr, tSMP_CB *p_cb) in smp_collect_local_ble_address() argument
1387 BTM_ReadConnectionAddr( p_cb->pairing_bda, bda, &addr_type); in smp_collect_local_ble_address()
1402 void smp_collect_peer_ble_address(UINT8 *le_addr, tSMP_CB *p_cb) in smp_collect_peer_ble_address() argument
1410 if (!BTM_ReadRemoteConnectionAddr(p_cb->pairing_bda, bda, &addr_type)) in smp_collect_peer_ble_address()
1431 BOOLEAN smp_check_commitment(tSMP_CB *p_cb) in smp_check_commitment() argument
1437 smp_calculate_peer_commitment(p_cb, expected); in smp_check_commitment()
1439 print128(p_cb->remote_commitment, (const UINT8 *)"received peer commitment"); in smp_check_commitment()
1441 if (memcmp(p_cb->remote_commitment, expected, BT_OCTET16_LEN)) in smp_check_commitment()
1461 void smp_save_secure_connections_long_term_key(tSMP_CB *p_cb) in smp_save_secure_connections_long_term_key() argument
1467 memcpy(lle_key.ltk, p_cb->ltk, BT_OCTET16_LEN); in smp_save_secure_connections_long_term_key()
1469 lle_key.key_size = p_cb->loc_enc_size; in smp_save_secure_connections_long_term_key()
1470 lle_key.sec_level = p_cb->sec_level; in smp_save_secure_connections_long_term_key()
1471 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()
1476 memcpy(ple_key.ltk, p_cb->ltk, BT_OCTET16_LEN); in smp_save_secure_connections_long_term_key()
1477 ple_key.sec_level = p_cb->sec_level; in smp_save_secure_connections_long_term_key()
1478 ple_key.key_size = p_cb->loc_enc_size; in smp_save_secure_connections_long_term_key()
1479 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()
1494 BOOLEAN smp_calculate_f5_mackey_and_long_term_key(tSMP_CB *p_cb) in smp_calculate_f5_mackey_and_long_term_key() argument
1503 if (p_cb->role == HCI_ROLE_MASTER) in smp_calculate_f5_mackey_and_long_term_key()
1505 smp_collect_local_ble_address(a, p_cb); in smp_calculate_f5_mackey_and_long_term_key()
1506 smp_collect_peer_ble_address(b, p_cb); in smp_calculate_f5_mackey_and_long_term_key()
1507 p_na = p_cb->rand; in smp_calculate_f5_mackey_and_long_term_key()
1508 p_nb = p_cb->rrand; in smp_calculate_f5_mackey_and_long_term_key()
1512 smp_collect_local_ble_address(b, p_cb); in smp_calculate_f5_mackey_and_long_term_key()
1513 smp_collect_peer_ble_address(a, p_cb); in smp_calculate_f5_mackey_and_long_term_key()
1514 p_na = p_cb->rrand; in smp_calculate_f5_mackey_and_long_term_key()
1515 p_nb = p_cb->rand; in smp_calculate_f5_mackey_and_long_term_key()
1518 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()
1538 BOOLEAN smp_request_oob_data(tSMP_CB *p_cb) in smp_request_oob_data() argument
1544 if (p_cb->peer_oob_flag == SMP_OOB_PRESENT && p_cb->loc_oob_flag == SMP_OOB_PRESENT) in smp_request_oob_data()
1549 else if (p_cb->peer_oob_flag == SMP_OOB_PRESENT) in smp_request_oob_data()
1554 else if (p_cb->loc_oob_flag == SMP_OOB_PRESENT) in smp_request_oob_data()
1564 p_cb->req_oob_type = req_oob_type; in smp_request_oob_data()
1565 p_cb->cb_evt = SMP_SC_OOB_REQ_EVT; in smp_request_oob_data()
1566 smp_sm_event(p_cb, SMP_TK_REQ_EVT, &req_oob_type); in smp_request_oob_data()