100 lines
2.5 KiB
C
100 lines
2.5 KiB
C
|
#ifndef _PACKETSTRUCT_H
|
|||
|
#define _PACKETSTRUCT_H
|
|||
|
|
|||
|
|
|||
|
#pragma pack(1)
|
|||
|
|
|||
|
|
|||
|
/*<2A><>̫<EFBFBD><CCAB>֡ͷ<D6A1><CDB7>ʽ<EFBFBD>ṹ<EFBFBD><E1B9B9> 14<31><34><EFBFBD>ֽ<EFBFBD>*/
|
|||
|
typedef struct ether_header
|
|||
|
{
|
|||
|
unsigned char ether_dhost[6];// Ŀ<><C4BF>MAC<41><43>ַ
|
|||
|
unsigned char ether_shost[6];// ԴMAC<41><43>ַ
|
|||
|
unsigned short ether_type;// eh_type<70><65>ֵ<EFBFBD><D6B5>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Э<EFBFBD>飬<EFBFBD><E9A3AC><EFBFBD><EFBFBD>Ϊip<69><70>Ϊ0<CEAA><30>0800
|
|||
|
}ETHERHEADER, *PETHERHEADER;
|
|||
|
|
|||
|
/*<2A><>ARP<52>ֶνṹ<CEBD><E1B9B9> 28<32><38><EFBFBD>ֽ<EFBFBD>*/
|
|||
|
typedef struct arp_header
|
|||
|
{
|
|||
|
unsigned short arp_hrd;
|
|||
|
unsigned short arp_pro;
|
|||
|
unsigned char arp_hln;
|
|||
|
unsigned char arp_pln;
|
|||
|
unsigned short arp_op;
|
|||
|
unsigned char arp_sourha[6];
|
|||
|
unsigned long arp_sourpa;
|
|||
|
unsigned char arp_destha[6];
|
|||
|
unsigned long arp_destpa;
|
|||
|
}ARPHEADER, *PARPHEADER;
|
|||
|
|
|||
|
/*ARP<52><50><EFBFBD>Ľṹ<C4BD><E1B9B9> 42<34><32><EFBFBD>ֽ<EFBFBD>*/
|
|||
|
typedef struct arp_packet
|
|||
|
{
|
|||
|
ETHERHEADER etherHeader;
|
|||
|
ARPHEADER arpHeader;
|
|||
|
}ARPPACKET, *PARPPACKET;
|
|||
|
|
|||
|
|
|||
|
// ipv4_pro<72>ֶΣ<D6B6>
|
|||
|
#define PROTOCOL_ICMP 0x01
|
|||
|
#define PROTOCOL_IGMP 0x02
|
|||
|
#define PROTOCOL_TCP 0x06
|
|||
|
#define PROTOCOL_UDP 0x11
|
|||
|
|
|||
|
/*IPv4<76><34>ͷ<EFBFBD>ṹ<EFBFBD><E1B9B9> 20<32><30><EFBFBD>ֽ<EFBFBD>*/
|
|||
|
typedef struct ipv4_header
|
|||
|
{
|
|||
|
unsigned char ipv4_ver_hl;// Version(4 bits) + Internet Header Length(4 bits)<29><><EFBFBD>Ȱ<EFBFBD>4<EFBFBD>ֽڶ<D6BD><DAB6><EFBFBD>
|
|||
|
unsigned char ipv4_stype; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
unsigned short ipv4_plen;// <20>ܳ<EFBFBD><DCB3>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD><EFBFBD>IP<49><50><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>TCP<43><50><EFBFBD><EFBFBD>ͷ<EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>ݣ<EFBFBD>
|
|||
|
unsigned short ipv4_pidentify;// ID<49><44><EFBFBD>嵥<EFBFBD><E5B5A5>IP
|
|||
|
unsigned short ipv4_flag_offset;// <20><>־λƫ<CEBB><C6AB><EFBFBD><EFBFBD>
|
|||
|
unsigned char ipv4_ttl; // <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
unsigned char ipv4_pro;// Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
unsigned short ipv4_crc;// У<><D0A3><EFBFBD><EFBFBD>
|
|||
|
unsigned long ipv4_sourpa;// ԴIP<49><50>ַ
|
|||
|
unsigned long ipv4_destpa;// Ŀ<><C4BF>IP<49><50>ַ
|
|||
|
}IPV4HEADER, *PIPV4HEADER;
|
|||
|
|
|||
|
|
|||
|
/*IPv6<76><36>ͷ<EFBFBD>ṹ<EFBFBD><E1B9B9> 40<34><30><EFBFBD>ֽ<EFBFBD>*/
|
|||
|
typedef struct ipv6_header
|
|||
|
{
|
|||
|
unsigned char ipv6_ver_hl;
|
|||
|
unsigned char ipv6_priority;
|
|||
|
unsigned short ipv6_lable;
|
|||
|
unsigned short ipv6_plen;
|
|||
|
unsigned char ipv6_nextheader;
|
|||
|
unsigned char ipv6_limits;
|
|||
|
unsigned char ipv6_sourpa[16];
|
|||
|
unsigned char ipv6_destpa[16];
|
|||
|
}IPV6HEADER, *PIPV6HEADER;
|
|||
|
|
|||
|
/*TCP<43><50>ͷ<EFBFBD>ṹ<EFBFBD><E1B9B9> 20<32><30><EFBFBD>ֽ<EFBFBD>*/
|
|||
|
typedef struct tcp_header
|
|||
|
{
|
|||
|
unsigned short tcp_sourport;//Դ<>˿<EFBFBD>
|
|||
|
unsigned short tcp_destport;//Ŀ<>Ķ˿<C4B6>
|
|||
|
unsigned long tcp_seqnu;//<2F><><EFBFBD>к<EFBFBD>
|
|||
|
unsigned long tcp_acknu;//ȷ<>Ϻ<EFBFBD>
|
|||
|
unsigned char tcp_hlen; //4λ<34>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
unsigned char tcp_reserved;//<2F><>־λ
|
|||
|
unsigned short tcp_window;//<2F><><EFBFBD>ڴ<EFBFBD>С
|
|||
|
unsigned short tcp_chksum;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
unsigned short tcp_urgpoint;//<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
|||
|
}TCPHEADER, *PTCPHEADER;
|
|||
|
|
|||
|
/*UDP<44><50>ͷ<EFBFBD>ṹ<EFBFBD><E1B9B9> 8<><38><EFBFBD>ֽ<EFBFBD>*/
|
|||
|
typedef struct udp_header
|
|||
|
{
|
|||
|
unsigned short udp_sourport;// Դ<>˿<EFBFBD>
|
|||
|
unsigned short udp_destport;// Ŀ<>Ķ˿<C4B6>
|
|||
|
unsigned short udp_hlen;// <20><><EFBFBD><EFBFBD>
|
|||
|
unsigned short udp_crc;// У<><D0A3><EFBFBD><EFBFBD>
|
|||
|
}UDPHEADER, *PUDPHEADER;
|
|||
|
|
|||
|
|
|||
|
#pragma pack()
|
|||
|
|
|||
|
|
|||
|
#endif
|