Implementation class of Ipv6AddressGenerator 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 | |
Ipv6AddressGeneratorImpl () | |
virtual | ~Ipv6AddressGeneratorImpl () |
bool | AddAllocated (const Ipv6Address addr) |
Add the Ipv6Address to the list of IPv6 entries. More... | |
Ipv6Address | GetAddress (const Ipv6Prefix prefix) const |
Get the Ipv6Address that will be allocated upon NextAddress () More... | |
Ipv6Address | GetNetwork (const Ipv6Prefix prefix) const |
Get the current network of the given Ipv6Prefix. More... | |
void | Init (const Ipv6Address net, const Ipv6Prefix prefix, const Ipv6Address interfaceId) |
Initialise the base network and interfaceId for the generator. More... | |
void | InitAddress (const Ipv6Address interfaceId, const Ipv6Prefix prefix) |
Set the interfaceId for the given Ipv6Prefix. More... | |
Ipv6Address | NextAddress (const Ipv6Prefix prefix) |
Allocate the next Ipv6Address for the configured network and prefix. More... | |
Ipv6Address | NextNetwork (const Ipv6Prefix prefix) |
Get the next network according to the given Ipv6Prefix. More... | |
void | Reset (void) |
Reset the networks and Ipv6Address to zero. More... | |
void | TestMode (void) |
Used to turn off fatal errors and assertions, for testing. More... | |
Private Member Functions | |
uint32_t | PrefixToIndex (Ipv6Prefix prefix) const |
Create an index number for the prefix. More... | |
Private Attributes | |
Ipv6Address | m_base |
/internal base address More... | |
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 = 0x80 |
/internal MSB set to 1 More... | |
static const uint32_t | N_BITS = 128 |
/internal the number of bits in the address More... | |
Implementation class of Ipv6AddressGenerator 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 41 of file ipv6-address-generator.cc.
ns3::Ipv6AddressGeneratorImpl::Ipv6AddressGeneratorImpl | ( | ) |
Definition at line 190 of file ipv6-address-generator.cc.
References NS_LOG_FUNCTION, and Reset().
|
virtual |
Definition at line 239 of file ipv6-address-generator.cc.
References NS_LOG_FUNCTION.
bool ns3::Ipv6AddressGeneratorImpl::AddAllocated | ( | const Ipv6Address | addr | ) |
Add the Ipv6Address to the list of IPv6 entries.
addr | The Ipv6Address to be added to the list of Ipv6 entries |
Definition at line 473 of file ipv6-address-generator.cc.
References ns3::Ipv6AddressGeneratorImpl::Entry::addrHigh, ns3::Ipv6AddressGeneratorImpl::Entry::addrLow, ns3::Ipv6Address::GetBytes(), m_entries, m_test, NS_FATAL_ERROR, NS_LOG_FUNCTION, and NS_LOG_LOGIC.
Referenced by NextAddress().
Ipv6Address ns3::Ipv6AddressGeneratorImpl::GetAddress | ( | const Ipv6Prefix | prefix | ) | const |
Get the Ipv6Address that will be allocated upon NextAddress ()
prefix | The Ipv6Prefix for the current network |
Definition at line 390 of file ipv6-address-generator.cc.
References ns3::Ipv6AddressGeneratorImpl::NetworkState::addr, m_netTable, ns3::Ipv6AddressGeneratorImpl::NetworkState::network, NS_LOG_FUNCTION, PrefixToIndex(), and ns3::Ipv6AddressGeneratorImpl::NetworkState::shift.
Ipv6Address ns3::Ipv6AddressGeneratorImpl::GetNetwork | ( | const Ipv6Prefix | prefix | ) | const |
Get the current network of the given Ipv6Prefix.
prefix | The Ipv6Prefix for the current network |
Definition at line 296 of file ipv6-address-generator.cc.
References m_netTable, ns3::Ipv6AddressGeneratorImpl::NetworkState::network, NS_LOG_FUNCTION, PrefixToIndex(), and ns3::Ipv6AddressGeneratorImpl::NetworkState::shift.
void ns3::Ipv6AddressGeneratorImpl::Init | ( | const Ipv6Address | net, |
const Ipv6Prefix | prefix, | ||
const Ipv6Address | interfaceId | ||
) |
Initialise the base network and interfaceId for the generator.
net | The network for the base Ipv6Address |
prefix | The prefix of the base Ipv6Address |
interfaceId | The base interface ID used for initialization |
Definition at line 245 of file ipv6-address-generator.cc.
References ns3::Ipv6AddressGeneratorImpl::NetworkState::addr, ns3::Ipv6Address::GetBytes(), ns3::Ipv6Prefix::GetBytes(), m_base, m_netTable, ns3::Ipv6AddressGeneratorImpl::NetworkState::network, NS_LOG_DEBUG, NS_LOG_FUNCTION, PrefixToIndex(), and ns3::Ipv6AddressGeneratorImpl::NetworkState::shift.
void ns3::Ipv6AddressGeneratorImpl::InitAddress | ( | const Ipv6Address | interfaceId, |
const Ipv6Prefix | prefix | ||
) |
Set the interfaceId for the given Ipv6Prefix.
interfaceId | The interfaceId to set for the current Ipv6Prefix |
prefix | The Ipv6Prefix whose address is to be set |
Definition at line 373 of file ipv6-address-generator.cc.
References ns3::Ipv6AddressGeneratorImpl::NetworkState::addr, ns3::Ipv6Address::GetBytes(), m_netTable, NS_LOG_FUNCTION, and PrefixToIndex().
Ipv6Address ns3::Ipv6AddressGeneratorImpl::NextAddress | ( | const Ipv6Prefix | prefix | ) |
Allocate the next Ipv6Address for the configured network and prefix.
prefix | The Ipv6Prefix for the current network |
Definition at line 422 of file ipv6-address-generator.cc.
References AddAllocated(), ns3::Ipv6AddressGeneratorImpl::NetworkState::addr, m_netTable, ns3::Ipv6AddressGeneratorImpl::NetworkState::network, NS_LOG_FUNCTION, PrefixToIndex(), and ns3::Ipv6AddressGeneratorImpl::NetworkState::shift.
Ipv6Address ns3::Ipv6AddressGeneratorImpl::NextNetwork | ( | const Ipv6Prefix | prefix | ) |
Get the next network according to the given Ipv6Prefix.
This also resets the interface ID to the base interface ID that was used for initialization.
prefix | The Ipv6Prefix used to set the next network |
Definition at line 323 of file ipv6-address-generator.cc.
References ns3::Ipv6AddressGeneratorImpl::NetworkState::addr, ns3::Ipv6Address::GetBytes(), m_base, m_netTable, ns3::Ipv6AddressGeneratorImpl::NetworkState::network, NS_LOG_FUNCTION, PrefixToIndex(), and ns3::Ipv6AddressGeneratorImpl::NetworkState::shift.
|
private |
Create an index number for the prefix.
prefix | the prefix to index |
Definition at line 594 of file ipv6-address-generator.cc.
References ns3::Ipv6Prefix::GetBytes(), N_BITS, NS_ABORT_MSG_UNLESS, and NS_ASSERT_MSG.
Referenced by GetAddress(), GetNetwork(), Init(), InitAddress(), NextAddress(), and NextNetwork().
void ns3::Ipv6AddressGeneratorImpl::Reset | ( | void | ) |
Reset the networks and Ipv6Address to zero.
Definition at line 200 of file ipv6-address-generator.cc.
References ns3::Ipv6AddressGeneratorImpl::NetworkState::addr, ns3::Ipv6AddressGeneratorImpl::NetworkState::addrMax, m_base, m_entries, m_netTable, m_test, MOST_SIGNIFICANT_BIT, N_BITS, ns3::Ipv6AddressGeneratorImpl::NetworkState::network, NS_LOG_FUNCTION, ns3::Ipv6AddressGeneratorImpl::NetworkState::prefix, and ns3::Ipv6AddressGeneratorImpl::NetworkState::shift.
Referenced by Ipv6AddressGeneratorImpl().
void ns3::Ipv6AddressGeneratorImpl::TestMode | ( | void | ) |
Used to turn off fatal errors and assertions, for testing.
Definition at line 587 of file ipv6-address-generator.cc.
References m_test, and NS_LOG_FUNCTION.
|
private |
/internal base address
Definition at line 186 of file ipv6-address-generator.cc.
Referenced by Init(), NextNetwork(), and Reset().
/internal contained of allocated addresses
Definition at line 185 of file ipv6-address-generator.cc.
Referenced by AddAllocated(), and Reset().
|
private |
/internal the available networks
Definition at line 172 of file ipv6-address-generator.cc.
Referenced by GetAddress(), GetNetwork(), Init(), InitAddress(), NextAddress(), NextNetwork(), and Reset().
|
private |
/internal test mode (if true)
Definition at line 187 of file ipv6-address-generator.cc.
Referenced by AddAllocated(), Reset(), and TestMode().
|
staticprivate |
/internal MSB set to 1
Definition at line 148 of file ipv6-address-generator.cc.
Referenced by Reset().
|
staticprivate |
/internal the number of bits in the address
Definition at line 147 of file ipv6-address-generator.cc.
Referenced by PrefixToIndex(), and Reset().