/*****************************************************************************
 *
 * 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_config.h of snet module
 *
 * SpiderISDN
 * Release 3.0.0 94/12/20
 * 
 * SpiderISDN Release 3 - Official Release.
 *
 *****************************************************************************/
 
/*
 *  il3_config.h
 *
 *	- IL3 module STREAMS configuration defines
 */

#define	IL3	0x494C3300	/* "IL3" :-)*/

/*
 * Stream ID - each kernel driver has one - used by strlog
 */
#define IL3_STID	504

#define	IL3_MACHINE				0x01
#define	IL3_SNCHAR				0x02
#define	IL3_TIMERS				0x03
#define	IL3_PROTOCOL				0x04
#define	IL3_STATS				0x05
#define	IL3_STATUS				0x06
#define	IL3_HISTORY				0x07
#define	IL3_TRACE_ON				0x08
#define	IL3_TRACE_OFF				0x09

/*
 * IL3 Machine
 */
#define	IL3_NATIONALITY				0x01
#define	IL3_TYPE_OF_ADDRESS			0x02
#define	IL3_NUMBERING_PLAN			0x03
#define	IL3_TYPE_OF_SUBADDRESS			0x04
#define	IL3_INFORMATION_TRANSFER_CAP_IN		0x05
#define	IL3_INFORMATION_TRANSFER_CAP_OUT	0x06
#define	IL3_USER_OPTIONS			0x07
#define	IL3_DATALINK_DELAY_ACK			0x08
#define IL3_RATE				0x09
#define	IL3_USER_OPTIONS_EXTRA			0x0B
#define	IL3_SPID				0x0C
#define	IL3_DIRECTORY_NUMBER			0x0D
#define	IL3_SUB_ADDRESS				0x10
#define	IL3_SNID_PUT				0x0E
#define	IL3_SNID_GET				0x0F

/*
 * The maximum number of multiple strings a variable can take.
 */
#define MAX_STRINGS_PER_VAR     8
#define MAX_LMI_STRING_LEN     	80

typedef struct il3stats {
	uint32 no_in_calls;		/* No of incoming calls. (SETUPs) */
	uint32 no_in_calls_up;	/* No of incoming calls passed to upper layer */
	uint32 no_in_calls_acc;	/* No of incoming calls accepted by upper layer */
	uint32 no_in_calls_rej; /* No of incoming calls rejected by upper layer */
	uint32 no_out_calls;	/* Total number of outgoing calls. */
	uint32 no_out_calls_acc;/* Number of outgoing calls accepted. */
	uint32 no_out_calls_rej;/* Number of outgoing calls rejected. */
	uint32 no_unk_msg_in;	/* Number of unknown messages in. */
	uint32 no_bad_msg_in;	/* Number of recognised but corrupted messages in */
} il3stats_t;

/*
 * Set snid structure.
 */
typedef struct il3_snchar
{
	uint32 snid;		/* SNID for this channel. */
	uint32 muxid;		/* Multiplexor ID of target channel. */
	uint8 channeltype;	/* ISDN_B_CHAN or ISDN_D_CHAN */
	uint8 channelno;	/* Channel no; 1 = B1, any for D-channel */
	uint8 controller;	/* Controller no; 1 = first controller. */
	uint8 pad;
} il3_snchar_t;

#define	MAX_T_LEN	8	/* Make sure following structure has no gaps */
typedef struct il3_timers
{
	uint8 timer_no[MAX_T_LEN];/* Timer number as specified in refs, eg "T301". */
	uint32 timeout;	/* Timeout value in seconds. */
} il3_timers_t;

#define	IL3_CHAN_TYPE_B		1	/* B-channel */
#define	IL3_CHAN_TYPE_D		2	/* D-channel */
/*
 * For just now until AA has header file.
 */
#define	ISDN_B_CHAN	IL3_CHAN_TYPE_B
#define	ISDN_D_CHAN	IL3_CHAN_TYPE_D

#ifndef ATNT
#define	MIN_CREF	0
#define	MAX_CREF	2
typedef struct cref	/* Call reference */
{
	uint8 cref_len;
	uint8 cref_val[3];
} cref_t;
#else /* ATNT */
#define MIN_CREF        0
#define MAX_CREF        3 
typedef struct cref     /* Call reference */
{
        uint8 cref_len;
        uint8 cref_val[4];
} cref_t;

#endif /* ATNT Meer */

typedef struct b_channel_no_s {
        uint8 chan_type;
        uint8 chan_num ;
        uint8 mult_num ;
        uint32 map_num ;
} b_channel_no_t; 
	
typedef struct il3cbstate
{
	cref_t cref;			/* Call reference */
	uint32 call_type;		/* Circuit, temp, global or packet */
	uint32 cc_state;		/* NOTE: This will NOT be a bitmask, 
                                                               but state no */
	xisdnf_t calling;		/* Calling num(includes subaddress) */
	xisdnf_t called;		/* Called num (includes subaddress) */
	b_channel_no_t b_channel;	/* B-channel number 		    */
	uint8  cause;			/* ETSI cause for failing call. */
	uint8  local_failure;	/* IL3 reason for failing call. */
} il3cbstate_t;

/*
 * This structure is used as the primary key for the GET STATUS
 * LMI call.
 */

typedef struct il3status_pk
{
	uint32	snid;			/* Subnetwork ID		*/
	uint8	chan_id;		/* B/D channel number		*/
	uint8	pad[3];			/* To pad to (*long) alignment	*/
} il3status_pk_t;

/*
 * Used to gain the dlpi state.
 */
#define IL3_CONS	0
#define IL3_CLNS	1

/*
 * This structure is used to return status information about 
 * D/B channels. This could have been separated into two structures
 * but using one keeps it simpler, and requires less kernel code.
 */
typedef struct il3status
{
	/*
	 * Common status information.
	 */
        uint8		state;          /* As taken from bdhead structure */

	/*
	 * D-channel status information.
	 */
	uint8		dlpi_cons_state;
	uint8		dlpi_cons_other_state;
	uint8		dlpi_clns_state;
	uint8		dlpi_cons_info_state;
	uint8		dlpi_clns_info_state;

	uint8		pad[3];		/* To pad to (*long) alignment	*/

	/*
	 * B-channel status information.
	 */
	uint32		cc_state;	
	uint32		call_type;	/* Circuit, temp, global or packet */

	cref_t		b_chan_cref;

	xisdnf_t	calling;	/* Calling number/subaddress)	*/
	xisdnf_t	called;		/* Called number/subaddress)	*/
} il3status_t;
