📄 transports.h
字号:
virtual BOOL ConnectControlChannel( H323Connection & connection ); //@} /**@name RAS Channel */ //@{ /**Discover a Gatekeeper on the network. This locates a gatekeeper on the network and associates this transport object with packet exchange with that gatekeeper. */ virtual BOOL DiscoverGatekeeper( H323Gatekeeper & gk, /// Gatekeeper to set on discovery. H323RasPDU & pdu, /// GatekeeperRequest PDU const H323TransportAddress & address /// Address of gatekeeper (if present) ); //@} /**@name Member variable access */ //@{ /**Attach a thread to the transport. */ void AttachThread( PThread * thread ); /**Wait for associated thread to terminate. */ void CleanUpOnTermination(); //@} protected: H323EndPoint & endpoint; /// Endpoint that owns the listener. PThread * thread; /// Thread handling the transport};///////////////////////////////////////////////////////////////////////////////// Transport classes for IP/**This class represents a particular H323 transport using IP. It is used by the TCP and UDP transports. */class H323TransportIP : public H323Transport{ PCLASSINFO(H323TransportIP, H323Transport); public: /**Create a new transport channel. */ H323TransportIP( H323EndPoint & endpoint, /// H323 End Point object WORD remPort ); /**Get the transport dependent name of the local endpoint. */ virtual H323TransportAddress GetLocalAddress() const; /**Get the transport dependent name of the remote endpoint. */ virtual H323TransportAddress GetRemoteAddress() const; /**Check that the transport address PDU is compatible with transport. */ virtual BOOL IsCompatibleTransport( const H225_TransportAddress & pdu ) const; /**Set up a transport address PDU for RAS channel. */ virtual void SetUpTransportPDU( H225_TransportAddress & pdu, BOOL localTsap ) const; /**Set up a transport address PDU for logical channel. */ virtual void SetUpTransportPDU( H245_TransportAddress & pdu, unsigned tsap ) const; protected: PIPSocket::Address localAddress; // Address of the local interface WORD localPort; PIPSocket::Address remoteAddress; // Address of the remote host WORD remotePort;};///////////////////////////////////////////////////////////////////////////////// Transport classes for TCP/IP/**This class manages H323 connections using TCP/IP transport. */class H323ListenerTCP : public H323Listener{ PCLASSINFO(H323ListenerTCP, H323Listener); public: enum { DefaultSignalPort = 1720 }; /**Create a new listener for the TCP/IP protocol. */ H323ListenerTCP( H323EndPoint & endpoint, /// Endpoint instance for channel PIPSocket::Address binding = INADDR_ANY, /// Local interface to listen on WORD port = DefaultSignalPort /// TCP port to listen for connections ); /** Destroy the listener thread. */ ~H323ListenerTCP(); // Overrides from H323Listener /** Open the listener. */ virtual BOOL Open(); /**Stop the listener thread and no longer accept incoming connections. */ virtual BOOL Close(); /**Set up a transport address PDU for RAS channel. */ virtual void SetUpTransportPDU( H225_ArrayOf_TransportAddress & pdu, /// List of transport addresses listening on const H225_TransportAddress & first /// Transport address to take precedence ); WORD GetListenerPort() const { return listener.GetPort(); } protected: /**Handle incoming H.323 connections and dispatch them in new threads based on the H323Transport class. This is defined in the descendent class that knows what the low level transport is, eg H323ListenerIP for the TCP/IP protocol. Note this function does not return until the Close() function is called or there is some other error. */ virtual void Main(); PTCPSocket listener; PIPSocket::Address localAddress;};/* This class represents a particular H323 transport using TCP/IP. */class H323TransportTCP : public H323TransportIP{ PCLASSINFO(H323TransportTCP, H323TransportIP); public: /**Create a new transport channel. */ H323TransportTCP( H323EndPoint & endpoint /// H323 End Point object ); /**Destroy transport channel. */ ~H323TransportTCP(); /**Set default remote address to connect to. Note that this does not necessarily initiate a transport level connection, but only indicates where to connect to. The actual connection is made by the Connect() function. */ virtual BOOL SetRemoteAddress( const H323TransportAddress & address ); /**Connect to the remote party. */ virtual BOOL Connect(); /**Read a protocol data unit from the transport. This will read using the transports mechanism for PDU boundaries, for example UDP is a single Read() call, while for TCP there is a TPKT header that indicates the size of the PDU. */ BOOL ReadPDU( PBYTEArray & pdu /// PDU read from transport ); /**Write a protocol data unit from the transport. This will write using the transports mechanism for PDU boundaries, for example UDP is a single Write() call, while for TCP there is a TPKT header that indicates the size of the PDU. */ BOOL WritePDU( const PBYTEArray & pdu /// PDU to write ); /**Begin the opening of a control channel. This sets up the channel so that the remote endpoint can connect back to this endpoint. */ virtual BOOL CreateControlChannel( H323Connection & connection, H323Transport * & transport ); /**Finish the opening of a control channel. This waits for the connect backfrom the remote endpoint, completing the control channel open sequence. */ virtual BOOL AcceptControlChannel( H323Connection & connection ); protected: /**This callback is executed when the Open() function is called with open channels. It may be used by descendent channels to do any handshaking required by the protocol that channel embodies. The default behaviour is to simply return TRUE. @return Returns TRUE if the protocol handshaking is successful. */ virtual BOOL OnOpen(); PTCPSocket * h245listener;};///////////////////////////////////////////////////////////////////////////////// Transport classes for UDP/IP/**This class represents a particular H323 transport using UDP/IP. */class H323TransportUDP : public H323TransportIP{ PCLASSINFO(H323TransportUDP, H323TransportIP); public: enum { DefaultRasPort = 1719 }; /**Create a new transport channel. */ H323TransportUDP( H323EndPoint & endpoint, /// H323 End Point object PIPSocket::Address binding = INADDR_ANY /// Local interface to listen on ); ~H323TransportUDP(); /**Set default remote address to connect to. Note that this does not necessarily initiate a transport level connection, but only indicates where to connect to. The actual connection is made by the Connect() function. */ virtual BOOL SetRemoteAddress( const H323TransportAddress & address ); /**Connect to the remote party. */ virtual BOOL Connect(); /**Read a protocol data unit from the transport. This will read using the transports mechanism for PDU boundaries, for example UDP is a single Read() call, while for TCP there is a TPKT header that indicates the size of the PDU. */ virtual BOOL ReadPDU( PBYTEArray & pdu /// PDU read from transport ); /**Write a protocol data unit from the transport. This will write using the transports mechanism for PDU boundaries, for example UDP is a single Write() call, while for TCP there is a TPKT header that indicates the size of the PDU. */ virtual BOOL WritePDU( const PBYTEArray & pdu /// PDU to write ); /**Discover a Gatekeeper on the local network. This locates a gatekeeper on the network and associates this transport object with packet exchange with that gatekeeper. This broadcasts a UDP packet on the local network to find the gatekeeper's IP address. */ virtual BOOL DiscoverGatekeeper( H323Gatekeeper & gk, /// Gatekeeper to set on discovery. H323RasPDU & pdu, /// GatekeeperRequest PDU const H323TransportAddress & address /// Address of gatekeeper (if present) );};#endif // __TRANSPORTS_H/////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -