/*=========================================*/
/* 								 	      */
/* 									      */
/* 	Author:     Zane Yi				      */
/* 	Date:       2007.02.01			      */
/* 									      */
/*=========================================*/
#ifndef _ISUPCONST_H_
#define _ISUPCONST_H_

//Protocol discriminator
#define ISUP_SI					0x05


//block
/************************************/
#define M_LOCAL_BLOCK			0x01
#define M_REMOTE_BLOCK			0x02

/************************************/

//SUS
/************************************/
#define ISUP_ORIG_SUSPEND			0x01
#define ISUP_TERM_SUSPEND			0x02

/************************************/

//call state
#define IDLE_FLAG					0x00
#define CALLIN_FLAG					0x01
#define CALLOUT_FLAG				0x02
#define START_RESET					0xFF


//timer flag
/************************************/
#define BLS_FLAG					0x04
#define BLR_FLAG					0x08
#define MGBS_FLAG					0x10
#define MGBR_FLAG					0x20
#define CRS_FLAG					0x40
#define CRR_FLAG					0x80
#define CGRS_FLAG					0x100
#define CGRR_FLAG					0x200
/************************************/

//state
/************************************/
#define CPCI_IDLE					0
#define CPCI_WAIT_CONTINUITY		1
#define CPCI_WAIT_ACM				2
#define CPCI_WAIT_ANM				3
#define CPCI_ANSWERED				4
#define CPCI_SUSPENDED				5
#define CPCI_WAIT_RLC				6
#define CPCI_WAIT_REL_COMP			7
#define CPCI_WAIT_RESET				8
#define CPCI_WAIT_GROUP_RESET		9
/************************************/
#define CPCO_IDLE					0
#define CPCO_WAIT_CONTINUITY		1
#define CPCO_WAIT_ACM				2
#define CPCO_WAIT_ANM				3
#define CPCO_ANSWERED				4
#define CPCO_SUSPENDED				5
#define CPCO_WAIT_RLC				6
#define CPCO_WAIT_REL_COMP			7
#define CPCO_WAIT_RESET				8
#define CPCO_WAIT_GROUP_RESET		9
/************************************/
#define BLS_IDLE					0
#define BLS_WAIT_BLA				1
#define BLS_LOCAL_LOCKED			2
#define BLS_WAIT_UBA				3
/************************************/
#define BLR_IDLE					0
#define BLR_WAIT_BLOCKING_RESP		1
#define BLR_REMOTE_LOCKED			2
#define BLR_WAIT_UNBLOCKING_RESP	3
/************************************/
#define MGBS_IDLE					0
#define MGBS_WAIT_CGBA				1
#define MGBS_WAIT_CGUA				2
/************************************/
#define MGBR_IDLE					0
#define MGBR_WAIT_BLOCKING_RESP		1
#define MGBR_WAIT_UNBLOCKING_RESP	2
/************************************/
#define CRS_IDLE					0
#define CRS_WAIT_REL				1
/************************************/
#define CRR_IDLE					0
#define CRR_WAIT_RESPONSE			1
/************************************/
#define CGRS_IDLE					0
#define CGRS_WAIT_GRA				1
/************************************/
#define CGRR_IDLE					0
#define CGRR_WAIT_GROUP_RESET_COMP	1
/************************************/




//********************************************/
//****** ISUP Internal Command		  
//********************************************/
#define CMD_UNBLO						0x01
#define CMD_BLO							0x02
#define CMD_RESET						0x03
#define CMD_RESET_COMP					0x04


#define SI_CPCI							0x10
#define SI_CPCO							0x20
#define SI_BLS							0x30
#define SI_BLR							0x40
#define SI_MGBR							0x50
#define SI_MGBS							0x60
#define SI_CRS							0x70
#define SI_CRR							0x80
#define SI_CGRS							0x90
#define SI_CGRR							0xA0


/********************************************/
/****** ISUP Event/Primitive Definition *****/
/********************************************/
//Primitive
#define ISUP_SETUP_REQ			0x11
#define ISUP_SETUP_IND			0x21
#define ISUP_SETUP_RSP			0x31
#define ISUP_SETUP_CNF			0x41

#define ISUP_RELEASE_REQ		0x12
#define ISUP_RELEASE_IND		0x22
#define ISUP_RELEASE_RSP		0x32
#define ISUP_RELEASE_CNF		0x42

#define ISUP_ALERT_REQ			0x13
#define ISUP_ALERT_IND			0x23
#define ISUP_INFO_REQ			0x33
#define ISUP_INFO_IND			0x43
#define ISUP_PROG_REQ			0x53
#define ISUP_PROG_IND			0x63
#define ISUP_SUSPEND_REQ		0x73
#define ISUP_SUSPEND_IND		0x83
#define ISUP_RESUME_REQ			0x93
#define ISUP_RESUME_IND			0xa3

#define ISUP_BLOCK_REQ			0x14
#define ISUP_BLOCK_IND			0x24
#define ISUP_BLOCK_RSP			0x34
#define ISUP_BLOCK_CNF			0x44
#define ISUP_UNBLOCK_REQ		0x54
#define ISUP_UNBLOCK_IND		0x64
#define ISUP_UNBLOCK_RSP		0x74
#define ISUP_UNBLOCK_CNF		0x84
#define ISUP_RESET_REQ			0x94
#define ISUP_RESET_IND			0xa4
#define ISUP_RESET_RSP			0xb4
#define ISUP_RESET_CNF			0xc4

#define ISUP_DATA_IND			0x0f

#define ISUP_REATTEMPT_IND		0x1f
#define ISUP_FAILURE_IND		0x2f
#define ISUP_MAINTENANCE_IND	0x3f
#define ISUP_STARTRESET_IND		0x4f

#define ISUP_STOP_REQ			0xef
#define ISUP_STOP_CNF			0xff





//Event
#define EN_NONE			0x00
#define EN_ANM			0x01
#define EN_CON			0x02
#define EN_GROUP		0x03

#define EN_CLEAR_BLR				0x04

#define EN_T5_TIMEOUT				0x10
#define EN_T13_TIMEOUT			0x11
#define EN_T15_TIMEOUT			0x12
#define EN_T19_TIMEOUT			0x13
#define EN_T21_TIMEOUT			0x14

/********************************************/
/****** ISUP Timer Definition 	(s)		*****/
/********************************************/
/*
T1	15-60 seconds	When release message is sent	At the receipt of release complete message	Retransmit release message and start timer T1
T2	3 minutes	When controlling exchange receives suspend (user) message	At the receipt of resume (user) message at controlling exchange	Initiate release procedure
T3	2 minutes	At receipt of overload message	On expiry	Initiate release procedure
T4	5-15 minutes	At receipt of MTP-STATUS primitive with the cause "remote user unavailable"	On expiry, or at receipt of user part available message (or any other)	Send user part test message. Start T4
T5	5-15 minutes	When initial release message is sent	At receipt of release complete message	Send reset circuit message, alert maintenance personnel and remove the circuit from service, stop T1, start T17. Procedure continues until maintenance intervention occurs
T6	Covered in Q.118	When controlling exchange receives suspend (network)	At the receipt of resume (network) message or release message	Initiate release procedure
T7	20-30 seconds	When the latest address message is sent	When the condition for normal release of address and routing information is met (receipt of ACM, CON messages)	Release all equipment and connection(Send release message)
T8	10-15 seconds	When an exchange receives initial address message requiring continuity check on this circuit or indicates that continuity check has been performed on a previous circuit	At receipt of continuity message	Release all equipment and connection into the network(Send release message)
T9	Interval specifiedin Q.118	When national controlling or outgoing international exchange receives ACM	At the receipt of answer	Release connection send back release message
T10	4-6 seconds	When last digit is received in interworking situations	At the receipt of fresh information	Send address complete message
T11	15-20 seconds	When latest address message is received in interworking situations	When ACM is sent	Send address complete message
T12	15-60 seconds	When blocking message is sent	At receipt of blocking acknowledgement 	Retransmit blocking message and start T12
T13	5-15 minutes	When initial blocking message is sent	At receipt of blocking acknowledgement	Transmit blocking message and alert maintenance personnel, start T13, stop T12. Procedure continues until maintenance intervention occurs
T14	15-60 seconds	When unblocking message is sent	At receipt of unblocking acknowledgement	Retransmit unblocking message and start T14
T15	5-15 minutes	When initial unblocking message is sent 	At receipt of unblocking acknowledgement	Retransmit unblocking message alert maintenance personnel, start T15 and stop T14. Procedure continues until maintenance intervention occurs
T16	15-60 seconds	When reset circuit message is sent not due to expiry of T5	At the receipt of the acknowledgement (RLC message)	Retransmit reset circuit message and start T16
T17	5-15 minutes	When initial reset circuit messageis sent	At the receipt of the acknowledgement	Alert maintenance personnel, retransmit reset circuit message, start T17, stop T16. Procedure continues until maintenance intervention occurs
T18	15-60 seconds	When group blocking message is sent 	At receipt of group blocking acknowledgement	Retransmit group blocking message and start T18
T19	5-15 minutes	When initial group blocking message is sent	At receipt of group blocking acknowledgement 	Retransmit group blocking message, alert maintenance personnel, start T19, stop T18. Procedure continues until maintenance intervention occurs
T20	15-60 seconds	When group unblocking message is sent	At receipt of group unblocking acknowledgement	Retransmit group unblocking message and start T20
T21	5-15 minutes	When initial group unblocking message is sent	At receipt of group unblocking acknowledgement	Retransmit group unblocking message, alert maintenance personnel, start T21, stop T20. Procedure continues until maintenance intervention occurs
T22	15-60 seconds	When circuit group reset message is sent	At the receipt of the acknowledgement	Retransmit circuit group reset message and start T22
T23	5-15 minutes	When initial circuit group reset message is sent	At the receipt of the acknowledgement	Alert maintenance personnel and start T23, retransmit circuit group reset message, stop T22. Procedure continues until maintenance intervention occurs
T24	< 2 seconds	When check tone is sent	At the receipt of backward check tone	Send continuity message with failure indication and:a)	start T25 if continuity check was asked in IAM and make automatic repeat attempt; orb)	start T26 if continuity check was asked in CCR
T25	1-10 seconds	When initial continuity check failure is detected	-	Send CCR message and repeat continuity check
T26	1-3 minutes	When second or subsequent continuity check failure is detected	-	Send CCR message and repeat continuity check
T27	4 minutes	When continuity check failure indication is received	At receipt of continuity check request message	Send reset circuit message. Start T16 and T17
T28	10 seconds	When send CQM	At receipt of CQR	Alert maintenance
T29	300-600 ms	Congestion indication received when T29 not running	-	New congestion indication will be taken into account
T30	5-10 seconds	Congestion indication received when T29 not running	-	Restore traffic by one step if not yet at full load and start T30
T31	> 6 minutes	Release of ISDN User Part signalling connection based on CO SCCP	On expiry	Call reference reusable
T32	3-5 seconds	When response to request of end-to-end connection establishment is sent	At receipt of first end?to-end message from the remote end	End-to-end message allowed to be sent
T33	12-15 seconds	When send INR	On receipt of INF	Release call, alert maintenance personnel
T34	2-4 seconds	When indication of a segmented message is received on an IAM, ACM, CPG, ANM or CON message	At receipt of a segmentation message	Proceed with call 
T35	15-20 seconds	At receipt of the latest digit (< > ST) and before the minimum or fixed number of digits have been received	At receipt of ST or when the minimum or fixed number of digits have been received	Send release message (cause 28)
T36	10-15 seconds	When transit or incoming international exchange receives continuity check request message	At receipt of continuity or release message	Release all equipment, send reset circuit message. Start T16 and T17
T37	2-4 seconds	When request for an echo control device is sent to another exchange	On expiry or when an indication of a half echo control device being included/not included is known	Half echo control device is included or enabled
T38	Interval specified in Q.118	When the incoming international exchange sends to the preceding exchange a suspend (network) message	At receipt of resume (network) or release message	Send release message (cause 102)
T39	Interval specified in Q.730	When an MCID request is sent	At receipt of an MCID response	Call continues
*/
#define ISUP_T1					15	 
#define ISUP_T5					300 
#define ISUP_T7					30  
#define ISUP_T8					10  
#define ISUP_T9					120 
#define ISUP_T12				15  
#define ISUP_T13				300 
#define ISUP_T14				15  
#define ISUP_T15				300 
#define ISUP_T16				15  
#define ISUP_T17				300 
#define ISUP_T18				15  
#define ISUP_T19				300 
#define ISUP_T20				15  
#define ISUP_T21				300 
#define ISUP_T22				15  
#define ISUP_T23				300 
#define ISUP_T24				1   
#define ISUP_T25				1   
#define ISUP_T26				60  
#define ISUP_T27				240 
#define ISUP_T34				2   
#define ISUP_T36				10  
#define ISUP_T37				2   


#endif











