Ipv4 addresses are stored in host order in this class. More...
#include "ipv4-address.h"
Public Member Functions | |
Ipv4Address () | |
Ipv4Address (char const *address) | |
Constructs an Ipv4Address by parsing a the input C-string. More... | |
Ipv4Address (uint32_t address) | |
input address is in host order. More... | |
Ipv4Address | CombineMask (Ipv4Mask const &mask) const |
Combine this address with a network mask. More... | |
uint32_t | Get (void) const |
Get the host-order 32-bit IP address. More... | |
Ipv4Address | GetSubnetDirectedBroadcast (Ipv4Mask const &mask) const |
Generate subnet-directed broadcast address corresponding to mask. More... | |
bool | IsAny (void) const |
bool | IsBroadcast (void) const |
bool | IsInitialized (void) const |
bool | IsLocalhost (void) const |
bool | IsLocalMulticast (void) const |
bool | IsMulticast (void) const |
bool | IsSubnetDirectedBroadcast (Ipv4Mask const &mask) const |
Generate subnet-directed broadcast address corresponding to mask. More... | |
operator Address () const | |
Convert an instance of this class to a polymorphic Address instance. More... | |
void | Print (std::ostream &os) const |
Print this address to the given output stream. More... | |
void | Serialize (uint8_t buf[4]) const |
Serialize this address to a 4-byte buffer. More... | |
void | Set (char const *address) |
Sets an Ipv4Address by parsing a the input C-string. More... | |
void | Set (uint32_t address) |
input address is in host order. More... | |
Static Public Member Functions | |
static Ipv4Address | ConvertFrom (const Address &address) |
static Ipv4Address | Deserialize (const uint8_t buf[4]) |
static Ipv4Address | GetAny (void) |
static Ipv4Address | GetBroadcast (void) |
static Ipv4Address | GetLoopback (void) |
static Ipv4Address | GetZero (void) |
static bool | IsMatchingType (const Address &address) |
Private Member Functions | |
Address | ConvertTo (void) const |
Convert to an Address type. More... | |
Static Private Member Functions | |
static uint8_t | GetType (void) |
Get the underlying address type (automatically assigned). More... | |
Private Attributes | |
uint32_t | m_address |
IPv4 address. More... | |
bool | m_initialized |
IPv4 address has been explicitly initialized to a valid value. More... | |
Friends | |
bool | operator!= (Ipv4Address const &a, Ipv4Address const &b) |
Not equal to operator. More... | |
bool | operator< (Ipv4Address const &a, Ipv4Address const &b) |
Less than to operator. More... | |
bool | operator== (Ipv4Address const &a, Ipv4Address const &b) |
Equal to operator. More... | |
Ipv4 addresses are stored in host order in this class.
Definition at line 41 of file ipv4-address.h.
ns3::Ipv4Address::Ipv4Address | ( | ) |
Definition at line 195 of file ipv4-address.cc.
References NS_LOG_FUNCTION.
Referenced by CombineMask(), and GetSubnetDirectedBroadcast().
|
explicit |
input address is in host order.
address | The host order 32-bit address |
Definition at line 200 of file ipv4-address.cc.
References first::address, m_address, m_initialized, and NS_LOG_FUNCTION.
ns3::Ipv4Address::Ipv4Address | ( | char const * | address | ) |
Constructs an Ipv4Address by parsing a the input C-string.
Input address is in format: hhh.xxx.xxx.lll
where h
is the high byte and l
the low byte
address | C-string containing the address as described above |
Definition at line 206 of file ipv4-address.cc.
References first::address, ns3::AsciiToIpv4Host(), m_address, m_initialized, and NS_LOG_FUNCTION.
Ipv4Address ns3::Ipv4Address::CombineMask | ( | Ipv4Mask const & | mask | ) | const |
Combine this address with a network mask.
This method returns an IPv4 address that is this address combined (bitwise and) with a network mask, yielding an IPv4 network address.
mask | a network mask |
Definition at line 235 of file ipv4-address.cc.
References Ipv4Address(), Get(), ns3::Ipv4Mask::Get(), and NS_LOG_FUNCTION.
Referenced by ns3::IpcsClassifierRecord::CheckMatchDstAddr(), ns3::IpcsClassifierRecord::CheckMatchSrcAddr(), ns3::Rip::DoSendRouteUpdate(), ns3::Rip::HandleRequests(), ns3::Rip::HandleResponses(), ns3::Ipv4InterfaceAddress::IsInSameSubnet(), ns3::Ipv4AddressGeneratorImpl::IsNetworkAllocated(), ns3::Ipv4L3Protocol::LocalDeliver(), ns3::Ipv4EndPointDemux::Lookup(), ns3::GlobalRouter::ProcessBridgedBroadcastLink(), ns3::GlobalRouter::ProcessSingleBroadcastLink(), ns3::Ipv4L3Protocol::SelectSourceAddress(), ns3::Ipv4L3Protocol::Send(), ns3::GlobalRouteManagerImpl::SPFAddASExternal(), ns3::GlobalRouteManagerImpl::SPFIntraAddStub(), and ns3::GlobalRouteManagerImpl::SPFIntraAddTransit().
|
static |
address | a polymorphic address |
This function performs a type check and asserts if the type of the input address is not compatible with an Ipv4Address.
Definition at line 370 of file ipv4-address.cc.
References first::address, Deserialize(), GetType(), NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by ns3::UdpSocketImpl::DoSend(), ns3::UdpSocketImpl::GetPeerName(), ns3::ThreeGppHttpClient::OpenConnection(), ns3::PbbAddressBlockIpv4::PrintAddress(), ns3::PbbMessageIpv4::PrintOriginatorAddress(), ns3::UdpEchoClient::Send(), ns3::TcpL4Protocol::SendPacket(), ns3::UdpTraceClient::SendPacket(), ns3::PbbAddressBlockIpv4::SerializeAddress(), ns3::PbbMessageIpv4::SerializeOriginatorAddress(), ns3::ThreeGppHttpServer::StartApplication(), ns3::UdpClient::StartApplication(), ns3::UdpEchoClient::StartApplication(), and ns3::UdpTraceClient::StartApplication().
|
private |
Convert to an Address type.
Definition at line 361 of file ipv4-address.cc.
References GetType(), NS_LOG_FUNCTION, and Serialize().
|
static |
buf | buffer to read address from |
The input address is expected to be in network byte order format.
Definition at line 322 of file ipv4-address.cc.
References m_address, m_initialized, and NS_LOG_FUNCTION.
Referenced by ns3::InetSocketAddress::ConvertFrom(), ConvertFrom(), ns3::dsr::DsrOptionRreqHeader::Deserialize(), ns3::dsr::DsrOptionRrepHeader::Deserialize(), ns3::dsr::DsrOptionSRHeader::Deserialize(), ns3::Ipv4FlowProbeTag::Deserialize(), ns3::Ipv4PacketInfoTag::Deserialize(), ns3::PbbAddressBlockIpv4::DeserializeAddress(), ns3::PbbMessageIpv4::DeserializeOriginatorAddress(), and ns3::Ipv6Address::GetIpv4MappedAddress().
uint32_t ns3::Ipv4Address::Get | ( | void | ) | const |
Get the host-order 32-bit IP address.
Definition at line 214 of file ipv4-address.cc.
References m_address, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4InterfaceAddress::Ipv4InterfaceAddress(), ns3::DhcpServer::AddStaticDhcpEntry(), ns3::Ipv4L3Protocol::BuildHeader(), ns3::EpcTftClassifier::Classify(), CombineMask(), ns3::Ipv4L3Protocol::DecreaseIdentification(), SwitchFlowTableTestCase::DoRun(), GetSubnetDirectedBroadcast(), ns3::Ipv4AddressGeneratorImpl::Init(), ns3::Ipv4AddressGeneratorImpl::InitAddress(), ns3::DhcpHelper::InstallDhcpServer(), ns3::DhcpHelper::InstallFixedAddress(), ns3::Ipv4Mask::IsMatch(), IsSubnetDirectedBroadcast(), ns3::DhcpServer::NetHandler(), ns3::PacketSink::AddressHash::operator()(), ns3::QKDApp004::AddressHash::operator()(), ns3::QKDApp014::AddressHash::operator()(), ns3::QKDKeyManagerSystemApplication::AddressHash::operator()(), ns3::QKDSDNController::AddressHash::operator()(), ns3::Ipv4L3Protocol::ProcessFragment(), ns3::DhcpClient::Request(), ns3::Ipv4Header::Serialize(), ns3::RipRte::Serialize(), ns3::olsr::MessageHeader::Serialize(), ns3::GtpcIes::SerializeFteid(), ns3::Ipv4AddressHelper::SetBase(), ns3::GlobalRouteManagerImpl::SPFIntraAddStub(), ns3::DhcpServer::StartApplication(), and ns3::WriteTo().
|
static |
Definition at line 395 of file ipv4-address.cc.
References NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::DhcpClient::DhcpClient(), ns3::Ipv4RawSocketImpl::Ipv4RawSocketImpl(), ns3::NoBackhaulEpcHelper::NoBackhaulEpcHelper(), ns3::QKDAppHelper::QKDAppHelper(), Tunnel::Tunnel(), ns3::Ipv4EndPointDemux::Allocate(), ns3::Ipv4RawSocketImpl::Bind(), ns3::TcpSocketBase::Bind(), ns3::UdpSocketImpl::Bind(), BuildAppsTest(), ns3::QKDKeyManagerSystemApplication::ConnectToSDNController(), ns3::olsr::Bug780Test::CreateNodes(), ns3::olsr::RoutingProtocol::DoInitialize(), ns3::TcpGeneralTest::DoRun(), ns3::LenaDeactivateBearerTestCase::DoRun(), ns3::Rip::DoSendRouteUpdate(), ns3::UdpSocketImpl::DoSendTo(), experiment(), ns3::Ipv4RawSocketImpl::ForwardUp(), ns3::Ipv4RawSocketImpl::GetPeerName(), ns3::Rip::HandleRequests(), InstallPacketSink(), ns3::Ipv4L3Protocol::IpMulticastForward(), ns3::Ipv4EndPointDemux::Lookup(), ns3::dsdv::RoutingProtocol::NotifyAddAddress(), ns3::dsdv::RoutingProtocol::NotifyInterfaceUp(), ns3::dsdv::RoutingProtocol::NotifyRemoveAddress(), ns3::QKDSDNController::PrepareSinkSocket(), ns3::QKDApp004::PrepareSinkSocketFromKMS(), ns3::QKDApp014::PrepareSinkSocketFromKMS(), Experiment::Run(), ns3::Ipv4L3Protocol::Send(), ns3::Rip::SendRouteRequest(), ns3::Ipv4RawSocketImpl::SendTo(), ns3::QKDAppHelper::SetSettings(), ns3::Ipv4EndPointDemux::SimpleLookup(), ns3::QKDPostprocessingApplication::StartApplication(), ns3::UdpEchoServer::StartApplication(), ns3::UdpServer::StartApplication(), ns3::DhcpClient::StartApplication(), ns3::DhcpServer::StartApplication(), ns3::V4Ping::StartApplication(), ns3::V4TraceRoute::StartApplication(), and ns3::BsmApplication::StartApplication().
|
static |
Definition at line 402 of file ipv4-address.cc.
References NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::ArpL3Protocol::SendArpRequest(), and ns3::aodv::RoutingProtocol::SendRerrMessage().
|
static |
Definition at line 409 of file ipv4-address.cc.
References NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::Ipv4InterfaceAddress::Ipv4InterfaceAddress(), ns3::aodv::LoopbackTestCase::DoRun(), ns3::Ipv4L3Protocol::RemoveAddress(), ns3::aodv::LoopbackTestCase::SendData(), ns3::aodv::RoutingProtocol::SetIpv4(), ns3::dsdv::RoutingProtocol::SetIpv4(), and ns3::Ipv4L3Protocol::SetupLoopback().
Ipv4Address ns3::Ipv4Address::GetSubnetDirectedBroadcast | ( | Ipv4Mask const & | mask | ) | const |
Generate subnet-directed broadcast address corresponding to mask.
The subnet-directed broadcast address has the host bits set to all ones. If this method is called with a mask of 255.255.255.255, (i.e., the address is a /32 address), the program will assert, since there is no subnet associated with a /32 address.
mask | a network mask |
Definition at line 242 of file ipv4-address.cc.
References Ipv4Address(), Get(), ns3::Ipv4Mask::GetInverse(), ns3::Ipv4Mask::GetOnes(), NS_ASSERT_MSG, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4FlowProbe::DropLogger(), and ns3::olsr::RoutingProtocol::SendPacket().
|
staticprivate |
Get the underlying address type (automatically assigned).
Definition at line 380 of file ipv4-address.cc.
References NS_LOG_FUNCTION_NOARGS, and ns3::Address::Register().
Referenced by ConvertFrom(), ConvertTo(), and IsMatchingType().
|
static |
Definition at line 388 of file ipv4-address.cc.
References NS_LOG_FUNCTION_NOARGS, and zero.
Referenced by ns3::TapFdNetDeviceHelper::TapFdNetDeviceHelper(), ns3::Ipv4RoutingTableEntry::CreateDefaultRoute(), ns3::TapFdNetDeviceHelper::CreateFileDescriptor(), ns3::Ipv4FlowClassifier::FindFlow(), ns3::TcpSocketBase::GetSockName(), ns3::UdpSocketImpl::GetSockName(), ns3::Ipv4RoutingTableEntry::IsDefault(), ns3::Ipv4RoutingTableEntry::IsGateway(), ns3::Rip::Lookup(), ns3::Ipv4StaticRouting::LookupStatic(), ns3::TcpSocketBase::RecvFrom(), and ns3::GlobalRouteManagerImpl::SPFNexthopCalculation().
bool ns3::Ipv4Address::IsAny | ( | void | ) | const |
Definition at line 273 of file ipv4-address.cc.
References m_address, and NS_LOG_FUNCTION.
Referenced by ns3::Rip::Lookup(), and ns3::Ipv4L3Protocol::Send().
bool ns3::Ipv4Address::IsBroadcast | ( | void | ) | const |
Definition at line 287 of file ipv4-address.cc.
References m_address, and NS_LOG_FUNCTION.
Referenced by ns3::TapBridge::CreateTap(), ns3::UdpSocketImpl::DoSendTo(), ns3::Ipv4L3Protocol::IpForward(), ns3::Ipv4L3Protocol::IsUnicast(), ns3::Ipv4L3Protocol::LocalDeliver(), ns3::dsr::DsrRouteCache::RebuildBestRouteTable(), ns3::aodv::RoutingProtocol::RouteInput(), ns3::dsdv::RoutingProtocol::RouteInput(), ns3::Rip::RouteInput(), ns3::Ipv4Interface::Send(), and ns3::Ipv4L3Protocol::Send().
bool ns3::Ipv4Address::IsInitialized | ( | void | ) | const |
Definition at line 266 of file ipv4-address.cc.
References m_initialized, and NS_LOG_FUNCTION.
bool ns3::Ipv4Address::IsLocalhost | ( | void | ) | const |
Definition at line 280 of file ipv4-address.cc.
References m_address, and NS_LOG_FUNCTION.
bool ns3::Ipv4Address::IsLocalMulticast | ( | void | ) | const |
Definition at line 305 of file ipv4-address.cc.
References m_address, and NS_LOG_FUNCTION.
Referenced by ns3::Rip::Lookup(), ns3::Ipv4StaticRouting::LookupStatic(), and ns3::Ipv4L3Protocol::Send().
|
static |
address | an address to compare type with |
Definition at line 350 of file ipv4-address.cc.
References first::address, GetType(), and NS_LOG_FUNCTION.
Referenced by ns3::TcpHeader::CalculateHeaderChecksum(), ns3::UdpHeader::CalculateHeaderChecksum(), ns3::UdpSocketImpl::DoSend(), ns3::UdpSocketImpl::GetPeerName(), ns3::ThreeGppHttpClient::OpenConnection(), ns3::UdpEchoClient::Send(), ns3::TcpL4Protocol::SendPacket(), ns3::UdpTraceClient::SendPacket(), ns3::ThreeGppHttpServer::StartApplication(), ns3::UdpClient::StartApplication(), ns3::UdpEchoClient::StartApplication(), and ns3::UdpTraceClient::StartApplication().
bool ns3::Ipv4Address::IsMulticast | ( | void | ) | const |
Definition at line 294 of file ipv4-address.cc.
References m_address, and NS_LOG_FUNCTION.
Referenced by ns3::dsr::DsrOptionRerr::DoSendError(), ns3::UdpSocketImpl::DoSendTo(), ns3::Ipv4L3Protocol::IpForward(), ns3::addressUtils::IsMulticast(), ns3::Ipv4L3Protocol::IsUnicast(), ns3::Ipv4L3Protocol::LocalDeliver(), ns3::dsr::DsrOptionSR::Process(), ns3::Ipv4L3Protocol::Receive(), ns3::aodv::RoutingProtocol::RouteInput(), ns3::dsdv::RoutingProtocol::RouteInput(), ns3::Ipv4ListRouting::RouteInput(), ns3::Ipv4StaticRouting::RouteInput(), ns3::Rip::RouteInput(), ns3::Ipv4GlobalRouting::RouteOutput(), ns3::Ipv4StaticRouting::RouteOutput(), ns3::Rip::RouteOutput(), ns3::Ipv4Interface::Send(), and ns3::Ipv4L3Protocol::Send().
bool ns3::Ipv4Address::IsSubnetDirectedBroadcast | ( | Ipv4Mask const & | mask | ) | const |
Generate subnet-directed broadcast address corresponding to mask.
The subnet-directed broadcast address has the host bits set to all ones. If this method is called with a mask of 255.255.255.255, (i.e., the address is a /32 address), the program will assert, since there is no subnet associated with a /32 address.
mask | a network mask |
Definition at line 253 of file ipv4-address.cc.
References Get(), ns3::Ipv4Mask::GetInverse(), ns3::Ipv4Mask::GetOnes(), and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3Protocol::IsUnicast(), ns3::Ipv4L3Protocol::LocalDeliver(), ns3::Ipv4Interface::Send(), and ns3::Ipv4L3Protocol::Send().
ns3::Ipv4Address::operator Address | ( | ) | const |
Convert an instance of this class to a polymorphic Address instance.
Definition at line 355 of file ipv4-address.cc.
void ns3::Ipv4Address::Print | ( | std::ostream & | os | ) | const |
Print this address to the given output stream.
The print format is in the typical "192.168.1.1"
os | The output stream to which this Ipv4Address is printed |
Definition at line 340 of file ipv4-address.cc.
References m_address, and NS_LOG_FUNCTION.
Referenced by ns3::QKDKeyManagerSystemApplication::AddNewLink(), ns3::QKDApp004::Close(), ns3::QKDApp004::CreateKeyQueues(), ns3::QKDApp004::GetKeyFromKMS(), ns3::QKDApp014::GetKeysFromKMS(), ns3::QKDApp014::GetKeyWithKeyIDs(), ns3::QKDApp014::GetStatusFromKMS(), ns3::QKDKeyManagerSystemApplication::NegotiateKeysForAssociation(), ns3::QKDApp004::OpenConnect(), ns3::PbbAddressBlockIpv4::PrintAddress(), ns3::PbbMessageIpv4::PrintOriginatorAddress(), ns3::QKDKeyManagerSystemApplication::ProcessRequest(), ns3::QKDKeyManagerSystemApplication::RegisterApplicationEntry(), ns3::QKDKeyManagerSystemApplication::RegisterRequest(), ns3::QKDApp004::SendKsidRequest(), ns3::QKDApp004::SendMaliciousRequestToKMS(), ns3::QKDKeyManagerSystemApplication::SendQKDLinkStatusToSDN(), and ns3::QKDKeyManagerSystemApplication::TransformKeys().
void ns3::Ipv4Address::Serialize | ( | uint8_t | buf[4] | ) | const |
Serialize this address to a 4-byte buffer.
buf | output buffer to which this address gets overwritten with this Ipv4Address |
Definition at line 313 of file ipv4-address.cc.
References m_address, and NS_LOG_FUNCTION.
Referenced by ns3::InetSocketAddress::ConvertTo(), ConvertTo(), ns3::Mac48Address::GetMulticast(), ns3::ArpQueueDiscItem::Hash(), ns3::Ipv4QueueDiscItem::Hash(), ns3::Ipv6Address::MakeIpv4MappedAddress(), ns3::Ipv4FlowProbeTag::Serialize(), ns3::Ipv4PacketInfoTag::Serialize(), ns3::PbbAddressBlockIpv4::SerializeAddress(), and ns3::PbbMessageIpv4::SerializeOriginatorAddress().
void ns3::Ipv4Address::Set | ( | char const * | address | ) |
Sets an Ipv4Address by parsing a the input C-string.
Input address is in format: hhh.xxx.xxx.lll
where h
is the high byte and l
the low byte
address | C-string containing the address as described above |
Definition at line 227 of file ipv4-address.cc.
References first::address, ns3::AsciiToIpv4Host(), m_address, m_initialized, and NS_LOG_FUNCTION.
void ns3::Ipv4Address::Set | ( | uint32_t | address | ) |
input address is in host order.
address | The host order 32-bit address |
Definition at line 220 of file ipv4-address.cc.
References first::address, m_address, m_initialized, and NS_LOG_FUNCTION.
Referenced by EpcTftClassifierTestSuite::EpcTftClassifierTestSuite(), ns3::GlobalRouter::GlobalRouter(), ns3::Ipv4Header::Deserialize(), ns3::RipRte::Deserialize(), ns3::GtpcIes::DeserializeFteid(), ns3::GlobalRouter::ProcessBridgedBroadcastLink(), ns3::GlobalRouter::ProcessSingleBroadcastLink(), and ns3::ReadFrom().
|
friend |
Not equal to operator.
a | the first operand. |
b | the first operand. |
Definition at line 382 of file ipv4-address.h.
|
friend |
Less than to operator.
a | the first operand. |
b | the first operand. |
Definition at line 387 of file ipv4-address.h.
|
friend |
Equal to operator.
a | the first operand. |
b | the first operand. |
Definition at line 377 of file ipv4-address.h.
|
private |
IPv4 address.
Definition at line 214 of file ipv4-address.h.
Referenced by Ipv4Address(), Deserialize(), Get(), IsAny(), IsBroadcast(), IsLocalhost(), IsLocalMulticast(), IsMulticast(), Print(), Serialize(), and Set().
|
private |
IPv4 address has been explicitly initialized to a valid value.
Definition at line 215 of file ipv4-address.h.
Referenced by Ipv4Address(), Deserialize(), IsInitialized(), and Set().