⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcpstream.h

📁 linux 上http email 协议分析程序 主要能够处理大数据量的主干网的应用
💻 H
字号:
/************************************************************ * Copyright(C)  1998-2001,CongXing Tech. Co. Ltd. * FileName:			TCPStream.h * Author:				Jay * Version:				V01.00.000  * Date:                2004.01.13 * Description:			定义TCP流类 ************************************************************/#ifndef __TCPSTREAM__H__ #define __TCPSTREAM__H__#include <TCPPacket.h>#include <time.h>#include <Mem.h>#include "BaseConst.h"/** * 定义TCP流类 **/class CTCPStream {	public:		//##Documentation		//## 构造函数		CTCPStream();		//##Documentation		//析构函数		~CTCPStream();		//##Documentation		//## copy构造函数		CTCPStream(const CTCPStream &_s);		//##Documentation		//## clear		//##@return :0 ok 	-1:fail		int clear();		//##Documentation		//## 初始化		//## @param		//## _baseSize:流的基础大小,不够则扩充		//## _ip:首个ip包		//## @return		//## 0:成功		//## -1:失败		int init(unsigned int _baseSize,IP_PACKET *_ip,CMem *_pmemAdm);		//##Documentation		//## 初始化		//## @param		//## _ip:首个ip包		//## @return		//## 0:成功		//## -1:失败		int  reinit( IP_PACKET *_ip);		//##Documentation		//## 提取流的内容		//## @param		//## *_pbuff:缓冲区指针		//## _bufsize:	缓冲区大小		//## @return		//## -1:失败		//## >=0:流长度		int getStream(unsigned char *_pbuff,unsigned int _bufsize);		//##Documentation		//## 收到一个包,加入流 		//## @param		//## *_p:指向IP包的指针			//## @return		//## 0:成功		//## -1:失败		int addPacket(IP_PACKET *_p);		//##Documentation		//## 判断流是否已经完成		//## @return 		//## true: 完成		//## false:	未完成		bool isStreamFinish() {return m_bFinish;};		//##Documentation		//## 判断流是否被中断		//## @return 		//## true: 完成		//## false:	未完成		bool isStreamAbort() {return m_bAbort;};		//##Documentation		//## 获取流的包到达率		//## @return		//## 到达率=包到达个数/流实际长度*100		unsigned short int getReceivedRate(){			if (m_len ==1)				return 100;			return (m_count *100 / (m_len-1));		};		//##Documentation		//## 判断流是否超时		//## 算法		//## 流最近到达的包的时刻是否超过一个值(7分钟左右)		//## @return		bool isStreamTimeOut();		//## Documentation		//## 判断是否HTTP协议的流		//## @return		bool isHTTPStream();		//## Documentation		//## 判断是否HTTP协议的文本内容		//## @return		bool isTextHTTPStream();		int length(){return m_len;}		ulong get_src_ip(){return m_src_ip;}		ulong get_dst_ip(){return m_dst_ip;}		unsigned short get_src_port(){return m_src_port;}		unsigned short get_dst_port(){return m_dst_port;}	//	unsigned char get_protocol(){return m_protocol;}	private:		//##Documentation		//## 扩充流大小		//## @return 		//## 0:成功		//## -1:失败		int resize();	private:		CMem *m_memAdm;		//##Documentation		//## 流基础大小,m_size是这个大小的整数倍		unsigned int m_baseSize;		//##Documentation		//## 流实际长度,即当前流最后一个包位置		unsigned int m_len;		//##Documentation		//## 流大小		unsigned int m_size;		//##Documentation		//## 流头指针		unsigned char *m_head;		//##Documentation		//## 流尾指针		//TCP_PACKET *m_tail;		//##Documentation		//## TCP包到达表		//bool *m_brReceiveTable;		//##Documentation		//## TCP包到达字节数		ulong m_count;		//##Documentation		//## 流第一个包的序列号		unsigned int m_firstSeqNum;		//##Documentation		//## 流最近一个包的序列号		unsigned int m_latestSeqNum;		//##Documentation		//## 扩充因子,2的倍数,最大8倍		unsigned short int m_iMultiGene;		//##Documentation		//## TCP流最后一个包到达时间		unsigned long m_lLastPacketTime;		//##Documentation		//## 流完成标志		bool m_bFinish;		//##Documentation		//## 流中断标志		bool m_bAbort;		//##Documentation		//## 源IP		ulong m_src_ip;		//##Documentation		//## 目标IP		ulong m_dst_ip;		//##Documentation		//## 源端口		unsigned short m_src_port;		//##Documentation		//## 目的端口		unsigned short m_dst_port;		//##Documentation		//## 协议//		unsigned char m_protocol;};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -