A Discrete-Event Network Simulator
API
ns3::Ipv6Prefix Class Reference

Describes an IPv6 prefix. More...

#include "ipv6-address.h"

Public Member Functions

 Ipv6Prefix ()
 Default constructor. More...
 
 Ipv6Prefix (uint8_t prefix[16])
 Constructs an Ipv6Prefix by using the input 16 bytes. More...
 
 Ipv6Prefix (char const *prefix)
 Constructs an Ipv6Prefix by using the input string. More...
 
 Ipv6Prefix (uint8_t prefix[16], uint8_t prefixLength)
 Constructs an Ipv6Prefix by using the input 16 bytes. More...
 
 Ipv6Prefix (char const *prefix, uint8_t prefixLength)
 Constructs an Ipv6Prefix by using the input string. More...
 
 Ipv6Prefix (uint8_t prefix)
 Constructs an Ipv6Prefix by using the input number of bits. More...
 
 Ipv6Prefix (Ipv6Prefix const &prefix)
 Copy constructor. More...
 
 Ipv6Prefix (Ipv6Prefix const *prefix)
 Copy constructor. More...
 
 ~Ipv6Prefix ()
 Destructor. More...
 
void GetBytes (uint8_t buf[16]) const
 Get the bytes corresponding to the prefix. More...
 
uint8_t GetMinimumPrefixLength () const
 Get the minimum prefix length, i.e., 128 - the length of the largest sequence trailing zeroes. More...
 
uint8_t GetPrefixLength () const
 Get prefix length. More...
 
NS_DEPRECATED_3_31 bool IsEqual (const Ipv6Prefix &other) const
 Comparison operation between two Ipv6Prefix. More...
 
bool IsMatch (Ipv6Address a, Ipv6Address b) const
 If the Address match the type. More...
 
void Print (std::ostream &os) const
 Print this address to the given output stream. More...
 
void SetPrefixLength (uint8_t prefixLength)
 Set prefix length. More...
 

Static Public Member Functions

static Ipv6Prefix GetLoopback ()
 Get the loopback prefix ( /128). More...
 
static Ipv6Prefix GetOnes ()
 Get the "all-1" IPv6 mask (ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff). More...
 
static Ipv6Prefix GetZero ()
 Get the zero prefix ( /0). More...
 

Private Attributes

uint8_t m_prefix [16]
 The prefix representation. More...
 
uint8_t m_prefixLength
 The prefix length. More...
 

Friends

bool operator!= (Ipv6Prefix const &a, Ipv6Prefix const &b)
 Not equal to operator. More...
 
bool operator== (Ipv6Prefix const &a, Ipv6Prefix const &b)
 Equal to operator. More...
 

Detailed Description

Describes an IPv6 prefix.

It is just a bitmask like Ipv4Mask.

See also
Ipv6Address
Ipv6Prefix Attribute

Definition at line 459 of file ipv6-address.h.

Constructor & Destructor Documentation

◆ Ipv6Prefix() [1/8]

ns3::Ipv6Prefix::Ipv6Prefix ( )

Default constructor.

Definition at line 950 of file ipv6-address.cc.

References m_prefix, m_prefixLength, and NS_LOG_FUNCTION.

◆ Ipv6Prefix() [2/8]

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.

Parameters
prefixthe 128-bit prefix

Definition at line 964 of file ipv6-address.cc.

References GetMinimumPrefixLength(), m_prefix, m_prefixLength, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ Ipv6Prefix() [3/8]

ns3::Ipv6Prefix::Ipv6Prefix ( char const *  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.

Parameters
prefixthe 128-bit prefix

Definition at line 957 of file ipv6-address.cc.

References ns3::AsciiToIpv6Host(), GetMinimumPrefixLength(), m_prefix, m_prefixLength, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ Ipv6Prefix() [4/8]

ns3::Ipv6Prefix::Ipv6Prefix ( uint8_t  prefix[16],
uint8_t  prefixLength 
)

Constructs an Ipv6Prefix by using the input 16 bytes.

Parameters
prefixthe 128-bit prefix
prefixLengththe prefix length

Definition at line 982 of file ipv6-address.cc.

References GetMinimumPrefixLength(), m_prefix, m_prefixLength, NS_ASSERT_MSG(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ Ipv6Prefix() [5/8]

ns3::Ipv6Prefix::Ipv6Prefix ( char const *  prefix,
uint8_t  prefixLength 
)

Constructs an Ipv6Prefix by using the input string.

Parameters
prefixthe 128-bit prefix
prefixLengththe prefix length

Definition at line 971 of file ipv6-address.cc.

References ns3::AsciiToIpv6Host(), GetMinimumPrefixLength(), m_prefix, m_prefixLength, NS_ASSERT_MSG(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ Ipv6Prefix() [6/8]

ns3::Ipv6Prefix::Ipv6Prefix ( uint8_t  prefix)

Constructs an Ipv6Prefix by using the input number of bits.

Parameters
prefixnumber of bits of the prefix (0 - 128)
Note
A valid number of bits is between 0 and 128).

Definition at line 993 of file ipv6-address.cc.

References m_prefix, m_prefixLength, NS_ASSERT, and NS_LOG_FUNCTION.

◆ Ipv6Prefix() [7/8]

ns3::Ipv6Prefix::Ipv6Prefix ( Ipv6Prefix const &  prefix)

Copy constructor.

Parameters
prefixIpv6Prefix object

Definition at line 1029 of file ipv6-address.cc.

References m_prefix, and m_prefixLength.

◆ Ipv6Prefix() [8/8]

ns3::Ipv6Prefix::Ipv6Prefix ( Ipv6Prefix const *  prefix)

Copy constructor.

Parameters
prefixIpv6Prefix pointer

Definition at line 1035 of file ipv6-address.cc.

References m_prefix, and m_prefixLength.

◆ ~Ipv6Prefix()

ns3::Ipv6Prefix::~Ipv6Prefix ( )

Destructor.

Definition at line 1041 of file ipv6-address.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ GetBytes()

void ns3::Ipv6Prefix::GetBytes ( uint8_t  buf[16]) const

Get the bytes corresponding to the prefix.

Parameters
bufbuffer to store the data

Definition at line 1096 of file ipv6-address.cc.

References m_prefix, and NS_LOG_FUNCTION.

◆ GetLoopback()

Ipv6Prefix ns3::Ipv6Prefix::GetLoopback ( void  )
static

Get the loopback prefix ( /128).

Returns
a Ipv6Prefix corresponding to loopback prefix

Definition at line 1075 of file ipv6-address.cc.

References NS_LOG_FUNCTION_NOARGS.

◆ GetMinimumPrefixLength()

uint8_t ns3::Ipv6Prefix::GetMinimumPrefixLength ( ) const

Get the minimum prefix length, i.e., 128 - the length of the largest sequence trailing zeroes.

Returns
minimum prefix length

Definition at line 1114 of file ipv6-address.cc.

References m_prefix, and NS_LOG_FUNCTION.

Referenced by Ipv6Prefix().

+ Here is the caller graph for this function:

◆ GetOnes()

Ipv6Prefix ns3::Ipv6Prefix::GetOnes ( void  )
static

Get the "all-1" IPv6 mask (ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff).

Returns
/128 Ipv6Prefix representation

Definition at line 1082 of file ipv6-address.cc.

References NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::Ipv6StaticRouting::AddHostRouteTo(), ns3::Ipv6RoutingTableEntry::CreateHostRouteTo(), and ns3::Ipv6RoutingTableEntry::IsHost().

+ Here is the caller graph for this function:

◆ GetPrefixLength()

uint8_t ns3::Ipv6Prefix::GetPrefixLength ( void  ) const

◆ GetZero()

Ipv6Prefix ns3::Ipv6Prefix::GetZero ( void  )
static

Get the zero prefix ( /0).

Returns
an Ipv6Prefix

Definition at line 1089 of file ipv6-address.cc.

References NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::RipNg::AddDefaultRouteTo(), ns3::RipNg::DoSendRouteUpdate(), ns3::RipNg::HandleRequests(), and ns3::Ipv6StaticRouting::SetDefaultRoute().

+ Here is the caller graph for this function:

◆ IsEqual()

bool ns3::Ipv6Prefix::IsEqual ( const Ipv6Prefix other) const

Comparison operation between two Ipv6Prefix.

Deprecated:
Use the == operator (same functionality)
Parameters
otherthe IPv6 prefix to which to compare this prefix
Returns
true if the prefixes are equal, false otherwise

Definition at line 1142 of file ipv6-address.cc.

References m_prefix.

◆ IsMatch()

bool ns3::Ipv6Prefix::IsMatch ( Ipv6Address  a,
Ipv6Address  b 
) const

If the Address match the type.

Parameters
aa first address
ba second address
Returns
true if the type match, false otherwise

Definition at line 1047 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(), and ns3::Ipv6StaticRouting::LookupStatic().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Print()

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".

Parameters
osthe output stream to which this Ipv6Address is printed

Definition at line 1068 of file ipv6-address.cc.

References GetPrefixLength(), and NS_LOG_FUNCTION.

Referenced by ns3::operator<<().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetPrefixLength()

void ns3::Ipv6Prefix::SetPrefixLength ( uint8_t  prefixLength)

Set prefix length.

Parameters
prefixLengththe prefix length

Definition at line 1108 of file ipv6-address.cc.

References m_prefixLength, and NS_LOG_FUNCTION.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( Ipv6Prefix const &  a,
Ipv6Prefix const &  b 
)
friend

Not equal to operator.

Parameters
athe first operand
bthe first operand
Returns
true if the operands are not equal

Definition at line 683 of file ipv6-address.h.

◆ operator==

bool operator== ( Ipv6Prefix const &  a,
Ipv6Prefix const &  b 
)
friend

Equal to operator.

Parameters
athe first operand
bthe first operand
Returns
true if the operands are equal

Definition at line 678 of file ipv6-address.h.

Member Data Documentation

◆ m_prefix

uint8_t ns3::Ipv6Prefix::m_prefix[16]
private

The prefix representation.

Definition at line 598 of file ipv6-address.h.

Referenced by GetBytes(), GetMinimumPrefixLength(), Ipv6Prefix(), IsEqual(), IsMatch(), ns3::operator!=(), and ns3::operator==().

◆ m_prefixLength

uint8_t ns3::Ipv6Prefix::m_prefixLength
private

The prefix length.

Definition at line 603 of file ipv6-address.h.

Referenced by GetPrefixLength(), Ipv6Prefix(), and SetPrefixLength().


The documentation for this class was generated from the following files: