Leaked source code of windows server 2003
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.

274 lines
10 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. // Link-layer IPv6 interface definitions.
  14. //
  15. // This file contains the definitions defining the interface between IPv6
  16. // and a link layer, such as Ethernet or Token-Ring.
  17. //
  18. // Also see Packet6Context and IPv6Packet in ip6imp.h.
  19. //
  20. // NB: We implicitly assume that all link-layer addresses that a
  21. // particular interface will communicate with are the same length,
  22. // although different interfaces/links may be using addresses of
  23. // different lengths.
  24. //
  25. #ifndef LLIP6IF_INCLUDED
  26. #define LLIP6IF_INCLUDED
  27. #define MAX_LINK_LAYER_ADDRESS_LENGTH 64
  28. //
  29. // Structure of information passed to IPAddInterface.
  30. //
  31. // lip_defmtu must be less than or equal to lip_maxmtu.
  32. // lip_defmtu and lip_maxmtu do NOT include lip_hdrsize.
  33. //
  34. typedef struct LLIPv6BindInfo {
  35. void *lip_context; // LL context handle.
  36. uint lip_maxmtu; // Max MTU that the link can use.
  37. uint lip_defmtu; // Default MTU for the link.
  38. uint lip_flags; // Various indicators, defined in ntddip6.h.
  39. uint lip_type; // What kind of link - defined in ntddip6.h.
  40. uint lip_hdrsize; // Size of link-layer header.
  41. uint lip_addrlen; // Length of address in bytes - see max above.
  42. uchar *lip_addr; // Pointer to interface address.
  43. uint lip_dadxmit; // Default value for DupAddrDetectTransmits.
  44. uint lip_pref; // Interface preference for routing decisions.
  45. //
  46. // The following five link-layer functions should return quickly.
  47. // They may be called from DPC context or with spin-locks held.
  48. //
  49. //
  50. // Initializes the interface identifier portion of the Address
  51. // with the interface identifier of this interface.
  52. // The interface identifier may depend on state (like the ifindex)
  53. // that is determined during CreateInterface, so it can't
  54. // be passed as a parameter to CreateInterface.
  55. //
  56. void (*lip_token)(IN void *LlContext, OUT IPv6Addr *Address);
  57. //
  58. // Given a pointer to a Source/Target Link-Layer Address Option
  59. // (see RFC 2461), return a pointer to the link-layer address.
  60. // Returns NULL if the option is misformatted (eg, the length is bad).
  61. //
  62. // lip_rdllopt may be NULL if the interface does not support
  63. // Neighbor Discovery (IF_FLAG_NEIGHBOR_DISCOVERS).
  64. //
  65. const void *(*lip_rdllopt)(IN void *LlContext, IN const uchar *OptionData);
  66. //
  67. // Given a pointer to a Source/Target Link-Layer Address Option
  68. // (see RFC 2461), initializes the option data with the link-layer
  69. // address and zeroes any padding bytes in the option data.
  70. // Does not modify the option type/length bytes.
  71. //
  72. // lip_wrllopt may be NULL if the interface does not support
  73. // Neighbor Discovery (IF_FLAG_NEIGHBOR_DISCOVERS).
  74. //
  75. void (*lip_wrllopt)(IN void *LlContext, OUT uchar *OptionData,
  76. IN const void *LinkAddress);
  77. //
  78. // Statically converts an IPv6 address into a link-layer address.
  79. // The return value is a Neighbor Discovery state value.
  80. // If static conversion is not possible (a common case),
  81. // returns ND_STATE_INCOMPLETE to indicate the use of Neighbor Discovery.
  82. // If static conversion is possible (for example with multicast
  83. // addresses or with a p2p interface), returns (typically)
  84. // ND_STATE_PERMANENT or ND_STATE_STALE. ND_STATE_STALE indicates
  85. // that Neighbor Unreachability Detection should be performed.
  86. //
  87. ushort (*lip_cvaddr)(IN void *LlContext,
  88. IN const IPv6Addr *Address,
  89. OUT void *LinkAddress);
  90. //
  91. // Set the default router's link-layer address on an NBMA link,
  92. // as well as our own link-layer address to use in stateless
  93. // address configuration, since we may have multiple choices available.
  94. //
  95. NTSTATUS (*lip_setrtrlladdr)(IN void *LlContext,
  96. IN const void *TokenLinkAddress,
  97. IN const void *RouterLinkAddress);
  98. //
  99. // Transmits the packet to the link-layer address.
  100. // The Offset argument indicates the location of the IPv6 header
  101. // in the packet. The IPv6 layer guarantees that Offset >= lip_hdrsize,
  102. // leaving room for the link-layer header.
  103. //
  104. // May be called from thread or DPC context, but should not be called
  105. // with spin-locks held. Calls are not serialized.
  106. //
  107. void (*lip_transmit)(IN void *LlContext, IN PNDIS_PACKET Packet,
  108. IN uint Offset, IN const void *LinkAddress);
  109. //
  110. // Sets the multicast address list on the interface.
  111. // LinkAddresses is an array of link-layer addresses.
  112. // The first NumKeep addresses were part of the previous
  113. // multicast list and are to be kept. The next NumAdd
  114. // addresses are new additions to the multicast address list.
  115. // The remaining NumDel addresses should be removed
  116. // from the multicast address list.
  117. //
  118. // A NULL lip_mclist function is valid and indicates
  119. // that the interface does not support link-layer multicast.
  120. // For example, a point-to-point or NBMA interface.
  121. // If lip_mclist is non-NULL, then lip_cvaddr must be non-NULL
  122. // and it should return ND_STATE_PERMANENT for multicast addresses.
  123. //
  124. // Called only from thread context; may block or otherwise
  125. // take a long time. The IPv6 layer serializes its calls.
  126. // Also see RestartLinkLayerMulticast below.
  127. //
  128. NDIS_STATUS (*lip_mclist)(IN void *LlContext, IN const void *LinkAddresses,
  129. IN uint NumKeep, IN uint NumAdd, IN uint NumDel);
  130. //
  131. // Initiate shut down of the link-layer connection.
  132. // The link layer should release its reference(s) for the IPv6 interface.
  133. // However, the IPv6 interface is not freed until after the call
  134. // to lip_cleanup and the link layer can make some use of it until then.
  135. //
  136. // Called only from thread context; may block or otherwise
  137. // take a long time. The IPv6 layer will only call once.
  138. //
  139. void (*lip_close)(IN void *LlContext);
  140. //
  141. // Final cleanup of the link-layer connection.
  142. // Called by the IPv6 layer when there are no more references.
  143. //
  144. // Called only from thread context; may block or otherwise
  145. // take a long time. The IPv6 layer will only call once,
  146. // after lip_close has returned.
  147. //
  148. // Up until the call to lip_cleanup, the IPv6 layer
  149. // may still make calls down to the link layer.
  150. // In lip_cleanup, the link layer should release any references
  151. // that it has for lower-layer data structures and
  152. // free its own context structure.
  153. //
  154. void (*lip_cleanup)(IN void *LlContext);
  155. } LLIPv6BindInfo;
  156. //
  157. // These values should agree with definitions also
  158. // found in ip6def.h and ntddip6.h.
  159. //
  160. #define IF_TYPE_LOOPBACK 0
  161. #define IF_TYPE_ETHERNET 1
  162. #define IF_TYPE_FDDI 2
  163. #define IF_TYPE_TUNNEL_AUTO 3
  164. #define IF_TYPE_TUNNEL_6OVER4 4
  165. #define IF_TYPE_TUNNEL_V6V4 5
  166. #define IF_TYPE_TUNNEL_6TO4 6
  167. #define IF_TYPE_TUNNEL_TEREDO 7
  168. //
  169. // These values should agree with definitions also
  170. // found in ip6def.h and ntddip6.h.
  171. //
  172. #define IF_FLAG_PSEUDO 0x00000001
  173. #define IF_FLAG_P2P 0x00000002
  174. #define IF_FLAG_NEIGHBOR_DISCOVERS 0x00000004
  175. #define IF_FLAG_FORWARDS 0x00000008
  176. #define IF_FLAG_ADVERTISES 0x00000010
  177. #define IF_FLAG_MULTICAST 0x00000020
  178. #define IF_FLAG_ROUTER_DISCOVERS 0x00000040
  179. #define IF_FLAG_PERIODICMLD 0x00000080
  180. #define IF_FLAG_MEDIA_DISCONNECTED 0x00001000
  181. //
  182. // Return values for lip_cvaddr.
  183. // These definitions are also in ip6def.h.
  184. //
  185. #define ND_STATE_INCOMPLETE 0
  186. #define ND_STATE_PROBE 1
  187. #define ND_STATE_DELAY 2
  188. #define ND_STATE_STALE 3
  189. #define ND_STATE_REACHABLE 4
  190. #define ND_STATE_PERMANENT 5
  191. //
  192. // The link-layer code calls these IPv6 functions.
  193. // See the function definitions for explanatory comments.
  194. //
  195. extern NTSTATUS
  196. CreateInterface(IN const GUID *Guid, IN const LLIPv6BindInfo *BindInfo,
  197. OUT void **IpContext);
  198. extern void *
  199. AdjustPacketBuffer(IN PNDIS_PACKET Packet,
  200. IN uint SpaceAvail, IN uint SpaceNeeded);
  201. extern void
  202. UndoAdjustPacketBuffer(IN PNDIS_PACKET Packet);
  203. extern void
  204. IPv6ReceiveComplete(void);
  205. //
  206. // The packet itself holds a reference for the IPv6 interface,
  207. // so the link layer does not need to hold another reference.
  208. //
  209. extern void
  210. IPv6SendComplete(IN void *IpContext,
  211. IN PNDIS_PACKET Packet, IN IP_STATUS Status);
  212. //
  213. // The following calls must be made before lip_cleanup
  214. // returns. Normally they require a reference for the IPv6 interface,
  215. // but between lip_close and lip_cleanup the link layer may call them
  216. // without holding a reference for the IPv6 interface.
  217. //
  218. // NB: IPv6Receive does not take IpContext (the IPv6 interface)
  219. // as an explicit argument. Instead it is passed as Packet->NTEorIF.
  220. //
  221. extern int
  222. IPv6Receive(IN IPv6Packet *Packet);
  223. extern void
  224. SetInterfaceLinkStatus(IN void *IpContext, IN int MediaConnected);
  225. extern void
  226. DestroyInterface(IN void *IpContext);
  227. //
  228. // This function asks the IPv6 layer to call lip_mclist again,
  229. // adding all the link-layer multicast addresses to the interface
  230. // as if for the first time. In other words, with NumKeep zero.
  231. // The ResetDone function is called under a lock that serializes
  232. // the ResetDone call with lip_mclist calls on this interface.
  233. // Hence the link layer can know at what point in the sequence
  234. // of lip_mclist calls the reset took place.
  235. //
  236. extern void
  237. RestartLinkLayerMulticast(IN void *IpContext,
  238. IN void (*ResetDone)(IN void *LlContext));
  239. //
  240. // The link layer must hold a reference
  241. // for the IPv6 interface to make the following calls.
  242. //
  243. extern void
  244. ReleaseInterface(IN void *IpContext);
  245. #endif // LLIP6IF_INCLUDED