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.

230 lines
4.8 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. AlgIF.h
  5. Abstract:
  6. This module contains declarations for the ALG transparent proxy's
  7. interface management.
  8. Author:
  9. Qiang Wang (qiangw) 10-Apr-2000
  10. Revision History:
  11. --*/
  12. #pragma once
  13. //
  14. // Structure: ALG_BINDING
  15. //
  16. // This structure holds information used for I/O on a logical network.
  17. // Each interface's 'BindingArray' contains an entry for each binding-entry
  18. // supplied during 'BindInterface'.
  19. //
  20. typedef struct _ALG_BINDING {
  21. ULONG Address;
  22. ULONG Mask;
  23. SOCKET ListeningSocket;
  24. HANDLE ListeningRedirectHandle[2];
  25. } ALG_BINDING, *PALG_BINDING;
  26. //
  27. // Structure: ALG_INTERFACE
  28. //
  29. // This structure holds operational information for an interface.
  30. //
  31. // Each interface is inserted into the list of ALG transparent proxy
  32. // interfaces, sorted by 'Index'.
  33. //
  34. // Synchronization on an interface makes use of an interface-list lock
  35. // ('AlgInterfaceLock'), a per-interface reference count, and a per-interface
  36. // critical-section:
  37. //
  38. // Acquiring a reference to an interface guarantees the interface's existence;
  39. // acquiring the interface's lock guarantees the interface's consistency.
  40. //
  41. // To acquire a reference, first acquire the interface-list lock;
  42. // to traverse the interface-list, first acquire the interface-list lock.
  43. //
  44. // An interface's lock can only be acquired if
  45. // (a) a reference to the interface has been acquired, or
  46. // (b) the interface-list lock is currently held.
  47. // Note that holding the list lock alone does not guarantee consistency.
  48. //
  49. // Fields marked read-only can be read so long as the interface is referenced.
  50. //
  51. typedef struct _ALG_INTERFACE {
  52. LIST_ENTRY Link;
  53. CRITICAL_SECTION Lock;
  54. ULONG ReferenceCount;
  55. ULONG Index; // read-only
  56. ULONG AdapterIndex; // read-only
  57. ULONG Characteristics; //read-only after activation
  58. NET_INTERFACE_TYPE Type; // read-only
  59. IP_ALG_INTERFACE_INFO Info;
  60. IP_NAT_PORT_MAPPING PortMapping;
  61. ULONG Flags;
  62. ULONG BindingCount;
  63. PALG_BINDING BindingArray;
  64. LIST_ENTRY ConnectionList;
  65. LIST_ENTRY EndpointList;
  66. } ALG_INTERFACE, *PALG_INTERFACE;
  67. //
  68. // Flags
  69. //
  70. #define ALG_INTERFACE_FLAG_DELETED 0x80000000
  71. #define ALG_INTERFACE_DELETED(i) \
  72. ((i)->Flags & ALG_INTERFACE_FLAG_DELETED)
  73. #define ALG_INTERFACE_FLAG_BOUND 0x40000000
  74. #define ALG_INTERFACE_BOUND(i) \
  75. ((i)->Flags & ALG_INTERFACE_FLAG_BOUND)
  76. #define ALG_INTERFACE_FLAG_ENABLED 0x20000000
  77. #define ALG_INTERFACE_ENABLED(i) \
  78. ((i)->Flags & ALG_INTERFACE_FLAG_ENABLED)
  79. #define ALG_INTERFACE_FLAG_CONFIGURED 0x10000000
  80. #define ALG_INTERFACE_CONFIGURED(i) \
  81. ((i)->Flags & ALG_INTERFACE_FLAG_CONFIGURED)
  82. #define ALG_INTERFACE_FLAG_MAPPED 0x01000000
  83. #define ALG_INTERFACE_MAPPED(i) \
  84. ((i)->Flags & ALG_INTERFACE_FLAG_MAPPED)
  85. #define ALG_INTERFACE_ACTIVE(i) \
  86. (((i)->Flags & (ALG_INTERFACE_FLAG_BOUND|ALG_INTERFACE_FLAG_ENABLED)) \
  87. == (ALG_INTERFACE_FLAG_BOUND|ALG_INTERFACE_FLAG_ENABLED))
  88. #define ALG_INTERFACE_ADMIN_DISABLED(i) \
  89. ((i)->Flags & IP_ALG_INTERFACE_FLAG_DISABLED)
  90. //
  91. // Synchronization
  92. //
  93. #define ALG_REFERENCE_INTERFACE(i) \
  94. REFERENCE_OBJECT(i, ALG_INTERFACE_DELETED)
  95. #define ALG_DEREFERENCE_INTERFACE(i) \
  96. DEREFERENCE_OBJECT(i, AlgCleanupInterface)
  97. //
  98. // GLOBAL DATA DECLARATIONS
  99. //
  100. extern LIST_ENTRY AlgInterfaceList;
  101. extern CRITICAL_SECTION AlgInterfaceLock;
  102. extern ULONG AlgFirewallIfCount;
  103. //
  104. // FUNCTION DECLARATIONS
  105. //
  106. ULONG
  107. AlgAcceptConnectionInterface(
  108. PALG_INTERFACE Interfacep,
  109. SOCKET ListeningSocket,
  110. SOCKET AcceptedSocket OPTIONAL,
  111. PNH_BUFFER Bufferp OPTIONAL,
  112. OUT PHANDLE DynamicRedirectHandlep OPTIONAL
  113. );
  114. ULONG
  115. AlgActivateInterface(
  116. PALG_INTERFACE Interfacep
  117. );
  118. ULONG
  119. AlgBindInterface(
  120. ULONG Index,
  121. PIP_ADAPTER_BINDING_INFO BindingInfo
  122. );
  123. VOID
  124. AlgCleanupInterface(
  125. PALG_INTERFACE Interfacep
  126. );
  127. ULONG
  128. AlgConfigureInterface(
  129. ULONG Index,
  130. PIP_ALG_INTERFACE_INFO InterfaceInfo
  131. );
  132. ULONG
  133. AlgCreateInterface(
  134. ULONG Index,
  135. NET_INTERFACE_TYPE Type,
  136. PIP_ALG_INTERFACE_INFO InterfaceInfo,
  137. PALG_INTERFACE* InterfaceCreated
  138. );
  139. VOID
  140. AlgDeactivateInterface(
  141. PALG_INTERFACE Interfacep
  142. );
  143. ULONG
  144. AlgDeleteInterface(
  145. ULONG Index
  146. );
  147. ULONG
  148. AlgDisableInterface(
  149. ULONG Index
  150. );
  151. ULONG
  152. AlgEnableInterface(
  153. ULONG Index
  154. );
  155. ULONG
  156. AlgInitializeInterfaceManagement(
  157. VOID
  158. );
  159. PALG_INTERFACE
  160. AlgLookupInterface(
  161. ULONG Index,
  162. OUT PLIST_ENTRY* InsertionPoint OPTIONAL
  163. );
  164. ULONG
  165. AlgQueryInterface(
  166. ULONG Index,
  167. PVOID InterfaceInfo,
  168. PULONG InterfaceInfoSize
  169. );
  170. VOID
  171. AlgShutdownInterfaceManagement(
  172. VOID
  173. );
  174. VOID
  175. AlgSignalNatInterface(
  176. ULONG Index,
  177. BOOLEAN Boundary
  178. );
  179. ULONG
  180. AlgUnbindInterface(
  181. ULONG Index
  182. );