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.

404 lines
12 KiB

  1. /* (C) 1997-1998 Microsoft Corp.
  2. *
  3. * file : MCSCommn.h
  4. * author : Erik Mavrinac
  5. *
  6. * description: Common definitions for MCS.
  7. */
  8. #ifndef __MCSCOMMN_H
  9. #define __MCSCOMMN_H
  10. /*
  11. * MCSError return codes from MCS entry points. These are distinct from
  12. * T.125 Result, Diagnostic, and Reason codes which are defined below.
  13. *
  14. * MCS_NO_ERROR
  15. * Success. This does not imply that the requested function is complete if
  16. * the requested service is asynchronous -- the result code in a callback
  17. * gives this information. This value should also be returned when handling
  18. * an MCS callback and the callback has been processed.
  19. *
  20. * MCS_COMMAND_NOT_SUPPORTED
  21. * The called entry point is not yet implemented.
  22. *
  23. * MCS_NOT_INITIALIZED
  24. * The application has attempted to use MCS services before MCS has been
  25. * initialized. It is necessary for the node controller (or whatever
  26. * application is serving as the node controller), to initialize MCS
  27. * before it is called upon to perform any services.
  28. *
  29. * MCS_ALREADY_INITIALIZED
  30. * The application has attempted to initialize MCS when it is already
  31. * initialized.
  32. *
  33. * MCS_DOMAIN_ALREADY_EXISTS
  34. * The application has attempted to create a domain that already exists.
  35. *
  36. * MCS_USER_NOT_ATTACHED
  37. * This indicates that the application has issued an MCSAttachUserRequest,
  38. * and then tried to use the returned handle before receiving an
  39. * MCS_ATTACH_USER_CONFIRM (which essentially validates the handle).
  40. *
  41. * MCS_NO_SUCH_USER
  42. * An unknown user handle was used during an MCS call.
  43. *
  44. * MCS_TRANSMIT_BUFFER_FULL
  45. * This indicates that the call failed due to an MCS resource shortage.
  46. * This will typically occur when there is a LOT of traffic through the
  47. * MCS layer. It simply means that MCS could not process the request at
  48. * this time. It is the responsibility of the application to retry at a
  49. * later time.
  50. *
  51. * MCS_NO_SUCH_CONNECTION
  52. * An unknown connection handle was used during an MCS call.
  53. *
  54. * MCS_NO_SUCH_DOMAIN
  55. * The DomainHandle used was not valid.
  56. *
  57. * MCS_DOMAIN_NOT_HIERARCHICAL
  58. * An attempt has been made to create an upward connection from a local
  59. * domain that already has an upward connection.
  60. *
  61. * MCS_ALLOCATION_FAILURE
  62. * The request could not be successfully invoked due to a resource
  63. * allocation failure.
  64. *
  65. * MCS_INVALID_PARAMETER
  66. * One of the parameters to an MCS call is invalid.
  67. */
  68. typedef enum
  69. {
  70. MCS_NO_ERROR,
  71. MCS_COMMAND_NOT_SUPPORTED,
  72. MCS_NOT_INITIALIZED,
  73. MCS_ALREADY_INITIALIZED,
  74. MCS_DOMAIN_ALREADY_EXISTS,
  75. MCS_NO_SUCH_DOMAIN,
  76. MCS_USER_NOT_ATTACHED,
  77. MCS_NO_SUCH_USER,
  78. MCS_NO_SUCH_CONNECTION,
  79. MCS_NO_SUCH_CHANNEL,
  80. MCS_DOMAIN_NOT_HIERARCHICAL,
  81. MCS_ALLOCATION_FAILURE,
  82. MCS_INVALID_PARAMETER,
  83. MCS_CALLBACK_NOT_PROCESSED,
  84. MCS_TOO_MANY_USERS,
  85. MCS_TOO_MANY_CHANNELS,
  86. MCS_CANT_JOIN_OTHER_USER_CHANNEL,
  87. MCS_USER_NOT_JOINED,
  88. MCS_SEND_SIZE_TOO_LARGE,
  89. MCS_SEND_SIZE_TOO_SMALL,
  90. MCS_NETWORK_ERROR,
  91. MCS_DUPLICATE_CHANNEL
  92. } MCSError;
  93. typedef MCSError *PMCSError;
  94. /*
  95. * MCS types
  96. *
  97. * DomainHandle: Identifies a unique domain.
  98. *
  99. * ConnectionHandle: Identifies a distinct connection between two nodes in
  100. * an MCS domain.
  101. *
  102. * UserHandle: Identifies a unique local user attachment.
  103. *
  104. * ChannelHandle: Identifies a unique channel that has been joined locally.
  105. * Different from a ChannelID -- a ChannelID corresponds to a T.125
  106. * ChannelID whereas a ChannelHandle is a local handle only.
  107. *
  108. * ChannelID: Identifies an MCS channel. There are four different
  109. * types of channels that are part of this type: user ID, static, private,
  110. * and assigned.
  111. *
  112. * UserID: This is a special channel that identifies a particular user in an
  113. * MCS domain. Only that user can join the channel, so this is referred
  114. * to as a single-cast channel. All other channels are multi-cast,
  115. * meaning that any number of users can join them at once.
  116. *
  117. * TokenID: A token is an MCS object that is used to resolve resource conflicts.
  118. * If an application has a particular resource or service that can only
  119. * be used by one user at a time, that user can request exclusive
  120. * ownership of a token.
  121. *
  122. * DomainParameters: The set of negotiated characteristics of an MCS domain.
  123. * These are negotiated by the first two nodes in a domain, after which
  124. * they are set for all members.
  125. *
  126. * MCSPriority: Identifiers for the four data send priorities allowed in MCS.
  127. *
  128. * Segmentation: Flag field for use during data sends, specifies how the data
  129. * are broken up between sends. SEGMENTATION_BEGIN implies that this is the
  130. * first block in a sequence; SEGMETNATION_END means this is the last block.
  131. * A singleton block would specify both flags.
  132. *
  133. * TokenStatus: States of a token. Corresponds to the TokenStatus enumeration
  134. * values defined in T.125.
  135. *
  136. * MCSReason, MCSResult: Correspond to the values defined for the Reason and
  137. * Result enumerations defined in the T.125 spec.
  138. */
  139. typedef HANDLE DomainHandle;
  140. typedef DomainHandle *PDomainHandle;
  141. typedef HANDLE ConnectionHandle;
  142. typedef ConnectionHandle *PConnectionHandle;
  143. typedef HANDLE UserHandle;
  144. typedef UserHandle *PUserHandle;
  145. typedef HANDLE ChannelHandle;
  146. typedef ChannelHandle *PChannelHandle;
  147. typedef unsigned char *DomainSelector;
  148. typedef unsigned ChannelID;
  149. typedef ChannelID *PChannelID;
  150. typedef ChannelID UserID;
  151. typedef UserID *PUserID;
  152. typedef ChannelID TokenID;
  153. typedef TokenID *PTokenID;
  154. typedef struct
  155. {
  156. unsigned MaxChannels;
  157. unsigned MaxUsers;
  158. unsigned MaxTokens;
  159. unsigned NumPriorities;
  160. unsigned MinThroughput;
  161. unsigned MaxDomainHeight;
  162. unsigned MaxPDUSize;
  163. unsigned ProtocolVersion;
  164. } DomainParameters, *PDomainParameters;
  165. typedef enum
  166. {
  167. MCS_TOP_PRIORITY = 0,
  168. MCS_HIGH_PRIORITY = 1,
  169. MCS_MEDIUM_PRIORITY = 2,
  170. MCS_LOW_PRIORITY = 3
  171. } MCSPriority;
  172. typedef MCSPriority *PMCSPriority;
  173. // Segmentation type and flags. The flag values correspond to bit locations
  174. // in PER-encoded PDUs for faster PDU creation.
  175. typedef unsigned Segmentation;
  176. typedef Segmentation *PSegmentation;
  177. #define SEGMENTATION_BEGIN 0x20
  178. #define SEGMENTATION_END 0x10
  179. // Not used in this implementation, this comes from the NetMeeting user-mode
  180. // MCS implementation.
  181. #if 0
  182. // SegmentationFlag: Alternate specification of segmentation type that defines
  183. // how the buffers that are given to SendDataRequest() are divided in packets.
  184. typedef enum {
  185. SEGMENTATION_ONE_PACKET, // All the buffers make up one packet
  186. SEGMENTATION_MANY_PACKETS, // Each buffer makes up one packet
  187. SEGMENTATION_PACKET_START, // The first buffers of one packet
  188. SEGMENTATION_PACKET_CONTINUE, // Middle buffers of a packet that was started earlier
  189. SEGMENTATION_PACKET_END // The ending buffers of a packet which started earlier
  190. } SegmentationFlag, *PSegmentationFlag;
  191. #endif
  192. typedef enum
  193. {
  194. TOKEN_NOT_IN_USE = 0,
  195. TOKEN_SELF_GRABBED = 1,
  196. TOKEN_OTHER_GRABBED = 2,
  197. TOKEN_SELF_INHIBITED = 3,
  198. TOKEN_OTHER_INHIBITED = 4,
  199. TOKEN_SELF_RECIPIENT = 5,
  200. TOKEN_SELF_GIVING = 6,
  201. TOKEN_OTHER_GIVING = 7
  202. } TokenStatus;
  203. typedef TokenStatus *PTokenStatus;
  204. typedef enum
  205. {
  206. REASON_DOMAIN_DISCONNECTED = 0,
  207. REASON_PROVIDER_INITIATED = 1,
  208. REASON_TOKEN_PURGED = 2,
  209. REASON_USER_REQUESTED = 3,
  210. REASON_CHANNEL_PURGED = 4
  211. } MCSReason, *PMCSReason;
  212. typedef enum
  213. {
  214. RESULT_SUCCESSFUL = 0,
  215. RESULT_DOMAIN_MERGING = 1,
  216. RESULT_DOMAIN_NOT_HIERARCHICAL = 2,
  217. RESULT_NO_SUCH_CHANNEL = 3,
  218. RESULT_NO_SUCH_DOMAIN = 4,
  219. RESULT_NO_SUCH_USER = 5,
  220. RESULT_NOT_ADMITTED = 6,
  221. RESULT_OTHER_USER_ID = 7,
  222. RESULT_PARAMETERS_UNACCEPTABLE = 8,
  223. RESULT_TOKEN_NOT_AVAILABLE = 9,
  224. RESULT_TOKEN_NOT_POSSESSED = 10,
  225. RESULT_TOO_MANY_CHANNELS = 11,
  226. RESULT_TOO_MANY_TOKENS = 12,
  227. RESULT_TOO_MANY_USERS = 13,
  228. RESULT_UNSPECIFIED_FAILURE = 14,
  229. RESULT_USER_REJECTED = 15
  230. } MCSResult, *PMCSResult;
  231. // The following defines the DataRequestType type that defines whether a
  232. // SendDataRequest is a normal send or a uniform send.
  233. typedef enum {
  234. NORMAL_SEND_DATA,
  235. UNIFORM_SEND_DATA,
  236. } DataRequestType, *PDataRequestType;
  237. /*
  238. * MCS callback definitions. The Params value is dependent on Message value
  239. * being received, and should be cast to the right type before use.
  240. */
  241. // MCS node controller callback.
  242. typedef void (__stdcall *MCSNodeControllerCallback) (DomainHandle hDomain,
  243. unsigned Message, void *Params, void *UserDefined);
  244. // MCS user callback.
  245. typedef void (__stdcall *MCSUserCallback) (UserHandle hUser, unsigned Message,
  246. void *Params, void *UserDefined);
  247. // MCS send-data indication callback.
  248. typedef BOOLEAN (__fastcall *MCSSendDataCallback) (BYTE *pData, unsigned DataLength,
  249. void *UserDefined, UserHandle hUser, BOOLEAN bUniform,
  250. ChannelHandle hChannel, MCSPriority Priority, UserID SenderID,
  251. Segmentation Segmentation);
  252. // Callback parameter types. Pointers to these structs are passed to the
  253. // callback in the Params value of the callback.
  254. typedef struct
  255. {
  256. ConnectionHandle hConnection;
  257. BOOLEAN bUpwardConnection;
  258. DomainParameters DomainParams;
  259. BYTE *pUserData;
  260. unsigned UserDataLength;
  261. } ConnectProviderIndication, *PConnectProviderIndication;
  262. typedef struct
  263. {
  264. DomainHandle hDomain;
  265. ConnectionHandle hConnection;
  266. DomainParameters DomainParams;
  267. MCSResult Result;
  268. BYTE *pUserData;
  269. unsigned UserDataLength;
  270. } ConnectProviderConfirm, *PConnectProviderConfirm;
  271. typedef struct
  272. {
  273. DomainHandle hDomain;
  274. ConnectionHandle hConnection;
  275. MCSReason Reason;
  276. } DisconnectProviderIndication, *PDisconnectProviderIndication;
  277. typedef struct
  278. {
  279. UserID UserID;
  280. BOOLEAN bSelf;
  281. MCSReason Reason;
  282. } DetachUserIndication, *PDetachUserIndication;
  283. typedef struct
  284. {
  285. ChannelHandle hChannel;
  286. MCSError ErrResult;
  287. } ChannelJoinConfirm, *PChannelJoinConfirm;
  288. /*
  289. * Callback values.
  290. */
  291. #define MCS_CONNECT_PROVIDER_INDICATION 0
  292. #define MCS_CONNECT_PROVIDER_CONFIRM 1
  293. #define MCS_DISCONNECT_PROVIDER_INDICATION 2
  294. #define MCS_ATTACH_USER_CONFIRM 3
  295. #define MCS_DETACH_USER_INDICATION 4
  296. #define MCS_CHANNEL_JOIN_CONFIRM 5
  297. #define MCS_CHANNEL_CONVENE_CONFIRM 6
  298. #define MCS_CHANNEL_DISBAND_INDICATION 7
  299. #define MCS_CHANNEL_ADMIT_INDICATION 8
  300. #define MCS_CHANNEL_EXPEL_INDICATION 9
  301. #define MCS_SEND_DATA_INDICATION 10
  302. #define MCS_UNIFORM_SEND_DATA_INDICATION 11
  303. #define MCS_TOKEN_GRAB_CONFIRM 12
  304. #define MCS_TOKEN_INHIBIT_CONFIRM 13
  305. #define MCS_TOKEN_GIVE_INDICATION 14
  306. #define MCS_TOKEN_GIVE_CONFIRM 15
  307. #define MCS_TOKEN_PLEASE_INDICATION 16
  308. #define MCS_TOKEN_RELEASE_CONFIRM 17
  309. #define MCS_TOKEN_TEST_CONFIRM 18
  310. #define MCS_TOKEN_RELEASE_INDICATION 19
  311. /*
  312. * API function prototypes common to user and kernel mode implementations.
  313. */
  314. #ifdef __cplusplus
  315. extern "C" {
  316. #endif
  317. #ifndef APIENTRY
  318. #define APIENTRY __stdcall
  319. #endif
  320. MCSError APIENTRY MCSAttachUserRequest(
  321. DomainHandle hDomain,
  322. MCSUserCallback UserCallback,
  323. MCSSendDataCallback SDCallback,
  324. void *UserDefined,
  325. UserHandle *phUser,
  326. unsigned *pMaxSendSize,
  327. BOOLEAN *pbCompleted);
  328. UserID APIENTRY MCSGetUserIDFromHandle(UserHandle hUser);
  329. MCSError APIENTRY MCSDetachUserRequest(
  330. UserHandle hUser);
  331. MCSError APIENTRY MCSChannelJoinRequest(
  332. UserHandle hUser,
  333. ChannelID ChannelID,
  334. ChannelHandle *phChannel,
  335. BOOLEAN *pbCompleted);
  336. ChannelID APIENTRY MCSGetChannelIDFromHandle(ChannelHandle hChannel);
  337. MCSError APIENTRY MCSChannelLeaveRequest(
  338. UserHandle hUser,
  339. ChannelHandle hChannel);
  340. #ifdef __cplusplus
  341. }
  342. #endif
  343. #endif // !defined(__MCSCOMMN_H)