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.

192 lines
4.7 KiB

  1. /*
  2. * pktcoder.h
  3. *
  4. * Copyright (c) 1993 - 1995 by DataBeam Corporation, Lexington, KY
  5. *
  6. * Abstract:
  7. * This is the interface file for the PacketCoder class. This
  8. * is an abstract base class which cannot be directly instantiated, but
  9. * rather, exists to be inherited from. It defines a set of virtual
  10. * member functions which will be shared by all classes that inherit from
  11. * this one. This class defines the behaviors necessary to encode,
  12. * decode, and manipulate Protocol Data Unit (PDU) structures.
  13. *
  14. * Caveats:
  15. * None.
  16. *
  17. * Author:
  18. * John B. O'Nan
  19. */
  20. #ifndef _PACKETCODER_
  21. #define _PACKETCODER_
  22. /*
  23. * Macros.
  24. */
  25. #define BASIC_ENCODING_RULES 0
  26. #define PACKED_ENCODING_RULES 1
  27. /*
  28. * This enumeration defines the various errors that can be returned during
  29. * the use of a PacketCoder object.
  30. */
  31. typedef enum
  32. {
  33. PACKET_CODER_NO_ERROR,
  34. PACKET_CODER_BAD_REVERSE_ATTEMPT,
  35. PACKET_CODER_INCOMPATIBLE_PROTOCOL
  36. } PacketCoderError;
  37. typedef PacketCoderError * PPacketCoderError;
  38. /*
  39. * This is the class definition for class PacketCoder
  40. */
  41. class PacketCoder
  42. {
  43. public:
  44. virtual ~PacketCoder ();
  45. virtual BOOL Encode (LPVOID pdu_structure,
  46. int pdu_type,
  47. UINT rules_type,
  48. LPBYTE *encoding_buffer,
  49. UINT *encoding_buffer_length) = 0;
  50. virtual BOOL Decode (LPBYTE encoded_buffer,
  51. UINT encoded_buffer_length,
  52. int pdu_type,
  53. UINT rules_type,
  54. LPVOID *pdecoding_buffer,
  55. UINT *pdecoding_buffer_length) = 0;
  56. virtual DBBoolean IsMCSDataPacket ( LPBYTE encoded_buffer,
  57. UINT rules_type) = 0;
  58. virtual void FreeEncoded (LPBYTE encoded_buffer) = 0;
  59. virtual void FreeDecoded (int pdu_type, LPVOID decoded_buffer) = 0;
  60. };
  61. typedef PacketCoder * PPacketCoder;
  62. /*
  63. * ~PacketCoder ()
  64. *
  65. * Functional Description:
  66. * This is a virtual destructor. It does not actually do anything in this
  67. * class.
  68. *
  69. * Formal Parameters:
  70. * None.
  71. *
  72. * Return Value:
  73. * None.
  74. *
  75. * Side Effects:
  76. * None.
  77. *
  78. * Caveats:
  79. * None.
  80. */
  81. /*
  82. * void Encode ( LPVOID pdu_structure,
  83. * int pdu_type,
  84. * LPBYTE *encoding_buffer,
  85. * UINT *encoding_buffer_length)
  86. *
  87. * Functional Description:
  88. * This function encodes Protocol data units (PDU's) into ASN.1 compliant
  89. * byte streams.
  90. * The coder allocates the buffer space for the encoded data.
  91. *
  92. * Formal Parameters:
  93. * pdu_structure (i) Pointer to structure holding PDU data.
  94. * pdu_type (i) Define indicating type of PDU.
  95. * encoding_buffer (o) Pointer to buffer to hold encoded data.
  96. * encoding_buffer_length (o) Pointer to length of buffer for encoded data.
  97. *
  98. * Return Value:
  99. * None.
  100. *
  101. * Side Effects:
  102. * None.
  103. *
  104. * Caveats:
  105. * None.
  106. */
  107. /*
  108. * void Decode ( LPBYTE encoded_buffer,
  109. * UINT encoded_buffer_length,
  110. * int pdu_type,
  111. * LPVOID decoding_buffer,
  112. * UINT decoding_buffer_length,
  113. * UINT *pulDataOffset)
  114. *
  115. * Functional Description:
  116. * This function decodes ASN.1 compliant byte streams into the
  117. * appropriate PDU structures.
  118. *
  119. * Formal Parameters:
  120. * encoded_buffer (i) Pointer to buffer holding data to decode.
  121. * encoded_buffer_length (i) Length of buffer holding data to decode.
  122. * pdu_type (o) Returns type of PDU.
  123. * decoding_buffer (o) Pointer to buffer to hold the decoded data.
  124. * decoding_buffer_length (i) Length of buffer to hold the decoded data.
  125. * pulDataOffset (o) Pointer to a value that stores the offset of the data in an encoded MCS data packet.
  126. *
  127. * Return Value:
  128. * None.
  129. *
  130. * Side Effects:
  131. * None.
  132. *
  133. * Caveats:
  134. * None.
  135. */
  136. /*
  137. * void CopyDecodedData ( LPVOID pdu_source_structure,
  138. * LPVOID pdu_destination_structure,
  139. * int pdu_type)
  140. *
  141. * Functional Description:
  142. * This function makes a copy of the non-encoded PDU structure. It returns
  143. * the length of the structure it has created. Normally, this will just
  144. * be the length of the source structure but the length is returned for
  145. * added flexibility later.
  146. *
  147. * Formal Parameters:
  148. * pdu_source_structure(i) Pointer to structure holding PDU data.
  149. * pdu_destination_structure(o) Pointer to structure to hold copy of
  150. * PDU data.
  151. * pdu_type (i) The type of PDU to copy.
  152. *
  153. * Return Value:
  154. * Size of the destination PDU structure.
  155. *
  156. * Side Effects:
  157. * None.
  158. *
  159. * Caveats:
  160. * None.
  161. */
  162. /*
  163. * DBBoolean IsMCSDataPacket ()
  164. *
  165. * Functional Description:
  166. * This function determines whether the encoded packet is an MCS Data packet
  167. * or not.
  168. *
  169. * Formal Parameters:
  170. * encoded_buffer (i) Pointer to buffer holding the encoded PDU.
  171. * rules_type (i) The used encoding rules.
  172. *
  173. * Return value:
  174. * TRUE, if the packet is an MCS Data packet. FALSE, otherwise.
  175. *
  176. * Side Effects:
  177. * None.
  178. *
  179. * Caveats:
  180. * None.
  181. */
  182. #endif