diff options
author | Grant Limberg <glimberg@gmail.com> | 2015-09-26 13:47:55 -0700 |
---|---|---|
committer | Grant Limberg <glimberg@gmail.com> | 2015-09-26 13:47:55 -0700 |
commit | e8cdff3eafd8096da22122eabddf57a09fe2bb90 (patch) | |
tree | d231aa6d9ccccc8ced6e1ead606ce16ff551cab9 /node/Path.hpp | |
parent | 53d98343b7b444508259f6f1643e8d6724fb11e9 (diff) | |
parent | f69454ec9879a0b0a424f743ca144d1123ef7e99 (diff) | |
download | infinitytier-e8cdff3eafd8096da22122eabddf57a09fe2bb90.tar.gz infinitytier-e8cdff3eafd8096da22122eabddf57a09fe2bb90.zip |
Merge branch 'adamierymenko-dev' into android-jni-dev
also update for changed function calls that now accept a local address
# Conflicts:
# include/ZeroTierOne.h
# java/CMakeLists.txt
# java/jni/Android.mk
# java/jni/ZT1_jnicache.cpp
# java/jni/ZT1_jnilookup.h
# java/jni/ZT1_jniutils.cpp
# java/jni/com_zerotierone_sdk_Node.cpp
Diffstat (limited to 'node/Path.hpp')
-rw-r--r-- | node/Path.hpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/node/Path.hpp b/node/Path.hpp index 0e53772d..3fa06b58 100644 --- a/node/Path.hpp +++ b/node/Path.hpp @@ -57,7 +57,7 @@ public: * Nearly all paths will be normal trust. The other levels are for high * performance local SDN use only. * - * These values MUST match ZT1_LocalInterfaceAddressTrust in ZeroTierOne.h + * These values MUST match ZT_LocalInterfaceAddressTrust in ZeroTierOne.h */ enum Trust { @@ -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 |