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

📄 transport.c

📁 基于h323协议的软phone
💻 C
📖 第 1 页 / 共 5 页
字号:
 * Output:  value           - An integer or pointer which is the value of the parameter.
 *
 **************************************************************************************/
TRANSERR cmTransGetSessionParam(IN  HSTRANSSESSION      hsTransSession,
                                IN  TRANSSESSIONPARAM   param,
                                OUT void                *value)
{
    cmTransSession *session = (cmTransSession *)hsTransSession;

    if (emaLock((EMAElement)session))
    {
        switch (param)
        {
            case cmTransParam_host:
                {
                    cmTransHost *host;

                    if (session->annexEUsageMode != cmTransNoAnnexE)
                        host = session->annexEConnection;
                    else
                        host = session->Q931Connection;

                    /* lock the host */
                    if (host)
                    {
                        if (emaLock((EMAElement)host))
                        {
                            *(cmTransHost **)value = host;
                            emaUnlock((EMAElement)host);
                        }
                    }
                }
                break;

            case cmTransParam_H245Connection:
                {
                    *(cmTransHost **)value = session->H245Connection;
                }
                break;

            case cmTransParam_isTunnelingSupported:
                {
                    if (session->tunnelingState == tunnRejected)
                    {
                        /* Tunneling was rejected - no way we're going to
                           have a tunneled call here */
                        *(RvBool *)value = RV_FALSE;
                    }
                    else
                    {
                        /* We're not sure if we're going tunneled or not, so we're just
                           assuming the user will be happy to know what his side is
                           doing. */
                        *(RvBool *)value = session->isTunnelingSupported;
                    }
                }
                break;

            case cmTransParam_notEstablishControl:
                {
                    *(RvBool *)value = session->notEstablishControl;
                }
                break;

            case cmTransParam_H245Stage:
                {
                    *(cmH245Stage *)value = session->h245Stage;
                }
                break;

            case cmTransParam_isParallelTunnelingSupported:
                {
                    *(RvBool *)value = session->isParallelTunnelingSupported;
                }
                break;

            case cmTransParam_shutdownEmptyConnection:
                {
                    *(RvBool *)value = session->closeOnNoSessions;
                }
                break;

            case cmTransParam_isMultiplexed:
                {
                    *(RvBool *)value = session->isMultiplexed;
                }
                break;

            case cmTransParam_isAnnexESupported:
                {
                    *(RvBool *)value = session->annexEUsageMode;
                }
                break;
        }

        /* release the lock on the session */
        emaUnlock((EMAElement)session);
        return cmTransOK;
    }

    return cmTransErr;
}

/**************************************************************************************
 * cmTransSetHostParam
 *
 * Purpose: Sets a specific parameter for the given host element.
 *
 * Input:   hsTranHost  - An handle to the host element
 *          param       - The name of the parameter to be set.
 *          value       - An integer or pointer to set as the new parameter.
 *          force       - In case of multiplexing parameters force the sending of FACILITY
 *                        to the remote with the new parameters.
 *
 * Output:  None.
 *
 **************************************************************************************/
TRANSERR cmTransSetHostParam(   IN HSTRANSHOST          hsTransHost,
                                IN TRANSHOSTPARAM       param,
                                IN void                 *value,
                                IN RvBool               force)
{
    cmTransHost     *host = (cmTransHost *)hsTransHost;
    cmTransGlobals  *transGlobals;
    TRANSERR res = cmTransOK;

    if (emaLock((EMAElement)host))
    {
        switch (param)
        {
            case cmTransHostParam_shutdownEmptyConnection:
                {
                    transGlobals = (cmTransGlobals *)emaGetUserData((EMAElement)hsTransHost);

                    host->closeOnNoSessions = *(RvBool *)value;

                    /* if we have a connected host, which is TPKT and we are
                       forced to send a facility about the change, do it */
                    if ( ( (host->state == hostConnected) || (host->state == hostBusy) ) &&
                         (force) &&
                         (host->annexEUsageMode == cmTransNoAnnexE) )
                        sendGeneralFacility(transGlobals, host);
                }
                break;

            case cmTransHostParam_isMultiplexed:
                {
                    transGlobals = (cmTransGlobals *)emaGetUserData((EMAElement)hsTransHost);

                    host->isMultiplexed = *(RvBool *)value;
                    /* if we have a connected host, which is TPKT and we are
                       forced to send a facility about the change, do it */
                    if ( ( (host->state == hostConnected) || (host->state == hostBusy) ) &&
                         (force) &&
                         (host->annexEUsageMode == cmTransNoAnnexE) )
                        sendGeneralFacility(transGlobals, host);
                }
                break;

            case cmTransHostParam_remoteAddress:
                {
                    if (setRemoteAddress((cmTransHost *)hsTransHost,
                                         (cmTransportAddress *)value) == cmTransErr)
                    {
                        transGlobals = (cmTransGlobals *)emaGetUserData((EMAElement)hsTransHost);

                        emaUnlock((EMAElement)host);
                        RvLogError(&transGlobals->hLog,
                            (&transGlobals->hLog,
                                "cmTransSetHostParam failed on updating hosts hash table"));
                        return cmTransErr;
                    }
                }
                break;

            case cmTransHostParam_localAddress:
                {
                    memcpy( (void *)&(host->localAddress),
                            value,
                            sizeof(cmTransportAddress));
                }
                break;

            case cmTransHostParam_isAnnexESupported:
                {
                    host->annexEUsageMode = *(cmAnnexEUsageMode *)value;
                }
                break;

            case cmTransHostParam_socketConnection:
                {
                    res = RV_ERROR_NOTSUPPORTED;
                }
                break;
        }

        emaUnlock((EMAElement)host);
        return res;
    }

    return cmTransErr;
}

/**************************************************************************************
 * cmTransGetHostParam
 *
 * Purpose: Gets a specific parameter from a given host element.
 *
 * Input:   hsTranHost  - An handle to the host element
 *          param       - The name of the parameter to get.
 *
 * Output:  value       - An integer or pointer which is the value of the parameter.
 *
 **************************************************************************************/
TRANSERR cmTransGetHostParam(   IN  HSTRANSHOST     hsTransHost,
                                IN  TRANSHOSTPARAM  param,
                                OUT void            *value)
{
    cmTransHost *host = (cmTransHost *)hsTransHost;

    if (emaLock((EMAElement)host))
    {
        switch (param)
        {
            case cmTransHostParam_shutdownEmptyConnection:
                {
                    *(RvBool *)value = host->closeOnNoSessions;
                }
                break;

            case cmTransHostParam_isMultiplexed:
                {
                    *(RvBool *)value = host->isMultiplexed;
                }
                break;

            case cmTransHostParam_remoteAddress:
                {
                    memcpy( value,
                            (void *)&(host->remoteAddress),
                            sizeof(cmTransportAddress));
                }
                break;

            case cmTransHostParam_localAddress:
                {
                    memcpy( value,
                            (void *)&(host->localAddress),
                            sizeof(cmTransportAddress));
                }
                break;

            case cmTransHostParam_isAnnexESupported:
                {
                    *(RvBool *)value = host->annexEUsageMode;
                }
                break;

            case cmTransHostParam_socketConnection:
                {
                    *(RvH323Connection **)value = tpktGetConnection(host->hTpkt);
                }
                break;
        }

        emaUnlock((EMAElement)host);
        return cmTransOK;
    }

    return cmTransErr;
}

/**************************************************************************************
 * cmTransSetSessionEventHandler
 *
 * Purpose: Sets the event handlers' pointers for session related callbacks
 *
 * Input:   hAppTrans           - A handle to the entire transport module
 *          transSessionEvents  - A structure with the pointers to the callbacks
 *          size                - The size of that structure.
 *
 * Output:  None.
 *
 **************************************************************************************/
TRANSERR cmTransSetSessionEventHandler( IN HAPPTRANS            hAppTrans,
                                        IN TRANSSESSIONEVENTS   *transSessionEvents,
                                        IN int                  size)
{
    cmTransGlobals *transGlobals = (cmTransGlobals *)hAppTrans;

    /* lock the entire module before intalling the handlers */
    RvMutexLock(&transGlobals->lockSessionsList);
    memcpy((void *)&(transGlobals->sessionEventHandlers),
           (void *)transSessionEvents,
           size);
    RvMutexUnlock(&transGlobals->lockSessionsList);

    return cmTransOK;
}

/**************************************************************************************
 * cmTransGetSessionEventHandler
 *
 * Purpose: Gets the event handlers' pointers for session related callbacks
 *
 * Input:   hAppTrans           - A handle to the entire transport module
 *          size                - The size of the given structure.
 *
 * Output:  transSessionEvents  - A structure with the pointers to the callbacks
 *
 **************************************************************************************/
TRANSERR cmTransGetSessionEventHandler( IN  HAPPTRANS           hAppTrans,
                                        OUT TRANSSESSIONEVENTS  *transSessionEvents,
                                        IN  int                 size)
{
    cmTransGlobals *transGlobals = (cmTransGlobals *)hAppTrans;

    /* lock the entire module before getting the handlers */
    RvMutexLock(&transGlobals->lockSessionsList);
    memcpy( (void *)transSessionEvents,
            (void *)&(transGlobals->sessionEventHandlers),
            size);
    RvMutexUnlock(&transGlobals->lockSessionsList);

    return cmTransOK;
}

/**************************************************************************************
 * cmTransSetHostEventHandler
 *
 * Purpose: Sets the event handlers' pointers for host related callbacks
 *
 * Input:   hAppTrans       - A handle to the entire transport module
 *          transHostEvents - A structure with the pointers to the callbacks
 *          size            - The size of that structure.
 *
 * Output:  None.
 *
 **************************************************************************************/
TRANSERR cmTransSetHostEventHandler(    IN HAPPTRANS        hAppTrans,
                                        IN TRANSHOSTEVENTS  *transHostEvents,

⌨️ 快捷键说明

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