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.

785 lines
27 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. WCHAR *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. // UPF Hear and bFTP information
  367. // NOTE: The CHAR version of the file name is the one that camera
  368. // sent us, the WCHAR version is the one we will actually
  369. // create. Note that the WCHAR version usually has a different
  370. // suffix.
  371. CHAR *m_pszFileName;
  372. CHAR *m_pszLongFileName;
  373. WCHAR *m_pwszFileName;
  374. FILETIME m_CreateTime;
  375. };
  376. //--------------------------------------------------------------------
  377. // Inline Functions:
  378. //--------------------------------------------------------------------
  379. inline BOOL CSCEP_CONNECTION::IsFragmented()
  380. {
  381. return m_Fragmented;
  382. }
  383. inline DWORD CSCEP_CONNECTION::GetSequenceNo()
  384. {
  385. return m_dwSequenceNo;
  386. }
  387. inline DWORD CSCEP_CONNECTION::GetRestNo()
  388. {
  389. return m_dwRestNo;
  390. }
  391. inline DWORD CSCEP_CONNECTION::GetCommandId()
  392. {
  393. return m_dwCommandId;
  394. }
  395. inline WCHAR *CSCEP_CONNECTION::GetFileName()
  396. {
  397. return m_pwszFileName;
  398. }
  399. inline UCHAR CSCEP_CONNECTION::GetDFlag()
  400. {
  401. return m_DFlag;
  402. }
  403. inline FILETIME *CSCEP_CONNECTION::GetCreateTime()
  404. {
  405. if ( (m_CreateTime.dwLowDateTime)
  406. || (m_CreateTime.dwHighDateTime) )
  407. {
  408. return &m_CreateTime;
  409. }
  410. else
  411. {
  412. return 0;
  413. }
  414. }
  415. //--------------------------------------------------------------------
  416. // Utility Functions/Macros:
  417. //--------------------------------------------------------------------
  418. #define ByteSwapShort(Value) \
  419. ( (((Value) & 0x00FF) << 8) \
  420. | (((Value) & 0xFF00) >> 8))
  421. #define ByteSwapLong(Value) \
  422. ( (((Value) & 0xFF000000) >> 24) \
  423. | (((Value) & 0x00FF0000) >> 8) \
  424. | (((Value) & 0x0000FF00) << 8) \
  425. | (((Value) & 0x000000FF) << 24))
  426. extern void ByteSwapReqHeaderShort( SCEP_REQ_HEADER_SHORT *pSingleShort );
  427. extern void ByteSwapReqHeaderLong( SCEP_REQ_HEADER_LONG *pSingleLong );
  428. extern void ByteSwapCommandHeader( COMMAND_HEADER *pCommandHeader );
  429. //--------------------------------------------------------------------
  430. // Memory management functions:
  431. //--------------------------------------------------------------------
  432. DWORD InitializeMemory();
  433. DWORD UninitializeMemory();
  434. void *AllocateMemory( DWORD dwBytes );
  435. DWORD FreeMemory( void *pvMemory );
  436. SCEP_HEADER *NewPdu( DWORD dwPduSize = MAX_PDU_SIZE );
  437. void DeletePdu( SCEP_HEADER *pPdu );
  438. #if FALSE
  439. //--------------------------------------------------------------------
  440. SCEP Connect PDU
  441. ----------------
  442. Connection request PDU. This is a SCEP_HEADER with Rest[] filled
  443. with three Inf Records, a SCEP_VERSION followed by a SCEP_NEGOTIATION
  444. followed by a SCEP_EXTEND. The Connect PDU must be less than or equal
  445. to 256 bytes in length.
  446. SCEP_HEADER 2 bytes.
  447. Rest[]: SCEP_VERSION 2 bytes.
  448. SCEP_NEGOTIATION 20 - 228 bytes.
  449. SCEP_EXTEND 4 bytes.
  450. --------
  451. 28 - 256 bytes.
  452. - If either the SecondaryMachineId[] or PrimariyMachineId is unused,
  453. then they are set to 00,00,00,00,00,00,00,00.
  454. - If a machine gets a Connect PDU but can't execute commands
  455. (CFlag = CFLAG_ISSUE_ONLY), then it needs to respond with a
  456. NACK PDU.
  457. - The negotiation information is a simple text based command
  458. language.
  459. SCEP Connection ACK PDU
  460. -----------------------
  461. Connection acceptance PDU. This is a SCEP_HEADER with Rest[] filled
  462. with two Inf Records, a SCEP_VERSION followed by a SCEP_NEGOTIATION.
  463. SCEP_HEADER 2 bytes.
  464. SCEP_VERSION 2 bytes.
  465. Rest[]: SCEP_NEGOTIATION 20-251 bytes.
  466. ------
  467. 24-255 bytes.
  468. - Note that the size of the ACK PDU is limited by the fact that
  469. the Length field is a single byte and that the ACK PDU can not
  470. be fragmented. Normally these PDUs will never be this long.
  471. SCEP Connection NACK PDU
  472. ------------------------
  473. Connection rejected PDU. This one can have either of two different
  474. formats.
  475. SCEP_HEADER
  476. Rest[]: SCEP_REQ_HEADER_SHORT
  477. or
  478. SCEP_HEADER
  479. Rest[]: SCEP_REQ_HEADER_LONG
  480. - In the first case, Length1 = 4, DFlag = DFLAG_CONNECT_REJECT,
  481. and Length 3 = 0.
  482. - In the second case, Length1 = 0xff, DFlag = DFLAG_CONNECT_REJECT,
  483. and Length 3 = 0.
  484. SCEP Disconnect PDU
  485. -------------------
  486. A disconnect can be generated by either side of the connection,
  487. or by one of the transports at any time.
  488. SCEP_HEADER
  489. Rest[]: SCEP_DISCONNECT
  490. - For V1.0, Length1 = 2, and ReasonCode is a USHORT.
  491. SCEP Command Request and Response PDUs (Non-fragmented)
  492. -------------------------------------------------------
  493. SCEP_HEADER 2 bytes
  494. Rest[]: SCEP_REQ_HEADER_SHORT 4 + 0-254 bytes
  495. ---------
  496. 6 - 260 bytes
  497. or
  498. SCEP_HEADER 2 bytes
  499. Rest[]: SCEP_REQ_HEADER_LONG 4 + 0-4090 bytes (1)
  500. ----------
  501. 6 - 4096 bytes
  502. - In either case, DFlag = DFLAG_SINGLE_PDU.
  503. - PduType = PDU_TYPE_REQUEST.
  504. - If Length1 = 0xff then the long version is used.
  505. - The Length1(2) field specifies the byte size from InfVersion to the
  506. end of the user data. If the total size will exceed the maximum PDU
  507. size then the request must be fragmented.
  508. - So the total PDU size is: 6 + Length1(2) bytes.
  509. (1) Assuming the maximum PDU size is 4096 (fr:4).
  510. SCEP Command Request and Response PDUs (Fragmented)
  511. ---------------------------------------------------
  512. For requests these PDUs are generated when the PDU size is greater
  513. than that of the responder that you are connected to. For responses,
  514. the PDUs are fragmented when the returned data is greater than the
  515. maximum that the requester specified during the connection establishment.
  516. SCEP_HEADER 2 bytes
  517. Rest[]: SCEP_REQ_HEADER_SHORT_FRAG 6 + 0-254 bytes
  518. ---------
  519. 8 - 260 bytes
  520. or
  521. SCEP_HEADER 2 bytes
  522. Rest[]: SCEP_REQ_HEADER_LONG_FRAG 8 + 0-4088 bytes (1)
  523. ---------
  524. 10 - 4096 bytes
  525. - For the first PDU fragment, DFlag = DFLAG_FIRST_FRAGMENT, for
  526. intermediate fragments, DFlag = DFLAG_FRAGMENT, and for the
  527. last fragment, DFlag = DFLAG_LAST_FRAGMENT.
  528. - PduType = PDU_TYPE_REQUEST for the request.
  529. - PduType = PDU_TYPE_REPLY_ACK or PDU_TYPE_REPLY_NACK in the
  530. response.
  531. - If Length1 = 0xff then the long version is used.
  532. - Length1(2) can not exceed the maximum PDU size - 6 bytes.
  533. - SequenceNo is 0 for the first PDU (NOTE: 4 bytes).
  534. - RestNo is the remaining number of PDUs to get. It is 1 for
  535. the last PDU (really, it says so in the spec!). So, a client
  536. should start this as the total number of PDUs in the first
  537. fragment (not really the number remaining). NOTE: 4 bytes.
  538. (1) Assuming the maximum PDU size is 4096 (fr:4).
  539. SCEP Abort PDU
  540. --------------
  541. Use the abort to stop execution of a command (specified by the
  542. DestPid and CommandId) after ALL of the request PDUs have been
  543. sent. An abort PDU also has two possible formats.
  544. SCEP_HEADER 2 bytes
  545. Rest[]: SCEP_REQ_HEADER_SHORT 34 bytes
  546. --
  547. 36 bytes
  548. or
  549. SCEP_HEADER 2 bytes
  550. Rest[]: SCEP_REQ_HEADER_LONG 36 bytes
  551. --
  552. 38 bytes
  553. - In either case, DFlag = DFLAG_SINGLE_PDU.
  554. - In either case, PduType = PDU_TYPE_ABORT.
  555. - For the short PDU, Length1 = 0x20 (32), and Length3 = 0x1c
  556. (28).
  557. - For the long PDU, Length1 = 0xff, Length2 = 0x20 (32),
  558. and Length3 = 0x1c (28).
  559. SCEP Stop (Interrupt) PDU
  560. -------------------------
  561. If an Abort PDU has been sent out to stop a command, and as the
  562. command is halted some response data has already been sent, the
  563. the responder will send this PDU. It appears that a Stop PDU should
  564. not be sent if no response has yet been sent back.
  565. SCEP_HEADER 2 bytes
  566. Rest[]: SCEP_REQ_HEADER_SHORT 6 bytes
  567. --
  568. 8 bytes
  569. or
  570. SCEP_HEADER 2 bytes
  571. Rest[]: SCEP_REQ_HEADER_LONG 8 bytes
  572. --
  573. 10 bytes
  574. - In either case, DFlag = DFLAG_INTERRUPT.
  575. - For the short PDU, Length1 = 4, and Length3 = 0.
  576. - For the long PDU, Length1 = 0xff, Length2 = 4, and
  577. Length3 = 0.
  578. Negotiation Information
  579. -----------------------
  580. The negotiation information is used to convey the frame size,
  581. authentication data, and product information, etc.
  582. Its structure is a version code (currently 0x11) followed by
  583. text in the following syntax:
  584. NegInf -> Attribute ':' Spaces Value CrLf
  585. Attribute -> AttribChar AttribChar
  586. AttribChar-> 'a-zA-Z'
  587. Value -> ValueChar Value
  588. ->
  589. ValueChar -> 'ASCII string, bytes must be between 0x20 and 0x8e
  590. inclusive'
  591. Spaces -> ' ' Spaces
  592. ->
  593. CrLf -> 0x0d 0x0a
  594. Attribute Meaning
  595. --------- -------
  596. fr Frame (PDU) size. The sender requests the maximum
  597. receivable PDU size, the receiver decides the
  598. transmission PDU size in accordance with the senders
  599. requested PDU size. The maximum PDU size of the sender
  600. may be different than that of the receiver. The value
  601. is one of:
  602. 1 - 512 bytes PDU size (default).
  603. 2 - 1024 bytes PDU size.
  604. 3 - 2048 bytes PDU size.
  605. 4 - 4096 bytes PDU size.
  606. id Product Identification string.
  607. nm User name. any byte string that doesn't include CR or
  608. LF (note the conflict in by values with the syntax
  609. specification above). The user name may be up to 32
  610. characters long.
  611. pw Password. This is a MD5 encoded password expressed
  612. in a 16 byte "hex" string, no spaces are allowd.
  613. It appears that this will always be 32 characters
  614. long. For example: 0aff3728e4a62791337984282871a6bc
  615. //--------------------------------------------------------------------
  616. #endif
  617. #endif //_SCEP_H_