You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
924 B

  1. // Copyright 2016 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build solaris
  5. // Package lif provides basic functions for the manipulation of
  6. // logical network interfaces and interface addresses on Solaris.
  7. //
  8. // The package supports Solaris 11 or above.
  9. package lif
  10. import "syscall"
  11. type endpoint struct {
  12. af int
  13. s uintptr
  14. }
  15. func (ep *endpoint) close() error {
  16. return syscall.Close(int(ep.s))
  17. }
  18. func newEndpoints(af int) ([]endpoint, error) {
  19. var lastErr error
  20. var eps []endpoint
  21. afs := []int{sysAF_INET, sysAF_INET6}
  22. if af != sysAF_UNSPEC {
  23. afs = []int{af}
  24. }
  25. for _, af := range afs {
  26. s, err := syscall.Socket(af, sysSOCK_DGRAM, 0)
  27. if err != nil {
  28. lastErr = err
  29. continue
  30. }
  31. eps = append(eps, endpoint{af: af, s: uintptr(s)})
  32. }
  33. if len(eps) == 0 {
  34. return nil, lastErr
  35. }
  36. return eps, nil
  37. }