1 /* ICMP for IP v4 and v6 */ 2 enum 3 { 4 /* Packet Types, icmp v4 (rfc 792) */ 5 EchoReply = 0, 6 Unreachable = 3, 7 SrcQuench = 4, 8 Redirect = 5, 9 EchoRequest = 8, 10 TimeExceed = 11, 11 InParmProblem = 12, 12 Timestamp = 13, 13 TimestampReply = 14, 14 InfoRequest = 15, 15 InfoReply = 16, 16 AddrMaskRequest = 17, 17 AddrMaskReply = 18, 18 Traceroute = 30, 19 IPv6WhereAreYou = 33, 20 IPv6IAmHere = 34, 21 22 /* packet types, icmp v6 (rfc 2463) */ 23 24 /* error messages */ 25 UnreachableV6 = 1, 26 PacketTooBigV6 = 2, 27 TimeExceedV6 = 3, 28 ParamProblemV6 = 4, 29 30 /* informational messages (rfc 2461 also) */ 31 EchoRequestV6 = 128, 32 EchoReplyV6 = 129, 33 RouterSolicit = 133, 34 RouterAdvert = 134, 35 NbrSolicit = 135, 36 NbrAdvert = 136, 37 RedirectV6 = 137, 38 39 Maxtype6 = 137, 40 41 ICMP_IPSIZE = 20, 42 ICMP_HDRSIZE = 8, 43 }; 44 45 typedef struct Icmp Icmp; 46 struct Icmp 47 { 48 uchar vihl; /* Version and header length */ 49 uchar tos; /* Type of service */ 50 uchar length[2]; /* packet length */ 51 uchar id[2]; /* Identification */ 52 uchar frag[2]; /* Fragment information */ 53 uchar ttl; /* Time to live */ 54 uchar proto; /* Protocol */ 55 uchar ipcksum[2]; /* Header checksum */ 56 uchar src[4]; /* Ip source */ 57 uchar dst[4]; /* Ip destination */ 58 59 uchar type; 60 uchar code; 61 uchar cksum[2]; 62 uchar icmpid[2]; 63 uchar seq[2]; 64 uchar data[1]; 65 }; 66 67 typedef struct Icmp6 Icmp6; 68 struct Icmp6 69 { 70 uchar vcf[4]; 71 uchar ploadlen[2]; 72 uchar proto; 73 uchar ttl; 74 uchar src[16]; /* Ip source */ 75 uchar dst[16]; /* Ip destination */ 76 77 uchar type; 78 uchar code; 79 uchar cksum[2]; 80 uchar icmpid[2]; 81 uchar seq[2]; 82 uchar data[1]; 83 }; 84