in simulation/src/sixlowpan/model/sixlowpan-net-device.cc [2784:2827]
bool SixLowPanNetDevice::FindMulticastCompressionContext (Ipv6Address address, uint8_t& contextId)
{
NS_LOG_FUNCTION (this << address);
// The only allowed context-based compressed multicast address is in the form
// ffXX:XXLL:PPPP:PPPP:PPPP:PPPP:XXXX:XXXX
for (const auto& iter: m_contextTable)
{
ContextEntry context = iter.second;
if ( (context.compressionAllowed == true) && (context.validLifetime > Simulator::Now ()) )
{
uint8_t contextLength = context.contextPrefix.GetPrefixLength ();
if (contextLength <= 64) // only 64-bit prefixes or less are allowed.
{
uint8_t contextBytes[16];
uint8_t addressBytes[16];
context.contextPrefix.GetBytes (contextBytes);
address.GetBytes (addressBytes);
if (addressBytes[3] == contextLength &&
addressBytes[4] == contextBytes[0] &&
addressBytes[5] == contextBytes[1] &&
addressBytes[6] == contextBytes[2] &&
addressBytes[7] == contextBytes[3] &&
addressBytes[8] == contextBytes[4] &&
addressBytes[9] == contextBytes[5] &&
addressBytes[10] == contextBytes[6] &&
addressBytes[11] == contextBytes[7])
{
NS_LOG_LOGIC ("Fount context " << +contextId << " " <<
Ipv6Address::GetOnes ().CombinePrefix (context.contextPrefix) << context.contextPrefix << " matching");
contextId = iter.first;
return true;
}
}
}
}
return false;
}