Source code of Windows XP (NT5)
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.

487 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 PayloadOffset;
  94. CL_NETWORK_ID NetworkId;
  95. ULONG ClusterNetworkBrand;
  96. USHORT SigBufferLen;
  97. UCHAR SigBuffer[1]; // dynamic
  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, SigBuffer[0]))
  115. #define CNP_SIG_LENGTH(_SignatureSize) \
  116. (CNP_SIGHDR_LENGTH + (_SignatureSize))
  117. #define MAX_UDP_SEND_SIZE ( 0xFFFF - 68 )
  118. #define CDP_MAX_SEND_SIZE(_SignatureSize) \
  119. (MAX_UDP_SEND_SIZE \
  120. - sizeof(CNP_HEADER) \
  121. - CNP_SIG_LENGTH(_SignatureSize)) \
  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. // put here for kdcn
  132. //
  133. typedef enum {
  134. CcmpInvalidMsgType = 0,
  135. CcmpHeartbeatMsgType = 1,
  136. CcmpPoisonMsgType = 2,
  137. CcmpMembershipMsgType = 3,
  138. CcmpMcastHeartbeatMsgType = 4
  139. } CCMP_MSG_TYPE;
  140. //
  141. // From MM in clussvc:
  142. //
  143. // The data type "cluster_t" is a bit array of size equal to the maximum
  144. // number of nodes in the cluster. The bit array is implemented as an
  145. // array of uint8s.
  146. //
  147. // Given a node#, its bit position in the bit array is computed by first
  148. // locating the byte in the array (node# / BYTEL) and then the bit in
  149. // the byte. Bits in the byte are numbered 0..7 (from left to right).
  150. // Thus, node 0 is placed in byte 0, bit 0, which is the left-most bit
  151. // in the bit array.
  152. //
  153. //
  154. // The cluster type sizing defines and manipulation routines are copied
  155. // from MM so there is some notion of how the mask is managed.
  156. //
  157. #define MAX_CLUSTER_SIZE ClusterDefaultMaxNodes
  158. #define BYTEL 8 // number of bits in a uint8
  159. #define BYTES_IN_CLUSTER ((MAX_CLUSTER_SIZE + BYTEL - 1) / BYTEL)
  160. #define BYTE(cluster, node) ( (cluster)[(node) / BYTEL] ) // byte# in array
  161. #define BIT(node) ( (node) % BYTEL ) // bit# in byte
  162. typedef UCHAR cluster_t [BYTES_IN_CLUSTER];
  163. typedef SHORT node_t;
  164. typedef union _CX_CLUSTERSCREEN {
  165. ULONG UlongScreen;
  166. cluster_t ClusterScreen;
  167. } CX_CLUSTERSCREEN;
  168. //
  169. // converts external node number to internal
  170. //
  171. #define LOWEST_NODENUM ((node_t)ClusterMinNodeId) // starting node number
  172. #define INT_NODE(ext_node) ((node_t)(ext_node - LOWEST_NODENUM))
  173. #define CnpClusterScreenMember(c, i) \
  174. ((BOOLEAN)((BYTE(c,i) >> (BYTEL-1-BIT(i))) & 1))
  175. #define CnpClusterScreenInsert(c, i) \
  176. (BYTE(c, i) |= (1 << (BYTEL-1-BIT(i))))
  177. #define CnpClusterScreenDelete(c, i) \
  178. (BYTE(c, i) &= ~(1 << (BYTEL-1-BIT(i))))
  179. //
  180. // CNP Receive Request structures and routines
  181. //
  182. //
  183. // Receive Request Pool
  184. //
  185. typedef struct {
  186. ULONG UpperProtocolContextSize;
  187. } CNP_RECEIVE_REQUEST_POOL_CONTEXT, *PCNP_RECEIVE_REQUEST_POOL_CONTEXT;
  188. //
  189. // Receive Request Structure
  190. //
  191. typedef struct {
  192. CN_RESOURCE CnResource;
  193. PIRP Irp;
  194. PVOID DataBuffer;
  195. PVOID UpperProtocolContext;
  196. } CNP_RECEIVE_REQUEST, *PCNP_RECEIVE_REQUEST;
  197. PCN_RESOURCE_POOL
  198. CnpCreateReceiveRequestPool(
  199. IN ULONG UpperProtocolContextSize,
  200. IN USHORT PoolDepth
  201. );
  202. #define CnpDeleteReceiveRequestPool(_pool) \
  203. { \
  204. CnDrainResourcePool(_pool); \
  205. CnFreePool(_pool); \
  206. }
  207. PCNP_RECEIVE_REQUEST
  208. CnpAllocateReceiveRequest(
  209. IN PCN_RESOURCE_POOL RequestPool,
  210. IN PVOID Network,
  211. IN ULONG BytesToReceive,
  212. IN PVOID CompletionRoutine
  213. );
  214. VOID
  215. CnpFreeReceiveRequest(
  216. PCNP_RECEIVE_REQUEST Request
  217. );
  218. //
  219. //
  220. // Function Prototypes
  221. //
  222. //
  223. VOID
  224. CxTdiAddAddressHandler(
  225. IN PTA_ADDRESS TaAddress,
  226. IN PUNICODE_STRING DeviceName,
  227. IN PTDI_PNP_CONTEXT Context
  228. );
  229. VOID
  230. CxTdiDelAddressHandler(
  231. IN PTA_ADDRESS TaAddress,
  232. IN PUNICODE_STRING DeviceName,
  233. IN PTDI_PNP_CONTEXT Context
  234. );
  235. NTSTATUS
  236. CxWmiPnpLoad(
  237. VOID
  238. );
  239. VOID
  240. CxWmiPnpUnload(
  241. VOID
  242. );
  243. NTSTATUS
  244. CxWmiPnpInitialize(
  245. VOID
  246. );
  247. VOID
  248. CxWmiPnpShutdown(
  249. VOID
  250. );
  251. VOID
  252. CxReconnectLocalInterface(
  253. IN CL_NETWORK_ID NetworkId
  254. );
  255. VOID
  256. CxQueryMediaStatus(
  257. IN HANDLE AdapterDeviceHandle,
  258. IN CL_NETWORK_ID NetworkId,
  259. OUT PULONG MediaStatus
  260. );
  261. VOID
  262. CxBuildTdiAddress(
  263. PVOID Buffer,
  264. CL_NODE_ID Node,
  265. USHORT Port,
  266. BOOLEAN Verified
  267. );
  268. NTSTATUS
  269. CxParseTransportAddress(
  270. IN TRANSPORT_ADDRESS UNALIGNED *AddrList,
  271. IN ULONG AddressListLength,
  272. OUT CL_NODE_ID * Node,
  273. OUT PUSHORT Port
  274. );
  275. PCX_ADDROBJ
  276. CxFindAddressObject(
  277. IN USHORT Port
  278. );
  279. NTSTATUS
  280. CnpLoadNodes(
  281. VOID
  282. );
  283. NTSTATUS
  284. CnpInitializeNodes(
  285. VOID
  286. );
  287. VOID
  288. CnpShutdownNodes(
  289. VOID
  290. );
  291. NTSTATUS
  292. CnpLoadNetworks(
  293. VOID
  294. );
  295. NTSTATUS
  296. CnpInitializeNetworks(
  297. VOID
  298. );
  299. VOID
  300. CnpShutdownNetworks(
  301. VOID
  302. );
  303. NTSTATUS
  304. CnpLoad(
  305. VOID
  306. );
  307. VOID
  308. CnpUnload(
  309. VOID
  310. );
  311. NTSTATUS
  312. CcmpLoad(
  313. VOID
  314. );
  315. VOID
  316. CcmpUnload(
  317. VOID
  318. );
  319. NTSTATUS
  320. CdpLoad(
  321. VOID
  322. );
  323. VOID
  324. CdpUnload(
  325. VOID
  326. );
  327. NTSTATUS
  328. CdpReceivePacketHandler(
  329. IN PVOID Network,
  330. IN CL_NODE_ID SourceNodeId,
  331. IN ULONG CnpReceiveFlags,
  332. IN ULONG TdiReceiveDatagramFlags,
  333. IN ULONG BytesIndicated,
  334. IN ULONG BytesAvailable,
  335. OUT PULONG BytesTaken,
  336. IN PVOID Tsdu,
  337. OUT PIRP * Irp
  338. );
  339. NTSTATUS
  340. CxInitializeHeartBeat(
  341. VOID
  342. );
  343. VOID
  344. CxUnloadHeartBeat(
  345. VOID
  346. );
  347. VOID
  348. CnpStartHeartBeats(
  349. VOID
  350. );
  351. VOID
  352. CnpStopHeartBeats(
  353. VOID
  354. );
  355. NTSTATUS
  356. CxReserveClusnetEndpoint(
  357. IN USHORT Port
  358. );
  359. NTSTATUS
  360. CxUnreserveClusnetEndpoint(
  361. VOID
  362. );
  363. NTSTATUS
  364. CxSendMcastHeartBeatMessage(
  365. IN CL_NETWORK_ID NetworkId,
  366. IN PVOID McastGroup,
  367. IN CX_CLUSTERSCREEN McastTargetNodes,
  368. IN CX_HB_NODE_INFO NodeInfo[],
  369. IN PCX_SEND_COMPLETE_ROUTINE CompletionRoutine, OPTIONAL
  370. IN PVOID CompletionContext OPTIONAL
  371. );
  372. NTSTATUS
  373. CxConfigureMulticast(
  374. IN CL_NETWORK_ID NetworkId,
  375. IN ULONG MulticastNetworkBrand,
  376. IN PTRANSPORT_ADDRESS TdiMcastBindAddress,
  377. IN ULONG TdiMcastBindAddressLength,
  378. IN PVOID Key,
  379. IN ULONG KeyLength,
  380. IN PVOID Salt,
  381. IN ULONG SaltLength,
  382. IN PIRP Irp
  383. );
  384. NTSTATUS
  385. CxGetMulticastReachableSet(
  386. IN CL_NETWORK_ID NetworkId,
  387. OUT ULONG * NodeScreen
  388. );
  389. #endif // ifndef _CXP_INCLUDED_
  390.