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.

316 lines
11 KiB

  1. /****************************************************************************/
  2. // cc.h
  3. //
  4. // Call controller class defs.
  5. //
  6. // Copyright (C) 1997-2000 Microsoft Corporation
  7. /****************************************************************************/
  8. #ifndef _H_CC
  9. #define _H_CC
  10. extern "C" {
  11. //#include <acmapi.h>
  12. //#include <afsapi.h>
  13. //#include <auhapi.h>
  14. #include <adcgdata.h>
  15. #include <adcgfsm.h>
  16. }
  17. #include "cd.h"
  18. #include "uh.h"
  19. #include "cm.h"
  20. #include "fs.h"
  21. class CUI;
  22. class CSL;
  23. class CUH;
  24. class CCD;
  25. class CIH;
  26. class COR;
  27. class CFS;
  28. class CCM;
  29. class CChan;
  30. /****************************************************************************/
  31. /* FSM events (different numbers as the internal events) */
  32. /****************************************************************************/
  33. #define CC_EVT_API_ONCONNECTOK 101
  34. #define CC_EVT_API_ONBUFFERAVAILABLE 104
  35. #define CC_EVT_API_ONDEACTIVATEALL 105
  36. #define CC_EVT_API_DISCONNECT 106
  37. #define CC_EVT_API_ONSHUTDOWNDENIED 107
  38. #define CC_EVT_API_DISCONNECTANDEXIT 108
  39. #define CC_EVT_API_SHUTDOWN 109
  40. /****************************************************************************/
  41. /* Structure: CC_COMBINED_CAPABILITIES */
  42. /* */
  43. /* Description: Capabilities sent from client to server. */
  44. /****************************************************************************/
  45. typedef struct tagCC_COMBINED_CAPABILITIES
  46. {
  47. UINT16 numberCapabilities;
  48. #ifdef DRAW_GDIPLUS
  49. #ifdef DRAW_NINEGRID
  50. #define CC_COMBINED_CAPS_NUMBER_CAPABILITIES 18
  51. #else // DRAW_NINEGRID
  52. #define CC_COMBINED_CAPS_NUMBER_CAPABILITIES 17
  53. #endif // DRAW_NINEGRID
  54. #else // DRAW_GDIPLUS
  55. #ifdef DRAW_NINEGRID
  56. #define CC_COMBINED_CAPS_NUMBER_CAPABILITIES 17
  57. #else
  58. #define CC_COMBINED_CAPS_NUMBER_CAPABILITIES 16
  59. #endif // DRAW_NINEGRID
  60. #endif // DRAW_GDIPLUS
  61. UINT16 pad2octets;
  62. TS_GENERAL_CAPABILITYSET generalCapabilitySet;
  63. TS_BITMAP_CAPABILITYSET bitmapCapabilitySet;
  64. TS_ORDER_CAPABILITYSET orderCapabilitySet;
  65. TS_BITMAPCACHE_CAPABILITYSET bitmapCacheCaps;
  66. TS_COLORTABLECACHE_CAPABILITYSET colorTableCacheCapabilitySet;
  67. TS_WINDOWACTIVATION_CAPABILITYSET windowActivationCapabilitySet;
  68. TS_CONTROL_CAPABILITYSET controlCapabilitySet;
  69. TS_POINTER_CAPABILITYSET pointerCapabilitySet;
  70. TS_SHARE_CAPABILITYSET shareCapabilitySet;
  71. TS_INPUT_CAPABILITYSET inputCapabilitySet;
  72. TS_SOUND_CAPABILITYSET soundCapabilitySet;
  73. TS_FONT_CAPABILITYSET fontCapabilitySet;
  74. TS_GLYPHCACHE_CAPABILITYSET glyphCacheCapabilitySet;
  75. TS_BRUSH_CAPABILITYSET brushCapabilitySet;
  76. TS_OFFSCREEN_CAPABILITYSET offscreenCapabilitySet;
  77. TS_VIRTUALCHANNEL_CAPABILITYSET virtualchannelCapabilitySet;
  78. #ifdef DRAW_NINEGRID
  79. TS_DRAW_NINEGRID_CAPABILITYSET drawNineGridCapabilitySet;
  80. #endif
  81. #ifdef DRAW_GDIPLUS
  82. TS_DRAW_GDIPLUS_CAPABILITYSET drawGdiplusCapabilitySet;
  83. #endif
  84. } CC_COMBINED_CAPABILITIES, DCPTR PCC_COMBINED_CAPABILITIES;
  85. /****************************************************************************/
  86. /* FSM definitions */
  87. /****************************************************************************/
  88. #define CC_FSM_INPUTS 11
  89. #define CC_FSM_STATES 11
  90. /****************************************************************************/
  91. /* FSM states */
  92. /****************************************************************************/
  93. #define CC_DISCONNECTED 0
  94. #define CC_CONNECTPENDING 1
  95. #define CC_WAITINGFORDEMANDACTIVE 2
  96. #define CC_SENDINGCONFIRMACTIVE1 3
  97. #define CC_SENDINGSYNC1 4
  98. #define CC_SENDINGCOOPCONTROL 5
  99. #define CC_SENDINGGRANTCONTROL CC_SENDINGCOOPCONTROL + 1
  100. #define CC_CONNECTED CC_SENDINGCOOPCONTROL + 2
  101. #define CC_SENDING_SHUTDOWNPDU CC_SENDINGCOOPCONTROL + 3
  102. #define CC_SENT_SHUTDOWNPDU CC_SENDINGCOOPCONTROL + 4
  103. #define CC_PENDING_SHUTDOWN CC_SENDINGCOOPCONTROL + 5
  104. #ifdef DC_DEBUG
  105. static TCHAR FAR *stateString[CC_FSM_STATES] =
  106. {
  107. _T("CC_DISCONNECTED"),
  108. _T("CC_CONNECTPENDING"),
  109. _T("CC_WAITINGFORDEMANDACTIVE"),
  110. _T("CC_SENDINGCONFIRMACTIVE1"),
  111. _T("CC_SENDINGSYNC1"),
  112. _T("CC_SENDINGCOOPCONTROL"),
  113. _T("CC_SENDINGGRANTCONTROL"),
  114. _T("CC_CONNECTED"),
  115. _T("CC_SENDING_SHUTDOWPDU"),
  116. _T("CC_SENT_SHUTDOWNPDU"),
  117. _T("CC_PENDING_SHUTDOWN")
  118. };
  119. #endif /* DEBUG */
  120. /****************************************************************************/
  121. /* FSM events */
  122. /****************************************************************************/
  123. #define CC_EVT_STARTCONNECT 0
  124. #define CC_EVT_ONCONNECTOK 1
  125. #define CC_EVT_ONDEMANDACTIVE 2
  126. #define CC_EVT_SENTOK 3
  127. #define CC_EVT_ONBUFFERAVAILABLE 4
  128. #define CC_EVT_ONDEACTIVATEALL 5
  129. #define CC_EVT_DISCONNECT 6
  130. #define CC_EVT_ONDISCONNECTED 7
  131. #define CC_EVT_SHUTDOWN 8
  132. #define CC_EVT_ONSHUTDOWNDENIED 9
  133. #define CC_EVT_DISCONNECT_AND_EXIT 10
  134. #ifdef DC_DEBUG
  135. static TCHAR FAR *eventString[CC_FSM_INPUTS] =
  136. {
  137. _T("CC_EVT_STARTCONNECT"),
  138. _T("CC_EVT_ONCONNECTOK"),
  139. _T("CC_EVT_ONDEMANDACTIVE"),
  140. _T("CC_EVT_SENTOK"),
  141. _T("CC_EVT_ONBUFFERAVAILABLE"),
  142. _T("CC_EVT_ONDEACTIVATEALL"),
  143. _T("CC_EVT_DISCONNECT"),
  144. _T("CC_EVT_ONDISCONNECTED"),
  145. _T("CC_EVT_SHUTDOWN"),
  146. _T("CC_EVT_ONSHUTDOWNDENIED"),
  147. _T("CC_EVT_DISCONNECT_AND_EXIT")
  148. };
  149. #endif /* DEBUG */
  150. typedef struct tagCC_GLOBAL_DATA
  151. {
  152. TS_SHARECONTROLHEADER shareControlHeader;
  153. TS_SHAREDATAHEADER shareDataHeader;
  154. unsigned fsmState;
  155. unsigned packetLen;
  156. PBYTE pBuffer;
  157. //
  158. // Flag indicating we've already set the safe checksum settings
  159. // for this link.
  160. //
  161. BOOL fSafeChecksumSettingsSet;
  162. } CC_GLOBAL_DATA;
  163. class CCC
  164. {
  165. public:
  166. CCC(CObjs* objs);
  167. ~CCC();
  168. //
  169. // API functions
  170. //
  171. void DCAPI CC_Init();
  172. void DCAPI CC_Term();
  173. void DCAPI CC_Event(ULONG_PTR);
  174. void DCAPI CC_Connect(PVOID, unsigned);
  175. EXPOSE_CD_NOTIFICATION_FN(CCC, CC_Connect);
  176. EXPOSE_CD_SIMPLE_NOTIFICATION_FN(CCC, CC_Event);
  177. void DCAPI CC_OnDisconnected(ULONG_PTR);
  178. EXPOSE_CD_SIMPLE_NOTIFICATION_FN(CCC, CC_OnDisconnected)
  179. void DCAPI CC_OnDemandActivePDU(PVOID, unsigned);
  180. EXPOSE_CD_NOTIFICATION_FN(CCC, CC_OnDemandActivePDU)
  181. //
  182. // Data members
  183. //
  184. public:
  185. /****************************************************************************/
  186. /* CC_BUFSIZE is big enough for the largest packet sent by CC - which is a */
  187. /* ConfirmActivePDU with Combined Caps and the largest legal */
  188. /* SourceDescriptor. */
  189. /****************************************************************************/
  190. #define CC_BUFSIZE \
  191. (TS_CA_NON_DATA_SIZE + TS_MAX_SOURCEDESCRIPTOR + \
  192. sizeof(CC_COMBINED_CAPABILITIES))
  193. /****************************************************************************/
  194. /* Call Controller global data */
  195. /****************************************************************************/
  196. /****************************************************************************/
  197. /* Structure: CC_GLOBAL_DATA */
  198. /* */
  199. /* Description: Data global in the Call Controller */
  200. /****************************************************************************/
  201. CC_GLOBAL_DATA _CC;
  202. CC_COMBINED_CAPABILITIES _ccCombinedCapabilities;
  203. //
  204. // FSM
  205. //
  206. //
  207. // Internal methods
  208. //
  209. private:
  210. /****************************************************************************/
  211. /* Name for use as terminal descriptor */
  212. /****************************************************************************/
  213. #define CC_DUCATI_NAME "MSTSC"
  214. /****************************************************************************/
  215. /* SL types */
  216. /****************************************************************************/
  217. #define CC_SEND_FLAGS_CONFIRM (RNS_SEC_RESET_SEQNO | \
  218. RNS_SEC_IGNORE_SEQNO | \
  219. RNS_SEC_ENCRYPT)
  220. #define CC_SEND_FLAGS_DATA (RNS_SEC_ENCRYPT)
  221. #define CC_SEND_FLAGS_OTHER (RNS_SEC_ENCRYPT | RNS_SEC_IGNORE_SEQNO)
  222. /****************************************************************************/
  223. /* Call Controller internal function prototypes */
  224. /****************************************************************************/
  225. void DCINTERNAL CCFSMProc(unsigned, ULONG_PTR, DCUINT dataLen);
  226. void DCINTERNAL CCBuildConfirmActivePDU();
  227. void DCINTERNAL CCBuildSyncPDU();
  228. void DCINTERNAL CCBuildCoopControlPDU();
  229. void DCINTERNAL CCSendPDU(unsigned, unsigned, unsigned, unsigned);
  230. void DCINTERNAL CCBuildShutdownReqPDU();
  231. void DCINTERNAL CCBuildRequestControlPDU();
  232. void DCINTERNAL CCBuildShareHeaders();
  233. HRESULT DCINTERNAL CCShareStart(PTS_DEMAND_ACTIVE_PDU, DCUINT dataLen,
  234. PBOOL pfChecksumEncryptedData);
  235. void DCINTERNAL CCShareEnd();
  236. void DCINTERNAL CCEnableShareSendCmpnts();
  237. void DCINTERNAL CCDisableShareSendCmpnts();
  238. void DCINTERNAL CCEnableShareRecvCmpnts();
  239. void DCINTERNAL CCDisableShareRecvCmpnts();
  240. void DCINTERNAL CCDisconnectShareRecvCmpnts();
  241. #define CC_TYPE_CONFIRMACTIVE 1
  242. #define CC_TYPE_SYNCHRONIZE 2
  243. #define CC_TYPE_COOPCONTROL 3
  244. #define CC_TYPE_REQUESTCONTROL 4
  245. #define CC_TYPE_SHUTDOWNREQ 5
  246. private:
  247. CUT* _pUt;
  248. CUI* _pUi;
  249. CSL* _pSl;
  250. CUH* _pUh;
  251. CCD* _pCd;
  252. CIH* _pIh;
  253. COR* _pOr;
  254. CFS* _pFs;
  255. CCM* _pCm;
  256. CChan* _pCChan;
  257. private:
  258. CObjs* _pClientObjects;
  259. };
  260. #endif // _H_CC