/***********************************************************
Copyright (C), LGC Wireless.
File Name:		isdn_msg.h
Description:	ISDN message structure or correlation
Version:		v9.0.0
Author:			Gengxin Chen
Create Date:	2008-1-17
Remark:			M:mandatory, O:optional
History:
	<author>	<date>		<version>		<desc>
	
************************************************************/
#ifndef _ISDN_MSG_H
#define _ISDN_MSG_H

#include "isdn_const.h"
#include "isdn_ie.h"


/************************************************************
ISDN mandatory information elements structure
************************************************************/
typedef struct _msgMan		//Message mandatory information elements
{
	u8 proto_Discr;		//Protocol discriminator
	u8 cr_len;			//Length of call reference value(in octets)
	u8 call_ref[2];		//Call reference value
	u8 msg_type;		//Message type
}MsgMan;


/************************************************************
ISDN message structure
************************************************************/

typedef struct _isdnAlert			//ALERTING
{
	ChnlId		chnl_id;		//Channel identification						O/M
	PrgInd		prg_ind;		//Progress indicator							O

	BrCap		br_cap;			//Bearer capability						O
	Disp		disp;			//Display
	Sign		sign;			//Signal
	HLComp		hl_comp;		//High layer compatibility

	//ansi
	Fac			facility;			//facility
}IsdnAlert;

typedef struct _isdnCallProc		//CALL PROCEEDING
{
	ChnlId		chnl_id;		//Channel identification						O/M

	BrCap		br_cap;			//Bearer capability						O
	PrgInd		prg_ind;		//Progress indicator
	Disp		disp;			//Display
	HLComp		hl_comp;		//High layer compatibility
}IsdnCallProc;

typedef struct _isdnConn			//CONNECT
{
	ChnlId		chnl_id;		//Channel identification						O/M

	BrCap		br_cap;			//Bearer capability						O
	PrgInd		prg_ind;		//Progress indicator
	Disp		disp;			//Display
	DtTime		dt_time;		//Date/time
	Sign		sign;			//Signal
	LLComp		ll_comp;		//Low layer compatibility
	HLComp		hl_comp;		//High layer compatibility
	//QSIG
	ConnNum	conn_num;		//Connected number
	//Connected subaddress
}IsdnConn;

typedef struct _isdnConnAck			//CONNECT ACKNOWLEDGE
{
	Disp		disp;			//Display								O
	Sign		sign;			//Signal
}IsdnConnAck;

typedef struct _isdnDisc			//DISCONNECT
{
	CauseStr		cause;			//Cause									M

	PrgInd		prg_ind;		//Progress indicator					O
	Disp		disp;			//Display
	Sign		sign;			//Signal
}IsdnDisc;

typedef struct _isdnInfo			//INFORMATION
{
	SdComp		sd_comp;		//Sending complete						O
	Disp		disp;			//Display
	KpdFac		kpd_fac;		//Keypad facility
	Sign		sign;			//Signal
	CdPtyNum	cd_pty_num;		//Called party number
}IsdnInfo;

typedef struct _isdnNoti			//NOTIFY
{
	NotifyInd		notify_ind;		//Notification indicator				M
	Disp			disp;			//Display								O

	BrCap		br_cap;			//Bearer capability						O
}IsdnNoti;

typedef struct _isdnProg			//PROGRESS
{
	PrgInd		prg_ind;		//Progress indicator					M

	BrCap		br_cap;			//Bearer capability						O
	CauseStr		cause;			//Cause									O
	Disp		disp;			//Display
	HLComp		hl_comp;		//High layer compatibility

	//ansi
	Fac			facility;			//facility
}IsdnProg;

typedef struct _isdnRel				//RELEASE
{
	CauseStr		cause;			//Cause									O

	Disp		disp;			//Display
	Sign		sign;			//Signal
}IsdnRel, IsdnRelComp;

/*typedef struct _isdnRelComp			//RELEASE COMPLETE
{
	CauseStr		cause;			//Cause									O
	Disp		disp;			//Display
	Sign		sign;			//Signal
}IsdnRelComp;
*/
typedef struct _isdnRestart		//Restart
{
	ChnlId		chnl_id;		//Channel identification				O
	RestartInd	restart_ind;	//Restart indicator					M

	Disp		disp;			//Display
}IsdnRestart, IsdnRestAck;

typedef struct _isdnSetup			//SETUP
{
	BrCap		br_cap;			//Bearer capability						M
	ChnlId		chnl_id;		//Channel identification				O/M
	PrgInd		prg_ind;		//Progress indicator
	NtSpFac		nt_sp_fac;		//Network specific facilities
	Disp		disp;			//Display
	CgPtyNum	cg_pty_num;		//Calling party number
	CdPtyNum	cd_pty_num;		//Called party number
	TranNtSel	tran_nt_sel;	//Transit network selection
	
	SdComp		sd_comp;		//Sending complete						O
	RptInd		rpt_ind;		//Repeat indicator						O
	DtTime		dt_time;		//Date/time
	KpdFac		kpd_fac;		//Keypad facility
	Sign		sign;			//Signal
	CgPtyAddr	cg_pty_addr;	//Calling party subaddress
	CdPtyAddr	cd_pty_addr;	//Called party subaddress
	LLComp		ll_comp;		//Low layer compatibility
	HLComp		hl_comp;		//High layer compatibility

	//ansi
	Fac			facility;		//facility
	RedirNum	redir_num;		//Redirection number
//	OrgCdNum	org_cd_num;	//original called number
}IsdnSetup;

typedef struct _isdnSetupAck		//SETUP ACKNOWLEDGE
{
	ChnlId		chnl_id;		//Channel identification				O
	PrgInd		prg_ind;		//Progress indicator
	Disp		disp;			//Display
	Sign		sign;			//Signal
}IsdnSetupAck;

typedef struct _isdnStatus			//STATUS
{
	CauseStr		cause;			//Cause									M
	CallStat	call_stat;		//Call state							M

	Disp		disp;			//Display								O
}IsdnStatus;

typedef struct _isdnStatEnq			//STATUS ENQUIRY
{
	Disp		disp;			//Display								O
}IsdnStatEnq;

typedef struct _isdnResuResp
{
	
}IsdnResuResp;

typedef struct _isdnResuRejReq
{
	
}IsdnResuRejReq;

typedef struct _isdnSusp
{
	
}IsdnSusp;

typedef struct _isdnSuspRejReq
{
	
}IsdnSuspRejReq;

typedef struct _isdnTimeout
{
	
}IsdnTimeout;


//ansi
typedef struct _isdnService			//Service
{
	ChgStat		chg_stat;		//change status				M
	ChnlId		chnl_id;			//channel identification		M
}IsdnService, IsdnServAck;

typedef struct _isdnFac				//Facility
{
	
}IsdnFac;




typedef struct	_isdnMsgStr
{
	MsgMan	msg_m;

	union
	{
		/*******Call establishment messages*******/
		IsdnAlert		alert;	//alerting
		IsdnCallProc	callProc;	//Call proceeding
		IsdnConn		conn;	//Connect
		IsdnConnAck	connAck;	//Connect acknowledge
		IsdnProg		prog;	//progress
		IsdnSetup	setup;	//setup
		IsdnSetupAck	setupAck;	//Setup acknowledge
		
		/*******Call information phase messages:*******/
		IsdnResuRejReq	resuRejReq;	//resume reject require
		
		/*******Call clearing messages:*******/
		IsdnDisc		disc;	//disconnect
		IsdnRel		rel;		//release
		IsdnRelComp	relComp;	//release complete
		IsdnRestart	restart;		//restart
		IsdnRestAck	restAck;		//restart Acknowledge

		/*******Miscellaneous messages:*******/
		IsdnInfo		info;		//
		IsdnNoti		noti;		//
		IsdnStatus	status;	//
		IsdnStatEnq	statEnq;	//

		/*******Maintenance messages*******/
		IsdnService	service;		//service
		IsdnServAck	servAck;	//service acknowledge
	}msg_list;
}IsdnMsgStr;


typedef struct _IuaMsgStr
{
	u8		pad[25];
	u8		msg_class;			/*xua msg type=0x05*/
	u8		e1_no;			 /* E1 number */    
	u16		msg_length	__attribute__((packed));		 	 /* ISDN Message length */
	union
	{
		struct
		{
			u8	mtp3_ip;			/* reserved */
			u8	opercode;			/* 1=Out Of Service   5=In Service  6=Processor Outage*/
			u8	alarmcode;
		}lkmsg;
		struct
		{
			MsgMan	msg_m;
			u8	ie_content[IE_MAX_LEN];			/* information elements Content */
		}isdn_msg;						/*isdn message content*/
	}msgcontent;
}IuaMsgStr;



/************************************************************
ISDN timer structure
************************************************************/
typedef struct _isdnTimerStr	//计数, 有几个十毫秒
{
	u16 t301;
	u16 t302;
	u16 t303;
	u16 t304;
	u16 t305;
	u16 t306;
	u16 t307;
	u16 t308;
	u16 t309;
	u16 t310;
	u16 t312;
	u16 t313;
	u16 t316;
	u16 t317;
	u16 t321;
	u16 t322;

	u16 t1s;
	u16 t40s;
	u16 t240s;
	//ansi	
	u16 t3M1;
}IsdnTimerStr;


IsdnTimerStr	isdn_timer_var;
IuaMsgStr	iua_sd_msg, iua_rv_msg;






#endif
