-
Notifications
You must be signed in to change notification settings - Fork 0
/
attr_service_type.go
executable file
·93 lines (72 loc) · 1.89 KB
/
attr_service_type.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
package radgo
import (
. "asdf"
)
type EAstValue uint32
func (me EAstValue) Tag() string {
return "Service-Type"
}
func (me EAstValue) Begin() int {
return int(astBegin)
}
func (me EAstValue) End() int {
return int(astEnd)
}
func (me EAstValue) Int() int {
return int(me)
}
func (me EAstValue) IsGood() bool {
if !IsGoodEnum(me) {
Log.Error("bad attr(%s) value(%d)", me.Tag(), me)
return false
} else if 0 == len(astBind[me]) {
Log.Error("no support attr(%s) value(%d)", me.Tag(), me)
return false
}
return true
}
func (me EAstValue) ToString() string {
var b EnumBinding = astBind[:]
return b.EntryShow(me)
}
func (me *EAstValue) FromString(Name string) error {
if e, ok := astMap[Name]; ok {
*me = e
return nil
}
return ErrNoFound
}
const (
astBegin EAstValue = 1
AstLogin EAstValue = 1
AstFramed EAstValue = 2
AstCallbackLogin EAstValue = 3
AstCallbackFramed EAstValue = 4
AstOutbound EAstValue = 5
AstAdministrative EAstValue = 6
AstNasPrompt EAstValue = 7
AstAuthenticateOnly EAstValue = 8
AstCallbackNasPrompt EAstValue = 9
AstCallCheck EAstValue = 10
AstCallbackAdministrative EAstValue = 11
astEnd EAstValue = 12
)
var astBind = [astEnd]string{
AstLogin: "Login",
AstFramed: "Framed",
AstCallbackLogin: "Callback Login",
AstCallbackFramed: "Callback Framed",
AstOutbound: "Outbound",
AstAdministrative: "Administrative",
AstNasPrompt: "NAS Prompt",
AstAuthenticateOnly: "Authenticate Only",
AstCallbackNasPrompt: "Callback NAS Prompt",
AstCallCheck: "Call Check",
AstCallbackAdministrative: "Callback Administrative",
}
var astMap = map[string]EAstValue{}
func initAst() {
for i := astBegin; i < astEnd; i++ {
astMap[astBind[i]] = i
}
}