📄 transports.h
字号:
/* * transports.h * * H.323 protocol handler * * Open H323 Library * * Copyright (c) 1998-2000 Equivalence Pty. Ltd. * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * The Original Code is Open H323 Library. * * The Initial Developer of the Original Code is Equivalence Pty. Ltd. * * Portions of this code were written with the assisance of funding from * Vovida Networks, Inc. http://www.vovida.com. * * Contributor(s): ______________________________________. * * $Log: transports.h,v $ * Revision 1.16 2000/06/07 05:47:55 robertj * Added call forwarding. * * Revision 1.15 2000/05/22 05:21:36 robertj * Fixed race condition where controlChannel variable could be used before set. * * Revision 1.14 2000/05/18 11:53:34 robertj * Changes to support doc++ documentation generation. * * Revision 1.13 2000/05/08 14:07:26 robertj * Improved the provision and detection of calling and caller numbers, aliases and hostnames. * * Revision 1.12 2000/05/02 04:32:25 robertj * Fixed copyright notice comment. * * Revision 1.11 1999/11/06 05:37:44 robertj * Complete rewrite of termination of connection to avoid numerous race conditions. * * Revision 1.10 1999/10/16 03:47:57 robertj * Fixed termination of gatekeeper RAS thread problem * * Revision 1.9 1999/10/10 08:59:47 robertj * Fixed race condition in connection shutdown * * Revision 1.8 1999/09/14 06:52:54 robertj * Added better support for multi-homed client hosts. * * Revision 1.7 1999/09/10 09:43:59 robertj * Removed attempt at determining local interface for gatekeeper, so still has problem on multi-homed hosts. * * Revision 1.6 1999/08/31 12:34:18 robertj * Added gatekeeper support. * * Revision 1.5 1999/08/25 05:14:21 robertj * Fixed problem with calling modal dialog from a background thread. * * Revision 1.4 1999/07/14 06:06:14 robertj * Fixed termination problems (race conditions) with deleting connection object. * * Revision 1.3 1999/07/09 06:09:49 robertj * Major implementation. An ENORMOUS amount of stuff added everywhere. * * Revision 1.2 1999/06/13 12:41:14 robertj * Implement logical channel transmitter. * Fixed H245 connect on receiving call. * * Revision 1.1 1999/06/09 05:26:20 robertj * Major restructuring of classes. * */#ifndef __TRANSPORTS_H#define __TRANSPORTS_H#include <ptlib/sockets.h>class H225_Setup_UUIE;class H225_TransportAddress;class H225_ArrayOf_TransportAddress;class H225_TransportAddress_ipAddress;class H245_TransportAddress;class H323SignalPDU;class H323RasPDU;class H323EndPoint;class H323Connection;class H323Transport;class H323Gatekeeper;class H323GloballyUniqueID;/**String representation of a transport address. */class H323TransportAddress : public PString{ PCLASSINFO(H323TransportAddress, PString); public: H323TransportAddress() { } H323TransportAddress(const char *); H323TransportAddress(const PString &); H323TransportAddress(const H225_TransportAddress &); H323TransportAddress(const H245_TransportAddress &); H323TransportAddress(const PIPSocket::Address &, WORD); BOOL SetPDU(H225_TransportAddress & pdu) const; BOOL SetPDU(H245_TransportAddress & pdu) const; /**Extract the ip address and port number from transport address. Returns FALSE, if the address is not an IP transport address. */ BOOL GetIpAndPort( PIPSocket::Address & ip, WORD & port, const char * proto = "tcp" ) const; /**Translate the transport address to a more human readable form. Returns the hostname if using IP. */ PString GetHostName() const; /**Create a transport suitable for this address type. */ H323Transport * CreateTransport( H323EndPoint & endpoint /// Endpoint object for transport creation. ) const; protected: void Validate();};/**This class describes a "listener" on a transport protocol. A "listener" is an object that listens for incoming connections on the particular transport. It is executed as a separate thread. The Main() function is used to handle incoming H.323 connections and dispatch them in new threads based on the actual H323Transport class. This is defined in the descendent class that knows what the low level transport is, eg H323ListenerIP for the TCP/IP protocol. An application may create a descendent off this class and override functions as required for operating the channel protocol. */class H323Listener : public PThread{ PCLASSINFO(H323Listener, PThread); public: /**@name Construction */ //@{ /**Create a new listener. */ H323Listener( H323EndPoint & endpoint /// Endpoint instance for channel ); //@} /**@name Operations */ //@{ /** Open the listener. */ virtual BOOL Open() = 0; /**Stop the listener thread and no longer accept incoming connections. */ virtual BOOL Close() = 0; /**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 ) = 0; //@} protected: H323EndPoint & endpoint; /// Endpoint that owns the listener.};PLIST(H323ListenerList, H323Listener);/**This class describes a I/O transport protocol.. A "transport" is an object that listens for incoming connections on the particular transport. */class H323Transport : public PIndirectChannel{ PCLASSINFO(H323Transport, PIndirectChannel); public: /**@name Construction */ //@{ /**Create a new transport channel. */ H323Transport(H323EndPoint & endpoint); ~H323Transport(); //@} /**@name Operations */ //@{ /**Get the transport dependent name of the local endpoint. */ virtual H323TransportAddress GetLocalAddress() const = 0; /**Get the transport dependent name of the remote endpoint. */ virtual H323TransportAddress GetRemoteAddress() const = 0; /**Set 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 ) = 0; /**Connect to the remote address. */ virtual BOOL Connect() = 0; /**Close the channel. */ BOOL Close(); /**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; /**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 ) = 0; /**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 ) = 0; //@} /**@name Signalling Channel */ //@{ /**Wait for first PDU and find/create connection object. */ H323Connection * HandleFirstSignallingChannelPDU(); //@} /**@name Control Channel */ //@{ /**Begin the opening of a control channel. This sets up the channel so that the remote endpoint can connect back to this endpoint. This would be called on the signalling channel instance of a H323Transport. */ 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 ); /**Connect the control channel. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -