aboutsummaryrefslogtreecommitdiff
path: root/src/netbase.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-02-12 13:45:24 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2012-05-04 16:12:23 +0200
commit39857190dee3ed296112cfcfd79b0a375143b6c6 (patch)
treec78b110e9731a9b495074e3889b5767ab8d40e8b /src/netbase.cpp
parent478b01d9a797f3ea41cca141992b161867a5996d (diff)
Support for multiple local addresses
Diffstat (limited to 'src/netbase.cpp')
-rw-r--r--src/netbase.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp
index a9cc0cf4d3..4fe3fb61da 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -772,6 +772,29 @@ void CNetAddr::print() const
printf("CNetAddr(%s)\n", ToString().c_str());
}
+// for IPv6 partners: for unknown/Teredo partners: for IPv4 partners:
+// 0 - unroutable // 0 - unroutable // 0 - unroutable
+// 1 - teredo // 1 - teredo // 1 - ipv4
+// 2 - tunneled ipv6 // 2 - tunneled ipv6
+// 3 - ipv4 // 3 - ipv6
+// 4 - ipv6 // 4 - ipv4
+int CNetAddr::GetReachabilityFrom(const CNetAddr *paddrPartner) const
+{
+ if (!IsValid() || !IsRoutable())
+ return 0;
+ if (paddrPartner && paddrPartner->IsIPv4())
+ return IsIPv4() ? 1 : 0;
+ if (IsRFC4380())
+ return 1;
+ if (IsRFC3964() || IsRFC6052())
+ return 2;
+ bool fRealIPv6 = paddrPartner && !paddrPartner->IsRFC4380() && paddrPartner->IsValid() && paddrPartner->IsRoutable();
+ if (fRealIPv6)
+ return IsIPv4() ? 3 : 4;
+ else
+ return IsIPv4() ? 4 : 3;
+}
+
void CService::Init()
{
port = 0;