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.

331 lines
9.6 KiB

  1. /***********************************************************************
  2. * *
  3. * Filename: rtdse.c *
  4. * Module: H245 Finite State Machine Subsystem *
  5. * *
  6. ***********************************************************************
  7. * INTEL Corporation Proprietary Information *
  8. * *
  9. * This listing is supplied under the terms of a license agreement *
  10. * with INTEL Corporation and may not be copied nor disclosed except *
  11. * in accordance with the terms of that agreement. *
  12. * *
  13. * Copyright (c) 1996 Intel Corporation. All rights reserved. *
  14. ***********************************************************************
  15. * *
  16. * $Workfile: rtdse.c $
  17. * $Revision: 1.4 $
  18. * $Modtime: Feb 28 1997 13:13:32 $
  19. * $Log: S:/STURGEON/SRC/H245/SRC/VCS/rtdse.c_v $
  20. *
  21. * Rev 1.4 Feb 28 1997 13:14:24 tomitowx
  22. * fixed Roundtripdelay timer problem.
  23. * that occurs when ping peer link is invalid/unvailable
  24. * due to an abnormal application/machine shutdown.
  25. *
  26. * Rev 1.3 09 Dec 1996 13:37:04 EHOWARDX
  27. * Updated copyright notice.
  28. *
  29. * Rev 1.2 04 Jun 1996 13:57:26 EHOWARDX
  30. * Fixed Release build warnings.
  31. *
  32. * Rev 1.1 30 May 1996 23:39:28 EHOWARDX
  33. * Cleanup.
  34. *
  35. * Rev 1.0 09 May 1996 21:06:42 EHOWARDX
  36. * Initial revision.
  37. *
  38. * Rev 1.1 09 May 1996 19:48:24 EHOWARDX
  39. * Change TimerExpiryF function arguements.
  40. *
  41. * Rev 1.0 15 Apr 1996 10:46:40 EHOWARDX
  42. * Initial revision.
  43. * *
  44. ***********************************************************************/
  45. #include "precomp.h"
  46. #include "h245api.h"
  47. #include "h245com.h"
  48. #include "h245fsm.h"
  49. #include "rtdse.h"
  50. // Out-going/In-coming RTDSE states
  51. #define RTDSE_IDLE 0 // IDLE
  52. #define RTDSE_WAIT 1 // AWAITING_RESPONSE
  53. extern unsigned int uT105;
  54. /***********************************************************************
  55. *
  56. * LOCAL FUNCTIONS
  57. *
  58. ***********************************************************************/
  59. /*
  60. * NAME
  61. * T105ExpiryF - Callback function called by the timer
  62. *
  63. *
  64. * PARAMETERS
  65. * INPUT dwInst current instance of H.245
  66. * INPUT id timer id
  67. * INPUT pObject pointer to a State Entity
  68. *
  69. *
  70. * RETURN VALUE
  71. * OK
  72. */
  73. int T105ExpiryF(struct InstanceStruct *pInstance, DWORD_PTR dwTimerId, void *pObject)
  74. {
  75. return FsmTimerEvent(pInstance, dwTimerId, pObject, T105Expiry);
  76. } // T105ExpiryF()
  77. static void BuildRoundTripDelayResponse(PDU_t *pOut, BYTE bySequenceNumber)
  78. {
  79. pOut->choice = MSCMg_rspns_chosen;
  80. pOut->u.MSCMg_rspns.choice = roundTripDelayResponse_chosen;
  81. pOut->u.MSCMg_rspns.u.roundTripDelayResponse.sequenceNumber = bySequenceNumber;
  82. } // BuildRoundTripDelayResponse()
  83. /***********************************************************************
  84. *
  85. * FINITE STATE MACHINE FUNCTIONS
  86. *
  87. ***********************************************************************/
  88. /*
  89. * NAME
  90. * RTDSE0_TRANSFER_requestF - TRANSFER.request from API in IDLE state
  91. *
  92. *
  93. * PARAMETERS
  94. * INPUT pObject pointer to State Entity
  95. * INPUT pPdu pointer to PDU
  96. *
  97. * RETURN VALUE
  98. * Error return codes defined in h245com.h
  99. */
  100. HRESULT RTDSE0_TRANSFER_requestF (Object_t *pObject, PDU_t *pPdu)
  101. {
  102. HRESULT lError;
  103. ASSERT(pObject->Entity == RTDSE);
  104. ASSERT(pObject->State == RTDSE_IDLE);
  105. H245TRACE(pObject->dwInst, 2, "RTDSE0_TRANSFER_request:%d", pObject->Key);
  106. pObject->pInstance->StateMachine.byRtdseSequence++;
  107. pPdu->u.MltmdSystmCntrlMssg_rqst.u.roundTripDelayRequest.sequenceNumber =
  108. pObject->pInstance->StateMachine.byRtdseSequence;
  109. // Send RoundTripDelayRequest PDU to remote peer
  110. lError = sendPDU(pObject->pInstance, pPdu);
  111. //[email protected]
  112. if(lError == H245_ERROR_OK)
  113. {
  114. // Set timer T105
  115. pObject->State = RTDSE_WAIT;
  116. FsmStartTimer(pObject, T105ExpiryF, uT105);
  117. }
  118. //[email protected]
  119. // Set timer T105
  120. // pObject->State = RTDSE_WAIT;
  121. // FsmStartTimer(pObject, T105ExpiryF, uT105);
  122. //[email protected]
  123. return lError;
  124. } // RTDSE0_TRANSFER_request
  125. /*
  126. * NAME
  127. * RTDSE0_RoundTripDelayRequestF - RoundTripDelayRequest received in IDLE state
  128. *
  129. *
  130. * PARAMETERS
  131. * INPUT pObject pointer to State Entity
  132. * INPUT pPdu pointer to PDU
  133. *
  134. * RETURN VALUE
  135. * Error return codes defined in h245com.h
  136. */
  137. HRESULT RTDSE0_RoundTripDelayRequestF (Object_t *pObject, PDU_t *pPdu)
  138. {
  139. PDU_t * pOut;
  140. HRESULT lError;
  141. ASSERT(pObject->Entity == RTDSE);
  142. ASSERT(pObject->State == RTDSE_IDLE);
  143. H245TRACE(pObject->dwInst, 2, "RTDSE0_RoundTripDelayRequest:%d", pObject->Key);
  144. // Send RoundTripDelayResponse to remote peer
  145. pOut = MemAlloc(sizeof(*pOut));
  146. if (pOut == NULL)
  147. {
  148. H245TRACE(pObject->dwInst, 2,
  149. "RTDSE0_RoundTripDelayRequestF: memory allocation failed");
  150. return H245_ERROR_NOMEM;
  151. }
  152. BuildRoundTripDelayResponse(pOut, (BYTE)pPdu->u.MltmdSystmCntrlMssg_rqst.u.roundTripDelayRequest.sequenceNumber);
  153. lError = sendPDU(pObject->pInstance, pOut);
  154. MemFree(pOut);
  155. return lError;
  156. } // RTDSE0_RoundTripDelayRequest
  157. /*
  158. * NAME
  159. * RTDSE1_TRANSFER_requestF - TRANSFER.request from API in AWAITING RESPONSE state
  160. *
  161. *
  162. * PARAMETERS
  163. * INPUT pObject pointer to State Entity
  164. * INPUT pPdu pointer to PDU
  165. *
  166. * RETURN VALUE
  167. * Error return codes defined in h245com.h
  168. */
  169. HRESULT RTDSE1_TRANSFER_requestF (Object_t *pObject, PDU_t *pPdu)
  170. {
  171. HRESULT lError;
  172. ASSERT(pObject->Entity == RTDSE);
  173. ASSERT(pObject->State == RTDSE_WAIT);
  174. H245TRACE(pObject->dwInst, 2, "RTDSE1_TRANSFER_request:%d", pObject->Key);
  175. // Reset timer T105
  176. FsmStopTimer(pObject);
  177. pObject->pInstance->StateMachine.byRtdseSequence++;
  178. pPdu->u.MltmdSystmCntrlMssg_rqst.u.roundTripDelayRequest.sequenceNumber =
  179. pObject->pInstance->StateMachine.byRtdseSequence;
  180. // Send RoundTripDelayRequest PDU to remote
  181. lError = sendPDU(pObject->pInstance, pPdu);
  182. // Set timer T105
  183. FsmStartTimer(pObject, T105ExpiryF, uT105);
  184. return lError;
  185. } // RTDSE1_TRANSFER_request
  186. /*
  187. * NAME
  188. * RTDSE1_RoundTripDelayRequestF - RoundTripDelayRequest received in AWAITING RESPONSE state
  189. *
  190. *
  191. * PARAMETERS
  192. * INPUT pObject pointer to State Entity
  193. * INPUT pPdu pointer to PDU
  194. *
  195. * RETURN VALUE
  196. * Error return codes defined in h245com.h
  197. */
  198. HRESULT RTDSE1_RoundTripDelayRequestF (Object_t *pObject, PDU_t *pPdu)
  199. {
  200. PDU_t * pOut;
  201. HRESULT lError;
  202. ASSERT(pObject->Entity == RTDSE);
  203. ASSERT(pObject->State == RTDSE_WAIT);
  204. H245TRACE(pObject->dwInst, 2, "RTDSE1_RoundTripDelayRequest:%d", pObject->Key);
  205. // Send RoundTripDelayResponse to remote peer
  206. pOut = MemAlloc(sizeof(*pOut));
  207. if (pOut == NULL)
  208. {
  209. H245TRACE(pObject->dwInst, 2,
  210. "RTDSE1_RoundTripDelayRequestF: memory allocation failed");
  211. return H245_ERROR_NOMEM;
  212. }
  213. BuildRoundTripDelayResponse(pOut, (BYTE)pPdu->u.MltmdSystmCntrlMssg_rqst.u.roundTripDelayRequest.sequenceNumber);
  214. lError = sendPDU(pObject->pInstance, pOut);
  215. MemFree(pOut);
  216. return lError;
  217. } // RTDSE1_RoundTripDelayRequest
  218. /*
  219. * NAME
  220. * RTDSE1_RoundTripDelayResponseF - RoundTripDelayResponse in AWAITING RESPONSE state
  221. *
  222. *
  223. * PARAMETERS
  224. * INPUT pObject pointer to State Entity
  225. * INPUT pPdu pointer to PDU
  226. *
  227. * RETURN VALUE
  228. * Error return codes defined in h245com.h
  229. */
  230. HRESULT RTDSE1_RoundTripDelayResponseF (Object_t *pObject, PDU_t *pPdu)
  231. {
  232. ASSERT(pObject->Entity == RTDSE);
  233. ASSERT(pObject->State == RTDSE_WAIT);
  234. H245TRACE(pObject->dwInst, 2, "RTDSE1_RoundTripDelayResponse:%d", pObject->Key);
  235. if (pPdu->u.MSCMg_rspns.u.roundTripDelayResponse.sequenceNumber ==
  236. pObject->pInstance->StateMachine.byRtdseSequence)
  237. {
  238. // Reset timer T105
  239. FsmStopTimer(pObject);
  240. // Send TRANSFER.confirm to H.245 user
  241. pObject->State = RTDSE_IDLE;
  242. H245FsmConfirm(pPdu, H245_CONF_RTDSE, pObject->pInstance, pObject->dwTransId, FSM_OK);
  243. }
  244. return 0;
  245. } // RTDSE1_RoundTripDelayResponse
  246. /*
  247. * NAME
  248. * RTDSE1_T105ExpiryF - timer T105 Expiry in AWAITING RESPONSE state
  249. *
  250. *
  251. * PARAMETERS
  252. * INPUT pObject pointer to State Entity
  253. * INPUT pPdu pointer to PDU
  254. *
  255. * RETURN VALUE
  256. * Error return codes defined in h245com.h
  257. */
  258. HRESULT RTDSE1_T105ExpiryF (Object_t *pObject, PDU_t *pPdu)
  259. {
  260. ASSERT(pObject->Entity == RTDSE);
  261. ASSERT(pObject->State == RTDSE_WAIT);
  262. ASSERT(pPdu == NULL);
  263. H245TRACE(pObject->dwInst, 2, "RTDSE1_T105Expiry:%d", pObject->Key);
  264. // Send EXPIRY.notification to client
  265. pObject->State = RTDSE_IDLE;
  266. H245FsmConfirm(NULL, H245_CONF_RTDSE_EXPIRED, pObject->pInstance, pObject->dwTransId, FSM_OK);
  267. return 0;
  268. } // RTDSE1_T105Expiry
  269.