forked from bougou/go-ipmi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_set_channel_access.go
72 lines (58 loc) · 1.69 KB
/
cmd_set_channel_access.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
package ipmi
// 22.22 Set Channel Access Command
type SetChannelAccessRequest struct {
ChannnelNumber uint8
// [7:6] - 00b = don't set or change Channel Access
// 01b = set non-volatile Channel Access according to bits [5:0]
// 10b = set volatile (active) setting of Channel Access according to bit [5:0]
// 11b = reserved
AccessOption uint8
DisablePEFAlerting bool
DisablePerMsgAuth bool
DisableUserLevelAuth bool
AccessMode ChannelAccessMode
PrivilegeOption uint8
MaxPrivilegeLevel uint8
}
type SetChannelAccessResponse struct {
}
func (req *SetChannelAccessRequest) Pack() []byte {
out := make([]byte, 3)
packUint8(req.ChannnelNumber, out, 0)
var b = req.AccessOption << 6
if req.DisablePEFAlerting {
b = setBit5(b)
}
if req.DisablePerMsgAuth {
b = setBit4(b)
}
if req.DisableUserLevelAuth {
b = setBit3(b)
}
b |= uint8(req.AccessMode) & 0x07
packUint8(b, out, 1)
var b2 = req.PrivilegeOption << 6
b2 |= req.MaxPrivilegeLevel & 0x3f
packUint8(b2, out, 2)
return out
}
func (req *SetChannelAccessRequest) Command() Command {
return CommandSetChannelAccess
}
func (res *SetChannelAccessResponse) CompletionCodes() map[uint8]string {
return map[uint8]string{
0x82: "set not supported on selected channel (e.g. channel is sessionless.)",
0x83: "access mode not supported",
}
}
func (res *SetChannelAccessResponse) Unpack(msg []byte) error {
return nil
}
func (res *SetChannelAccessResponse) Format() string {
return ""
}
func (c *Client) SetChannelAccess(request *SetChannelAccessRequest) (response *SetChannelAccessResponse, err error) {
response = &SetChannelAccessResponse{}
err = c.Exchange(request, response)
return
}