Source code of Windows XP (NT5)
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.

1457 lines
28 KiB

  1. /*++
  2. Copyright (c) 1998 - 2000 Microsoft Corporation
  3. Module Name:
  4. cbridge.cpp
  5. Abstract:
  6. Contains the call bridge class declaration.
  7. Associated Q931 and H245 protocol stack related classes
  8. and constants are also declared here.
  9. Revision History:
  10. 1. created
  11. Byrisetty Rajeev (rajeevb) 12-Jun-1998
  12. 2. moved several inline functions to q931.cpp, h245.cpp
  13. (rajeevb, 21-Aug-1998)
  14. --*/
  15. #ifndef __h323ics_call_bridge_h
  16. #define __h323ics_call_bridge_h
  17. /*---------------------------------------------------
  18. DESIGN OVERVIEW:
  19. The CALL_BRIDGE completely describes an H.323 call being proxied. The
  20. proxy receives a call from the source and then originates a call
  21. to the destination. Each of these calls is represented by an H323_STATE.
  22. PDUs received on one call are processed and passed on to the other call.
  23. A source leads an H.323 call with Q.931. The SETUP PDU contains info for
  24. the proxy to locate the destination. The two end points exchange their
  25. H.245 channel addresses at this stage. This portion of the call is
  26. encapsulated in Q931_INFO. *The proxy must replace any end-point address
  27. and port with its own address and port to protect internal corporate
  28. addresses and retain control of the multi-layered H.323 call setup*.
  29. The H.245 channel is used to exchange end-point capabilities. This
  30. information is of no significance today (in future, security exchanges
  31. etc. may be done). H245_INFO represents an H.245 channel end-point. We
  32. merely pass on the source/destination PDUs.
  33. The H.245 channel is used to maintain (open, close) logical channels.
  34. The logical channel messages exchange end-point address and port to
  35. send audio/video media to. These addresses/ports are replaced with the
  36. proxy's address/ports. Each logical channel is represented by a
  37. LOGICAL_CHANNEL instance. An H245_INFO instance contains an array of
  38. LOGICAL_CHANNELs which were originated from the corresponding client
  39. end-point. Hence, all of the logical channel related state is contained
  40. in a single LOGICAL_CHANNEL instance (unlike two instances for the
  41. Q931_INFO and H245_INFO which have a SOURCE and DEST instance).
  42. Audio/video media are sent in RTP streams (with RTCP for control info).
  43. The proxy uses NAT to forward these packets after replacing the
  44. source and destination address/port.
  45. CLASS HIERARCHY :
  46. The Q931_INFO and H323_INFO classes need to make overlapped calls to
  47. accept connections, send and receive data. The OVERLAPPED_PROCESSOR
  48. provides call back methods to the event manager and completely
  49. encapsulates the socket representing a connection. Both Q931_INFO and
  50. H323_INFO are derived from it and pass themselves as OVERLAPPED_PROCESSOR
  51. to the event manager while registering callbacks.
  52. When making an overlapped call, a context is also passed in. This context
  53. enables the caller to retrieve relevant information when the corresponding
  54. callback is received. The EVENT_MANAGER_CONTEXT provides the base class
  55. abstraction for the callback context. Q931/H245 Source/Dest instances
  56. derive their own contexts from this base class (for storing their state).
  57. The Q931_INFO and H323_INFO classes need to create and cancel timers. The
  58. TIMER_PROCESSOR provides call back methods to the event manager and
  59. helper methods for this.
  60. Both SOURCE and DEST versions are derived from the base classes for
  61. Q931_INFO, H245_INFO and H323_STATE. While the states and transitions
  62. for H.245 (for the proxy) are more or less symmetric, those for Q.931
  63. are quite different. A SOURCE_H323_STATE contains a SOURCE_Q931_INFO and
  64. a SOURCE_H245_INFO (similarly for the DEST version).
  65. A CALL_BRIDGE contains a SOURCE_H323_STATE and a DEST_H323_STATE. Hence
  66. all the Q931, H245 and generic data is stored in a single memory block for
  67. the CALL_BRIDGE. Additional memory is needed for the LOGICAL_CHANNEL_ARRAY
  68. (one per H245_INFO instance) and each of the LOGICAL_CHANNEL instances. There
  69. might be a better way to allocate this memory to reduce memory allocations/freeing.
  70. A single critical section protects all accesses to a CALL_BRIDGE and
  71. is acquired inside the CALL_BRIDGE method being called. The CALL_BRIDGE
  72. also destroys itself when it is appropriate and releases the critical
  73. section before doing so (The CALL_BRIDGE cannot get called at such a point)
  74. SCALABILITY ISSUES :
  75. 1. We currently use a single critical section per instance of the CALL_BRIDGE.
  76. This is clearly not scalable to a large number of connections. We plan
  77. to use dynamic critical sections for this. This involves using a pool of
  78. critical sections and a critical section from the pool is assigned to
  79. a CALL_BRIDGE instance dynamically.
  80. 2. We currently need 4 ports (RTP/RTCP send/receive) for each of the two
  81. calls being bridged in a CALL_BRIDGE for a total of 8 ports per
  82. proxied call. This also means that we would need a socket for each of
  83. the ports to actually reserve the port. The following approaches will
  84. make this scalable -
  85. * AjayCh is talking with NKSrin for an IOCTL to the TCP/IP stack for
  86. reserving a pool of ports at a time (just like memory). This would
  87. thus preclude any need for keeeping a socket open just for reserving
  88. a port and reduce the number of calls needed to do so.
  89. * The TCP/IP stack treats ports as global objects and would make the
  90. reserved port unavailable on ALL interfaces. However, a port can be
  91. reused several times as long as it satisfies the unique 5tuple
  92. requirement for sockets
  93. (protocol, src addr, src port, dest addr, dest port). We can reuse
  94. the allocated port in the following ways -
  95. ** for each interface on the machine.
  96. ** for each different remote end-point address/port pairs
  97. ---------------------------------------------------*/
  98. /*---------------------------------------------------
  99. NOTES:
  100. 1. Typically, constructors are avoided and replaced by Init fns as
  101. they can return error codes.
  102. 2. The attempt is to convert all error codes to HRESULTs as early in
  103. the execution as possible.
  104. 3. Separate heaps are used for different classes. This reduces heap
  105. contention as well as fragmentation. This is done by over-riding
  106. new/delete.
  107. 4. inline fns are used where
  108. - a virtual fn is not needed
  109. - amount of code is small AND/OR
  110. - number of calls to the fn is few (1-2).
  111. since some inline fn definitions involve calling other inline
  112. functions, there are several dependencies among the classes
  113. declared below. This forces declaration of all these classes
  114. in a single header file.
  115. 5. We need to count all outstanding overlapped calls and make sure
  116. there are none before destroying a CALL_BRIDGE instance (to avoid
  117. avs when the event manager calls back and to release the associated
  118. contexts). We try to keep track of all this inside the CALL_BRIDGE
  119. centrally.
  120. 6. We try to maintain the abstraction of two separate calls being bridged
  121. as far as possible. As a convention, methods processing PDUs/messages
  122. directly received from a socket start with "Handle". These methods pass
  123. on the received PDU/message to the "other" H245 or Q931 instance (for the
  124. bridged call). The "other" methods which process these start with
  125. "Process". They decide whether or not the PDU/message must be sent to
  126. the other end-point.
  127. 7. NAT has problems with unidirectional redirects. If a unidirectional
  128. redirect X is setup and we later try to setup a unidirectional redirect
  129. Y in the reverse direction that shares all the parameters of X, NAT
  130. exhibits undefined behaviour. This is solved by the following steps -
  131. * We only setup unidirectional redirects. Thus, RTCP requires 2
  132. separate redirects.
  133. * Logical channel signaling only exchanges addresses/ports to receive
  134. media on. We exploit that by using different ports for sending and
  135. receiving media.
  136. 8. We have tried to restrict the use of virtual functions and use inline
  137. functions wherever possible. Proliferation of short virtual fns can
  138. result in performance problems.
  139. 9. Overlapped callbacks pass in H245, Q931 pdus that were read along
  140. with the corresponding context. We follow a flexible convention for
  141. freeing them -
  142. * if the callback or any called method frees them or reuses
  143. them for sending out the opposite end, it sets them to null.
  144. * if not set to null on return, the event manager which called the
  145. callback frees these.
  146. 10. Currently all state transitions are in code (ex.
  147. if current state == b1, current state = b2 etc.). Its usually
  148. better to do this in data (ex. an array {current state, new state}).
  149. However, I haven't been able to figure out an appropriate model for
  150. this so far.
  151. 11. Commenting doesn't have the NT standard blocks explaining each fn,
  152. parameters, return code etc. I have instead, written a small block of
  153. comments at the top of the function when appropriate. I have also tried
  154. to comment logical blocks of code.
  155. ---------------------------------------------------*/
  156. #include "sockinfo.h"
  157. #include "q931info.h"
  158. #include "logchan.h"
  159. #include "h245info.h"
  160. #include "ipnatapi.h"
  161. // Call state description - one side of a call
  162. class H323_STATE
  163. {
  164. public:
  165. inline
  166. H323_STATE (
  167. void
  168. );
  169. // initialize when a tcp connection is established on a listening
  170. // interface
  171. inline
  172. void
  173. Init (
  174. IN CALL_BRIDGE &CallBridge,
  175. IN Q931_INFO &Q931Info,
  176. IN H245_INFO &H245Info,
  177. IN BOOL fIsSource // source call state iff TRUE
  178. );
  179. inline
  180. CALL_BRIDGE &
  181. GetCallBridge (
  182. void
  183. );
  184. inline
  185. BOOL
  186. IsSourceCall (
  187. void
  188. );
  189. inline
  190. Q931_INFO &
  191. GetQ931Info (
  192. void
  193. );
  194. inline
  195. H245_INFO &
  196. GetH245Info (
  197. void
  198. );
  199. inline
  200. H323_STATE &
  201. GetOtherH323State (
  202. void
  203. );
  204. protected:
  205. // it belongs to this call bridge
  206. CALL_BRIDGE *m_pCallBridge;
  207. // TRUE iff its the source call state
  208. BOOL m_fIsSourceCall;
  209. // contains the Q931 tcp info, timeout, remote end info
  210. Q931_INFO *m_pQ931Info;
  211. // contains the H.245 tcp info, timeout, remote end info
  212. H245_INFO *m_pH245Info;
  213. };
  214. /*++
  215. Routine Description:
  216. Constructor for H323_STATE class
  217. Arguments:
  218. None
  219. Return Values:
  220. None
  221. Notes:
  222. --*/
  223. inline
  224. H323_STATE::H323_STATE (
  225. void
  226. )
  227. : m_pCallBridge (
  228. NULL
  229. ),
  230. m_fIsSourceCall (
  231. FALSE
  232. ),
  233. m_pQ931Info(
  234. NULL
  235. ),
  236. m_pH245Info(
  237. NULL)
  238. {
  239. } // H323_STATE::H323_STATE
  240. inline
  241. void
  242. H323_STATE::Init (
  243. IN CALL_BRIDGE &CallBridge,
  244. IN Q931_INFO &Q931Info,
  245. IN H245_INFO &H245Info,
  246. IN BOOL fIsSource
  247. )
  248. /*++
  249. Routine Description:
  250. Initializes an instance of H323_STATE class
  251. Arguments:
  252. CallBridge -- parent call-bridge
  253. Q931Info -- contained Q931 information
  254. H245Info -- contained H245 information
  255. fIsSource -- TRUE if this is source call state, FALSE otherwise
  256. Return Values:
  257. None
  258. Notes:
  259. --*/
  260. {
  261. _ASSERTE(NULL == m_pCallBridge);
  262. _ASSERTE(NULL == m_pQ931Info);
  263. _ASSERTE(NULL == m_pH245Info);
  264. m_pCallBridge = &CallBridge;
  265. m_pQ931Info = &Q931Info;
  266. m_pH245Info = &H245Info;
  267. m_fIsSourceCall = fIsSource;
  268. } // H323_STATE::Init
  269. inline
  270. CALL_BRIDGE &
  271. H323_STATE::GetCallBridge (
  272. void
  273. )
  274. /*++
  275. Routine Description:
  276. Accessor method
  277. Arguments:
  278. None
  279. Return Values:
  280. Reference to the parent call-bridge
  281. Notes:
  282. --*/
  283. {
  284. _ASSERTE(NULL != m_pCallBridge);
  285. return *m_pCallBridge;
  286. } // H323_STATE::GetCallBridge
  287. inline
  288. BOOL
  289. H323_STATE::IsSourceCall (
  290. void
  291. )
  292. /*++
  293. Routine Description:
  294. Accessor method
  295. Arguments:
  296. None
  297. Return Values:
  298. Indication of whether this is a source
  299. call state, or destination call state
  300. Notes:
  301. --*/
  302. {
  303. return m_fIsSourceCall;
  304. } // H323_STATE::IsSourceCall
  305. inline
  306. Q931_INFO &
  307. H323_STATE::GetQ931Info (
  308. void
  309. )
  310. /*++
  311. Routine Description:
  312. Accessor method
  313. Arguments:
  314. None
  315. Return Values:
  316. Reference to the contained Q.931 information
  317. Notes:
  318. --*/
  319. {
  320. _ASSERTE(NULL != m_pQ931Info);
  321. return *m_pQ931Info;
  322. } // H323_STATE::GetQ931Info
  323. inline
  324. H245_INFO &
  325. H323_STATE::GetH245Info (
  326. void
  327. )
  328. /*++
  329. Routine Description:
  330. Accessor method
  331. Arguments:
  332. None
  333. Return Values:
  334. Reference to the contained H.245 information
  335. Notes:
  336. --*/
  337. {
  338. _ASSERTE(NULL != m_pH245Info);
  339. return *m_pH245Info;
  340. } // H323_STATE::GetH245Info
  341. // Source call state description - one side of a call
  342. class SOURCE_H323_STATE :
  343. public H323_STATE
  344. {
  345. public:
  346. // initialize when a tcp connection is established on a listening
  347. // interface
  348. inline
  349. void
  350. Init (
  351. IN CALL_BRIDGE &CallBridge
  352. );
  353. inline
  354. SOURCE_Q931_INFO &
  355. GetSourceQ931Info (
  356. void
  357. );
  358. inline
  359. SOURCE_H245_INFO &
  360. GetSourceH245Info (
  361. void
  362. );
  363. inline
  364. DEST_H323_STATE &
  365. GetDestH323State (
  366. void
  367. );
  368. protected:
  369. // contains the source Q931 tcp info, timeout, remote end info
  370. SOURCE_Q931_INFO m_SourceQ931Info;
  371. // contains the H.245 tcp info, timeout, remote end info
  372. SOURCE_H245_INFO m_SourceH245Info;
  373. };
  374. inline
  375. void
  376. SOURCE_H323_STATE::Init (
  377. IN CALL_BRIDGE &CallBridge
  378. )
  379. /*++
  380. Routine Description:
  381. Initialize H323 state when a tcp connection is established
  382. on a listening interface
  383. Arguments:
  384. CallBridge -- "parent" call-bridge
  385. Return Values:
  386. None
  387. Notes:
  388. --*/
  389. {
  390. m_SourceQ931Info.Init(*this);
  391. m_SourceH245Info.Init(*this);
  392. H323_STATE::Init(
  393. CallBridge,
  394. m_SourceQ931Info,
  395. m_SourceH245Info,
  396. TRUE
  397. );
  398. } // SOURCE_H323_STATE::Init
  399. inline
  400. SOURCE_Q931_INFO &
  401. SOURCE_H323_STATE::GetSourceQ931Info (
  402. void
  403. )
  404. /*++
  405. Routine Description:
  406. Accessor method
  407. Arguments:
  408. None
  409. Return Values:
  410. None
  411. Notes:
  412. Retrieves a reference to the contained Q.931 information
  413. --*/
  414. {
  415. return m_SourceQ931Info;
  416. } // SOURCE_H323_STATE::GetSourceQ931Info
  417. inline
  418. SOURCE_H245_INFO &
  419. SOURCE_H323_STATE::GetSourceH245Info (
  420. void
  421. )
  422. /*++
  423. Routine Description:
  424. Accessor method
  425. Arguments:
  426. None
  427. Return Values:
  428. None
  429. Notes:
  430. Retrieves a reference to the contained H.245 information
  431. --*/
  432. {
  433. return m_SourceH245Info;
  434. } // SOURCE_H323_STATE::GetSourceH245Info
  435. // Destination call state description - one side of a call
  436. class DEST_H323_STATE :
  437. public H323_STATE
  438. {
  439. public:
  440. inline
  441. DEST_H323_STATE (
  442. void
  443. );
  444. // initialize when a tcp connection is established on a listening
  445. // interface
  446. inline
  447. HRESULT Init (
  448. IN CALL_BRIDGE &CallBridge
  449. );
  450. inline
  451. DEST_Q931_INFO &
  452. GetDestQ931Info (
  453. void
  454. );
  455. inline
  456. DEST_H245_INFO &
  457. GetDestH245Info (
  458. void
  459. );
  460. inline
  461. SOURCE_H323_STATE &
  462. GetSourceH323State (
  463. void);
  464. protected:
  465. // contains the destination Q931 tcp info, timeout, remote end info
  466. DEST_Q931_INFO m_DestQ931Info;
  467. // contains the H.245 tcp info, timeout, remote end info
  468. DEST_H245_INFO m_DestH245Info;
  469. };
  470. inline
  471. DEST_H323_STATE::DEST_H323_STATE (
  472. void
  473. )
  474. /*++
  475. Routine Description:
  476. Constructor for DEST_H323_STATE class
  477. Arguments:
  478. None
  479. Return Values:
  480. None
  481. Notes:
  482. --*/
  483. {
  484. } // DEST_H323_STATE::DEST_H323_STATE
  485. inline
  486. HRESULT
  487. DEST_H323_STATE::Init (
  488. IN CALL_BRIDGE &CallBridge
  489. )
  490. /*++
  491. Routine Description:
  492. Initialize instance of DEST_H323_STATE when a tcp connection
  493. is established on a listening interface
  494. Arguments:
  495. CallBridge -- reference to the "parent" call-bridge
  496. Return Values:
  497. S_OK if successful
  498. Otherwise passes through status code of initializing contained sockets
  499. Notes:
  500. --*/
  501. {
  502. HRESULT HResult = m_DestQ931Info.Init(*this);
  503. if (FAILED(HResult))
  504. {
  505. return HResult;
  506. }
  507. _ASSERTE(S_FALSE != HResult);
  508. m_DestH245Info.Init(*this);
  509. H323_STATE::Init(
  510. CallBridge,
  511. m_DestQ931Info,
  512. m_DestH245Info,
  513. FALSE
  514. );
  515. return S_OK;
  516. } // DEST_H323_STATE::Init (
  517. inline
  518. DEST_Q931_INFO &
  519. DEST_H323_STATE::GetDestQ931Info (
  520. void
  521. )
  522. /*++
  523. Routine Description:
  524. Accessor method
  525. Arguments:
  526. None
  527. Return Values:
  528. Retrieves reference to the contained Q.931 information
  529. Notes:
  530. --*/
  531. {
  532. return m_DestQ931Info;
  533. } // DEST_H323_STATE::GetDestQ931Info (
  534. inline
  535. DEST_H245_INFO &
  536. DEST_H323_STATE::GetDestH245Info (
  537. void
  538. )
  539. /*++
  540. Routine Description:
  541. Accessor method
  542. Arguments:
  543. None
  544. Return Values:
  545. Retrieves reference to the contained H.245 information
  546. Notes:
  547. --*/
  548. {
  549. return m_DestH245Info;
  550. } // DEST_H323_STATE::GetDestH245Info
  551. // The CALL_BRIDGE represents an active call that is being proxied.
  552. // Number of outstanding i/os is stored only in the call bridge instance
  553. // it is only needed to determine when the call bridge instance can safely
  554. // be shut down
  555. class CALL_BRIDGE :
  556. public SIMPLE_CRITICAL_SECTION_BASE,
  557. public LIFETIME_CONTROLLER
  558. {
  559. public:
  560. enum STATE {
  561. STATE_NONE,
  562. STATE_CONNECTED,
  563. STATE_TERMINATED,
  564. };
  565. protected:
  566. STATE State;
  567. // call state info for the source side. i.e. the side which
  568. // sends the Setup packet
  569. SOURCE_H323_STATE m_SourceH323State;
  570. SOCKADDR_IN SourceAddress; // address of the source (originator of the connection)
  571. DWORD SourceInterfaceAddress; // address of the interface on which the connection was accepted, host order
  572. // call state info for the destination side. i.e. the recipient
  573. // of the setup packet
  574. DEST_H323_STATE m_DestH323State;
  575. SOCKADDR_IN DestinationAddress; // address of the destination (recipient of the connection)
  576. public:
  577. DWORD DestinationInterfaceAddress; // address of the interface to which the connection is destined, host order
  578. private:
  579. HRESULT
  580. InitializeLocked (
  581. IN SOCKET IncomingSocket,
  582. IN SOCKADDR_IN * LocalAddress,
  583. IN SOCKADDR_IN * RemoteAddress,
  584. IN NAT_KEY_SESSION_MAPPING_EX_INFORMATION * RedirectInformation
  585. );
  586. public:
  587. CALL_BRIDGE (
  588. IN NAT_KEY_SESSION_MAPPING_EX_INFORMATION * RedirectInformation
  589. );
  590. ~CALL_BRIDGE (
  591. void
  592. );
  593. // initialize member call state instances
  594. HRESULT
  595. Initialize (
  596. IN SOCKET IncomingSocket,
  597. IN SOCKADDR_IN * LocalAddress,
  598. IN SOCKADDR_IN * RemoteAddress ,
  599. IN NAT_KEY_SESSION_MAPPING_EX_INFORMATION * RedirectInformation
  600. );
  601. DWORD
  602. GetSourceInterfaceAddress (
  603. void
  604. ) const;
  605. VOID
  606. CALL_BRIDGE::GetSourceAddress (
  607. OUT SOCKADDR_IN* ReturnSourceAddress
  608. );
  609. void
  610. GetDestinationAddress (
  611. OUT SOCKADDR_IN * ReturnDestinationAddress
  612. );
  613. // this function may be called by any thread that holds a safe,
  614. // counted reference to this object.
  615. void
  616. TerminateExternal (
  617. void
  618. );
  619. BOOL
  620. IsConnectionThrough (
  621. IN DWORD InterfaceAddress // host order
  622. );
  623. void
  624. OnInterfaceShutdown (
  625. void
  626. );
  627. // private:
  628. friend class Q931_INFO;
  629. friend class H245_INFO;
  630. friend class SOURCE_H245_INFO;
  631. friend class DEST_H245_INFO;
  632. friend class LOGICAL_CHANNEL;
  633. inline
  634. BOOL
  635. IsTerminated (
  636. void
  637. );
  638. inline
  639. BOOL
  640. IsTerminatedExternal (
  641. void
  642. );
  643. inline
  644. void
  645. CancelAllTimers (
  646. void
  647. );
  648. void
  649. TerminateCallOnReleaseComplete (
  650. void
  651. );
  652. void
  653. Terminate (
  654. void
  655. );
  656. inline
  657. SOURCE_H323_STATE &
  658. GetSourceH323State (
  659. void
  660. );
  661. inline
  662. DEST_H323_STATE &
  663. GetDestH323State (
  664. void
  665. );
  666. };
  667. inline
  668. void
  669. CALL_BRIDGE::CancelAllTimers (
  670. void
  671. )
  672. /*++
  673. Routine Description:
  674. Cancels outstanding timers for all H.245 logical channels and Q.931 connections
  675. Arguments:
  676. None
  677. Return Values:
  678. None
  679. Notes:
  680. --*/
  681. {
  682. m_SourceH323State.GetQ931Info().TimprocCancelTimer();
  683. m_DestH323State.GetQ931Info().TimprocCancelTimer();
  684. GetSourceH323State().GetH245Info().GetLogicalChannelArray().CancelAllTimers();
  685. GetDestH323State().GetH245Info().GetLogicalChannelArray().CancelAllTimers();
  686. } // CALL_BRIDGE::CancelAllTimers
  687. inline
  688. BOOL
  689. CALL_BRIDGE::IsTerminated (
  690. void
  691. )
  692. /*++
  693. Routine Description:
  694. Checks whether the instance is terminated.
  695. Arguments:
  696. None
  697. Return Values:
  698. TRUE - if the instance is terminated
  699. FALSE - if the instance is not terminated
  700. Notes:
  701. 1. To be called for locked instance only
  702. --*/
  703. {
  704. return State == STATE_TERMINATED;
  705. } // CALL_BRIDGE::IsTerminated
  706. inline
  707. BOOL
  708. CALL_BRIDGE::IsTerminatedExternal (
  709. void
  710. )
  711. /*++
  712. Routine Description:
  713. Checks whether the instance is terminated
  714. Arguments:
  715. None
  716. Return Values:
  717. TRUE - if the instance is terminated
  718. FALSE - if the instance is not terminated
  719. Notes:
  720. --*/
  721. {
  722. BOOL IsCallBridgeTerminated = TRUE;
  723. Lock ();
  724. IsCallBridgeTerminated = IsTerminated ();
  725. Unlock ();
  726. return IsCallBridgeTerminated;
  727. } // CALL_BRIDGE::IsTerminatedExternal
  728. inline
  729. SOURCE_H323_STATE &
  730. CALL_BRIDGE::GetSourceH323State (
  731. void
  732. )
  733. /*++
  734. Routine Description:
  735. Accessor function
  736. Arguments:
  737. None
  738. Return Values:
  739. Retrieves reference to the source H.323 state
  740. Notes:
  741. --*/
  742. {
  743. return m_SourceH323State;
  744. } // CALL_BRIDGE::GetSourceH323State
  745. inline
  746. DEST_H323_STATE &
  747. CALL_BRIDGE::GetDestH323State (
  748. void
  749. )
  750. /*++
  751. Routine Description:
  752. Accessor function
  753. Arguments:
  754. None
  755. Return Values:
  756. Retrieves reference to the destination H.323 state
  757. Notes:
  758. --*/
  759. {
  760. return m_DestH323State;
  761. } // CALL_BRIDGE::GetDestH323State
  762. ///////////////////////////////////////////////////////////////////////////////
  763. // //
  764. // Misc. inline functions that require declarations //
  765. // which are made after them //
  766. // //
  767. ///////////////////////////////////////////////////////////////////////////////
  768. //
  769. // OVERLAPPED_PROCESSOR
  770. inline
  771. CALL_BRIDGE &
  772. OVERLAPPED_PROCESSOR::GetCallBridge (
  773. void
  774. )
  775. /*++
  776. Routine Description:
  777. Accessor method
  778. Arguments:
  779. None
  780. Return Values:
  781. Reference to the call-bridge for this
  782. overlapped processor
  783. Notes:
  784. --*/
  785. {
  786. return m_pH323State->GetCallBridge();
  787. } // OVERLAPPED_PROCESSOR::GetCallBridge
  788. inline
  789. CALL_REF_TYPE
  790. Q931_INFO::GetCallRefVal (
  791. void
  792. )
  793. /*++
  794. Routine Description:
  795. Accessor method
  796. Arguments:
  797. None
  798. Return Values:
  799. Reference value for the call
  800. Notes:
  801. --*/
  802. {
  803. return m_CallRefVal;
  804. } // Q931_INFO::GetCallRefVal
  805. inline
  806. HRESULT
  807. SOURCE_Q931_INFO::SetIncomingSocket (
  808. IN SOCKET IncomingSocket,
  809. IN SOCKADDR_IN * LocalAddress,
  810. IN SOCKADDR_IN * RemoteAddress
  811. )
  812. /*++
  813. Routine Description:
  814. Socket initialization
  815. Arguments:
  816. IncomingSocket -- socket on which connection was accepted
  817. LocalAddress -- address of the local side of the connection
  818. RemoteAddress -- address of the remote side of the connection
  819. Return Values:
  820. Result of issuing an async receive
  821. Notes:
  822. --*/
  823. {
  824. assert (IncomingSocket != INVALID_SOCKET);
  825. assert (m_pH323State->IsSourceCall());
  826. assert (Q931_SOURCE_STATE_INIT == m_Q931SourceState);
  827. m_SocketInfo.Init(
  828. IncomingSocket,
  829. LocalAddress,
  830. RemoteAddress);
  831. m_Q931SourceState = Q931_SOURCE_STATE_CON_ESTD;
  832. return QueueReceive();
  833. } // SOURCE_Q931_INFO::SetIncomingSocket
  834. inline
  835. DEST_Q931_INFO &
  836. SOURCE_Q931_INFO::GetDestQ931Info (
  837. void
  838. )
  839. /*++
  840. Routine Description:
  841. Accessor method
  842. Arguments:
  843. None
  844. Return Values:
  845. Reference to the destination Q.931 information
  846. Notes:
  847. --*/
  848. {
  849. return ((SOURCE_H323_STATE *)m_pH323State)->GetDestH323State().GetDestQ931Info();
  850. } // SOURCE_Q931_INFO::GetDestQ931Info
  851. inline
  852. SOURCE_H245_INFO &
  853. SOURCE_Q931_INFO::GetSourceH245Info (
  854. void
  855. )
  856. /*++
  857. Routine Description:
  858. Accessor method
  859. Arguments:
  860. None
  861. Return Values:
  862. Reference to the source H.245 information
  863. Notes:
  864. --*/
  865. {
  866. return ((SOURCE_H323_STATE *)m_pH323State)->GetSourceH245Info();
  867. } // SOURCE_Q931_INFO::GetSourceH245Info
  868. inline
  869. SOURCE_Q931_INFO &
  870. DEST_Q931_INFO::GetSourceQ931Info (
  871. void
  872. )
  873. /*++
  874. Routine Description:
  875. Accessor method
  876. Arguments:
  877. None
  878. Return Values:
  879. Reference to the source Q.931 information
  880. Notes:
  881. --*/
  882. {
  883. return ((DEST_H323_STATE *)m_pH323State)->GetSourceH323State().GetSourceQ931Info();
  884. } // DEST_Q931_INFO::GetSourceQ931Info
  885. inline
  886. DEST_H245_INFO &
  887. DEST_Q931_INFO::GetDestH245Info (
  888. void
  889. )
  890. /*++
  891. Routine Description:
  892. Accessor method
  893. Arguments:
  894. None
  895. Return Values:
  896. Reference to the source Q.931 information
  897. Notes:
  898. --*/
  899. {
  900. return ((DEST_H323_STATE *)m_pH323State)->GetDestH245Info();
  901. } // DEST_Q931_INFO::GetDestH245Info
  902. inline
  903. CALL_BRIDGE &
  904. LOGICAL_CHANNEL::GetCallBridge (
  905. void
  906. )
  907. /*++
  908. Routine Description:
  909. Accessor method
  910. Arguments:
  911. None
  912. Return Values:
  913. Reference to the "parent" call-bridge
  914. Notes:
  915. --*/
  916. {
  917. return GetH245Info().GetCallBridge();
  918. } // LOGICAL_CHANNEL::GetCallBridge
  919. inline
  920. void
  921. LOGICAL_CHANNEL::DeleteAndRemoveSelf (
  922. void
  923. )
  924. /*++
  925. Routine Description:
  926. Remove logical channel from the array of those,
  927. and terminate it.
  928. Arguments:
  929. None
  930. Return Values:
  931. None
  932. Notes:
  933. --*/
  934. {
  935. // remove self from the logical channel array
  936. m_pH245Info->GetLogicalChannelArray().Remove(*this);
  937. TimprocCancelTimer ();
  938. // destroy self
  939. delete this;
  940. } // LOGICAL_CHANNEL::DeleteAndRemoveSelf
  941. inline
  942. H245_INFO &
  943. H245_INFO::GetOtherH245Info (
  944. void
  945. )
  946. /*++
  947. Routine Description:
  948. Accessor function
  949. Arguments:
  950. None
  951. Return Values:
  952. "The other" H.245 information (source for destination, and
  953. destination for source)
  954. Notes:
  955. --*/
  956. {
  957. return GetH323State().GetOtherH323State().GetH245Info();
  958. } // H245_INFO::GetOtherH245Info (
  959. inline
  960. SOURCE_Q931_INFO &
  961. SOURCE_H245_INFO::GetSourceQ931Info (
  962. void
  963. )
  964. /*++
  965. Routine Description:
  966. Accessor function
  967. Arguments:
  968. None
  969. Return Values:
  970. Retrieves source Q.931 information
  971. Notes:
  972. --*/
  973. {
  974. return ((SOURCE_H323_STATE *)m_pH323State)->GetSourceQ931Info();
  975. } // SOURCE_H245_INFO::GetSourceQ931Info
  976. inline
  977. DEST_H245_INFO &
  978. SOURCE_H245_INFO::GetDestH245Info (
  979. void
  980. )
  981. /*++
  982. Routine Description:
  983. Accessor function
  984. Arguments:
  985. None
  986. Return Values:
  987. Retrieves destination H.245 information
  988. Notes:
  989. --*/
  990. {
  991. return ((SOURCE_H323_STATE *)m_pH323State)->GetDestH323State().GetDestH245Info();
  992. } // SOURCE_H245_INFO::GetDestH245Info
  993. inline
  994. DEST_Q931_INFO &
  995. DEST_H245_INFO::GetDestQ931Info (
  996. void
  997. )
  998. /*++
  999. Routine Description:
  1000. Accessor function
  1001. Arguments:
  1002. None
  1003. Return Values:
  1004. Retrieves destination Q.931 information
  1005. Notes:
  1006. --*/
  1007. {
  1008. return ((DEST_H323_STATE *)m_pH323State)->GetDestQ931Info();
  1009. } // DEST_H245_INFO::GetDestQ931Info
  1010. inline
  1011. H323_STATE &
  1012. H323_STATE::GetOtherH323State (
  1013. void
  1014. )
  1015. /*++
  1016. Routine Description:
  1017. Accessor function
  1018. Arguments:
  1019. None
  1020. Return Values:
  1021. Retrieves "the other" H.323 state (source for destination, and
  1022. destination for source)
  1023. Notes:
  1024. --*/
  1025. {
  1026. return (TRUE == m_fIsSourceCall)?
  1027. (H323_STATE &)m_pCallBridge->GetDestH323State() :
  1028. (H323_STATE &)m_pCallBridge->GetSourceH323State();
  1029. } // H323_STATE::GetOtherH323State
  1030. inline
  1031. DEST_H323_STATE &
  1032. SOURCE_H323_STATE::GetDestH323State (
  1033. void
  1034. )
  1035. /*++
  1036. Routine Description:
  1037. Accessor function
  1038. Arguments:
  1039. None
  1040. Return Values:
  1041. Retrieves destination H.323 information
  1042. Notes:
  1043. --*/
  1044. {
  1045. return GetCallBridge().GetDestH323State();
  1046. } // SOURCE_H323_STATE::GetDestH323State
  1047. inline SOURCE_H323_STATE &
  1048. DEST_H323_STATE::GetSourceH323State (
  1049. void
  1050. )
  1051. /*++
  1052. Routine Description:
  1053. Accessor function
  1054. Arguments:
  1055. None
  1056. Return Values:
  1057. Retrieves source H.323 information
  1058. Notes:
  1059. --*/
  1060. {
  1061. return GetCallBridge().GetSourceH323State();
  1062. } // DEST_H323_STATE::GetSourceH323State
  1063. #endif // __h323ics_call_bridge_h