/*
 *
 * Copyright (c) 1993-1994 Spider Systems Limited
 *
 * This Source Code is furnished under Licence, and may not be
 * copied or distributed without express written agreement.
 *
 * All rights reserved.  Made in Scotland.
 *
 * Authors: Harry Bryson
 *
 * il3_sm.h of il3 module
 *
 * SpiderISDN
 * Release 3.0.0 94/12/20
 * 
 * SpiderISDN Release 3 - Official Release.
 *
 */
 
/*
 *  il3sm.h
 *
 *    - IL3 module STREAMS state machine defines
 */

/*
 * States.
 * Use bitmask. < 32 states and saves having horrendous if()s.
 * Keep state number in #define; makes checking with SDL easier.
 */
#define IL3_0STATE_NULL				0x00000001
#define IL3_1STATE_CALL_INI			0x00000002
#define IL3_2STATE_OVERLAP_SEN			0x00000004
#define IL3_3STATE_OUTGOING_CALL_PRO		0x00000008
#define	IL3_4STATE_CALL_DEL			0x00000010
#define	IL3_6STATE_CALL_PRE			0x00000040
#define	IL3_7STATE_CALL_REC			0x00000080
#define	IL3_8STATE_CONNECT_REQ			0x00000100
#define	IL3_9STATE_INCOMING_CALL_PRO		0x00000200
#define	IL3_10STATE_ACTIVE			0x00000400
#define	IL3_11STATE_DISCONNECT_REQ		0x00000800
#define	IL3_12STATE_DISCONNECT_IND		0x00001000
#define	IL3_15STATE_SUSPEND_REQ			0x00008000
#define	IL3_17STATE_RESUME_REQ			0x00020000
#define	IL3_19STATE_RELEASE_REQ			0x00080000
#define	IL3_25STATE_OVERLAP_REC			0x02000000

/*
 * 1TR6 PD = N0, editor process states.
 */
#define	IL3_1STATE_OPEN_REQ			0x00000002
#define	IL3_10STATE_CLOSE_REQ			0x00000400
#define	IL3_20STATE_STATUS_REQ			0x00100000
#define	IL3_21STATE_INFO_REQ			0x00200000
/*
 * Used by SETUP at least.
 */
#define	IL3_NSTATE_ALL				0xFFFFFFFF
/*
 * il3cb cc_info bits. Keeps global info about current call.
 */
#define	ONETR6_SPV		0x1000
#define	ONETR6_DEAC		0x2000
#define	SETUP_BC	0x80	/* Setup broadcast */
#define	MT_BC		0x40	/* Message broadcast */
#define	USER_PRESENT	0x20	/* IL3 user for call present */
#define	NOT_ALL_ISDN	0x10	/* Call not end-to-end ISDN */
#define CALL_CHARGED	0x08	/* Charging for call has started */
#define	CALL_STARTED	0x04	/* Call processing started */
#define	Q_CACTIVE	0x02	/* Waiting for data before CACTIVating */

/*
 * Info bits. Used by messages and information elements.
 */
#define	NAT_GERMAN		0x00010000
#define NAT_BRITISH		0x00020000
#define	NAT_FRENCH		0x00040000
#define	NAT_ETSI		0x00080000
#define	NAT_NATIONAL_ISDN_1	0x00100000
#define	NAT_NATIONAL_ISDN_2	0x00200000
#define NAT_ATT_41449           0x00400000
#define NAT_DMS100	        0x00800000
#define NAT_NTT	        	0x01000000
#define NAT_AUSTEL	        0x02000000

#define	NAT_EITHER_NATIONAL_ISDN \
			(NAT_NATIONAL_ISDN_1|NAT_NATIONAL_ISDN_2)

#define	NAT_ALL		(NAT_BRITISH|NAT_FRENCH|NAT_GERMAN|NAT_ETSI| \
			 NAT_ATT_41449|NAT_DMS100|NAT_EITHER_NATIONAL_ISDN| \
                         NAT_NTT|NAT_AUSTEL )

#define	NAT_NOT_GERMAN	(NAT_ALL & ~NAT_GERMAN)


/*
 * Following orthogonal bits to allow user-combination of
 * valid in transfer capabilities.
 */
#define	I_INFO_TC_SPEECH		0x01
#define	I_INFO_TC_UNRES_DIG		0x02
#define	I_INFO_TC_RES_DIG		0x04
#define	I_INFO_TC_31AUDIO		0x08
#define	I_INFO_TC_7AUDIO		0x10
#define	I_INFO_TC_VIDEO			0x20
#define	I_INFO_TC_UNRES_DIG_56		0x40
#define	I_INFO_TC_ALL			0x7F


/*
 * Following values are used to allow user define rate
 * adaption standard in bearer services(octet 5).
 */
#define	I_RATE_ADAPT_V110        	0x21
#define	I_RATE_MU_LAW			0x22
#define	I_RATE_A_LAW		        0x23
#define	I_RATE_ADAPT_V120		0x28
#define	I_RATE_ADAPT_HDLC        	0x29

/* 
 * Following values are used to allow user define
 * Intermediate rate adaption value, Network Independent
 * clock value, Flow control on transmission and 
 * reception values, for V.110 mode 
 * for bearer services(octet 5b).
 */  
#define	I_RATE_V110_FLOW_RX		0x02
#define	I_RATE_V110_FLOW_TX	        0x04
#define	I_RATE_V110_NIC_RX  		0x08
#define	I_RATE_V110_NIC_TX 		0x10
#define	I_RATE_V110_INTER_8 		0x20
#define	I_RATE_V110_INTER_16 		0x40
#define	I_RATE_V110_INTER_32 		0x60

/* 
 * Following values are used to allow user define
 * Inband/Outband Negotiation, Assignor/Assignee,
 * Logical Link identifier, Mode of Operation, 
 * Multiple frame establishment in data link layer
 * Rate adaption header or no header values , for 
 * V.120 mode for bearer services(octet 5b).
 */  
#define	I_RATE_V120_BAND		0x02
#define	I_RATE_V120_ASSIG	        0x04
#define	I_RATE_V120_LLI  		0x08
#define	I_RATE_V120_MOP 		0x10
#define	I_RATE_V120_MFE 		0x20
#define	I_RATE_V120_HEADER 		0x40

/* 
 * Following values are used to allow user define
 * stop bits, data bits excluding parity,
 * parity info, for bearer services(octet 5c).
 */  
#define	I_DB_PI_ODD      		0x00
#define	I_DB_PI_EVEN	                0x02
#define	I_DB_PI_NONE     		0x03
#define	I_DB_PI_F0 		        0x04
#define	I_DB_PI_F1       		0x05
#define	I_DB_DB_5       		0x08
#define	I_DB_DB_7	                0x10
#define	I_DB_DB_8        		0x18
#define	I_DB_STOP_1 		        0x20
#define	I_DB_STOP_15       		0x40
#define	I_DB_STOP_2       		0x60


/* 
 * Following values will allow user to prefer 
 * 64K  HDLC or 56K HDLC B-Channel for an 
 * incoming call. Thic will be set when sending
 * a XN_CONNACK .     Meer
 */

#define HDLC_64K	0x01
#define HDLC_56K	0x02


/*
 * Conformance types - specific to NATIONAL_ISDN.
 *
 * The conformance type is stored in il3gcb.
 */
#define	CONFORMANCE_NONE	0x00
#define	CONFORMANCE_NIUF	0x01
#define	CONFORMANCE_COS		0x02

/*
 * CC_CIRCUIT MUST be lowest bit value of the set below and bit values for
 * following 4 things must increase sequentially. Used bit-shifted into
 * a uint8 for bearer capability argument structure.
 * Do NOT change these values.
 */
#define	CC_CIRCUIT	0x1000	/* Circuit-mode */
#define	CC_PACKET	0x2000	/* Packet-mode */
#define	CC_TEMP		0x4000	/* Temp-mode */
#define	CC_GLOBAL	0x8000	/* Global call reference */

#define	CC_SHIFT	12	/* 2 ^ CC_SHIFT == CC_CIRCUIT */

#define	CC_NOTGLOB	(CC_CIRCUIT|CC_PACKET|CC_TEMP)
#define	CC_ALL		(CC_CIRCUIT|CC_PACKET|CC_TEMP|CC_GLOBAL)
#define	CS_0		0x100	/* Codeset 0 IE */
#define	CS_6		0x200	/* Codeset 6 IE */
#define	CS_5		0x400	/* Codeset 5 IE */
#define	CS_ALL		(CS_0|CS_5|CS_6)
/*
 * Next define for il3cb codeset field, not info field.
 * It is a *fixed* Q.931 value.
 * Hence can share #define value with other info field #define.
 * MUST be different from CS_0 and CS_6 (and any other CS_? introduced).
 */
#define	CS_LOCKED	0x08	/* Locked codeset, otherwise temporary */
#define	CC_PD_N0	0x400	/* Otherwise N1 for 1TR6 */
#define	INFO_NORM	(NAT_ALL|CC_NOTGLOB|CS_0)
#define	INFO_NORM6	(NAT_ALL|CC_NOTGLOB|CS_6)
#define	REPEAT_IE	0x800	/* IE can be repeated in message */

/*
 * Facility IE TLV sub-types
 */
#define	IL3_FAC_CHARGE_CONT	1	/* Continuous charging information */
#define	IL3_FAC_CHARGE_END	2	/* Charging information at end */
#define	IL3_FAC_CHARGE_INFO	3	/* Charging information */

/* 
 * Following values are used to allow user define
 * Octet 5a User Rate in Bearer Capability IE.
 * These values are the supported User rate for 
 * Munich controller. Depending upon the user
 * seeting Rate adaption value , for 
 * V.110 mode connect_cfg_t will be filled
 * for Munich.  Meer
 */  
#define	I_RVAL_600			0x01
#define	I_RVAL_1200	        	0x02
#define	I_RVAL_2400  			0x03
#define	I_RVAL_4800	 		0x05
#define	I_RVAL_9600	 		0x08
#define	I_RVAL_19200	 		0x0B
#define	I_RVAL_56K	 		0x0F

/*
 * For BIT-6 of octet 5a 
 */
#define I_INBAND_NEGO_POS	0x20

/*
 * For BIT-7 of octet 5a
 */

#define I_USER_RATE_ASYCH	0x40
