|
|
| 1646 |
{ |
1646 |
{ |
| 1647 |
SetType (source ? Icmpv6Header::ICMPV6_OPT_LINK_LAYER_SOURCE : Icmpv6Header::ICMPV6_OPT_LINK_LAYER_TARGET); |
1647 |
SetType (source ? Icmpv6Header::ICMPV6_OPT_LINK_LAYER_SOURCE : Icmpv6Header::ICMPV6_OPT_LINK_LAYER_TARGET); |
| 1648 |
SetAddress (addr); |
1648 |
SetAddress (addr); |
| 1649 |
SetLength (GetSerializedSize () / 8); |
1649 |
|
|
|
1650 |
uint8_t len = (2 + m_addr.GetLength ()) / 8; |
| 1651 |
if ( (2 + m_addr.GetLength ()) % 8 ) |
| 1652 |
{ |
| 1653 |
len ++; |
| 1654 |
} |
| 1655 |
SetLength (len); |
| 1650 |
} |
1656 |
} |
| 1651 |
|
1657 |
|
| 1652 |
Icmpv6OptionLinkLayerAddress::~Icmpv6OptionLinkLayerAddress () |
1658 |
Icmpv6OptionLinkLayerAddress::~Icmpv6OptionLinkLayerAddress () |
|
|
| 1670 |
|
1676 |
|
| 1671 |
uint32_t Icmpv6OptionLinkLayerAddress::GetSerializedSize () const |
1677 |
uint32_t Icmpv6OptionLinkLayerAddress::GetSerializedSize () const |
| 1672 |
{ |
1678 |
{ |
| 1673 |
/* TODO add padding */ |
1679 |
uint8_t nb = GetLength() * 8; |
| 1674 |
uint8_t nb = 2 + m_addr.GetLength (); |
|
|
| 1675 |
return nb; |
1680 |
return nb; |
| 1676 |
} |
1681 |
} |
| 1677 |
|
1682 |
|
|
|
| 1686 |
m_addr.CopyTo (mac); |
1691 |
m_addr.CopyTo (mac); |
| 1687 |
i.Write (mac, m_addr.GetLength ()); |
1692 |
i.Write (mac, m_addr.GetLength ()); |
| 1688 |
|
1693 |
|
| 1689 |
/* XXX if size of the option is not a multiple of 8, add padding */ |
1694 |
uint8_t len = GetLength ()*8 - (2 + m_addr.GetLength ()); |
|
|
1695 |
for (uint8_t nb = 0; nb<len; nb++) |
| 1696 |
{ |
| 1697 |
i.WriteU8 (0); |
| 1698 |
} |
| 1690 |
} |
1699 |
} |
| 1691 |
|
1700 |
|
| 1692 |
uint32_t Icmpv6OptionLinkLayerAddress::Deserialize (Buffer::Iterator start) |
1701 |
uint32_t Icmpv6OptionLinkLayerAddress::Deserialize (Buffer::Iterator start) |