a class to store IPv4 address information on an interface More...
#include "ipv4-interface-address.h"
Public Types | |
enum | InterfaceAddressScope_e { HOST , LINK , GLOBAL } |
Address scope. More... | |
Public Member Functions | |
Ipv4InterfaceAddress () | |
Ipv4InterfaceAddress (const Ipv4InterfaceAddress &o) | |
Copy constructor. More... | |
Ipv4InterfaceAddress (Ipv4Address local, Ipv4Mask mask) | |
Configure local address, mask and broadcast address. More... | |
Ipv4Address | GetAddress (void) const |
Get the local address. More... | |
Ipv4Address | GetBroadcast (void) const |
Get the broadcast address. More... | |
Ipv4Address | GetLocal (void) const |
Get the local address. More... | |
Ipv4Mask | GetMask (void) const |
Get the network mask. More... | |
Ipv4InterfaceAddress::InterfaceAddressScope_e | GetScope (void) const |
Get address scope. More... | |
bool | IsInSameSubnet (const Ipv4Address b) const |
Checks if the address is in the same subnet. More... | |
bool | IsSecondary (void) const |
Check if the address is a secondary address. More... | |
void | SetAddress (Ipv4Address address) |
Set local address. More... | |
void | SetBroadcast (Ipv4Address broadcast) |
Set the broadcast address. More... | |
void | SetLocal (Ipv4Address local) |
Set local address. More... | |
void | SetMask (Ipv4Mask mask) |
Set the network mask. More... | |
void | SetPrimary (void) |
Make the address primary. More... | |
void | SetScope (Ipv4InterfaceAddress::InterfaceAddressScope_e scope) |
Set the scope. More... | |
void | SetSecondary (void) |
Make the address secondary (used for multihoming) More... | |
Private Attributes | |
Ipv4Address | m_broadcast |
Broadcast address. More... | |
Ipv4Address | m_local |
Interface address. More... | |
Ipv4Mask | m_mask |
Network mask. More... | |
InterfaceAddressScope_e | m_scope |
Address scope. More... | |
bool | m_secondary |
For use in multihoming. More... | |
Friends | |
bool | operator!= (Ipv4InterfaceAddress const &a, Ipv4InterfaceAddress const &b) |
Not equal to operator. More... | |
bool | operator== (Ipv4InterfaceAddress const &a, Ipv4InterfaceAddress const &b) |
Equal to operator. More... | |
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 43 of file ipv4-interface-address.h.
ns3::Ipv4InterfaceAddress::Ipv4InterfaceAddress | ( | ) |
Definition at line 29 of file ipv4-interface-address.cc.
References NS_LOG_FUNCTION.
ns3::Ipv4InterfaceAddress::Ipv4InterfaceAddress | ( | Ipv4Address | local, |
Ipv4Mask | mask | ||
) |
Configure local address, mask and broadcast address.
local | the local address |
mask | the network mask |
Definition at line 36 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.
ns3::Ipv4InterfaceAddress::Ipv4InterfaceAddress | ( | const Ipv4InterfaceAddress & | o | ) |
Copy constructor.
o | the object to copy |
Definition at line 50 of file ipv4-interface-address.cc.
References NS_LOG_FUNCTION.
Ipv4Address ns3::Ipv4InterfaceAddress::GetAddress | ( | void | ) | const |
Get the local address.
Ipv4InterfaceAddress::GetLocal
. This function is consistent with Ipv6InterfaceAddress::GetAddress
. Definition at line 81 of file ipv4-interface-address.cc.
References GetLocal().
Referenced by Ipv4L3ProtocolTestCase::DoRun(), and PrintPosition().
Ipv4Address ns3::Ipv4InterfaceAddress::GetBroadcast | ( | void | ) | const |
Get the broadcast address.
Definition at line 108 of file ipv4-interface-address.cc.
References m_broadcast, and NS_LOG_FUNCTION.
Referenced by DsdvTableTestCase::DoRun(), ns3::UdpSocketImpl::DoSendTo(), ns3::Ipv4L3Protocol::IsDestinationAddress(), ns3::Ipv4L3Protocol::IsUnicast(), ns3::aodv::RoutingProtocol::NotifyAddAddress(), ns3::dsdv::RoutingProtocol::NotifyAddAddress(), ns3::aodv::RoutingProtocol::NotifyInterfaceUp(), ns3::aodv::RoutingProtocol::NotifyRemoveAddress(), ns3::operator<<(), ns3::aodv::RoutingProtocol::RecvRequest(), ns3::aodv::RoutingProtocol::RouteInput(), ns3::dsdv::RoutingProtocol::RouteInput(), ns3::aodv::RoutingProtocol::SendHello(), ns3::dsdv::RoutingProtocol::SendPeriodicUpdate(), ns3::aodv::RoutingProtocol::SendRequest(), ns3::aodv::RoutingProtocol::SendRerrWhenNoRouteToForward(), and ns3::dsdv::RoutingProtocol::SendTriggeredUpdate().
Ipv4Address ns3::Ipv4InterfaceAddress::GetLocal | ( | void | ) | const |
Get the local address.
Ipv4InterfaceAddress::GetAddress
. The method corresponds to the linux variable in_ifaddr.ifa_local Ipv4InterfaceAddress::GetAddress
is to be preferred. Definition at line 74 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::aodv::RoutingTableEntry::Print(), ns3::dsdv::RoutingTableEntry::Print(), PrintPosition(), ns3::ArpL3Protocol::Receive(), 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(), and ns3::Ipv4L3Protocol::SourceAddressSelection().
Ipv4Mask ns3::Ipv4InterfaceAddress::GetMask | ( | void | ) | const |
Get the network mask.
Definition at line 94 of file ipv4-interface-address.cc.
References m_mask, and NS_LOG_FUNCTION.
Referenced by ns3::Rip::DoSendRouteUpdate(), ns3::Ipv4L3Protocol::LocalDeliver(), ns3::Ipv4EndPointDemux::Lookup(), ns3::operator<<(), ns3::aodv::RoutingProtocol::RecvRequest(), ns3::Ipv4L3Protocol::SelectSourceAddress(), ns3::Ipv4L3Protocol::Send(), ns3::aodv::RoutingProtocol::SendHello(), ns3::dsdv::RoutingProtocol::SendPeriodicUpdate(), ns3::aodv::RoutingProtocol::SendRequest(), ns3::aodv::RoutingProtocol::SendRerrWhenNoRouteToForward(), ns3::Ipv4RawSocketImpl::SendTo(), and ns3::dsdv::RoutingProtocol::SendTriggeredUpdate().
Ipv4InterfaceAddress::InterfaceAddressScope_e ns3::Ipv4InterfaceAddress::GetScope | ( | void | ) | const |
Get address scope.
Definition at line 122 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().
bool ns3::Ipv4InterfaceAddress::IsInSameSubnet | ( | const Ipv4Address | b | ) | const |
Checks if the address is in the same subnet.
b | the address to check |
Definition at line 128 of file ipv4-interface-address.cc.
References ns3::Ipv4Address::CombineMask(), m_local, and m_mask.
bool ns3::Ipv4InterfaceAddress::IsSecondary | ( | void | ) | const |
Check if the address is a secondary address.
Secondary address is used for multihoming
Definition at line 139 of file ipv4-interface-address.cc.
References m_secondary, and NS_LOG_FUNCTION.
Referenced by ns3::operator<<(), and ns3::Ipv4L3Protocol::SelectSourceAddress().
void ns3::Ipv4InterfaceAddress::SetAddress | ( | Ipv4Address | address | ) |
Set local address.
address | the address |
Ipv4InterfaceAddress::SetLocal
. This function is consistent with Ipv6InterfaceAddress::SetAddress
. Definition at line 68 of file ipv4-interface-address.cc.
References first::address, and SetLocal().
void ns3::Ipv4InterfaceAddress::SetBroadcast | ( | Ipv4Address | broadcast | ) |
Set the broadcast address.
broadcast | the broadcast address |
Definition at line 101 of file ipv4-interface-address.cc.
References m_broadcast, and NS_LOG_FUNCTION.
void ns3::Ipv4InterfaceAddress::SetLocal | ( | Ipv4Address | local | ) |
Set local address.
local | the address |
Ipv4InterfaceAddress::SetAddress
. The method corresponds to the linux variable in_ifaddr.ifa_local Ipv4InterfaceAddress::SetAddress
is to be preferred. Definition at line 61 of file ipv4-interface-address.cc.
References m_local, and NS_LOG_FUNCTION.
Referenced by SetAddress().
void ns3::Ipv4InterfaceAddress::SetMask | ( | Ipv4Mask | mask | ) |
Set the network mask.
mask | the network mask |
Definition at line 87 of file ipv4-interface-address.cc.
References m_mask, and NS_LOG_FUNCTION.
void ns3::Ipv4InterfaceAddress::SetPrimary | ( | void | ) |
Make the address primary.
Definition at line 153 of file ipv4-interface-address.cc.
References m_secondary, and NS_LOG_FUNCTION.
void ns3::Ipv4InterfaceAddress::SetScope | ( | Ipv4InterfaceAddress::InterfaceAddressScope_e | scope | ) |
Set the scope.
scope | the scope of address |
Definition at line 115 of file ipv4-interface-address.cc.
References m_scope, and NS_LOG_FUNCTION.
void ns3::Ipv4InterfaceAddress::SetSecondary | ( | void | ) |
Make the address secondary (used for multihoming)
Definition at line 146 of file ipv4-interface-address.cc.
References m_secondary, and NS_LOG_FUNCTION.
|
friend |
Not equal to operator.
a | the first operand |
b | the first operand |
Definition at line 209 of file ipv4-interface-address.h.
|
friend |
Equal to operator.
a | the first operand |
b | the first operand |
Definition at line 204 of file ipv4-interface-address.h.
|
private |
Broadcast address.
Definition at line 171 of file ipv4-interface-address.h.
Referenced by Ipv4InterfaceAddress(), GetBroadcast(), and SetBroadcast().
|
private |
Interface address.
Definition at line 167 of file ipv4-interface-address.h.
Referenced by Ipv4InterfaceAddress(), GetLocal(), IsInSameSubnet(), and SetLocal().
|
private |
Network mask.
Definition at line 170 of file ipv4-interface-address.h.
Referenced by Ipv4InterfaceAddress(), GetMask(), IsInSameSubnet(), and SetMask().
|
private |
Address scope.
Definition at line 173 of file ipv4-interface-address.h.
Referenced by Ipv4InterfaceAddress(), GetScope(), and SetScope().
|
private |
For use in multihoming.
Definition at line 174 of file ipv4-interface-address.h.
Referenced by IsSecondary(), SetPrimary(), and SetSecondary().