activemq-cpp-3.8.2
InetAddress.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _DECAF_NET_INETADDRESS_H_
19 #define _DECAF_NET_INETADDRESS_H_
20 
21 #include <decaf/util/Config.h>
22 
24 
25 namespace decaf {
26 namespace net {
27 
34  protected:
35 
36  static const unsigned char loopbackBytes[4];
37  static const unsigned char anyBytes[4];
38 
39  protected:
40 
41  mutable std::string hostname;
42  mutable bool reached;
44 
45  protected:
46 
47  InetAddress();
48  InetAddress(const unsigned char* ipAddress, int numBytes);
49  InetAddress(const std::string& hostname, const unsigned char* ipAddress, int numBytes);
50 
51  public:
52 
53  virtual ~InetAddress();
54 
61  virtual decaf::lang::ArrayPointer<unsigned char> getAddress() const;
62 
68  virtual std::string getHostAddress() const;
69 
80  virtual std::string getHostName() const;
81 
89  virtual std::string toString() const;
90 
97  virtual InetAddress* clone() const;
98 
99  public:
100  // Address Property Tests, override in the subclasses for correct results
101 
107  virtual bool isAnyLocalAddress() const {
108  return false;
109  }
110 
116  virtual bool isLoopbackAddress() const {
117  return false;
118  }
119 
125  virtual bool isMulticastAddress() const {
126  return false;
127  }
128 
134  virtual bool isLinkLocalAddress() const {
135  return false;
136  }
137 
143  virtual bool isSiteLocalAddress() const {
144  return false;
145  }
146 
152  virtual bool isMCGlobal() const {
153  return false;
154  }
155 
161  virtual bool isMCNodeLocal() const {
162  return false;
163  }
164 
170  virtual bool isMCLinkLocal() const {
171  return false;
172  }
173 
179  virtual bool isMCSiteLocal() const {
180  return false;
181  }
182 
188  virtual bool isMCOrgLocal() const {
189  return false;
190  }
191 
192  public:
193  // Static Create methods.
194 
204  static InetAddress getByAddress(const unsigned char* bytes, int numBytes);
205 
217  static InetAddress getByAddress(const std::string& hostname, const unsigned char* bytes, int numBytes);
218 
227  static InetAddress getLocalHost();
228 
229  protected:
230 
242  static unsigned int bytesToInt(const unsigned char* bytes, int start);
243 
244  static InetAddress getAnyAddress();
245 
246  static InetAddress getLoopbackAddress();
247 
248  };
249 
250 }}
251 
252 #endif /* _DECAF_NET_INETADDRESS_H_ */
virtual bool isSiteLocalAddress() const
Check if this InetAddress is a valid site local address.
Definition: InetAddress.h:143
virtual bool isMCGlobal() const
Check if this InetAddress is Multicast and has Global scope.
Definition: InetAddress.h:152
virtual bool isMCSiteLocal() const
Check if this InetAddress is Multicast and has Site Local scope.
Definition: InetAddress.h:179
virtual bool isMCOrgLocal() const
Check if this InetAddress is Multicast and has Organization scope.
Definition: InetAddress.h:188
std::string hostname
Definition: InetAddress.h:41
virtual bool isAnyLocalAddress() const
Check if this InetAddress is a valid wildcard address.
Definition: InetAddress.h:107
Represents an IP address.
Definition: InetAddress.h:33
virtual bool isLoopbackAddress() const
Check if this InetAddress is a valid loopback address.
Definition: InetAddress.h:116
virtual bool isMCLinkLocal() const
Check if this InetAddress is Multicast and has Link Local scope.
Definition: InetAddress.h:170
#define DECAF_API
Definition: Config.h:29
virtual bool isMCNodeLocal() const
Check if this InetAddress is Multicast and has Node Local scope.
Definition: InetAddress.h:161
virtual bool isMulticastAddress() const
Check if this InetAddress is a valid Multicast address.
Definition: InetAddress.h:125
decaf::lang::ArrayPointer< unsigned char > addressBytes
Definition: InetAddress.h:43
bool reached
Definition: InetAddress.h:42
virtual bool isLinkLocalAddress() const
Check if this InetAddress is a valid link local address.
Definition: InetAddress.h:134
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25