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

📄 header.h

📁 实现简单的ping程序功能
💻 H
字号:
// Header.h

#ifndef _HEADER_H_
#define _HEADER_H_

/* The IP header */ 
typedef struct iphdr 
{ 
	unsigned int h_len:4; // length of the header 
	unsigned int version:4; // Version of IP 
	unsigned char tos; // Type of service 
	unsigned short total_len; // total length of the packet 
	unsigned short ident; // unique identifier 
	unsigned short frag_and_flags; // flags 
	unsigned char ttl;	// time to live
	unsigned char proto; // protocol (TCP, UDP etc) 
	unsigned short checksum; // IP checksum 
	unsigned int sourceIP; 
	unsigned int destIP; 
}IpHeader; 


//
// ICMP header structure
//
typedef struct _icmphdr 
{
	BYTE i_type;		// 8 bits type 
	BYTE i_code;		// Type sub code
	USHORT i_cksum;		// 16 bits checksum
	USHORT i_id;
	USHORT i_seq;
	// This is not the standard header, but we reserve space for time
	ULONG timestamp;
} IcmpHeader;

#define ICMP_ECHO		8			// ping 回显
#define ICMP_ECHOREPLY	0			// 回显应答 ping
#define ICMP_MIN		8			// minimum 8 byte icmp packet (just header)

#define STATUS_FAILED		0xFFFF 
#define DEF_PACKET_SIZE		32
#define DEF_PACKET_NUMBER	4		// 发送数据报的个数 
#define MAX_PACKET			1024 

#define xmalloc(s) HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(s)) 
#define xfree(p) HeapFree (GetProcessHeap(),0,(p)) 




#endif // _HEADER_H_

⌨️ 快捷键说明

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