4 * Remote networking connection class.
6 * Portable Windows Library
8 * Copyright (c) 1993-1998 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 Portable Windows Library.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25 * All Rights Reserved.
27 * Contributor(s): ______________________________________.
30 * Revision 1.18 2005/11/25 03:43:47 csoutheren
31 * Fixed function argument comments to be compatible with Doxygen
33 * Revision 1.17 2003/09/17 05:41:59 csoutheren
34 * Removed recursive includes
36 * Revision 1.16 2003/09/17 01:18:02 csoutheren
37 * Removed recursive include file system and removed all references
38 * to deprecated coooperative threading support
40 * Revision 1.15 2002/09/16 01:08:59 robertj
41 * Added #define so can select if #pragma interface/implementation is used on
42 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
44 * Revision 1.14 2001/05/22 12:49:32 robertj
45 * Did some seriously wierd rewrite of platform headers to eliminate the
46 * stupid GNU compiler warning about braces not matching.
48 * Revision 1.13 1999/03/09 02:59:50 robertj
49 * Changed comments to doc++ compatible documentation.
51 * Revision 1.12 1999/02/16 08:11:10 robertj
52 * MSVC 6.0 compatibility changes.
54 * Revision 1.11 1998/09/23 06:21:17 robertj
55 * Added open source copyright license.
57 * Revision 1.10 1998/07/24 06:58:27 robertj
58 * Added ability to get IP number of RAS connection.
60 * Revision 1.9 1998/02/03 06:28:46 robertj
61 * Added more error codes.
63 * Revision 1.8 1998/01/26 00:34:51 robertj
64 * Added parameter to PRemoteConnection to open only if already connected.
65 * Added function to PRemoteConnection to get at OS error code.
67 * Revision 1.7 1997/04/01 06:00:05 robertj
68 * Added Remove Configuration.
70 * Revision 1.6 1997/01/12 04:15:11 robertj
71 * Added ability to add/change new connections.
73 * Revision 1.5 1996/11/04 03:40:43 robertj
74 * Added more debugging for remote drop outs.
76 * Revision 1.4 1996/08/11 07:03:45 robertj
77 * Changed remote connection to late bind DLL.
79 * Revision 1.3 1996/04/23 11:33:04 robertj
80 * Added username and password.
82 * Revision 1.2 1996/03/02 03:09:48 robertj
83 * Added function to get all possible remote access connection names.
85 * Revision 1.1 1995/12/10 13:04:46 robertj
90 #ifndef _PREMOTECONNECTION
91 #define _PREMOTECONNECTION
97 #include <ptlib/pipechan.h>
101 #include <raserror.h>
104 /** Remote Access Connection class.
106 class PRemoteConnection
: public PObject
108 PCLASSINFO(PRemoteConnection
, PObject
);
111 /**@name Construction */
113 /// Create a new remote connection.
116 /**Create a new remote connection.
117 This will initiate the connection using the specified settings.
120 const PString
& name
///< Name of RAS configuration.
123 /// Disconnect remote connection.
124 ~PRemoteConnection();
127 /**@name Overrides from class PObject */
129 /** Compare two connections.
130 @return EqualTo of same RAS connectionconfiguration.
132 virtual Comparison
Compare(
133 const PObject
& obj
///< Another connection instance.
136 /** Get has value for the connection
137 @return Hash value of the connection name string.
139 virtual PINDEX
HashFunction() const;
142 /**@name Dial/Hangup functions */
144 /** Open the remote connection.
147 BOOL existing
= FALSE
///< Flag for open only if already connected.
150 /** Open the remote connection.
153 const PString
& name
, ///< RAS name of of connection to open.
154 BOOL existing
= FALSE
///< Flag for open only if already connected.
157 /** Open the remote connection.
160 const PString
& name
, ///< RAS name of of connection to open.
161 const PString
& username
, ///< Username for remote log in.
162 const PString
& password
, ///< password for remote log in.
163 BOOL existing
= FALSE
///< Flag for open only if already connected.
166 /** Close the remote connection.
167 This will hang up/dosconnect the connection, net access will no longer
168 be available to this site.
173 /**@name Error/Status functions */
175 /// Status codes for remote connection.
177 /// Connection has not been made and no attempt is being made.
179 /// Connection is completed and active.
181 /// Connection is in progress.
183 /// Connection failed due to the line being busy.
185 /// Connection failed due to the line havin no dial tone.
187 /// Connection failed due to the remote not answering.
189 /// Connection failed due to the port being in use.
191 /// Connection failed due to the RAS setting name/number being incorrect.
193 /// Connection failed due to insufficient privilege.
195 /// Connection failed due to a hardware failure.
197 /// Connection failed due to a general failure.
199 /// Connection was lost after successful establishment.
201 /// The Remote Access Operating System support is not installed.
206 /**Get the current status of the RAS connection.
211 Status
GetStatus() const;
213 /**Get the error code for the last operation.
216 Operating system error code.
218 DWORD
GetErrorCode() const { return osError
; }
221 /**@name Information functions */
223 /**Get the name of the RAS connection.
226 String for IP address, or empty string if none.
228 const PString
& GetName() const { return remoteName
; }
230 /**Get the IP address in dotted decimal form for the RAS connection.
233 String for IP address, or empty string if none.
235 PString
GetAddress();
237 /**Get an array of names for all of the available remote connections on
241 Array of strings for remote connection names.
243 static PStringArray
GetAvailableNames();
246 /**@name Configuration functions */
248 /// Structure for a RAS configuration.
249 struct Configuration
{
250 /// Device name for connection eg /dev/modem
252 /// Telephone number to call to make the connection.
254 /// IP address of local machine after connection is made.
256 /// DNS host on remote site.
258 /// Script name for doing remote log in.
260 /// Sub-entry number when Multi-link PPP is used.
262 /// Always establish maximum bandwidth when Multi-link PPP is used.
263 BOOL dialAllSubEntries
;
266 /**Get the configuration of the specified remote access connection.
269 #Connected# if the configuration information was obtained,
270 #NoNameOrNumber# if the particular RAS name does not exist,
271 #NotInstalled# if there is no RAS support in the operating system,
272 #GeneralFailure# on any other error.
274 Status
GetConfiguration(
275 Configuration
& config
///< Configuration of remote connection
278 /**Get the configuration of the specified remote access connection.
281 #Connected# if the configuration information was obtained,
282 #NoNameOrNumber# if the particular RAS name does not exist,
283 #NotInstalled# if there is no RAS support in the operating system,
284 #GeneralFailure# on any other error.
286 static Status
GetConfiguration(
287 const PString
& name
, ///< Remote connection name to get configuration
288 Configuration
& config
///< Configuration of remote connection
291 /**Set the configuration of the specified remote access connection.
294 #Connected# if the configuration information was set,
295 #NoNameOrNumber# if the particular RAS name does not exist,
296 #NotInstalled# if there is no RAS support in the operating system,
297 #GeneralFailure# on any other error.
299 Status
SetConfiguration(
300 const Configuration
& config
, ///< Configuration of remote connection
301 BOOL create
= FALSE
///< Flag to create connection if not present
304 /**Set the configuration of the specified remote access connection.
307 #Connected# if the configuration information was set,
308 #NoNameOrNumber# if the particular RAS name does not exist,
309 #NotInstalled# if there is no RAS support in the operating system,
310 #GeneralFailure# on any other error.
312 static Status
SetConfiguration(
313 const PString
& name
, ///< Remote connection name to configure
314 const Configuration
& config
, ///< Configuration of remote connection
315 BOOL create
= FALSE
///< Flag to create connection if not present
318 /**Remove the specified remote access connection.
321 #Connected# if the configuration information was removed,
322 #NoNameOrNumber# if the particular RAS name does not exist,
323 #NotInstalled# if there is no RAS support in the operating system,
324 #GeneralFailure# on any other error.
326 static Status
RemoveConfiguration(
327 const PString
& name
///< Remote connection name to configure
338 PRemoteConnection(const PRemoteConnection
&) { }
339 void operator=(const PRemoteConnection
&) { }
343 // Include platform dependent part of class
345 #include "msos/ptlib/remconn.h"
347 #include "unix/ptlib/remconn.h"
353 // End Of File ///////////////////////////////////////////////////////////////