activemq-cpp-3.9.5
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
25namespace decaf {
26namespace 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
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
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
228
229 protected:
230
242 static unsigned int bytesToInt(const unsigned char* bytes, int start);
243
245
247
248 };
249
250}}
251
252#endif /* _DECAF_NET_INETADDRESS_H_ */
Decaf's implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition ArrayPointer.h:51
virtual bool isLoopbackAddress() const
Check if this InetAddress is a valid loopback address.
Definition InetAddress.h:116
decaf::lang::ArrayPointer< unsigned char > addressBytes
Definition InetAddress.h:43
static InetAddress getByAddress(const unsigned char *bytes, int numBytes)
Given a raw IP Address in byte array form, create and return a new InetAddress instance.
virtual std::string toString() const
Returns a string representation of the InetAddress in the form 'hostname / ipaddress'.
static InetAddress getByAddress(const std::string &hostname, const unsigned char *bytes, int numBytes)
Given a host name and IPAddress return a new InetAddress.
static InetAddress getLocalHost()
Gets an InetAddress that is the local host address.
virtual bool isMCGlobal() const
Check if this InetAddress is Multicast and has Global scope.
Definition InetAddress.h:152
virtual bool isMCOrgLocal() const
Check if this InetAddress is Multicast and has Organization scope.
Definition InetAddress.h:188
virtual decaf::lang::ArrayPointer< unsigned char > getAddress() const
Returns the Raw IP address in Network byte order.
virtual bool isSiteLocalAddress() const
Check if this InetAddress is a valid site local address.
Definition InetAddress.h:143
virtual bool isMCSiteLocal() const
Check if this InetAddress is Multicast and has Site Local scope.
Definition InetAddress.h:179
virtual bool isLinkLocalAddress() const
Check if this InetAddress is a valid link local address.
Definition InetAddress.h:134
std::string hostname
Definition InetAddress.h:41
virtual bool isAnyLocalAddress() const
Check if this InetAddress is a valid wildcard address.
Definition InetAddress.h:107
static InetAddress getLoopbackAddress()
bool reached
Definition InetAddress.h:42
InetAddress(const unsigned char *ipAddress, int numBytes)
virtual bool isMCLinkLocal() const
Check if this InetAddress is Multicast and has Link Local scope.
Definition InetAddress.h:170
static const unsigned char loopbackBytes[4]
Definition InetAddress.h:36
virtual std::string getHostAddress() const
Returns a textual representation of the IP Address.
virtual bool isMulticastAddress() const
Check if this InetAddress is a valid Multicast address.
Definition InetAddress.h:125
InetAddress(const std::string &hostname, const unsigned char *ipAddress, int numBytes)
virtual InetAddress * clone() const
Returns a newly allocated copy of this InetAddress.
static InetAddress getAnyAddress()
virtual std::string getHostName() const
Get the host name associated with this InetAddress instance.
static const unsigned char anyBytes[4]
Definition InetAddress.h:37
static unsigned int bytesToInt(const unsigned char *bytes, int start)
Converts the bytes in an address array to an int starting from the value start treating the start val...
virtual bool isMCNodeLocal() const
Check if this InetAddress is Multicast and has Node Local scope.
Definition InetAddress.h:161
#define DECAF_API
Definition Config.h:29
Definition URLStreamHandlerManager.h:26
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25