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

📄 voip_msg.c

📁 telcobridges voip develop
💻 C
📖 第 1 页 / 共 4 页
字号:
	/*---------------------------------------------------------------------------------------------------------------------------
	 |  Code section
	 *--------------------------------------------------------------------------------------------------------------------------*/
	CODE
	{
		/* Initialize local variables */
		Result			= TBX_RESULT_OK;
		pCliContext		= &g_pContext->CliContext;
		pEvt			= NULL;

		/* Allocate the message buffer */
		Result = TBXGetMsg (g_pContext->hTbxLib, sizeof(*pEvt), &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_BERT_STATS,
			TBX_MSG_TYPE_REQUEST,
			sizeof(*pEvt),
			TBX_HOSTLIB_ADAPTER_HANDLE,
			0,
			0
		);

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

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

	RETURN;
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipCliSendPollStreamResStats	:	Send a message type VOIP_MSG_ID_OP_POLL_STREAM_RES_STATS
 |										to the main state machine.
 |
 |	in_pCliContext					:	Cli context
 |	in_fGlobalStats					:	Global accumulated statistics
 |	in_Interface					:	Stream interface identifier to poll statistics
 |	in_un16RxIPPort					:	Stream Rx IP port to poll statistics
 |	in_un16TxIPPort					:	Stream Tx IP port to poll statistics
 |	in_fResetStats					:	Reset statistics
 |
 |  Note							:	~
 |
 |  Return							:	~
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT VoipCliSendPollStreamResStats(
	IN		PVOIP_CLI_CONTEXT			in_pCliContext,
	IN		TBX_BOOL					in_fGlobalStats,
	IN		TB640_STREAM_INTERFACE_TYPE	in_Interface,
	IN		TBX_UINT16					in_un16RxIPPort,
	IN		TBX_UINT16					in_un16TxIPPort,
	IN		TBX_BOOL					in_fResetStats )
{
	TBX_RESULT							Result;
	PVOIP_ADAPTER_CONTEXT				pAdapterContext;
	PVOIP_EVT_OP_POLL_STREAM_RES_STATS	pEvt;
	TBX_MSG_HANDLE						hMsg;

	/*---------------------------------------------------------------------------------------------------------------------------
	 |  Code section
	 *--------------------------------------------------------------------------------------------------------------------------*/
	CODE
	{
		/* Initialize local variables */
		Result			= TBX_RESULT_OK;
		pAdapterContext	= in_pCliContext->pActiveAdapterContext;
		pEvt			= NULL;

		/* Allocate the message buffer */
		Result = TBXGetMsg (g_pContext->hTbxLib, sizeof(*pEvt), &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_POLL_STREAM_RES_STATS,
			TBX_MSG_TYPE_REQUEST,
			sizeof(*pEvt),
			TBX_HOSTLIB_ADAPTER_HANDLE,
			pAdapterContext->AdapterInfo.hAdapter,
			0
		);

		/* Fill the request */
		pEvt = (PVOIP_EVT_OP_POLL_STREAM_RES_STATS) TBX_MSG_PAYLOAD_POINTER (hMsg);
		pEvt->un32MsgVersion = 1;
		pEvt->fGlobalStats	= in_fGlobalStats;
		pEvt->Interface		= in_Interface;
		pEvt->un16RxIPPort	= in_un16RxIPPort;
		pEvt->un16TxIPPort	= in_un16TxIPPort;
		pEvt->fResetStats	= in_fResetStats;

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

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

	RETURN;
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipCliSendStartStressTest		:	Send a message type VOIP_MSG_ID_OP_START_STRESS_TEST
 |										to the main state machine.
 |
 |	in_pCliContext					:	Cli context
 |	in_pszStreamSocketIP			:	Stream socket IP address.
 |	in_FirstResType					:	First resource type to use (type VOIP_RESOURCE_TYPE)
 |	in_un32ConnectionsPerSecond		:	Connections per second target
 |	in_un32MinConnectionDuration	:	Minimum connection duration
 |	in_un32MaxConnectionDuration	:	Maximum connection duration
 |	in_fAutoAbort					:	Automatically abort stress test on failure
 |	in_fClearConnection				:	Clear connection upon startup
 |	in_fDoBert						:	Do BERT testing during stress test
 |	in_un32TestDurationSec			:	Stress-test duration
 |
 |  Note						:	~
 |
 |  Return						:	~
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT VoipCliSendStartStressTest(
	IN		PVOIP_CLI_CONTEXT		in_pCliContext,
	IN		PTBX_CHAR				in_pszStreamSocketIP,
	IN		TBX_INT					in_FirstResType,
	IN		TBX_UINT32				in_un32ConnectionsPerSecond,
	IN		TBX_UINT32				in_un32MinConnectionDuration,
	IN		TBX_UINT32				in_un32MaxConnectionDuration,
	IN		TBX_BOOL				in_fAutoAbort,
	IN		TBX_BOOL				in_fClearConnection,
	IN		TBX_BOOL				in_fDoBert,
	IN		TBX_UINT32				in_un32TestDurationSec)
{
	TBX_RESULT						Result;
	PVOIP_CLI_CONTEXT				pCliContext;
	PVOIP_EVT_OP_START_STRESS_TEST	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_STRESS_TEST,
			TBX_MSG_TYPE_REQUEST,
			un32MsgSize,
			TBX_HOSTLIB_ADAPTER_HANDLE,
			pAdapterContext->AdapterInfo.hAdapter,
			0
		);

		/* Fill the request */
		pEvt = (PVOIP_EVT_OP_START_STRESS_TEST) TBX_MSG_PAYLOAD_POINTER (hMsg);
		pEvt->un32MsgVersion					= 1;
		strcpy( pEvt->szStreamSocketIP, in_pszStreamSocketIP );
		pEvt->FirstResType						= in_FirstResType;
		pEvt->un32ConnectionsPerSecond			= in_un32ConnectionsPerSecond;
		pEvt->un32MinConnectionDuration			= in_un32MinConnectionDuration;
		pEvt->un32MaxConnectionDuration			= in_un32MaxConnectionDuration;
		pEvt->fAutoAbort						= in_fAutoAbort;
		pEvt->fClearOpenedConnectionUponStartup	= in_fClearConnection;
		pEvt->fDoBertTests						= in_fDoBert;
		pEvt->un32TestDurationInSec				= in_un32TestDurationSec;

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

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

	RETURN;
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipCliSendStopStressTest	:	Send a message type VOIP_MSG_ID_OP_STOP_STRESS_TEST
 |									to the main state machine.
 |
 |	in_pCliContext				:	Cli context
 |
 |  Note						:	~
 |
 |  Return						:	~
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT VoipCliSendStopStressTest(
	IN		PVOIP_CLI_CONTEXT	in_pCliContext )
{
	TBX_RESULT						Result;
	PVOIP_CLI_CONTEXT				pCliContext;
	PVOIP_EVT_OP_STOP_STRESS_TEST	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;

⌨️ 快捷键说明

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