Bugzilla – Bug 2834
internet: add a CheckAllocated function to Ipv[4,6]AddressGenerator
Last modified: 2017-12-23 14:24:07 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.
(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.
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.
Pushed in changeset: 13232:896e8dc8bd93