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

📄 isdn.h

📁 telcobridges pri develop,30b+d
💻 H
📖 第 1 页 / 共 2 页
字号:
/*--------------------------------------------------------------------------------------------------------------------------------
 |
 |	Project:    	VoiceLink TB640 sample (ISDN)
 |
 |	Filename:   	isdn.h
 |
 |	Copyright:  	TelcoBridges 2002-2003, All Rights Reserved
 |
 |	Description:	This file contains the internal structure required by the application
 |
 |	Notes:      	Tabs = 4
 |
 *-------------------------------------------------------------------------------------------------------------------------------
 |
 |	Revision:   	$Revision: 1.59 $
 |
 *------------------------------------------------------------------------------------------------------------------------------*/


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Define header file
 *------------------------------------------------------------------------------------------------------------------------------*/
#ifndef __ISDN_H__
#define __ISDN_H__


/*--------------------------------------------------------------------------------------------------------------------------------
 |  C++ support
 *------------------------------------------------------------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Forward declarations
 *------------------------------------------------------------------------------------------------------------------------------*/


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Defines
 *------------------------------------------------------------------------------------------------------------------------------*/

/* The following defines create the apppropriate function inlining according to the selected OS */
#define INLINE													__inline

/* Defines a interval at which the adapter sends an heartbeat to the library */
#define TB640_ISDN_ADAPTER_KEEPALIVE_TIMER_SEC					1

/* Maximum number of boards (or softadapters) can this application control */
#define TB640_ISDN_MAX_SUPPORTED_ADAPTERS						2

/* Maximum number of trunks on an adapter */
#define TB640_ISDN_MAX_SUPPORTED_TRUNKS_PER_ADAPTER				64

/* Maximum number of CTBUS stream on an adapter */
#define TB640_ISDN_MAX_SUPPORTED_CTBUS_STREAM_PER_ADAPTER		32

/* Maximum number of TDM timeslot (half-duplex) in a CTBUS stream */
#define TB640_ISDN_MAX_TIMESLOT_PER_CTBUS_STREAM				128

/* Maximum number of TDM timeslot (full-duplex) in a trunk */
#define TB640_ISDN_MAX_TIMESLOT_IN_TRUNK						32

/*
 | Maximum number of trunks controlled by a single operation library (contexts and timers).
 | MUST be a multiple of TB640_ISDN_MAX_SUPPORTED_TRUNKS_PER_ADAPTER.
 */
#define TB640_ISDN_MAX_TRUNK_PER_OPERATION_LIBRARY				TB640_ISDN_MAX_SUPPORTED_TRUNKS_PER_ADAPTER

/* The actual number of operation library to be used */
#define TB640_ISDN_NB_OPERATION_LIBRARY_REQUIRED				(TB640_ISDN_MAX_SUPPORTED_TRUNKS_PER_ADAPTER/TB640_ISDN_MAX_TRUNK_PER_OPERATION_LIBRARY)

/* Default name for configuration file (can be overriden with an argument */
#define TB640_ISDN_DEFAULT_CONFIGURATION_FILENAME				"config.txt"

/* Maximum number of characters in log filename */
#define TB640_ISDN_MAX_LOG_FILENAME_LENGTH						32

/* Maximum number of characters in adapter name */
#define TB640_ISDN_MAX_ADAPTER_NAME_LENGTH						64

/* Maximum number of characters in a configuration line */
#define TB640_ISDN_MAX_CONFIGURATION_LINE_LENGTH				132

/* Maximum idle code value */
#define TB640_ISDN_MAX_IDLE_CODE_VALUE							127

/* Maximum timeout value (in sec) after which an adapter is considered down if no activity (and heartbeat) is detected */
#define TB640_ISDN_ADAPTER_WATCHDOG_TIMEOUT_SEC					10

/* Maximum timeout waiting for adapters to register */
#define TB640_ISDN_ADAPTER_DISCOVERY_TIMEOUT_MSEC				(5*1000)

/* Maximum number of adapters being discovered in the network */
#define TB640_ISDN_MAX_ADAPTER_DISCOVERED						32

/* Defines the adapter name string to represents any adapter */
#define TB640_ISDN_ANY_ADAPTER_STRING							"ANY"

/* Define the maximum number of digit in a received number */
#define TB640_ISDN_MAX_NB_DIGIT_IN_NUMBERS						32

/* Define the maximum number of states remembered for a specific timeslot */
#define TB640_ISDN_NB_HISTORY_FOR_TIMESLOT						256

/* Define the maximum number of states remembered for a specific call */
#define TB640_ISDN_NB_HISTORY_FOR_CALL							32

/* Defines the maximum setup time for a call */
#define TB640_ISDN_CALL_SETUP_MAX_DURATION_SEC					45

/* Defines the maximum disconnect time for a call */
#define TB640_ISDN_CALL_DISCONNECT_MAX_DURATION_SEC				15

/* Defines the maximum restart timeout for a timeslot */
#define TB640_ISDN_CALL_RESTART_MAX_DURATION_SEC				150		/* Q.931 spec mentions T316=2 minutes for a RESTART */

/* Define the minimum number of digits before the state machine answers the call automatically */
#define TB640_ISDN_NB_MINIMUM_DIGIT_BEFORE_ANSWERING_CALL		4

/* Special message IDs we are going to use for the state machine as "trigger" events */
#define	TB640_MSG_ID_NOT_USED							TBX_MSG_ID_GEN (0, 0x00)
#define	TB640_MSG_ID_ISDN_TIMEOUT						TBX_MSG_ID_GEN (0, 0x01)
#define	TB640_MSG_ID_ISDN_MAKE_CALL						TBX_MSG_ID_GEN (0, 0x02)
#define	TB640_MSG_ID_ISDN_DROP_CALL						TBX_MSG_ID_GEN (0, 0x03)
#define	TB640_MSG_ID_ISDN_RESTART						TBX_MSG_ID_GEN (0, 0x04)
#define TB640_MSG_ID_ISDN_RECOVERED						TBX_MSG_ID_GEN (0, 0x05)
#define TB640_MSG_ID_ISDN_ANSWER_CALL					TBX_MSG_ID_GEN (0, 0x06)
#define TB640_MSG_ID_ISDN_DIGIT_ENTERED					TBX_MSG_ID_GEN (0, 0x07)


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Types
 *------------------------------------------------------------------------------------------------------------------------------*/
/*
 | The following type is used to match a string to a parsing token
 */
typedef struct _TB640_ISDN_PARSING_ENTRY
{
	PTBX_CHAR						pszIdentifier;
	TBX_UINT32						un32Value;

} TB640_ISDN_PARSING_ENTRY, *PTB640_ISDN_PARSING_ENTRY;

/* This structure represents the statistics for stress testing */
typedef struct _TB640_ISDN_STRESS_STATS
{
	TBX_BOOL			fStatsActivated;
	TBX_UINT32			un32StartTimestamp;
	TBX_UINT32			un32CurrentTimestamp;
	TBX_UINT32			un32NbCallOpeningOutOfRes;
	TBX_UINT32			un32NbCallOpeningFailure;
	TBX_UINT32			un32NbCallOpeningSuccess;
	TBX_UINT32			un32NbCallClosingTotal;
	TBX_UINT32			un32NbCallCompleted;
	TBX_UINT32			un32NbCallNoFreeTimeslotToOpen;
	TBX_UINT32			un32NbTimeoutOccured;
	TBX_UINT32			un32NbRestartAttempt;
	TBX_UINT32			un32NbResetAttempt;
	TBX_UINT32			un32NbOutgoingCallCollision;
	TBX_UINT32			un32NbIncomingCallCollision;

} TB640_ISDN_STRESS_STATS, *PTB640_ISDN_STRESS_STATS;


/*
 | Enumeration describing the different states of a call
 */
typedef enum _TB640_ISDN_CALL_APP_STATE
{
	TB640_ISDN_CALL_APP_STATE_IDLE				= 0,
	TB640_ISDN_CALL_APP_STATE_1					= 1,
	TB640_ISDN_CALL_APP_STATE_2					= 2,
	TB640_ISDN_CALL_APP_STATE_3					= 3,
	TB640_ISDN_CALL_APP_STATE_4					= 4,
	TB640_ISDN_CALL_APP_STATE_5					= 5,
	TB640_ISDN_CALL_APP_STATE_6					= 6,
	TB640_ISDN_CALL_APP_STATE_7					= 7,
	TB640_ISDN_CALL_APP_STATE_8					= 8,
	TB640_ISDN_CALL_APP_STATE_9					= 9,
	TB640_ISDN_CALL_APP_STATE_10				= 10,
	TB640_ISDN_CALL_APP_STATE_11				= 11,
	TB640_ISDN_CALL_APP_STATE_12				= 12,
	TB640_ISDN_CALL_APP_STATE_13				= 13,
	TB640_ISDN_CALL_APP_STATE_14				= 14,
	TB640_ISDN_CALL_APP_STATE_15				= 15,

	/* Fake 'state' used when recovering call for HA */
	TB640_ISDN_CALL_APP_STATE_RECOVERED				= 100

} TB640_ISDN_CALL_APP_STATE, *PTB640_ISDN_CALL_APP_STATE;


/*
 | Enumeration describing the different sub states of a call
 */
typedef enum _TB640_ISDN_CALL_APP_SUB_STATE
{
	TB640_ISDN_CALL_APP_SUB_STATE_ENTRY				= 0,
	TB640_ISDN_CALL_APP_SUB_STATE_PROCESS			= 1,

} TB640_ISDN_CALL_APP_SUB_STATE, *PTB640_ISDN_CALL_APP_SUB_STATE;


/* Define the action that can be triggered after an event processig */
typedef enum _TB640_ISDN_STATE_ACTION
{
	TB640_ISDN_STATE_ACTION_WAIT					= 1,
	TB640_ISDN_STATE_ACTION_CONTINUE				= 2,
	TB640_ISDN_STATE_ACTION_DESTROY_CONTEXT			= 3,

} TB640_ISDN_STATE_ACTION, *PTB640_ISDN_STATE_ACTION;


/*
 | Enumeration describing the different states of a timeslot
 */
typedef enum _TB640_ISDN_TRUNK_RESOURCE_STATE
{
	TB640_ISDN_TRUNK_RESOURCE_STATE_IDLE				= '.',
	TB640_ISDN_TRUNK_RESOURCE_STATE_OPENING_INCOMING	= 'I',
	TB640_ISDN_TRUNK_RESOURCE_STATE_OPENING_OUTGOING	= 'O',
	TB640_ISDN_TRUNK_RESOURCE_STATE_CONNECTING			= '>',
	TB640_ISDN_TRUNK_RESOURCE_STATE_ACTIVE				= '*',
	TB640_ISDN_TRUNK_RESOURCE_STATE_DISCONNECTING		= '<',
	TB640_ISDN_TRUNK_RESOURCE_STATE_CLOSING				= '-',
	TB640_ISDN_TRUNK_RESOURCE_STATE_RESTARTING			= 'R',
	TB640_ISDN_TRUNK_RESOURCE_STATE_CONDEMNED			= 'X',
	TB640_ISDN_TRUNK_RESOURCE_STATE_FRAMING_UP			= 'F',
	TB640_ISDN_TRUNK_RESOURCE_STATE_FRAMING_DOWN		= 'f',
	TB640_ISDN_TRUNK_RESOURCE_STATE_LINK_UP				= 'D',
	TB640_ISDN_TRUNK_RESOURCE_STATE_LINK_DOWN			= 'd',
	TB640_ISDN_TRUNK_RESOURCE_STATE_NOT_USED			= 'N'

} TB640_ISDN_TRUNK_RESOURCE_STATE, *PTB640_ISDN_TRUNK_RESOURCE_STATE;


/*
 | Enumeration describing the different states of a timeslot
 */
typedef enum _TB640_ISDN_TRUNK_BCHANNEL_STATE
{
	TB640_ISDN_TRUNK_BCHANNEL_STATE_IN_SERVICE				= 'I',
	TB640_ISDN_TRUNK_BCHANNEL_STATE_MAINTENANCE				= 'M',
	TB640_ISDN_TRUNK_BCHANNEL_STATE_OUT_OF_SERVICE			= 'O',
	TB640_ISDN_TRUNK_BCHANNEL_STATE_UNKNOWN					= '?'

} TB640_ISDN_TRUNK_BCHANNEL_STATE, *PTB640_ISDN_TRUNK_BCHANNEL_STATE;


/*
 | Structure containing state history entry
 */
typedef struct _TB640_ISDN_HISTORY_ENTRY
{
	TBX_UINT32							un32Timestamp;
	TB640_CALL_HANDLE					hCall;
	TB640_ISDN_TRUNK_RESOURCE_STATE		CurrentState;
	TBX_UINT32							un32Event;

} TB640_ISDN_HISTORY_ENTRY, *PTB640_ISDN_HISTORY_ENTRY;


/*

⌨️ 快捷键说明

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