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.

270 lines
10 KiB

  1. /*
  2. * remote filename and checksum server
  3. *
  4. * sumserve.h packet definitions
  5. *
  6. * client attaches to the named pipe \\servername\pipe\NPNAME,
  7. * and sends one of the request packets below. He then
  8. * waits for one or more of the reply packets.
  9. *
  10. * when he gets a reply packet indicating the end of the reply,
  11. * he either sends another request, or closes his named pipe handle.
  12. *
  13. */
  14. /* Versions...
  15. * The server must always be at a version at least as great as a client.
  16. * New versions of the server will handle old clients (at least for a bit?)
  17. * The client specifies a version number when it connects. (The original
  18. * version with no number is version 0). The server will then respond
  19. * with structures and protocols for that version. The version number is
  20. * included in the response packets to allow me to change this scheme,
  21. * should it ever be necessary.
  22. * New version requests can be distinguished from version 0 requests by
  23. * having NEGATIVE request codes.
  24. */
  25. /* name of named pipe */
  26. #define NPNAME "sumserve"
  27. #define SS_VERSION 1 /* latest version number */
  28. /* request packets ---------------------------------- */
  29. typedef struct {
  30. long lCode; /* request code (below) */
  31. char szPath[MAX_PATH]; /* null terminated pathname string */
  32. } SSREQUEST, * PSSREQUEST;
  33. /* If the requst comes in with a NEGATIVE lCode then it means use this
  34. * structure instead. This has a version number and so future structures
  35. * can all be told apart by that.
  36. */
  37. typedef struct {
  38. long lCode; /* request code (below) */
  39. long lRequest; /* should be LREQUEST */
  40. long lVersion; /* version number */
  41. DWORD lFlags; /* options - INCLUDESUBS is only one so far */
  42. char szPath[MAX_PATH]; /* null terminated pathname string */
  43. char szLocal[MAX_PATH]; /* for a FILES request, the local name is
  44. appended directly after the terminating
  45. NULL of szPath. This field ensures
  46. enough space is allocated */
  47. } SSNEWREQ, * PSSNEWREQ;
  48. #define INCLUDESUBS 0x01
  49. #define LREQUEST 33333333
  50. /* values for lCode*/
  51. /* server should exit. no args. will receive no response */
  52. #define SSREQ_EXIT 32895 /* chosen to be an unusual number so that
  53. we will NOT get one of these by mistake.
  54. New version server will fail to respond to
  55. version 0 EXIT requests. Big deal!
  56. */
  57. /* arg is a pathname: please send all files with checksums.
  58. * will receive either SSRESP_BADPASS or a mixture of 0 or more SSRESP_FILE and
  59. * SSRESP_ERROR responses, terminated by SSRESP_END.
  60. */
  61. #define SSREQ_SCAN 2 /* please return list of dirs. arg:path */
  62. /* end of this client's session. no args. will receive no response */
  63. #define SSREQ_END 3 /* end of session - I have no more requests */
  64. /* szPath buffer contains two null-term. strings. first is the password,
  65. * second is the \\server\share name. please make a connection to this
  66. * server for the rest of my session.
  67. * one reply: either SSRESP_ERROR or SSRESP_END
  68. */
  69. #define SSREQ_UNC 4 /* connect to UNC name passed. szPath contains
  70. * two null-terminated strings; first is
  71. * the password, second is \\server\share
  72. *
  73. * share will be disconnected at end of client
  74. * session.
  75. */
  76. /*
  77. * please send a file. szPath is the name of the file. response
  78. * will be a sequence of ssPacket structs, continuing until lSequence is < 1
  79. * or ulSize is 0
  80. */
  81. #define SSREQ_FILE 5
  82. /*
  83. * please send a set of files, First request does NOT have a file.
  84. * a series of following NEXTFILE requests do name the files.
  85. * The NEXTFILE requests expect no response. After the last
  86. * files request will come an SSREQ_ENDFILES.
  87. */
  88. #define SSREQ_FILES 6
  89. #define SSREQ_NEXTFILE 7
  90. #define SSREQ_ENDFILES 8
  91. /* arg is a pathname: please send all files with times, sizes but NO checksums.
  92. * will receive either SSRESP_BADPASS or a mixture of 0 or more SSRESP_FILE and
  93. * SSRESP_ERROR responses, terminated by SSRESP_END.
  94. */
  95. #define SSREQ_QUICKSCAN 9 /* please return list of dirs. arg:path */
  96. /*
  97. * please send the error log buffer (in one packet)
  98. */
  99. #define SSREQ_ERRORLOG 10
  100. /*
  101. * please send the activity log buffer in one packet
  102. */
  103. #define SSREQ_EVENTLOG 11
  104. /*
  105. * please send the current connections log in one packet
  106. */
  107. #define SSREQ_CONNECTS 12
  108. /* response packets ---------------------------------- */
  109. typedef struct {
  110. long lCode; /* response code */
  111. ULONG ulSize; /* file size */
  112. ULONG ulSum; /* checksum for file */
  113. char szFile[MAX_PATH]; /* null-term. filename relative to orig req. */
  114. } SSRESPONSE, * PSSRESPONSE;
  115. /* for version 1 and later */
  116. typedef struct { /* files.c knows this is
  117. RESPHEADSIZE+strlen(szFile)+1
  118. + strlen(szLocal)+1 bytes long */
  119. long lVersion; /* protocol version (it will be >=1) */
  120. long lResponse; /* 22222222 decimal means This is a Response */
  121. long lCode; /* response code */
  122. ULONG ulSize; /* file size (Win32 error code for SSRESP_ERROR) */
  123. DWORD fileattribs;
  124. FILETIME ft_create;
  125. FILETIME ft_lastaccess;
  126. FILETIME ft_lastwrite;
  127. ULONG ulSum; /* checksum for file */
  128. BOOL bSumValid; /* TRUE iff there was a checksum for file */
  129. char szFile[MAX_PATH]; /* null-term. filename/pipename
  130. relative to orig req. */
  131. char szLocal[MAX_PATH]; /* client file name - but the data is actually
  132. concatenated straight on the end of szFile
  133. after the terminating NULL */
  134. } SSNEWRESP, * PSSNEWRESP;
  135. #define RESPHEADSIZE (3*sizeof(long)+2*sizeof(ULONG)+3*sizeof(FILETIME)+sizeof(DWORD)+sizeof(BOOL))
  136. #define LRESPONSE 22222222
  137. /* response codes for lCode */
  138. #define SSRESP_FILE 1 /* file passed: lSum and szFile are valid
  139. This is followed by a series of data Packets
  140. which are the compressed file.
  141. */
  142. #define SSRESP_DIR 2 /* dir passed: szFile ok, lSum not valid */
  143. #define SSRESP_PIPENAME 3 /* files requested. Here is the pipe name */
  144. #define SSRESP_END 0 /* no more files: lSum and szFile are empty*/
  145. #define SSRESP_ERROR -1 /* file/dir cannot be read: szFile is valid */
  146. #define SSRESP_BADPASS -2 /* bad password error (on UNC name) */
  147. #define SSRESP_BADVERS -3 /* down level server */
  148. #define SSRESP_CANTOPEN -4 /* Can't open file
  149. In reply to a scan, szFile, date/time and size are valid
  150. */
  151. #define SSRESP_NOATTRIBS -5 /* Can't get file attributes */
  152. #define SSRESP_NOCOMPRESS -6 /* Can't compress the file (obsolete) */
  153. #define SSRESP_NOREADCOMP -7 /* Can't read the compressed file
  154. Uncompressed file follows as data packets
  155. */
  156. #define SSRESP_NOTEMPPATH -8 /* Can't create a temp path
  157. Uncompressed file follows as data packets
  158. */
  159. #define SSRESP_COMPRESSEXCEPT -9 /* Exception from Compress
  160. Uncompressed file follows as data packets
  161. */
  162. #define SSRESP_NOREAD -10 /* Couldn't read uncompressed file (either)
  163. No file follows.
  164. */
  165. #define SSRESP_COMPRESSFAIL -11 /* COMPRESS reported failure
  166. Uncompressed file follows as data packets
  167. */
  168. #define PACKDATALENGTH 8192
  169. /*
  170. * response block for FILE request.
  171. */
  172. typedef struct {
  173. long lSequence ; /* packet sequence nr, or -1 if error and end*/
  174. ULONG ulSize; /* length of data in this block */
  175. ULONG ulSum; /* checksum for this block */
  176. char Data[PACKDATALENGTH]; /* send in blocks of 8k */
  177. } SSPACKET, * PSSPACKET;
  178. /*
  179. * response block for FILE request.
  180. */
  181. typedef struct { /* files.c knows this starts "long lSequence" */
  182. /* and is PACKHEADSIZE+ulSize in length really*/
  183. long lVersion; /* server/protocol version number */
  184. long lPacket; /* 11111111 decimal means This is a Packet */
  185. long lSequence ; /* packet sequence nr, or -1 if error and end*/
  186. ULONG ulSize; /* length of data in this block */
  187. ULONG ulSum; /* checksum for this block */
  188. char Data[PACKDATALENGTH]; /* send in blocks of 8k */
  189. } SSNEWPACK, * PSSNEWPACK;
  190. /* size of SSNEWPACK header */
  191. #define PACKHEADSIZE (3*sizeof(long)+2*sizeof(ULONG))
  192. #define LPACKET 11111111
  193. /*
  194. * in response to a FILE request, we send SSPACKET responses until there
  195. * is no more data. The final block will have ulSize == 0 to indicate that
  196. * there is no more data. The Data[] field of this block will then be
  197. * a SSATTRIBS containing the file attributes and file times.
  198. */
  199. typedef struct {
  200. DWORD fileattribs;
  201. FILETIME ft_create;
  202. FILETIME ft_lastaccess;
  203. FILETIME ft_lastwrite;
  204. } SSATTRIBS, * PSSATTRIBS;
  205. /*
  206. * in response to errorlog, eventlog and connections requests, we send one
  207. * of these structures.
  208. *
  209. * The Data section consists of a FILETIME (64-bit UTC event time), followed
  210. * by a null-terminated ansi string, for each event logged.
  211. *
  212. */
  213. struct corelog {
  214. DWORD lcode; /* packet checkcode - should be LRESPONSE */
  215. BOOL bWrapped; /* log overrun - earlier data lost */
  216. DWORD dwRevCount; /* revision count of log */
  217. DWORD length; /* length of data in log */
  218. BYTE Data[PACKDATALENGTH];
  219. };
  220. #ifdef trace
  221. /* add msg to the trace file */
  222. void APIENTRY Trace_File(LPSTR msg);
  223. #endif //trace