Implementation class of Ipv4AddressGenerator This generator assigns addresses sequentially from a provided network address; used in topology code. It also keeps track of all addresses assigned to perform duplicate detection. More...
Classes | |
class | Entry |
This class holds the allocated addresses. More... | |
class | NetworkState |
This class holds the state for a given network. More... | |
Public Member Functions | |
Ipv4AddressGeneratorImpl () | |
virtual | ~Ipv4AddressGeneratorImpl () |
bool | AddAllocated (const Ipv4Address addr) |
Add the Ipv4Address to the list of IPv4 entries. More... | |
Ipv4Address | GetAddress (const Ipv4Mask mask) const |
Get the Ipv4Address that will be allocated upon NextAddress () More... | |
Ipv4Address | GetNetwork (const Ipv4Mask mask) const |
Get the current network of the given Ipv4Mask. More... | |
void | Init (const Ipv4Address net, const Ipv4Mask mask, const Ipv4Address addr) |
Initialise the base network, mask and address for the generator. More... | |
void | InitAddress (const Ipv4Address addr, const Ipv4Mask mask) |
Set the address for the given mask. More... | |
Ipv4Address | NextAddress (const Ipv4Mask mask) |
Allocate the next Ipv4Address for the configured network and mask. More... | |
Ipv4Address | NextNetwork (const Ipv4Mask mask) |
Get the next network according to the given Ipv4Mask. More... | |
void | Reset (void) |
Reset the networks and Ipv4Address to zero. More... | |
void | TestMode (void) |
Used to turn off fatal errors and assertions, for testing. More... | |
Private Member Functions | |
uint32_t | MaskToIndex (Ipv4Mask mask) const |
Create an index number for the network mask. More... | |
Private Attributes | |
std::list< Entry > | m_entries |
/internal contained of allocated addresses More... | |
NetworkState | m_netTable [N_BITS] |
/internal the available networks More... | |
bool | m_test |
/internal test mode (if true) More... | |
Static Private Attributes | |
static const uint32_t | MOST_SIGNIFICANT_BIT = 0x80000000 |
/internal MSB set to 1 More... | |
static const uint32_t | N_BITS = 32 |
/internal the number of bits in the address More... | |
Implementation class of Ipv4AddressGenerator This generator assigns addresses sequentially from a provided network address; used in topology code. It also keeps track of all addresses assigned to perform duplicate detection.
Definition at line 39 of file ipv4-address-generator.cc.
ns3::Ipv4AddressGeneratorImpl::Ipv4AddressGeneratorImpl | ( | ) |
Definition at line 186 of file ipv4-address-generator.cc.
References NS_LOG_FUNCTION, and Reset().
|
virtual |
Definition at line 232 of file ipv4-address-generator.cc.
References NS_LOG_FUNCTION.
bool ns3::Ipv4AddressGeneratorImpl::AddAllocated | ( | const Ipv4Address | addr | ) |
Add the Ipv4Address to the list of IPv4 entries.
addr | The Ipv4Address to be added to the list of Ipv4 entries |
Definition at line 357 of file ipv4-address-generator.cc.
References ns3::Ipv4AddressGeneratorImpl::Entry::addrHigh, ns3::Ipv4AddressGeneratorImpl::Entry::addrLow, ns3::Ipv4Address::Get(), m_entries, m_test, NS_ABORT_MSG_UNLESS, NS_FATAL_ERROR, NS_LOG_FUNCTION, and NS_LOG_LOGIC.
Referenced by NextAddress().
Ipv4Address ns3::Ipv4AddressGeneratorImpl::GetAddress | ( | const Ipv4Mask | mask | ) | const |
Get the Ipv4Address that will be allocated upon NextAddress ()
mask | The Ipv4Mask for the current network |
Definition at line 315 of file ipv4-address-generator.cc.
References m_netTable, MaskToIndex(), and NS_LOG_FUNCTION.
Ipv4Address ns3::Ipv4AddressGeneratorImpl::GetNetwork | ( | const Ipv4Mask | mask | ) | const |
Get the current network of the given Ipv4Mask.
mask | The Ipv4Mask for the current network |
Definition at line 272 of file ipv4-address-generator.cc.
References m_netTable, MaskToIndex(), and NS_LOG_FUNCTION.
void ns3::Ipv4AddressGeneratorImpl::Init | ( | const Ipv4Address | net, |
const Ipv4Mask | mask, | ||
const Ipv4Address | addr | ||
) |
Initialise the base network, mask and address for the generator.
net | The network for the base Ipv4Address |
mask | The network mask of the base Ipv4Address |
addr | The base address used for initialization |
Definition at line 238 of file ipv4-address-generator.cc.
References ns3::Ipv4AddressGeneratorImpl::NetworkState::addr, ns3::Ipv4Address::Get(), ns3::Ipv4Mask::Get(), m_netTable, MaskToIndex(), ns3::Ipv4AddressGeneratorImpl::NetworkState::network, NS_ABORT_MSG_UNLESS, NS_LOG_FUNCTION, and ns3::Ipv4AddressGeneratorImpl::NetworkState::shift.
void ns3::Ipv4AddressGeneratorImpl::InitAddress | ( | const Ipv4Address | addr, |
const Ipv4Mask | mask | ||
) |
Set the address for the given mask.
addr | The address to set for the current mask |
mask | The Ipv4Mask whose address is to be set |
Definition at line 301 of file ipv4-address-generator.cc.
References ns3::Ipv4AddressGeneratorImpl::NetworkState::addr, ns3::Ipv4Address::Get(), m_netTable, MaskToIndex(), NS_ABORT_MSG_UNLESS, and NS_LOG_FUNCTION.
|
private |
Create an index number for the network mask.
mask | the mask to index |
Definition at line 452 of file ipv4-address-generator.cc.
References ns3::Ipv4Mask::Get(), N_BITS, NS_ABORT_MSG_UNLESS, NS_ASSERT_MSG, and NS_LOG_FUNCTION.
Referenced by GetAddress(), GetNetwork(), Init(), InitAddress(), NextAddress(), and NextNetwork().
Ipv4Address ns3::Ipv4AddressGeneratorImpl::NextAddress | ( | const Ipv4Mask | mask | ) |
Allocate the next Ipv4Address for the configured network and mask.
mask | The Ipv4Mask for the current network |
Definition at line 328 of file ipv4-address-generator.cc.
References AddAllocated(), ns3::Ipv4AddressGeneratorImpl::NetworkState::addr, m_netTable, MaskToIndex(), NS_ABORT_MSG_UNLESS, and NS_LOG_FUNCTION.
Ipv4Address ns3::Ipv4AddressGeneratorImpl::NextNetwork | ( | const Ipv4Mask | mask | ) |
Get the next network according to the given Ipv4Mask.
This also resets the address to the base address that was used for initialization.
mask | The Ipv4Mask used to set the next network |
Definition at line 282 of file ipv4-address-generator.cc.
References m_netTable, MaskToIndex(), ns3::Ipv4AddressGeneratorImpl::NetworkState::network, and NS_LOG_FUNCTION.
void ns3::Ipv4AddressGeneratorImpl::Reset | ( | void | ) |
Reset the networks and Ipv4Address to zero.
Definition at line 194 of file ipv4-address-generator.cc.
References ns3::Ipv4AddressGeneratorImpl::NetworkState::addr, ns3::Ipv4AddressGeneratorImpl::NetworkState::addrMax, m_entries, m_netTable, m_test, ns3::Ipv4AddressGeneratorImpl::NetworkState::mask, MOST_SIGNIFICANT_BIT, N_BITS, ns3::Ipv4AddressGeneratorImpl::NetworkState::network, NS_LOG_FUNCTION, and ns3::Ipv4AddressGeneratorImpl::NetworkState::shift.
Referenced by Ipv4AddressGeneratorImpl().
void ns3::Ipv4AddressGeneratorImpl::TestMode | ( | void | ) |
Used to turn off fatal errors and assertions, for testing.
Definition at line 445 of file ipv4-address-generator.cc.
References m_test, and NS_LOG_FUNCTION.
/internal contained of allocated addresses
Definition at line 182 of file ipv4-address-generator.cc.
Referenced by AddAllocated(), and Reset().
|
private |
/internal the available networks
Definition at line 169 of file ipv4-address-generator.cc.
Referenced by GetAddress(), GetNetwork(), Init(), InitAddress(), NextAddress(), NextNetwork(), and Reset().
|
private |
/internal test mode (if true)
Definition at line 183 of file ipv4-address-generator.cc.
Referenced by AddAllocated(), Reset(), and TestMode().
|
staticprivate |
/internal MSB set to 1
Definition at line 145 of file ipv4-address-generator.cc.
Referenced by Reset().
|
staticprivate |
/internal the number of bits in the address
Definition at line 144 of file ipv4-address-generator.cc.
Referenced by MaskToIndex(), and Reset().