⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 voip_adapter_compare.c

📁 telcobridges voip develop
💻 C
📖 第 1 页 / 共 5 页
字号:
/*--------------------------------------------------------------------------------------------------------------------------------
 |
 |	Project:    	VOIP sample
 |
 |	Filename:   	voip_adapter_compare.c
 |
 |	Copyright:  	TelcoBridges 2002-2004, All Rights Reserved
 |
 |	Description:	This file contains functions used to compare target and current adapter configurations
 |
 |	Notes:      	Tabs = 4
 |
 *-------------------------------------------------------------------------------------------------------------------------------
 |
 |	Revision:   	$Revision: 1.19 $
 |
 *------------------------------------------------------------------------------------------------------------------------------*/


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Includes
 *------------------------------------------------------------------------------------------------------------------------------*/

#include "voip_includes.h"


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Forward declarations
 *------------------------------------------------------------------------------------------------------------------------------*/


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Defines
 *------------------------------------------------------------------------------------------------------------------------------*/


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Types
 *------------------------------------------------------------------------------------------------------------------------------*/


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Versioning
 *------------------------------------------------------------------------------------------------------------------------------*/

#ifdef WIN32
/*@unused@*/ static char g_szFileVersion [] = "$Revision: 1.19 $";
#endif


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Global variables
 *------------------------------------------------------------------------------------------------------------------------------*/


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Macros
 *------------------------------------------------------------------------------------------------------------------------------*/


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Function Prototypes
 *------------------------------------------------------------------------------------------------------------------------------*/


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Implementation
 *------------------------------------------------------------------------------------------------------------------------------*/

 /*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipAdapterClockConfigConfigureCompare	:	Compares the clock 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
 |	out_pfMustReallocate					:	Tell if must clear clock on the adapter
 |	out_pfMustSetParams						:	Tell if must "config set" clock on the adapter
 |
 |  Note									:	~
 |
 |  Return									:	TBX_RESULT_OK if the function succeeded
 |												Other error code if the function could not complete properly.
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_VOID	VoipAdapterClockConfigConfigureCompare(
	IN		PVOIP_ADAPTER_CONTEXT	in_pAdapterContext,
	OUT		PTBX_BOOL				out_pfMustReallocate,
	OUT		PTBX_BOOL				out_pfMustSetParams)
{
	PVOIP_CLOCK_CONFIG	pCurrentClockConfig;
	PVOIP_CLOCK_CONFIG	pTargetClockConfig;

	/*---------------------------------------------------------------------------------------------------------------------------
	 |  Code section
	 *--------------------------------------------------------------------------------------------------------------------------*/
	CODE
	{
		pCurrentClockConfig		= &in_pAdapterContext->CurrentConfig.Clock;
		pTargetClockConfig		= &in_pAdapterContext->pTargetConfig->Clock;
		*out_pfMustReallocate	= TBX_FALSE;
		*out_pfMustSetParams	= TBX_FALSE;

		VoipCliAdapterStatePrint( in_pAdapterContext, TRACE_LEVEL_0, "Comparing clock configuration\n" );

		if
		(
			( pCurrentClockConfig->LocalRef1.ClkSrc				!= pTargetClockConfig->LocalRef1.ClkSrc )		||
			( pCurrentClockConfig->LocalRef2.ClkSrc				!= pTargetClockConfig->LocalRef2.ClkSrc )		||
			( pCurrentClockConfig->fLocalRefAutoFallback		!= pTargetClockConfig->fLocalRefAutoFallback )	||
			( pCurrentClockConfig->MasterClk					!= pTargetClockConfig->MasterClk )				||
			( pCurrentClockConfig->InitialMasterRole			!= pTargetClockConfig->InitialMasterRole )		||
			( pCurrentClockConfig->NetRef1.ClkSrc				!= pTargetClockConfig->NetRef1.ClkSrc )			||
			( pCurrentClockConfig->NetRef2.ClkSrc				!= pTargetClockConfig->NetRef2.ClkSrc )			||
			( pCurrentClockConfig->NetRef1Freq					!= pTargetClockConfig->NetRef1Freq )			||
			( pCurrentClockConfig->NetRef2Freq					!= pTargetClockConfig->NetRef2Freq )			||
			( pCurrentClockConfig->fMBLSystemClockingEnabled	!= pTargetClockConfig->fMBLSystemClockingEnabled )
		)
		{
			*out_pfMustSetParams = TBX_TRUE;
		}

		switch( pCurrentClockConfig->LocalRef1.ClkSrc )
		{
			case TB640_CLK_SRC_TRUNK:
				if( pCurrentClockConfig->LocalRef1.un32Trunk != pTargetClockConfig->LocalRef1.un32Trunk )
					*out_pfMustSetParams = TBX_TRUE;
				break;

			case TB640_CLK_SRC_MBL:
				if( pCurrentClockConfig->LocalRef1.un32MblPort != pTargetClockConfig->LocalRef1.un32MblPort )
					*out_pfMustSetParams = TBX_TRUE;
				break;

			case TB640_CLK_SRC_BITS:
				if( pCurrentClockConfig->LocalRef1.un32BitsPort != pTargetClockConfig->LocalRef1.un32BitsPort )
					*out_pfMustSetParams = TBX_TRUE;
				break;

			default:
				break;
		}

		switch( pCurrentClockConfig->LocalRef2.ClkSrc )
		{
			case TB640_CLK_SRC_TRUNK:
				if( pCurrentClockConfig->LocalRef2.un32Trunk != pTargetClockConfig->LocalRef2.un32Trunk )
					*out_pfMustSetParams = TBX_TRUE;
				break;

			case TB640_CLK_SRC_MBL:
				if( pCurrentClockConfig->LocalRef2.un32MblPort != pTargetClockConfig->LocalRef2.un32MblPort )
					*out_pfMustSetParams = TBX_TRUE;
				break;

			case TB640_CLK_SRC_BITS:
				if( pCurrentClockConfig->LocalRef2.un32BitsPort != pTargetClockConfig->LocalRef2.un32BitsPort )
					*out_pfMustSetParams = TBX_TRUE;
				break;

			default:
				break;
		}

		switch( pCurrentClockConfig->NetRef1.ClkSrc )
		{
			case TB640_CLK_SRC_TRUNK:
				if( pCurrentClockConfig->NetRef1.un32Trunk != pTargetClockConfig->NetRef1.un32Trunk )
					*out_pfMustSetParams = TBX_TRUE;
				break;

			case TB640_CLK_SRC_MBL:
				if( pCurrentClockConfig->NetRef1.un32MblPort != pTargetClockConfig->NetRef1.un32MblPort )
					*out_pfMustSetParams = TBX_TRUE;
				break;

			case TB640_CLK_SRC_BITS:
				if( pCurrentClockConfig->NetRef1.un32BitsPort != pTargetClockConfig->NetRef1.un32BitsPort )
					*out_pfMustSetParams = TBX_TRUE;
				break;

			default:
				break;
		}

		switch( pCurrentClockConfig->NetRef2.ClkSrc )
		{
			case TB640_CLK_SRC_TRUNK:
				if( pCurrentClockConfig->NetRef2.un32Trunk != pTargetClockConfig->NetRef2.un32Trunk )
					*out_pfMustSetParams = TBX_TRUE;
				break;

			case TB640_CLK_SRC_MBL:
				if( pCurrentClockConfig->NetRef2.un32MblPort != pTargetClockConfig->NetRef2.un32MblPort )
					*out_pfMustSetParams = TBX_TRUE;
				break;

			case TB640_CLK_SRC_BITS:
				if( pCurrentClockConfig->NetRef2.un32BitsPort != pTargetClockConfig->NetRef2.un32BitsPort )
					*out_pfMustSetParams = TBX_TRUE;
				break;

			default:
				break;
		}

		/* End of the code (skip to cleanup) */
		TBX_EXIT_SUCCESS (TBX_RESULT_OK);
	}

	/*---------------------------------------------------------------------------------------------------------------------------
	 |  Error handling section
	 *--------------------------------------------------------------------------------------------------------------------------*/
	ERROR_HANDLING
	{
	}

	/*---------------------------------------------------------------------------------------------------------------------------
	 |  Cleanup section
	 *--------------------------------------------------------------------------------------------------------------------------*/
	CLEANUP
	{
		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;
}

 /*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipAdapterPromptConfigureCompare	:	Compares the prompt 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_pCurrentPromptContext			:	Current prompt context on the adapter
 |	in_pTargetPromptContext				:	Target prompt context
 |	out_pfMustReallocate				:	Tell if must clear this prompt resource on the adapter
 |	out_pfMustSetParams					:	Tell if must "config set" this prompt 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	VoipAdapterPromptConfigureCompare(
	IN		PVOIP_ADAPTER_CONTEXT	in_pAdapterContext,
	IN		PVOIP_PROMPT_CONTEXT	in_pCurrentPromptContext,
	IN		PVOIP_PROMPT_CONTEXT	in_pTargetPromptContext,
	OUT		PTBX_BOOL				out_pfMustReallocate,
	OUT		PTBX_BOOL				out_pfMustSetParams)
{
	/*---------------------------------------------------------------------------------------------------------------------------
	 |  Code section
	 *--------------------------------------------------------------------------------------------------------------------------*/
	CODE
	{
		*out_pfMustReallocate	= TBX_FALSE;
		*out_pfMustSetParams	= TBX_FALSE;

		if( !in_pCurrentPromptContext->fAllocated )
		{
			/* Not allocated. Ignore. */
			TBX_EXIT_SUCCESS (TBX_RESULT_OK);
		}

		VoipCliAdapterStatePrint
		(
			in_pAdapterContext,
			TRACE_LEVEL_0,
			"Comparing prompt %s config\n",
			in_pCurrentPromptContext->Params.szPromptName
		);

		if
		(
			in_pCurrentPromptContext->fAllocated !=
			in_pTargetPromptContext->fAllocated
		)
		{
			*out_pfMustReallocate = TBX_TRUE;
			TBX_EXIT_SUCCESS (TBX_RESULT_OK);
		}

		if( strcmp( in_pCurrentPromptContext->Params.szPathName, in_pTargetPromptContext->Params.szPathName ) != 0 )
		{
			*out_pfMustReallocate = TBX_TRUE;
			TBX_EXIT_SUCCESS (TBX_RESULT_OK);
		}

		if( in_pCurrentPromptContext->Params.un16RxIPPort != in_pTargetPromptContext->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_pCurrentPromptContext->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;
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipAdapterRawDataFileConfigureCompare	:	Compares the raw data file config on the adapter with the target config
 |											and determines if must be reallocated, reconfigured, or
 |											if configuration is already correct.
 |

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -