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

📄 voip_msg.c

📁 telcobridges voip develop
💻 C
📖 第 1 页 / 共 4 页
字号:
/*--------------------------------------------------------------------------------------------------------------------------------
 |
 |	Project:    	VOIP sample
 |
 |	Filename:   	voip_msg.c
 |
 |	Copyright:  	TelcoBridges 2002-2004, All Rights Reserved
 |
 |	Description:	This file contains functions to format and send messages to the main state machine.
 |
 |	Notes:      	Tabs = 4
 |
 *-------------------------------------------------------------------------------------------------------------------------------
 |
 |	Revision:   	$Revision: 1.25 $
 |
 *------------------------------------------------------------------------------------------------------------------------------*/

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

#include "voip_includes.h"


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

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


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


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


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

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipCliSendQuit	:	Send a message type VOIP_MSG_ID_OP_QUIT
 |						to the main state machine.
 |
 |  Note			:	~
 |
 |  Return			:	~
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT VoipCliSendQuit()
{
	TBX_RESULT			Result;
	PVOIP_CLI_CONTEXT	pCliContext;
	PVOIP_EVT_OP_QUIT	pEvt;
	TBX_MSG_HANDLE		hMsg;

	/*---------------------------------------------------------------------------------------------------------------------------
	 |  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_QUIT,
			TBX_MSG_TYPE_REQUEST,
			sizeof(*pEvt),
			TBX_HOSTLIB_ADAPTER_HANDLE,
			0,
			0
		);

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

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

	RETURN;
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipCliSendSetTraceLevel	:	Send a message type VOIP_MSG_ID_OP_SET_TRACE_LEVEL
 |									to the main state machine.
 |
 |	in_un32DisplayTraceLevel		:	Trace level to set for display
 |	in_un32LogFileTraceLevel	:	Trace level to set for log file
 |
 |  Note						:	~
 |
 |  Return						:	~
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT VoipCliSendSetTraceLevel(
	IN		TBX_UINT32	in_un32DisplayTraceLevel,
	IN		TBX_UINT32	in_un32LogFileTraceLevel)
{
	TBX_RESULT						Result;
	PVOIP_CLI_CONTEXT				pCliContext;
	PVOIP_EVT_OP_SET_TRACE_LEVEL	pEvt;
	TBX_MSG_HANDLE					hMsg;

	/*---------------------------------------------------------------------------------------------------------------------------
	 |  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_SET_TRACE_LEVEL,
			TBX_MSG_TYPE_REQUEST,
			sizeof(*pEvt),
			TBX_HOSTLIB_ADAPTER_HANDLE,
			0,
			0
		);

		/* Fill the request */
		pEvt = (PVOIP_EVT_OP_SET_TRACE_LEVEL) TBX_MSG_PAYLOAD_POINTER (hMsg);
		pEvt->un32MsgVersion			= 1;
		pEvt->un32DisplayTraceLevel		= in_un32DisplayTraceLevel;
		pEvt->un32LogFileTraceLevel		= in_un32LogFileTraceLevel;

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

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

	RETURN;
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipCliSendReloadConfig	:	Send a message type VOIP_MSG_ID_OP_RELOAD_CONFIG
 |								to the main state machine.
 |
 |  Note					:	~
 |
 |  Return					:	~
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT VoipCliSendReloadConfig( TBX_VOID )
{
	TBX_RESULT					Result;
	PVOIP_CLI_CONTEXT			pCliContext;
	PVOIP_EVT_OP_RELOAD_CONFIG	pEvt;
	TBX_MSG_HANDLE				hMsg;

	/*---------------------------------------------------------------------------------------------------------------------------
	 |  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_RELOAD_CONFIG,
			TBX_MSG_TYPE_REQUEST,
			sizeof(*pEvt),
			TBX_HOSTLIB_ADAPTER_HANDLE,
			0,
			0
		);

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

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

	RETURN;
}

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  VoipCliSendResetBertStats		:	Send a message type VOIP_MSG_ID_OP_RESET_BERT_STATS
 |										to the main state machine.
 |
 |  Note							:	~
 |
 |  Return							:	~
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT VoipCliSendResetBertStats( TBX_VOID )
{
	TBX_RESULT							Result;
	PVOIP_CLI_CONTEXT					pCliContext;
	PVOIP_EVT_OP_RESET_BERT_STATS		pEvt;
	TBX_MSG_HANDLE						hMsg;

⌨️ 快捷键说明

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