20 #include "ns3/abort.h"
21 #include "ns3/assert.h"
23 #include "ns3/simulation-singleton.h"
80 : m_entries (), m_test (false)
111 for (uint32_t i = 0; i <
N_BITS; ++i)
141 uint32_t maskBits = mask.
Get ();
142 uint32_t netBits = net.
Get ();
143 uint32_t addrBits = addr.
Get ();
147 NS_ABORT_MSG_UNLESS ((netBits & ~maskBits) == 0,
"Ipv4AddressGeneratorImpl::Init (): Inconsistent network and mask");
148 NS_ABORT_MSG_UNLESS ((addrBits & maskBits) == 0,
"Ipv4AddressGeneratorImpl::Init (): Inconsistent address and mask");
201 uint32_t addrBits = addr.
Get ();
234 "Ipv4AddressGeneratorImpl::NextAddress(): Address overflow");
254 uint32_t addr = address.
Get ();
256 NS_ABORT_MSG_UNLESS (addr,
"Ipv4AddressGeneratorImpl::Add(): Allocating the broadcast address is not a good idea");
258 std::list<Entry>::iterator i;
268 if (addr >= (*i).addrLow && addr <= (*i).addrHigh)
282 if (addr < (*i).addrLow - 1)
293 if (addr == (*i).addrHigh + 1)
295 std::list<Entry>::iterator j = i;
300 if (addr == (*j).addrLow)
313 (*i).addrHigh = addr;
323 if (addr == (*i).addrLow - 1)
361 uint32_t maskBits = mask.
Get ();
363 for (uint32_t i = 0; i <
N_BITS; ++i)
367 uint32_t index = N_BITS - i;
368 NS_ABORT_MSG_UNLESS (index > 0 && index < N_BITS,
"Ipv4AddressGenerator::MaskToIndex(): Illegal Mask");
373 NS_ASSERT_MSG (
false,
"Ipv4AddressGenerator::MaskToIndex(): Impossible");
386 ->Init (net, mask, addr);
395 ->NextNetwork (mask);
415 ->InitAddress (addr, mask);
433 ->NextAddress (mask);
451 ->AddAllocated (addr);
void Init(const Ipv4Address net, const Ipv4Mask mask, const Ipv4Address addr)
#define NS_LOG_FUNCTION(parameters)
a class to represent an Ipv4 address mask
static Ipv4Address NextAddress(const Ipv4Mask mask)
#define NS_LOG_COMPONENT_DEFINE(name)
static void InitAddress(const Ipv4Address addr, const Ipv4Mask mask)
bool AddAllocated(const Ipv4Address addr)
static void TestMode(void)
#define NS_LOG_FUNCTION_NOARGS()
Ipv4AddressGeneratorImpl()
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if cond is false.
#define NS_FATAL_ERROR(msg)
fatal error handling
static const uint32_t MOST_SIGNIFICANT_BIT
uint32_t MaskToIndex(Ipv4Mask mask) const
static Ipv4Address NextNetwork(const Ipv4Mask mask)
Ipv4Address GetAddress(const Ipv4Mask mask) const
void InitAddress(const Ipv4Address addr, const Ipv4Mask mask)
#define NS_LOG_LOGIC(msg)
std::list< Entry > m_entries
static bool AddAllocated(const Ipv4Address addr)
static const uint32_t N_BITS
#define NS_ASSERT_MSG(condition, message)
virtual ~Ipv4AddressGeneratorImpl()
static Ipv4Address GetNetwork(const Ipv4Mask mask)
Ipv4 addresses are stored in host order in this class.
Ipv4Address NextAddress(const Ipv4Mask mask)
Ipv4Address NextNetwork(const Ipv4Mask mask)
Ipv4Address GetNetwork(const Ipv4Mask mask) const
NetworkState m_netTable[N_BITS]
static Ipv4Address GetAddress(const Ipv4Mask mask)
static void Init(const Ipv4Address net, const Ipv4Mask mask, const Ipv4Address addr="0.0.0.1")