summaryrefslogtreecommitdiff
path: root/node/InetAddress.hpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2016-06-15 15:02:40 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2016-06-15 15:02:40 -0700
commitb90e66f7c7546aaf9c0c8a6bf14cc834f82fa680 (patch)
tree2c9e5f87535084e91ebe26e6e43a3136dcc4c258 /node/InetAddress.hpp
parent4446dbde5edfd8f7ec9730886e5d577259d73de2 (diff)
downloadinfinitytier-b90e66f7c7546aaf9c0c8a6bf14cc834f82fa680.tar.gz
infinitytier-b90e66f7c7546aaf9c0c8a6bf14cc834f82fa680.zip
ManagedRoute, which applies C++ RAII to injected routes. Move RoutingTable to attic.
Diffstat (limited to 'node/InetAddress.hpp')
-rw-r--r--node/InetAddress.hpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/node/InetAddress.hpp b/node/InetAddress.hpp
index b60a5a3a..1d171ba7 100644
--- a/node/InetAddress.hpp
+++ b/node/InetAddress.hpp
@@ -231,7 +231,6 @@ struct InetAddress : public sockaddr_storage
* @param port Port, 0 to 65535
*/
inline void setPort(unsigned int port)
- throw()
{
switch(ss_family) {
case AF_INET:
@@ -244,6 +243,25 @@ struct InetAddress : public sockaddr_storage
}
/**
+ * @return True if this network/netmask route describes a default route (e.g. 0.0.0.0/0)
+ */
+ inline bool isDefaultRoute()
+ {
+ switch(ss_family) {
+ case AF_INET:
+ return ( (reinterpret_cast<struct sockaddr_in *>(this)->sin_addr.s_addr == 0) && (reinterpret_cast<struct sockaddr_in *>(this)->sin_port == 0) );
+ case AF_INET6:
+ const uint8_t *ipb = reinterpret_cast<const uint8_t *>(reinterpret_cast<struct sockaddr_in6 *>(this)->sin6_addr.s6_addr);
+ for(int i=0;i<16;++i) {
+ if (ipb[i])
+ return false;
+ }
+ return (reinterpret_cast<struct sockaddr_in6 *>(this)->sin6_port == 0);
+ }
+ return false;
+ }
+
+ /**
* @return ASCII IP/port format representation
*/
std::string toString() const;