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

📄 voip_msg.c

📁 telcobridges voip develop
💻 C
📖 第 1 页 / 共 4 页
字号:
	}

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

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

	RETURN;
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipCliSendNextDemoStep		:	Send a message type VOIP_MSG_ID_OP_NEXT_DEMO_STEP
 |									to the main state machine.
 |
 |	in_pCliContext				:	Cli context
 |
 |  Note						:	~
 |
 |  Return						:	~
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT VoipCliSendNextDemoStep(
	IN		PVOIP_CLI_CONTEXT	in_pCliContext )
{
	TBX_RESULT					Result;
	PVOIP_CLI_CONTEXT			pCliContext;
	PVOIP_EVT_OP_NEXT_DEMO_STEP	pEvt;
	TBX_MSG_HANDLE				hMsg;
	TBX_UINT32					un32MsgSize;
	PVOIP_ADAPTER_CONTEXT		pAdapterContext;

	/*---------------------------------------------------------------------------------------------------------------------------
	 |  Code section
	 *--------------------------------------------------------------------------------------------------------------------------*/
	CODE
	{
		/* Initialize local variables */
		Result		= TBX_RESULT_OK;
		pCliContext	= &g_pContext->CliContext;
		pEvt		= NULL;

		/* Retrieve the active adapter context */
		pAdapterContext = in_pCliContext->pActiveAdapterContext;

		/* Allocate the message buffer */
		un32MsgSize = sizeof(*pEvt);
		Result = TBXGetMsg (g_pContext->hTbxLib, un32MsgSize , &hMsg);
		if (TBX_RESULT_FAILURE (Result))
		{
			TBX_EXIT_ERROR (Result, 0, "Failed to get message buffer.");
		}

		/* Clear the buffer... */
		memset (TBX_MSG_PAYLOAD_POINTER (hMsg), 0, TBX_MSG_PAYLOAD_MAX_LENGTH_GET (hMsg));

		/* Set the message header */
		TBX_FORMAT_MSG_HEADER
		(
			hMsg,
			VOIP_MSG_ID_OP_NEXT_DEMO_STEP,
			TBX_MSG_TYPE_REQUEST,
			un32MsgSize,
			TBX_HOSTLIB_ADAPTER_HANDLE,
			pAdapterContext->AdapterInfo.hAdapter,
			0
		);

		/* Fill the request */
		pEvt = (PVOIP_EVT_OP_NEXT_DEMO_STEP) TBX_MSG_PAYLOAD_POINTER (hMsg);
		pEvt->un32MsgVersion = 1;

		/* Send the message */
		Result	= TBXSendMsg (g_pContext->hTbxLib, hMsg, NULL);
		hMsg	= TBX_HANDLE_INVALID;
		pEvt	= NULL;

		if (TBX_RESULT_FAILURE (Result))
		{
			TBX_EXIT_ERROR (Result, 0, "Failed to send message buffer.");
		}

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

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

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

	RETURN;
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipCliSendAllocateConnection	:	Send a message type VOIP_MSG_ID_OP_ALLOCATE_CONNECTION
 |										to the main state machine.
 |
 |	in_pCliContext				:
 |	in_pConnectionParams		:	Connection parameters
 |	in_un32NbConnections		:	Number of connections
 |	in_un16IPPortIncrement		:	IP port increment
 |
 |  Note						:	~
 |
 |  Return						:	~
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT VoipCliSendAllocateConnection(
	IN		PVOIP_CLI_CONTEXT		in_pCliContext,
	IN		PVOIP_CONNECTION_PARAMS	in_pConnectionParams,
	IN		TBX_UINT32				in_un32NbConnections,
	IN		TBX_UINT16				in_un16IPPortIncrement )
{
	TBX_RESULT							Result;
	PVOIP_CLI_CONTEXT					pCliContext;
	PVOIP_EVT_OP_ALLOCATE_CONNECTION	pEvt;
	TBX_MSG_HANDLE						hMsg;
	TBX_UINT32							un32MsgSize;
	PVOIP_ADAPTER_CONTEXT				pAdapterContext;

	/*---------------------------------------------------------------------------------------------------------------------------
	 |  Code section
	 *--------------------------------------------------------------------------------------------------------------------------*/
	CODE
	{
		/* Initialize local variables */
		Result		= TBX_RESULT_OK;
		pCliContext	= &g_pContext->CliContext;
		pEvt		= NULL;

		/* Retrieve the active adapter context */
		pAdapterContext = in_pCliContext->pActiveAdapterContext;

		/* Allocate the message buffer */
		un32MsgSize = sizeof(*pEvt);
		Result = TBXGetMsg (g_pContext->hTbxLib, un32MsgSize , &hMsg);
		if (TBX_RESULT_FAILURE (Result))
		{
			TBX_EXIT_ERROR (Result, 0, "Failed to get message buffer.");
		}

		/* Clear the buffer... */
		memset (TBX_MSG_PAYLOAD_POINTER (hMsg), 0, TBX_MSG_PAYLOAD_MAX_LENGTH_GET (hMsg));

		/* Set the message header */
		TBX_FORMAT_MSG_HEADER
		(
			hMsg,
			VOIP_MSG_ID_OP_ALLOCATE_CONNECTION,
			TBX_MSG_TYPE_REQUEST,
			un32MsgSize,
			TBX_HOSTLIB_ADAPTER_HANDLE,
			pAdapterContext->AdapterInfo.hAdapter,
			0
		);

		/* Fill the request */
		pEvt = (PVOIP_EVT_OP_ALLOCATE_CONNECTION) TBX_MSG_PAYLOAD_POINTER (hMsg);
		pEvt->un32MsgVersion		= 1;
		pEvt->Params				= *in_pConnectionParams;
		pEvt->un32NbConnections		= in_un32NbConnections;
		pEvt->un16IPPortIncrement	= in_un16IPPortIncrement;

		/* Send the message */
		Result	= TBXSendMsg (g_pContext->hTbxLib, hMsg, NULL);
		hMsg	= TBX_HANDLE_INVALID;
		pEvt	= NULL;

		if (TBX_RESULT_FAILURE (Result))
		{
			TBX_EXIT_ERROR (Result, 0, "Failed to send message buffer.");
		}

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

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

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

	RETURN;
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipCliSendClearConnection	:	Send a message type VOIP_MSG_ID_OP_CLEAR_CONNECTION
 |									to the main state machine.
 |
 |	in_pCliContext				:
 |	in_fAll						:	Tell to disconnect all resources when TBX_TRUE
 |	in_fIncludeInfiniteDur		:	Clear connections with infinite call duration also?
 |	in_un32ConnectionId			:	Identifier of the connection to destroy.
 |
 |  Note						:	~
 |
 |  Return						:	~
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT VoipCliSendClearConnection(
	IN		PVOIP_CLI_CONTEXT	in_pCliContext,
	IN		TBX_BOOL			in_fAll,
	IN		TBX_BOOL			in_fIncludeInfiniteDur,
	IN		TBX_UINT32			in_un32ConnectionId )
{
	TBX_RESULT						Result;
	PVOIP_CLI_CONTEXT				pCliContext;
	PVOIP_EVT_OP_CLEAR_CONNECTION	pEvt;
	TBX_MSG_HANDLE					hMsg;
	TBX_UINT32						un32MsgSize;
	PVOIP_ADAPTER_CONTEXT			pAdapterContext;

	/*---------------------------------------------------------------------------------------------------------------------------
	 |  Code section
	 *--------------------------------------------------------------------------------------------------------------------------*/
	CODE
	{
		/* Initialize local variables */
		Result		= TBX_RESULT_OK;
		pCliContext	= &g_pContext->CliContext;
		pEvt		= NULL;

		/* Retrieve the active adapter context */
		pAdapterContext = in_pCliContext->pActiveAdapterContext;

		/* Allocate the message buffer */
		un32MsgSize = sizeof(*pEvt);
		Result = TBXGetMsg (g_pContext->hTbxLib, un32MsgSize , &hMsg);
		if (TBX_RESULT_FAILURE (Result))
		{
			TBX_EXIT_ERROR (Result, 0, "Failed to get message buffer.");
		}

		/* Clear the buffer... */
		memset (TBX_MSG_PAYLOAD_POINTER (hMsg), 0, TBX_MSG_PAYLOAD_MAX_LENGTH_GET (hMsg));

		/* Set the message header */
		TBX_FORMAT_MSG_HEADER
		(
			hMsg,
			VOIP_MSG_ID_OP_CLEAR_CONNECTION,
			TBX_MSG_TYPE_REQUEST,
			un32MsgSize,
			TBX_HOSTLIB_ADAPTER_HANDLE,
			pAdapterContext->AdapterInfo.hAdapter,
			0
		);

		/* Fill the request */
		pEvt = (PVOIP_EVT_OP_CLEAR_CONNECTION) TBX_MSG_PAYLOAD_POINTER (hMsg);
		pEvt->un32MsgVersion			= 1;
		pEvt->fAll						= in_fAll;
		pEvt->fIncludeInfiniteDurCall	= in_fIncludeInfiniteDur;
		pEvt->un32ConnectionId			= in_un32ConnectionId;

		/* Send the message */
		Result	= TBXSendMsg (g_pContext->hTbxLib, hMsg, NULL);
		hMsg	= TBX_HANDLE_INVALID;
		pEvt	= NULL;

		if (TBX_RESULT_FAILURE (Result))
		{
			TBX_EXIT_ERROR (Result, 0, "Failed to send message buffer.");
		}

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

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

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

	RETURN;
}

⌨️ 快捷键说明

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