Implements the unique identifier for DHCPv6. More...
#include "dhcp6-duid.h"
Classes | |
| class | DuidHash |
| Class providing a hash for DUIDs. More... | |
Public Types | |
| enum class | Type { LLT = 1 , EN , LL , UUID } |
| DUID type. More... | |
Public Member Functions | |
| uint32_t | Deserialize (Buffer::Iterator start, uint32_t len) |
| Deserialize the DUID. | |
| Type | GetDuidType () const |
| Get the DUID type. | |
| std::vector< uint8_t > | GetIdentifier () const |
| Return the identifier of the node. | |
| uint8_t | GetLength () const |
| Get the length of the DUID. | |
| uint32_t | GetSerializedSize () const |
| Get the DUID serialized size. | |
| void | Initialize (Type duidType, Ptr< Node > node, uint32_t enIdentifierLength) |
| Initialize a DUID. | |
| void | InitializeEN (uint32_t enNumber, const std::vector< uint8_t > &identifier) |
| Initialize the DUID-EN for a client or server. | |
| void | InitializeLL (Ptr< Node > node) |
| Initialize the DUID-LL for a client or server. | |
| void | InitializeLLT (Ptr< Node > node) |
| Initialize the DUID-LLT for a client or server. | |
| void | InitializeUUID (const std::vector< uint8_t > &uuid) |
| Initialize the DUID-EN for a client or server. | |
| bool | IsInvalid () const |
| Check if the DUID is invalid. | |
| bool | operator== (const Duid &other) const |
| Comparison operator. | |
| void | Serialize (Buffer::Iterator start) const |
| Serialize the DUID. | |
Private Types | |
| enum | Offset { LLT = 6 , EN = 4 , LL = 2 , UUID = 0 } |
| DUID data offset. More... | |
Private Member Functions | |
| Address | FindSuitableNetDeviceAddress (Ptr< Node > node) |
| Find a suitable NetDevice address to create a DUID-LL or DUID-LLT. | |
| void | HtoN (uint32_t source, std::vector< uint8_t >::iterator dest) |
| Utility function to convert a 32-bit number to an array with its bytes in network order. | |
Private Attributes | |
| std::vector< uint8_t > | m_blob {} |
| DUID data, content depending on the DUID type. | |
| Type | m_duidType {Duid::Type::LL} |
| DUID type. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Duid &duid) |
| Stream output operator. | |
| std::strong_ordering | operator<=> (const Duid &a, const Duid &b) |
| Spaceship comparison operator. | |
Implements the unique identifier for DHCPv6.
Definition at line 26 of file dhcp6-duid.h.
|
private |
DUID data offset.
Each DUID has some fixed-length fields (e.g., Hardware Type), and a variable length part. This is the offset to the variable length part.
| Enumerator | |
|---|---|
| LLT | |
| EN | |
| LL | |
| UUID | |
Definition at line 191 of file dhcp6-duid.h.
|
strong |
| uint32_t ns3::Duid::Deserialize | ( | Buffer::Iterator | start, |
| uint32_t | len ) |
Deserialize the DUID.
| start | The buffer iterator. |
| len | The number of bytes to be read. |
Definition at line 229 of file dhcp6-duid.cc.
References GetSerializedSize(), m_blob, m_duidType, ns3::Buffer::Iterator::Read(), and ns3::Buffer::Iterator::ReadNtohU16().
Referenced by ns3::Dhcp6Header::Deserialize().
Find a suitable NetDevice address to create a DUID-LL or DUID-LLT.
We select the NetDevices with the longest MAC address length, and among them, the one with the smallest index.
| node | The node for which the DUID is to be generated. |
Definition at line 169 of file dhcp6-duid.cc.
References ns3::DynamicCast(), ns3::Address::IsInvalid(), NS_ASSERT_MSG, NS_LOG_DEBUG, and NS_LOG_FUNCTION.
Referenced by InitializeLL(), and InitializeLLT().
| Duid::Type ns3::Duid::GetDuidType | ( | ) | const |
Get the DUID type.
Definition at line 47 of file dhcp6-duid.cc.
References m_duidType.
| std::vector< uint8_t > ns3::Duid::GetIdentifier | ( | ) | const |
Return the identifier of the node.
Definition at line 41 of file dhcp6-duid.cc.
References m_blob.
| uint8_t ns3::Duid::GetLength | ( | ) | const |
Get the length of the DUID.
Definition at line 35 of file dhcp6-duid.cc.
References m_blob.
| uint32_t ns3::Duid::GetSerializedSize | ( | ) | const |
Get the DUID serialized size.
Definition at line 213 of file dhcp6-duid.cc.
References m_blob.
Referenced by ns3::Dhcp6Header::AddIdentifierOption(), Deserialize(), Dhcp6DuidTestCase::DoRun(), and ns3::Dhcp6Header::Serialize().
|
private |
Utility function to convert a 32-bit number to an array with its bytes in network order.
| [in] | source | the number to convert. |
| [out] | dest | the converted number. |
Definition at line 243 of file dhcp6-duid.cc.
Referenced by Initialize(), InitializeEN(), and InitializeLLT().
Initialize a DUID.
The DUID initialization logic is the following:
| duidType | the DUID type. |
| node | the node this DUID refers to |
| enIdentifierLength | the DUID-EN identifier length (unused in other DUID types) |
Definition at line 136 of file dhcp6-duid.cc.
References EN, HtoN(), InitializeEN(), InitializeLL(), InitializeLLT(), InitializeUUID(), LL, LLT, NS_LOG_FUNCTION, and UUID.
| void ns3::Duid::InitializeEN | ( | uint32_t | enNumber, |
| const std::vector< uint8_t > & | identifier ) |
Initialize the DUID-EN for a client or server.
| enNumber | The Enterprise Number. |
| identifier | The device Identifier. |
Definition at line 102 of file dhcp6-duid.cc.
References EN, HtoN(), m_blob, m_duidType, NS_ASSERT_MSG, and NS_LOG_FUNCTION.
Referenced by Dhcp6DuidTestCase::DoRun(), and Initialize().
Initialize the DUID-LL for a client or server.
| node | The node for which the DUID is to be generated. |
Definition at line 53 of file dhcp6-duid.cc.
References ns3::Address::CopyTo(), FindSuitableNetDeviceAddress(), ns3::Address::GetLength(), LL, m_blob, m_duidType, NS_ASSERT_MSG, and NS_LOG_FUNCTION.
Referenced by Dhcp6DuidTestCase::DoRun(), and Initialize().
Initialize the DUID-LLT for a client or server.
| node | The node for which the DUID is to be generated. |
Definition at line 74 of file dhcp6-duid.cc.
References ns3::Address::CopyTo(), FindSuitableNetDeviceAddress(), ns3::Address::GetLength(), HtoN(), LL, LLT, m_blob, m_duidType, ns3::Simulator::Now(), NS_ASSERT_MSG, and NS_LOG_FUNCTION.
Referenced by Dhcp6DuidTestCase::DoRun(), and Initialize().
| void ns3::Duid::InitializeUUID | ( | const std::vector< uint8_t > & | uuid | ) |
Initialize the DUID-EN for a client or server.
| uuid | The UUID. |
Definition at line 122 of file dhcp6-duid.cc.
References m_blob, m_duidType, NS_ASSERT_MSG, NS_LOG_FUNCTION, and UUID.
Referenced by Dhcp6DuidTestCase::DoRun(), and Initialize().
| bool ns3::Duid::IsInvalid | ( | ) | const |
Check if the DUID is invalid.
Definition at line 29 of file dhcp6-duid.cc.
References m_blob.
| bool ns3::Duid::operator== | ( | const Duid & | other | ) | const |
Comparison operator.
| other | DUID to compare to this one. |
Definition at line 264 of file dhcp6-duid.cc.
| void ns3::Duid::Serialize | ( | Buffer::Iterator | start | ) | const |
Serialize the DUID.
| start | The buffer iterator. |
Definition at line 220 of file dhcp6-duid.cc.
References m_blob, m_duidType, ns3::Buffer::Iterator::Write(), and ns3::Buffer::Iterator::WriteHtonU16().
Referenced by ns3::Dhcp6Header::Serialize().
|
friend |
Stream output operator.
The DUID is printed according to its type, e.g.:
| os | output stream |
| duid | The reference to the DUID object. |
Definition at line 280 of file dhcp6-duid.cc.
Spaceship comparison operator.
All the other comparison operators are automatically generated from this one.
| a | left operand DUID to compare. |
| b | right operand DUID to compare. |
Definition at line 269 of file dhcp6-duid.cc.
References m_blob, and m_duidType.
|
private |
DUID data, content depending on the DUID type.
Definition at line 221 of file dhcp6-duid.h.
Referenced by Deserialize(), GetIdentifier(), GetLength(), GetSerializedSize(), InitializeEN(), InitializeLL(), InitializeLLT(), InitializeUUID(), IsInvalid(), operator<<, operator<=>, and Serialize().
|
private |
DUID type.
Definition at line 219 of file dhcp6-duid.h.
Referenced by Deserialize(), GetDuidType(), InitializeEN(), InitializeLL(), InitializeLLT(), InitializeUUID(), operator<<, operator<=>, and Serialize().