in simulation/src/sixlowpan/model/sixlowpan-header.cc [183:272]
void SixLowPanHc1::Serialize (Buffer::Iterator start) const
{
Buffer::Iterator i = start;
uint8_t encoding;
encoding = m_srcCompression;
encoding <<= 2;
encoding |= m_dstCompression;
encoding <<= 1;
encoding |= m_tcflCompression;
encoding <<= 2;
encoding |= m_nextHeaderCompression;
encoding <<= 1;
encoding |= m_hc2HeaderPresent;
i.WriteU8 (SixLowPanDispatch::LOWPAN_HC1);
i.WriteU8 (encoding);
i.WriteU8 (m_hopLimit);
switch (m_srcCompression)
{
case HC1_PIII:
for ( int j = 0; j < 8; j++ )
{
i.WriteU8 (m_srcPrefix[j]);
}
for ( int j = 0; j < 8; j++ )
{
i.WriteU8 (m_srcInterface[j]);
}
break;
case HC1_PIIC:
for ( int j = 0; j < 8; j++ )
{
i.WriteU8 (m_srcPrefix[j]);
}
break;
case HC1_PCII:
for ( int j = 0; j < 8; j++ )
{
i.WriteU8 (m_srcInterface[j]);
}
break;
case HC1_PCIC:
break;
}
switch (m_dstCompression)
{
case HC1_PIII:
for ( int j = 0; j < 8; j++ )
{
i.WriteU8 (m_dstPrefix[j]);
}
for ( int j = 0; j < 8; j++ )
{
i.WriteU8 (m_dstInterface[j]);
}
break;
case HC1_PIIC:
for ( int j = 0; j < 8; j++ )
{
i.WriteU8 (m_dstPrefix[j]);
}
break;
case HC1_PCII:
for ( int j = 0; j < 8; j++ )
{
i.WriteU8 (m_dstInterface[j]);
}
break;
case HC1_PCIC:
break;
}
if ( m_tcflCompression == false )
{
i.WriteU8 (m_trafficClass);
uint8_t temp[3];
temp[0] = uint8_t (m_flowLabel & 0xff);
temp[1] = uint8_t ((m_flowLabel >> 8) & 0xff);
temp[2] = uint8_t ((m_flowLabel >> 16) & 0xff);
i.Write (temp, 3);
}
if (m_nextHeaderCompression == HC1_NC )
{
i.WriteU8 (m_nextHeader);
}
// TODO: HC2 is not yet supported. Should be.
NS_ASSERT_MSG ( m_hc2HeaderPresent != true, "Can not compress HC2, exiting. Very sorry." );
}