?? icmp.h
字號:
// ICMP.h: interface for the CICMP class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_ICMP_H_INCLUDED_)
#define AFX_ICMP_H_INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define DEF_PACKET 32
#define MAX_PACKET 1024
#define MIN_PACKET 8
//----------ICMP消息定義-------------
#define ICMP_ECHO 8 //回應(yīng)請求
#define ICMP_ECHOREPLY 0 //回應(yīng)應(yīng)答
#define ICMP_DESUNREACH 3 //目的不可達
#define ICMP_TTLOUT 11 //TTL超時
//IP及ICMP包頭部結(jié)構(gòu)
typedef struct ip_head{
unsigned int HeadLen:4; //用32位字表示的報頭長度
unsigned int version:4; //協(xié)議版本
unsigned char level; //優(yōu)先級
unsigned short len; //包長度
unsigned short ID; //標(biāo)識
unsigned short mflag; //其它標(biāo)記
unsigned char ttl; //生命期
unsigned char prot; //協(xié)議
unsigned short cksum; //檢查和
unsigned int sourIP; //源IP地址
unsigned int destIP; //目的IP地址
}IP_HEAD;
typedef struct icmp_head{
unsigned char type; //類型
unsigned char code; //編碼
unsigned short cksum; //檢查和
unsigned short ID; //標(biāo)識
unsigned short number; //計數(shù)值
unsigned int time; //時間
}ICMP_HEAD;
class CICMP
{
public:
IP_HEAD * m_pIp;
ICMP_HEAD * m_pIcmp;
SOCKET winsock;
CString m_strInfo;
CString RouteState;
sockaddr_in m_sockAddr;
int routestate;
char * routeaddr;
public:
BOOL Initialize(void); //初始化
void Uninitialize(void); //反初始化
USHORT CheckSum(USHORT *buffer, int size); //檢查和
BOOL SendICMPPack(char * pAddr); //發(fā)送報文
BOOL SendICMPPack(sockaddr_in * pAddr); //發(fā)送報文
BOOL RecvICMPPack(void); //接收報文
int SetTTL(int TTL); //設(shè)置TTL
CICMP();
virtual ~CICMP();
};
#endif // !defined(AFX_ICMP_H_INCLUDED_)
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -