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.

357 lines
7.6 KiB

  1. #ifndef _cbridge_h245_h_
  2. #define _cbridge_h245_h_
  3. // H245 states
  4. // H245_STATE_CON_LISTEN is only applicable to the source side
  5. // H245_STATE_CON_INFO is only applicable to the dest side
  6. enum H245_STATE
  7. {
  8. H245_STATE_NOT_INIT = 0,
  9. H245_STATE_INIT,
  10. H245_STATE_CON_LISTEN,
  11. H245_STATE_CON_INFO,
  12. H245_STATE_CON_ESTD
  13. };
  14. class H245_INFO :
  15. public OVERLAPPED_PROCESSOR
  16. {
  17. // we need to let the LOGICAL_CHANNEL send PDUs using the
  18. // H245 sockets and transition to shutdown mode
  19. friend HRESULT
  20. LOGICAL_CHANNEL::ProcessOpenLogicalChannelRejectPDU (
  21. IN MultimediaSystemControlMessage *pH245pdu
  22. );
  23. // XXX Is this the only way out ?
  24. friend HRESULT
  25. T120_LOGICAL_CHANNEL::HandleOpenLogicalChannelPDU(
  26. IN H245_INFO &H245Info,
  27. IN MEDIA_TYPE MediaType,
  28. IN WORD LogicalChannelNumber,
  29. IN BYTE SessionId,
  30. IN DWORD T120ConnectToIPAddr,
  31. IN WORD T120ConnectToPort,
  32. IN MultimediaSystemControlMessage *pH245pdu
  33. );
  34. friend HRESULT
  35. T120_LOGICAL_CHANNEL::ProcessOpenLogicalChannelAckPDU(
  36. IN MultimediaSystemControlMessage *pH245pdu
  37. );
  38. public:
  39. inline
  40. H245_INFO (
  41. void
  42. );
  43. inline
  44. void
  45. Init (
  46. IN H323_STATE &H323State
  47. );
  48. inline
  49. H245_INFO &GetOtherH245Info (
  50. void
  51. );
  52. inline
  53. LOGICAL_CHANNEL_ARRAY &GetLogicalChannelArray (
  54. void
  55. );
  56. HRESULT
  57. ProcessMessage (
  58. IN MultimediaSystemControlMessage * pH245pdu
  59. );
  60. HRESULT
  61. H245_INFO::SendEndSessionCommand (
  62. void
  63. );
  64. virtual
  65. ~H245_INFO (
  66. void
  67. );
  68. protected:
  69. H245_STATE m_H245State;
  70. // logical channels
  71. LOGICAL_CHANNEL_ARRAY m_LogicalChannelArray;
  72. // the other h245 addresses are needed because we need to
  73. // cancel NAT redirections in the logical channel destructor
  74. // and we can't access the other h245 instance there because
  75. // it may have been destroyed already
  76. // queue an asynchronous receive call back
  77. inline
  78. HRESULT
  79. QueueReceive (
  80. void
  81. );
  82. // queue an asynchronous send call back
  83. inline
  84. HRESULT QueueSend (
  85. IN MultimediaSystemControlMessage *pH245pdu
  86. );
  87. virtual
  88. HRESULT AcceptCallback (
  89. IN DWORD Status,
  90. IN SOCKET Socket,
  91. IN SOCKADDR_IN * LocalAddress,
  92. IN SOCKADDR_IN * RemoteAddress
  93. )
  94. {
  95. _ASSERTE(FALSE);
  96. return E_UNEXPECTED;
  97. }
  98. virtual
  99. HRESULT
  100. ReceiveCallback (
  101. IN HRESULT CallbackHResult,
  102. IN BYTE *pBuf,
  103. IN DWORD BufLen
  104. );
  105. virtual
  106. HRESULT
  107. ReceiveCallback (
  108. IN MultimediaSystemControlMessage *pH245pdu
  109. );
  110. virtual
  111. HRESULT
  112. SendCallback (
  113. IN HRESULT CallbackHResult
  114. );
  115. private:
  116. HRESULT
  117. HandleRequestMessage (
  118. IN MultimediaSystemControlMessage *pH245pdu
  119. );
  120. HRESULT ProcessResponseMessage (
  121. IN MultimediaSystemControlMessage *pH245pdu
  122. );
  123. HRESULT CheckOpenLogicalChannelPDU (
  124. IN MultimediaSystemControlMessage &H245pdu,
  125. OUT BYTE &SessionId,
  126. OUT MEDIA_TYPE &MediaType
  127. );
  128. HRESULT CheckOpenLogicalChannelPDU (
  129. IN MultimediaSystemControlMessage &H245pdu,
  130. OUT BYTE &SessionId,
  131. OUT DWORD &SourceIPv4Address,
  132. OUT WORD &SourceRTCPPort
  133. );
  134. HRESULT HandleOpenLogicalChannelPDU (
  135. IN MultimediaSystemControlMessage *pH245pdu
  136. );
  137. HRESULT HandleCloseLogicalChannelPDU (
  138. IN MultimediaSystemControlMessage *pH245pdu
  139. );
  140. HRESULT CheckOpenRtpLogicalChannelPDU (
  141. IN OpenLogicalChannel &OlcPDU,
  142. OUT SOCKADDR_IN * ReturnSourceAddress
  143. );
  144. HRESULT CheckOpenT120LogicalChannelPDU (
  145. IN OpenLogicalChannel &OlcPDU,
  146. OUT DWORD &T120ConnectToIPAddr,
  147. OUT WORD &T120ConnectToPort
  148. );
  149. HRESULT CreateRtpLogicalChannel (
  150. IN OpenLogicalChannel &OlcPDU,
  151. IN BYTE SessionId,
  152. IN MEDIA_TYPE MediaType,
  153. IN MultimediaSystemControlMessage *pH245pdu,
  154. OUT LOGICAL_CHANNEL **ppReturnLogicalChannel
  155. );
  156. HRESULT CreateT120LogicalChannel (
  157. IN OpenLogicalChannel &OlcPDU,
  158. IN BYTE SessionId,
  159. IN MEDIA_TYPE MediaType,
  160. IN MultimediaSystemControlMessage *pH245pdu,
  161. OUT LOGICAL_CHANNEL **ppReturnLogicalChannel
  162. );
  163. };
  164. inline
  165. H245_INFO::H245_INFO (
  166. )
  167. : m_H245State(H245_STATE_NOT_INIT)
  168. {
  169. }
  170. inline
  171. void
  172. H245_INFO::Init (
  173. IN H323_STATE &H323State
  174. )
  175. {
  176. // initialize the overlaped processor
  177. OVERLAPPED_PROCESSOR::Init(OPT_H245, H323State);
  178. m_LogicalChannelArray.Init();
  179. m_H245State = H245_STATE_INIT;
  180. }
  181. inline LOGICAL_CHANNEL_ARRAY &
  182. H245_INFO::GetLogicalChannelArray (
  183. void
  184. )
  185. {
  186. return m_LogicalChannelArray;
  187. }
  188. class SOURCE_H245_INFO :
  189. public H245_INFO
  190. {
  191. public:
  192. inline
  193. SOURCE_H245_INFO (
  194. void
  195. );
  196. inline
  197. void Init (
  198. IN SOURCE_H323_STATE &SourceH323State
  199. );
  200. inline
  201. SOURCE_Q931_INFO &GetSourceQ931Info (
  202. void
  203. );
  204. inline
  205. DEST_H245_INFO &GetDestH245Info (
  206. void
  207. );
  208. HRESULT
  209. ListenForCaller (
  210. IN SOCKADDR_IN * ListenAddress
  211. );
  212. protected:
  213. virtual
  214. HRESULT
  215. AcceptCallback (
  216. IN DWORD Status,
  217. IN SOCKET Socket,
  218. IN SOCKADDR_IN * LocalAddress,
  219. IN SOCKADDR_IN * RemoteAddress
  220. );
  221. };
  222. inline
  223. SOURCE_H245_INFO::SOURCE_H245_INFO (
  224. void
  225. )
  226. {
  227. }
  228. inline
  229. void
  230. SOURCE_H245_INFO::Init (
  231. IN SOURCE_H323_STATE &SourceH323State
  232. )
  233. {
  234. H245_INFO::Init((H323_STATE &)SourceH323State);
  235. }
  236. class DEST_H245_INFO :
  237. public H245_INFO
  238. {
  239. public:
  240. inline
  241. DEST_H245_INFO (
  242. void
  243. );
  244. inline
  245. void
  246. Init (
  247. IN DEST_H323_STATE &DestH323State
  248. );
  249. inline
  250. void
  251. SetCalleeInfo (
  252. IN SOCKADDR_IN * CalleeAddress
  253. );
  254. inline
  255. DEST_Q931_INFO &GetDestQ931Info (
  256. void
  257. );
  258. inline
  259. HRESULT ConnectToCallee (
  260. void
  261. );
  262. protected:
  263. SOCKADDR_IN m_CalleeAddress;
  264. };
  265. inline
  266. DEST_H245_INFO::DEST_H245_INFO (
  267. void
  268. )
  269. {
  270. }
  271. inline
  272. void
  273. DEST_H245_INFO::Init (
  274. IN DEST_H323_STATE &DestH323State
  275. )
  276. {
  277. H245_INFO::Init((H323_STATE &)DestH323State);
  278. }
  279. inline void
  280. DEST_H245_INFO::SetCalleeInfo (
  281. IN SOCKADDR_IN * ArgCalleeAddress
  282. )
  283. {
  284. assert (ArgCalleeAddress);
  285. m_CalleeAddress = *ArgCalleeAddress;
  286. // state transition to H245_STATE_CON_INFO
  287. m_H245State = H245_STATE_CON_INFO;
  288. }
  289. #endif // _cbridge_h245_h_