options_linux.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package osl
  2. import "net"
  3. func (nh *neigh) processNeighOptions(options ...NeighOption) {
  4. for _, opt := range options {
  5. if opt != nil {
  6. opt(nh)
  7. }
  8. }
  9. }
  10. func (n *networkNamespace) LinkName(name string) NeighOption {
  11. return func(nh *neigh) {
  12. nh.linkName = name
  13. }
  14. }
  15. func (n *networkNamespace) Family(family int) NeighOption {
  16. return func(nh *neigh) {
  17. nh.family = family
  18. }
  19. }
  20. func (i *nwIface) processInterfaceOptions(options ...IfaceOption) {
  21. for _, opt := range options {
  22. if opt != nil {
  23. opt(i)
  24. }
  25. }
  26. }
  27. func (n *networkNamespace) Bridge(isBridge bool) IfaceOption {
  28. return func(i *nwIface) {
  29. i.bridge = isBridge
  30. }
  31. }
  32. func (n *networkNamespace) Master(name string) IfaceOption {
  33. return func(i *nwIface) {
  34. i.master = name
  35. }
  36. }
  37. func (n *networkNamespace) Address(addr *net.IPNet) IfaceOption {
  38. return func(i *nwIface) {
  39. i.address = addr
  40. }
  41. }
  42. func (n *networkNamespace) AddressIPv6(addr *net.IPNet) IfaceOption {
  43. return func(i *nwIface) {
  44. i.addressIPv6 = addr
  45. }
  46. }
  47. func (n *networkNamespace) Routes(routes []*net.IPNet) IfaceOption {
  48. return func(i *nwIface) {
  49. i.routes = routes
  50. }
  51. }