|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
24 #include "ns3/assert.h"
30 #define ASCII_DOT (0x2e)
31 #define ASCII_ZERO (0x30)
32 #define ASCII_SLASH (0x2f)
44 uint8_t numberOfDots = 0;
68 NS_ASSERT_MSG (numberOfDots == 3,
"Error, can not build an IPv4 address from an invalid string: " <<
address);
95 uint32_t plen =
static_cast<uint32_t
> (std::atoi (++mask));
99 m_mask = 0xffffffff << (32 - plen);
146 os << ((
m_mask >> 24) & 0xff) <<
"."
147 << ((
m_mask >> 16) & 0xff) <<
"."
148 << ((
m_mask >> 8) & 0xff) <<
"."
149 << ((
m_mask >> 0) & 0xff);
247 NS_ASSERT_MSG (
false,
"Trying to get subnet-directed broadcast address with an all-ones netmask");
309 return (
m_address & 0xffffff00) == 0xe0000000;
418 return std::hash<uint32_t>()(
x.Get ());
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
static Ipv4Mask GetZero(void)
bool IsInitialized(void) const
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
static bool IsMatchingType(const Address &address)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static Ipv4Address GetBroadcast(void)
void Print(std::ostream &os) const
Print this mask to the given output stream.
bool IsLocalhost(void) const
uint32_t Get(void) const
Get the host-order 32-bit IP mask.
bool m_initialized
IPv4 address has been explicitly initialized to a valid value.
static uint8_t Register(void)
Allocate a new type id for a new type of address.
void Set(uint32_t address)
input address is in host order.
uint32_t Get(void) const
Get the host-order 32-bit IP address.
Ipv4 addresses are stored in host order in this class.
static Ipv4Mask GetLoopback(void)
Address ConvertTo(void) const
Convert to an Address type.
Ipv4Mask()
Will initialize to a garbage value (0x66666666)
static uint32_t AsciiToIpv4Host(char const *address)
Converts a string representing an IP address into the address.
bool IsMulticast(void) const
static Ipv4Address Deserialize(const uint8_t buf[4])
static Ipv4Address GetZero(void)
a polymophic address class
#define ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type
bool IsLocalMulticast(void) const
uint32_t m_address
IPv4 address.
bool IsBroadcast(void) const
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
uint16_t GetPrefixLength(void) const
static Ipv4Address GetLoopback(void)
Ipv4Address GetSubnetDirectedBroadcast(Ipv4Mask const &mask) const
Generate subnet-directed broadcast address corresponding to mask.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
static Ipv4Address GetAny(void)
static uint8_t GetType(void)
Get the underlying address type (automatically assigned).
static Ipv4Mask GetOnes(void)
void Serialize(uint8_t buf[4]) const
Serialize this address to a 4-byte buffer.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
bool IsMatch(Ipv4Address a, Ipv4Address b) const
a class to represent an Ipv4 address mask
void Set(uint32_t mask)
input mask is in host order.
uint32_t GetInverse(void) const
Return the inverse mask in host order.
Ipv4Address CombineMask(Ipv4Mask const &mask) const
Combine this address with a network mask.
std::ostream & operator<<(std::ostream &os, const Angles &a)
static constexpr uint32_t UNINITIALIZED
Value of a not-yet-initialized IPv4 address, corresponding to 102.102.102.102.
size_t operator()(Ipv4Address const &x) const
Returns the hash of an IPv4 address.
static Ipv4Address ConvertFrom(const Address &address)
void Print(std::ostream &os) const
Print this address to the given output stream.
bool IsSubnetDirectedBroadcast(Ipv4Mask const &mask) const
Generate subnet-directed broadcast address corresponding to mask.
std::istream & operator>>(std::istream &is, Angles &a)