This generator assigns addresses sequentially from a provided network address; used in topology code. More...
#include "ipv4-address-generator.h"
Static Public Member Functions | |
static bool | AddAllocated (const Ipv4Address addr) |
Add the Ipv4Address to the list of IPv4 entries. More... | |
static Ipv4Address | GetAddress (const Ipv4Mask mask) |
Get the Ipv4Address that will be allocated upon NextAddress () More... | |
static Ipv4Address | GetNetwork (const Ipv4Mask mask) |
Get the current network of the given Ipv4Mask. More... | |
static void | Init (const Ipv4Address net, const Ipv4Mask mask, const Ipv4Address addr="0.0.0.1") |
Initialise the base network, mask and address for the generator. More... | |
static void | InitAddress (const Ipv4Address addr, const Ipv4Mask mask) |
Set the address for the given mask. More... | |
static bool | IsAddressAllocated (const Ipv4Address addr) |
Check the Ipv4Address allocation in the list of IPv4 entries. More... | |
static bool | IsNetworkAllocated (const Ipv4Address addr, const Ipv4Mask mask) |
Check if a network has already allocated addresses. More... | |
static Ipv4Address | NextAddress (const Ipv4Mask mask) |
Allocate the next Ipv4Address for the configured network and mask. More... | |
static Ipv4Address | NextNetwork (const Ipv4Mask mask) |
Get the next network according to the given Ipv4Mask. More... | |
static void | Reset (void) |
Reset the networks and Ipv4Address to zero. More... | |
static void | TestMode (void) |
Used to turn off fatal errors and assertions, for testing. More... | |
This generator assigns addresses sequentially from a provided network address; used in topology code.
Definition at line 39 of file ipv4-address-generator.h.
|
static |
Add the Ipv4Address to the list of IPv4 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 Ipv4Address to be added to the list of Ipv4 entries |
Definition at line 610 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::Ipv4AddressHelper::NewAddress().
|
static |
Get the Ipv4Address 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 ()
mask | The Ipv4Mask for the current network |
Definition at line 583 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION_NOARGS.
|
static |
Get the current network of the given Ipv4Mask.
Does not change the internal state; this just peeks at the current network
mask | The Ipv4Mask for the current network |
Definition at line 563 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION_NOARGS.
|
static |
Initialise the base network, mask and address for the generator.
The first call to NextAddress() or GetAddress() will return the value passed in.
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 542 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION_NOARGS.
|
static |
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 572 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION_NOARGS.
|
static |
Check the Ipv4Address allocation in the list of IPv4 entries.
addr | The Ipv4Address to be checked in the list of Ipv4 entries |
Definition at line 619 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION_NOARGS.
|
static |
Check if a network has already allocated addresses.
Definition at line 628 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION_NOARGS.
|
static |
Allocate the next Ipv4Address for the configured network and mask.
This operation is a post-increment, meaning that the first address allocated will be the one that was initially configured.
mask | The Ipv4Mask for the current network |
Definition at line 592 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION_NOARGS.
|
static |
Get the next network according to the given Ipv4Mask.
This operation is a pre-increment, meaning that the internal state is changed before returning the new network address.
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 554 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION_NOARGS.
|
static |
Reset the networks and Ipv4Address to zero.
Definition at line 601 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION_NOARGS.
|
static |
Used to turn off fatal errors and assertions, for testing.
Definition at line 637 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION_NOARGS.