github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/libnetwork/osl/options_linux.go (about) 1 package osl 2 3 import "net" 4 5 func (nh *neigh) processNeighOptions(options ...NeighOption) { 6 for _, opt := range options { 7 if opt != nil { 8 opt(nh) 9 } 10 } 11 } 12 13 // WithLinkName sets the srcName of the link to use in the neighbor entry. 14 func WithLinkName(name string) NeighOption { 15 return func(nh *neigh) { 16 nh.linkName = name 17 } 18 } 19 20 // WithFamily sets the address-family for the neighbor entry. e.g. [syscall.AF_BRIDGE]. 21 func WithFamily(family int) NeighOption { 22 return func(nh *neigh) { 23 nh.family = family 24 } 25 } 26 27 // WithIsBridge sets whether the interface is a bridge. 28 func WithIsBridge(isBridge bool) IfaceOption { 29 return func(i *Interface) error { 30 i.bridge = isBridge 31 return nil 32 } 33 } 34 35 // WithMaster sets the master interface (if any) for this interface. The 36 // master interface name should refer to the srcName of a previously added 37 // interface of type bridge. 38 func WithMaster(name string) IfaceOption { 39 return func(i *Interface) error { 40 i.master = name 41 return nil 42 } 43 } 44 45 // WithMACAddress sets the interface MAC-address. 46 func WithMACAddress(mac net.HardwareAddr) IfaceOption { 47 return func(i *Interface) error { 48 i.mac = mac 49 return nil 50 } 51 } 52 53 // WithIPv4Address sets the IPv4 address of the interface. 54 func WithIPv4Address(addr *net.IPNet) IfaceOption { 55 return func(i *Interface) error { 56 i.address = addr 57 return nil 58 } 59 } 60 61 // WithIPv6Address sets the IPv6 address of the interface. 62 func WithIPv6Address(addr *net.IPNet) IfaceOption { 63 return func(i *Interface) error { 64 i.addressIPv6 = addr 65 return nil 66 } 67 } 68 69 // WithLinkLocalAddresses set the link-local IP addresses of the interface. 70 func WithLinkLocalAddresses(list []*net.IPNet) IfaceOption { 71 return func(i *Interface) error { 72 i.llAddrs = list 73 return nil 74 } 75 } 76 77 // WithRoutes sets the interface routes. 78 func WithRoutes(routes []*net.IPNet) IfaceOption { 79 return func(i *Interface) error { 80 i.routes = routes 81 return nil 82 } 83 }