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.

1323 lines
30 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ipnatapi.h
  5. Abstract:
  6. This module contains declarations for use by user-mode clients of the NAT.
  7. Functions are included to access the kernel-mode packet-redirection
  8. functionality implemented using the Windows 2000 firewall hook.
  9. To facilitate development of transparent application proxies,
  10. functions are also included to access the port-reservation functionality
  11. implemented by the Windows 2000 TCP/IP driver.
  12. Author:
  13. Abolade Gbadegesin (aboladeg) 8-May-1998
  14. Revision History:
  15. Abolade Gbadegesin (aboladeg) 25-May-1999
  16. Added port-reservation routines.
  17. Jonathan Burstein (jonburs) 13-March-2000
  18. Adapter-restricted variants.
  19. --*/
  20. #ifndef _ROUTING_IPNATAPI_H_
  21. #define _ROUTING_IPNATAPI_H_
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. //
  26. // General API declarations
  27. //
  28. typedef VOID
  29. (WINAPI* PNAT_COMPLETION_ROUTINE)(
  30. HANDLE RedirectHandle,
  31. BOOLEAN Cancelled,
  32. PVOID CompletionContext
  33. );
  34. ULONG
  35. NatInitializeTranslator(
  36. PHANDLE TranslatorHandle
  37. );
  38. VOID
  39. NatShutdownTranslator(
  40. HANDLE TranslatorHandle
  41. );
  42. //
  43. // Redirect API declarations
  44. //
  45. typedef enum _NAT_REDIRECT_FLAGS {
  46. NatRedirectFlagNoTimeout = 0x00000004,
  47. NatRedirectFlagUnidirectional = 0x00000008,
  48. NatRedirectFlagRestrictSource = 0x00000010,
  49. NatRedirectFlagPortRedirect = 0x00000040,
  50. NatRedirectFlagReceiveOnly = 0x00000080,
  51. NatRedirectFlagLoopback = 0x00000100,
  52. #if _WIN32_WINNT > 0x0500
  53. NatRedirectFlagSendOnly = 0x00000200,
  54. NatRedirectFlagRestrictAdapter = 0x00000400,
  55. NatRedirectFlagSourceRedirect = 0x00000800,
  56. NatRedirectFlagsAll = 0x00000fdc
  57. #else
  58. NatRedirectFlagsAll = 0x000001dc
  59. #endif
  60. } NAT_REDIRECT_FLAGS, *PNAT_REDIRECT_FLAGS;
  61. typedef enum _NAT_REDIRECT_INFORMATION_CLASS {
  62. NatByteCountRedirectInformation=1,
  63. NatRejectRedirectInformation,
  64. NatSourceMappingRedirectInformation,
  65. NatDestinationMappingRedirectInformation,
  66. NatMaximumRedirectInformation
  67. } NAT_REDIRECT_INFORMATION_CLASS, *PNAT_REDIRECT_INFORMATION_CLASS;
  68. typedef struct _NAT_BYTE_COUNT_REDIRECT_INFORMATION {
  69. ULONG64 BytesForward;
  70. ULONG64 BytesReverse;
  71. } NAT_BYTE_COUNT_REDIRECT_INFORMATION, *PNAT_BYTE_COUNT_REDIRECT_INFORMATION;
  72. typedef struct _NAT_REJECT_REDIRECT_INFORMATION {
  73. ULONG64 RejectsForward;
  74. ULONG64 RejectsReverse;
  75. } NAT_REJECT_REDIRECT_INFORMATION, *PNAT_REJECT_REDIRECT_INFORMATION;
  76. typedef struct _NAT_SOURCE_MAPPING_REDIRECT_INFORMATION {
  77. ULONG SourceAddress;
  78. USHORT SourcePort;
  79. ULONG NewSourceAddress;
  80. USHORT NewSourcePort;
  81. } NAT_SOURCE_MAPPING_REDIRECT_INFORMATION,
  82. *PNAT_SOURCE_MAPPING_REDIRECT_INFORMATION;
  83. typedef struct _NAT_DESTINATION_MAPPING_REDIRECT_INFORMATION {
  84. ULONG DestinationAddress;
  85. USHORT DestinationPort;
  86. ULONG NewDestinationAddress;
  87. USHORT NewDestinationPort;
  88. } NAT_DESTINATION_MAPPING_REDIRECT_INFORMATION,
  89. *PNAT_DESTINATION_MAPPING_REDIRECT_INFORMATION;
  90. #define NAT_INVALID_IF_INDEX (ULONG)-1 // The invalid inteface index.
  91. //
  92. // ULONG
  93. // NatCancelPartialRedirect(
  94. // HANDLE TranslatorHandle,
  95. // UCHAR Protocol,
  96. // ULONG DestinationAddress,
  97. // USHORT DestinationPort,
  98. // ULONG NewDestinationAddress,
  99. // USHORT NewDestinationPort
  100. // );
  101. //
  102. #define \
  103. NatCancelPartialRedirect( \
  104. TranslatorHandle, \
  105. Protocol, \
  106. DestinationAddress, \
  107. DestinationPort, \
  108. NewDestinationAddress, \
  109. NewDestinationPort \
  110. ) \
  111. NatCancelRedirect( \
  112. TranslatorHandle, \
  113. Protocol, \
  114. DestinationAddress, \
  115. DestinationPort, \
  116. 0, \
  117. 0, \
  118. NewDestinationAddress, \
  119. NewDestinationPort, \
  120. 0, \
  121. 0 \
  122. )
  123. //
  124. // ULONG
  125. // NatCancelPortRedirect(
  126. // HANDLE TranslatorHandle,
  127. // UCHAR Protocol,
  128. // USHORT DestinationPort,
  129. // ULONG NewDestinationAddress,
  130. // USHORT NewDestinationPort
  131. // );
  132. //
  133. #define \
  134. NatCancelPortRedirect( \
  135. TranslatorHandle, \
  136. Protocol, \
  137. DestinationPort, \
  138. NewDestinationAddress, \
  139. NewDestinationPort \
  140. ) \
  141. NatCancelRedirect( \
  142. TranslatorHandle, \
  143. Protocol, \
  144. 0, \
  145. DestinationPort, \
  146. 0, \
  147. 0, \
  148. NewDestinationAddress, \
  149. NewDestinationPort, \
  150. 0, \
  151. 0 \
  152. )
  153. ULONG
  154. NatCancelRedirect(
  155. HANDLE TranslatorHandle,
  156. UCHAR Protocol,
  157. ULONG DestinationAddress,
  158. USHORT DestinationPort,
  159. ULONG SourceAddress,
  160. USHORT SourcePort,
  161. ULONG NewDestinationAddress,
  162. USHORT NewDestinationPort,
  163. ULONG NewSourceAddress,
  164. USHORT NewSourcePort
  165. );
  166. //
  167. // ULONG
  168. // NatCreatePartialRedirect(
  169. // HANDLE TranslatorHandle,
  170. // ULONG Flags,
  171. // UCHAR Protocol,
  172. // ULONG DestinationAddress,
  173. // USHORT DestinationPort,
  174. // ULONG NewDestinationAddress,
  175. // USHORT NewDestinationPort,
  176. // PNAT_COMPLETION_ROUTINE CompletionRoutine,
  177. // PVOID CompletionContext,
  178. // HANDLE NotifyEvent OPTIONAL
  179. // );
  180. //
  181. #define \
  182. NatCreatePartialRedirect( \
  183. TranslatorHandle, \
  184. Flags, \
  185. Protocol, \
  186. DestinationAddress, \
  187. DestinationPort, \
  188. NewDestinationAddress, \
  189. NewDestinationPort, \
  190. CompletionRoutine, \
  191. CompletionContext, \
  192. NotifyEvent \
  193. ) \
  194. NatCreateRedirect( \
  195. TranslatorHandle, \
  196. Flags, \
  197. Protocol, \
  198. DestinationAddress, \
  199. DestinationPort, \
  200. 0, \
  201. 0, \
  202. NewDestinationAddress, \
  203. NewDestinationPort, \
  204. 0, \
  205. 0, \
  206. CompletionRoutine, \
  207. CompletionContext, \
  208. NotifyEvent \
  209. )
  210. #if _WIN32_WINNT > 0x0500
  211. //
  212. // ULONG
  213. // NatCreateAdapterRestrictedPartialRedirect(
  214. // HANDLE TranslatorHandle,
  215. // ULONG Flags,
  216. // UCHAR Protocol,
  217. // ULONG DestinationAddress,
  218. // USHORT DestinationPort,
  219. // ULONG NewDestinationAddress,
  220. // USHORT NewDestinationPort,
  221. // ULONG RestrictAdapterIndex,
  222. // PNAT_COMPLETION_ROUTINE CompletionRoutine,
  223. // PVOID CompletionContext,
  224. // HANDLE NotifyEvent OPTIONAL
  225. // );
  226. //
  227. #define \
  228. NatCreateAdapterRestrictedPartialRedirect( \
  229. TranslatorHandle, \
  230. Flags, \
  231. Protocol, \
  232. DestinationAddress, \
  233. DestinationPort, \
  234. NewDestinationAddress, \
  235. NewDestinationPort, \
  236. RestrictAdapterIndex, \
  237. CompletionRoutine, \
  238. CompletionContext, \
  239. NotifyEvent \
  240. ) \
  241. NatCreateRedirectEx( \
  242. TranslatorHandle, \
  243. Flags | NatRedirectFlagRestrictAdapter, \
  244. Protocol, \
  245. DestinationAddress, \
  246. DestinationPort, \
  247. 0, \
  248. 0, \
  249. NewDestinationAddress, \
  250. NewDestinationPort, \
  251. 0, \
  252. 0, \
  253. RestrictAdapterIndex, \
  254. CompletionRoutine, \
  255. CompletionContext, \
  256. NotifyEvent \
  257. )
  258. #endif
  259. //
  260. // ULONG
  261. // NatCreatePortRedirect(
  262. // HANDLE TranslatorHandle,
  263. // ULONG Flags,
  264. // UCHAR Protocol,
  265. // USHORT DestinationPort,
  266. // ULONG NewDestinationAddress,
  267. // USHORT NewDestinationPort,
  268. // PNAT_COMPLETION_ROUTINE CompletionRoutine,
  269. // PVOID CompletionContext,
  270. // HANDLE NotifyEvent OPTIONAL
  271. // );
  272. //
  273. #define \
  274. NatCreatePortRedirect( \
  275. TranslatorHandle, \
  276. Flags, \
  277. Protocol, \
  278. DestinationPort, \
  279. NewDestinationAddress, \
  280. NewDestinationPort, \
  281. CompletionRoutine, \
  282. CompletionContext, \
  283. NotifyEvent \
  284. ) \
  285. NatCreateRedirect( \
  286. TranslatorHandle, \
  287. Flags | NatRedirectFlagPortRedirect, \
  288. Protocol, \
  289. 0, \
  290. DestinationPort, \
  291. 0, \
  292. 0, \
  293. NewDestinationAddress, \
  294. NewDestinationPort, \
  295. 0, \
  296. 0, \
  297. CompletionRoutine, \
  298. CompletionContext, \
  299. NotifyEvent \
  300. )
  301. #if _WIN32_WINNT > 0x0500
  302. //
  303. // ULONG
  304. // NatCreateAdapterRestrictedPortRedirect(
  305. // HANDLE TranslatorHandle,
  306. // ULONG Flags,
  307. // UCHAR Protocol,
  308. // USHORT DestinationPort,
  309. // ULONG NewDestinationAddress,
  310. // USHORT NewDestinationPort,
  311. // ULONG RestrictAdapterIndex,
  312. // PNAT_COMPLETION_ROUTINE CompletionRoutine,
  313. // PVOID CompletionContext,
  314. // HANDLE NotifyEvent OPTIONAL
  315. // );
  316. //
  317. #define \
  318. NatCreateAdapterRestrictedPortRedirect( \
  319. TranslatorHandle, \
  320. Flags, \
  321. Protocol, \
  322. DestinationPort, \
  323. NewDestinationAddress, \
  324. NewDestinationPort, \
  325. RestrictAdapterIndex, \
  326. CompletionRoutine, \
  327. CompletionContext, \
  328. NotifyEvent \
  329. ) \
  330. NatCreateRedirectEx( \
  331. TranslatorHandle, \
  332. Flags | NatRedirectFlagPortRedirect | NatRedirectFlagRestrictAdapter, \
  333. Protocol, \
  334. 0, \
  335. DestinationPort, \
  336. 0, \
  337. 0, \
  338. NewDestinationAddress, \
  339. NewDestinationPort, \
  340. 0, \
  341. 0, \
  342. RestrictAdapterIndex, \
  343. CompletionRoutine, \
  344. CompletionContext, \
  345. NotifyEvent \
  346. )
  347. #endif
  348. ULONG
  349. NatCreateRedirect(
  350. HANDLE TranslatorHandle,
  351. ULONG Flags,
  352. UCHAR Protocol,
  353. ULONG DestinationAddress,
  354. USHORT DestinationPort,
  355. ULONG SourceAddress,
  356. USHORT SourcePort,
  357. ULONG NewDestinationAddress,
  358. USHORT NewDestinationPort,
  359. ULONG NewSourceAddress,
  360. USHORT NewSourcePort,
  361. PNAT_COMPLETION_ROUTINE CompletionRoutine,
  362. PVOID CompletionContext,
  363. HANDLE NotifyEvent OPTIONAL
  364. );
  365. #if _WIN32_WINNT > 0x0500
  366. //
  367. // If IPNATAPI_SET_EVENT_ON_COMPLETION is specified as the completion
  368. // routine, the completion context must be a valid event handle. The
  369. // event object that the handle refers to will be signaled upon the
  370. // completion of the redirect.
  371. //
  372. // N.B. Note that using this form of completion notification gives
  373. // no indication if the redirect was cancelled or completed normally.
  374. //
  375. #define IPNATAPI_SET_EVENT_ON_COMPLETION (PNAT_COMPLETION_ROUTINE) -1
  376. ULONG
  377. NatCreateRedirectEx(
  378. HANDLE TranslatorHandle,
  379. ULONG Flags,
  380. UCHAR Protocol,
  381. ULONG DestinationAddress,
  382. USHORT DestinationPort,
  383. ULONG SourceAddress,
  384. USHORT SourcePort,
  385. ULONG NewDestinationAddress,
  386. USHORT NewDestinationPort,
  387. ULONG NewSourceAddress,
  388. USHORT NewSourcePort,
  389. ULONG RestrictAdapterIndex OPTIONAL,
  390. PNAT_COMPLETION_ROUTINE CompletionRoutine,
  391. PVOID CompletionContext,
  392. HANDLE NotifyEvent OPTIONAL
  393. );
  394. #endif
  395. //
  396. // ULONG
  397. // NatCreateAddressRestrictedPartialRedirect(
  398. // HANDLE TranslatorHandle,
  399. // ULONG Flags,
  400. // UCHAR Protocol,
  401. // ULONG DestinationAddress,
  402. // USHORT DestinationPort,
  403. // ULONG NewDestinationAddress,
  404. // USHORT NewDestinationPort,
  405. // ULONG RestrictSourceAddress,
  406. // PNAT_COMPLETION_ROUTINE CompletionRoutine,
  407. // PVOID CompletionContext,
  408. // HANDLE NotifyEvent OPTIONAL
  409. // );
  410. //
  411. #define \
  412. NatCreateAddressRestrictedPartialRedirect( \
  413. TranslatorHandle, \
  414. Flags, \
  415. Protocol, \
  416. DestinationAddress, \
  417. DestinationPort, \
  418. NewDestinationAddress, \
  419. NewDestinationPort, \
  420. RestrictSourceAddress, \
  421. CompletionRoutine, \
  422. CompletionContext, \
  423. NotifyEvent \
  424. ) \
  425. NatCreateRedirect( \
  426. TranslatorHandle, \
  427. Flags | NatRedirectFlagRestrictSource, \
  428. Protocol, \
  429. DestinationAddress, \
  430. DestinationPort, \
  431. RestrictSourceAddress, \
  432. 0, \
  433. NewDestinationAddress, \
  434. NewDestinationPort, \
  435. 0, \
  436. 0, \
  437. CompletionRoutine, \
  438. CompletionContext, \
  439. NotifyEvent \
  440. )
  441. //
  442. // ULONG
  443. // NatCreateRestrictedPartialRedirect(
  444. // HANDLE TranslatorHandle,
  445. // ULONG Flags,
  446. // UCHAR Protocol,
  447. // ULONG DestinationAddress,
  448. // USHORT DestinationPort,
  449. // ULONG NewDestinationAddress,
  450. // USHORT NewDestinationPort,
  451. // ULONG RestrictSourceAddress,
  452. // PNAT_COMPLETION_ROUTINE CompletionRoutine,
  453. // PVOID CompletionContext,
  454. // HANDLE NotifyEvent OPTIONAL
  455. // );
  456. //
  457. #define \
  458. NatCreateRestrictedPartialRedirect( \
  459. TranslatorHandle, \
  460. Flags, \
  461. Protocol, \
  462. DestinationAddress, \
  463. DestinationPort, \
  464. NewDestinationAddress, \
  465. NewDestinationPort, \
  466. RestrictSourceAddress, \
  467. CompletionRoutine, \
  468. CompletionContext, \
  469. NotifyEvent \
  470. ) \
  471. NatCreateRedirect( \
  472. TranslatorHandle, \
  473. Flags | NatRedirectFlagRestrictSource, \
  474. Protocol, \
  475. DestinationAddress, \
  476. DestinationPort, \
  477. RestrictSourceAddress, \
  478. 0, \
  479. NewDestinationAddress, \
  480. NewDestinationPort, \
  481. 0, \
  482. 0, \
  483. CompletionRoutine, \
  484. CompletionContext, \
  485. NotifyEvent \
  486. )
  487. #if _WIN32_WINNT > 0x0500
  488. //
  489. // ULONG
  490. // NatCreateAdapterRestrictedAddressRestrictedPartialRedirect(
  491. // HANDLE TranslatorHandle,
  492. // ULONG Flags,
  493. // UCHAR Protocol,
  494. // ULONG DestinationAddress,
  495. // USHORT DestinationPort,
  496. // ULONG NewDestinationAddress,
  497. // USHORT NewDestinationPort,
  498. // ULONG RestrictSourceAddress,
  499. // ULONG RestrictAdapterIndex,
  500. // PNAT_COMPLETION_ROUTINE CompletionRoutine,
  501. // PVOID CompletionContext,
  502. // HANDLE NotifyEvent OPTIONAL
  503. // );
  504. //
  505. #define \
  506. NatCreateAdapterRestrictedAddressRestrictedPartialRedirect( \
  507. TranslatorHandle, \
  508. Flags, \
  509. Protocol, \
  510. DestinationAddress, \
  511. DestinationPort, \
  512. NewDestinationAddress, \
  513. NewDestinationPort, \
  514. RestrictSourceAddress, \
  515. RestrictAdapterIndex, \
  516. CompletionRoutine, \
  517. CompletionContext, \
  518. NotifyEvent \
  519. ) \
  520. NatCreateRedirectEx( \
  521. TranslatorHandle, \
  522. Flags | NatRedirectFlagRestrictSource | NatRedirectFlagRestrictAdapter, \
  523. Protocol, \
  524. DestinationAddress, \
  525. DestinationPort, \
  526. RestrictSourceAddress, \
  527. 0, \
  528. NewDestinationAddress, \
  529. NewDestinationPort, \
  530. 0, \
  531. 0, \
  532. RestrictAdapterIndex, \
  533. CompletionRoutine, \
  534. CompletionContext, \
  535. NotifyEvent \
  536. )
  537. #endif
  538. //
  539. // ULONG
  540. // NatQueryInformationPartialRedirect(
  541. // HANDLE TranslatorHandle,
  542. // UCHAR Protocol,
  543. // ULONG DestinationAddress,
  544. // USHORT DestinationPort,
  545. // ULONG NewDestinationAddress,
  546. // USHORT NewDestinationPort,
  547. // OUT PVOID Information,
  548. // IN OUT PULONG InformationLength,
  549. // NAT_REDIRECT_INFORMATION_CLASS InformationClass
  550. // );
  551. //
  552. #define \
  553. NatQueryInformationPartialRedirect( \
  554. TranslatorHandle, \
  555. Protocol, \
  556. DestinationAddress, \
  557. DestinationPort, \
  558. NewDestinationAddress, \
  559. NewDestinationPort, \
  560. Information, \
  561. InformationLength, \
  562. InformationClass \
  563. ) \
  564. NatQueryInformationRedirect( \
  565. TranslatorHandle, \
  566. Protocol, \
  567. DestinationAddress, \
  568. DestinationPort, \
  569. 0, \
  570. 0, \
  571. NewDestinationAddress, \
  572. NewDestinationPort, \
  573. 0, \
  574. 0, \
  575. Information, \
  576. InformationLength, \
  577. InformationClass \
  578. )
  579. //
  580. // ULONG
  581. // NatQueryInformationPortRedirect(
  582. // HANDLE TranslatorHandle,
  583. // UCHAR Protocol,
  584. // USHORT DestinationPort,
  585. // ULONG NewDestinationAddress,
  586. // USHORT NewDestinationPort,
  587. // OUT PVOID Information,
  588. // IN OUT PULONG InformationLength,
  589. // NAT_REDIRECT_INFORMATION_CLASS InformationClass
  590. // );
  591. //
  592. #define \
  593. NatQueryInformationPortRedirect( \
  594. TranslatorHandle, \
  595. Protocol, \
  596. DestinationPort, \
  597. NewDestinationAddress, \
  598. NewDestinationPort, \
  599. Information, \
  600. InformationLength, \
  601. InformationClass \
  602. ) \
  603. NatQueryInformationRedirect( \
  604. TranslatorHandle, \
  605. Protocol, \
  606. 0, \
  607. DestinationPort, \
  608. 0, \
  609. 0, \
  610. NewDestinationAddress, \
  611. NewDestinationPort, \
  612. 0, \
  613. 0, \
  614. Information, \
  615. InformationLength, \
  616. InformationClass \
  617. )
  618. ULONG
  619. NatQueryInformationRedirect(
  620. HANDLE TranslatorHandle,
  621. UCHAR Protocol,
  622. ULONG DestinationAddress,
  623. USHORT DestinationPort,
  624. ULONG SourceAddress,
  625. USHORT SourcePort,
  626. ULONG NewDestinationAddress,
  627. USHORT NewDestinationPort,
  628. ULONG NewSourceAddress,
  629. USHORT NewSourcePort,
  630. OUT PVOID Information,
  631. IN OUT PULONG InformationLength,
  632. NAT_REDIRECT_INFORMATION_CLASS InformationClass
  633. );
  634. ULONG
  635. NatQueryInformationRedirectHandle(
  636. HANDLE RedirectHandle,
  637. OUT PVOID Information,
  638. IN OUT PULONG InformationLength,
  639. NAT_REDIRECT_INFORMATION_CLASS InformationClass
  640. );
  641. //
  642. // Dynamic-redirect API declarations
  643. //
  644. #define NatCancelDynamicPortRedirect NatCancelDynamicRedirect
  645. #define NatCancelDynamicPartialRedirect NatCancelDynamicRedirect
  646. ULONG
  647. NatCancelDynamicRedirect(
  648. HANDLE DynamicRedirectHandle
  649. );
  650. //
  651. // ULONG
  652. // NatCreateDynamicPortRedirect(
  653. // ULONG Flags,
  654. // UCHAR Protocol,
  655. // USHORT DestinationPort,
  656. // ULONG NewDestinationAddress,
  657. // USHORT NewDestinationPort,
  658. // ULONG MinimumBacklog OPTIONAL,
  659. // OUT PHANDLE DynamicRedirectHandlep
  660. // );
  661. //
  662. #define \
  663. NatCreateDynamicPortRedirect( \
  664. Flags, \
  665. Protocol, \
  666. DestinationPort, \
  667. NewDestinationAddress, \
  668. NewDestinationPort, \
  669. MinimumBacklog, \
  670. DynamicRedirectHandlep \
  671. ) \
  672. NatCreateDynamicRedirect( \
  673. Flags | NatRedirectFlagPortRedirect, \
  674. Protocol, \
  675. 0, \
  676. DestinationPort, \
  677. NewDestinationAddress, \
  678. NewDestinationPort, \
  679. 0, \
  680. MinimumBacklog, \
  681. DynamicRedirectHandlep \
  682. )
  683. #if _WIN32_WINNT > 0x0500
  684. //
  685. // ULONG
  686. // NatCreateDynamicAdapterRestrictedPortRedirect(
  687. // ULONG Flags,
  688. // UCHAR Protocol,
  689. // USHORT DestinationPort,
  690. // ULONG NewDestinationAddress,
  691. // USHORT NewDestinationPort,
  692. // ULONG RestrictAdapterIndex,
  693. // ULONG MinimumBacklog OPTIONAL,
  694. // OUT PHANDLE DynamicRedirectHandlep
  695. // );
  696. //
  697. #define \
  698. NatCreateDynamicAdapterRestrictedPortRedirect( \
  699. Flags, \
  700. Protocol, \
  701. DestinationPort, \
  702. NewDestinationAddress, \
  703. NewDestinationPort, \
  704. RestrictAdapterIndex, \
  705. MinimumBacklog, \
  706. DynamicRedirectHandlep \
  707. ) \
  708. NatCreateDynamicRedirectEx( \
  709. Flags | NatRedirectFlagPortRedirect | NatRedirectFlagRestrictAdapter, \
  710. Protocol, \
  711. 0, \
  712. DestinationPort, \
  713. NewDestinationAddress, \
  714. NewDestinationPort, \
  715. 0, \
  716. RestrictAdapterIndex, \
  717. MinimumBacklog, \
  718. DynamicRedirectHandlep \
  719. )
  720. //
  721. // ULONG
  722. // NatCreateDynamicAdapterRestrictedSourcePortRedirect(
  723. // ULONG Flags,
  724. // UCHAR Protocol,
  725. // USHORT SourcePort,
  726. // ULONG NewDestinationAddress,
  727. // USHORT NewDestinationPort,
  728. // ULONG RestrictAdapterIndex,
  729. // ULONG MinimumBacklog OPTIONAL,
  730. // OUT PHANDLE DynamicRedirectHandlep
  731. // );
  732. //
  733. #define \
  734. NatCreateDynamicAdapterRestrictedSourcePortRedirect( \
  735. Flags, \
  736. Protocol, \
  737. SourcePort, \
  738. NewDestinationAddress, \
  739. NewDestinationPort, \
  740. RestrictAdapterIndex, \
  741. MinimumBacklog, \
  742. DynamicRedirectHandlep \
  743. ) \
  744. NatCreateDynamicFullRedirect( \
  745. Flags | NatRedirectFlagPortRedirect | NatRedirectFlagRestrictAdapter \
  746. | NatRedirectFlagSourceRedirect, \
  747. Protocol, \
  748. 0, \
  749. 0, \
  750. 0, \
  751. SourcePort, \
  752. NewDestinationAddress, \
  753. NewDestinationPort, \
  754. 0, \
  755. 0, \
  756. 0, \
  757. RestrictAdapterIndex, \
  758. MinimumBacklog, \
  759. DynamicRedirectHandlep \
  760. )
  761. //
  762. // ULONG
  763. // NatCreateDynamicAdapterRestrictedSourceRedirect(
  764. // ULONG Flags,
  765. // UCHAR Protocol,
  766. // ULONG SourceAddress
  767. // USHORT SourcePort,
  768. // ULONG NewSourceAddress,
  769. // USHORT NewSourcePort,
  770. // ULONG RestrictAdapterIndex,
  771. // ULONG MinimumBacklog OPTIONAL,
  772. // OUT PHANDLE DynamicRedirectHandlep
  773. // );
  774. //
  775. #define \
  776. NatCreateDynamicAdapterRestrictedSourceRedirect( \
  777. Flags, \
  778. Protocol, \
  779. SourceAddress, \
  780. SourcePort, \
  781. NewSourceAddress, \
  782. NewSourcePort, \
  783. RestrictAdapterIndex, \
  784. MinimumBacklog, \
  785. DynamicRedirectHandlep \
  786. ) \
  787. NatCreateDynamicFullRedirect( \
  788. Flags | NatRedirectFlagRestrictAdapter | NatRedirectFlagSourceRedirect, \
  789. Protocol, \
  790. 0, \
  791. 0, \
  792. SourceAddress, \
  793. SourcePort, \
  794. 0, \
  795. 0, \
  796. NewSourceAddress, \
  797. NewSourcePort, \
  798. 0, \
  799. RestrictAdapterIndex, \
  800. MinimumBacklog, \
  801. DynamicRedirectHandlep \
  802. )
  803. #endif
  804. //
  805. // ULONG
  806. // NatCreateDynamicPartialRedirect(
  807. // ULONG Flags,
  808. // UCHAR Protocol,
  809. // ULONG DestinationAddress,
  810. // USHORT DestinationPort,
  811. // ULONG NewDestinationAddress,
  812. // USHORT NewDestinationPort,
  813. // ULONG MinimumBacklog OPTIONAL,
  814. // OUT PHANDLE DynamicRedirectHandlep
  815. // );
  816. //
  817. #define \
  818. NatCreateDynamicPartialRedirect( \
  819. Flags, \
  820. Protocol, \
  821. DestinationAddress, \
  822. DestinationPort, \
  823. NewDestinationAddress, \
  824. NewDestinationPort, \
  825. MinimumBacklog, \
  826. DynamicRedirectHandlep \
  827. ) \
  828. NatCreateDynamicRedirect( \
  829. Flags, \
  830. Protocol, \
  831. DestinationAddress, \
  832. DestinationPort, \
  833. NewDestinationAddress, \
  834. NewDestinationPort, \
  835. 0, \
  836. MinimumBacklog, \
  837. DynamicRedirectHandlep \
  838. )
  839. #if _WIN32_WINNT > 0x0500
  840. //
  841. // ULONG
  842. // NatCreateDynamicAdapterRestrictedPartialRedirect(
  843. // ULONG Flags,
  844. // UCHAR Protocol,
  845. // ULONG DestinationAddress,
  846. // USHORT DestinationPort,
  847. // ULONG NewDestinationAddress,
  848. // USHORT NewDestinationPort,
  849. // ULONG RestrictAdapterIndex,
  850. // ULONG MinimumBacklog OPTIONAL,
  851. // OUT PHANDLE DynamicRedirectHandlep
  852. // );
  853. //
  854. #define \
  855. NatCreateDynamicAdapterRestrictedPartialRedirect( \
  856. Flags, \
  857. Protocol, \
  858. DestinationAddress, \
  859. DestinationPort, \
  860. NewDestinationAddress, \
  861. NewDestinationPort, \
  862. RestrictAdapterIndex, \
  863. MinimumBacklog, \
  864. DynamicRedirectHandlep \
  865. ) \
  866. NatCreateDynamicRedirectEx( \
  867. Flags | NatRedirectFlagRestrictAdapter, \
  868. Protocol, \
  869. DestinationAddress, \
  870. DestinationPort, \
  871. NewDestinationAddress, \
  872. NewDestinationPort, \
  873. 0, \
  874. RestrictAdapterIndex, \
  875. MinimumBacklog, \
  876. DynamicRedirectHandlep \
  877. )
  878. ULONG
  879. NatCreateDynamicFullRedirect(
  880. ULONG Flags,
  881. UCHAR Protocol,
  882. ULONG DestinationAddress,
  883. USHORT DestinationPort,
  884. ULONG SourceAddress,
  885. USHORT SourcePort,
  886. ULONG NewDestinationAddress,
  887. USHORT NewDestinationPort,
  888. ULONG NewSourceAddress,
  889. USHORT NewSourcePort,
  890. ULONG RestrictSourceAddress OPTIONAL,
  891. ULONG RestrictAdapterIndex OPTIONAL,
  892. ULONG MinimumBacklog OPTIONAL,
  893. OUT PHANDLE DynamicRedirectHandlep
  894. );
  895. #endif
  896. ULONG
  897. NatCreateDynamicRedirect(
  898. ULONG Flags,
  899. UCHAR Protocol,
  900. ULONG DestinationAddress,
  901. USHORT DestinationPort,
  902. ULONG NewDestinationAddress,
  903. USHORT NewDestinationPort,
  904. ULONG RestrictSourceAddress OPTIONAL,
  905. ULONG MinimumBacklog OPTIONAL,
  906. OUT PHANDLE DynamicRedirectHandlep
  907. );
  908. #if _WIN32_WINNT > 0x0500
  909. ULONG
  910. NatCreateDynamicRedirectEx(
  911. ULONG Flags,
  912. UCHAR Protocol,
  913. ULONG DestinationAddress,
  914. USHORT DestinationPort,
  915. ULONG NewDestinationAddress,
  916. USHORT NewDestinationPort,
  917. ULONG RestrictSourceAddress OPTIONAL,
  918. ULONG RestrictAdapterIndex OPTIONAL,
  919. ULONG MinimumBacklog OPTIONAL,
  920. OUT PHANDLE DynamicRedirectHandlep
  921. );
  922. #endif
  923. //
  924. // ULONG
  925. // NatCreateDynamicAddressRestrictedPartialRedirect(
  926. // ULONG Flags,
  927. // UCHAR Protocol,
  928. // ULONG DestinationAddress,
  929. // USHORT DestinationPort,
  930. // ULONG NewDestinationAddress,
  931. // USHORT NewDestinationPort,
  932. // ULONG RestrictSourceAddress,
  933. // ULONG MinimumBacklog OPTIONAL,
  934. // OUT PHANDLE DynamicRedirectHandlep
  935. // );
  936. //
  937. #define \
  938. NatCreateDynamicAddressRestrictedPartialRedirect( \
  939. Flags, \
  940. Protocol, \
  941. DestinationAddress, \
  942. DestinationPort, \
  943. NewDestinationAddress, \
  944. NewDestinationPort, \
  945. RestrictSourceAddress, \
  946. MinimumBacklog, \
  947. DynamicRedirectHandlep \
  948. ) \
  949. NatCreateDynamicRedirect( \
  950. Flags | NatRedirectFlagRestrictSource, \
  951. Protocol, \
  952. DestinationAddress, \
  953. DestinationPort, \
  954. NewDestinationAddress, \
  955. NewDestinationPort, \
  956. RestrictSourceAddress, \
  957. MinimumBacklog, \
  958. DynamicRedirectHandlep \
  959. )
  960. //
  961. // ULONG
  962. // NatCreateDynamicRestrictedPartialRedirect(
  963. // ULONG Flags,
  964. // UCHAR Protocol,
  965. // ULONG DestinationAddress,
  966. // USHORT DestinationPort,
  967. // ULONG NewDestinationAddress,
  968. // USHORT NewDestinationPort,
  969. // ULONG RestrictSourceAddress,
  970. // ULONG MinimumBacklog OPTIONAL,
  971. // OUT PHANDLE DynamicRedirectHandlep
  972. // );
  973. //
  974. #define \
  975. NatCreateDynamicRestrictedPartialRedirect( \
  976. Flags, \
  977. Protocol, \
  978. DestinationAddress, \
  979. DestinationPort, \
  980. NewDestinationAddress, \
  981. NewDestinationPort, \
  982. RestrictSourceAddress, \
  983. MinimumBacklog, \
  984. DynamicRedirectHandlep \
  985. ) \
  986. NatCreateDynamicRedirect( \
  987. Flags | NatRedirectFlagRestrictSource, \
  988. Protocol, \
  989. DestinationAddress, \
  990. DestinationPort, \
  991. NewDestinationAddress, \
  992. NewDestinationPort, \
  993. RestrictSourceAddress, \
  994. MinimumBacklog, \
  995. DynamicRedirectHandlep \
  996. )
  997. #if _WIN32_WINNT > 0x0500
  998. //
  999. // ULONG
  1000. // NatCreateDynamicAdapterRestrictedAddressRestrictedPartialRedirect(
  1001. // ULONG Flags,
  1002. // UCHAR Protocol,
  1003. // ULONG DestinationAddress,
  1004. // USHORT DestinationPort,
  1005. // ULONG NewDestinationAddress,
  1006. // USHORT NewDestinationPort,
  1007. // ULONG RestrictSourceAddress,
  1008. // ULONG RestrictAdapterIndex,
  1009. // ULONG MinimumBacklog OPTIONAL,
  1010. // OUT PHANDLE DynamicRedirectHandlep
  1011. // );
  1012. //
  1013. #define \
  1014. NatCreateDynamicAdapterRestrictedAddressRestrictedPartialRedirect( \
  1015. Flags, \
  1016. Protocol, \
  1017. DestinationAddress, \
  1018. DestinationPort, \
  1019. NewDestinationAddress, \
  1020. NewDestinationPort, \
  1021. RestrictSourceAddress, \
  1022. RestrictAdapterIndex, \
  1023. MinimumBacklog, \
  1024. DynamicRedirectHandlep \
  1025. ) \
  1026. NatCreateDynamicRedirectEx( \
  1027. Flags | NatRedirectFlagRestrictSource | NatRedirectFlagRestrictAdapter, \
  1028. Protocol, \
  1029. DestinationAddress, \
  1030. DestinationPort, \
  1031. NewDestinationAddress, \
  1032. NewDestinationPort, \
  1033. RestrictSourceAddress, \
  1034. RestrictAdapterIndex, \
  1035. MinimumBacklog, \
  1036. DynamicRedirectHandlep \
  1037. )
  1038. //
  1039. // ULONG
  1040. // NatCreateDynamicSourcePortRedirect(
  1041. // ULONG Flags,
  1042. // UCHAR Protocol,
  1043. // USHORT SourcePort,
  1044. // ULONG NewDestinationAddress,
  1045. // USHORT NewDestinationPort,
  1046. // ULONG MinimumBacklog OPTIONAL,
  1047. // OUT PHANDLE DynamicRedirectHandlep
  1048. // );
  1049. //
  1050. #define \
  1051. NatCreateDynamicSourcePortRedirect( \
  1052. Flags, \
  1053. Protocol, \
  1054. SourcePort, \
  1055. NewDestinationAddress, \
  1056. NewDestinationPort, \
  1057. MinimumBacklog, \
  1058. DynamicRedirectHandlep \
  1059. ) \
  1060. NatCreateDynamicFullRedirect( \
  1061. Flags | NatRedirectFlagPortRedirect | NatRedirectFlagSourceRedirect, \
  1062. Protocol, \
  1063. 0, \
  1064. 0, \
  1065. 0, \
  1066. SourcePort, \
  1067. NewDestinationAddress, \
  1068. NewDestinationPort, \
  1069. 0, \
  1070. 0, \
  1071. 0, \
  1072. 0, \
  1073. MinimumBacklog, \
  1074. DynamicRedirectHandlep \
  1075. )
  1076. //
  1077. // ULONG
  1078. // NatCreateDynamicSourceRedirect(
  1079. // ULONG Flags,
  1080. // UCHAR Protocol,
  1081. // ULONG SourceAddress
  1082. // USHORT SourcePort,
  1083. // ULONG NewSourceAddress,
  1084. // USHORT NewSourcePort,
  1085. // ULONG MinimumBacklog OPTIONAL,
  1086. // OUT PHANDLE DynamicRedirectHandlep
  1087. // );
  1088. //
  1089. #define \
  1090. NatCreateDynamicSourceRedirect( \
  1091. Flags, \
  1092. Protocol, \
  1093. SourceAddress, \
  1094. SourcePort, \
  1095. NewSourceAddress, \
  1096. NewSourcePort, \
  1097. MinimumBacklog, \
  1098. DynamicRedirectHandlep \
  1099. ) \
  1100. NatCreateDynamicFullRedirect( \
  1101. Flags | NatRedirectFlagSourceRedirect, \
  1102. Protocol, \
  1103. 0, \
  1104. 0, \
  1105. SourceAddress, \
  1106. SourcePort, \
  1107. 0, \
  1108. 0, \
  1109. NewSourceAddress, \
  1110. NewSourcePort, \
  1111. 0, \
  1112. 0, \
  1113. MinimumBacklog, \
  1114. DynamicRedirectHandlep \
  1115. )
  1116. #endif
  1117. //
  1118. // Session-mapping API declarations
  1119. //
  1120. typedef enum _NAT_SESSION_MAPPING_INFORMATION {
  1121. NatKeySessionMappingInformation,
  1122. NatStatisticsSessionMappingInformation,
  1123. #if _WIN32_WINNT > 0x0500
  1124. NatKeySessionMappingExInformation,
  1125. #endif
  1126. NatMaximumSessionMappingInformation
  1127. } NAT_SESSION_MAPPING_INFORMATION_CLASS,
  1128. *PNAT_SESSION_MAPPING_INFORMATION_CLASS;
  1129. typedef struct _NAT_KEY_SESSION_MAPPING_INFORMATION {
  1130. UCHAR Protocol;
  1131. ULONG DestinationAddress;
  1132. USHORT DestinationPort;
  1133. ULONG SourceAddress;
  1134. USHORT SourcePort;
  1135. ULONG NewDestinationAddress;
  1136. USHORT NewDestinationPort;
  1137. ULONG NewSourceAddress;
  1138. USHORT NewSourcePort;
  1139. } NAT_KEY_SESSION_MAPPING_INFORMATION, *PNAT_KEY_SESSION_MAPPING_INFORMATION;
  1140. #if _WIN32_WINNT > 0x0500
  1141. typedef struct _NAT_KEY_SESSION_MAPPING_EX_INFORMATION {
  1142. UCHAR Protocol;
  1143. ULONG DestinationAddress;
  1144. USHORT DestinationPort;
  1145. ULONG SourceAddress;
  1146. USHORT SourcePort;
  1147. ULONG NewDestinationAddress;
  1148. USHORT NewDestinationPort;
  1149. ULONG NewSourceAddress;
  1150. USHORT NewSourcePort;
  1151. ULONG AdapterIndex;
  1152. } NAT_KEY_SESSION_MAPPING_EX_INFORMATION, *PNAT_KEY_SESSION_MAPPING_EX_INFORMATION;
  1153. #endif
  1154. typedef struct _NAT_STATISTICS_SESSION_MAPPING_INFORMATION {
  1155. ULONG64 BytesForward;
  1156. ULONG64 BytesReverse;
  1157. ULONG64 PacketsForward;
  1158. ULONG64 PacketsReverse;
  1159. ULONG64 RejectsForward;
  1160. ULONG64 RejectsReverse;
  1161. } NAT_STATISTICS_SESSION_MAPPING_INFORMATION,
  1162. *PNAT_STATISTICS_SESSION_MAPPING_INFORMATION;
  1163. ULONG
  1164. NatLookupAndQueryInformationSessionMapping(
  1165. HANDLE TranslatorHandle,
  1166. UCHAR Protocol,
  1167. ULONG DestinationAddress,
  1168. USHORT DestinationPort,
  1169. ULONG SourceAddress,
  1170. USHORT SourcePort,
  1171. OUT PVOID Information,
  1172. IN OUT PULONG InformationLength,
  1173. NAT_SESSION_MAPPING_INFORMATION_CLASS InformationClass
  1174. );
  1175. //
  1176. // Port-reservation API declarations
  1177. //
  1178. ULONG
  1179. NatInitializePortReservation(
  1180. USHORT BlockSize,
  1181. OUT PHANDLE ReservationHandle
  1182. );
  1183. VOID
  1184. NatShutdownPortReservation(
  1185. HANDLE ReservationHandle
  1186. );
  1187. ULONG
  1188. NatAcquirePortReservation(
  1189. HANDLE ReservationHandle,
  1190. USHORT PortCount,
  1191. OUT PUSHORT ReservedPortBase
  1192. );
  1193. ULONG
  1194. NatReleasePortReservation(
  1195. HANDLE ReservationHandle,
  1196. USHORT ReservedPortBase,
  1197. USHORT PortCount
  1198. );
  1199. #ifdef __cplusplus
  1200. }
  1201. #endif
  1202. #endif // _ROUTING_IPNATAPI_H_