📄 rasparams.c
字号:
if (pvtGet(ras->hVal, nodeId, NULL, NULL, &length, NULL) < 0)
{
alias->length = 0;
return RV_ERROR_UNKNOWN;
}
alias->length = (RvUint16)length;
pvtGetString(ras->hVal, nodeId, length, alias->string);
if (param == cmRASParamEndpointID)
alias->type = cmAliasTypeEndpointID;
else
alias->type = cmAliasTypeGatekeeperID;
if (value) *value = sizeof(cmAlias);
return 0;
}
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))
nodeId = pvtGetByIndex(ras->hVal, nodeId, index + 1, NULL);
else
{
/* Make sure the index is 0 */
if (index != 0)
{
alias->length = 0;
return RV_ERROR_UNKNOWN;
}
}
/* Convert the alias */
if (nodeId >= 0)
return vtToAlias(ras->hVal, alias, nodeId);
if (value) *value = sizeof(cmAlias);
return RV_ERROR_UNKNOWN;
}
case cmRASParamIrrFrequency:
case cmRASParamDiscoveryComplete:
case cmRASParamActiveMC:
case cmRASParamAnswerCall:
case cmRASParamAnsweredCall:
case cmRASParamBandwidth:
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 */
if ((pvtGet(ras->hVal, nodeId, NULL, NULL, value, NULL) >= 0) && (index == 0))
{
if (param == cmRASParamBandwidth)
(*value) *= 100;
return 0;
}
return RV_ERROR_UNKNOWN;
case cmRASParamCID:
case cmRASParamCallID:
/* Strings of 16 bytes length */
if (svalue == NULL) return RV_ERROR_UNKNOWN;
if ((pvtGetString(ras->hVal, nodeId, 16, svalue) >= 0) && (index == 0))
return 0;
memset(svalue, 0, 16);
return RV_ERROR_UNKNOWN;
case cmRASParamEndpointVendor:
{
cmVendor* vendor;
RvInt32 length = 0;
int tempId;
if ((svalue == NULL) || (index != 0)) return RV_ERROR_UNKNOWN;
vendor = (cmVendor *)svalue;
/* Get vendor information */
tempId = pvtGetChild(ras->hVal, nodeId, __q931(vendor), NULL);
memset(vendor, 0, sizeof(cmVendor));
getNonStandard(ras->hVal, tempId, &vendor->info);
tempId = pvtGetChildByFieldId(ras->hVal, nodeId, __q931(productId), &length, NULL);
if (tempId >= 0)
{
pvtGetString(ras->hVal, tempId, sizeof(vendor->productID), vendor->productID);
vendor->productLen = (int)length;
}
tempId = pvtGetChildByFieldId(ras->hVal, nodeId, __q931(versionId), &length, NULL);
if (tempId >= 0)
{
pvtGetString(ras->hVal, tempId, sizeof(vendor->versionID), vendor->versionID);
vendor->versionLen = (int)length;
}
return 0;
}
case cmRASParamAltGKInfo:
case cmRASParamAlternateGatekeeper:
{
cmAlternateGatekeeper* altGk;
int tempId;
RvInt32 length = 0;
if (svalue == NULL) return RV_ERROR_UNKNOWN;
altGk = (cmAlternateGatekeeper *)svalue;
/* Make sure we pass the SEQUENCE OF */
nodeId = pvtGetByIndex(ras->hVal, nodeId, index + 1, NULL);
/* Build the struct */
tempId = pvtGetChild(ras->hVal, nodeId, __q931(rasAddress), NULL);
if (tempId >= 0)
status = cmVtToTA(ras->hVal, tempId, &altGk->rasAddress);
else
return RV_ERROR_UNKNOWN;
altGk->gatekeeperIdentifier.length = 0;
tempId = pvtGetChild(ras->hVal, nodeId, __q931(gatekeeperIdentifier), NULL);
if (tempId >= 0)
{
if (pvtGet(ras->hVal, tempId, NULL, NULL, &length, NULL) < 0) return RV_ERROR_UNKNOWN;
pvtGetString(ras->hVal, tempId, length, altGk->gatekeeperIdentifier.string);
altGk->gatekeeperIdentifier.length = (RvUint16)length;
}
__pvtGetByFieldIds(status, ras->hVal, nodeId,
{_q931(needToRegister) LAST_TOKEN}, NULL, &length, NULL);
altGk->needToRegister = (RvBool)length;
__pvtGetByFieldIds(status, ras->hVal, nodeId,
{_q931(priority) LAST_TOKEN}, NULL, &length, NULL);
altGk->priority = (RvUint8)length;
if (value) *value = sizeof(cmAlternateGatekeeper);
return status;
}
case cmRASParamNonStandardData:
/* Return the nodeId's value */
if (index != 0) return RV_ERROR_UNKNOWN;
*value = nodeId;
return 0;
case cmRASParamNonStandard:
if ((svalue == NULL) || (index != 0)) return RV_ERROR_UNKNOWN;
if (value) *value = sizeof(cmNonStandardParam);
return getNonStandardParam(ras->hVal, nodeId, (cmNonStandardParam*)svalue);
case cmRASParamCallType:
case cmRASParamCallModel:
case cmRASParamDisengageReason:
case cmRASParamRejectReason:
case cmRASParamTransportQOS:
case cmRASParamUnregReason:
{
/* Enumerations are handled here */
RvPstFieldId fieldId;
if ((pvtGet(ras->hVal, pvtChild(ras->hVal, nodeId), &fieldId, NULL, NULL, NULL) >= 0) && (index == 0))
{
/* Match the fieldId with the possible ones and set the value */
*value = getEnumValueByNameId(rasGetParamEnumerationValues(param), fieldId);
return 0;
}
*value = RV_ERROR_UNKNOWN;
return RV_ERROR_UNKNOWN;
}
case cmRASParamTerminalType:
case cmRASParamEndpointType:
{
/* Terminal type - we check each of the values.
* The first one we find is the right one - except for Gateway.
*/
fieldNames* names;
int i;
*value = RV_ERROR_UNKNOWN;
names = rasGetParamEnumerationValues(param);
for(i = 0; names[i].nameId != LAST_TOKEN; i++)
if (pvtGetChild(ras->hVal, nodeId, names[i].nameId, NULL) >= 0)
{
*value = i;
if (i == cmEndpointTypeGateway) continue;
return 0;
}
if (*value == RV_ERROR_UNKNOWN)
return RV_ERROR_UNKNOWN;
return 0;
}
default:
RvLogError(&ras->log,
(&ras->log, "rasGetParam: Bad parameter %d", param));
return RV_ERROR_UNKNOWN;
}
}
/************************************************************************
* rasSetParam
* 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 - 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.
* return : If an error occurs, the function returns a negative value.
* If no error occurs, the function returns a non-negative value.
************************************************************************/
int rasSetParam(
IN rasModule* ras,
IN HRAS hsRas,
IN cmRASTrStage trStage,
IN cmRASParam param,
IN int index,
IN RvInt32 value,
IN char* svalue)
{
int txType;
rasInTx* inTx = NULL;
rasOutTx* outTx = NULL;
cmRASTransaction transactionType;
int rootId, txProperty, nodeId;
int status;
int iLen;
/* 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;
/* Build a response if one doesn't already exist */
if ((inTx->responseSet == rasNoResponseSet) && (trStage != cmRASTrStageRequest))
{
int responseNodeId;
responseNodeId = pvtAdd(ras->hVal, txProperty, __q931(response), 0, NULL, NULL);
pvtSetTree(ras->hVal, responseNodeId, ras->hVal, ras->defaultMessages[inTx->transactionType][trStage]);
switch(trStage)
{
case (cmRASTrStageConfirm) : inTx->responseSet = rasConfirmSet; break;
case (cmRASTrStageReject) : inTx->responseSet = rasRejectSet; break;
default : break;
}
}
else if( ((trStage == cmRASTrStageConfirm) && (inTx->responseSet == rasRejectSet)) ||
((trStage == cmRASTrStageReject) && (inTx->responseSet == rasConfirmSet)) )
{
int responseNodeId;
pvtGetChild(ras->hVal, txProperty, __q931(response), &responseNodeId);
pvtSetTree(ras->hVal, responseNodeId, ras->hVal, ras->defaultMessages[inTx->transactionType][trStage]);
switch(trStage)
{
case (cmRASTrStageConfirm) : inTx->responseSet = rasConfirmSet; break;
case (cmRASTrStageReject) : inTx->responseSet = rasRejectSet; break;
default : break;
}
}
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(&outTx->destAddress, svalue, sizeof(cmRASTransport));
else
memcpy(&inTx->destAddress, svalue, sizeof(cmRASTransport));
return 0;
case cmRASParamMulticastTransaction:
if (txType == RAS_OUT_TX)
{
outTx->isMulticast = value;
if (outTx->isMulticast)
{
/* Set the address as the one we recognize as the multicast address */
int srcNodeId;
srcNodeId = pvtGetChild(ras->hVal, ras->confNode, __q931(rasMulticastAddress), NULL);
cmVtToTA(ras->hVal, srcNodeId, &outTx->destAddress);
}
}
else
inTx->isMulticast = value;
return 0;
case cmRASParamCallHandle:
RvLogError(&ras->log,
(&ras->log, "rasSetParam: cmRASParamCallHandle is read only"));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -