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

📄 biyeshejiview.h

📁 电子邮件系统数据包获取与还原技术的研究原码
💻 H
字号:
// biyeshejiView.h : interface of the CBiyeshejiView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_BIYESHEJIVIEW_H__62169D0B_B1C9_4585_91FE_3907E6FA8A27__INCLUDED_)
#define AFX_BIYESHEJIVIEW_H__62169D0B_B1C9_4585_91FE_3907E6FA8A27__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "biyeshejiDoc.h"
#include "pcap.h"

class CBiyeshejiView : public CEditView
{
protected: // create from serialization only
	CBiyeshejiView();
	DECLARE_DYNCREATE(CBiyeshejiView)

// Attributes
public:
	CBiyeshejiDoc* GetDocument();

// Operations
public:
void addstr(LPCTSTR str);
CWinThread *m_pCaptthread;
// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CBiyeshejiView)
	public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	protected:
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CBiyeshejiView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//{{AFX_MSG(CBiyeshejiView)
		// NOTE - the ClassWizard will add and remove member functions here.
		//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnStart();
	afx_msg void OnStop();
	afx_msg void OnMailview();
};

#ifndef _DEBUG  // debug version in biyeshejiView.cpp
inline CBiyeshejiDoc* CBiyeshejiView::GetDocument()
   { return (CBiyeshejiDoc*)m_pDocument; }
#endif

   UINT capture_packet(LPVOID lpParam);//thread founction
/////////////////////////////////////////////////////////////////////////////

   typedef struct ip_address{
	   u_char byte1;
	   u_char byte2;
	   u_char byte3;
	   u_char byte4;
   }ip_address;

   /* IPv4 header */
   typedef struct ip_header{
	   u_char ver_ihl; // version << 4 | header length >> 2
	   u_char tos; // type of service 
	   u_short len; // total length
	   u_short identification; // Identification
	   u_short flg_off;         // fragment offset field 
#define IP_RF 0x8000            // reserved fragment flag 
#define IP_DF 0x4000            // dont fragment flag 
#define IP_MF 0x2000            // more fragments flag 
#define IP_OFFMASK 0x1fff       // mask for fragmenting bits 
	   u_char ttl; // time to live
	   u_char proto; // protocol
	   u_short checksum; // checksum
	   ip_address saddr; // source address
	   ip_address daddr; // destination address
   }ip_header;
#define IP_HL(ip)               (((ip)->ver_ihl) & 0x0f)
#define IP_V(ip)                (((ip)->ver_ihl) >> 4)

   /* TCP header*/
   typedef struct tcp_header {
	   u_short sport;               /* source port */
	   u_short dport;               /* destination port */
	   u_int seq;                 /* sequence number */
	   u_int ack;                 /* acknowledgement number */
	   u_char  offset;               /* data offset, rsvd */
	   u_char  flags;
	   u_short window;                 /* window */
	   u_short checksum;                 /* checksum */
	   u_short urgentP;                 /* urgent pointer */
   }tcp_header;
#define TH_FIN  0x01
#define TH_SYN  0x02
#define TH_RST  0x04
#define TH_PUSH 0x08
#define TH_ACK  0x10
#define TH_URG  0x20
#define TH_ECE  0x40
#define TH_CWR  0x80
#define TH_FLAGS        (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG|TH_ECE|TH_CWR)
#define TCP_OFF(tcp)      (((tcp)->offset & 0xf0) >> 4)

   /* describe the ip fragment */
   typedef struct ip_frag{
	   u_char    *data;                  /* data */
	   u_short offset;                 /* fragment offset */
	   u_short length;                 /* data length */
	   u_short  mf;                     /* flag */
	   struct  ip_frag *next;          /* a pointer to next struct */
   }ip_frag;

   /* identify datagram fragments */
   typedef struct ip_datagram{
	   ip_address ip_src,ip_dst;  /* Source Address,Destination Address */
	   u_char  ip_pro;                 /* Protocol */
	   u_short ip_id;                  /* Identification */
	   ip_frag *frag;
	   struct ip_datagram *next;
   }ip_datagram;

   /* tcp fragment */
   typedef struct tcp_frag{
	   u_int seq;
	   u_int len;
	   u_char  *data;
	   struct tcp_frag *next;
   }tcp_frag;

   /* identify tcp datagram */
   typedef struct tcp_datagram{
	   u_short sport;               /* source port */
	   u_short dport;               /* destination port */
	   u_int begin_seq,final_seq;     
	   ip_address ip_src,ip_dst;    /*  source sddress,destination address */
	   u_int  ocet_num;                /* ocet number */
	   tcp_frag *frag;
	   struct tcp_datagram *next;
   }tcp_datagram;

   /*packet handler*/
   void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data);
   /*copy data*/
   void copy_data(const u_char *data,int len,u_char *dst_data);
   /*compare address*/
   bool compare_address(const ip_address *address1,const ip_address *address2);
   /*check ip list*/
   u_char* check_ip(ip_address *src,ip_address *dst,u_short*off);
   /*tcp packet*/
   void tcp(const ip_address src,const ip_address dst,int tcp_lenth,u_char* head);
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_BIYESHEJIVIEW_H__62169D0B_B1C9_4585_91FE_3907E6FA8A27__INCLUDED_)

⌨️ 快捷键说明

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