📄 config.c
字号:
result = TBXAsyncOpen (
g_AppContext->hTbxLib,
pAdapterInfo->hAdapter,
&OperationLibParams,
&(pAdapterInfo->ahOperationLib [un32Count2]),
&(pAdapterInfo->aun64UniqueId [un32Count2]));
if (TBX_RESULT_FAILURE (result))
{
TBX_EXIT_ERROR(TBX_RESULT_FAIL, 0, "Unable to open operation library");
}
}
/* Activate the host lib inter-adapter communications */
if (g_AppContext->fTestModeActivated)
{
result = TBXGetLibParams (g_AppContext->hTbxLib, &LibParam);
if (TBX_RESULT_FAILURE (result))
{
TBX_EXIT_ERROR(result, 0, "Unable to retrieve host library parameters");
}
LibParam.fEnableInterAppCommunication = TBX_TRUE;
result = TBXModifLibParams (g_AppContext->hTbxLib, &LibParam);
if (TBX_RESULT_FAILURE (result))
{
TBX_EXIT_ERROR(result, 0, "Unable to modify host library parameters");
}
}
/***************************************************************/
/* At this point, we start sync'ing process for this adapter */
/***************************************************************/
if (g_AppContext->fTestModeActivated)
{
/* Yield the CPU to make sure all async lib processes to get into their receive thread */
TBX_SLEEP_MS (1000);
if (g_AppContext->hTbTestCtrl == 0)
{
TBX_EXIT_ERROR(result, 0, "Cannot find tb test controller");
}
}
}
/* Allocate trunks */
result = TB640CasAllocateTrunks ();
if (TBX_RESULT_FAILURE (result))
{
TBX_EXIT_ERROR(TBX_RESULT_FAIL, 0, "Unable to allocate trunks");
}
/* Activate trunks */
result = TB640CasActivateTrunks ();
if (TBX_RESULT_FAILURE (result))
{
TBX_EXIT_ERROR(TBX_RESULT_FAIL, 0, "Unable to activate trunks");
}
/* Allocate trunk resources */
result = TB640CasAllocateTrunkResources ();
if (TBX_RESULT_FAILURE (result))
{
TBX_EXIT_ERROR(TBX_RESULT_FAIL, 0, "Unable to allocate trunk resources");
}
/* Allocate CTbus resource on each adapters */
result = TB640CasAllocateCtBusResources ();
if (TBX_RESULT_FAILURE (result))
{
TBX_EXIT_ERROR(TBX_RESULT_FAIL, 0, "Unable to allocate CTbus resources");
}
/* Allocate stacks */
result = TB640CasAllocateStacks ();
if (TBX_RESULT_FAILURE (result))
{
TBX_EXIT_ERROR(TBX_RESULT_FAIL, 0, "Unable to allocate stacks");
}
/* End of the code (skip to cleanup) */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Error handling section
*--------------------------------------------------------------------------------------------------------------------------*/
ERROR_HANDLING
{
/* Print error message */
TB640_CAS_LOG (TRACE_LEVEL_ALWAYS, "%s (Result = 0x%08X, %s, line %d)\n", TBX_ERROR_DESCRIPTION, TBX_ERROR_RESULT, __FILE__, TBX_ERROR_LINE);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Cleanup section
*--------------------------------------------------------------------------------------------------------------------------*/
CLEANUP
{
}
RETURN;
}
/*-------------------------------------------------------------------------------------------------------------------------------
|
| TB640CasCleanSystem: This function desallocates and free the trunks, stacks, CTBus resources and operation librairies
| that were (maybe partially) opened by TB640CasConfigureSystem().
|
| ~ : No arguments used
|
| Note : ~
|
| Return : TBX_RESULT_OK
| TBX_RESULT_FAIL
|
*------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT
TB640CasCleanSystem (void)
{
TBX_RESULT result;
TBX_UINT32 un32Count;
TBX_UINT32 un32Count2;
PTB640_CAS_ADAPTER_INFO pAdapterInfo;
/*---------------------------------------------------------------------------------------------------------------------------
| Code section
*--------------------------------------------------------------------------------------------------------------------------*/
CODE
{
/* Initialize local variables */
/* Check if the TBX library was opened */
if (g_AppContext->hTbxLib == (TBX_LIB_HANDLE)NULL)
{
/* Nothing to do (library hasn't been opened */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/* Close the operation libraries */
for (un32Count=0; un32Count<g_AppContext->un32NbAdapter; un32Count++)
{
pAdapterInfo = &(g_AppContext->ahAdapterInfo [un32Count]);
for (un32Count2=0; un32Count2<TB640_CAS_NB_OPERATION_LIBRARY_REQUIRED; un32Count2++)
{
if (pAdapterInfo->ahOperationLib [un32Count2] != (TBX_ASYNC_LIB_HANDLE)NULL)
{
/* Close the library */
result = TBXAsyncClose (pAdapterInfo->ahOperationLib [un32Count2]);
if (TBX_RESULT_FAILURE (result))
{
TBX_EXIT_ERROR(TBX_RESULT_FAIL, 0, "Unable to close operation library");
}
pAdapterInfo->ahOperationLib [un32Count2] = NULL;
}
}
}
/* Destroy the transiant calls semaphore */
if( g_AppContext->TransientCallsSem )
{
TBX_SEM_DESTROY (&(g_AppContext->TransientCallsSem));
}
if (g_AppContext->un32TransientCalls > 0)
{
TB640_CAS_LOG (TRACE_LEVEL_4, "%d calls were still transient when you exited the application.\n", g_AppContext->un32TransientCalls);
TB640_CAS_LOG (TRACE_LEVEL_4, "This could results in resource leak(s)\n");
}
/* Free stacks */
TB640CasFreeStacks ();
/* Destroy connections */
TB640CasDestroyConnections ();
/* Free CTbus resource on each adapters */
TB640CasFreeCtBusResources ();
/* Free trunk resources */
TB640CasFreeTrunkResources ();
/* Put trunks in maintenance mode */
TB640CasMaintenanceTrunks ();
/* Free trunks */
TB640CasFreeTrunks ();
/* Closed opened adapters */
TB640CasCloseAdapters ();
/* Destroy the operation lib semaphores */
for (un32Count=0; un32Count<g_AppContext->un32NbAdapter; un32Count++)
{
pAdapterInfo = &(g_AppContext->ahAdapterInfo [un32Count]);
for (un32Count2=0; un32Count2<TB640_CAS_NB_OPERATION_LIBRARY_REQUIRED; un32Count2++)
{
if( pAdapterInfo->Lock.aOperationLibSem[ un32Count2 ] != (TBX_SEM)TBX_HANDLE_INVALID )
{
TBX_SEM_DESTROY (&(pAdapterInfo->Lock.aOperationLibSem[ un32Count2 ]));
}
}
}
/* Close the TBX library */
TBXCloseLib (g_AppContext->hTbxLib);
g_AppContext->hTbxLib = (TBX_LIB_HANDLE)TBX_HANDLE_INVALID;
/* Destroy stress-test statistics semaphore */
TBX_SEM_DESTROY (&g_StressStatsSem);
/* End of the code (skip to cleanup) */
TBX_EXIT_SUCCESS (TBX_RESULT_OK);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Error handling section
*--------------------------------------------------------------------------------------------------------------------------*/
ERROR_HANDLING
{
/* Print error message */
TB640_CAS_LOG (TRACE_LEVEL_ALWAYS, "%s (Result = 0x%08X, %s, line %d)\n", TBX_ERROR_DESCRIPTION, TBX_ERROR_RESULT, __FILE__, TBX_ERROR_LINE);
}
/*---------------------------------------------------------------------------------------------------------------------------
| Cleanup section
*--------------------------------------------------------------------------------------------------------------------------*/
CLEANUP
{
}
RETURN;
}
/*--------------------------------------------------------------------------------------------------------------------------------
| Utility functions
*------------------------------------------------------------------------------------------------------------------------------*/
static void
TB640CasGetAdapterIpAddresses(
IN PTBX_ADAPTER_INFO in_pAdapterInfo,
OUT TBX_CHAR out_szIpAddresses[ 256 ]
)
{
out_szIpAddresses [0] = '\0';
if( in_pAdapterInfo->szIpAddress0[0] != 0 && in_pAdapterInfo->szIpAddress1[0] != '\0' )
{
sprintf
(
out_szIpAddresses,
"%s, %s, redundant ethernet",
in_pAdapterInfo->szIpAddress0,
in_pAdapterInfo->szIpAddress1
);
}
else if( in_pAdapterInfo->szIpAddress0[0] != 0 )
{
sprintf
(
out_szIpAddresses,
"%s",
in_pAdapterInfo->szIpAddress0
);
}
else if( in_pAdapterInfo->szIpAddress1[0] != 0 )
{
sprintf
(
out_szIpAddresses,
"%s",
in_pAdapterInfo->szIpAddress1
);
}
return;
}
/*-------------------------------------------------------------------------------------------------------------------------------
|
| TB640CasCheckAdapterFeatures:
|
| ~ : No arguments used
|
| Note : ~
|
| Return :
|
*------------------------------------------------------------------------------------------------------------------------------*/
#define SET_FEATURE_MISMATCH_AND_RESULT(featureId, aMismatch, result ) \
do { \
aMismatch[featureId] = TBX_TRUE; \
result = TBX_RESULT_NOT_SUPPORTED_BY_LICENSE; \
} while(0)
#define SET_TRUNK_MISMATCH_AND_RESULT(featureId, aMismatch, result, fTrunkMismatch ) \
do { \
aMismatch[featureId] = TBX_TRUE; \
result = TBX_RESULT_NOT_SUPPORTED_BY_LICENSE; \
fTrunkMismatch = TBX_TRUE; \
} while(0)
#define STR_TOKEN_SIZE 20
#define STR_TOKEN_LINE_SIZE 80
/* This size should be sufficient for to log adapter info and Licence features unmatching configuration (max 40 lignes de 80 char. */
#define STR_LOG_BUFFER_LICENSE_FEATURE_SIZE (40*80)
/* This size should be sufficient for to log Trunk configuration unmatching license features (max 70 ligne de 80 char.) */
#define STR_LOG_BUFFER_TRUNK_CONFIG_SIZE (80*80)
TBX_UINT32 g_au32TrunkTypeToFeatureId[TB640_TRUNK_TYPE_LAST] = {
(TBX_UINT32)NULL,
TBX_FEATURE_TYPE_TRUNK_E1,
TBX_FEATURE_TYPE_TRUNK_T1,
TBX_FEATURE_TYPE_TRUNK_J1 };
TBX_UINT32 g_au32CasVariantToFeatureId[TB640_CAS_VARIANT_LAST] = {
(TBX_UINT32)NULL, /* TB640_CAS_VARIANT_FIRST */
TBX_FEATURE_TYPE_CAS_R1_WINK_START, /* TB640_CAS_VARIANT_WINK_START */
TBX_FEATURE_TYPE_CAS_FXS_GROUND_START, /* TB640_CAS_VARIANT_FXS_GROUND_START */
TBX_FEATURE_TYPE_CAS_FXS_LOOP_START, /* TB640_CAS_VARIANT_FXS_LOOP_START */
TBX_FEATURE_TYPE_CAS_FXO, /* TB640_CAS_VARIANT_FXO */
TBX_FEATURE_TYPE_CAS_R1_TAIWAN, /* TB640_CAS_VARIANT_TAIWAN_R1 */
(TBX_UINT32)NULL, /* TB640_CAS_VARIANT_RESERVED */
TBX_FEATURE_TYPE_CAS_R2_CHINA, /* TB640_CAS_VARIANT_R2_CHINA */
TBX_FEATURE_TYPE_CAS_R2_KOREA, /* TB640_CAS_VARIANT_R2_KOREA */
TBX_FEATURE_TYPE_CAS_R2_SINGAPORE, /* TB640_CAS_VARIANT_R2_SINGAPORE */
TBX_FEATURE_TYPE_CAS_R2_BANGLADESH, /* TB640_CAS_VARIANT_R2_BANGLADESH */
TBX_FEATURE_TYPE_CAS_R2_GENERIC}; /* TB640_CAS_VARIANT_R2_GENERIC */
PTBX_CHAR g_apszTrunkTypeString[TB640_TRUNK_TYPE_LAST] = { NULL, "E1", "T1", "J1" };
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -