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.

1416 lines
43 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. // IPv6 private definitions.
  14. //
  15. // This file contains all of the definitions for IPv6 that
  16. // are not visible to outside layers.
  17. //
  18. #ifndef IPv6DEF_INCLUDED
  19. #define IPv6DEF_INCLUDED 1
  20. #pragma warning(push)
  21. #pragma warning(disable:4200) // zero-sized array in struct/union
  22. typedef struct NeighborCacheEntry NeighborCacheEntry;
  23. typedef struct AddressEntry AddressEntry;
  24. typedef struct MulticastAddressEntry MulticastAddressEntry;
  25. typedef struct AnycastAddressEntry AnycastAddressEntry;
  26. typedef struct NetTableEntryOrInterface NetTableEntryOrInterface;
  27. typedef struct NetTableEntry NetTableEntry;
  28. typedef struct Interface Interface;
  29. typedef struct IPSecProc IPSecProc;
  30. // REVIEW: Added so the build will work.
  31. typedef unsigned long IPAddr;
  32. #define INADDR_ANY 0
  33. #ifndef ABORTMSG
  34. #if DBG
  35. #define ABORT() \
  36. RtlAssert( "FALSE", __FILE__, __LINE__, NULL )
  37. #define ABORTMSG(msg) \
  38. RtlAssert( "FALSE", __FILE__, __LINE__, (msg) )
  39. #else
  40. #define ABORT()
  41. #define ABORTMSG(msg)
  42. #endif // DBG
  43. #endif // ABORTMSG
  44. //
  45. // Per-neighbor information. We keep address translation and unreachability
  46. // detection info for each of our neighbors that we're in communication with.
  47. //
  48. // A non-zero reference count prevents the NCE from being reclaimed.
  49. // An NCE with zero references may be kept cached.
  50. // A per-interface lock protects all NCEs for that interface.
  51. //
  52. // NCEs with a non-zero reference count hold a reference for their interface.
  53. // NCEs with a zero reference count do not hold a reference.
  54. // This means if you hold a reference for an NCE,
  55. // you can always safely access and dereference NCE->IF.
  56. //
  57. // The Next/Prev fields link NCEs into a circular doubly-linked list.
  58. // They must be first and must match the IF->FirstNCE/LastNCE fields
  59. // to make the casting work out.
  60. //
  61. // The list of NCEs is kept sorted, from most-recently-used to least.
  62. //
  63. struct NeighborCacheEntry { // a.k.a. NCE
  64. NeighborCacheEntry *Next; // Next entry on I/F neighbor list.
  65. NeighborCacheEntry *Prev; // Previous entry on I/F neighbor list.
  66. IPv6Addr NeighborAddress; // Address of I/F on neighboring node.
  67. void *LinkAddress; // Media address corresponding to above.
  68. // NB: LinkAddressLength field not needed - use IF->LinkAddressLength.
  69. ushort IsRouter:1, // Is the neighbor a router?
  70. IsUnreachable:1, // Does ND indicate unreachability?
  71. // DoRoundRobin is only meaningful if IsUnreachable is TRUE.
  72. DoRoundRobin:1, // Should FindNextHop do round-robin?
  73. IsLoopback:1; // Do we loopback to this neighbor
  74. // in software?
  75. ushort NDState; // Neighbor Discovery Protocol state.
  76. uint LastReachability; // Timestamp (IPv6Timer ticks).
  77. ushort NSTimer; // In IPv6Timer ticks (see IPv6Timeout).
  78. uchar NSCount; // Number of solicits sent so far.
  79. uchar NSLimit; // Total number of solicits to send.
  80. Interface *IF; // Interface on media with neighbor.
  81. NDIS_PACKET *WaitQueue; // Queue of packets waiting on ND.
  82. long RefCnt; // Reference count - interlocked.
  83. };
  84. //
  85. // The caller must already have a reference for the NCE.
  86. // The interface need not be locked.
  87. //
  88. __inline void
  89. AddRefNCE(NeighborCacheEntry *NCE)
  90. {
  91. long RefCnt = InterlockedIncrement(&NCE->RefCnt);
  92. ASSERT(RefCnt != 1);
  93. UNREFERENCED_PARAMETER(RefCnt);
  94. }
  95. extern void
  96. AddRefNCEInCache(NeighborCacheEntry *NCE);
  97. extern void
  98. ReleaseNCE(NeighborCacheEntry *NCE);
  99. //
  100. // Values for "NDState" above. See RFC 1970, section 7.3.2 for details.
  101. // Note: only state names are documented, we chose the values used here.
  102. //
  103. // In the INCOMPLETE state, the LinkAddress is not valid.
  104. // In all other states, LinkAddress may be used to send packets.
  105. // WaitQueue is usually only non-NULL in the INCOMPLETE state,
  106. // but sometimes a packet is left queued for NeighborCacheTimeout.
  107. //
  108. // The INCOMPLETE state has two flavors, dormant and active. If
  109. // EventTimer and EventCount are both zero, then we are not actively
  110. // trying to solicit the link address. If someone tries to send to
  111. // this neighbor, then we start soliciting the link address. If the
  112. // solicitation fails (or if we enter the PROBE state and then fail to
  113. // confirm reachability), then any waiting packets are discarded and
  114. // we reset to INCOMPLETE with zero EventTimer/EventCount. (So with
  115. // the next use of this neighbor, we start soliciting again from scratch.)
  116. //
  117. // The DELAY state is not used internally. Instead we use the PROBE state
  118. // with zero NSCount and non-zero NSTimer to indicate that we are delaying
  119. // the start of probing. However link-layer lip_cvaddr functions can
  120. // return ND_STATE_DELAY and IoctlQueryNeighborCache returns ND_STATE_DELAY.
  121. //
  122. // The IsUnreachable flag tracks separately whether the neighbor is
  123. // *known* to be unreachable. For example, a new NCE will be in in the
  124. // INCOMPLETE state, but IsUnreachable is FALSE because we don't know
  125. // yet whether the neighbor is reachable. Because FindNextHop uses
  126. // IsUnreachable, code paths that change this flag must call
  127. // InvalidateRouteCache.
  128. //
  129. // These definitions are also in llip6if.h and ntddip6.w.
  130. //
  131. #define ND_STATE_INCOMPLETE 0
  132. #define ND_STATE_PROBE 1
  133. #define ND_STATE_DELAY 2 // Not used internally.
  134. #define ND_STATE_STALE 3
  135. #define ND_STATE_REACHABLE 4
  136. #define ND_STATE_PERMANENT 5
  137. //
  138. // There are a few places in the implementation where we need
  139. // to pass a pointer which is either a NetTableEntry or an Interface.
  140. // NetTableEntries and Interfaces share this structure as their
  141. // first element. With Interfaces, the IF field points back
  142. // at the Interface itself.
  143. //
  144. struct NetTableEntryOrInterface { // a.k.a. NTEorIF
  145. Interface *IF;
  146. };
  147. __inline int
  148. IsNTE(NetTableEntryOrInterface *NTEorIF)
  149. {
  150. return (NetTableEntryOrInterface *)NTEorIF->IF != NTEorIF;
  151. }
  152. __inline NetTableEntry *
  153. CastToNTE(NetTableEntryOrInterface *NTEorIF)
  154. {
  155. ASSERT(IsNTE(NTEorIF));
  156. return (NetTableEntry *) NTEorIF;
  157. }
  158. __inline NetTableEntryOrInterface *
  159. CastFromNTE(NetTableEntry *NTE)
  160. {
  161. return (NetTableEntryOrInterface *) NTE;
  162. }
  163. __inline int
  164. IsIF(NetTableEntryOrInterface *NTEorIF)
  165. {
  166. return (NetTableEntryOrInterface *)NTEorIF->IF == NTEorIF;
  167. }
  168. __inline Interface *
  169. CastToIF(NetTableEntryOrInterface *NTEorIF)
  170. {
  171. ASSERT(IsIF(NTEorIF));
  172. return (Interface *) NTEorIF;
  173. }
  174. __inline NetTableEntryOrInterface *
  175. CastFromIF(Interface *IF)
  176. {
  177. return (NetTableEntryOrInterface *) IF;
  178. }
  179. //
  180. // Local address information. Each interface keeps track of the addresses
  181. // assigned to the interface. Depending on the type of address, each
  182. // ADE structure is the first element of a larger NTE, MAE, or AAE structure.
  183. // The address information is protected by the interface's lock.
  184. //
  185. // The NTEorIF field must be first. In NTEs, it points to the interface
  186. // and holds a reference for the interface. In MAEs and AAEs, it can
  187. // point to the interface or to one of the NTEs on the interface but in
  188. // either case it does NOT hold a reference.
  189. //
  190. struct AddressEntry { // a.k.a. ADE
  191. union {
  192. Interface *IF;
  193. NetTableEntry *NTE;
  194. NetTableEntryOrInterface *NTEorIF;
  195. };
  196. AddressEntry *Next; // Linkage on chain.
  197. IPv6Addr Address; // Address identifying this entry.
  198. ushort Type; // Address type (unicast, multicast, etc).
  199. ushort Scope; // Address scope (link, site, global, etc).
  200. };
  201. //
  202. // Values for address Type.
  203. //
  204. #define ADE_UNICAST 0x00
  205. #define ADE_ANYCAST 0x01
  206. #define ADE_MULTICAST 0x02
  207. #define ADE_NONE ((ushort)-1) // Indicates absence of an ADE.
  208. //
  209. // Values for address Scope.
  210. //
  211. #define ADE_SMALLEST_SCOPE 0x00
  212. #define ADE_INTERFACE_LOCAL 0x01
  213. #define ADE_LINK_LOCAL 0x02
  214. #define ADE_SUBNET_LOCAL 0x03
  215. #define ADE_ADMIN_LOCAL 0x04
  216. #define ADE_SITE_LOCAL 0x05
  217. #define ADE_ORG_LOCAL 0x08
  218. #define ADE_GLOBAL 0x0e
  219. #define ADE_LARGEST_SCOPE 0x0f
  220. #define ADE_NUM_SCOPES (ADE_LARGEST_SCOPE - ADE_SMALLEST_SCOPE + 1)
  221. //
  222. // Multicast ADEs are really MAEs.
  223. //
  224. // MAEs can be a separate global QueryList.
  225. // If an MAE on an Interface has a non-zero MCastTimer value,
  226. // then it is on the QueryList.
  227. //
  228. // An MAE can be on the QueryList with a zero MCastTimer value
  229. // only when it is not on any interface and it just needs
  230. // a Done message sent before it can be deleted.
  231. // When it is in this state (but not otherwise), MAE->IF
  232. // holds a reference for the interface.
  233. //
  234. struct MulticastAddressEntry { // a.k.a. MAE
  235. AddressEntry; // Inherit the ADE fields.
  236. uint MCastRefCount; // Sockets/etc receiving from this group.
  237. //
  238. // The fields below are protected by the QueryList lock.
  239. //
  240. ushort MCastFlags:4, // Necessary info about a group.
  241. MCastCount:4; // Count of initial reports left to send.
  242. ushort MCastTimer; // Ticks until a membership report is sent.
  243. MulticastAddressEntry *NextQL; // For the QueryList.
  244. };
  245. //
  246. // Bit values for MCastFlags.
  247. //
  248. #define MAE_REPORTABLE 0x01 // We should send Reports.
  249. #define MAE_LAST_REPORTER 0x02 // We should send Done.
  250. //
  251. // Anycast ADEs are really AAEs.
  252. // Currently an AAE has no additional fields.
  253. //
  254. struct AnycastAddressEntry { // a.k.a. AAE
  255. AddressEntry; // Inherit the ADE fields.
  256. };
  257. //
  258. // Unicast ADEs are really NTEs.
  259. // There is one NTE for each source (unicast) address
  260. // assigned to an interface.
  261. //
  262. // NTEs hold a reference for their interface,
  263. // so if you have a reference for an NTE
  264. // you can always safely access and dereference NTE->IF.
  265. //
  266. // Most NTE fields are either read-only or are protected
  267. // by the interface lock. The interface WorkerLock protects
  268. // the TdiRegistrationHandle field.
  269. //
  270. // Temporary addresses (AddrConf == ADDR_CONF_TEMPORARY)
  271. // have extra fields - see TempNetTableEntry.
  272. //
  273. struct NetTableEntry { // a.k.a. NTE
  274. AddressEntry; // Inherit the ADE fields.
  275. NetTableEntry *NextOnNTL; // Next NTE on NetTableList.
  276. NetTableEntry **PrevOnNTL; // Previous Next pointer in NetTableList.
  277. HANDLE TdiRegistrationHandle; // Opaque token for TDI De/notification.
  278. uint TdiRegistrationScopeId; // Scope Id when registered with TDI.
  279. long RefCnt; // Reference count - interlocked.
  280. uint ValidLifetime; // In IPv6Timer ticks (see IPv6Timeout).
  281. uint PreferredLifetime; // In IPv6Timer ticks (see IPv6Timeout).
  282. uchar AddrConf; // Address configuration status.
  283. uchar DADState; // Address configuration state.
  284. ushort DADCount; // How many DAD solicits left to send.
  285. ushort DADTimer; // In IPv6Timer ticks (see IPv6Timeout).
  286. };
  287. __inline void
  288. AddRefNTE(NetTableEntry *NTE)
  289. {
  290. InterlockedIncrement(&NTE->RefCnt);
  291. }
  292. __inline void
  293. ReleaseNTE(NetTableEntry *NTE)
  294. {
  295. InterlockedDecrement(&NTE->RefCnt);
  296. }
  297. struct AddrConfEntry {
  298. union {
  299. uchar Value; // Address configuration status.
  300. struct {
  301. uchar InterfaceIdConf : 4;
  302. uchar PrefixConf : 4;
  303. };
  304. };
  305. };
  306. //
  307. // Values for PrefixConf - must fit in 4 bits.
  308. // These must match the values in ntddip6.h, as well as the
  309. // IP_PREFIX_ORIGIN values in iptypes.h.
  310. //
  311. #define PREFIX_CONF_OTHER 0 // None of the ones below.
  312. #define PREFIX_CONF_MANUAL 1 // From a user or administrator.
  313. #define PREFIX_CONF_WELLKNOWN 2 // IANA-assigned.
  314. #define PREFIX_CONF_DHCP 3 // Configured via DHCP.
  315. #define PREFIX_CONF_RA 4 // From a Router Advertisement.
  316. //
  317. // Values for InterfaceIdConf - must fit in 4 bits.
  318. // These must match the values in ntddip6.h, as well as the
  319. // IP_SUFFIX_ORIGIN values in iptypes.h.
  320. //
  321. #define IID_CONF_OTHER 0 // None of the ones below.
  322. #define IID_CONF_MANUAL 1 // From a user or administrator.
  323. #define IID_CONF_WELLKNOWN 2 // IANA-assigned.
  324. #define IID_CONF_DHCP 3 // Configured via DHCP.
  325. #define IID_CONF_LL_ADDRESS 4 // Derived from the link-layer address.
  326. #define IID_CONF_RANDOM 5 // Random, e.g. temporary address.
  327. //
  328. // Values for AddrConf - must fit in 8 bits.
  329. //
  330. #define ADDR_CONF_MANUAL ((PREFIX_CONF_MANUAL << 4) | IID_CONF_MANUAL)
  331. #define ADDR_CONF_PUBLIC ((PREFIX_CONF_RA << 4) | IID_CONF_LL_ADDRESS)
  332. #define ADDR_CONF_TEMPORARY ((PREFIX_CONF_RA << 4) | IID_CONF_RANDOM)
  333. #define ADDR_CONF_DHCP ((PREFIX_CONF_DHCP << 4) | IID_CONF_DHCP)
  334. #define ADDR_CONF_WELLKNOWN ((PREFIX_CONF_WELLKNOWN << 4) | IID_CONF_WELLKNOWN)
  335. #define ADDR_CONF_LINK ((PREFIX_CONF_WELLKNOWN << 4) | IID_CONF_LL_ADDRESS)
  336. __inline int
  337. IsValidPrefixConfValue(uint PrefixConf)
  338. {
  339. return PrefixConf < (1 << 4);
  340. }
  341. __inline int
  342. IsValidInterfaceIdConfValue(uint InterfaceIdConf)
  343. {
  344. return InterfaceIdConf < (1 << 4);
  345. }
  346. __inline int
  347. IsStatelessAutoConfNTE(NetTableEntry *NTE)
  348. {
  349. return ((struct AddrConfEntry *)&NTE->AddrConf)->PrefixConf == PREFIX_CONF_RA;
  350. }
  351. //
  352. // Values for DADState.
  353. //
  354. // The "deprecated" and "preferred" states are valid,
  355. // meaning that addresses in those two states can be
  356. // used as a source address, can receive packets, etc.
  357. // The invalid states mean that the address is
  358. // not actually assigned to the interface,
  359. // using the terminology of RFC 2462.
  360. //
  361. // Valid<->invalid and deprecated<->preferred transitions
  362. // must call InvalidateRouteCache because they affect
  363. // source address selection.
  364. //
  365. // Among valid states, bigger is better
  366. // for source address selection.
  367. //
  368. #define DAD_STATE_INVALID 0
  369. #define DAD_STATE_TENTATIVE 1
  370. #define DAD_STATE_DUPLICATE 2
  371. #define DAD_STATE_DEPRECATED 3
  372. #define DAD_STATE_PREFERRED 4
  373. __inline int
  374. IsValidNTE(NetTableEntry *NTE)
  375. {
  376. return (NTE->DADState >= DAD_STATE_DEPRECATED);
  377. }
  378. __inline int
  379. IsTentativeNTE(NetTableEntry *NTE)
  380. {
  381. return (NTE->DADState == DAD_STATE_TENTATIVE);
  382. }
  383. //
  384. // We use this infinite lifetime value for prefix lifetimes,
  385. // router lifetimes, address lifetimes, etc.
  386. //
  387. #define INFINITE_LIFETIME 0xffffffff
  388. //
  389. // Temporary addresses have extra fields.
  390. //
  391. typedef struct TempNetTableEntry {
  392. NetTableEntry; // Inherit the NTE fields.
  393. NetTableEntry *Public; // Does not hold a reference.
  394. uint CreationTime; // In ticks (see IPv6TickCount).
  395. } TempNetTableEntry;
  396. //
  397. // Each interface keeps track of which link-layer multicast addresses
  398. // are currently enabled for receive. A reference count is required because
  399. // multiple IPv6 multicast addresses can map to a single link-layer
  400. // multicast address. The low bit of RefCntAndFlags is a flag that, if set,
  401. // indicates the link-layer address has been registered with the link.
  402. //
  403. typedef struct LinkLayerMulticastAddress {
  404. uint RefCntAndFlags;
  405. uchar LinkAddress[]; // The link-layer address follows in memory.
  406. // Padded to provide alignment.
  407. } LinkLayerMulticastAddress;
  408. #define LLMA_FLAG_REGISTERED 0x1
  409. __inline void
  410. AddRefLLMA(LinkLayerMulticastAddress *LLMA)
  411. {
  412. LLMA->RefCntAndFlags += (LLMA_FLAG_REGISTERED << 1);
  413. }
  414. __inline void
  415. ReleaseLLMA(LinkLayerMulticastAddress *LLMA)
  416. {
  417. LLMA->RefCntAndFlags -= (LLMA_FLAG_REGISTERED << 1);
  418. }
  419. __inline int
  420. IsLLMAReferenced(LinkLayerMulticastAddress *LLMA)
  421. {
  422. return LLMA->RefCntAndFlags > LLMA_FLAG_REGISTERED;
  423. }
  424. //
  425. // Information about IPv6 interfaces. There can be multiple NTEs for each
  426. // interface, but there is exactly one interface per NTE.
  427. //
  428. struct Interface { // a.k.a. IF
  429. NetTableEntryOrInterface; // For NTEorIF. Points to self.
  430. Interface *Next; // Next interface on chain.
  431. long RefCnt; // Reference count - interlocked.
  432. //
  433. // Interface to the link layer. The functions all take
  434. // the LinkContext as their first argument. See comments
  435. // in llip6if.h.
  436. //
  437. void *LinkContext; // Link layer context.
  438. void (*CreateToken)(void *Context, IPv6Addr *Address);
  439. const void *(*ReadLLOpt)(void *Context, const uchar *OptionData);
  440. void (*WriteLLOpt)(void *Context, uchar *OptionData,
  441. const void *LinkAddress);
  442. ushort (*ConvertAddr)(void *Context,
  443. const IPv6Addr *Address, void *LinkAddress);
  444. NTSTATUS (*SetRouterLLAddress)(void *Context, const void *TokenLinkAddress,
  445. const void *RouterLinkAddress);
  446. void (*Transmit)(void *Context, PNDIS_PACKET Packet,
  447. uint Offset, const void *LinkAddress);
  448. NDIS_STATUS (*SetMCastAddrList)(void *Context, const void *LinkAddresses,
  449. uint NumKeep, uint NumAdd, uint NumDel);
  450. void (*Close)(void *Context);
  451. void (*Cleanup)(void *Context);
  452. uint Index; // Node unique index of this I/F.
  453. uint Type; // Values in ntddip6.h.
  454. uint Flags; // Changes require lock, reads don't.
  455. uint DefaultPreference; // Read-only.
  456. uint Preference; // For routing.
  457. //
  458. // ZoneIndices[0] (ADE_SMALLEST_SCOPE) and
  459. // ZoneIndices[1] (ADE_INTERFACE_LOCAL) must be Index.
  460. // ZoneIndices[14] (ADE_GLOBAL) and
  461. // ZoneIndices[15] (ADE_LARGEST_SCOPE) must be one.
  462. // ZoneIndices must respect zone containment:
  463. // If two interfaces have the same value for ZoneIndices[N],
  464. // then they must have the same value for ZoneIndices[N+1].
  465. // To ensure consistency, modifying ZoneIndices requires
  466. // the global ZoneUpdateLock.
  467. //
  468. uint ZoneIndices[ADE_NUM_SCOPES]; // Changes require lock, reads don't.
  469. AddressEntry *ADE; // List of ADEs on this I/F.
  470. NetTableEntry *LinkLocalNTE; // Primary link-local address.
  471. KSPIN_LOCK LockNC; // Neighbor cache lock.
  472. NeighborCacheEntry *FirstNCE; // List of active neighbors on I/F.
  473. NeighborCacheEntry *LastNCE; // Last NCE in the list.
  474. uint NCENumUnused; // Number of unused NCEs - interlocked.
  475. NDIS_PACKET *PacketList; // List of packets to be completed.
  476. uint TrueLinkMTU; // Read-only, true maximum MTU.
  477. uint DefaultLinkMTU; // Read-only, default for LinkMTU.
  478. uint LinkMTU; // Manually configured or received from RAs.
  479. uint CurHopLimit; // Default Hop Limit for unicast.
  480. uint BaseReachableTime; // Base for random ReachableTime (in ms).
  481. uint ReachableTime; // Reachable timeout (in IPv6Timer ticks).
  482. uint RetransTimer; // NS timeout (in IPv6Timer ticks).
  483. uint DefaultDupAddrDetectTransmits; // Read-only.
  484. uint DupAddrDetectTransmits; // Number of solicits during DAD.
  485. uint DupAddrDetects; // Number of consecutive DAD detects.
  486. uint DefSitePrefixLength; // Default Site Prefix Length for RAs.
  487. uint TempStateAge; // Age of the temporary state.
  488. IPv6Addr TempState; // State for generating temporary addresses.
  489. uint RSCount; // Number of Router Solicits sent.
  490. uint RSTimer; // RS timeout (in IPv6Timer ticks).
  491. uint RACount; // Number of "fast" RAs left to send.
  492. uint RATimer; // RA timeout (in IPv6Timer ticks).
  493. uint RALast; // Time of last RA (in IPv6Timer ticks).
  494. uint LinkAddressLength; // Length of I/F link-level address.
  495. uchar *LinkAddress; // Pointer to link-level address.
  496. uint LinkHeaderSize; // Length of link-level header.
  497. KSPIN_LOCK Lock; // Main interface lock.
  498. KMUTEX WorkerLock; // Serializes worker thread operations.
  499. LinkLayerMulticastAddress *MCastAddresses; // Current addresses.
  500. uint MCastAddrNum; // Number of link-layer mcast addresses.
  501. uint TcpInitialRTT; // InitialRTT that TCP connections should use
  502. // on this interface.
  503. HANDLE TdiRegistrationHandle; // Opaque token for TDI De/notification.
  504. GUID Guid;
  505. NDIS_STRING DeviceName; // IPV6_EXPORT_STRING_PREFIX + string Guid.
  506. };
  507. __inline NeighborCacheEntry *
  508. SentinelNCE(Interface *IF)
  509. {
  510. return (NeighborCacheEntry *) &IF->FirstNCE;
  511. }
  512. __inline uint
  513. SizeofLinkLayerMulticastAddress(Interface *IF)
  514. {
  515. uint RawSize = (sizeof(struct LinkLayerMulticastAddress) +
  516. IF->LinkAddressLength);
  517. uint Align = __builtin_alignof(struct LinkLayerMulticastAddress) - 1;
  518. return (RawSize + Align) &~ Align;
  519. }
  520. //
  521. // These values should agree with definitions also
  522. // found in llip6if.h and ntddip6.h.
  523. //
  524. #define IF_TYPE_LOOPBACK 0
  525. #define IF_TYPE_ETHERNET 1
  526. #define IF_TYPE_FDDI 2
  527. #define IF_TYPE_TUNNEL_AUTO 3
  528. #define IF_TYPE_TUNNEL_6OVER4 4
  529. #define IF_TYPE_TUNNEL_V6V4 5
  530. #define IF_TYPE_TUNNEL_6TO4 6
  531. #define IF_TYPE_TUNNEL_TEREDO 7
  532. #define IF_TYPE_MIPV6 8 // Holds a mobile node's home addresses.
  533. __inline int
  534. IsIPv4TunnelIF(Interface *IF)
  535. {
  536. return ((IF_TYPE_TUNNEL_AUTO <= IF->Type) &&
  537. (IF->Type <= IF_TYPE_TUNNEL_6TO4));
  538. }
  539. //
  540. // These values should agree with definitions also
  541. // found in llip6if.h and ntddip6.h.
  542. //
  543. #define IF_FLAG_PSEUDO 0x00000001
  544. #define IF_FLAG_P2P 0x00000002
  545. #define IF_FLAG_NEIGHBOR_DISCOVERS 0x00000004
  546. #define IF_FLAG_FORWARDS 0x00000008
  547. #define IF_FLAG_ADVERTISES 0x00000010
  548. #define IF_FLAG_MULTICAST 0x00000020
  549. #define IF_FLAG_ROUTER_DISCOVERS 0x00000040
  550. #define IF_FLAG_PERIODICMLD 0x00000080
  551. #define IF_FLAG_FIREWALL_ENABLED 0x00000100
  552. #define IF_FLAG_MEDIA_DISCONNECTED 0x00001000
  553. #define IF_FLAGS_DISCOVERS \
  554. (IF_FLAG_NEIGHBOR_DISCOVERS|IF_FLAG_ROUTER_DISCOVERS)
  555. #define IF_FLAGS_BINDINFO 0x0000ffff
  556. #define IF_FLAG_DISABLED 0x00010000
  557. #define IF_FLAG_MCAST_SYNC 0x00020000
  558. #define IF_FLAG_OTHER_STATEFUL_CONFIG 0x00040000
  559. //
  560. // The DISCONNECTED and RECONNECTED flags should not both be set.
  561. // RECONNECTED indicates that the host interface was recently reconnected;
  562. // it is cleared upon receiving a Router Advertisement.
  563. //
  564. #define IF_FLAG_MEDIA_RECONNECTED 0x00080000
  565. //
  566. // This function should be used after taking the interface lock
  567. // or interface list lock, to check if the interface is disabled.
  568. //
  569. __inline int
  570. IsDisabledIF(Interface *IF)
  571. {
  572. return IF->Flags & IF_FLAG_DISABLED;
  573. }
  574. //
  575. // Called with the interface lock held.
  576. //
  577. __inline int
  578. IsMCastSyncNeeded(Interface *IF)
  579. {
  580. return IF->Flags & IF_FLAG_MCAST_SYNC;
  581. }
  582. //
  583. // Active interfaces hold a reference to themselves.
  584. // NTEs hold a reference to their interface.
  585. // NCEs that have a non-zero ref count hold a reference.
  586. // MAEs and AAEs do not hold a reference for their NTE or IF.
  587. //
  588. __inline void
  589. AddRefIF(Interface *IF)
  590. {
  591. //
  592. // A stronger assertion would be !IsDisabledIF(IF),
  593. // which is mostly true, but that assertion would
  594. // imply that AddRefIF could be used only while
  595. // holding the interface list lock or the interface lock,
  596. // which is an undesirable restriction.
  597. //
  598. ASSERT(IF->RefCnt > 0);
  599. InterlockedIncrement(&IF->RefCnt);
  600. }
  601. __inline void
  602. ReleaseIF(Interface *IF)
  603. {
  604. InterlockedDecrement(&IF->RefCnt);
  605. }
  606. //
  607. // We have a periodic timer (IPv6Timer) that causes our IPv6Timeout
  608. // routine to be called IPv6_TICKS_SECOND times per second. Most of the
  609. // timers and timeouts in this implementation are driven off this routine.
  610. //
  611. // There is a trade-off here between timer granularity/resolution
  612. // and overhead. The resolution should be subsecond because
  613. // RETRANS_TIMER is only one second.
  614. //
  615. extern uint IPv6TickCount;
  616. #define IPv6_TICKS_SECOND 2 // Two ticks per second.
  617. #define IPv6_TIMEOUT (1000 / IPv6_TICKS_SECOND) // In milliseconds.
  618. #define IPv6TimerTicks(seconds) ((seconds) * IPv6_TICKS_SECOND)
  619. //
  620. // ConvertSecondsToTicks and ConvertTicksToSeconds
  621. // both leave the value INFINITE_LIFETIME unchanged.
  622. //
  623. extern uint
  624. ConvertSecondsToTicks(uint Seconds);
  625. extern uint
  626. ConvertTicksToSeconds(uint Ticks);
  627. //
  628. // ConvertMillisToTicks and ConvertTicksToMillis
  629. // do not have an infinite value.
  630. //
  631. extern uint
  632. ConvertMillisToTicks(uint Millis);
  633. __inline uint
  634. ConvertTicksToMillis(uint Ticks)
  635. {
  636. return Ticks * IPv6_TIMEOUT;
  637. }
  638. //
  639. // REVIEW: Hack to handle those few remaining places where we still need
  640. // REVIEW: to allocate space for a link-level header before we know the
  641. // REVIEW: outgoing inteface (and thus know how big said header will be).
  642. // REVIEW: When these places have all been fixed, we won't need this.
  643. //
  644. #define MAX_LINK_HEADER_SIZE 32
  645. //
  646. // Various constants from the IPv6 RFCs...
  647. //
  648. // REVIEW: Some of these should be per link-layer type.
  649. // REVIEW: Put them in the Interface structure?
  650. //
  651. #define MAX_INITIAL_RTR_ADVERT_INTERVAL IPv6TimerTicks(16)
  652. #define MAX_INITIAL_RTR_ADVERTISEMENTS 3 // Produces 4 quick RAs.
  653. #define MAX_FINAL_RTR_ADVERTISEMENTS 3
  654. #define MIN_DELAY_BETWEEN_RAS IPv6TimerTicks(3)
  655. #define MAX_RA_DELAY_TIME 1 // 0.5 seconds
  656. #define MaxRtrAdvInterval IPv6TimerTicks(600)
  657. #define MinRtrAdvInterval IPv6TimerTicks(200)
  658. // MAX_RTR_SOLICITATION_DELAY IPv6_TIMEOUT is used instead.
  659. #define RTR_SOLICITATION_INTERVAL IPv6TimerTicks(4) // 4 seconds.
  660. #define SLOW_RTR_SOLICITATION_INTERVAL IPv6TimerTicks(15 * 60) // 15 minutes.
  661. #define MAX_RTR_SOLICITATIONS 3
  662. #define MAX_MULTICAST_SOLICIT 3 // Total transmissions before giving up.
  663. #define MAX_UNICAST_SOLICIT 3 // Total transmissions before giving up.
  664. #define MAX_UNREACH_SOLICIT 1 // Total transmissions before giving up.
  665. #define UNREACH_SOLICIT_INTERVAL IPv6TimerTicks(60) // 1 minute.
  666. #define MAX_ANYCAST_DELAY_TIME 1 // seconds.
  667. #define REACHABLE_TIME (30 * 1000) // 30 seconds in milliseconds.
  668. #define MAX_REACHABLE_TIME (60 * 60 * 1000) // 1 hour in milliseconds.
  669. #define ICMP_MIN_ERROR_INTERVAL 1 // Ticks - a half second.
  670. #define RETRANS_TIMER IPv6TimerTicks(1) // 1 second.
  671. #define DELAY_FIRST_PROBE_TIME IPv6TimerTicks(5) // 5 seconds.
  672. #define MIN_RANDOM_FACTOR 50 // Percentage of base value.
  673. #define MAX_RANDOM_FACTOR 150 // Percentage of base value.
  674. #define PREFIX_LIFETIME_SAFETY IPv6TimerTicks(2 * 60 * 60) // 2 hours.
  675. #define RECALC_REACHABLE_INTERVAL IPv6TimerTicks(3 * 60 * 60) // 3 hours.
  676. #define PATH_MTU_RETRY_TIME IPv6TimerTicks(10 * 60) // 10 minutes.
  677. #define MLD_UNSOLICITED_REPORT_INTERVAL IPv6TimerTicks(10) // 10 seconds.
  678. #define MLD_QUERY_INTERVAL IPv6TimerTicks(125) // 125 seconds.
  679. #define MLD_NUM_INITIAL_REPORTS 2
  680. #define MAX_TEMP_DAD_ATTEMPTS 5
  681. #define MAX_TEMP_PREFERRED_LIFETIME (24 * 60 * 60) // 1 day.
  682. #define MAX_TEMP_VALID_LIFETIME (7 * MAX_TEMP_PREFERRED_LIFETIME)
  683. #define TEMP_REGENERATE_TIME 5 // 5 seconds.
  684. #define MAX_TEMP_RANDOM_TIME (10 * 60) // 10 minutes.
  685. #define DEFAULT_CUR_HOP_LIMIT 0x80
  686. #define DEFAULT_SITE_PREFIX_LENGTH 48
  687. //
  688. // Various implementation constants.
  689. //
  690. #define NEIGHBOR_CACHE_LIMIT 256
  691. #define ROUTE_CACHE_LIMIT 32
  692. #define BINDING_CACHE_LIMIT 32
  693. #define SMALL_POOL 10000
  694. #define MEDIUM_POOL 30000
  695. #define LARGE_POOL 60000
  696. //
  697. // Under NT, we use the assembly language version of the common core checksum
  698. // routine instead of the C language version.
  699. //
  700. ULONG
  701. tcpxsum(IN ULONG Checksum, IN PUCHAR Source, IN ULONG Length);
  702. #define Cksum(Buffer, Length) ((ushort)tcpxsum(0, (PUCHAR)(Buffer), (Length)))
  703. //
  704. // Protocol Receive Procedures ("Next Header" handlers) have this prototype.
  705. //
  706. typedef uchar ProtoRecvProc(IPv6Packet *Packet);
  707. typedef struct StatusArg {
  708. IP_STATUS Status;
  709. unsigned long Arg;
  710. IPv6Header UNALIGNED *IP;
  711. } StatusArg;
  712. //
  713. // Protocol Control Receive Procedures have this prototype.
  714. // These receive handlers are called for ICMP errors.
  715. //
  716. typedef uchar ProtoControlRecvProc(IPv6Packet *Packet, StatusArg *Arg);
  717. typedef struct ProtocolSwitch {
  718. ProtoRecvProc *DataReceive;
  719. ProtoControlRecvProc *ControlReceive;
  720. } ProtocolSwitch;
  721. extern ProtoRecvProc IPv6HeaderReceive;
  722. extern ProtoRecvProc ICMPv6Receive;
  723. extern ProtoRecvProc FragmentReceive;
  724. extern ProtoRecvProc DestinationOptionsReceive;
  725. extern ProtoRecvProc RoutingReceive;
  726. extern ProtoRecvProc EncapsulatingSecurityPayloadReceive;
  727. extern ProtoRecvProc AuthenticationHeaderReceive;
  728. extern ProtoControlRecvProc ICMPv6ControlReceive;
  729. extern ProtoControlRecvProc ExtHdrControlReceive;
  730. //
  731. // Hop-by-Hop Options use a special receive handler.
  732. // This is because they are processed even when a
  733. // a packet is being forwarded instead of received.
  734. // Note that they are only processed when immediately
  735. // following an IPv6 header.
  736. //
  737. extern int
  738. HopByHopOptionsReceive(IPv6Packet *Packet);
  739. //
  740. // The Raw Receive handler supports external protocol handlers.
  741. //
  742. extern int RawReceive(IPv6Packet *Packet, uchar Protocol);
  743. //
  744. // The actual definition of a reassembly structure
  745. // can be found in fragment.h.
  746. //
  747. typedef struct Reassembly Reassembly;
  748. #define USE_TEMP_NO 0 // Don't use temporary addresses.
  749. #define USE_TEMP_YES 1 // Use them.
  750. #define USE_TEMP_ALWAYS 2 // Always generating random numbers.
  751. #define USE_TEMP_COUNTER 3 // Use them with per-interface counter.
  752. //
  753. // Prototypes for global variables.
  754. //
  755. extern uint DefaultCurHopLimit;
  756. extern uint MaxTempDADAttempts;
  757. extern uint MaxTempPreferredLifetime; // Ticks.
  758. extern uint MaxTempValidLifetime; // Ticks.
  759. extern uint TempRegenerateTime; // Ticks.
  760. extern uint UseTemporaryAddresses; // See values above.
  761. extern uint MaxTempRandomTime; // Ticks.
  762. extern uint TempRandomTime; // Ticks.
  763. extern ProtocolSwitch ProtocolSwitchTable[];
  764. extern KSPIN_LOCK NetTableListLock;
  765. extern NetTableEntry *NetTableList; // Pointer to the net table.
  766. extern KSPIN_LOCK IFListLock;
  767. extern Interface *IFList; // List of all interfaces on the system.
  768. extern KSPIN_LOCK ZoneUpdateLock;
  769. extern struct EchoControl *ICMPv6OutstandingEchos;
  770. extern LIST_ENTRY PendingEchoList; // def needed for initialization.
  771. extern Interface *LoopInterface;
  772. extern IPv6Addr UnspecifiedAddr;
  773. extern IPv6Addr LoopbackAddr;
  774. extern IPv6Addr AllNodesOnNodeAddr;
  775. extern IPv6Addr AllNodesOnLinkAddr;
  776. extern IPv6Addr AllRoutersOnLinkAddr;
  777. extern IPv6Addr LinkLocalPrefix;
  778. extern IPv6Addr SiteLocalPrefix;
  779. extern IPv6Addr SixToFourPrefix;
  780. extern IPv6Addr V4MappedPrefix;
  781. extern PDEVICE_OBJECT IPDeviceObject;
  782. extern HANDLE IPv6ProviderHandle;
  783. //
  784. // Some handy functions for working with IPv6 addresses.
  785. //
  786. __inline IPv6Addr *
  787. AlignAddr(IPv6Addr UNALIGNED *Addr)
  788. {
  789. //
  790. // IPv6 addresses only have char & short members,
  791. // so they need 2-byte alignment.
  792. // In practice addresses in headers are always
  793. // appropriately aligned.
  794. //
  795. ASSERT(((UINT_PTR)Addr % __builtin_alignof(IPv6Addr)) == 0);
  796. return (IPv6Addr *) Addr;
  797. }
  798. __inline int
  799. IsUnspecified(const IPv6Addr *Addr)
  800. {
  801. return IP6_ADDR_EQUAL(Addr, &UnspecifiedAddr);
  802. }
  803. __inline int
  804. IsLoopback(const IPv6Addr *Addr)
  805. {
  806. return IP6_ADDR_EQUAL(Addr, &LoopbackAddr);
  807. }
  808. __inline int
  809. IsGlobal(const IPv6Addr *Addr)
  810. {
  811. //
  812. // Check the format prefix and exclude addresses
  813. // whose high 4 bits are all zero or all one.
  814. // This is a cheap way of excluding v4-compatible,
  815. // v4-mapped, loopback, multicast, link-local, site-local.
  816. //
  817. uint High = (Addr->s6_bytes[0] & 0xf0);
  818. return (High != 0) && (High != 0xf0);
  819. }
  820. __inline int
  821. IsMulticast(const IPv6Addr *Addr)
  822. {
  823. return Addr->s6_bytes[0] == 0xff;
  824. }
  825. __inline int
  826. IsLinkLocal(const IPv6Addr *Addr)
  827. {
  828. return ((Addr->s6_bytes[0] == 0xfe) &&
  829. ((Addr->s6_bytes[1] & 0xc0) == 0x80));
  830. }
  831. __inline int
  832. IsLinkLocalMulticast(const IPv6Addr *Addr)
  833. {
  834. return IsMulticast(Addr) && ((Addr->s6_bytes[1] & 0xf) == ADE_LINK_LOCAL);
  835. }
  836. __inline int
  837. IsInterfaceLocalMulticast(const IPv6Addr *Addr)
  838. {
  839. return (IsMulticast(Addr) &&
  840. ((Addr->s6_bytes[1] & 0xf) == ADE_INTERFACE_LOCAL));
  841. }
  842. extern int
  843. IsSolicitedNodeMulticast(const IPv6Addr *Addr);
  844. __inline int
  845. IsSiteLocal(const IPv6Addr *Addr)
  846. {
  847. return ((Addr->s6_bytes[0] == 0xfe) &&
  848. ((Addr->s6_bytes[1] & 0xc0) == 0xc0));
  849. }
  850. __inline int
  851. IsSiteLocalMulticast(const IPv6Addr *Addr)
  852. {
  853. return IsMulticast(Addr) && ((Addr->s6_bytes[1] & 0xf) == ADE_SITE_LOCAL);
  854. }
  855. extern int
  856. IP6_ADDR_LTEQ(const IPv6Addr *A, const IPv6Addr *B);
  857. extern int
  858. IsEUI64Address(const IPv6Addr *Addr);
  859. extern int
  860. IsKnownAnycast(const IPv6Addr *Addr);
  861. extern int
  862. IsSubnetRouterAnycast(const IPv6Addr *Addr);
  863. extern int
  864. IsSubnetReservedAnycast(const IPv6Addr *Addr);
  865. extern int
  866. IsInvalidSourceAddress(const IPv6Addr *Addr);
  867. extern int
  868. IsNotManualAddress(const IPv6Addr *Addr);
  869. extern int
  870. IsV4Compatible(const IPv6Addr *Addr);
  871. extern void
  872. CreateV4Compatible(IPv6Addr *Addr, IPAddr V4Addr);
  873. extern int
  874. IsV4Mapped(const IPv6Addr *Addr);
  875. extern void
  876. CreateV4Mapped(IPv6Addr *Addr, IPAddr V4Addr);
  877. __inline IPAddr
  878. ExtractV4Address(const IPv6Addr *Addr)
  879. {
  880. return * (IPAddr UNALIGNED *) &Addr->s6_bytes[12];
  881. }
  882. __inline int
  883. Is6to4(const IPv6Addr *Addr)
  884. {
  885. return Addr->s6_words[0] == 0x0220;
  886. }
  887. __inline IPAddr
  888. Extract6to4Address(const IPv6Addr *Addr)
  889. {
  890. return * (IPAddr UNALIGNED *) &Addr->s6_bytes[2];
  891. }
  892. __inline int
  893. IsISATAP(const IPv6Addr *Addr)
  894. {
  895. return (((Addr->s6_words[4] & 0xFFFD) == 0x0000) &&
  896. (Addr->s6_words[5] == 0xfe5e));
  897. }
  898. __inline int
  899. IsV4Multicast(IPAddr Addr)
  900. {
  901. return (Addr & 0x000000f0) == 0x000000e0;
  902. }
  903. __inline int
  904. IsV4Broadcast(IPAddr Addr)
  905. {
  906. return Addr == 0xffffffff;
  907. }
  908. __inline int
  909. IsV4Loopback(IPAddr Addr)
  910. {
  911. return (Addr & 0x000000ff) == 0x0000007f;
  912. }
  913. __inline int
  914. IsV4Unspecified(IPAddr Addr)
  915. {
  916. return (Addr & 0x000000ff) == 0x00000000;
  917. }
  918. __inline ushort
  919. MulticastAddressScope(const IPv6Addr *Addr)
  920. {
  921. return Addr->s6_bytes[1] & 0xf;
  922. }
  923. extern ushort
  924. UnicastAddressScope(const IPv6Addr *Addr);
  925. extern ushort
  926. AddressScope(const IPv6Addr *Addr);
  927. extern ushort
  928. V4AddressScope(IPAddr Addr);
  929. extern uint
  930. DetermineScopeId(const IPv6Addr *Addr, Interface *IF);
  931. extern void
  932. CreateSolicitedNodeMulticastAddress(const IPv6Addr *Addr, IPv6Addr *MCastAddr);
  933. extern int
  934. HasPrefix(const IPv6Addr *Addr, const IPv6Addr *Prefix, uint PrefixLength);
  935. extern void
  936. CopyPrefix(IPv6Addr *Addr, const IPv6Addr *Prefix, uint PrefixLength);
  937. extern uint
  938. CommonPrefixLength(const IPv6Addr *Addr, const IPv6Addr *Addr2);
  939. extern int
  940. IntersectPrefix(const IPv6Addr *Prefix1, uint Prefix1Length,
  941. const IPv6Addr *Prefix2, uint Prefix2Length);
  942. //
  943. // Function prototypes.
  944. //
  945. extern int
  946. GetSystemRandomBits(uchar *Buffer, uint Length);
  947. extern void
  948. SeedRandom(const uchar *Seed, uint Length);
  949. extern uint
  950. Random(void);
  951. extern uint
  952. RandomNumber(uint Min, uint Max);
  953. //
  954. // Taken from ws2tcpip.h - unfortunately we can not include that file here.
  955. // These numbers include space for a port number, which we do not need,
  956. // but that's OK.
  957. //
  958. #define INET_ADDRSTRLEN 22
  959. #define INET6_ADDRSTRLEN 65
  960. __inline int
  961. ParseV6Address(const WCHAR *Sz, const WCHAR **Terminator, IPv6Addr *Addr)
  962. {
  963. return NT_SUCCESS(RtlIpv6StringToAddressW(Sz, Terminator, Addr));
  964. }
  965. __inline void
  966. FormatV6AddressWorker(char *Sz, const IPv6Addr *Addr)
  967. {
  968. (void) RtlIpv6AddressToStringA(Addr, Sz);
  969. }
  970. extern char *
  971. FormatV6Address(const IPv6Addr *Addr);
  972. __inline int
  973. ParseV4Address(const WCHAR *Sz, const WCHAR **Terminator, IPAddr *Addr)
  974. {
  975. return NT_SUCCESS(RtlIpv4StringToAddressW(Sz, TRUE, Terminator, (struct in_addr *)Addr));
  976. }
  977. __inline void
  978. FormatV4AddressWorker(char *Sz, IPAddr Addr)
  979. {
  980. (void) RtlIpv4AddressToStringA((struct in_addr *)&Addr, Sz);
  981. }
  982. extern char *
  983. FormatV4Address(IPAddr Addr);
  984. extern ushort
  985. ChecksumPacket(PNDIS_PACKET Packet, uint Offset, uchar *Data, uint Length,
  986. const IPv6Addr *Source, const IPv6Addr *Dest, uchar NextHeader);
  987. extern void
  988. LoopQueueTransmit(PNDIS_PACKET Packet);
  989. extern NDIS_STATUS
  990. IPv6SendLater(LARGE_INTEGER Time,
  991. Interface *IF, PNDIS_PACKET Packet,
  992. uint Offset, const void *LinkAddress);
  993. extern void
  994. IPv6SendLL(Interface *IF, PNDIS_PACKET Packet,
  995. uint Offset, const void *LinkAddress);
  996. extern void
  997. IPv6SendND(PNDIS_PACKET Packet, uint Offset, NeighborCacheEntry *NCE,
  998. const IPv6Addr *DiscoveryAddress);
  999. #define SEND_FLAG_BYPASS_BINDING_CACHE 0x00000001
  1000. extern void
  1001. IPv6Send(PNDIS_PACKET Packet, uint Offset, IPv6Header UNALIGNED *IP,
  1002. uint PayloadLength, RouteCacheEntry *RCE, uint Flags,
  1003. ushort TransportProtocol, ushort SourcePort, ushort DestPort);
  1004. extern void
  1005. IPv6Forward(NetTableEntryOrInterface *RecvNTEorIF,
  1006. PNDIS_PACKET Packet, uint Offset, IPv6Header UNALIGNED *IP,
  1007. uint PayloadLength, int Redirect, IPSecProc *IPSecToDo,
  1008. RouteCacheEntry *RCE);
  1009. extern void
  1010. IPv6SendAbort(NetTableEntryOrInterface *NTEorIF,
  1011. PNDIS_PACKET Packet, uint Offset,
  1012. uchar ICMPType, uchar ICMPCode, ulong ErrorParameter,
  1013. int MulticastOverride);
  1014. extern void
  1015. ICMPv6EchoTimeout(void);
  1016. extern void
  1017. IPULUnloadNotify(void);
  1018. extern Interface *
  1019. FindInterfaceFromIndex(uint Index);
  1020. extern Interface *
  1021. FindInterfaceFromGuid(const GUID *Guid);
  1022. extern Interface *
  1023. FindNextInterface(Interface *IF);
  1024. extern Interface *
  1025. FindInterfaceFromZone(Interface *OrigIF, uint Scope, uint Index);
  1026. extern uint
  1027. FindNewZoneIndex(uint Scope);
  1028. extern void
  1029. InitZoneIndices(uint *ZoneIndices, uint Index);
  1030. extern void
  1031. UpdateZoneIndices(Interface *IF, uint *ZoneIndices);
  1032. extern Interface *
  1033. FindDefaultInterfaceForZone(uint Scope, uint ScopeId);
  1034. extern void
  1035. IPv6Timeout(PKDPC MyDpcObject, void *Context, void *Unused1, void *Unused2);
  1036. extern int
  1037. MapNdisBuffers(NDIS_BUFFER *Buffer);
  1038. extern uchar *
  1039. GetDataFromNdis(PNDIS_BUFFER SrcBuffer, uint SrcOffset, uint Length,
  1040. uchar *DataBuffer);
  1041. extern IPv6Header UNALIGNED *
  1042. GetIPv6Header(PNDIS_PACKET Packet, uint Offset, IPv6Header *HdrBuffer);
  1043. extern int
  1044. CheckLinkLayerMulticastAddress(Interface *IF, const void *LinkAddress);
  1045. extern void
  1046. AddNTEToInterface(Interface *IF, NetTableEntry *NTE);
  1047. extern uint
  1048. InterfaceIndex(void);
  1049. extern void
  1050. AddInterface(Interface *IF);
  1051. extern void
  1052. UpdateLinkMTU(Interface *IF, uint MTU);
  1053. extern NetTableEntry *
  1054. CreateNTE(Interface *IF, const IPv6Addr *Address,
  1055. uint AddrConf,
  1056. uint ValidLifetime, uint PreferredLifetime);
  1057. extern MulticastAddressEntry *
  1058. FindOrCreateMAE(Interface *IF, const IPv6Addr *Addr, NetTableEntry *NTE);
  1059. extern MulticastAddressEntry *
  1060. FindAndReleaseMAE(Interface *IF, const IPv6Addr *Addr);
  1061. extern int
  1062. FindOrCreateAAE(Interface *IF, const IPv6Addr *Addr,
  1063. NetTableEntryOrInterface *NTEorIF);
  1064. extern int
  1065. FindAndDeleteAAE(Interface *IF, const IPv6Addr *Addr);
  1066. extern void
  1067. DestroyADEs(Interface *IF, NetTableEntry *NTE);
  1068. extern void
  1069. DestroyNTE(Interface *IF, NetTableEntry *NTE);
  1070. extern void
  1071. EnlivenNTE(Interface *IF, NetTableEntry *NTE);
  1072. extern void
  1073. DestroyIF(Interface *IF);
  1074. extern AddressEntry **
  1075. FindADE(Interface *IF, const IPv6Addr *Addr);
  1076. extern NetTableEntryOrInterface *
  1077. FindAddressOnInterface(Interface *IF, const IPv6Addr *Addr, ushort *AddrType);
  1078. extern NetTableEntry *
  1079. GetLinkLocalNTE(Interface *IF);
  1080. extern int
  1081. GetLinkLocalAddress(Interface *IF, IPv6Addr *Addr);
  1082. extern void
  1083. DeferRegisterNetAddress(NetTableEntry *NTE);
  1084. extern void
  1085. DeferSynchronizeMulticastAddresses(Interface *IF);
  1086. extern int
  1087. IPInit(void);
  1088. extern int Unloading;
  1089. extern void
  1090. IPUnload(void);
  1091. extern void
  1092. AddrConfUpdate(Interface *IF, const IPv6Addr *Prefix,
  1093. uint ValidLifetime, uint PreferredLifetime,
  1094. int Authenticated, NetTableEntry **pNTE);
  1095. extern int
  1096. FindOrCreateNTE(Interface *IF, const IPv6Addr *Addr,
  1097. uint AddrConf,
  1098. uint ValidLifetime, uint PreferredLifetime);
  1099. extern void
  1100. AddrConfDuplicate(Interface *IF, NetTableEntry *NTE);
  1101. extern void
  1102. AddrConfNotDuplicate(Interface *IF, NetTableEntry *NTE);
  1103. extern void
  1104. AddrConfResetAutoConfig(Interface *IF, uint MaxLifetime);
  1105. extern void
  1106. AddrConfTimeout(NetTableEntry *NTE);
  1107. extern void
  1108. NetTableTimeout(void);
  1109. extern void
  1110. NetTableCleanup(void);
  1111. extern void
  1112. InterfaceTimeout(void);
  1113. extern void
  1114. InterfaceCleanup(void);
  1115. extern void
  1116. InterfaceReset(void);
  1117. extern NTSTATUS
  1118. UpdateInterface(Interface *IF, int Advertises, int Forwards);
  1119. extern void
  1120. ReconnectInterface(Interface *IF);
  1121. extern void
  1122. InterfaceResetAutoConfig(Interface *IF);
  1123. extern int
  1124. LanInit(void);
  1125. extern void
  1126. LanUnload(void);
  1127. extern int
  1128. LoopbackInit(void);
  1129. extern void
  1130. ProtoTabInit(void);
  1131. extern void
  1132. ICMPv6Init(void);
  1133. extern int
  1134. IPSecInit(void);
  1135. extern void
  1136. IPSecUnload(void);
  1137. extern int
  1138. TunnelInit(void);
  1139. extern void
  1140. TunnelUnload(void);
  1141. extern NTSTATUS
  1142. TunnelCreateTunnel(IPAddr SrcAddr, IPAddr DstAddr,
  1143. uint Flags, Interface **ReturnIF);
  1144. extern int
  1145. TunnelGetSourceAddress(IPAddr Dest, IPAddr *Source);
  1146. extern ulong
  1147. NewFragmentId(void);
  1148. extern void
  1149. ReassemblyInit(void);
  1150. extern void
  1151. ReassemblyUnload(void);
  1152. extern void
  1153. ReassemblyRemove(Interface *IF);
  1154. extern void
  1155. CreateGUIDFromName(const char *Name, GUID *Guid);
  1156. extern void
  1157. ConfigureGlobalParameters(void);
  1158. extern void
  1159. ConfigureInterface(Interface *IF);
  1160. extern void
  1161. ConfigurePrefixPolicies(void);
  1162. extern void
  1163. ConfigurePersistentInterfaces(void);
  1164. #pragma warning(pop)
  1165. #endif // IPv6DEF_INCLUDED