43 #ifndef COMMONCPP_ADDRESS_H_
44 #define COMMONCPP_ADDRESS_H_
46 #ifndef COMMONCPP_CONFIG_H_
47 #include <commoncpp/config.h>
50 #ifndef COMMONCPP_THREAD_H_
54 #ifndef COMMMONCPP_EXCEPTION_H_
62 #define INET_IPV4_ADDRESS_SIZE 16
63 #define CIDR_IPV4_ADDRESS_SIZE 32
64 #define INET_IPV6_ADDRESS_SIZE 40
65 #define CIDR_IPV6_ADDRESS_SIZE 45
68 #define InetAddress IPV4Address
69 #define InetHostAddress IPV4Host
70 #define InetMaskAddress IPV4Mask
71 #define InetMcastAddress IPV4Multicast
72 #define InetMcastAddressValidator IPV4MulticastValidator
73 #define InetAddrValidator IPV4Validator
74 #define BroadcastAddress IPV4Broadcast
79 typedef unsigned short tpport_t;
109 operator()(
const in_addr address)
const = 0;
137 void operator()(
const in_addr address)
const;
150 struct in_addr netmask, network;
152 unsigned getMask(
const char *cp)
const;
159 inline struct in_addr getNetwork(void) const
167 inline struct in_addr getNetmask(void) const
175 struct in_addr getBroadcast(void) const;
183 void set(
const char *cidr);
210 bool isMember(
const struct sockaddr *saddr)
const;
218 bool isMember(
const struct in_addr &inaddr)
const;
220 inline bool operator==(
const struct sockaddr *a)
const
221 {
return isMember(a);}
223 inline bool operator==(
const struct in_addr &a)
const
224 {
return isMember(a);}
238 struct in6_addr netmask, network;
240 unsigned getMask(
const char *cp)
const;
247 inline struct in6_addr getNetwork(void) const
255 inline struct in6_addr getNetmask(void) const
263 struct in6_addr getBroadcast(void) const;
271 void set(
const char *cidr);
298 bool isMember(
const struct sockaddr *saddr)
const;
306 bool isMember(
const struct in6_addr &inaddr)
const;
308 inline bool operator==(
const struct sockaddr *sa)
const
309 {
return isMember(sa);}
311 inline bool operator==(
const struct in6_addr &a)
const
312 {
return isMember(a);}
339 const InetAddrValidator *validator;
342 struct in_addr * ipaddr;
344 mutable char* hostname;
345 #if defined(_MSWINDOWS_)
357 bool setIPAddress(
const char *host);
365 void setAddress(
const char *host);
375 IPV4Address(
const InetAddrValidator *validator = NULL);
385 IPV4Address(
struct in_addr
addr,
const InetAddrValidator *validator = NULL);
397 IPV4Address(
const char *address,
const InetAddrValidator *validator = NULL);
415 const char *getHostname(
void)
const;
424 bool isInetAddress(
void)
const;
433 struct in_addr getAddress(void) const;
446 struct in_addr getAddress(size_t i) const;
466 {
return *
this = (
unsigned long) addr; }
468 inline bool operator!()
const
469 {
return !isInetAddress();}
479 bool operator==(
const IPV4Address &a)
const;
488 bool operator!=(
const IPV4Address &a)
const;
532 {
return IPV4Address::operator =(addr); }
576 {
return IPV4Address::operator =(addr); }
654 extern __EXPORT std::ostream& operator<<(std::ostream &os,
const IPV4Address &ia);
656 inline struct in_addr getaddress(const
IPV4Address &ia)
657 {
return ia.getAddress();}
689 virtual void operator()(
const in6_addr address)
const = 0;
717 void operator()(
const in6_addr address)
const;
745 struct in6_addr * ipaddr;
747 mutable char* hostname;
748 #if defined(_MSWINDOWS_)
760 bool setIPAddress(
const char *host);
768 void setAddress(
const char *host);
818 const char *getHostname(
void)
const;
827 bool isInetAddress(
void)
const;
836 struct in6_addr getAddress(void) const;
849 struct in6_addr getAddress(size_t i) const;
862 inline bool operator!()
const
863 {
return !isInetAddress();}
873 bool operator==(
const IPV6Address &a)
const;
882 bool operator!=(
const IPV6Address &a)
const;
1030 extern __EXPORT std::ostream& operator<<(std::ostream &os,
const IPV6Address &ia);
1032 inline struct in6_addr getaddress(const
IPV6Address &ia)
1033 {
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...
Common C++ thread class and sychronization objects.
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()
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...
virtual ~IPV6Validator()
Keeps compilers happy.
virtual ~IPV6MulticastValidator()
Keeps compilers happy...
Class for the function object that validates multicast addresses.
virtual ~IPV4MulticastValidator()
Keeps compilers happy.
struct sockaddr * addr(Socket::address &address)
A convenience function to convert a socket address list into a socket address.
This object is used to hold the actual and valid internet address of a specific host machine that wil...
GNU Common C++ exception model base classes.