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.

491 lines
10 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. cxp.h
  5. Abstract:
  6. Common definitions for the Cluster Transport.
  7. Author:
  8. Mike Massa (mikemas) July 29, 1996
  9. Revision History:
  10. Who When What
  11. -------- -------- ----------------------------------------------
  12. mikemas 07-29-96 created
  13. Notes:
  14. --*/
  15. #ifndef _CXP_INCLUDED_
  16. #define _CXP_INCLUDED_
  17. #include <clusnet.h>
  18. #include <ntddtcp.h>
  19. #include <ntddndis.h>
  20. //
  21. // Tdi Definitions
  22. //
  23. //
  24. // TDI Address Object
  25. //
  26. // This structure represents a cluster transport address opened by a
  27. // TDI client. It is also used as an endpoint for datagram communication.
  28. // One such structure exists for each port address opened on the local node.
  29. //
  30. // Address objects are stored in a bucket hash table. The table is
  31. // hashed by port number.
  32. //
  33. typedef struct {
  34. CN_FSCONTEXT FsContext;
  35. LIST_ENTRY AOTableLinkage;
  36. CN_LOCK Lock;
  37. CN_IRQL Irql;
  38. ULONG Flags;
  39. USHORT LocalPort;
  40. LIST_ENTRY ReceiveQueue;
  41. PTDI_IND_ERROR ErrorHandler;
  42. PVOID ErrorContext;
  43. PTDI_IND_RECEIVE_DATAGRAM ReceiveDatagramHandler;
  44. PVOID ReceiveDatagramContext;
  45. PTDI_IND_CHAINED_RECEIVE_DATAGRAM ChainedReceiveDatagramHandler;
  46. PVOID ChainedReceiveDatagramContext;
  47. } CX_ADDROBJ, *PCX_ADDROBJ;
  48. #define CX_ADDROBJ_SIG 'rdda'
  49. #define CX_ADDROBJ_TABLE_SIZE 7
  50. #define CX_ADDROBJ_TABLE_HASH(_port) \
  51. ((ULONG) ((_port) % CX_ADDROBJ_TABLE_SIZE))
  52. #define CX_AO_FLAG_DELETING 0x00000001
  53. #define CX_AO_FLAG_CHECKSTATE 0x00000002
  54. extern LIST_ENTRY CxAddrObjTable[CX_ADDROBJ_TABLE_SIZE];
  55. extern CN_LOCK CxAddrObjTableLock;
  56. extern HANDLE CxTdiRegistrationHandle;
  57. //
  58. // Packet header structures need to be packed.
  59. //
  60. #include <packon.h>
  61. //
  62. // CNP Header
  63. //
  64. typedef struct {
  65. UCHAR Version;
  66. UCHAR NextHeader;
  67. USHORT PayloadLength;
  68. ULONG SourceAddress;
  69. ULONG DestinationAddress;
  70. } CNP_HEADER, *PCNP_HEADER;
  71. //
  72. // CDP Header
  73. //
  74. typedef struct {
  75. USHORT SourcePort;
  76. USHORT DestinationPort;
  77. USHORT PayloadLength;
  78. USHORT Checksum;
  79. } CDP_HEADER, *PCDP_HEADER;
  80. //
  81. // Node info structure for heartbeats.
  82. //
  83. typedef struct _CX_HB_NODE_INFO {
  84. ULONG SeqNumber;
  85. ULONG AckNumber;
  86. } CX_HB_NODE_INFO, *PCX_HB_NODE_INFO;
  87. //
  88. // Multicast signature data.
  89. //
  90. typedef struct {
  91. UCHAR Version;
  92. UCHAR Reserved;
  93. USHORT SigLength;
  94. CL_NETWORK_ID NetworkId;
  95. ULONG ClusterNetworkBrand;
  96. USHORT SaltLength;
  97. UCHAR SigDataBuffer[1]; // Dynamic: SigLength + SaltLength
  98. } CNP_SIGNATURE, *PCNP_SIGNATURE;
  99. #include <packoff.h>
  100. //
  101. // Protocol constants
  102. //
  103. #define CNP_VERSION_1 0x1 // original CNP
  104. #define CNP_VERSION_2 0x2 // original CNP + multicast
  105. #define CNP_VERSION_UNICAST CNP_VERSION_1
  106. #define CNP_VERSION_MULTICAST CNP_VERSION_2
  107. #define PROTOCOL_CCMP 1
  108. #define PROTOCOL_CDP 2
  109. #define CNP_SIG_VERSION_1 0x1
  110. //
  111. // Size of CNP multicast signature data.
  112. //
  113. #define CNP_SIGHDR_LENGTH \
  114. (FIELD_OFFSET(CNP_SIGNATURE, SigDataBuffer[0]))
  115. #define CNP_SIG_LENGTH(_SignatureDataSize) \
  116. (CNP_SIGHDR_LENGTH + (_SignatureDataSize))
  117. #define MAX_UDP_SEND_SIZE ( 0xFFFF - 68 )
  118. #define CDP_MAX_SEND_SIZE(_SignatureDataSize) \
  119. (MAX_UDP_SEND_SIZE \
  120. - sizeof(CNP_HEADER) \
  121. - CNP_SIG_LENGTH(_SignatureDataSize)) \
  122. - sizeof(CDP_HEADER)
  123. //
  124. // CNP Receive Flags
  125. //
  126. #define CNP_RECV_FLAG_NODE_STATE_CHECK_PASSED 0x00000001
  127. #define CNP_RECV_FLAG_MULTICAST 0x00000002
  128. #define CNP_RECV_FLAG_CURRENT_MULTICAST_GROUP 0x00000004
  129. #define CNP_RECV_FLAG_SIGNATURE_VERIFIED 0x00000008
  130. //
  131. // Multicast epoch
  132. //
  133. extern ULONG CxMulticastEpoch;
  134. //
  135. // put here for kdcn
  136. //
  137. typedef enum {
  138. CcmpInvalidMsgType = 0,
  139. CcmpHeartbeatMsgType = 1,
  140. CcmpPoisonMsgType = 2,
  141. CcmpMembershipMsgType = 3,
  142. CcmpMcastHeartbeatMsgType = 4
  143. } CCMP_MSG_TYPE;
  144. //
  145. // From MM in clussvc:
  146. //
  147. // The data type "cluster_t" is a bit array of size equal to the maximum
  148. // number of nodes in the cluster. The bit array is implemented as an
  149. // array of uint8s.
  150. //
  151. // Given a node#, its bit position in the bit array is computed by first
  152. // locating the byte in the array (node# / BYTEL) and then the bit in
  153. // the byte. Bits in the byte are numbered 0..7 (from left to right).
  154. // Thus, node 0 is placed in byte 0, bit 0, which is the left-most bit
  155. // in the bit array.
  156. //
  157. //
  158. // The cluster type sizing defines and manipulation routines are copied
  159. // from MM so there is some notion of how the mask is managed.
  160. //
  161. #define MAX_CLUSTER_SIZE ClusterDefaultMaxNodes
  162. #define BYTEL 8 // number of bits in a uint8
  163. #define BYTES_IN_CLUSTER ((MAX_CLUSTER_SIZE + BYTEL - 1) / BYTEL)
  164. #define BYTE(cluster, node) ( (cluster)[(node) / BYTEL] ) // byte# in array
  165. #define BIT(node) ( (node) % BYTEL ) // bit# in byte
  166. typedef UCHAR cluster_t [BYTES_IN_CLUSTER];
  167. typedef SHORT node_t;
  168. typedef union _CX_CLUSTERSCREEN {
  169. ULONG UlongScreen;
  170. cluster_t ClusterScreen;
  171. } CX_CLUSTERSCREEN;
  172. //
  173. // converts external node number to internal
  174. //
  175. #define LOWEST_NODENUM ((node_t)ClusterMinNodeId) // starting node number
  176. #define INT_NODE(ext_node) ((node_t)(ext_node - LOWEST_NODENUM))
  177. #define CnpClusterScreenMember(c, i) \
  178. ((BOOLEAN)((BYTE(c,i) >> (BYTEL-1-BIT(i))) & 1))
  179. #define CnpClusterScreenInsert(c, i) \
  180. (BYTE(c, i) |= (1 << (BYTEL-1-BIT(i))))
  181. #define CnpClusterScreenDelete(c, i) \
  182. (BYTE(c, i) &= ~(1 << (BYTEL-1-BIT(i))))
  183. //
  184. // CNP Receive Request structures and routines
  185. //
  186. //
  187. // Receive Request Pool
  188. //
  189. typedef struct {
  190. ULONG UpperProtocolContextSize;
  191. } CNP_RECEIVE_REQUEST_POOL_CONTEXT, *PCNP_RECEIVE_REQUEST_POOL_CONTEXT;
  192. //
  193. // Receive Request Structure
  194. //
  195. typedef struct {
  196. CN_RESOURCE CnResource;
  197. PIRP Irp;
  198. PVOID DataBuffer;
  199. PVOID UpperProtocolContext;
  200. } CNP_RECEIVE_REQUEST, *PCNP_RECEIVE_REQUEST;
  201. PCN_RESOURCE_POOL
  202. CnpCreateReceiveRequestPool(
  203. IN ULONG UpperProtocolContextSize,
  204. IN USHORT PoolDepth
  205. );
  206. #define CnpDeleteReceiveRequestPool(_pool) \
  207. { \
  208. CnDrainResourcePool(_pool); \
  209. CnFreePool(_pool); \
  210. }
  211. PCNP_RECEIVE_REQUEST
  212. CnpAllocateReceiveRequest(
  213. IN PCN_RESOURCE_POOL RequestPool,
  214. IN PVOID Network,
  215. IN ULONG BytesToReceive,
  216. IN PVOID CompletionRoutine
  217. );
  218. VOID
  219. CnpFreeReceiveRequest(
  220. PCNP_RECEIVE_REQUEST Request
  221. );
  222. //
  223. //
  224. // Function Prototypes
  225. //
  226. //
  227. VOID
  228. CxTdiAddAddressHandler(
  229. IN PTA_ADDRESS TaAddress,
  230. IN PUNICODE_STRING DeviceName,
  231. IN PTDI_PNP_CONTEXT Context
  232. );
  233. VOID
  234. CxTdiDelAddressHandler(
  235. IN PTA_ADDRESS TaAddress,
  236. IN PUNICODE_STRING DeviceName,
  237. IN PTDI_PNP_CONTEXT Context
  238. );
  239. NTSTATUS
  240. CxWmiPnpLoad(
  241. VOID
  242. );
  243. VOID
  244. CxWmiPnpUnload(
  245. VOID
  246. );
  247. NTSTATUS
  248. CxWmiPnpInitialize(
  249. VOID
  250. );
  251. VOID
  252. CxWmiPnpShutdown(
  253. VOID
  254. );
  255. VOID
  256. CxReconnectLocalInterface(
  257. IN CL_NETWORK_ID NetworkId
  258. );
  259. VOID
  260. CxQueryMediaStatus(
  261. IN HANDLE AdapterDeviceHandle,
  262. IN CL_NETWORK_ID NetworkId,
  263. OUT PULONG MediaStatus
  264. );
  265. VOID
  266. CxBuildTdiAddress(
  267. PVOID Buffer,
  268. CL_NODE_ID Node,
  269. USHORT Port,
  270. BOOLEAN Verified
  271. );
  272. NTSTATUS
  273. CxParseTransportAddress(
  274. IN TRANSPORT_ADDRESS UNALIGNED *AddrList,
  275. IN ULONG AddressListLength,
  276. OUT CL_NODE_ID * Node,
  277. OUT PUSHORT Port
  278. );
  279. PCX_ADDROBJ
  280. CxFindAddressObject(
  281. IN USHORT Port
  282. );
  283. NTSTATUS
  284. CnpLoadNodes(
  285. VOID
  286. );
  287. NTSTATUS
  288. CnpInitializeNodes(
  289. VOID
  290. );
  291. VOID
  292. CnpShutdownNodes(
  293. VOID
  294. );
  295. NTSTATUS
  296. CnpLoadNetworks(
  297. VOID
  298. );
  299. NTSTATUS
  300. CnpInitializeNetworks(
  301. VOID
  302. );
  303. VOID
  304. CnpShutdownNetworks(
  305. VOID
  306. );
  307. NTSTATUS
  308. CnpLoad(
  309. VOID
  310. );
  311. VOID
  312. CnpUnload(
  313. VOID
  314. );
  315. NTSTATUS
  316. CcmpLoad(
  317. VOID
  318. );
  319. VOID
  320. CcmpUnload(
  321. VOID
  322. );
  323. NTSTATUS
  324. CdpLoad(
  325. VOID
  326. );
  327. VOID
  328. CdpUnload(
  329. VOID
  330. );
  331. NTSTATUS
  332. CdpReceivePacketHandler(
  333. IN PVOID Network,
  334. IN CL_NODE_ID SourceNodeId,
  335. IN ULONG CnpReceiveFlags,
  336. IN ULONG TdiReceiveDatagramFlags,
  337. IN ULONG BytesIndicated,
  338. IN ULONG BytesAvailable,
  339. OUT PULONG BytesTaken,
  340. IN PVOID Tsdu,
  341. OUT PIRP * Irp
  342. );
  343. NTSTATUS
  344. CxInitializeHeartBeat(
  345. VOID
  346. );
  347. VOID
  348. CxUnloadHeartBeat(
  349. VOID
  350. );
  351. NTSTATUS
  352. CnpStartHeartBeats(
  353. VOID
  354. );
  355. VOID
  356. CnpStopHeartBeats(
  357. VOID
  358. );
  359. NTSTATUS
  360. CxReserveClusnetEndpoint(
  361. IN USHORT Port
  362. );
  363. NTSTATUS
  364. CxUnreserveClusnetEndpoint(
  365. VOID
  366. );
  367. NTSTATUS
  368. CxSendMcastHeartBeatMessage(
  369. IN CL_NETWORK_ID NetworkId,
  370. IN PVOID McastGroup,
  371. IN CX_CLUSTERSCREEN McastTargetNodes,
  372. IN ULONG McastEpoch,
  373. IN CX_HB_NODE_INFO NodeInfo[],
  374. IN PCX_SEND_COMPLETE_ROUTINE CompletionRoutine, OPTIONAL
  375. IN PVOID CompletionContext OPTIONAL
  376. );
  377. NTSTATUS
  378. CxConfigureMulticast(
  379. IN CL_NETWORK_ID NetworkId,
  380. IN ULONG MulticastNetworkBrand,
  381. IN PTRANSPORT_ADDRESS TdiMcastBindAddress,
  382. IN ULONG TdiMcastBindAddressLength,
  383. IN PVOID Key,
  384. IN ULONG KeyLength,
  385. IN PIRP Irp
  386. );
  387. NTSTATUS
  388. CxGetMulticastReachableSet(
  389. IN CL_NETWORK_ID NetworkId,
  390. OUT ULONG * NodeScreen
  391. );
  392. #endif // ifndef _CXP_INCLUDED_