diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-09-24 11:00:22 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-09-24 11:00:22 -0700 |
| commit | fbde40d1fc8767e4b6e9fcf0b078a8a4eb0646bd (patch) | |
| tree | e6776e96db9f90e985ac86c9967d7d945033328a /node/Path.hpp | |
| parent | 557c0c29b0781ff6190189fc080075b1c773f382 (diff) | |
| parent | 0e5aac6a117c28fde63f4cdb94e6c9fc415ca098 (diff) | |
| download | infinitytier-fbde40d1fc8767e4b6e9fcf0b078a8a4eb0646bd.tar.gz infinitytier-fbde40d1fc8767e4b6e9fcf0b078a8a4eb0646bd.zip | |
Merge branch 'adamierymenko-dev' into netcon
Diffstat (limited to 'node/Path.hpp')
| -rw-r--r-- | node/Path.hpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/node/Path.hpp b/node/Path.hpp index 0e53772d..1f947911 100644 --- a/node/Path.hpp +++ b/node/Path.hpp @@ -93,7 +93,16 @@ public: /** * @return Preference rank, higher == better */ - inline int preferenceRank() const throw() { return (int)_ipScope; } // IP scopes are in ascending rank order in InetAddress.hpp + inline int preferenceRank() const throw() + { + // First, since the scope enum values in InetAddress.hpp are in order of + // use preference rank, we take that. Then we multiple by two, yielding + // a sequence like 0, 2, 4, 6, etc. Then if it's IPv6 we add one. This + // makes IPv6 addresses of a given scope outrank IPv4 addresses of the + // same scope -- e.g. 1 outranks 0. This makes us prefer IPv6, but not + // if the address scope/class is of a fundamentally lower rank. + return ( ((int)_ipScope * 2) + ((_addr.ss_family == AF_INET6) ? 1 : 0) ); + } /** * @return Path trust level |
