utils_solaris.go 893 B

12345678910111213141516171819202122232425262728293031
  1. // Package ipamutils provides utililty functions for ipam management
  2. package ipamutils
  3. // Solaris: TODO
  4. import (
  5. "net"
  6. )
  7. // ElectInterfaceAddresses looks for an interface on the OS with the specified name
  8. // and returns its IPv4 and IPv6 addresses in CIDR form. If the interface does not exist,
  9. // it chooses from a predifined list the first IPv4 address which does not conflict
  10. // with other interfaces on the system.
  11. func ElectInterfaceAddresses(name string) (*net.IPNet, []*net.IPNet, error) {
  12. var (
  13. v4Net *net.IPNet
  14. err error
  15. )
  16. v4Net, err = FindAvailableNetwork(PredefinedBroadNetworks)
  17. if err != nil {
  18. return nil, nil, err
  19. }
  20. return v4Net, nil, nil
  21. }
  22. // FindAvailableNetwork returns a network from the passed list which does not
  23. // overlap with existing interfaces in the system
  24. func FindAvailableNetwork(list []*net.IPNet) (*net.IPNet, error) {
  25. return list[0], nil
  26. }