Implementation class of Ipv6AddressGenerator This generator assigns addresses sequentially from a provided network address; used in topology code. 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... | |
bool | IsAddressAllocated (const Ipv6Address addr) |
Check the Ipv6Address allocation in the list of IPv6 entries. More... | |
bool | IsNetworkAllocated (const Ipv6Address addr, const Ipv6Prefix prefix) |
Check if a network has already allocated addresses. 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 |
base address More... | |
std::list< Entry > | m_entries |
contained of allocated addresses More... | |
NetworkState | m_netTable [N_BITS] |
the available networks More... | |
bool | m_test |
test mode (if true) More... | |
Static Private Attributes | |
static const uint32_t | MOST_SIGNIFICANT_BIT = 0x80 |
MSB set to 1. More... | |
static const uint32_t | N_BITS = 128 |
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 40 of file ipv6-address-generator.cc.
ns3::Ipv6AddressGeneratorImpl::Ipv6AddressGeneratorImpl | ( | ) |
Definition at line 194 of file ipv6-address-generator.cc.
References NS_LOG_FUNCTION, and Reset().
|
virtual |
Definition at line 243 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.
Typically, this is used by external address allocators that want to make use of this class's ability to track duplicates. AddAllocated is always called internally for any address generated by NextAddress ()
addr | The Ipv6Address to be added to the list of Ipv6 entries |
Definition at line 465 of file ipv6-address-generator.cc.
References first::address, ns3::Ipv6AddressGeneratorImpl::Entry::addrHigh, ns3::Ipv6AddressGeneratorImpl::Entry::addrLow, 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 ()
Does not change the internal state; just is used to peek the next address 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.
Does not change the internal state; this just peeks at the current network
prefix | The Ipv6Prefix for the current network |
Definition at line 300 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.
The first call to NextAddress() or GetAddress() will return the value passed in.
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 249 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().
bool ns3::Ipv6AddressGeneratorImpl::IsAddressAllocated | ( | const Ipv6Address | addr | ) |
Check the Ipv6Address allocation in the list of IPv6 entries.
addr | The Ipv6Address to be checked in the list of Ipv4 entries |
Definition at line 579 of file ipv6-address-generator.cc.
References first::address, m_entries, NS_LOG_FUNCTION, and NS_LOG_LOGIC.
bool ns3::Ipv6AddressGeneratorImpl::IsNetworkAllocated | ( | const Ipv6Address | addr, |
const Ipv6Prefix | prefix | ||
) |
Check if a network has already allocated addresses.
Definition at line 605 of file ipv6-address-generator.cc.
References first::address, ns3::Ipv6Address::CombinePrefix(), m_entries, NS_ABORT_MSG_UNLESS, NS_LOG_FUNCTION, and NS_LOG_LOGIC.
Ipv6Address ns3::Ipv6AddressGeneratorImpl::NextAddress | ( | const Ipv6Prefix | prefix | ) |
Allocate the next Ipv6Address for the configured network and prefix.
This operation is a post-increment, meaning that the first address allocated will be the one that was initially configured.
prefix | The Ipv6Prefix for the current network |
Definition at line 418 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 operation is a pre-increment, meaning that the internal state is changed before returning the new network address.
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 641 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 204 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 634 of file ipv6-address-generator.cc.
References m_test, and NS_LOG_FUNCTION.
|
private |
base address
Definition at line 190 of file ipv6-address-generator.cc.
Referenced by Init(), NextNetwork(), and Reset().
contained of allocated addresses
Definition at line 189 of file ipv6-address-generator.cc.
Referenced by AddAllocated(), IsAddressAllocated(), IsNetworkAllocated(), and Reset().
|
private |
the available networks
Definition at line 177 of file ipv6-address-generator.cc.
Referenced by GetAddress(), GetNetwork(), Init(), InitAddress(), NextAddress(), NextNetwork(), and Reset().
|
private |
test mode (if true)
Definition at line 191 of file ipv6-address-generator.cc.
Referenced by AddAllocated(), Reset(), and TestMode().
|
staticprivate |
|
staticprivate |
the number of bits in the address
Definition at line 154 of file ipv6-address-generator.cc.
Referenced by PrefixToIndex(), and Reset().