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.

210 lines
3.8 KiB

  1. //
  2. // Copyright (C) 2001 Microsoft Corp
  3. //
  4. // FtpControl.cpp
  5. //
  6. // Sanjiv
  7. // JPDup
  8. //
  9. #pragma once
  10. class CFtpControlConnection;
  11. //#include "PreComp.h" // Theis FtpControl.h file get included by MyAlg.h that is used in the ALG.exe build
  12. // so we can't use this precompile file
  13. #include "buffer.h"
  14. #include "list.h"
  15. #define FTP_MAX_MSG_SIZE 1024
  16. typedef enum _READ_TYPE
  17. {
  18. CLIENT_READ = 0x1,
  19. SERVER_READ = 0x2
  20. } READ_TYPE;
  21. typedef enum _CONNECTION_TYPE
  22. {
  23. INCOMING = 0x1,
  24. OUTGOING = 0x2
  25. }CONNECTION_TYPE;
  26. extern CControlObjectList g_ControlObjectList;
  27. #define ERROR_IO_CANCELLED 0xC0000120
  28. #define DATA_CREATION_TIMEO 1000
  29. #define ADD_STR_SIZE 23
  30. class CControlState
  31. {
  32. public:
  33. ULONG m_nAddressNew;
  34. ULONG m_nAddressOld;
  35. USHORT m_nPortNew;
  36. USHORT m_nPortOld;
  37. UCHAR m_szAddressPortNew[ADD_STR_SIZE];
  38. ULONG m_nAddressLenNew;
  39. };
  40. //
  41. //
  42. // Main class that controls the FTP
  43. //
  44. //
  45. class CFtpControlConnection
  46. {
  47. public:
  48. // Constructor(s)
  49. CFtpControlConnection();
  50. // Destruction
  51. ~CFtpControlConnection();
  52. //
  53. // Properties
  54. //
  55. SOCKET m_ClientConnectedSocket;
  56. SOCKET m_AlgConnectedSocket;
  57. USHORT m_nSourcePortReplacement;
  58. private:
  59. IPendingProxyConnection* m_pPendingProxy;
  60. CONNECTION_TYPE m_ConnectionType;
  61. CControlState m_ControlState;
  62. volatile LONG m_RefCount;
  63. CDataChannelList m_DataChannelList;
  64. //
  65. // Methods
  66. //
  67. private:
  68. //
  69. void
  70. ProcessFtpMessage(
  71. UCHAR* Buffer,
  72. ULONG* pBytes
  73. );
  74. //
  75. HRESULT
  76. CreateNewAddress(void);
  77. //
  78. HRESULT
  79. SetupDataRedirect(void);
  80. public:
  81. //
  82. ULONG
  83. IncReference();
  84. //
  85. ULONG
  86. DecReference();
  87. //
  88. void
  89. Shutdown();
  90. //
  91. HRESULT
  92. Init(
  93. SOCKET AcceptedSocket,
  94. ULONG ToAddr,
  95. USHORT ToPort,
  96. CONNECTION_TYPE ConnType
  97. );
  98. //
  99. void
  100. DataChannelDeletion(
  101. BOOLEAN TimerOrWait,
  102. PVOID Context
  103. );
  104. //
  105. void
  106. DataChannelCreation(
  107. BOOLEAN TimerOrWait,
  108. PVOID Context
  109. );
  110. //
  111. void
  112. ConnectCompletionRoutine(
  113. ULONG ErrCode,
  114. ULONG BytesTransferred
  115. );
  116. //
  117. void
  118. ReadCompletionRoutine(
  119. ULONG ErrCode,
  120. ULONG BytesTransferred,
  121. PNH_BUFFER Bufferp
  122. );
  123. //
  124. void
  125. WriteCompletionRoutine(
  126. ULONG ErrCode,
  127. ULONG BytesTransferred,
  128. PNH_BUFFER Bufferp
  129. );
  130. };
  131. void
  132. DataChannelCreationCallback(
  133. BOOLEAN TimerOrWait,PVOID Context,PVOID Context2
  134. );
  135. void
  136. DataChannelDeletionCallback(
  137. BOOLEAN TimerOrWait,PVOID Context,PVOID Context2
  138. );
  139. void
  140. MyAcceptCompletion(
  141. ULONG ErrCode,
  142. ULONG BytesTransferred,
  143. PNH_BUFFER Bufferp);
  144. void
  145. MyConnectCompletion(ULONG ErrCode,
  146. ULONG BytesTransferred,
  147. PNH_BUFFER Bufferp);
  148. void
  149. MyReadCompletion(ULONG ErrCode,
  150. ULONG BytesTransferred,
  151. PNH_BUFFER Bufferp);
  152. void
  153. MyWriteCompletion(ULONG ErrCode,
  154. ULONG BytesTransferred,
  155. PNH_BUFFER Bufferp);