ns3::Ipv4Address Class Reference
[Address]

Ipv4 addresses are stored in host order in this class. More...

#include <ipv4-address.h>

List of all members.

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)

Detailed Description

Ipv4 addresses are stored in host order in this class.

Definition at line 38 of file ipv4-address.h.


Constructor & Destructor Documentation

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.

Parameters:
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

Parameters:
address C-string containing the address as described above

Definition at line 142 of file ipv4-address.cc.

References ns3::AsciiToIpv4Host(), and m_address.


Member Function Documentation

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.

Parameters:
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]
Parameters:
address a polymorphic address
Returns:
a new Ipv4Address from the 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]
Parameters:
buf buffer to read address from
Returns:
an Ipv4Address

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
Ipv4Address ns3::Ipv4Address::GetAny ( void   )  [static]
Ipv4Address ns3::Ipv4Address::GetBroadcast ( void   )  [static]
Returns:
the 255.255.255.255 address

Definition at line 286 of file ipv4-address.cc.

Ipv4Address ns3::Ipv4Address::GetLoopback ( void   )  [static]
Returns:
the 127.0.0.1 address

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.

Parameters:
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]
Returns:
the 0.0.0.0 address

Definition at line 274 of file ipv4-address.cc.

Referenced by ns3::UdpSocketImpl::GetSockName().

bool ns3::Ipv4Address::IsBroadcast ( void   )  const
Returns:
true if address is 255.255.255.255; false otherwise

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.

Parameters:
other address to which to compare this address
Returns:
True if the addresses are equal. False otherwise.

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]
Parameters:
address an address to compare type with
Returns:
true if the type of the address stored internally is compatible with the type of the input address, false otherwise.

Definition at line 240 of file ipv4-address.cc.

References ns3::Address::CheckCompatible(), and GetType().

bool ns3::Ipv4Address::IsMulticast ( void   )  const
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.

Parameters:
mask a network mask
Returns:
true if the address, when combined with the input mask, has all of its host bits set to one

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.

Returns:
a new 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"

Parameters:
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

Parameters:
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

Parameters:
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.

Parameters:
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().


Friends And Related Function Documentation

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.


Member Data Documentation

uint32_t ns3::Ipv4Address::m_address [private]

The documentation for this class was generated from the following files:
Generated on Thu Dec 3 14:12:01 2009 for NS-3 by  doxygen 1.6.3