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

📄 transstates.c

📁 基于h323协议的软phone
💻 C
📖 第 1 页 / 共 5 页
字号:
            /* for parallel tunneling we insert it in a different place in the
               setup message than normal */
            if ( (session->parallelTunnelingState == parllOffered) && (msgType == cmQ931setup) )
            {

                __pvtBuildByFieldIds(node,
                                     transGlobals->hPvt,
                                     messageBodyNode,
                                    {   _q931(h323_message_body)
                                        _q931(setup)
                                        _q931(parallelH245Control)
                                        _nul(0)
                                        LAST_TOKEN
                                    },
                                    msgSize,
                                    (char *)&buffer[MSG_HEADER_SIZE + TPKT_HEADER_SIZE]);
            }
            else
            {
                __pvtBuildByFieldIds(node,
                                     transGlobals->hPvt,
                                     messageBodyNode,
                                    {   _q931(h245Control)
                                        _nul(0)
                                        LAST_TOKEN
                                    },
                                    msgSize,
                                    (char *)&buffer[MSG_HEADER_SIZE + TPKT_HEADER_SIZE]);
            }

            if (node < 0)
            {
                nextMsg = NULL;
                RvLogError(&transGlobals->hLog,
                    (&transGlobals->hLog, "insertH245TunneledMessages failed on inserting tunneled message (%d)",node));
            }
            else
            {
                /* if tunneling is established we need not keep this messgae */
                if (session->tunnelingState == tunnApproved)
                    nextMsg = extractMessageFromPool(transGlobals, session, RV_TRUE);
                else
                {
                    /* get the next message */
                    memcpy((void*)&nextMsg, &buffer[0], MSG_HEADER_SIZE);
                }
            }
        }

        /* after sending for the first time, we must wait to see if the other
           side supports tunneling */
        if (session->tunnelingState == tunnPossible)
            session->tunnelingState = tunnOffered;
    }
}

/**************************************************************************************
 * insertH450TunneledMessages
 *
 * putrpose: This routine fills the H.450 tunneled messages into the outgoing Q.931 message.
 *
 * Input: transGlobals      - The global data of the module.
 *        session           - the session on which the message is to be sent.
 *        msgBodyNode       - The messages UU-IE part.
 *        msgType           - The message type into which the tunneled messages are inserted
 *
 ***************************************************************************************/
void insertH450TunneledMessages(cmTransGlobals  *transGlobals,
                                cmTransSession  *session,
                                int             messageBodyNode,
                                int             msgType)
{
    int nodeId;
    RvBool isAlert = ((msgType == cmQ931alerting) || (msgType == cmQ931connect));

    if (RV_PVT_NODEID_IS_VALID(session->h450Element) ||
        (isAlert && RV_PVT_NODEID_IS_VALID(session->h450AlertElement)))
    {
        nodeId = pvtAdd(transGlobals->hPvt, messageBodyNode, __q931(h4501SupplementaryService), 0, NULL, NULL);

        if(!RV_PVT_NODEID_IS_VALID(nodeId))
        {
            RvLogError(&transGlobals->hLog,
                (&transGlobals->hLog, "insertH450TunneledMessages failed on inserting tunneled message (session=%d-%x)",
                emaGetIndex((EMAElement)session), session));
            return;
        }
    }
    else
        return;

    if (RV_PVT_NODEID_IS_VALID(session->h450Element))
    {
        pvtMoveTree(transGlobals->hPvt,nodeId, session->h450Element);
        session->h450Element = RV_PVT_INVALID_NODEID;
    }

    if (isAlert && RV_PVT_NODEID_IS_VALID(session->h450AlertElement))
    {
        pvtAddChilds(transGlobals->hPvt, nodeId, transGlobals->hPvt, session->h450AlertElement);
        pvtDelete(transGlobals->hPvt, session->h450AlertElement);
        session->h450AlertElement = RV_PVT_INVALID_NODEID;
    }
}


/**************************************************************************************
 * insertAnnexLTunneledMessages
 *
 * putrpose: This routine fills the annex L tunneled messages into the outgoing Q.931 message.
 *
 * Input: transGlobals      - The global data of the module.
 *        session           - the session on which the message is to be sent.
 *        msgBodyNode       - The messages UU-IE part.
 *
 ***************************************************************************************/
void insertAnnexLTunneledMessages(cmTransGlobals    *transGlobals,
                                  cmTransSession    *session,
                                  int               messageBodyNode)
{
    int nodeId;

    if (session->annexLElement >= 0)
    {
        nodeId = pvtAdd(transGlobals->hPvt, messageBodyNode, __q931(stimulusControl), 0, NULL, NULL);

        if (nodeId>=0)
        {
            pvtMoveTree(transGlobals->hPvt,nodeId, session->annexLElement);
            session->annexLElement = -1;
        }
        else
        {
            RvLogError(&transGlobals->hLog,
                (&transGlobals->hLog, "insertAnnexLTunneledMessages failed on inserting tunneled message (session=%d-%x)",
                    emaGetIndex((EMAElement)session), session));
        }
    }
}


/**************************************************************************************
 * insertAnnexMTunneledMessages
 *
 * putrpose: This routine fills the annex M tunneled messages into the outgoing Q.931 message.
 *
 * Input: transGlobals      - The global data of the module.
 *        session           - the session on which the message is to be sent.
 *        msgBodyNode       - The messages UU-IE part.
 *
 ***************************************************************************************/
void insertAnnexMTunneledMessages(cmTransGlobals    *transGlobals,
                                  cmTransSession    *session,
                                  int               messageBodyNode)
{
    int nodeId;

    if (session->annexMElement >= 0)
    {
        nodeId = pvtAdd(transGlobals->hPvt, messageBodyNode, __q931(tunnelledSignallingMessage), 0, NULL, NULL);

        if (nodeId>=0)
        {
            pvtMoveTree(transGlobals->hPvt,nodeId, session->annexMElement);
            session->annexMElement = -1;
        }
        else
        {
            RvLogError(&transGlobals->hLog,
                (&transGlobals->hLog, "insertAnnexMTunneledMessages failed on inserting tunneled message (session=%d-%x)",
                    emaGetIndex((EMAElement)session), session));
        }
    }
}


/**************************************************************************************
 * getMultiplexedParams
 *
 * putrpose: to get the multiplexed parameters from an incoming message. The parameters
 *           are taken from the message and set into the host parameters which are constatntly
 *           updated by the incoming messages and user API calls.
 *
 * Input: transGlobals - The global data of the module.
 *        host         - the host on which the message was received.
 *        pvtNode      - the message from which the parameters are to be get.
 *        msgType      - The type of the message.
 ***************************************************************************************/
void getMultiplexedParams(cmTransGlobals *transGlobals, cmTransHost *host, int pvtNode, int msgType)
{
    int res;
    RvBool value;
    RvBool supportsMultiplexing = RV_FALSE;
    RvBool oldSupportsMultiplexing = RV_FALSE;

    switch (msgType)
    {
        case cmQ931alerting:
        case cmQ931callProceeding:
        case cmQ931connect:
        case cmQ931setup:
        case cmQ931facility:
        case cmQ931progress:
        {
            if (host->annexEUsageMode == cmTransNoAnnexE)
            {
                /* we are interested in these parameters just for none annex E connections */
                if ( ((host->isMultiplexed) && (host->remoteIsMultiplexed)) ||
                     ((!host->closeOnNoSessions) && (!host->remoteCloseOnNoSessions)) )
                     oldSupportsMultiplexing = RV_TRUE;

                /* get the isMultiplexed element */
                __pvtGetByFieldIds(res, transGlobals->hPvt, pvtNode,
                                        { _q931(message)
                                          _anyField
                                          _q931(userUser)
                                          _q931(h323_UserInformation)
                                          _q931(h323_uu_pdu)
                                          _q931(h323_message_body)
                                          _anyField
                                          _q931(multipleCalls)
                                          LAST_TOKEN
                                        },
                                     NULL, (RvInt32 *)&value, NULL);
                if (res >= 0)
                    host->remoteIsMultiplexed = value;
                else
                    host->remoteIsMultiplexed = RV_FALSE;


                /* get the maintainConnection element */
                __pvtGetByFieldIds(res, transGlobals->hPvt, pvtNode,
                                        { _q931(message)
                                          _anyField
                                          _q931(userUser)
                                          _q931(h323_UserInformation)
                                          _q931(h323_uu_pdu)
                                          _q931(h323_message_body)
                                          _anyField
                                          _q931(maintainConnection)
                                          LAST_TOKEN
                                        },
                                     NULL, (RvInt32 *)&value, NULL);

                if (res >= 0)
                    host->remoteCloseOnNoSessions = !value;
                else
                    host->remoteCloseOnNoSessions = RV_TRUE;

                if ( ((host->isMultiplexed) && (host->remoteIsMultiplexed)) )/*||
                     ((!host->closeOnNoSessions) && (!host->remoteCloseOnNoSessions)) )*/
                     supportsMultiplexing = RV_TRUE;

                /* report if the multiplex state has changed */
                if (oldSupportsMultiplexing != supportsMultiplexing)
                {
                    HATRANSHOST haTransHost =
                                      (HATRANSHOST)emaGetApplicationHandle((EMAElement)host);

                    if (transGlobals->hostEventHandlers.cmEvTransHostMultiplexChangeState)
                    {
                        int numOfLocks;
                        RvLogInfo(&transGlobals->hLog,
                            (&transGlobals->hLog, "cmEvTransHostMultiplexChangeState(hsHost = %d(%x), haHost=%x, isMultiplex=%d",
                                emaGetIndex((EMAElement)host), host, haTransHost,supportsMultiplexing));

                        numOfLocks = emaPrepareForCallback((EMAElement)host);
                        (transGlobals->hostEventHandlers.cmEvTransHostMultiplexChangeState)(
                                                            (HSTRANSHOST) host,
                                                            haTransHost,
                                                            supportsMultiplexing);
                        emaReturnFromCallback((EMAElement)host, numOfLocks);
                    }
                }
            }
        }

        break;

        default:
            break;
    }
}

/**************************************************************************************
 * extractH245Messages
 *
 * putrpose: extracts, decodes and reports the tunneled H.245 messages from the given message.
 *
 * Input: transGlobals      - The global data of the module.
 *        session           - the session on which the message was received.
 *        host              - the host on which the message was received.

⌨️ 快捷键说明

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