|
|
|
@ -166,31 +166,46 @@ namespace i2p
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RouterContext::SetHighBandwidth ()
|
|
|
|
|
{
|
|
|
|
|
if (!m_RouterInfo.IsHighBandwidth () || m_RouterInfo.IsExtraBandwidth ())
|
|
|
|
|
{
|
|
|
|
|
m_RouterInfo.SetCaps ((m_RouterInfo.GetCaps () | i2p::data::RouterInfo::eHighBandwidth) & ~i2p::data::RouterInfo::eExtraBandwidth);
|
|
|
|
|
UpdateRouterInfo ();
|
|
|
|
|
}
|
|
|
|
|
void RouterContext::SetBandwidth (char L) {
|
|
|
|
|
uint16_t limit = 0;
|
|
|
|
|
enum { low, high, extra } type = high;
|
|
|
|
|
/* detect parameters */
|
|
|
|
|
switch (L)
|
|
|
|
|
{
|
|
|
|
|
case i2p::data::CAPS_FLAG_LOW_BANDWIDTH1 : limit = 12; type = low; break;
|
|
|
|
|
case i2p::data::CAPS_FLAG_LOW_BANDWIDTH2 : limit = 48; type = low; break;
|
|
|
|
|
case i2p::data::CAPS_FLAG_HIGH_BANDWIDTH1 : limit = 64; type = high; break;
|
|
|
|
|
case i2p::data::CAPS_FLAG_HIGH_BANDWIDTH2 : limit = 128; type = high; break;
|
|
|
|
|
case i2p::data::CAPS_FLAG_HIGH_BANDWIDTH3 : limit = 256; type = high; break;
|
|
|
|
|
case i2p::data::CAPS_FLAG_EXTRA_BANDWIDTH1 : limit = 2048; type = extra; break;
|
|
|
|
|
case i2p::data::CAPS_FLAG_EXTRA_BANDWIDTH2 : limit = 9999; type = extra; break;
|
|
|
|
|
default:
|
|
|
|
|
limit = 48; type = low;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RouterContext::SetLowBandwidth ()
|
|
|
|
|
{
|
|
|
|
|
if (m_RouterInfo.IsHighBandwidth () || m_RouterInfo.IsExtraBandwidth ())
|
|
|
|
|
/* update caps & flags in RI */
|
|
|
|
|
auto caps = m_RouterInfo.GetCaps ();
|
|
|
|
|
caps &= ~i2p::data::RouterInfo::eHighBandwidth;
|
|
|
|
|
caps &= ~i2p::data::RouterInfo::eExtraBandwidth;
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
m_RouterInfo.SetCaps (m_RouterInfo.GetCaps () & ~i2p::data::RouterInfo::eHighBandwidth & ~i2p::data::RouterInfo::eExtraBandwidth);
|
|
|
|
|
UpdateRouterInfo ();
|
|
|
|
|
case low : /* not set */; break;
|
|
|
|
|
case high : caps |= i2p::data::RouterInfo::eHighBandwidth; break;
|
|
|
|
|
case extra : caps |= i2p::data::RouterInfo::eExtraBandwidth; break;
|
|
|
|
|
}
|
|
|
|
|
m_RouterInfo.SetCaps (caps);
|
|
|
|
|
UpdateRouterInfo ();
|
|
|
|
|
m_BandwidthLimit = limit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RouterContext::SetExtraBandwidth ()
|
|
|
|
|
void RouterContext::SetBandwidth (int limit)
|
|
|
|
|
{
|
|
|
|
|
if (!m_RouterInfo.IsExtraBandwidth () || !m_RouterInfo.IsHighBandwidth ())
|
|
|
|
|
{
|
|
|
|
|
m_RouterInfo.SetCaps (m_RouterInfo.GetCaps () | i2p::data::RouterInfo::eExtraBandwidth | i2p::data::RouterInfo::eHighBandwidth);
|
|
|
|
|
UpdateRouterInfo ();
|
|
|
|
|
}
|
|
|
|
|
if (limit > 2000) { SetBandwidth('X'); }
|
|
|
|
|
else if (limit > 256) { SetBandwidth('P'); }
|
|
|
|
|
else if (limit > 128) { SetBandwidth('O'); }
|
|
|
|
|
else if (limit > 64) { SetBandwidth('N'); }
|
|
|
|
|
else if (limit > 48) { SetBandwidth('M'); }
|
|
|
|
|
else if (limit > 12) { SetBandwidth('L'); }
|
|
|
|
|
else { SetBandwidth('K'); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool RouterContext::IsUnreachable () const
|
|
|
|
|