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

📄 icmpprotocoldlg.h

📁 实现发送ICMP封包
💻 H
字号:
// ICMPProtocolDlg.h : 头文件
//

#pragma once
#include "afxcmn.h"
#include "Icmp.h"

/////////////////////////////////////////////////////////////////////////////

#define	MAXHOSTNAME			128	  // maximum size of a host name buffer

/////////////////////////////////////////////////////////////////////////////
//
//					Local Message Interrupts to Process
//
/////////////////////////////////////////////////////////////////////////////

#define WSA_PING_ASYNC		WM_USER + 200

#define IDT_TIMER1			WSA_PING_ASYNC + 1

#define MAX_MESSAGE			IDT_TIMER1 + 1

/////////////////////////////////////////////////////////////////////////////

#define MAX_INTERVAL_TIME	500

// CICMPProtocolDlg 对话框
class CICMPProtocolDlg : public CDialog
{

enum ImageType
	{
		Icon_Blank,
		Icon_BlueArrow
	};

private:
	//////////////////////////////////////////////////
	//												//
	//			Timer support routines				//
	//												//
	//////////////////////////////////////////////////

	void StopTimer();
	void StartTimer();
	void ChangeIconState(void);

	//////////////////////////////////////////////////
	//												//
	//			Icmp Socket Initialization			//
	//												//
	//////////////////////////////////////////////////

	BOOL InitSockets();

	//////////////////////////////////////////////////
	//												//
	//			Registry Support Routines			//
	//												//
	//////////////////////////////////////////////////

	BOOL FetchWinsockSettings();
	BOOL LoadRegValues(void);
	void SaveRegValues();

	//////////////////////////////////////////////////
	//												//
	//		ICMP Ping and IP Address Routines		//
	//												//
	//////////////////////////////////////////////////

	void SendPing(void);
	unsigned long HostIPAddress();

	//////////////////////////////////////////////////
	//												//
	//		ListCtrl ICMP Trace Routines			//
	//												//
	//////////////////////////////////////////////////

	void UpdateTrace ();
	void DisplayTrace(LPCSTR TripTimeMessage, LPCSTR IPAddressMessage, LPCSTR HostMessage);
	void EndTrace(void);
	
	//////////////////////////////////////////////////
	//												//
	//		ListCtrl Image/Display Routines			//
	//												//
	//////////////////////////////////////////////////

	void InitImageList();
	int AddListColumn(int column, int lfmt, int lmaxwidth, LPSTR ltext, int lsubitem);
	void DisplayBlankLine(void);
	void SetTraceSequence(int Seq, int FocusItem, ImageType FocusImage);
	void SetTraceFocus(int FocusItem, int FocusSubItem);
	void SetDisplayImage(int FocusItem, enum ImageType FocusImage);
	void TraceComment(CString Comment);
// 构造
public:
	CICMPProtocolDlg(CWnd* pParent = NULL);	// 标准构造函数

// 对话框数据
	enum { IDD = IDD_ICMPPROTOCOL_DLG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV 支持


// 实现
protected:
	HICON m_hIcon;
	afx_msg LRESULT OnPINGAsynch(WPARAM wParam, LPARAM lParam);  // PING Asynchronous Message Processor

	// 生成的消息映射函数
//	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnTimer(UINT);
	afx_msg void OnBnClickedPingbutton();
	afx_msg void OnBnClickedTracebutton();
	afx_msg void OnBnClickedOptionsbutton();
	afx_msg void OnBnClickedClearbutton();
	afx_msg void OnBnClickedStop();
	DECLARE_MESSAGE_MAP()
public://控件关联变量
	CString m_strHost;
	CListCtrl m_ctlTraceList;
	CString m_strLocalHost;
	CString m_strNameServer;
public:
	CIcmp				PingSocket;						// Icmp Object
	WSADATA				wsaData;						// Windows Socket Information structure

	CString				LocalNameServer;				// Default name server (from Registry)
	CString				LocalDomainName;				// Domain name (from Registry)
	CString				DefHost;						// Default Host Name (from Registry)

	char				HostName[MAXHOSTNAME];			// Host name entered in dialog
	char				CurrentHostName[MAXHOSTNAME];	// Current host being Ping-ed

	struct in_addr		TraceTarget;					// Endpoint for trace operation

	BOOL				TimerActive;					// TRUE = timer is running
	int					TimerNumber;					// Assigned by system, used to access the timer
	int					TimerInterval;					// How long to set the timer for (from Registry)
	unsigned long		icmpIntervalCount;				// Current interval being counted
	unsigned long		icmpMaxIntervals;				// Maximum intervals (icmpMaxIntervals * icmpIntervalCount = TimerInterval)

	int					IconState;						// Next icon to display in icon animation sequence

	CImageList			smallImageList;					// List of small images for ListCtrl
	CImageList			largeImageList;					// List of large images for ListCtrl

	char				icmpBuffer[MAX_PACKET];			// General purpose buffer for Icmp operations
	LPSTR				pIcmpBuffer;					// FAR pointer to icmpBuffer
	int					icmpDataLen;					// Number of bytes in ICMP outgoing message (not counting header)
	int					icmpPingTTL;					// TTL value - used for TRACE operation
	BOOL				icmpTracing;					// TRUE = TRACE operation, FALSE = PING operation
	BOOL				PingSent;						// TRUE = Waiting for ECHO REPLY, FALSE = ignore input
	virtual BOOL OnInitDialog();
	afx_msg void OnBnClickedQuit();
};

⌨️ 快捷键说明

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