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.

334 lines
6.2 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. session.h
  5. Abstract:
  6. Structures, prototypes for session.c
  7. Author:
  8. Heath Hunnicutt (t-hheath) 21-Jun-1994
  9. Revision History:
  10. 21-Jun-1994 t-heathh
  11. Created
  12. --*/
  13. #if defined(__cplusplus)
  14. extern "C" {
  15. #endif
  16. //
  17. // manifests
  18. //
  19. #define FTP_SESSION_SIGNATURE 0x53707446 // "FtpS" (when viewed via db/dc)
  20. //
  21. // macros
  22. //
  23. #if INET_DEBUG
  24. #define SetSessionSignature(lpSessionInfo) \
  25. (lpSessionInfo)->Signature = FTP_SESSION_SIGNATURE
  26. #else
  27. #define SetSessionSignature(lpSessionInfo)
  28. #endif
  29. #define SetSessionLastResponseCode(pSession, prc) \
  30. CopyMemory(&((pSession)->rcResponseOpenFile), (prc), sizeof(FTP_RESPONSE_CODE))
  31. #define GetSessionLastResponseCode(pSession, prc) \
  32. CopyMemory((prc), &((pSession)->rcResponseOpenFile), sizeof(FTP_RESPONSE_CODE))
  33. #define IsPassiveModeSession(lpSessionInfo) \
  34. (((lpSessionInfo)->Flags & FFTP_PASSIVE_MODE) ? TRUE : FALSE)
  35. //
  36. // types
  37. //
  38. typedef enum {
  39. FTP_SERVER_TYPE_UNKNOWN = 0,
  40. FTP_SERVER_TYPE_NT = 1,
  41. FTP_SERVER_TYPE_UNIX = 2
  42. } FTP_SERVER_TYPE;
  43. //
  44. // FTP_SESSION_INFO - describes an FTP server and our connection to it
  45. //
  46. typedef struct {
  47. //
  48. // List - SESSION_INFOs are maintained on double-linked list
  49. //
  50. LIST_ENTRY List;
  51. //
  52. // Host - name of the server we are connected to. We only need this for
  53. // diagnositic purposes - e.g. knowing which server to talk to to
  54. // reproduce a problem
  55. //
  56. LPSTR Host;
  57. //
  58. // Port - the port at which the FTP server listens
  59. //
  60. INTERNET_PORT Port;
  61. //
  62. // socketListener - listening socket
  63. //
  64. ICSocket *socketListener;
  65. //
  66. // socketControl - control connection socket
  67. //
  68. ICSocket *socketControl;
  69. //
  70. // socketData - data connection socket
  71. //
  72. ICSocket *socketData;
  73. //
  74. // ServerType - type of FTP server, e.g. NT or *nix
  75. //
  76. FTP_SERVER_TYPE ServerType;
  77. //
  78. // Handle - internally identifies this FTP session
  79. //
  80. HANDLE Handle;
  81. //
  82. // Flags - bitmask of various flags - see below
  83. //
  84. DWORD Flags;
  85. //
  86. // ReferenceCount - keeps object alive whilst we are not holding
  87. // CriticalSection
  88. //
  89. LONG ReferenceCount;
  90. //
  91. // dwTransferAccess - Indicates, for an ongoing transfer, whether the
  92. // transfer was begun with GENERIC_READ or GENERIC_WRITE access.
  93. //
  94. // {dwTransferAccess} = {GENERIC_READ, GENERIC_WRITE}
  95. //
  96. DWORD dwTransferAccess;
  97. //
  98. // rcResponseOpenFile - The response code sent back when a data connection
  99. // was opened, either by FtpOpenFile or FtpCommand.
  100. //
  101. // Used by FtpCloseFile to determine whether the completion
  102. // code was already received.
  103. //
  104. FTP_RESPONSE_CODE rcResponseOpenFile;
  105. //
  106. // FindFileList - A linked-list of WIN32_FIND_DATA structures, formed by a
  107. // call to FtpFindFirstFile, used by FtpFindNextFile and
  108. // FtpFindClose.
  109. //
  110. LIST_ENTRY FindFileList;
  111. //
  112. // CriticalSection - Synchronize access to this structure's contents
  113. //
  114. CRITICAL_SECTION CriticalSection;
  115. //
  116. // dwFileSizeLow - Size of the file found on the FTP server, should be gotten
  117. // from response data on openning a data connection
  118. //
  119. DWORD dwFileSizeLow;
  120. DWORD dwFileSizeHigh;
  121. #if INET_DEBUG
  122. //
  123. // Signature - to help us know this is what its supposed to be in debug build
  124. //
  125. DWORD Signature;
  126. #endif
  127. } FTP_SESSION_INFO, *LPFTP_SESSION_INFO;
  128. //
  129. // Flags defines
  130. //
  131. //
  132. // FFTP_PASSIVE_MODE - set if the session uses passive mode data connections
  133. //
  134. #define FFTP_PASSIVE_MODE 0x00000001
  135. //
  136. // FFTP_ABORT_TRANSFER - set if we have not completed a file transfer on this
  137. // (data) connection, and therefore need to send an ABOR command when we close
  138. // the connection
  139. //
  140. #define FFTP_ABORT_TRANSFER 0x00000002
  141. //
  142. // FFTP_FIND_ACTIVE - set when a directory listing is active on this session
  143. //
  144. #define FFTP_FIND_ACTIVE 0x00000004
  145. //
  146. // FFTP_IN_DESTRUCTOR - set when this session is being terminated
  147. //
  148. #define FFTP_IN_DESTRUCTOR 0x00000008
  149. //
  150. // FFTP_EOF - set when we have reached the end of a (receive) data connection
  151. //
  152. #define FFTP_EOF 0x00000010
  153. //
  154. // FFTP_FILE_ACTIVE - set when a file is open on this session
  155. //
  156. #define FFTP_FILE_ACTIVE 0x00000020
  157. //
  158. // FFTP_KNOWN_FILE_SIZE - set when we know the size of the file we're downloading
  159. //
  160. #define FFTP_KNOWN_FILE_SIZE 0x00000040
  161. //
  162. // prototypes
  163. //
  164. VOID
  165. CleanupFtpSessions(
  166. VOID
  167. );
  168. VOID
  169. TerminateFtpSession(
  170. IN LPFTP_SESSION_INFO SessionInfo
  171. );
  172. VOID
  173. DereferenceFtpSession(
  174. IN LPFTP_SESSION_INFO SessionInfo
  175. );
  176. DWORD
  177. CreateFtpSession(
  178. IN LPSTR lpszHost,
  179. IN INTERNET_PORT Port,
  180. IN DWORD dwFlags,
  181. OUT LPFTP_SESSION_INFO* lpSessionInfo
  182. );
  183. BOOL
  184. FindFtpSession(
  185. IN HANDLE Handle,
  186. OUT LPFTP_SESSION_INFO* lpSessionInfo
  187. );
  188. #if INET_DEBUG
  189. VOID
  190. FtpSessionInitialize(
  191. VOID
  192. );
  193. VOID
  194. FtpSessionTerminate(
  195. VOID
  196. );
  197. VOID
  198. AcquireFtpSessionList(
  199. VOID
  200. );
  201. VOID
  202. ReleaseFtpSessionList(
  203. VOID
  204. );
  205. VOID
  206. AcquireFtpSessionLock(
  207. IN LPFTP_SESSION_INFO SessionInfo
  208. );
  209. VOID
  210. ReleaseFtpSessionLock(
  211. IN LPFTP_SESSION_INFO SessionInfo
  212. );
  213. #else
  214. //
  215. // one-line functions replaced by macros in retail version
  216. //
  217. extern SERIALIZED_LIST FtpSessionList;
  218. #define FtpSessionInitialize() \
  219. InitializeSerializedList(&FtpSessionList)
  220. #define FtpSessionTerminate() \
  221. TerminateSerializedList(&FtpSessionList)
  222. #define AcquireFtpSessionList() \
  223. LockSerializedList(&FtpSessionList)
  224. #define ReleaseFtpSessionList() \
  225. UnlockSerializedList(&FtpSessionList)
  226. #define AcquireFtpSessionLock(lpSessionInfo) \
  227. EnterCriticalSection(&lpSessionInfo->CriticalSection)
  228. #define ReleaseFtpSessionLock(lpSessionInfo) \
  229. LeaveCriticalSection(&lpSessionInfo->CriticalSection)
  230. #endif // INET_DEBUG
  231. #if defined(__cplusplus)
  232. }
  233. #endif