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

📄 rasparams.c

📁 基于h323协议的软phone
💻 C
📖 第 1 页 / 共 4 页
字号:
            return RV_ERROR_UNKNOWN;
        case cmRASParamEmpty:
            /* Make sure we don't process this one - it's only here so we'll have a response... */
            return 0;
        default:
            /* Go on - we've got to look inside the PVT */
            break;
    }

    /* Make sure we're dealing with the right root by the stage we're looking for */
    switch (trStage)
    {
        case cmRASTrStageRequest:
            __pvtBuildByFieldIds(rootId, ras->hVal, txProperty, {_q931(request) _anyField LAST_TOKEN}, 0, NULL);
            break;
        case cmRASTrStageProgress:
            __pvtBuildByFieldIds(rootId, ras->hVal, txProperty, {_q931(progress) _anyField LAST_TOKEN}, 0, NULL);
            break;
        case cmRASTrStageConfirm:
        case cmRASTrStageReject:
            __pvtBuildByFieldIds(rootId, ras->hVal, txProperty, {_q931(response) _anyField LAST_TOKEN}, 0, NULL);
            break;
        default:
            RvLogError(&ras->log,
                     (&ras->log, "rasSetParam: Bad stage given to function (%d)", trStage));
            return RV_ERROR_UNKNOWN;
    }

    /* Get the field for the parameter we're dealing with */
    nodeId = pvtBuildByFieldIds(ras->hVal, rootId, rasGetParamPath(transactionType, param), 0, NULL);
    if (nodeId < 0)
    {
        RvLogWarning(&ras->log,
            (&ras->log, "rasSetParam: Bad path for parameter %s,%d in transaction 0x%p",
                 rasGetParamName(param), param, hsRas));
        return nodeId;
    }

    switch (param)
    {
        case cmRASParamRASAddress:
        case cmRASParamCallSignalAddress:
        case cmRASParamDestCallSignalAddress:
        case cmRASParamSrcCallSignalAddress:
        case cmRASParamReplyAddress:
        {
            int             synNodeId;
            pstNodeType     nodeType;

            /* See if it's a SEQUENCE OF or not */
            pvtGet(ras->hVal, nodeId, NULL, &synNodeId, NULL, NULL);
            nodeType = pstGetNodeType(ras->synProperty, synNodeId);
            if ((nodeType == pstSequenceOf) || (nodeType == pstSetOf))
            {
                /* We've got an index inside the SEQUENCE OF */
                nodeId = rasBuildElement(ras, nodeId, index);
            }
            else
            {
                /* Make sure the index is 0 */
                if (index != 0)
                    return RV_ERROR_UNKNOWN;
            }

            /* Convert the C struct to an address */
            return cmTAToVt(ras->hVal, nodeId, (cmTransportAddress *)svalue);
        }

        case cmRASParamEndpointID:
        case cmRASParamGatekeeperID:
        {
            cmAlias* alias;

            if (svalue == NULL) return RV_ERROR_UNKNOWN;
            alias = (cmAlias *)svalue;

            /* Make sure the index is 0 */
            if (index != 0) return RV_ERROR_UNKNOWN;

            iLen = alias->length;
            return pvtSet(ras->hVal, nodeId, -1, iLen, alias->string);
        }

        case cmRASParamDestInfo:
        case cmRASParamSrcInfo:
        case cmRASParamSourceInfo:
        case cmRASParamTerminalAlias:
        case cmRASParamEndpointAlias:
        case cmRASParamDestExtraCallInfo:
        case cmRASParamRejectedAlias:
        case cmRASParamInvalidTerminalAlias:
        case cmRASParamExtension:
        {
            cmAlias*    alias;
            int         synNodeId;
            pstNodeType nodeType;

            if (svalue == NULL) return RV_ERROR_UNKNOWN;
            alias = (cmAlias *)svalue;

            /* See if it's a SEQUENCE OF or not */
            pvtGet(ras->hVal, nodeId, NULL, &synNodeId, NULL, NULL);
            nodeType = pstGetNodeType(ras->synProperty, synNodeId);
            if ((nodeType == pstSequenceOf) || (nodeType == pstSetOf))
            {
                /* We've got an index inside the SEQUENCE OF */
                nodeId = rasBuildElement(ras, nodeId, index);
            }
            else
            {
                /* Make sure the index is 0 */
                if (index != 0)
                {
                    alias->length = 0;
                    return RV_ERROR_UNKNOWN;
                }
            }

            /* Convert the alias */
            return aliasToVt(ras->hVal, alias, nodeId);
        }

        case cmRASParamSupportsAltGk:
        case cmRASParamAdditiveRegistration:
        case cmRASParamSupportsAdditiveRegistration:
        case cmRASParamSegmentedResponseSupported:
        case cmRASParamCapacityInfoRequested:
            /* NULL OPTIONAL parameters - handled here */
            if (value == 0)
            {
                /* We actually need to remove this parameter... */
                return pvtDelete(ras->hVal, nodeId);
            }

            /* If we built it - it's fine */
            return 0;

        case cmRASParamBandwidth:
            /* We make sure the bandwidth parameter is divided by 100 */
            value /= 100;

        case cmRASParamIrrFrequency:
        case cmRASParamDiscoveryComplete:
        case cmRASParamActiveMC:
        case cmRASParamAnswerCall:
        case cmRASParamAnsweredCall:
        case cmRASParamCRV:
        case cmRASParamKeepAlive:
        case cmRASParamTimeToLive:
        case cmRASParamDelay:
        case cmRASParamAlmostOutOfResources:
        case cmRASParamAltGKisPermanent:
        case cmRASParamNeedResponse:
        case cmRASParamMaintainConnection:
        case cmRASParamMultipleCalls:
        case cmRASParamWillRespondToIRR:
        case cmRASParamNextSegmentRequested:
        case cmRASParamHopCount:
            /* Integer parameters - handled here */
            return pvtSet(ras->hVal, nodeId, -1, value, NULL);

        case cmRASParamCID:
        case cmRASParamCallID:
            /* Strings of 16 bytes length */
            return pvtSet(ras->hVal, nodeId, -1, 16, svalue);

        case cmRASParamEndpointVendor:
        {
            cmVendor* vendor;
            int tempId;
            int status;
            vendor = (cmVendor *)svalue;

            tempId = pvtAdd(ras->hVal, nodeId, __q931(vendor), 0, NULL, NULL);
            status = setNonStandard(ras->hVal, tempId, &vendor->info);

            if ((status >= 0) && (vendor->productLen > 0))
                status = pvtAdd(ras->hVal, nodeId, __q931(productId), vendor->productLen, vendor->productID, NULL);
            if ((status >= 0) && (vendor->versionLen > 0))
                status = pvtAdd(ras->hVal, nodeId, __q931(versionId), vendor->versionLen, vendor->versionID, NULL);
            return status;
        }

        case cmRASParamAltGKInfo:
        case cmRASParamAlternateGatekeeper:
            {
                int tempId;
                cmAlternateGatekeeper* altGk = (cmAlternateGatekeeper *)svalue;

                nodeId = rasBuildElement(ras, nodeId, index);

                tempId = pvtAdd(ras->hVal, nodeId, __q931(rasAddress), 0, NULL, NULL);
                status = cmTAToVt(ras->hVal, tempId, &altGk->rasAddress);

                if (status >= 0)
                {
                    tempId = pvtAdd(ras->hVal, nodeId, __q931(gatekeeperIdentifier), 0, NULL, NULL);
                    status = aliasToVt(ras->hVal, &altGk->gatekeeperIdentifier, tempId);
                }

                if (status >= 0)
                    status = pvtAdd(ras->hVal, nodeId, __q931(needToRegister), (RvInt32)altGk->needToRegister, NULL, NULL);
                if (status >= 0)
                {
                    int priority = altGk->priority;
                    status = pvtAdd(ras->hVal, nodeId, __q931(priority), priority, NULL, NULL);
                }
                return status;
            }

        case cmRASParamNonStandardData:
            /* NodeIDs replacing old ones */
            return pvtShiftTree(ras->hVal, nodeId, value);

        case cmRASParamNonStandard:
            return setNonStandardParam(ras->hVal, nodeId, (cmNonStandardParam *)svalue);

        case cmRASParamCallType:
        case cmRASParamCallModel:
        case cmRASParamDisengageReason:
        case cmRASParamRejectReason:
        case cmRASParamTransportQOS:
        case cmRASParamEndpointType:
        case cmRASParamTerminalType:
        case cmRASParamUnregReason:
            return pvtAdd(ras->hVal, nodeId,
                          getEnumNameId(rasGetParamEnumerationValues(param),
                                        rasGetParamEnumerationSize(param),
                                        (unsigned)value),
                          0, NULL, NULL);

        default:
            RvLogError(&ras->log,
                (&ras->log, "rasSetParam: Bad parameter %d", param));
            return RV_ERROR_UNKNOWN;
    }
}


/************************************************************************
 * rasGetNumOfParams
 * purpose: Returns the number of params in sequences on the property
 *          tree.
 * input  : ras     - RAS instance we're using
 *          hsRas   - Stack's handle for the RAS transaction
 *          trStage - The transaction stage the parameters
 *          param   - Type of the RAS parameter
 * output : none
 * return : Number of params in sequence on the property tree on success
 *          Negative value on failure
 ************************************************************************/
int rasGetNumOfParams(
    IN  rasModule*      ras,
    IN  HRAS            hsRas,
    IN  cmRASTrStage    trStage,
    IN  cmRASParam      param)
{
    int                 txType;
    rasInTx*            inTx = NULL;
    rasOutTx*           outTx = NULL;
    cmRASTransaction    transactionType;
    int                 rootId, txProperty, nodeId;
    pstNodeType         nodeType;
    int                 synNodeId;

    /* Get the right transaction type and the property database */
    txType = emaGetType((EMAElement)hsRas);
    switch (txType)
    {
        case RAS_OUT_TX:
        {
            outTx = rasGetOutgoing(hsRas);
            txProperty = outTx->txProperty;
            transactionType = outTx->transactionType;
            break;
        }
        case RAS_IN_TX:
        {
            inTx = rasGetIncoming(hsRas);
            txProperty = inTx->txProperty;
            transactionType = inTx->transactionType;
            break;
        }
        default:
            return RV_ERROR_UNKNOWN;
    }

    /* Make sure we're dealing with the right root by the stage we're looking for */
    switch (trStage)
    {
        case cmRASTrStageRequest:
            __pvtGetNodeIdByFieldIds(rootId, ras->hVal, txProperty, {_q931(request) _anyField LAST_TOKEN});
            break;
        case cmRASTrStageProgress:
            __pvtGetNodeIdByFieldIds(rootId, ras->hVal, txProperty, {_q931(progress) _anyField LAST_TOKEN});
            break;
        case cmRASTrStageConfirm:
        case cmRASTrStageReject:
            __pvtGetNodeIdByFieldIds(rootId, ras->hVal, txProperty, {_q931(response) _anyField LAST_TOKEN});
            break;
        default:
            RvLogError(&ras->log,
                (&ras->log, "rasGetNumOfParams: Bad stage given to function (%d)", trStage));
            return RV_ERROR_UNKNOWN;
    }

    /* Get the field for the parameter we're dealing with */
    nodeId = pvtGetByFieldIds(ras->hVal, rootId, rasGetParamPath(transactionType, param), NULL, NULL, NULL);
    if (nodeId < 0)
    {
        RvLogWarning(&ras->log,
            (&ras->log, "rasGetNumOfParams: Bad path for parameter %s,%d in transaction 0x%p",
                 rasGetParamName(param), param, hsRas));
        return nodeId;
    }

    /* Make sure this parameter is actually a SEQUENCE OF */
    pvtGet(ras->hVal, nodeId, NULL, &synNodeId, NULL, NULL);
    nodeType = pstGetNodeType(ras->synProperty, synNodeId);
    if ((nodeType == pstSequenceOf) || (nodeType == pstSetOf))
        return pvtNumChilds(ras->hVal, nodeId);

    RvLogError(&ras->log,
        (&ras->log, "rasGetNumOfParams: Parameter %s,%d is not an array type",
             rasGetParamName(param), param));
    return RV_ERROR_UNKNOWN;
}



#ifdef __cplusplus
}
#endif


⌨️ 快捷键说明

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