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.

279 lines
4.9 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. homenetp.h
  5. Abstract:
  6. Header file for functions shared in home network transport.
  7. Author:
  8. Jim Schmidt (jimschm) 03-Jul-2000
  9. Revision History:
  10. <alias> <date> <comments>
  11. --*/
  12. //
  13. // Includes
  14. //
  15. #include "logmsg.h"
  16. //
  17. // Strings
  18. //
  19. #define S_TRANSPORT_DAT_FILE TEXT("TRANSDB.DAT")
  20. #define S_TRANSPORT_IMG_FILE TEXT("IMG%05X.DAT")
  21. //
  22. // Constants
  23. //
  24. #define GLOBALKEY_SIZE 8
  25. #define HOMENETTR_SIG 0x55534D32 //USM2
  26. #define TRSTATUS_DIRTY 0x00000001
  27. #define TRSTATUS_READY 0x00000002
  28. #define TRSTATUS_LOCKED 0x00000003
  29. #define TRFLAG_FILE 0x01
  30. #define TRFLAG_MEMORY 0x02
  31. #define MESSAGE_ERROR 0x0000
  32. #define MESSAGE_FILE 0x0001
  33. #define MESSAGE_DONE 0x0002
  34. #define MESSAGE_KEEP_ALIVE 0x0003
  35. #define MESSAGE_DATA 0x0004
  36. #define MESSAGE_PASSWORDWRONG 0x0005
  37. #define MESSAGE_PASSWORDOK 0x0006
  38. #define MESSAGE_CANCEL 0x0007
  39. #define MAX_SOCKADDR (max(sizeof(SOCKADDR_IN),max(sizeof(SOCKADDR_IPX),sizeof(SOCKADDR_NB))))
  40. //
  41. // Macros
  42. //
  43. // None
  44. //
  45. // Types
  46. //
  47. #pragma pack(push,1)
  48. typedef struct {
  49. WORD PacketNumber;
  50. WORD DataLength;
  51. } DATAGRAM_PACKET, *PDATAGRAM_PACKET;
  52. #pragma pack(pop)
  53. typedef struct TAG_DATAGRAM_POOL_ITEM {
  54. struct TAG_DATAGRAM_POOL_ITEM *Next, *Prev;
  55. DATAGRAM_PACKET Header;
  56. PCBYTE PacketData;
  57. // PacketData follows
  58. } DATAGRAM_POOL_ITEM, *PDATAGRAM_POOL_ITEM;
  59. typedef struct {
  60. PMHANDLE Pool;
  61. PDATAGRAM_POOL_ITEM FirstItem;
  62. WORD SendSequenceNumber;
  63. WORD RecvSequenceNumber;
  64. UINT LastPacketNumber;
  65. } DATAGRAM_POOL, *PDATAGRAM_POOL;
  66. typedef struct {
  67. SOCKET Socket;
  68. BYTE LocalAddress[MAX_SOCKADDR];
  69. INT LocalAddressLen;
  70. BYTE RemoteAddress[MAX_SOCKADDR];
  71. INT RemoteAddressLen;
  72. INT Family;
  73. INT Protocol;
  74. DATAGRAM_POOL DatagramPool;
  75. BOOL Datagram;
  76. UINT LastSend;
  77. UINT KeepAliveSpacing;
  78. } CONNECTIONSOCKET, *PCONNECTIONSOCKET;
  79. typedef struct {
  80. BYTE LocalAddress[MAX_SOCKADDR];
  81. INT LocalAddressLen;
  82. BYTE RemoteAddress[MAX_SOCKADDR];
  83. INT RemoteAddressLen;
  84. INT Family;
  85. INT Protocol;
  86. BOOL Datagram;
  87. TCHAR DestinationName[MAX_COMPUTER_NAME];
  88. } CONNECTADDRESS, *PCONNECTADDRESS;
  89. typedef struct {
  90. UINT StructSize;
  91. DWORD Signature;
  92. UINT FileCount;
  93. LONGLONG TotalSize;
  94. TCHAR SourceName[MAX_COMPUTER_NAME];
  95. } TRANSFERMETRICS, *PTRANSFERMETRICS;
  96. //
  97. // Globals
  98. //
  99. extern PCTSTR g_TransportTempDir;
  100. extern PCTSTR g_StatusFile;
  101. extern HANDLE g_StatusFileHandle;
  102. extern UINT g_Platform;
  103. extern TRANSFERMETRICS g_Metrics;
  104. extern CONNECTIONSOCKET g_Connection;
  105. extern BOOL g_CompressData;
  106. extern HANDLE g_BackgroundThread;
  107. extern HANDLE g_BackgroundThreadTerminate;
  108. extern MIG_PROGRESSSLICEID g_DownloadSlice;
  109. extern UINT g_DownloadTicks;
  110. extern UINT g_DownloadSliceSize;
  111. extern CHAR g_GlobalKey [GLOBALKEY_SIZE + 1];
  112. //
  113. // Macro expansion list
  114. //
  115. // None
  116. //
  117. // Public function prototypes
  118. //
  119. BOOL
  120. FindDestination (
  121. OUT PCONNECTADDRESS Address,
  122. IN UINT Timeout, OPTIONAL
  123. IN BOOL IgnoreMultipleDests
  124. );
  125. BOOL
  126. TestConnection (
  127. IN PCONNECTADDRESS Address
  128. );
  129. BOOL
  130. ConnectToDestination (
  131. IN PCONNECTADDRESS Address,
  132. IN PTRANSFERMETRICS Metrics,
  133. OUT PCONNECTIONSOCKET Connection
  134. );
  135. DWORD
  136. SendMessageToDestination (
  137. IN PCONNECTIONSOCKET Connection,
  138. IN DWORD Message
  139. );
  140. BOOL
  141. SendFileToDestination (
  142. IN PCONNECTIONSOCKET Connection,
  143. IN PCTSTR LocalPath, OPTIONAL
  144. IN PCTSTR DestSubPath OPTIONAL
  145. );
  146. BOOL
  147. SendDataToDestination (
  148. IN PCONNECTIONSOCKET Connection,
  149. IN PCBYTE Data,
  150. IN UINT DataSize
  151. );
  152. BOOL
  153. ConnectToSource (
  154. OUT PCONNECTIONSOCKET Connection,
  155. OUT PTRANSFERMETRICS Metrics
  156. );
  157. DWORD
  158. ReceiveFromSource (
  159. IN PCONNECTIONSOCKET Connection,
  160. IN PCTSTR LocalFileRoot,
  161. OUT PBYTE *Buffer,
  162. IN UINT Timeout OPTIONAL
  163. );
  164. VOID
  165. CloseConnection (
  166. IN PCONNECTIONSOCKET Connection
  167. );
  168. DWORD
  169. GetTransportStatus (
  170. IN PCTSTR TrJournal,
  171. OUT PBOOL Compressed OPTIONAL
  172. );
  173. PCTSTR
  174. BuildImageFileName (
  175. IN UINT ImageIdx
  176. );
  177. VOID
  178. FreeImageFileName (
  179. IN PCTSTR ImageFileName
  180. );
  181. PCTSTR
  182. CreateStorageDir (
  183. VOID
  184. );
  185. PCTSTR
  186. BuildDecoratedObject (
  187. IN MIG_OBJECTTYPEID ObjectTypeId,
  188. IN ENCODEDSTRHANDLE ObjectName
  189. );
  190. VOID
  191. DestroyDecoratedObject (
  192. IN PCTSTR String
  193. );
  194. PCTSTR
  195. AllocStorageFileName (
  196. IN PCTSTR FileName OPTIONAL
  197. );
  198. VOID
  199. FreeStorageFileName (
  200. IN PCTSTR NameToFree
  201. );
  202. DWORD
  203. WINAPI
  204. DestinationBackgroundThread (
  205. PVOID DontCare
  206. );
  207. //
  208. // Macro expansion definition
  209. //
  210. // None
  211. //
  212. // ANSI/UNICODE macros
  213. //
  214. // None