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

📄 osptransapi.c

📁 mgcp协议源代码。支持多种编码:g711
💻 C
📖 第 1 页 / 共 5 页
字号:
 * OSPPTransactionGetFirstDestination function (to define the endpoints of the  * call. In the destination device, this function serves as an alternative to  * the function  OSPPTransactionValidateAuthorisation.  * Parameters to the function are: *  ospvTransaction: handle of the (previously created) transaction object. *  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.*/intOSPPTransactionInitializeAtDevice(    OSPTTRANHANDLE  ospvTransaction,        /*In - Transaction handle */    unsigned        ospvIsSource,           /*In - Is this the ogw or tgw */    const char     *ospvSource,             /*In - Source of call */    const char     *ospvDestination,        /*In - Destination for call */    const char     *ospvSourceDevice,       /*In - SourceDevice */    const char     *ospvDestinationDevice,  /*In - DestinationDevice */    const char     *ospvCallingNumber,      /*In - Calling number */    const char     *ospvCalledNumber,       /*In - Called number */    unsigned        ospvSizeOfCallId,       /*In - Size of Callid */    const void     *ospvCallId,             /*In - Call identifier */    unsigned        ospvSizeOfToken,        /*In - Size of Token */    const void     *ospvToken,              /*In - token */    unsigned       *ospvAuthorised,         /*Out - indicates authorisation */    unsigned       *ospvTimeLimit,          /*Out - number of seconds allowed*/    unsigned       *ospvSizeOfDetailLog,    /* In/Out - Max size of detail log Actual size of detail log */    void           *ospvDetailLog){    int                 errorcode   = OSPC_ERR_NO_ERROR;    OSPTTRANS          *trans       = (OSPTTRANS *)OSPC_OSNULL;    unsigned            numcallids  = 1;    OSPTCALLID          *callid     = (OSPTCALLID *)OSPC_OSNULL;    /* verify input */    if(((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 Initialize");    }    /* Get transaction context */    if (errorcode == OSPC_ERR_NO_ERROR)    {        trans = OSPPTransactionGetContext(ospvTransaction,             &errorcode);    }    /* 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);    }    /*      * move data into authreq & authrsp, (OGW) struct so      * report usage will work.      * We are adding a destination to authrsp->dest, setting current dest to     * point to it.     */    if((errorcode == OSPC_ERR_NO_ERROR) &&        (*ospvAuthorised == OSPC_TRAN_AUTHORISED))    {        if(ospvIsSource == OSPC_SOURCE)        {            if(trans->AuthReq != (OSPTAUTHREQ *)OSPC_OSNULL)            {                errorcode = OSPC_ERR_TRAN_INVALID_ENTRY;                OSPM_DBGERRORLOG(errorcode, "Transaction already initialized");            }            else            {                /* create callid structure */                callid = OSPPCallIdNew(ospvSizeOfCallId, (const unsigned char *)ospvCallId);                if(callid == (OSPTCALLID *)OSPC_OSNULL)                {                    errorcode = OSPC_ERR_DATA_NOCALLID;                }                if(errorcode == OSPC_ERR_NO_ERROR)                {                    /* we need to build authreq and authrsp */                    errorcode = OSPPTransactionRequestNew(trans, ospvSource,                        ospvSourceDevice,                        ospvCallingNumber,                        ospvCalledNumber,                         (const char *)OSPC_OSNULL,                        numcallids,&callid,                        (const char **)OSPC_OSNULL,                        &numcallids,                         ospvSizeOfDetailLog,                         ospvDetailLog);                }                /* delete callid - TransactionRequestNew created new one */                OSPPCallIdDelete(&callid);            }            if(errorcode == OSPC_ERR_NO_ERROR)            {                errorcode = OSPPTransactionResponseBuild(trans,                     ospvDestination,                    ospvSizeOfCallId,                    ospvCallId,                     ospvSizeOfToken,                     ospvToken);            }            /* Set correct role */            OSPPAuthIndSetRole(trans->AuthInd,OSPC_SOURCE);        }        else if(ospvIsSource == OSPC_DESTINATION)        {            /* authind  already built by validate, just make sure role is correct */            OSPPAuthIndSetRole(trans->AuthInd,OSPC_DESTINATION);        }        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");        }    }    /* Set transaction state */    if (errorcode == OSPC_ERR_NO_ERROR)    {        OSPPTransactionSetState(trans, OSPC_INITIALIZE_SUCCESS);    }    else    {        OSPPTransactionSetState(trans, OSPC_INITIALIZE_FAIL);    }    return errorcode;}/* * The OSPPTransactionNew function creates a new transaction object for  * ospvProvider. A handle to that object is returned to the location pointed  * to by ospvTransaction. * After calling this function to allocate storage for a transaction object,  * applications should call one of the following three functions to initialize  * the object: *  OSPPTransactionRequestAuthorisation: used by the source of a call. *  OSPPTransactionValidateAuthorisation: used by the destination for a call. *  OSPPTransactionInitialize: used primarily in architectures that separate  *      the call authorisation functions from call setup and usage reporting  *      functions. * 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. */intOSPPTransactionNew(    OSPTPROVHANDLE  ospvProvider,       /* In - Provider Handle */    OSPTTRANHANDLE  *ospvTransaction)   /* Out - Transaction Handle */{    int         errorcode = OSPC_ERR_NO_ERROR;    OSPTTRANS   *trans = NULL;    errorcode = OSPPTransactionGetNewContext(ospvProvider, ospvTransaction);    if (errorcode == OSPC_ERR_NO_ERROR)    {        trans = OSPPTransactionGetContext(*ospvTransaction, &errorcode);    }    if (errorcode == OSPC_ERR_NO_ERROR)    {        trans->Provider = OSPPProviderGetContext(ospvProvider, &errorcode);    }    if (errorcode == OSPC_ERR_NO_ERROR)    {        OSPPTransactionSetState(trans, OSPC_TRANSNEW);    }    return errorcode;}/* * The OSPPTransactionRecordFailure function allows an application to record  * the failure of a call attempt. Applications can use this function when they  * wish to abandon a call attempt without exhausting the list of possible  * destinations, and in a distributed architecture in which the system  * retrieving successive destinations (e.g. an H.323 gatekeeper) is different  * than the system that ultimately reports usage information (e.g. an H.323  * gateway). * The parameters to this function consist of the following: *  ospvTransaction: handle of the 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. * 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. * 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.*/intOSPPTransactionRecordFailure(    OSPTTRANHANDLE       ospvTransaction,    enum OSPEFAILREASON  ospvFailureReason){    int         errorcode = OSPC_ERR_NO_ERROR;    OSPTTRANS  *trans     = (OSPTTRANS *)OSPC_OSNULL;    trans = OSPPTransactionGetContext(ospvTransaction, &errorcode);    if((errorcode == OSPC_ERR_NO_ERROR) &&        (trans != (OSPTTRANS *)OSPC_OSNULL))    {

⌨️ 快捷键说明

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