正在加载图片...
unsigned int h len; 4: // lenth of the head on: 4://Ve of IP unsigned char tos: / Type of service d short total len;// total length of the packe unsigned short ident: / unique identifier t frag and flags; //fla unsigned char ttl 1(TCP, UDP etc) unsigned short checksum; //IP checksum unsigned int sourceIP unsigned ibt destIP 3 IpHeader typedef struct ihdr( bYtE i t BYTE i code; /type sub code */ USHoRT i cksum UShoRT i id USHORT i seq; / *This is not the std header, but we reserve space for time*/ ULONG timestamp 3 IcmpHeader #define status FaIled oXFFFr #define de PacKet size 32 #define max packet 1024 #defing xmalloc(s) HeapAlloc(GetprocessHeap)), HEAP ZERO MEMORY, (S)) #defing free(p) Heap Free (GetprocessHeap o, 0, (p)) void fill icmp data(char*, int) USHORT checksum (USHORT*, int) void decode resp (char*, int, struct sockaddr in*) oid Usage(char*progname) fprintf (stderr, " Usage: /n") fprintf(stderr, %s [data size]/n", progname) fprintf(stderr, datasize can be up to lkb/n") ExitProcess(STATUS FAILED int main(int argc, char**argv) WSADATA wsaData SOCKET SOckRaw struct sockaddr in dest. from struct hostent *hp int bread. datasizeunsigned int h_len;4; // lenth 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; unsigned char proto; // protocol (TCP,UDP etc) unsigned short checksum; //IP checksum unsigned int sourceIP; unsigned ibt destIP }IpHeader; typedef struct_ihdr{ BYTE i_type; BYTE i_code; /*type sub code */ USHORT i_cksum; USHORT i_id; USHORT i_seq; /*This is not the std header,but we reserve space for time*/ ULONG timestamp; }IcmpHeader; #define STATUS_FAILED 0XFFFF #define DE_PACKET_SIZE 32 #define MAX_PACKET 1024 #defing xmalloc(s) HeapAlloc(GetprocessHeap)),HEAP_ZERO_MEMORY,(S)) #defing xfree(p) HeapFree (GetprocessHeap(),0,(p)) void fill_icmp_data(char*,int); USHORT checksum(USHORT*,int); void decode_resp(char*,int,struct sockaddr_in*); void Usage(char*progname) { fprintf(stderr,″Usage:/n″); fprintf(stderr,″%s [data_size]/n″,progname); fprintf(stderr,″datasize can be up to 1kb/n″) ExitProcess(STATUS_FAILED); } int main(int argc,char**argv) { WSADATA wsaData; SOCKET sockRaw; struct sockaddr_in dest,from; struct hostent *hp; int bread,datasize;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有