Bug 2834

Summary: internet: add a CheckAllocated function to Ipv[4,6]AddressGenerator
Product: ns-3 Reporter: Tommaso Pecorella <tommaso.pecorella>
Component: internetAssignee: Tommaso Pecorella <tommaso.pecorella>
Status: RESOLVED FIXED    
Severity: enhancement CC: ns-bugs, tomh
Priority: P3    
Version: ns-3-dev   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 2835    
Attachments: first option
Much better approach

Description Tommaso Pecorella 2017-12-04 19:56:11 UTC
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 UTC
(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 UTC
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 UTC
Pushed in changeset: 13232:896e8dc8bd93