44 #ifndef COMMONCPP_ADDRESS_H_
45 #define COMMONCPP_ADDRESS_H_
47 #ifndef COMMONCPP_CONFIG_H_
48 #include <commoncpp/config.h>
51 #ifndef COMMONCPP_THREAD_H_
55 #ifndef COMMMONCPP_EXCEPTION_H_
63 #define INET_IPV4_ADDRESS_SIZE 16
64 #define CIDR_IPV4_ADDRESS_SIZE 32
65 #define INET_IPV6_ADDRESS_SIZE 40
66 #define CIDR_IPV6_ADDRESS_SIZE 45
69 #define InetAddress IPV4Address
70 #define InetHostAddress IPV4Host
71 #define InetMaskAddress IPV4Mask
72 #define InetMcastAddress IPV4Multicast
73 #define InetMcastAddressValidator IPV4MulticastValidator
74 #define InetAddrValidator IPV4Validator
75 #define BroadcastAddress IPV4Broadcast
80 typedef unsigned short tpport_t;
110 operator()(
const in_addr address)
const = 0;
138 void operator()(
const in_addr address)
const;
151 struct in_addr netmask, network;
153 unsigned getMask(
const char *cp)
const;
160 inline struct in_addr getNetwork(void) const
168 inline struct in_addr getNetmask(void) const
176 struct in_addr getBroadcast(void) const;
184 void set(
const char *cidr);
211 bool isMember(
const struct sockaddr *saddr)
const;
219 bool isMember(
const struct in_addr &inaddr)
const;
221 inline bool operator==(
const struct sockaddr *a)
const
222 {
return isMember(a);}
224 inline bool operator==(
const struct in_addr &a)
const
225 {
return isMember(a);}
239 struct in6_addr netmask, network;
241 unsigned getMask(
const char *cp)
const;
248 inline struct in6_addr getNetwork(void) const
256 inline struct in6_addr getNetmask(void) const
264 struct in6_addr getBroadcast(void) const;
272 void set(
const char *cidr);
299 bool isMember(
const struct sockaddr *saddr)
const;
307 bool isMember(
const struct in6_addr &inaddr)
const;
309 inline bool operator==(
const struct sockaddr *sa)
const
310 {
return isMember(sa);}
312 inline bool operator==(
const struct in6_addr &a)
const
313 {
return isMember(a);}
340 const InetAddrValidator *validator;
343 struct in_addr * ipaddr;
345 mutable char* hostname;
346 #if defined(_MSWINDOWS_)
358 bool setIPAddress(
const char *host);
366 void setAddress(
const char *host);
376 IPV4Address(
const InetAddrValidator *validator = NULL);
386 IPV4Address(
struct in_addr
addr,
const InetAddrValidator *validator = NULL);
398 IPV4Address(
const char *address,
const InetAddrValidator *validator = NULL);
416 const char *getHostname(
void)
const;
425 bool isInetAddress(
void)
const;
434 struct in_addr getAddress(void) const;
447 struct in_addr getAddress(size_t i) const;
467 {
return *
this = (
unsigned long) addr; }
469 inline bool operator!()
const
470 {
return !isInetAddress();}
480 bool operator==(
const IPV4Address &a)
const;
489 bool operator!=(
const IPV4Address &a)
const;
533 {
return IPV4Address::operator =(addr); }
577 {
return IPV4Address::operator =(addr); }
655 extern __EXPORT std::ostream& operator<<(std::ostream &os,
const IPV4Address &ia);
657 inline struct in_addr getaddress(const
IPV4Address &ia)
658 {
return ia.getAddress();}
690 virtual void operator()(
const in6_addr address)
const = 0;
718 void operator()(
const in6_addr address)
const;
746 struct in6_addr * ipaddr;
748 mutable char* hostname;
749 #if defined(_MSWINDOWS_)
761 bool setIPAddress(
const char *host);
769 void setAddress(
const char *host);
819 const char *getHostname(
void)
const;
828 bool isInetAddress(
void)
const;
837 struct in6_addr getAddress(void) const;
850 struct in6_addr getAddress(size_t i) const;
863 inline bool operator!()
const
864 {
return !isInetAddress();}
874 bool operator==(
const IPV6Address &a)
const;
883 bool operator!=(
const IPV6Address &a)
const;
1031 extern __EXPORT std::ostream& operator<<(std::ostream &os,
const IPV6Address &ia);
1033 inline struct in6_addr getaddress(const
IPV6Address &ia)
1034 {
return ia.getAddress();}
IPV4Validator()
Constructor.
size_t getAddressCount() const
Returns the number of internet addresses that an IPV4Address object contains.
The CIDR class is used to support routing tables and validate address policies.
IPV6MulticastValidator()
Constructor.
Classes derived from IPV4Address would require an specific validator to pass to the IPV4Address const...
A specialization of IPV4Address that provides address validation for multicast addresses.
virtual ~IPV4Validator()
keeps compilers happy.
The CIDR class is used to support routing tables and validate address policies.
IPV4Address & operator=(unsigned long addr)
Allows assignment from the return of functions like inet_addr() or htonl()
The Mutex Counter is a counter variable which can safely be incremented or decremented by multiple th...
A specialization of IPV6Address that provides address validation for multicast addresses.
Class for the function object that validates multicast addresses.
Internet addresses used specifically as masking addresses (such as " 255.255.255.0") are held in the ...
size_t getAddressCount() const
Returns the number of internet addresses that an IPV6Address object contains.
The broadcast address object is used to store the broadcast address for a specific subnet...
IPV4Address & operator=(unsigned long addr)
Allows assignment from the return of functions like inet_addr() or htonl()
struct sockaddr * addr(Socket::address &address)
A convenience function to convert a socket address list into a socket address.
IPV4MulticastValidator()
Constructor.
The broadcast address object is used to store the broadcast address for a specific subnet...
Internet addresses used specifically as masking addresses (such as " 255.255.255.0") are held in the ...
The network name and address objects are all derived from a common IPV4Address base class...
Classes derived from IPV6Address would require an specific validator to pass to the IPV6Address const...
IPV6Validator()
Constructor.
This object is used to hold the actual and valid internet address of a specific host machine that wil...
The network name and address objects are all derived from a common IPV6Address base class...
Common C++ thread class and sychronization objects.
virtual ~IPV6Validator()
Keeps compilers happy.
virtual ~IPV6MulticastValidator()
Keeps compilers happy...
Class for the function object that validates multicast addresses.
GNU Common C++ exception model base classes.
virtual ~IPV4MulticastValidator()
Keeps compilers happy.
This object is used to hold the actual and valid internet address of a specific host machine that wil...