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.

231 lines
8.5 KiB

  1. /* PSTNFram.h
  2. *
  3. * Copyright (c) 1993-1995 by DataBeam Corporation, Lexington, KY
  4. *
  5. * Abstract:
  6. * This function encodes and decodes functions according to the encoding
  7. * rules set by the T.123 communications standard for PSTN. The standard
  8. * states that a flag will precede each packet and a flag will be appended
  9. * to the end of each packet. Therefore no flags are permitted in the body
  10. * of the packet. Flags are replaced by an ESCAPE sequence. If an ESCAPE
  11. * byte is found in a packet, remove the ESCAPE, and negate the 6th bit of
  12. * the next byte.
  13. *
  14. * Caveats:
  15. * None
  16. *
  17. * Authors:
  18. * James W. Lawwill
  19. */
  20. #ifndef _PSTN_FRAME_H_
  21. #define _PSTN_FRAME_H_
  22. #include "framer.h"
  23. /*
  24. ** Commonly used definitions
  25. */
  26. #define FLAG 0x7e
  27. #define ESCAPE 0x7d
  28. #define COMPLEMENT_BIT 0x20
  29. #define NEGATE_COMPLEMENT_BIT 0xdf
  30. class PSTNFrame : public PacketFrame
  31. {
  32. public:
  33. PSTNFrame(void);
  34. virtual ~PSTNFrame(void);
  35. PacketFrameError PacketEncode (
  36. PUChar source_address,
  37. UShort source_length,
  38. PUChar dest_address,
  39. UShort dest_length,
  40. DBBoolean prepend_flag,
  41. DBBoolean append_flag,
  42. PUShort packet_size);
  43. PacketFrameError PacketDecode (
  44. PUChar source_address,
  45. UShort source_length,
  46. PUChar dest_address,
  47. UShort dest_length,
  48. PUShort bytes_accepted,
  49. PUShort packet_size,
  50. DBBoolean continue_packet);
  51. Void GetOverhead (
  52. UShort original_packet_size,
  53. PUShort max_packet_size);
  54. private:
  55. PUChar Source_Address;
  56. UShort Source_Length;
  57. PUChar Dest_Address;
  58. UShort Dest_Length;
  59. UShort Source_Byte_Count;
  60. UShort Dest_Byte_Count;
  61. DBBoolean Escape_Found;
  62. DBBoolean First_Flag_Found;
  63. };
  64. typedef PSTNFrame * PPSTNFrame;
  65. #endif
  66. /*
  67. * PSTNFrame::PSTNFrame (
  68. * Void);
  69. *
  70. * Functional Description
  71. * This is the constructor for the PSTNFrame class. It initializes all
  72. * internal variables.
  73. *
  74. * Formal Parameters
  75. * None.
  76. *
  77. * Return Value
  78. * None
  79. *
  80. * Side Effects
  81. * None
  82. *
  83. * Caveats
  84. * None
  85. */
  86. /*
  87. * PSTNFrame::~PSTNFrame (
  88. * Void);
  89. *
  90. * Functional Description
  91. * This is the destructor for the PSTNFrame class. It does nothing
  92. *
  93. * Formal Parameters
  94. * None.
  95. *
  96. * Return Value
  97. * None
  98. *
  99. * Side Effects
  100. * None
  101. *
  102. * Caveats
  103. * None
  104. */
  105. /*
  106. * PacketFrameError PSTNFrame::PacketEncode (
  107. * PUChar source_address,
  108. * UShort source_length,
  109. * PUChar dest_address,
  110. * UShort dest_length,
  111. * DBBoolean prepend_flag,
  112. * DBBoolean append_flag,
  113. * PUShort packet_size);
  114. *
  115. *
  116. * Functional Description
  117. * This function encodes the passed in buffer to meet the T.123 standard.
  118. *
  119. * Formal Parameters
  120. * source_address (i) - Address of the buffer to encode
  121. * source_length (i) - Length of the buffer to encode
  122. * dest_address (i) - Address of the destination buffer
  123. * dest_length (i) - Length of the destination buffer
  124. * prepend_flag (i) - DBBoolean that tells us whether or not to put
  125. * a flag at the beginning of the packet
  126. * append_flag (i) - DBBoolean that tells us whether or not to put
  127. * a flag at the end of the packet
  128. * packet_size (o) - We return this to the user to tell them the new
  129. * size of the packet
  130. *
  131. * Return Value
  132. * PACKET_FRAME_NO_ERROR - No error occured
  133. * PACKET_FRAME_DEST_BUFFER_TOO_SMALL - The destination buffer passed
  134. * in was too small
  135. *
  136. * Side Effects
  137. * None
  138. *
  139. * Caveats
  140. * None
  141. */
  142. /*
  143. * PacketFrameError PSTNFrame::PacketDecode (
  144. * PUChar source_address,
  145. * UShort source_length,
  146. * PUChar dest_address,
  147. * UShort dest_length,
  148. * PUShort bytes_accepted,
  149. * PUShort packet_size,
  150. * DBBoolean continue_packet);
  151. *
  152. * Functional Description
  153. * This function takes the input data and decodes it, looking for a
  154. * T123 packet. The user may have to call this function many times
  155. * before a packet is pieced together. If the user calls this function
  156. * and and sets either soure_address or dest_address to NULL, it uses
  157. * the addresses passed in, the last time this function was called. If
  158. * there is one source buffer to decode, the user can pass that address
  159. * in the first time and continue calling the function with NULL as the
  160. * source address until the buffer is exhausted. The user will know the
  161. * buffer is exhausted when the return code is simply PACKET_FRAME_NO_ERROR
  162. * rather than PACKET_FRAME_PACKET_DECODED.
  163. *
  164. * Formal Parameters
  165. * source_address (i) - Address of the buffer to decode
  166. * source_length (i) - Length of the buffer to decode
  167. * dest_address (i) - Address of the destination buffer
  168. * dest_length (i) - Length of the destination buffer
  169. * bytes_accepted (o) - We return the number of source bytes processed
  170. * packet_size (o) - We return the size of the packet. This is only
  171. * valid if the return code is
  172. * PACKET_FRAME_PACKET_DECODED.
  173. * continue_packet (i) - DBBoolean, tells us if we should start by
  174. * looking for the first flag. If the user wants
  175. * to abort the current search, use this flag.
  176. *
  177. * Return Value
  178. * PACKET_FRAME_NO_ERROR - No error occured, source buffer
  179. * exhausted
  180. * PACKET_FRAME_DEST_BUFFER_TOO_SMALL - The destination buffer passed
  181. * in was too small
  182. * PACKET_FRAME_PACKET_DECODED - Decoding stopped, packet decoded
  183. *
  184. * Side Effects
  185. * None
  186. *
  187. * Caveats
  188. * None
  189. */
  190. /*
  191. * Void PSTNFrame::GetOverhead (
  192. * UShort original_packet_size,
  193. * PUShort max_packet_size);
  194. *
  195. * Functional Description
  196. * This function takes the original packet size and returns the maximum
  197. * size of the packet after it has been encoded. Worst case will be
  198. * twice as big as it was with two flags.
  199. *
  200. * Formal Parameters
  201. * original_packet_size (i) - Self-explanatory
  202. * max_packet_size (o) - Worst case size of the packet
  203. *
  204. * Return Value
  205. * None
  206. *
  207. * Side Effects
  208. * None
  209. *
  210. * Caveats
  211. * None
  212. */