A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::Ipv4Mask Class Reference

a class to represent an Ipv4 address mask More...

#include "ipv4-address.h"

Collaboration diagram for ns3::Ipv4Mask:

Public Member Functions

 Ipv4Mask ()=default
 Will initialize to a zero-length mask, which will match any address.
 Ipv4Mask (const char *mask)
 Ipv4Mask (uint32_t mask)
uint32_t Get () const
 Get the host-order 32-bit IP mask.
uint32_t GetInverse () const
 Return the inverse mask in host order.
uint16_t GetPrefixLength () const
bool IsMatch (Ipv4Address a, Ipv4Address b) const
std::strong_ordering operator<=> (const Ipv4Mask &a) const =default
 Three-way comparison operator.
void Print (std::ostream &os) const
 Print this mask to the given output stream.
void Set (uint32_t mask)
 input mask is in host order.

Static Public Member Functions

static Ipv4Mask GetLoopback ()
static Ipv4Mask GetOnes ()
static Ipv4Mask GetZero ()

Private Attributes

uint32_t m_mask {0}
 IP mask.

Detailed Description

a class to represent an Ipv4 address mask

The constructor takes arguments according to a few formats. Ipv4Mask ("255.255.255.255"), Ipv4Mask ("/32"), and Ipv4Mask (0xffffffff) are all equivalent.

See also
Ipv4Mask Attribute

Definition at line 256 of file ipv4-address.h.

Constructor & Destructor Documentation

◆ Ipv4Mask() [1/3]

ns3::Ipv4Mask::Ipv4Mask ( )
default

Will initialize to a zero-length mask, which will match any address.

References Ipv4Mask().

Referenced by Ipv4Mask(), GetLoopback(), GetOnes(), GetZero(), and operator<=>().

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

◆ Ipv4Mask() [2/3]

ns3::Ipv4Mask::Ipv4Mask ( uint32_t mask)
Parameters
maskbitwise integer representation of the mask

For example, the integer input 0xffffff00 yields a 24-bit mask

Definition at line 28 of file ipv4-address.cc.

References m_mask, and NS_LOG_FUNCTION.

◆ Ipv4Mask() [3/3]

ns3::Ipv4Mask::Ipv4Mask ( const char * mask)
Parameters
maskString constant either in "255.255.255.0" or "/24" format

Definition at line 34 of file ipv4-address.cc.

References m_mask, NS_ABORT_MSG, NS_ASSERT, and NS_LOG_FUNCTION.

Member Function Documentation

◆ Get()

uint32_t ns3::Ipv4Mask::Get ( ) const

Get the host-order 32-bit IP mask.

Returns
the host-order 32-bit IP mask

Definition at line 68 of file ipv4-address.cc.

References m_mask, and NS_LOG_FUNCTION.

Referenced by ns3::Ipv4Address::CombineMask(), ns3::Ipv4AddressGeneratorImpl::Init(), ns3::Ipv4Address::IsSubnetDirectedBroadcast(), ns3::Ipv4AddressGeneratorImpl::MaskToIndex(), ns3::GlobalRouter::ProcessBridgedBroadcastLink(), ns3::GlobalRouter::ProcessPointToPointLink(), ns3::GlobalRouter::ProcessSingleBroadcastLink(), and ns3::Ipv4AddressHelper::SetBase().

Here is the caller graph for this function:

◆ GetInverse()

uint32_t ns3::Ipv4Mask::GetInverse ( ) const

Return the inverse mask in host order.

Returns
The inverse mask

Definition at line 82 of file ipv4-address.cc.

References m_mask, and NS_LOG_FUNCTION.

Referenced by ns3::Ipv4Address::GetSubnetDirectedBroadcast().

Here is the caller graph for this function:

◆ GetLoopback()

Ipv4Mask ns3::Ipv4Mask::GetLoopback ( )
static
Returns
the 255.0.0.0 mask corresponding to a typical loopback address

Definition at line 97 of file ipv4-address.cc.

References Ipv4Mask(), and NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::Ipv4L3ClickProtocol::SetupLoopback(), and ns3::Ipv4L3Protocol::SetupLoopback().

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

◆ GetOnes()

Ipv4Mask ns3::Ipv4Mask::GetOnes ( )
static

◆ GetPrefixLength()

uint16_t ns3::Ipv4Mask::GetPrefixLength ( ) const
Returns
the prefix length of mask (the yy in x.x.x.x/yy notation)

Definition at line 121 of file ipv4-address.cc.

References m_mask, and NS_LOG_FUNCTION.

Referenced by ns3::Ipv4StaticRouting::GetDefaultRoute(), ns3::Ipv4EndPointDemux::Lookup(), ns3::Rip::Lookup(), ns3::Ipv4GlobalRouting::LookupGlobal(), ns3::Ipv4StaticRouting::LookupStatic(), ns3::GlobalRouter::ProcessBridgedBroadcastLink(), and ns3::GlobalRouter::ProcessSingleBroadcastLink().

Here is the caller graph for this function:

◆ GetZero()

Ipv4Mask ns3::Ipv4Mask::GetZero ( )
static
Returns
the 0.0.0.0 mask

Definition at line 105 of file ipv4-address.cc.

References Ipv4Mask(), and NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::TapFdNetDeviceHelper::TapFdNetDeviceHelper(), ns3::Rip::AddDefaultRouteTo(), ns3::Ipv4RoutingTableEntry::CreateDefaultRoute(), ns3::TapFdNetDeviceHelper::CreateFileDescriptor(), ns3::Rip::DoSendRouteUpdate(), ns3::Rip::HandleRequests(), ns3::Rip::SendRouteRequest(), and ns3::Ipv4StaticRouting::SetDefaultRoute().

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

◆ IsMatch()

bool ns3::Ipv4Mask::IsMatch ( Ipv4Address a,
Ipv4Address b ) const
Parameters
afirst address to compare
bsecond address to compare
Returns
true if both addresses are equal in their masked bits, corresponding to this mask

Definition at line 61 of file ipv4-address.cc.

References ns3::Ipv4Address::Get(), m_mask, and NS_LOG_FUNCTION.

Referenced by ns3::Rip::Lookup(), ns3::Ipv4GlobalRouting::LookupGlobal(), and ns3::Ipv4StaticRouting::LookupStatic().

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

◆ operator<=>()

std::strong_ordering ns3::Ipv4Mask::operator<=> ( const Ipv4Mask & a) const
default

Three-way comparison operator.

Parameters
athe other mask to compare with
Returns
comparison result

References Ipv4Mask().

Here is the call graph for this function:

◆ Print()

void ns3::Ipv4Mask::Print ( std::ostream & os) const

Print this mask to the given output stream.

The print format is in the typical "255.255.255.0"

Parameters
osThe output stream to which this Ipv4Address is printed

Definition at line 89 of file ipv4-address.cc.

References m_mask, and NS_LOG_FUNCTION.

Referenced by ns3::operator<<().

Here is the caller graph for this function:

◆ Set()

void ns3::Ipv4Mask::Set ( uint32_t mask)

input mask is in host order.

Parameters
maskThe host order 32-bit mask

Definition at line 75 of file ipv4-address.cc.

References m_mask, and NS_LOG_FUNCTION.

Referenced by EpcTftClassifierTestSuite::EpcTftClassifierTestSuite().

Here is the caller graph for this function:

Member Data Documentation

◆ m_mask

uint32_t ns3::Ipv4Mask::m_mask {0}
private

IP mask.

Definition at line 328 of file ipv4-address.h.

Referenced by Ipv4Mask(), Ipv4Mask(), Get(), GetInverse(), GetPrefixLength(), IsMatch(), Print(), and Set().


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