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

📄 osptnepinit.c

📁 mgcp协议源代码。支持多种编码:g711
💻 C
📖 第 1 页 / 共 5 页
字号:
/**########################################################################*########################################################################*########################################################################*                                                               *   COPYRIGHT (c) 1998, 1999, 2000 by TransNexus, LLC                          *                                                                    *   This software contains proprietary and confidential information  *   of TransNexus, LLC. Except as may be set forth in the license    *   agreement under which this software is supplied, use, disclosure, *   or reproduction is prohibited without the prior, express, written*   consent of TransNexus, LLC.                                      *                                     *******#########################################################################*#########################################################################*#########################################################################*/#include "ospcomm.h"#include "ospssl.h"#include "ospsecurity.h"#include "ospb64.h"#include "osptnep.h"#include "osptnepinit.h"#include "ospcryptowrap.h"/*  * Initialize the Enrollment Parameter object sent in. All of the * structures will have to be malloced in this case. * * Input: Pointer to an OSPTENROLLPARAMS object * * Errors: *     o the pointer to the OSPTENROLLPARAMS is null; *     o malloc or initialization fails on any member of the OSPTENROLLPARAMS. */int OSPPInitEnrollParams (    OSPTENROLLPARAMS* ospvEnrollParamsIn){    int retVal = OSPC_ERR_NO_ERROR;    OSPM_DBGENTER(( "ENTER: OSPPInitEnrollParams\n" ));    /* If ( the pointer to the enrollment parameter list is ok ) then     *  o allocate memory for every string in the enrollment parameter list     *    using default lengths. If a string is too short, too long, or needs     *    to be allocated in another function for some other reason, then     *    just take it out here.     *  o if ( all of the pointers are ok ) then     *      - initialize all of their values.     */    if ( ospvEnrollParamsIn == OSPC_OSNULL )    {        retVal = OSPC_ERR_ENROLL_INVALID_ARG;        OSPM_DBGERRORLOG(             retVal,             "Unable to initialize a null enrollment parameter set.\n" );    }    if ( retVal == OSPC_ERR_NO_ERROR )    {        ospvEnrollParamsIn->Verbose    = 0;        ospvEnrollParamsIn->Nonce      = OSPC_OSNULL;        ospvEnrollParamsIn->NonceLen   = 0;        ospvEnrollParamsIn->CACert = OSPC_OSNULL;        ospvEnrollParamsIn->CACertLen = 0;        ospvEnrollParamsIn->CACertB64 = OSPC_OSNULL;        ospvEnrollParamsIn->CACertB64Len = 0;        ospvEnrollParamsIn->Function = OSPC_OSNULL;        ospvEnrollParamsIn->Username = OSPC_OSNULL;        ospvEnrollParamsIn->Password = OSPC_OSNULL;        ospvEnrollParamsIn->DeviceId = OSPC_OSNULL;        ospvEnrollParamsIn->CustomerId = OSPC_OSNULL;        ospvEnrollParamsIn->CertReq = OSPC_OSNULL;        ospvEnrollParamsIn->SSLUrl = OSPC_OSNULL;        ospvEnrollParamsIn->CAUrl = OSPC_OSNULL;        ospvEnrollParamsIn->CAFprint = OSPC_OSNULL;    }    OSPM_DBGEXIT(( "EXIT: OSPPFreeEnrollParams\n" ));    return retVal;}/*  * This function is called for freeing up all the memory taken up * by an enrollment parameter object. * * Input:  *     o pointer to an OSPTENROLLPARAMS; * * Errors: *     o if the input variable is null ( OSPC_ERR_ENROLL_ENROLL_PARAMS_FREE )  */int OSPPFreeEnrollParams (    OSPTENROLLPARAMS* ospvEnrollParamsIn){    int retVal = OSPC_ERR_NO_ERROR;    OSPM_DBGENTER(( "ENTER: OSPPFreeEnrollParams\n" ));    if ( ospvEnrollParamsIn == OSPC_OSNULL )    {        retVal = OSPC_ERR_ENROLL_INVALID_ARG;        OSPM_DBGERRORLOG(             retVal,             "The enrollment parameter list being freed was null.\n" );    }    /* Free all of the parameters in the enrollment list, just so long as     * they're valid ( and the enrollment list itself isn't null, either ):     */    if ( retVal == OSPC_ERR_NO_ERROR )    {        if ( ospvEnrollParamsIn->Function  != OSPC_OSNULL )        {            OSPM_FREE( ospvEnrollParamsIn->Function  );        }        if ( ospvEnrollParamsIn->Username  != OSPC_OSNULL )        {            OSPM_FREE( ospvEnrollParamsIn->Username  );        }        if ( ospvEnrollParamsIn->Password  != OSPC_OSNULL )        {            OSPM_FREE( ospvEnrollParamsIn->Password  );        }        if ( ospvEnrollParamsIn->DeviceId  != OSPC_OSNULL )        {            OSPM_FREE( ospvEnrollParamsIn->DeviceId  );        }        if ( ospvEnrollParamsIn->CustomerId  != OSPC_OSNULL )        {            OSPM_FREE( ospvEnrollParamsIn->CustomerId  );        }        if ( ospvEnrollParamsIn->CertReq  != OSPC_OSNULL )        {            OSPM_FREE( ospvEnrollParamsIn->CertReq  );        }        if ( ospvEnrollParamsIn->CAFprint != OSPC_OSNULL )        {            OSPM_FREE( ospvEnrollParamsIn->CAFprint );        }        if ( ospvEnrollParamsIn->SSLUrl  != OSPC_OSNULL )        {            OSPM_FREE( ospvEnrollParamsIn->SSLUrl  );        }        if ( ospvEnrollParamsIn->CAUrl  != OSPC_OSNULL )        {            OSPM_FREE( ospvEnrollParamsIn->CAUrl  );        }        if ( ospvEnrollParamsIn->CACertB64 != OSPC_OSNULL )        {            OSPM_FREE( ospvEnrollParamsIn->CACertB64 );        }        if ( ospvEnrollParamsIn->CACert != OSPC_OSNULL )        {            OSPM_FREE( ospvEnrollParamsIn->CACert );        }        if ( ospvEnrollParamsIn->Nonce != OSPC_OSNULL )        {            OSPM_FREE( ospvEnrollParamsIn->Nonce );        }    }    OSPM_DBGEXIT(( "EXIT: OSPPFreeEnrollParams\n" ));    return retVal;}/*  * This function will take a list of enrollment parameters and communications * parameters that specify how a communications manager will be set up. * The communications manager will first be created and then initialized * with all of the non-SSL-related parameters, followed by all of the * SSL-related parameters. * * Input: a pointer to the enrollment server parameters ( for the enrollment *        server's url ); a pointer to the communication parameters; and a  *        pointer to the reference to the communication manager to be initialized. *        *ospvCommOut should be null ( but ospvCommOut should not. ) * * Output: *ospvCommMgrOut should be initialized as a communications manager. *         If it can't be initialized, then it should be null and the  *         return value will be non-zero. Otherwise, the return value should *         be zero. */int OSPPInitSecureCommMgr(    OSPTENROLLPARAMS* ospvEnrollParamsIn,    OSPTCOMMPARAMS*   ospvCommParamsIn,    OSPTCOMM**        ospvCommOut ){    int retVal = OSPC_ERR_NO_ERROR;    OSPM_DBGENTER(( "ENTER: OSPPInitSecureCommMgr\n" ));    /* If ( any of the parameters are null or      *      if the url for the CA is null ) then     *  o set an error code and complain.     */    if ( ( ospvEnrollParamsIn == OSPC_OSNULL ) ||         ( ospvCommParamsIn == OSPC_OSNULL ) ||         ( ospvCommOut == OSPC_OSNULL ) ||         ( ospvEnrollParamsIn->SSLUrl == OSPC_OSNULL ) )    {        retVal = OSPC_ERR_ENROLL_INVALID_ARG;        OSPM_DBGERRORLOG(             retVal,             "The parameters for initializing the secure comm manager are invalid.\n" );    }    /* Now create the communications manager. We should check the     * pointer returned for the communications manager even if the return     * value says otherwise.     */    if ( retVal == OSPC_ERR_NO_ERROR )    {        retVal = OSPPCommNew( ospvCommOut );        if ( retVal != OSPC_ERR_NO_ERROR )        {            OSPM_DBGERRORLOG(                 retVal,                 "Unable to allocate the space for the communications manager.\n" );        }        else if ( *ospvCommOut == OSPC_OSNULL )        {            retVal = OSPC_ERR_COMM_NO_MEMORY;            OSPM_DBGERRORLOG(                 retVal,                 "The communications manager returned was invalid.\n" );        }    }    /* Initialize the communications manager, which includes allocating     * its memory.     */    if ( retVal == OSPC_ERR_NO_ERROR )    {        retVal =             OSPPInitNonSSLCommMgrParams(                 ospvEnrollParamsIn->SSLUrl,                ospvCommParamsIn,                 *ospvCommOut );        if ( retVal != OSPC_ERR_NO_ERROR )        {            OSPM_DBGERRORLOG(                 retVal,                 "Unable to initialize the communication manager's non-SSL related parameters.\n" );         }    }    /* Now set up all of the communications parameters specific to SSL: */    if ( retVal == OSPC_ERR_NO_ERROR )    {        retVal =            OSPPInitSSLCommMgrParams(                ospvEnrollParamsIn,                ospvCommParamsIn,                *ospvCommOut );        if ( retVal != OSPC_ERR_NO_ERROR )        {            OSPM_DBGERRORLOG(                 retVal,                 "Unable to initialize the communication manager's SSL related parameters.\n" );         }    }    OSPM_DBGEXIT(( "EXIT: OSPPInitSecureCommMgr\n" ));    return retVal;}    /* This is just a minimal wrapper for calling OSPPInitNonSecureCommMgrParams; * it just extracts the service point for the CA from the enrollment  * parameters and passes it along as the service point to be explicitly  * contacted by the communications manager. * * Input: a pointer to the enrollment server parameters ( for the CA's *        url ); a pointer to the communication parameters; and a pointer *        to the reference to the communication manager to be initialized. * * Output: *ospvCommMgrOut should be initialized as a communications manager. *         If it can't be initialized, then it should be null and the  *         return value will be non-zero. Otherwise, the return value should *         be zero. */int OSPPInitNonSecureCommMgr(    OSPTENROLLPARAMS* ospvEnrollParamsIn,    OSPTCOMMPARAMS*  ospvCommParamsIn,    OSPTCOMM**       ospvCommOut ){    int retVal = OSPC_ERR_NO_ERROR;    OSPM_DBGENTER(( "OSPPInitNonSecureCommMgr\n" ));    /* If ( any of the parameters are null or      *      if the url for the CA is null ) then     *  o set an error code and complain.     */    if ( ( ospvEnrollParamsIn == OSPC_OSNULL ) ||         ( ospvCommParamsIn == OSPC_OSNULL ) ||         ( ospvCommOut == OSPC_OSNULL ) ||         ( ospvEnrollParamsIn->CAUrl == OSPC_OSNULL ) )    {        retVal = OSPC_ERR_ENROLL_INVALID_ARG;        OSPM_DBGERRORLOG(             retVal,             "The parameters for initializing the CA's communications manager are invalid.\n" );    }    /* Create the communications manager before we initialize it: */    if ( retVal == OSPC_ERR_NO_ERROR )    {        retVal = OSPPCommNew( ospvCommOut );        if ( retVal != OSPC_ERR_NO_ERROR )         {            OSPM_DBGERRORLOG(                 retVal,                 "Unable to create communications manager\n" );        }        /* For some reason we got a valid return value but an invalid          * communications manager; set an error code and complain:         */        else if ( *ospvCommOut == OSPC_OSNULL )        {            retVal = OSPC_ERR_COMM_NO_MEMORY;            OSPM_DBGERRORLOG(                 retVal,                 "The communications manager returned was invalid.\n" );        }    }    /* Now that the communications manager has been created, initialize     * its basic parameters. We'll use the CAUrl from the enrollment     * parameters as the service point:     */    if ( retVal == OSPC_ERR_NO_ERROR )    {

⌨️ 快捷键说明

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