/*	TCAP head file						*/
/*	Written by Liu Zhiguo 2002-08-06	*/
/*	Version 2.0							*/
/*	---------------------------------	*/
#ifndef _TCAP_HEAD
#define _TCAP_HEAD

/*	TC or TR dialogue portion	*/
/*	TC or TR message type tag	*/
#define Unidirectional					0x61
#define Begin							0x62
#define End								0x64
#define Continue						0x65
#define P_Abort							0x66	// terminated by service provider
#define U_Abort							0x67	// terminated by TC user
#define Abort							0x67
#define Notice							0x68	// Network Service Provider inform

#define Unidirectional_Ansi				0xE1
#define Query_WithPerm_Ansi				0xE2
#define Query_WithoutPerm_Ansi			0xE3
#define Response_Ansi					0xE4
#define Conversation_WithPerm_Ansi		0xE5
#define Conversation_WithoutPerm_Ansi	0xE6
#define Abort_Ansi						0xF6
#define P_Abort_Ansi					0xF5	// terminated by service provider
#define U_Abort_Ansi					0xF6	// terminated by TC user

/*	transaction ID tags	*/
#define Org_TID							0x48	// originating transaction ID tag
#define Dst_TID							0x49	// destination transaction ID tag

/*	P-Abort cause tag	*/
#define P_Abort_Cause					0x4a

/*	coding of P-Abort Cause values	*/
#define P_Abort_UMT						0x00	// unrecognized message type
#define P_Abort_UTID					0x01	// unrecognized transaction ID
#define P_Abort_BFTP					0x02	// badly formatted transaction portion
#define P_Abort_ITP						0x03	// incorrect transaction portion
#define P_Abort_RL						0x04	// resource limitation
#define P_Abort_ADLG					0x05	// abnormal dialogue
#define P_Abort_NCDP					0x06	// no common dialogue portion

#define P_Abort_UMT_Ansi				0x01	// unrecognized message type
#define P_Abort_ITP_Ansi				0x02	// incorrect transaction portion
#define P_Abort_BFTP_Ansi				0x03	// badly formatted transaction portion
#define P_Abort_UTID_Ansi				0x04	// unrecognized transaction ID
#define	P_Abort_PTRP_Ansi				0x05	// permission to release problem
#define P_Abort_RL_Ansi					0x06	// resource limitation
#define P_Abort_UDPID_Ansi				0x07	// unrecognized dialogue portion id
#define P_Abort_BSDP_Ansi				0x08	// badly structured dialogue portion
#define P_Abort_MDP_Ansi				0x09	// missing dialogue portion
#define P_Abort_IDP_Ansi				0x0A	// inconsistent dialogue portion

/*	dialogue portion tag	*/
#define Dialogue_Portion				0x6b

/*	component portion tag	*/
#define Component_Portion				0x6c

/*	TC Component portion	*/
/*	component type tag	*/
#define Invoke							0xa1
#define Result_L						0xa2	// return result last
#define Error							0xa3	// indicate operation execution failed
#define U_Error							0xa3
#define Reject							0xa4
#define U_Reject						0xa4	// reject by TC user
#define L_Reject						0xa5	// local reject
#define R_Reject						0xa6	// remote reject
#define Result_NL						0xa7	// return result not last
#define L_Cancel						0xa8	// inform TC user local terminated by timeout
#define U_Cancel						0xa8	// local terminate by TC user

#define Invoke_L_Ansi					0xe9	// Invoke Last
#define Result_L_Ansi					0xea	// return result last
#define Error_Ansi						0xeb	// indicate operation execution failed
#define U_Error_Ansi					0xeb
#define Reject_Ansi						0xec	// Reject
#define U_Reject_Ansi					0xec	// reject by TC user
#define L_Reject_Ansi					0xe8	// local reject
#define R_Reject_Ansi					0xe7	// remote reject
#define Invoke_NL_Ansi					0xed	// Invoke not last
#define Result_NL_Ansi					0xee	// return result not last

/*	component ID tag	*/
#define Invoke_ID						0x02
#define Linked_ID						0x80

/*	coding of NULL tag	*/
#define Invoke_ID_NULL					0x05

/*	operation code tag	*/
#define Local_Operation_Code			0x02
#define Global_Operation_Code			0x06

/*	parameter tag		*/
#define Sequence						0x30
#define Set								0x31

/*	error code tag		*/
#define Local_Error_Code				0x02
#define Global_Error_Code				0x06

/*	coding of problem type tag	*/
#define General_Problem					0x80
#define Invoke_Problem					0x81
#define Return_Result					0x82
#define Return_Error					0x83

#define General_Problem_Ansi			0x01
#define Invoke_Problem_Ansi				0x02
#define Return_Result_Ansi				0x03
#define Return_Error_Ansi				0x04
#define Transaction_Ansi				0x05

/*	coding of general problem	*/
#define General_Problem_UC				0x00	// unrecognized component
#define General_Problem_MC				0x01	// mistyped component
#define General_Problem_BSC				0x02	// badly structured component

#define General_Problem_UC_Ansi			0x01	// unrecognized component
#define General_Problem_MC_Ansi			0x02	// mistyped component/incorrect component portion
#define General_Problem_BSC_Ansi		0x03	// badly structured component
#define General_Problem_ICC_Ansi		0x04	// incorrect component coding

/*	coding of invoke problem	*/
#define Invoke_Problem_DIID				0x00	// duplicate invoke ID
#define Invoke_Problem_UO				0x01	// unrecognized operation
#define Invoke_Problem_MP				0x02	// mistyped parameter
#define Invoke_Problem_RL				0x03	// resource limitation
#define Invoke_Problem_IR				0x04	// initiating release
#define Invoke_Problem_ULID				0x05	// unrecognized linked ID
#define Invoke_Problem_LRU				0x06	// linked response unexpected
#define Invoke_Problem_ULO				0x07	// unexpected linked operation

#define Invoke_Problem_DIID_Ansi		0x01	// duplicate invoke ID
#define Invoke_Problem_UO_Ansi			0x02	// unrecognized operation
#define Invoke_Problem_MP_Ansi			0x03	// mistyped parameter
#define Invoke_Problem_ULID_Ansi		0x04	// unrecognized linked ID

/*	coding of return result problem	*/
#define Return_Result_UIID				0x00	// unrecognized invoke ID
#define Return_Result_RRU				0x01	// return result unexpected
#define Return_Result_MP				0x02	// mistyped parameter

#define Return_Result_UIID_Ansi			0x01	// unrecognized invoke ID
#define Return_Result_RRU_Ansi			0x02	// return result unexpected
#define Return_Result_MP_Ansi			0x03	// mistyped parameter

/*	coding of return error problem	*/
#define Return_Error_UIID				0x00	// unrecognized invoke ID
#define Return_Error_REU				0x01	// return error unexpected
#define Return_Error_URE				0x02	// unrecognized error
#define Return_Error_UEE				0x03	// unexpected error
#define Return_Error_MP					0x04	// mistyped parameter

#define Return_Error_UIID_Ansi			0x01	// unrecognized invoke ID
#define Return_Error_REU_Ansi			0x02	// return error unexpected
#define Return_Error_URE_Ansi			0x03	// unrecognized error
#define Return_Error_UEE_Ansi			0x04	// unexpected error
#define Return_Error_MP_Ansi			0x05	// mistyped parameter

/*	Dialogue Portion		*/
/*	external tag			*/
#define External						0x28

/*	object identifier		*/
#define Object_Identifier				0x06
#define Integer							0x02

/*	dialogue tag	*/
#define PDU_AARQ						0x60
#define PDU_AARE						0x61
#define PDU_ABRT						0x64
/*	protocol version tag	*/
#define Protocol_Version				0x80

/*	application context name tag	*/
#define Application_Context_Name		0xa1

/*	user information tag	*/
#define User_Information				0xbe

/*	abort source tag		*/
#define Abort_Source					0x80

/*	result tag	 in Q.773 this tag is 0x82	*/
//#define Result							0xa2

/*	result source diagnostic tag	*/
#define Result_Source_Diagnostic		0xa3

/*	encoding tag	*/
#define Single_ASN1_type				0xa0
#define Octet_Aligned					0x81	// maybe 0xa1
#define Arbitrary						0x82	// maybe 0xa2

/*	result value	*/
#define Accepted						0x00
#define Reject_permanent				0x01

/*	dialogue service diagnostic tag	 in Q.773,value is 0x21 and 0x22	*/
#define Dialogue_Service_Provider		0x02
#define Dialogue_Service_User			0x01

/*	dialogue service user diagnostic tag	*/
#define DSU_N							0x00	// null
#define DSU_NRG							0x01	// no reason given
#define DSU_ACNNS						0x02	// application context name not supplied

/*	dialogue service provider diagnostic tag	*/
#define DSP_N							0x00	// null
#define DSP_NRG							0x01	// no reason given
#define DSP_NCDP						0x02	// no common dialogue portion

/*	abort source	*/

#define ABRTDlg_Service_User			0x00
#define ABRTDlg_Service_Provider		0x01

/*	unidirectional dialogue tag	*/
#define PDU_AUDT						0x65
#define PDU_ASUDT						0x66

#define REQUEST							1
#define INDICATE						2
#define RESPONSE						3
#define CONFIRM							4

#define PRE_END							1		// pre arranged end
#define BASIC_END						2		// basic end

#define DERR_ASN1						0x01	// decode error: asn1 decode error
#define DERR_UNTYPE						0x02	// decode error: unknown message type
#define DERR_UNTID						0x03	// decode error: lack transaction id
#define DERR_OTHER						0x04	// decode error: other reason

#define UABORT_NULL						0x00	// uabort reason:no
#define UABORT_SPEC						0x01	// uabort reason:specific reason
#define UABORT_ACNNS					0x02	// uabort reason:application context name not supplied

#define	ANSI_TAG_CLASS_CONS				0xE0
#define	ANSI_TAG_CLASS_PRIM				0xC0

#define	ITU_TCAP						0
#define	ANSI_TCAP						1

#define	TYPE_NATIONAL 					0
#define TYPE_PRIVATE					1

#define TYPE_INT						0
#define TYPE_OID						1

#endif
