| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
package rawfile |
| 19 |
|
| 20 |
import ( |
| 21 |
"golang.org/x/sys/unix" |
| 22 |
"inet.af/netstack/tcpip" |
| 23 |
) |
| 24 |
|
| 25 |
const maxErrno = 134 |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
func TranslateErrno(e unix.Errno) tcpip.Error { |
| 33 |
switch e { |
| 34 |
case unix.EEXIST: |
| 35 |
return &tcpip.ErrDuplicateAddress{} |
| 36 |
case unix.ENETUNREACH: |
| 37 |
return &tcpip.ErrNoRoute{} |
| 38 |
case unix.EINVAL: |
| 39 |
return &tcpip.ErrInvalidEndpointState{} |
| 40 |
case unix.EALREADY: |
| 41 |
return &tcpip.ErrAlreadyConnecting{} |
| 42 |
case unix.EISCONN: |
| 43 |
return &tcpip.ErrAlreadyConnected{} |
| 44 |
case unix.EADDRINUSE: |
| 45 |
return &tcpip.ErrPortInUse{} |
| 46 |
case unix.EADDRNOTAVAIL: |
| 47 |
return &tcpip.ErrBadLocalAddress{} |
| 48 |
case unix.EPIPE: |
| 49 |
return &tcpip.ErrClosedForSend{} |
| 50 |
case unix.EWOULDBLOCK: |
| 51 |
return &tcpip.ErrWouldBlock{} |
| 52 |
case unix.ECONNREFUSED: |
| 53 |
return &tcpip.ErrConnectionRefused{} |
| 54 |
case unix.ETIMEDOUT: |
| 55 |
return &tcpip.ErrTimeout{} |
| 56 |
case unix.EINPROGRESS: |
| 57 |
return &tcpip.ErrConnectStarted{} |
| 58 |
case unix.EDESTADDRREQ: |
| 59 |
return &tcpip.ErrDestinationRequired{} |
| 60 |
case unix.ENOTSUP: |
| 61 |
return &tcpip.ErrNotSupported{} |
| 62 |
case unix.ENOTTY: |
| 63 |
return &tcpip.ErrQueueSizeNotSupported{} |
| 64 |
case unix.ENOTCONN: |
| 65 |
return &tcpip.ErrNotConnected{} |
| 66 |
case unix.ECONNRESET: |
| 67 |
return &tcpip.ErrConnectionReset{} |
| 68 |
case unix.ECONNABORTED: |
| 69 |
return &tcpip.ErrConnectionAborted{} |
| 70 |
case unix.EMSGSIZE: |
| 71 |
return &tcpip.ErrMessageTooLong{} |
| 72 |
case unix.ENOBUFS: |
| 73 |
return &tcpip.ErrNoBufferSpace{} |
| 74 |
default: |
| 75 |
return &tcpip.ErrInvalidEndpointState{} |
| 76 |
} |
| 77 |
} |