icmp.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. /* ICMP for IP v4 and v6 */
  10. enum
  11. {
  12. /* Packet Types, icmp v4 (rfc 792) */
  13. EchoReply = 0,
  14. Unreachable = 3,
  15. SrcQuench = 4,
  16. Redirect = 5,
  17. EchoRequest = 8,
  18. TimeExceed = 11,
  19. InParmProblem = 12,
  20. Timestamp = 13,
  21. TimestampReply = 14,
  22. InfoRequest = 15,
  23. InfoReply = 16,
  24. AddrMaskRequest = 17,
  25. AddrMaskReply = 18,
  26. Traceroute = 30,
  27. IPv6WhereAreYou = 33,
  28. IPv6IAmHere = 34,
  29. /* packet types, icmp v6 (rfc 2463) */
  30. /* error messages */
  31. UnreachableV6 = 1,
  32. PacketTooBigV6 = 2,
  33. TimeExceedV6 = 3,
  34. ParamProblemV6 = 4,
  35. /* informational messages (rfc 2461 also) */
  36. EchoRequestV6 = 128,
  37. EchoReplyV6 = 129,
  38. RouterSolicit = 133,
  39. RouterAdvert = 134,
  40. NbrSolicit = 135,
  41. NbrAdvert = 136,
  42. RedirectV6 = 137,
  43. Maxtype6 = 137,
  44. ICMP_HDRSIZE = 8,
  45. };
  46. typedef struct Ip4hdr Ip4hdr;
  47. struct Ip4hdr
  48. {
  49. unsigned char vihl; /* Version and header length */
  50. unsigned char tos; /* Type of service */
  51. unsigned char length[2]; /* packet length */
  52. unsigned char id[2]; /* Identification */
  53. unsigned char frag[2]; /* Fragment information */
  54. unsigned char ttl; /* Time to live */
  55. unsigned char proto; /* Protocol */
  56. unsigned char ipcksum[2]; /* Header checksum */
  57. unsigned char src[4]; /* Ipv4 source */
  58. unsigned char dst[4]; /* Ipv4 destination */
  59. unsigned char data[];
  60. };
  61. // #define IP4HDRSZ offsetof(Ip4hdr, data[0])
  62. /* the icmp payload has the same format in v4 and v6 */
  63. typedef struct Icmphdr Icmphdr;
  64. struct Icmphdr {
  65. unsigned char type;
  66. unsigned char code;
  67. unsigned char cksum[2];
  68. unsigned char icmpid[2];
  69. unsigned char seq[2];
  70. unsigned char data[];
  71. };
  72. // #define ICMPHDRSZ offsetof(Icmphdr, data[0])