forked from ooni/probe-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errno_openbsd.go
112 lines (107 loc) · 3.03 KB
/
errno_openbsd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Code generated by go generate; DO NOT EDIT.
// Generated: 2022-09-04 17:20:35.701025 +0200 CEST m=+0.168455543
package netxlite
import (
"errors"
"syscall"
"golang.org/x/sys/unix"
)
// This enumeration provides a canonical name for
// every system-call error we support. Note: this list
// is system dependent. You're currently looking at
// the list of errors for openbsd.
const (
ECONNREFUSED = unix.ECONNREFUSED
ECONNRESET = unix.ECONNRESET
EHOSTUNREACH = unix.EHOSTUNREACH
ETIMEDOUT = unix.ETIMEDOUT
EAFNOSUPPORT = unix.EAFNOSUPPORT
EADDRINUSE = unix.EADDRINUSE
EADDRNOTAVAIL = unix.EADDRNOTAVAIL
EISCONN = unix.EISCONN
EFAULT = unix.EFAULT
EBADF = unix.EBADF
ECONNABORTED = unix.ECONNABORTED
EALREADY = unix.EALREADY
EDESTADDRREQ = unix.EDESTADDRREQ
EINTR = unix.EINTR
EINVAL = unix.EINVAL
EMSGSIZE = unix.EMSGSIZE
ENETDOWN = unix.ENETDOWN
ENETRESET = unix.ENETRESET
ENETUNREACH = unix.ENETUNREACH
ENOBUFS = unix.ENOBUFS
ENOPROTOOPT = unix.ENOPROTOOPT
ENOTSOCK = unix.ENOTSOCK
ENOTCONN = unix.ENOTCONN
EWOULDBLOCK = unix.EWOULDBLOCK
EACCES = unix.EACCES
EPROTONOSUPPORT = unix.EPROTONOSUPPORT
EPROTOTYPE = unix.EPROTOTYPE
)
// classifySyscallError converts a syscall error to the
// proper OONI error. Returns the OONI error string
// on success, an empty string otherwise.
func classifySyscallError(err error) string {
var errno syscall.Errno
if !errors.As(err, &errno) {
return ""
}
switch errno {
case unix.ECONNREFUSED:
return FailureConnectionRefused
case unix.ECONNRESET:
return FailureConnectionReset
case unix.EHOSTUNREACH:
return FailureHostUnreachable
case unix.ETIMEDOUT:
return FailureTimedOut
case unix.EAFNOSUPPORT:
return FailureAddressFamilyNotSupported
case unix.EADDRINUSE:
return FailureAddressInUse
case unix.EADDRNOTAVAIL:
return FailureAddressNotAvailable
case unix.EISCONN:
return FailureAlreadyConnected
case unix.EFAULT:
return FailureBadAddress
case unix.EBADF:
return FailureBadFileDescriptor
case unix.ECONNABORTED:
return FailureConnectionAborted
case unix.EALREADY:
return FailureConnectionAlreadyInProgress
case unix.EDESTADDRREQ:
return FailureDestinationAddressRequired
case unix.EINTR:
return FailureInterrupted
case unix.EINVAL:
return FailureInvalidArgument
case unix.EMSGSIZE:
return FailureMessageSize
case unix.ENETDOWN:
return FailureNetworkDown
case unix.ENETRESET:
return FailureNetworkReset
case unix.ENETUNREACH:
return FailureNetworkUnreachable
case unix.ENOBUFS:
return FailureNoBufferSpace
case unix.ENOPROTOOPT:
return FailureNoProtocolOption
case unix.ENOTSOCK:
return FailureNotASocket
case unix.ENOTCONN:
return FailureNotConnected
case unix.EWOULDBLOCK:
return FailureOperationWouldBlock
case unix.EACCES:
return FailurePermissionDenied
case unix.EPROTONOSUPPORT:
return FailureProtocolNotSupported
case unix.EPROTOTYPE:
return FailureWrongProtocolType
}
return ""
}