From bd15262e5459c6003e54bcfd1d98966ff6bd1f97 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 15 Aug 2016 18:49:50 -0700 Subject: Bunch of rule JSON stuff. --- node/InetAddress.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'node') diff --git a/node/InetAddress.hpp b/node/InetAddress.hpp index b97e2ca6..2cd4dbd3 100644 --- a/node/InetAddress.hpp +++ b/node/InetAddress.hpp @@ -300,6 +300,19 @@ struct InetAddress : public sockaddr_storage */ inline unsigned int netmaskBits() const throw() { return port(); } + /** + * @return True if netmask bits is valid for the address type + */ + inline bool netmaskBitsValid() const + { + const unsigned int n = port(); + switch(ss_family) { + case AF_INET: return (n <= 32); + case AF_INET6: return (n <= 128); + } + return false; + } + /** * Alias for port() * -- cgit v1.2.3