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

📄 voip_msg.c

📁 telcobridges voip develop
💻 C
📖 第 1 页 / 共 4 页
字号:
		/* 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_STOP_STRESS_TEST,
			TBX_MSG_TYPE_REQUEST,
			un32MsgSize,
			TBX_HOSTLIB_ADAPTER_HANDLE,
			pAdapterContext->AdapterInfo.hAdapter,
			0
		);

		/* Fill the request */
		pEvt = (PVOIP_EVT_OP_STOP_STRESS_TEST) 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,
			"VoipCliSendStopStressTest: %s (Result 0x%08X, %s, line %d)\n",
			TBX_ERROR_DESCRIPTION,
			(int)TBX_ERROR_RESULT,
			__FILE__,
			TBX_ERROR_LINE);
	}

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

	RETURN;
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipCliSendResetStressTestStats	:	Send a message type VOIP_MSG_ID_OP_RESET_STRESS_TEST_STATS
 |										to the main state machine.
 |
 |	in_pCliContext					:	Cli context
 |
 |  Note							:	~
 |
 |  Return							:	~
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT VoipCliSendResetStressTestStats(
	IN		PVOIP_CLI_CONTEXT	in_pCliContext )
{
	TBX_RESULT								Result;
	PVOIP_CLI_CONTEXT						pCliContext;
	PVOIP_EVT_OP_RESET_STRESS_TEST_STATS	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_RESET_STRESS_TEST_STATS,
			TBX_MSG_TYPE_REQUEST,
			un32MsgSize,
			TBX_HOSTLIB_ADAPTER_HANDLE,
			pAdapterContext->AdapterInfo.hAdapter,
			0
		);

		/* Fill the request */
		pEvt = (PVOIP_EVT_OP_RESET_STRESS_TEST_STATS) 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,
			"VoipCliSendResetStressTestStats: %s (Result 0x%08X, %s, line %d)\n",
			TBX_ERROR_DESCRIPTION,
			(int)TBX_ERROR_RESULT,
			__FILE__,
			TBX_ERROR_LINE);
	}

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

	RETURN;
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipCliSendStartDemo	:	Send a message type VOIP_MSG_ID_OP_START_DEMO
 |								to the main state machine.
 |
 |	in_pCliContext			:	Cli context
 |	in_fSkipPauses			:	Skip pauses
 |	in_fAutoAbort			:	Automatically abort demo on failure
 |
 |  Note					:	~
 |
 |  Return					:	~
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT VoipCliSendStartDemo(
	IN		PVOIP_CLI_CONTEXT		in_pCliContext,
	IN		TBX_BOOL				in_fSkipPauses,
	IN		TBX_BOOL				in_fAutoAbort )
{
	TBX_RESULT					Result;
	PVOIP_CLI_CONTEXT			pCliContext;
	PVOIP_EVT_OP_START_DEMO		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_START_DEMO,
			TBX_MSG_TYPE_REQUEST,
			un32MsgSize,
			TBX_HOSTLIB_ADAPTER_HANDLE,
			pAdapterContext->AdapterInfo.hAdapter,
			0
		);

		/* Fill the request */
		pEvt = (PVOIP_EVT_OP_START_DEMO) TBX_MSG_PAYLOAD_POINTER (hMsg);
		pEvt->un32MsgVersion	= 1;
		pEvt->fSkipPauses		= in_fSkipPauses;
		pEvt->fAutoAbort		= in_fAutoAbort;

		/* 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,
			"VoipCliSendStartDemo: %s (Result 0x%08X, %s, line %d)\n",
			TBX_ERROR_DESCRIPTION,
			(int)TBX_ERROR_RESULT,
			__FILE__,
			TBX_ERROR_LINE);
	}

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

	RETURN;
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipCliSendStopDemo		:	Send a message type VOIP_MSG_ID_OP_STOP_DEMO
 |								to the main state machine.
 |
 |	in_pCliContext			:	Cli context
 |
 |  Note					:	~
 |
 |  Return					:	~
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT VoipCliSendStopDemo(
	IN		PVOIP_CLI_CONTEXT	in_pCliContext )
{
	TBX_RESULT				Result;
	PVOIP_CLI_CONTEXT		pCliContext;
	PVOIP_EVT_OP_STOP_DEMO	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_STOP_DEMO,
			TBX_MSG_TYPE_REQUEST,
			un32MsgSize,
			TBX_HOSTLIB_ADAPTER_HANDLE,
			pAdapterContext->AdapterInfo.hAdapter,
			0
		);

		/* Fill the request */
		pEvt = (PVOIP_EVT_OP_STOP_DEMO) 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);

⌨️ 快捷键说明

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