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

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