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.

248 lines
9.5 KiB

  1. /*
  2. * File: ctrlh323.h
  3. *
  4. * H.323/H.245 implementation of IControlChannel.
  5. *
  6. * Revision History:
  7. *
  8. * 05/03/96 mikev created
  9. */
  10. #ifndef _CTRLH323_H
  11. #define _CTRLH323_H
  12. //
  13. // Build with BETA_2_ASN_PRESENT defined to detect a peer that is using
  14. // downlevel ASN.1. It has been discovered that some PDUs encoded with the
  15. // old encoder (OSS version 4.2.1 beta) cause the new decoder (OSS 4.2.2) to
  16. // crash. The only known products to beware of are:
  17. // Microsoft NetMeeting Version 2, (beta 2 and beta 3.) These do not set
  18. // either version field.
  19. // Intel Internet Video Phone Beta 1 (expires 4/19/97)
  20. //
  21. // The only PDUs known (so far) to crash are the acks for "MiscellaneousCommand"
  22. // and "MiscelaneousIndication". We avoid the acks by not sending the Command or
  23. // Indication.
  24. #define BETA_2_ASN_PRESENT
  25. #ifdef BETA_2_ASN_PRESENT
  26. // Intel products: (country code: 0xb5, manufacturer code: 0x8080)
  27. // Intel Internet Video Phone Beta 1 (expires 4/19/97): product number: "Intel
  28. // Internet Video Phone"; version number: "1.0"
  29. #define INTEL_H_221_MFG_CODE 0x8080
  30. #endif
  31. //
  32. // control channel flags
  33. //
  34. typedef ULONG CCHFLAGS;
  35. #define CTRLF_OPEN 0x10000000 // control channel is open
  36. #define CTRLF_ORIGINATING 0x00000001 // call originated at this end
  37. #define IsCtlChanOpen(f) (f & CTRLF_OPEN)
  38. #define IsOriginating(f) (f & CTRLF_ORIGINATING)
  39. #define CTRLF_INIT_ORIGINATING CTRLF_ORIGINATING
  40. #define CTRLF_INIT_NOT_ORIGINATING 0
  41. #define CTRLF_INIT_ACCEPT CTRLF_OPEN
  42. #define CTRLF_RESET 0
  43. //
  44. // Extensible Nonstandard data structure
  45. //
  46. typedef enum
  47. {
  48. NSTD_ID_ONLY = 0, // placeholder so that H.221 stuff like Mfr.Id
  49. // can be exchanged without sacrificing extensibility later
  50. NSTD_VENDORINFO, // wrapped CC_VENDORINFO, redundant.
  51. NSTD_APPLICATION_DATA // array of bytes passed from application layer to
  52. // application layer
  53. } NSTD_DATA_TYPE;
  54. typedef struct
  55. {
  56. #define APPLICATION_DATA_DEFAULT_SIZE 4
  57. DWORD dwDataSize;
  58. BYTE data[APPLICATION_DATA_DEFAULT_SIZE]; // variable sized
  59. }APPLICATION_DATA;
  60. typedef struct {
  61. NSTD_DATA_TYPE data_type;
  62. DWORD dw_nonstd_data_size;
  63. union {
  64. CC_VENDORINFO VendorInfo;
  65. APPLICATION_DATA AppData;
  66. }nonstd_data;
  67. }MSFT_NONSTANDARD_DATA, *PMSFT_NONSTANDARD_DATA;
  68. class CH323Ctrl : public IControlChannel
  69. {
  70. protected:
  71. OBJ_CPT; // profiling timer
  72. #ifdef BETA_2_ASN_PRESENT
  73. BOOL m_fAvoidCrashingPDUs;
  74. #endif
  75. //
  76. // Handles and data specific to CALLCONT.DLL apis (H245 call control DLL)
  77. //
  78. CC_HLISTEN m_hListen;
  79. CC_HCONFERENCE m_hConference;
  80. CC_CONFERENCEID m_ConferenceID;
  81. CC_HCALL m_hCall;
  82. PCC_ALIASNAMES m_pRemoteAliases;
  83. PCC_ALIASITEM m_pRemoteAliasItem;
  84. LPWSTR pwszPeerAliasName; // unicode peer ID - this is always used for caller ID
  85. LPWSTR pwszPeerDisplayName; // unicode peer display name - used for called party ID
  86. // in the absence of szPeerAliasName
  87. BOOL m_bMultipointController;
  88. CC_VENDORINFO m_VendorInfo;
  89. CC_VENDORINFO m_RemoteVendorInfo;
  90. CC_NONSTANDARDDATA m_NonstandardData;
  91. MSFT_NONSTANDARD_DATA m_NonstdContent; // empty for now
  92. CC_CONFERENCEATTRIBUTES m_ConferenceAttributes;
  93. CC_PARTICIPANTLIST m_ParticipantList;
  94. public:
  95. //
  96. // access methods specific to support of CALLCONT.DLL apis (H245 call control DLL)
  97. //
  98. CC_HCONFERENCE GetConfHandle() {return(m_hConference);};
  99. CC_CONFERENCEID GetConfID() {return(m_ConferenceID);};
  100. CC_CONFERENCEID *GetConfIDptr() {return(&m_ConferenceID);};
  101. CC_HLISTEN GetListenHandle() {return(m_hListen);};
  102. CC_HCALL GetHCall() {return(m_hCall);};
  103. // Callbacks and event handling functions specific to support of
  104. // CALLCONT.DLL callbacks
  105. //
  106. HRESULT ConfCallback (BYTE bIndication,
  107. HRESULT hStatus, PCC_CONFERENCE_CALLBACK_PARAMS pConferenceCallbackParams);
  108. VOID ListenCallback (HRESULT hStatus,PCC_LISTEN_CALLBACK_PARAMS pListenCallbackParams);
  109. VOID OnCallConnect(HRESULT hStatus, PCC_CONNECT_CALLBACK_PARAMS pConfParams);
  110. VOID OnCallRinging(HRESULT hStatus, PCC_RINGING_CALLBACK_PARAMS pRingingParams);
  111. VOID OnChannelRequest(HRESULT hStatus,PCC_RX_CHANNEL_REQUEST_CALLBACK_PARAMS pChannelReqParams);
  112. VOID OnChannelAcceptComplete(HRESULT hStatus, PCC_TX_CHANNEL_CLOSE_REQUEST_CALLBACK_PARAMS pChannelParams);
  113. VOID OnChannelOpen(HRESULT hStatus,PCC_TX_CHANNEL_OPEN_CALLBACK_PARAMS pChannelParams );
  114. VOID OnT120ChannelRequest(HRESULT hStatus,PCC_T120_CHANNEL_REQUEST_CALLBACK_PARAMS pT120RequestParams);
  115. VOID OnT120ChannelOpen(HRESULT hStatus, PCC_T120_CHANNEL_OPEN_CALLBACK_PARAMS pT120OpenParams);
  116. BOOL OnCallAccept(PCC_LISTEN_CALLBACK_PARAMS pListenCallbackParams);
  117. VOID OnHangup(HRESULT hStatus);
  118. VOID OnRxChannelClose(HRESULT hStatus,PCC_RX_CHANNEL_CLOSE_CALLBACK_PARAMS pChannelParams );
  119. VOID OnTxChannelClose(HRESULT hStatus,PCC_TX_CHANNEL_CLOSE_REQUEST_CALLBACK_PARAMS pChannelParams );
  120. VOID OnMiscCommand(HRESULT hStatus,
  121. PCC_H245_MISCELLANEOUS_COMMAND_CALLBACK_PARAMS pParams);
  122. VOID OnMiscIndication(HRESULT hStatus,
  123. PCC_H245_MISCELLANEOUS_INDICATION_CALLBACK_PARAMS pParams);
  124. VOID OnMute(HRESULT hStatus, PCC_MUTE_CALLBACK_PARAMS pParams);
  125. VOID OnUnMute(HRESULT hStatus, PCC_UNMUTE_CALLBACK_PARAMS pParams);
  126. // support functions
  127. HRESULT NewConference(VOID);
  128. VOID SetRemoteVendorID(PCC_VENDORINFO pVendorInfo);
  129. //
  130. // End of CALLCONT.DLL specific members
  131. //
  132. BOOL IsReleasing() {return((uRef==0)?TRUE:FALSE);}; // object is being released and should not
  133. // be reentered
  134. // this implementation has a coarse concept of call setup protocol phase because it's
  135. // using apis of CALLCONT.DLL.
  136. CtlChanStateType m_Phase; // our perception of protocol phase
  137. BOOL m_fLocalT120Cap;
  138. BOOL m_fRemoteT120Cap;
  139. public:
  140. CH323Ctrl();
  141. ~CH323Ctrl();
  142. protected:
  143. SOCKADDR_IN local_sin;
  144. SOCKADDR_IN remote_sin;
  145. int local_sin_len;
  146. int remote_sin_len;
  147. LPVOID lpvRemoteCustomFormats;
  148. virtual VOID Cleanup();
  149. BOOL ConfigureRecvChannelCapability(ICtrlCommChan *pChannel , PCC_RX_CHANNEL_REQUEST_CALLBACK_PARAMS pChannelParams);
  150. BOOL ValidateChannelParameters(PCC_TERMCAP pChanCap1, PCC_TERMCAP pChanCap2);
  151. STDMETHOD(FindDefaultRXChannel(PCC_TERMCAP pChannelCapability, ICtrlCommChan **lplpChannel));
  152. GUID m_PID;
  153. private:
  154. UINT uRef;
  155. HRESULT hrLast;
  156. CCHFLAGS m_ChanFlags;
  157. HRESULT m_hCallCompleteCode;
  158. COBLIST m_ChannelList;
  159. IConfAdvise *m_pConfAdvise;
  160. ICtrlCommChan *FindChannel(CC_HCHANNEL hChannel);
  161. VOID DoAdvise(DWORD dwEvent, LPVOID lpvData);
  162. VOID CheckChannelsReady(VOID);
  163. VOID NewRemoteUserInfo(PCC_ALIASNAMES pRemoteAliasNames, LPWSTR szRemotePeerDisplayName);
  164. VOID ConnectNotify(DWORD dwEvent);
  165. VOID GoNextPhase(CtlChanStateType phase);
  166. VOID InternalDisconnect();
  167. HRESULT AllocConferenceAttributes();
  168. VOID CleanupConferenceAttributes();
  169. VOID ReleaseAllChannels();
  170. public:
  171. STDMETHOD_(ULONG, AddRef());
  172. STDMETHOD_(ULONG, Release());
  173. STDMETHOD( Init(IConfAdvise *pConfAdvise));
  174. STDMETHOD( DeInit(IConfAdvise *pConfAdvise));
  175. VOID SetRemoteAddress(PSOCKADDR_IN psin) {remote_sin = *psin;};
  176. VOID SetLocalAddress(PSOCKADDR_IN psin) {local_sin = *psin;};
  177. // so we know what address we accepted on
  178. STDMETHOD( GetLocalAddress(PSOCKADDR_IN *lplpAddr));
  179. // so we know the address of the caller
  180. STDMETHOD( GetRemoteAddress(PSOCKADDR_IN *lplpAddr));
  181. STDMETHOD( GetRemotePort(PORT * lpPort));
  182. STDMETHOD( GetLocalPort(PORT * lpPort));
  183. STDMETHOD(PlaceCall (BOOL bUseGKResolution, PSOCKADDR_IN pCallAddr,
  184. P_H323ALIASLIST pDestinationAliases, P_H323ALIASLIST pExtraAliases,
  185. LPCWSTR pCalledPartyNumber, P_APP_CALL_SETUP_DATA pAppData));
  186. STDMETHOD_(VOID, Disconnect(DWORD dwReason));
  187. STDMETHOD( ListenOn(PORT Port));
  188. STDMETHOD( StopListen(VOID));
  189. STDMETHOD( AsyncAcceptRejectCall(CREQ_RESPONSETYPE Response));
  190. // accept from the listening connection. The ideal is that the accepting
  191. // object would QueryInterface for a private interface, then grab all the
  192. // pertinent connection info through that interface. Temporarily expose this
  193. // using the IControlChannel interface. The call control state will vary greatly
  194. // between implementations. For some implementations, this may perform
  195. // a socket accept before user information has been exchanged. User information will
  196. // be read into the accepting object directly. For other implementations, the
  197. // socket accept is decoupled and has already been performed, and user information
  198. // has already been read into the listening object. In that case, this method
  199. // copies the user info and advises the parent "Conference" object of the
  200. // incoming call
  201. STDMETHOD( AcceptConnection(LPIControlChannel pIListenCtrlChan, LPVOID lpvListenCallbackParams));
  202. STDMETHOD_(BOOL, IsAcceptingConference(LPVOID lpvConfID));
  203. STDMETHOD( GetProtocolID(LPGUID lpPID));
  204. STDMETHOD_(IH323Endpoint *, GetIConnIF());
  205. STDMETHOD( MiscChannelCommand(ICtrlCommChan *pChannel,VOID * pCmd));
  206. STDMETHOD( MiscChannelIndication(ICtrlCommChan *pChannel,VOID * pCmd));
  207. STDMETHOD( OpenChannel(ICtrlCommChan * pCommChannel, IH323PubCap *pCapResolver,
  208. MEDIA_FORMAT_ID dwIDLocalSend, MEDIA_FORMAT_ID dwIDRemoteRecv));
  209. STDMETHOD (CloseChannel(ICtrlCommChan* pCommChannel));
  210. STDMETHOD (AddChannel(ICtrlCommChan * pCommChannel, LPIH323PubCap pCapabilityResolver));
  211. STDMETHOD(GetVersionInfo(
  212. PCC_VENDORINFO *ppLocalVendorInfo, PCC_VENDORINFO *ppRemoteVendorInfo));
  213. };
  214. #endif //#ifndef _CTRLH323_H