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

📄 rasutils.c

📁 基于h323协议的软phone
💻 C
📖 第 1 页 / 共 3 页
字号:
/***********************************************************************
        Copyright (c) 2002 RADVISION Ltd.
************************************************************************
NOTICE:
This document contains information that is confidential and proprietary
to RADVISION Ltd.. No part of this document may be reproduced in any
form whatsoever without written prior approval by RADVISION Ltd..

RADVISION Ltd. reserve the right to revise this publication and make
changes without obligation to notify any person of such revisions or
changes.
***********************************************************************/

#include "psyntreeStackApi.h"
#include "pvaltreeStackApi.h"
#include "pvaltree.h"
#include "prnutils.h"
#include "cmutils.h"
#include "rasdef.h"
#include "rasin.h"
#include "rasout.h"
#include "rasirr.h"
#include "rasparams.h"
#include "rasutils.h"
#include "cmintr.h"
#include "msg.h"


#ifdef __cplusplus
extern "C" {
#endif



/************************************************************************
 * rasGetOutgoing
 * purpose: Get the outgoing RAS transaction from its handle
 * input  : hsRas   - Application handle
 * output : none
 * return : RAS outgoing transaction on success
 *          NULL on failure
 ************************************************************************/
#ifdef RV_RAS_DEBUG
rasOutTx* rasGetOutgoing(IN HRAS hsRas)
{
    rasOutTx*   tx;

    if (hsRas == NULL) return NULL;

    tx = (rasOutTx *)hsRas;

    /* Make sure the pointer is an outgoing transaction */
    if (emaGetType((EMAElement)hsRas) != RAS_OUT_TX)
    {
        RvLogSource * log;
        log = &((rasModule *)emaGetUserData((EMAElement)hsRas))->log;

        RvLogExcep(log,
            (log, "rasGetOutgoing: Not an outgoing transaction 0x%p", hsRas));
        return NULL;
    }

    return tx;
}
#endif  /* RV_RAS_DEBUG */



/************************************************************************
 * rasGetIncoming
 * purpose: Get the incoming RAS transaction from its handle
 * input  : hsRas   - Application handle
 * output : none
 * return : RAS incoming transaction on success
 *          NULL on failure
 ************************************************************************/
#ifdef RV_RAS_DEBUG
rasInTx* rasGetIncoming(IN HRAS hsRas)
{
    rasInTx*   tx;

    if (hsRas == NULL) return NULL;

    tx = (rasInTx *)hsRas;

    /* Make sure the pointer is an incoming transaction */
    if (emaGetType((EMAElement)hsRas) != RAS_IN_TX)
    {
        RvLogSource * log;
        log = &((rasModule *)emaGetUserData((EMAElement)hsRas))->log;

        RvLogExcep(log,
            (log, "rasGetIncoming: Not an incoming transaction 0x%p", hsRas));
        return NULL;
    }

    return tx;
}
#endif  /* RV_RAS_DEBUG */


#if (RV_LOGMASK_COMPILEMASK & RV_LOGLEVEL_ENTER)
/************************************************************************
 * rasGetParamName
 * purpose: Get the parameter's name
 * input  : param   - Parameter enumeration value
 * output : none
 * return : Parameter's name on success
 *          Empty string on failure
 ************************************************************************/
const char *rasGetParamName(IN cmRASParam param)
{
    switch(param)
    {
        case cmRASParamGatekeeperID:                 return "gatekeeperIdentifier";
        case cmRASParamRASAddress:                   return "rasAddress";
        case cmRASParamCallSignalAddress:            return "callSignalAddress";
        case cmRASParamEndpointType:                 return "endpointType";
        case cmRASParamTerminalType:                 return "terminalType";
        case cmRASParamEndpointAlias:                return "endpointAlias";
        case cmRASParamTerminalAlias:                return "terminalAlias";
        case cmRASParamDiscoveryComplete:            return "discoveryComplete";
        case cmRASParamEndpointVendor:               return "endpointVendor";
        case cmRASParamCallType:                     return "callType";
        case cmRASParamCallModel:                    return "callModel";
        case cmRASParamEndpointID:                   return "endpointIdentifier";
        case cmRASParamDestInfo:                     return "destinationInfo";
        case cmRASParamSrcInfo:                      return "srcInfo";
        case cmRASParamDestExtraCallInfo:            return "destExtraCallInfo";
        case cmRASParamDestCallSignalAddress:        return "destCallSignalAddress";
        case cmRASParamSrcCallSignalAddress:         return "srcCallSignalAddress";
        case cmRASParamBandwidth:                    return "bandWidth";
        case cmRASParamActiveMC:                     return "activeMC";
        case cmRASParamAnswerCall:                   return "answerCall";
        case cmRASParamIrrFrequency:                 return "irrFrequency";
        case cmRASParamReplyAddress:                 return "replyAddress";
        case cmRASParamDisengageReason:              return "disengageReason";
        case cmRASParamRejectedAlias:                return "rejectReason.duplicateAlias";
        case cmRASParamRejectReason:                 return "rejectReason";
        case cmRASParamCID:                          return "conferenceID";
        case cmRASParamDestinationIpAddress:         return "destinationIpAddress";
        case cmRASParamNonStandard:                  return "nonStandard";
        case cmRASParamNonStandardData:              return "nonStandardData";
        case cmRASParamCRV:                          return "callReferenceValue";
        case cmRASParamMulticastTransaction:         return "multicast";
        case cmRASParamTransportQOS:                 return "transportQOS";
        case cmRASParamKeepAlive:                    return "keepAlive";
        case cmRASParamTimeToLive:                   return "timeToLive";
        case cmRASParamDelay:                        return "delay";
        case cmRASParamCallID:                       return "callIdentifier.guid";
        case cmRASParamAnsweredCall:                 return "answeredCall";
        case cmRASParamAlmostOutOfResources:         return "almostOutOfResources";
        case cmRASParamAlternateGatekeeper:          return "alternateGatekeeper";
        case cmRASParamAltGKInfo:                    return "altGKInfo.alternateGatekeeper";
        case cmRASParamAltGKisPermanent:             return "altGKInfo.altGKisPermanent";
        case cmRASParamEmpty:                        return "empty";
        case cmRASParamSourceInfo:                   return "sourceInfo";
        case cmRASParamNeedResponse:                 return "needResponse";
        case cmRASParamMaintainConnection:           return "maintainConnection";
        case cmRASParamMultipleCalls:                return "multipleCalls";
        case cmRASParamWillRespondToIRR:             return "willRespondToIRR";
        case cmRASParamSupportsAltGk:                return "supportsAltGk";
        case cmRASParamAdditiveRegistration:         return "additiveRegistration";
        case cmRASParamSupportsAdditiveRegistration: return "supportsAdditiveRegistration";
        case cmRASParamSegmentedResponseSupported:   return "segmentedResponseSupported";
        case cmRASParamNextSegmentRequested:         return "nextSegmentRequested";
        case cmRASParamCapacityInfoRequested:        return "capacityInfoRequested";
        case cmRASParamHopCount:                     return "hopCount";
        case cmRASParamInvalidTerminalAlias:         return "invalidTerminalAlias";
        case cmRASParamUnregReason:                  return "unregReason";
        case cmRASParamIrrStatus:                    return "irrStatus";
        case cmRASParamCallHandle:                   return "callHandle";
        case cmRASParamExtension:                    return "extension";
        default:                                     break;
    }

    return "*ERROR*";
}
#endif  /* (RV_LOGMASK_COMPILEMASK & RV_LOGLEVEL_ENTER) */


/************************************************************************
 * rasCfgGetTimeout
 * purpose: Get the timeout of a transaction before a retry is sent from
 *          the configuration
 * input  : ras     - RAS instance handle
 * output : none
 * return : Timeout in seconds
 ************************************************************************/
int rasCfgGetTimeout(IN rasModule* ras)
{
    int nodeId, status;
    RvInt32 timeout;

    /* Check in the configuration */
    nodeId = pvtGetChild(ras->hVal, ras->confNode, __q931(responseTimeOut), NULL);
    status = pvtGet(ras->hVal, nodeId, NULL, NULL, &timeout, NULL);

    if (status >= 0)
        return timeout;
    else
        return 4; /* Default of 4 seconds */
}


/************************************************************************
 * rasCfgGetRetries
 * purpose: Get the number of retries for a transaction before a timeout
 *          from the configuration
 * input  : ras     - RAS instance handle
 * output : none
 * return : Number of retries
 ************************************************************************/
int rasCfgGetRetries(IN rasModule* ras)
{
    int nodeId, status;
    RvInt32 retries;

    /* Set the number of retries */
    nodeId = pvtGetChild(ras->hVal, ras->confNode, __q931(maxRetries), NULL);
    status = pvtGet(ras->hVal, nodeId, NULL, NULL, &retries, NULL);

    if (status >= 0)
    {
        if (retries > 0)
            return retries;
        RvLogExcep(&ras->log, 
            (&ras->log, "Invalid number of RAS.maxRetries in Stack configuration: %d. using 3.", retries));
    }
    return 3; /* 3 retries on default */
}


/************************************************************************
 * rasRetransmit
 * purpose: Retransmit a message to the other side
 *          This function is used for both requests and responses.
 * input  : ras         - RAS instance handle
 *          rasTx       - RAS transaction of the message
 *          rpootMsg    - RPOOL message handle to retransmit
 *          destAddr    - Destination address
 *          typeStr     - Type of retransmission
 * output : none
 * return : Non-negative value on success
 *          Negative value on failure
 ************************************************************************/
int rasRetransmit(
    IN  rasModule*          ras,
    IN  HRAS                rasTx,
    IN  HRPOOLELEM          rpoolMsg,
    IN  cmTransportAddress* destAddr,
    IN  const char*         typeStr)
{
    int messageSize, status;
    RvUint8* buffer;
    if (rasTx || typeStr);

    RvLogDebug(&ras->log,
        (&ras->log, "rasRetransmit: Retransmitting %s on 0x%p", typeStr, rasTx));

    getEncodeDecodeBuffer((int)ras->bufferSize, &buffer);

    /* Get message from RPOOL to a single buffer */
    messageSize = rpoolChunkSize(ras->messages, rpoolMsg);
    rpoolCopyToExternal(ras->messages, buffer, rpoolMsg, 0, messageSize);

    /* Send the message. We always send through the unicast port */
    status = ras->evSendMessage(ras->app, rasChanUnicast, destAddr, buffer, (RvSize_t)messageSize);
    if (status < 0)
    {
        RvLogError(&ras->log,
            (&ras->log, "rasRetransmit: Couldn't send the message 0x%p: %d", rasTx, status));
    }

    return status;
}


/************************************************************************
 * rasEncodeAndSend
 * purpose: Encode and send a message on the net
 * input  : ras         - RAS instance handle
 *          rasTx       - RAS transaction of the message
 *          stage       - Stage of the RAS transaction
 *          nodeId      - nodeId of the message to send out
 *          isMulticast - Are we sending it to a multicast address
 *          destAddr    - Destination address
 *          storeInRPOOL- Indicate if we want the message to be stored in RPOOL
 * output : rpoolHandle - RPOOL handle storing the message
 * return : Non-negative value on success
 *          Negative value on failure
 ************************************************************************/
int rasEncodeAndSend(
    IN  rasModule*          ras,
    IN  HRAS                rasTx,
    IN  cmRASTrStage        stage,
    IN  int                 nodeId,
    IN  RvBool              isMulticast,
    IN  cmTransportAddress* destAddr,
    IN  RvBool              storeInRPOOL,
    OUT HRPOOLELEM*         rpoolHandle)

⌨️ 快捷键说明

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