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.

116 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 1998, Microsoft Corporation
  3. Module Name:
  4. raw.h
  5. Abstract:
  6. This module contains declarations for translation of raw IP packets,
  7. i.e. IP packets whose 'protocol field does not contain a recognized
  8. value.
  9. Author:
  10. Abolade Gbadegesin (aboladeg) 18-Apr-1998
  11. Revision History:
  12. Abolade Gbadegesin (aboladeg) 18-Apr-1998
  13. Based on icmp.h.
  14. --*/
  15. #ifndef _NAT_RAW_H_
  16. #define _NAT_RAW_H_
  17. //
  18. // Structure: NAT_IP_MAPPING
  19. //
  20. // This structure holds information about a mapping created
  21. // for a raw IP packet.
  22. // Each such mapping is on its interface's lists of mappings.
  23. // The inbound list is sorted on the 'PublicKey' and 'Protocol',
  24. // and the outbound list is sorted on the 'PrivateKey' and 'Protocol'.
  25. //
  26. typedef struct _NAT_IP_MAPPING {
  27. LIST_ENTRY Link[NatMaximumDirection];
  28. ULONG64 PublicKey;
  29. ULONG64 PrivateKey;
  30. UCHAR Protocol;
  31. LONG64 LastAccessTime;
  32. } NAT_IP_MAPPING, *PNAT_IP_MAPPING;
  33. //
  34. // IP mapping key macros
  35. //
  36. #define MAKE_IP_KEY(RemoteAddress,OtherAddress) \
  37. ((ULONG)(RemoteAddress) | ((ULONG64)((ULONG)(OtherAddress)) << 32))
  38. #define IP_KEY_REMOTE(Key) ((ULONG)(Key))
  39. #define IP_KEY_PRIVATE(Key) ((ULONG)((Key) >> 32))
  40. #define IP_KEY_PUBLIC(Key) ((ULONG)((Key) >> 32))
  41. //
  42. // IP mapping allocation macros
  43. //
  44. #define ALLOCATE_IP_BLOCK() \
  45. ExAllocateFromNPagedLookasideList(&IpLookasideList)
  46. #define FREE_IP_BLOCK(Block) \
  47. ExFreeToNPagedLookasideList(&IpLookasideList,(Block))
  48. extern NPAGED_LOOKASIDE_LIST IpLookasideList;
  49. extern LIST_ENTRY IpMappingList[NatMaximumDirection];
  50. extern KSPIN_LOCK IpMappingLock;
  51. //
  52. // IP MAPPING MANAGEMENT ROUTINES
  53. //
  54. NTSTATUS
  55. NatCreateIpMapping(
  56. PNAT_INTERFACE Interfacep,
  57. ULONG RemoteAddress,
  58. ULONG PrivateAddress,
  59. ULONG PublicAddress,
  60. UCHAR Protocol,
  61. PLIST_ENTRY InboundInsertionPoint,
  62. PLIST_ENTRY OutboundInsertionPoint,
  63. PNAT_IP_MAPPING* MappingCreated
  64. );
  65. VOID
  66. NatInitializeRawIpManagement(
  67. VOID
  68. );
  69. PNAT_IP_MAPPING
  70. NatLookupInboundIpMapping(
  71. ULONG64 PublicKey,
  72. UCHAR Protocol,
  73. PLIST_ENTRY* InsertionPoint
  74. );
  75. PNAT_IP_MAPPING
  76. NatLookupOutboundIpMapping(
  77. ULONG64 PrivateKey,
  78. UCHAR Protocol,
  79. PLIST_ENTRY* InsertionPoint
  80. );
  81. VOID
  82. NatShutdownRawIpManagement(
  83. VOID
  84. );
  85. XLATE_IP_ROUTINE(NatTranslateIp);
  86. #endif // _NAT_RAW_H_