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

📄 osptransapi.c

📁 mgcp协议源代码。支持多种编码:g711
💻 C
📖 第 1 页 / 共 5 页
字号:
        if (ospvFailureReason == OSPC_FAIL_NONE)         {            errorcode = OSPC_ERR_TRAN_INVALID_FAILURE_CODE;            OSPM_DBGERRORLOG(errorcode, "failure code invalid");        }        if(errorcode == OSPC_ERR_NO_ERROR)        {            errorcode = OSPPFailReasonFind(ospvFailureReason);        }        if(errorcode == OSPC_ERR_NO_ERROR)        {            /* Set failure reason for current destination */            OSPPDestSetTNFailReason(trans->CurrentDest, ospvFailureReason);        }    }    else if(errorcode == OSPC_ERR_NO_ERROR)    {        errorcode = OSPC_ERR_TRAN_TRANSACTION_NOT_FOUND;        OSPM_DBGERRORLOG(errorcode, "Transaction pointer is NULL.");    }    return errorcode;}/** OSPPTransactionReinitializeAtDevice* The OSPPTransactionReinitializeAtDevice function re-initializes a (previously* initialized) transaction object. Applications can use this with a distributed* architecture in which the systems requesting and validating authorisation * (e.g. H.323 gatekeepers) are different than the systems that ultimately * report usage information (e.g. H.323 gateways). The reporting device can call* this function after failing to reach a previous destination. As such, this* function is an alternative to the OSPPTransactionGetNextDestination function.* Parameters to the function are:*   ospvTransaction: handle of the (previously created) transaction object.*   ospvFailureReason: the reason that attempts to use the previously *       identified destination failed; values for this parameter are listed in*       the ospfail.h file.* ospvIsSource: indicates whether the system calling this function is acting as*       the source (if non-zero) or destination (if zero) for the call.* ospvSource: character string identifying the source of the call. The value is*       expressed as either a DNS name or an IP address enclosed in square *       brackets, followed by an optional colon and TCP port number. *       Examples of valid sources include "gateway1.carrier.com" and *           "[172.16.1.2]:112".* ospvDestination: character string identifying the destination for the call. *       The value is expressed as either a DNS name or an IP address enclosed *       in square brackets, followed by an optional colon and TCP port number. *       Examples of valid destinations include "gateway1.carrier.com" and *           "[172.16.1.2]:112".* ospvSourceDevice: character string identifying the source device in a *       protocol specific manner (e.g. H.323 Identifier); this string is *       optional and may be empty.* ospvDestinationDevice: character string identifying the destination device *       in a protocol specific manner (e.g. H.323 Identifier); this string is *       optional and may be empty.* ospvCallingNumber: character string containing the calling party's number *       expressed as a full international number conforming to the ITU E.164 *       standard (with no punctuation).* ospvCalledNumber: character string containing the called number, expressed *       as a full international number conforming to the ITU E.164 standard *       (with no punctuation).* ospvSizeOfCallId: size of the memory buffer containing the call identifier.* ospvCallId: memory location containing the H.323 call identifier for the *       call.* ospvSizeOfToken: size of the memory buffer containing an authorisation token*       for the call.* ospvToken: memory location containing an authorisation token.* ospvAuthorised: pointer to a variable in which the function will indicate *       whether or not the call is authorised. On return, a non-zero value *       indicates that the call is authorised by the provider, while a zero *       value indicates an authorisation failure.* ospvTimeLimit: pointer to a variable in which to place the number of seconds*       for which the call is initially authorised. A value of zero indicates *       that no limit exists. Note that the initial time limit may be extended *       during the call by using the function *       OSPPTransactionRequestReauthorisation.* ospvSizeOfDetailLog: pointer to a variable which, on input, contains the *       maximum size of the detail log; on output, the variable will be updated*       with the actual size of the detail log. By setting this value to zero, *       applications indicate that they do not wish a detail log for the *       authorisation validation.* ospvDetailLog: pointer to a location in which to store a detail log for the *       validation. If this pointer is not NULL, and if the ospvSizeOfDetailLog*       parameter is non-zero, then the library will store a copy of the *       authorisation confirmation obtained from the settlement provider, *       including the settlement provider's digital signature.* If the provider has been configured to perform local validation, the SDK * library is able to perform this function without network interaction, and, * therefore, does not block for network input or output during its execution. * If local validation is not used, this function blocks until authorisation has* been validated, refused, or an error has been detected. The Open Settlement * Protocol SDK Porting Guide includes information on modifying that behavior to* prevent blocking.* The function returns an error code or zero (if the operation was successful).* Specific error codes and their meanings can be found in the osperrno.h file.*/intOSPPTransactionReinitializeAtDevice(    OSPTTRANHANDLE       ospvTransaction,    enum OSPEFAILREASON  ospvFailureReason,    unsigned             ospvIsSource,    const char          *ospvSource,    const char          *ospvDestination,    const char          *ospvSourceDevice,    const char          *ospvDestinationDevice,    const char          *ospvCallingNumber,    const char          *ospvCalledNumber,    unsigned             ospvSizeOfCallId,    const void          *ospvCallId,    unsigned             ospvSizeOfToken,    const void          *ospvToken,    unsigned            *ospvAuthorised,    unsigned            *ospvTimeLimit,    unsigned            *ospvSizeOfDetailLog,    void                *ospvDetailLog){    int         errorcode = OSPC_ERR_NO_ERROR;    OSPTTRANS  *trans     = (OSPTTRANS *)OSPC_OSNULL;    /* verify input */    if(((ospvSource == (const char *)OSPC_OSNULL) &&         (ospvSourceDevice == (const char *)OSPC_OSNULL)) ||        ((ospvDestination == (const char *)OSPC_OSNULL)&&        (ospvDestinationDevice == (const char *)OSPC_OSNULL)) ||        (ospvCallingNumber == (const char *)OSPC_OSNULL) ||        (ospvCalledNumber == (const char *)OSPC_OSNULL)  ||        (ospvSizeOfCallId == 0)                          ||        (ospvCallId == (const void *)OSPC_OSNULL)   ||        (ospvSizeOfToken == 0)                      ||        (ospvToken == (const void *)OSPC_OSNULL))    {        errorcode = OSPC_ERR_TRAN_INVALID_ENTRY;        OSPM_DBGERRORLOG(errorcode, "Invalid input for ReInitialize");    }    else    {        trans = OSPPTransactionGetContext(ospvTransaction, &errorcode);        /* First make sure they sent us a failure code */        if (ospvFailureReason == OSPC_FAIL_NONE)         {            errorcode = OSPC_ERR_FAILRSN_NO_DATA;            OSPM_DBGERRORLOG(errorcode, "Failure code missing");        }        /* Set failure reason for current destination, validate token and add new           destination. only on OGW           */        /* Now check for acceptable failure code */        if(errorcode == OSPC_ERR_NO_ERROR)        {            errorcode = OSPPFailReasonFind(ospvFailureReason);        }        /* call validate */        if(errorcode == OSPC_ERR_NO_ERROR)        {            errorcode = OSPPTransactionValidateAuthorisation(ospvTransaction,                 ospvSource,                ospvDestination,                 ospvSourceDevice,                ospvDestinationDevice,                ospvCallingNumber, ospvCalledNumber,                ospvSizeOfCallId, ospvCallId,                 ospvSizeOfToken, ospvToken,                 ospvAuthorised,                ospvTimeLimit, ospvSizeOfDetailLog,                ospvDetailLog);        }        if((errorcode == OSPC_ERR_NO_ERROR) &&            (*ospvAuthorised == OSPC_TRAN_AUTHORISED))        {            /* should only be called by OGW */            if(ospvIsSource == OSPC_SOURCE)            {                /* we are only adding a destination */                /* first set failure code in authrsp->currentdest */                OSPPDestSetTNFailReason(trans->CurrentDest, ospvFailureReason);                /* now build new dest */                errorcode = OSPPTransactionResponseBuild(trans,                     ospvDestination, ospvSizeOfCallId,                    ospvCallId, ospvSizeOfToken, ospvToken);            }            else            {                errorcode = OSPC_ERR_TRAN_NOT_IMPLEMENTED;                OSPM_DBGERRORLOG(errorcode, "Invalid system type.");            }        }        else        {            if(errorcode == OSPC_ERR_NO_ERROR)            {                /* no error from validate, but token not authorised */                errorcode = OSPC_ERR_TRAN_TOKEN_INVALID;                OSPM_DBGERRORLOG(errorcode, "Token invalid");            }        }    } /* end else (parameters are correct) */    /* Set transaction state */    if (errorcode == OSPC_ERR_NO_ERROR)    {        OSPPTransactionSetState(trans, OSPC_REINITIALIZE_SUCCESS);    }    else    {        OSPPTransactionSetState(trans, OSPC_REINITIALIZE_FAIL);    }    return errorcode;}/* * OSPPTransactionReportUsage() * * Reports usage information for a call. * * The OSPPTransactionReportUsage function reports usage information for a call * Once this function returns successfully, it may not be called again for the  * life of the transaction object. Parameters to the function are: *   ospvTransaction: handle of the transaction object. *   ospvDuration: the duration of the call, in seconds. *   ospvLossPacketsSent: a count of the total number of packets sent by the  *      reporting system that were not received by its peer, as reported in  *      the peer's RTCP sender and receiver reports. *   ospvLossFractionSent: the fraction of packets sent by the reporting system *      that were not received by its peer, as reported in the peer's RTCP  *      sender and receiver reports. The fraction is expressed as an integer  *      number from 0 (no loss) to 255 (total loss). *   ospvLossPacketsReceived: a count of the total number of packets that the  *      reporting system expected to receive but did not, as reported in the  *      system's RTCP sender and receiver reports. *   ospvLossFractionReceived: the fraction of packets that the reporting  *      system expected to receive but did not, as reported in it's RTCP sender *      and receiver reports. The fraction is expressed as an integer number  *      from 0 (no loss) to 255 (total loss). *   ospvSizeOfDetailLog: pointer to a variable which, on input, contains the  *      maximum size of the detail log; on output, the variable will be updated *      with the actual size of the detail log. By setting this value to zero,  *      applications indicate that they do not wish a detail log for the usage  *      report. *   ospvDetailLog: pointer to a location in which to store a detail log for  *      the usage report. If this pointer is not NULL, and if the  *      ospvSizeOfDetailLog parameter is non-zero, then the library will store  *      a copy of the usage confirmation obtained from the settlement provider, *      including the settlement provider's digital signature. * As delivered in the SDK library, this function blocks until usage has been  * reported or an error has been detected. The Open Settlement Protocol SDK  * Porting Guide includes information on modifying that behavior to prevent  * blocking. * * returns OSPC_ERR_NO_ERROR if successful, otherwise error code. */intOSPPTransactionReportUsage(    OSPTTRANHANDLE          ospvTransaction,            /* In - Transaction handle */    unsigned                ospvDuration,               /* In - Length of call */    unsigned                ospvLossPacketsSent,        /* In - Packets not received by peer */     signed                  ospvLossFractionSent,       /* In - Fraction of packets not received by peer */    unsigned                ospvLossPacketsReceived,    /* In - Packets not received that were expected */    signed                  ospvLossFractionReceived,   /* In - Fraction of packets expected but not received */    unsigned                *ospvSizeOfDetailLog,    /* In/Out - Max size of detail log \ Actual size of detail log */    void                    *ospvDetailLog)             /* Out - Pointer to detail log storage */{    int                     errorcode    = OSPC_ERR_NO_ERROR;    OSPTTRANS               *trans       = OSPC_OSNULL;    OSPTUSAGEIND            *usage       = OSPC_OSNULL;    OSPE_MSG_DATATYPES      datatype     = OSPC_MSG_LOWER_BOUND;    unsigned char           *xmldoc      = OSPC_OSNULL;    unsigned                sizeofxmldoc = 0;    OSPTMSGINFO             *msginfo     = OSPC_OSNULL;    OSPTDEST                *dest        = OSPC_OSNULL;    OSPTBOOL                usageallowed = OSPC_FALSE;    OSPTSTATISTICS          stats;    OSPM_ARGUSED(ospvSizeOfDetailLog);    OSPM_ARGUSED(ospvDet

⌨️ 快捷键说明

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