blob: f412a78cbc0fc88dda484f392c71635f19e3c82a [file] [log] [blame]
Mikio Hara7db411a2014-11-09 20:13:42 +09001// 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
Russ Cox5f55cee2021-02-19 18:54:43 -05005//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows || zos
Mikio Hara7db411a2014-11-09 20:13:42 +09006
Mikio Hara63eda1e2018-07-11 01:05:18 +09007package ipv6_test
Mikio Hara7db411a2014-11-09 20:13:42 +09008
9import (
Tobias Klauser0bfab662023-04-28 17:33:01 +020010 "errors"
Mikio Hara7db411a2014-11-09 20:13:42 +090011 "os"
12 "syscall"
Tobias Klauser0bfab662023-04-28 17:33:01 +020013
14 "golang.org/x/net/ipv6"
Mikio Hara7db411a2014-11-09 20:13:42 +090015)
16
17func 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 }
Tobias Klauser0bfab662023-04-28 17:33:01 +020033 return errors.Is(err, ipv6.ErrNotImplemented)
Mikio Hara7db411a2014-11-09 20:13:42 +090034}