📄 rasparams.c
字号:
* input : param - Parameter enumeration value
* output : none
* return : Pointer to the enumeration's field IDs on success
* NULL on failure
************************************************************************/
fieldNames* rasGetParamEnumerationValues(IN cmRASParam param)
{
switch (param)
{
case cmRASParamTerminalType:
case cmRASParamEndpointType: return rasEndpointTypes;
case cmRASParamCallType: return rasCallTypes;
case cmRASParamCallModel: return rasCallModels;
case cmRASParamDisengageReason: return rasDisengageReasons;
case cmRASParamRejectReason: return rasRejectReasons;
case cmParamConferenceGoal: return rasConferenceGoals;
case cmParamReleaseCompleteReason:
case cmParamFacilityReason: return rasReasons;
case cmRASParamTransportQOS: return rasTransportQOSs;
case cmRASParamUnregReason: return rasUnregReasons;
default: return NULL;
}
}
/************************************************************************
* rasGetParamEnumerationSize
* purpose: Get the size of the list of enumeration values.
* input : param - Parameter enumeration value
* output : none
* return : Number of values in list
************************************************************************/
int rasGetParamEnumerationSize(IN cmRASParam param)
{
switch(param)
{
case cmRASParamTerminalType:
case cmRASParamEndpointType: return sizeof(rasEndpointTypes);
case cmRASParamCallType: return sizeof(rasCallTypes);
case cmRASParamCallModel: return sizeof(rasCallModels);
case cmRASParamDisengageReason: return sizeof(rasDisengageReasons);
case cmRASParamRejectReason: return sizeof(rasRejectReasons);
case cmParamConferenceGoal: return sizeof(rasConferenceGoals);
case cmParamReleaseCompleteReason:
case cmParamFacilityReason: return sizeof(rasReasons);
case cmRASParamTransportQOS: return sizeof(rasTransportQOSs);
case cmRASParamUnregReason: return sizeof(rasUnregReasons);
default: return RV_ERROR_UNKNOWN;
}
}
/************************************************************************
* rasBuildElement
* purpose: Set a node inside a SEQUENCE OF. This function will return
* the nodeId of the existing index, or build a new one if the
* index given is just after the last one.
* input : ras - RAS instance used
* nodeId - Node ID of the SEQUENCE OF
* index - Index value to build (0-based)
* output : none
* return : Node ID created on success
* Negative-value on failure
************************************************************************/
int rasBuildElement(
IN rasModule* ras,
IN int nodeId,
IN int index)
{
int tempId;
/* Make sure index is within range */
if (index > pvtNumChilds(ras->hVal, nodeId))
{
RvLogError(&ras->log,
(&ras->log, "rasBuildElement: Index %d out of range", index));
return RV_ERROR_UNKNOWN;
}
if (index >= 0)
{
/* See if it exists */
tempId = pvtGetByIndex(ras->hVal, nodeId, index+1, NULL);
}
else
{
/* We must be able to handle negative index values to support the
way the gatekeeper adds his parameters...
This means that we aloways add it in a negative value case. */
tempId = -1;
}
if (tempId < 0)
{
/* Element doesn't exist - create is as the last element */
if ((tempId=pvtAdd(ras->hVal, nodeId, RV_ERROR_UNKNOWN, 0, NULL, NULL)) <0)
return RV_ERROR_UNKNOWN;
}
return tempId;
}
/************************************************************************
*
* Public functions
*
************************************************************************/
/************************************************************************
* rasGetParam
* purpose: Get a parameter about the RAS transaction
* 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
* index - If the parameter has several instances, the index
* that identifies the specific instance (1-based).
* 0 otherwise.
* value - If the parameter value is a structure, the value
* represents the length of the parameter.
* output : value - For a simple integer - the parameter's value.
* For a structure - the length of the parameter.
* svalue - For a structure - svalue represents the parameter
* itself. Can be set to NULL if we're only interested
* in its length.
* return : If an error occurs, the function returns a negative value.
* If no error occurs, the function returns a non-negative value.
************************************************************************/
int rasGetParam(
IN rasModule* ras,
IN HRAS hsRas,
IN cmRASTrStage trStage,
IN cmRASParam param,
IN int index,
IN OUT RvInt32* value,
IN char* svalue)
{
int txType;
rasInTx* inTx = NULL;
rasOutTx* outTx = NULL;
cmRASTransaction transactionType;
int rootId, txProperty, nodeId;
int status;
/* 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;
}
/* First, we check parameters that are not in the PVT */
switch (param)
{
case cmRASParamDestinationIpAddress:
if (txType == RAS_OUT_TX)
memcpy(svalue, &outTx->destAddress, sizeof(cmRASTransport));
else
memcpy(svalue, &inTx->destAddress, sizeof(cmRASTransport));
return 0;
case cmRASParamMulticastTransaction:
if (value != NULL)
{
if (txType == RAS_OUT_TX)
*value = outTx->isMulticast;
else
*value = inTx->isMulticast;
}
return 0;
case cmRASParamCallHandle:
if (svalue != NULL)
{
if (txType == RAS_OUT_TX)
memcpy(svalue, &outTx->hsCall, sizeof(outTx->hsCall));
else
memcpy(svalue, &inTx->hsCall, sizeof(inTx->hsCall));
}
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:
__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, "rasGetParam: 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);
/* We check the NULL OPTIONAL parameters here, since there's reason to do it
before we know if the node we're holding is valid */
switch (param)
{
case cmRASParamSupportsAltGk:
case cmRASParamAdditiveRegistration:
case cmRASParamSupportsAdditiveRegistration:
case cmRASParamSegmentedResponseSupported:
case cmRASParamCapacityInfoRequested:
/* NULL OPTIONAL parameters - handled here */
/* 0 - if node doesn't exist
1 - if node exists */
*value = (nodeId >= 0);
return 0;
default:
break;
}
/* Make sure we've got a valid node */
if (nodeId < 0)
{
switch (param)
{
case cmRASParamDestInfo:
case cmRASParamSrcInfo:
case cmRASParamSourceInfo:
case cmRASParamTerminalAlias:
case cmRASParamEndpointAlias:
case cmRASParamDestExtraCallInfo:
case cmRASParamRejectedAlias:
case cmRASParamInvalidTerminalAlias:
case cmRASParamExtension:
case cmRASParamEndpointID:
case cmRASParamGatekeeperID:
/* In case we're looking for an alias, we notify the application that
the length is 0 if we couldn't find it - the GK won't be able to
work properly without it... */
if (svalue != NULL)
((cmAlias *)svalue)->length = 0;
break;
case cmRASParamRASAddress:
case cmRASParamCallSignalAddress:
case cmRASParamDestCallSignalAddress:
case cmRASParamSrcCallSignalAddress:
case cmRASParamReplyAddress:
/* Well, it seems like the GK and other applications just like getting their
error values with the parameters blanked out, so we had to add this memset()
over here - especially for them... */
if (svalue != NULL)
memset(svalue, 0, sizeof(cmTransportAddress));
break;
default:
break;
}
RvLogWarning(&ras->log,
(&ras->log, "rasGetParam: Bad path for parameter %s,%d in transaction 0x%p",
rasGetParamName(param), param, hsRas));
return nodeId;
}
/* Check the parameter's value */
switch (param)
{
case cmRASParamRASAddress:
case cmRASParamCallSignalAddress:
case cmRASParamDestCallSignalAddress:
case cmRASParamSrcCallSignalAddress:
case cmRASParamReplyAddress:
{
cmRASTransport* addr;
int synNodeId;
pstNodeType nodeType;
if (svalue == NULL) return RV_ERROR_UNKNOWN;
addr = (cmRASTransport *)svalue;
memset(addr, 0, sizeof(cmRASTransport));
/* 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))
nodeId = pvtGetByIndex(ras->hVal, nodeId, index + 1, NULL);
else
{
/* Make sure the index is 0 */
if (index != 0)
return RV_ERROR_UNKNOWN;
}
/* Convert the address to a C struct */
if (value) *value = sizeof(cmRASTransport);
return cmVtToTA(ras->hVal, nodeId, addr);
}
case cmRASParamEndpointID:
case cmRASParamGatekeeperID:
{
cmAlias* alias;
RvInt32 length = 0;
if (svalue == NULL) return RV_ERROR_UNKNOWN;
alias = (cmAlias *)svalue;
if (index != 0)
{
alias->length = 0;
return RV_ERROR_UNKNOWN;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -