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.

996 lines
28 KiB

  1. /***********************************************************************
  2. * *
  3. * Filename: openb.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: openb.c $
  17. * $Revision: 1.5 $
  18. * $Modtime: 09 Dec 1996 18:05:30 $
  19. * $Log L:\mphone\h245\h245env\comm\h245_3\h245_fsm\vcs\src\openb.c_v $
  20. * *
  21. ***********************************************************************/
  22. #include "precomp.h"
  23. #include "h245api.h"
  24. #include "h245com.h"
  25. #include "h245fsm.h"
  26. #include "openb.h"
  27. #include "pdu.x"
  28. // Open Bi-directional Logical Channel Out-going states
  29. #define OpenOutBReleased 0
  30. #define OpenOutBAwaitingEstablishment 1
  31. #define OpenOutBEstablished 2
  32. #define OpenOutBAwaitingRelease 3
  33. // Open Bi-directional Logical Channel In-coming states
  34. #define OpenInBReleased 0
  35. #define OpenInBAwaitingEstablishment 1
  36. #define OpenInBAwaitingConfirmation 2
  37. #define OpenInBEstablished 3
  38. extern unsigned int uT103;
  39. /***********************************************************************
  40. *
  41. * LOCAL FUNCTIONS
  42. *
  43. ***********************************************************************/
  44. /*
  45. * NAME
  46. * T103OutExpiryF - Callback function called by the timer.
  47. * T103InExpiryF - Callback function called by the timer.
  48. *
  49. *
  50. * PARAMETERS
  51. * INPUT dwInst current instance of H245
  52. * INPUT id timer id
  53. * INPUT obj pointer to a FSM object
  54. *
  55. *
  56. * RETURN VALUE
  57. * OK
  58. */
  59. int T103OutExpiryF(struct InstanceStruct *pInstance, DWORD_PTR dwTimerId, void *pObject)
  60. {
  61. return FsmTimerEvent(pInstance, dwTimerId, pObject, T103OutExpiry);
  62. } // T103OutExpiryF()
  63. int T103InExpiryF(struct InstanceStruct *pInstance, DWORD_PTR dwTimerId, void *pObject)
  64. {
  65. return FsmTimerEvent(pInstance, dwTimerId, pObject, T103InExpiry);
  66. } // T103InExpiryF()
  67. /***********************************************************************
  68. *
  69. * OUT-GOING FINITE STATE MACHINE FUNCTIONS
  70. *
  71. ***********************************************************************/
  72. /*
  73. * NAME
  74. * establishReqBReleased - API request to open bidirectional channel in idle state
  75. *
  76. *
  77. * PARAMETERS
  78. * INPUT pObject pointer to a State Entity
  79. *
  80. * RETURN VALUE
  81. * error return codes defined in h245com.h
  82. */
  83. HRESULT establishReqBReleased(Object_t *pObject, PDU_t *pPdu)
  84. {
  85. HRESULT lError;
  86. ASSERT(pObject->Entity == BLCSE_OUT);
  87. ASSERT(pObject->State == OpenOutBReleased);
  88. H245TRACE(pObject->dwInst, 2,
  89. "Sending open Bidirectional channel to ASN; Channel=%d",
  90. pObject->Key);
  91. /* Send Open Logical Channel to remote peer */
  92. lError = sendPDU(pObject->pInstance, pPdu);
  93. /* set timer T103 */
  94. pObject->State = OpenOutBAwaitingEstablishment;
  95. FsmStartTimer(pObject, T103OutExpiryF, uT103);
  96. return lError;
  97. }
  98. /*
  99. * NAME
  100. * openChannelAckBAwaitingE - received open bidirectional channel Ack in Awaiting Establishment state
  101. *
  102. *
  103. * PARAMETERS
  104. * INPUT pObject pointer to a State Entity
  105. *
  106. * RETURN VALUE
  107. * error return codes defined in h245com.h
  108. */
  109. HRESULT openChannelAckBAwaitingE(Object_t *pObject, PDU_t *pPdu)
  110. {
  111. PDU_t * pOut;
  112. HRESULT lError;
  113. ASSERT(pObject->Entity == BLCSE_OUT);
  114. ASSERT(pObject->State == OpenOutBAwaitingEstablishment);
  115. H245TRACE(pObject->dwInst, 2,
  116. "H245_CONF_NEEDRSP_OPEN with no error to API; Channel=%d",
  117. pObject->Key);
  118. /* reset timer T103 */
  119. FsmStopTimer(pObject);
  120. /* Send ESTABLISH.confirm to client */
  121. pObject->State = OpenOutBEstablished;
  122. H245FsmConfirm(pPdu,H245_CONF_NEEDRSP_OPEN, pObject->pInstance, pObject->dwTransId, FSM_OK);
  123. /* Send Open Logical Channel Confirm to remote peer */
  124. pOut = (PDU_t *) MemAlloc(sizeof(PDU_t ));
  125. if (pOut == NULL)
  126. {
  127. H245TRACE(pObject->dwInst, 1,
  128. "openChannelAckBAwaitingE: memory allocation failed");
  129. return H245_ERROR_NOMEM;
  130. }
  131. pdu_ind_open_logical_channel_conf(pOut, (WORD)pObject->Key);
  132. lError = sendPDU(pObject->pInstance, pOut);
  133. MemFree(pOut);
  134. return lError;
  135. }
  136. /*
  137. * NAME
  138. * openChannelRejBAwaitingE - received open bidirectional channel reject in Awaiting Establishment state
  139. *
  140. *
  141. * PARAMETERS
  142. * INPUT pObject pointer to a State Entity
  143. *
  144. * RETURN VALUE
  145. * error return codes defined in h245com.h
  146. */
  147. HRESULT openChannelRejBAwaitingE(Object_t *pObject, PDU_t *pPdu)
  148. {
  149. ASSERT(pObject->Entity == BLCSE_OUT);
  150. ASSERT(pObject->State == OpenOutBAwaitingEstablishment);
  151. H245TRACE(pObject->dwInst, 2,
  152. "H245_CONF_NEEDRSP_OPEN with REJECT to API; Channel=%d",
  153. pObject->Key);
  154. /* reset timer T103 */
  155. FsmStopTimer(pObject);
  156. /* Send RELEASE.indication to client */
  157. pObject->State = OpenOutBReleased;
  158. H245FsmConfirm(pPdu, H245_CONF_NEEDRSP_OPEN, pObject->pInstance, pObject->dwTransId, REJECT);
  159. return 0;
  160. }
  161. /*
  162. * NAME
  163. * releaseReqBOutAwaitingE - API request to close bidirectional channel in Awaiting Establishment state
  164. *
  165. *
  166. * PARAMETERS
  167. * INPUT pObject pointer to a State Entity
  168. *
  169. * RETURN VALUE
  170. * error return codes defined in h245com.h
  171. */
  172. HRESULT releaseReqBOutAwaitingE(Object_t *pObject, PDU_t *pPdu)
  173. {
  174. HRESULT lError;
  175. ASSERT(pObject->Entity == BLCSE_OUT);
  176. ASSERT(pObject->State == OpenOutBAwaitingEstablishment);
  177. H245TRACE(pObject->dwInst, 2,
  178. "Close (Bidirectional) to ASN; Channel=%d",
  179. pObject->Key);
  180. /* reset timer T103 */
  181. FsmStopTimer(pObject);
  182. /* Send Close Logical Channel to remote peer */
  183. lError = sendPDU(pObject->pInstance,pPdu);
  184. /* set timer T103 */
  185. pObject->State = OpenOutBAwaitingRelease;
  186. FsmStartTimer(pObject, T103OutExpiryF, uT103);
  187. return lError;
  188. }
  189. /*
  190. * NAME
  191. * t103ExpiryBAwaitingE - handle timeout for outstanding open bidirectional pdu
  192. *
  193. *
  194. * PARAMETERS
  195. * INPUT pObject pointer to a State Entity
  196. *
  197. * RETURN VALUE
  198. * error return codes defined in h245com.h
  199. */
  200. HRESULT t103ExpiryBAwaitingE(Object_t *pObject, PDU_t *pPdu)
  201. {
  202. PDU_t * pOut;
  203. HRESULT lError;
  204. ASSERT(pObject->Entity == BLCSE_OUT);
  205. ASSERT(pObject->State == OpenOutBAwaitingEstablishment);
  206. ASSERT(pPdu == NULL);
  207. H245TRACE(pObject->dwInst, 2, "H245_CONF_NEEDRSP_OPEN with a timer expiry to API->Channel=%d", pObject->Key);
  208. /* Send ERROR.indication(D) to client */
  209. pObject->State = OpenOutBReleased;
  210. H245FsmConfirm(NULL, H245_CONF_NEEDRSP_OPEN, pObject->pInstance, pObject->dwTransId, ERROR_D_TIMEOUT);
  211. /* Send Close Logical Channel (source:=lcse) to remote peer */
  212. pOut = (PDU_t *) MemAlloc(sizeof(PDU_t ));
  213. if (pOut == NULL)
  214. {
  215. H245TRACE(pObject->dwInst, 1,
  216. "t103ExpiryBAwaitingE: memory allocation failed");
  217. return H245_ERROR_NOMEM;
  218. }
  219. pdu_req_close_logical_channel(pOut, (WORD)pObject->Key, 1);
  220. lError = sendPDU(pObject->pInstance, pOut);
  221. MemFree(pOut);
  222. #if defined(SDL_COMPLIANT)
  223. /* Send RELEASE.indication to client */
  224. H245FsmIndication(pPdu, H245_IND_CLOSE, pObject->pInstance, 0, FSM_OK);
  225. #endif
  226. return lError;
  227. }
  228. /*
  229. * NAME
  230. * releaseReqBEstablished - API request to close channel in established state
  231. *
  232. * PARAMETERS
  233. * INPUT pObject pointer to a State Entity
  234. *
  235. * RETURN VALUE
  236. * error return codes defined in h245com.h
  237. */
  238. HRESULT releaseReqBEstablished(Object_t *pObject, PDU_t *pPdu)
  239. {
  240. HRESULT lError;
  241. ASSERT(pObject->Entity == BLCSE_OUT);
  242. ASSERT(pObject->State == OpenOutBEstablished);
  243. H245TRACE(pObject->dwInst, 2,
  244. "Send Close Bidirectional Channel to ASN; Channel=%d",
  245. pObject->Key);
  246. /* Send Close Logical Channel to remote peer */
  247. lError = sendPDU(pObject->pInstance,pPdu);
  248. /* set timer T103 */
  249. pObject->State = OpenOutBAwaitingRelease;
  250. FsmStartTimer(pObject, T103OutExpiryF, uT103);
  251. return lError;
  252. }
  253. /*
  254. * NAME
  255. * openChannelRejBEstablished - received open reject in established state
  256. *
  257. * PARAMETERS
  258. * INPUT pObject pointer to a State Entity
  259. *
  260. * RETURN VALUE
  261. * error return codes defined in h245com.h
  262. */
  263. HRESULT openChannelRejBEstablished(Object_t *pObject, PDU_t *pPdu)
  264. {
  265. ASSERT(pObject->Entity == BLCSE_OUT);
  266. ASSERT(pObject->State == OpenOutBEstablished);
  267. H245TRACE(pObject->dwInst, 2, "H245_CONF_NEEDRSP_OPEN with error B then with REJECT to API->Channel=%d", pObject->Key);
  268. pObject->State = OpenOutBReleased;
  269. #if defined(SDL_COMPLIANT)
  270. /* Send ERROR.indication(B) to client */
  271. H245FsmConfirm(pPdu, H245_CONF_NEEDRSP_OPEN, pObject->pInstance, pObject->dwTransId, ERROR_B_INAPPROPRIATE);
  272. #endif
  273. /* Send RELEASE.indication (SOURCE:=B-LCSE) to client */
  274. H245FsmConfirm(pPdu, H245_CONF_NEEDRSP_OPEN, pObject->pInstance, pObject->dwTransId, REJECT);
  275. return 0;
  276. }
  277. /*
  278. * NAME
  279. * closeChannelAckBEstablished - received close ack in established state
  280. *
  281. * PARAMETERS
  282. * INPUT pObject pointer to a State Entity
  283. *
  284. * RETURN VALUE
  285. * error return codes defined in h245com.h
  286. */
  287. HRESULT closeChannelAckBEstablished(Object_t *pObject, PDU_t *pPdu)
  288. {
  289. ASSERT(pObject->Entity == BLCSE_OUT);
  290. ASSERT(pObject->State == OpenOutBEstablished);
  291. H245TRACE(pObject->dwInst, 2,
  292. "H245_CONF_NEEDRSP_OPEN with error C then with REJECT to API; Channel=%d",
  293. pObject->Key);
  294. pObject->State = OpenOutBReleased;
  295. #if defined(SDL_COMPLIANT)
  296. /* Send ERROR.indication(C) to client */
  297. H245FsmConfirm(pPdu, H245_CONF_NEEDRSP_OPEN, pObject->pInstance, pObject->dwTransId, ERROR_C_INAPPROPRIATE);
  298. #endif
  299. /* Send RELEASE.indication to client */
  300. H245FsmConfirm(pPdu, H245_CONF_NEEDRSP_OPEN, pObject->pInstance, pObject->dwTransId, REJECT);
  301. return 0;
  302. }
  303. /*
  304. * NAME
  305. * closeChannelAckAwaitingR - received close ack in Awaiting Release state
  306. *
  307. * PARAMETERS
  308. * INPUT pObject pointer to a State Entity
  309. *
  310. * RETURN VALUE
  311. * error return codes defined in h245com.h
  312. */
  313. HRESULT closeChannelAckAwaitingR(Object_t *pObject, PDU_t *pPdu)
  314. {
  315. ASSERT(pObject->Entity == BLCSE_OUT);
  316. ASSERT(pObject->State == OpenOutBAwaitingRelease);
  317. H245TRACE(pObject->dwInst, 2,
  318. "H245_CONF_CLOSE with no error to API; Channel=%d",
  319. pObject->Key);
  320. /* reset timer T103 */
  321. FsmStopTimer(pObject);
  322. /* Send RELEASE.confirm to client */
  323. pObject->State = OpenOutBReleased;
  324. H245FsmConfirm(pPdu, H245_CONF_CLOSE, pObject->pInstance, pObject->dwTransId, FSM_OK);
  325. return 0;
  326. }
  327. /*
  328. * NAME
  329. * openChannelRejBAwaitingR - received open reject in awaiting release state
  330. *
  331. * PARAMETERS
  332. * INPUT pObject pointer to a State Entity
  333. *
  334. * RETURN VALUE
  335. * error return codes defined in h245com.h
  336. */
  337. HRESULT openChannelRejBAwaitingR(Object_t *pObject, PDU_t *pPdu)
  338. {
  339. return closeChannelAckAwaitingR(pObject, pPdu);
  340. }
  341. /*
  342. * NAME
  343. * t103ExpiryBAwaitingR - handle timer expiry in awaiting release
  344. *
  345. * PARAMETERS
  346. * INPUT pObject pointer to a State Entity
  347. *
  348. * RETURN VALUE
  349. * error return codes defined in h245com.h
  350. */
  351. HRESULT t103ExpiryBAwaitingR(Object_t *pObject, PDU_t *pPdu)
  352. {
  353. ASSERT(pObject->Entity == BLCSE_OUT);
  354. ASSERT(pObject->State == OpenOutBAwaitingRelease);
  355. ASSERT(pPdu == NULL);
  356. H245TRACE(pObject->dwInst, 2,
  357. "H245_CONF_CLOSE with timer expiry to API; Channel=%d",
  358. pObject->Key);
  359. /* Send ERROR.indication(D) to client */
  360. pObject->State = OpenOutBReleased;
  361. H245FsmConfirm(NULL, H245_CONF_CLOSE, pObject->pInstance, pObject->dwTransId, ERROR_D_TIMEOUT);
  362. #if defined(SDL_COMPLIANT)
  363. /* Send RELEASE.confirm to client */
  364. #endif
  365. return 0;
  366. }
  367. /*
  368. * NAME
  369. * establishReqAwaitingR - API open request in awaiting release state
  370. *
  371. * PARAMETERS
  372. * INPUT pObject pointer to a State Entity
  373. *
  374. * RETURN VALUE
  375. * error return codes defined in h245com.h
  376. */
  377. HRESULT establishReqAwaitingR(Object_t *pObject, PDU_t *pPdu)
  378. {
  379. HRESULT lError;
  380. ASSERT(pObject->Entity == BLCSE_OUT);
  381. ASSERT(pObject->State == OpenOutBAwaitingRelease);
  382. H245TRACE(pObject->dwInst, 2,
  383. "Send a (re) Open Bidirectional Channel to ASN; Channel=%d",
  384. pObject->Key);
  385. /* reset timer T103 */
  386. FsmStopTimer(pObject);
  387. /* Send Open Logical Channel to remote peer */
  388. lError = sendPDU(pObject->pInstance, pPdu);
  389. /* set timer T103 */
  390. pObject->State = OpenOutBAwaitingEstablishment;
  391. FsmStartTimer(pObject, T103OutExpiryF, uT103);
  392. return lError;
  393. }
  394. /***********************************************************************
  395. *
  396. * IN-COMING FINITE STATE MACHINE FUNCTIONS
  397. *
  398. ***********************************************************************/
  399. /*
  400. * NAME
  401. * openChannelBReleased - open channel received in idle state
  402. *
  403. *
  404. * PARAMETERS
  405. * INPUT pObject pointer to a State Entity
  406. *
  407. * RETURN VALUE
  408. * error return codes defined in h245com.h
  409. */
  410. HRESULT openChannelBReleased(Object_t *pObject, PDU_t *pPdu)
  411. {
  412. ASSERT(pObject->Entity == BLCSE_IN);
  413. ASSERT(pObject->State == OpenInBReleased);
  414. H245TRACE(pObject->dwInst, 2,
  415. "H245_IND_OPEN with no error to API; Channel=%d",
  416. pObject->Key);
  417. /* Send ESTABLISH.indication to client */
  418. pObject->State = OpenInBAwaitingEstablishment;
  419. H245FsmIndication(pPdu, H245_IND_OPEN, pObject->pInstance, 0, FSM_OK);
  420. return 0;
  421. }
  422. /*
  423. * NAME
  424. * closeChannelBReleased - close channel received in idle state
  425. *
  426. *
  427. * PARAMETERS
  428. * INPUT pObject pointer to a State Entity
  429. *
  430. * RETURN VALUE
  431. * error return codes defined in h245com.h
  432. */
  433. HRESULT closeChannelBReleased (Object_t *pObject, PDU_t *pPdu)
  434. {
  435. PDU_t * pOut;
  436. HRESULT lError;
  437. ASSERT(pObject->Entity == BLCSE_IN);
  438. ASSERT(pObject->State == OpenInBReleased);
  439. ASSERT(pObject->Key == pPdu->u.MltmdSystmCntrlMssg_rqst.u.closeLogicalChannel.forwardLogicalChannelNumber);
  440. H245TRACE(pObject->dwInst, 2,
  441. "Close Channel (Bidirectional) received while in Released state; Channel=%d",
  442. pObject->Key);
  443. H245TRACE(pObject->dwInst, 2,
  444. "Send Close Ack (Bidirectional) to ASN; Channel=%d",
  445. pObject->Key);
  446. /* Send Close Logical Channel Ack to remote peer */
  447. pOut = (PDU_t *) MemAlloc(sizeof(PDU_t));
  448. if (pOut == NULL)
  449. {
  450. H245TRACE(pObject->dwInst, 2,
  451. "closeChannelBReleased: memory allocation failed");
  452. return H245_ERROR_NOMEM;
  453. }
  454. pdu_rsp_close_logical_channel_ack(pOut, (WORD)pObject->Key);
  455. lError = sendPDU(pObject->pInstance, pOut);
  456. MemFree(pOut);
  457. return lError;
  458. }
  459. /*
  460. * NAME
  461. * establishResBAwaitingE - response to an open request with an ack
  462. *
  463. *
  464. * PARAMETERS
  465. * INPUT pObject pointer to a State Entity
  466. *
  467. * RETURN VALUE
  468. * error return codes defined in h245com.h
  469. */
  470. HRESULT establishResBAwaitingE (Object_t *pObject, PDU_t *pPdu)
  471. {
  472. HRESULT lError;
  473. ASSERT(pObject->Entity == BLCSE_IN);
  474. ASSERT(pObject->State == OpenInBAwaitingEstablishment);
  475. H245TRACE(pObject->dwInst, 2,
  476. "Send OpenAck (Bidirectional) to ASN module; Channel=%d",
  477. pObject->Key);
  478. /* Send Open Logical Channel Ack to remote peer */
  479. lError = sendPDU(pObject->pInstance, pPdu);
  480. /* set timer T103 */
  481. pObject->State = OpenInBAwaitingConfirmation;
  482. FsmStartTimer(pObject, T103InExpiryF, uT103);
  483. return lError;
  484. }
  485. /*
  486. * NAME
  487. * releaseReqBInAwaitingE - response to an open request with a reject
  488. *
  489. *
  490. * PARAMETERS
  491. * INPUT pObject pointer to a State Entity
  492. *
  493. * RETURN VALUE
  494. * error return codes defined in h245com.h
  495. */
  496. HRESULT releaseReqBInAwaitingE (Object_t *pObject, PDU_t *pPdu)
  497. {
  498. ASSERT(pObject->Entity == BLCSE_IN);
  499. ASSERT(pObject->State == OpenInBAwaitingEstablishment);
  500. H245TRACE(pObject->dwInst, 2, "Send OpenReject (Bidirectional) to SR module; Channel=%d", pObject->Key);
  501. /* Send Open Logical Channel Reject to remote peer */
  502. pObject->State = OpenInBReleased;
  503. return sendPDU(pObject->pInstance, pPdu);
  504. }
  505. /*
  506. * NAME
  507. * closeChannelBAwaitingE - received close channel in Awaiting establishment state
  508. *
  509. *
  510. * PARAMETERS
  511. * INPUT pObject pointer to a State Entity
  512. *
  513. * RETURN VALUE
  514. * error return codes defined in h245com.h
  515. */
  516. HRESULT closeChannelBAwaitingE(Object_t *pObject, PDU_t *pPdu)
  517. {
  518. PDU_t * pOut;
  519. HRESULT lError;
  520. ASSERT(pObject->Entity == BLCSE_IN);
  521. ASSERT(pObject->State == OpenInBAwaitingEstablishment);
  522. H245TRACE(pObject->dwInst, 2,
  523. "H245_IND_CLOSE with no error to API; Channel=%d",
  524. pObject->Key);
  525. /* Send Close Logical Channel Ack to remote peer */
  526. pOut = (PDU_t *) MemAlloc(sizeof(PDU_t ));
  527. if (pOut == NULL)
  528. {
  529. H245TRACE(pObject->dwInst, 2,
  530. "closeChannelBAwaitingE: memory allocation failed");
  531. return H245_ERROR_NOMEM;
  532. }
  533. pdu_rsp_close_logical_channel_ack(pOut, (WORD)pObject->Key);
  534. lError = sendPDU(pObject->pInstance, pOut);
  535. MemFree(pOut);
  536. /* Send RELEASE.indication to client */
  537. pObject->State = OpenInBReleased;
  538. H245FsmIndication(pPdu, H245_IND_CLOSE, pObject->pInstance, 0, FSM_OK);
  539. return lError;
  540. }
  541. /*
  542. * NAME
  543. * openChannelBAwaitingE - overriding open request
  544. *
  545. *
  546. * PARAMETERS
  547. * INPUT pObject pointer to a State Entity
  548. *
  549. * RETURN VALUE
  550. * error return codes defined in h245com.h
  551. */
  552. HRESULT openChannelBAwaitingE(Object_t *pObject, PDU_t *pPdu)
  553. {
  554. ASSERT(pObject->Entity == BLCSE_IN);
  555. ASSERT(pObject->State == OpenInBAwaitingEstablishment);
  556. H245TRACE(pObject->dwInst, 2, "Overriding H245_IND_OPEN to API; Channel=%d", pObject->Key);
  557. #if defined(SDL_COMPLIANT)
  558. /* Send RELEASE.indication (SOURCE:=USER) to client */
  559. H245FsmIndication(pPdu, H245_IND_CLOSE, pObject->pInstance, 0, FSM_OK);
  560. #endif
  561. /* Send ESTABLISH.indication to client */
  562. H245FsmIndication(pPdu, H245_IND_OPEN, pObject->pInstance, 0, FSM_OK);
  563. return 0;
  564. }
  565. /*
  566. * NAME
  567. * openChannelConfirmBAwaitingE - received open confirm while awaiting establishment
  568. *
  569. *
  570. * PARAMETERS
  571. * INPUT pObject pointer to a State Entity
  572. *
  573. * RETURN VALUE
  574. * error return codes defined in h245com.h
  575. */
  576. HRESULT openChannelConfirmBAwaitingE (Object_t *pObject, PDU_t *pPdu)
  577. {
  578. PDU_t * pOut;
  579. HRESULT lError;
  580. ASSERT(pObject->Entity == BLCSE_IN);
  581. ASSERT(pObject->State == OpenInBAwaitingEstablishment);
  582. H245TRACE(pObject->dwInst, 2,
  583. "H245_IND_OPEN_CONF with error F to API; Channel=%d",
  584. pObject->Key);
  585. /* Send ERROR.indication(F) to client */
  586. pObject->State = OpenInBReleased;
  587. H245FsmIndication(pPdu, H245_IND_OPEN_CONF, pObject->pInstance, 0, ERROR_E_INAPPROPRIATE);
  588. /* Send Close Logical Channel Ack to remote peer */
  589. pOut = (PDU_t *) MemAlloc(sizeof(PDU_t ));
  590. if (pOut == NULL)
  591. {
  592. H245TRACE(pObject->dwInst, 2,
  593. "openChannelConfirmBAwaitingE: memory allocation failed");
  594. return H245_ERROR_NOMEM;
  595. }
  596. pdu_rsp_close_logical_channel_ack(pOut, (WORD)pObject->Key);
  597. lError = sendPDU(pObject->pInstance, pOut);
  598. MemFree(pOut);
  599. #if defined(SDL_COMPLIANT)
  600. /* Send RELEASE.indication (SOURCE:=B-LCSE) to client */
  601. H245FsmIndication(pPdu, H245_IND_CLOSE, pObject->pInstance, 0, FSM_OK);
  602. #endif
  603. return lError;
  604. }
  605. /*
  606. * NAME
  607. * t103ExpiryBAwaitingC - timer expired waiting for open confirm
  608. *
  609. *
  610. * PARAMETERS
  611. * INPUT pObject pointer to a State Entity
  612. *
  613. * RETURN VALUE
  614. * error return codes defined in h245com.h
  615. */
  616. HRESULT t103ExpiryBAwaitingC(Object_t *pObject, PDU_t *pPdu)
  617. {
  618. PDU_t * pOut;
  619. HRESULT lError;
  620. ASSERT(pObject->Entity == BLCSE_IN);
  621. ASSERT(pObject->State == OpenInBAwaitingConfirmation);
  622. ASSERT(pPdu == NULL);
  623. H245TRACE(pObject->dwInst, 2,
  624. "Timer T103 expired while waiting for OpenConfirm for OpenAck");
  625. /* Send ERROR.indication(G) to client */
  626. pObject->State = OpenInBReleased;
  627. H245FsmIndication(NULL, H245_IND_OPEN_CONF, pObject->pInstance, pObject->dwTransId, ERROR_F_TIMEOUT);
  628. /* Send Close Logical Channel Ack to remote peer */
  629. pOut = (PDU_t *) MemAlloc(sizeof(PDU_t ));
  630. if (pOut == NULL)
  631. {
  632. H245TRACE(pObject->dwInst, 2,
  633. "t103ExpiryBAwaitingC: memory allocation failed");
  634. return H245_ERROR_NOMEM;
  635. }
  636. pdu_rsp_close_logical_channel_ack(pOut, (WORD)pObject->Key);
  637. lError = sendPDU(pObject->pInstance, pOut);
  638. MemFree(pOut);
  639. #if defined(SDL_COMPLIANT)
  640. /* Send RELEASE.indication to client */
  641. H245FsmIndication(pPdu, H245_IND_CLOSE, pObject->pInstance, 0, FSM_OK);
  642. #endif
  643. return lError;
  644. }
  645. /*
  646. * NAME
  647. * openChannelConfirmBAwaitingC - received open confirm while awaiting confirmation
  648. *
  649. *
  650. * PARAMETERS
  651. * INPUT pObject pointer to a State Entity
  652. *
  653. * RETURN VALUE
  654. * error return codes defined in h245com.h
  655. */
  656. HRESULT openChannelConfirmBAwaitingC (Object_t *pObject, PDU_t *pPdu)
  657. {
  658. ASSERT(pObject->Entity == BLCSE_IN);
  659. ASSERT(pObject->State == OpenInBAwaitingConfirmation);
  660. H245TRACE(pObject->dwInst, 2,
  661. "H245_IND_OPEN_CONF with no errors; Channel=%d",
  662. pObject->Key);
  663. /* reset timer T103 */
  664. FsmStopTimer(pObject);
  665. /* Send ESTABLISH.confirm to client */
  666. pObject->State = OpenInBEstablished;
  667. H245FsmIndication(pPdu, H245_IND_OPEN_CONF, pObject->pInstance, pObject->dwTransId, FSM_OK);
  668. return 0;
  669. }
  670. /*
  671. * NAME
  672. * closeChannelBAwaitingC - received close channel while awaiting confirmation
  673. *
  674. *
  675. * PARAMETERS
  676. * INPUT pObject pointer to a State Entity
  677. *
  678. * RETURN VALUE
  679. * error return codes defined in h245com.h
  680. */
  681. HRESULT closeChannelBAwaitingC (Object_t *pObject, PDU_t *pPdu)
  682. {
  683. PDU_t * pOut;
  684. HRESULT lError;
  685. ASSERT(pObject->Entity == BLCSE_IN);
  686. ASSERT(pObject->State == OpenInBAwaitingConfirmation);
  687. H245TRACE(pObject->dwInst, 2,
  688. "H245_IND_CLOSE with no error; Channel=%d",
  689. pObject->Key);
  690. H245TRACE(pObject->dwInst, 2,
  691. "Send Close Ack (Bidirectional) to ASN; Channel=%d",
  692. pObject->Key);
  693. /* reset timer T103 */
  694. FsmStopTimer(pObject);
  695. /* Send Close Logical Channel Ack to remote peer */
  696. pOut = (PDU_t *) MemAlloc(sizeof(PDU_t));
  697. if (pOut == NULL)
  698. {
  699. H245TRACE(pObject->dwInst, 2,
  700. "closeChannelBAwaitingC: memory allocation failed");
  701. return H245_ERROR_NOMEM;
  702. }
  703. pdu_rsp_close_logical_channel_ack(pOut, (WORD)pObject->Key);
  704. lError = sendPDU(pObject->pInstance, pOut);
  705. MemFree(pOut);
  706. /* Send RELEASE.indication to client */
  707. pObject->State = OpenInBReleased;
  708. H245FsmIndication(pPdu, H245_IND_CLOSE, pObject->pInstance, 0, FSM_OK);
  709. return lError;
  710. }
  711. /*
  712. * NAME
  713. * openChannelBAwaitingC - received open channel while awaiting confirmation
  714. *
  715. *
  716. * PARAMETERS
  717. * INPUT pObject pointer to a State Entity
  718. *
  719. * RETURN VALUE
  720. * error return codes defined in h245com.h
  721. */
  722. HRESULT openChannelBAwaitingC (Object_t *pObject, PDU_t *pPdu)
  723. {
  724. ASSERT(pObject->Entity == BLCSE_IN);
  725. ASSERT(pObject->State == OpenInBAwaitingConfirmation);
  726. H245TRACE(pObject->dwInst, 2, "Overriding H245_IND_OPEN to API; Channel=%d", pObject->Key);
  727. /* reset timer T103 */
  728. FsmStopTimer(pObject);
  729. pObject->State = OpenInBAwaitingEstablishment;
  730. #if defined(SDL_COMPLIANT)
  731. /* Send RELEASE.indication (SOURCE:=USER) to client */
  732. H245FsmIndication(pPdu, H245_IND_CLOSE, pObject->pInstance, 0, FSM_OK);
  733. #endif
  734. /* Send ESTABLISH.indication to client */
  735. H245FsmIndication(pPdu, H245_IND_OPEN, pObject->pInstance, 0, FSM_OK);
  736. return 0;
  737. }
  738. /*
  739. * NAME
  740. * closeChannelBEstablished - received close channel while in established state
  741. *
  742. *
  743. * PARAMETERS
  744. * INPUT pObject pointer to a State Entity
  745. *
  746. * RETURN VALUE
  747. * error return codes defined in h245com.h
  748. */
  749. HRESULT closeChannelBEstablished(Object_t *pObject, PDU_t *pPdu)
  750. {
  751. PDU_t * pOut;
  752. HRESULT lError;
  753. ASSERT(pObject->Entity == BLCSE_IN);
  754. ASSERT(pObject->State == OpenInBEstablished);
  755. H245TRACE(pObject->dwInst, 2,
  756. "H245_IND_CLOSE with no error up to API; Channel=%d",
  757. pObject->Key);
  758. /* Send Close Logical Channel Ack to remote peer */
  759. pOut = (PDU_t *) MemAlloc(sizeof(PDU_t ));
  760. if (pOut == NULL)
  761. {
  762. H245TRACE(pObject->dwInst, 2,
  763. "closeChannelBEstablished: memory allocation failed");
  764. return H245_ERROR_NOMEM;
  765. }
  766. pdu_rsp_close_logical_channel_ack(pOut, (WORD)pObject->Key);
  767. lError = sendPDU(pObject->pInstance, pOut);
  768. MemFree(pOut);
  769. /* Send RELEASE.indication to client */
  770. pObject->State = OpenInBReleased;
  771. H245FsmIndication(pPdu, H245_IND_CLOSE, pObject->pInstance, 0, FSM_OK);
  772. return lError;
  773. }
  774. /*
  775. * NAME
  776. * openChannelBEstablished - received open channel while in established state
  777. *
  778. *
  779. * PARAMETERS
  780. * INPUT pObject pointer to a State Entity
  781. *
  782. * RETURN VALUE
  783. * error return codes defined in h245com.h
  784. */
  785. HRESULT openChannelBEstablished(Object_t *pObject, PDU_t *pPdu)
  786. {
  787. ASSERT(pObject->Entity == BLCSE_IN);
  788. ASSERT(pObject->State == OpenInBEstablished);
  789. H245TRACE(pObject->dwInst, 2, "Overriding H245_IND_OPEN to API; Channel=%d", pObject->Key);
  790. pObject->State = OpenInBAwaitingEstablishment;
  791. #if defined(SDL_COMPLIANT)
  792. /* Send RELEASE.indication to client */
  793. H245FsmIndication(pPdu, H245_IND_CLOSE, pObject->pInstance, 0, FSM_OK);
  794. #endif
  795. /* Send ESTABLISH.indication to client*/
  796. H245FsmIndication(pPdu, H245_IND_OPEN, pObject->pInstance, 0, FSM_OK);
  797. return 0;
  798. }
  799.