ADDED:
* The -s/--size argument to the VLSM splitter may now be a
  comma-delimited list of sizes instead of needing to specify -s/--size
  for each size.
  This change is backwards-compatible.
This commit is contained in:
brent saner
2025-04-04 11:53:55 -04:00
parent 0c8577f149
commit d37aa3eb6b
5 changed files with 72 additions and 4 deletions

View File

@@ -0,0 +1,33 @@
package main
import (
`strconv`
`strings`
)
// Sizes returns a parsed/split slice of uint8s from a vlsmSize.
func (v *vlsmSize) Sizes() (sizes []uint8, err error) {
var s []string
var u uint64
if v == nil {
return
}
s = strings.Split(string(*v), ",")
for idx, i := range s {
s[idx] = strings.TrimSpace(i)
}
sizes = make([]uint8, len(s))
// No validation is performed since we don't have access to the addr inet family; that's up to the parsers.
for idx, i := range s {
if u, err = strconv.ParseUint(i, 10, 8); err != nil {
return
}
sizes[idx] = uint8(u)
}
return
}