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.

216 lines
7.9 KiB

  1. /******************************************************************************
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. UploadLibrary.h
  5. Abstract:
  6. This file contains the declaration of support structures and typedefs
  7. for the Transport Procotol used by the Upload Library.
  8. Revision History:
  9. Davide Massarenti (Dmassare) 04/20/99
  10. created
  11. ******************************************************************************/
  12. #if !defined(__INCLUDED___UL___UPLOADLIBRARY_H___)
  13. #define __INCLUDED___UL___UPLOADLIBRARY_H___
  14. #include <MPC_main.h>
  15. #include <MPC_utils.h>
  16. #include <MPC_streams.h>
  17. #define UPLOAD_LIBRARY_PROTOCOL_SIGNATURE (0x55504C42) // UPLB
  18. #define UPLOAD_LIBRARY_PROTOCOL_VERSION_CLT (0xBEEF0102)
  19. #define UPLOAD_LIBRARY_PROTOCOL_VERSION_SRV (0xBEEF0202)
  20. #define UPLOAD_LIBRARY_PROTOCOL_VERSION_CLT__TEXTONLY (0x434c5431) // CLT1
  21. #define UPLOAD_LIBRARY_PROTOCOL_VERSION_SRV__TEXTONLY (0x53525631) // SRV1
  22. /////////////////////////////////////////////////////////////////////////
  23. namespace UploadLibrary
  24. {
  25. //
  26. // This enumeration defines the commands understood by the server.
  27. //
  28. typedef enum
  29. {
  30. UL_COMMAND_OPENSESSION = 0x00,
  31. UL_COMMAND_WRITESESSION = 0x01
  32. } Command;
  33. //
  34. // This enumeration defines the response codes generated by the server.
  35. //
  36. typedef enum
  37. {
  38. UL_RESPONSE_SUCCESS = 0x00000000,
  39. UL_RESPONSE_SKIPPED = 0x00000001 | UL_RESPONSE_SUCCESS, // Ok, but move forward.
  40. UL_RESPONSE_COMMITTED = 0x00000002 | UL_RESPONSE_SUCCESS, // File has been committed.
  41. UL_RESPONSE_FAILED = 0x80000000,
  42. UL_RESPONSE_BAD_REQUEST = 0x00000001 | UL_RESPONSE_FAILED, // Bad packet format.
  43. UL_RESPONSE_DENIED = 0x00000002 | UL_RESPONSE_FAILED, // Generic access deny.
  44. UL_RESPONSE_NOT_AUTHORIZED = 0x00000003 | UL_RESPONSE_FAILED, // Authorization failure.
  45. UL_RESPONSE_QUOTA_EXCEEDED = 0x00000004 | UL_RESPONSE_FAILED, // Quota exceeded.
  46. UL_RESPONSE_BUSY = 0x00000005 | UL_RESPONSE_FAILED, // Server is busy, retry later.
  47. UL_RESPONSE_EXISTS = 0x00000006 | UL_RESPONSE_FAILED, // File already exists and is committed.
  48. UL_RESPONSE_NOTACTIVE = 0x00000007 | UL_RESPONSE_FAILED, // Session not active.
  49. UL_RESPONSE_BADCRC = 0x00000008 | UL_RESPONSE_FAILED // The sent bytes and the CRC don't match!!
  50. } Response;
  51. /////////////////////////////////////////////////////////////////////////
  52. //
  53. // Forward declaractions.
  54. //
  55. struct Signature;
  56. struct RequestHeader;
  57. struct ClientRequest;
  58. struct ClientRequest_OpenSession;
  59. struct ClientRequest_WriteSession;
  60. struct ServerResponse;
  61. /////////////////////////////////////////////////////////////////////////
  62. MPC::Serializer* SelectStream( MPC::Serializer& stream, MPC::Serializer_Text& streamText );
  63. /////////////////////////////////////////////////////////////////////////
  64. //
  65. // This structure defines the authentication signature of a client.
  66. //
  67. struct Signature // Hungarian: sig
  68. {
  69. GUID guidMachineID;
  70. DWORD dwHash;
  71. Signature( /*[in]*/ GUID id = IID_IUnknown ) : guidMachineID( id ),
  72. dwHash ( 0 ) {}
  73. bool operator==( /*[in]*/ const Signature& sig ) const
  74. {
  75. if(IsEqualGUID( guidMachineID, sig.guidMachineID ) == FALSE) return false;
  76. if(dwHash != sig.dwHash) return false;
  77. return true;
  78. }
  79. friend HRESULT operator>>( /*[in]*/ MPC::Serializer& stream, /*[out]*/ struct Signature& sigVal );
  80. friend HRESULT operator<<( /*[in]*/ MPC::Serializer& stream, /*[in] */ const struct Signature& sigVal );
  81. };
  82. //
  83. // This structure defines the start of every request.
  84. //
  85. struct RequestHeader // Hungarian: rh
  86. {
  87. DWORD dwSignature;
  88. DWORD dwVersion;
  89. RequestHeader( /*[in]*/ DWORD dwMode ) : dwSignature( UPLOAD_LIBRARY_PROTOCOL_SIGNATURE ), dwVersion( dwMode ) {}
  90. friend HRESULT operator>>( /*[in]*/ MPC::Serializer& stream, /*[out]*/ struct RequestHeader& rhVal );
  91. friend HRESULT operator<<( /*[in]*/ MPC::Serializer& stream, /*[in] */ const struct RequestHeader& rhVal );
  92. bool VerifyClient() const;
  93. bool VerifyServer() const;
  94. };
  95. //
  96. // This structure defines the tipical response from the server.
  97. //
  98. struct ServerResponse // Hungarian: sr
  99. {
  100. RequestHeader rhProlog;
  101. DWORD fResponse;
  102. DWORD dwPosition;
  103. ServerResponse( /*[in]*/ DWORD dwVer, /*[in]*/ DWORD fRes = UL_RESPONSE_DENIED ) : rhProlog ( dwVer ),
  104. fResponse ( fRes ),
  105. dwPosition ( 0 ) {}
  106. friend HRESULT operator>>( /*[in]*/ MPC::Serializer& stream, /*[out]*/ struct ServerResponse& srVal );
  107. friend HRESULT operator<<( /*[in]*/ MPC::Serializer& stream, /*[in] */ const struct ServerResponse& srVal );
  108. bool MatchVersion( /*[in]*/ const ClientRequest& cr );
  109. };
  110. //
  111. // This structure defines the start of every client request.
  112. //
  113. struct ClientRequest // Hungarian: cr
  114. {
  115. RequestHeader rhProlog;
  116. Signature sigClient;
  117. DWORD dwCommand;
  118. ClientRequest( /*[in]*/ DWORD dwVer, /*[in]*/ DWORD dwCmd = -1 ) : rhProlog ( dwVer ),
  119. dwCommand( dwCmd ) {}
  120. friend HRESULT operator>>( /*[in]*/ MPC::Serializer& stream, /*[out]*/ struct ClientRequest& crVal );
  121. friend HRESULT operator<<( /*[in]*/ MPC::Serializer& stream, /*[in] */ const struct ClientRequest& crVal );
  122. };
  123. //
  124. // This structure defines an 'Open New or Old File' request.
  125. //
  126. struct ClientRequest_OpenSession // Hungarian: cros
  127. {
  128. ClientRequest crHeader;
  129. MPC::wstring szJobID;
  130. MPC::wstring szProviderID;
  131. MPC::wstring szUsername;
  132. DWORD dwSize;
  133. DWORD dwSizeOriginal;
  134. DWORD dwCRC;
  135. bool fCompressed;
  136. ClientRequest_OpenSession( /*[in]*/ DWORD dwVer ) : crHeader ( dwVer, UL_COMMAND_OPENSESSION ),
  137. dwSize ( 0 ),
  138. dwSizeOriginal( 0 ),
  139. fCompressed ( false ) {}
  140. friend HRESULT operator>>( /*[in]*/ MPC::Serializer& stream, /*[out]*/ struct ClientRequest_OpenSession& crosVal );
  141. friend HRESULT operator<<( /*[in]*/ MPC::Serializer& stream, /*[in] */ const struct ClientRequest_OpenSession& crosVal );
  142. };
  143. //
  144. // This structure defines a request to add new data to an opened file.
  145. //
  146. struct ClientRequest_WriteSession // Hungarian: crws
  147. {
  148. ClientRequest crHeader;
  149. MPC::wstring szJobID;
  150. DWORD dwOffset;
  151. DWORD dwSize;
  152. ClientRequest_WriteSession( /*[in]*/ DWORD dwVer ) : crHeader( dwVer, UL_COMMAND_WRITESESSION ),
  153. dwOffset( 0 ),
  154. dwSize ( 0 ) {}
  155. friend HRESULT operator>>( /*[in]*/ MPC::Serializer& stream, /*[out]*/ struct ClientRequest_WriteSession& crwsVal );
  156. friend HRESULT operator<<( /*[in]*/ MPC::Serializer& stream, /*[in] */ const struct ClientRequest_WriteSession& crwsVal );
  157. };
  158. }; // namespace
  159. /////////////////////////////////////////////////////////////////////////
  160. #endif // !defined(__INCLUDED___UL___UPLOADLIBRARY_H___)