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.

89 lines
2.3 KiB

  1. /* (C) 1997 Microsoft Corp.
  2. *
  3. * file : X224.h
  4. * author : Erik Mavrinac
  5. *
  6. * description: X.224 types and defines for encoding and decoding X.224
  7. * packets for MCS.
  8. */
  9. #ifndef __X224_H
  10. #define __X224_H
  11. /*
  12. * Defines
  13. */
  14. #define X224_ConnectionConPacketSize 11
  15. #define X224_DataHeaderSize 7
  16. // TPDU types.
  17. #define X224_None 0
  18. #define X224_ConnectionReq 0xE0
  19. #define X224_ConnectionCon 0xD0
  20. #define X224_Disconnect 0x80
  21. #define X224_Error 0x70
  22. #define X224_Data 0xF0
  23. // X.224 Data EOT field.
  24. #define X224_EOT 0x80
  25. // X.224 Connect Request extra field type.
  26. #define TPDU_SIZE 0xC0
  27. // RFC1006 default of 65531 minus 3 bytes for data TPDU header.
  28. #define X224_DefaultDataSize 65528
  29. /*
  30. * Prototypes for worker functions referred to by other files.
  31. */
  32. void CreateX224ConnectionConfirmPacket(BYTE *, unsigned, unsigned);
  33. /*
  34. * X.224 data header is laid out as follows:
  35. * Byte Contents
  36. * ---- --------
  37. * 0 RFC1006 version number, must be 0x03.
  38. * 1 RFC1006 Reserved, must be 0x00.
  39. * 2 RFC1006 MSB of word-sized total-frame length (incl. whole X.224 header).
  40. * 3 RFC1006 LSB of word-sized total-frame length.
  41. * 4 Length Indicator, the size of the header bytes following (== 2).
  42. * 5 Data packet indicator, 0xF0.
  43. * 6 X224_EOT (0x80) if this is the last packet, 0x00 otherwise.
  44. *
  45. * bLastTPDU is nonzero when the data in this TPDU is the final X.224 block
  46. * in this data send sequence.
  47. *
  48. * Assumes that PayloadDataSize does not exceed the maximum X.224 user data size
  49. * negotiated during X.224 connection.
  50. */
  51. __inline void CreateX224DataHeader(
  52. BYTE *pBuffer,
  53. unsigned PayloadDataSize,
  54. BOOLEAN bLastTPDU)
  55. {
  56. unsigned TotalSize;
  57. TotalSize = PayloadDataSize + X224_DataHeaderSize;
  58. // RFC1006 header.
  59. pBuffer[0] = 0x03;
  60. pBuffer[1] = 0x00;
  61. pBuffer[2] = (TotalSize & 0x0000FF00) >> 8;
  62. pBuffer[3] = (TotalSize & 0x000000FF);
  63. // Data TPDU header.
  64. pBuffer[4] = 0x02; // Size of TPDU bytes following.
  65. pBuffer[5] = X224_Data;
  66. pBuffer[6] = (PayloadDataSize && bLastTPDU) ? X224_EOT : 0;
  67. }
  68. #endif // !defined(__X224_H)