📄 cmautorasep.c
字号:
pvtSetTree(autoras->hVal, toNode, autoras->hVal, fromNode);
}
/* now delete the copied tree */
pvtDelete(autoras->hVal, newRoot);
return 0;
}
break;
}
case cmRASTrStageReject:
{
/* RRJ received */
int chNodeId;
/* Change the state and notify the application */
autoras->state = cmIdle;
autoRasChangeState(autoras, cmRegistrationReject, responseId);
/* Make sure this transaction wasn't killed by the user */
if (emaWasDeleted((EMAElement)hsRas))
return 0;
/* Check out the reason */
__pvtGetNodeIdByFieldIds(chNodeId, autoras->hVal, messageId, {_q931(rejectReason) _q931(discoveryRequired) LAST_TOKEN});
if (chNodeId >= 0)
{
/* We have to try all over again, this time for GRQ */
autoras->discoveryRequired = RV_TRUE;
if (autoRasIsInSearch(autoras,NULL))
{
/* we'll just send a GRQ to the current Alt GK - no need to go Idle */
autoRasPrepareGRQ(autoras);
}
else
{
/* Idle and try again */
autoRasIdleAndRegister(autoras);
}
return 0;
}
else
{
/* See if this is a redirection */
chNodeId = pvtGetChild(autoras->hVal, messageId, __q931(altGKInfo), NULL);
if (RV_PVT_NODEID_IS_VALID(chNodeId))
{
/* Se we are redirected to an AltGK.*/
RvInt32 isPerm;
int newAltGKs;
/* maybe we are already working on a redirection */
if(!autoRasIsInSearch(autoras,NULL))
{
/* We're not working on anything right now - we start redirection */
/* Let's see if permanently of temporeraly */
newAltGKs = pvtGetChild(autoras->hVal, chNodeId, __q931(alternateGatekeeper), NULL);
pvtGetChildByFieldId(autoras->hVal, chNodeId, __q931(altGKisPermanent), &isPerm, NULL);
if(isPerm)
autoRasSetPermList(autoras, newAltGKs);
else
{
autoras->isTempRdrn = RV_TRUE;
autoRasSetTempList(autoras, newAltGKs);
}
}
/* ok, let's get a gatekeeper */
if(autoRasEpSendToNextGK(autoras) >= 0)
/* We have sent an RRQ to the next GK*/
return 0;
else
{ /* no more GKs in AltGKs list - get rid of it */
if(autoras->isTempRdrn)
{
autoras->isTempRdrn = RV_FALSE;
autoRasRemoveTempList(autoras);
}
else autoRasRemovePermList(autoras);
autoRasResetSearch(autoras,NULL);
}
}
{
/* Timeout and wait a little before trying again */
/* 2004.11.10, deleted. we don't need retry here. */
#if 0
RvInt32 timeout;
pvtGet(autoras->hVal, pvtGetChild(autoras->hVal, autoras->confNode, __q931(responseTimeOut), NULL), NULL, NULL, &timeout, NULL);
autoras->regTimer = RvH323TimerStart(autoras->hTimers, autoRasRetry, autoras, timeout * 1000);
#endif
}
}
break;
}
case cmRASTrStageTimeout:
/* maybe we are already working on a redirection */
if(autoRasIsInSearch(autoras,NULL))
{
/* ok, let's get a gatekeeper */
if(autoRasEpSendToNextGK(autoras) >= 0)
/* We have sent an RRQ to the next GK*/
return 0;
else
{ /* no more GKs in AltGKs list - get rid of it */
if(autoras->isTempRdrn)
{
autoras->isTempRdrn = RV_FALSE;
autoRasRemoveTempList(autoras);
}
else autoRasRemovePermList(autoras);
autoRasResetSearch(autoras,NULL);
}
}
/* We've timed out - try again */
autoRasIdleAndRegister(autoras);
return 0;
default:
break;
}
if(hsRas == autoras->registrationTx)
{
/* no one removed this tx yet. kill it. */
cmRASClose(hsRas);
autoras->registrationTx = NULL;
}
return 0;
}
/************************************************************************
* autoRasUnregistrationResponse
* purpose: Callback function indicating the response of a URQ
* input : haRas - Application's handle (autoras in this context)
* hsRas - RAS Transaction handle
* trStage - Stage of response
* output : none
* return : non-negative value on success
* negative value on failure
************************************************************************/
static int RVCALLCONV autoRasUnregistrationResponse(
IN HAPPRAS haRas,
IN HRAS hsRas,
IN cmRASTrStage trStage)
{
autorasEndpoint* autoras = (autorasEndpoint *)haRas;
cmRegEvent event;
RvPvtNodeId tmpNode;
RvPvtNodeId requestId = cmiRASGetRequest(hsRas);
RvPvtNodeId responseId = cmiRASGetResponse(hsRas);
RvBool isPartial;
/* See if this was a partial URQ */
__pvtGetNodeIdByFieldIds(tmpNode, autoras->hVal, requestId , {_q931(unregistrationRequest) _q931(endpointAlias) LAST_TOKEN});
isPartial = (tmpNode>=0);
/* See what we've got - the event will be set accordingly */
switch(trStage)
{
case cmRASTrStageConfirm:
event = cmUnregistrationConfirm;
break;
case cmRASTrStageReject:
{
/* See if this is a redirection */
__pvtGetNodeIdByFieldIds(tmpNode, autoras->hVal, responseId, {_anyField _q931(altGKInfo) LAST_TOKEN});
if (tmpNode >= 0)
{
/* Se we are redirected to an AltGK.*/
RvInt32 isPerm;
int newAltGKs;
/* maybe we are already working on a redirection */
if(!autoRasIsInSearch(autoras,NULL))
{
/* We're not working on anything right now - we start redirection */
/* Let's see if permanently of temporeraly */
newAltGKs = pvtGetChild(autoras->hVal, tmpNode, __q931(alternateGatekeeper), NULL);
pvtGetChildByFieldId(autoras->hVal, tmpNode, __q931(altGKisPermanent), &isPerm, NULL);
if(isPerm)
autoRasSetPermList(autoras, newAltGKs);
else
{
autoras->isTempRdrn = RV_TRUE;
autoRasSetTempList(autoras, newAltGKs);
}
}
/* ok, let's get a gatekeeper */
if(autoRasEpSendToNextGK(autoras) >= 0)
/* We have sent a URQ to the next GK*/
return 0;
else
{ /* no more GKs in AltGKs list - get rid of it */
if(autoras->isTempRdrn)
{
autoras->isTempRdrn = RV_FALSE;
autoRasRemoveTempList(autoras);
}
else autoRasRemovePermList(autoras);
autoRasResetSearch(autoras,NULL);
}
}
event = cmUnregistrationReject;
break;
}
default:
/* maybe we are already working on a redirection */
if(autoRasIsInSearch(autoras,NULL))
{
/* ok, let's get a gatekeeper */
if(autoRasEpSendToNextGK(autoras) >= 0)
/* We have sent a URQ to the next GK*/
return 0;
else
{ /* no more GKs in AltGKs list - get rid of it */
if(autoras->isTempRdrn)
{
autoras->isTempRdrn = RV_FALSE;
autoRasRemoveTempList(autoras);
}
else autoRasRemovePermList(autoras);
autoRasResetSearch(autoras,NULL);
}
}
event = (cmRegEvent)RV_ERROR_UNKNOWN;
break;
}
/* Set the state to IDLE */
if(!isPartial)
autoras->state = cmIdle;
autoRasChangeState(autoras, event, cmiRASGetResponse(hsRas));
if(hsRas == autoras->registrationTx)
{
/* no one removed this tx yet. kill it. */
cmRASClose(hsRas);
autoras->registrationTx = NULL;
}
return 0;
}
/************************************************************************
* autoRasRaiResponse
* purpose: Callback function indicating the response of a RAI
* input : haRas - Application's handle (autoras in this context)
* hsRas - RAS Transaction handle
* trStage - Stage of response
* output : none
* return : non-negative value on success
* negative value on failure
************************************************************************/
static int RVCALLCONV autoRasRaiResponse(
IN HAPPRAS haRas,
IN HRAS hsRas,
IN cmRASTrStage trStage)
{
autorasEndpoint* autoras = (autorasEndpoint *)haRas;
/* See what we've got - the event will be set accordingly */
switch(trStage)
{
case cmRASTrStageConfirm:
autoRasChangeState(autoras, cmResourceAvailabilityConfirmation, cmiRASGetResponse(hsRas));
break;
case cmRASTrStageTimeout:
autoRasChangeState(autoras, cmResourceAvailabilityConfirmation, RV_PVT_INVALID_NODEID);
break;
default:
break;
}
/* Close the transaction and we're done */
cmRASClose(hsRas);
return 0;
}
/************************************************************************
* autoRasSendLightweightRRQ
* purpose: Callback function which sends an RRQ for keepalive messages
* input : context - autoras
* output : none
* return : non-negative value on success
* negative value on failure
************************************************************************/
static RvBool autoRasSendLightweightRRQ(IN void* context)
{
autorasEndpoint* autoras = (autorasEndpoint *)context;
int requestId, ret;
RvInt32 keepAlive;
/* Reset the timer - we don't need it until we get an RCF */
RvH323TimerClear(autoras->hTimers, &autoras->regTimer);
/* 2004.07.22. Add CallSignalAddress to the lightweight RRQ message. */
{
cmTransportAddress addr;
memset(&addr, 0, sizeof(cmTransportAddress));
if (cmGetLocalCallSignalAddress(autoras->hApp, &addr) >= 0)
cmRASSetParam(autoras->registrationTx, cmRASTrStageRequest, cmRASParamCallSignalAddress, 0, sizeof(addr), (char *)&addr);
}
/* maybe we already have a light weight RRQ */
requestId = cmiRASGetRequest(autoras->registrationTx);
__pvtGetByFieldIds(ret, autoras->hVal, requestId, {_q931(registrationRequest) _q931(keepAlive) LAST_TOKEN} , NULL, &keepAlive, NULL);
if((ret>=0) && keepAlive)
{
/* we already got a LWRRQ. send it. */
if(autoras->GKID.length)
cmRASSetParam(autoras->registrationTx, cmRASTrStageRequest, cmRASParamGatekeeperID, 0, sizeof(autoras->GKID), (char *) &autoras->GKID);
if(autoras->setGK.port)
cmRASSetParam(autoras->registrationTx, cmRASTrStageRequest, cmRASParamDestinationIpAddress, 0, sizeof(autoras->setGK), (char *) &autoras->setGK);
cmRASRequest(autoras->registrationTx);
return RV_FALSE;
}
/* Close a ras transaction if we have one */
if (autoras->registrationTx != NULL)
{
cmRASClose(autoras->registrationTx);
autoras->registrationTx = NULL;
}
/* Create an RRQ transaction */
ret = cmRASStartTransaction(autoras->hApp, (HAPPRAS)autoras, &autoras->registrationTx, cmRASRegistration, NULL, NULL);
if (ret >= 0)
{
/* Set the parameters to make sure it's a lightweight RRQ */
cmRASSetParam(autoras->registrationTx, cmRASTrStageRequest, cmRASParamDiscoveryComplete, 0, (RvInt32)autoras->discoveryComplete, NULL);
cmRASSetParam(autoras->registrationTx, cmRASTrStageRequest, cmRASParamKeepAlive, 0, RV_TRUE, NULL);
autoras->discoveryComplete = RV_FALSE;
cmiRASSetTrEventHandler(autoras->registrationTx, autoRasRegistrationResponse);
/* Send the request */
cmRASRequest(autoras->registrationTx);
}
return RV_FALSE;
}
/************************************************************************
* autoRasRetry
* purpose: Retry callback. Called after a request transaction timedout
* and a specified time has passed.
* input : context - Context used (automatic RAS handle)
* output : none
* return : non-negative value on success
* negative value on failure
************************************************************************/
static RvBool autoRasRetry(IN void* context)
{
autorasEndpoint* autoras = (autorasEndpoint *)context;
/* Make sure there's a timer to reset */
RvH323TimerClear(autoras->hTimers, &autoras->regTimer);
/* Retry after setting to idle */
autoRasIdleAndRegister(autoras);
return RV_FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -