#ifndef _MGC_STRUCT_H
#define _MGC_STRUCT_H

#include "mgc.h"
#include "../../../mgcp/src/include/mgcp.h"
#include "../../../8ecp/src/include/8ecp.h"

#define MGC_PORT_LIST_EN
#define MGC_REC_PORT
typedef struct _MGCP_REC_TAG
{
    PUB_SDP_MEDIA m;
    PUB_SDP_C c;	
	MGCP_M mode;
	char esCci[32];
}MGCP_REC_TAG;


typedef struct _CONNECT_INFO
{
	int id;
        DWORD           flag;	
	struct _MGCF_OPER_STEP *pOperStep;
#ifdef MGC_REC_PORT
    struct _PORT_INFO *pPrePortInfo;
#endif
	struct _CHNL_INFO *pChnlInfo;
	MGC_CONNECT_STATUS status;
        MGC_CODEC_LIST	codecList; 	
	MEDIA_ATTR		mediaAttr;   
	OPER_REC    operRec;
    MGCP_REC_TAG	mgcpRec;
	struct _MGC_TANDEM_INFO *pTandem;	
}CONNECT_INFO;



typedef struct _CHNL_INFO
{
	int id;
	BOOL 	monFlag;	// monitor flag		
	MGC_CHNL_INFO_STATUS	status;
	struct _PHY_PORT_INFO *pPhyPort;    //chnl's owner	
    WORD    connectNum;       //how many connection is attached
	WORD    maxConnectNum;    //max connection num could be attached to the chnl accroding to chnl's owner
	struct _CONNECT_INFO    *pConnection[MGC_MAX_NUM_OF_CHNL_CON]; //Media Index	
}CHNL_INFO;



typedef struct _PHY_PORT_INFO
{
	int id;
	int	portNo;		// mg local physical port No.  ??
	MGC_SAP	*pMgcSap;	// sap index, indicating which user creates this port
	BOOL 	monFlag;		
	MGC_PHY_PORT_STATUS 	status;	// physical port status: online/offline
	MGC_PHY_PORT_TYPE	portType;	// port type: E1/T1/analogue	
	struct _MG_INFO	*pMgInfo;		// mg No. this port resides on  ??	
	WORD	chnlNum;	// depend on mg type
	struct _CHNL_INFO *pChnlInfo[MGC_MAX_CHNL_NUM_PER_PHY];
}PHY_PORT_INFO;



typedef struct _MG_INFO
{
	int    id;         //internal used
	BOOL	created;	// created flag;
	BOOL	enable;		// MG status: available/unavailable
	BOOL 	monFlag;
	MG_ATTR	mgAttr;		// MG attributes

    PHY_PORT_INFO *pPhyPort[MGC_MAX_PHY_PORT_PER_MG];
	DWORD	requestId;	// SNMP request id
	DWORD auditTimer;
}MG_INFO;


typedef struct _MGCF_STEP_INFO
{
	struct _CONNECT_INFO *pPeerConn;
	int		delay;	
    MGC_CON_MODE mode;
	MGC_CMD_TYPE		cmd;
	MGC_CODEC_LIST codecList;
	PKG_SIGNAL pkgSig;
	BOOL    sigEn;    
	PKG_EVENT pkgEvent;
	BOOL    eventEn;
	PKG_REQ   pkgReq;
	BOOL    reqEn;
	DWORD remoteIp;      //only used for MG
}MGCF_STEP_INFO;


typedef struct _MGCF_OPER_STEP
{
    int id;
	struct _CONNECT_INFO *pConnect; //chnl connectIndex
	struct _PORT_INFO *pPortInfo;
	MGCF_STEP_INFO stepInfo;
	MGCP_OPER_STEP_STATUS status;
	WORD	hdlPort;		// lower layer port
	WORD	llCmd;		// lower layer command or response		
}MGCF_OPER_STEP;

typedef struct _PORT_INFO{
    int id;
	BOOL	assigned;
	WORD usrPort;
	WORD	mgcfTimer;	// mgcf timer
	MGC_MG_OPER_ID_TYPE  mgcfOperId;
	WORD cause;          //reason to tell uplayer	
	struct _MGCF_OPER_STEP *pMgcOperCurrent;
	struct _MGCF_OPER_STEP mgcfOperSteps[MGC_MAX_OPER_STEPS_NUM];	// max 8 steps
}
PORT_INFO;


typedef struct _MGC_8ECP_SAP
{
	struct _8ECP_SAP sap8ecp;
    int sapIndex;
}MGC_8ECP_SAP;

typedef struct _MGC_MGCP_SAP
{
    struct _MGCP_SAP sapMgcp;
	int sapIndex;
}MGC_MGCP_SAP;

typedef struct _MGC_CTL
{
    WORD sysId;       
    WORD localIp;
    WORD peerIp; //???
    WORD mgcMaxMgNo;
	WORD mgcMaxChlNo;
	WORD mgcMgCreated;
	WORD mgcChlAssigned;
}MGC_CTL;

typedef struct _MGC_INTERNAL_SAP
{
	MGC_SAP  mgcSap;
    int mgcSapIndex;
	int mgNoITL;
}MGC_INTERNAL_SAP;


typedef struct _MGC_SUR_INFO_NODE
{
	int id;
	struct _CONNECT_INFO *pConn;
    struct _MGC_SUR_INFO_NODE *pPrior;
    struct _MGC_SUR_INFO_NODE *pNext;
}MGC_SUR_INFO_NODE;

typedef struct _MGC_SUR_INFO_LIST
{
	struct _MGC_SUR_INFO_NODE *pHead;
    WORD len;	
}MGC_SUR_INFO_LIST;



typedef struct _MGC_TANDEM_INFO
{
    int id;
	char escci[32];
	struct _MGC_SUR_INFO_LIST list;
    MGC_TANDEM_STATUS status;	
    CONNECT_INFO *pTconn;  //pointer to target 
    CONNECT_INFO *pTxconn;  //pointer to where  target conn  to send
    CONNECT_INFO *pRxconn;  //pointer to where targe conn to recieve from 
    CONNECT_INFO *pAconn; // pointer to associator
}MGC_TANDEM_INFO;

typedef struct _MGC_PORT_LIST
{
    struct _MGC_PORT_NODE *pHead;
	WORD len;
}MGC_PORT_LIST;

typedef struct _MGC_PORT_NODE
{
    int id;
    struct _PORT_INFO *pPortInfo;
	struct _MGC_PORT_NODE *pPrior;
	struct _MGC_PORT_NODE *pNext;
    struct _MGC_PORT_LIST *pList;
}MGC_PORT_NODE;

#endif

