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.

145 lines
3.7 KiB

  1. /* (C) 1997 Microsoft Corp.
  2. *
  3. * file : MCSMUX.h
  4. * author : Erik Mavrinac
  5. *
  6. * description: MCSMUX API types and definitions.
  7. */
  8. #include "MCS.h"
  9. #include "MCSIoctl.h"
  10. #include "Trace.h"
  11. #include "slist.h"
  12. #include "tshrutil.h"
  13. /*
  14. * Defines
  15. */
  16. // Memory alloc and copy functions.
  17. #define Malloc(size) TSHeapAlloc(HEAP_ZERO_MEMORY, size, TS_HTAG_MCSMUX_ALL)
  18. #define Free(ptr) TSHeapFree(ptr)
  19. #define MemCpy(dest, src, len) memcpy((dest), (src), (len))
  20. // Code common to all entry points except MCSInitialized(), we don't want it
  21. // around in retail builds.
  22. #if DBG
  23. #define CheckInitialized(funcname) \
  24. if (!g_bInitialized) { \
  25. ErrOut(funcname " called when MCS not initialized"); \
  26. return MCS_NOT_INITIALIZED; \
  27. }
  28. #else
  29. #define CheckInitialized(funcname)
  30. #endif
  31. // Must be as large as the largest MCS node controller indication/confirm
  32. // size sent up from PDMCS.
  33. //TODO FUTURE: Will need to change if we support SendData indications to user
  34. // mode.
  35. #define DefaultInputBufSize sizeof(ConnectProviderIndicationIoctl)
  36. /*
  37. * Types
  38. */
  39. // Forward reference.
  40. typedef struct _Domain Domain;
  41. typedef struct {
  42. Domain *pDomain;
  43. ConnectionHandle hConnKernel;
  44. } Connection;
  45. typedef enum
  46. {
  47. Dom_Unconnected, // Initial state.
  48. Dom_Connected, // Up-and-running state.
  49. Dom_PendingCPResponse, // Waiting for ConnectProvResponse.
  50. Dom_Rejected, // Rejected during ConnectProvInd.
  51. } DomainState;
  52. typedef struct _Domain
  53. {
  54. LONG RefCount;
  55. // Locks access to this struct.
  56. CRITICAL_SECTION csLock;
  57. #if MCS_Future
  58. // Selector. This is determined by MCSMUX to be unique across the system.
  59. // Not currently exported to node controller, may be in the future.
  60. unsigned SelLen;
  61. unsigned char Sel[MaxDomainSelectorLength];
  62. #endif
  63. // ICA-related bindings.
  64. HANDLE hIca;
  65. HANDLE hIcaStack;
  66. HANDLE hIcaT120Channel;
  67. void *NCUserDefined;
  68. // Domain-specific information.
  69. unsigned bDeleteDomainCalled :1;
  70. unsigned bPortDisconnected :1;
  71. DomainState State;
  72. DomainParameters DomParams;
  73. // IoPort required member.
  74. OVERLAPPED Overlapped;
  75. // TODO FUTURE: This is for a hack for single-connection system,
  76. // get rid of it by implementing Connection objects.
  77. HANDLE hConn;
  78. //TODO FUTURE: Connection objects will need to be separate allocations
  79. // for future systems with more than one connection.
  80. Connection MainConn;
  81. // Domain IOPort receive buffer.
  82. BYTE InputBuf[DefaultInputBufSize];
  83. } Domain;
  84. typedef enum {
  85. User_Attached,
  86. User_AttachConfirmPending,
  87. } UserState;
  88. typedef struct {
  89. MCSUserCallback Callback;
  90. MCSSendDataCallback SDCallback;
  91. void *UserDefined;
  92. UserState State;
  93. UserHandle hUserKernel; // Returned from kernel mode.
  94. UserID UserID; // Returned from kernel mode.
  95. Domain *pDomain;
  96. SList JoinedChannelList;
  97. unsigned MaxSendSize;
  98. } UserInformation;
  99. // Contains little info, this is used as a guard against bluescreens --
  100. // if bad hChannel is presented a user-mode fault will occur.
  101. typedef struct
  102. {
  103. ChannelHandle hChannelKernel;
  104. ChannelID ChannelID;
  105. } MCSChannel;
  106. /*
  107. * Globals
  108. */
  109. extern BOOL g_bInitialized; // Overall DLL initialization status.
  110. extern CRITICAL_SECTION g_csGlobalListLock;
  111. extern SList g_DomainList; // List of active domains.
  112. extern SList g_hUserList; // Maps hUsers to domains.
  113. extern SList g_hConnList; // Maps hConnections to domains.