|
|
@ -186,6 +186,7 @@ namespace data |
|
|
|
|
|
|
|
|
|
|
|
void RouterInfo::ReadFromStream (std::istream& s) |
|
|
|
void RouterInfo::ReadFromStream (std::istream& s) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
m_Caps = 0; |
|
|
|
s.read ((char *)&m_Timestamp, sizeof (m_Timestamp)); |
|
|
|
s.read ((char *)&m_Timestamp, sizeof (m_Timestamp)); |
|
|
|
m_Timestamp = be64toh (m_Timestamp); |
|
|
|
m_Timestamp = be64toh (m_Timestamp); |
|
|
|
// read addresses
|
|
|
|
// read addresses
|
|
|
@ -251,7 +252,7 @@ namespace data |
|
|
|
LogPrint (eLogWarning, "RouterInfo: Unexpected field 'key' for NTCP"); |
|
|
|
LogPrint (eLogWarning, "RouterInfo: Unexpected field 'key' for NTCP"); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (!strcmp (key, "caps")) |
|
|
|
else if (!strcmp (key, "caps")) |
|
|
|
address->caps = ExtractCaps (value); |
|
|
|
address->caps = ExtractAddressCaps (value); |
|
|
|
else if (!strcmp (key, "s")) // ntcp2 static key
|
|
|
|
else if (!strcmp (key, "s")) // ntcp2 static key
|
|
|
|
{ |
|
|
|
{ |
|
|
|
Base64ToByteStream (value, strlen (value), address->ntcp2->staticKey, 32); |
|
|
|
Base64ToByteStream (value, strlen (value), address->ntcp2->staticKey, 32); |
|
|
@ -354,7 +355,7 @@ namespace data |
|
|
|
|
|
|
|
|
|
|
|
// extract caps
|
|
|
|
// extract caps
|
|
|
|
if (!strcmp (key, "caps")) |
|
|
|
if (!strcmp (key, "caps")) |
|
|
|
m_Caps = ExtractCaps (value); |
|
|
|
ExtractCaps (value); |
|
|
|
// extract version
|
|
|
|
// extract version
|
|
|
|
else if (!strcmp (key, ROUTER_INFO_PROPERTY_VERSION)) |
|
|
|
else if (!strcmp (key, ROUTER_INFO_PROPERTY_VERSION)) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -403,40 +404,59 @@ namespace data |
|
|
|
return m_Family == fam; |
|
|
|
return m_Family == fam; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uint8_t RouterInfo::ExtractCaps (const char * value) |
|
|
|
void RouterInfo::ExtractCaps (const char * value) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint8_t caps = 0; |
|
|
|
|
|
|
|
const char * cap = value; |
|
|
|
const char * cap = value; |
|
|
|
while (*cap) |
|
|
|
while (*cap) |
|
|
|
{ |
|
|
|
{ |
|
|
|
switch (*cap) |
|
|
|
switch (*cap) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case CAPS_FLAG_FLOODFILL: |
|
|
|
case CAPS_FLAG_FLOODFILL: |
|
|
|
caps |= Caps::eFloodfill; |
|
|
|
m_Caps |= Caps::eFloodfill; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case CAPS_FLAG_HIGH_BANDWIDTH1: |
|
|
|
case CAPS_FLAG_HIGH_BANDWIDTH1: |
|
|
|
case CAPS_FLAG_HIGH_BANDWIDTH2: |
|
|
|
case CAPS_FLAG_HIGH_BANDWIDTH2: |
|
|
|
case CAPS_FLAG_HIGH_BANDWIDTH3: |
|
|
|
case CAPS_FLAG_HIGH_BANDWIDTH3: |
|
|
|
caps |= Caps::eHighBandwidth; |
|
|
|
m_Caps |= Caps::eHighBandwidth; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case CAPS_FLAG_EXTRA_BANDWIDTH1: |
|
|
|
case CAPS_FLAG_EXTRA_BANDWIDTH1: |
|
|
|
case CAPS_FLAG_EXTRA_BANDWIDTH2: |
|
|
|
case CAPS_FLAG_EXTRA_BANDWIDTH2: |
|
|
|
caps |= Caps::eExtraBandwidth | Caps::eHighBandwidth; |
|
|
|
m_Caps |= Caps::eExtraBandwidth | Caps::eHighBandwidth; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case CAPS_FLAG_HIDDEN: |
|
|
|
case CAPS_FLAG_HIDDEN: |
|
|
|
caps |= Caps::eHidden; |
|
|
|
m_Caps |= Caps::eHidden; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case CAPS_FLAG_REACHABLE: |
|
|
|
case CAPS_FLAG_REACHABLE: |
|
|
|
caps |= Caps::eReachable; |
|
|
|
m_Caps |= Caps::eReachable; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case CAPS_FLAG_UNREACHABLE: |
|
|
|
case CAPS_FLAG_UNREACHABLE: |
|
|
|
caps |= Caps::eUnreachable; |
|
|
|
m_Caps |= Caps::eUnreachable; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: ; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
cap++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t RouterInfo::ExtractAddressCaps (const char * value) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
uint8_t caps = 0; |
|
|
|
|
|
|
|
const char * cap = value; |
|
|
|
|
|
|
|
while (*cap) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
switch (*cap) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case CAPS_FLAG_V4: |
|
|
|
|
|
|
|
caps |= AddressCaps::eV4; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case CAPS_FLAG_V6: |
|
|
|
|
|
|
|
caps |= AddressCaps::eV6; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case CAPS_FLAG_SSU_TESTING: |
|
|
|
case CAPS_FLAG_SSU_TESTING: |
|
|
|
caps |= Caps::eSSUTesting; |
|
|
|
caps |= AddressCaps::eSSUTesting; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case CAPS_FLAG_SSU_INTRODUCER: |
|
|
|
case CAPS_FLAG_SSU_INTRODUCER: |
|
|
|
caps |= Caps::eSSUIntroducer; |
|
|
|
caps |= AddressCaps::eSSUIntroducer; |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: ; |
|
|
|
default: ; |
|
|
|
} |
|
|
|
} |
|
|
@ -799,7 +819,8 @@ namespace data |
|
|
|
void RouterInfo::SetCaps (const char * caps) |
|
|
|
void RouterInfo::SetCaps (const char * caps) |
|
|
|
{ |
|
|
|
{ |
|
|
|
SetProperty ("caps", caps); |
|
|
|
SetProperty ("caps", caps); |
|
|
|
m_Caps = ExtractCaps (caps); |
|
|
|
m_Caps = 0; |
|
|
|
|
|
|
|
ExtractCaps (caps); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void RouterInfo::SetProperty (const std::string& key, const std::string& value) |
|
|
|
void RouterInfo::SetProperty (const std::string& key, const std::string& value) |
|
|
|