diff options
author | Doug Huff <mith@jrbobdobbs.org> | 2011-06-02 14:46:41 -0500 |
---|---|---|
committer | Doug Huff <mith@jrbobdobbs.org> | 2011-06-02 14:46:41 -0500 |
commit | 482cb6569058423ca952076459f1539a88d70074 (patch) | |
tree | 51ea99402d8a958551c3ac7cbcb8726a40466e61 /src/net.h | |
parent | e104c7937455bf2c9b535ec14ea710a97b66750b (diff) |
Fix rfc1918 and rfc3927 compliance for ignoring non-internet-routable hosts.
Diffstat (limited to 'src/net.h')
-rw-r--r-- | src/net.h | 24 |
1 files changed, 20 insertions, 4 deletions
@@ -283,13 +283,29 @@ public: return (memcmp(pchReserved, pchIPv4, sizeof(pchIPv4)) == 0); } + bool IsRFC1918() const + { + return IsIPv4() && (GetByte(3) == 10 || + (GetByte(3) == 192 && GetByte(2) == 168) || + (GetByte(3) == 172 && + (GetByte(2) >= 16 && GetByte(2) <= 31))); + } + + bool IsRFC3927() const + { + return IsIPv4() && (GetByte(3) == 169 && GetByte(2) == 254); + } + + bool IsLocal() const + { + return IsIPv4() && (GetByte(3) == 127 || + GetByte(3) == 0); + } + bool IsRoutable() const { return IsValid() && - !(GetByte(3) == 10 || - (GetByte(3) == 192 && GetByte(2) == 168) || - GetByte(3) == 127 || - GetByte(3) == 0); + !(IsRFC1918() || IsRFC3927() || IsLocal()); } bool IsValid() const |