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.

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