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.

292 lines
7.7 KiB

  1. /*
  2. * omcscode.h
  3. *
  4. * Copyright (c) 1993 - 1995 by DataBeam Corporation, Lexington, KY
  5. *
  6. * Abstract:
  7. * This is the interface file for the CMCSCoder class. This
  8. * class is used to encode and decode MCS Protocol Data Units (PDU's)
  9. * to and from ASN.1 compliant byte streams using the ASN.1 toolkit.
  10. *
  11. * Caveats:
  12. * None.
  13. *
  14. * Author:
  15. * John B. O'Nan
  16. *
  17. */
  18. #ifndef _CMCSCODER_
  19. #define _CMCSCODER_
  20. #include "pktcoder.h"
  21. #include "mcspdu.h"
  22. /*
  23. * Macros
  24. */
  25. #define PLUMB_DOMAIN_INDICATION 0x60
  26. #define ERECT_DOMAIN_REQUEST 0x61
  27. #define MERGE_CHANNELS_REQUEST 0x62
  28. #define MERGE_CHANNELS_CONFIRM 0x63
  29. #define PURGE_CHANNEL_INDICATION 0x64
  30. #define MERGE_TOKENS_REQUEST 0x65
  31. #define MERGE_TOKENS_CONFIRM 0x66
  32. #define PURGE_TOKEN_INDICATION 0x67
  33. #define DISCONNECT_PROVIDER_ULTIMATUM 0x68
  34. #define REJECT_ULTIMATUM 0x69
  35. #define ATTACH_USER_REQUEST 0x6a
  36. #define ATTACH_USER_CONFIRM 0x6b
  37. #define DETACH_USER_REQUEST 0x6c
  38. #define DETACH_USER_INDICATION 0x6d
  39. #define CHANNEL_JOIN_REQUEST 0x6e
  40. #define CHANNEL_JOIN_CONFIRM 0x6f
  41. #define CHANNEL_LEAVE_REQUEST 0x70
  42. #define CHANNEL_CONVENE_REQUEST 0x71
  43. #define CHANNEL_CONVENE_CONFIRM 0x72
  44. #define CHANNEL_DISBAND_REQUEST 0x73
  45. #define CHANNEL_DISBAND_INDICATION 0x74
  46. #define CHANNEL_ADMIT_REQUEST 0x75
  47. #define CHANNEL_ADMIT_INDICATION 0x76
  48. #define CHANNEL_EXPEL_REQUEST 0x77
  49. #define CHANNEL_EXPEL_INDICATION 0x78
  50. #define SEND_DATA_REQUEST 0x79
  51. #define SEND_DATA_INDICATION 0x7a
  52. #define UNIFORM_SEND_DATA_REQUEST 0x7b
  53. #define UNIFORM_SEND_DATA_INDICATION 0x7c
  54. #define TOKEN_GRAB_REQUEST 0x7d
  55. #define TOKEN_GRAB_CONFIRM 0x7e
  56. #define MULTIPLE_OCTET_ID 0x7f
  57. #define TOKEN_INHIBIT_REQUEST 0x1f
  58. #define TOKEN_INHIBIT_CONFIRM 0x20
  59. #define TOKEN_GIVE_REQUEST 0x21
  60. #define TOKEN_GIVE_INDICATION 0x22
  61. #define TOKEN_GIVE_RESPONSE 0x23
  62. #define TOKEN_GIVE_CONFIRM 0x24
  63. #define TOKEN_PLEASE_REQUEST 0x25
  64. #define TOKEN_PLEASE_INDICATION 0x26
  65. #define TOKEN_RELEASE_REQUEST 0x27
  66. #define TOKEN_RELEASE_CONFIRM 0x28
  67. #define TOKEN_TEST_REQUEST 0x29
  68. #define TOKEN_TEST_CONFIRM 0x2a
  69. #define CONNECT_INITIAL 0x65
  70. #define CONNECT_RESPONSE 0x66
  71. #define CONNECT_ADDITIONAL 0x67
  72. #define CONNECT_RESULT 0x68
  73. #define HIGHEST_BER_SEND_DATA_OVERHEAD 25
  74. #define LOWEST_BER_SEND_DATA_OVERHEAD 19
  75. #define HIGHEST_PER_SEND_DATA_OVERHEAD 9
  76. #define LOWEST_PER_SEND_DATA_OVERHEAD 7
  77. #define PER_SEND_DATA_REQUEST 0x64
  78. #define PER_SEND_DATA_INDICATION 0x68
  79. #define PER_UNIFORM_SEND_DATA_REQUEST 0x6c
  80. #define PER_UNIFORM_SEND_DATA_INDICATION 0x70
  81. #define INITIATOR_LOWER_BOUND 1001
  82. /*
  83. * This is the class definition for class CMCSCoder
  84. */
  85. class CMCSCoder : public PacketCoder
  86. {
  87. public:
  88. CMCSCoder ();
  89. BOOL Init ( void );
  90. virtual ~CMCSCoder ();
  91. virtual BOOL Encode (LPVOID pdu_structure,
  92. int pdu_type,
  93. UINT rules_type,
  94. LPBYTE *encoding_buffer,
  95. UINT *encoding_buffer_length);
  96. virtual BOOL Decode (LPBYTE encoded_buffer,
  97. UINT encoded_buffer_length,
  98. int pdu_type,
  99. UINT rules_type,
  100. LPVOID *pdecoding_buffer,
  101. UINT *pdecoding_buffer_length);
  102. Void ReverseDirection (LPBYTE encoded_buffer);
  103. virtual DBBoolean IsMCSDataPacket ( LPBYTE encoded_buffer,
  104. UINT rules_type);
  105. virtual void FreeEncoded (LPBYTE encoded_buffer);
  106. virtual void FreeDecoded (int pdu_type, LPVOID decoded_buffer);
  107. private:
  108. void SetEncodingRules (UINT rules_type);
  109. UINT Encoding_Rules_Type;
  110. ASN1encoding_t m_pEncInfo; // ptr to encoder info
  111. ASN1decoding_t m_pDecInfo; // ptr to decoder info
  112. };
  113. typedef CMCSCoder * PCMCSCoder;
  114. /*
  115. * CMCSCoder ()
  116. *
  117. * Functional Description:
  118. * This is the constructor for the CMCSCoder class. It initializes the
  119. * ASN.1 toolkit and sets the type of encoding rules to Basic Encoding
  120. * Rules (BER). It also initializes some private instance variables.
  121. *
  122. * Formal Parameters:
  123. * None.
  124. *
  125. * Return Value:
  126. * None.
  127. *
  128. * Side Effects:
  129. * None.
  130. *
  131. * Caveats:
  132. * None.
  133. */
  134. /*
  135. * ~CMCSCoder ()
  136. *
  137. * Functional Description:
  138. * This is a virtual destructor. It cleans up after the ASN.1 toolkit.
  139. *
  140. * Formal Parameters:
  141. * None.
  142. *
  143. * Return Value:
  144. * None.
  145. *
  146. * Side Effects:
  147. * None.
  148. *
  149. * Caveats:
  150. * None.
  151. */
  152. /*
  153. * void Encode ( LPVOID pdu_structure,
  154. * int pdu_type,
  155. * UINT rules_type,
  156. * LPBYTE *encoding_buffer,
  157. * UINT *encoding_buffer_length)
  158. *
  159. * Functional Description:
  160. * This function encodes Protocol data units (PDU's) into ASN.1 compliant
  161. * byte streams.
  162. * The coder allocates the buffer space for the encoded data.
  163. *
  164. * Formal Parameters:
  165. * pdu_structure (i) Pointer to structure holding PDU data.
  166. * pdu_type (i) Define indicating Connect or Domain MCS PDU.
  167. * rules_type (i) Type of encoding rules (BER or PER).
  168. * encoding_buffer (o) Pointer to buffer to hold encoded data.
  169. * encoding_buffer_length (o) Length of encoded data.
  170. *
  171. * Return Value:
  172. * None.
  173. *
  174. * Side Effects:
  175. * None.
  176. *
  177. * Caveats:
  178. * None.
  179. */
  180. /*
  181. * void Decode ( LPBYTE encoded_buffer,
  182. * UINT encoded_buffer_length,
  183. * int pdu_type,
  184. * UINT rules_type,
  185. * LPVOID decoding_buffer,
  186. * UINT decoding_buffer_length,
  187. * UINT *pulDataOffset)
  188. *
  189. * Functional Description:
  190. * This function decodes ASN.1 compliant byte streams into the
  191. * appropriate MCS PDU structures.
  192. *
  193. * Formal Parameters:
  194. * encoded_buffer (i) Pointer to buffer holding data to decode.
  195. * encoded_buffer_length(i) Length of buffer holding encoded data.
  196. * pdu_type (i) Type (Domain or Connect) of MCS PDU.
  197. * rules_type (i) Type of encoding rules (BER or PER).
  198. * decoding_buffer (o) Pointer to buffer to hold the decoded data.
  199. * decoding_buffer_length (i) Length of buffer to hold decoded data.
  200. * pulDataOffset (o) Pointer to a value that stores the offset of the data in an encoded MCS data packet.
  201. *
  202. * Return Value:
  203. * None.
  204. *
  205. * Side Effects:
  206. * None.
  207. *
  208. * Caveats:
  209. * None.
  210. */
  211. /*
  212. * void CopyDecodedData ( LPVOID pdu_source_structure,
  213. * LPVOID pdu_destination_structure,
  214. * UINT pdu_type)
  215. *
  216. * Functional Description:
  217. * This function makes a complete copy of a decoded PDU structure.
  218. *
  219. * Formal Parameters:
  220. * pdu_source_structure (i) Pointer to buffer holding decoded structure.
  221. * pdu_destination_structure (i) Pointer to copy buffer.
  222. * pdu_type (i) Type (Domain or Connect) of PDU.
  223. *
  224. * Return Value:
  225. * None.
  226. *
  227. * Side Effects:
  228. * None.
  229. *
  230. * Caveats:
  231. * None.
  232. */
  233. /*
  234. * Void ReverseDirection (LPBYTE encoded_buffer)
  235. *
  236. * Functional Description:
  237. * This function alters the identifier of encoded "Send Data" PDU's in
  238. * order to change back and forth between data requests and indications.
  239. *
  240. * Formal Parameters:
  241. * encoded_buffer (i) Pointer to buffer holding encoded data.
  242. *
  243. * Return Value:
  244. * None.
  245. *
  246. * Side Effects:
  247. * None.
  248. *
  249. * Caveats:
  250. * None.
  251. */
  252. /*
  253. * DBBoolean IsMCSDataPacket ()
  254. *
  255. * Functional Description:
  256. * This function determines whether the encoded packet is an MCS Data packet
  257. * or not.
  258. *
  259. * Formal Parameters:
  260. * encoded_buffer (i) Pointer to buffer holding the encoded PDU.
  261. * rules_type (i) The used encoding rules.
  262. *
  263. * Return value:
  264. * TRUE, if the packet is an MCS Data packet. FALSE, otherwise.
  265. *
  266. * Side Effects:
  267. * None.
  268. *
  269. * Caveats:
  270. * None.
  271. */
  272. #endif