static bool add_client_tag_and_connid_to_request(pscc_msg_t *request_p, exe_request_record_t *record_p)
{
    bool result = false;
    int client_tag = 0;
    int conn_id = 0;

    if (NULL == request_p ||
            NULL == request_p->common.message_set_descr_p ||
            NULL == request_p->common.message_set_descr_p->param_descr_set_p) {
        ATC_LOG_E("request_p not fully allocated");
        goto error;
    }

    client_tag = request_record_get_client_tag(record_p);


    switch (request_p->common.message_set_descr_p->param_descr_set_p->param_set_id) {
    case PSCC_PARAM_SET_ID:

        if (psccclient_iadb_get_conn_id_on_at_ct((uintptr_t)record_p, &conn_id)) {
            if (mpl_add_param_to_list(&request_p->req.param_list_p, pscc_paramid_connid, &conn_id) < 0) {
                ATC_LOG_E("mpl_add_param_to_list failed!");
                goto error;
            }
        }

        if (mpl_add_param_to_list(&request_p->req.param_list_p, pscc_paramid_ct, &client_tag) < 0) {
            ATC_LOG_E("mpl_add_param_to_list (pscc) failed!");
            goto error;
        }

        ATC_LOG_I("(pscc): CT=%d connId=%d", client_tag, conn_id);
        break;
    case STERC_PARAM_SET_ID:

        if (mpl_add_param_to_list(&request_p->req.param_list_p, sterc_paramid_ct, &client_tag) < 0) {
            ATC_LOG_E("mpl_add_param_to_list (sterc) failed!");
            goto error;
        }

        ATC_LOG_I("(sterc): CT=%d ", client_tag);
        break;
    default:
        ATC_LOG_E("invalid param_set_id!");
        goto error;
    }

    result = true;

error:

    return result;
}
Example #2
0
mpl_list_t *handle_testprot(mpl_list_t *reqMsg)
{
    mpl_bag_t *reqParams;

    if (!TESTPROT_IS_COMMAND(reqMsg)) {
        goto req_failure;
    }

    reqParams = TESTPROT_GET_COMMAND_PARAMS_PTR(reqMsg);

    switch (TESTPROT_GET_COMMAND_ID(reqMsg)) {
        case TESTP_PARAM_ID(TestEchoInt_Req):
            return handle_TestEchoInt(reqParams);
        case TESTP_PARAM_ID(TestEchoIntPN_Req):
            return handle_TestEchoIntPN(reqParams);
        case TESTP_PARAM_ID(TestEchoEnum_Req):
            return handle_TestEchoEnum(reqParams);
        case TESTP_PARAM_ID(TestEchoEnumPN_Req):
            return handle_TestEchoEnumPN(reqParams);
        case TESTP_PARAM_ID(TestEchoBool_Req):
            return handle_TestEchoBool(reqParams);
        case TESTP_PARAM_ID(TestEchoBoolPN_Req):
            return handle_TestEchoBoolPN(reqParams);
        case TESTP_PARAM_ID(TestEchoString_Req):
            return handle_TestEchoString(reqParams);
        case TESTP_PARAM_ID(TestEchoStringPN_Req):
            return handle_TestEchoStringPN(reqParams);
        case TESTP_PARAM_ID(TestEchoAddr_Req):
            return handle_TestEchoAddr(reqParams);
        case TESTP_PARAM_ID(TestEchoAddrPN_Req):
            return handle_TestEchoAddrPN(reqParams);
        case TESTP_PARAM_ID(TestEchoArray_Req):
            return handle_TestEchoArray(reqParams);
        case TESTP_PARAM_ID(TestEchoArrayPN_Req):
            return handle_TestEchoArrayPN(reqParams);
        case TESTP_PARAM_ID(TestEchoTuple_Req):
            return handle_TestEchoTuple(reqParams);
        case TESTP_PARAM_ID(TestEchoTuplePN_Req):
            return handle_TestEchoTuplePN(reqParams);
        case TESTP_PARAM_ID(TestEchoBag_Req):
            return handle_TestEchoBag(reqParams);
        case TESTP_PARAM_ID(TestEchoBagPN_Req):
            return handle_TestEchoBagPN(reqParams);
        default:
            break;
    }

req_failure:
    {
        mpl_list_t *respMsg = NULL;
        mpl_bag_t *respParams = NULL;

        mpl_add_param_to_list(&respMsg,
                              TESTPROT_COMMAND_ID_TO_RESPONSE_ID(TESTPROT_GET_COMMAND_ID(reqMsg)),
                              respParams);
        mpl_param_list_destroy(&respParams);
        return respMsg;
    }
}
psccd_test_state_type_t tc_hcmp_dcmp_ON(int state)
{
  int cid = 1;
  char apn[] = "default-apn.services";
  ip_address_t ip;
  ip_address_t pdns;
  ip_address_t sdns;
  char ifname[] = "calle0";
  mal_gpds_qos_profile_t qosreq;
  mal_gpds_qos_profile_t qosrel5;
  mal_gpds_qos_profile_t qosmin;
  mal_gpds_qos_profile_t qosneg;
  memset(&qosneg,0,sizeof(mal_gpds_qos_profile_t));
  memset(&ip,0,sizeof(ip_address_t));
  memset(&pdns,0,sizeof(ip_address_t));
  memset(&sdns,0,sizeof(ip_address_t));
  inet_pton(AF_INET, "192.168.1.13", &ip);
  inet_pton(AF_INET, "192.168.1.14", &pdns);
  inet_pton(AF_INET, "192.168.1.15", &sdns);
  mpl_msg_t *pscc_msg_p=NULL;
  mpl_msg_t resp;
  ste_sim_t sim;
  char pdpactmsg[] = "apn1,pco1,nsapi1";
  mal_gpds_resource_control_info_t mal_gpds_resource_control_info;
  uintptr_t clienttag = 0;

  int dcomp = MAL_PDP_DCMP_ON;
  int hcomp = MAL_PDP_HCMP_ON;
  /* set service availability */

  {
    PSCC_test_ste_sim_cb_t callback;
    ste_uicc_get_service_availability_response_t ste_uicc_get_service_availability_response;
    memset(&callback, 0, sizeof(callback));
    memset(&ste_uicc_get_service_availability_response, 0, sizeof(ste_uicc_get_service_availability_response));
    callback.cause = STE_UICC_CAUSE_REQ_GET_SERVICE_AVAILABILITY;
    callback.client_tag = clienttag;
    ste_uicc_get_service_availability_response.service_availability = STE_UICC_SERVICE_AVAILABLE;
    ste_uicc_get_service_availability_response.uicc_status_code = STE_UICC_STATUS_CODE_OK;
    memcpy(&callback.data, &ste_uicc_get_service_availability_response, sizeof(ste_uicc_get_service_availability_response_t));
    TESTNOTNEG(sendToSim(PSCCD_TEST_TEST_STUB, PSCC_STE_SIM_CB, &callback,
           sizeof(callback)));
  }

  TESTNOTNEG(waitAndRespondToSim_ste_sim_read(0,sim));

  TESTNOTNEG(util_create(cid));

  /* perform connect */
  /* set parameters */
  pscc_msg_p = mpl_msg_alloc(PSCC_PARAM_SET_ID);
  pscc_msg_p->common.type = pscc_msgtype_req;
  pscc_msg_p->common.id = pscc_set;
  pscc_msg_p->common.param_list_p = NULL;
  mpl_add_param_to_list(&pscc_msg_p->common.param_list_p, pscc_paramid_connid,&cid);
  mpl_add_param_to_list(&pscc_msg_p->common.param_list_p, pscc_paramid_apn ,(char*) apn);
  mpl_add_param_to_list(&pscc_msg_p->common.param_list_p, pscc_paramid_hcmp,&(hcomp));
  mpl_add_param_to_list(&pscc_msg_p->common.param_list_p, pscc_paramid_dcmp,&(dcomp));
  TESTNOTNEG(sendToStecomCtrl(pscc_msg_p));
  mpl_msg_free((mpl_msg_t*)pscc_msg_p);

  TESTNOTNEG(waitAndReadStecomResp(&resp));
  TESTBOOL(MPL_GET_PARAM_VALUE_FROM_LIST(int,pscc_paramid_connid,(resp.common.param_list_p)), cid);
  TESTBOOL(resp.resp.result, 0);
  mpl_param_list_destroy(&resp.common.param_list_p);

  /* connect */
  pscc_msg_p = mpl_msg_alloc(PSCC_PARAM_SET_ID);
  pscc_msg_p->common.type = pscc_msgtype_req;
  pscc_msg_p->common.id = pscc_connect;
  pscc_msg_p->common.param_list_p = NULL;
  mpl_add_param_to_list(&pscc_msg_p->common.param_list_p, pscc_paramid_connid,&cid);
  TESTNOTNEG(sendToStecomCtrl(pscc_msg_p));
  mpl_msg_free((mpl_msg_t*)pscc_msg_p);

  /* has to be in the same order that pscc calls mal */
  TESTNOTNEG(waitAndRespondToGPDSSet_APN(0, apn, cid));
  TESTNOTNEG(waitAndRespondToGPDSSet_DCMP_on(0, MAL_PDP_DCMP_ON, cid));
  TESTNOTNEG(waitAndRespondToGPDSSet_HCMP_on(0, MAL_PDP_HCMP_ON, cid));
  TESTNOTNEG(waitAndRespondToGPDSSet_PDPType(0, MAL_PDP_TYPE_IPV4, cid));
  TESTNOTNEG(waitAndRespondToGPDSSet_AuthMeth(0, MAL_AUTH_METHOD_NONE, cid));
  TESTNOTNEG(waitAndRespondToGPDSSet_QoSReq(0, qosreq, cid));
  TESTNOTNEG(waitAndRespondToGPDSSet_QoSRel5(0, qosrel5, cid));
  TESTNOTNEG(waitAndRespondToGPDSSet_QoSMin(0, qosmin, cid));
  TESTNOTNEG(waitAndRespondToGPDSSet_PDPContextType(0, MAL_PDP_CONTEXT_TYPE_PRIMARY, cid));

  TESTNOTNEG(waitAndRespondToGPDSReq_Request(0, cid, MAL_GPDS_REQ_PSCONN_ACTIVATE, 0, 0));

  TESTNOTNEG(waitAndReadStecomResp(&resp));
  TESTBOOL(MPL_GET_PARAM_VALUE_FROM_LIST(int,pscc_paramid_connid,(resp.common.param_list_p)), cid);
  TESTBOOL(resp.resp.result, 0);
  mpl_param_list_destroy(&resp.common.param_list_p);

  /* we are now connecting and need to send callback resource control */
  {
    PSCC_test_mal_gpds_cb_t callback;
    memset(&callback, 0, sizeof(callback));
    memset(&mal_gpds_resource_control_info, 0, sizeof(mal_gpds_resource_control_info));
    mal_gpds_resource_control_info.seq_id = 101;
    mal_gpds_resource_control_info.resource_control_data.data_length = strlen(pdpactmsg);
    callback.conn_id = 0;
    callback.event_id = MAL_GPDS_EVENT_ID_RESOURCE_CONTROL_REQUESTED;
    memcpy(&callback.data, &mal_gpds_resource_control_info, sizeof(mal_gpds_resource_control_info));
    memcpy(&callback.extradata, &pdpactmsg, strlen(pdpactmsg));
    TESTNOTNEG(sendToGPDS(PSCCD_TEST_TEST_STUB, PSCC_MAL_GPDS_CALLBACK, &callback,
            sizeof(callback)));
  }

  TESTNOTNEG(waitAndRespondToGPDSReq_ResponseHandler());

  /* clienttag is same as seq_id */
  TESTNOTNEG(waitAndRespondToSim_ste_cat_call_control(0, sim, 101, (char*) pdpactmsg, (uint32_t) strlen(pdpactmsg)));

  {
    PSCC_test_ste_sim_cb_t callback;
    ste_cat_call_control_response_t ste_cat_call_control_response;
    memset(&callback, 0, sizeof(callback));
    memset(&ste_cat_call_control_response, 0, sizeof(ste_cat_call_control_response));
    callback.cause = STE_CAT_CAUSE_SIM_EC_CALL_CONTROL;
    callback.client_tag = 101;
    ste_cat_call_control_response.cc_result = STE_CAT_CC_ALLOWED_NO_MODIFICATION;
    memcpy(&callback.data, &ste_cat_call_control_response, sizeof(ste_cat_call_control_response_t));
    TESTNOTNEG(sendToSim(PSCCD_TEST_TEST_STUB, PSCC_STE_SIM_CB, &callback,
            sizeof(callback)));
  }

  TESTNOTNEG(waitAndRespondToSim_ste_sim_read(0,sim));

  {
    mal_gpds_resource_control_req_info_t mal_gpds_resource_control_req_info;
    memset(&mal_gpds_resource_control_req_info, 0, sizeof(mal_gpds_resource_control_req_info));
    mal_gpds_resource_control_req_info.seq_id = mal_gpds_resource_control_info.seq_id;
    mal_gpds_resource_control_req_info.cc_result = MAL_GPDS_RESOURCE_ALLOWED;
    TESTNOTNEG(waitAndRespondToGPDSReq_Request(0, 0, MAL_GPDS_REQ_RESOURCE_CONTROL, &mal_gpds_resource_control_req_info, sizeof(mal_gpds_resource_control_req_info_t)));
  }

  /* we are now connecting and need to send callback resource control */
  {
    PSCC_test_mal_gpds_cb_t callback;
    memset(&callback, 0, sizeof(callback));
    callback.conn_id = 0;
    callback.event_id = MAL_GPDS_EVENT_ID_RESOURCE_CONTROL_DONE;
    TESTNOTNEG(sendToGPDS(PSCCD_TEST_TEST_STUB, PSCC_MAL_GPDS_CALLBACK, &callback,
            sizeof(callback)));
  }

  TESTNOTNEG(waitAndRespondToGPDSReq_ResponseHandler());

  /* we are now resource controlled and need to send callback connected */
  {
    PSCC_test_mal_gpds_cb_t callback;
    memset(&callback, 0, sizeof(callback));
    callback.conn_id = cid;
    callback.event_id = MAL_GPDS_EVENT_ID_PDP_ACTIVE;
    TESTNOTNEG(sendToGPDS(PSCCD_TEST_TEST_STUB, PSCC_MAL_GPDS_CALLBACK, &callback,
            sizeof(callback)));
  }

  TESTNOTNEG(waitAndRespondToGPDSReq_ResponseHandler());

  TESTNOTNEG(waitAndRespondToGPDSGet_IPMAP(0, (int)(IPV4_MAP), cid));
  TESTNOTNEG(waitAndRespondToGPDSGet_IP(0, ip, cid));
  TESTNOTNEG(waitAndRespondToGPDSGet_PDNS(0, pdns, cid));
  TESTNOTNEG(waitAndRespondToGPDSGet_SDNS(0, sdns, cid));
  TESTNOTNEG(waitAndRespondToGPDSGet_IFNAME(0, ifname, cid));
  TESTNOTNEG(waitAndRespondToGPDSGet_QoSNeg(0, qosneg, cid));

  TESTNOTNEG(waitAndReadStecomEvent(&resp));
  TESTBOOL(resp.common.type,pscc_msgtype_event);
  TESTBOOL(resp.common.id,pscc_event_connected);
  TESTBOOL(MPL_GET_PARAM_VALUE_FROM_LIST(int,pscc_paramid_connid,(resp.common.param_list_p)), cid);
  TESTBOOL(resp.resp.result, 0);
  mpl_param_list_destroy(&resp.common.param_list_p);

  TESTNOTNEG(util_disconnect(cid));
  TESTNOTNEG(util_destroy(cid));

  /* reset service availability */
  {
    PSCC_test_ste_sim_cb_t callback;
    ste_uicc_get_service_availability_response_t ste_uicc_get_service_availability_response;
    memset(&callback, 0, sizeof(callback));
    memset(&ste_uicc_get_service_availability_response, 0, sizeof(ste_uicc_get_service_availability_response));
    callback.cause = STE_UICC_CAUSE_REQ_GET_SERVICE_AVAILABILITY;
    callback.client_tag = clienttag;
    ste_uicc_get_service_availability_response.service_availability = STE_UICC_SERVICE_NOT_AVAILABLE;
    ste_uicc_get_service_availability_response.uicc_status_code = STE_UICC_STATUS_CODE_OK;
    memcpy(&callback.data, &ste_uicc_get_service_availability_response, sizeof(ste_uicc_get_service_availability_response_t));
    TESTNOTNEG(sendToSim(PSCCD_TEST_TEST_STUB, PSCC_STE_SIM_CB, &callback,
            sizeof(callback)));
  }
  TESTNOTNEG(waitAndRespondToSim_ste_sim_read(0,sim));

  return PSCCD_TEST_SUCCESS;

  error:
  return PSCCD_TEST_FAIL;

}
psccd_test_state_type_t tc_cc_denied_by_gpds(int state)
{
  int cid = 1;
  char apn[] = "default-apn.services";
  ip_address_t ip;
  ip_address_t pdns;
  ip_address_t sdns;
  mal_gpds_qos_profile_t qosreq;
  mal_gpds_qos_profile_t qosrel5;
  mal_gpds_qos_profile_t qosmin;
  mal_gpds_qos_profile_t qosneg;
  memset(&qosneg,0,sizeof(mal_gpds_qos_profile_t));
  memset(&ip,0,sizeof(ip_address_t));
  memset(&pdns,0,sizeof(ip_address_t));
  memset(&sdns,0,sizeof(ip_address_t));
  inet_pton(AF_INET, "192.168.1.13", &ip);
  inet_pton(AF_INET, "192.168.1.14", &pdns);
  inet_pton(AF_INET, "192.168.1.15", &sdns);
  mpl_msg_t *pscc_msg_p=NULL;
  mpl_msg_t resp;
  ste_sim_t sim;
  char pdpactmsg[] = "apn1,pco1,nsapi1";
  char pdpactmsg_mod[] = "apn2,pco2,nsapi2";
  mal_gpds_resource_control_info_t mal_gpds_resource_control_info;
  uintptr_t clienttag = 0;


  /* set service availability with status code STE_UICC_STATUS_CODE_FAIL*/
  {
    PSCC_test_ste_sim_cb_t callback;
    ste_uicc_get_service_availability_response_t ste_uicc_get_service_availability_response;
    memset(&callback, 0, sizeof(callback));
    memset(&ste_uicc_get_service_availability_response, 0, sizeof(ste_uicc_get_service_availability_response));
    callback.cause = STE_UICC_CAUSE_REQ_GET_SERVICE_AVAILABILITY;
    callback.client_tag = clienttag;
    ste_uicc_get_service_availability_response.service_availability = STE_UICC_SERVICE_AVAILABLE;
    ste_uicc_get_service_availability_response.uicc_status_code = STE_UICC_STATUS_CODE_FAIL;
    memcpy(&callback.data, &ste_uicc_get_service_availability_response, sizeof(ste_uicc_get_service_availability_response_t));
    TESTNOTNEG(sendToSim(PSCCD_TEST_TEST_STUB, PSCC_STE_SIM_CB, &callback,
           sizeof(callback)));
  }

  TESTNOTNEG(waitAndRespondToSim_ste_sim_read(0,sim));

  /* send STE_UICC_CAUSE_SIM_STATE_CHANGED with state SIM_STATE_UNKNOWN*/
  {
    PSCC_test_ste_sim_cb_t callback;
    ste_uicc_sim_state_changed_t ste_uicc_state_changed_response;
    memset(&callback, 0, sizeof(callback));
    memset(&ste_uicc_state_changed_response, 0, sizeof(ste_uicc_state_changed_response));
    callback.cause = STE_UICC_CAUSE_SIM_STATE_CHANGED;
    callback.client_tag = clienttag;
    ste_uicc_state_changed_response.state = SIM_STATE_UNKNOWN;
    memcpy(&callback.data, &ste_uicc_state_changed_response, sizeof(ste_uicc_sim_state_changed_t));
    TESTNOTNEG(sendToSim(PSCCD_TEST_TEST_STUB, PSCC_STE_SIM_CB, &callback,
           sizeof(callback)));
  }

   TESTNOTNEG(waitAndRespondToSim_ste_sim_read(0,sim));

#if 1
  /* send STE_UICC_CAUSE_SIM_STATE_CHANGED with state EXE_SIM_STATE_UNKNOWN */
  {
    PSCC_test_ste_sim_cb_t callback;
    ste_uicc_sim_state_changed_t ste_uicc_state_changed_response;
    memset(&callback, 0, sizeof(callback));
    memset(&ste_uicc_state_changed_response, 0, sizeof(ste_uicc_state_changed_response));
    callback.cause = STE_UICC_CAUSE_SIM_STATE_CHANGED;
    callback.client_tag = clienttag;
    ste_uicc_state_changed_response.state = SIM_STATE_READY;
    memcpy(&callback.data, &ste_uicc_state_changed_response, sizeof(ste_uicc_sim_state_changed_t));
    TESTNOTNEG(sendToSim(PSCCD_TEST_TEST_STUB, PSCC_STE_SIM_CB, &callback,
           sizeof(callback)));
  }

  TESTNOTNEG(waitAndRespondToSim_ste_sim_read(0,sim));

  TESTNOTNEG(waitAndRespondToSim_ste_uicc_get_service_availability(-1, sim,  &clienttag, SIM_SERVICE_TYPE_CALL_CONTROL_ON_GPRS));


  /* send STE_CAT_CAUSE_SIM_EC_CALL_CONTROL with result STE_CAT_CC_NOT_ALLOWED_TEMP_PROBLEM */
  {
    PSCC_test_ste_sim_cb_t callback;
    ste_cat_call_control_response_t ste_cat_call_control_response;
    ste_cat_cc_pdp_t ste_cat_cc_pdp;
    memset(&callback, 0, sizeof(callback));
    memset(&ste_cat_call_control_response, 0, sizeof(ste_cat_call_control_response));
    callback.cause = STE_CAT_CAUSE_SIM_EC_CALL_CONTROL;
    callback.client_tag = 101;
    ste_cat_call_control_response.cc_result = STE_CAT_CC_NOT_ALLOWED_TEMP_PROBLEM;
    ste_cat_cc_pdp.pdp_context.str_p = (uint8_t*) pdpactmsg_mod;
    ste_cat_cc_pdp.pdp_context.no_of_bytes = strlen(pdpactmsg_mod);
    memcpy(&callback.user_data, &ste_cat_cc_pdp, sizeof(ste_cat_cc_pdp_t));
    memcpy(&callback.data, &ste_cat_call_control_response, sizeof(ste_cat_call_control_response_t));
    TESTNOTNEG(sendToSim(PSCCD_TEST_TEST_STUB, PSCC_STE_SIM_CB, &callback,
            sizeof(callback)));
  }
#endif
  TESTNOTNEG(waitAndRespondToSim_ste_sim_read(0,sim));



  /* set service availability with status code STE_UICC_STATUS_CODE_OK */
  {
    PSCC_test_ste_sim_cb_t callback;
    ste_uicc_get_service_availability_response_t ste_uicc_get_service_availability_response;
    memset(&callback, 0, sizeof(callback));
    memset(&ste_uicc_get_service_availability_response, 0, sizeof(ste_uicc_get_service_availability_response));
    callback.cause = STE_UICC_CAUSE_REQ_GET_SERVICE_AVAILABILITY;
    callback.client_tag = clienttag;
    ste_uicc_get_service_availability_response.service_availability = STE_UICC_SERVICE_AVAILABLE;
    ste_uicc_get_service_availability_response.uicc_status_code = STE_UICC_STATUS_CODE_OK;
    memcpy(&callback.data, &ste_uicc_get_service_availability_response, sizeof(ste_uicc_get_service_availability_response_t));
    TESTNOTNEG(sendToSim(PSCCD_TEST_TEST_STUB, PSCC_STE_SIM_CB, &callback,
           sizeof(callback)));
  }

  TESTNOTNEG(waitAndRespondToSim_ste_sim_read(0,sim));

  TESTNOTNEG(util_create(cid));

  /* perform connect */
  /* set parameters */
  pscc_msg_p = mpl_msg_alloc(PSCC_PARAM_SET_ID);
  pscc_msg_p->common.type = pscc_msgtype_req;
  pscc_msg_p->common.id = pscc_set;
  pscc_msg_p->common.param_list_p = NULL;
  mpl_add_param_to_list(&pscc_msg_p->common.param_list_p, pscc_paramid_connid,&cid);
  mpl_add_param_to_list(&pscc_msg_p->common.param_list_p, pscc_paramid_apn,(char*) apn);
  TESTNOTNEG(sendToStecomCtrl(pscc_msg_p));
  mpl_msg_free((mpl_msg_t*)pscc_msg_p);

  TESTNOTNEG(waitAndReadStecomResp(&resp));
  TESTBOOL(MPL_GET_PARAM_VALUE_FROM_LIST(int,pscc_paramid_connid,(resp.common.param_list_p)), cid);
  TESTBOOL(resp.resp.result, 0);
  mpl_param_list_destroy(&resp.common.param_list_p);

  /* connect */
  pscc_msg_p = mpl_msg_alloc(PSCC_PARAM_SET_ID);
  pscc_msg_p->common.type = pscc_msgtype_req;
  pscc_msg_p->common.id = pscc_connect;
  pscc_msg_p->common.param_list_p = NULL;
  mpl_add_param_to_list(&pscc_msg_p->common.param_list_p, pscc_paramid_connid,&cid);
  TESTNOTNEG(sendToStecomCtrl(pscc_msg_p));
  mpl_msg_free((mpl_msg_t*)pscc_msg_p);

  /* has to be in the same order that pscc calls mal */
  TESTNOTNEG(waitAndRespondToGPDSSet_APN(0, apn, cid));
  TESTNOTNEG(waitAndRespondToGPDSSet_DCMP(0, MAL_PDP_DCMP_OFF, cid));
  TESTNOTNEG(waitAndRespondToGPDSSet_HCMP(0, MAL_PDP_HCMP_OFF, cid));
  TESTNOTNEG(waitAndRespondToGPDSSet_PDPType(0, MAL_PDP_TYPE_IPV4, cid));
  TESTNOTNEG(waitAndRespondToGPDSSet_AuthMeth(0, MAL_AUTH_METHOD_NONE, cid));
  TESTNOTNEG(waitAndRespondToGPDSSet_QoSReq(0, qosreq, cid));
  TESTNOTNEG(waitAndRespondToGPDSSet_QoSRel5(0, qosrel5, cid));
  TESTNOTNEG(waitAndRespondToGPDSSet_QoSMin(0, qosmin, cid));
  TESTNOTNEG(waitAndRespondToGPDSSet_PDPContextType(0, MAL_PDP_CONTEXT_TYPE_PRIMARY, cid));

  TESTNOTNEG(waitAndRespondToGPDSReq_Request(0, cid, MAL_GPDS_REQ_PSCONN_ACTIVATE, 0, 0));

  TESTNOTNEG(waitAndReadStecomResp(&resp));
  TESTBOOL(MPL_GET_PARAM_VALUE_FROM_LIST(int,pscc_paramid_connid,(resp.common.param_list_p)), cid);
  TESTBOOL(resp.resp.result, 0);
  mpl_param_list_destroy(&resp.common.param_list_p);

  /* we are now connecting and need to send callback resource control */
  {
    PSCC_test_mal_gpds_cb_t callback;
    memset(&callback, 0, sizeof(callback));
    memset(&mal_gpds_resource_control_info, 0, sizeof(mal_gpds_resource_control_info));
    mal_gpds_resource_control_info.seq_id = 101;
    mal_gpds_resource_control_info.resource_control_data.data_length = strlen(pdpactmsg);
    callback.conn_id = cid;
    callback.event_id = MAL_GPDS_EVENT_ID_RESOURCE_CONTROL_REQUESTED;
    memcpy(&callback.data, &mal_gpds_resource_control_info, sizeof(mal_gpds_resource_control_info));
    memcpy(&callback.extradata, &pdpactmsg, strlen(pdpactmsg));
    TESTNOTNEG(sendToGPDS(PSCCD_TEST_TEST_STUB, PSCC_MAL_GPDS_CALLBACK, &callback,
            sizeof(callback)));
  }

  TESTNOTNEG(waitAndRespondToGPDSReq_ResponseHandler());

  TESTNOTNEG(waitAndRespondToSim_ste_cat_call_control(0, sim, 101, (char*) pdpactmsg, (uint32_t) strlen(pdpactmsg)));

  {
    PSCC_test_ste_sim_cb_t callback;
    ste_cat_call_control_response_t ste_cat_call_control_response;
    ste_cat_cc_pdp_t ste_cat_cc_pdp;
    memset(&callback, 0, sizeof(callback));
    memset(&ste_cat_call_control_response, 0, sizeof(ste_cat_call_control_response));
    callback.cause = STE_CAT_CAUSE_SIM_EC_CALL_CONTROL;
    callback.client_tag = 101;
    ste_cat_call_control_response.cc_result = STE_CAT_CC_ALLOWED_WITH_MODIFICATIONS;
    ste_cat_cc_pdp.pdp_context.str_p = (uint8_t*) pdpactmsg_mod;
    ste_cat_cc_pdp.pdp_context.no_of_bytes = strlen(pdpactmsg_mod);
    memcpy(&callback.user_data, &ste_cat_cc_pdp, sizeof(ste_cat_cc_pdp_t));
    memcpy(&callback.data, &ste_cat_call_control_response, sizeof(ste_cat_call_control_response_t));
    TESTNOTNEG(sendToSim(PSCCD_TEST_TEST_STUB, PSCC_STE_SIM_CB, &callback,
            sizeof(callback)));
  }

  TESTNOTNEG(waitAndRespondToSim_ste_sim_read(0,sim));

  {
    mal_gpds_resource_control_req_info_t mal_gpds_resource_control_req_info;
    memset(&mal_gpds_resource_control_req_info, 0, sizeof(mal_gpds_resource_control_req_info));
    mal_gpds_resource_control_req_info.seq_id = mal_gpds_resource_control_info.seq_id;
    mal_gpds_resource_control_req_info.cc_result = MAL_GPDS_RESOURCE_MODIFIED;
    mal_gpds_resource_control_req_info.resource_control_data.data = (uint8_t*) pdpactmsg_mod;
    mal_gpds_resource_control_req_info.resource_control_data.data_length = strlen(pdpactmsg_mod);
    TESTNOTNEG(waitAndRespondToGPDSReq_Request(0, 0, MAL_GPDS_REQ_RESOURCE_CONTROL, &mal_gpds_resource_control_req_info, sizeof(mal_gpds_resource_control_req_info_t)));
  }

  /* we are now connecting and need to send callback resource control */
  {
    PSCC_test_mal_gpds_cb_t callback;
    memset(&callback, 0, sizeof(callback));
    callback.conn_id = cid;
    callback.event_id = MAL_GPDS_EVENT_ID_RESOURCE_CONTROL_FAILED;
    TESTNOTNEG(sendToGPDS(PSCCD_TEST_TEST_STUB, PSCC_MAL_GPDS_CALLBACK, &callback,
            sizeof(callback)));
  }

  TESTNOTNEG(waitAndRespondToGPDSReq_ResponseHandler());

  /* gpds will send a activation failed event */
  {
    PSCC_test_mal_gpds_cb_t callback;
    memset(&callback, 0, sizeof(callback));
    callback.conn_id = cid;
    callback.event_id = MAL_GPDS_EVENT_ID_PDP_ACTIVATION_FAILED;
    TESTNOTNEG(sendToGPDS(PSCCD_TEST_TEST_STUB, PSCC_MAL_GPDS_CALLBACK, &callback,
            sizeof(callback)));
  }

  TESTNOTNEG(waitAndRespondToGPDSReq_ResponseHandler());

  TESTNOTNEG(waitAndReadStecomEvent(&resp));
  TESTBOOL(resp.common.type,pscc_msgtype_event);
  TESTBOOL(resp.common.id,pscc_event_disconnected);
  TESTBOOL(MPL_GET_PARAM_VALUE_FROM_LIST(int,pscc_paramid_connid,(resp.common.param_list_p)), cid);
  TESTBOOL(MPL_GET_PARAM_VALUE_FROM_LIST(int,pscc_paramid_reason,(resp.common.param_list_p)), pscc_reason_pdp_context_activation_failed);
  TESTBOOL(resp.resp.result, 0);
  mpl_param_list_destroy(&resp.common.param_list_p);

  TESTNOTNEG(util_destroy(cid));

  /* reset service availability */
  {
    PSCC_test_ste_sim_cb_t callback;
    ste_uicc_get_service_availability_response_t ste_uicc_get_service_availability_response;
    memset(&callback, 0, sizeof(callback));
    memset(&ste_uicc_get_service_availability_response, 0, sizeof(ste_uicc_get_service_availability_response));
    callback.cause = STE_UICC_CAUSE_REQ_GET_SERVICE_AVAILABILITY;
    callback.client_tag = clienttag;
    ste_uicc_get_service_availability_response.service_availability = STE_UICC_SERVICE_NOT_AVAILABLE;
    ste_uicc_get_service_availability_response.uicc_status_code = STE_UICC_STATUS_CODE_OK;
    memcpy(&callback.data, &ste_uicc_get_service_availability_response, sizeof(ste_uicc_get_service_availability_response_t));
    TESTNOTNEG(sendToSim(PSCCD_TEST_TEST_STUB, PSCC_STE_SIM_CB, &callback,
            sizeof(callback)));
  }
  TESTNOTNEG(waitAndRespondToSim_ste_sim_read(0,sim));

  return PSCCD_TEST_SUCCESS;

  error:
  return PSCCD_TEST_FAIL;
}
int main() {
  int client_tag = 1;
  int handle;
  char lan_device_p[] = "usb0";
  char wan_device_p[] = "rmnet0";
  char dns_server_p[] = "10.10.10.10";

  printf("\n");
  printf("#############\n");
  printf("Starting test\n");
  printf("#############\n");

  if (initStecom() < 0)
  {
    printf("Failed to start stecom\n");
    goto error;
  }
  TESTNOTNEG(sterc_init(NULL, &my_log_func));

  printf("Test 1 - create\n");
  {
    mpl_msg_t           *request_p  = NULL;
    mpl_msg_t resp;

    request_p = mpl_req_msg_alloc(STERC_PARAM_SET_ID);
    if (NULL == request_p) {
        printf("mpl_req_msg_alloc failed!\n");
        goto error;
    }

    request_p->req.id = sterc_create;
    TESTNOTNEG(mpl_add_param_to_list(&request_p->req.param_list_p, sterc_paramid_lan_device, lan_device_p));
    TESTNOTNEG(mpl_add_param_to_list(&request_p->req.param_list_p, sterc_paramid_wan_device, wan_device_p));
    TESTNOTNEG(mpl_add_param_to_list(&request_p->req.param_list_p, sterc_paramid_wan_dns, dns_server_p));
    TESTNOTNEG(mpl_add_param_to_list(&request_p->req.param_list_p, sterc_paramid_ct, &client_tag));
    TESTNOTNEG(sendToStecomCtrl(request_p));
    mpl_msg_free((mpl_msg_t *)request_p);

    TESTNOTNEG(waitAndReadStecomResp(&resp));
    TESTBOOL(resp.common.type, sterc_msgtype_resp);
    TESTBOOL(resp.common.id, sterc_create);
    TESTBOOL(MPL_GET_PARAM_VALUE_FROM_LIST(int,sterc_paramid_ct,(resp.common.param_list_p)), client_tag);
    handle = MPL_GET_PARAM_VALUE_FROM_LIST(int,sterc_paramid_handle,(resp.common.param_list_p));
    TESTBOOL(resp.resp.result, sterc_result_ok);
    mpl_param_list_destroy(&resp.common.param_list_p);

  }

  printf("Test 2 - set parameter req\n");
  {
    mpl_msg_t           *request_p  = NULL;
    mpl_msg_t resp;
    memcpy(lan_device_p, "usb1\0", 5);

    request_p = mpl_req_msg_alloc(STERC_PARAM_SET_ID);
    if (NULL == request_p) {
        printf("mpl_req_msg_alloc failed!\n");
        goto error;
    }

    request_p->req.id = sterc_set;
    TESTNOTNEG(mpl_add_param_to_list(&request_p->req.param_list_p, sterc_paramid_handle, &handle));
    TESTNOTNEG(mpl_add_param_to_list(&request_p->req.param_list_p, sterc_paramid_lan_device, lan_device_p));
    TESTNOTNEG(mpl_add_param_to_list(&request_p->req.param_list_p, sterc_paramid_ct, &client_tag));
    TESTNOTNEG(sendToStecomCtrl(request_p));
    mpl_msg_free((mpl_msg_t *)request_p);

    TESTNOTNEG(waitAndReadStecomResp(&resp));
    TESTBOOL(resp.common.type, sterc_msgtype_resp);
    TESTBOOL(resp.common.id, sterc_set);
    TESTBOOL(MPL_GET_PARAM_VALUE_FROM_LIST(int,sterc_paramid_ct,(resp.common.param_list_p)), client_tag);
    TESTBOOL(resp.resp.result, sterc_result_ok);
    mpl_param_list_destroy(&resp.common.param_list_p);
  }

  printf("Test 3 - get parameter req\n");
  {
    mpl_msg_t           *request_p  = NULL;
    mpl_msg_t resp;
    char* lan_device;
    mpl_param_element_t       *param_element_p  = NULL;

    request_p = mpl_req_msg_alloc(STERC_PARAM_SET_ID);
    if (NULL == request_p) {
        printf("mpl_req_msg_alloc failed!\n");
        goto error;
    }

    request_p->req.id = sterc_get;
    TESTNOTNEG(mpl_add_param_to_list(&request_p->req.param_list_p, sterc_paramid_handle, &handle));
    TESTNOTNEG(mpl_add_param_to_list(&request_p->req.param_list_p, sterc_paramid_lan_device, lan_device_p));
    TESTNOTNEG(mpl_add_param_to_list(&request_p->req.param_list_p, sterc_paramid_ct, &client_tag));
    TESTNOTNEG(sendToStecomCtrl(request_p));
    mpl_msg_free((mpl_msg_t *)request_p);

    TESTNOTNEG(waitAndReadStecomResp(&resp));
    TESTBOOL(resp.common.type, sterc_msgtype_resp);
    TESTBOOL(resp.common.id, sterc_get);
    TESTBOOL(MPL_GET_PARAM_VALUE_FROM_LIST(int,sterc_paramid_ct,(resp.common.param_list_p)), client_tag);

    param_element_p = mpl_param_list_find(sterc_paramid_lan_device, resp.common.param_list_p);
    if (param_element_p == NULL) {
      printf("Could not find lan device parameter in response\n");
      goto error;
    }
    lan_device = (char*) param_element_p->value_p;
    TESTBOOL(strncmp(lan_device, lan_device_p, 5),0);
    TESTBOOL(resp.resp.result, sterc_result_ok);
    mpl_param_list_destroy(&resp.common.param_list_p);
  }

  printf("Test 4 - destroy req\n");
  {
    mpl_msg_t           *request_p  = NULL;
    mpl_msg_t resp;

    request_p = mpl_req_msg_alloc(STERC_PARAM_SET_ID);
    if (NULL == request_p) {
        printf("mpl_req_msg_alloc failed!\n");
        goto error;
    }

    request_p->req.id = sterc_destroy;
    TESTNOTNEG(mpl_add_param_to_list(&request_p->req.param_list_p, sterc_paramid_handle, &handle));
    TESTNOTNEG(mpl_add_param_to_list(&request_p->req.param_list_p, sterc_paramid_ct, &client_tag));
    TESTNOTNEG(sendToStecomCtrl(request_p));
    mpl_msg_free((mpl_msg_t *)request_p);

    TESTNOTNEG(waitAndReadStecomResp(&resp));
    TESTBOOL(resp.common.type, sterc_msgtype_resp);
    TESTBOOL(resp.common.id, sterc_destroy);
    TESTBOOL(MPL_GET_PARAM_VALUE_FROM_LIST(int,sterc_paramid_ct,(resp.common.param_list_p)), client_tag);
    TESTBOOL(resp.resp.result, sterc_result_ok);
    mpl_param_list_destroy(&resp.common.param_list_p);

  }

  printf("Test 5 - create without wan_device\n");
  {
    mpl_msg_t           *request_p  = NULL;
    mpl_msg_t resp;

    request_p = mpl_req_msg_alloc(STERC_PARAM_SET_ID);
    if (NULL == request_p) {
        printf("mpl_req_msg_alloc failed!\n");
        goto error;
    }

    request_p->req.id = sterc_create;
    TESTNOTNEG(mpl_add_param_to_list(&request_p->req.param_list_p, sterc_paramid_lan_device, lan_device_p));
    TESTNOTNEG(mpl_add_param_to_list(&request_p->req.param_list_p, sterc_paramid_wan_dns, dns_server_p));
    TESTNOTNEG(mpl_add_param_to_list(&request_p->req.param_list_p, sterc_paramid_ct, &client_tag));
    TESTNOTNEG(sendToStecomCtrl(request_p));
    mpl_msg_free((mpl_msg_t *)request_p);

    TESTNOTNEG(waitAndReadStecomResp(&resp));
    TESTBOOL(resp.common.type, sterc_msgtype_resp);
    TESTBOOL(resp.common.id, sterc_create);
    TESTBOOL(resp.resp.result, sterc_result_failed_parameter_not_found);
    mpl_param_list_destroy(&resp.common.param_list_p);
  }

  closeStecom();

  printf("#######################\n");
  printf("Testing done, all pass!\n");
  printf("#######################\n\n");

  return 0;
error:

  printf("##############\n");
  printf("Testing failed\n");
  printf("##############\n\n");
  return -1;
}