forked from layeh/radius
-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.go
64 lines (60 loc) · 1.5 KB
/
code.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
package radius
import (
"strconv"
)
// Code defines the RADIUS packet type.
type Code int
// Standard RADIUS packet codes.
const (
CodeAccessRequest Code = 1
CodeAccessAccept Code = 2
CodeAccessReject Code = 3
CodeAccountingRequest Code = 4
CodeAccountingResponse Code = 5
CodeAccessChallenge Code = 11
CodeStatusServer Code = 12
CodeStatusClient Code = 13
CodeDisconnectRequest Code = 40
CodeDisconnectACK Code = 41
CodeDisconnectNAK Code = 42
CodeCoARequest Code = 43
CodeCoAACK Code = 44
CodeCoANAK Code = 45
CodeReserved Code = 255
)
// String returns a string representation of the code.
func (c Code) String() string {
switch c {
case CodeAccessRequest:
return `Access-Request`
case CodeAccessAccept:
return `Access-Accept`
case CodeAccessReject:
return `Access-Reject`
case CodeAccountingRequest:
return `Accounting-Request`
case CodeAccountingResponse:
return `Accounting-Response`
case CodeAccessChallenge:
return `Access-Challenge`
case CodeStatusServer:
return `Status-Server`
case CodeStatusClient:
return `Status-Client`
case CodeDisconnectRequest:
return `Disconnect-Request`
case CodeDisconnectACK:
return `Disconnect-ACK`
case CodeDisconnectNAK:
return `Disconnect-NAK`
case CodeCoARequest:
return `CoA-Request`
case CodeCoAACK:
return `CoA-ACK`
case CodeCoANAK:
return `CoA-NAK`
case CodeReserved:
return `Reserved`
}
return "Code(" + strconv.Itoa(int(c)) + ")"
}