github.com/icodeface/tls@v0.0.0-20230910023335-34df9250cd12/internal/x/net/lif/lif.go (about) 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 5 // +build solaris 6 7 // Package lif provides basic functions for the manipulation of 8 // logical network interfaces and interface addresses on Solaris. 9 // 10 // The package supports Solaris 11 or above. 11 package lif 12 13 import "syscall" 14 15 type endpoint struct { 16 af int 17 s uintptr 18 } 19 20 func (ep *endpoint) close() error { 21 return syscall.Close(int(ep.s)) 22 } 23 24 func newEndpoints(af int) ([]endpoint, error) { 25 var lastErr error 26 var eps []endpoint 27 afs := []int{sysAF_INET, sysAF_INET6} 28 if af != sysAF_UNSPEC { 29 afs = []int{af} 30 } 31 for _, af := range afs { 32 s, err := syscall.Socket(af, sysSOCK_DGRAM, 0) 33 if err != nil { 34 lastErr = err 35 continue 36 } 37 eps = append(eps, endpoint{af: af, s: uintptr(s)}) 38 } 39 if len(eps) == 0 { 40 return nil, lastErr 41 } 42 return eps, nil 43 }