www.pudn.com > listen.zip > listenDlg.h, change:2005-03-16,size:4998b


// listenDlg.h : header file 
// 
 
#if !defined(AFX_LISTENDLG_H__02B25220_7DB0_45A8_91FB_650EE99648D1__INCLUDED_) 
#define AFX_LISTENDLG_H__02B25220_7DB0_45A8_91FB_650EE99648D1__INCLUDED_ 
 
#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 
 
///////////////////////////////////////////////////////////////////////////// 
// CListenDlg dialog 
#include "NewList.h" 
#include "IpDataShow.h" 
#define STATUS_FAILED 0xFFFF		//定义异常出错代码 
#define MAX_PACK_LEN  65535			//接收的最大IP报文	 
#define MAX_ADDR_LEN  16			//点分十进制地址的最大长度 
#define MAX_PROTO_TEXT_LEN	16		//子协议名称(如"TCP")最大长度 
#define MAX_PROTO_NUM 12			//子协议数量 
#define MAX_HOSTNAME_LAN 255		//最大主机名长度 
#define CMD_PARAM_HELP true 
 
typedef struct _tagPROTOMAP 
{ 
	int  ProtoNum; 
	char ProtoText[MAX_PROTO_TEXT_LEN]; 
}PROTOMAP; 
 
static PROTOMAP ProtoMap[MAX_PROTO_NUM]= 
{ 
	{ IPPROTO_IP   , "IP "  }, 
	{ IPPROTO_ICMP , "ICMP" },  
	{ IPPROTO_IGMP , "IGMP" }, 
	{ IPPROTO_GGP  , "GGP " },  
	{ IPPROTO_TCP  , "TCP " },  
	{ IPPROTO_PUP  , "PUP " },  
	{ IPPROTO_UDP  , "UDP " },  
	{ IPPROTO_IDP  , "IDP " },  
	{ IPPROTO_ND   , "NP "  },  
	{ IPPROTO_RAW  , "RAW " },  
	{ IPPROTO_MAX  , "MAX " }, 
	{ NULL         , ""     } 
}; 
	 
 
typedef struct _iphdr  
{ 
	unsigned char	h_lenver;		//4位首部长度+4位IP版本号 
	unsigned char	tos;			//8位服务类型TOS 
	unsigned short	total_len;		//16位总长度(字节) 
	unsigned short	ident;			//16位标识 
	unsigned short	frag_and_flags;	//3位标志位 
	unsigned char	ttl;			//8位生存时间 TTL 
	unsigned char	proto;			//8位协议 (TCP, UDP 或其他) 
	unsigned short	checksum;		//16位IP首部校验和 
	unsigned int	sourceIP;		//32位源IP地址 
	unsigned int	destIP;			//32位目的IP地址 
}IP_HEADER; 
 
typedef struct _tcphdr				//定义TCP首部 
{ 
	USHORT th_sport;				//16位源端口 
	USHORT th_dport;				//16位目的端口 
	unsigned int  th_seq;			//32位序列号 
	unsigned int  th_ack;			//32位确认号 
	unsigned char th_lenres;		//4位首部长度/6位保留字 
	unsigned char th_flag;			//6位标志位 
	USHORT th_win;					//16位窗口大小 
	USHORT th_sum;					//16位校验和 
	USHORT th_urp;					//16位紧急数据偏移量 
}TCP_HEADER; 
 
typedef struct _icmphdr				//定义ICMP首部 
{ 
	BYTE   i_type;					//8位类型 
	BYTE   i_code;					//8位代码 
	USHORT i_cksum;					//16位校验和  
	USHORT i_id;					//识别号(一般用进程号作为识别号) 
	USHORT i_seq;					//报文序列号	 
	ULONG  timestamp;				//时间戳 
}ICMP_HEADER; 
 
typedef struct _udphdr				//定义UDP首部 
{ 
    unsigned short uh_sport;		//16位源端口 
    unsigned short uh_dport;		//16位目的端口 
    unsigned short uh_len;			//16位长度 
    unsigned short uh_sum;			//16位校验和 
} UDP_HEADER; 
 
typedef struct _ipdata 
{ 
	int len; 
	char *buf; 
}IPDATA; 
 
class CListenDlg : public CDialog 
{ 
// Construction 
public: 
	void DelListBuf(); 
	BOOL m_IsAllProto; //选中全部协议 
	BOOL m_IsAllIp; //选中全部IP 
	BOOL m_IsAllPort; //选中全部端口 
	char m_szProto[16]; //得到用户选择的协议 
	char* m_HostIp; //本机IP 
	void ShowIpInfo(char *pData,int len); //将IP包拆分后进行显示 
	int m_ihLen; //IP包头长度 
	CRITICAL_SECTION m_ls; //临界区结构 
	char m_szDestPort[16]; //得到IP包中目标协议 
	char m_szSourcePort[16]; //得到IP包中源协议 
	char m_szTTL[16]; //得到IP包中TTL 
	char m_szDestIP[16]; //得到IP包中目标IP 
	char m_szSourceIP[16]; //得到IP包中源IP 
	char m_szProtocol[16]; //得到IP包中协议 
	char * CheckProtocol(int iProtocol); //得到协议名 
	void SplitIpPack(char* pData,int len); //拆分IP包 
	SOCKET m_RawSock; //SOCK 
	int CreateSock(); //设置SOCK 
	BOOL InitSock(); //加载SOCK.DLL 
	BOOL SetClipboard(char* pData); //写入剪贴板 
	CListenDlg(CWnd* pParent = NULL);	// standard constructor 
	CIpDataShow m_IpShowDlg; 
 
// Dialog Data 
	//{{AFX_DATA(CListenDlg) 
	enum { IDD = IDD_LISTEN_DIALOG }; 
	CNewList	m_NewList; 
	int		m_iWprot; 
	//}}AFX_DATA 
 
	// ClassWizard generated virtual function overrides 
	//{{AFX_VIRTUAL(CListenDlg) 
	public: 
	virtual BOOL PreTranslateMessage(MSG* pMsg); 
	protected: 
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support 
	//}}AFX_VIRTUAL 
 
// Implementation 
protected: 
	HICON m_hIcon; 
 
	// Generated message map functions 
	//{{AFX_MSG(CListenDlg) 
	virtual BOOL OnInitDialog(); 
	afx_msg void OnPaint(); 
	afx_msg HCURSOR OnQueryDragIcon(); 
	afx_msg void OnButton1(); 
	afx_msg void OnButton3(); 
	afx_msg void OnRadio2(); 
	afx_msg void OnRadio3(); 
	afx_msg void OnRadio1(); 
	afx_msg void OnRadio4(); 
	afx_msg void OnRadio5(); 
	afx_msg void OnRadio6(); 
	afx_msg void OnRadio7(); 
	afx_msg void OnRadio8(); 
	afx_msg void OnCopySip(); 
	afx_msg void OnCopyDip(); 
	afx_msg void OnSysCommand( UINT nID, LPARAM lParam ); 
	afx_msg void OnSelchangeList1(); 
	afx_msg void OnDestroy(); 
	//}}AFX_MSG 
	DECLARE_MESSAGE_MAP() 
}; 
 
//{{AFX_INSERT_LOCATION}} 
// Microsoft Visual C++ will insert additional declarations immediately before the previous line. 
 
#endif // !defined(AFX_LISTENDLG_H__02B25220_7DB0_45A8_91FB_650EE99648D1__INCLUDED_)