00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _DECAF_NET_INETADDRESS_H_
00019 #define _DECAF_NET_INETADDRESS_H_
00020
00021 #include <decaf/util/Config.h>
00022
00023 #include <decaf/lang/ArrayPointer.h>
00024
00025 namespace decaf {
00026 namespace net {
00027
00033 class DECAF_API InetAddress {
00034 protected:
00035
00036 static const unsigned char loopbackBytes[4];
00037 static const unsigned char anyBytes[4];
00038
00039 protected:
00040
00041 mutable std::string hostname;
00042 mutable bool reached;
00043 mutable decaf::lang::ArrayPointer<unsigned char> addressBytes;
00044
00045 protected:
00046
00047 InetAddress();
00048 InetAddress(const unsigned char* ipAddress, int numBytes);
00049 InetAddress(const std::string& hostname, const unsigned char* ipAddress, int numBytes);
00050
00051 public:
00052
00053 virtual ~InetAddress();
00054
00061 virtual decaf::lang::ArrayPointer<unsigned char> getAddress() const;
00062
00068 virtual std::string getHostAddress() const;
00069
00080 virtual std::string getHostName() const;
00081
00089 virtual std::string toString() const;
00090
00097 virtual InetAddress* clone() const;
00098
00099 public:
00100
00101
00107 virtual bool isAnyLocalAddress() const {
00108 return false;
00109 }
00110
00116 virtual bool isLoopbackAddress() const {
00117 return false;
00118 }
00119
00125 virtual bool isMulticastAddress() const {
00126 return false;
00127 }
00128
00134 virtual bool isLinkLocalAddress() const {
00135 return false;
00136 }
00137
00143 virtual bool isSiteLocalAddress() const {
00144 return false;
00145 }
00146
00152 virtual bool isMCGlobal() const {
00153 return false;
00154 }
00155
00161 virtual bool isMCNodeLocal() const {
00162 return false;
00163 }
00164
00170 virtual bool isMCLinkLocal() const {
00171 return false;
00172 }
00173
00179 virtual bool isMCSiteLocal() const {
00180 return false;
00181 }
00182
00188 virtual bool isMCOrgLocal() const {
00189 return false;
00190 }
00191
00192 public:
00193
00194
00204 static InetAddress getByAddress(const unsigned char* bytes, int numBytes);
00205
00217 static InetAddress getByAddress(const std::string& hostname, const unsigned char* bytes, int numBytes);
00218
00227 static InetAddress getLocalHost();
00228
00229 protected:
00230
00242 static unsigned int bytesToInt(const unsigned char* bytes, int start);
00243
00244 static InetAddress getAnyAddress();
00245
00246 static InetAddress getLoopbackAddress();
00247
00248 };
00249
00250 }}
00251
00252 #endif