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.

417 lines
12 KiB

  1. /***********************************************************************
  2. * *
  3. * Filename: rmese.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: RMESE.C $
  17. * $Revision: 1.3 $
  18. * $Modtime: 09 Dec 1996 13:36:34 $
  19. * $Log: S:/STURGEON/SRC/H245/SRC/VCS/RMESE.C_v $
  20. *
  21. * Rev 1.3 09 Dec 1996 13:37:00 EHOWARDX
  22. * Updated copyright notice.
  23. *
  24. * Rev 1.2 04 Jun 1996 13:57:38 EHOWARDX
  25. * Fixed Release build warnings.
  26. *
  27. * Rev 1.1 30 May 1996 23:39:26 EHOWARDX
  28. * Cleanup.
  29. *
  30. * Rev 1.0 09 May 1996 21:06:40 EHOWARDX
  31. * Initial revision.
  32. *
  33. * Rev 1.1 09 May 1996 19:48:50 EHOWARDX
  34. * Change TimerExpiryF function arguements.
  35. *
  36. * Rev 1.0 15 Apr 1996 10:45:20 EHOWARDX
  37. * Initial revision.
  38. * *
  39. ***********************************************************************/
  40. #include "precomp.h"
  41. #include "h245api.h"
  42. #include "h245com.h"
  43. #include "h245fsm.h"
  44. #include "rmese.h"
  45. // Out-going/In-coming RMESE states
  46. #define RMESE_IDLE 0 // IDLE
  47. #define RMESE_WAIT 1 // AWAITING_RESPONSE
  48. extern unsigned int uT107;
  49. /***********************************************************************
  50. *
  51. * LOCAL FUNCTIONS
  52. *
  53. ***********************************************************************/
  54. /*
  55. * NAME
  56. * T107ExpiryF - Callback function called by the timer
  57. *
  58. *
  59. * PARAMETERS
  60. * INPUT dwInst current instance of H245
  61. * INPUT id timer id
  62. * INPUT pObject pointer to a State Entity
  63. *
  64. *
  65. * RETURN VALUE
  66. * OK
  67. */
  68. int T107ExpiryF(struct InstanceStruct *pInstance, DWORD_PTR dwTimerId, void *pObject)
  69. {
  70. return FsmTimerEvent(pInstance, dwTimerId, pObject, T107Expiry);
  71. } // T107ExpiryF()
  72. /***********************************************************************
  73. *
  74. * OUT-GOING FINITE STATE MACHINE FUNCTIONS
  75. *
  76. ***********************************************************************/
  77. /*
  78. * NAME
  79. * RMESE0_SEND_requestF - SEND.request from API in IDLE state
  80. *
  81. *
  82. * PARAMETERS
  83. * INPUT pObject pointer to State Entity
  84. * INPUT pPdu pointer to PDU
  85. *
  86. * RETURN VALUE
  87. * Error return codes defined in h245com.h
  88. */
  89. HRESULT RMESE0_SEND_requestF (Object_t *pObject, PDU_t *pPdu)
  90. {
  91. HRESULT lError;
  92. ASSERT(pObject->Entity == RMESE_OUT);
  93. ASSERT(pObject->State == RMESE_IDLE);
  94. H245TRACE(pObject->dwInst, 2, "RMESE0_SEND_request:%d", pObject->Key);
  95. // Save information for release
  96. pObject->u.rmese = pPdu->u.indication.u.rqstMltplxEntryRls;
  97. // Send RequestMultiplexEntry PDU to remote peer
  98. lError = sendPDU(pObject->pInstance, pPdu);
  99. // Set timer T107
  100. pObject->State = RMESE_WAIT;
  101. FsmStartTimer(pObject, T107ExpiryF, uT107);
  102. return lError;
  103. } // RMESE0_SEND_request
  104. /*
  105. * NAME
  106. * RMESE1_SEND_requestF - SEND.request from API in AWAITING RESPONSE state
  107. *
  108. *
  109. * PARAMETERS
  110. * INPUT pObject pointer to State Entity
  111. * INPUT pPdu pointer to PDU
  112. *
  113. * RETURN VALUE
  114. * Error return codes defined in h245com.h
  115. */
  116. HRESULT RMESE1_SEND_requestF (Object_t *pObject, PDU_t *pPdu)
  117. {
  118. HRESULT lError;
  119. ASSERT(pObject->Entity == RMESE_OUT);
  120. ASSERT(pObject->State == RMESE_WAIT);
  121. H245TRACE(pObject->dwInst, 2, "RMESE1_SEND_request:%d", pObject->Key);
  122. // Reset timer T107
  123. FsmStopTimer(pObject);
  124. // Save information for release
  125. pObject->u.rmese = pPdu->u.indication.u.rqstMltplxEntryRls;
  126. // Send RequestMultiplexEntry PDU to remote peer
  127. lError = sendPDU(pObject->pInstance, pPdu);
  128. // Set timer T107
  129. FsmStartTimer(pObject, T107ExpiryF, uT107);
  130. return lError;
  131. } // RMESE1_SEND_request
  132. /*
  133. * NAME
  134. * RMESE1_RequestMuxEntryAckF - RequestMultiplexEntryAck in AWAITING RESPONSE state
  135. *
  136. *
  137. * PARAMETERS
  138. * INPUT pObject pointer to State Entity
  139. * INPUT pPdu pointer to PDU
  140. *
  141. * RETURN VALUE
  142. * Error return codes defined in h245com.h
  143. */
  144. HRESULT RMESE1_RequestMuxEntryAckF (Object_t *pObject, PDU_t *pPdu)
  145. {
  146. ASSERT(pObject->Entity == RMESE_OUT);
  147. ASSERT(pObject->State == RMESE_WAIT);
  148. H245TRACE(pObject->dwInst, 2, "RMESE1_RequestMuxEntryAck:%d", pObject->Key);
  149. // Reset timer T107
  150. FsmStopTimer(pObject);
  151. // Send SEND.confirm to H.245 user
  152. pObject->State = RMESE_IDLE;
  153. H245FsmConfirm(pPdu, H245_CONF_RMESE, pObject->pInstance, pObject->dwTransId, FSM_OK);
  154. return 0;
  155. } // RMESE1_RequestMuxEntryAck
  156. /*
  157. * NAME
  158. * RMESE1_RequestMuxEntryRejF - RequestMultiplexEntryReject in AWAITING RESPONSE state
  159. *
  160. *
  161. * PARAMETERS
  162. * INPUT pObject pointer to State Entity
  163. * INPUT pPdu pointer to PDU
  164. *
  165. * RETURN VALUE
  166. * Error return codes defined in h245com.h
  167. */
  168. HRESULT RMESE1_RequestMuxEntryRejF (Object_t *pObject, PDU_t *pPdu)
  169. {
  170. ASSERT(pObject->Entity == RMESE_OUT);
  171. ASSERT(pObject->State == RMESE_WAIT);
  172. H245TRACE(pObject->dwInst, 2, "RMESE0_RequestMuxEntryRej:%d", pObject->Key);
  173. // Reset timer T107
  174. FsmStopTimer(pObject);
  175. // Send REJECT.indication to H.245 user
  176. pObject->State = RMESE_IDLE;
  177. H245FsmConfirm(pPdu, H245_CONF_RMESE_REJECT, pObject->pInstance, pObject->dwTransId, FSM_OK);
  178. return 0;
  179. } // RMESE1_RequestMuxEntryRej
  180. /*
  181. * NAME
  182. * RMESE1_T107ExpiryF - timer T107 Expiry
  183. *
  184. *
  185. * PARAMETERS
  186. * INPUT pObject pointer to State Entity
  187. * INPUT pPdu pointer to PDU
  188. *
  189. * RETURN VALUE
  190. * Error return codes defined in h245com.h
  191. */
  192. HRESULT RMESE1_T107ExpiryF (Object_t *pObject, PDU_t *pPdu)
  193. {
  194. HRESULT lError;
  195. PDU_t * pOut;
  196. unsigned short wNumber = (unsigned short) pObject->Key;
  197. ASSERT(pObject->Entity == RMESE_OUT);
  198. ASSERT(pObject->State == RMESE_WAIT);
  199. ASSERT(pPdu == NULL);
  200. H245TRACE(pObject->dwInst, 2, "RMESE1_T107Expiry:%d", pObject->Key);
  201. // Send RequestMultiplexEntryRelease PDU to remote peer
  202. pOut = MemAlloc(sizeof(*pOut));
  203. if (pOut == NULL)
  204. {
  205. H245TRACE(pObject->dwInst, 2,
  206. "RMESE1_T107ExpiryF: memory allocation failed");
  207. return H245_ERROR_NOMEM;
  208. }
  209. pOut->choice = indication_chosen;
  210. pOut->u.indication.choice = rqstMltplxEntryRls_chosen;
  211. pOut->u.indication.u.rqstMltplxEntryRls = pObject->u.rmese;
  212. lError = sendPDU(pObject->pInstance, pOut);
  213. MemFree(pOut);
  214. // Send REJECT.indication to H.245 user
  215. // SOURCE := PROTOCOL
  216. pObject->State = RMESE_IDLE;
  217. H245FsmConfirm(NULL, H245_CONF_RMESE_EXPIRED, pObject->pInstance, pObject->dwTransId, FSM_OK);
  218. return lError;
  219. } // RMESE1_T107Expiry
  220. /***********************************************************************
  221. *
  222. * IN-COMING FINITE STATE MACHINE FUNCTIONS
  223. *
  224. ***********************************************************************/
  225. /*
  226. * NAME
  227. * RMESE0_RequestMuxEntryF - RequestMultiplexEntry received in IDLE state
  228. *
  229. *
  230. * PARAMETERS
  231. * INPUT pObject pointer to State Entity
  232. * INPUT pPdu pointer to PDU
  233. *
  234. * RETURN VALUE
  235. * Error return codes defined in h245com.h
  236. */
  237. HRESULT RMESE0_RequestMuxEntryF (Object_t *pObject, PDU_t *pPdu)
  238. {
  239. ASSERT(pObject->Entity == RMESE_IN);
  240. ASSERT(pObject->State == RMESE_IDLE);
  241. H245TRACE(pObject->dwInst, 2, "RMESE0_RequestMuxEntry:%d", pObject->Key);
  242. // Send SEND.indication to H.245 user
  243. pObject->State = RMESE_WAIT;
  244. H245FsmIndication(pPdu, H245_IND_RMESE, pObject->pInstance, pObject->dwTransId, FSM_OK);
  245. return 0;
  246. } // RMESE0_RequestMuxEntry
  247. /*
  248. * NAME
  249. * RMESE1_RequestMuxEntryF - RequestMultiplexEntry received in AWAITING RESPONSE state
  250. *
  251. *
  252. * PARAMETERS
  253. * INPUT pObject pointer to State Entity
  254. * INPUT pPdu pointer to PDU
  255. *
  256. * RETURN VALUE
  257. * Error return codes defined in h245com.h
  258. */
  259. HRESULT RMESE1_RequestMuxEntryF (Object_t *pObject, PDU_t *pPdu)
  260. {
  261. ASSERT(pObject->Entity == RMESE_IN);
  262. ASSERT(pObject->State == RMESE_WAIT);
  263. H245TRACE(pObject->dwInst, 2, "RMESE1_RequestMuxEntry:%d", pObject->Key);
  264. #if defined(SDL_COMPLIANT)
  265. // Send REJECT.indication to H.245 user
  266. H245FsmIndication(pPdu, H245_IND_RMESE_RELEASE, pObject->pInstance, pObject->dwTransId, FSM_OK);
  267. #endif
  268. // Send SEND.indication to H.245 user
  269. H245FsmIndication(pPdu, H245_IND_RMESE, pObject->pInstance, pObject->dwTransId, FSM_OK);
  270. return 0;
  271. } // RMESE1_RequestMuxEntry
  272. /*
  273. * NAME
  274. * RMESE1_RequestMuxEntryReleaseF - RequestMultiplexEntryRelease received in AWAITING RESPONSE state
  275. *
  276. *
  277. * PARAMETERS
  278. * INPUT pObject pointer to State Entity
  279. * INPUT pPdu pointer to PDU
  280. *
  281. * RETURN VALUE
  282. * Error return codes defined in h245com.h
  283. */
  284. HRESULT RMESE1_RequestMuxEntryReleaseF (Object_t *pObject, PDU_t *pPdu)
  285. {
  286. ASSERT(pObject->Entity == RMESE_IN);
  287. ASSERT(pObject->State == RMESE_WAIT);
  288. H245TRACE(pObject->dwInst, 2, "RMESE1_RequestMuxEntryRelease:%d", pObject->Key);
  289. // Send REJECT.indication to H.245 user
  290. // SOURCE := PROTOCOL
  291. pObject->State = RMESE_IDLE;
  292. H245FsmIndication(pPdu, H245_IND_RMESE_RELEASE, pObject->pInstance, pObject->dwTransId, FSM_OK);
  293. return 0;
  294. } // RMESE1_RequestMuxEntryRelease
  295. /*
  296. * NAME
  297. * RMESE1_SEND_responseF - SEND.response from API in AWAITING RESPONSE state
  298. *
  299. *
  300. * PARAMETERS
  301. * INPUT pObject pointer to State Entity
  302. * INPUT pPdu pointer to PDU
  303. *
  304. * RETURN VALUE
  305. * Error return codes defined in h245com.h
  306. */
  307. HRESULT RMESE1_SEND_responseF (Object_t *pObject, PDU_t *pPdu)
  308. {
  309. ASSERT(pObject->Entity == RMESE_IN);
  310. ASSERT(pObject->State == RMESE_WAIT);
  311. H245TRACE(pObject->dwInst, 2, "RMESE1_SEND_response:%d", pObject->Key);
  312. // Send RequestMultiplexEntryAck PDU to remote peer
  313. pObject->State = RMESE_IDLE;
  314. return sendPDU(pObject->pInstance, pPdu);
  315. } // RMESE1_SEND_response
  316. /*
  317. * NAME
  318. * RMESE1_REJECT_requestF - REJECT.request from API in AWAITING RESPONSE state
  319. *
  320. *
  321. * PARAMETERS
  322. * INPUT pObject pointer to State Entity
  323. * INPUT pPdu pointer to PDU
  324. *
  325. * RETURN VALUE
  326. * Error return codes defined in h245com.h
  327. */
  328. HRESULT RMESE1_REJECT_requestF (Object_t *pObject, PDU_t *pPdu)
  329. {
  330. ASSERT(pObject->Entity == RMESE_IN);
  331. ASSERT(pObject->State == RMESE_WAIT);
  332. H245TRACE(pObject->dwInst, 2, "RMESE1_REJECT_request:%d", pObject->Key);
  333. // Send RequestMultiplexEntryReject PDU to remote
  334. pObject->State = RMESE_IDLE;
  335. return sendPDU(pObject->pInstance, pPdu);
  336. } // RMESE1_REJECT_request
  337.