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

a class to store IPv4 address information on an interface More...

#include "ipv4-interface-address.h"

+ Collaboration diagram for ns3::Ipv4InterfaceAddress:

Public Types

enum  InterfaceAddressScope_e { HOST , LINK , GLOBAL }
 Address scope. More...
 

Public Member Functions

 Ipv4InterfaceAddress ()
 
 Ipv4InterfaceAddress (const Ipv4InterfaceAddress &o)
 Copy constructor.
 
 Ipv4InterfaceAddress (Ipv4Address local, Ipv4Mask mask)
 Configure local address, mask and broadcast address.
 
Ipv4Address GetAddress () const
 Get the local address.
 
Ipv4Address GetBroadcast () const
 Get the broadcast address.
 
Ipv4Address GetLocal () const
 Get the local address.
 
Ipv4Mask GetMask () const
 Get the network mask.
 
Ipv4InterfaceAddress::InterfaceAddressScope_e GetScope () const
 Get address scope.
 
bool IsInSameSubnet (const Ipv4Address b) const
 Checks if the address is in the same subnet.
 
bool IsSecondary () const
 Check if the address is a secondary address.
 
void SetAddress (Ipv4Address address)
 Set local address.
 
void SetBroadcast (Ipv4Address broadcast)
 Set the broadcast address.
 
void SetLocal (Ipv4Address local)
 Set local address.
 
void SetMask (Ipv4Mask mask)
 Set the network mask.
 
void SetPrimary ()
 Make the address primary.
 
void SetScope (Ipv4InterfaceAddress::InterfaceAddressScope_e scope)
 Set the scope.
 
void SetSecondary ()
 Make the address secondary (used for multihoming)
 

Private Attributes

Ipv4Address m_broadcast
 Broadcast address.
 
Ipv4Address m_local
 Interface address.
 
Ipv4Mask m_mask
 Network mask.
 
InterfaceAddressScope_e m_scope
 Address scope.
 
bool m_secondary
 For use in multihoming.
 

Friends

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

Detailed Description

a class to store IPv4 address information on an interface

Corresponds to Linux struct in_ifaddr. A list of these addresses is stored in Ipv4Interface. This class is modelled after how current Linux handles IP aliasing for IPv4. Notably, aliasing of IPv4 interfaces (e.g., "eth0:1") is not used, and instead an interface is assigned possibly multiple addresses, with each address being classified as being primary and secondary. See the iproute2 documentation for this distinction.

Definition at line 44 of file ipv4-interface-address.h.

Member Enumeration Documentation

◆ InterfaceAddressScope_e

Address scope.

Enumerator
HOST 
LINK 
GLOBAL 

Definition at line 51 of file ipv4-interface-address.h.

Constructor & Destructor Documentation

◆ Ipv4InterfaceAddress() [1/3]

ns3::Ipv4InterfaceAddress::Ipv4InterfaceAddress ( )

Definition at line 30 of file ipv4-interface-address.cc.

References NS_LOG_FUNCTION.

◆ Ipv4InterfaceAddress() [2/3]

ns3::Ipv4InterfaceAddress::Ipv4InterfaceAddress ( Ipv4Address  local,
Ipv4Mask  mask 
)

Configure local address, mask and broadcast address.

Parameters
localthe local address
maskthe network mask

Definition at line 37 of file ipv4-interface-address.cc.

References ns3::Ipv4Address::Get(), ns3::Ipv4Mask::Get(), ns3::Ipv4Address::GetLoopback(), HOST, m_broadcast, m_local, m_mask, m_scope, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ Ipv4InterfaceAddress() [3/3]

ns3::Ipv4InterfaceAddress::Ipv4InterfaceAddress ( const Ipv4InterfaceAddress o)

Copy constructor.

Parameters
othe object to copy

Definition at line 51 of file ipv4-interface-address.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ GetAddress()

Ipv4Address ns3::Ipv4InterfaceAddress::GetAddress ( ) const

Get the local address.

Returns
the local address
Note
Functially identical to Ipv4InterfaceAddress::GetLocal. This function is consistent with Ipv6InterfaceAddress::GetAddress.

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

References GetLocal().

Referenced by Ipv4L3ProtocolTestCase::DoRun(), ns3::NeighborCacheHelper::PopulateNeighborEntriesIpv4(), PrintPosition(), ns3::Icmpv4L4Protocol::Receive(), and ns3::NeighborCacheHelper::UpdateCacheByIpv4AddressAdded().

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

◆ GetBroadcast()

◆ GetLocal()

Ipv4Address ns3::Ipv4InterfaceAddress::GetLocal ( ) const

Get the local address.

Returns
the local address
Note
Functionally identical to Ipv4InterfaceAddress::GetAddress. The method corresponds to the linux variable in_ifaddr.ifa_local Ipv4InterfaceAddress::GetAddress is to be preferred.

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

References m_local, and NS_LOG_FUNCTION.

Referenced by ns3::aodv::RoutingTableEntry::RoutingTableEntry(), ns3::dsdv::RoutingTableEntry::RoutingTableEntry(), DsdvTableTestCase::DoRun(), ns3::Rip::DoSendRouteUpdate(), ns3::UdpSocketImpl::DoSendTo(), GetAddress(), ns3::AnimationInterface::GetIpv4Address(), ns3::AnimationInterface::GetIpv4Addresses(), ns3::Ipv4L3Protocol::IsDestinationAddress(), ns3::olsr::RoutingProtocol::IsMyOwnAddress(), ns3::aodv::RoutingProtocol::IsMyOwnAddress(), ns3::Ipv4L3Protocol::LocalDeliver(), ns3::Ipv4EndPointDemux::Lookup(), ns3::aodv::RoutingProtocol::NotifyAddAddress(), ns3::dsdv::RoutingProtocol::NotifyAddAddress(), ns3::aodv::RoutingProtocol::NotifyInterfaceUp(), ns3::aodv::RoutingProtocol::NotifyRemoveAddress(), ns3::operator<<(), ns3::NeighborCacheHelper::PopulateNeighborEntriesIpv4(), ns3::aodv::RoutingTableEntry::Print(), ns3::dsdv::RoutingTableEntry::Print(), PrintPosition(), ns3::aodv::RoutingProtocol::RouteInput(), ns3::dsdv::RoutingProtocol::RouteInput(), ns3::olsr::RoutingProtocol::RouteInput(), ns3::olsr::RoutingProtocol::RouteOutput(), ns3::Ipv4L3Protocol::SelectSourceAddress(), ns3::Ipv4L3Protocol::Send(), ns3::aodv::RoutingProtocol::SendHello(), ns3::aodv::RoutingProtocol::SendRequest(), ns3::aodv::RoutingProtocol::SendRerrMessage(), ns3::aodv::RoutingProtocol::SendRerrWhenNoRouteToForward(), ns3::Ipv4L3Protocol::SourceAddressSelection(), ns3::NeighborCacheHelper::UpdateCacheByIpv4AddressAdded(), and ns3::NeighborCacheHelper::UpdateCacheByIpv4AddressRemoved().

+ Here is the caller graph for this function:

◆ GetMask()

◆ GetScope()

Ipv4InterfaceAddress::InterfaceAddressScope_e ns3::Ipv4InterfaceAddress::GetScope ( ) const

Get address scope.

Returns
scope

Definition at line 123 of file ipv4-interface-address.cc.

References m_scope, and NS_LOG_FUNCTION.

Referenced by ns3::Rip::DoSendRouteUpdate(), ns3::Rip::HandleRequests(), ns3::operator<<(), and ns3::Ipv4L3Protocol::SelectSourceAddress().

+ Here is the caller graph for this function:

◆ IsInSameSubnet()

bool ns3::Ipv4InterfaceAddress::IsInSameSubnet ( const Ipv4Address  b) const

Checks if the address is in the same subnet.

Parameters
bthe address to check
Returns
true if the address is in the same subnet.

Definition at line 130 of file ipv4-interface-address.cc.

References ns3::Ipv4Address::CombineMask(), m_local, and m_mask.

Referenced by ns3::NeighborCacheHelper::PopulateNeighborEntriesIpv4(), ns3::Icmpv4L4Protocol::Receive(), and ns3::NeighborCacheHelper::UpdateCacheByIpv4AddressAdded().

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

◆ IsSecondary()

bool ns3::Ipv4InterfaceAddress::IsSecondary ( ) const

Check if the address is a secondary address.

Secondary address is used for multihoming

Returns
true if the address is secondary

Definition at line 141 of file ipv4-interface-address.cc.

References m_secondary, and NS_LOG_FUNCTION.

Referenced by ns3::operator<<(), and ns3::Ipv4L3Protocol::SelectSourceAddress().

+ Here is the caller graph for this function:

◆ SetAddress()

void ns3::Ipv4InterfaceAddress::SetAddress ( Ipv4Address  address)

Set local address.

Parameters
addressthe address
Note
Functially identical to Ipv4InterfaceAddress::SetLocal. This function is consistent with Ipv6InterfaceAddress::SetAddress.

Definition at line 69 of file ipv4-interface-address.cc.

References SetLocal().

+ Here is the call graph for this function:

◆ SetBroadcast()

void ns3::Ipv4InterfaceAddress::SetBroadcast ( Ipv4Address  broadcast)

Set the broadcast address.

Parameters
broadcastthe broadcast address

Definition at line 102 of file ipv4-interface-address.cc.

References m_broadcast, and NS_LOG_FUNCTION.

◆ SetLocal()

void ns3::Ipv4InterfaceAddress::SetLocal ( Ipv4Address  local)

Set local address.

Parameters
localthe address
Note
Functionally identical to Ipv4InterfaceAddress::SetAddress. The method corresponds to the linux variable in_ifaddr.ifa_local Ipv4InterfaceAddress::SetAddress is to be preferred.

Definition at line 62 of file ipv4-interface-address.cc.

References m_local, and NS_LOG_FUNCTION.

Referenced by SetAddress().

+ Here is the caller graph for this function:

◆ SetMask()

void ns3::Ipv4InterfaceAddress::SetMask ( Ipv4Mask  mask)

Set the network mask.

Parameters
maskthe network mask

Definition at line 88 of file ipv4-interface-address.cc.

References m_mask, and NS_LOG_FUNCTION.

◆ SetPrimary()

void ns3::Ipv4InterfaceAddress::SetPrimary ( )

Make the address primary.

Definition at line 155 of file ipv4-interface-address.cc.

References m_secondary, and NS_LOG_FUNCTION.

◆ SetScope()

void ns3::Ipv4InterfaceAddress::SetScope ( Ipv4InterfaceAddress::InterfaceAddressScope_e  scope)

Set the scope.

Parameters
scopethe scope of address

Definition at line 116 of file ipv4-interface-address.cc.

References m_scope, and NS_LOG_FUNCTION.

◆ SetSecondary()

void ns3::Ipv4InterfaceAddress::SetSecondary ( )

Make the address secondary (used for multihoming)

Definition at line 148 of file ipv4-interface-address.cc.

References m_secondary, and NS_LOG_FUNCTION.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const Ipv4InterfaceAddress a,
const Ipv4InterfaceAddress b 
)
friend

Not equal to operator.

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

Definition at line 213 of file ipv4-interface-address.h.

◆ operator==

bool operator== ( const Ipv4InterfaceAddress a,
const Ipv4InterfaceAddress b 
)
friend

Equal to operator.

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

Definition at line 206 of file ipv4-interface-address.h.

Member Data Documentation

◆ m_broadcast

Ipv4Address ns3::Ipv4InterfaceAddress::m_broadcast
private

Broadcast address.

Definition at line 172 of file ipv4-interface-address.h.

Referenced by Ipv4InterfaceAddress(), GetBroadcast(), and SetBroadcast().

◆ m_local

Ipv4Address ns3::Ipv4InterfaceAddress::m_local
private

Interface address.

Definition at line 168 of file ipv4-interface-address.h.

Referenced by Ipv4InterfaceAddress(), GetLocal(), IsInSameSubnet(), and SetLocal().

◆ m_mask

Ipv4Mask ns3::Ipv4InterfaceAddress::m_mask
private

Network mask.

Definition at line 171 of file ipv4-interface-address.h.

Referenced by Ipv4InterfaceAddress(), GetMask(), IsInSameSubnet(), and SetMask().

◆ m_scope

InterfaceAddressScope_e ns3::Ipv4InterfaceAddress::m_scope
private

Address scope.

Definition at line 174 of file ipv4-interface-address.h.

Referenced by Ipv4InterfaceAddress(), GetScope(), and SetScope().

◆ m_secondary

bool ns3::Ipv4InterfaceAddress::m_secondary
private

For use in multihoming.

Definition at line 175 of file ipv4-interface-address.h.

Referenced by IsSecondary(), SetPrimary(), and SetSecondary().


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