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.

1093 lines
37 KiB

  1. // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil -*- (for GNU Emacs)
  2. //
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  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. // This header file defines constants and types for accessing
  14. // the MSR IPv6 driver via ioctls.
  15. //
  16. #ifndef _NTDDIP6_
  17. #define _NTDDIP6_
  18. #include <ipexport.h>
  19. //
  20. // We need a definition of CTL_CODE for use below.
  21. // When compiling kernel components in the DDK environment,
  22. // ntddk.h supplies this definition. Otherwise get it
  23. // from devioctl.h in the SDK environment.
  24. //
  25. #ifndef CTL_CODE
  26. #include <devioctl.h>
  27. #endif
  28. #pragma warning(push)
  29. #pragma warning(disable:4201) // nameless struct/union
  30. //
  31. // We also need a definition of TDI_ADDRESS_IP6.
  32. // In the DDK environment, tdi.h supplies this.
  33. // We provide a definition here for the SDK environment.
  34. //
  35. #ifndef TDI_ADDRESS_LENGTH_IP6
  36. #include <packon.h>
  37. typedef struct _TDI_ADDRESS_IP6 {
  38. USHORT sin6_port;
  39. ULONG sin6_flowinfo;
  40. USHORT sin6_addr[8];
  41. ULONG sin6_scope_id;
  42. } TDI_ADDRESS_IP6, *PTDI_ADDRESS_IP6;
  43. #include <packoff.h>
  44. #define TDI_ADDRESS_LENGTH_IP6 sizeof (TDI_ADDRESS_IP6)
  45. #endif
  46. //
  47. // This is the key name of the TCP/IPv6 protocol stack in the registry.
  48. // The protocol driver and the winsock helper both use it.
  49. //
  50. #define TCPIPV6_NAME L"Tcpip6"
  51. //
  52. // Device Name - this string is the name of the device. It is the name
  53. // that should be passed to NtCreateFile when accessing the device.
  54. //
  55. #define DD_TCPV6_DEVICE_NAME L"\\Device\\Tcp6"
  56. #define DD_UDPV6_DEVICE_NAME L"\\Device\\Udp6"
  57. #define DD_RAW_IPV6_DEVICE_NAME L"\\Device\\RawIp6"
  58. #define DD_IPV6_DEVICE_NAME L"\\Device\\Ip6"
  59. //
  60. // The Windows-accessible device name. It is the name that
  61. // (prepended with "\\\\.\\") should be passed to CreateFile.
  62. //
  63. #define WIN_IPV6_BASE_DEVICE_NAME L"Ip6"
  64. #define WIN_IPV6_DEVICE_NAME L"\\\\.\\" WIN_IPV6_BASE_DEVICE_NAME
  65. //
  66. // When an interface is bound, we are passed a name beginning with
  67. // IPV6_BIND_STRING_PREFIX. However, we register our interfaces with
  68. // TDI using names beginning with IPV6_EXPORT_STRING_PREFIX.
  69. //
  70. #define IPV6_BIND_STRING_PREFIX L"\\DEVICE\\"
  71. #define IPV6_EXPORT_STRING_PREFIX L"\\DEVICE\\TCPIP6_"
  72. //
  73. // For buffer sizing convenience, bound the link-layer address size.
  74. //
  75. #define MAX_LINK_LAYER_ADDRESS_LENGTH 64
  76. //
  77. // IPv6 IOCTL code definitions.
  78. //
  79. // The codes that use FILE_ANY_ACCESS are open to all users.
  80. // The codes that use FILE_WRITE_ACCESS require local Administrator privs.
  81. //
  82. #define FSCTL_IPV6_BASE FILE_DEVICE_NETWORK
  83. #define _IPV6_CTL_CODE(function, method, access) \
  84. CTL_CODE(FSCTL_IPV6_BASE, function, method, access)
  85. //
  86. // This IOCTL is used to send an ICMPv6 Echo request.
  87. // It returns the reply (unless there was a timeout or TTL expired).
  88. //
  89. #define IOCTL_ICMPV6_ECHO_REQUEST \
  90. _IPV6_CTL_CODE(0, METHOD_BUFFERED, FILE_ANY_ACCESS)
  91. typedef struct icmpv6_echo_request {
  92. TDI_ADDRESS_IP6 DstAddress; // Destination address.
  93. TDI_ADDRESS_IP6 SrcAddress; // Source address.
  94. unsigned int Timeout; // Request timeout in milliseconds.
  95. unsigned char TTL; // TTL or Hop Count.
  96. unsigned int Flags;
  97. // Request data follows this structure in memory.
  98. } ICMPV6_ECHO_REQUEST, *PICMPV6_ECHO_REQUEST;
  99. #define ICMPV6_ECHO_REQUEST_FLAG_REVERSE 0x1 // Use routing header.
  100. typedef struct icmpv6_echo_reply {
  101. TDI_ADDRESS_IP6 Address; // Replying address.
  102. IP_STATUS Status; // Reply IP_STATUS.
  103. unsigned int RoundTripTime; // RTT in milliseconds.
  104. // Reply data follows this structure in memory.
  105. } ICMPV6_ECHO_REPLY, *PICMPV6_ECHO_REPLY;
  106. //
  107. // This IOCTL retrieves information about an interface,
  108. // given an interface index or guid.
  109. // It takes as input an IPV6_QUERY_INTERFACE structure
  110. // and returns as output an IPV6_INFO_INTERFACE structure.
  111. // To perform an iteration, start with Index set to -1, in which case
  112. // only an IPV6_QUERY_INTERFACE is returned, for the first interface.
  113. // If there are no more interfaces, then the Index in the returned
  114. // IPV6_QUERY_INTERFACE will be -1.
  115. //
  116. #define IOCTL_IPV6_QUERY_INTERFACE \
  117. _IPV6_CTL_CODE(1, METHOD_BUFFERED, FILE_ANY_ACCESS)
  118. typedef struct ipv6_query_interface {
  119. unsigned int Index; // -1 means start/finish iteration,
  120. // 0 means use the Guid.
  121. GUID Guid;
  122. } IPV6_QUERY_INTERFACE;
  123. //
  124. // This IOCTL retrieves persisted information about an interface,
  125. // given a registry index or guid.
  126. // It takes as input an IPV6_PERSISTENT_QUERY_INTERFACE structure
  127. // and returns as output an IPV6_INFO_INTERFACE structure.
  128. //
  129. #define IOCTL_IPV6_PERSISTENT_QUERY_INTERFACE \
  130. _IPV6_CTL_CODE(48, METHOD_BUFFERED, FILE_ANY_ACCESS)
  131. typedef struct ipv6_persistent_query_interface {
  132. unsigned int RegistryIndex; // -1 means use the Guid.
  133. GUID Guid;
  134. } IPV6_PERSISTENT_QUERY_INTERFACE;
  135. typedef struct ipv6_info_interface {
  136. IPV6_QUERY_INTERFACE Next; // For non-persistent queries only.
  137. IPV6_QUERY_INTERFACE This;
  138. //
  139. // Length of this structure in bytes, not including
  140. // any link-layer addresses following in memory.
  141. //
  142. unsigned int Length;
  143. //
  144. // These fields are ignored for updates.
  145. //
  146. unsigned int LinkLayerAddressLength;
  147. unsigned int LocalLinkLayerAddress; // Offset, zero indicates absence.
  148. unsigned int RemoteLinkLayerAddress; // Offset, zero indicates absence.
  149. unsigned int Type; // Ignored for updates.
  150. int RouterDiscovers; // Ignored for updates.
  151. int NeighborDiscovers; // Ignored for updates.
  152. int PeriodicMLD; // Ignored for updates.
  153. int Advertises; // -1 means no change, else boolean.
  154. int Forwards; // -1 means no change, else boolean.
  155. unsigned int MediaStatus; // Ignored for updates.
  156. int OtherStatefulConfig; // Ignored for updates.
  157. unsigned int ZoneIndices[16]; // 0 means no change.
  158. unsigned int TrueLinkMTU; // Ignored for updates.
  159. unsigned int LinkMTU; // 0 means no change.
  160. unsigned int CurHopLimit; // -1 means no change.
  161. unsigned int BaseReachableTime; // Milliseconds, 0 means no change.
  162. unsigned int ReachableTime; // Milliseconds, ignored for updates.
  163. unsigned int RetransTimer; // Milliseconds, 0 means no change.
  164. unsigned int DupAddrDetectTransmits; // -1 means no change.
  165. unsigned int Preference; // -1 means no change.
  166. int FirewallEnabled; // -1 means no change, else boolean.
  167. unsigned int DefSitePrefixLength; // -1 means no change, 0 means none.
  168. // Link-layer addresses may follow.
  169. } IPV6_INFO_INTERFACE;
  170. //
  171. // These values should agree with definitions also
  172. // found in llip6if.h and ip6def.h.
  173. //
  174. #define IPV6_IF_TYPE_LOOPBACK 0
  175. #define IPV6_IF_TYPE_ETHERNET 1
  176. #define IPV6_IF_TYPE_FDDI 2
  177. #define IPV6_IF_TYPE_TUNNEL_AUTO 3
  178. #define IPV6_IF_TYPE_TUNNEL_6OVER4 4
  179. #define IPV6_IF_TYPE_TUNNEL_V6V4 5
  180. #define IPV6_IF_TYPE_TUNNEL_6TO4 6
  181. #define IPV6_IF_TYPE_TUNNEL_TEREDO 7
  182. #define IPV6_IF_TYPE_MIPV6 8
  183. #define IPV6_IF_MEDIA_STATUS_DISCONNECTED 0
  184. #define IPV6_IF_MEDIA_STATUS_RECONNECTED 1
  185. #define IPV6_IF_MEDIA_STATUS_CONNECTED 2
  186. //
  187. // Initialize the fields of the IPV6_INFO_INTERFACE structure
  188. // to values that indicate no change.
  189. //
  190. __inline void
  191. IPV6_INIT_INFO_INTERFACE(IPV6_INFO_INTERFACE *Info)
  192. {
  193. memset(Info, 0, sizeof *Info);
  194. Info->Length = sizeof *Info;
  195. Info->Type = (unsigned int)-1;
  196. Info->RouterDiscovers = -1;
  197. Info->NeighborDiscovers = -1;
  198. Info->PeriodicMLD = -1;
  199. Info->Advertises = -1;
  200. Info->Forwards = -1;
  201. Info->MediaStatus = (unsigned int)-1;
  202. Info->CurHopLimit = (unsigned int)-1;
  203. Info->DupAddrDetectTransmits = (unsigned int)-1;
  204. Info->Preference = (unsigned int)-1;
  205. Info->FirewallEnabled = -1;
  206. Info->DefSitePrefixLength = (unsigned int)-1;
  207. }
  208. //
  209. // This IOCTL retrieves information about an address
  210. // on an interface.
  211. //
  212. #define IOCTL_IPV6_QUERY_ADDRESS \
  213. _IPV6_CTL_CODE(2, METHOD_BUFFERED, FILE_ANY_ACCESS)
  214. typedef struct ipv6_query_address {
  215. IPV6_QUERY_INTERFACE IF; // Fields that identify an interface.
  216. IPv6Addr Address;
  217. } IPV6_QUERY_ADDRESS;
  218. typedef struct ipv6_info_address {
  219. IPV6_QUERY_ADDRESS Next;
  220. IPV6_QUERY_ADDRESS This;
  221. unsigned int Type;
  222. unsigned int Scope;
  223. unsigned int ScopeId;
  224. union {
  225. struct { // If it's a unicast address.
  226. unsigned int DADState;
  227. unsigned int PrefixConf;
  228. unsigned int InterfaceIdConf;
  229. unsigned int ValidLifetime; // Seconds.
  230. unsigned int PreferredLifetime; // Seconds.
  231. };
  232. struct { // If it's a multicast address.
  233. unsigned int MCastRefCount;
  234. unsigned int MCastFlags;
  235. unsigned int MCastTimer; // Seconds.
  236. };
  237. };
  238. } IPV6_INFO_ADDRESS;
  239. //
  240. // Values for address Type.
  241. //
  242. #define ADE_UNICAST 0x00
  243. #define ADE_ANYCAST 0x01
  244. #define ADE_MULTICAST 0x02
  245. //
  246. // Values for address Scope.
  247. //
  248. #define ADE_SMALLEST_SCOPE 0x00
  249. #define ADE_INTERFACE_LOCAL 0x01
  250. #define ADE_LINK_LOCAL 0x02
  251. #define ADE_SUBNET_LOCAL 0x03
  252. #define ADE_ADMIN_LOCAL 0x04
  253. #define ADE_SITE_LOCAL 0x05
  254. #define ADE_ORG_LOCAL 0x08
  255. #define ADE_GLOBAL 0x0e
  256. #define ADE_LARGEST_SCOPE 0x0f
  257. #define ADE_NUM_SCOPES (ADE_LARGEST_SCOPE - ADE_SMALLEST_SCOPE + 1)
  258. //
  259. // Bit values for MCastFlags.
  260. //
  261. #define MAE_REPORTABLE 0x01
  262. #define MAE_LAST_REPORTER 0x02
  263. //
  264. // Values for PrefixConf.
  265. // These must match the IP_PREFIX_ORIGIN values in iptypes.h.
  266. //
  267. #define PREFIX_CONF_OTHER 0 // None of the ones below.
  268. #define PREFIX_CONF_MANUAL 1 // From a user or administrator.
  269. #define PREFIX_CONF_WELLKNOWN 2 // IANA-assigned.
  270. #define PREFIX_CONF_DHCP 3 // Configured via DHCP.
  271. #define PREFIX_CONF_RA 4 // From a Router Advertisement.
  272. //
  273. // Values for InterfaceIdConf.
  274. // These must match the IP_SUFFIX_ORIGIN values in iptypes.h.
  275. //
  276. #define IID_CONF_OTHER 0 // None of the ones below.
  277. #define IID_CONF_MANUAL 1 // From a user or administrator.
  278. #define IID_CONF_WELLKNOWN 2 // IANA-assigned.
  279. #define IID_CONF_DHCP 3 // Configured via DHCP.
  280. #define IID_CONF_LL_ADDRESS 4 // Derived from the link-layer address.
  281. #define IID_CONF_RANDOM 5 // Random, e.g. temporary address.
  282. //
  283. // Values for DADState.
  284. //
  285. // The low bit set indicates whether the state is valid.
  286. // Among valid states, bigger is better
  287. // for source address selection.
  288. //
  289. #define DAD_STATE_INVALID 0
  290. #define DAD_STATE_TENTATIVE 1
  291. #define DAD_STATE_DUPLICATE 2
  292. #define DAD_STATE_DEPRECATED 3
  293. #define DAD_STATE_PREFERRED 4
  294. //
  295. // We use this infinite lifetime value for prefix lifetimes,
  296. // router lifetimes, address lifetimes, etc.
  297. //
  298. #define INFINITE_LIFETIME 0xffffffff
  299. //
  300. // This IOCTL retrieves information about an address
  301. // that has been assigned persistently to an interface.
  302. // It takes the IPV6_PERSISTENT_QUERY_ADDRESS structure
  303. // and returns the IPV6_UPDATE_ADDRESS structure.
  304. //
  305. #define IOCTL_IPV6_PERSISTENT_QUERY_ADDRESS \
  306. _IPV6_CTL_CODE(47, METHOD_BUFFERED, FILE_ANY_ACCESS)
  307. typedef struct ipv6_persistent_query_address {
  308. IPV6_PERSISTENT_QUERY_INTERFACE IF;
  309. unsigned int RegistryIndex; // -1 means use the Address.
  310. IPv6Addr Address;
  311. } IPV6_PERSISTENT_QUERY_ADDRESS;
  312. //
  313. // This IOCTL retrieves information from the neighbor cache.
  314. //
  315. #define IOCTL_IPV6_QUERY_NEIGHBOR_CACHE \
  316. _IPV6_CTL_CODE(3, METHOD_BUFFERED, FILE_ANY_ACCESS)
  317. typedef struct ipv6_query_neighbor_cache {
  318. IPV6_QUERY_INTERFACE IF; // Fields that identify an interface.
  319. IPv6Addr Address;
  320. } IPV6_QUERY_NEIGHBOR_CACHE;
  321. typedef struct ipv6_info_neighbor_cache {
  322. IPV6_QUERY_NEIGHBOR_CACHE Query;
  323. unsigned int IsRouter; // Whether neighbor is a router.
  324. unsigned int IsUnreachable; // Whether neighbor is unreachable.
  325. unsigned int NDState; // Current state of entry.
  326. unsigned int ReachableTimer; // Reachable time remaining (in ms).
  327. unsigned int LinkLayerAddressLength;
  328. // Link-layer address follows.
  329. } IPV6_INFO_NEIGHBOR_CACHE;
  330. #define ND_STATE_INCOMPLETE 0
  331. #define ND_STATE_PROBE 1
  332. #define ND_STATE_DELAY 2
  333. #define ND_STATE_STALE 3
  334. #define ND_STATE_REACHABLE 4
  335. #define ND_STATE_PERMANENT 5
  336. //
  337. // This IOCTL retrieves information from the route cache.
  338. //
  339. #define IOCTL_IPV6_QUERY_ROUTE_CACHE \
  340. _IPV6_CTL_CODE(4, METHOD_BUFFERED, FILE_ANY_ACCESS)
  341. typedef struct ipv6_query_route_cache {
  342. IPV6_QUERY_INTERFACE IF; // Fields that identify an interface.
  343. IPv6Addr Address;
  344. } IPV6_QUERY_ROUTE_CACHE;
  345. typedef struct ipv6_info_route_cache {
  346. IPV6_QUERY_ROUTE_CACHE Query;
  347. unsigned int Type;
  348. unsigned int Flags;
  349. int Valid; // Boolean - FALSE means it is stale.
  350. IPv6Addr SourceAddress;
  351. IPv6Addr NextHopAddress;
  352. unsigned int NextHopInterface;
  353. unsigned int PathMTU;
  354. unsigned int PMTUProbeTimer; // Time until next PMTU probe (in ms).
  355. unsigned int ICMPLastError; // Time since last ICMP error sent (in ms).
  356. unsigned int BindingSeqNumber;
  357. unsigned int BindingLifetime; // Seconds.
  358. IPv6Addr CareOfAddress;
  359. } IPV6_INFO_ROUTE_CACHE;
  360. #define RCE_FLAG_CONSTRAINED_IF 0x1
  361. #define RCE_FLAG_CONSTRAINED_SCOPEID 0x2
  362. #define RCE_FLAG_CONSTRAINED 0x3
  363. #define RCE_TYPE_COMPUTED 1
  364. #define RCE_TYPE_REDIRECT 2
  365. #if 0 // obsolete
  366. //
  367. // This IOCTL retrieves information from the prefix list.
  368. //
  369. #define IOCTL_IPV6_QUERY_PREFIX_LIST \
  370. _IPV6_CTL_CODE(5, METHOD_BUFFERED, FILE_ANY_ACCESS)
  371. //
  372. // This IOCTL retrieves information from the default router list.
  373. //
  374. #define IOCTL_IPV6_QUERY_ROUTER_LIST \
  375. _IPV6_CTL_CODE(6, METHOD_BUFFERED, FILE_ANY_ACCESS)
  376. //
  377. // This IOCTL adds a multicast group to the desired interface.
  378. //
  379. #define IOCTL_IPV6_ADD_MEMBERSHIP \
  380. _IPV6_CTL_CODE(7, METHOD_BUFFERED, FILE_ANY_ACCESS)
  381. //
  382. // This IOCTL drops a multicast group.
  383. //
  384. #define IOCTL_IPV6_DROP_MEMBERSHIP \
  385. _IPV6_CTL_CODE(8, METHOD_BUFFERED, FILE_ANY_ACCESS)
  386. #endif
  387. //
  388. // This IOCTL adds an SP to the SP list.
  389. //
  390. #define IOCTL_IPV6_CREATE_SECURITY_POLICY \
  391. _IPV6_CTL_CODE(9, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  392. typedef struct ipv6_create_security_policy {
  393. unsigned long SPIndex; // Index of policy to create.
  394. unsigned int RemoteAddrField;
  395. unsigned int RemoteAddrSelector;
  396. IPv6Addr RemoteAddr; // Remote IP Address.
  397. IPv6Addr RemoteAddrData;
  398. unsigned int LocalAddrField; // Single, range, or wildcard.
  399. unsigned int LocalAddrSelector; // Packet or policy.
  400. IPv6Addr LocalAddr; // Start of range or single value.
  401. IPv6Addr LocalAddrData; // End of range.
  402. unsigned int TransportProtoSelector; // Packet or policy.
  403. unsigned short TransportProto;
  404. unsigned int RemotePortField; // Single, range, or wildcard.
  405. unsigned int RemotePortSelector; // Packet or policy.
  406. unsigned short RemotePort; // Start of range or single value.
  407. unsigned short RemotePortData; // End of range.
  408. unsigned int LocalPortField; // Single, range, or wildcard.
  409. unsigned int LocalPortSelector; // Packet or policy.
  410. unsigned short LocalPort; // Start of range or single value.
  411. unsigned short LocalPortData; // End of range.
  412. unsigned int IPSecProtocol;
  413. unsigned int IPSecMode;
  414. IPv6Addr RemoteSecurityGWAddr;
  415. unsigned int Direction;
  416. unsigned int IPSecAction;
  417. unsigned long SABundleIndex;
  418. unsigned int SPInterface;
  419. } IPV6_CREATE_SECURITY_POLICY;
  420. //
  421. // This IOCTL adds an SA to the SA list.
  422. //
  423. #define IOCTL_IPV6_CREATE_SECURITY_ASSOCIATION \
  424. _IPV6_CTL_CODE(10, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  425. typedef struct ipv6_create_security_association {
  426. unsigned long SAIndex;
  427. unsigned long SPI; // Security Parameter Index.
  428. IPv6Addr SADestAddr;
  429. IPv6Addr DestAddr;
  430. IPv6Addr SrcAddr;
  431. unsigned short TransportProto;
  432. unsigned short DestPort;
  433. unsigned short SrcPort;
  434. unsigned int Direction;
  435. unsigned long SecPolicyIndex;
  436. unsigned int AlgorithmId;
  437. unsigned int RawKeySize;
  438. } IPV6_CREATE_SECURITY_ASSOCIATION;
  439. //
  440. // This IOCTL gets all the SPs from the SP list.
  441. //
  442. #define IOCTL_IPV6_QUERY_SECURITY_POLICY_LIST \
  443. _IPV6_CTL_CODE(11, METHOD_BUFFERED, FILE_ANY_ACCESS)
  444. typedef struct ipv6_query_security_policy_list {
  445. unsigned int SPInterface;
  446. unsigned long Index;
  447. } IPV6_QUERY_SECURITY_POLICY_LIST;
  448. typedef struct ipv6_info_security_policy_list {
  449. IPV6_QUERY_SECURITY_POLICY_LIST Query;
  450. unsigned long SPIndex;
  451. unsigned long NextSPIndex;
  452. unsigned int RemoteAddrField;
  453. unsigned int RemoteAddrSelector;
  454. IPv6Addr RemoteAddr; // Remote IP Address.
  455. IPv6Addr RemoteAddrData;
  456. unsigned int LocalAddrField; // Single, range, or wildcard.
  457. unsigned int LocalAddrSelector; // Packet or policy.
  458. IPv6Addr LocalAddr; // Start of range or single value.
  459. IPv6Addr LocalAddrData; // End of range.
  460. unsigned int TransportProtoSelector; // Packet or policy.
  461. unsigned short TransportProto;
  462. unsigned int RemotePortField; // Single, range, or wildcard.
  463. unsigned int RemotePortSelector; // Packet or policy.
  464. unsigned short RemotePort; // Start of range or single value.
  465. unsigned short RemotePortData; // End of range.
  466. unsigned int LocalPortField; // Single, range, or wildcard.
  467. unsigned int LocalPortSelector; // Packet or policy.
  468. unsigned short LocalPort; // Start of range or single value.
  469. unsigned short LocalPortData; // End of range.
  470. unsigned int IPSecProtocol;
  471. unsigned int IPSecMode;
  472. IPv6Addr RemoteSecurityGWAddr;
  473. unsigned int Direction;
  474. unsigned int IPSecAction;
  475. unsigned long SABundleIndex;
  476. unsigned int SPInterface;
  477. } IPV6_INFO_SECURITY_POLICY_LIST;
  478. //
  479. // This IOCTL gets all the SAs from the SA list.
  480. //
  481. #define IOCTL_IPV6_QUERY_SECURITY_ASSOCIATION_LIST \
  482. _IPV6_CTL_CODE(12, METHOD_BUFFERED, FILE_ANY_ACCESS)
  483. typedef struct ipv6_query_security_association_list {
  484. unsigned long Index;
  485. } IPV6_QUERY_SECURITY_ASSOCIATION_LIST;
  486. typedef struct ipv6_info_security_association_list {
  487. IPV6_QUERY_SECURITY_ASSOCIATION_LIST Query;
  488. unsigned long SAIndex;
  489. unsigned long NextSAIndex;
  490. unsigned long SPI; // Security Parameter Index.
  491. IPv6Addr SADestAddr;
  492. IPv6Addr DestAddr;
  493. IPv6Addr SrcAddr;
  494. unsigned short TransportProto;
  495. unsigned short DestPort;
  496. unsigned short SrcPort;
  497. unsigned int Direction;
  498. unsigned long SecPolicyIndex;
  499. unsigned int AlgorithmId;
  500. } IPV6_INFO_SECURITY_ASSOCIATION_LIST;
  501. //
  502. // This IOCTL retrieves information from the route table.
  503. // It takes the IPV6_QUERY_ROUTE_TABLE structure
  504. // and returns the IPV6_INFO_ROUTE_TABLE structure.
  505. //
  506. //
  507. #define IOCTL_IPV6_QUERY_ROUTE_TABLE \
  508. _IPV6_CTL_CODE(13, METHOD_BUFFERED, FILE_ANY_ACCESS)
  509. typedef struct ipv6_query_route_table {
  510. IPv6Addr Prefix;
  511. unsigned int PrefixLength;
  512. IPV6_QUERY_NEIGHBOR_CACHE Neighbor;
  513. } IPV6_QUERY_ROUTE_TABLE;
  514. typedef struct ipv6_info_route_table {
  515. union {
  516. IPV6_QUERY_ROUTE_TABLE Next; // Non-persistent query results.
  517. IPV6_QUERY_ROUTE_TABLE This; // All other uses.
  518. };
  519. unsigned int SitePrefixLength;
  520. unsigned int ValidLifetime; // Seconds.
  521. unsigned int PreferredLifetime; // Seconds.
  522. unsigned int Preference; // Smaller is better. See below.
  523. unsigned int Type; // See values below.
  524. int Publish; // Boolean.
  525. int Immortal; // Boolean.
  526. } IPV6_INFO_ROUTE_TABLE;
  527. //
  528. // The Type field indicates where the route came from.
  529. // These are RFC 2465 ipv6RouteProtocol values.
  530. // Routing protocols are free to define new values.
  531. //
  532. #define RTE_TYPE_SYSTEM 2
  533. #define RTE_TYPE_MANUAL 3
  534. #define RTE_TYPE_AUTOCONF 4
  535. #define RTE_TYPE_RIP 5
  536. #define RTE_TYPE_OSPF 6
  537. #define RTE_TYPE_BGP 7
  538. #define RTE_TYPE_IDRP 8
  539. #define RTE_TYPE_IGRP 9
  540. //
  541. // Standard route preference values.
  542. // The value zero is reserved for administrative configuration.
  543. //
  544. #define ROUTE_PREF_LOW (16*16*16)
  545. #define ROUTE_PREF_MEDIUM (16*16)
  546. #define ROUTE_PREF_HIGH 16
  547. #define ROUTE_PREF_ON_LINK 8
  548. #define ROUTE_PREF_LOOPBACK 4
  549. #define ROUTE_PREF_HIGHEST 0
  550. //
  551. // This IOCTL retrieves information about a persistent route.
  552. // It takes the IPV6_PERSISTENT_QUERY_ROUTE_TABLE structure
  553. // and returns the IPV6_INFO_ROUTE_TABLE structure.
  554. //
  555. #define IOCTL_IPV6_PERSISTENT_QUERY_ROUTE_TABLE \
  556. _IPV6_CTL_CODE(46, METHOD_BUFFERED, FILE_ANY_ACCESS)
  557. typedef struct ipv6_persistent_query_route_table {
  558. IPV6_PERSISTENT_QUERY_INTERFACE IF;
  559. unsigned int RegistryIndex; // -1 means use the parameters below.
  560. IPv6Addr Neighbor;
  561. IPv6Addr Prefix;
  562. unsigned int PrefixLength;
  563. } IPV6_PERSISTENT_QUERY_ROUTE_TABLE;
  564. //
  565. // This IOCTL adds/removes a route in the route table.
  566. // It uses the IPV6_INFO_ROUTE_TABLE structure.
  567. //
  568. #define IOCTL_IPV6_UPDATE_ROUTE_TABLE \
  569. _IPV6_CTL_CODE(14, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  570. #define IOCTL_IPV6_PERSISTENT_UPDATE_ROUTE_TABLE \
  571. _IPV6_CTL_CODE(40, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  572. //
  573. // This IOCTL adds/removes an address on an interface.
  574. // It uses the IPV6_UPDATE_ADDRESS structure.
  575. //
  576. #define IOCTL_IPV6_UPDATE_ADDRESS \
  577. _IPV6_CTL_CODE(15, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  578. #define IOCTL_IPV6_PERSISTENT_UPDATE_ADDRESS \
  579. _IPV6_CTL_CODE(38, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  580. typedef struct ipv6_update_address {
  581. IPV6_QUERY_ADDRESS This;
  582. unsigned int Type; // Unicast or anycast.
  583. unsigned int PrefixConf;
  584. unsigned int InterfaceIdConf;
  585. unsigned int PreferredLifetime; // Seconds.
  586. unsigned int ValidLifetime; // Seconds.
  587. } IPV6_UPDATE_ADDRESS;
  588. //
  589. // This IOCTL retrieves information from the binding cache.
  590. //
  591. #define IOCTL_IPV6_QUERY_BINDING_CACHE \
  592. _IPV6_CTL_CODE(16, METHOD_BUFFERED, FILE_ANY_ACCESS)
  593. typedef struct ipv6_query_binding_cache {
  594. IPv6Addr HomeAddress;
  595. } IPV6_QUERY_BINDING_CACHE;
  596. typedef struct ipv6_info_binding_cache {
  597. IPV6_QUERY_BINDING_CACHE Query;
  598. IPv6Addr HomeAddress;
  599. IPv6Addr CareOfAddress;
  600. unsigned int BindingSeqNumber;
  601. unsigned int BindingLifetime; // Seconds.
  602. } IPV6_INFO_BINDING_CACHE;
  603. //
  604. // This IOCTL controls some attributes of an interface.
  605. // It uses the IPV6_INFO_INTERFACE structure.
  606. //
  607. #define IOCTL_IPV6_UPDATE_INTERFACE \
  608. _IPV6_CTL_CODE(17, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  609. #define IOCTL_IPV6_PERSISTENT_UPDATE_INTERFACE \
  610. _IPV6_CTL_CODE(36, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  611. //
  612. // This IOCTL flushes entries from the neighbor cache.
  613. // It uses the IPV6_QUERY_NEIGHBOR_CACHE structure.
  614. //
  615. #define IOCTL_IPV6_FLUSH_NEIGHBOR_CACHE \
  616. _IPV6_CTL_CODE(18, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  617. //
  618. // This IOCTL flushes entries from the route cache.
  619. // It uses the IPV6_QUERY_ROUTE_CACHE structure.
  620. //
  621. #define IOCTL_IPV6_FLUSH_ROUTE_CACHE \
  622. _IPV6_CTL_CODE(19, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  623. //
  624. // This IOCTL deletes SA entries from the SA list.
  625. // It uses the IPV6_QUERY_SECURITY_ASSOCIATION_LIST structure.
  626. //
  627. #define IOCTL_IPV6_DELETE_SECURITY_ASSOCIATION \
  628. _IPV6_CTL_CODE(20, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  629. //
  630. // This IOCTL deletes SP entries from the SP list.
  631. // It uses the IPV6_QUERY_SECURITY_POLICY_LIST structure.
  632. //
  633. #define IOCTL_IPV6_DELETE_SECURITY_POLICY \
  634. _IPV6_CTL_CODE(21, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  635. //
  636. // This IOCTL deletes an interface.
  637. // It uses the IPV6_QUERY_INTERFACE structure.
  638. //
  639. // The persistent variant, in addition to deleting the runtime interface,
  640. // also keeps the interface from being (re)created persistently.
  641. // However, it does NOT reset or delete any persistent attributes
  642. // of the interface. For example, suppose you have a persisent tunnel
  643. // interface with a persistent attribute, the interface metric.
  644. // If you delete the tunnel interface and reboot, the tunnel interface
  645. // will be recreated with the non-default interface metric.
  646. // If you persistently delete the tunnel interface and reboot,
  647. // the tunnel interface will not be created. But if you then create
  648. // the tunnel interface, it will get the non-default interface metric.
  649. // This is analogous to persistent attributes on removable ethernet interfaces.
  650. //
  651. #define IOCTL_IPV6_DELETE_INTERFACE \
  652. _IPV6_CTL_CODE(22, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  653. #define IOCTL_IPV6_PERSISTENT_DELETE_INTERFACE \
  654. _IPV6_CTL_CODE(44, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  655. #if 0 // obsolete
  656. //
  657. // This IOCTL sets the mobility security to either on or off.
  658. // When mobility security is turned on, Binding Cache Updates
  659. // must be protected via IPsec.
  660. //
  661. #define IOCTL_IPV6_SET_MOBILITY_SECURITY \
  662. _IPV6_CTL_CODE(23, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  663. typedef struct ipv6_set_mobility_security {
  664. unsigned int MobilitySecurity; // See MOBILITY_SECURITY values in ipsec.h.
  665. } IPV6_SET_MOBILITY_SECURITY;
  666. #endif
  667. //
  668. // This IOCTL sorts a list of destination addresses.
  669. // The returned list may contain fewer addresses.
  670. // It uses an array of TDI_ADDRESS_IP6 in/out.
  671. //
  672. #define IOCTL_IPV6_SORT_DEST_ADDRS \
  673. _IPV6_CTL_CODE(24, METHOD_BUFFERED, FILE_ANY_ACCESS)
  674. //
  675. // This IOCTL retrieves information from the site prefix table.
  676. //
  677. #define IOCTL_IPV6_QUERY_SITE_PREFIX \
  678. _IPV6_CTL_CODE(25, METHOD_BUFFERED, FILE_ANY_ACCESS)
  679. typedef struct ipv6_query_site_prefix {
  680. IPv6Addr Prefix;
  681. unsigned int PrefixLength;
  682. IPV6_QUERY_INTERFACE IF;
  683. } IPV6_QUERY_SITE_PREFIX;
  684. typedef struct ipv6_info_site_prefix {
  685. IPV6_QUERY_SITE_PREFIX Query;
  686. unsigned int ValidLifetime; // Seconds.
  687. } IPV6_INFO_SITE_PREFIX;
  688. //
  689. // This IOCTL adds/removes a prefix in the site prefix table.
  690. // It uses the IPV6_INFO_SITE_PREFIX structure.
  691. //
  692. // This ioctl is provided for testing purposes.
  693. // Administrative configuration of site prefixes should never
  694. // be required, because site prefixes are configured from
  695. // Router Advertisements on hosts and from the routing table
  696. // on routers. Hence there is no persistent version of this ioctl.
  697. //
  698. #define IOCTL_IPV6_UPDATE_SITE_PREFIX \
  699. _IPV6_CTL_CODE(26, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  700. //
  701. // This IOCTL create a new interface.
  702. // It uses the IPV6_INFO_INTERFACE structure,
  703. // with many fields ignored.
  704. //
  705. #define IOCTL_IPV6_CREATE_INTERFACE \
  706. _IPV6_CTL_CODE(27, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  707. #define IOCTL_IPV6_PERSISTENT_CREATE_INTERFACE \
  708. _IPV6_CTL_CODE(43, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  709. //
  710. // This IOCTL requests a routing change notification.
  711. // It uses the IPV6_RTCHANGE_NOTIFY_REQUEST (input) and
  712. // IPV6_INFO_ROUTE_TABLE (output) structures.
  713. //
  714. // A notification request completes when a route
  715. // that matches is added or deleted.
  716. // A route matches the requested prefix if the route
  717. // prefix and the request prefix intersect.
  718. // So the ::/0 request prefix matches all route updates.
  719. //
  720. #define IOCTL_IPV6_RTCHANGE_NOTIFY_REQUEST \
  721. _IPV6_CTL_CODE(28, METHOD_BUFFERED, FILE_ANY_ACCESS)
  722. typedef struct ipv6_rtchange_notify_request {
  723. unsigned int Flags;
  724. unsigned int PrefixLength;
  725. unsigned long ScopeId;
  726. IPv6Addr Prefix;
  727. } IPV6_RTCHANGE_NOTIFY_REQUEST;
  728. #define IPV6_RTCHANGE_NOTIFY_REQUEST_FLAG_SYNCHRONIZE 0x1
  729. // Only one wakeup per requestor per change.
  730. #define IPV6_RTCHANGE_NOTIFY_REQUEST_FLAG_SUPPRESS_MINE 0x2
  731. // Ignore route changes from this requestor.
  732. #if 0
  733. //
  734. // This IOCTL retrieves an interface index, given a device name.
  735. // It takes a PWSTR for input, and uses the IPV6_QUERY_INTERFACE structure
  736. // for output.
  737. //
  738. #define IOCTL_IPV6_QUERY_INTERFACE_INDEX \
  739. _IPV6_CTL_CODE(29, METHOD_BUFFERED, FILE_ANY_ACCESS)
  740. #endif
  741. //
  742. // This IOCTL queries global IPv6 parameters.
  743. // It uses the IPV6_GLOBAL_PARAMETERS structure.
  744. //
  745. // Note that changing these parameters typically does not affect
  746. // existing uses of them. For example changing DefaultCurHopLimit
  747. // will not affect the CurHopLimit of existing interfaces,
  748. // but it will affect the CurHopLimit of new interfaces.
  749. //
  750. #define IOCTL_IPV6_QUERY_GLOBAL_PARAMETERS \
  751. _IPV6_CTL_CODE(30, METHOD_BUFFERED, FILE_ANY_ACCESS)
  752. #define IOCTL_IPV6_PERSISTENT_QUERY_GLOBAL_PARAMETERS \
  753. _IPV6_CTL_CODE(49, METHOD_BUFFERED, FILE_ANY_ACCESS)
  754. typedef struct ipv6_global_parameters {
  755. unsigned int DefaultCurHopLimit; // -1 means no change.
  756. unsigned int UseTemporaryAddresses; // -1 means no change.
  757. unsigned int MaxTempDADAttempts; // -1 means no change.
  758. unsigned int MaxTempValidLifetime; // -1 means no change.
  759. unsigned int MaxTempPreferredLifetime; // -1 means no change.
  760. unsigned int TempRegenerateTime; // -1 means no change.
  761. unsigned int MaxTempRandomTime; // -1 means no change.
  762. unsigned int TempRandomTime; // -1 means no change.
  763. unsigned int NeighborCacheLimit; // -1 means no change.
  764. unsigned int RouteCacheLimit; // -1 means no change.
  765. unsigned int BindingCacheLimit; // -1 means no change.
  766. unsigned int ReassemblyLimit; // -1 means no change.
  767. int MobilitySecurity; // Boolean, -1 means no change.
  768. unsigned int MobileIPv6Mode; // -1 means no change.
  769. } IPV6_GLOBAL_PARAMETERS;
  770. #define USE_TEMP_NO 0 // Don't use temporary addresses.
  771. #define USE_TEMP_YES 1 // Use them.
  772. #define USE_TEMP_ALWAYS 2 // Always generating random numbers.
  773. #define USE_TEMP_COUNTER 3 // Use them with per-interface counter.
  774. //
  775. // Bits in the MobileIPv6Mode field.
  776. //
  777. #define MOBILE_CORRESPONDENT 0x01
  778. #define MOBILE_MOBILE_NODE 0x02
  779. #define MOBILE_HOME_AGENT 0x04
  780. //
  781. // Initialize the fields of the IPV6_GLOBAL_PARAMETERS structure
  782. // to values that indicate no change.
  783. //
  784. __inline void
  785. IPV6_INIT_GLOBAL_PARAMETERS(IPV6_GLOBAL_PARAMETERS *Params)
  786. {
  787. Params->DefaultCurHopLimit = (unsigned int) -1;
  788. Params->UseTemporaryAddresses = (unsigned int) -1;
  789. Params->MaxTempDADAttempts = (unsigned int) -1;
  790. Params->MaxTempValidLifetime = (unsigned int) -1;
  791. Params->MaxTempPreferredLifetime = (unsigned int) -1;
  792. Params->TempRegenerateTime = (unsigned int) -1;
  793. Params->MaxTempRandomTime = (unsigned int) -1;
  794. Params->TempRandomTime = (unsigned int) -1;
  795. Params->NeighborCacheLimit = (unsigned int) -1;
  796. Params->RouteCacheLimit = (unsigned int) -1;
  797. Params->BindingCacheLimit = (unsigned int) -1;
  798. Params->ReassemblyLimit = (unsigned int) -1;
  799. Params->MobilitySecurity = -1;
  800. Params->MobileIPv6Mode = (unsigned int) -1;
  801. }
  802. //
  803. // This IOCTL sets global IPv6 parameters.
  804. // It uses the IPV6_GLOBAL_PARAMETERS structure.
  805. //
  806. // Note that changing these parameters typically does not affect
  807. // existing uses of them. For example changing DefaultCurHopLimit
  808. // will not affect the CurHopLimit of existing interfaces,
  809. // but it will affect the CurHopLimit of new interfaces.
  810. //
  811. #define IOCTL_IPV6_UPDATE_GLOBAL_PARAMETERS \
  812. _IPV6_CTL_CODE(31, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  813. #define IOCTL_IPV6_PERSISTENT_UPDATE_GLOBAL_PARAMETERS \
  814. _IPV6_CTL_CODE(37, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  815. //
  816. // This IOCTL retrieves information from the prefix policy table.
  817. // It takes as input an IPV6_QUERY_PREFIX_POLICY structure
  818. // and returns as output an IPV6_INFO_PREFIX_POLICY structure.
  819. // To perform an iteration, start with PrefixLength set to -1, in which case
  820. // only an IPV6_QUERY_PREFIX_POLICY is returned, for the first policy.
  821. // If there are no more policies, then the PrefixLength in the returned
  822. // IPV6_QUERY_PREFIX_POLICY will be -1.
  823. //
  824. #define IOCTL_IPV6_QUERY_PREFIX_POLICY \
  825. _IPV6_CTL_CODE(32, METHOD_BUFFERED, FILE_ANY_ACCESS)
  826. typedef struct ipv6_query_prefix_policy {
  827. IPv6Addr Prefix;
  828. unsigned int PrefixLength;
  829. } IPV6_QUERY_PREFIX_POLICY;
  830. typedef struct ipv6_info_prefix_policy {
  831. IPV6_QUERY_PREFIX_POLICY Next; // For non-persistent queries only.
  832. IPV6_QUERY_PREFIX_POLICY This;
  833. unsigned int Precedence;
  834. unsigned int SrcLabel;
  835. unsigned int DstLabel;
  836. } IPV6_INFO_PREFIX_POLICY;
  837. //
  838. // This IOCTL retrieves information about persisted prefix policies.
  839. // It takes as input an IPV6_PERSISTENT_QUERY_PREFIX_POLICY structure
  840. // and returns as output an IPV6_INFO_PREFIX_POLICY structure.
  841. // (The Next field is not returned.)
  842. // To perform an iteration, start with index 0 and increment
  843. // until getting STATUS_NO_MORE_ENTRIES / ERROR_NO_MORE_ITEMS.
  844. //
  845. // An IOCTL to retrieve persisted prefix policies via prefix
  846. // (like IPV6_QUERY_PREFIX_POLICY) is conceivable but not supported.
  847. //
  848. #define IOCTL_IPV6_PERSISTENT_QUERY_PREFIX_POLICY \
  849. _IPV6_CTL_CODE(50, METHOD_BUFFERED, FILE_ANY_ACCESS)
  850. typedef struct ipv6_persistent_query_prefix_policy {
  851. unsigned int RegistryIndex;
  852. } IPV6_PERSISTENT_QUERY_PREFIX_POLICY;
  853. //
  854. // This IOCTL adds a prefix to the prefix policy table,
  855. // or updates an existing prefix policy.
  856. // It uses the IPV6_INFO_PREFIX_POLICY structure.
  857. // (The Next field is ignored.)
  858. //
  859. #define IOCTL_IPV6_UPDATE_PREFIX_POLICY \
  860. _IPV6_CTL_CODE(33, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  861. #define IOCTL_IPV6_PERSISTENT_UPDATE_PREFIX_POLICY \
  862. _IPV6_CTL_CODE(41, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  863. //
  864. // This IOCTL removes a prefix from the prefix policy table.
  865. // It uses the IPV6_QUERY_PREFIX_POLICY structure.
  866. //
  867. #define IOCTL_IPV6_DELETE_PREFIX_POLICY \
  868. _IPV6_CTL_CODE(34, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  869. #define IOCTL_IPV6_PERSISTENT_DELETE_PREFIX_POLICY \
  870. _IPV6_CTL_CODE(42, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  871. //
  872. // This IOCTL deletes all manual configuration.
  873. //
  874. #define IOCTL_IPV6_RESET \
  875. _IPV6_CTL_CODE(39, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  876. #define IOCTL_IPV6_PERSISTENT_RESET \
  877. _IPV6_CTL_CODE(45, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  878. //
  879. // This IOCTL sets the link-layer address of a default router
  880. // on a non-broadcast multi-access (NBMA) link, such as the ISATAP
  881. // link, where Router Solicitations, Router Advertistments, and
  882. // Redirects are desired.
  883. //
  884. // There is no persistent version of this ioctl because
  885. // 6to4svc always configures this information dynamically.
  886. //
  887. #define IOCTL_IPV6_UPDATE_ROUTER_LL_ADDRESS \
  888. _IPV6_CTL_CODE(35, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  889. typedef struct ipv6_update_router_ll_address {
  890. IPV6_QUERY_INTERFACE IF;
  891. // Following this structure in memory are:
  892. // Own link-layer address to use for EUI-64 creation.
  893. // Link-layer address of router.
  894. } IPV6_UPDATE_ROUTER_LL_ADDRESS;
  895. //
  896. // This IOCTL renews an interface, meaning that all
  897. // auto-configured state is thrown away and regenerated.
  898. // Same behavior as reconnecting the interface to a link.
  899. // It uses the IPV6_QUERY_INTERFACE structure.
  900. //
  901. #define IOCTL_IPV6_RENEW_INTERFACE \
  902. _IPV6_CTL_CODE(51, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  903. #pragma warning(pop)
  904. #endif // ifndef _NTDDIP6_