#ifndef _TCP_PORT_H_
#define _TCP_PORT_H_

#include "tcp_inc.h"

#define TCP_MAX_NUM_OF_PORT	16
#define TCP_MAX_RECV_MSG_LEN	1500
#define TCP_MAX_SEND_MSG_LEN	1500
#define TCP_MAX_PAYLOAD_SIZE	1350
#define TCP_MAX_RECV_BUF_LEN	8192
#define TCP_MAX_RECV_COUNT		128

typedef struct _tcp_header_t
{
	BYTE	ver;	// version
	BYTE	pt;	// payload type
	WORD	sn;	// sequence number
	DWORD	timestamp;
	DWORD	ssrc;	//synchronization src
}tcp_header_t;

typedef struct	_tcp_session_t
{
	DWORD	src_ip;
	WORD	src_port;
	DWORD	dst_ip;
	WORD	dst_port;
	BYTE		bServer;	// tcp client: 0; server: 1;
}tcp_session_t;

typedef struct _tcp_port_t
{
	BYTE		flag;
	int		index;
	BYTE		status;
	int		timer;
	int		retry_num;
	WORD	usr_port;
	int		fd;
	int		cli_fd;

	BYTE		rv_buf[TCP_MAX_RECV_BUF_LEN];
	int		buf_len;

	int		connected_num;
	int		disconnect_num;
	int		sent_fail_num;
	tcp_session_t sess;
	struct _tcp_sap_t	*ptr_sap;
}tcp_port_t;

extern void tcp_port_init(WORD id);
extern void tcp_port_recv_msg(void);
extern int tcp_link_fsm();

int get_tcp_sess(WORD hdlPort, tcp_session_t *sess);

#endif

