00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef CEYLAN_NETWORK_H_
00028 #define CEYLAN_NETWORK_H_
00029
00030
00031 #include "CeylanException.h"
00032 #include "CeylanTextDisplayable.h"
00033 #include "CeylanTypes.h"
00034
00035
00036 #include <string>
00037 #include <list>
00038
00039
00040
00041
00042 namespace Ceylan
00043 {
00044
00045
00046
00055 namespace Network
00056 {
00057
00058
00060 class CEYLAN_DLL NetworkException: public Ceylan::Exception
00061 {
00062
00063 public:
00064 explicit NetworkException( const std::string & message ) ;
00065
00066 virtual ~NetworkException() throw() ;
00067
00068 } ;
00069
00070
00071
00072
00077 enum NetworkAddressType
00078 {
00079
00080
00081 IPv4,
00082
00083
00084 IPv6
00085
00086
00087 } ;
00088
00089
00090
00091
00092
00093 class IPAddress ;
00094
00095
00096
00097
00104 class CEYLAN_DLL HostDNSEntry: public Ceylan::TextDisplayable
00105 {
00106
00107
00108
00119 struct SystemSpecificHostEntry ;
00120
00121
00122
00123 public:
00124
00125
00138 explicit HostDNSEntry( const std::string & hostName ) ;
00139
00140
00141
00155 explicit HostDNSEntry( const IPAddress & ip ) ;
00156
00157
00158
00160 virtual ~HostDNSEntry() throw() ;
00161
00162
00163
00170 std::string getOfficialHostName() const ;
00171
00172
00173
00181 std::list<std::string> & getAliasList() const ;
00182
00183
00184
00193 NetworkAddressType getAddressType() const ;
00194
00195
00196
00204 std::list<IPAddress *> & getAddresses() const ;
00205
00206
00207
00219 virtual const std::string toString(
00220 Ceylan::VerbosityLevels level = Ceylan::high ) const ;
00221
00222
00223
00225 static const Ceylan::Uint16 HostNameMaxLength ;
00226
00227
00228
00229
00230 protected:
00231
00232
00237 virtual void manageHostEntry() ;
00238
00239
00240
00245 SystemSpecificHostEntry * _internalEntry ;
00246
00247
00248
00249
00250 private:
00251
00252
00253
00262 HostDNSEntry( const HostDNSEntry & source ) ;
00263
00264
00265
00274 HostDNSEntry & operator = ( const HostDNSEntry & source ) ;
00275
00276
00277 } ;
00278
00279
00280
00281
00282
00283
00284
00285
00287 CEYLAN_DLL const std::string getLocalHostName() ;
00288
00289
00290
00301 CEYLAN_DLL void setLocalHostName( const std::string & newHostName ) ;
00302
00303
00304
00317 CEYLAN_DLL const std::string getLocalHostDomainName() ;
00318
00319
00320
00322 CEYLAN_DLL void setLocalHostDomainName(
00323 const std::string & newHostName ) ;
00324
00325
00326
00342 CEYLAN_DLL const std::string getMostPreciseLocalHostName() ;
00343
00344
00345
00346
00347
00348
00349
00350
00359 CEYLAN_DLL const std::string getFQDNFromIP( const IPAddress & ip ) ;
00360
00361
00362
00370 CEYLAN_DLL const std::string getFQDNFromIPv4(
00371 const std::string & ipString ) ;
00372
00373
00374
00383 CEYLAN_DLL const std::string getFQDNFromHostname(
00384 const std::string & hostname ) ;
00385
00386
00387
00395 CEYLAN_DLL const std::string getFQDNFromDNSEntry(
00396 const HostDNSEntry & entry ) ;
00397
00398
00399
00409 CEYLAN_DLL bool isAValidHostName( const std::string & hostnameString ) ;
00410
00411
00412
00418 typedef int SocketError ;
00419
00420
00421
00429 CEYLAN_DLL std::string interpretSocketError( SocketError errorCode ) ;
00430
00431
00432
00434 CEYLAN_DLL SocketError getSocketError() ;
00435
00436
00438 CEYLAN_DLL std::string explainSocketError() ;
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450 #ifdef CEYLAN_RUNS_ON_WINDOWS
00451
00452
00453
00461 class CEYLAN_DLL NetworkManager
00462 {
00463
00464
00465 public:
00466
00467
00469 NetworkManager() ;
00470
00471
00473 ~NetworkManager() throw() ;
00474
00475
00476
00477 private:
00478
00479
00480
00482 static NetworkManager _Manager ;
00483
00484
00493 NetworkManager( const NetworkManager & source ) ;
00494
00495
00496
00505 NetworkManager & operator = ( const NetworkManager & source ) ;
00506
00507
00508 } ;
00509
00510
00511
00512 #endif // CEYLAN_RUNS_ON_WINDOWS
00513
00514
00515
00516 }
00517
00518 }
00519
00520
00521
00522 #endif // CEYLAN_NETWORK_H_
00523