Ipv4 addresses are stored in host order in this class. More...
#include <ipv4-address.h>
Public Member Functions | |
Ipv4Address () | |
Ipv4Address (uint32_t address) | |
Ipv4Address (char const *address) | |
Constructs an Ipv4Address by parsing a the input C-string. | |
uint32_t | Get (void) const |
void | Set (uint32_t address) |
void | Set (char const *address) |
Sets an Ipv4Address by parsing a the input C-string. | |
bool | IsEqual (const Ipv4Address &other) const |
Comparison operation between two Ipv4Addresses. | |
void | Serialize (uint8_t buf[4]) const |
void | Print (std::ostream &os) const |
Print this address to the given output stream. | |
bool | IsBroadcast (void) const |
bool | IsMulticast (void) const |
Ipv4Address | CombineMask (Ipv4Mask const &mask) const |
Combine this address with a network mask. | |
Ipv4Address | GetSubnetDirectedBroadcast (Ipv4Mask const &mask) const |
Generate subnet-directed broadcast address corresponding to mask. | |
bool | IsSubnetDirectedBroadcast (Ipv4Mask const &mask) const |
Generate subnet-directed broadcast address corresponding to mask. | |
operator Address () const | |
Static Public Member Functions | |
static Ipv4Address | Deserialize (const uint8_t buf[4]) |
static bool | IsMatchingType (const Address &address) |
static Ipv4Address | ConvertFrom (const Address &address) |
static Ipv4Address | GetZero (void) |
static Ipv4Address | GetAny (void) |
static Ipv4Address | GetBroadcast (void) |
static Ipv4Address | GetLoopback (void) |
Private Member Functions | |
Address | ConvertTo (void) const |
Static Private Member Functions | |
static uint8_t | GetType (void) |
Private Attributes | |
uint32_t | m_address |
Friends | |
bool | operator== (Ipv4Address const &a, Ipv4Address const &b) |
bool | operator!= (Ipv4Address const &a, Ipv4Address const &b) |
bool | operator< (Ipv4Address const &addrA, Ipv4Address const &addrB) |
Ipv4 addresses are stored in host order in this class.
Definition at line 38 of file ipv4-address.h.
ns3::Ipv4Address::Ipv4Address | ( | ) |
Definition at line 135 of file ipv4-address.cc.
Referenced by CombineMask(), and GetSubnetDirectedBroadcast().
ns3::Ipv4Address::Ipv4Address | ( | uint32_t | address | ) | [explicit] |
input address is in host order.
address | The host order 32-bit address |
Definition at line 138 of file ipv4-address.cc.
References m_address.
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 142 of file ipv4-address.cc.
References ns3::AsciiToIpv4Host(), and m_address.
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 164 of file ipv4-address.cc.
References ns3::Ipv4Mask::Get(), Get(), and Ipv4Address().
Referenced by ns3::Ipv4L3Protocol::FindInterfaceForAddr(), ns3::Ipv4::GetIfIndexByAddress(), ns3::GlobalRouter::ProcessBridgedBroadcastLink(), ns3::GlobalRouter::ProcessSingleBroadcastLink(), ns3::GlobalRouteManagerImpl::SPFIntraAddStub(), and ns3::GlobalRouteManagerImpl::SPFIntraAddTransit().
Ipv4Address ns3::Ipv4Address::ConvertFrom | ( | const Address & | address | ) | [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 258 of file ipv4-address.cc.
References ns3::Address::CheckCompatible(), ns3::Address::CopyTo(), Deserialize(), GetType(), and NS_ASSERT.
Address ns3::Ipv4Address::ConvertTo | ( | void | ) | const [private] |
Definition at line 250 of file ipv4-address.cc.
References GetType(), and Serialize().
Referenced by operator Address().
Ipv4Address ns3::Ipv4Address::Deserialize | ( | const uint8_t | buf[4] | ) | [static] |
buf | buffer to read address from |
The input address is expected to be in network byte order format.
Definition at line 216 of file ipv4-address.cc.
References m_address.
Referenced by ns3::NscTcpL4Protocol::AddInterface(), ns3::NscTcpSocketImpl::CompleteFork(), ns3::NscTcpSocketImpl::ConnectionSucceeded(), and ConvertFrom().
uint32_t ns3::Ipv4Address::Get | ( | void | ) | const |
Get the host-order 32-bit IP address
Definition at line 148 of file ipv4-address.cc.
References m_address.
Referenced by ns3::Ipv4AddressGeneratorImpl::AddAllocated(), CombineMask(), ns3::Ipv4Interface::GetBroadcast(), GetSubnetDirectedBroadcast(), ns3::Ipv4AddressGeneratorImpl::Init(), ns3::Ipv4AddressGeneratorImpl::InitAddress(), ns3::Ipv4Mask::IsMatch(), IsSubnetDirectedBroadcast(), ns3::Ipv4AddressHash::operator()(), ns3::olsr::MessageHeader::Serialize(), ns3::Ipv4Header::Serialize(), and ns3::Ipv4AddressHelper::SetBase().
Ipv4Address ns3::Ipv4Address::GetAny | ( | void | ) | [static] |
Definition at line 280 of file ipv4-address.cc.
Referenced by ns3::Ipv4EndPointDemux::Allocate(), ns3::UdpSocketImpl::Bind(), ns3::TcpSocketImpl::Bind(), ns3::NscTcpSocketImpl::Bind(), ns3::Ipv4RawSocketImpl::Bind(), ns3::Ipv4L3Protocol::Forwarding(), ns3::Ipv4RawSocketImpl::ForwardUp(), ns3::Ipv4Impl::GetSourceAddress(), ns3::Ipv4RawSocketImpl::Ipv4RawSocketImpl(), ns3::Ipv4EndPointDemux::Lookup(), ns3::Ipv4StaticRouting::LookupStatic(), ns3::Ipv4StaticRouting::RequestIfIndex(), ns3::Ipv4StaticRouting::SetDefaultMulticastRoute(), ns3::TcpSocketImplTest::SetupDefaultSim(), ns3::Ipv4EndPointDemux::SimpleLookup(), and ns3::UdpEchoServer::StartApplication().
Ipv4Address ns3::Ipv4Address::GetBroadcast | ( | void | ) | [static] |
Definition at line 286 of file ipv4-address.cc.
Ipv4Address ns3::Ipv4Address::GetLoopback | ( | void | ) | [static] |
Definition at line 292 of file ipv4-address.cc.
Referenced by 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 170 of file ipv4-address.cc.
References Get(), ns3::Ipv4Mask::GetInverse(), ns3::Ipv4Mask::GetOnes(), Ipv4Address(), and NS_ASSERT_MSG.
Referenced by ns3::UdpSocketImpl::DoSendTo().
uint8_t ns3::Ipv4Address::GetType | ( | void | ) | [static, private] |
Definition at line 267 of file ipv4-address.cc.
References ns3::Address::Register().
Referenced by ConvertFrom(), ConvertTo(), and IsMatchingType().
Ipv4Address ns3::Ipv4Address::GetZero | ( | void | ) | [static] |
Definition at line 274 of file ipv4-address.cc.
Referenced by ns3::UdpSocketImpl::GetSockName().
bool ns3::Ipv4Address::IsBroadcast | ( | void | ) | const |
Definition at line 192 of file ipv4-address.cc.
References m_address.
Referenced by ns3::UdpSocketImpl::DoSendTo(), ns3::Ipv4L3Protocol::Forwarding(), ns3::Ipv4EndPointDemux::Lookup(), ns3::Ipv4L3Protocol::Send(), and ns3::ArpIpv4Interface::SendTo().
bool ns3::Ipv4Address::IsEqual | ( | const Ipv4Address & | other | ) | const [inline] |
Comparison operation between two Ipv4Addresses.
other | address to which to compare this address |
Definition at line 81 of file ipv4-address.h.
References m_address.
Referenced by ns3::Ipv4L3Protocol::Forwarding(), and ns3::ArpL3Protocol::Receive().
bool ns3::Ipv4Address::IsMatchingType | ( | const Address & | address | ) | [static] |
address | an address to compare type with |
Definition at line 240 of file ipv4-address.cc.
References ns3::Address::CheckCompatible(), and GetType().
bool ns3::Ipv4Address::IsMulticast | ( | void | ) | const |
Definition at line 198 of file ipv4-address.cc.
References m_address.
Referenced by ns3::UdpSocketImpl::DoSendTo(), ns3::Ipv4L3Protocol::IsUnicast(), ns3::Ipv4L3Protocol::Lookup(), ns3::Ipv4StaticRouting::RequestIfIndex(), ns3::Ipv4GlobalRouting::RequestIfIndex(), ns3::Ipv4StaticRouting::RequestRoute(), ns3::Ipv4GlobalRouting::RequestRoute(), and ns3::ArpIpv4Interface::SendTo().
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 180 of file ipv4-address.cc.
References Get(), ns3::Ipv4Mask::GetInverse(), and ns3::Ipv4Mask::GetOnes().
Referenced by ns3::Ipv4L3Protocol::IsUnicast(), ns3::Ipv4EndPointDemux::Lookup(), ns3::Ipv4L3Protocol::Send(), and ns3::ArpIpv4Interface::SendTo().
ns3::Ipv4Address::operator Address | ( | void | ) | const |
Convert an instance of this class to a polymorphic Address instance.
Definition at line 244 of file ipv4-address.cc.
References ConvertTo().
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 231 of file ipv4-address.cc.
References m_address.
Referenced by ns3::NscTcpL4Protocol::AddInterface(), ns3::NscTcpSocketImpl::Connect(), and ns3::TcpL4Protocol::Receive().
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 208 of file ipv4-address.cc.
References m_address.
Referenced by ns3::NscTcpL4Protocol::AddInterface(), ConvertTo(), ns3::InetSocketAddress::ConvertTo(), and ns3::Mac48Address::GetMulticast().
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 158 of file ipv4-address.cc.
References ns3::AsciiToIpv4Host(), and m_address.
void ns3::Ipv4Address::Set | ( | uint32_t | address | ) |
input address is in host order.
address | The host order 32-bit address |
Definition at line 153 of file ipv4-address.cc.
References m_address.
Referenced by ns3::Ipv4Header::Deserialize(), ns3::GlobalRouter::GlobalRouter(), ns3::GlobalRouter::ProcessBridgedBroadcastLink(), and ns3::GlobalRouter::ProcessSingleBroadcastLink().
bool operator!= | ( | Ipv4Address const & | a, | |
Ipv4Address const & | b | |||
) | [friend] |
Definition at line 278 of file ipv4-address.h.
bool operator< | ( | Ipv4Address const & | addrA, | |
Ipv4Address const & | addrB | |||
) | [friend] |
Definition at line 282 of file ipv4-address.h.
bool operator== | ( | Ipv4Address const & | a, | |
Ipv4Address const & | b | |||
) | [friend] |
Definition at line 274 of file ipv4-address.h.
uint32_t ns3::Ipv4Address::m_address [private] |
Definition at line 190 of file ipv4-address.h.
Referenced by Deserialize(), Get(), Ipv4Address(), IsBroadcast(), IsEqual(), IsMulticast(), ns3::operator!=(), ns3::operator<(), ns3::operator==(), Print(), Serialize(), and Set().