...
1
2
3
4
5
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 }
35
View as plain text