#ifndef _MGC_PORT_INFO_H
#define _MGC_PORT_INFO_H
#include "mgc_struct.h"


void mgc_port_info_setup(void);
void mgc_port_info_init(PORT_INFO *pPortInfo , int id);
void mgc_port_info_clear(PORT_INFO *pPortInfo);
PORT_INFO *mgc_port_info_get_unused_port(void);
void mgc_port_info_fsm(PORT_INFO *pPortInfo);
void mgc_port_info_oper_failure_report(PORT_INFO *pPortInfo ,  MGC_SAP *pMgcSap);
void mgc_port_info_oper_success_report(PORT_INFO *pPortInfo , MGC_SAP *pMgcSap);
PORT_INFO *mgc_port_info_find_port_by_id(int id);
PORT_INFO *mgc_port_info_get_step_port(MGCF_OPER_STEP *pOperStep);
BOOL mgc_port_info_add_opera_to_port(PORT_INFO *pPortInfo , CONNECT_INFO *pConnect , MGCF_STEP_INFO *pStepInfo);
BOOL mgc_port_info_add_ind_to_port(PORT_INFO *pPortInfo , CONNECT_INFO *pConnect , MGC_CMD_TYPE cmd , int hdlPort , DWORD remoteIp);
int mgc_port_info_cnf(PORT_INFO *pPortInfo , BYTE cmd, WORD hdlPort, WORD retCode, MGCP_PARA *pPara);


MGCF_OPER_STEP *mgc_port_info_get_unused_oper_step(PORT_INFO *pPortInfo);
void mgc_port_info_set_step_to_start(PORT_INFO *pPortInfo);
BOOL mgc_port_info_set_step_to_next(PORT_INFO *pPortInfo);
void mgc_port_info_set_oper_id(PORT_INFO *pPortInfo , MGC_MG_OPER_ID_TYPE operId);
void mgc_port_info_set_fsm_time(PORT_INFO *pPortInfo , WORD timer);
BOOL mgc_port_info_set_oper_step(MGCF_OPER_STEP *pMgcfOperStep , CONNECT_INFO *pConnect , MGCF_STEP_INFO *pStepInfo);
BOOL mgc_port_info_oper_step_cnf(MGCF_OPER_STEP *pMgcOperStep , MGCP_PARA *pPara);

void mgc_port_info_set_step_info(MGCF_STEP_INFO *pStepInfo , MGC_CMD_TYPE cmd , CONNECT_INFO *pPeerConn , 
	                                  WORD delay, MGC_CON_MODE mode, PKG_EVENT *pPkgEvent, PKG_SIGNAL *pPkgSig , PKG_REQ *pPkgReq);

BYTE *mgc_port_info_get_res_addr(void);
char *mgc_port_info_print_cmd(MGC_CMD_TYPE cmd);
char *mgc_port_info_print_opera_id(MGC_MG_OPER_ID_TYPE operaId);

BOOL mgc_port_info_insert_dlcx_req(PORT_INFO *pPortInfo , CONNECT_INFO *pConnect);
BOOL mgc_port_info_mv_step_into_new_port(PORT_INFO *pPortInfo , MGCF_OPER_STEP *pOperStep);

#endif
