Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
5.7 KiB

  1. // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil -*- (for GNU Emacs)
  2. //
  3. // Copyright (c) 1985-2000 Microsoft Corporation
  4. //
  5. // This file is part of the Microsoft Research IPv6 Network Protocol Stack.
  6. // You should have received a copy of the Microsoft End-User License Agreement
  7. // for this software along with this release; see the file "license.txt".
  8. // If not, please see http://www.research.microsoft.com/msripv6/license.htm,
  9. // or write to Microsoft Research, One Microsoft Way, Redmond, WA 98052-6399.
  10. //
  11. // Abstract:
  12. //
  13. // Definitions derived from the IPv6 specifications.
  14. //
  15. #ifndef ICMP6_INCLUDED
  16. #define ICMP6_INCLUDED 1
  17. //
  18. // ICMPv6 Header.
  19. // The actual message body follows this header and is type-specific.
  20. //
  21. typedef struct ICMPv6Header {
  22. UCHAR Type; // Type of message (high bit zero for error messages).
  23. UCHAR Code; // Type-specific differentiater.
  24. USHORT Checksum; // Calculated over ICMPv6 message and IPv6 psuedo-header.
  25. } ICMPv6Header;
  26. //
  27. // ICMPv6 Type field definitions.
  28. //
  29. #define ICMPv6_DESTINATION_UNREACHABLE 1
  30. #define ICMPv6_PACKET_TOO_BIG 2
  31. #define ICMPv6_TIME_EXCEEDED 3
  32. #define ICMPv6_PARAMETER_PROBLEM 4
  33. #define ICMPv6_ECHO_REQUEST 128
  34. #define ICMPv6_ECHO_REPLY 129
  35. #define ICMPv6_MULTICAST_LISTENER_QUERY 130
  36. #define ICMPv6_MULTICAST_LISTENER_REPORT 131
  37. #define ICMPv6_MULTICAST_LISTENER_DONE 132
  38. #define ICMPv6_ROUTER_SOLICIT 133
  39. #define ICMPv6_ROUTER_ADVERT 134
  40. #define ICMPv6_NEIGHBOR_SOLICIT 135
  41. #define ICMPv6_NEIGHBOR_ADVERT 136
  42. #define ICMPv6_REDIRECT 137
  43. #define ICMPv6_ROUTER_RENUMBERING 138
  44. #define ICMPv6_INFORMATION_TYPE(type) ((type) & 0x80)
  45. #define ICMPv6_ERROR_TYPE(type) (((type) & 0x80) == 0)
  46. // Max amount of packet data in an ICMP error message.
  47. #define ICMPv6_ERROR_MAX_DATA_LEN \
  48. (IPv6_MINIMUM_MTU - sizeof(IPv6Header) - \
  49. sizeof(ICMPv6Header) - sizeof(UINT))
  50. //
  51. // ICMPv6 Code field definitions.
  52. //
  53. // For Destination Unreachable errors:
  54. #define ICMPv6_NO_ROUTE_TO_DESTINATION 0
  55. #define ICMPv6_COMMUNICATION_PROHIBITED 1
  56. // was ICMPv6_NOT_NEIGHBOR 2
  57. #define ICMPv6_SCOPE_MISMATCH 2
  58. #define ICMPv6_ADDRESS_UNREACHABLE 3
  59. #define ICMPv6_PORT_UNREACHABLE 4
  60. // For Time Exceeded errors:
  61. #define ICMPv6_HOP_LIMIT_EXCEEDED 0
  62. #define ICMPv6_REASSEMBLY_TIME_EXCEEDED 1
  63. // For Parameter Problem errors:
  64. #define ICMPv6_ERRONEOUS_HEADER_FIELD 0
  65. #define ICMPv6_UNRECOGNIZED_NEXT_HEADER 1
  66. #define ICMPv6_UNRECOGNIZED_OPTION 2
  67. //
  68. // Neighbor Discovery message option definitions.
  69. //
  70. #define ND_OPTION_SOURCE_LINK_LAYER_ADDRESS 1
  71. #define ND_OPTION_TARGET_LINK_LAYER_ADDRESS 2
  72. #define ND_OPTION_PREFIX_INFORMATION 3
  73. #define ND_OPTION_REDIRECTED_HEADER 4
  74. #define ND_OPTION_MTU 5
  75. #define ND_NBMA_SHORTCUT_LIMIT 6 // Related to IPv6-NBMA.
  76. #define ND_ADVERTISEMENT_INTERVAL 7 // For IPv6 Mobility.
  77. #define ND_HOME_AGENT_INFO 8 // For IPv6 Mobility.
  78. #define ND_OPTION_ROUTE_INFORMATION 9
  79. //
  80. // Neighbor Advertisement message flags.
  81. //
  82. #define ND_NA_FLAG_ROUTER 0x80000000
  83. #define ND_NA_FLAG_SOLICITED 0x40000000
  84. #define ND_NA_FLAG_OVERRIDE 0x20000000
  85. typedef struct NDRouterAdvertisement {
  86. UCHAR CurHopLimit;
  87. UCHAR Flags;
  88. USHORT RouterLifetime;
  89. UINT ReachableTime;
  90. UINT RetransTimer;
  91. } NDRouterAdvertisement;
  92. //
  93. // Router Advertisement message flags.
  94. //
  95. #define ND_RA_FLAG_MANAGED 0x80
  96. #define ND_RA_FLAG_OTHER 0x40
  97. #define ND_RA_FLAG_HOME_AGENT 0x20
  98. #define ND_RA_FLAG_PREFERENCE 0x18 // A two-bit field.
  99. typedef struct NDOptionMTU {
  100. UCHAR Type;
  101. UCHAR Length;
  102. USHORT Reserved;
  103. UINT MTU;
  104. } NDOptionMTU;
  105. typedef struct NDOptionPrefixInformation {
  106. UCHAR Type;
  107. UCHAR Length;
  108. UCHAR PrefixLength;
  109. UCHAR Flags;
  110. UINT ValidLifetime;
  111. UINT PreferredLifetime;
  112. union { // Preserve compatibility with the pre-SitePrefixLength version.
  113. UINT Reserved2;
  114. struct {
  115. UCHAR Reserved3[3];
  116. UCHAR SitePrefixLength;
  117. };
  118. };
  119. IN6_ADDR Prefix;
  120. } NDOptionPrefixInformation;
  121. //
  122. // Prefix Information option flags.
  123. //
  124. #define ND_PREFIX_FLAG_ON_LINK 0x80
  125. #define ND_PREFIX_FLAG_AUTONOMOUS 0x40
  126. #define ND_PREFIX_FLAG_ROUTER_ADDRESS 0x20
  127. #define ND_PREFIX_FLAG_SITE_PREFIX 0x10
  128. #define ND_PREFIX_FLAG_ROUTE 0x01
  129. //
  130. // NDOptionRouteInformation is actually variable-sized.
  131. // If PrefixLength is zero, then the Prefix field may be 0 bytes.
  132. // If PrefixLength is <= 64, then the Prefix field may be 8 bytes.
  133. // Otherwise the Prefix field is a full 16 bytes.
  134. //
  135. typedef struct NDOptionRouteInformation {
  136. UCHAR Type;
  137. UCHAR Length;
  138. UCHAR PrefixLength;
  139. UCHAR Flags;
  140. UINT RouteLifetime;
  141. IN6_ADDR Prefix;
  142. } NDOptionRouteInformation;
  143. //
  144. // MLD message struct - this immediately follows the ICMPv6 header.
  145. // NB: If IN6_ADDR ever has stricter alignment than USHORT,
  146. // this definition will need to change. Probably it should
  147. // include ICMPv6Header so that GroupAddr is aligned properly.
  148. //
  149. typedef struct MLDMessage {
  150. USHORT MaxResponseDelay;
  151. USHORT Unused;
  152. IN6_ADDR GroupAddr;
  153. } MLDMessage;
  154. C_ASSERT(__builtin_alignof(MLDMessage) == __builtin_alignof(USHORT));
  155. //
  156. // Router Renumbering code values.
  157. //
  158. #define RR_COMMAND 0
  159. #define RR_RESULT 1
  160. #define RR_SEQUENCE_NO_RESET 255
  161. #endif // ICMP6_INCLUDED