22#include "ns3/assert.h" 
   24#include "ns3/simulation-singleton.h" 
  208  uint8_t prefix[16] = { 0};
 
  218          prefix[15 - j] >>= 1;
 
  219          prefix[15 - j] |= (prefix[15 - j - 1] & 1);
 
  261  uint8_t prefixBits[16];
 
  265  uint8_t interfaceIdBits[16];
 
  266  interfaceId.
GetBytes (interfaceIdBits);
 
  279  for (
int32_t j = 15 - a; j >= 0; j--)
 
  292  for (
int32_t j = 0; j < 16; j++)
 
  304  uint8_t nw[16] = { 0 };
 
  308  for (
uint32_t j = 0; j < 16 - a; ++j)
 
  315      nw[j] |= nw[j + 1] >> (8 - b);
 
  317  nw[15] = nw[15] << b;
 
  330  uint8_t interfaceIdBits[16];
 
  332  for (
int32_t j = 0; j < 16; j++)
 
  337  for (
int32_t j = 15; j >= 0; j--)
 
  353  for (
uint32_t j = 0; j < 16 - a; ++j)
 
  357  for (
uint32_t j = 16 - a; j < 16; ++j)
 
  364      nw[j] |= nw[j + 1] >> (8 - b);
 
  366  nw[15] = nw[15] << b;
 
  380  uint8_t interfaceIdBits[16];
 
  381  interfaceId.
GetBytes (interfaceIdBits);
 
  396  uint8_t nw[16] = { 0 };
 
  399  for (
uint32_t j = 0; j < 16 - a; ++j)
 
  406      nw[j] |= nw[j + 1] >> (8 - b);
 
  408  nw[15] = nw[15] << b;
 
  424  uint8_t ad[16] = { 0 };
 
  427  for (
uint32_t j = 0; j < 16 - a; ++j)
 
  434      ad[j] |= ad[j + 1] >> (8 - b);
 
  436  ad[15] = ad[15] << b;
 
  443  for (
int32_t j = 15; j >= 0; j--)
 
  472  std::list<Entry>::iterator i;
 
  501          taddr[j] = (*i).addrLow[j];
 
  517          taddr[j] = (*i).addrLow[j];
 
  522          std::list<Entry>::iterator j = i;
 
  542              (*i).addrHigh[j] = addr[j];
 
  555          taddr[j] = (*i).addrLow[j];
 
  563              (*i).addrLow[j] = addr[j];
 
  586  std::list<Entry>::iterator i;
 
  611                       "Ipv6AddressGeneratorImpl::IsNetworkAllocated(): network address and mask don't match " << 
address << 
" " << prefix);
 
  613  std::list<Entry>::iterator i;
 
  623          NS_LOG_LOGIC (
"Ipv6AddressGeneratorImpl::IsNetworkAllocated(): Network already allocated: " <<
 
  624                        address << 
" " << low << 
"-" << high);
 
  654  uint8_t prefixBits[16];
 
  657  for (
int32_t i = 15; i >= 0; --i)
 
  661          if (prefixBits[i] & 1)
 
  670  NS_ASSERT_MSG (
false, 
"Ipv6AddressGenerator::PrefixToIndex(): Impossible");
 
  683  ->Init (net, prefix, interfaceId);
 
  692         ->NextNetwork (prefix);
 
  701         ->GetNetwork (prefix);
 
  712  ->InitAddress (interfaceId, prefix);
 
  721         ->GetAddress (prefix);
 
  730         ->NextAddress (prefix);
 
  748         ->AddAllocated (addr);
 
  757         ->IsAddressAllocated (addr);
 
  766         ->IsNetworkAllocated (addr, prefix);
 
static void Init(const Ipv6Address net, const Ipv6Prefix prefix, const Ipv6Address interfaceId="::1")
Initialise the base network and interfaceId for the generator.
static Ipv6Address NextAddress(const Ipv6Prefix prefix)
Allocate the next Ipv6Address for the configured network and prefix.
static Ipv6Address GetNetwork(const Ipv6Prefix prefix)
Get the current network of the given Ipv6Prefix.
static void InitAddress(const Ipv6Address interfaceId, const Ipv6Prefix prefix)
Set the interfaceId for the given Ipv6Prefix.
static bool IsNetworkAllocated(const Ipv6Address addr, const Ipv6Prefix prefix)
Check if a network has already allocated addresses.
static void TestMode(void)
Used to turn off fatal errors and assertions, for testing.
static bool AddAllocated(const Ipv6Address addr)
Add the Ipv6Address to the list of IPv6 entries.
static void Reset(void)
Reset the networks and Ipv6Address to zero.
static Ipv6Address GetAddress(const Ipv6Prefix prefix)
Get the Ipv6Address that will be allocated upon NextAddress ()
static Ipv6Address NextNetwork(const Ipv6Prefix prefix)
Get the next network according to the given Ipv6Prefix.
static bool IsAddressAllocated(const Ipv6Address addr)
Check the Ipv6Address allocation in the list of IPv6 entries.
This class holds the allocated addresses.
uint8_t addrLow[16]
the lowest allocated address
uint8_t addrHigh[16]
the highest allocated address
This class holds the state for a given network.
uint8_t addrMax[16]
the maximum address
uint8_t addr[16]
the address
uint8_t network[16]
the network
uint8_t prefix[16]
the network prefix
Implementation class of Ipv6AddressGenerator This generator assigns addresses sequentially from a pro...
static const uint32_t MOST_SIGNIFICANT_BIT
MSB set to 1.
Ipv6Address m_base
base address
void Reset(void)
Reset the networks and Ipv6Address to zero.
virtual ~Ipv6AddressGeneratorImpl()
NetworkState m_netTable[N_BITS]
the available networks
Ipv6AddressGeneratorImpl()
bool m_test
test mode (if true)
bool AddAllocated(const Ipv6Address addr)
Add the Ipv6Address to the list of IPv6 entries.
Ipv6Address GetAddress(const Ipv6Prefix prefix) const
Get the Ipv6Address that will be allocated upon NextAddress ()
uint32_t PrefixToIndex(Ipv6Prefix prefix) const
Create an index number for the prefix.
void TestMode(void)
Used to turn off fatal errors and assertions, for testing.
Ipv6Address NextNetwork(const Ipv6Prefix prefix)
Get the next network according to the given Ipv6Prefix.
std::list< Entry > m_entries
contained of allocated addresses
static const uint32_t N_BITS
the number of bits in the address
void Init(const Ipv6Address net, const Ipv6Prefix prefix, const Ipv6Address interfaceId)
Initialise the base network and interfaceId for the generator.
void InitAddress(const Ipv6Address interfaceId, const Ipv6Prefix prefix)
Set the interfaceId for the given Ipv6Prefix.
bool IsNetworkAllocated(const Ipv6Address addr, const Ipv6Prefix prefix)
Check if a network has already allocated addresses.
Ipv6Address GetNetwork(const Ipv6Prefix prefix) const
Get the current network of the given Ipv6Prefix.
bool IsAddressAllocated(const Ipv6Address addr)
Check the Ipv6Address allocation in the list of IPv6 entries.
Ipv6Address NextAddress(const Ipv6Prefix prefix)
Allocate the next Ipv6Address for the configured network and prefix.
Describes an IPv6 address.
Ipv6Address CombinePrefix(Ipv6Prefix const &prefix) const
Combine this address with a prefix.
void GetBytes(uint8_t buf[16]) const
Get the bytes corresponding to the address.
Describes an IPv6 prefix.
void GetBytes(uint8_t buf[16]) const
Get the bytes corresponding to the prefix.
static T * Get(void)
Get a pointer to the singleton instance.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.