Go to the documentation of this file.
44 #ifndef CCXX_ADDRESS_H_
45 #define CCXX_ADDRESS_H_
47 #ifndef CCXX_CONFIG_H_
51 #ifndef CCXX_MISSING_H_
55 #ifndef CCXX_THREAD_H_
59 #ifndef CCXX_EXCEPTION_H_
63 #ifdef CCXX_NAMESPACES
69 #define INET_IPV4_ADDRESS_SIZE 16
70 #define CIDR_IPV4_ADDRESS_SIZE 32
71 #define INET_IPV6_ADDRESS_SIZE 40
72 #define CIDR_IPV6_ADDRESS_SIZE 45
75 #define InetAddress IPV4Address
76 #define InetHostAddress IPV4Host
77 #define InetMaskAddress IPV4Mask
78 #define InetMcastAddress IPV4Multicast
79 #define InetMcastAddressValidator IPV4MulticastValidator
80 #define InetAddrValidator IPV4Validator
81 #define BroadcastAddress IPV4Broadcast
146 #if __BYTE_ORDER == __BIG_ENDIAN
148 MCAST_VALID_MASK = 0xF0000000,
149 MCAST_VALID_VALUE = 0xE0000000
153 MCAST_VALID_MASK = 0x000000F0,
154 MCAST_VALID_VALUE = 0x000000E0
169 struct in_addr netmask, network;
171 unsigned getMask(
const char *cp)
const;
178 inline struct in_addr getNetwork(void) const
186 inline struct in_addr getNetmask(void) const
194 struct in_addr getBroadcast(void) const;
202 void set(
const char *cidr);
240 {
return isMember(a);};
243 {
return isMember(a);};
257 struct in6_addr netmask, network;
259 unsigned getMask(
const char *cp)
const;
266 inline struct in6_addr getNetwork(void) const
274 inline struct in6_addr getNetmask(void) const
282 struct in6_addr getBroadcast(void) const;
290 void set(
const char *cidr);
325 bool isMember(
const struct in6_addr &inaddr)
const;
328 {
return isMember(sa);};
331 {
return isMember(a);};
452 struct in_addr getAddress(void) const;
465 struct in_addr getAddress(size_t i) const;
485 {
return *
this = (
unsigned long) addr; }
488 {
return !isInetAddress();};
676 {
return ia.getAddress();}
855 struct in6_addr getAddress(void) const;
868 struct in6_addr getAddress(size_t i) const;
882 {
return !isInetAddress();};
1052 {
return ia.getAddress();}
1057 #ifdef CCXX_NAMESPACES
A specialization of IPV4Address that provides address validation for multicast addresses.
Definition: address.h:635
bool isMember(const struct sockaddr *saddr) const
See if a socket address is a member of this cidr's network.
unsigned short tpport_t
Transport Protocol Ports.
Definition: address.h:86
static Mutex mutex
Definition: address.h:367
IPV6Host & operator&=(const IPV6Mask &mask)
Mask the internet host address object with a network mask address.
IPV4Cidr(IPV4Cidr &)
Construct a copy of a cidr.
void setAddress(const char *host)
Used to specify a host name or numeric internet address.
Internet addresses used specifically as masking addresses (such as " 255.255.255.0") are held in the ...
Definition: address.h:523
This object is used to hold the actual and valid internet address of a specific host machine that wil...
Definition: address.h:562
IPV4Host(struct in_addr addr)
Convert a system socket binary address such as may be returned through the accept() call or getsockpe...
friend __EXPORT IPV6Host operator&(const IPV6Host &addr, const IPV6Mask &mask)
Masks are usually used to coerce host addresses into a specific router or class domain.
IPV4Address(const char *address, const IPV4Validator *validator=NULL)
Convert a null terminated ASCII host address string (example: "127.0.0.1") or host address name (exam...
IPV4Multicast(const struct in_addr address)
Convert the system internet address data type (struct in_addr) into a Common C++ IPV4Multicast object...
bool isInetAddress(void) const
May be used to verify if a given IPV4Address returned by another function contains a "valid" address,...
friend __EXPORT IPV6Host operator&(const IPV6Host &addr, const IPV6Mask &mask)
const char * getHostname(void) const
Provide a string representation of the value (Internet Address) held in the IPV4Address object.
size_t addr_count
Definition: address.h:765
bool operator==(const struct in_addr &a) const
Definition: address.h:242
IPV6Address(const char *address, const IPV6Validator *validator=NULL)
Convert a null terminated ASCII host address string (example: "127.0.0.1") or host address name (exam...
IPV6Multicast(const struct in6_addr address)
Convert the system internet address data type (struct in_addr) into a Common C++ IPV4Multicast object...
virtual void operator()(const in_addr address) const =0
Pure virtual application operator.
Internet addresses used specifically as masking addresses (such as " 255.255.255.0") are held in the ...
Definition: address.h:917
struct in6_addr * ipaddr
Definition: address.h:764
This object is used to hold the actual and valid internet address of a specific host machine that wil...
Definition: address.h:949
Class for the function object that validates multicast addresses.
Definition: address.h:720
bool setIPAddress(const char *host)
Sets the IP address from a string representation of the numeric address, ie "127.0....
Class for the function object that validates multicast addresses.
Definition: address.h:128
void set(const char *cidr)
Set the cidr from a full or partial hostname, or from an address/mask, or a host/bits specification.
The broadcast address object is used to store the broadcast address for a specific subnet.
Definition: address.h:989
The CIDR class is used to support routing tables and validate address policies.
Definition: address.h:167
class __EXPORT IPV6Host
Definition: address.h:681
bool isInetAddress(void) const
May be used to verify if a given IPV6Address returned by another function contains a "valid" address,...
static Mutex mutex
Definition: address.h:770
The Mutex class is used to protect a section of code so that at any given time only a single thread c...
Definition: thread.h:187
struct in_addr getaddress(const IPV4Address &ia)
Definition: address.h:675
IPV4Broadcast(const char *net="255.255.255.255")
Specify the physical broadcast address to use and create a new broadcast address object based on a nu...
void set(const char *cidr)
Set the cidr from a full or partial hostname, or from a host/bits specification.
void operator()(const in6_addr address) const
Application operator.
virtual ~IPV4Address()
Destructor.
IPV6Validator()
Constructor.
Definition: address.h:697
IPV4Cidr()
Construct an empty cidr.
virtual ~IPV4MulticastValidator()
Keeps compilers happy.
Definition: address.h:138
The CIDR class is used to support routing tables and validate address policies.
Definition: address.h:255
bool operator==(const struct in6_addr &a) const
Definition: address.h:330
virtual ~IPV4Validator()
keeps compilers happy.
Definition: address.h:109
IPV4Address & operator=(struct in_addr addr)
bool operator==(const IPV4Address &a) const
Compare two internet addresses to see if they are equal (if they specify the physical address of the ...
const char * getHostname(void) const
Provide a string representation of the value (Internet Address) held in the IPV6Address object.
IPV4Address(const IPV4Address &rhs)
Copy constructor.
The Mutex Counter is a counter variable which can safely be incremented or decremented by multiple th...
Definition: thread.h:500
size_t getAddressCount() const
Returns the number of internet addresses that an IPV4Address object contains.
Definition: address.h:472
IPV6Cidr(const char *cidr)
Construct a new cidr from a string.
IPV6Host(struct in6_addr addr)
Convert a system socket binary address such as may be returned through the accept() call or getsockpe...
IPV6Multicast(const char *address)
Convert a null terminated ASCII multicast address string (example: "224.0.0.1") or multicast name str...
char * hostname
Definition: address.h:363
The broadcast address object is used to store the broadcast address for a specific subnet.
Definition: address.h:613
IPV6Address & operator=(struct in6_addr addr)
Classes derived from IPV6Address would require an specific validator to pass to the IPV6Address const...
Definition: address.h:692
IPV4Host(const char *host=NULL)
Create a new host address for a specific internet host.
IPV4Address & operator=(unsigned int addr)
Definition: address.h:484
void operator()(const in_addr address) const
Application operator.
bool setIPAddress(const char *host)
Sets the IP address from a string representation of the numeric address, ie "127.0....
#define __EXPORT
Definition: config.h:979
The network name and address objects are all derived from a common IPV6Address base class.
Definition: address.h:754
The network name and address objects are all derived from a common IPV4Address base class.
Definition: address.h:351
friend __EXPORT IPV4Host operator&(const IPV4Host &addr, const IPV4Mask &mask)
IPV6Address(const IPV6Validator *validator=NULL)
Create an Internet Address object with an empty (0.0.0.0) address.
IPV4Address & operator=(unsigned long addr)
Allows assignment from the return of functions like inet_addr() or htonl()
bool operator!=(const IPV4Address &a) const
Compare two internet addresses to see if they are not equal (if they each refer to unique and differe...
bool operator==(const struct sockaddr *sa) const
Definition: address.h:327
IPV6Address & operator=(const char *str)
size_t getAddressCount() const
Returns the number of internet addresses that an IPV6Address object contains.
Definition: address.h:875
IPV4Address(const IPV4Validator *validator=NULL)
Create an Internet Address object with an empty (0.0.0.0) address.
bool isMember(const struct in6_addr &inaddr) const
See if a low level address object is a member of this cidr's net.
IPV4MulticastValidator()
Constructor.
Definition: address.h:133
IPV6Address & operator=(const IPV6Address &rhs)
bool isMember(const struct sockaddr *saddr) const
See if a socket address is a member of this cidr's network.
Classes derived from IPV4Address would require an specific validator to pass to the IPV4Address const...
Definition: address.h:99
IPV6Cidr()
Construct an empty cidr.
IPV6Address(const IPV6Address &rhs)
Copy constructor.
IPV4Multicast()
Create an Internet Multicast Address object with an empty (0.0.0.0) address.
IPV4Address & operator=(const IPV4Address &rhs)
void setAddress(const char *host)
Used to specify a host name or numeric internet address.
IPV4Address & operator=(unsigned long addr)
Allows assignment from the return of functions like inet_addr() or htonl()
Definition: address.h:550
friend __EXPORT IPV4Host operator&(const IPV4Host &addr, const IPV4Mask &mask)
Masks are usually used to coerce host addresses into a specific router or class domain.
IPV6MulticastValidator()
Constructor.
Definition: address.h:725
substitute functions which may be missing in target platform libc.
IPV4Address & operator=(unsigned long addr)
Allows assignment from the return of functions like inet_addr() or htonl()
Definition: address.h:594
bool operator!() const
Definition: address.h:487
bool operator==(const struct sockaddr *a) const
Definition: address.h:239
bool isMember(const struct in_addr &inaddr) const
See if a low level address object is a member of this cidr's net.
#define InetAddrValidator
Definition: address.h:80
size_t addr_count
Definition: address.h:362
IPV6Address(struct in6_addr addr, const IPV6Validator *validator=NULL)
Convert the system internet address data type (struct in_addr) into a Common C++ IPV6Address object.
virtual ~IPV6Validator()
Keeps compilers happy.
Definition: address.h:702
struct in_addr * ipaddr
Definition: address.h:361
bool operator!() const
Definition: address.h:881
A specialization of IPV6Address that provides address validation for multicast addresses.
Definition: address.h:1011
IPV4Validator()
Constructor.
Definition: address.h:104
char * hostname
Definition: address.h:766
GNU Common C++ exception model base classes.
IPV6Broadcast(const char *net="255.255.255.255")
Specify the physical broadcast address to use and create a new broadcast address object based on a nu...
IPV6Multicast()
Create an Internet Multicast Address object with an empty (0.0.0.0) address.
IPV4Host & operator&=(const IPV4Mask &mask)
Mask the internet host address object with a network mask address.
virtual void operator()(const in6_addr address) const =0
Pure virtual application operator.
__EXPORT std::ostream & operator<<(std::ostream &os, const IPV4Address &ia)
IPV4Multicast(const char *address)
Convert a null terminated ASCII multicast address string (example: "224.0.0.1") or multicast name str...
Synchronization and threading services.
IPV4Cidr(const char *cidr)
Construct a new cidr from a string.
IPV6Mask(const char *mask)
Create the mask from a null terminated ASCII string such as "255.255.255.128".
IPV6Host(const char *host=NULL)
Create a new host address for a specific internet host.
virtual ~IPV6Address()
Destructor.
IPV4Address(struct in_addr addr, const IPV4Validator *validator=NULL)
Convert the system internet address data type (struct in_addr) into a Common C++ IPV4Address object.
bool operator!=(const IPV6Address &a) const
Compare two internet addresses to see if they are not equal (if they each refer to unique and differe...
virtual ~IPV6MulticastValidator()
Keeps compilers happy...
Definition: address.h:730
IPV6Cidr(IPV6Cidr &)
Construct a copy of a cidr.
IPV4Address & operator=(const char *str)
IPV4Mask(const char *mask)
Create the mask from a null terminated ASCII string such as "255.255.255.128".
bool operator==(const IPV6Address &a) const
Compare two internet addresses to see if they are equal (if they specify the physical address of the ...