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.

379 lines
12 KiB

  1. #ifndef __MBFT_HPP__
  2. #define __MBFT_HPP__
  3. #include "osshelp.hpp"
  4. #include "messages.hpp"
  5. #include <it120app.h>
  6. // LONCHANC: temporarily enable conductorship
  7. // #define ENABLE_CONDUCTORSHIP 1
  8. //Intel specific non-collapsing capabilities values....
  9. enum NonCollapsCaps
  10. {
  11. _iMBFT_FIRST_PROSHARE_CAPABILITY_ID = 0x100,
  12. _iMBFT_PROSHARE_VERSION_ID____NOT_USED,
  13. _iMBFT_PROSHARE_FILE_EOF_ACK_ID,
  14. _iMBFT_LAST_NON_COLLAPSING_CAPABILITIES
  15. };
  16. //Intel specific collapsing capabilities values....
  17. //Note: The size of _iMBFT_MAX_FILEDATA_PDU_LENGTH actually controls the maximum number
  18. //of bytes in the file start and data PDUs. If this is increased, the corresponding constant
  19. //in MCSHELP.HPP (_MAX_MCS_MESSAGE_SIZE) must also be increased...
  20. const USHORT _iMBFT_MAX_FILEDATA_PDU_LENGTH = 25000;
  21. const USHORT _iMBFT_DEFAULT_MAX_FILEDATA_PDU_LENGTH = 8192;
  22. const ULONG _iMBFT_MAX_FILE_SIZE = 0xFFFFFFFFUL;
  23. const USHORT _iMBFT_V42_NO_OF_CODEWORDS = 512;
  24. const USHORT _iMBFT_V42_MAX_STRING_LENGTH = 6;
  25. const USHORT _iMBFT_V42_COMPRESSION_SUPPORTED = TRUE;
  26. const USHORT _iMBFT_MAX_COLLAPSING_CAPABILITIES = 3;
  27. #define _iMBFT_MAX_NON_COLLAPSING_CAPABILITIES _iMBFT_LAST_NON_COLLAPSING_CAPABILITIES - _iMBFT_FIRST_PROSHARE_CAPABILITY_ID
  28. //Added by Atul -- another magic number that we subtract from MCSMaxDomainPDU size
  29. //presumably to allow for the overhead added by the lower layers...
  30. const USHORT _iMBFT_FILEDATA_PDU_SUBTRACT = 64;
  31. //In our implementation we get the max pdu by a proprietary MCS api called
  32. //GetDomainParameters. No such liberties with MSFT stuff!!
  33. const unsigned int _iMBFT_DEFAULT_MAX_MCS_SIZE = MAX_MCS_DATA_SIZE;
  34. //Standard MBFT identifiers and channel IDs
  35. const USHORT _MBFT_MAX_FILE_SIZE_ID = 1;
  36. const USHORT _MBFT_MAX_DATA_PAYLOAD_ID = 2;
  37. const USHORT _MBFT_V42_COMPRESSION_ID = 3;
  38. const USHORT _MBFT_V42_NO_OF_CODEWORDS_ID = 4;
  39. const USHORT _MBFT_V42_MAX_STRING_LENGTH_ID = 5;
  40. MBFTEVENTHANDLE GetNewEventHandle(void);
  41. MBFTFILEHANDLE GetNewFileHandle(void);
  42. enum MBFTState
  43. {
  44. IdleNotInitialized,
  45. IdleInitialized
  46. };
  47. class MBFTInterface;
  48. class MBFTMsg;
  49. class MBFTPDUMsg;
  50. class CAppletWindow;
  51. class MBFTSession;
  52. class CSessionList : public CList
  53. {
  54. DEFINE_CLIST(CSessionList, MBFTSession *)
  55. void Delete(MBFTSession *);
  56. };
  57. class CPeerData;
  58. class CPeerList : public CList
  59. {
  60. DEFINE_CLIST(CPeerList, CPeerData *)
  61. CPeerData *Find(T120UserID uidPeer);
  62. BOOL IsValidPeerID(T120UserID uidPeer) { return (NULL != Find(uidPeer)); }
  63. CPeerData * CPeerList::FindSamePeer(CPeerData *pPeer);
  64. void CPeerList::Delete(CPeerData *p);
  65. void DeleteAll(void);
  66. };
  67. //
  68. // MBFT engine, one per conference
  69. //
  70. class MBFTEngine : public CRefCount
  71. {
  72. public:
  73. MBFTEngine(MBFTInterface *, MBFT_MODE, T120SessionID);
  74. ~MBFTEngine(void);
  75. private:
  76. IT120AppletSession *m_pAppletSession;
  77. T120Error m_eLastSendDataError;
  78. MBFTInterface *m_pMBFTIntf;
  79. T120ConfID m_nConfID;
  80. MBFT_MODE m_eMBFTMode;
  81. T120SessionID m_SessionID;
  82. T120UserID m_uidMyself;
  83. T120NodeID m_nidMyself;
  84. T120EntityID m_eidMyself;
  85. T120ChannelID m_MBFTControlChannel;
  86. T120ChannelID m_MBFTDataChannel;
  87. T120ChannelID m_aStaticChannels[2];
  88. #ifdef USE_MULTICAST_SESSION
  89. T120ResourceRequest m_aJoinResourceReqs[1];
  90. #endif
  91. T120JoinSessionRequest m_JoinSessionReq;
  92. BOOL m_fConfAvailable;
  93. BOOL m_fJoinedConf;
  94. MBFTState m_State;
  95. // LONCHANC: NetMeeting's Node Controller does not exercise conductorship.
  96. #ifdef ENABLE_CONDUCTORSHIP
  97. BOOL m_bInConductedMode;
  98. T120NodeID m_ConductorNodeID;
  99. T120UserID m_MBFTConductorID;
  100. ULONG m_ConductedModePermission;
  101. BOOL m_bWaitingForPermission;
  102. #endif // ENABLE_CONDUCTORSHIP
  103. CSessionList m_SessionList;
  104. CPeerList m_PeerList;
  105. ULONG m_nRosterInstance;
  106. ULONG m_MBFTMaxFileSize;
  107. ULONG m_MBFTMaxDataPayload;
  108. ULONG m_MBFTMaxSendDataPayload;
  109. BOOL m_bV42CompressionSupported;
  110. USHORT m_v42bisP1;
  111. USHORT m_v42bisP2;
  112. MBFTEVENTHANDLE m_lEventHandle;
  113. CAppletWindow *m_pWindow;
  114. #ifdef ENABLE_HEARTBEAT_TIMER
  115. UINT_PTR m_nTimerID;
  116. #endif
  117. public:
  118. //
  119. // Handy inline methods
  120. //
  121. T120Error GetLastSendDataError(void) { return m_eLastSendDataError; }
  122. CPeerList *GetPeerList(void) { return &m_PeerList; }
  123. ULONG GetPeerCount(void) { return m_PeerList.GetCount(); }
  124. T120ConfID GetConfID(void) { return m_nConfID; }
  125. T120UserID GetUserID(void) { return m_uidMyself; }
  126. T120NodeID GetNodeID(void) { return m_nidMyself; }
  127. T120SessionID GetSessionID(void) { return m_SessionID; }
  128. T120ChannelID GetDefaultControlChannel(void) { return m_MBFTControlChannel; }
  129. T120ChannelID GetDefaultDataChannel(void) { return m_MBFTDataChannel; }
  130. BOOL Has2xNodeInConf(void);
  131. BOOL HasSDK(void);
  132. void SetConferenceAvailable(BOOL fConfAvailable) { m_fConfAvailable = fConfAvailable; }
  133. BOOL IsValidPeerID(T120UserID uidPeer) { return m_PeerList.IsValidPeerID(uidPeer); }
  134. ULONG GetRosterInstance(void) { return m_nRosterInstance; }
  135. HRESULT SafePostMessage(MBFTMsg *p);
  136. HRESULT SafePostNotifyMessage(MBFTMsg *p);
  137. void ClearInterfacePointer(void) { m_pMBFTIntf = NULL; }
  138. MBFTInterface *GetInterfacePointer(void) { return m_pMBFTIntf; }
  139. void SetInterfacePointer(MBFTInterface *pIntf);
  140. #ifdef ENABLE_HEARTBEAT_TIMER
  141. UINT_PTR GetTimerID(void) { return m_nTimerID; }
  142. #endif
  143. void SetWindow(CAppletWindow *pWindow) { m_pWindow = pWindow; }
  144. //
  145. // Conducted-mode methods
  146. //
  147. // LONCHANC: NetMeeting's Node Controller does not exercise conductorship.
  148. #ifdef ENABLE_CONDUCTORSHIP
  149. void OnConductAssignIndication(GCCConductorAssignInd *);
  150. void OnConductReleaseIndication(GCCConferenceID);
  151. void OnConductGrantIndication(GCCConductorPermitGrantInd *);
  152. void AbortAllSends(void);
  153. void ApplyForPermission(void);
  154. BOOL ConductedModeOK(void);
  155. #else
  156. BOOL ConductedModeOK(void) { return TRUE; }
  157. #endif // ENABLE_CONDUCTORSHIP
  158. //
  159. // Notification for file transfer protocol
  160. //
  161. BOOL OnReceivedPrivateChannelInvitePDU(T120ChannelID, T120Priority, T120UserID,
  162. LPPRIVATECHANNELINVITEPDU lpNewPDU,
  163. BOOL IsUniformSendData);
  164. BOOL OnReceivedFileRequestPDU(T120ChannelID, T120Priority, T120UserID,
  165. LPFILEREQUESTPDU lpNewPDU,
  166. BOOL IsUniformSendData);
  167. BOOL OnReceivedDirectoryRequestPDU(T120ChannelID, T120Priority, T120UserID,
  168. LPDIRECTORYREQUESTPDU lpNewPDU,
  169. BOOL IsUniformSendData);
  170. BOOL OnReceivedPrivilegeAssignPDU(T120ChannelID, T120Priority, T120UserID,
  171. LPPRIVILEGEASSIGNPDU lpNewPDU,
  172. BOOL IsUniformSendData);
  173. //
  174. // Common public methods
  175. //
  176. BOOL HandleSessionCreation(MBFTMsg *pMsg);
  177. BOOL DispatchPDUMessage(MBFTSession *, MBFTPDUMsg *);
  178. BOOL ProcessMessage(MBFTMsg *pMsg);
  179. BOOL DoStateMachine(MBFTMsg *pMsg);
  180. void AddAllPeers(void);
  181. BOOL NoUIMode(void) { return (m_pWindow == NULL); }
  182. private:
  183. void AddPeerNotification(T120NodeID, T120UserID, BOOL IsLocalNode, BOOL IsProshareNode, BOOL bPeerAdded, LPCSTR lpszAppKey, T120SessionID);
  184. BOOL SimpleChannelRequest(AppletChannelCommand, T120ChannelID);
  185. T120NodeID GetNodeIdByUserID(T120UserID UserID);
  186. public:
  187. //
  188. // T120 service request
  189. //
  190. BOOL MCSChannelJoinRequest(T120ChannelID nChannelID) { return SimpleChannelRequest(APPLET_JOIN_CHANNEL, nChannelID); }
  191. BOOL MCSChannelLeaveRequest(T120ChannelID nChannelID) { return SimpleChannelRequest(APPLET_LEAVE_CHANNEL, nChannelID); }
  192. BOOL MCSChannelConveneRequest(void) { return SimpleChannelRequest(APPLET_CONVENE_CHANNEL, 0); }
  193. BOOL MCSChannelDisbandRequest(T120ChannelID nChannelID) { return SimpleChannelRequest(APPLET_DISBAND_CHANNEL, nChannelID); }
  194. BOOL MCSChannelAdmitRequest(T120ChannelID, T120UserID *, ULONG cUsers);
  195. BOOL SendDataRequest(T120ChannelID, T120Priority, LPBYTE lpBuffer, ULONG ulSize);
  196. //
  197. // Notification for T.120 applet
  198. //
  199. void OnPermitToEnrollIndication(GCCAppPermissionToEnrollInd *);
  200. void OnJoinSessionConfirm(T120JoinSessionConfirm *);
  201. void OnDetachUserIndication(T120UserID, T120Reason);
  202. void OnRosterReportIndication(ULONG cRosters, GCCAppRoster **);
  203. void OnChannelAdmitIndication(T120ChannelID, T120UserID uidManager);
  204. void OnSendDataIndication(
  205. BOOL fUniformSend,
  206. T120UserID nSenderID,
  207. T120ChannelID nChannelID,
  208. T120Priority ePriority,
  209. ULONG cbBufSize,
  210. LPBYTE pBufData);
  211. };
  212. typedef MBFTEngine * LPMBFTENGINE;
  213. //
  214. // Peer data
  215. //
  216. class CPeerData
  217. {
  218. private:
  219. T120UserID m_NodeID;
  220. T120UserID m_MBFTUserID;
  221. BOOL m_bIsLocalNode;
  222. BOOL m_bIsProshareNode;
  223. BOOL m_bCanConduct;
  224. BOOL m_bEOFAcknowledgment;
  225. char m_szAppKey[MAX_APP_KEY_SIZE];
  226. DWORD m_dwVersion;
  227. public:
  228. CPeerData(UserID NodeID,UserID MBFTUserID,BOOL IsLocalNode,
  229. BOOL IsProshareNode,BOOL bCanConduct,BOOL m_bEOFAcknowledgment,
  230. LPCSTR lpszAppKey, DWORD dwVersion);
  231. ~CPeerData(void) {}
  232. T120UserID GetUserID(void) { return m_MBFTUserID; }
  233. T120NodeID GetNodeID(void) { return m_NodeID; }
  234. BOOL GetIsLocalNode(void) { return m_bIsLocalNode; }
  235. BOOL GetIsProshareNode(void) { return m_bIsProshareNode; }
  236. BOOL GetCanConduct(void) { return m_bCanConduct; }
  237. BOOL GetEOFAcknowledge(void) { return m_bEOFAcknowledgment; }
  238. LPCSTR GetAppKey(void) { return m_szAppKey; }
  239. DWORD GetVersion(void) { return m_dwVersion; }
  240. };
  241. typedef CPeerData * LPPEERDATA;
  242. //
  243. // MBFT sub session, the interface class of
  244. // MBFTPrivateSend
  245. // MBFTPrivateReceive
  246. // MBFTBroadcastReceive
  247. //
  248. class MBFTSession
  249. {
  250. public:
  251. MBFTSession::MBFTSession(MBFTEngine *pEngine, MBFTEVENTHANDLE nEventHandle, MBFT_SESSION_TYPE eType)
  252. :
  253. m_lpParentEngine(pEngine),
  254. m_EventHandle(nEventHandle),
  255. m_MBFTSessionType(eType)
  256. {
  257. }
  258. virtual ~MBFTSession(void) = 0;
  259. MBFTEVENTHANDLE GetEventHandle(void) { return m_EventHandle; }
  260. MBFT_SESSION_TYPE GetSessionType(void) { return m_MBFTSessionType; }
  261. BOOL IsSendSession(void) { return (MBFT_PRIVATE_SEND_TYPE == m_MBFTSessionType); }
  262. BOOL IsReceiveSession(void)
  263. {
  264. return (MBFT_PRIVATE_SEND_TYPE != m_MBFTSessionType);
  265. }
  266. //
  267. // T120 callback
  268. //
  269. virtual BOOL OnMCSChannelJoinConfirm(T120ChannelID, BOOL bSuccess) = 0;
  270. //
  271. // File transfer protocal callback
  272. //
  273. virtual BOOL OnReceivedFileErrorPDU(T120ChannelID, T120Priority, T120UserID,
  274. LPFILEERRORPDU lpNewPDU,
  275. BOOL IsUniformSendData) = 0;
  276. virtual void OnPeerDeletedNotification(CPeerData * lpPeerData) = 0;
  277. virtual void OnControlNotification(MBFTFILEHANDLE,
  278. FileTransferControlMsg::FileTransferControl iControlCommand,
  279. LPCSTR lpszDirectory,
  280. LPCSTR lpszFileName) = 0;
  281. virtual void DoStateMachine(void) = 0;
  282. virtual void UnInitialize(BOOL bIsShutDown) = 0;
  283. protected:
  284. LPMBFTENGINE m_lpParentEngine;
  285. MBFTEVENTHANDLE m_EventHandle;
  286. MBFT_SESSION_TYPE m_MBFTSessionType;
  287. };
  288. typedef class MBFTSession * LPMBFTSESSION;
  289. #endif //__MBFT_HPP__
  290.