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.

186 lines
5.0 KiB

  1. #include "stdafx.h"
  2. #include "portmgmt.h"
  3. #include "timerval.h"
  4. #include "cbridge.h"
  5. void LOGICAL_CHANNEL::IncrementLifetimeCounter (void) { GetCallBridge().AddRef (); }
  6. void LOGICAL_CHANNEL::DecrementLifetimeCounter (void) { GetCallBridge().Release (); }
  7. // Code common for both RTP and T.120 logical channels
  8. // Only OpenLogicalChannel and OpenLogicalChannelAck need to
  9. // be handled differently for RTP and T.120 logical channels
  10. HRESULT
  11. LOGICAL_CHANNEL::CreateTimer(DWORD TimeoutValue)
  12. {
  13. DWORD RetCode;
  14. RetCode = TimprocCreateTimer (TimeoutValue);
  15. return HRESULT_FROM_WIN32(RetCode);
  16. }
  17. // the event manager tells us about timer expiry via this method
  18. /* virtual */ void
  19. LOGICAL_CHANNEL::TimerCallback (void)
  20. {
  21. CALL_BRIDGE *pCallBridge = &GetCallBridge();
  22. ///////////////////////////////
  23. //// LOCK the CALL_BRIDGE
  24. ///////////////////////////////
  25. pCallBridge->Lock ();
  26. // Clear the timer - Note that Terminate () will try to
  27. // cancel all the timers in this CALL_BRIDGE
  28. TimprocCancelTimer();
  29. DebugF (_T("LC : 0x%x cancelled timer.\n"),
  30. &GetCallBridge ());
  31. // Don't do anything if the CALL_BRIDGE is already terminated.
  32. if (!pCallBridge->IsTerminated ())
  33. {
  34. // CODE WORK *** TO DO
  35. // if the current state is LC_STATE_OPEN_RCVD, send close LC PDU to
  36. // both the source and the destination
  37. // if the current state is LC_STATE_CLOSE_RCVD or
  38. // LC_STATE_OPENED_CLOSE_RCVD, send close LC PDU to just
  39. // the destination
  40. // delete self and remove the pointer from the logical channel array
  41. DeleteAndRemoveSelf ();
  42. }
  43. ///////////////////////////////
  44. //// UNLOCK the CALL_BRIDGE
  45. ///////////////////////////////
  46. pCallBridge -> Unlock ();
  47. pCallBridge -> Release ();
  48. }
  49. HRESULT
  50. LOGICAL_CHANNEL::HandleCloseLogicalChannelPDU(
  51. IN MultimediaSystemControlMessage *pH245pdu
  52. )
  53. {
  54. HRESULT HResult = E_FAIL;
  55. switch(m_LogicalChannelState)
  56. {
  57. case LC_STATE_OPEN_RCVD:
  58. case LC_STATE_OPEN_ACK_RCVD:
  59. {
  60. #if 0 // 0 ******* Region Commented Out Begins *******
  61. // start timer, if we don't receive a response in this time,
  62. // we must close this logical channel
  63. HResult = CreateTimer(LC_POST_CLOSE_TIMER_VALUE);
  64. if (FAILED(HResult))
  65. {
  66. DebugF( _T("LOGICAL_CHANNEL::HandleCloseLogicalChannelPDU, ")
  67. _T("couldn't create timer, returning 0x%x\n"),
  68. HResult));
  69. return HResult;
  70. }
  71. #endif // 0 ******* Region Commented Out Ends *******
  72. // save the reason for closing the logical channel
  73. // forward the PDU to the other H245 instance
  74. HResult = m_pH245Info->GetOtherH245Info().ProcessMessage(pH245pdu);
  75. if (FAILED(HResult))
  76. {
  77. return HResult;
  78. }
  79. _ASSERTE(S_OK == HResult);
  80. // Don't wait for CLCAck. Just CLC is sufficient to delete the
  81. // logical channel. CLCAck is just forwarded without doing anything.
  82. // delete self and remove the pointer from the logical channel array
  83. DeleteAndRemoveSelf();
  84. #if 0 // 0 ******* Region Commented Out Begins *******
  85. // state trasition
  86. if (LC_STATE_OPEN_ACK_RCVD == m_LogicalChannelState)
  87. {
  88. // we had opened the logical channel
  89. m_LogicalChannelState = LC_STATE_OPENED_CLOSE_RCVD;
  90. }
  91. else
  92. {
  93. // the logical channel was never opened
  94. m_LogicalChannelState = LC_STATE_CLOSE_RCVD;
  95. }
  96. #endif // 0 ******* Region Commented Out Ends *******
  97. }
  98. break;
  99. case LC_STATE_CLOSE_RCVD:
  100. case LC_STATE_OPENED_CLOSE_RCVD:
  101. {
  102. return E_INVALIDARG;
  103. }
  104. break;
  105. case LC_STATE_NOT_INIT:
  106. default:
  107. {
  108. _ASSERTE(FALSE);
  109. return E_UNEXPECTED;
  110. }
  111. break;
  112. };
  113. return HResult;
  114. }
  115. HRESULT
  116. LOGICAL_CHANNEL::ProcessOpenLogicalChannelRejectPDU(
  117. IN MultimediaSystemControlMessage *pH245pdu
  118. )
  119. {
  120. // delete self and remove the pointer from the logical channel array
  121. DeleteAndRemoveSelf();
  122. // shouldn't access any members of the logical channel as it may have
  123. // been destroyed already
  124. // NOTE: Since we return S_OK, the PDU gets forwarded to the other end
  125. return S_OK;
  126. }
  127. // Unused.
  128. HRESULT
  129. LOGICAL_CHANNEL::ProcessCloseLogicalChannelAckPDU(
  130. IN MultimediaSystemControlMessage *pH245pdu
  131. )
  132. {
  133. DebugF( _T("LOGICAL_CHANNEL::ProcessCloseLogicalChannelAckPDU(&%x) called ")
  134. _T("m_LogicalChannelState: %d, LCN: %d\n"),
  135. pH245pdu,
  136. m_LogicalChannelState, m_LogicalChannelNumber);
  137. // cancel timer
  138. // CODEWORK: Make some checks on the PDU and current state ??
  139. // delete self and remove the pointer from the logical channel array
  140. DeleteAndRemoveSelf();
  141. // shouldn't access any members of the logical channel as it may have
  142. // been destroyed already
  143. DebugF( _T("LOGICAL_CHANNEL::ProcessCloseLogicalChannelAckPDU(&%x) ")
  144. _T("returning S_OK\n"),
  145. pH245pdu);
  146. return S_OK;
  147. }