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.

301 lines
9.7 KiB

  1. #ifndef _CLMSG_H_
  2. #define _CLMSG_H_
  3. /* ----------------------- ClMsg.h ----------------------- */
  4. /* Cluster messaging */
  5. /* This file contains the specifications of the low-level messaging
  6. functions required by the Cluster Manager's module. Primary input
  7. to this is the node#; see the MM module for details. It is assumed
  8. that this module is configured (by mechanisms not described here)
  9. to know the various paths to the target node (IP address, netbios
  10. address, async line, Snet address, ...).
  11. It is also assumed that *all* CM->CM communication uses this
  12. module. The various CM components must be able to do this without
  13. conflict.
  14. The model is this: There are a set of apis for sending messages
  15. from one CM module to another CM. All messages are sent either to
  16. existing cluster members or to a node attempting to join the
  17. cluster. A message being sent is directed to one or more nodes,
  18. and its characteristics are defined (reliable, unreliable, etc).
  19. This module is entirely responsible for finding out the best way to
  20. get the message to the target node(s). It chooses the transport; it
  21. chooses the protocol; it chooses which of the n possible paths to
  22. use. No module outside this one cares about such details.
  23. On the receiving side, messages must be delivered to the
  24. appropriate CM module. For this, each message is tagged with a
  25. type. There is one type per independent module of the CM (to a
  26. total of a few, say less than 10). Types are statically assigned by
  27. values in this header file. When a message of type t arrives in a
  28. destination CM process, a function (msgproc) associated with that
  29. type t is called. Calls to msgprocs are single-threaded (by the CM
  30. caller). After calling a msgproc, this module no longer cares
  31. about the details of the message. Messages of one type must be
  32. delivered promptly, without interference from messages of different
  33. types; this probably requires there to be a thread per message
  34. type. The characteristics of the msgproc (whether it can block,
  35. take a long time, etc) are not defined; if a msgproc takes too
  36. long, then the effect will be that other messages destined for it
  37. will be deferred; if it is important to avoid this, msgprocs can
  38. pass work off to further threads.
  39. /* ------------ */
  40. /* NOTE: only the important semantics of the messaging api are shown
  41. below. This module also needs open/close, handles, error
  42. returns and so on. */
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif /* __cplusplus */
  46. #include <windows.h>
  47. #if defined (TDM_DEBUG)
  48. #include <jrgpos.h>
  49. #endif // TDM_DEBUG
  50. /*------------------------- */
  51. /* the set of messages understood by this module */
  52. typedef enum {
  53. MM_MSGTYPE = 1, /* for Membership Mgr */
  54. /* others to be added */
  55. } CLMSGTYPE;
  56. #define CLMSGMAXBUFFERLENGTH 1024 /* random number; no reason */
  57. /* the biggest buffer which can be sent/received by the CM */
  58. typedef DWORD (*CLMSGPROC) (LPCSTR buffer, DWORD length);
  59. void ClProcRegister (CLMSGTYPE msgtype, CLMSGPROC msgproc);
  60. /* registers that function <msgproc> should be called whenever an
  61. incoming message of type <msgtype> is seen. The type field is always
  62. the first DWORD of the incoming buffer. The length passed to
  63. <ptype> is the length received. The worst-case length of all users
  64. of this api is known, so there are never cases where the
  65. receive-buffer isn't big enough.
  66. This must be called by all CM modules in all nodes on CM startup.
  67. The msgproc should be called immediately an incoming msg arrives;
  68. such msgs should not be delayed by an long blocking events in the
  69. thread which delivers these messages. (This may imply that clMsg
  70. have a special thread dedicated to handling incoming msgs).
  71. Every msgproc will return quickly to its caller.
  72. Errors: none possible.
  73. */
  74. DWORD ClMsgSendUnack(DWORD targetnode,
  75. LPCSTR buffer,
  76. DWORD length);
  77. /*
  78. Sends an unacknowledged packet to a destination up node. This is
  79. used mostly for heartbeats.
  80. The target node may not be Up at the time.
  81. The paths to that node are unknown to MM. (For safety, all paths
  82. should be used periodically). The packet should arrive with low
  83. latency (bypassing other traffic, if required; going at high
  84. priority if possible), and with a high probability of delivery.
  85. Although the message can be lost, the contents must be correct.
  86. This function should never fail unless zero connectivity exists.
  87. This function should return asap; it is preferred that the
  88. buffer simply be queued to some driver for later delivery.
  89. [It must be the case that, when this routine is used for
  90. heartbeats, it is possible to deliver a packet to all other
  91. nodes within the <polltime> established in the MM. This places
  92. constraints on this module to work fast, and/or on the minimum
  93. polltime value... tbd]
  94. It is undefined whether this function should always send all
  95. packets on all available paths, cycle through all available paths,
  96. or send on some preferred path till a failure occurs, or whether
  97. the choice of the above should be user-configurable. [Note that the
  98. decision eventually affects the user settings of polltime].
  99. [<length> is typically short and can be restricted to be so (eg,
  100. 256 bytes) is necessary].
  101. Errors:
  102. xxx No path to designated node.
  103. xxx Success; message was queued for delivery.
  104. */
  105. DWORD ClSend (DWORD targetnode,
  106. LPCSTR buffer,
  107. DWORD length,
  108. DWORD timeout);
  109. /* This sends the given message to the designated node, eg to download
  110. configuration data to it. The message should be reliable. The
  111. function should block until the msg is delivered to the target CM.
  112. The target node may not be Up at the time.
  113. The function must fail if the target node becomes unreachable
  114. or is declared down during the operation.
  115. The function should fail if the message cannot be delivered to the
  116. target CM within <timeout> ms.
  117. Errors:
  118. xxx No path to node; node went down.
  119. xxx Timeout
  120. */
  121. /* ------------------------------------------------------ */
  122. DWORD ClMsgInit (DWORD mynode);
  123. /* Input - my node number
  124. Errors :
  125. WSAsocket errors.
  126. */
  127. #if defined (TDM_DEBUG)
  128. /* The following templates are for simulation purposes and temporary */
  129. DWORD ClMsgGet (LPCSTR buffer,
  130. DWORD maxlen,
  131. LPDWORD actuallen);
  132. /* Input - pointer to buffer data.
  133. buffer length in bytes.
  134. pointer to actual buffer length in bytes.
  135. Modifies - buffer data
  136. actual byte length
  137. Errors :
  138. WSAsocket errors.
  139. */
  140. DWORD ClWriteRead(
  141. IN DWORD targetnode, // node to send to
  142. IN OUT LPCSTR buffer, // buffer to send and to receive in
  143. IN DWORD writelen, // number of bytes to write
  144. IN DWORD readlen, // number of bytes to read
  145. OUT LPDWORD actuallen, // number of bytes actually read
  146. IN DWORD timeout // timeout value in milliseconds
  147. );
  148. DWORD ClReadUpdate(
  149. IN LPCSTR buffer, // buffer to receive data into
  150. IN DWORD readlen, // number of bytes to read
  151. OUT LPDWORD actuallen // number of bytes actually read
  152. );
  153. DWORD ClReply(
  154. IN LPCSTR buffer, // buffer to send
  155. IN DWORD writelen // number of bytes to send
  156. );
  157. //
  158. // This structure is used for request reply messages so that we know
  159. // who sent the message.
  160. //
  161. #define MAX_REQUEST_REPLY_SIZE 256
  162. typedef struct _request_reply_message
  163. {
  164. DWORD sending_node;
  165. DWORD sending_IPaddr; // only used for CLI (sending_node is -1)
  166. CHAR message[MAX_REQUEST_REPLY_SIZE];
  167. DWORD messagelen;
  168. } REQUEST_REPLY_MESSAGE, *PREQUEST_REPLY_MESSAGE;
  169. typedef struct _reply_message_header
  170. {
  171. DWORD status;
  172. cluster_t UpMask;
  173. } REPLY_MESSAGE_HEADER, *PREPLY_MESSAGE_HEADER;
  174. typedef struct _reply_message
  175. {
  176. REPLY_MESSAGE_HEADER reply_hdr;
  177. DWORD reply_data_len;
  178. CHAR reply_data[];
  179. } REPLY_MESSAGE, *PREPLY_MESSAGE;
  180. #else //TDM_DEBUG
  181. DWORD
  182. ClMsgCreateRpcBinding(
  183. IN PNM_NODE Node,
  184. OUT RPC_BINDING_HANDLE * BindingHandle,
  185. IN DWORD RpcBindingOptions
  186. );
  187. DWORD
  188. ClMsgVerifyRpcBinding(
  189. IN RPC_BINDING_HANDLE BindingHandle
  190. );
  191. VOID
  192. ClMsgDeleteRpcBinding(
  193. IN RPC_BINDING_HANDLE BindingHandle
  194. );
  195. DWORD
  196. ClMsgCreateDefaultRpcBinding(
  197. IN PNM_NODE Node,
  198. OUT PDWORD Generation
  199. );
  200. VOID
  201. ClMsgDeleteDefaultRpcBinding(
  202. IN PNM_NODE Node,
  203. IN DWORD Generation
  204. );
  205. DWORD
  206. ClMsgCreateActiveNodeSecurityContext(
  207. IN DWORD JoinSequence,
  208. IN PNM_NODE Node
  209. );
  210. DWORD
  211. ClMsgInit(
  212. IN DWORD MyNode
  213. );
  214. VOID
  215. ClMsgCleanup(
  216. VOID
  217. );
  218. VOID
  219. ClMsgBanishNode(
  220. IN CL_NODE_ID NodeId
  221. );
  222. extern RPC_BINDING_HANDLE * Session;
  223. #endif //TDM_DEBUG
  224. #ifdef __cplusplus
  225. }
  226. #endif /* __cplusplus */
  227. /* ------------------------ end ------------------------- */
  228. #endif /* _CLMSG_H_ */