📄 voip_adapter_clear.c
字号:
VoipCliAdapterStatePrint
(
in_pAdapterContext,
TRACE_LEVEL_0,
"Clearing raw data file %s\n",
in_pCurrentRawDataFileContext->Params.szRawDataFileResName
);
Result = VoipRawDataFileClearContext( in_pAdapterContext, in_pCurrentRawDataFileContext );
if( TBX_RESULT_FAILURE( Result ) && Result != TBX_RESULT_OPERATION_INCOMPLETE )
{
TBX_EXIT_ERROR( Result, 0, "Error while clearing raw data file context" );
}
/* End of the code (skip to cleanup) */
TBX_EXIT_SUCCESS (Result);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Error handling section
*--------------------------------------------------------------------------------------------------------------------------*/
ERROR_HANDLING
{
VoipCliAdapterStatePrint(
in_pAdapterContext,
TRACE_LEVEL_ERROR,
"VoipAdapterRawDataFileClear: %s (Result 0x%08X, %s, line %d)\n",
TBX_ERROR_DESCRIPTION,
(int)TBX_ERROR_RESULT,
__FILE__,
TBX_ERROR_LINE);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Cleanup section
*--------------------------------------------------------------------------------------------------------------------------*/
CLEANUP
{
}
RETURN;
}
/*-------------------------------------------------------------------------------------------------------------------------------
|
| VoipSendAdapterBertResClear : Clear a BERT resource on the adapter.
|
| in_pAdapterContext : Adapter configuration we are configuring
| in_pCurrentBertRes : Current BERT resource to clear
|
| Note : ~
|
| Return : TBX_RESULT_OK if the function succeeded
| Other error code if the function could not complete properly.
|
*------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT VoipSendAdapterBertResClear(
IN PVOIP_ADAPTER_CONTEXT in_pAdapterContext,
IN PVOIP_BERT_RES in_pCurrentBertRes)
{
VOIP_SEND_REQUEST_BODY_PART1( BERT_RES_FREE, 0 )
{
if( in_pAdapterContext->fNewConfigPending && !in_pAdapterContext->fStopUsingPending )
{
/* Config has been changed. Don't loose too much time trying to clearing things that may
remain valid in new config ... */
TBX_EXIT_SUCCESS (Result);
}
VoipCliAdapterStatePrint
(
in_pAdapterContext,
TRACE_LEVEL_1,
"Clearing BERT resource %d\n",
0
);
pMsg->Request.hResource = in_pCurrentBertRes->Common.hRes;
/* Mark this BERT resource as not configured in our structures. If response indicates "fail", we will
resync from scratch anyways. */
in_pCurrentBertRes->Common.fAllocated = TBX_FALSE;
}
/* Send request macro part 2: Send the request, return Result code */
VOIP_SEND_REQUEST_BODY_PART2("VoipSendAdapterBertResClear")
}
/* Function to handle the response of the message above */
TBX_RESULT VoipHandleAdapterBertResClearResponse(
IN PVOIP_ADAPTER_CONTEXT in_pAdapterContext,
IN TBX_MSG_HANDLE in_hMsg)
{
PTB640_RSP_BERT_RES_FREE pResponse;
/*---------------------------------------------------------------------------------------------------------------------------
| Code section
*--------------------------------------------------------------------------------------------------------------------------*/
CODE
{
/* Initialize local variables */
pResponse = TBX_MSG_PAYLOAD_POINTER( in_hMsg );
/* Count this received response */
if( in_pAdapterContext->un32NbResponsesExpected )
{
in_pAdapterContext->un32NbResponsesExpected--;
}
VoipCliAdapterStatePrint
(
in_pAdapterContext,
TRACE_LEVEL_0,
"Clear BERT resource %d result is 0x%08X\n",
0,
(int)pResponse->Result
);
if( TBX_RESULT_FAILURE( pResponse->Result ) )
{
/* Request failed. */
TBX_EXIT_ERROR (pResponse->Result, 0, "Failed to free BERT resource!");
}
/* End of the code (skip to cleanup) */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Error handling section
*--------------------------------------------------------------------------------------------------------------------------*/
ERROR_HANDLING
{
VoipCliAdapterStatePrint(
in_pAdapterContext,
TRACE_LEVEL_ERROR,
"VoipHandleAdapterBertResClearResponse: %s (Result 0x%08X, %s, line %d)\n",
TBX_ERROR_DESCRIPTION,
(int)TBX_ERROR_RESULT,
__FILE__,
TBX_ERROR_LINE);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Cleanup section
*--------------------------------------------------------------------------------------------------------------------------*/
CLEANUP
{
}
RETURN;
}
/*-------------------------------------------------------------------------------------------------------------------------------
|
| VoipSendAdapterTrunkResClear : Clear a trunk resource on the adapter.
|
| in_pAdapterContext : Adapter configuration we are configuring
| in_un32TrunkNb : Trunk number of the trunk resource to clear
| in_un32TimeSlot : Timeslot number of the trunk resource to clear
|
| Note : ~
|
| Return : TBX_RESULT_OK if the function succeeded
| Other error code if the function could not complete properly.
|
*------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT VoipSendAdapterTrunkResClear(
IN PVOIP_ADAPTER_CONTEXT in_pAdapterContext,
IN TBX_UINT32 in_un32TrunkNb,
IN TBX_UINT32 in_un32TimeSlot)
{
PVOIP_TRUNK_CONFIG pTrunkConfig;
PVOIP_TRUNK_RES pTrunkRes;
VOIP_SEND_REQUEST_BODY_PART1( TRUNK_RES_FREE, 0 )
{
if( in_pAdapterContext->fNewConfigPending && !in_pAdapterContext->fStopUsingPending )
{
/* Config has been changed. Don't loose too much time trying to clearing things that may
remain valid in new config ... */
TBX_EXIT_SUCCESS (Result);
}
VoipCliAdapterStatePrint
(
in_pAdapterContext,
TRACE_LEVEL_1,
"Clearing trunk %d timeslot %d\n",
in_un32TrunkNb,
in_un32TimeSlot
);
/* Store the trunk number we are configuring in the user context, to retrieve our context upon response reception */
TBX_MSG_USER_CONTEXT1_SET( hMsg, (TBX_UINT64)in_un32TrunkNb );
TBX_MSG_USER_CONTEXT2_SET( hMsg, (TBX_UINT64)in_un32TimeSlot );
pTrunkConfig = &in_pAdapterContext->CurrentConfig.aTrunk[in_un32TrunkNb];
pTrunkRes = &pTrunkConfig->aRes[in_un32TimeSlot];
pMsg->Request.hTrunkRes = pTrunkRes->Common.hRes;
/* Mark this trunk resource as not configured in our structures. If response indicates "fail", we will
resync from scratch anyways. */
pTrunkRes->Common.fAllocated = TBX_FALSE;
}
/* Send request macro part 2: Send the request, return Result code */
VOIP_SEND_REQUEST_BODY_PART2("VoipSendAdapterTrunkResClear")
}
/* Function to handle the response of the message above */
TBX_RESULT VoipHandleAdapterTrunkResClearResponse(
IN PVOIP_ADAPTER_CONTEXT in_pAdapterContext,
IN TBX_MSG_HANDLE in_hMsg)
{
PTB640_RSP_TRUNK_RES_FREE pResponse;
TBX_UINT32 un32TrunkNb;
TBX_UINT32 un32TimeSlot;
/*---------------------------------------------------------------------------------------------------------------------------
| Code section
*--------------------------------------------------------------------------------------------------------------------------*/
CODE
{
/* Initialize local variables */
pResponse = TBX_MSG_PAYLOAD_POINTER( in_hMsg );
un32TrunkNb = (TBX_UINT32)TBX_MSG_USER_CONTEXT1_GET( in_hMsg );
un32TimeSlot = (TBX_UINT32)TBX_MSG_USER_CONTEXT2_GET( in_hMsg );
/* Count this received response */
if( in_pAdapterContext->un32NbResponsesExpected )
{
in_pAdapterContext->un32NbResponsesExpected--;
}
VoipCliAdapterStatePrint
(
in_pAdapterContext,
TRACE_LEVEL_0,
"Clear trunk %d timeslot %d, result is 0x%08X\n",
(int)un32TrunkNb,
(int)un32TimeSlot,
(int)pResponse->Result
);
if( TBX_RESULT_FAILURE( pResponse->Result ) )
{
/* Request failed. */
TBX_EXIT_ERROR (pResponse->Result, 0, "Failed to free trunk resource!");
}
/* End of the code (skip to cleanup) */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Error handling section
*--------------------------------------------------------------------------------------------------------------------------*/
ERROR_HANDLING
{
VoipCliAdapterStatePrint(
in_pAdapterContext,
TRACE_LEVEL_ERROR,
"VoipHandleAdapterTrunkResClearResponse: %s (Result 0x%08X, %s, line %d)\n",
TBX_ERROR_DESCRIPTION,
(int)TBX_ERROR_RESULT,
__FILE__,
TBX_ERROR_LINE);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Cleanup section
*--------------------------------------------------------------------------------------------------------------------------*/
CLEANUP
{
}
RETURN;
}
/*-------------------------------------------------------------------------------------------------------------------------------
|
| VoipSendAdapterTrunkClear : Clear a trunk on the adapter.
|
| in_pAdapterContext : Adapter configuration we are configuring
| in_pCurrentTrunkConfig : Current trunk to clear
|
| Note : ~
|
| Return : TBX_RESULT_OK if the function succeeded
| Other error code if the function could not complete properly.
|
*------------------------------------------------------------------------------------------------------------------------------*/
static TBX_RESULT VoipSendAdapterTrunkClear(
IN PVOIP_ADAPTER_CONTEXT in_pAdapterContext,
IN PVOIP_TRUNK_CONFIG in_pCurrentTrunkConfig)
{
VOIP_SEND_REQUEST_BODY_PART1( TRUNK_OP_FREE, 0 )
{
if( in_pAdapterContext->fNewConfigPending && !in_pAdapterContext->fStopUsingPending )
{
/* Config has been changed. Don't loose too much time trying to clearing things that may
remain valid in new config ... */
TBX_EXIT_SUCCESS (Result);
}
VoipCliAdapterStatePrint
(
in_pAdapterContext,
TRACE_LEVEL_1,
"Clearing Trunk %d\n",
in_pCurrentTrunkConfig->un32TrunkNumber
);
/* Store the trunk number we are configuring in the user context, to retrieve our context upon response reception */
TBX_MSG_USER_CONTEXT1_SET( hMsg, (TBX_UINT64)in_pCurrentTrunkConfig->un32TrunkNumber );
pMsg->Request.hTrunk = in_pCurrentTrunkConfig->hTrunk;
/* Mark this trunk as not configured in our structures. If response indicates "fail", we will
resync from scratch anyways. */
in_pCurrentTrunkConfig->fAllocated = TBX_FALSE;
}
/* Send request macro part 2: Send the request, return Result code */
VOIP_SEND_REQUEST_BODY_PART2("VoipSendAdapterTrunkClear")
}
/* Function to handle the response of the message above */
TBX_RESULT VoipHandleAdapterTrunkClearResponse(
IN PVOIP_ADAPTER_CONTEXT in_pAdapterContext,
IN TBX_MSG_HANDLE in_hMsg)
{
PTB640_RSP_TRUNK_OP_FREE pResponse;
TBX_UINT32 un32TrunkNb;
/*---------------------------------------------------------------------------------------------------------------------------
| Code section
*--------------------------------------------------------------------------------------------------------------------------*/
CODE
{
/* Initialize local variables */
pResponse = TBX_MSG_PAYLOAD_POINTER( in_hMsg );
un32TrunkNb = (TBX_UINT32)TBX_MSG_USER_CONTEXT1_GET( in_hMsg );
/* Count this received response */
if( in_pAdapterContext->un32NbResponsesExpected )
{
in_pAdapterContext->un32NbResponsesExpected--;
}
VoipCliAdapterStatePrint
(
in_pAdapterContext,
TRACE_LEVEL_0,
"Clear trunk %d result is 0x%08X\n",
(int)un32TrunkNb,
(int)pResponse->Result
);
if( TBX_RESULT_FAILURE( pResponse->Result ) )
{
/* Request failed. */
TBX_EXIT_ERROR (pResponse->Result, 0, "Failed to free trunk!");
}
/* End of the code (skip to cleanup) */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Error handling section
*--------------------------------------------------------------------------------------------------------------------------*/
ERROR_HANDLING
{
VoipCliAdapterStatePrint(
in_pAdapterContext,
TRACE_LEVEL_ERROR,
"VoipHandleAdapterTrunkClearResponse: %s (Result 0x%08X, %s, line %d)\n",
TBX_ERROR_DESCRIPTION,
(int)TBX_ERROR_RESULT,
__FILE__,
TBX_ERROR_LINE);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Cleanup section
*--------------------------------------------------------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -