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

📄 voip_config.c

📁 telcobridges voip develop
💻 C
📖 第 1 页 / 共 3 页
字号:
			/* Open stream server library */
			Result = VoipStreamServerOpen( pCurrentConfig->szStreamServerIp0, pCurrentConfig->szStreamServerIp1 );
			if( TBX_RESULT_SUCCESS( Result ) )
			{
				TbxCliToolsLogPrint( pCliContext->hCliTools, TRACE_LEVEL_ALWAYS, NULL, "Starting stream server operation...\n");

				/* Start stream server */
				Result = VoipStreamServerStart();
				if( TBX_RESULT_FAILURE( Result ) )
				{
					TBX_EXIT_ERROR (Result, 0, "Failed to start stream server.");
				}
			}
		}

		TbxCliToolsLogPrint( pCliContext->hCliTools, TRACE_LEVEL_ALWAYS, NULL, "Updating command-line interface...\n");

		/* Update CLI context */
		Result = VoipCliUpdate();
		if( TBX_RESULT_FAILURE( Result ) )
		{
			TBX_EXIT_ERROR (Result, 0, "Failed to update CLI context.");
		}

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

	/*---------------------------------------------------------------------------------------------------------------------------
	 |  Error handling section
	 *--------------------------------------------------------------------------------------------------------------------------*/
	ERROR_HANDLING
	{
		/* Print the error to the user */
		TbxCliToolsLogPrint(
			pCliContext->hCliTools,
			TRACE_LEVEL_ERROR, NULL,
			"VoipStartInitialConfig: %s (Result 0x%08X, %s, line %d)\n",
			TBX_ERROR_DESCRIPTION,
			(int)TBX_ERROR_RESULT,
			__FILE__,
			TBX_ERROR_LINE);
	}

	/*---------------------------------------------------------------------------------------------------------------------------
	 |  Cleanup section
	 *--------------------------------------------------------------------------------------------------------------------------*/
	CLEANUP
	{
		/* Free the temporary pool of adapters */
		if( g_pContext->hTempPoolOfAdapters != (TBX_POOL_OF_BUFFERS_HANDLE)TBX_HANDLE_INVALID )
		{
			pAdapterContextNode = TBXPoolOfBuffersFirst( g_pContext->hTempPoolOfAdapters );
			while( pAdapterContextNode )
			{
				/* Clear the "target configuration" context of this adapter */
				VoipAdapterClearConfig( pAdapterContextNode->pAdapterContext->pTargetConfig );
				free( pAdapterContextNode->pAdapterContext );
				pAdapterContextNode->pAdapterContext = NULL;

				TBXPoolOfBuffersFree( g_pContext->hTempPoolOfAdapters, pAdapterContextNode );

				pAdapterContextNode = TBXPoolOfBuffersFirst( g_pContext->hTempPoolOfAdapters );
			}

			/* Free the pool of adapter contexts */
			TBXPoolOfBuffersDestroy( g_pContext->hTempPoolOfAdapters );
			g_pContext->hTempPoolOfAdapters = (TBX_POOL_OF_BUFFERS_HANDLE)TBX_HANDLE_INVALID;
		}
	}

	RETURN;
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipConfigureNetworkRedundancy	:	Configure network redundancy for a remote peer
 |
 |  in_hAdapter						:	Adapter handle to configure network redundancy for.
 |	in_fUsed						:	This adapter is used or not used with this setup
 |
 |  Note							:	~
 |
 |  Return							:	TBX_RESULT_OK if network redundancy could be configured
 |										Other error code otherwise.
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT VoipConfigureNetworkRedundancy( 
	IN		TBX_ADAPTER_HANDLE	in_hAdapter,
	IN		TBX_BOOL			in_fUsed)
{
	TBX_RESULT							Result;
	PVOIP_CLI_CONTEXT					pCliContext;
	TBX_NETWORK_REDUNDANCY_PARAMETERS	RedundancyParams;
	PVOIP_CONFIG						pConfig;

	/*---------------------------------------------------------------------------------------------------------------------------
	 |  Code section
	 *--------------------------------------------------------------------------------------------------------------------------*/
	CODE
	{
		/* Initialize local variables */
		pCliContext	= &g_pContext->CliContext;
		pConfig		= &g_pContext->CurrentConfig;

		/* Configure network redundancy for this adapter */
		Result = TBXGetNetworkRedundancyState
		(
			g_pContext->hTbxLib,
			in_hAdapter,
			&RedundancyParams,
			NULL,
			NULL
		);
		if( TBX_RESULT_FAILURE( Result ) )
		{
			TBX_EXIT_ERROR (TBX_RESULT_NOT_FOUND, 0, "Failed to get network redundancy state.");
		}

		RedundancyParams.un32NetworkDownDelayMs	= pConfig->un32NetworkDownDelayMs;
		RedundancyParams.un32AdapterDownDelayMs	= pConfig->un32AdapterDownDelayMs;
		RedundancyParams.un32PollDelayMs		= pConfig->un32PollDelayMs;

		if( in_fUsed )
		{
			RedundancyParams.fUseNetworkGw0	= TBX_TRUE;
			RedundancyParams.fUseNetworkGw1	= TBX_TRUE;
		}
		else
		{
			RedundancyParams.fUseNetworkGw0	= TBX_FALSE;
			RedundancyParams.fUseNetworkGw1	= TBX_FALSE;
		}

		Result = TBXConfigureNetworkRedundancy
		(
			g_pContext->hTbxLib,
			in_hAdapter,
			&RedundancyParams
		);
		if( TBX_RESULT_FAILURE( Result ) )
		{
			TBX_EXIT_ERROR (TBX_RESULT_NOT_FOUND, 0, "Failed to configure network redundancy.");
		}

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

	/*---------------------------------------------------------------------------------------------------------------------------
	 |  Error handling section
	 *--------------------------------------------------------------------------------------------------------------------------*/
	ERROR_HANDLING
	{
		/* Print the error to the user */
		TbxCliToolsLogPrint(
			pCliContext->hCliTools,
			TRACE_LEVEL_ERROR, NULL,
			"VoipConfigureNetworkRedundancy: 0x%08X: %s (Result 0x%08X, %s, line %d)\n",
			(int)in_hAdapter,
			TBX_ERROR_DESCRIPTION,
			(int)TBX_ERROR_RESULT,
			__FILE__,
			TBX_ERROR_LINE);
	}

	/*---------------------------------------------------------------------------------------------------------------------------
	 |  Cleanup section
	 *--------------------------------------------------------------------------------------------------------------------------*/
	CLEANUP
	{
	}

	RETURN;
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipTrunkNameGetKey		:	Function to get hash key from pointer to trunk config.
 |								The Hash table hash key is the trunk name.
 |
 |  in_pAdapterContext		:	Pointer to trunk config structure
 |								(cast to PVOIP_TRUNK_CONFIG)
 |
 |  Note					:	~
 |
 |  Return					:	Hash key associated with trunk name
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_HASH_KEY VoipTrunkNameGetKey(
	IN		PTBX_VOID	in_pUserContext,
	IN		PTBX_VOID	in_pTrunkConfig)
{
	(TBX_VOID)in_pUserContext;

	return (TBX_HASH_KEY)( ( (PVOIP_TRUNK_CONFIG)in_pTrunkConfig )->szTrunkName );
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipMblPortNameGetKey	:	Function to get hash key from pointer to MBL port config.
 |								The Hash table hash key is the MBL port name.
 |
 |  in_pAdapterContext		:	Pointer to MBL port config structure
 |								(cast to PVOIP_MBL_PORT_CONFIG)
 |
 |  Note					:	~
 |
 |  Return					:	Hash key associated with trunk name
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_HASH_KEY VoipMblPortNameGetKey(
	IN		PTBX_VOID	in_pUserContext,
	IN		PTBX_VOID	in_pMblPortConfig)
{
	(TBX_VOID)in_pUserContext;

	return (TBX_HASH_KEY)( ( (PVOIP_MBL_PORT_CONFIG)in_pMblPortConfig )->szPortName );
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipResHandleGetKey	:	Function to get hash key from pointer to resource context.
 |							The Hash table hash key is the associated resource handle.
 |
 |  in_pRes				:	Pointer to resource context structure
 |							(cast to PVOIP_RES)
 |
 |  Note				:	~
 |
 |  Return				:	Hash key associated with resource context.
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_HASH_KEY VoipResHandleGetKey(
	IN		PTBX_VOID	in_pUserContext,
	IN		PTBX_VOID	in_pRes)
{
	(TBX_VOID)in_pUserContext;

	return (TBX_HASH_KEY)( ((PVOIP_RES)in_pRes)->hRes );
}

/*--------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipPromptContextGetKey	:	Function called by the hash table to retrieve the key (user context)
 |								from the element stored in the hash table (pointer to the stream server call
 |								context structure)
 |
 |  Note					:	~
 |								
 |  Return					:	Hash key associated to prompt configuration
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_HASH_KEY	VoipPromptContextGetKey(
	IN		PTBX_VOID	in_pUserContext,
	IN		PTBX_VOID	in_pElement)
{
	PVOIP_PROMPT_CONTEXT	pPromptContext = (PVOIP_PROMPT_CONTEXT)in_pElement;

	(TBX_VOID)in_pUserContext;

	return (TBX_HASH_KEY)pPromptContext->un32ConnectionId;
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipPromptNameGetKey	:	Function to get hash key from pointer to prompt configuration context.
 |								The Hash table hash key is the prompt name.
 |										
 |
 |  in_pPromptContext		:	Pointer to prompt context structure
 |								(cast to PVOIP_PROMPT_CONTEXT)
 |
 |  Note					:	~
 |
 |  Return					:	Hash key associated to prompt configuration
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_HASH_KEY VoipPromptNameGetKey(
	IN		PTBX_VOID	in_pUserContext,
	IN		PTBX_VOID	in_pPromptContext)
{
	(TBX_VOID)in_pUserContext;

	return (TBX_HASH_KEY)( ( (PVOIP_PROMPT_CONTEXT)in_pPromptContext )->Params.szPromptName );
}

/*--------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipRawDataFileContextGetKey	:	Function called by the hash table to retrieve the key (user context)
 |								from the element stored in the hash table (pointer to the stream server call
 |								context structure)
 |
 |  Note					:	~
 |								
 |  Return					:	Hash key associated to raw data file configuration
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_HASH_KEY	VoipRawDataFileContextGetKey(
	IN		PTBX_VOID	in_pUserContext,
	IN		PTBX_VOID	in_pElement)
{
	PVOIP_RAW_DATA_FILE_CONTEXT	pRawDataFileContext = (PVOIP_RAW_DATA_FILE_CONTEXT)in_pElement;

	(TBX_VOID)in_pUserContext;

	return (TBX_HASH_KEY)pRawDataFileContext->un32ConnectionId;
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipRawDataFileNameGetKey	:	Function to get hash key from pointer to raw data file configuration context.
 |								The Hash table hash key is the raw data file name.
 |										
 |
 |  in_pRawDataFileContext		:	Pointer to raw data file context structure
 |								(cast to PVOIP_RAW_DATA_FILE_CONTEXT)
 |
 |  Note					:	~
 |
 |  Return					:	Hash key associated to raw data file configuration
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_HASH_KEY VoipRawDataFileNameGetKey(
	IN		PTBX_VOID	in_pUserContext,
	IN		PTBX_VOID	in_pRawDataFileContext)
{
	(TBX_VOID)in_pUserContext;

	return (TBX_HASH_KEY)( ( (PVOIP_RAW_DATA_FILE_CONTEXT)in_pRawDataFileContext )->Params.szRawDataFileResName );
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipRawDataFileIdGetKey	:	Function to get hash key from pointer to raw data file configuration context.
 |								The Hash64 table hash key is the raw data file id.
 |										
 |
 |  in_pRawDataFileContext		:	Pointer to raw data file context structure
 |								(cast to PVOIP_RAW_DATA_FILE_CONTEXT)
 |
 |  Note					:	~
 |
 |  Return					:	Hash64 key associated to raw data file configuration
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_HASH_64_KEY VoipRawDataFileIdGetKey(
	IN		PTBX_VOID	in_pUserContext,
	IN		PTBX_VOID	in_pRawDataFileContext)
{
	(TBX_VOID)in_pUserContext;

	return (TBX_HASH_64_KEY)( ( (PVOIP_RAW_DATA_FILE_CONTEXT)in_pRawDataFileContext )->un64Id );
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipTrunkResGetKey	:	Function to get hash key from pointer to trunk resource context.
 |							The Hash table hash key is the connection identifier.
 |
 |  in_pTrunkRes		:	Pointer to trunk resource context
 |							(cast to PVOIP_TRUNK_RES)
 |
 |  Note				:	~
 |
 |  Return				:	Hash key associated with connection identifier.
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_HASH_KEY VoipTrunkResGetKey(
	IN		PTBX_VOID	in_pUserContext,
	IN		PTBX_VOID	in_pTrunkRes)
{
	(TBX_VOID)in_pUserContext;

	return (TBX_HASH_KEY)( ( (PVOIP_TRUNK_RES)in_pTrunkRes )->Common.un32ConnectionId );
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipConnectionGetKey	:	Function to get hash key from pointer to connection context.
 |								The Hash table hash key is the connection identifier.
 |
 |  in_pConnectionContext	:	Pointer to connection context structure
 |								(cast to PVOIP_CONNECTION_CONTEXT)
 |
 |  Note					:	~
 |
 |  Return					:	Hash key associated with connection context.
 |
 *------------------------------------------------------------------------------------------------------------------------------*/

⌨️ 快捷键说明

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