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.

1184 lines
33 KiB

  1. /*++
  2. Copyright (c) 1997, Microsoft Corporation
  3. Module Name:
  4. ipnat.h
  5. Abstract:
  6. Contains semi-public IOCTLS and data-structures related to
  7. the IP Network Address Translator.
  8. For kernel-mode load-balancing support, see the director-registration
  9. declarations below (IOCTL_IP_NAT_REGISTER_DIRECTOR).
  10. For kernel-mode data-stream editing support, see the editor-registration
  11. declarations below (IOCTL_IP_NAT_REGISTER_EDITOR).
  12. Author:
  13. Abolade Gbadegesin (t-abolag) 11-July-1997
  14. Revision History:
  15. --*/
  16. #ifndef _ROUTING_IP_NAT_H_
  17. #define _ROUTING_IP_NAT_H_
  18. #include <rtinfo.h> // for RTR_INFO_BLOCK_HEADER
  19. #include <ipinfoid.h> // for IP_GENERAL_INFO_BASE
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. //
  24. // MISCELLANEOUS DECLARATIONS
  25. //
  26. #define IP_NAT_VERSION 1
  27. #define IP_NAT_SERVICE_NAME "IPNAT"
  28. #define DD_IP_NAT_DEVICE_NAME L"\\Device\\IPNAT"
  29. //
  30. // IP header protocol-field constants
  31. //
  32. #define NAT_PROTOCOL_ICMP 0x01
  33. #define NAT_PROTOCOL_IGMP 0x02
  34. #define NAT_PROTOCOL_TCP 0x06
  35. #define NAT_PROTOCOL_UDP 0x11
  36. #define NAT_PROTOCOL_IP6IN4 0x29
  37. #define NAT_PROTOCOL_PPTP 0x2F
  38. #define NAT_PROTOCOL_IPSEC_ESP 0x32
  39. #define NAT_PROTOCOL_IPSEC_AH 0x33
  40. typedef enum {
  41. NatInboundDirection = 0,
  42. NatOutboundDirection,
  43. NatMaximumDirection
  44. } IP_NAT_DIRECTION, *PIP_NAT_DIRECTION;
  45. typedef enum {
  46. NatForwardPath = 0,
  47. NatReversePath,
  48. NatMaximumPath
  49. } IP_NAT_PATH, *PIP_NAT_PATH;
  50. typedef enum {
  51. NatCreateFailureDeleteReason = 0,
  52. NatCleanupSessionDeleteReason,
  53. NatCleanupDirectorDeleteReason,
  54. NatDissociateDirectorDeleteReason,
  55. NatMaximumDeleteReason
  56. } IP_NAT_DELETE_REASON, *PIP_NAT_DELETE_REASON;
  57. //
  58. // IOCTL DECLARATIONS
  59. //
  60. #define FSCTL_IP_NAT_BASE FILE_DEVICE_NETWORK
  61. #define _IP_NAT_CTL_CODE(function, method, access) \
  62. CTL_CODE(FSCTL_IP_NAT_BASE, function, method, access)
  63. //
  64. // NAT-supported IOCTL constant declarations
  65. //
  66. #define IOCTL_IP_NAT_SET_GLOBAL_INFO \
  67. _IP_NAT_CTL_CODE(0, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  68. #define IOCTL_IP_NAT_REQUEST_NOTIFICATION \
  69. _IP_NAT_CTL_CODE(1, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  70. #define IOCTL_IP_NAT_CREATE_INTERFACE \
  71. _IP_NAT_CTL_CODE(2, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  72. #define IOCTL_IP_NAT_DELETE_INTERFACE \
  73. _IP_NAT_CTL_CODE(3, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  74. // Unused: Functions 4-5
  75. #define IOCTL_IP_NAT_SET_INTERFACE_INFO \
  76. _IP_NAT_CTL_CODE(6, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  77. #define IOCTL_IP_NAT_GET_INTERFACE_INFO \
  78. _IP_NAT_CTL_CODE(7, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  79. #define IOCTL_IP_NAT_REGISTER_EDITOR \
  80. _IP_NAT_CTL_CODE(8, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  81. #define IOCTL_IP_NAT_GET_INTERFACE_STATISTICS \
  82. _IP_NAT_CTL_CODE(9, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  83. #define IOCTL_IP_NAT_GET_MAPPING_TABLE \
  84. _IP_NAT_CTL_CODE(10, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  85. #define IOCTL_IP_NAT_REGISTER_DIRECTOR \
  86. _IP_NAT_CTL_CODE(11, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  87. #define IOCTL_IP_NAT_CREATE_REDIRECT \
  88. _IP_NAT_CTL_CODE(12, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  89. #define IOCTL_IP_NAT_CANCEL_REDIRECT \
  90. _IP_NAT_CTL_CODE(13, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  91. #define IOCTL_IP_NAT_GET_INTERFACE_MAPPING_TABLE \
  92. _IP_NAT_CTL_CODE(14, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  93. #define IOCTL_IP_NAT_GET_REDIRECT_STATISTICS \
  94. _IP_NAT_CTL_CODE(15, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  95. #define IOCTL_IP_NAT_CREATE_DYNAMIC_TICKET \
  96. _IP_NAT_CTL_CODE(16, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  97. #define IOCTL_IP_NAT_DELETE_DYNAMIC_TICKET \
  98. _IP_NAT_CTL_CODE(17, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  99. #define IOCTL_IP_NAT_GET_REDIRECT_SOURCE_MAPPING \
  100. _IP_NAT_CTL_CODE(18, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  101. #define IOCTL_IP_NAT_GET_EDITOR_TABLE \
  102. _IP_NAT_CTL_CODE(19, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  103. #define IOCTL_IP_NAT_GET_DIRECTOR_TABLE \
  104. _IP_NAT_CTL_CODE(20, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  105. #define IOCTL_IP_NAT_GET_REDIRECT_DESTINATION_MAPPING \
  106. _IP_NAT_CTL_CODE(21, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  107. #define IOCTL_IP_NAT_LOOKUP_SESSION_MAPPING_KEY \
  108. _IP_NAT_CTL_CODE(22, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  109. #define IOCTL_IP_NAT_LOOKUP_SESSION_MAPPING_STATISTICS \
  110. _IP_NAT_CTL_CODE(23, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  111. #define IOCTL_IP_NAT_LOOKUP_SESSION_MAPPING_KEY_EX \
  112. _IP_NAT_CTL_CODE(24, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  113. #define IOCTL_IP_NAT_CREATE_REDIRECT_EX \
  114. _IP_NAT_CTL_CODE(25, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  115. #define IOCTL_IP_NAT_CREATE_TICKET \
  116. _IP_NAT_CTL_CODE(26, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  117. #define IOCTL_IP_NAT_DELETE_TICKET \
  118. _IP_NAT_CTL_CODE(27, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  119. #define IOCTL_IP_NAT_LOOKUP_TICKET \
  120. _IP_NAT_CTL_CODE(28, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  121. //
  122. // IOCTL_IP_NAT_SET_GLOBAL_INFO
  123. //
  124. // Invoked to supply the NAT with its configuration.
  125. //
  126. // InputBuffer: IP_NAT_GLOBAL_INFO
  127. // OutputBuffer: none.
  128. //
  129. //
  130. // IOCTL_IP_NAT_GET_GLOBAL_INFO
  131. //
  132. // Invoked to retrieve the NAT's configuration.
  133. //
  134. // InputBuffer: none.
  135. // OutputBuffer: IP_NAT_GLOBAL_INFO
  136. //
  137. //
  138. // IOCTL_IP_NAT_CREATE_INTERFACE
  139. //
  140. // Invoked to add router-interfaces to the NAT.
  141. //
  142. // InputBuffer: IP_NAT_CREATE_INTERFACE
  143. // OutputBuffer: none.
  144. //
  145. //
  146. // IOCTL_IP_NAT_DELETE_INTERFACE
  147. //
  148. // Invoked to delete router-interfaces from the NAT.
  149. //
  150. // InputBuffer: the 32-bit index of the interface to be deleted.
  151. // OutputBuffer: none.
  152. //
  153. //
  154. // IOCTL_IP_NAT_SET_INTERFACE_INFO
  155. //
  156. // Invoked to set configuration information for an interface.
  157. //
  158. // InputBuffer: 'IP_NAT_INTERFACE_INFO' holding the interface's configuration
  159. // OutputBuffer: none.
  160. //
  161. //
  162. // IOCTL_IP_NAT_GET_INTERFACE_INFO
  163. //
  164. // Invoked to retrieve the configuration information of an interface.
  165. //
  166. // InputBuffer: the 32-bit index of the interface in question
  167. // OutputBuffer: 'IP_NAT_INTERFACE_INFO' holding the interface's configuration
  168. //
  169. //
  170. // IOCTL_IP_NAT_GET_INTERFACE_STATISTICS
  171. //
  172. // This IOCTL is invoked to retrieve per-interface statistics.
  173. //
  174. // InputBuffer: the 32-bit index of the interface in question
  175. // OutputBuffer: 'IP_NAT_INTERFACE_STATISTICS' with the interface's statistics
  176. //
  177. //
  178. // IOCTL_IP_NAT_GET_MAPPING_TABLE
  179. // IOCTL_IP_NAT_GET_INTERFACE_MAPPING_TABLE
  180. //
  181. // This IOCTL is invoked to enumerate the dynamic TCP and UDP mappings
  182. // globally, and for each interface.
  183. //
  184. // InputBuffer: 'IP_NAT_ENUMERATE_SESSION_MAPPINGS' with input parameters set
  185. // OutputBuffer: 'IP_NAT_ENUMERATE_SESSION_MAPPINGS' with output parameters
  186. // filled in.
  187. //
  188. //
  189. // IOCTL_IP_NAT_REGISTER_EDITOR
  190. //
  191. // This IOCTL is invoked by a kernel-mode component which wishes to act
  192. // as an editor for packets which match a particular session-description.
  193. //
  194. // InputBuffer: 'IP_NAT_REGISTER_EDITOR' with input parameters set
  195. // OutputBuffer: 'IP_NAT_REGISTER_EDITOR' with output parameters filled in
  196. //
  197. //
  198. // IOCTL_IP_NAT_GET_EDITOR_TABLE
  199. //
  200. // This IOCTL is invoked to enumerate the editors which are currently
  201. // registered.
  202. //
  203. // InputBuffer: 'IP_NAT_ENUMERATE_EDITORS' with input parameters set
  204. // OutputBuffer: 'Ip_NAT_ENUMERATE_EDITORS' with output parameters filled in.
  205. //
  206. //
  207. // IOCTL_IP_NAT_REGISTER_DIRECTOR
  208. //
  209. // This IOCTL is invoked by a kernel-mode component that wishes to be consulted
  210. // about the direction of incoming TCP/UDP sessions.
  211. //
  212. // InputBuffer: 'IP_NAT_REGISTER_DIRECTOR' with input parameters set
  213. // OutputBuffer: 'IP_NAT_REGISTER_DIRECTOR' with output parameters filled in
  214. //
  215. //
  216. // IOCTL_IP_NAT_GET_DIRECTOR_TABLE
  217. //
  218. // This IOCTL is invoked to enumerate the directors which are currently
  219. // registered.
  220. //
  221. // InputBuffer: 'IP_NAT_ENUMERATE_DIRECTORS' with input parameters set
  222. // OutputBuffer: 'Ip_NAT_ENUMERATE_DIRECTORS' with output parameters filled in.
  223. //
  224. //
  225. // IOCTL_IP_NAT_CREATE_REDIRECT
  226. //
  227. // Invoked to cancel or query a 'redirect' which instructs the NAT
  228. // to modify a specific session.
  229. //
  230. // InputBuffer: 'IP_NAT_CREATE_REDIRECT'
  231. // OutputBuffer: 'IP_NAT_REDIRECT_STATISTICS'
  232. //
  233. //
  234. // IOCTL_IP_NAT_CREATE_REDIRECT_EX
  235. //
  236. // Invoked to cancel or query a 'redirect' which instructs the NAT
  237. // to modify a specific session. Can include an optional adapter restriction.
  238. //
  239. // InputBuffer: 'IP_NAT_CREATE_REDIRECT_EX'
  240. // OutputBuffer: 'IP_NAT_REDIRECT_STATISTICS'
  241. //
  242. //
  243. // IOCTL_IP_NAT_CANCEL_REDIRECT
  244. // IOCTL_IP_NAT_GET_REDIRECT_STATISTICS
  245. // IOCTL_IP_NAT_GET_REDIRECT_SOURCE_MAPPING
  246. // IOCTL_IP_NAT_GET_REDIRECT_DESTINATION_MAPPING
  247. //
  248. // Invoked to cancel or query a 'redirect' which instructs the NAT
  249. // to modify a specific session.
  250. //
  251. // InputBuffer: 'IP_NAT_LOOKUP_REDIRECT'
  252. // OutputBuffer:
  253. // cancel: Unused
  254. // statistics: 'IP_NAT_REDIRECT_STATISTICS'
  255. // source mapping: 'IP_NAT_REDIRECT_SOURCE_MAPPING'
  256. // destination mapping: 'IP_NAT_REDIRECT_DESTINATION_MAPPING'
  257. //
  258. //
  259. // IOCTL_IP_NAT_REQUEST_NOTIFICATION
  260. //
  261. // Invoked to request notification of a specific event from the NAT.
  262. //
  263. // InputBuffer: 'IP_NAT_NOTIFICATION' indicating the notification required
  264. // OutputBuffer: depends on 'IP_NAT_NOTIFICATION'.
  265. //
  266. //
  267. // IOCTL_IP_NAT_CREATE_DYNAMIC_TICKET
  268. //
  269. // Invoked to create a dynamic ticket, which becomes active when specific
  270. // outbound session is seen.
  271. //
  272. // InputBuffer: 'IP_NAT_CREATE_DYNAMIC_TICKET' describes the ticket
  273. // OutputBuffer: none.
  274. //
  275. //
  276. // IOCTL_IP_NAT_DELETE_DYNAMIC_TICKET
  277. //
  278. // Invoked to delete a dynamic ticket.
  279. //
  280. // InputBuffer: 'IP_NAT_DELETE_DYNAMIC_TICKET' describes the ticket.
  281. // OutputBuffer: none.
  282. //
  283. //
  284. // IOCTL_IP_NAT_LOOKUP_SESSION_MAPPING_KEY
  285. // IOCTL_IP_NAT_LOOKUP_SESSION_MAPPING_KEY_EX
  286. // IOCTL_IP_NAT_LOOKUP_SESSION_MAPPING_STATISTICS
  287. //
  288. // Invoked to search for a mapping and retrieve information about it.
  289. // InputBuffer: 'IP_NAT_LOOKUP_SESSION_MAPPING'
  290. // OutputBuffer:
  291. // key: 'IP_NAT_SESSION_MAPPING_KEY'
  292. // key_ex: 'IP_NAT_SESSION_MAPPING_KEY_EX'
  293. // statistics: 'IP_NAT_SESSION_MAPPING_STATISTICS'
  294. //
  295. //
  296. // IOCTL_IP_NAT_CREATE_TICKET
  297. //
  298. // Invoked to create a ticket on an interface.
  299. //
  300. // InputBuffer: 'IP_NAT_CREATE_TICKET' describes the ticket.
  301. // OutputBuffer: none.
  302. //
  303. //
  304. // IOCTL_IP_NAT_DELETE_TICKET
  305. //
  306. // Invoked to create a ticket on an interface.
  307. //
  308. // InputBuffer: 'IP_NAT_CREATE_TICKET' describes the ticket.
  309. // OutputBuffer: none.
  310. //
  311. //
  312. // IOCTL_IP_NAT_LOOKUP_TICKET
  313. //
  314. // Invoked to lookup a ticket on an interface.
  315. //
  316. // InputBuffer: 'IP_NAT_CREATE_TICKET' describes the ticket. The private
  317. // parameters are ignored.
  318. // OutputBuffer: IP_NAT_PORT_MAPPING.
  319. //
  320. //
  321. // Structure: IP_NAT_GLOBAL_INFO
  322. //
  323. // Holds global configuration information for the NAT.
  324. //
  325. typedef struct _IP_NAT_GLOBAL_INFO {
  326. ULONG LoggingLevel; // see IPNATHLP.H (IPNATHLP_LOGGING_*).
  327. ULONG Flags;
  328. RTR_INFO_BLOCK_HEADER Header;
  329. } IP_NAT_GLOBAL_INFO, *PIP_NAT_GLOBAL_INFO;
  330. #define IP_NAT_ALLOW_RAS_CLIENTS 0x00000001
  331. //
  332. // Type-codes for the IP_NAT_GLOBAL_INFO.Header.TocEntry[] array.
  333. //
  334. // The structures which correspond to each info-type are given below.
  335. //
  336. #define IP_NAT_TIMEOUT_TYPE IP_GENERAL_INFO_BASE + 1
  337. #define IP_NAT_PROTOCOLS_ALLOWED_TYPE IP_GENERAL_INFO_BASE + 2
  338. //
  339. // Structure: IP_NAT_TIMEOUT
  340. //
  341. // Used to amend the default timeouts for TCP and UDP session mappings.
  342. //
  343. typedef struct _IP_NAT_TIMEOUT {
  344. ULONG TCPTimeoutSeconds;
  345. ULONG UDPTimeoutSeconds;
  346. } IP_NAT_TIMEOUT, *PIP_NAT_TIMEOUT;
  347. //
  348. // Structure: IP_NAT_PROTOCOLS_ALLOWED
  349. //
  350. // Used to define which IP-layer protocols (other than TCP/UDP/ICMP/PPTP)
  351. // may be translated by the NAT. Only one session for each such protocol
  352. // is supported for each remote destination.
  353. //
  354. typedef struct _IP_NAT_PROTOCOLS_ALLOWED {
  355. ULONG Bitmap[256 / (sizeof(ULONG) * 8)];
  356. } IP_NAT_PROTOCOLS_ALLOWED, *PIP_NAT_PROTOCOLS_ALLOWED;
  357. //
  358. // Structure: IP_NAT_CREATE_INTERFACE
  359. //
  360. // 'Index' must correspond to a valid IP adapter-index.
  361. // This implies that addition of a demand-dial interface can only occur
  362. // when such an interface is connected.
  363. //
  364. // The field 'BindingInfo' should be the beginning of
  365. // an IP_ADAPTER_BINDING_INFO structure (see routprot.h) which
  366. // contains the interface's binding.
  367. //
  368. #pragma warning(disable:4200) // 0-element array
  369. typedef struct _IP_NAT_CREATE_INTERFACE {
  370. IN ULONG Index;
  371. IN ULONG BindingInfo[0];
  372. } IP_NAT_CREATE_INTERFACE, *PIP_NAT_CREATE_INTERFACE;
  373. #pragma warning(default:4200)
  374. //
  375. // Structure: IP_NAT_INTERFACE_INFO
  376. //
  377. // 'Index' identifies the interface to be configured.
  378. //
  379. // The configuration information uses the RTR_INFO_BLOCK_HEADER structure
  380. // of rtinfo.h. See below for the type-codes for structures which may appear
  381. // after IP_NAT_INTERFACE_INFO.Header within the RTR_TOC_ENTRY.InfoType field.
  382. //
  383. typedef struct _IP_NAT_INTERFACE_INFO {
  384. ULONG Index;
  385. ULONG Flags;
  386. RTR_INFO_BLOCK_HEADER Header;
  387. } IP_NAT_INTERFACE_INFO, *PIP_NAT_INTERFACE_INFO;
  388. //
  389. // Flags for IP_NAT_INTERFACE_INFO.Flags
  390. //
  391. // _BOUNDARY: set to mark interface as boundary-interface.
  392. //
  393. // _NAPT: set to enable address-sharing via port-translation.
  394. //
  395. // _FW: set to enable firewall mode on the interface. This works with all
  396. // other flags. An interface in firewall mode is much more strict on what
  397. // inbound packets it will allow to propogate up the stack; in general,
  398. // it will only allow packets that are part of a locally-initiated connection
  399. // flow (i.e., packets for which a mapping or ticket exists)
  400. //
  401. #define IP_NAT_INTERFACE_FLAGS_BOUNDARY 0x00000001
  402. #define IP_NAT_INTERFACE_FLAGS_NAPT 0x00000002
  403. #define IP_NAT_INTERFACE_FLAGS_DISABLE_PPTP 0x00000004
  404. #define IP_NAT_INTERFACE_FLAGS_FW 0x00000010
  405. #define IP_NAT_INTERFACE_FLAGS_ALL 0x0000001f
  406. //
  407. // Type-codes for the IP_NAT_INTERFACE_INFO.Header.TocEntry[] array.
  408. //
  409. // The structures which correspond to each info-type are given below.
  410. //
  411. #define IP_NAT_ADDRESS_RANGE_TYPE IP_GENERAL_INFO_BASE + 2
  412. #define IP_NAT_PORT_MAPPING_TYPE IP_GENERAL_INFO_BASE + 3
  413. #define IP_NAT_ADDRESS_MAPPING_TYPE IP_GENERAL_INFO_BASE + 4
  414. #define IP_NAT_ICMP_CONFIG_TYPE IP_GENERAL_INFO_BASE + 5
  415. //
  416. // Structure: IP_NAT_ADDRESS_RANGE
  417. //
  418. // Holds a range of addresses which are part of the address-pool
  419. // for a boundary interface.
  420. //
  421. // An address-pool consists of a list of these structures.
  422. //
  423. // N.B. Overlapping address-ranges are not supported;
  424. // discontiguous subnet masks are also unsupported.
  425. //
  426. typedef struct _IP_NAT_ADDRESS_RANGE {
  427. ULONG StartAddress;
  428. ULONG EndAddress;
  429. ULONG SubnetMask;
  430. } IP_NAT_ADDRESS_RANGE, *PIP_NAT_ADDRESS_RANGE;
  431. //
  432. // Structure: IP_NAT_PORT_MAPPING
  433. //
  434. // Holds a static mapping which ties a public-side port on this NAT interface
  435. // to a particular private machine's address/port.
  436. //
  437. // In the case of an interface with a pool of addresses, 'PublicAddress'
  438. // should specify which of those addresses this static-mapping applies to.
  439. //
  440. typedef struct _IP_NAT_PORT_MAPPING {
  441. UCHAR Protocol;
  442. USHORT PublicPort;
  443. ULONG PublicAddress; // OPTIONAL - see IP_NAT_ADDRESS_UNSPECIFIED
  444. USHORT PrivatePort;
  445. ULONG PrivateAddress;
  446. } IP_NAT_PORT_MAPPING, *PIP_NAT_PORT_MAPPING;
  447. //
  448. // Constant for 'PublicAddress' in IP_NAT_PORT_RANGE and IP_NAT_PORT_MAPPING;
  449. // may be specified for boundary-interfaces which have no address-pool, in
  450. // which case the range/mapping is for the boundary-interface's sole address.
  451. //
  452. #define IP_NAT_ADDRESS_UNSPECIFIED ((ULONG)0)
  453. //
  454. // Structure: IP_NAT_ADDRESS_MAPPING
  455. //
  456. // Holds a static mapping which ties an address from this NAT interface's
  457. // address pool to a particular private-machine's address.
  458. //
  459. // Note that this address must fall within one of the ranges comprising
  460. // the pool as specified by the IP_NAT_ADDRESS_RANGE structures.
  461. //
  462. typedef struct _IP_NAT_ADDRESS_MAPPING {
  463. ULONG PrivateAddress;
  464. ULONG PublicAddress;
  465. BOOLEAN AllowInboundSessions;
  466. } IP_NAT_ADDRESS_MAPPING, *PIP_NAT_ADDRESS_MAPPING;
  467. //
  468. // There is no structure for IP_NAT_ICMP_CONFIG -- it's just a ULONG,
  469. // with the following flags defining the behavior. These flags are
  470. // only for exceptions to our default (very strict) security policy.
  471. //
  472. // IB == inbound, OB == outbound. Redirect is for either direction.
  473. //
  474. // The numerical values for the flags are derived from the ICMP
  475. // message type code -- 1 << MessageType.
  476. //
  477. //
  478. #define IP_NAT_ICMP_ALLOW_OB_DEST_UNREACH 0x00000008
  479. #define IP_NAT_ICMP_ALLOW_OB_SOURCE_QUENCH 0x00000010
  480. #define IP_NAT_ICMP_ALLOW_REDIRECT 0x00000020
  481. #define IP_NAT_ICMP_ALLOW_IB_ECHO 0x00000100
  482. #define IP_NAT_ICMP_ALLOW_IB_ROUTER 0x00000200
  483. #define IP_NAT_ICMP_ALLOW_OB_TIME_EXCEEDED 0x00000800
  484. #define IP_NAT_ICMP_ALLOW_OB_PARAM_PROBLEM 0x00001000
  485. #define IP_NAT_ICMP_ALLOW_IB_TIMESTAMP 0x00002000
  486. #define IP_NAT_ICMP_ALLOW_IB_MASK 0x00020000
  487. //
  488. // Structure: IP_NAT_INTERFACE_STATISTICS
  489. //
  490. // This structure holds statistics for an interface
  491. //
  492. typedef struct _IP_NAT_INTERFACE_STATISTICS {
  493. OUT ULONG TotalMappings;
  494. OUT ULONG InboundMappings;
  495. OUT ULONG64 BytesForward;
  496. OUT ULONG64 BytesReverse;
  497. OUT ULONG64 PacketsForward;
  498. OUT ULONG64 PacketsReverse;
  499. OUT ULONG64 RejectsForward;
  500. OUT ULONG64 RejectsReverse;
  501. } IP_NAT_INTERFACE_STATISTICS, *PIP_NAT_INTERFACE_STATISTICS;
  502. //
  503. // Structure: IP_NAT_SESSION_MAPPING
  504. //
  505. // This structure holds information for a single mapping
  506. //
  507. typedef struct _IP_NAT_SESSION_MAPPING {
  508. UCHAR Protocol; // see NAT_PROTOCOL_* above
  509. ULONG PrivateAddress;
  510. USHORT PrivatePort;
  511. ULONG PublicAddress;
  512. USHORT PublicPort;
  513. ULONG RemoteAddress;
  514. USHORT RemotePort;
  515. IP_NAT_DIRECTION Direction;
  516. ULONG IdleTime; // in seconds
  517. } IP_NAT_SESSION_MAPPING, *PIP_NAT_SESSION_MAPPING;
  518. //
  519. // Structure: IP_NAT_SESSION_MAPPING_STATISTICS
  520. //
  521. // Holds statistics for a single session-mapping.
  522. //
  523. typedef struct _IP_NAT_SESSION_MAPPING_STATISTICS {
  524. ULONG64 BytesForward;
  525. ULONG64 BytesReverse;
  526. ULONG64 PacketsForward;
  527. ULONG64 PacketsReverse;
  528. ULONG64 RejectsForward;
  529. ULONG64 RejectsReverse;
  530. } IP_NAT_SESSION_MAPPING_STATISTICS, *PIP_NAT_SESSION_MAPPING_STATISTICS;
  531. //
  532. // Structure: IP_NAT_SESSION_MAPPING_KEY
  533. //
  534. // Holds key-information for a single session-mapping.
  535. //
  536. typedef struct _IP_NAT_SESSION_MAPPING_KEY {
  537. UCHAR Protocol;
  538. ULONG DestinationAddress;
  539. USHORT DestinationPort;
  540. ULONG SourceAddress;
  541. USHORT SourcePort;
  542. ULONG NewDestinationAddress;
  543. USHORT NewDestinationPort;
  544. ULONG NewSourceAddress;
  545. USHORT NewSourcePort;
  546. } IP_NAT_SESSION_MAPPING_KEY, *PIP_NAT_SESSION_MAPPING_KEY;
  547. //
  548. // Structure: IP_NAT_SESSION_MAPPING_KEY_EX
  549. //
  550. // Holds key-information for a single session-mapping, including
  551. // the AdapterIndex if this session was created by the redirector.
  552. //
  553. typedef struct _IP_NAT_SESSION_MAPPING_KEY_EX {
  554. UCHAR Protocol;
  555. ULONG DestinationAddress;
  556. USHORT DestinationPort;
  557. ULONG SourceAddress;
  558. USHORT SourcePort;
  559. ULONG NewDestinationAddress;
  560. USHORT NewDestinationPort;
  561. ULONG NewSourceAddress;
  562. USHORT NewSourcePort;
  563. ULONG AdapterIndex;
  564. } IP_NAT_SESSION_MAPPING_KEY_EX, *PIP_NAT_SESSION_MAPPING_KEY_EX;
  565. //
  566. // Structure: IP_NAT_ENUMERATE_SESSION_MAPPINGS
  567. //
  568. // Used for enumerating session mappings.
  569. // On the first call to this routine, 'EnumerateContext' should be zeroed out;
  570. // it will be filled by the NAT with information to be passed back down
  571. // as the enumeration continues. To indicate there are no items remaining,
  572. // the NAT will set EnumerateContext[0] to 0.
  573. //
  574. typedef struct _IP_NAT_ENUMERATE_SESSION_MAPPINGS {
  575. IN ULONG Index;
  576. IN OUT ULONG EnumerateContext[4];
  577. OUT ULONG EnumerateCount;
  578. OUT ULONG EnumerateTotalHint;
  579. OUT IP_NAT_SESSION_MAPPING EnumerateTable[1];
  580. } IP_NAT_ENUMERATE_SESSION_MAPPINGS, *PIP_NAT_ENUMERATE_SESSION_MAPPINGS;
  581. //
  582. // Structure: IP_NAT_LOOKUP_SESSION_MAPPING
  583. //
  584. // Used to search for and query a specified session mapping.
  585. // On input, the address/port fields are initialized either to
  586. // pre-translation values or post-translation values.
  587. // The NAT attempts to find a session mapping with matching values,
  588. // and retrieves the requested information for that session mapping, if found.
  589. //
  590. typedef struct _IP_NAT_LOOKUP_SESSION_MAPPING {
  591. UCHAR Protocol;
  592. ULONG DestinationAddress;
  593. USHORT DestinationPort;
  594. ULONG SourceAddress;
  595. USHORT SourcePort;
  596. } IP_NAT_LOOKUP_SESSION_MAPPING, *PIP_NAT_LOOKUP_SESSION_MAPPING;
  597. //
  598. // Editor function prototypes
  599. //
  600. //
  601. // For synchronization reasons, 'CreateHandler' and 'DeleteHandler'
  602. // CANNOT invoke any helper functions other than 'QueryInfoSession'.
  603. //
  604. typedef NTSTATUS
  605. (*PNAT_EDITOR_CREATE_HANDLER)(
  606. IN PVOID EditorContext,
  607. IN ULONG PrivateAddress,
  608. IN USHORT PrivatePort,
  609. IN ULONG PublicAddress,
  610. IN USHORT PublicPort,
  611. IN ULONG RemoteAddress,
  612. IN USHORT RemotePort,
  613. OUT PVOID* EditorSessionContextp OPTIONAL
  614. );
  615. typedef NTSTATUS
  616. (*PNAT_EDITOR_DELETE_HANDLER)(
  617. IN PVOID InterfaceHandle,
  618. IN PVOID SessionHandle,
  619. IN PVOID EditorContext,
  620. IN PVOID EditorSessionContext
  621. );
  622. typedef NTSTATUS
  623. (*PNAT_EDITOR_DATA_HANDLER)(
  624. IN PVOID InterfaceHandle,
  625. IN PVOID SessionHandle,
  626. IN PVOID DataHandle,
  627. IN PVOID EditorContext,
  628. IN PVOID EditorSessionContext,
  629. IN PVOID RecvBuffer,
  630. IN ULONG DataOffset
  631. );
  632. //
  633. // Helper function prototypes
  634. //
  635. typedef NTSTATUS
  636. (*PNAT_EDITOR_CREATE_TICKET)(
  637. IN PVOID InterfaceHandle,
  638. IN UCHAR Protocol,
  639. IN ULONG PrivateAddress,
  640. IN USHORT PrivatePort,
  641. IN ULONG RemoteAddress OPTIONAL,
  642. IN USHORT RemotePort OPTIONAL,
  643. OUT PULONG PublicAddress,
  644. OUT PUSHORT PublicPort
  645. );
  646. typedef NTSTATUS
  647. (*PNAT_EDITOR_DELETE_TICKET)(
  648. IN PVOID InterfaceHandle,
  649. IN ULONG PublicAddress,
  650. IN UCHAR Protocol,
  651. IN USHORT PublicPort,
  652. IN ULONG RemoteAddress OPTIONAL,
  653. IN USHORT RemotePort OPTIONAL
  654. );
  655. typedef NTSTATUS
  656. (*PNAT_EDITOR_DEREGISTER)(
  657. IN PVOID EditorHandle
  658. );
  659. typedef NTSTATUS
  660. (*PNAT_EDITOR_DISSOCIATE_SESSION)(
  661. IN PVOID EditorHandle,
  662. IN PVOID SessionHandle
  663. );
  664. typedef NTSTATUS
  665. (*PNAT_EDITOR_EDIT_SESSION)(
  666. IN PVOID DataHandle,
  667. IN PVOID RecvBuffer,
  668. IN ULONG OldDataOffset,
  669. IN ULONG OldDataLength,
  670. IN PUCHAR NewData,
  671. IN ULONG NewDataLength
  672. );
  673. typedef VOID
  674. (*PNAT_EDITOR_QUERY_INFO_SESSION)(
  675. IN PVOID SessionHandle,
  676. OUT PULONG PrivateAddress OPTIONAL,
  677. OUT PUSHORT PrivatePort OPTIONAL,
  678. OUT PULONG RemoteAddress OPTIONAL,
  679. OUT PUSHORT RemotePort OPTIONAL,
  680. OUT PULONG PublicAddress OPTIONAL,
  681. OUT PUSHORT PublicPort OPTIONAL,
  682. OUT PIP_NAT_SESSION_MAPPING_STATISTICS Statistics OPTIONAL
  683. );
  684. typedef VOID
  685. (*PNAT_EDITOR_TIMEOUT_SESSION)(
  686. IN PVOID EditorHandle,
  687. IN PVOID SessionHandle
  688. );
  689. //
  690. // Structure: IP_NAT_REGISTER_EDITOR
  691. //
  692. // The editor uses this structure to register itself with the NAT,
  693. // and to obtain entrypoints of helper-functions provided by the NAT.
  694. //
  695. // On input, 'EditorContext' should contain a value which the NAT will
  696. // pass to the editor's provided functions to serve as identification.
  697. //
  698. // On output, 'EditorHandle' contains the handle which the editor should
  699. // pass to the NAT's helper functions to identify itself.
  700. //
  701. typedef struct _IP_NAT_REGISTER_EDITOR {
  702. IN ULONG Version;
  703. IN ULONG Flags;
  704. IN UCHAR Protocol;
  705. IN USHORT Port;
  706. IN IP_NAT_DIRECTION Direction;
  707. IN PVOID EditorContext;
  708. IN PNAT_EDITOR_CREATE_HANDLER CreateHandler; // OPTIONAL
  709. IN PNAT_EDITOR_DELETE_HANDLER DeleteHandler; // OPTIONAL
  710. IN PNAT_EDITOR_DATA_HANDLER ForwardDataHandler; // OPTIONAL
  711. IN PNAT_EDITOR_DATA_HANDLER ReverseDataHandler; // OPTIONAL
  712. OUT PVOID EditorHandle;
  713. OUT PNAT_EDITOR_CREATE_TICKET CreateTicket;
  714. OUT PNAT_EDITOR_DELETE_TICKET DeleteTicket;
  715. OUT PNAT_EDITOR_DEREGISTER Deregister;
  716. OUT PNAT_EDITOR_DISSOCIATE_SESSION DissociateSession;
  717. OUT PNAT_EDITOR_EDIT_SESSION EditSession;
  718. OUT PNAT_EDITOR_QUERY_INFO_SESSION QueryInfoSession;
  719. OUT PNAT_EDITOR_TIMEOUT_SESSION TimeoutSession;
  720. } IP_NAT_REGISTER_EDITOR, *PIP_NAT_REGISTER_EDITOR;
  721. #define IP_NAT_EDITOR_FLAGS_RESIZE 0x00000001
  722. //
  723. // Structure: IP_NAT_EDITOR
  724. //
  725. // This structure contains information describing a registered editor.
  726. //
  727. typedef struct _IP_NAT_EDITOR {
  728. IP_NAT_DIRECTION Direction;
  729. UCHAR Protocol;
  730. USHORT Port;
  731. } IP_NAT_EDITOR, *PIP_NAT_EDITOR;
  732. //
  733. // Structure: IP_NAT_ENUMERATE_EDITORS
  734. //
  735. // Used for enumerating editors.
  736. // On the first call to this routine, 'EnumerateContext' should be zeroed out;
  737. // it will be filled by the NAT with information to be passed back down
  738. // as the enumeration continues. To indicate there are no items remaining,
  739. // the NAT will set EnumerateContext[0] to 0.
  740. //
  741. typedef struct _IP_NAT_ENUMERATE_EDITORS {
  742. IN OUT ULONG EnumerateContext;
  743. OUT ULONG EnumerateCount;
  744. OUT ULONG EnumerateTotalHint;
  745. OUT IP_NAT_EDITOR EnumerateTable[1];
  746. } IP_NAT_ENUMERATE_EDITORS, *PIP_NAT_ENUMERATE_EDITORS;
  747. //
  748. // Director function prototypes
  749. //
  750. typedef struct _IP_NAT_DIRECTOR_QUERY {
  751. IN PVOID DirectorContext;
  752. IN ULONG ReceiveIndex;
  753. IN ULONG SendIndex;
  754. IN UCHAR Protocol;
  755. IN ULONG DestinationAddress;
  756. IN USHORT DestinationPort;
  757. IN ULONG SourceAddress;
  758. IN USHORT SourcePort;
  759. IN OUT ULONG Flags;
  760. OUT ULONG NewDestinationAddress;
  761. OUT USHORT NewDestinationPort;
  762. OUT ULONG NewSourceAddress OPTIONAL;
  763. OUT USHORT NewSourcePort OPTIONAL;
  764. OUT PVOID DirectorSessionContext;
  765. } IP_NAT_DIRECTOR_QUERY, *PIP_NAT_DIRECTOR_QUERY;
  766. #define IP_NAT_DIRECTOR_QUERY_FLAG_LOOPBACK 0x00000001
  767. #define IP_NAT_DIRECTOR_QUERY_FLAG_DROP 0x80000000
  768. #define IP_NAT_DIRECTOR_QUERY_FLAG_STATISTICS 0x40000000
  769. #define IP_NAT_DIRECTOR_QUERY_FLAG_NO_TIMEOUT 0x20000000
  770. #define IP_NAT_DIRECTOR_QUERY_FLAG_UNIDIRECTIONAL 0x10000000
  771. #define IP_NAT_DIRECTOR_QUERY_FLAG_DELETE_ON_DISSOCIATE 0x08000000
  772. typedef NTSTATUS
  773. (*PNAT_DIRECTOR_QUERY_SESSION)(
  774. PIP_NAT_DIRECTOR_QUERY DirectorQuery
  775. );
  776. typedef VOID
  777. (*PNAT_DIRECTOR_CREATE_SESSION)(
  778. IN PVOID SessionHandle,
  779. IN PVOID DirectorContext,
  780. IN PVOID DirectorSessionContext
  781. );
  782. typedef VOID
  783. (*PNAT_DIRECTOR_DELETE_SESSION)(
  784. IN PVOID SessionHandle,
  785. IN PVOID DirectorContext,
  786. IN PVOID DirectorSessionContext,
  787. IN IP_NAT_DELETE_REASON DeleteReason
  788. );
  789. typedef VOID
  790. (*PNAT_DIRECTOR_UNLOAD)(
  791. IN PVOID DirectorContext
  792. );
  793. //
  794. // Director-helper function prototypes
  795. //
  796. typedef NTSTATUS
  797. (*PNAT_DIRECTOR_DEREGISTER)(
  798. IN PVOID DirectorHandle
  799. );
  800. typedef NTSTATUS
  801. (*PNAT_DIRECTOR_DISSOCIATE_SESSION)(
  802. IN PVOID DirectorHandle,
  803. IN PVOID SessionHandle
  804. );
  805. typedef VOID
  806. (*PNAT_DIRECTOR_QUERY_INFO_SESSION)(
  807. IN PVOID SessionHandle,
  808. OUT PIP_NAT_SESSION_MAPPING_STATISTICS Statistics OPTIONAL
  809. );
  810. //
  811. // Structure: IP_NAT_REGISTER_DIRECTOR
  812. //
  813. // The director uses this structure to register itself with the NAT.
  814. //
  815. typedef struct _IP_NAT_REGISTER_DIRECTOR {
  816. IN ULONG Version;
  817. IN ULONG Flags;
  818. IN UCHAR Protocol;
  819. IN USHORT Port;
  820. IN PVOID DirectorContext;
  821. IN PNAT_DIRECTOR_QUERY_SESSION QueryHandler;
  822. IN PNAT_DIRECTOR_CREATE_SESSION CreateHandler;
  823. IN PNAT_DIRECTOR_DELETE_SESSION DeleteHandler;
  824. IN PNAT_DIRECTOR_UNLOAD UnloadHandler;
  825. OUT PVOID DirectorHandle;
  826. OUT PNAT_DIRECTOR_QUERY_INFO_SESSION QueryInfoSession;
  827. OUT PNAT_DIRECTOR_DEREGISTER Deregister;
  828. OUT PNAT_DIRECTOR_DISSOCIATE_SESSION DissociateSession;
  829. } IP_NAT_REGISTER_DIRECTOR, *PIP_NAT_REGISTER_DIRECTOR;
  830. //
  831. // Structure: IP_NAT_DIRECTOR
  832. //
  833. // This structure contains information describing a registered director.
  834. //
  835. typedef struct _IP_NAT_DIRECTOR {
  836. UCHAR Protocol;
  837. USHORT Port;
  838. } IP_NAT_DIRECTOR, *PIP_NAT_DIRECTOR;
  839. //
  840. // Structure: IP_NAT_ENUMERATE_DIRECTORS
  841. //
  842. // Used for enumerating directors.
  843. // On the first call to this routine, 'EnumerateContext' should be zeroed out;
  844. // it will be filled by the NAT with information to be passed back down
  845. // as the enumeration continues. To indicate there are no items remaining,
  846. // the NAT will set EnumerateContext[0] to 0.
  847. //
  848. typedef struct _IP_NAT_ENUMERATE_DIRECTORS {
  849. IN OUT ULONG EnumerateContext;
  850. OUT ULONG EnumerateCount;
  851. OUT ULONG EnumerateTotalHint;
  852. OUT IP_NAT_DIRECTOR EnumerateTable[1];
  853. } IP_NAT_ENUMERATE_DIRECTORS, *PIP_NAT_ENUMERATE_DIRECTORS;
  854. //
  855. // Structure: IP_NAT_REDIRECT
  856. //
  857. // Describes the manner in which a specific session is to be modified.
  858. //
  859. typedef struct _IP_NAT_REDIRECT {
  860. UCHAR Protocol;
  861. ULONG SourceAddress;
  862. USHORT SourcePort;
  863. ULONG DestinationAddress;
  864. USHORT DestinationPort;
  865. ULONG NewSourceAddress;
  866. USHORT NewSourcePort;
  867. ULONG NewDestinationAddress;
  868. USHORT NewDestinationPort;
  869. } IP_NAT_REDIRECT, *PIP_NAT_REDIRECT;
  870. typedef struct _IP_NAT_CREATE_REDIRECT {
  871. IN ULONG Flags;
  872. IN HANDLE NotifyEvent OPTIONAL;
  873. IN ULONG RestrictSourceAddress OPTIONAL;
  874. #ifdef __cplusplus
  875. IN IP_NAT_REDIRECT Redirect;
  876. #else
  877. IN IP_NAT_REDIRECT;
  878. #endif
  879. } IP_NAT_CREATE_REDIRECT, *PIP_NAT_CREATE_REDIRECT;
  880. typedef struct _IP_NAT_CREATE_REDIRECT_EX {
  881. IN ULONG Flags;
  882. IN HANDLE NotifyEvent OPTIONAL;
  883. IN ULONG RestrictSourceAddress OPTIONAL;
  884. ULONG RestrictAdapterIndex OPTIONAL;
  885. #ifdef __cplusplus
  886. IN IP_NAT_REDIRECT Redirect;
  887. #else
  888. IN IP_NAT_REDIRECT;
  889. #endif
  890. } IP_NAT_CREATE_REDIRECT_EX, *PIP_NAT_CREATE_REDIRECT_EX;
  891. #define IP_NAT_REDIRECT_FLAG_ASYNCHRONOUS 0x00000001
  892. #define IP_NAT_REDIRECT_FLAG_STATISTICS 0x00000002
  893. #define IP_NAT_REDIRECT_FLAG_NO_TIMEOUT 0x00000004
  894. #define IP_NAT_REDIRECT_FLAG_UNIDIRECTIONAL 0x00000008
  895. #define IP_NAT_REDIRECT_FLAG_RESTRICT_SOURCE 0x00000010
  896. #define IP_NAT_REDIRECT_FLAG_IO_COMPLETION 0x00000020
  897. #define IP_NAT_REDIRECT_FLAG_PORT_REDIRECT 0x00000040
  898. #define IP_NAT_REDIRECT_FLAG_RECEIVE_ONLY 0x00000080
  899. #define IP_NAT_REDIRECT_FLAG_LOOPBACK 0x00000100
  900. #define IP_NAT_REDIRECT_FLAG_SEND_ONLY 0x00000200
  901. #define IP_NAT_REDIRECT_FLAG_RESTRICT_ADAPTER 0x00000400
  902. #define IP_NAT_REDIRECT_FLAG_SOURCE_REDIRECT 0x00000800
  903. typedef struct _IP_NAT_LOOKUP_REDIRECT {
  904. IN ULONG Flags;
  905. IN PVOID RedirectApcContext;
  906. #ifdef __cplusplus
  907. IN IP_NAT_REDIRECT Redirect;
  908. #else
  909. IN IP_NAT_REDIRECT;
  910. #endif
  911. } IP_NAT_LOOKUP_REDIRECT, *PIP_NAT_LOOKUP_REDIRECT;
  912. #define IP_NAT_LOOKUP_REDIRECT_FLAG_MATCH_APC_CONTEXT 0x00000001
  913. typedef struct _IP_NAT_SESSION_MAPPING_STATISTICS
  914. IP_NAT_REDIRECT_STATISTICS, *PIP_NAT_REDIRECT_STATISTICS;
  915. typedef struct _IP_NAT_REDIRECT_SOURCE_MAPPING {
  916. ULONG SourceAddress;
  917. USHORT SourcePort;
  918. ULONG NewSourceAddress;
  919. USHORT NewSourcePort;
  920. } IP_NAT_REDIRECT_SOURCE_MAPPING, *PIP_NAT_REDIRECT_SOURCE_MAPPING;
  921. typedef struct _IP_NAT_REDIRECT_DESTINATION_MAPPING {
  922. ULONG DestinationAddress;
  923. USHORT DestinationPort;
  924. ULONG NewDestinationAddress;
  925. USHORT NewDestinationPort;
  926. } IP_NAT_REDIRECT_DESTINATION_MAPPING, *PIP_NAT_REDIRECT_DESTINATION_MAPPING;
  927. //
  928. // Enumeration: IP_NAT_NOTIFICATION
  929. //
  930. // Lists the forms of notification supported by the NAT.
  931. //
  932. typedef enum {
  933. NatRoutingFailureNotification = 0,
  934. NatMaximumNotification
  935. } IP_NAT_NOTIFICATION, *PIP_NAT_NOTIFICATION;
  936. //
  937. // Structure: IP_NAT_REQUEST_NOTIFICATION
  938. //
  939. // Used to request notification from the NAT.
  940. //
  941. typedef struct _IP_NAT_REQUEST_NOTIFICATION {
  942. IP_NAT_NOTIFICATION Code;
  943. } IP_NAT_REQUEST_NOTIFICATION, *PIP_NAT_REQUEST_NOTIFICATION;
  944. //
  945. // Structure: IP_NAT_ROUTING_FAILURE_NOTIFICATION
  946. //
  947. // Supplies information on a packet which could not be routed.
  948. //
  949. typedef struct _IP_NAT_ROUTING_FAILURE_NOTIFICATION {
  950. ULONG DestinationAddress;
  951. ULONG SourceAddress;
  952. } IP_NAT_ROUTING_FAILURE_NOTIFICATION, *PIP_NAT_ROUTING_FAILURE_NOTIFICATION;
  953. //
  954. // Structure: IP_NAT_CREATE_DYNAMIC_TICKET
  955. //
  956. // Used to describe a dynamic ticket to be created.
  957. //
  958. #pragma warning(disable:4200) // 0-element array
  959. typedef struct _IP_NAT_CREATE_DYNAMIC_TICKET {
  960. UCHAR Protocol;
  961. USHORT Port;
  962. ULONG ResponseCount;
  963. struct {
  964. UCHAR Protocol;
  965. USHORT StartPort;
  966. USHORT EndPort;
  967. } ResponseArray[0];
  968. } IP_NAT_CREATE_DYNAMIC_TICKET, *PIP_NAT_CREATE_DYNAMIC_TICKET;
  969. #pragma warning(default:4200)
  970. //
  971. // Structure: IP_NAT_DELETE_DYNAMIC_TICKET
  972. //
  973. // Used to describe a dynamic ticket to be deleted.
  974. //
  975. typedef struct _IP_NAT_DELETE_DYNAMIC_TICKET {
  976. UCHAR Protocol;
  977. USHORT Port;
  978. } IP_NAT_DELETE_DYNAMIC_TICKET, *PIP_NAT_DELETE_DYNAMIC_TICKET;
  979. //
  980. // Structure: IP_NAT_CREATE_TICKET
  981. //
  982. // Used to describe a ticket to be created or deleted.
  983. //
  984. typedef struct _IP_NAT_CREATE_TICKET {
  985. IN ULONG InterfaceIndex;
  986. IN IP_NAT_PORT_MAPPING PortMapping;
  987. } IP_NAT_CREATE_TICKET, *PIP_NAT_CREATE_TICKET;
  988. #ifdef __cplusplus
  989. }
  990. #endif
  991. #endif // _ROUTING_IP_NAT_H_