/
constants.go
87 lines (72 loc) · 1.74 KB
/
constants.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
package rpc
import (
"errors"
)
type status interface{}
type callType uint32
type msgStatus uint32
type acceptStatus uint32
type rejectStatus uint32
type authFlavor uint32
const (
typeCall callType = iota
typeReply
msgAccepted msgStatus = iota
msgDenied
acceptSucess acceptStatus = iota
acceptProgramUnavailable
acceptProgramMismatch
acceptProcessUnavailable
acceptGarbageArguments
acceptSystemError
rejectRPCMismatch rejectStatus = iota
rejectAuthenticationError
authNone authFlavor = iota
authSystem
authShort
authDH
authRPCSECGSS
)
type success struct {
Payload []byte
}
type programMismatch struct {
low, high uint32
}
type programUnavailable struct{}
type processUnavailable struct{}
type garbargeArguments struct{}
type systemError struct{}
type rpcMismatch struct {
low, high uint32
}
type authError struct{}
var (
ErrProgramMismatch = errors.New("Program Version mismatch")
ErrProgramUnavilable = errors.New("Program not avilable")
ErrProcessUnavilable = errors.New("Process not available")
ErrGarbargeArguments = errors.New("Arguments not interpreted correctly")
ErrSystemError = errors.New("Generic system error")
ErrRPCMismatch = errors.New("Wrong RPC version")
ErrAuthError = errors.New("Authentication error")
ErrUnknownError = errors.New("Server returned unknown error")
)
func toError(st status) error {
switch st.(type) {
case programMismatch:
return ErrProgramMismatch
case programUnavailable:
return ErrProgramUnavilable
case processUnavailable:
return ErrProcessUnavilable
case garbargeArguments:
return ErrGarbargeArguments
case systemError:
return ErrSystemError
case rpcMismatch:
return ErrRPCMismatch
case authError:
return ErrAuthError
}
return ErrUnknownError
}