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.

195 lines
3.6 KiB

  1. /* crc.h
  2. *
  3. * Copyright (c) 1994-1995 by DataBeam Corporation, Lexington, KY
  4. *
  5. * Abstract:
  6. * This file contains the CRC class definition. This class can use either
  7. * the table-driven or bit-shifting approach to generate its CRC.
  8. *
  9. * Public Instance Variable:
  10. * None
  11. *
  12. * Caveats:
  13. * None.
  14. *
  15. * Authors:
  16. * Marvin Nicholson
  17. */
  18. #ifndef _CRC_
  19. #define _CRC_
  20. #include "databeam.h"
  21. #define CRC_TABLE_SIZE 256
  22. class CRC
  23. {
  24. public:
  25. CRC ();
  26. ~CRC ();
  27. ULong OldCRCGenerator(
  28. PUChar block_adr,
  29. ULong block_len);
  30. ULong CRCGenerator(
  31. PUChar block_adr,
  32. ULong block_len);
  33. DBBoolean CheckCRC(
  34. PUChar block_adr,
  35. ULong block_len);
  36. Void GetOverhead(
  37. UShort maximum_packet,
  38. PUShort new_maximum_packet);
  39. private:
  40. UShort CRCTableValue(
  41. Int Index,
  42. ULong poly);
  43. Void CRCTableGenerator(
  44. ULong poly);
  45. UShort CRC_Table[CRC_TABLE_SIZE];
  46. Int CRC_Width;
  47. ULong CRC_Poly;
  48. ULong CRC_Init;
  49. UShort CRC_Check_Value;
  50. DBBoolean Invert;
  51. UShort CRC_Register;
  52. };
  53. typedef CRC * PCRC;
  54. #endif
  55. /*
  56. * CRC::CRC ();
  57. *
  58. * Functional Description
  59. * This is the constructor for this class.
  60. *
  61. * Formal Parameters
  62. * None.
  63. *
  64. * Return Value
  65. * None
  66. *
  67. * Side Effects
  68. * None
  69. *
  70. * Caveats
  71. * None
  72. */
  73. /*
  74. * CRC::~CRC ();
  75. *
  76. * Functional Description
  77. * This is the destructor for this class.
  78. *
  79. * Formal Parameters
  80. * None.
  81. *
  82. * Return Value
  83. * None
  84. *
  85. * Side Effects
  86. * None
  87. *
  88. * Caveats
  89. * None
  90. */
  91. /*
  92. * ULong CRC::OldCRCGenerator(
  93. * PUChar block_adr,
  94. * ULong block_len);
  95. *
  96. * Functional Description
  97. * This function generates the crc using bit-shifting methods. This method
  98. * is slower than the table-driven approach.
  99. *
  100. * Formal Parameters
  101. * block_adr (i) - Address of buffer to generate CRC on.
  102. * block_lengh (i) - Length of buffer
  103. *
  104. * Return Value
  105. * CRC value
  106. *
  107. * Side Effects
  108. * None
  109. *
  110. * Caveats
  111. * None
  112. */
  113. /*
  114. * ULong CRC::CRCGenerator(
  115. * PUChar block_adr,
  116. * ULong block_len);
  117. *
  118. * Functional Description
  119. * This function generates the crc using the table-driven method.
  120. *
  121. * Formal Parameters
  122. * block_adr (i) - Address of buffer to generate CRC on.
  123. * block_lengh (i) - Length of buffer
  124. *
  125. * Return Value
  126. * CRC value
  127. *
  128. * Side Effects
  129. * None
  130. *
  131. * Caveats
  132. * None
  133. */
  134. /*
  135. * DBBoolean CRC::CheckCRC(
  136. * PUChar block_adr,
  137. * ULong block_len);
  138. *
  139. * Functional Description
  140. * This function generates a CRC based on the block passed in. It assumes
  141. * that the CRC is attached to the end of the block. It compares the
  142. * CRC generated to the CRC at the end of the block and returns TRUE if
  143. * the CRC is correct.
  144. *
  145. * Formal Parameters
  146. * block_adr (i) - Address of buffer to generate CRC on.
  147. * block_lengh (i) - Length of buffer
  148. *
  149. * Return Value
  150. * TRUE - CRC in the block is correct
  151. * FALSE - CRC in the block is NOT correct
  152. *
  153. * Side Effects
  154. * None
  155. *
  156. * Caveats
  157. * None
  158. */
  159. /*
  160. * Void CRC::GetOverhead(
  161. * UShort maximum_packet,
  162. * PUShort new_maximum_packet);
  163. *
  164. * Functional Description
  165. * This function is called to determine the overhead that will be added
  166. * to the packet by the CRC.
  167. *
  168. * Formal Parameters
  169. * maximum_packet (i) - Current max. packet size
  170. * new_maximum_packet (o) - Maximum length of packet including CRC.
  171. *
  172. * Return Value
  173. * None
  174. *
  175. * Side Effects
  176. * None
  177. *
  178. * Caveats
  179. * None
  180. */