Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

transports.h

Go to the documentation of this file.
00001 /* 00002 * transports.h 00003 * 00004 * H.323 protocol handler 00005 * 00006 * Open H323 Library 00007 * 00008 * Copyright (c) 1998-2000 Equivalence Pty. Ltd. 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * The Original Code is Open H323 Library. 00021 * 00022 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00023 * 00024 * Portions of this code were written with the assisance of funding from 00025 * Vovida Networks, Inc. http://www.vovida.com. 00026 * 00027 * Contributor(s): ______________________________________. 00028 * 00029 * $Log: transports.h,v $ 00030 * Revision 1.44 2004/05/13 02:26:13 dereksmithies 00031 * Fixes so make docs does not generate warning messages about brackets. 00032 * 00033 * Revision 1.43 2003/12/29 13:28:45 dominance 00034 * fixed docbook syntax trying to generate LaTeX formula with ip$10.x.x.x. 00035 * 00036 * Revision 1.42 2003/04/10 09:44:55 robertj 00037 * Added associated transport to new GetInterfaceAddresses() function so 00038 * interfaces can be ordered according to active transport links. Improves 00039 * interoperability. 00040 * Replaced old listener GetTransportPDU() with GetInterfaceAddresses() 00041 * and H323SetTransportAddresses() functions. 00042 * 00043 * Revision 1.41 2003/04/10 01:03:25 craigs 00044 * Added functions to access to lists of interfaces 00045 * 00046 * Revision 1.40 2003/03/21 05:24:02 robertj 00047 * Added setting of remote port in UDP transport constructor. 00048 * 00049 * Revision 1.39 2003/02/06 04:29:23 robertj 00050 * Added more support for adding things to H323TransportAddressArrays 00051 * 00052 * Revision 1.38 2002/11/21 06:39:56 robertj 00053 * Changed promiscuous mode to be three way. Fixes race condition in gkserver 00054 * which can cause crashes or more PDUs to be sent to the wrong place. 00055 * 00056 * Revision 1.37 2002/11/10 08:10:43 robertj 00057 * Moved constants for "well known" ports to better place (OPAL change). 00058 * 00059 * Revision 1.36 2002/09/16 01:14:15 robertj 00060 * Added #define so can select if #pragma interface/implementation is used on 00061 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00062 * 00063 * Revision 1.35 2002/07/22 09:40:15 robertj 00064 * Added ability to automatically convert string arrays, lists sorted lists 00065 * directly to H323TransportAddressArray. 00066 * 00067 * Revision 1.34 2002/07/02 10:02:29 robertj 00068 * Added H323TransportAddress::GetIpAddress() so don't have to provide port 00069 * when you don't need it as in GetIpAndPort(),. 00070 * 00071 * Revision 1.33 2002/06/28 03:34:25 robertj 00072 * Fixed issues with address translation on gatekeeper RAS channel. 00073 * 00074 * Revision 1.32 2002/06/12 03:51:59 robertj 00075 * Added function to compare two transport addresses in a more intelligent 00076 * way that strict string comparison. Takes into account wildcarding. 00077 * 00078 * Revision 1.31 2002/02/11 04:20:25 robertj 00079 * Fixed documentation errors, thanks Horacio J. Peņa 00080 * 00081 * Revision 1.30 2002/02/05 23:29:23 robertj 00082 * Changed default for H.323 listener to reuse addresses. 00083 * 00084 * Revision 1.29 2001/12/22 01:48:12 robertj 00085 * Added ability to use local and remote port from transport channel as well 00086 * as explicit port in H.245 address PDU setting routine. 00087 * Added PrintOn() to listener and transport for tracing purposes. 00088 * 00089 * Revision 1.28 2001/07/17 04:44:29 robertj 00090 * Partial implementation of T.120 and T.38 logical channels. 00091 * 00092 * Revision 1.27 2001/06/25 02:30:46 robertj 00093 * Allowed TCP listener socket to be opened in non-exclusive mode 00094 * (ie SO_REUSEADDR) to avoid daemon restart problems. 00095 * 00096 * Revision 1.26 2001/06/22 00:14:14 robertj 00097 * Added ConnectTo() function to conencto specific address. 00098 * Added promiscuous mode for UDP channel. 00099 * 00100 * Revision 1.25 2001/05/17 06:37:02 robertj 00101 * Added multicast gatekeeper discovery support. 00102 * 00103 * Revision 1.24 2001/04/09 08:43:39 robertj 00104 * Added ability to get transport address for a listener. 00105 * 00106 * Revision 1.23 2001/03/02 06:59:57 robertj 00107 * Enhanced the globally unique identifier class. 00108 * 00109 * Revision 1.22 2001/02/09 05:16:24 robertj 00110 * Added #pragma interface for GNU C++. 00111 * 00112 * Revision 1.21 2001/01/23 05:08:04 robertj 00113 * Fixed bug when trying to clear call while waiting on H.245 channel connect, thanks Yura Aksyonov. 00114 * 00115 * Revision 1.20 2000/10/20 06:18:58 robertj 00116 * Fixed very small race condition on creating new connectionon incoming call. 00117 * Fixed memory/socket leak if do TCP connect and don't send valid setup PDU. 00118 * 00119 * Revision 1.19 2000/10/04 05:59:09 robertj 00120 * Minor reorganisation of the H.245 secondary channel start up to make it simpler 00121 * to override its behaviour. 00122 * 00123 * Revision 1.18 2000/09/25 12:59:16 robertj 00124 * Added StartListener() function that takes a H323TransportAddress to start 00125 * listeners bound to specific interfaces. 00126 * 00127 * Revision 1.17 2000/09/22 01:35:03 robertj 00128 * Added support for handling LID's that only do symmetric codecs. 00129 * 00130 * Revision 1.16 2000/06/07 05:47:55 robertj 00131 * Added call forwarding. 00132 * 00133 * Revision 1.15 2000/05/22 05:21:36 robertj 00134 * Fixed race condition where controlChannel variable could be used before set. 00135 * 00136 * Revision 1.14 2000/05/18 11:53:34 robertj 00137 * Changes to support doc++ documentation generation. 00138 * 00139 * Revision 1.13 2000/05/08 14:07:26 robertj 00140 * Improved the provision and detection of calling and caller numbers, aliases and hostnames. 00141 * 00142 * Revision 1.12 2000/05/02 04:32:25 robertj 00143 * Fixed copyright notice comment. 00144 * 00145 * Revision 1.11 1999/11/06 05:37:44 robertj 00146 * Complete rewrite of termination of connection to avoid numerous race conditions. 00147 * 00148 * Revision 1.10 1999/10/16 03:47:57 robertj 00149 * Fixed termination of gatekeeper RAS thread problem 00150 * 00151 * Revision 1.9 1999/10/10 08:59:47 robertj 00152 * Fixed race condition in connection shutdown 00153 * 00154 * Revision 1.8 1999/09/14 06:52:54 robertj 00155 * Added better support for multi-homed client hosts. 00156 * 00157 * Revision 1.7 1999/09/10 09:43:59 robertj 00158 * Removed attempt at determining local interface for gatekeeper, so still has problem on multi-homed hosts. 00159 * 00160 * Revision 1.6 1999/08/31 12:34:18 robertj 00161 * Added gatekeeper support. 00162 * 00163 * Revision 1.5 1999/08/25 05:14:21 robertj 00164 * Fixed problem with calling modal dialog from a background thread. 00165 * 00166 * Revision 1.4 1999/07/14 06:06:14 robertj 00167 * Fixed termination problems (race conditions) with deleting connection object. 00168 * 00169 * Revision 1.3 1999/07/09 06:09:49 robertj 00170 * Major implementation. An ENORMOUS amount of stuff added everywhere. 00171 * 00172 * Revision 1.2 1999/06/13 12:41:14 robertj 00173 * Implement logical channel transmitter. 00174 * Fixed H245 connect on receiving call. 00175 * 00176 * Revision 1.1 1999/06/09 05:26:20 robertj 00177 * Major restructuring of classes. 00178 * 00179 */ 00180 00181 #ifndef __TRANSPORTS_H 00182 #define __TRANSPORTS_H 00183 00184 #ifdef P_USE_PRAGMA 00185 #pragma interface 00186 #endif 00187 00188 00189 #include <ptlib/sockets.h> 00190 00191 00192 class H225_Setup_UUIE; 00193 class H225_TransportAddress; 00194 class H225_ArrayOf_TransportAddress; 00195 class H225_TransportAddress_ipAddress; 00196 00197 class H245_TransportAddress; 00198 00199 class H323SignalPDU; 00200 class H323RasPDU; 00201 class H323EndPoint; 00202 class H323Connection; 00203 class H323Listener; 00204 class H323Transport; 00205 class H323Gatekeeper; 00206 00207 00208 00210 00214 class H323TransportAddress : public PString 00215 { 00216 PCLASSINFO(H323TransportAddress, PString); 00217 public: 00218 H323TransportAddress() { } 00219 H323TransportAddress(const char *); 00220 H323TransportAddress(const PString &); 00221 H323TransportAddress(const H225_TransportAddress &); 00222 H323TransportAddress(const H245_TransportAddress &); 00223 H323TransportAddress(const PIPSocket::Address &, WORD); 00224 00225 BOOL SetPDU(H225_TransportAddress & pdu) const; 00226 BOOL SetPDU(H245_TransportAddress & pdu) const; 00227 00230 BOOL IsEquivalent( 00231 const H323TransportAddress & address 00232 ); 00233 00237 BOOL GetIpAddress( 00238 PIPSocket::Address & ip 00239 ) const; 00240 00244 BOOL GetIpAndPort( 00245 PIPSocket::Address & ip, 00246 WORD & port, 00247 const char * proto = "tcp" 00248 ) const; 00249 00253 PString GetHostName() const; 00254 00265 H323Listener * CreateListener( 00266 H323EndPoint & endpoint 00267 ) const; 00268 00275 H323Listener * CreateCompatibleListener( 00276 H323EndPoint & endpoint 00277 ) const; 00278 00281 H323Transport * CreateTransport( 00282 H323EndPoint & endpoint 00283 ) const; 00284 00285 protected: 00286 void Validate(); 00287 }; 00288 00289 00290 PDECLARE_ARRAY(H323TransportAddressArray, H323TransportAddress) 00291 #ifdef DOC_PLUS_PLUS 00292 { 00293 #endif 00294 public: 00295 H323TransportAddressArray( 00296 const H323TransportAddress & address 00297 ) { AppendAddress(address); } 00298 H323TransportAddressArray( 00299 const H225_ArrayOf_TransportAddress & addresses 00300 ); 00301 H323TransportAddressArray( 00302 const PStringArray & array 00303 ) { AppendStringCollection(array); } 00304 H323TransportAddressArray( 00305 const PStringList & list 00306 ) { AppendStringCollection(list); } 00307 H323TransportAddressArray( 00308 const PSortedStringList & list 00309 ) { AppendStringCollection(list); } 00310 00311 void AppendString( 00312 const char * address 00313 ); 00314 void AppendString( 00315 const PString & address 00316 ); 00317 void AppendAddress( 00318 const H323TransportAddress & address 00319 ); 00320 00321 protected: 00322 void AppendStringCollection( 00323 const PCollection & coll 00324 ); 00325 }; 00326 00327 00340 class H323Listener : public PThread 00341 { 00342 PCLASSINFO(H323Listener, PThread); 00343 00344 public: 00349 H323Listener( 00350 H323EndPoint & endpoint 00351 ); 00353 00356 virtual void PrintOn( 00357 ostream & strm 00358 ) const; 00360 00365 virtual BOOL Open() = 0; 00366 00369 virtual BOOL Close() = 0; 00370 00373 virtual H323Transport * Accept( 00374 const PTimeInterval & timeout 00375 ) = 0; 00376 00379 virtual H323TransportAddress GetTransportAddress() const = 0; 00380 00383 virtual BOOL SetUpTransportPDU( 00384 H245_TransportAddress & pdu, 00385 const H323Transport & associatedTransport 00386 ) = 0; 00388 00389 protected: 00390 H323EndPoint & endpoint; 00391 }; 00392 00393 00394 PLIST(H323ListenerList, H323Listener); 00395 00396 00399 H323TransportAddressArray H323GetInterfaceAddresses( 00400 const H323ListenerList & listeners, 00401 BOOL excludeLocalHost = TRUE, 00402 H323Transport * associatedTransport = NULL 00404 ); 00405 00406 H323TransportAddressArray H323GetInterfaceAddresses( 00407 const H323TransportAddress & addr, 00408 BOOL excludeLocalHost = TRUE, 00409 H323Transport * associatedTransport = NULL 00411 ); 00412 00415 void H323SetTransportAddresses( 00416 const H323Transport & associatedTransport, 00417 const H323TransportAddressArray & addresses, 00418 H225_ArrayOf_TransportAddress & pdu 00419 ); 00420 00421 00426 class H323Transport : public PIndirectChannel 00427 { 00428 PCLASSINFO(H323Transport, PIndirectChannel); 00429 00430 public: 00435 H323Transport(H323EndPoint & endpoint); 00436 ~H323Transport(); 00438 00441 virtual void PrintOn( 00442 ostream & strm 00443 ) const; 00445 00450 virtual H323TransportAddress GetLocalAddress() const = 0; 00451 00454 virtual H323TransportAddress GetRemoteAddress() const = 0; 00455 00461 virtual BOOL SetRemoteAddress( 00462 const H323TransportAddress & address 00463 ) = 0; 00464 00467 virtual BOOL Connect() = 0; 00468 00471 BOOL ConnectTo( 00472 const H323TransportAddress & address 00473 ) { return SetRemoteAddress(address) && Connect(); } 00474 00477 virtual BOOL Close(); 00478 00481 virtual BOOL IsCompatibleTransport( 00482 const H225_TransportAddress & pdu 00483 ) const; 00484 00487 virtual void SetUpTransportPDU( 00488 H225_TransportAddress & pdu, 00489 BOOL localTsap 00490 ) const; 00491 00492 enum { 00493 UseLocalTSAP = 0x10001, 00494 UseRemoteTSAP 00495 }; 00496 00501 virtual void SetUpTransportPDU( 00502 H245_TransportAddress & pdu, 00503 unsigned tsap 00504 ) const; 00505 00507 enum PromisciousModes { 00508 AcceptFromRemoteOnly, 00509 AcceptFromAnyAutoSet, 00510 AcceptFromAny, 00511 NumPromisciousModes 00512 }; 00513 00524 virtual void SetPromiscuous( 00525 PromisciousModes promiscuous 00526 ); 00527 00532 virtual H323TransportAddress GetLastReceivedAddress() const; 00533 00539 virtual BOOL ReadPDU( 00540 PBYTEArray & pdu 00541 ) = 0; 00542 00548 virtual BOOL WritePDU( 00549 const PBYTEArray & pdu 00550 ) = 0; 00552 00558 BOOL HandleFirstSignallingChannelPDU(); 00560 00568 virtual H323Transport * CreateControlChannel( 00569 H323Connection & connection 00570 ); 00571 00576 virtual BOOL AcceptControlChannel( 00577 H323Connection & connection 00578 ); 00579 00582 virtual void StartControlChannel( 00583 H323Connection & connection 00584 ); 00586 00593 virtual BOOL DiscoverGatekeeper( 00594 H323Gatekeeper & gk, 00595 H323RasPDU & pdu, 00596 const H323TransportAddress & address 00597 ); 00599 00600 00605 H323EndPoint & GetEndPoint() const { return endpoint; } 00606 00609 void AttachThread( 00610 PThread * thread 00611 ); 00612 00615 void CleanUpOnTermination(); 00617 00618 protected: 00619 H323EndPoint & endpoint; 00620 PThread * thread; 00621 }; 00622 00623 00624 00626 // Transport classes for IP 00627 00631 class H323TransportIP : public H323Transport 00632 { 00633 PCLASSINFO(H323TransportIP, H323Transport); 00634 00635 public: 00638 H323TransportIP( 00639 H323EndPoint & endpoint, 00640 PIPSocket::Address binding, 00641 WORD remPort 00642 ); 00643 00646 virtual H323TransportAddress GetLocalAddress() const; 00647 00650 virtual H323TransportAddress GetRemoteAddress() const; 00651 00654 virtual BOOL IsCompatibleTransport( 00655 const H225_TransportAddress & pdu 00656 ) const; 00657 00660 virtual void SetUpTransportPDU( 00661 H225_TransportAddress & pdu, 00662 BOOL localTsap 00663 ) const; 00664 00667 virtual void SetUpTransportPDU( 00668 H245_TransportAddress & pdu, 00669 unsigned tsap 00670 ) const; 00671 00672 00673 protected: 00674 PIPSocket::Address localAddress; // Address of the local interface 00675 WORD localPort; 00676 PIPSocket::Address remoteAddress; // Address of the remote host 00677 WORD remotePort; 00678 }; 00679 00680 00682 // Transport classes for TCP/IP 00683 00686 class H323ListenerTCP : public H323Listener 00687 { 00688 PCLASSINFO(H323ListenerTCP, H323Listener); 00689 00690 public: 00693 H323ListenerTCP( 00694 H323EndPoint & endpoint, 00695 PIPSocket::Address binding, 00696 WORD port, 00697 BOOL exclusive = FALSE 00698 ); 00699 00702 ~H323ListenerTCP(); 00703 00704 // Overrides from H323Listener 00707 virtual BOOL Open(); 00708 00711 virtual BOOL Close(); 00712 00715 virtual H323Transport * Accept( 00716 const PTimeInterval & timeout 00717 ); 00718 00721 virtual H323TransportAddress GetTransportAddress() const; 00722 00725 virtual BOOL SetUpTransportPDU( 00726 H245_TransportAddress & pdu, 00727 const H323Transport & associatedTransport 00728 ); 00729 00730 WORD GetListenerPort() const { return listener.GetPort(); } 00731 00732 00733 protected: 00742 virtual void Main(); 00743 00744 00745 PTCPSocket listener; 00746 PIPSocket::Address localAddress; 00747 BOOL exclusiveListener; 00748 }; 00749 00750 00753 class H323TransportTCP : public H323TransportIP 00754 { 00755 PCLASSINFO(H323TransportTCP, H323TransportIP); 00756 00757 public: 00760 H323TransportTCP( 00761 H323EndPoint & endpoint, 00762 PIPSocket::Address binding = INADDR_ANY, 00763 BOOL listen = FALSE 00764 ); 00765 00768 ~H323TransportTCP(); 00769 00775 virtual BOOL SetRemoteAddress( 00776 const H323TransportAddress & address 00777 ); 00778 00781 virtual BOOL Connect(); 00782 00785 virtual BOOL Close(); 00786 00792 BOOL ReadPDU( 00793 PBYTEArray & pdu 00794 ); 00795 00801 BOOL WritePDU( 00802 const PBYTEArray & pdu 00803 ); 00804 00809 virtual H323Transport * CreateControlChannel( 00810 H323Connection & connection 00811 ); 00812 00817 virtual BOOL AcceptControlChannel( 00818 H323Connection & connection 00819 ); 00820 00823 BOOL IsListening() const; 00824 00825 00826 protected: 00836 virtual BOOL OnOpen(); 00837 00838 00839 PTCPSocket * h245listener; 00840 }; 00841 00842 00844 // Transport classes for UDP/IP 00845 00848 class H323TransportUDP : public H323TransportIP 00849 { 00850 PCLASSINFO(H323TransportUDP, H323TransportIP); 00851 00852 public: 00855 H323TransportUDP( 00856 H323EndPoint & endpoint, 00857 PIPSocket::Address binding = INADDR_ANY, 00858 WORD localPort = 0, 00859 WORD remotePort = 0 00860 ); 00861 ~H323TransportUDP(); 00862 00868 virtual BOOL SetRemoteAddress( 00869 const H323TransportAddress & address 00870 ); 00871 00874 virtual BOOL Connect(); 00875 00887 virtual void SetPromiscuous( 00888 PromisciousModes promiscuous 00889 ); 00890 00895 virtual H323TransportAddress GetLastReceivedAddress() const; 00896 00902 virtual BOOL ReadPDU( 00903 PBYTEArray & pdu 00904 ); 00905 00911 virtual BOOL WritePDU( 00912 const PBYTEArray & pdu 00913 ); 00914 00920 virtual BOOL DiscoverGatekeeper( 00921 H323Gatekeeper & gk, 00922 H323RasPDU & pdu, 00923 const H323TransportAddress & address 00924 ); 00925 00926 protected: 00927 PromisciousModes promiscuousReads; 00928 H323TransportAddress lastReceivedAddress; 00929 }; 00930 00931 00932 #endif // __TRANSPORTS_H 00933 00934

Generated on Sat Jul 24 17:03:36 2004 for OpenH323 by doxygen 1.3.7