//core_ehp.h #ifndef __core_ehp_h #define __core_ehp_h #define ETH_ADDR_LEN 6 #include #include #include #include #include #include typedef const struct pcap_pkthdr cp_pkthdr; typedef const u_char cu_char; typedef struct pcap_pkthdr p_pkthr; typedef struct _eth_hdr eth_hdr; struct _eth_hdr{ u_char src[ETH_ADDR_LEN]; u_char dst[ETH_ADDR_LEN]; u_short type; }; #define SIZE_ETH (sizeof(eth_hdr)) typedef struct _ip_hdr ip_hdr; struct _ip_hdr{ #if __BYTE_ORDER == __LITTLE_ENDIAN u_char hd_len:4; u_char version:4; #elif __BYTE__ORDER == __BIG_ENDIAN u_char version:4; u_char hd_len:4; #endif u_char tos; u_short tot_len; u_short id; #if __BYTE_ORDER == __LITTLE_ENDIAN u_short offset:13;//per 8byte u_short m_flag:1;//more fragment u_short d_flag:1;//don't fragment u_short r_flag:1;//reserved #endif #if __BYTE_ORDER == __BIG_ENDIAN u_short r_flag:1;//reserved u_short d_flag:1;//don't fragment u_short m_flag:1;//more fragment u_short offset:13;//per 8byte #endif u_char ttl; u_char type; u_short check; u_int src_addr; u_int dst_addr; }; #define SIZE_IP (sizeof(ip_hdr)) typedef struct _tcp_hdr tcp_hdr; struct _tcp_hdr{ u_short sport; u_short dport; u_int seq; u_int ack; #if __BYTE_ORDER == __LITTLE_ENDIAN u_short reserved:4; u_short doff:4;//data offset per 4byte; #endif #if __BYTE_ORDER == __BIG_ENDIAN u_short doff:4; u_short reserved:4; #endif u_char flags; #define TCP_FIN 0x01 #define TCP_SYN 0x02 #define TCP_RST 0x04 #define TCP_PUSH 0x08 #define TCP_ACK 0x10 #define TCP_URG 0x20 u_short window; u_short check; u_short urgent; }; //to do - define udp header //to do - define icmp header //to do - define ip6 header //to do - define icmp6 header //to do - define igmp header #endif