⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 osptrans.c

📁 mgcp协议源代码。支持多种编码:g711
💻 C
📖 第 1 页 / 共 5 页
字号:
            }        }        else        {            errorcode = OSPC_ERR_TRAN_INVALID_ENTRY;            OSPM_DBGERRORLOG(errorcode, "Usage type not found.");        }    }    else    {        errorcode = OSPC_ERR_TRAN_MALLOC_FAILED;        OSPM_DBGERRORLOG(errorcode, "Malloc failed for usage");    }    /* set timestamp */    if(errorcode == OSPC_ERR_NO_ERROR)    {        OSPPUsageIndSetTimestamp(*ospvUsage,time(OSPC_OSNULL));        /* Get Transaction ID */        if(ospvTrans->HasTransactionID != OSPC_FALSE)        {            OSPPUsageIndSetTransactionId(*ospvUsage,                ospvTrans->TransactionID);                        /* Set ComponentID */            errorcode = OSPPUtilBuildString(ospvTrans->TransactionID,                                             OSPPTransactionGetCounter(ospvTrans),                                            (char **)&((*ospvUsage)->ospmUsageIndComponentId));            /* Update the componentId Unique counter */            OSPPTransactionUpdateCounter(ospvTrans);            /* Set MessageId */            if(errorcode == OSPC_ERR_NO_ERROR)            {                errorcode = OSPPUtilBuildString(ospvTrans->TransactionID,                                             OSPPTransactionGetCounter(ospvTrans),                                            (char **)&((*ospvUsage)->ospmUsageIndMessageId));            }            /* Update the ComponentId Unique counter again to              * keep the MessageId and ComponentId values unique              */            OSPPTransactionUpdateCounter(ospvTrans);        }        else        {            errorcode = OSPC_ERR_TRAN_TXID_NOT_FOUND;            OSPM_DBGERRORLOG(errorcode, "Transaction id not found");        }    }    /* TransNexus extensions */    if (errorcode == OSPC_ERR_NO_ERROR)    {        /* set Customer Id */        OSPPUsageIndSetTNCustId(*ospvUsage, OSPPProviderGetTNCustId(ospvTrans->Provider));        /* set Device Id */        OSPPUsageIndSetTNDeviceId(*ospvUsage, OSPPProviderGetTNDeviceId(ospvTrans->Provider));        /* set Fail Reason */        OSPPUsageIndSetTNFailReason(*ospvUsage, OSPPDestGetTNFailReason(ospvTrans->CurrentDest));    }    else    {        /* Some error occurred. Get rid of this usage */        if(ospvUsage != OSPC_OSNULL)        {            OSPPUsageIndDelete(ospvUsage);        }    }    return errorcode;}/* * get pointer to transaction indicated by index. * * returns OSPTTRANS pointer or OSPC_OSNULL if unsuccessful. */OSPTTRANS *    OSPPTransactionCollectionGetItem(    OSPTTRANCOLLECTION  *ospvTranColl, /* In - Transaction Collection pointer */    OSPTCOLLECTIONINDEX tranindex)     /* In - Index of needed item */{    OSPTTRANS   *tmptrans = OSPC_OSNULL;    if (ospvTranColl->Trans[tranindex.Index] != (OSPTTRANS *)OSPC_OSNULL)        tmptrans = ospvTranColl->Trans[tranindex.Index];    return tmptrans;}/* * gets handle for new transaction. * * returns valid OSPTTRANHANDLE if successful,  *     OSPC_TRAN_HANDLE_INVALID (-1) otherwise  */OSPTTRANHANDLE    OSPPTransactionCollectionGetNewItem(    OSPTPROVHANDLE      ospvProvider,  /* In - Provider handle */    OSPTTRANCOLLECTION  *ospvTranColl, /* In - Transaction collection pointer */    int                 *ospvError)    /* In - Error object pointer */{    int             count         = 0;    OSPTTRANHANDLE  tmptranhandle = OSPC_TRAN_HANDLE_INVALID;     /*     * go through transaction collection til we find one that is set to      * OSPC_OSNULL     */    for (count = 0; count < OSPC_MAX_TRANS; count++)     {        if (ospvTranColl->Trans[count] == (OSPTTRANS *)OSPC_OSNULL)            break;    }    /* we looked at all of them and there is no empty slot */    if (count == OSPC_MAX_TRANS)     {        *ospvError = OSPC_ERR_TRAN_NO_TRANS_SPACE;        OSPM_DBGERRORLOG(*ospvError, "no empty slot for new transaction.");    }    else     {        OSPM_MALLOC(ospvTranColl->Trans[count], OSPTTRANS, sizeof(OSPTTRANS));        if (ospvTranColl->Trans[count] != (OSPTTRANS *)OSPC_OSNULL)         {            OSPM_MEMSET(ospvTranColl->Trans[count], 0, sizeof(OSPTTRANS));            /* Set up transaction handle */            tmptranhandle = (count | (ospvProvider << OSPC_PROV_SHIFT));        }        else         {            /* Set to generic malloc failure with this module identifier */            *ospvError = OSPC_ERR_TRAN_MALLOC_FAILED;            OSPM_DBGERRORLOG(*ospvError, "malloc new transaction failed.");        }    }    return tmptranhandle;}/* * set indicated transaction pointer to OSPC_OSNULL. * * returns void. */voidOSPPTransactionCollectionRemoveItem(    OSPTTRANCOLLECTION  *ospvTranColl,  /* In - Transaction collection ptr  */    OSPTCOLLECTIONINDEX ospvTranIndex)  /* In - Index of item to be removed */{    ospvTranColl->Trans[ospvTranIndex.Index] = OSPC_OSNULL;    ospvTranColl->NumberOfTrans--;    return;}/* delete authcnf structure and all associated structures and pointers. * * returns void */voidOSPPTransactionDeleteAuthCnf(    OSPTTRANS       *ospvTrans) /* In - Pointer to transaction */{    OSPPAuthCnfDelete(&(ospvTrans)->AuthCnf);    ospvTrans->AuthCnf = (OSPTAUTHCNF *)OSPC_OSNULL;     return;}/* delete authind structure and all associated structures and pointers. * * returns void */voidOSPPTransactionDeleteAuthInd(    OSPTTRANS       *ospvTrans) /* In - Pointer to transaction */{    OSPPAuthIndDelete(&(ospvTrans)->AuthInd);    ospvTrans->AuthInd = (OSPTAUTHIND *)OSPC_OSNULL;     return;}/* delete reauthrequest structure and all associated structures and pointers. * * returns void */voidOSPPTransactionDeleteReauthReq(    OSPTTRANS       *ospvTrans) /* In - Pointer to transaction */{    OSPPReauthReqDelete(&(ospvTrans)->ReauthReq);    ospvTrans->ReauthReq = (OSPTREAUTHREQ *)OSPC_OSNULL;     return;}/* delete reauthresponse structure and all associated structures and pointers. * * returns void */voidOSPPTransactionDeleteReauthRsp(    OSPTTRANS       *ospvTrans) /* In - Pointer to transaction */{    OSPPReauthRspDelete(&(ospvTrans)->ReauthRsp);    ospvTrans->ReauthRsp = (OSPTREAUTHRSP *)OSPC_OSNULL;     return;}/* delete request structure and all associated structures and pointers. * * returns void */voidOSPPTransactionDeleteRequest(    OSPTTRANS       *ospvTrans) /* In - Pointer to transaction */{    OSPPAuthReqDelete(&(ospvTrans)->AuthReq);    ospvTrans->AuthReq = (OSPTAUTHREQ *)OSPC_OSNULL;     return;}/*  * delete response structure and all associated structures and pointers. * * returns void. */voidOSPPTransactionDeleteResponse(    OSPTTRANS   *ospvTrans) /* In - Pointer to transaction */{    OSPPAuthRspDelete(&(ospvTrans)->AuthRsp);    ospvTrans->AuthRsp = OSPC_OSNULL;    return;}/*  * delete statistics structure and all associated structures and pointers. * * returns void. */voidOSPPTransactionDeleteStatistics(    OSPTTRANS   *ospvTrans) /* In - Pointer to transaction */{    OSPPStatisticsDelete(&(ospvTrans)->TNStatistics);    ospvTrans->TNStatistics = OSPC_OSNULL;    return;}/* delete usagecnf structure and all associated structures and pointers. * * returns void */voidOSPPTransactionDeleteUsageCnf(    OSPTTRANS       *ospvTrans) /* In - Pointer to transaction */{    OSPPUsageCnfDelete(&(ospvTrans)->UsageCnf);    ospvTrans->UsageCnf = (OSPTUSAGECNF *)OSPC_OSNULL;     return;}/* delete usageind structure and all associated structures and pointers. * * returns void */voidOSPPTransactionDeleteUsageInd(    OSPTTRANS       *ospvTrans) /* In - Pointer to transaction */{    OSPTUSAGEIND    *usage = OSPC_OSNULL;    if((ospvTrans != OSPC_OSNULL) &&        (ospvTrans->UsageInd != OSPC_OSNULL))    {        while(!OSPPListEmpty(&((ospvTrans)->UsageInd)))        {            usage = (OSPTUSAGEIND *)OSPPListRemove(&((ospvTrans)->UsageInd));            if(usage != OSPC_OSNULL)            {                OSPPUsageIndDelete(&(usage));            }        }          OSPPListDelete(&((ospvTrans)->UsageInd));    }    return;}/*  Make sure accumulation is allowed in this state */void         OSPPTransactionGetAccumAllowed(    OSPTTRANS *ospvTrans,    OSPTBOOL  *ospvAccumAllowed){    switch(ospvTrans->State)    {        case    OSPC_TRANSNEW:        case    OSPC_AUTH_REQUEST_FAIL:        case    OSPC_AUTH_REQUEST_SUCCESS:        case    OSPC_GET_DEST_FAIL:        case    OSPC_REPORT_USAGE_BLOCK:        case    OSPC_REPORT_USAGE_SUCCESS:        case    OSPC_VALIDATE_AUTH_FAIL:        case    OSPC_INITIALIZE_FAIL:        case    OSPC_REINITIALIZE_FAIL:        case    OSPC_AUTH_REQUEST_BLOCK:        case    OSPC_REPORT_USAGE_FAIL:        *ospvAccumAllowed = OSPC_FALSE;        break;        case    OSPC_INITIALIZE_SUCCESS:        case    OSPC_REINITIALIZE_SUCCESS:        case    OSPC_VALIDATE_AUTH_SUCCESS:        case    OSPC_GET_DEST_SUCCESS:        case    OSPC_ACCUMULATE_SUCCESS:        case    OSPC_ACCUMULATE_FAIL:        *ospvAccumAllowed = OSPC_TRUE;        break;        default:        /* unknown state */        *ospvAccumAllowed = OSPC_FALSE;    }    return;}/* * Get the value of the counter in the transaction structure. * Returns stored value as int. */int                OSPPTransactionGetCounter(    OSPTTRANS *ospvTransaction      /* In - Transaction handle */    ){    int returnval = 0;    if (ospvTransaction != OSPC_OSNULL)    {        returnval = ospvTransaction->Counter;      }    return returnval;}/* * gets pointer to transaction structure. * * returns pointer if successful, else OSPC_OSNULL. */OSPTTRANS *    OSPPTransactionGetContext(    OSPTTRANHANDLE  ospvTransaction,    /* In - Transaction handle */    int             *ospvError)         /* Out - Error return pointer */{    OSPTTRANS           *transctxt = OSPC_OSNULL;    OSPTTRANCOLLECTION  *trancoll  = OSPC_OSNULL;    OSPTCOLLECTIONINDEX tranindex;    OSPTTRANHANDLE      trans      = OSPC_TRAN_HANDLE_INVALID;    OSPTPROVHANDLE      provider   = OSPC_TRAN_HANDLE_INVALID;    OSPTPROVIDER        *prov      = OSPC_OSNULL;    OSPM_MEMSET(&tranindex, 0, sizeof(tranindex));    if (*ospvError == OSPC_ERR_NO_ERROR)     {        /* Get transaction index. Mask off provider bits */        trans = OSPM_GET_TRANSACTION_INDEX(ospvTransaction);        if (trans != OSPC_TRAN_HANDLE_INVALID)         {            /* Get provider index. Top 8 bits of transaction handle. */            provider = OSPM_GET_PROV_INDEX_FM_TRANS_HANDLE(ospvTransaction);        }        else         {            *ospvError = OSPC_ERR_TRAN_HANDLE_INVALID;            OSPM_DBGERRORLOG(*ospvError, "can't get valid transaction handle.");        }        if (provider != OSPC_TRAN_HANDLE_INVALID)         {            /* Get provider context pointer */            prov = OSPPProviderGetContext(provider, ospvError);        }        else         {            *ospvError = OSPC_ERR_TRAN_HANDLE_INVALID;            OSPM_DBGERRORLOG(*ospvError, "can't get valid provider handle.");        }        if (*ospvError == OSPC_ERR_NO_ERROR)         {            /* Get transaction collection pointer */            *ospvError = OSPPProviderGetTransactionCollection(prov, &trancoll);        }        if (*ospvError == OSPC_ERR_NO_ERROR)         {            tranindex.Index = OSPM_GET_TRANSACTION_INDEX(trans);            transctxt = OSPPTransactionCollectionGetItem(trancoll, tranindex);        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -