package s6netdev import ( "fmt" "net" "net/netip" ) func (i *Iface) NetdevIfaceAddAddr(addr string) (err error) { var ( a netip.Prefix ) if a, err = netip.ParsePrefix(addr); err != nil { err = fmt.Errorf("Failed to parse address %s, %w", addr, err) } i.Addresses = append(i.Addresses, a) return } func (i *Iface) NetdevIfaceAddRoute(route, r_type, via string, vrf *Iface, table *RouteTable, metric Metric) (err error) { var ( r = Route{ Type: r_type, Vrf: vrf, Table: table, Metric: metric, } ) if via != "" { if r.Via, err = netip.ParseAddr(via); err != nil { err = fmt.Errorf("Failed to parse via %s, %w", via, err) } } i.Routes = append(i.Routes, r) return } func (i *Iface) NetdevIfaceMAC(mac string) (err error) { i.MACAddr, err = net.ParseMAC(mac) return } func (i *Iface) NetdevIfaceEnslave(s ...*Iface) { i.Slaves = append(i.Slaves, s...) } func (i *Iface) NetdevIfaceSysctl(ipv int, key, value, def string) { l := &i.Sysctls.V4 if ipv == 6 { l = &i.Sysctls.V6 } *l = append(*l, Property{Key: key, Value: value, Default: def}) } func (i *Iface) NetdevIfaceProperty(key, value, def string) { i.Properties = append(i.Properties, Property{Key: key, Value: value, Default: def}) }