Bug 2834 - internet: add a CheckAllocated function to Ipv[4,6]AddressGenerator
internet: add a CheckAllocated function to Ipv[4,6]AddressGenerator
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: internet
ns-3-dev
All All
: P3 enhancement
Assigned To: Tommaso Pecorella
:
Depends on:
Blocks: 2835
  Show dependency treegraph
 
Reported: 2017-12-04 19:56 EST by Tommaso Pecorella
Modified: 2017-12-23 14:24 EST (History)
2 users (show)

See Also:


Attachments
first option (10.03 KB, patch)
2017-12-04 19:56 EST, Tommaso Pecorella
Details | Diff
Much better approach (9.36 KB, patch)
2017-12-05 18:38 EST, Tommaso Pecorella
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tommaso Pecorella 2017-12-04 19:56:11 EST
Created attachment 2970 [details]
first option

At the moment there is no way to ask an Ipv[4,6]AddressGenerator about if a network is allocated or not.
This patch just does that.

The code is mostly borrowed from AddNetwork, but it is not changing any internal state.
Probably I could optimize it to eliminate the duplicated code and just have AddNetwork depend on CheckNetwork.
Comment 1 Tom Henderson 2017-12-04 22:01:00 EST
(In reply to Tommaso Pecorella from comment #0)

> Probably I could optimize it to eliminate the duplicated code and just have
> AddNetwork depend on CheckNetwork.

I would prefer that solution.
Comment 2 Tommaso Pecorella 2017-12-05 18:38:44 EST
Created attachment 2974 [details]
Much better approach

The code doesn't borrow from AddAddress anymore.

The CheckAllocated function is now much simpler, and a new IsNetworkAllocated function checks if any address in a given network has been already allocated.

IsNetworkAllocated is actually the function I needed for LTE, the other one is kept because I think it's useful in some cases.
Comment 3 Tommaso Pecorella 2017-12-23 14:24:07 EST
Pushed in changeset: 13232:896e8dc8bd93