diff --git a/controller/topology/ports/configuration/configuration.go b/controller/topology/ports/configuration/configuration.go new file mode 100644 index 0000000000000000000000000000000000000000..f97abf5265e148a11d246d60ceadc6f23115b431 --- /dev/null +++ b/controller/topology/ports/configuration/configuration.go @@ -0,0 +1,24 @@ +package configuration + +import ( + "fmt" + "net" +) + +type IPConfig struct { + IP net.IP `json:"ip,omitempty"` + PrefixLength int `json:"prefix_length,omitempty"` +} + +func New(ip string, prefixLength int) (IPConfig, error) { + newIPConfig := IPConfig{} + parsedIP := net.ParseIP(ip) + if parsedIP == nil { + return newIPConfig, fmt.Errorf("%s can not be parsed to an IP.", ip) + } + + newIPConfig.IP = parsedIP + newIPConfig.PrefixLength = prefixLength + + return newIPConfig, nil +}