#ifndef DELIVER_PRIVATE_H
#define DELIVER_PRIVATE_H

#include <mirror_stream.h>
#include <MESA/field_stat2.h>

#ifndef MAX_THREAD_NUM
#define MAX_THREAD_NUM 	128
#endif

#define DELIVER_DEFAULT_MTU					1500
#define DELIVER_SENDPKT_BUFLEN				2048

//runtime log
#define DELIVER_MODULE_INIT					"mirror_stream_init"
#define DELIVER_MODULE_SENDPKT				"mirror_stream_sendpkt"
#define DELIVER_SENDPKT_START				"sendpkt_start"
#define DELIVER_SENDPKT_DEBUG				"sendpkt_debug"
#define DELIVER_RECVPKT_DEBUG				"recvpkt_debug"
#define DELIVER_SENDPKT_END					"sendpkt_end"

#define DELIVER_FLAG_SENDPKT				0
#define DELIVER_FLAG_RECVPKT				1
#define DELIVER_FLAG_ENT					2

//init profile info
#define DELIVER_CARDNAME_LEN				128
#define DELIVER_CONF_MAXLEN					1024
#define DELIVER_CONF_MODE					"DELIVER"
#define DELIVER_RCV_MAC						"reveiver_mac"

#define PROTO_TYPE_TCP						6
#define PROTO_TYPE_UDP						17


//lqueue info
#define DELIVER_THREAD_SAFE					1
#define DELIVER_USLEEP_TIME					10
#define DELIVER_LQUEUE_MAXNUM				100000	


//send pkt
#define DELIVER_MACADDR_LEN					6
#define DELIVER_MACADDR_STR_LEN				18			
#define DELIVER_ETHER_LEN					14
#define TCPHDR_DEFAULT_LEN					20

//fs2 info
#define FS2_COLUMN_NUM						5
#define FS2_APPNAME							"DELIVER"


enum deliver_fs_colume
{
	FS2_COLUME_RECVPKT=0,
	FS2_COLUME_RECVBYTE,
	FS2_COLUME_SENDPKT,	
	FS2_COLUME_SENDBYTE,
	FS2_COLUME_ERROR,
};


struct deliver_fs2_info
{
	screen_stat_handle_t handler;
	int column_id[FS2_COLUMN_NUM];
	unsigned long long column_value[MAX_THREAD_NUM][FS2_COLUMN_NUM];
};

struct deliver_comm_info
{
	int threadnum;
	void* logger;
};


struct deliver_pkt_info
{
	int dir;
	unsigned int seq;				//host order
	unsigned int ack;				//host order
	unsigned int len;				//host order,tcp payload len
	unsigned short ipid;			//host order
	unsigned short win;				//host order
	unsigned char flag;				
	unsigned char ttl;

};

struct deliver_session_info
{
	int recv_pkt;
	int send_pkt;
	long long recv_byte;
	long long send_byte;
};


struct deliver_pme_info
{
	unsigned char dst_macaddr[DELIVER_MACADDR_LEN];
	const struct tfe_stream_addr* addr_info;
	struct deliver_pkt_info pkt_info;
	struct deliver_session_info session_info;
};

struct deliver_recver_info
{
	unsigned char dst_macaddr[DELIVER_MACADDR_LEN];
};

struct deliver_sendpkt_info
{
	int mtu;
	int thread_num;
	int receiver_num;
	struct ifreq ifr;
	int* send_socket;
	char senddevice[DELIVER_CARDNAME_LEN];
	unsigned char src_macaddr[DELIVER_MACADDR_LEN];
	struct deliver_recver_info* receiver_info;
};

struct deliver_globle_info
{
	char *fs2_name[FS2_COLUMN_NUM];
	unsigned char* sendbuf[MAX_THREAD_NUM];
	struct deliver_comm_info comminfo;
	struct deliver_sendpkt_info sendinfo;
	struct deliver_fs2_info fs2info;
	

};
#endif

