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.

165 lines
4.8 KiB

  1. #define FREE(x) {if(x) {free(x);}}
  2. VOID*
  3. MALLOC(size_t x);
  4. //
  5. // Types for the common comm subsystem
  6. //
  7. // WARNING: The order of these entries can never change. This ensures that
  8. // packets can be exchanged between uplevel and downlevel members.
  9. //
  10. typedef enum _COMMTYPE {
  11. COMM_NONE = 0,
  12. COMM_BOP, // beginning of packet
  13. COMM_COMMAND, // command packet stuff
  14. COMM_TO,
  15. COMM_FROM,
  16. COMM_REPLICA,
  17. COMM_JOIN_GUID,
  18. COMM_VVECTOR,
  19. COMM_CXTION,
  20. COMM_BLOCK, // file data
  21. COMM_BLOCK_SIZE,
  22. COMM_FILE_SIZE,
  23. COMM_FILE_OFFSET,
  24. COMM_REMOTE_CO, // remote change order command
  25. COMM_GVSN, // version (guid, vsn)
  26. COMM_CO_GUID, // change order guid
  27. COMM_CO_SEQUENCE_NUMBER,// CO Seq number for ack.
  28. COMM_JOIN_TIME, // machine's can't join if there times or badly out of sync
  29. COMM_LAST_JOIN_TIME, // The Last time this connection was joined.
  30. // Used to detect Database mismatch.
  31. COMM_EOP, // end of packet
  32. COMM_REPLICA_VERSION_GUID, // replica version guid (originator guid)
  33. COMM_MD5_DIGEST, // md5 digest
  34. //
  35. // Change Order Record Extension. If not supplied the the ptr for
  36. // what was Spare1Bin (now Extension) is left as Null. So comm packets
  37. // sent from down level members still work.
  38. //
  39. COMM_CO_EXT_WIN2K, // in down level code this was called COMM_CO_EXTENSION.
  40. //
  41. // See comment in schema.h for why we need to seperate the var len
  42. // COMM_CO_EXTENSION_2 from COMM_CO_EXT_WIN2K above.
  43. //
  44. COMM_CO_EXTENSION_2,
  45. COMM_COMPRESSION_GUID, // Guid for a supported compression algorithm.
  46. //
  47. // WARNING: To ensure that down level members can read Comm packets
  48. // from uplevel clients always add net data type codes here.
  49. //
  50. COMM_MAX
  51. } COMM_TYPE, *PCOMM_TYPE;
  52. #define COMM_NULL_DATA (-1)
  53. //
  54. // The decode data types are defined below. They are used in the CommPacketTable
  55. // to aid in decode dispatching and comm packet construction
  56. // They DO NOT get sent in the actual packet.
  57. //
  58. typedef enum _COMM_PACKET_DECODE_TYPE {
  59. COMM_DECODE_NONE = 0,
  60. COMM_DECODE_ULONG,
  61. COMM_DECODE_ULONG_TO_USHORT,
  62. COMM_DECODE_GNAME,
  63. COMM_DECODE_BLOB,
  64. COMM_DECODE_ULONGLONG,
  65. COMM_DECODE_VVECTOR,
  66. COMM_DECODE_VAR_LEN_BLOB,
  67. COMM_DECODE_REMOTE_CO,
  68. COMM_DECODE_GUID,
  69. COMM_DECODE_MAX
  70. } COMM_PACKET_DECODE_TYPE, *PCOMM_PACKET_DECODE_TYPE;
  71. //
  72. // The COMM_PACKET_ELEMENT struct is used in a table to describe the data
  73. // elements in a Comm packet.
  74. //
  75. typedef struct _COMM_PACKET_ELEMENT_ {
  76. COMM_TYPE CommType;
  77. PCHAR CommTag;
  78. ULONG DataSize;
  79. ULONG DecodeType;
  80. ULONG NativeOffset;
  81. } COMM_PACKET_ELEMENT, *PCOMM_PACKET_ELEMENT;
  82. #define COMM_MEM_SIZE (128)
  83. //
  84. // Size of the required Beginning-of-packet and End-of-Packet fields
  85. //
  86. #define MIN_COMM_PACKET_SIZE (2 * (sizeof(USHORT) + sizeof(ULONG) + sizeof(ULONG)))
  87. #define COMM_SZ_UL sizeof(ULONG)
  88. #define COMM_SZ_ULL sizeof(ULONGLONG)
  89. #define COMM_SZ_GUID sizeof(GUID)
  90. #define COMM_SZ_GUL sizeof(GUID) + sizeof(ULONG)
  91. #define COMM_SZ_GVSN sizeof(GVSN) + sizeof(ULONG)
  92. #define COMM_SZ_NULL 0
  93. #define COMM_SZ_COC sizeof(CHANGE_ORDER_COMMAND) + sizeof(ULONG)
  94. //#define COMM_SZ_COC CO_PART1_SIZE + CO_PART2_SIZE + CO_PART3_SIZE + sizeof(ULONG)
  95. #define COMM_SZ_COEXT_W2K sizeof(CO_RECORD_EXTENSION_WIN2K) + sizeof(ULONG)
  96. #define COMM_SZ_MD5 MD5DIGESTLEN + sizeof(ULONG)
  97. #define COMM_SZ_JTIME sizeof(ULONGLONG) + sizeof(ULONG)
  98. PCOMM_PACKET
  99. CommStartCommPkt(
  100. IN PWCHAR Name
  101. );
  102. VOID
  103. CommPackULong(
  104. IN PCOMM_PACKET CommPkt,
  105. IN COMM_TYPE Type,
  106. IN ULONG Data
  107. );
  108. //
  109. // Use a list of COMM_PKT_DESCRIPTOR items to build an
  110. // arbitrary COMM_PACKET via BuildCommPktFromDescriptorList
  111. //
  112. typedef struct _CommPktDescriptor {
  113. struct _CommPktDescriptor *Next; // for linking together the items.
  114. USHORT CommType; // We might want to use an undefined type, so don't limit to COMM_TYPE
  115. ULONG CommDataLength; // The length to put in the CommPkt
  116. ULONG ActualDataLength; // The real length of Data
  117. PVOID Data; // the data
  118. } COMM_PKT_DESCRIPTOR, *PCOMM_PKT_DESCRIPTOR;
  119. PCOMM_PACKET
  120. BuildCommPktFromDescriptorList(
  121. IN PCOMM_PKT_DESCRIPTOR pListHead,
  122. IN ULONG ActualPktSize,
  123. IN OPTIONAL ULONG *Major,
  124. IN OPTIONAL ULONG *Minor,
  125. IN OPTIONAL ULONG *CsId,
  126. IN OPTIONAL ULONG *MemLen,
  127. IN OPTIONAL ULONG *PktLen,
  128. IN OPTIONAL ULONG *UpkLen
  129. );
  130. #define COPY_GUID(_a_, _b_) CopyGuid((GUID UNALIGNED *)(_a_), (GUID UNALIGNED *)(_b_))