options_linux.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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) MacAddress(mac net.HardwareAddr) IfaceOption {
  38. return func(i *nwIface) {
  39. i.mac = mac
  40. }
  41. }
  42. func (n *networkNamespace) Address(addr *net.IPNet) IfaceOption {
  43. return func(i *nwIface) {
  44. i.address = addr
  45. }
  46. }
  47. func (n *networkNamespace) AddressIPv6(addr *net.IPNet) IfaceOption {
  48. return func(i *nwIface) {
  49. i.addressIPv6 = addr
  50. }
  51. }
  52. func (n *networkNamespace) LinkLocalAddresses(list []*net.IPNet) IfaceOption {
  53. return func(i *nwIface) {
  54. i.llAddrs = list
  55. }
  56. }
  57. func (n *networkNamespace) IPAliases(list []*net.IPNet) IfaceOption {
  58. return func(i *nwIface) {
  59. i.ipAliases = list
  60. }
  61. }
  62. func (n *networkNamespace) Routes(routes []*net.IPNet) IfaceOption {
  63. return func(i *nwIface) {
  64. i.routes = routes
  65. }
  66. }