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.

232 lines
4.8 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. ftpif.h
  5. Abstract:
  6. This module contains declarations for the FTP transparent proxy's
  7. interface management.
  8. Author:
  9. Qiang Wang (qiangw) 10-Apr-2000
  10. Revision History:
  11. --*/
  12. #ifndef _NATHLP_FTPIF_H_
  13. #define _NATHLP_FTPIF_H_
  14. //
  15. // Structure: FTP_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 _FTP_BINDING {
  22. ULONG Address;
  23. ULONG Mask;
  24. SOCKET ListeningSocket;
  25. HANDLE ListeningRedirectHandle[2];
  26. } FTP_BINDING, *PFTP_BINDING;
  27. //
  28. // Structure: FTP_INTERFACE
  29. //
  30. // This structure holds operational information for an interface.
  31. //
  32. // Each interface is inserted into the list of FTP transparent proxy
  33. // interfaces, sorted by 'Index'.
  34. //
  35. // Synchronization on an interface makes use of an interface-list lock
  36. // ('FtpInterfaceLock'), 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 _FTP_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_FTP_INTERFACE_INFO Info;
  61. IP_NAT_PORT_MAPPING PortMapping;
  62. ULONG Flags;
  63. ULONG BindingCount;
  64. PFTP_BINDING BindingArray;
  65. LIST_ENTRY ConnectionList;
  66. LIST_ENTRY EndpointList;
  67. } FTP_INTERFACE, *PFTP_INTERFACE;
  68. //
  69. // Flags
  70. //
  71. #define FTP_INTERFACE_FLAG_DELETED 0x80000000
  72. #define FTP_INTERFACE_DELETED(i) \
  73. ((i)->Flags & FTP_INTERFACE_FLAG_DELETED)
  74. #define FTP_INTERFACE_FLAG_BOUND 0x40000000
  75. #define FTP_INTERFACE_BOUND(i) \
  76. ((i)->Flags & FTP_INTERFACE_FLAG_BOUND)
  77. #define FTP_INTERFACE_FLAG_ENABLED 0x20000000
  78. #define FTP_INTERFACE_ENABLED(i) \
  79. ((i)->Flags & FTP_INTERFACE_FLAG_ENABLED)
  80. #define FTP_INTERFACE_FLAG_CONFIGURED 0x10000000
  81. #define FTP_INTERFACE_CONFIGURED(i) \
  82. ((i)->Flags & FTP_INTERFACE_FLAG_CONFIGURED)
  83. #define FTP_INTERFACE_FLAG_MAPPED 0x01000000
  84. #define FTP_INTERFACE_MAPPED(i) \
  85. ((i)->Flags & FTP_INTERFACE_FLAG_MAPPED)
  86. #define FTP_INTERFACE_ACTIVE(i) \
  87. (((i)->Flags & (FTP_INTERFACE_FLAG_BOUND|FTP_INTERFACE_FLAG_ENABLED)) \
  88. == (FTP_INTERFACE_FLAG_BOUND|FTP_INTERFACE_FLAG_ENABLED))
  89. #define FTP_INTERFACE_ADMIN_DISABLED(i) \
  90. ((i)->Flags & IP_FTP_INTERFACE_FLAG_DISABLED)
  91. //
  92. // Synchronization
  93. //
  94. #define FTP_REFERENCE_INTERFACE(i) \
  95. REFERENCE_OBJECT(i, FTP_INTERFACE_DELETED)
  96. #define FTP_DEREFERENCE_INTERFACE(i) \
  97. DEREFERENCE_OBJECT(i, FtpCleanupInterface)
  98. //
  99. // GLOBAL DATA DECLARATIONS
  100. //
  101. extern LIST_ENTRY FtpInterfaceList;
  102. extern CRITICAL_SECTION FtpInterfaceLock;
  103. extern ULONG FtpFirewallIfCount;
  104. //
  105. // FUNCTION DECLARATIONS
  106. //
  107. ULONG
  108. FtpAcceptConnectionInterface(
  109. PFTP_INTERFACE Interfacep,
  110. SOCKET ListeningSocket,
  111. SOCKET AcceptedSocket OPTIONAL,
  112. PNH_BUFFER Bufferp OPTIONAL,
  113. OUT PHANDLE DynamicRedirectHandlep OPTIONAL
  114. );
  115. ULONG
  116. FtpActivateInterface(
  117. PFTP_INTERFACE Interfacep
  118. );
  119. ULONG
  120. FtpBindInterface(
  121. ULONG Index,
  122. PIP_ADAPTER_BINDING_INFO BindingInfo
  123. );
  124. VOID
  125. FtpCleanupInterface(
  126. PFTP_INTERFACE Interfacep
  127. );
  128. ULONG
  129. FtpConfigureInterface(
  130. ULONG Index,
  131. PIP_FTP_INTERFACE_INFO InterfaceInfo
  132. );
  133. ULONG
  134. FtpCreateInterface(
  135. ULONG Index,
  136. NET_INTERFACE_TYPE Type,
  137. PIP_FTP_INTERFACE_INFO InterfaceInfo,
  138. PFTP_INTERFACE* InterfaceCreated
  139. );
  140. VOID
  141. FtpDeactivateInterface(
  142. PFTP_INTERFACE Interfacep
  143. );
  144. ULONG
  145. FtpDeleteInterface(
  146. ULONG Index
  147. );
  148. ULONG
  149. FtpDisableInterface(
  150. ULONG Index
  151. );
  152. ULONG
  153. FtpEnableInterface(
  154. ULONG Index
  155. );
  156. ULONG
  157. FtpInitializeInterfaceManagement(
  158. VOID
  159. );
  160. PFTP_INTERFACE
  161. FtpLookupInterface(
  162. ULONG Index,
  163. OUT PLIST_ENTRY* InsertionPoint OPTIONAL
  164. );
  165. ULONG
  166. FtpQueryInterface(
  167. ULONG Index,
  168. PVOID InterfaceInfo,
  169. PULONG InterfaceInfoSize
  170. );
  171. VOID
  172. FtpShutdownInterfaceManagement(
  173. VOID
  174. );
  175. VOID
  176. FtpSignalNatInterface(
  177. ULONG Index,
  178. BOOLEAN Boundary
  179. );
  180. ULONG
  181. FtpUnbindInterface(
  182. ULONG Index
  183. );
  184. #endif // _NATHLP_FTPIF_H_