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. | |
| 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 | 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_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. | |
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 33 of file ipv4-interface-address.h.
| ns3::Ipv4InterfaceAddress::Ipv4InterfaceAddress | ( | ) |
Definition at line 19 of file ipv4-interface-address.cc.
References GLOBAL, m_scope, m_secondary, and NS_LOG_FUNCTION.
Referenced by Ipv4InterfaceAddress(), operator!=, and operator==.
| 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 26 of file ipv4-interface-address.cc.
References ns3::Ipv4Address::GetLoopback(), GLOBAL, HOST, m_local, m_mask, m_scope, m_secondary, and NS_LOG_FUNCTION.
| ns3::Ipv4InterfaceAddress::Ipv4InterfaceAddress | ( | const Ipv4InterfaceAddress & | o | ) |
Copy constructor.
| o | the object to copy |
Definition at line 39 of file ipv4-interface-address.cc.
References Ipv4InterfaceAddress(), m_local, m_mask, m_scope, m_secondary, and NS_LOG_FUNCTION.
| Ipv4Address ns3::Ipv4InterfaceAddress::GetAddress | ( | ) | const |
Get the local address.
Definition at line 69 of file ipv4-interface-address.cc.
References GetLocal().
Referenced by Ipv4L3ProtocolTestCase::DoRun(), ns3::NeighborCacheHelper::PopulateNeighborEntriesIpv4(), anonymous_namespace{wifi-multirate.cc}::PrintPosition(), ns3::Icmpv4L4Protocol::Receive(), and ns3::NeighborCacheHelper::UpdateCacheByIpv4AddressAdded().
| Ipv4Address ns3::Ipv4InterfaceAddress::GetBroadcast | ( | ) | const |
Get the broadcast address.
Definition at line 89 of file ipv4-interface-address.cc.
References m_local, m_mask, and NS_LOG_FUNCTION.
Referenced by DsdvTableTestCase::DoRun(), ns3::UdpSocketImpl::DoSendTo(), ns3::Ipv4L3ClickProtocol::IsDestinationAddress(), 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::Icmpv4L4Protocol::Receive(), 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 | ( | ) | const |
Get the local address.
Definition at line 62 of file ipv4-interface-address.cc.
References m_local, and NS_LOG_FUNCTION.
Referenced by DsdvTableTestCase::DoRun(), ns3::Rip::DoSendRouteUpdate(), ns3::UdpSocketImpl::DoSendTo(), GetAddress(), ns3::AnimationInterface::GetIpv4Address(), ns3::AnimationInterface::GetIpv4Addresses(), ns3::Ipv4L3ClickProtocol::IsDestinationAddress(), ns3::Ipv4L3Protocol::IsDestinationAddress(), ns3::aodv::RoutingProtocol::IsMyOwnAddress(), ns3::olsr::RoutingProtocol::IsMyOwnAddress(), ns3::Ipv4L3ClickProtocol::LocalDeliver(), 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(), anonymous_namespace{wifi-multirate.cc}::PrintPosition(), ns3::aodv::RoutingProtocol::RouteInput(), ns3::dsdv::RoutingProtocol::RouteInput(), ns3::olsr::RoutingProtocol::RouteInput(), ns3::Ipv4ClickRouting::RouteOutput(), ns3::olsr::RoutingProtocol::RouteOutput(), ns3::Ipv4L3ClickProtocol::SelectSourceAddress(), ns3::Ipv4L3Protocol::SelectSourceAddress(), ns3::Ipv4L3Protocol::Send(), ns3::aodv::RoutingProtocol::SendHello(), ns3::aodv::RoutingProtocol::SendRequest(), ns3::aodv::RoutingProtocol::SendRerrMessage(), ns3::aodv::RoutingProtocol::SendRerrWhenNoRouteToForward(), ns3::Ipv4L3ClickProtocol::SourceAddressSelection(), ns3::Ipv4L3Protocol::SourceAddressSelection(), ns3::NeighborCacheHelper::UpdateCacheByIpv4AddressAdded(), and ns3::NeighborCacheHelper::UpdateCacheByIpv4AddressRemoved().
| Ipv4Mask ns3::Ipv4InterfaceAddress::GetMask | ( | ) | const |
Get the network mask.
Definition at line 82 of file ipv4-interface-address.cc.
References m_mask, and NS_LOG_FUNCTION.
Referenced by ns3::Rip::DoSendRouteUpdate(), ns3::Ipv4L3ClickProtocol::LocalDeliver(), ns3::Ipv4L3Protocol::LocalDeliver(), ns3::Ipv4EndPointDemux::Lookup(), ns3::operator<<(), ns3::aodv::RoutingProtocol::RecvRequest(), ns3::Ipv4L3ClickProtocol::SelectSourceAddress(), 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 | ( | ) | const |
Get address scope.
Definition at line 103 of file ipv4-interface-address.cc.
References m_scope, and NS_LOG_FUNCTION.
Referenced by ns3::Rip::DoSendRouteUpdate(), ns3::Rip::HandleRequests(), ns3::operator<<(), ns3::Ipv4L3ClickProtocol::SelectSourceAddress(), 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 110 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().
| bool ns3::Ipv4InterfaceAddress::IsSecondary | ( | ) | const |
Check if the address is a secondary address.
Secondary address is used for multihoming
Definition at line 121 of file ipv4-interface-address.cc.
References m_secondary, and NS_LOG_FUNCTION.
Referenced by ns3::operator<<(), ns3::Ipv4L3ClickProtocol::SelectSourceAddress(), and ns3::Ipv4L3Protocol::SelectSourceAddress().
| void ns3::Ipv4InterfaceAddress::SetAddress | ( | Ipv4Address | address | ) |
Set local address.
| address | the address |
Definition at line 56 of file ipv4-interface-address.cc.
References SetLocal().
| void ns3::Ipv4InterfaceAddress::SetLocal | ( | Ipv4Address | local | ) |
Set local address.
| local | the address |
Definition at line 49 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 75 of file ipv4-interface-address.cc.
References m_mask, and NS_LOG_FUNCTION.
| void ns3::Ipv4InterfaceAddress::SetPrimary | ( | ) |
Make the address primary.
Definition at line 135 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 96 of file ipv4-interface-address.cc.
References m_scope, and NS_LOG_FUNCTION.
| void ns3::Ipv4InterfaceAddress::SetSecondary | ( | ) |
Make the address secondary (used for multihoming).
Definition at line 128 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 198 of file ipv4-interface-address.h.
References Ipv4InterfaceAddress(), m_local, m_mask, m_scope, and m_secondary.
|
friend |
Equal to operator.
| a | the first operand |
| b | the first operand |
Definition at line 191 of file ipv4-interface-address.h.
References Ipv4InterfaceAddress(), m_local, m_mask, m_scope, and m_secondary.
|
private |
Interface address.
Definition at line 154 of file ipv4-interface-address.h.
Referenced by Ipv4InterfaceAddress(), Ipv4InterfaceAddress(), GetBroadcast(), GetLocal(), IsInSameSubnet(), operator!=, operator==, and SetLocal().
|
private |
Network mask.
Definition at line 157 of file ipv4-interface-address.h.
Referenced by Ipv4InterfaceAddress(), Ipv4InterfaceAddress(), GetBroadcast(), GetMask(), IsInSameSubnet(), operator!=, operator==, and SetMask().
|
private |
Address scope.
Definition at line 159 of file ipv4-interface-address.h.
Referenced by Ipv4InterfaceAddress(), Ipv4InterfaceAddress(), Ipv4InterfaceAddress(), GetScope(), operator!=, operator==, and SetScope().
|
private |
For use in multihoming.
Definition at line 160 of file ipv4-interface-address.h.
Referenced by Ipv4InterfaceAddress(), Ipv4InterfaceAddress(), Ipv4InterfaceAddress(), IsSecondary(), operator!=, operator==, SetPrimary(), and SetSecondary().