📄 cmiras.c
字号:
* to deal with
* cmEvRASResponse - The callback 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 cmiRASSetTrEventHandler(
IN HRAS hRas,
IN cmiEvRASResponseT cmEvRASResponse)
{
rasOutTx* tx;
if (hRas == NULL) return RV_ERROR_UNKNOWN;
tx = (rasOutTx *)hRas;
#if defined(RV_RAS_DEBUG)
/* Make sure the pointer is an outgoing transaction */
{
if (emaGetType((EMAElement)hRas) != RAS_OUT_TX)
{
RvLogSource * log;
log = &((rasModule *)emaGetUserData((EMAElement)hRas))->log;
RvLogExcep(log,
(log, "cmiRASSetTrEventHandler: Not an outgoing transaction 0x%p", hRas));
return RV_ERROR_UNKNOWN;
}
if (tx->state != rasTxStateIdle)
{
RvLogSource * log;
log = &((rasModule *)emaGetUserData((EMAElement)hRas))->log;
RvLogExcep(log,
(log, "cmiRASSetTrEventHandler: Called after request was sent for transaction 0x%p", hRas));
return RV_ERROR_UNKNOWN;
}
}
#endif /* defined(RV_RAS_DEBUG) */
/* Set the event handler */
tx->evResponse = cmEvRASResponse;
return 0;
}
/************************************************************************
* cmiRASSetEPTrEventHandler
* purpose: Set the callback function to use for new RAS requests that
* are not related to specific calls.
* input : hApp - Application's handle for a stack instance
* cmEvRASRequest - The callback 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 cmiRASSetEPTrEventHandler(
IN HAPP hApp,
IN cmiEvRASEPRequestT cmEvRASEPRequest)
{
rasModule* ras;
if (hApp == NULL) return RV_ERROR_UNKNOWN;
ras = (rasModule *)cmiGetRasHandle(hApp);
ras->evEpRequest = cmEvRASEPRequest;
return 0;
}
/************************************************************************
* cmiRASSetCallTrEventHandler
* purpose: Set the callback function to use for new RAS requests that
* are related to specific calls.
* input : hApp - Application's handle for a stack instance
* cmEvRASRequest - The callback 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 cmiRASSetCallTrEventHandler(
IN HAPP hApp,
IN cmiEvRASCallRequestT cmEvRASCallRequest)
{
rasModule* ras;
if (hApp == NULL) return RV_ERROR_UNKNOWN;
ras = (rasModule *)cmiGetRasHandle(hApp);
ras->evCallRequest = cmEvRASCallRequest;
return 0;
}
/************************************************************************
* cmRASMsgSetEventHandler
* purpose: Set the callback function to use for RAS messages.
* Used specifically by the MIB.
* input : hApp - Application's handle for a stack instance
* cmRASMsgEvent - The callbacks to use
* size - Size of the callbacks struct
* output : none
* return : If an error occurs, the function returns a negative value.
* If no error occurs, the function returns a non-negative value.
* note : This function is part of an API that wasn't published. It
* is used for H235v1.
************************************************************************/
RVAPI
int RVCALLCONV cmRASMsgSetEventHandler(
IN HAPP hApp,
IN cmRasMessageEvent* cmRASMsgEvent,
IN int size)
{
rasModule* ras;
if (hApp == NULL) return RV_ERROR_UNKNOWN;
ras = (rasModule *)cmiGetRasHandle(hApp);
memset(&ras->evMessages, 0, sizeof(ras->evMessages));
memcpy(&ras->evMessages, cmRASMsgEvent, (RvSize_t)RvMin(size, (int)sizeof(ras->evMessages)));
return 0;
}
/************************************************************************
* cmiRASGetProperty
* purpose: Gets the pvt node of the RAS property DB
* input : hsRas - Stack's handle for the RAS transaction
* output : none
* return : pvt node of the RAS property DB
* or negative value on error
************************************************************************/
int cmiRASGetProperty(
IN HRAS hsRas)
{
if (hsRas == NULL) return RV_ERROR_UNKNOWN;
switch (emaGetType((EMAElement)hsRas))
{
case RAS_OUT_TX:
{
rasOutTx* outTx = (rasOutTx *)hsRas;
return outTx->txProperty;
}
case RAS_IN_TX:
{
rasInTx* inTx = (rasInTx *)hsRas;
return inTx->txProperty;
}
default:
break;
}
return RV_ERROR_UNKNOWN;
}
/************************************************************************
* cmiRASSetNewCallEventHandler
* purpose: Set the callback function to use when RAS detects new call
*
* input : hApp - Application's handle for a stack instance
* cmiEvRASNewCall - The callback for new call
* 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 cmiRASSetNewCallEventHandler(
IN HAPP hApp,
IN cmiEvRASNewCallT cmiEvRASNewCall)
{
rasModule* ras;
if (hApp == NULL) return RV_ERROR_UNKNOWN;
ras = (rasModule *)cmiGetRasHandle(hApp);
ras->evRASNewCall = cmiEvRASNewCall;
return 0;
}
/************************************************************************
* cmiRASSetMessageEventHandler
* purpose: Sets messages events for the use of the security module.
* These events allows the application later on to check on
* specific messages if they passed the security or not.
* input : hApp - Application's handle for a stack instance
* cmEviRASNewRawMessage - Indication of a new incoming buffer for RAS
* cmEviRASSendRawMessage - Indication of an outgoing RAS message
* cmEviRASReleaseMessageContext - Indication that the RAS module
* is through with a specific message
* output : none
* return : If an error occurs, the function returns a negative value.
* If no error occurs, the function returns a non-negative value.
************************************************************************/
RVAPI
int RVCALLCONV cmiRASSetMessageEventHandler(
IN HAPP hApp,
IN cmiEvRASNewRawMessageT cmiEvRASNewRawMessage,
IN cmiEvRASSendRawMessageT cmiEvRASSendRawMessage,
IN cmiEvRASReleaseMessageContextT cmiEvRASReleaseMessageContext)
{
rasModule* ras = (rasModule *)cmiGetRasHandle(hApp);
if (hApp == NULL) return RV_ERROR_UNKNOWN;
ras->cmiEvRASNewRawMessage=cmiEvRASNewRawMessage;
ras->cmiEvRASSendRawMessage=cmiEvRASSendRawMessage;
ras->cmiEvRASReleaseMessageContext=cmiEvRASReleaseMessageContext;
return 0;
}
/************************************************************************
* cmiRASGetMessageContext
* purpose: Returns the message context for a RAS transaction
* input : hsRas - Stack's handle for the RAS transaction
* output : hMsgContext - Message context for the incoming request/response
* message of the given transaction.
* return : If an error occurs, the function returns a negative value.
* If no error occurs, the function returns a non-negative value.
************************************************************************/
RVAPI
int RVCALLCONV cmiRASGetMessageContext(
IN HRAS hsRas,
OUT void** hMsgContext)
{
rasModule* ras;
int status = 0;
ras = (rasModule *)emaGetUserData((EMAElement)hsRas);
/*cmiAPIEnter(ras->app, "cmiRASGetMessageContext(hsRas=0x%p)", hsRas);*/
/* Check if it's an incoming or an outgong transaction */
switch (emaGetType((EMAElement)hsRas))
{
case RAS_OUT_TX:
{
rasOutTx* tx;
tx = rasGetOutgoing(hsRas);
if (tx != NULL)
{
if (hMsgContext)
*hMsgContext = tx->hMsgContext;
}
else
{
RvLogError(&ras->log,
(&ras->log, "cmiRASGetMessageContext: Bad outgoing transaction handle (0x%p)", hsRas));
status = RV_ERROR_UNKNOWN;
}
break;
}
case RAS_IN_TX:
{
rasInTx* tx;
tx = rasGetIncoming(hsRas);
if (tx != NULL)
{
if (hMsgContext)
*hMsgContext = tx->hMsgContext;
}
else
{
RvLogError(&ras->log,
(&ras->log, "cmiRASGetMessageContext: Bad incoming transaction handle (0x%p)", hsRas));
status = RV_ERROR_UNKNOWN;
}
break;
}
default:
status = RV_ERROR_UNKNOWN;
}
/*cmiAPIExit(ras->app, "cmiRASGetMessageContext(hsRas=0x%p,ret=%d)", hsRas, status);*/
return status;
}
#ifdef __cplusplus
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -