4 * H.323 protocol handler
8 * Copyright (c) 1998-2000 Equivalence Pty. Ltd.
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
20 * The Original Code is Open H323 Library.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Portions of this code were written with the assisance of funding from
25 * Vovida Networks, Inc. http://www.vovida.com.
27 * Contributor(s): ______________________________________.
29 * $Log: transports.h,v $
30 * Revision 1.49 2006/01/20 00:32:24 csoutheren
31 * First check-in of signalling aggregation code - incomplete and disabled by default
33 * Revision 1.48 2005/11/30 13:05:01 csoutheren
34 * Changed tags for Doxygen
36 * Revision 1.47 2005/11/21 21:07:41 shorne
37 * Added GnuGK Nat support
39 * Revision 1.46 2005/01/16 20:39:43 csoutheren
40 * Fixed problem with IPv6 INADDR_ANY
42 * Revision 1.45 2004/08/24 08:11:25 csoutheren
43 * Added initial support for receiving broadcasts on Linux
45 * Revision 1.44 2004/05/13 02:26:13 dereksmithies
46 * Fixes so make docs does not generate warning messages about brackets.
48 * Revision 1.43 2003/12/29 13:28:45 dominance
49 * fixed docbook syntax trying to generate LaTeX formula with ip$10.x.x.x.
51 * Revision 1.42 2003/04/10 09:44:55 robertj
52 * Added associated transport to new GetInterfaceAddresses() function so
53 * interfaces can be ordered according to active transport links. Improves
55 * Replaced old listener GetTransportPDU() with GetInterfaceAddresses()
56 * and H323SetTransportAddresses() functions.
58 * Revision 1.41 2003/04/10 01:03:25 craigs
59 * Added functions to access to lists of interfaces
61 * Revision 1.40 2003/03/21 05:24:02 robertj
62 * Added setting of remote port in UDP transport constructor.
64 * Revision 1.39 2003/02/06 04:29:23 robertj
65 * Added more support for adding things to H323TransportAddressArrays
67 * Revision 1.38 2002/11/21 06:39:56 robertj
68 * Changed promiscuous mode to be three way. Fixes race condition in gkserver
69 * which can cause crashes or more PDUs to be sent to the wrong place.
71 * Revision 1.37 2002/11/10 08:10:43 robertj
72 * Moved constants for "well known" ports to better place (OPAL change).
74 * Revision 1.36 2002/09/16 01:14:15 robertj
75 * Added #define so can select if #pragma interface/implementation is used on
76 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
78 * Revision 1.35 2002/07/22 09:40:15 robertj
79 * Added ability to automatically convert string arrays, lists sorted lists
80 * directly to H323TransportAddressArray.
82 * Revision 1.34 2002/07/02 10:02:29 robertj
83 * Added H323TransportAddress::GetIpAddress() so don't have to provide port
84 * when you don't need it as in GetIpAndPort(),.
86 * Revision 1.33 2002/06/28 03:34:25 robertj
87 * Fixed issues with address translation on gatekeeper RAS channel.
89 * Revision 1.32 2002/06/12 03:51:59 robertj
90 * Added function to compare two transport addresses in a more intelligent
91 * way that strict string comparison. Takes into account wildcarding.
93 * Revision 1.31 2002/02/11 04:20:25 robertj
94 * Fixed documentation errors, thanks Horacio J. Peña
96 * Revision 1.30 2002/02/05 23:29:23 robertj
97 * Changed default for H.323 listener to reuse addresses.
99 * Revision 1.29 2001/12/22 01:48:12 robertj
100 * Added ability to use local and remote port from transport channel as well
101 * as explicit port in H.245 address PDU setting routine.
102 * Added PrintOn() to listener and transport for tracing purposes.
104 * Revision 1.28 2001/07/17 04:44:29 robertj
105 * Partial implementation of T.120 and T.38 logical channels.
107 * Revision 1.27 2001/06/25 02:30:46 robertj
108 * Allowed TCP listener socket to be opened in non-exclusive mode
109 * (ie SO_REUSEADDR) to avoid daemon restart problems.
111 * Revision 1.26 2001/06/22 00:14:14 robertj
112 * Added ConnectTo() function to conencto specific address.
113 * Added promiscuous mode for UDP channel.
115 * Revision 1.25 2001/05/17 06:37:02 robertj
116 * Added multicast gatekeeper discovery support.
118 * Revision 1.24 2001/04/09 08:43:39 robertj
119 * Added ability to get transport address for a listener.
121 * Revision 1.23 2001/03/02 06:59:57 robertj
122 * Enhanced the globally unique identifier class.
124 * Revision 1.22 2001/02/09 05:16:24 robertj
125 * Added #pragma interface for GNU C++.
127 * Revision 1.21 2001/01/23 05:08:04 robertj
128 * Fixed bug when trying to clear call while waiting on H.245 channel connect, thanks Yura Aksyonov.
130 * Revision 1.20 2000/10/20 06:18:58 robertj
131 * Fixed very small race condition on creating new connectionon incoming call.
132 * Fixed memory/socket leak if do TCP connect and don't send valid setup PDU.
134 * Revision 1.19 2000/10/04 05:59:09 robertj
135 * Minor reorganisation of the H.245 secondary channel start up to make it simpler
136 * to override its behaviour.
138 * Revision 1.18 2000/09/25 12:59:16 robertj
139 * Added StartListener() function that takes a H323TransportAddress to start
140 * listeners bound to specific interfaces.
142 * Revision 1.17 2000/09/22 01:35:03 robertj
143 * Added support for handling LID's that only do symmetric codecs.
145 * Revision 1.16 2000/06/07 05:47:55 robertj
146 * Added call forwarding.
148 * Revision 1.15 2000/05/22 05:21:36 robertj
149 * Fixed race condition where controlChannel variable could be used before set.
151 * Revision 1.14 2000/05/18 11:53:34 robertj
152 * Changes to support doc++ documentation generation.
154 * Revision 1.13 2000/05/08 14:07:26 robertj
155 * Improved the provision and detection of calling and caller numbers, aliases and hostnames.
157 * Revision 1.12 2000/05/02 04:32:25 robertj
158 * Fixed copyright notice comment.
160 * Revision 1.11 1999/11/06 05:37:44 robertj
161 * Complete rewrite of termination of connection to avoid numerous race conditions.
163 * Revision 1.10 1999/10/16 03:47:57 robertj
164 * Fixed termination of gatekeeper RAS thread problem
166 * Revision 1.9 1999/10/10 08:59:47 robertj
167 * Fixed race condition in connection shutdown
169 * Revision 1.8 1999/09/14 06:52:54 robertj
170 * Added better support for multi-homed client hosts.
172 * Revision 1.7 1999/09/10 09:43:59 robertj
173 * Removed attempt at determining local interface for gatekeeper, so still has problem on multi-homed hosts.
175 * Revision 1.6 1999/08/31 12:34:18 robertj
176 * Added gatekeeper support.
178 * Revision 1.5 1999/08/25 05:14:21 robertj
179 * Fixed problem with calling modal dialog from a background thread.
181 * Revision 1.4 1999/07/14 06:06:14 robertj
182 * Fixed termination problems (race conditions) with deleting connection object.
184 * Revision 1.3 1999/07/09 06:09:49 robertj
185 * Major implementation. An ENORMOUS amount of stuff added everywhere.
187 * Revision 1.2 1999/06/13 12:41:14 robertj
188 * Implement logical channel transmitter.
189 * Fixed H245 connect on receiving call.
191 * Revision 1.1 1999/06/09 05:26:20 robertj
192 * Major restructuring of classes.
196 #ifndef __TRANSPORTS_H
197 #define __TRANSPORTS_H
204 #include <ptlib/sockets.h>
207 class H225_Setup_UUIE;
208 class H225_TransportAddress;
209 class H225_ArrayOf_TransportAddress;
210 class H225_TransportAddress_ipAddress;
212 class H245_TransportAddress;
217 class H323Connection;
220 class H323Gatekeeper;
224 ///////////////////////////////////////////////////////////////////////////////
226 /**String representation of a transport address.
229 class H323TransportAddress : public PString
231 PCLASSINFO(H323TransportAddress, PString);
233 H323TransportAddress() { }
234 H323TransportAddress(const char *);
235 H323TransportAddress(const PString &);
236 H323TransportAddress(const H225_TransportAddress &);
237 H323TransportAddress(const H245_TransportAddress &);
238 H323TransportAddress(const PIPSocket::Address &, WORD);
240 BOOL SetPDU(H225_TransportAddress & pdu) const;
241 BOOL SetPDU(H245_TransportAddress & pdu) const;
243 /**Determine if the two transport addresses are equivalent.
246 const H323TransportAddress & address
249 /**Extract the ip address from transport address.
250 Returns FALSE, if the address is not an IP transport address.
253 PIPSocket::Address & ip
256 /**Extract the ip address and port number from transport address.
257 Returns FALSE, if the address is not an IP transport address.
260 PIPSocket::Address & ip,
262 const char * proto = "tcp"
265 /**Translate the transport address to a more human readable form.
266 Returns the hostname if using IP.
268 PString GetHostName() const;
270 /**Create a listener based on this transport address.
272 For example an address of "#ip$10.0.0.1:1720#" would create a TCP
273 listening socket that would be bound to the specific interface
274 10.0.0.1 and listens on port 1720. Note that the address
275 "#ip$*:1720#" can be used to bind to INADDR_ANY.
277 Also note that if the address has a trailing '+' character then the
278 socket will be bound using the REUSEADDR option.
280 H323Listener * CreateListener(
281 H323EndPoint & endpoint ///< Endpoint object for transport creation.
284 /**Create a listener compatible for this address type.
285 This is similar to CreateListener() but does not use the TSAP specified
286 in the H323Transport. For example an address of "#ip$10.0.0.1:1720#"
287 would create a TCP listening socket that would be bound to the specific
288 interface 10.0.0.1 but listens on a random OS allocated port number.
290 H323Listener * CreateCompatibleListener(
291 H323EndPoint & endpoint ///< Endpoint object for transport creation.
294 /**Create a transport suitable for this address type.
296 H323Transport * CreateTransport(
297 H323EndPoint & endpoint ///< Endpoint object for transport creation.
305 PDECLARE_ARRAY(H323TransportAddressArray, H323TransportAddress)
310 H323TransportAddressArray(
311 const H323TransportAddress & address
312 ) { AppendAddress(address); }
313 H323TransportAddressArray(
314 const H225_ArrayOf_TransportAddress & addresses
316 H323TransportAddressArray(
317 const PStringArray & array
318 ) { AppendStringCollection(array); }
319 H323TransportAddressArray(
320 const PStringList & list
321 ) { AppendStringCollection(list); }
322 H323TransportAddressArray(
323 const PSortedStringList & list
324 ) { AppendStringCollection(list); }
330 const PString & address
333 const H323TransportAddress & address
337 void AppendStringCollection(
338 const PCollection & coll
343 /**This class describes a "listener" on a transport protocol.
344 A "listener" is an object that listens for incoming connections on the
345 particular transport. It is executed as a separate thread.
347 The Main() function is used to handle incoming H.323 connections and
348 dispatch them in new threads based on the actual H323Transport class. This
349 is defined in the descendent class that knows what the low level transport
350 is, eg H323ListenerIP for the TCP/IP protocol.
352 An application may create a descendent off this class and override
353 functions as required for operating the channel protocol.
355 class H323Listener : public PThread
357 PCLASSINFO(H323Listener, PThread);
360 /**@name Construction */
362 /**Create a new listener.
365 H323EndPoint & endpoint ///< Endpoint instance for channel
369 /**@name Overrides from PObject */
371 virtual void PrintOn(
376 /**@name Operations */
378 /** Open the listener.
380 virtual BOOL Open() = 0;
382 /**Stop the listener thread and no longer accept incoming connections.
384 virtual BOOL Close() = 0;
386 /**Accept a new incoming transport.
388 virtual H323Transport * Accept(
389 const PTimeInterval & timeout ///< Time to wait for incoming connection
392 /**Get the local transport address on which this listener may be accessed.
394 virtual H323TransportAddress GetTransportAddress() const = 0;
396 /**Set up a transport address PDU for bidirectional logical channels.
398 virtual BOOL SetUpTransportPDU(
399 H245_TransportAddress & pdu, ///< Transport addresses listening on
400 const H323Transport & associatedTransport ///< Associated transport for precendence and translation
405 H323EndPoint & endpoint; /// Endpoint that owns the listener.
409 PLIST(H323ListenerList, H323Listener);
412 /** Return a list of transport addresses corresponding to a listener list
414 H323TransportAddressArray H323GetInterfaceAddresses(
415 const H323ListenerList & listeners, ///< List of listeners
416 BOOL excludeLocalHost = TRUE, ///< Flag to exclude 127.0.0.1
417 H323Transport * associatedTransport = NULL
418 ///< Associated transport for precedence and translation
421 H323TransportAddressArray H323GetInterfaceAddresses(
422 const H323TransportAddress & addr, ///< Possible INADDR_ANY address
423 BOOL excludeLocalHost = TRUE, ///< Flag to exclude 127.0.0.1
424 H323Transport * associatedTransport = NULL
425 ///< Associated transport for precedence and translation
428 /**Set the PDU field for the list of transport addresses
430 void H323SetTransportAddresses(
431 const H323Transport & associatedTransport, ///< Transport for NAT address translation
432 const H323TransportAddressArray & addresses, ///< Addresses to set
433 H225_ArrayOf_TransportAddress & pdu ///< List of PDU transport addresses
437 /**This class describes a I/O transport protocol..
438 A "transport" is an object that listens for incoming connections on the
439 particular transport.
441 class H323Transport : public PIndirectChannel
443 PCLASSINFO(H323Transport, PIndirectChannel);
446 /**@name Construction */
448 /**Create a new transport channel.
450 H323Transport(H323EndPoint & endpoint);
454 /**@name Overrides from PObject */
456 virtual void PrintOn(
461 /**@name Operations */
463 /**Get the transport address of the local endpoint.
465 virtual H323TransportAddress GetLocalAddress() const = 0;
467 /**Get the transport address of the remote endpoint.
469 virtual H323TransportAddress GetRemoteAddress() const = 0;
471 /**Set remote address to connect to.
472 Note that this does not necessarily initiate a transport level
473 connection, but only indicates where to connect to. The actual
474 connection is made by the Connect() function.
476 virtual BOOL SetRemoteAddress(
477 const H323TransportAddress & address
480 /**Connect to the remote address.
482 virtual BOOL Connect() = 0;
484 /**Connect to the specified address.
487 const H323TransportAddress & address
488 ) { return SetRemoteAddress(address) && Connect(); }
490 /**Close the channel.
492 virtual BOOL Close();
494 /**Check that the transport address PDU is compatible with transport.
496 virtual BOOL IsCompatibleTransport(
497 const H225_TransportAddress & pdu
500 /**Set up a transport address PDU for RAS channel.
502 virtual void SetUpTransportPDU(
503 H225_TransportAddress & pdu,
508 UseLocalTSAP = 0x10001,
512 /**Set up a transport address PDU for logical channel.
513 If tsap is UseLocalTSAP or UseRemoteTSAP then the local or remote port
514 of the transport is used, otherwise the explicit port number is used.
516 virtual void SetUpTransportPDU(
517 H245_TransportAddress & pdu,
521 /// Promiscious modes for transport
522 enum PromisciousModes {
523 AcceptFromRemoteOnly,
524 AcceptFromAnyAutoSet,
529 /**Set read to promiscuous mode.
530 Normally only reads from the specifed remote address are accepted. This
531 flag allows packets to be accepted from any remote, provided the
532 underlying protocol can do so. For example TCP will do nothing.
534 The Read() call may optionally set the remote address automatically to
535 whatever the sender host of the last received message was.
537 Default behaviour does nothing.
539 virtual void SetPromiscuous(
540 PromisciousModes promiscuous
543 /**Get the transport address of the last received PDU.
545 Default behaviour returns GetRemoteAddress().
547 virtual H323TransportAddress GetLastReceivedAddress() const;
549 /**Read a protocol data unit from the transport.
550 This will read using the transports mechanism for PDU boundaries, for
551 example UDP is a single Read() call, while for TCP there is a TPKT
552 header that indicates the size of the PDU.
554 virtual BOOL ReadPDU(
555 PBYTEArray & pdu ///< PDU read from transport
558 /**Extract a protocol data unit from the transport
559 This is used by the aggregator to deblock the incoming data stream
562 virtual BOOL ExtractPDU(
563 const PBYTEArray & pdu,
567 /**Write a protocol data unit from the transport.
568 This will write using the transports mechanism for PDU boundaries, for
569 example UDP is a single Write() call, while for TCP there is a TPKT
570 header that indicates the size of the PDU.
572 virtual BOOL WritePDU(
573 const PBYTEArray & pdu ///< PDU to write
577 /**@name Signalling Channel */
579 /**Wait for first PDU and find/create connection object.
580 If returns FALSE, then the transport is deleted by the calling thread.
582 BOOL HandleFirstSignallingChannelPDU();
585 /**@name Control Channel */
587 /**Begin the opening of a control channel.
588 This sets up the channel so that the remote endpoint can connect back
589 to this endpoint. This would be called on the signalling channel
590 instance of a H323Transport.
592 virtual H323Transport * CreateControlChannel(
593 H323Connection & connection
596 /**Finish the opening of a control channel.
597 This waits for the connect backfrom the remote endpoint, completing the
598 control channel open sequence.
600 virtual BOOL AcceptControlChannel(
601 H323Connection & connection
604 /**Connect the control channel.
606 virtual void StartControlChannel(
607 H323Connection & connection
611 /**@name RAS Channel */
613 /**Discover a Gatekeeper on the network.
614 This locates a gatekeeper on the network and associates this transport
615 object with packet exchange with that gatekeeper.
617 virtual BOOL DiscoverGatekeeper(
618 H323Gatekeeper & gk, ///< Gatekeeper to set on discovery.
619 H323RasPDU & pdu, ///< GatekeeperRequest PDU
620 const H323TransportAddress & address ///< Address of gatekeeper (if present)
625 /**@name Member variable access */
627 /**Get the associated endpoint to this transport.
629 H323EndPoint & GetEndPoint() const { return endpoint; }
631 /**Attach a thread to the transport.
637 /**Wait for associated thread to terminate.
639 void CleanUpOnTermination();
643 H323EndPoint & endpoint; /// Endpoint that owns the listener.
644 PThread * thread; /// Thread handling the transport
645 BOOL canGetInterface;
650 ///////////////////////////////////////////////////////////////////////////////
651 // Transport classes for IP
653 /**This class represents a particular H323 transport using IP.
654 It is used by the TCP and UDP transports.
656 class H323TransportIP : public H323Transport
658 PCLASSINFO(H323TransportIP, H323Transport);
661 /**Create a new transport channel.
664 H323EndPoint & endpoint, ///< H323 End Point object
665 PIPSocket::Address binding, ///< Local interface to use
666 WORD remPort ///< Remote port to use
669 /**Get the transport dependent name of the local endpoint.
671 virtual H323TransportAddress GetLocalAddress() const;
673 /**Get the transport dependent name of the remote endpoint.
675 virtual H323TransportAddress GetRemoteAddress() const;
677 /**Check that the transport address PDU is compatible with transport.
679 virtual BOOL IsCompatibleTransport(
680 const H225_TransportAddress & pdu
683 /**Set up a transport address PDU for RAS channel.
685 virtual void SetUpTransportPDU(
686 H225_TransportAddress & pdu,
690 /**Set up a transport address PDU for logical channel.
692 virtual void SetUpTransportPDU(
693 H245_TransportAddress & pdu,
699 PIPSocket::Address localAddress; // Address of the local interface
701 PIPSocket::Address remoteAddress; // Address of the remote host
706 ///////////////////////////////////////////////////////////////////////////////
707 // Transport classes for TCP/IP
709 /**This class manages H323 connections using TCP/IP transport.
711 class H323ListenerTCP : public H323Listener
713 PCLASSINFO(H323ListenerTCP, H323Listener);
716 /**Create a new listener for the TCP/IP protocol.
719 H323EndPoint & endpoint, ///< Endpoint instance for channel
720 PIPSocket::Address binding, ///< Local interface to listen on
721 WORD port, ///< TCP port to listen for connections
722 BOOL exclusive = FALSE ///< Fail if listener port in use
725 /** Destroy the listener thread.
729 // Overrides from H323Listener
730 /** Open the listener.
734 /**Stop the listener thread and no longer accept incoming connections.
736 virtual BOOL Close();
738 /**Accept a new incoming transport.
740 virtual H323Transport * Accept(
741 const PTimeInterval & timeout ///< Time to wait for incoming connection
744 /**Get the local transport address on which this listener may be accessed.
746 virtual H323TransportAddress GetTransportAddress() const;
748 /**Set up a transport address PDU for bidirectional logical channels.
750 virtual BOOL SetUpTransportPDU(
751 H245_TransportAddress & pdu, ///< Transport addresses listening on
752 const H323Transport & associatedTransport ///< Associated transport for precendence and translation
755 WORD GetListenerPort() const { return listener.GetPort(); }
759 /**Handle incoming H.323 connections and dispatch them in new threads
760 based on the H323Transport class. This is defined in the descendent
761 class that knows what the low level transport is, eg H323ListenerIP
762 for the TCP/IP protocol.
764 Note this function does not return until the Close() function is called
765 or there is some other error.
771 PIPSocket::Address localAddress;
772 BOOL exclusiveListener;
776 /**This class represents a particular H323 transport using TCP/IP.
778 class H323TransportTCP : public H323TransportIP
780 PCLASSINFO(H323TransportTCP, H323TransportIP);
783 /**Create a new transport channel.
786 H323EndPoint & endpoint, ///< H323 End Point object
787 PIPSocket::Address binding = PIPSocket::GetDefaultIpAny(), ///< Local interface to use
788 BOOL listen = FALSE ///< Flag for need to wait for remote to connect
791 /**Destroy transport channel.
795 /**Set default remote address to connect to.
796 Note that this does not necessarily initiate a transport level
797 connection, but only indicates where to connect to. The actual
798 connection is made by the Connect() function.
800 virtual BOOL SetRemoteAddress(
801 const H323TransportAddress & address
804 /**Connect to the remote party.
806 virtual BOOL Connect();
808 /**Close the channel.
810 virtual BOOL Close();
812 /**Read a protocol data unit from the transport.
813 This will read using the transports mechanism for PDU boundaries, for
814 example UDP is a single Read() call, while for TCP there is a TPKT
815 header that indicates the size of the PDU.
818 PBYTEArray & pdu ///< PDU read from transport
821 /**Extract a protocol data unit from the transport
824 const PBYTEArray & pdu,
828 /**Write a protocol data unit from the transport.
829 This will write using the transports mechanism for PDU boundaries, for
830 example UDP is a single Write() call, while for TCP there is a TPKT
831 header that indicates the size of the PDU.
834 const PBYTEArray & pdu ///< PDU to write
837 /**Begin the opening of a control channel.
838 This sets up the channel so that the remote endpoint can connect back
841 virtual H323Transport * CreateControlChannel(
842 H323Connection & connection
845 /**Finish the opening of a control channel.
846 This waits for the connect backfrom the remote endpoint, completing the
847 control channel open sequence.
849 virtual BOOL AcceptControlChannel(
850 H323Connection & connection
853 /**Indicate we are waiting from remote to connect back to us.
855 virtual BOOL IsListening() const;
859 /**This callback is executed when the Open() function is called with
860 open channels. It may be used by descendent channels to do any
861 handshaking required by the protocol that channel embodies.
863 The default behaviour is to simply return TRUE.
866 Returns TRUE if the protocol handshaking is successful.
868 virtual BOOL OnOpen();
871 PTCPSocket * h245listener;
875 ///////////////////////////////////////////////////////////////////////////////
876 // Transport classes for UDP/IP
878 /**This class represents a particular H323 transport using UDP/IP.
880 class H323TransportUDP : public H323TransportIP
882 PCLASSINFO(H323TransportUDP, H323TransportIP);
885 /**Create a new transport channel.
888 H323EndPoint & endpoint, ///< H323 End Point object
889 PIPSocket::Address binding = PIPSocket::GetDefaultIpAny(), ///< Local interface to listen on
890 WORD localPort = 0, ///< Local port to listen on
891 WORD remotePort = 0 ///< Remote port to connect on
895 /**Set default remote address to connect to.
896 Note that this does not necessarily initiate a transport level
897 connection, but only indicates where to connect to. The actual
898 connection is made by the Connect() function.
900 virtual BOOL SetRemoteAddress(
901 const H323TransportAddress & address
904 /**Connect to the remote party.
906 virtual BOOL Connect();
908 /**Set read to promiscuous mode.
909 Normally only reads from the specifed remote address are accepted. This
910 flag allows packets to be accepted from any remote, provided the
911 underlying protocol can do so.
913 The Read() call may optionally set the remote address automatically to
914 whatever the sender host of the last received message was.
916 Default behaviour sets the internal flag, so that Read() operates as
919 virtual void SetPromiscuous(
920 PromisciousModes promiscuous
923 /**Get the transport address of the last received PDU.
925 Default behaviour returns the lastReceivedAddress member variable.
927 virtual H323TransportAddress GetLastReceivedAddress() const;
929 /**Read a protocol data unit from the transport.
930 This will read using the transports mechanism for PDU boundaries, for
931 example UDP is a single Read() call, while for TCP there is a TPKT
932 header that indicates the size of the PDU.
934 virtual BOOL ReadPDU(
935 PBYTEArray & pdu ///< PDU read from transport
938 /**Extract a protocol data unit from the transport
941 const PBYTEArray & pdu,
945 /**Write a protocol data unit from the transport.
946 This will write using the transports mechanism for PDU boundaries, for
947 example UDP is a single Write() call, while for TCP there is a TPKT
948 header that indicates the size of the PDU.
950 virtual BOOL WritePDU(
951 const PBYTEArray & pdu ///< PDU to write
954 /**Discover a Gatekeeper on the local network.
955 This locates a gatekeeper on the network and associates this transport
956 object with packet exchange with that gatekeeper. This broadcasts a UDP
957 packet on the local network to find the gatekeeper's IP address.
959 virtual BOOL DiscoverGatekeeper(
960 H323Gatekeeper & gk, ///< Gatekeeper to set on discovery.
961 H323RasPDU & pdu, ///< GatekeeperRequest PDU
962 const H323TransportAddress & address ///< Address of gatekeeper (if present)
965 /**Get the transport address of the local endpoint.
967 virtual H323TransportAddress GetLocalAddress() const;
970 PromisciousModes promiscuousReads;
971 H323TransportAddress lastReceivedAddress;
972 PIPSocket::Address lastReceivedInterface;
977 #endif // __TRANSPORTS_H
980 /////////////////////////////////////////////////////////////////////////////