#ifndef _MGC_STRUCT__H
#define _MGC_STRUCT__H

#include "mgc.h"
#include "mgc_const.h"

typedef struct _MG_INFO
{
	BYTE	created;	// created flag;
	BYTE	status;		// MG status: available/unavailable
	BYTE	stLast;		// MG status last: available/unavailable
	BYTE 	monFlag;
	BYTE	usrType;	// user acts as a mg or mgc
    DWORD   auditTimer;
	
	MG_ATTR	mgAttr;		// MG attributes

	// number and index of the ports created on this MG, not applicable to virtual MG
	BYTE	portNum;
	WORD	portIndex[MGC_MAX_PHY_PORT_PER_MG];// max 32 physical ports per MG

	// number and starting index of the channel created on this MG, only applicable to virtual MG
	WORD	chnlNum;
	WORD	chnlStartIndex;
	BYTE	sapIndex[MGC_MAX_NUM_OF_SAP];
	
	DWORD	requestId;	// SNMP request id
}MG_INFO;

typedef struct _PHY_PORT_INFO
{
	BYTE	created;	// created flag
	BYTE	mgNo;		// mg No. this port resides on
	BYTE	portNo;		// mg local physical port No.
	BYTE	portType;	// port type: E1/T1/analogue
	BYTE	sapIndex;	// sap index, indicating which user creates this port
	BYTE 	phyStatus;	// physical port status: online/offline
	BYTE 	stLast;		// physical port status: online/offline
	BYTE 	monFlag;
	
	// number and starting index of the channel created on this port, not applicable to virtual MG
	BYTE	chnlNum;	// depend on mg type
	WORD	chnlStartIndex;
}PHY_PORT_INFO;

typedef struct _CHNL_INFO
{
	BYTE	assigned;	// assigned flag
	BYTE	mgNo;		// mg No. this channel resides on
	BYTE	portNo;		// mg local physical port No., not applicable to virtual MG
	BYTE	status;		// connection status, created or not
	WORD 	port;		// which port is in handling this channel
	BYTE	sapIndex;   // sap index, indicating which user creates this channel, applicable for ANN MG
	BYTE 	monFlag;	// monitor flag
	BYTE	auepSt;		// AUEP status
    WORD    connectNum;
    
	WORD    connectIndex[MGC_MAX_NUM_OF_CHNL_CON]; //Media Index
	MEDIA_ATTR    comMediaAttr;
    

//	MGC_CODEC_LIST	codecList;	// list of codecs that this channel may negotiate with other channel 
//	MEDIA_ATTR		mediaAttr;	// media info of this channel
}CHNL_INFO;

typedef struct _CONNECT_INFO
{
	BYTE	        assigned;
	WORD	        chlIndex;
	WORD 	        port;		// which port is in handling this connection
	BYTE            status;
    CHNL            aasChnl;
    DWORD           flag;

    MGC_CODEC_LIST	codecList;           
	MEDIA_ATTR		mediaAttr;
	OPER_REC     operRec;
}CONNECT_INFO;

typedef struct _MGCF_OPER_STEP
{
	CHNL		localChnl;	// local channel to be operated, mandatory
	CHNL		remChnl;	// remote channel to be operated, optional
	BYTE		cmd;		// operation command
	DWORD		delay;		// delay after the operation 
	WORD		pkgSignal;	// package + signal
	MEDIA_PARA	media;		// media para

	WORD        chnlConnectIndex; //chnl connectIndex

	WORD        flag;
}MGCF_OPER_STEP;

typedef struct _PORT_INFO
{
	BYTE	assigned;
	BYTE	mgcfState;	// mgcf state
	BYTE	mgcfState2;	// mgcf state2
	WORD	mgcfTimer;	// mgcf timer
	CHNL	mgcfChnl;	// current operation channel
	WORD	usrPort;	// user port
	WORD	llPort;		// lower layer port
	WORD	usrCmd;		// user command or response
	WORD	llCmd;		// lower layer command or response
	BYTE	mngCmd;		// management commmand
	DWORD   ip;
	
	BYTE	mgcfOperId;
	BYTE 	mgcfOperStepsNum;	// total number of operation steps
	BYTE	mgcfOperStepIndex;	// current operation step index
	MGCF_OPER_STEP mgcfOperSteps[MGC_MAX_OPER_STEPS_NUM];	// max 8 steps
}PORT_INFO;

#endif
