icmp.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. /* packet types, icmp v6 (rfc 2463) */
  22. /* error messages */
  23. UnreachableV6 = 1,
  24. PacketTooBigV6 = 2,
  25. TimeExceedV6 = 3,
  26. ParamProblemV6 = 4,
  27. /* informational messages (rfc 2461 also) */
  28. EchoRequestV6 = 128,
  29. EchoReplyV6 = 129,
  30. RouterSolicit = 133,
  31. RouterAdvert = 134,
  32. NbrSolicit = 135,
  33. NbrAdvert = 136,
  34. RedirectV6 = 137,
  35. Maxtype6 = 137,
  36. ICMP_HDRSIZE = 8,
  37. };
  38. typedef struct Ip4hdr Ip4hdr;
  39. struct Ip4hdr
  40. {
  41. uchar vihl; /* Version and header length */
  42. uchar tos; /* Type of service */
  43. uchar length[2]; /* packet length */
  44. uchar id[2]; /* Identification */
  45. uchar frag[2]; /* Fragment information */
  46. uchar ttl; /* Time to live */
  47. uchar proto; /* Protocol */
  48. uchar ipcksum[2]; /* Header checksum */
  49. uchar src[4]; /* Ipv4 source */
  50. uchar dst[4]; /* Ipv4 destination */
  51. uchar data[];
  52. };
  53. // #define IP4HDRSZ offsetof(Ip4hdr, data[0])
  54. /* the icmp payload has the same format in v4 and v6 */
  55. typedef struct Icmphdr Icmphdr;
  56. struct Icmphdr {
  57. uchar type;
  58. uchar code;
  59. uchar cksum[2];
  60. uchar icmpid[2];
  61. uchar seq[2];
  62. uchar data[];
  63. };
  64. // #define ICMPHDRSZ offsetof(Icmphdr, data[0])