📄 voip_adapter_compare.c
字号:
| in_pAdapterContext : Adapter configuration we are configuring
| in_pCurrentRawDataFileContext : Current raw data file context on the adapter
| in_pTargetRawDataFileContext : Target raw data file context
| out_pfMustReallocate : Tell if must clear this raw data file resource on the adapter
| out_pfMustSetParams : Tell if must "config set" this raw data file resource on the adapter
|
| Note : ~
|
| Return : TBX_RESULT_OK if the function succeeded
| Other error code if the function could not complete properly.
|
*------------------------------------------------------------------------------------------------------------------------------*/
TBX_VOID VoipAdapterRawDataFileConfigureCompare(
IN PVOIP_ADAPTER_CONTEXT in_pAdapterContext,
IN PVOIP_RAW_DATA_FILE_CONTEXT in_pCurrentRawDataFileContext,
IN PVOIP_RAW_DATA_FILE_CONTEXT in_pTargetRawDataFileContext,
OUT PTBX_BOOL out_pfMustReallocate,
OUT PTBX_BOOL out_pfMustSetParams)
{
/*---------------------------------------------------------------------------------------------------------------------------
| Code section
*--------------------------------------------------------------------------------------------------------------------------*/
CODE
{
*out_pfMustReallocate = TBX_FALSE;
*out_pfMustSetParams = TBX_FALSE;
if( !in_pCurrentRawDataFileContext->fAllocated )
{
/* Not allocated. Ignore. */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
VoipCliAdapterStatePrint
(
in_pAdapterContext,
TRACE_LEVEL_0,
"Comparing raw data file %s config\n",
in_pCurrentRawDataFileContext->Params.szRawDataFileResName
);
if
(
in_pCurrentRawDataFileContext->fAllocated !=
in_pTargetRawDataFileContext->fAllocated
)
{
*out_pfMustReallocate = TBX_TRUE;
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
if( strcmp( in_pCurrentRawDataFileContext->Params.szPathName, in_pTargetRawDataFileContext->Params.szPathName ) != 0 )
{
*out_pfMustReallocate = TBX_TRUE;
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
if( in_pCurrentRawDataFileContext->Params.un16RxIPPort != in_pTargetRawDataFileContext->Params.un16RxIPPort )
{
*out_pfMustReallocate = TBX_TRUE;
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/* End of the code (skip to cleanup) */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Error handling section
*--------------------------------------------------------------------------------------------------------------------------*/
ERROR_HANDLING
{
}
/*---------------------------------------------------------------------------------------------------------------------------
| Cleanup section
*--------------------------------------------------------------------------------------------------------------------------*/
CLEANUP
{
if( in_pCurrentRawDataFileContext->fAllocated )
{
if( *out_pfMustReallocate )
{
VoipCliAdapterStatePrint( in_pAdapterContext, TRACE_LEVEL_0, " -> Need to clear\n" );
}
else if( *out_pfMustSetParams )
{
VoipCliAdapterStatePrint( in_pAdapterContext, TRACE_LEVEL_0, " -> Need to set config\n" );
}
}
}
RETURN_VOID;
}
/*-------------------------------------------------------------------------------------------------------------------------------
|
| VoipAdapterBertResConfigureCompare : Compares the BERT resource config on the adapter with the target config
| and determines if must be reallocated, reconfigured, or
| if configuration is already correct.
|
| in_pAdapterContext : Adapter configuration we are configuring
| in_pCurrentBertRes : Current BERT resource configuration on the adapter
| in_pTargetBertRes : Target BERT resources configuration
| out_pfMustReallocate : Tell if must clear this BERT resource on the adapter
| out_pfMustSetParams : Tell if must "config set" this BERT resource on the adapter
|
| Note : ~
|
| Return : TBX_RESULT_OK if the function succeeded
| Other error code if the function could not complete properly.
|
*------------------------------------------------------------------------------------------------------------------------------*/
TBX_VOID VoipAdapterBertResConfigureCompare(
IN PVOIP_ADAPTER_CONTEXT in_pAdapterContext,
IN PVOIP_BERT_RES in_pCurrentBertRes,
IN PVOIP_BERT_RES in_pTargetBertRes,
OUT PTBX_BOOL out_pfMustReallocate,
OUT PTBX_BOOL out_pfMustSetParams)
{
/*---------------------------------------------------------------------------------------------------------------------------
| Code section
*--------------------------------------------------------------------------------------------------------------------------*/
CODE
{
*out_pfMustReallocate = TBX_FALSE;
*out_pfMustSetParams = TBX_FALSE;
if( !in_pCurrentBertRes->Common.fAllocated )
{
/* Not allocated. Ignore. */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
VoipCliAdapterStatePrint
(
in_pAdapterContext,
TRACE_LEVEL_0,
"Comparing BERT resource 0x%08X config\n",
in_pCurrentBertRes->Common.hRes
);
if
(
in_pCurrentBertRes->Common.fAllocated !=
in_pTargetBertRes->Common.fAllocated
)
{
*out_pfMustReallocate = TBX_TRUE;
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
if( in_pCurrentBertRes->Params.PatternType != in_pTargetBertRes->Params.PatternType )
{
*out_pfMustReallocate = TBX_TRUE;
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
if( in_pCurrentBertRes->Params.PatternType == TB640_BERT_PATTERN_TYPE_FIXED )
{
if( in_pCurrentBertRes->Params.un8FixedPattern != in_pTargetBertRes->Params.un8FixedPattern )
{
*out_pfMustReallocate = TBX_TRUE;
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
}
/* End of the code (skip to cleanup) */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Error handling section
*--------------------------------------------------------------------------------------------------------------------------*/
ERROR_HANDLING
{
}
/*---------------------------------------------------------------------------------------------------------------------------
| Cleanup section
*--------------------------------------------------------------------------------------------------------------------------*/
CLEANUP
{
if( in_pCurrentBertRes->Common.fAllocated )
{
if( *out_pfMustReallocate )
{
VoipCliAdapterStatePrint( in_pAdapterContext, TRACE_LEVEL_0, " -> Need to clear\n" );
}
else if( *out_pfMustSetParams )
{
VoipCliAdapterStatePrint( in_pAdapterContext, TRACE_LEVEL_0, " -> Need to set config\n" );
}
}
}
RETURN_VOID;
}
/*-------------------------------------------------------------------------------------------------------------------------------
|
| VoipAdapterTrunkConfigureCompare : Compares the Trunk config on the adapter with the target config
| and determines if must be reallocated, reconfigured, or
| if configuration is already correct.
|
| in_pAdapterContext : Adapter configuration we are configuring
| in_pCurrentTrunkConfig : Current trunk configuration on the adapter
| in_pTargetTrunkConfig : Target trunk configuration
| out_pfMustReallocate : Tell if must clear this trunk on the adapter
| out_pfMustSetParams : Tell if must "config set" this trunk on the adapter
|
| Note : ~
|
| Return : TBX_RESULT_OK if the function succeeded
| Other error code if the function could not complete properly.
|
*------------------------------------------------------------------------------------------------------------------------------*/
TBX_VOID VoipAdapterTrunkConfigureCompare(
IN PVOIP_ADAPTER_CONTEXT in_pAdapterContext,
IN PVOIP_TRUNK_CONFIG in_pCurrentTrunkConfig,
IN PVOIP_TRUNK_CONFIG in_pTargetTrunkConfig,
OUT PTBX_BOOL out_pfMustReallocate,
OUT PTBX_BOOL out_pfMustSetParams)
{
/*---------------------------------------------------------------------------------------------------------------------------
| Code section
*--------------------------------------------------------------------------------------------------------------------------*/
CODE
{
*out_pfMustReallocate = TBX_FALSE;
*out_pfMustSetParams = TBX_FALSE;
if( !in_pCurrentTrunkConfig->fAllocated )
{
/* Not allocated. Ignore. */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
VoipCliAdapterStatePrint
(
in_pAdapterContext,
TRACE_LEVEL_0,
"Comparing trunk 0x%08X config\n",
(int)in_pCurrentTrunkConfig->hTrunk
);
if
(
in_pCurrentTrunkConfig->fAllocated !=
in_pTargetTrunkConfig->fAllocated
)
{
*out_pfMustReallocate = TBX_TRUE;
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
if( in_pCurrentTrunkConfig->TrunkCfg.Type != in_pTargetTrunkConfig->TrunkCfg.Type )
{
*out_pfMustReallocate = TBX_TRUE;
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
switch( in_pCurrentTrunkConfig->TrunkCfg.Type )
{
case TB640_TRUNK_TYPE_E1:
{
if
(
(in_pCurrentTrunkConfig->TrunkCfg.Cfg.E1.Framing != in_pTargetTrunkConfig->TrunkCfg.Cfg.E1.Framing ) ||
(in_pCurrentTrunkConfig->TrunkCfg.Cfg.E1.Encoding != in_pTargetTrunkConfig->TrunkCfg.Cfg.E1.Encoding ) ||
(in_pCurrentTrunkConfig->TrunkCfg.Cfg.E1.Termination != in_pTargetTrunkConfig->TrunkCfg.Cfg.E1.Termination ) ||
(in_pCurrentTrunkConfig->TrunkCfg.Cfg.E1.fLoopTime != in_pTargetTrunkConfig->TrunkCfg.Cfg.E1.fLoopTime ) ||
(in_pCurrentTrunkConfig->TrunkCfg.Cfg.E1.byIdleCode != in_pTargetTrunkConfig->TrunkCfg.Cfg.E1.byIdleCode )
)
{
*out_pfMustReallocate = TBX_TRUE;
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
} break;
case TB640_TRUNK_TYPE_T1:
{
if
(
(in_pCurrentTrunkConfig->TrunkCfg.Cfg.T1.Framing != in_pTargetTrunkConfig->TrunkCfg.Cfg.T1.Framing ) ||
(in_pCurrentTrunkConfig->TrunkCfg.Cfg.T1.Encoding != in_pTargetTrunkConfig->TrunkCfg.Cfg.T1.Encoding ) ||
(in_pCurrentTrunkConfig->TrunkCfg.Cfg.T1.Termination != in_pTargetTrunkConfig->TrunkCfg.Cfg.T1.Termination ) ||
(in_pCurrentTrunkConfig->TrunkCfg.Cfg.T1.fLoopTime != in_pTargetTrunkConfig->TrunkCfg.Cfg.T1.fLoopTime ) ||
(in_pCurrentTrunkConfig->TrunkCfg.Cfg.T1.byIdleCode != in_pTargetTrunkConfig->TrunkCfg.Cfg.T1.byIdleCode )
)
{
*out_pfMustReallocate = TBX_TRUE;
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
} break;
case TB640_TRUNK_TYPE_J1:
{
if
(
(in_pCurrentTrunkConfig->TrunkCfg.Cfg.J1.Framing != in_pTargetTrunkConfig->TrunkCfg.Cfg.J1.Framing ) ||
(in_pCurrentTrunkConfig->TrunkCfg.Cfg.J1.Encoding != in_pTargetTrunkConfig->TrunkCfg.Cfg.J1.Encoding ) ||
(in_pCurrentTrunkConfig->TrunkCfg.Cfg.J1.Termination != in_pTargetTrunkConfig->TrunkCfg.Cfg.J1.Termination ) ||
(in_pCurrentTrunkConfig->TrunkCfg.Cfg.J1.fLoopTime != in_pTargetTrunkConfig->TrunkCfg.Cfg.J1.fLoopTime ) ||
(in_pCurrentTrunkConfig->TrunkCfg.Cfg.J1.byIdleCode != in_pTargetTrunkConfig->TrunkCfg.Cfg.J1.byIdleCode )
)
{
*out_pfMustReallocate = TBX_TRUE;
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
} break;
default:
{
/* Not supposed to happen */
*out_pfMustReallocate = TBX_TRUE;
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
} break;
}
/* End of the code (skip to cleanup) */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Error handling section
*--------------------------------------------------------------------------------------------------------------------------*/
ERROR_HANDLING
{
}
/*---------------------------------------------------------------------------------------------------------------------------
| Cleanup section
*--------------------------------------------------------------------------------------------------------------------------*/
CLEANUP
{
if( in_pCurrentTrunkConfig->fAllocated )
{
if( *out_pfMustReallocate )
{
VoipCliAdapterStatePrint( in_pAdapterContext, TRACE_LEVEL_0, " -> Need to clear\n" );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -