nettest_unix.go 497 B

123456789101112131415161718192021
  1. // Copyright 2019 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 aix darwin dragonfly freebsd linux netbsd openbsd solaris
  5. package nettest
  6. import "syscall"
  7. func supportsRawSocket() bool {
  8. for _, af := range []int{syscall.AF_INET, syscall.AF_INET6} {
  9. s, err := syscall.Socket(af, syscall.SOCK_RAW, 0)
  10. if err != nil {
  11. continue
  12. }
  13. syscall.Close(s)
  14. return true
  15. }
  16. return false
  17. }