www.pudn.com > ipman.zip > IP.H, change:1998-04-08,size:2948b


/*  IP structure defination  
        Written by HiHint */ 
 
#define BUFFER_SIZE 16384 
#define READ 1 
#define WRITE 2 
 
#define ETHER_PROTO_IP 0x0800	/* Ethernet protocol IP */ 
#define ETHER_PROTO_ARP 0x0806	/* Ethernet protocol ARP */ 
#define ETHER_HEAD_LEN	14/* Ethernet head length */ 
 
#define ARP_HARD_TYPE 1	/* Ethernet card*/ 
#define ARP_PROTO_TYPE 0x0800	/* IP protocol */ 
#define ARP_HARD_ADDR_LEN 6	/* Ethernet card address length */ 
#define ARP_ADDR_LEN 4	/* IP protocol address length */ 
#define ARP_OPER_ARP_REQ 1	/* Arp request */ 
#define ARP_OPER_ARP_ANS 2	/* Arp answer */ 
#define ARP_OPER_RARP_REQ 3	/* Rarp request */ 
#define ARP_OPER_RARP_ANS 4	/* Rarp answer */ 
#define ARP_PACKET_LEN 28	/* Arp packet length */ 
 
#define IP_VER 4	/* IP version */ 
#define IP_HEAD_LEN 5	/* IP head length */ 
#define IP_SERV_TYPE 0	/* IP service type */ 
#define IP_PROTO_TCP 6	/* TCP protocol */ 
#define IP_PROTO_UDP 17	/* UDP protocol */ 
#define IP_PROTO_ICMP 1	/* ICMP protocol */ 
#define IP_PAD 0	/* IP pseudohead padding */ 
#define IP_MF 0x4000	/* IP MF */ 
#define IP_DF 0x2000	/* IP DF */ 
#define IP_FLAG_MASK 0x1fff	/* IP flagoffset mask */ 
#define IP_HEAD_BYTE_LEN 20	/* IP head length in byte */ 
 
#define TCP_HEAD_LEN 5	/* TCP head length */ 
#define TCP_URG 0x20	/* TCP URG */ 
#define TCP_ACK 0x10	/* TCP ACK */ 
#define TCP_PSH 0x08	/* TCP PSH */ 
#define TCP_RST 0x04	/* TCP RST */ 
#define TCP_SYN 0x02	/* TCP SYN */ 
#define TCP_FIN	0x01	/* TCP FIN */ 
#define TCP_HEAD_BYTE_LEN 20	/* TCP head length in byte */ 
 
#define UDP_HEAD_LEN 8	/* UDP head length */ 
 
#define PSEUDO_HEAD_LEN 12	/* Pseudo head length */ 
 
#define ICMP_HEAD_LEN 4	/* ICMP head length */ 
 
struct EtherAddr { 
	unsigned char AddrByte[6]; 
}; 
 
struct EtherPacketHead { 
	struct EtherAddr DestEther; 
	struct EtherAddr SourEther; 
	unsigned short ServType; 
}; 
 
struct IPAddr { 
		unsigned char AddrByte[4]; 
}; 
 
struct IPPacketHead { 
	BYTE VerHLen; 
	BYTE Type; 
	WORD TtlLen; 
	WORD Id; 
	WORD FlgOff; 
	BYTE TTL; 
	BYTE Proto; 
	WORD ChkSum; 
	struct IPAddr SourIP; 
	struct IPAddr DestIP; 
}; 
 
struct TCPPacketHead { 
	WORD SourPort; 
	WORD DestPort; 
	DWORD SeqNo; 
	DWORD AckNo; 
	BYTE HLen; 
	BYTE Flag; 
	WORD WndSize; 
	WORD ChkSum; 
	WORD UrgPtr; 
}; 
 
struct ICMPPacketHead { 
	BYTE Type; 
	BYTE Code; 
	WORD ChkSum; 
}; 
 
struct UDPPacketHead { 
	WORD SourPort; 
	WORD DestPort; 
	WORD Len; 
	WORD ChkSum; 
}; 
 
struct PseudoHead { 
	struct IPAddr SourIP; 
	struct IPAddr DestIP; 
	BYTE Pad; 
	BYTE Proto; 
	WORD Len; 
}; 
 
struct ARPPacket { 
	 WORD Type; 
	 WORD Proto; 
	 BYTE HardAddrLen; 
	 BYTE AddrLen; 
	 WORD Oper; 
	 struct EtherAddr SourEther; 
	 struct IPAddr SourIP; 
	 struct EtherAddr DestEther; 
	 struct IPAddr DestIP; 
}; 
 
struct PacketTable { 
	HANDLE hEvent; 
	BOOL Active; 
	OVERLAPPED Overlap; 
	DWORD Size; 
	BYTE Buffer[BUFFER_SIZE]; 
	DWORD Length; 
	WORD Type; 
};