📄 cmiras.c
字号:
__pvtGetNodeIdByFieldIds(destNodeId, ras->hVal, ras->defaultMessages[cmRASGatekeeper][cmRASTrStageRequest], {_anyField _q931(gatekeeperIdentifier) LAST_TOKEN});
if (RV_PVT_NODEID_IS_VALID(destNodeId))
pvtDelete(ras->hVal, destNodeId);
/* URQ */
__pvtGetNodeIdByFieldIds(destNodeId, ras->hVal, ras->defaultMessages[cmRASUnregistration][cmRASTrStageRequest], {_anyField _q931(gatekeeperIdentifier) LAST_TOKEN});
if (RV_PVT_NODEID_IS_VALID(destNodeId))
pvtDelete(ras->hVal, destNodeId);
/* ARQ */
__pvtGetNodeIdByFieldIds(destNodeId, ras->hVal, ras->defaultMessages[cmRASAdmission][cmRASTrStageRequest], {_anyField _q931(gatekeeperIdentifier) LAST_TOKEN});
if (RV_PVT_NODEID_IS_VALID(destNodeId))
pvtDelete(ras->hVal, destNodeId);
/* BRQ */
__pvtGetNodeIdByFieldIds(destNodeId, ras->hVal, ras->defaultMessages[cmRASBandwidth][cmRASTrStageRequest], {_anyField _q931(gatekeeperIdentifier) LAST_TOKEN});
if (RV_PVT_NODEID_IS_VALID(destNodeId))
pvtDelete(ras->hVal, destNodeId);
/* DRQ */
__pvtGetNodeIdByFieldIds(destNodeId, ras->hVal, ras->defaultMessages[cmRASDisengage][cmRASTrStageRequest], {_anyField _q931(gatekeeperIdentifier) LAST_TOKEN});
if (RV_PVT_NODEID_IS_VALID(destNodeId))
pvtDelete(ras->hVal, destNodeId);
}
/* Set timeToLive in default RRQ message */
__pvtGetNodeIdByFieldIds(srcNodeId, ras->hVal, ras->confNode, {_q931(registrationInfo) _q931(timeToLive) LAST_TOKEN});
if (RV_PVT_NODEID_IS_VALID(srcNodeId))
{
__pvtBuildByFieldIds(destNodeId, ras->hVal, ras->defaultMessages[cmRASRegistration][cmRASTrStageRequest], {_anyField _q931(timeToLive) LAST_TOKEN}, 0, NULL);
pvtSetTree(ras->hVal, destNodeId, ras->hVal, srcNodeId);
}
else
{
__pvtGetNodeIdByFieldIds(destNodeId, ras->hVal, ras->defaultMessages[cmRASRegistration][cmRASTrStageRequest], {_anyField _q931(timeToLive) LAST_TOKEN});
if (RV_PVT_NODEID_IS_VALID(destNodeId))
pvtDelete(ras->hVal, destNodeId);
}
/* Set supportAltGK in default RRQ message */
__pvtGetNodeIdByFieldIds(srcNodeId, ras->hVal, ras->confNode, {_q931(supportAltGK) LAST_TOKEN});
if (RV_PVT_NODEID_IS_VALID(srcNodeId))
{
__pvtBuildByFieldIds(destNodeId, ras->hVal, ras->defaultMessages[cmRASRegistration][cmRASTrStageRequest], {_anyField _q931(supportsAltGK) LAST_TOKEN}, 0, NULL);
}
return 0;
}
/************************************************************************
* cmiRASUpdateCallSignalingAddress
* purpose: Update the CallSignalling address inside the default RAS
* messages. This function should be called whenever this
* adress changes.
* It takes most of the information from the given nodeId
* input : hRasMgr - RAS instance handle
* addressId - nodeId of the address to set
* annexEId - nodeId of the annexE address to set
* output : none
* return : Non negative value on success
* Negative value on failure
************************************************************************/
int RVCALLCONV cmiRASUpdateCallSignalingAddress(
IN HRASMGR hRasMgr,
IN int addressId,
IN int annexEId)
{
rasModule* ras;
int nodeId;
if (hRasMgr == NULL) return RV_ERROR_UNKNOWN;
ras = (rasModule *)hRasMgr;
/* RRQ (TPKT)*/
__pvtBuildByFieldIds(nodeId, ras->hVal, ras->defaultMessages[cmRASRegistration][cmRASTrStageRequest], {_anyField _q931(callSignalAddress) _nul(1) LAST_TOKEN}, 0, NULL);
pvtSetTree(ras->hVal, nodeId, ras->hVal, addressId);
/* RRQ (ANNEX E)*/
if (annexEId >= 0)
{
__pvtBuildByFieldIds(nodeId, ras->hVal, ras->defaultMessages[cmRASRegistration][cmRASTrStageRequest], {_anyField _q931(alternateTransportAddresses) _q931(annexE) _nul(1) LAST_TOKEN}, 0, NULL);
pvtSetTree(ras->hVal, nodeId, ras->hVal, annexEId);
}
/* RCF */
__pvtBuildByFieldIds(nodeId, ras->hVal, ras->defaultMessages[cmRASRegistration][cmRASTrStageConfirm], {_anyField _q931(callSignalAddress) _nul(1) LAST_TOKEN}, 0, NULL);
pvtSetTree(ras->hVal, nodeId, ras->hVal, addressId);
/* URQ */
__pvtBuildByFieldIds(nodeId, ras->hVal, ras->defaultMessages[cmRASUnregistration][cmRASTrStageRequest], {_anyField _q931(callSignalAddress) _nul(1) LAST_TOKEN}, 0, NULL);
pvtSetTree(ras->hVal, nodeId, ras->hVal, addressId);
/* IRR - solicited */
__pvtBuildByFieldIds(nodeId, ras->hVal, ras->defaultMessages[cmRASInfo][cmRASTrStageConfirm], {_anyField _q931(callSignalAddress) _nul(1) LAST_TOKEN}, 0, NULL);
pvtSetTree(ras->hVal, nodeId, ras->hVal, addressId);
/* IRR - unsolicited */
__pvtBuildByFieldIds(nodeId, ras->hVal, ras->defaultMessages[cmRASUnsolicitedIRR][cmRASTrStageRequest], {_anyField _q931(callSignalAddress) _nul(1) LAST_TOKEN}, 0, NULL);
pvtSetTree(ras->hVal, nodeId, ras->hVal, addressId);
return 0;
}
/************************************************************************
* cmiRASGetHAPP
* purpose: Get the application's handle of a RAS instance for a
* specific stack's RAS transaction handle
* input : hsRas - Stack's handle for the RAS transaction
* output : none
* return : The application's handle of the RAS instance on success
* NULL on failure
************************************************************************/
RVAPI
HAPP RVCALLCONV cmiRASGetHAPP(
IN HRAS hsRas)
{
rasModule* ras;
/* Find out if it's incoming or outgoing */
ras = (rasModule *)emaGetUserData((EMAElement)hsRas);
return ras->app;
}
/************************************************************************
* cmiRASGetRequest
* purpose: Gets the pvt node of the current RAS request
* input : hsRas - Stack's handle for the RAS transaction
* output : none
* return : pvt node of the current RAS request
* or negative value on error
************************************************************************/
RvPvtNodeId RVCALLCONV cmiRASGetRequest(
IN HRAS hsRas)
{
rasModule* ras;
RvPvtNodeId propertyDb;
if (hsRas == NULL) return RV_ERROR_UNKNOWN;
/* Check if it's an incoming transaction or an outgoing transaction */
switch (emaGetType((EMAElement)hsRas))
{
case RAS_OUT_TX:
{
rasOutTx* outTx = (rasOutTx *)hsRas;
propertyDb = outTx->txProperty;
break;
}
case RAS_IN_TX:
{
rasInTx* inTx = (rasInTx *)hsRas;
propertyDb = inTx->txProperty;
break;
}
default:
return RV_ERROR_UNKNOWN;
}
ras = (rasModule *)emaGetUserData((EMAElement)hsRas);
/* Get the request from the property database */
return pvtGetChild(ras->hVal, propertyDb, __q931(request), NULL);
}
/************************************************************************
* cmiRASGetResponse
* purpose: Gets the pvt node of the current RAS response
* input : hsRas - Stack's handle for the RAS transaction
* output : none
* return : pvt node of the current RAS response
* or negative value on error
************************************************************************/
RvPvtNodeId RVCALLCONV cmiRASGetResponse(
IN HRAS hsRas)
{
rasModule* ras;
RvPvtNodeId propertyDb;
if (hsRas == NULL) return RV_ERROR_UNKNOWN;
/* Check if it's an incoming transaction or an outgoing transaction */
switch (emaGetType((EMAElement)hsRas))
{
case RAS_OUT_TX:
{
rasOutTx* outTx = (rasOutTx *)hsRas;
propertyDb = outTx->txProperty;
break;
}
case RAS_IN_TX:
{
rasInTx* outTx = (rasInTx *)hsRas;
propertyDb = outTx->txProperty;
break;
}
default:
return RV_ERROR_UNKNOWN;
}
ras = (rasModule *)emaGetUserData((EMAElement)hsRas);
/* Get the request from the property database */
return pvtGetChild(ras->hVal, propertyDb, __q931(response), NULL);
}
/************************************************************************
* cmiRASReceiveMessage
* purpose: Notify the RAS instance that a message was received from the
* network and should be handled.
* input : hRasMgr - RAS instance that needs to handle the message
* chanType - Type of channel to send through
* srcAddress - Address of the sender
* message - The message received
* output : none
* return : If an error occurs, the function returns a negative value.
* If no error occurs, the function returns a non-negative value.
************************************************************************/
int RVCALLCONV cmiRASReceiveMessage(
IN HRASMGR hRasMgr,
IN rasChanType chanType,
IN cmRASTransport* srcAddress,
IN RvUint8* messageBuf,
IN RvSize_t messageLength)
{
rasModule* ras = (rasModule *)hRasMgr;
RvUint32 index, seqNum;
int status;
void* hMsgContext = NULL;
/* Check out which message is it */
status = rasDecodePart(ras, messageBuf, (RvUint32)messageLength, &index, &seqNum);
if (status < 0)
return status;
if (index >= rasMsgLast)
{
RvLogError(&ras->log,
(&ras->log, "cmiRASReceiveMessage: Index out of bounds (%d)", index));
return RV_ERROR_UNKNOWN;
}
/* Route the message to the right transaction type */
status = rasRouteMessage(ras, chanType, srcAddress, messageBuf, (RvUint32)messageLength, -1, (rasMessages)index, seqNum, &hMsgContext);
/* If we've got a message context at this point, then we have to release it... */
if (hMsgContext != NULL)
ras->cmiEvRASReleaseMessageContext(hMsgContext);
return status;
}
/************************************************************************
* cmiRASSetSendEventHandler
* purpose: Set the callback function to use for sending messages through
* the network.
* input : hRasMgr - RAS module to set
* evMessageToSend - Callback function to use
* output : none
* return : If an error occurs, the function returns a negative value.
* If no error occurs, the function returns a non-negative value.
************************************************************************/
int RVCALLCONV cmiRASSetSendEventHandler(
IN HRASMGR hRasMgr,
IN cmiEvRasMessageToSend evMessageToSend)
{
rasModule* ras;
if (hRasMgr == NULL) return RV_ERROR_UNKNOWN;
ras = (rasModule *)hRasMgr;
ras->evSendMessage = evMessageToSend;
return 0;
}
/************************************************************************
* cmiRASSetTrEventHandler
* purpose: Set the callback function to use for responses to RAS
* transactions.
* It is called per transaction if the stack wishes to be
* notified of the response.
* input : hRas - The application's RAS transaction handle
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -