|
activemq-cpp-3.3.0
|
00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 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: // Address Property Tests, override in the subclasses for correct results 00100 00106 virtual bool isAnyLocalAddress() const { 00107 return false; 00108 } 00109 00115 virtual bool isLoopbackAddress() const { 00116 return false; 00117 } 00118 00124 virtual bool isMulticastAddress() const { 00125 return false; 00126 } 00127 00133 virtual bool isLinkLocalAddress() const { 00134 return false; 00135 } 00136 00142 virtual bool isSiteLocalAddress() const { 00143 return false; 00144 } 00145 00151 virtual bool isMCGlobal() const { 00152 return false; 00153 } 00154 00160 virtual bool isMCNodeLocal() const { 00161 return false; 00162 } 00163 00169 virtual bool isMCLinkLocal() const { 00170 return false; 00171 } 00172 00178 virtual bool isMCSiteLocal() const { 00179 return false; 00180 } 00181 00187 virtual bool isMCOrgLocal() const { 00188 return false; 00189 } 00190 00191 public: // Static Create methods. 00192 00202 static InetAddress getByAddress( const unsigned char* bytes, int numBytes ); 00203 00215 static InetAddress getByAddress( const std::string& hostname, const unsigned char* bytes, int numBytes ); 00216 00225 static InetAddress getLocalHost(); 00226 00227 protected: 00228 00240 static unsigned int bytesToInt( const unsigned char* bytes, int start ); 00241 00242 static InetAddress getAnyAddress(); 00243 00244 static InetAddress getLoopbackAddress(); 00245 00246 }; 00247 00248 }} 00249 00250 #endif /* _DECAF_NET_INETADDRESS_H_ */