ADDED:
* num-addrs subcommand, to get the number of hosts/addresses in a given
  prefix length
* get-net subcommand, to more easily get a single subnet from either the
  beginning or the end of a prefix. (MUCH FASTER than CIDR-splitting!)
This commit is contained in:
brent saner
2025-04-13 18:25:32 -04:00
parent c05f9c4d47
commit 860ad5842b
16 changed files with 334 additions and 78 deletions

View File

@@ -21,7 +21,15 @@ func (v *VLSMSplitter) Split() (nets []*netip.Prefix, remaining *netipx.IPSet, e
var base netip.Prefix
var sub netip.Prefix
var subPtr *netip.Prefix
var ipsb = new(netipx.IPSetBuilder)
var ipsb *netipx.IPSetBuilder = new(netipx.IPSetBuilder)
if v == nil || v.PrefixLengths == nil || len(v.PrefixLengths) == 0 || v.BaseSplitter == nil || v.network == nil {
return
}
if err = validate.Struct(v); err != nil {
return
}
if err = ValidateSizes(v.network, v.PrefixLengths...); err != nil {
return
@@ -38,10 +46,6 @@ func (v *VLSMSplitter) Split() (nets []*netip.Prefix, remaining *netipx.IPSet, e
But, as I expected, netipx ftw again.
*/
if v == nil || v.PrefixLengths == nil || len(v.PrefixLengths) == 0 || v.BaseSplitter == nil || v.network == nil {
return
}
if !v.Explicit {
sort.SliceStable(
v.PrefixLengths,