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

📄 ospproviderapi.c

📁 mgcp协议源代码。支持多种编码:g711
💻 C
📖 第 1 页 / 共 3 页
字号:
 * * Get number of service points defined for provider. * * The OSPPProviderGetNumberOfServicePoints interface provides the number of  * service points currently defined for ospvProvider. The result is returned  * in the location pointed to by ospvNumberOfServicePoints. * * Returns: OSPC_ERR_NO_ERROR if successful, OSPC_ERR_xxx otherwise. */intOSPPProviderGetNumberOfServicePoints(    OSPTPROVHANDLE ospvProvider,               /* In  - Provider handle     */    unsigned       *ospvNumberOfServicePoints) /* Out - Ptr to result store */{    OSPTPROVIDER *provider = OSPC_OSNULL;    int          errorcode = OSPC_ERR_NO_ERROR;    provider = OSPPProviderGetContext(ospvProvider, &errorcode);    if (errorcode == OSPC_ERR_NO_ERROR)         errorcode = OSPPCommGetNumberOfServicePoints(provider->Comm, ospvNumberOfServicePoints);    return errorcode;}/*  * OSPPProviderGetServicePoints() * * Get list of currently defined service points for provider. * * The OSPPProviderGetServicePoints function gives the caller the * list of service points currently defined for ospvProvider. The  * ospvNumberOfServicePoints parameter indicates the maximum number * of service points to include, and the ospvSizeOfServicePoint  * parameter indicates the maximum length of the character string  * (including the terminating '\0') in which service points are placed. * The service points themselves are stored in the character strings  * indicated by the ospvServicePoints array. If the number of service * points is less than ospvNumberOfServicePoints, then excess entries  * in the ospvServicePoints array are set to empty strings. If the actual * number is more than the parameter, then only the first  * ospvNumberOfServicePoints are supplied. If the string length of any  * particular service point is greater than ospvSizeOfServicePoint, then no * service points are supplied (all pointers in the ospvServicePoints array * are set to empty strings) and an error is returned. * * Returns: OSPC_ERR_NO_ERROR if successful, OSPC_ERR_xxx otherwise. */intOSPPProviderGetServicePoints(    OSPTPROVHANDLE  ospvProvider,              /* In  - Provider handle       */    unsigned        ospvNumberOfServicePoints, /* In  - Number of items       */    unsigned        ospvSizeOfServicePoint,    /* In  - Max size of each item */    char            *ospvServicePoints[])      /* Out - Ptr to result store   */{    OSPTPROVIDER *provider = OSPC_OSNULL;    int          errorcode = OSPC_ERR_NO_ERROR;    provider = OSPPProviderGetContext(ospvProvider, &errorcode);    if (errorcode == OSPC_ERR_NO_ERROR)     {        /*         * get the service points from the Communication Manager module.         */        errorcode = OSPPCommGetServicePoints(provider->Comm,             ospvNumberOfServicePoints,            ospvSizeOfServicePoint,            ospvServicePoints);    }    return errorcode;}/*  * OSPPProviderGetSSLLifetime() * * Get maximum lifetime, in seconds, of SSL session keys for provider. * * The OSPPProviderGetSSLLifetime function returns the maximum lifetime * of SSL session keys established with ospvProvider. That lifetime,  * expressed in seconds, is returned in the location pointed to by  * ospvSSLLifetime. * * Returns: OSPC_ERR_NO_ERROR if successful, OSPC_ERR_xxx otherwise. */intOSPPProviderGetSSLLifetime(    OSPTPROVHANDLE ospvProvider,     /* In - Provider handle      */    unsigned       *ospvSSLLifetime) /* Out - Ptr to result store */{    OSPTPROVIDER *provider = OSPC_OSNULL;    int          errorcode = OSPC_ERR_NO_ERROR;    provider = OSPPProviderGetContext(ospvProvider, &errorcode);    if (errorcode == OSPC_ERR_NO_ERROR)         *ospvSSLLifetime = OSPPSecGetSSLLifetime(provider->Security);    return errorcode;}/*  * OSPPProviderNew() * * Create and initialize a provider object. * * The OSPPProviderNew function creates and initializes a provider object. * This function must be called and return without errors before any other * interaction with the SDK library can take place. * * The parameters passed to this function provide the initial configuration * information for the provider. That information consists of the following  * items: * * ospvNumberOfServicePoints: the number of service points included in the  * list referenced by the ospvServicePoints parameter. * * ospvServicePoints: a list of character strings indicating where the library * should send requests and indications. Each service point in the list takes * the form of a standard URL,and may consist of up to four components: * *  An optional indication of the protocol to be used for communicating with *  the service point. This release of the SDK supports both HTTP and HTTP  *  secured with SSL; they are indicated by "http://" and "https://"  *  respectively. If the protocol is not explicitly indicated, the SDK defaults *  to HTTP secured with SSL. * *  The Internet domain name for the service point. Raw IP addresses may also *  be used, provided they are enclosed in square brackets such as "[172.16.1.1]". * *  An optional TCP port number for communicating with the service point. If the *  port number is omitted, the SDK defaults to port 80 (for HTTP) or port 443 *  (for HTTP secured with SSL). * *  The uniform resource identifier for requests to the service point. This  *  component is not optional and must be included. * * The service points are ordered in the list by decreasing preference. The SDK * library, therefore, attempts to contact the first service point first. Only  * if that attempt fails will it fall back to the second service point. * *  Examples of valid service points include: *      "https://service.transnexus.com/scripts/voice/osp.cmd" *      "service.uk.transnexus.co.uk/scripts/fax/osp.cmd" *      "http://[172.16.1.2]:443/scripts/video/osp.cmd" * * ospvLocalPrivateKey: the RSA private key to be used for signing messages sent * to the settlement service. * * ospvLocalCertificate: a X.509 formatted certificate containing the RSA public * key corresponding to the local private key. * * ospvNumberOfAuthorityCertificates: the number of certificate authority  * certificates passed in the next parameter. * * ospvAuthorityCertificates: an array of X.509 formatted certificates  * containing certificate authority public keys. These public keys are used to  * authenticate the settlement provider server during the initial SSL exchange. * * ospvLocalValidation: a Boolean value to indicate whether or not the SDK  * should validation authorisation tokens locally (i.e. by verifying digital  * signatures) or via a protocol exchange. * * ospvSSLLifetime: the lifetime, in seconds, of a single SSL session key.  * Once this time limit is exceeded, the SDK library will negotiate a new  * session key. Communication exchanges in progress will not be interrupted  * when this time limit expires. * * ospvHTTPMaxConnections: the maximum number of simultaneous connections  * to be used for communication to the settlement provider. * * ospvHTTPPersistence: the time, in seconds, that an HTTP connection should * be maintained after the completion of a communication exchange. The library * will maintain the connection for this time period in anticipation of future * communication exchanges to the same server. * * ospvHTTPRetryDelay: the time, in seconds, between retrying connection  * attempts to the provider. After exhausting all service points for the  * provider, the library will delay for this amount of time before resuming  * connection attempts. * * ospvHTTPRetryLimit: the maximum number of retries for connection attempts  * to the provider.If no connection is established after this many retry  * attempts to all service points, then the library will cease connection  * attempts and return appropriate error codes.  * This number does not count the initial connection attempt, so that an  * ospvHTTPRetryLimit of 1 will result in a total of two connection attempts  * to every service point. * * ospvHTTPTimeout: the maximum time, in milliseconds, to wait for a response * from a server. If no response is received within this time, the current  * connection is aborted and the  library attempts to contact the next service * point. *  * ospvProvider: pointer to variable in which to store a handle for the newly * created provider object. That handle must be used for all subsequent  * interactions with the provider. * * Returns: OSPC_ERR_NO_ERROR if successful, OSPC_ERR_xxx otherwise. */intOSPPProviderNew(    unsigned             ospvNumberOfServicePoints, /* In  - Svc ptr count           */    const char           *ospvServicePoints[],       /* In  - Svc pts strings         */    const char           *ospvAuditURL,             /* In  - Audit URL string         */    const OSPTPRIVATEKEY *ospvLocalPrivateKey,       /* In  - Private key obj ptr     */    const void           *ospvLocalCertificate,     /* In  - Local cert ptr          */    unsigned             ospvNumberOfAuthorityCertificates, /* In  - Auth cert nt            */    const void           *ospvAuthorityCertificates[],       /* In  - Auth certs              */    unsigned             ospvLocalValidation,       /* In  - Local validation or not */    unsigned             ospvSSLLifetime,           /* In  - SSL lifetime            */    unsigned             ospvHTTPMaxConnections,     /* In  - Max connections         */    unsigned             ospvHTTPPersistence,       /* In  - Connection persistence  */    unsigned             ospvHTTPRetryDelay,         /* In  - Retry delay             */    unsigned             ospvHTTPRetryLimit,         /* In  - Retry limit             */    unsigned             ospvHTTPTimeout,           /* In  - Timeout                 */    const char           *ospvCustomerId,           /* In - Customer Id              */    const char           *ospvDeviceId,             /* In - Device Id                */    OSPTPROVHANDLE       *ospvProvider)             /* Out - Handle to new provider  */{    OSPTPROVIDER    *provider   = OSPC_OSNULL;    int             errorcode   = OSPC_ERR_NO_ERROR;    unsigned long   custid      = 0L,                     deviceid    = 0L;    /*      * check incoming values and reset to defaults if necessary     */    if((ospvNumberOfServicePoints <= 0)         ||       (ospvServicePoints == OSPC_OSNULL)       ||       (ospvLocalPrivateKey == OSPC_OSNULL)     ||       (ospvLocalCertificate == OSPC_OSNULL)    ||       (ospvNumberOfAuthorityCertificates <= 0) ||       (ospvAuthorityCertificates == OSPC_OSNULL)   ||       (ospvSSLLifetime < 0)        ||       (ospvHTTPMaxConnections < 0) ||       (ospvHTTPPersistence < 0)    ||       (ospvHTTPRetryDelay < 0)     ||       (ospvAuditURL == OSPC_OSNULL)    ||       (ospvHTTPRetryLimit < 0)     ||       (ospvHTTPTimeout < 0))    {        errorcode = OSPC_ERR_PROV_INVALID_VALUE;    }    else    {        /* if proper values are not set, set them to defaults */        if(ospvSSLLifetime == 0)        {            ospvSSLLifetime = OSPC_DEFAULT_SSLLIFETIME;        }        if(ospvHTTPMaxConnections == 0)        {            ospvHTTPMaxConnections = OSPC_DEFAULT_HTTPMAXCONNECTIONS;        }        if(ospvHTTPPersistence == 0)        {            ospvHTTPPersistence = OSPC_DEFAULT_HTTPPERSISTENCE;        }        if(ospvHTTPRetryDelay == 0)        {            ospvHTTPRetryDelay = OSPC_DEFAULT_HTTPRETRYDELAY;        }        if(ospvHTTPTimeout < 1000)        {            ospvHTTPTimeout = OSPC_DEFAULT_HTTPTIMEOUT;        }             /*         * get a new Provider handle         */        errorcode = OSPPProviderGetNewCollectionItem(ospvProvider);        if (errorcode == OSPC_ERR_NO_ERROR)         {            /*             * get the new Provider handle context             */            provider = OSPPProviderGetContext(*ospvProvider, &errorcode);            if (errorcode == OSPC_ERR_NO_ERROR)             {                          if(errorcode == OSPC_ERR_NO_ERROR)                {                    /*                     * initialize the area which holds the transactions                      */                    errorcode = OSPPProviderTransactionCollectionNew(                        &(provider->TransCollection));                }                if(errorcode == OSPC_ERR_NO_ERROR)                {                    /*                     * initialize security area                     */                    errorcode = OSPPSecNew(&(provider->Security));                }                if (errorcode == OSPC_ERR_NO_ERROR)                {                    /*                     * initialize the Comm object                     */                    errorcode = OSPPCommNew(&(provider->Comm));                }                if (errorcode == OSPC_ERR_NO_ERROR)                {                    /*                     * set security for the Comm object                     */                    OSPPCommSetSecurity(provider->Comm, provider->Security);                }                if (errorcode == OSPC_ERR_NO_ERROR)                {                    /*                     * set the connection SSL Session Lifetime                     */                    errorcode = OSPPProviderSetSSLLifetime(*ospvProvider,                         ospvSSLLifetime);                       }                if (errorcode == OSPC_ERR_NO_ERROR)                {                    /*                     * Perform any global SSL initialisation routines                     */                    errorcode = OSPPSSLSessionInit((void *)provider->Security);                }            }            if (errorcode == OSPC_ERR_NO_ERROR)                 /*                 * allow new transactions to be processed                 */                OSPPProviderSetNewTransactionAllowed(provider, OSPC_TRUE);            /*             * set the service points configured             */            errorcode = OSPPProviderSetServicePoints(                *ospvProvider,                  ospvNumberOfServicePoints,                 ospvServicePoints);            if (errorcode == OSPC_ERR_NO_ERROR)                /*                 * set the CA certs                 */                errorcode = OSPPProviderSetAuthorityCertificates(                *ospvProvider,                 ospvNumberOfAuthorityCertificates,                ospvAuthorityCertificates);            if (errorcode == OSPC_ERR_NO_ERROR)                /*                 * set the connection HTTP Persistence                 */                errorcode = OSPPProviderSetHTTPPersistence(                *ospvProvider,                 ospvHTTPPersistence);            if (errorcode == OSPC_ERR_NO_ERROR)                 /*                 * set the maximum number of HTTP connections                  */                errorcode = OSPPProviderSetHTTPMaxConnections(                *ospvProvider,                 ospvHTTPMaxConnections);                            if (errorcode == OSPC_ERR_NO_ERROR)            {                /* set Customer Id */                custid = atol(ospvCustomerId);                OSPPProviderSetTNCustId(provider, custid);                /* set Device Id */                deviceid = atol(ospvDeviceId);                OSPPProviderSetTNDeviceId(provider, deviceid);                /*                 * set the private key.                  */                errorcode = OSPPProviderSetLocalKeys(                    *ospvProvider,                     ospvLocalPrivateKey,                     ospvLocalCertificate);            }            if (errorcode == OSPC_ERR_NO_ERROR)                /*                 * set the HTTP retry delay                 */                errorcode = OSPPProviderSetHTTPRetryDelay(                *ospvProvider,                 ospvHTTPRetryDelay);            if (errorcode == OSPC_ERR_NO_ERROR)                /*                 * set the HTTP retry limit                 */                errorcode = OSPPProviderSetHTTPRetryLimit(                *ospvProvider,                 ospvHTTPRetryLimit);            if (errorcode == OSPC_ERR_NO_ERROR)                /*                 * set the HTTP timeout

⌨️ 快捷键说明

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