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.17 2003/09/17 05:41:59 csoutheren
31 * Removed recursive includes
33 * Revision 1.16 2003/09/17 01:18:02 csoutheren
34 * Removed recursive include file system and removed all references
35 * to deprecated coooperative threading support
37 * Revision 1.15 2002/09/16 01:08:59 robertj
38 * Added #define so can select if #pragma interface/implementation is used on
39 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
41 * Revision 1.14 2001/05/22 12:49:32 robertj
42 * Did some seriously wierd rewrite of platform headers to eliminate the
43 * stupid GNU compiler warning about braces not matching.
45 * Revision 1.13 1999/03/09 02:59:50 robertj
46 * Changed comments to doc++ compatible documentation.
48 * Revision 1.12 1999/02/16 08:11:10 robertj
49 * MSVC 6.0 compatibility changes.
51 * Revision 1.11 1998/09/23 06:21:17 robertj
52 * Added open source copyright license.
54 * Revision 1.10 1998/07/24 06:58:27 robertj
55 * Added ability to get IP number of RAS connection.
57 * Revision 1.9 1998/02/03 06:28:46 robertj
58 * Added more error codes.
60 * Revision 1.8 1998/01/26 00:34:51 robertj
61 * Added parameter to PRemoteConnection to open only if already connected.
62 * Added function to PRemoteConnection to get at OS error code.
64 * Revision 1.7 1997/04/01 06:00:05 robertj
65 * Added Remove Configuration.
67 * Revision 1.6 1997/01/12 04:15:11 robertj
68 * Added ability to add/change new connections.
70 * Revision 1.5 1996/11/04 03:40:43 robertj
71 * Added more debugging for remote drop outs.
73 * Revision 1.4 1996/08/11 07:03:45 robertj
74 * Changed remote connection to late bind DLL.
76 * Revision 1.3 1996/04/23 11:33:04 robertj
77 * Added username and password.
79 * Revision 1.2 1996/03/02 03:09:48 robertj
80 * Added function to get all possible remote access connection names.
82 * Revision 1.1 1995/12/10 13:04:46 robertj
87 #ifndef _PREMOTECONNECTION
88 #define _PREMOTECONNECTION
94 #include <ptlib/pipechan.h>
101 /** Remote Access Connection class.
103 class PRemoteConnection
: public PObject
105 PCLASSINFO(PRemoteConnection
, PObject
);
108 /**@name Construction */
110 /// Create a new remote connection.
113 /**Create a new remote connection.
114 This will initiate the connection using the specified settings.
117 const PString
& name
/// Name of RAS configuration.
120 /// Disconnect remote connection.
121 ~PRemoteConnection();
124 /**@name Overrides from class PObject */
126 /** Compare two connections.
127 @return EqualTo of same RAS connectionconfiguration.
129 virtual Comparison
Compare(
130 const PObject
& obj
/// Another connection instance.
133 /** Get has value for the connection
134 @return Hash value of the connection name string.
136 virtual PINDEX
HashFunction() const;
139 /**@name Dial/Hangup functions */
141 /** Open the remote connection.
144 BOOL existing
= FALSE
/// Flag for open only if already connected.
147 /** Open the remote connection.
150 const PString
& name
, /// RAS name of of connection to open.
151 BOOL existing
= FALSE
/// Flag for open only if already connected.
154 /** Open the remote connection.
157 const PString
& name
, /// RAS name of of connection to open.
158 const PString
& username
, /// Username for remote log in.
159 const PString
& password
, /// password for remote log in.
160 BOOL existing
= FALSE
/// Flag for open only if already connected.
163 /** Close the remote connection.
164 This will hang up/dosconnect the connection, net access will no longer
165 be available to this site.
170 /**@name Error/Status functions */
172 /// Status codes for remote connection.
174 /// Connection has not been made and no attempt is being made.
176 /// Connection is completed and active.
178 /// Connection is in progress.
180 /// Connection failed due to the line being busy.
182 /// Connection failed due to the line havin no dial tone.
184 /// Connection failed due to the remote not answering.
186 /// Connection failed due to the port being in use.
188 /// Connection failed due to the RAS setting name/number being incorrect.
190 /// Connection failed due to insufficient privilege.
192 /// Connection failed due to a hardware failure.
194 /// Connection failed due to a general failure.
196 /// Connection was lost after successful establishment.
198 /// The Remote Access Operating System support is not installed.
203 /**Get the current status of the RAS connection.
208 Status
GetStatus() const;
210 /**Get the error code for the last operation.
213 Operating system error code.
215 DWORD
GetErrorCode() const { return osError
; }
218 /**@name Information functions */
220 /**Get the name of the RAS connection.
223 String for IP address, or empty string if none.
225 const PString
& GetName() const { return remoteName
; }
227 /**Get the IP address in dotted decimal form for the RAS connection.
230 String for IP address, or empty string if none.
232 PString
GetAddress();
234 /**Get an array of names for all of the available remote connections on
238 Array of strings for remote connection names.
240 static PStringArray
GetAvailableNames();
243 /**@name Configuration functions */
245 /// Structure for a RAS configuration.
246 struct Configuration
{
247 /// Device name for connection eg /dev/modem
249 /// Telephone number to call to make the connection.
251 /// IP address of local machine after connection is made.
253 /// DNS host on remote site.
255 /// Script name for doing remote log in.
257 /// Sub-entry number when Multi-link PPP is used.
259 /// Always establish maximum bandwidth when Multi-link PPP is used.
260 BOOL dialAllSubEntries
;
263 /**Get the configuration of the specified remote access connection.
266 #Connected# if the configuration information was obtained,
267 #NoNameOrNumber# if the particular RAS name does not exist,
268 #NotInstalled# if there is no RAS support in the operating system,
269 #GeneralFailure# on any other error.
271 Status
GetConfiguration(
272 Configuration
& config
/// Configuration of remote connection
275 /**Get the configuration of the specified remote access connection.
278 #Connected# if the configuration information was obtained,
279 #NoNameOrNumber# if the particular RAS name does not exist,
280 #NotInstalled# if there is no RAS support in the operating system,
281 #GeneralFailure# on any other error.
283 static Status
GetConfiguration(
284 const PString
& name
, /// Remote connection name to get configuration
285 Configuration
& config
// Configuration of remote connection
288 /**Set the configuration of the specified remote access connection.
291 #Connected# if the configuration information was set,
292 #NoNameOrNumber# if the particular RAS name does not exist,
293 #NotInstalled# if there is no RAS support in the operating system,
294 #GeneralFailure# on any other error.
296 Status
SetConfiguration(
297 const Configuration
& config
, /// Configuration of remote connection
298 BOOL create
= FALSE
/// Flag to create connection if not present
301 /**Set the configuration of the specified remote access connection.
304 #Connected# if the configuration information was set,
305 #NoNameOrNumber# if the particular RAS name does not exist,
306 #NotInstalled# if there is no RAS support in the operating system,
307 #GeneralFailure# on any other error.
309 static Status
SetConfiguration(
310 const PString
& name
, /// Remote connection name to configure
311 const Configuration
& config
, /// Configuration of remote connection
312 BOOL create
= FALSE
/// Flag to create connection if not present
315 /**Remove the specified remote access connection.
318 #Connected# if the configuration information was removed,
319 #NoNameOrNumber# if the particular RAS name does not exist,
320 #NotInstalled# if there is no RAS support in the operating system,
321 #GeneralFailure# on any other error.
323 static Status
RemoveConfiguration(
324 const PString
& name
/// Remote connection name to configure
335 PRemoteConnection(const PRemoteConnection
&) { }
336 void operator=(const PRemoteConnection
&) { }
340 // Include platform dependent part of class
342 #include "msos/ptlib/remconn.h"
344 #include "unix/ptlib/remconn.h"
350 // End Of File ///////////////////////////////////////////////////////////////