in simulation/src/sixlowpan/model/sixlowpan-header.cc [1088:1222]
uint32_t SixLowPanIphc::Deserialize (Buffer::Iterator start)
{
Buffer::Iterator i = start;
m_baseFormat = i.ReadNtohU16 ();
if ( GetCid () )
{
m_srcdstContextId = i.ReadU8 ();
}
else
{
m_srcdstContextId = 0;
}
// Traffic Class and Flow Label
switch ( GetTf () )
{
uint8_t temp;
case TF_FULL:
temp = i.ReadU8 ();
m_ecn = temp >> 6;
m_dscp = temp & 0x3F;
temp = i.ReadU8 ();
m_flowLabel = temp;
temp = i.ReadU8 ();
m_flowLabel = (m_flowLabel << 8) | temp;
temp = i.ReadU8 ();
m_flowLabel = (m_flowLabel << 8) | temp;
break;
case TF_DSCP_ELIDED:
temp = i.ReadU8 ();
m_ecn = temp >> 6;
m_flowLabel = temp & 0x3F;
temp = i.ReadU8 ();
m_flowLabel = (m_flowLabel << 8) | temp;
temp = i.ReadU8 ();
m_flowLabel = (m_flowLabel << 8) | temp;
break;
case TF_FL_ELIDED:
temp = i.ReadU8 ();
m_ecn = temp >> 6;
m_dscp = temp & 0x3F;
break;
default:
break;
}
// Next Header
if ( GetNh () == false )
{
m_nextHeader = i.ReadU8 ();
}
// Hop Limit
switch ( GetHlim () )
{
case HLIM_INLINE:
m_hopLimit = i.ReadU8 ();
break;
case HLIM_COMPR_1:
m_hopLimit = 1;
break;
case HLIM_COMPR_64:
m_hopLimit = 64;
break;
case HLIM_COMPR_255:
default:
m_hopLimit = 255;
break;
}
// Source Address
memset (m_srcInlinePart, 0x00, sizeof (m_srcInlinePart));
switch (GetSam () )
{
case HC_INLINE:
if ( GetSac () == false )
{
i.Read (m_srcInlinePart, 16);
}
break;
case HC_COMPR_64:
i.Read (m_srcInlinePart, 8);
break;
case HC_COMPR_16:
i.Read (m_srcInlinePart, 2);
break;
case HC_COMPR_0:
default:
break;
}
// Destination Address
memset (m_dstInlinePart, 0x00, sizeof (m_dstInlinePart));
if ( GetM () == false)
{
// unicast
switch (GetDam () )
{
case HC_INLINE:
i.Read (m_dstInlinePart, 16);
break;
case HC_COMPR_64:
i.Read (m_dstInlinePart, 8);
break;
case HC_COMPR_16:
i.Read (m_dstInlinePart, 2);
break;
case HC_COMPR_0:
default:
break;
}
}
else
{
// multicast
switch (GetDam () )
{
case HC_INLINE:
i.Read (m_dstInlinePart, 16);
break;
case HC_COMPR_64:
i.Read (m_dstInlinePart, 6);
break;
case HC_COMPR_16:
i.Read (m_dstInlinePart, 4);
break;
case HC_COMPR_0:
i.Read (m_dstInlinePart, 1);
break;
default:
break;
}
}
return GetSerializedSize ();
}