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.

788 lines
28 KiB

  1. //--------------------------------------------------------------------
  2. // Copyright (c)1998 Microsoft Corporation, All Rights Reserved.
  3. //
  4. // scep.h
  5. //
  6. // Constants and Types for the Simple Command Execution Protocol
  7. // (SCEP). This is the transport protocol for IrTran-P V1.0.
  8. //
  9. // NOTE: That IrTran-P is a big-endian protocol when on the net.
  10. //
  11. // NOTE: That the protocol data structures below assume that the
  12. // compiler generates structures with natural alignment by
  13. // field type.
  14. //
  15. // Author:
  16. //
  17. // Edward Reus (edwardr) 02-05-98 Initial coding.
  18. //
  19. //--------------------------------------------------------------------
  20. #ifndef _SCEP_H_
  21. #define _SCEP_H_
  22. #ifndef _BFTP_H_
  23. #include "bftp.h"
  24. #endif
  25. //--------------------------------------------------------------------
  26. // Constants:
  27. //--------------------------------------------------------------------
  28. #define LITTLE_ENDIAN
  29. #define PROTOCOL_VERSION 0x01
  30. #define NEGOTIATION_VERSION 0x11 // SCEP_NEGOTIATION revision.
  31. #define INF_VERSION 0x10 // Information Struct version.
  32. #define USE_LENGTH2 0xff
  33. // These PDU sizes are the default and negotiated sizes:
  34. #define PDU_SIZE_1 512
  35. #define PDU_SIZE_2 1024
  36. #define PDU_SIZE_3 2048
  37. #define PDU_SIZE_4 4096
  38. #define MAX_PDU_SIZE PDU_SIZE_4
  39. #define DEFAULT_PDU_SIZE MAX_PDU_SIZE
  40. // These sizes are used to check if we have a complete PDU:
  41. #define MIN_PDU_SIZE_CONNECT 28
  42. #define MAX_PDU_SIZE_CONNECT 256
  43. #define MIN_PDU_SIZE_CONNECT_RESP 24
  44. #define MAX_PDU_SIZE_CONNECT_RESP 255
  45. #define MIN_PDU_SIZE_DATA 8
  46. #define MIN_PDU_SIZE_DISCONNECT 6
  47. // These are the sizes of the SCEP headers:
  48. #define SCEP_HEADER_SIZE 2
  49. #define SCEP_REQ_HEADER_SHORT_SIZE 34
  50. #define COMMAND_HEADER_SIZE 28
  51. #define FILE_NAME_SIZE 12 // 8.3
  52. // These are the attribute strings that go in the negotiation part
  53. // of connect request and response PDUs:
  54. #define CONNECT_PDU_ATTRIBUTES "fr:3\r\nid:Microsoft IrTran-P v1.0\r\n"
  55. #define RESPONSE_PDU_ATTRIBUTES "fr:4\r\nid:Microsoft IrTran-P v1.0\r\n"
  56. // Message Types (field: MsgType):
  57. #define MSG_TYPE_CONNECT_REQ 0x10 // Connection request.
  58. #define MSG_TYPE_CONNECT_RESP 0x11 // Connection confirmation.
  59. #define MSG_TYPE_DATA 0x20 // Data PDU.
  60. #define MSG_TYPE_DISCONNECT 0x30 // Disconnection.
  61. // Information Types (field: InfType):
  62. #define INF_TYPE_VERSION 0x00 // Connection establishment.
  63. #define INF_TYPE_NEGOTIATION 0x01 // Connection establish or accept.
  64. #define INF_TYPE_USER_DATA 0x03 // Only if MsgType is MSG_TYPE_DATA.
  65. #define INF_TYPE_EXTEND 0x10 // Connection establishment.
  66. #define INF_TYPE_REASON 0x20 // Only for disconnect.
  67. // Command Header: Pdu Types (top two bits in PduType):
  68. #define PDU_TYPE_REQUEST 0x00 // b:00000000
  69. #define PDU_TYPE_REPLY_ACK 0x40 // b:01000000
  70. #define PDU_TYPE_REPLY_NACK 0x80 // b:10000000
  71. #define PDU_TYPE_ABORT 0xc0 // b:11000000
  72. #define PDU_TYPE_MASK 0xc0 // b:11000000
  73. #define PDU_TYPE_RESERVED 0x3f // b:00111111
  74. // The machine ID is in the Connect PDU (SCEP_NEGOTIATION), it
  75. // is in EUI-64 format:
  76. #define MACHINE_ID_SIZE 8
  77. // Machine PIDs: In the command header, the default source and destination
  78. // program Ids are unsigned shorts with value 8. Some machines will have
  79. // a PID other than this (see the first command header sent to us):
  80. #define DEFAULT_PID 8
  81. // CFlag meanings:
  82. //
  83. // There are two cases, one where a device/machine can only issue commands,
  84. // the other when a device can both issue and execute commands.
  85. //
  86. #define CFLAG_ISSUE_ONLY 0x00
  87. #define CFLAG_ISSUE_OR_EXECUTE 0x04
  88. // DFlag Meanings:
  89. //
  90. // DFlag give information about the data and fragmentation (why did they
  91. // put the reject in here?).
  92. //
  93. #define DFLAG_SINGLE_PDU 0xc1
  94. #define DFLAG_FIRST_FRAGMENT 0x41
  95. #define DFLAG_FRAGMENT 0x01
  96. #define DFLAG_LAST_FRAGMENT 0x81
  97. #define DFLAG_INTERRUPT 0xc2
  98. #define DFLAG_CONNECT_REJECT 0xc3
  99. // Reason Codes:
  100. //
  101. // Currently for V1.0 all reason codes are 2-byte numbers:
  102. #define REASON_CODE_UNSPECIFIED 0x0000
  103. #define REASON_CODE_USER_DISCONNECT 0x0001
  104. #define REASON_CODE_PROVIDER_DISCONNECT 0x0002
  105. // Connection States:
  106. #define STATE_CLOSED 0
  107. #define STATE_CONNECTING 1
  108. #define STATE_CONNECTED 2
  109. // Put Response Protocol Error Codes (sent back to the camera):
  110. #define ERROR_PUT_UNDEFINED_ERROR 0x0000
  111. #define ERROR_PUT_ILLEGAL_DATA 0x0001
  112. #define ERROR_PUT_UNSUPPORTED_PID 0x0002
  113. #define ERROR_PUT_ILLEGAL_ATTRIBUTE 0x0010
  114. #define ERROR_PUT_UNSUPPORTED_CMD 0x0011
  115. #define ERROR_PUT_FILE_SYSTEM_FULL 0x0020
  116. #define ERROR_PUT_NO_FILE_OR_DIR 0x0021
  117. #define ERROR_PUT_LOW_BATTERY 0x0030
  118. #define ERROR_PUT_ABORT_EXECUTION 0x0031
  119. #define ERROR_PUT_NO_ERROR 0xffff
  120. //--------------------------------------------------------------------
  121. // SCEP Protocol Headers:
  122. //--------------------------------------------------------------------
  123. // Turn off warning for zero-sized array...
  124. #pragma warning(disable:4200)
  125. #pragma pack(1)
  126. typedef struct _SCEP_HEADER
  127. {
  128. UCHAR Null; // Always zero.
  129. UCHAR MsgType; // See MSG_TYPE_* above.
  130. UCHAR Rest[]; // Dependent on the MsgType...
  131. } SCEP_HEADER;
  132. typedef struct _SCEP_VERSION
  133. {
  134. UCHAR InfType; // Always INF_TYPE_VERSION (0x00).
  135. UCHAR Version; // Currently 0x01 (Version = 1).
  136. } SCEP_VERSION;
  137. typedef struct _SCEP_NEGOTIATION
  138. {
  139. UCHAR InfType; // Always INF_TYPE_NEGOTATION (0x01).
  140. UCHAR Length; // Length (bytes) from InfVersion to
  141. // the end of the Negotiation information.
  142. // This will be from 0 to 228.
  143. UCHAR InfVersion; // Version of InfType = INF_VERSION.
  144. UCHAR CFlag; //
  145. UCHAR SecondaryMachineId[8]; //
  146. UCHAR PrimaryMachineId[8]; //
  147. UCHAR Negotiation[]; //
  148. } SCEP_NEGOTIATION;
  149. typedef struct _SCEP_DISCONNECT
  150. {
  151. UCHAR InfType; // Always INF_TYPE_REASON (0x20).
  152. UCHAR Length1; // For V1.0 this should be 2.
  153. USHORT ReasonCode; // See the REASON_CODE_xxx
  154. } SCEP_DISCONNECT;
  155. typedef struct _SCEP_EXTEND
  156. {
  157. UCHAR InfType; // Always INF_TYPE_EXTEND (0x10).
  158. UCHAR Length; // Always 2 (bytes).
  159. UCHAR Parameter1;
  160. UCHAR Parameter2;
  161. } SCEP_EXTEND;
  162. typedef struct _COMMAND_HEADER
  163. {
  164. UCHAR Marker58h; // Always 0x58 (See: 3.2.2.1.3 of Protocol).
  165. UCHAR PduType; // One of: PDU_TYPE_xxxx.
  166. ULONG Length4;
  167. UCHAR DestMachineId[MACHINE_ID_SIZE];
  168. UCHAR SrcMachineId[MACHINE_ID_SIZE];
  169. USHORT DestPid;
  170. USHORT SrcPid;
  171. USHORT CommandId;
  172. } COMMAND_HEADER;
  173. typedef struct _SCEP_REQ_HEADER_SHORT
  174. {
  175. UCHAR InfType; // Always INF_TYPE_USER_DATA (0x03).
  176. UCHAR Length1;
  177. UCHAR InfVersion; // Version of InfType = INF_VERSION.
  178. UCHAR DFlag;
  179. USHORT Length3;
  180. UCHAR CommandHeader[sizeof(COMMAND_HEADER)];
  181. UCHAR UserData[];
  182. } SCEP_REQ_HEADER_SHORT;
  183. typedef struct _SCEP_REQ_HEADER_LONG
  184. {
  185. UCHAR InfType; // Always INF_TYPE_USER_DATA (0x03).
  186. UCHAR Length1;
  187. USHORT Length2; // Only present if Length1 == 0xff.
  188. UCHAR InfVersion; // Version of InfType = INF_VERSION.
  189. UCHAR DFlag;
  190. USHORT Length3;
  191. UCHAR CommandHeader[sizeof(COMMAND_HEADER)];
  192. UCHAR UserData[];
  193. } SCEP_REQ_HEADER_LONG;
  194. typedef struct _SCEP_REQ_HEADER_SHORT_FRAG
  195. {
  196. UCHAR Inftype; // Always INF_TYPE_USER_DATA (0x03).
  197. UCHAR Length1;
  198. UCHAR InfVersion; // Version of InfType = INF_VERSION.
  199. UCHAR DFlag;
  200. USHORT Length3;
  201. DWORD SequenceNo; // Fragment number.
  202. DWORD RestNo; // Number of fragments left for this PDU.
  203. UCHAR CommandHeader[sizeof(COMMAND_HEADER)];
  204. UCHAR UserData[];
  205. } SCEP_REQ_HEADER_SHORT_FRAG;
  206. typedef struct _SCEP_REQ_HEADER_LONG_FRAG
  207. {
  208. UCHAR InfType; // Always INF_TYPE_USER_DATA (0x03).
  209. UCHAR Length1;
  210. USHORT Length2; // Only present if Length1 == 0xff.
  211. UCHAR InfVersion; // Version of InfType = INF_VERSION.
  212. UCHAR DFlag;
  213. USHORT Length3;
  214. DWORD SequenceNo; // Fragment number.
  215. DWORD RestNo; // Number of fragments left for this PDU.
  216. UCHAR CommandHeader[sizeof(COMMAND_HEADER)];
  217. UCHAR UserData[];
  218. } SCEP_REQ_HEADER_LONG_FRAG;
  219. #pragma pack()
  220. #pragma warning(default:4200)
  221. //--------------------------------------------------------------------
  222. // SCEP API Structures:
  223. //--------------------------------------------------------------------
  224. class CSCEP_CONNECTION
  225. {
  226. public:
  227. CSCEP_CONNECTION();
  228. ~CSCEP_CONNECTION();
  229. void *operator new( IN size_t Size );
  230. void operator delete( IN void *pObj,
  231. IN size_t Size );
  232. // Assemble the next PDU as data comes in:
  233. DWORD AssemblePdu( IN void *pInputData,
  234. IN DWORD dwInputDataSize,
  235. OUT SCEP_HEADER **ppPdu,
  236. OUT DWORD *pdwPduSize );
  237. // Parse the PDU returned from AssemblePdu():
  238. DWORD ParsePdu( IN SCEP_HEADER *pPdu,
  239. IN DWORD dwPduSize,
  240. OUT COMMAND_HEADER **ppCommand,
  241. OUT UCHAR **ppUserData,
  242. OUT DWORD *pdwUserDataSize );
  243. DWORD SetScepLength( IN SCEP_HEADER *pPdu,
  244. IN DWORD dwTotalPduSize );
  245. // Construct SCEP connection/control PDUs:
  246. DWORD BuildConnectPdu( OUT SCEP_HEADER **ppPdu,
  247. OUT DWORD *pdwPduSize );
  248. DWORD BuildConnectRespPdu( OUT SCEP_HEADER **ppPdu,
  249. OUT DWORD *pdwPduSize );
  250. DWORD BuildConnectNackPdu( OUT SCEP_HEADER **ppPdu,
  251. OUT DWORD *pdwPduSize );
  252. DWORD BuildAbortPdu( OUT SCEP_HEADER **ppPdu,
  253. OUT DWORD *pdwPduSize );
  254. DWORD BuildStopPdu( OUT SCEP_HEADER **ppPdu,
  255. OUT DWORD *pdwPduSize );
  256. DWORD BuildDisconnectPdu( IN USHORT ReasonCode,
  257. OUT SCEP_HEADER **ppPdu,
  258. OUT DWORD *pdwPduSize );
  259. // Build bFTP request (client-side) PDUs:
  260. DWORD BuildBftpWht0RinfPdu( OUT SCEP_HEADER **ppPdu,
  261. OUT DWORD *pdwPduSize,
  262. OUT SCEP_REQ_HEADER_LONG **ppCommand,
  263. OUT COMMAND_HEADER **ppCommandHeader );
  264. DWORD BuildBftpPutPdu( IN DWORD dwUpfFileSize,
  265. IN CHAR *pszUpfFile,
  266. IN OUT DWORD *pdwFragNo,
  267. OUT SCEP_HEADER **ppPdu,
  268. OUT DWORD *pdwPduSize,
  269. OUT SCEP_REQ_HEADER_LONG_FRAG **ppCommand );
  270. // Build bFTP response PDUs:
  271. DWORD BuildBftpRespPdu( IN DWORD dwPduSize,
  272. OUT SCEP_HEADER **ppPdu,
  273. OUT SCEP_REQ_HEADER_SHORT **ppCommand,
  274. OUT COMMAND_HEADER **ppCommandHeader );
  275. DWORD BuildWht0RespPdu( IN DWORD dwWht0Type,
  276. OUT SCEP_HEADER **ppPdu,
  277. OUT DWORD *pdwPduSize );
  278. DWORD BuildPutRespPdu( IN DWORD dwPduAckOrNack,
  279. IN USHORT usErrorCode,
  280. OUT SCEP_HEADER **ppPdu,
  281. OUT DWORD *pdwPduSize );
  282. // Parse the bFTP in a SCEP command request PDU:
  283. DWORD ParseBftp( IN UCHAR *pvBftpData,
  284. IN DWORD dwDataSize,
  285. IN BOOL fSaveAsUPF,
  286. OUT DWORD *pdwBftpOp,
  287. OUT UCHAR **ppPutData,
  288. OUT DWORD *pdwPutDataSize );
  289. // Parse and save the create date/time that was specified as a
  290. // bFTP option:
  291. DWORD SaveBftpCreateDate( IN UCHAR *pDate,
  292. IN DWORD dwLength );
  293. // Parse the UPF file header to find the image JPEG file:
  294. DWORD ParseUpfHeaders( IN UCHAR *pPutData,
  295. IN DWORD dwPutDataSize,
  296. OUT DWORD *pdwJpegOffset,
  297. OUT DWORD *pdwJpegSize );
  298. // Used when a SCEP command PDU is received:
  299. BOOL IsFragmented();
  300. DWORD GetSequenceNo();
  301. DWORD GetRestNo();
  302. DWORD GetCommandId();
  303. CHAR *GetFileName();
  304. UCHAR GetDFlag();
  305. FILETIME *GetCreateTime();
  306. protected:
  307. DWORD CheckPdu( OUT SCEP_HEADER **ppPdu,
  308. OUT DWORD *pdwPduSize );
  309. DWORD CheckConnectPdu( OUT SCEP_HEADER **ppPdu,
  310. OUT DWORD *pdwPduSize );
  311. DWORD CheckAckPdu( OUT SCEP_HEADER **ppPdu,
  312. OUT DWORD *pdwPduSize );
  313. DWORD CheckNackPdu( OUT SCEP_HEADER **ppPdu,
  314. OUT DWORD *pdwPduSize );
  315. DWORD CheckConnectRespPdu( OUT SCEP_HEADER **ppPdu,
  316. OUT DWORD *pdwPduSize );
  317. DWORD CheckDataPdu( OUT SCEP_HEADER **ppPdu,
  318. OUT DWORD *pdwPduSize );
  319. DWORD CheckDisconnectPdu( OUT SCEP_HEADER **ppPdu,
  320. OUT DWORD *pdwPduSize );
  321. DWORD ParseConnectPdu( IN SCEP_HEADER *pPdu,
  322. IN DWORD dwPduSize );
  323. DWORD ParseConnectRespPdu( IN SCEP_HEADER *pPdu,
  324. IN DWORD dwPduSize );
  325. DWORD ParseDataPdu( IN SCEP_HEADER *pPdu,
  326. IN DWORD dwPduSize,
  327. OUT COMMAND_HEADER **ppCommand,
  328. OUT UCHAR **ppUserData,
  329. OUT DWORD *pdwUserDataSize );
  330. DWORD ParseDisconnectPdu( IN SCEP_HEADER *pPdu,
  331. IN DWORD dwPduSize );
  332. DWORD ParseNegotiation( IN UCHAR *pNegotiation,
  333. IN DWORD dwNegotiationSize );
  334. UCHAR *ParseAttribute( IN UCHAR *pAttributes,
  335. IN OUT DWORD *pdwAttributeSize,
  336. OUT DWORD *pdwStatus );
  337. DWORD ParseSingleLongPdu( IN SCEP_HEADER *pPdu,
  338. IN DWORD dwPduSize );
  339. BFTP_ATTRIBUTE *ParseBftpAttributeName(
  340. IN BFTP_ATTRIBUTE *pAttr,
  341. IN OUT DWORD *pdwSize,
  342. OUT DWORD *pdwWhichAttr );
  343. DWORD m_dwConnectionState;
  344. DWORD m_dwPduSendSize;
  345. DWORD m_dwPduReceiveSize;
  346. UCHAR m_CFlag;
  347. UCHAR *m_pPrimaryMachineId;
  348. UCHAR *m_pSecondaryMachineId;
  349. USHORT m_DestPid; // My PID (Camera point of view).
  350. USHORT m_SrcPid; // Camera's PID (Camera point of view).
  351. UCHAR *m_pszProductId;
  352. UCHAR *m_pszUserName;
  353. UCHAR *m_pszPassword;
  354. // Used during PDU assembley process.
  355. UCHAR *m_pAssembleBuffer;
  356. DWORD m_dwAssembleBufferSize;
  357. DWORD m_dwMaxAssembleBufferSize;
  358. BOOL m_fDidByteSwap;
  359. // Used to manage the current SCEP command PDU.
  360. UCHAR m_Fragmented;
  361. UCHAR m_DFlag;
  362. DWORD m_dwSequenceNo;
  363. DWORD m_dwRestNo;
  364. DWORD m_dwCommandId;
  365. COMMAND_HEADER *m_pCommandHeader;
  366. //
  367. // NOTE: The m_pszFileName is the file name that the camera sent us,
  368. // while pszSaveFileName is the file name will will actually
  369. // save the file under (different extension). m_pszLongFileName
  370. // is the optional BFTP file name (not currently used), it
  371. // is not usually present in the BFTP.
  372. //
  373. CHAR *m_pszFileName;
  374. CHAR *m_pszSaveFileName;
  375. CHAR *m_pszLongFileName;
  376. FILETIME m_CreateTime;
  377. };
  378. //--------------------------------------------------------------------
  379. // Inline Functions:
  380. //--------------------------------------------------------------------
  381. inline BOOL CSCEP_CONNECTION::IsFragmented()
  382. {
  383. return m_Fragmented;
  384. }
  385. inline DWORD CSCEP_CONNECTION::GetSequenceNo()
  386. {
  387. return m_dwSequenceNo;
  388. }
  389. inline DWORD CSCEP_CONNECTION::GetRestNo()
  390. {
  391. return m_dwRestNo;
  392. }
  393. inline DWORD CSCEP_CONNECTION::GetCommandId()
  394. {
  395. return m_dwCommandId;
  396. }
  397. inline CHAR *CSCEP_CONNECTION::GetFileName()
  398. {
  399. return m_pszSaveFileName;
  400. }
  401. inline UCHAR CSCEP_CONNECTION::GetDFlag()
  402. {
  403. return m_DFlag;
  404. }
  405. inline FILETIME *CSCEP_CONNECTION::GetCreateTime()
  406. {
  407. if ( (m_CreateTime.dwLowDateTime)
  408. || (m_CreateTime.dwHighDateTime) )
  409. {
  410. return &m_CreateTime;
  411. }
  412. else
  413. {
  414. return 0;
  415. }
  416. }
  417. //--------------------------------------------------------------------
  418. // Utility Functions/Macros:
  419. //--------------------------------------------------------------------
  420. #define ByteSwapShort(Value) \
  421. ( (((Value) & 0x00FF) << 8) \
  422. | (((Value) & 0xFF00) >> 8))
  423. #define ByteSwapLong(Value) \
  424. ( (((Value) & 0xFF000000) >> 24) \
  425. | (((Value) & 0x00FF0000) >> 8) \
  426. | (((Value) & 0x0000FF00) << 8) \
  427. | (((Value) & 0x000000FF) << 24))
  428. extern void ByteSwapReqHeaderShort( SCEP_REQ_HEADER_SHORT *pSingleShort );
  429. extern void ByteSwapReqHeaderLong( SCEP_REQ_HEADER_LONG *pSingleLong );
  430. extern void ByteSwapCommandHeader( COMMAND_HEADER *pCommandHeader );
  431. //--------------------------------------------------------------------
  432. // Memory management functions:
  433. //--------------------------------------------------------------------
  434. DWORD InitializeMemory();
  435. DWORD UninitializeMemory();
  436. void *AllocateMemory( DWORD dwBytes );
  437. DWORD FreeMemory( void *pvMemory );
  438. SCEP_HEADER *NewPdu( DWORD dwPduSize = MAX_PDU_SIZE );
  439. void DeletePdu( SCEP_HEADER *pPdu );
  440. #if FALSE
  441. //--------------------------------------------------------------------
  442. SCEP Connect PDU
  443. ----------------
  444. Connection request PDU. This is a SCEP_HEADER with Rest[] filled
  445. with three Inf Records, a SCEP_VERSION followed by a SCEP_NEGOTIATION
  446. followed by a SCEP_EXTEND. The Connect PDU must be less than or equal
  447. to 256 bytes in length.
  448. SCEP_HEADER 2 bytes.
  449. Rest[]: SCEP_VERSION 2 bytes.
  450. SCEP_NEGOTIATION 20 - 228 bytes.
  451. SCEP_EXTEND 4 bytes.
  452. --------
  453. 28 - 256 bytes.
  454. - If either the SecondaryMachineId[] or PrimariyMachineId is unused,
  455. then they are set to 00,00,00,00,00,00,00,00.
  456. - If a machine gets a Connect PDU but can't execute commands
  457. (CFlag = CFLAG_ISSUE_ONLY), then it needs to respond with a
  458. NACK PDU.
  459. - The negotiation information is a simple text based command
  460. language.
  461. SCEP Connection ACK PDU
  462. -----------------------
  463. Connection acceptance PDU. This is a SCEP_HEADER with Rest[] filled
  464. with two Inf Records, a SCEP_VERSION followed by a SCEP_NEGOTIATION.
  465. SCEP_HEADER 2 bytes.
  466. SCEP_VERSION 2 bytes.
  467. Rest[]: SCEP_NEGOTIATION 20-251 bytes.
  468. ------
  469. 24-255 bytes.
  470. - Note that the size of the ACK PDU is limited by the fact that
  471. the Length field is a single byte and that the ACK PDU can not
  472. be fragmented. Normally these PDUs will never be this long.
  473. SCEP Connection NACK PDU
  474. ------------------------
  475. Connection rejected PDU. This one can have either of two different
  476. formats.
  477. SCEP_HEADER
  478. Rest[]: SCEP_REQ_HEADER_SHORT
  479. or
  480. SCEP_HEADER
  481. Rest[]: SCEP_REQ_HEADER_LONG
  482. - In the first case, Length1 = 4, DFlag = DFLAG_CONNECT_REJECT,
  483. and Length 3 = 0.
  484. - In the second case, Length1 = 0xff, DFlag = DFLAG_CONNECT_REJECT,
  485. and Length 3 = 0.
  486. SCEP Disconnect PDU
  487. -------------------
  488. A disconnect can be generated by either side of the connection,
  489. or by one of the transports at any time.
  490. SCEP_HEADER
  491. Rest[]: SCEP_DISCONNECT
  492. - For V1.0, Length1 = 2, and ReasonCode is a USHORT.
  493. SCEP Command Request and Response PDUs (Non-fragmented)
  494. -------------------------------------------------------
  495. SCEP_HEADER 2 bytes
  496. Rest[]: SCEP_REQ_HEADER_SHORT 4 + 0-254 bytes
  497. ---------
  498. 6 - 260 bytes
  499. or
  500. SCEP_HEADER 2 bytes
  501. Rest[]: SCEP_REQ_HEADER_LONG 4 + 0-4090 bytes (1)
  502. ----------
  503. 6 - 4096 bytes
  504. - In either case, DFlag = DFLAG_SINGLE_PDU.
  505. - PduType = PDU_TYPE_REQUEST.
  506. - If Length1 = 0xff then the long version is used.
  507. - The Length1(2) field specifies the byte size from InfVersion to the
  508. end of the user data. If the total size will exceed the maximum PDU
  509. size then the request must be fragmented.
  510. - So the total PDU size is: 6 + Length1(2) bytes.
  511. (1) Assuming the maximum PDU size is 4096 (fr:4).
  512. SCEP Command Request and Response PDUs (Fragmented)
  513. ---------------------------------------------------
  514. For requests these PDUs are generated when the PDU size is greater
  515. than that of the responder that you are connected to. For responses,
  516. the PDUs are fragmented when the returned data is greater than the
  517. maximum that the requester specified during the connection establishment.
  518. SCEP_HEADER 2 bytes
  519. Rest[]: SCEP_REQ_HEADER_SHORT_FRAG 6 + 0-254 bytes
  520. ---------
  521. 8 - 260 bytes
  522. or
  523. SCEP_HEADER 2 bytes
  524. Rest[]: SCEP_REQ_HEADER_LONG_FRAG 8 + 0-4088 bytes (1)
  525. ---------
  526. 10 - 4096 bytes
  527. - For the first PDU fragment, DFlag = DFLAG_FIRST_FRAGMENT, for
  528. intermediate fragments, DFlag = DFLAG_FRAGMENT, and for the
  529. last fragment, DFlag = DFLAG_LAST_FRAGMENT.
  530. - PduType = PDU_TYPE_REQUEST for the request.
  531. - PduType = PDU_TYPE_REPLY_ACK or PDU_TYPE_REPLY_NACK in the
  532. response.
  533. - If Length1 = 0xff then the long version is used.
  534. - Length1(2) can not exceed the maximum PDU size - 6 bytes.
  535. - SequenceNo is 0 for the first PDU (NOTE: 4 bytes).
  536. - RestNo is the remaining number of PDUs to get. It is 1 for
  537. the last PDU (really, it says so in the spec!). So, a client
  538. should start this as the total number of PDUs in the first
  539. fragment (not really the number remaining). NOTE: 4 bytes.
  540. (1) Assuming the maximum PDU size is 4096 (fr:4).
  541. SCEP Abort PDU
  542. --------------
  543. Use the abort to stop execution of a command (specified by the
  544. DestPid and CommandId) after ALL of the request PDUs have been
  545. sent. An abort PDU also has two possible formats.
  546. SCEP_HEADER 2 bytes
  547. Rest[]: SCEP_REQ_HEADER_SHORT 34 bytes
  548. --
  549. 36 bytes
  550. or
  551. SCEP_HEADER 2 bytes
  552. Rest[]: SCEP_REQ_HEADER_LONG 36 bytes
  553. --
  554. 38 bytes
  555. - In either case, DFlag = DFLAG_SINGLE_PDU.
  556. - In either case, PduType = PDU_TYPE_ABORT.
  557. - For the short PDU, Length1 = 0x20 (32), and Length3 = 0x1c
  558. (28).
  559. - For the long PDU, Length1 = 0xff, Length2 = 0x20 (32),
  560. and Length3 = 0x1c (28).
  561. SCEP Stop (Interrupt) PDU
  562. -------------------------
  563. If an Abort PDU has been sent out to stop a command, and as the
  564. command is halted some response data has already been sent, the
  565. the responder will send this PDU. It appears that a Stop PDU should
  566. not be sent if no response has yet been sent back.
  567. SCEP_HEADER 2 bytes
  568. Rest[]: SCEP_REQ_HEADER_SHORT 6 bytes
  569. --
  570. 8 bytes
  571. or
  572. SCEP_HEADER 2 bytes
  573. Rest[]: SCEP_REQ_HEADER_LONG 8 bytes
  574. --
  575. 10 bytes
  576. - In either case, DFlag = DFLAG_INTERRUPT.
  577. - For the short PDU, Length1 = 4, and Length3 = 0.
  578. - For the long PDU, Length1 = 0xff, Length2 = 4, and
  579. Length3 = 0.
  580. Negotiation Information
  581. -----------------------
  582. The negotiation information is used to convey the frame size,
  583. authentication data, and product information, etc.
  584. Its structure is a version code (currently 0x11) followed by
  585. text in the following syntax:
  586. NegInf -> Attribute ':' Spaces Value CrLf
  587. Attribute -> AttribChar AttribChar
  588. AttribChar-> 'a-zA-Z'
  589. Value -> ValueChar Value
  590. ->
  591. ValueChar -> 'ASCII string, bytes must be between 0x20 and 0x8e
  592. inclusive'
  593. Spaces -> ' ' Spaces
  594. ->
  595. CrLf -> 0x0d 0x0a
  596. Attribute Meaning
  597. --------- -------
  598. fr Frame (PDU) size. The sender requests the maximum
  599. receivable PDU size, the receiver decides the
  600. transmission PDU size in accordance with the senders
  601. requested PDU size. The maximum PDU size of the sender
  602. may be different than that of the receiver. The value
  603. is one of:
  604. 1 - 512 bytes PDU size (default).
  605. 2 - 1024 bytes PDU size.
  606. 3 - 2048 bytes PDU size.
  607. 4 - 4096 bytes PDU size.
  608. id Product Identification string.
  609. nm User name. any byte string that doesn't include CR or
  610. LF (note the conflict in by values with the syntax
  611. specification above). The user name may be up to 32
  612. characters long.
  613. pw Password. This is a MD5 encoded password expressed
  614. in a 16 byte "hex" string, no spaces are allowd.
  615. It appears that this will always be 32 characters
  616. long. For example: 0aff3728e4a62791337984282871a6bc
  617. //--------------------------------------------------------------------
  618. #endif
  619. #endif //_SCEP_H_