12#include "ns3/address.h"
13#include "ns3/assert.h"
14#include "ns3/ipv6-l3-protocol.h"
16#include "ns3/loopback-net-device.h"
111 uint8_t idLen = identifier.size();
113 NS_ASSERT_MSG(idLen == 6 || idLen == 8,
"Duid: Invalid identifier length.");
135 uint32_t nInterfaces = ipv6->GetNInterfaces();
140 for (
uint32_t i = 0; i < nInterfaces; i++)
151 if (device->IsLinkUp())
153 NS_LOG_DEBUG(
"Interface " << device->GetIfIndex() <<
" up on node " << node->GetId());
154 Address address = device->GetAddress();
155 if (address.GetLength() > maxAddressLength)
157 maxAddressLength = address.GetLength();
158 duidAddress = address;
165 NS_LOG_DEBUG(
"DUID of node " << node->GetId() <<
" is " << duidAddress);
169 duidAddress.
CopyTo(buffer);
171 std::vector<uint8_t> identifier(duidAddress.
GetLength());
172 std::copy(buffer, buffer + duidAddress.
GetLength(), identifier.begin());
228 uint8_t duidLen = x.GetLength();
229 std::vector<uint8_t> buffer = x.GetIdentifier();
231 std::string s(buffer.begin(), buffer.begin() + duidLen);
232 return std::hash<std::string>{}(s);
a polymophic address class
uint8_t GetLength() const
Get the length of the underlying address.
uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const
Copy the address bytes into a buffer.
iterator in a Buffer instance
void WriteU8(uint8_t data)
void WriteHtonU16(uint16_t data)
size_t operator()(const Duid &x) const noexcept
Returns the hash of a DUID.
Implements the unique identifier for DHCPv6.
void SetHardwareType(uint16_t hardwareType)
Set the hardware type.
uint32_t Deserialize(Buffer::Iterator start, uint32_t len)
Deserialize the DUID.
uint8_t GetLength() const
Get the length of the DUID.
Type m_duidType
Type of the DUID.
Time m_time
Time at which the DUID is generated.
void SetDuidType(Type duidType)
Set the DUID type.
void SetDuid(std::vector< uint8_t > identifier)
Set the identifier as the DUID.
void Serialize(Buffer::Iterator start) const
Serialize the DUID.
uint16_t m_hardwareType
Valid hardware type assigned by IANA.
bool IsInvalid() const
Check if the DUID is invalid.
bool operator==(const Duid &duid) const
Comparison operator.
void SetTime(Time time)
Set the time at which DUID is generated.
std::vector< uint8_t > GetIdentifier() const
Return the identifier of the node.
uint32_t GetSerializedSize() const
Get the DUID serialized size.
Type GetDuidType() const
Get the DUID type.
uint16_t GetHardwareType() const
Get the hardware type.
void Initialize(Ptr< Node > node)
Initialize the DUID for a client or server.
Duid()
Default constructor.
std::vector< uint8_t > m_identifier
Identifier of the node in bytes.
Time GetTime() const
Get the time at which the DUID is generated.
IPv6 layer implementation.
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
bool operator<(const EventId &a, const EventId &b)