#include #include #define DISPLAY 1 #define ETH_ALEN 6 #define ETH_HLEN 14 #define ETH_ZLEN 60 #define ETH_DATA_LEN 1500 #define ETH_FRAME_LEN 1514 #define ETHERTYPE_PUP 0x0200 #define ETHERTYPE_IP 0x0800 #define ETHERTYPE_ARP 0x0806 #define ETHERTYPE_REVARP 0x8035 #define IP_RF 0x8000 #define IP_DF 0x4000 #define IP_MF 0x2000 #define IP_OFFMASK 0x1fff #define IP_WINDOWS "192.168.10.64" #define IP_LINUX "192.168.10.94" #define IPPROTO_IPIP 4 #define IPPROTO_EGP 8 #define arp_hrd ea_hdr.ar_hrd #define arp_pro ea_hdr.ar_pro #define arp_hln ea_hdr.ar_hln #define arp_pln ea_hdr.ar_pln #define arp_op ea_hdr.ar_op #define ARPHRD_NETROM 0 #define ARPHRD_ETHER 1 #define ARPHRD_EETHER 2 #define ARPHRD_IEEE802 6 // ARP protocol opcodes #define ARPOP_REQUEST 1 // ARP request #define ARPOP_REPLY 2 // ARP reply #define ARPOP_RREQUEST 3 // RARP request #define ARPOP_RREPLY 4 // RARP reply #define ARPOP_InREQUEST 8 // InARP request #define ARPOP_InREPLY 9 // InARP reply #define ARPOP_NAK 10 // (ATM)ARP NAK typedef unsigned int in_addr_t; #pragma pack(push, 1) struct ether_header { u_int8_t ether_dhost[ETH_ALEN]; // destination ether addr u_int8_t ether_shost[ETH_ALEN]; // source ether addr u_int16_t ether_type; // packet type ID field }; struct ip { u_char ip_hl:4; u_char ip_v:4; u_char ip_tos; u_short ip_len; u_short ip_id; u_short ip_off; u_char ip_ttl; u_char ip_p; u_short ip_sum; struct in_addr ip_src, ip_dst; }; struct arphdr { unsigned short ar_hrd; unsigned short ar_pro; unsigned char ar_hln; unsigned char ar_pln; unsigned short ar_op; }; struct ether_arp { struct arphdr ea_hdr; unsigned char arp_sha[ETH_ALEN]; unsigned char arp_spa[4]; unsigned char arp_tha[ETH_ALEN]; unsigned char arp_tpa[4]; }; struct tcphdr { unsigned short source; unsigned short dest; unsigned int seq; unsigned int ack_seq; unsigned short res; unsigned short window; unsigned short check; unsigned short urg_ptr; }; struct icmp { u_char type; u_char code; u_short checksum; u_int resthdr; u_int datasection; }; #pragma pack(pop) void pcapdata(char *, int); void PrintHexaNAscii(void *, int); int UEC_HPreEther(struct ether_header *); int UEC_HDisplayIP(struct ip *); int UEC_HPreARP(struct ether_arp *); int UEC_HPreTCP(struct tcphdr *); int UEC_HPreICMP(struct icmp *); #pragma comment (lib, "ws2_32.lib")