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.

383 lines
11 KiB

  1. /***********************************************************************
  2. * *
  3. * Filename: rqstcls.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: RQSTCLS.C $
  17. * $Revision: 1.5 $
  18. * $Modtime: 09 Dec 1996 13:36:34 $
  19. * $Log: S:/STURGEON/SRC/H245/SRC/VCS/RQSTCLS.C_v $
  20. *
  21. * Rev 1.5 09 Dec 1996 13:37:02 EHOWARDX
  22. * Updated copyright notice.
  23. *
  24. * Rev 1.4 19 Jul 1996 12:15:40 EHOWARDX
  25. *
  26. * Changed to use event definitions from H245API.H.
  27. *
  28. * Rev 1.3 04 Jun 1996 13:57:30 EHOWARDX
  29. * Fixed Release build warnings.
  30. *
  31. * Rev 1.2 30 May 1996 23:39:26 EHOWARDX
  32. * Cleanup.
  33. *
  34. * Rev 1.1 29 May 1996 15:20:26 EHOWARDX
  35. * Change to use HRESULT.
  36. *
  37. * Rev 1.0 09 May 1996 21:06:42 EHOWARDX
  38. * Initial revision.
  39. *
  40. * Rev 1.6.1.2 09 May 1996 19:48:46 EHOWARDX
  41. * Change TimerExpiryF function arguements.
  42. *
  43. * Rev 1.6.1.1 15 Apr 1996 10:46:22 EHOWARDX
  44. * Update.
  45. *
  46. * Rev 1.6.1.0 10 Apr 1996 21:12:42 EHOWARDX
  47. * Branched.
  48. * *
  49. ***********************************************************************/
  50. #include "precomp.h"
  51. #include "h245api.h"
  52. #include "h245com.h"
  53. #include "h245fsm.h"
  54. #include "rqstcls.h"
  55. // request close channels from receive side outgoing states
  56. #define ReqCloseOutIDLE 0
  57. #define ReqCloseOutAwaitingResponse 1
  58. // request close channels on open side incoming states
  59. #define ReqCloseInIDLE 0
  60. #define ReqCloseInAwaitingResponse 1
  61. extern unsigned int uT108;
  62. /***********************************************************************
  63. *
  64. * LOCAL FUNCTIONS
  65. *
  66. ***********************************************************************/
  67. /*
  68. * NAME
  69. * T108ExpiryF - Callback function called by the timer
  70. *
  71. *
  72. * PARAMETERS
  73. * INPUT dwInst current instance of H245
  74. * INPUT id timer id
  75. * INPUT pObject pointer to a State Entity
  76. *
  77. *
  78. * RETURN VALUE
  79. * OK
  80. */
  81. int T108ExpiryF(struct InstanceStruct *pInstance, DWORD_PTR dwTimerId, void *pObject)
  82. {
  83. return FsmTimerEvent(pInstance, dwTimerId, pObject, T108Expiry);
  84. } // T108ExpiryF()
  85. /***********************************************************************
  86. *
  87. * OUT-GOING FINITE STATE MACHINE FUNCTIONS
  88. *
  89. ***********************************************************************/
  90. /*
  91. * NAME
  92. * closeRequestIdle - request to close a remote channel by API in idle state
  93. *
  94. *
  95. * PARAMETERS
  96. * INPUT pObject pointer to a State Entity
  97. *
  98. * RETURN VALUE
  99. * error return codes defined in h245com.h
  100. */
  101. HRESULT closeRequestIdle (Object_t *pObject, PDU_t *pPdu)
  102. {
  103. HRESULT lError;
  104. ASSERT(pObject->Entity == CLCSE_OUT);
  105. ASSERT(pObject->State == ReqCloseOutIDLE);
  106. H245TRACE(pObject->dwInst, 2,
  107. "Send RequestChannelClose to ASN; Channel=%d",
  108. pObject->Key);
  109. /* Send Request Channel Close to remote peer */
  110. lError = sendPDU(pObject->pInstance, pPdu);
  111. /* set timer T108 */
  112. pObject->State = ReqCloseOutAwaitingResponse;
  113. FsmStartTimer(pObject, T108ExpiryF, uT108);
  114. return lError;
  115. }
  116. /*
  117. * NAME
  118. * requestCloseAckAwaitingR - received request close Ack in awaiting release state
  119. *
  120. *
  121. * PARAMETERS
  122. * INPUT pObject pointer to a State Entity
  123. *
  124. * RETURN VALUE
  125. * error return codes defined in h245com.h
  126. */
  127. HRESULT requestCloseAckAwaitingR(Object_t *pObject, PDU_t *pPdu)
  128. {
  129. ASSERT(pObject->Entity == CLCSE_OUT);
  130. ASSERT(pObject->State == ReqCloseOutAwaitingResponse);
  131. H245TRACE(pObject->dwInst, 2,
  132. "H245_CONF_REQ_CLOSE to API; Channel=%d",
  133. pObject->Key);
  134. /* reset timer T108 */
  135. FsmStopTimer(pObject);
  136. /* Send CLOSE.confirm to client */
  137. pObject->State = ReqCloseOutIDLE;
  138. H245FsmConfirm(pPdu, H245_CONF_REQ_CLOSE, pObject->pInstance, pObject->dwTransId, FSM_OK);
  139. return 0;
  140. }
  141. /*
  142. * NAME
  143. * requestCloseRejAwaitingR - received request close reject in Awaiting Release state
  144. *
  145. *
  146. * PARAMETERS
  147. * INPUT pObject pointer to a State Entity
  148. *
  149. * RETURN VALUE
  150. * error return codes defined in h245com.h
  151. */
  152. HRESULT requestCloseRejAwaitingR(Object_t *pObject, PDU_t *pPdu)
  153. {
  154. ASSERT(pObject->Entity == CLCSE_OUT);
  155. ASSERT(pObject->State == ReqCloseOutAwaitingResponse);
  156. H245TRACE(pObject->dwInst, 2,
  157. "H245_CONF_REQ_CLOSE to API with REJECT; Channel=%d",
  158. pObject->Key);
  159. /* reset timer T108 */
  160. FsmStopTimer(pObject);
  161. /* Send REJECT.indication to client */
  162. pObject->State = ReqCloseOutIDLE;
  163. H245FsmConfirm(pPdu,H245_CONF_REQ_CLOSE, pObject->pInstance, pObject->dwTransId,REJECT);
  164. return 0;
  165. }
  166. /*
  167. * NAME
  168. * t108ExpiryAwaitingR - handle timer expiry of an outstanding request close
  169. *
  170. *
  171. * PARAMETERS
  172. * INPUT pObject pointer to a State Entity
  173. *
  174. * RETURN VALUE
  175. * error return codes defined in h245com.h
  176. */
  177. HRESULT t108ExpiryAwaitingR (Object_t *pObject, PDU_t *pPdu)
  178. {
  179. PDU_t * pOut;
  180. HRESULT lError;
  181. ASSERT(pObject->Entity == CLCSE_OUT);
  182. ASSERT(pObject->State == ReqCloseOutAwaitingResponse);
  183. ASSERT(pPdu == NULL);
  184. H245TRACE(pObject->dwInst, 2,
  185. "H245_CONF_REQ_CLOSE with Timer T108 Expiry to API; Channel=%d",
  186. pObject->Key);
  187. /* Send Request Channel Close Release to remote peer */
  188. pOut = (PDU_t *) MemAlloc(sizeof(*pOut));
  189. if (pOut == NULL)
  190. {
  191. H245TRACE(pObject->dwInst, 2,
  192. "t108ExpiryAwaitingR: memory allocation failed");
  193. return H245_ERROR_NOMEM;
  194. }
  195. pOut->choice = indication_chosen;
  196. pOut->u.indication.choice = rqstChnnlClsRls_chosen;
  197. pOut->u.indication.u.rqstChnnlClsRls.forwardLogicalChannelNumber = (WORD)pObject->Key;
  198. lError = sendPDU(pObject->pInstance, pOut);
  199. MemFree(pOut);
  200. /* Send REJECT.indication (SOURCE:=PROTOCOL to client */
  201. pObject->State = ReqCloseOutIDLE;
  202. H245FsmConfirm(NULL, H245_CONF_REQ_CLOSE, pObject->pInstance, pObject->dwTransId, TIMER_EXPIRY);
  203. return lError;
  204. }
  205. /***********************************************************************
  206. *
  207. * IN-COMING FINITE STATE MACHINE FUNCTIONS
  208. *
  209. ***********************************************************************/
  210. /*
  211. * NAME
  212. * requestCloseIdle - received requestClose in idle state
  213. *
  214. *
  215. * PARAMETERS
  216. * INPUT pObject pointer to a State Entity
  217. *
  218. * RETURN VALUE
  219. * error return codes defined in h245com.h
  220. */
  221. HRESULT requestCloseIdle (Object_t *pObject, PDU_t *pPdu)
  222. {
  223. ASSERT(pObject->Entity == CLCSE_IN);
  224. ASSERT(pObject->State == ReqCloseInIDLE);
  225. H245TRACE(pObject->dwInst, 2,
  226. "H245_IND_REQ_CLOSE with no error to API; Channel=%d",
  227. pObject->Key);
  228. /* Send CLOSE.indication to client */
  229. pObject->State = ReqCloseInAwaitingResponse;
  230. H245FsmIndication(pPdu, H245_IND_REQ_CLOSE, pObject->pInstance, pObject->dwTransId, FSM_OK);
  231. return 0;
  232. }
  233. /*
  234. * NAME
  235. * closeResponseAwaitingR - respond to a requestclose with an Ack (or Reject)
  236. *
  237. *
  238. * PARAMETERS
  239. * INPUT pObject pointer to a State Entity
  240. *
  241. * RETURN VALUE
  242. * error return codes defined in h245com.h
  243. */
  244. HRESULT closeResponseAwaitingR(Object_t *pObject, PDU_t *pPdu)
  245. {
  246. ASSERT(pObject->Entity == CLCSE_IN);
  247. ASSERT(pObject->State == ReqCloseInAwaitingResponse);
  248. H245TRACE(pObject->dwInst, 2,
  249. "Request Close Response Ack to ASN; Channel=%d",
  250. pObject->Key);
  251. /* Send Request Channel Close Ack to remote peer */
  252. pObject->State = ReqCloseInIDLE;
  253. return sendPDU(pObject->pInstance, pPdu);
  254. }
  255. HRESULT rejectRequestAwaitingR(Object_t *pObject, PDU_t *pPdu)
  256. {
  257. ASSERT(pObject->Entity == CLCSE_IN);
  258. ASSERT(pObject->State == ReqCloseInAwaitingResponse);
  259. H245TRACE(pObject->dwInst, 2, "Request Close Response Reject to ASN; Channel=%d",
  260. pObject->Key);
  261. /* Send Request Channel Close Reject to remote peer */
  262. pObject->State = ReqCloseInIDLE;
  263. return sendPDU(pObject->pInstance, pPdu);
  264. }
  265. /*
  266. * NAME
  267. * requestCloseReleaseAwaitingR - received a release while awaiting the api to respond
  268. *
  269. *
  270. * PARAMETERS
  271. * INPUT pObject pointer to a State Entity
  272. *
  273. * RETURN VALUE
  274. * error return codes defined in h245com.h
  275. */
  276. HRESULT requestCloseReleaseAwaitingR(Object_t *pObject, PDU_t *pPdu)
  277. {
  278. ASSERT(pObject->Entity == CLCSE_IN);
  279. ASSERT(pObject->State == ReqCloseInAwaitingResponse);
  280. H245TRACE(pObject->dwInst, 2,
  281. "H245_IND_REQ_CLOSE with Reject to API; Channel=%d",
  282. pObject->Key);
  283. /* Send REJECT.indication to client */
  284. pObject->State = ReqCloseInIDLE;
  285. H245FsmIndication(pPdu, H245_IND_CLCSE_RELEASE, pObject->pInstance, pObject->dwTransId, FSM_OK);
  286. return 0;
  287. }
  288. /*
  289. * NAME
  290. * requestCloseAwaitingR - overriding requestClose pdu in Awaiting Release state
  291. *
  292. *
  293. * PARAMETERS
  294. * INPUT pObject pointer to a State Entity
  295. *
  296. * RETURN VALUE
  297. * error return codes defined in h245com.h
  298. */
  299. HRESULT requestCloseAwaitingR (Object_t *pObject, PDU_t *pPdu)
  300. {
  301. ASSERT(pObject->Entity == CLCSE_IN);
  302. ASSERT(pObject->State == ReqCloseInAwaitingResponse);
  303. H245TRACE(pObject->dwInst, 2,
  304. "Overriding H245_IND_REQ_CLOSE with OK to API; Channel=%d",
  305. pObject->Key);
  306. #if defined(SDL_COMPLIANT)
  307. /* Send REJECT.indication to client - not necessary */
  308. H245FsmIndication(pPdu, H245_IND_REQ_CLOSE, pObject->pInstance, pObject->dwTransId, REJECT);
  309. #endif
  310. /* Send CLOSE.indication to client */
  311. H245FsmIndication(pPdu, H245_IND_REQ_CLOSE, pObject->pInstance, pObject->dwTransId, FSM_OK);
  312. return 0;
  313. }
  314.