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.

124 lines
3.1 KiB

  1. /*++
  2. Copyright (c) 1997, Microsoft Corporation
  3. Module Name:
  4. nbt.h
  5. Abstract:
  6. This module contains declarations for the NAT's NetBT support.
  7. NetBT's datagram service embeds source IP address/port in the datagrams
  8. that it sends out, hence the need for additional translation.
  9. Author:
  10. Abolade Gbadegesin (t-abolag) 25-Aug-1997
  11. Revision History:
  12. --*/
  13. #ifndef _NAT_NBT_H_
  14. #define _NAT_NBT_H_
  15. //
  16. // Structure: NAT_NBT_MAPPING
  17. //
  18. // This structure describes a mapping defined to allow translation of
  19. // NetBT datagram-service sessions across the NAT.
  20. //
  21. // The NetBT datagram-service operates over UDP using port 138 for sending
  22. // and receiving messages. This means that regardless of what value the NAT
  23. // places in the NetBT datagram header, replies will be directed to port 138.
  24. // Therefore, in order to translate NetBT datagrams, the NAT must incorporate
  25. // additional information.
  26. //
  27. // The NAT registers a handler for outbound traffic destined for the NetBT
  28. // datagram-service port, as well as implementing an IP-layer translator
  29. // for inbound traffic destined for the NetBT datagram-service port.
  30. // Each outgoing message is then examined, and a mapping is created using
  31. // (a) the source (private) IP address in the datagram header
  32. // (b) the public IP address chosen by the NAT
  33. // (c) the source name in the datagram header
  34. // The source IP address is then replaced with the public IP address,
  35. // and the source port is replaced with the NetBT datagram-service port.
  36. //
  37. // Each incoming message is in turn examined by the IP-layer translator,
  38. // and a lookup is done using
  39. // (a) the receiving (public) IP address
  40. // (b) the destination name in the datagram header.
  41. // after which the packet's destination IP address is translated.
  42. //
  43. // A list of mappings is maintained on each interface, ordered by
  44. // by public IP address and source name for outbound searching.
  45. //
  46. typedef struct _NAT_NBT_MAPPING {
  47. LIST_ENTRY Link;
  48. ULONG PrivateAddress;
  49. ULONG PublicAddress;
  50. UCHAR SourceName[NBT_NAME_LENGTH];
  51. LONG64 LastAccessTime;
  52. } NAT_NBT_MAPPING, *PNAT_NBT_MAPPING;
  53. //
  54. // NBT mapping allocation macros
  55. //
  56. #define ALLOCATE_NBT_BLOCK() \
  57. ExAllocateFromNPagedLookasideList(&NbtLookasideList)
  58. #define FREE_NBT_BLOCK(Block) \
  59. ExFreeToNPagedLookasideList(&NbtLookasideList,(Block))
  60. //
  61. // FUNCTION DECLARATIONS
  62. //
  63. NTSTATUS
  64. NatCreateNbtMapping(
  65. PNAT_INTERFACE Interfacep,
  66. ULONG PrivateAddress,
  67. ULONG PublicAddress,
  68. UCHAR SourceName[],
  69. PLIST_ENTRY InboundInsertionPoint,
  70. PNAT_NBT_MAPPING* MappingCreated
  71. );
  72. PNAT_NBT_MAPPING
  73. NatLookupInboundNbtMapping(
  74. PNAT_INTERFACE Interfacep,
  75. ULONG PublicAddress,
  76. UCHAR SourceName[],
  77. PLIST_ENTRY* InboundInsertionPoint
  78. );
  79. NTSTATUS
  80. NatInitializeEditorNbt(
  81. VOID
  82. );
  83. NTSTATUS
  84. NatOutboundDataHandlerNbt(
  85. IN PVOID InterfaceHandle,
  86. IN PVOID SessionHandle,
  87. IN PVOID DataHandle,
  88. IN PVOID EditorContext,
  89. IN PVOID EditorSessionContext,
  90. IN PVOID RecvBuffer,
  91. IN ULONG DataOffset
  92. );
  93. XLATE_IP_ROUTINE(NatTranslateNbt)
  94. extern IP_NAT_REGISTER_EDITOR NbtRegisterEditor;
  95. #endif // _NAT_NBT_H_