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. | |
static Ipv4Address | GetAddress (const Ipv4Mask mask) |
Get the Ipv4Address that will be allocated upon NextAddress () | |
static Ipv4Address | GetNetwork (const Ipv4Mask mask) |
Get the current network of the given Ipv4Mask. | |
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. | |
static void | InitAddress (const Ipv4Address addr, const Ipv4Mask mask) |
Set the address for the given mask. | |
static bool | IsAddressAllocated (const Ipv4Address addr) |
Check the Ipv4Address allocation in the list of IPv4 entries. | |
static bool | IsNetworkAllocated (const Ipv4Address addr, const Ipv4Mask mask) |
Check if a network has already allocated addresses. | |
static Ipv4Address | NextAddress (const Ipv4Mask mask) |
Allocate the next Ipv4Address for the configured network and mask. | |
static Ipv4Address | NextNetwork (const Ipv4Mask mask) |
Get the next network according to the given Ipv4Mask. | |
static void | Reset () |
Reset the networks and Ipv4Address to zero. | |
static void | TestMode () |
Used to turn off fatal errors and assertions, for testing. | |
This generator assigns addresses sequentially from a provided network address; used in topology code.
Definition at line 28 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 590 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION.
Referenced by AddressCollisionTestCase::DoRun(), and 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 566 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION.
|
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 550 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION.
Referenced by NetworkNumberAllocatorTestCase::DoRun().
|
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 534 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION.
Referenced by AddressAllocatorTestCase::DoRun(), ExampleAddressGeneratorTestCase::DoRun(), NetworkAndAddressTestCase::DoRun(), and NetworkNumberAllocatorTestCase::DoRun().
|
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 558 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION.
Referenced by ExampleAddressGeneratorTestCase::DoRun().
|
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 598 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION.
Referenced by AddressCollisionTestCase::DoRun().
|
static |
Check if a network has already allocated addresses.
Definition at line 606 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION.
|
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 574 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION.
Referenced by AddressAllocatorTestCase::DoRun(), ExampleAddressGeneratorTestCase::DoRun(), and NetworkAndAddressTestCase::DoRun().
|
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 542 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION.
Referenced by ExampleAddressGeneratorTestCase::DoRun(), NetworkAndAddressTestCase::DoRun(), and NetworkNumberAllocatorTestCase::DoRun().
|
static |
Reset the networks and Ipv4Address to zero.
Definition at line 582 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION_NOARGS.
Referenced by AddressAllocatorHelperTestCase::DoTeardown(), AddressAllocatorTestCase::DoTeardown(), AddressCollisionTestCase::DoTeardown(), ExampleAddressGeneratorTestCase::DoTeardown(), IpAddressHelperTestCasev4::DoTeardown(), NetworkAllocatorHelperTestCase::DoTeardown(), NetworkAndAddressTestCase::DoTeardown(), NetworkNumberAllocatorTestCase::DoTeardown(), and ResetAllocatorHelperTestCase::DoTeardown().
|
static |
Used to turn off fatal errors and assertions, for testing.
Definition at line 614 of file ipv4-address-generator.cc.
References ns3::SimulationSingleton< T >::Get(), and NS_LOG_FUNCTION_NOARGS.
Referenced by AddressCollisionTestCase::DoRun().