#include "debug.h"
#include "p_util.h"
#include "p_rtp.h"
#include "p_sdp.h"

extern DSHORT Mgcp_iSendLen;
extern BOOLEAN Cnc_bReqAuthoc;
extern XSHORT Mgcp_iRecvMsgType;

#define MGCP_VERB_EPCF	0
#define MGCP_VERB_CRCX	1
#define MGCP_VERB_MDCX	2
#define MGCP_VERB_DLCX	3
#define MGCP_VERB_RQNT	4
#define MGCP_VERB_NTFY	5
#define MGCP_VERB_AUEP	6
#define MGCP_VERB_AUCX	7
#define MGCP_VERB_RSIP	8
#define MGCP_VERB_NUM	9
#define MGCP_VERB_UNKNOWN	99

#define MGCP_RSIP_GRACEFUL		0
#define MGCP_RSIP_FORCED		1
#define MGCP_RSIP_RESTART		2
#define MGCP_RSIP_DISCONNECTED	3
#define MGCP_RSIP_CANCEL		4
#define MGCP_RSIP_CNC_SPECIAL	5

// functions in mgcp_trans.c
void MgcpTransInit();
void MgcpTransSendReq(ULONG iTransId, UCHAR iMethod);
void MgcpTransSendResp(ULONG iTransId);
BOOLEAN MgcpTransRecvReq(ULONG iTransId);
UCHAR MgcpTransRecvResp(ULONG iTransId);
void MgcpTransFree(ULONG iTransId);
void MgcpTransHandleTimer();

// functions in mgcp_tsp.c
void MgcpSendReqData();
void MgcpSendRespData();
void MgcpRxReqPacket(UCHAR iTransNo);
void MgcpRxRespPacket(UCHAR iTransNo);

// functions in mgcp_map.c
void MgcpMapAddEntry(PXCHAR pMapEntry);
UCHAR MgcpMatchMap(PXCHAR pEvent, UCHAR iEventNum);

// functions in mgcp_sdp.c
void MgcpSdpMsg(BOOLEAN bOffer);
BOOLEAN MgcpHandleSdp(UCHAR iRecvSdpNum);

// functions in mgcp_core.c
void MgcpCommandLine(UCHAR iCode, BOOLEAN bWildCard);
void MgcpSendReq(UCHAR iRequest);
void MgcpSendResp(USHORT iCode);
void MgcpSendRSIP(UCHAR iMethod);
void MgcpInitRecv();
void MgcpProcessData();
void MgcpRunData(PXCHAR pData);
void MgcpHandleTspError(UCHAR iMethod);
void MgcpInitConn();

// functions in mgcputil.c
PXCHAR _StrchrBrkt_x(PXCHAR pData, UCHAR iChar);
void _NewToken(PXCHAR pToken, UCHAR iLen);

void MgcpCopyFromSdram(UCHAR iSdramLo);

BOOLEAN	p_strstr_nocase_c(PXCHAR pDst, PCCHAR pSrc);

// mgcp_auth.c
void CncSendRSIP();
void CncHandleS();
void CncAuthInit();
