helper_posix_test.go 658 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2014 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 windows
  5. package ipv4_test
  6. import (
  7. "os"
  8. "syscall"
  9. )
  10. func protocolNotSupported(err error) bool {
  11. switch err := err.(type) {
  12. case syscall.Errno:
  13. switch err {
  14. case syscall.EPROTONOSUPPORT, syscall.ENOPROTOOPT:
  15. return true
  16. }
  17. case *os.SyscallError:
  18. switch err := err.Err.(type) {
  19. case syscall.Errno:
  20. switch err {
  21. case syscall.EPROTONOSUPPORT, syscall.ENOPROTOOPT:
  22. return true
  23. }
  24. }
  25. }
  26. return false
  27. }