Esempio n. 1
0
static mpl_list_t *handle_TestEchoTuple(mpl_bag_t *reqParams)
{
    mpl_list_t *respMsg = NULL;
    mpl_bag_t *respParams = NULL;
    int i;

    if (TESTP_TestEchoTuple_Req_stringtup_EXISTS(reqParams))
        TESTP_ADD_TestEchoTuple_Resp_stringtup(&respParams, TESTP_GET_TestEchoTuple_Req_stringtup_PTR(reqParams));
    for (i = 1; i <= TESTP_TestEchoTuple_Req_stringtup_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoTuple_Resp_stringtup_arr_TAG(&respParams, TESTP_GET_TestEchoTuple_Req_stringtup_arr_PTR_TAG(reqParams, i), i);
    if (TESTP_TestEchoTuple_Req_inttup_EXISTS(reqParams))
        TESTP_ADD_TestEchoTuple_Resp_inttup(&respParams, TESTP_GET_TestEchoTuple_Req_inttup_PTR(reqParams));
    for (i = 1; i <= TESTP_TestEchoTuple_Req_inttup_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoTuple_Resp_inttup_arr_TAG(&respParams, TESTP_GET_TestEchoTuple_Req_inttup_arr_PTR_TAG(reqParams, i), i);
    if (TESTP_TestEchoTuple_Req_strinttup_EXISTS(reqParams))
        TESTP_ADD_TestEchoTuple_Resp_strinttup(&respParams, TESTP_GET_TestEchoTuple_Req_strinttup_PTR(reqParams));
    for (i = 1; i <= TESTP_TestEchoTuple_Req_strinttup_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoTuple_Resp_strinttup_arr_TAG(&respParams, TESTP_GET_TestEchoTuple_Req_strinttup_arr_PTR_TAG(reqParams, i), i);
    if (TESTP_TestEchoTuple_Req_struint8tup_EXISTS(reqParams))
        TESTP_ADD_TestEchoTuple_Resp_struint8tup(&respParams, TESTP_GET_TestEchoTuple_Req_struint8tup_PTR(reqParams));
    for (i = 1; i <= TESTP_TestEchoTuple_Req_struint8tup_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoTuple_Resp_struint8tup_arr_TAG(&respParams, TESTP_GET_TestEchoTuple_Req_struint8tup_arr_PTR_TAG(reqParams, i), i);

    TESTP_ADD_BAG(&respMsg,TestEchoTuple_Resp,respParams);
    mpl_param_list_destroy(&respParams);
    return respMsg;
}
Esempio n. 2
0
static mpl_list_t *handle_TestEchoTuplePN(mpl_bag_t *reqParams)
{
    mpl_list_t *respMsg = NULL;
    mpl_bag_t *respParams = NULL;
    int i;

    if (TESTP_EXISTS(reqParams, StringTup))
        TESTP_ADD_STRING_TUPLE(&respParams, StringTup, TESTP_GET_STRING_TUPLE_PTR(reqParams, StringTup));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, StringTupArr); i++)
        TESTP_ADD_STRING_TUPLE_TAG(&respParams, StringTupArr, TESTP_GET_STRING_TUPLE_PTR_TAG(reqParams, StringTupArr, i), i);
    if (TESTP_EXISTS(reqParams, IntTup))
        TESTP_ADD_INT_TUPLE(&respParams, IntTup, TESTP_GET_INT_TUPLE_PTR(reqParams, IntTup));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, IntTupArr); i++)
        TESTP_ADD_INT_TUPLE_TAG(&respParams, IntTupArr, TESTP_GET_INT_TUPLE_PTR_TAG(reqParams, IntTupArr, i), i);
    if (TESTP_EXISTS(reqParams, StrintTup))
        TESTP_ADD_STRINT_TUPLE(&respParams, StrintTup, TESTP_GET_STRINT_TUPLE_PTR(reqParams, StrintTup));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, StrintTupArr); i++)
        TESTP_ADD_STRINT_TUPLE_TAG(&respParams, StrintTupArr, TESTP_GET_STRINT_TUPLE_PTR_TAG(reqParams, StrintTupArr, i), i);
    if (TESTP_EXISTS(reqParams, Struint8Tup))
        TESTP_ADD_STRUINT8_TUPLE(&respParams, Struint8Tup, TESTP_GET_STRUINT8_TUPLE_PTR(reqParams, Struint8Tup));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, Struint8TupArr); i++)
        TESTP_ADD_STRUINT8_TUPLE_TAG(&respParams, Struint8TupArr, TESTP_GET_STRUINT8_TUPLE_PTR_TAG(reqParams, Struint8TupArr, i), i);
    
    TESTP_ADD_BAG(&respMsg,TestEchoTuplePN_Resp,respParams);
    mpl_param_list_destroy(&respParams);
    return respMsg;
}
Esempio n. 3
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;
    }
}
Esempio n. 4
0
static int readlines(void) {
    char *line;
    mpl_list_t *reqMsg = NULL;
    int quit = 0;
    mpl_list_t *tmp;

    completionStrings = calloc(maxStrings, sizeof(char *));

    while((line = linenoise("PERS> ")) != NULL) {
        if (line[0] != '\0') {
            if (strcmp(line,"quit") && strncmp(line, "help ", 5)) {
                char *req;
                int ret = -1;
                req = formatCmdLine(line, "Req");
                reqMsg = mpl_param_list_unpack_param_set(req, PERSONNEL_PARAM_SET_ID);
                if (!reqMsg) {
                    printf("Protocol error\n");
                    ret = -1;
                }
                else if (checkCommand(reqMsg) == 0) {
                    ret = pack_and_send(reqMsg);
                }
                mpl_param_list_destroy(&reqMsg);
                free(req);
                if (ret == 0) {
                    fgets(buf, 1024, fi);
                    printf("%s\n", buf);
                }
            }
            else if (!strncmp(line, "help ", 5)) {
                char *helptext;
                persfile_get_command_help(line, &helptext);
                if (helptext != NULL) {
                    printf("%s", helptext);
                    free(helptext);
                }
                else
                    printf("No help\n");
            }
            else {
                quit = 1;
            }
            linenoiseHistoryAdd(line);
            linenoiseHistorySave("history.txt"); /* Save every new entry */
            free(line);
            while ((tmp = mpl_list_remove(&completionCallstack, NULL)) != NULL) {
                completion_callstack_entry_t *e;
                e = MPL_LIST_CONTAINER(tmp, completion_callstack_entry_t, list_entry);
                free(e);
            }
        }
        if (quit)
            break;
    }
    free(completionStrings);
    return 0;
}
/**
 * pscc_obj_delete - delete ps connection control object
 **/
int pscc_obj_delete(int connid)
{
  pscc_object_t* cur;
  cur = pscc_obj_get(connid);
  if (cur==NULL)
  {
    PSCC_DBG_TRACE(LOG_ERR, "Failed finding object for connid=%d\n", connid);    
    return (-1);
  }
  
  mpl_list_remove(&objects_list,&cur->list_entry);
  mpl_param_list_destroy(&cur->param_list_p);
  free(cur);
  return (0);
}
Esempio n. 6
0
static mpl_list_t *handle_TestEchoAddr(mpl_bag_t *reqParams)
{
    mpl_list_t *respMsg = NULL;
    mpl_bag_t *respParams = NULL;
    int i;

    if (TESTP_TestEchoAddr_Req_a_EXISTS(reqParams))
        TESTP_ADD_TestEchoAddr_Resp_a(&respParams, TESTP_GET_TestEchoAddr_Req_a(reqParams));
    for (i = 1; i <= TESTP_TestEchoAddr_Req_a_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoAddr_Resp_a_arr_TAG(&respParams, TESTP_GET_TestEchoAddr_Req_a_arr_TAG(reqParams, i), i);

    TESTP_ADD_BAG(&respMsg,TestEchoAddr_Resp,respParams);
    mpl_param_list_destroy(&respParams);
    return respMsg;
}
Esempio n. 7
0
static mpl_list_t *handle_TestEchoBagPN(mpl_bag_t *reqParams)
{
    mpl_list_t *respMsg = NULL;
    mpl_bag_t *respParams = NULL;
    int i;

    if (TESTP_EXISTS(reqParams, Bag))
        TESTP_ADD_BAG(&respParams, Bag, TESTP_GET_BAG_PTR(reqParams, Bag));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, BagArr); i++)
        TESTP_ADD_BAG_TAG(&respParams, BagArr, TESTP_GET_BAG_PTR_TAG(reqParams, BagArr, i), i);
    
    TESTP_ADD_BAG(&respMsg,TestEchoBagPN_Resp,respParams);
    mpl_param_list_destroy(&respParams);
    return respMsg;
}
Esempio n. 8
0
static mpl_list_t *handle_TestEchoIntPN(mpl_bag_t *reqParams)
{
    mpl_list_t *respMsg = NULL;
    mpl_bag_t *respParams = NULL;
    int i;

    if (TESTP_EXISTS(reqParams, Int))
        TESTP_ADD_INT(&respParams, Int, TESTP_GET_INT(reqParams, Int));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, IntArr); i++)
        TESTP_ADD_INT_TAG(&respParams, IntArr, TESTP_GET_INT_TAG(reqParams, IntArr, i), i);
    if (TESTP_EXISTS(reqParams, Sint8))
        TESTP_ADD_SINT8(&respParams, Sint8, TESTP_GET_SINT8(reqParams, Sint8));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, Sint8Arr); i++)
        TESTP_ADD_SINT8_TAG(&respParams, Sint8Arr, TESTP_GET_SINT8_TAG(reqParams, Sint8Arr, i), i);
    if (TESTP_EXISTS(reqParams, Sint16))
        TESTP_ADD_SINT16(&respParams, Sint16, TESTP_GET_SINT16(reqParams, Sint16));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, Sint16Arr); i++)
        TESTP_ADD_SINT16_TAG(&respParams, Sint16Arr, TESTP_GET_SINT16_TAG(reqParams, Sint16Arr, i), i);
    if (TESTP_EXISTS(reqParams, Sint32))
        TESTP_ADD_SINT32(&respParams, Sint32, TESTP_GET_SINT32(reqParams, Sint32));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, Sint32Arr); i++)
        TESTP_ADD_SINT32_TAG(&respParams, Sint32Arr, TESTP_GET_SINT32_TAG(reqParams, Sint32Arr, i), i);
    if (TESTP_EXISTS(reqParams, Sint64))
        TESTP_ADD_SINT64(&respParams, Sint64, TESTP_GET_SINT64(reqParams, Sint64));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, Sint64Arr); i++)
        TESTP_ADD_SINT64_TAG(&respParams, Sint64Arr, TESTP_GET_SINT64_TAG(reqParams, Sint64Arr, i), i);
    if (TESTP_EXISTS(reqParams, Uint8))
        TESTP_ADD_UINT8(&respParams, Uint8, TESTP_GET_UINT8(reqParams, Uint8));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, Uint8Arr); i++)
        TESTP_ADD_UINT8_TAG(&respParams, Uint8Arr, TESTP_GET_UINT8_TAG(reqParams, Uint8Arr, i), i);
    if (TESTP_EXISTS(reqParams, Uint16))
        TESTP_ADD_UINT16(&respParams, Uint16, TESTP_GET_UINT16(reqParams, Uint16));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, Uint16Arr); i++)
        TESTP_ADD_UINT16_TAG(&respParams, Uint16Arr, TESTP_GET_UINT16_TAG(reqParams, Uint16Arr, i), i);
    if (TESTP_EXISTS(reqParams, Uint32))
        TESTP_ADD_UINT32(&respParams, Uint32, TESTP_GET_UINT32(reqParams, Uint32));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, Uint32Arr); i++)
        TESTP_ADD_UINT32_TAG(&respParams, Uint32Arr, TESTP_GET_UINT32_TAG(reqParams, Uint32Arr, i), i);
    if (TESTP_EXISTS(reqParams, Uint64))
        TESTP_ADD_UINT64(&respParams, Uint64, TESTP_GET_UINT64(reqParams, Uint64));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, Uint64Arr); i++)
        TESTP_ADD_UINT64_TAG(&respParams, Uint64Arr, TESTP_GET_UINT64_TAG(reqParams, Uint64Arr, i), i);
    
    TESTP_ADD_BAG(&respMsg,TestEchoIntPN_Resp,respParams);
    mpl_param_list_destroy(&respParams);
    return respMsg;
}
Esempio n. 9
0
static mpl_list_t *handle_TestEchoInt(mpl_bag_t *reqParams)
{
    mpl_list_t *respMsg = NULL;
    mpl_bag_t *respParams = NULL;
    int i;

    if (TESTP_TestEchoInt_Req_i_EXISTS(reqParams))
        TESTP_ADD_TestEchoInt_Resp_i(&respParams, TESTP_GET_TestEchoInt_Req_i(reqParams));
    for (i = 1; i <= TESTP_TestEchoInt_Req_i_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoInt_Resp_i_arr_TAG(&respParams, TESTP_GET_TestEchoInt_Req_i_arr_TAG(reqParams, i), i);
    if (TESTP_TestEchoInt_Req_s8_EXISTS(reqParams))
        TESTP_ADD_TestEchoInt_Resp_s8(&respParams, TESTP_GET_TestEchoInt_Req_s8(reqParams));
    for (i = 1; i <= TESTP_TestEchoInt_Req_s8_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoInt_Resp_s8_arr_TAG(&respParams, TESTP_GET_TestEchoInt_Req_s8_arr_TAG(reqParams, i), i);
    if (TESTP_TestEchoInt_Req_s16_EXISTS(reqParams))
        TESTP_ADD_TestEchoInt_Resp_s16(&respParams, TESTP_GET_TestEchoInt_Req_s16(reqParams));
    for (i = 1; i <= TESTP_TestEchoInt_Req_s16_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoInt_Resp_s16_arr_TAG(&respParams, TESTP_GET_TestEchoInt_Req_s16_arr_TAG(reqParams, i), i);
    if (TESTP_TestEchoInt_Req_s32_EXISTS(reqParams))
        TESTP_ADD_TestEchoInt_Resp_s32(&respParams, TESTP_GET_TestEchoInt_Req_s32(reqParams));
    for (i = 1; i <= TESTP_TestEchoInt_Req_s32_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoInt_Resp_s32_arr_TAG(&respParams, TESTP_GET_TestEchoInt_Req_s32_arr_TAG(reqParams, i), i);
    if (TESTP_TestEchoInt_Req_s64_EXISTS(reqParams))
        TESTP_ADD_TestEchoInt_Resp_s64(&respParams, TESTP_GET_TestEchoInt_Req_s64(reqParams));
    for (i = 1; i <= TESTP_TestEchoInt_Req_s64_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoInt_Resp_s64_arr_TAG(&respParams, TESTP_GET_TestEchoInt_Req_s64_arr_TAG(reqParams, i), i);
    if (TESTP_TestEchoInt_Req_u8_EXISTS(reqParams))
        TESTP_ADD_TestEchoInt_Resp_u8(&respParams, TESTP_GET_TestEchoInt_Req_u8(reqParams));
    for (i = 1; i <= TESTP_TestEchoInt_Req_u8_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoInt_Resp_u8_arr_TAG(&respParams, TESTP_GET_TestEchoInt_Req_u8_arr_TAG(reqParams, i), i);
    if (TESTP_TestEchoInt_Req_u16_EXISTS(reqParams))
        TESTP_ADD_TestEchoInt_Resp_u16(&respParams, TESTP_GET_TestEchoInt_Req_u16(reqParams));
    for (i = 1; i <= TESTP_TestEchoInt_Req_u16_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoInt_Resp_u16_arr_TAG(&respParams, TESTP_GET_TestEchoInt_Req_u16_arr_TAG(reqParams, i), i);
    if (TESTP_TestEchoInt_Req_u32_EXISTS(reqParams))
        TESTP_ADD_TestEchoInt_Resp_u32(&respParams, TESTP_GET_TestEchoInt_Req_u32(reqParams));
    for (i = 1; i <= TESTP_TestEchoInt_Req_u32_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoInt_Resp_u32_arr_TAG(&respParams, TESTP_GET_TestEchoInt_Req_u32_arr_TAG(reqParams, i), i);
    if (TESTP_TestEchoInt_Req_u64_EXISTS(reqParams))
        TESTP_ADD_TestEchoInt_Resp_u64(&respParams, TESTP_GET_TestEchoInt_Req_u64(reqParams));
    for (i = 1; i <= TESTP_TestEchoInt_Req_u64_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoInt_Resp_u64_arr_TAG(&respParams, TESTP_GET_TestEchoInt_Req_u64_arr_TAG(reqParams, i), i);

    TESTP_ADD_BAG(&respMsg,TestEchoInt_Resp,respParams);
    mpl_param_list_destroy(&respParams);
    return respMsg;
}
Esempio n. 10
0
static mpl_list_t *handle_TestEchoBoolPN(mpl_bag_t *reqParams)
{
    mpl_list_t *respMsg = NULL;
    mpl_bag_t *respParams = NULL;
    int i;

    if (TESTP_EXISTS(reqParams, MyBool))
        TESTP_ADD_BOOL(&respParams, MyBool, TESTP_GET_BOOL(reqParams, MyBool));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, BoolArr); i++)
        TESTP_ADD_BOOL_TAG(&respParams, BoolArr, TESTP_GET_BOOL_TAG(reqParams, BoolArr, i), i);
    if (TESTP_EXISTS(reqParams, Bool8))
        TESTP_ADD_BOOL8(&respParams, Bool8, TESTP_GET_BOOL8(reqParams, Bool8));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, Bool8Arr); i++)
        TESTP_ADD_BOOL8_TAG(&respParams, Bool8Arr, TESTP_GET_BOOL8_TAG(reqParams, Bool8Arr, i), i);
    
    TESTP_ADD_BAG(&respMsg,TestEchoBoolPN_Resp,respParams);
    mpl_param_list_destroy(&respParams);
    return respMsg;
}
Esempio n. 11
0
static mpl_list_t *handle_TestEchoEnum(mpl_bag_t *reqParams)
{
    mpl_list_t *respMsg = NULL;
    mpl_bag_t *respParams = NULL;
    int i;

    if (TESTP_TestEchoEnum_Req_se_EXISTS(reqParams))
        TESTP_ADD_TestEchoEnum_Resp_se(&respParams, TESTP_GET_TestEchoEnum_Req_se(reqParams));
    for (i = 1; i <= TESTP_TestEchoEnum_Req_se_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoEnum_Resp_se_arr_TAG(&respParams, TESTP_GET_TestEchoEnum_Req_se_arr_TAG(reqParams, i), i);
    if (TESTP_TestEchoEnum_Req_se8_EXISTS(reqParams))
        TESTP_ADD_TestEchoEnum_Resp_se8(&respParams, TESTP_GET_TestEchoEnum_Req_se8(reqParams));
    for (i = 1; i <= TESTP_TestEchoEnum_Req_se8_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoEnum_Resp_se8_arr_TAG(&respParams, TESTP_GET_TestEchoEnum_Req_se8_arr_TAG(reqParams, i), i);
    if (TESTP_TestEchoEnum_Req_se16_EXISTS(reqParams))
        TESTP_ADD_TestEchoEnum_Resp_se16(&respParams, TESTP_GET_TestEchoEnum_Req_se16(reqParams));
    for (i = 1; i <= TESTP_TestEchoEnum_Req_se16_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoEnum_Resp_se16_arr_TAG(&respParams, TESTP_GET_TestEchoEnum_Req_se16_arr_TAG(reqParams, i), i);
    if (TESTP_TestEchoEnum_Req_se32_EXISTS(reqParams))
        TESTP_ADD_TestEchoEnum_Resp_se32(&respParams, TESTP_GET_TestEchoEnum_Req_se32(reqParams));
    for (i = 1; i <= TESTP_TestEchoEnum_Req_se32_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoEnum_Resp_se32_arr_TAG(&respParams, TESTP_GET_TestEchoEnum_Req_se32_arr_TAG(reqParams, i), i);
    if (TESTP_TestEchoEnum_Req_ue8_EXISTS(reqParams))
        TESTP_ADD_TestEchoEnum_Resp_ue8(&respParams, TESTP_GET_TestEchoEnum_Req_ue8(reqParams));
    for (i = 1; i <= TESTP_TestEchoEnum_Req_ue8_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoEnum_Resp_ue8_arr_TAG(&respParams, TESTP_GET_TestEchoEnum_Req_ue8_arr_TAG(reqParams, i), i);
    if (TESTP_TestEchoEnum_Req_ue16_EXISTS(reqParams))
        TESTP_ADD_TestEchoEnum_Resp_ue16(&respParams, TESTP_GET_TestEchoEnum_Req_ue16(reqParams));
    for (i = 1; i <= TESTP_TestEchoEnum_Req_ue16_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoEnum_Resp_ue16_arr_TAG(&respParams, TESTP_GET_TestEchoEnum_Req_ue16_arr_TAG(reqParams, i), i);
    if (TESTP_TestEchoEnum_Req_ue32_EXISTS(reqParams))
        TESTP_ADD_TestEchoEnum_Resp_ue32(&respParams, TESTP_GET_TestEchoEnum_Req_ue32(reqParams));
    for (i = 1; i <= TESTP_TestEchoEnum_Req_ue32_arr_FIELD_COUNT(reqParams); i++)
        TESTP_ADD_TestEchoEnum_Resp_ue32_arr_TAG(&respParams, TESTP_GET_TestEchoEnum_Req_ue32_arr_TAG(reqParams, i), i);

    TESTP_ADD_BAG(&respMsg,TestEchoEnum_Resp,respParams);
    mpl_param_list_destroy(&respParams);
    return respMsg;
}
Esempio n. 12
0
static mpl_list_t *handle_TestEchoEnumPN(mpl_bag_t *reqParams)
{
    mpl_list_t *respMsg = NULL;
    mpl_bag_t *respParams = NULL;
    int i;

    if (TESTP_EXISTS(reqParams, Se))
        TESTP_ADD_ENUM_FROM_VAR(&respParams, Se, TESTP_GET_ENUM(reqParams, Se));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, SeArr); i++)
        TESTP_ADD_ENUM_FROM_VAR_TAG(&respParams, SeArr, TESTP_GET_ENUM_TAG(reqParams, SeArr, i), i);
    if (TESTP_EXISTS(reqParams, Se8))
        TESTP_ADD_SIGNED_ENUM8_FROM_VAR(&respParams, Se8, TESTP_GET_SIGNED_ENUM8(reqParams, Se8));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, Se8Arr); i++)
        TESTP_ADD_SIGNED_ENUM8_FROM_VAR_TAG(&respParams, Se8Arr, TESTP_GET_SIGNED_ENUM8_TAG(reqParams, Se8Arr, i), i);
    if (TESTP_EXISTS(reqParams, Se16))
        TESTP_ADD_SIGNED_ENUM16_FROM_VAR(&respParams, Se16, TESTP_GET_SIGNED_ENUM16(reqParams, Se16));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, Se16Arr); i++)
        TESTP_ADD_SIGNED_ENUM16_FROM_VAR_TAG(&respParams, Se16Arr, TESTP_GET_SIGNED_ENUM16_TAG(reqParams, Se16Arr, i), i);
    if (TESTP_EXISTS(reqParams, Se32))
        TESTP_ADD_SIGNED_ENUM32_FROM_VAR(&respParams, Se32, TESTP_GET_SIGNED_ENUM32(reqParams, Se32));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, Se32Arr); i++)
        TESTP_ADD_SIGNED_ENUM32_FROM_VAR_TAG(&respParams, Se32Arr, TESTP_GET_SIGNED_ENUM32_TAG(reqParams, Se32Arr, i), i);
    if (TESTP_EXISTS(reqParams, Ue8))
        TESTP_ADD_ENUM8_FROM_VAR(&respParams, Ue8, TESTP_GET_ENUM8(reqParams, Ue8));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, Ue8Arr); i++)
        TESTP_ADD_ENUM8_FROM_VAR_TAG(&respParams, Ue8Arr, TESTP_GET_ENUM8_TAG(reqParams, Ue8Arr, i), i);
    if (TESTP_EXISTS(reqParams, Ue16))
        TESTP_ADD_ENUM16_FROM_VAR(&respParams, Ue16, TESTP_GET_ENUM16(reqParams, Ue16));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, Ue16Arr); i++)
        TESTP_ADD_ENUM16_FROM_VAR_TAG(&respParams, Ue16Arr, TESTP_GET_ENUM16_TAG(reqParams, Ue16Arr, i), i);
    if (TESTP_EXISTS(reqParams, Ue32))
        TESTP_ADD_ENUM32_FROM_VAR(&respParams, Ue32, TESTP_GET_ENUM32(reqParams, Ue32));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, Ue32Arr); i++)
        TESTP_ADD_ENUM32_FROM_VAR_TAG(&respParams, Ue32Arr, TESTP_GET_ENUM32_TAG(reqParams, Ue32Arr, i), i);

    TESTP_ADD_BAG(&respMsg,TestEchoEnumPN_Resp,respParams);
    mpl_param_list_destroy(&respParams);
    return respMsg;
}
Esempio n. 13
0
static int checkCommand(mpl_list_t *cmdMsg)
{
    char *buf = NULL;
    int len;
    mpl_param_element_t *elem_p;
    mpl_list_t *check_result_list_p = NULL;
    mpl_pack_options_t options = MPL_PACK_OPTIONS_DEFAULT;
    const char *prompt = "Protocol error: ";
    options.force_field_pack_mode = true;

    elem_p = mpl_param_list_find(PERS_PARAM_ID(Req), cmdMsg);
    if (elem_p == NULL) {
        printf("%sno command\n", prompt);
        return -1;
    }
    if (personnel_checkBag_Req(elem_p, &check_result_list_p)) {
        len = mpl_param_list_pack_extended(check_result_list_p,
                                           NULL,
                                           0,
                                           &options);
        buf = calloc(1, len + 1);
        strcat(buf, prompt);
        if (buf != NULL) {
            (void)mpl_param_list_pack_extended(check_result_list_p,
                                               buf,
                                               len+1,
                                               &options);
            printf("%s%s\n", prompt, buf);
            free(buf);
        }
        else {
            printf("%smemory error\n", prompt);
        }
        mpl_param_list_destroy(&check_result_list_p);
        return -1;
    }
    return 0;
}
Esempio n. 14
0
static mpl_list_t *handle_TestEchoArrayPN(mpl_bag_t *reqParams)
{
    mpl_list_t *respMsg = NULL;
    mpl_bag_t *respParams = NULL;
    int i;

    if (TESTP_EXISTS(reqParams, U8a))
        TESTP_ADD_UINT8_ARRAY(&respParams, U8a, TESTP_GET_UINT8_ARRAY_PTR(reqParams, U8a));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, U8aArr); i++)
        TESTP_ADD_UINT8_ARRAY_TAG(&respParams, U8aArr, TESTP_GET_UINT8_ARRAY_PTR_TAG(reqParams, U8aArr, i), i);
    if (TESTP_EXISTS(reqParams, U16a))
        TESTP_ADD_UINT16_ARRAY(&respParams, U16a, TESTP_GET_UINT16_ARRAY_PTR(reqParams, U16a));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, U16aArr); i++)
        TESTP_ADD_UINT16_ARRAY_TAG(&respParams, U16aArr, TESTP_GET_UINT16_ARRAY_PTR_TAG(reqParams, U16aArr, i), i);
    if (TESTP_EXISTS(reqParams, U32a))
        TESTP_ADD_UINT32_ARRAY(&respParams, U32a, TESTP_GET_UINT32_ARRAY_PTR(reqParams, U32a));
    for (i = 1; i <= TESTP_PARAM_COUNT(reqParams, U32aArr); i++)
        TESTP_ADD_UINT32_ARRAY_TAG(&respParams, U32aArr, TESTP_GET_UINT32_ARRAY_PTR_TAG(reqParams, U32aArr, i), i);
    
    TESTP_ADD_BAG(&respMsg,TestEchoArrayPN_Resp,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;
}
Esempio n. 17
0
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;
}