int test_1_execute(dsi_test_obj_t * obj) { dsi_hndl_t hndl; DSI_TEST_FUNC_ENTRY; do { dsi_inited = TRUE; /* get hndl */ hndl = dsi_get_data_srvc_hndl(dsi_test_1_cb, (void *)obj); if (NULL == hndl) { printf("couldnt' get hndl \n"); break; } /* statt data call */ dsi_start_data_call(hndl); /* generate SNI async rsp */ dsi_test_sni_rsp(hndl, sni_wds_hndl); /* generate pkt srvc ind */ dsi_test_pkt_data_connected(sni_wds_hndl, sni_dev_id); /* generate NET PLATFORM UP EV */ dsi_test_platform_up(sni_dev_id); /* wait for cond variable */ pthread_mutex_lock(&mutex); pthread_cond_wait(&cond, &mutex); if (test_cb_event != DSI_EVT_NET_IS_CONN) { DSI_TEST_ERR("rcvd evt [%d] instead of NET_IS_CONN", test_cb_event); break; } pthread_mutex_unlock(&mutex); DSI_TEST_REPORT_LOG("%s","verified NET_IS_CONN rcvd"); /* modem oos */ qmi_sys_event_info_type sys_event_info; dsi_qmi_sys_cb(QMI_SYS_EVENT_MODEM_OUT_OF_SERVICE_IND, &sys_event_info, NULL); /* wait for cond variable */ pthread_mutex_lock(&mutex); pthread_cond_wait(&cond, &mutex); if (test_cb_event != DSI_EVT_NET_NO_NET) { DSI_TEST_ERR("rcvd evt [%d] instead of NET_NO_NET", test_cb_event); break; } pthread_mutex_unlock(&mutex); DSI_TEST_REPORT_LOG("%s","verified NET_NO_NET rcvd in modem oos"); /* get hndl */ hndl = dsi_get_data_srvc_hndl(dsi_test_1_cb, (void *)obj); if (NULL != hndl) { DSI_TEST_ERR("able to get [%d] hndl when modem oos", hndl); break; } else { DSI_TEST_REPORT_LOG("%s","verified can't get hndl when modem oos"); } /* modem is */ dsi_qmi_sys_cb(QMI_SYS_EVENT_MODEM_IN_SERVICE_IND, &sys_event_info, NULL); /* let dsi_netctrl lib be re-initialized again */ sleep(1); /* get hndl */ hndl = dsi_get_data_srvc_hndl(dsi_test_1_cb, (void *)obj); if (NULL == hndl) { DSI_TEST_ERR("%s","couldnt' get hndl \n"); break; } /* statt data call */ dsi_start_data_call(hndl); /* generate SNI async rsp */ dsi_test_sni_rsp(hndl, sni_wds_hndl); /* generate pkt srvc ind */ dsi_test_pkt_data_connected(sni_wds_hndl, sni_dev_id); /* generate NET PLATFORM UP EV */ dsi_test_platform_up(sni_dev_id); /* wait for cond variable */ pthread_mutex_lock(&mutex); pthread_cond_wait(&cond, &mutex); if (test_cb_event != DSI_EVT_NET_IS_CONN) { DSI_TEST_ERR("rcvd evt [%d] instead of NET_IS_CONN", test_cb_event); break; } pthread_mutex_unlock(&mutex); DSI_TEST_REPORT_LOG("%s","verified NET_IS_CONN rcvd after modem is"); /* generate NET PLATFORM DOWN EV */ dsi_test_platform_down(sni_dev_id); /* wait for cond variable */ pthread_mutex_lock(&mutex); pthread_cond_wait(&cond, &mutex); if (test_cb_event != DSI_EVT_NET_NO_NET) { DSI_TEST_ERR("rcvd evt [%d] instead of NET_NO_NET", test_cb_event); break; } pthread_mutex_unlock(&mutex); DSI_TEST_REPORT_LOG("%s","verified NET_NO_NET rcvd after test posted platform down"); /* if condition is signalled, test passes */ DSI_TEST_REPORT_LOG("[%s] PASS", obj->name); DSI_TEST_FUNC_EXIT; return; } while (0); DSI_TEST_REPORT_LOG("[%s] FAIL", obj->name); DSI_TEST_FUNC_EXIT; }
/** * @brief Prepares for call. * * Obtains a handle to the dsi_netctrl layer and looks up the profile * to make the call. As of now. It only searches for profiles that * support emergency calls. * * Function to open an emergency call. Does the following things: * - Obtains a handle to the WDS service * - Obtains a list of profiles configured in the modem * - Queries each profile and obtains settings to check if emergency calls * are supported * - Returns the profile index that supports emergency calls * - Returns handle to dsi_netctrl * * @param[out] client_handle Client handle to initialize. * @param[in] callback Pointer to callback function table. * @param[in] cookie Client's cookie for using with callback calls. * @param[out] profile_index Pointer to profile index number. * @param[out] pdp_type Pointer to PDP type. * * @return Operation result * @retval E_DS_CLIENT_SUCCESS On success. Output parameters are initialized. * @retval E_DS_CLIENT_FAILURE... On error. */ static ds_client_status_enum_type ds_client_open_call ( dsClientHandleType *client_handle, const ds_client_cb_data *callback, void *cookie, int *profile_index, int *pdp_type ) { ds_client_status_enum_type ret = E_DS_CLIENT_FAILURE_GENERAL; ds_client_resp_union_type profile_list_resp_msg; ds_client_resp_union_type profile_settings_resp_msg; wds_profile_identifier_type_v01 profile_identifier; uint32_t i=0; dsi_hndl_t dsi_handle; ds_client_session_data **ds_global_data = (ds_client_session_data **)client_handle; unsigned char call_profile_index_found = 0; uint32_t emergency_profile_index=0; qmi_client_type wds_qmi_client; profile_list_resp_msg.p_get_profile_list_resp = NULL; profile_settings_resp_msg.p_get_profile_setting_resp = NULL; LOC_LOGD("%s:%d]:Enter\n", __func__, __LINE__); if(callback == NULL || ds_global_data == NULL) { LOC_LOGE("%s:%d]: Null callback parameter\n", __func__, __LINE__); goto err; } ret = ds_client_qmi_ctrl_point_init(&wds_qmi_client); if(ret != E_DS_CLIENT_SUCCESS) { LOC_LOGE("%s:%d]: ds_client_qmi_ctrl_point_init failed. ret: %d\n", __func__, __LINE__, ret); goto err; } //Allocate memory for the response msg to obtain a list of profiles profile_list_resp_msg.p_get_profile_list_resp = (wds_get_profile_list_resp_msg_v01 *) calloc(1, sizeof(wds_get_profile_list_resp_msg_v01)); if(profile_list_resp_msg.p_get_profile_list_resp == NULL) { LOC_LOGE("%s:%d]: Could not allocate memory for" "p_get_profile_list_resp\n", __func__, __LINE__); ret = E_DS_CLIENT_FAILURE_NOT_ENOUGH_MEMORY; goto err; } LOC_LOGD("%s:%d]: Getting profile list\n", __func__, __LINE__); ret = ds_client_get_profile_list(&wds_qmi_client, &profile_list_resp_msg, WDS_PROFILE_TYPE_3GPP_V01); if(ret != E_DS_CLIENT_SUCCESS) { LOC_LOGE("%s:%d]: ds_client_get_profile_list failed. ret: %d\n", __func__, __LINE__, ret); goto err; } LOC_LOGD("%s:%d]: Got profile list; length = %d\n", __func__, __LINE__, profile_list_resp_msg.p_get_profile_list_resp->profile_list_len); //Allocate memory for the response msg to obtain profile settings //We allocate memory for only one response msg and keep re-using it profile_settings_resp_msg.p_get_profile_setting_resp = (wds_get_profile_settings_resp_msg_v01 *) calloc(1, sizeof(wds_get_profile_settings_resp_msg_v01)); if(profile_settings_resp_msg.p_get_profile_setting_resp == NULL) { LOC_LOGE("%s:%d]: Could not allocate memory for" "p_get_profile_setting_resp\n", __func__, __LINE__); ret = E_DS_CLIENT_FAILURE_NOT_ENOUGH_MEMORY; goto err; } //Loop over the list of profiles to find a profile that supports //emergency calls for(i=0; i < profile_list_resp_msg.p_get_profile_list_resp->profile_list_len; i++) { /*QMI_WDS_GET_PROFILE_SETTINGS_REQ requires an input data structure that is of type wds_profile_identifier_type_v01 We have to fill that structure for each profile from the info obtained from the profile list*/ //copy profile type profile_identifier.profile_type = profile_list_resp_msg.p_get_profile_list_resp->profile_list[i].profile_type; //copy profile index profile_identifier.profile_index = profile_list_resp_msg.p_get_profile_list_resp->profile_list[i].profile_index; ret = ds_client_get_profile_settings(&wds_qmi_client, &profile_settings_resp_msg, &profile_identifier); if(ret != E_DS_CLIENT_SUCCESS) { LOC_LOGE("%s:%d]: ds_client_get_profile_settings failed. ret: %d\n", __func__, __LINE__, ret); goto err; } LOC_LOGD("%s:%d]: Got profile setting for profile %d; name: %s\n", __func__, __LINE__, i, profile_settings_resp_msg.p_get_profile_setting_resp->profile_name); if(profile_settings_resp_msg.p_get_profile_setting_resp->support_emergency_calls_valid) { if(profile_settings_resp_msg.p_get_profile_setting_resp->support_emergency_calls) { LOC_LOGD("%s:%d]: Found emergency profile in profile %d" , __func__, __LINE__, i); call_profile_index_found = 1; emergency_profile_index = profile_identifier.profile_index; if(profile_settings_resp_msg.p_get_profile_setting_resp->pdp_type_valid) { *pdp_type = (int)profile_settings_resp_msg.p_get_profile_setting_resp->pdp_type; LOC_LOGD("%s:%d]: pdp_type: %d\n", __func__, __LINE__, *pdp_type); switch(*pdp_type) { case WDS_PDP_TYPE_PDP_IPV4_V01: *pdp_type = DSI_IP_VERSION_4; break; case WDS_PDP_TYPE_PDP_IPV6_V01: *pdp_type = DSI_IP_VERSION_6; break; case WDS_PDP_TYPE_PDP_IPV4V6_V01: *pdp_type = DSI_IP_VERSION_4_6; break; default: LOC_LOGE("%s:%d]: pdp_type unknown. Setting default as ipv4/v6\n", __func__, __LINE__); *pdp_type = DSI_IP_VERSION_4; } } else { LOC_LOGD("%s:%d]: pdp type not valid in profile setting. Default ipv4\n", __func__, __LINE__); *pdp_type = DSI_IP_VERSION_4; } //Break out of for loop since we found the emergency profile break; } else LOC_LOGE("%s:%d]: Emergency profile valid but not supported in profile: %d " , __func__, __LINE__, i); } //Since this struct is loaded with settings for the next profile, //it is important to clear out the memory to avoid values/flags //from being carried over memset((void *)profile_settings_resp_msg.p_get_profile_setting_resp, 0, sizeof(wds_get_profile_settings_resp_msg_v01)); } //Release qmi client handle if(qmi_client_release(wds_qmi_client) != QMI_NO_ERR) { LOC_LOGE("%s:%d]: Could not release qmi client handle\n", __func__, __LINE__); ret = E_DS_CLIENT_FAILURE_GENERAL; } if(call_profile_index_found) { *profile_index = emergency_profile_index; *ds_global_data = (ds_client_session_data *)calloc(1, sizeof(ds_client_session_data)); if(*ds_global_data == NULL) { LOC_LOGE("%s:%d]: Could not allocate memory for ds_global_data. Failing\n", __func__, __LINE__); ret = E_DS_CLIENT_FAILURE_NOT_ENOUGH_MEMORY; goto err; } (*ds_global_data)->caller_data.event_cb = callback->event_cb; (*ds_global_data)->caller_data.caller_cookie = cookie; dsi_handle = dsi_get_data_srvc_hndl(net_ev_cb, &(*ds_global_data)->caller_data); if(dsi_handle == NULL) { LOC_LOGE("%s:%d]: Could not get data handle. Retry Later\n", __func__, __LINE__); ret = E_DS_CLIENT_RETRY_LATER; goto err; } else (*ds_global_data)->dsi_net_handle = dsi_handle; } else { LOC_LOGE("%s:%d]: Could not find a profile that supports emergency calls", __func__, __LINE__); ret = E_DS_CLIENT_FAILURE_GENERAL; } err: if(profile_list_resp_msg.p_get_profile_list_resp) free(profile_list_resp_msg.p_get_profile_list_resp); if(profile_settings_resp_msg.p_get_profile_setting_resp) free(profile_settings_resp_msg.p_get_profile_setting_resp); LOC_LOGD("%s:%d]:Exit\n", __func__, __LINE__); return ret; }