Describes an IPv6 prefix. More...
#include "ipv6-address.h"
Public Member Functions | |
| Ipv6Prefix ()=default | |
| Default constructor. | |
| Ipv6Prefix (const char *prefix) | |
| Constructs an Ipv6Prefix by using the input string. | |
| Ipv6Prefix (const char *prefix, uint8_t prefixLength) | |
| Constructs an Ipv6Prefix by using the input string. | |
| Ipv6Prefix (uint8_t prefix) | |
| Constructs an Ipv6Prefix by using the input number of bits. | |
| Ipv6Prefix (uint8_t prefix[16]) | |
| Constructs an Ipv6Prefix by using the input 16 bytes. | |
| Ipv6Prefix (uint8_t prefix[16], uint8_t prefixLength) | |
| Constructs an Ipv6Prefix by using the input 16 bytes. | |
| Ipv6Address | ConvertToIpv6Address () const |
| Convert the Prefix into an IPv6 Address. | |
| void | GetBytes (uint8_t buf[16]) const |
| Get the bytes corresponding to the prefix. | |
| uint8_t | GetMinimumPrefixLength () const |
| Get the minimum prefix length, i.e., 128 - the length of the largest sequence trailing zeroes. | |
| uint8_t | GetPrefixLength () const |
| Get prefix length. | |
| bool | IsMatch (Ipv6Address a, Ipv6Address b) const |
| Check whether two addresses have the same bits in the prefix portion of their addresses. | |
| std::strong_ordering | operator<=> (const Ipv6Prefix &other) const =default |
| Three-way comparison operator. | |
| void | Print (std::ostream &os) const |
| Print this address to the given output stream. | |
| void | SetPrefixLength (uint8_t prefixLength) |
| Set prefix length. | |
Static Public Member Functions | |
| static Ipv6Prefix | GetLoopback () |
| Get the loopback prefix ( /128). | |
| static Ipv6Prefix | GetOnes () |
| Get the "all-1" IPv6 mask (ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff). | |
| static Ipv6Prefix | GetZero () |
| Get the zero prefix ( /0). | |
Private Attributes | |
| std::array< uint8_t, 16 > | m_prefix {} |
| The prefix representation. | |
| uint8_t | m_prefixLength {0} |
| The prefix length. | |
Describes an IPv6 prefix.
It is just a bitmask like Ipv4Mask.
Definition at line 425 of file ipv6-address.h.
|
default |
Default constructor.
The default prefix is empty, corresponding to /0
References Ipv6Prefix().
Referenced by Ipv6Prefix(), GetLoopback(), GetOnes(), GetZero(), and operator<=>().
| ns3::Ipv6Prefix::Ipv6Prefix | ( | uint8_t | prefix[16] | ) |
Constructs an Ipv6Prefix by using the input 16 bytes.
The prefix length is calculated as the minimum prefix length, i.e., 2001:db8:cafe:: will have a 47 bit prefix length (0xE is 0b1110).
| prefix | the 128-bit prefix |
Definition at line 762 of file ipv6-address.cc.
References GetMinimumPrefixLength(), m_prefix, m_prefixLength, and NS_LOG_FUNCTION.
| ns3::Ipv6Prefix::Ipv6Prefix | ( | const char * | prefix | ) |
Constructs an Ipv6Prefix by using the input string.
The prefix length is calculated as the minimum prefix length, i.e., 2001:db8:cafe:: will have a 47 bit prefix length.
| prefix | the 128-bit prefix |
Definition at line 752 of file ipv6-address.cc.
References GetMinimumPrefixLength(), m_prefix, m_prefixLength, NS_ABORT_MSG, and NS_LOG_FUNCTION.
| ns3::Ipv6Prefix::Ipv6Prefix | ( | uint8_t | prefix[16], |
| uint8_t | prefixLength ) |
Constructs an Ipv6Prefix by using the input 16 bytes.
| prefix | the 128-bit prefix |
| prefixLength | the prefix length |
Definition at line 784 of file ipv6-address.cc.
References GetMinimumPrefixLength(), m_prefix, m_prefixLength, NS_ASSERT_MSG, and NS_LOG_FUNCTION.
| ns3::Ipv6Prefix::Ipv6Prefix | ( | const char * | prefix, |
| uint8_t | prefixLength ) |
Constructs an Ipv6Prefix by using the input string.
| prefix | the 128-bit prefix |
| prefixLength | the prefix length |
Definition at line 769 of file ipv6-address.cc.
References GetMinimumPrefixLength(), m_prefix, m_prefixLength, NS_ABORT_MSG, NS_ASSERT_MSG, and NS_LOG_FUNCTION.
| ns3::Ipv6Prefix::Ipv6Prefix | ( | uint8_t | prefix | ) |
Constructs an Ipv6Prefix by using the input number of bits.
| prefix | number of bits of the prefix (0 - 128) |
Definition at line 797 of file ipv6-address.cc.
References m_prefix, m_prefixLength, NS_ASSERT, and NS_LOG_FUNCTION.
| Ipv6Address ns3::Ipv6Prefix::ConvertToIpv6Address | ( | ) | const |
Convert the Prefix into an IPv6 Address.
Definition at line 895 of file ipv6-address.cc.
References m_prefix.
| void ns3::Ipv6Prefix::GetBytes | ( | uint8_t | buf[16] | ) | const |
Get the bytes corresponding to the prefix.
| buf | buffer to store the data |
Definition at line 888 of file ipv6-address.cc.
References m_prefix, and NS_LOG_FUNCTION.
Referenced by ns3::SixLowPanNetDevice::FindMulticastCompressionContext(), ns3::Ipv6AddressGeneratorImpl::Init(), and ns3::Ipv6AddressGeneratorImpl::PrefixToIndex().
|
static |
Get the loopback prefix ( /128).
Definition at line 864 of file ipv6-address.cc.
References Ipv6Prefix(), and NS_LOG_FUNCTION_NOARGS.
| uint8_t ns3::Ipv6Prefix::GetMinimumPrefixLength | ( | ) | const |
Get the minimum prefix length, i.e., 128 - the length of the largest sequence trailing zeroes.
Definition at line 919 of file ipv6-address.cc.
References m_prefix, and NS_LOG_FUNCTION.
Referenced by Ipv6Prefix(), Ipv6Prefix(), Ipv6Prefix(), and Ipv6Prefix().
|
static |
Get the "all-1" IPv6 mask (ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff).
Definition at line 872 of file ipv6-address.cc.
References Ipv6Prefix(), and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::Ipv6StaticRouting::AddHostRouteTo(), ns3::Ipv6StaticRouting::AddHostRouteTo(), ns3::Ipv6RoutingTableEntry::CreateHostRouteTo(), and ns3::Ipv6RoutingTableEntry::IsHost().
| uint8_t ns3::Ipv6Prefix::GetPrefixLength | ( | ) | const |
Get prefix length.
Definition at line 905 of file ipv6-address.cc.
References m_prefixLength, and NS_LOG_FUNCTION.
Referenced by ns3::SixLowPanNetDevice::CleanPrefix(), ns3::SixLowPanNetDevice::FindMulticastCompressionContext(), ns3::Ipv6StaticRouting::GetDefaultRoute(), ns3::RipNg::Lookup(), ns3::Ipv6StaticRouting::LookupStatic(), ns3::operator<<(), Print(), ns3::Ipv6StaticRouting::PrintRoutingTable(), and ns3::RipNg::PrintRoutingTable().
|
static |
Get the zero prefix ( /0).
Definition at line 880 of file ipv6-address.cc.
References Ipv6Prefix(), and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::RipNg::AddDefaultRouteTo(), ns3::RipNg::DoSendRouteUpdate(), ns3::RipNg::HandleRequests(), and ns3::Ipv6StaticRouting::SetDefaultRoute().
| bool ns3::Ipv6Prefix::IsMatch | ( | Ipv6Address | a, |
| Ipv6Address | b ) const |
Check whether two addresses have the same bits in the prefix portion of their addresses.
If the prefix length is 0, this method will return true regardless of the two address argument values. If the prefix length is 128, this method will require that the two address arguments are the same.
| a | first address to compare |
| b | second address to compare |
Definition at line 834 of file ipv6-address.cc.
References ns3::Ipv6Address::GetBytes(), m_prefix, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv6Interface::GetAddressMatchingDestination(), ns3::Ipv6StaticRouting::HasNetworkDest(), ns3::RipNg::Lookup(), ns3::Ipv6StaticRouting::LookupStatic(), ns3::Dhcp6Server::RenewRebindLeases(), and ns3::Dhcp6Server::SendReply().
|
default |
Three-way comparison operator.
| other | the other prefix to compare with |
References Ipv6Prefix().
| void ns3::Ipv6Prefix::Print | ( | std::ostream & | os | ) | const |
Print this address to the given output stream.
The print format is in the typical "2001:660:4701::1".
| os | the output stream to which this Ipv6Address is printed |
Definition at line 856 of file ipv6-address.cc.
References GetPrefixLength(), and NS_LOG_FUNCTION.
Referenced by ns3::operator<<().
| void ns3::Ipv6Prefix::SetPrefixLength | ( | uint8_t | prefixLength | ) |
Set prefix length.
| prefixLength | the prefix length |
Definition at line 912 of file ipv6-address.cc.
References m_prefixLength, and NS_LOG_FUNCTION.
|
private |
The prefix representation.
Definition at line 560 of file ipv6-address.h.
Referenced by Ipv6Prefix(), Ipv6Prefix(), Ipv6Prefix(), Ipv6Prefix(), Ipv6Prefix(), ConvertToIpv6Address(), GetBytes(), GetMinimumPrefixLength(), and IsMatch().
|
private |
The prefix length.
Definition at line 565 of file ipv6-address.h.
Referenced by Ipv6Prefix(), Ipv6Prefix(), Ipv6Prefix(), Ipv6Prefix(), Ipv6Prefix(), GetPrefixLength(), and SetPrefixLength().