golang.org/x/net@v0.25.1-0.20240516223405-c87a5b62e243/ipv4/helper_posix_test.go (about) 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 5 //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows || zos 6 7 package ipv4_test 8 9 import ( 10 "errors" 11 "os" 12 "syscall" 13 14 "golang.org/x/net/ipv4" 15 ) 16 17 func protocolNotSupported(err error) bool { 18 switch err := err.(type) { 19 case syscall.Errno: 20 switch err { 21 case syscall.EPROTONOSUPPORT, syscall.ENOPROTOOPT: 22 return true 23 } 24 case *os.SyscallError: 25 switch err := err.Err.(type) { 26 case syscall.Errno: 27 switch err { 28 case syscall.EPROTONOSUPPORT, syscall.ENOPROTOOPT: 29 return true 30 } 31 } 32 } 33 return errors.Is(err, ipv4.ErrNotImplemented) 34 }