forked from bougou/go-ipmi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_get_command_enables.go
77 lines (61 loc) · 1.73 KB
/
cmd_get_command_enables.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
package ipmi
// 21.8 Get Command Enables Command
type GetCommandEnablesRequest struct {
ChannelNumber uint8
CommandRangeMask CommandRangeMask
NetFn NetFn
LUN uint8
CodeForNetFn2C uint8
OEM_IANA uint32 // 3 bytes only
}
type GetCommandEnablesResponse struct {
// Todo
CommandEnableMask []byte
}
func (req *GetCommandEnablesRequest) Command() Command {
return CommandGetCommandEnables
}
func (req *GetCommandEnablesRequest) Pack() []byte {
out := make([]byte, 6)
packUint8(req.ChannelNumber, out, 0)
netfn := uint8(req.NetFn) & (uint8(req.CommandRangeMask) << 6)
packUint8(netfn, out, 1)
packUint8(req.LUN&0x03, out, 2)
if uint8(req.NetFn) == 0x2c {
packUint8(req.CodeForNetFn2C, out, 3)
return out[0:4]
}
if uint8(req.NetFn) == 0x2e {
packUint24L(req.OEM_IANA, out, 3)
return out[0:6]
}
return out[0:3]
}
func (res *GetCommandEnablesResponse) Unpack(msg []byte) error {
if len(msg) < 16 {
return ErrUnpackedDataTooShort
}
res.CommandEnableMask, _, _ = unpackBytes(msg, 0, 16)
return nil
}
func (*GetCommandEnablesResponse) CompletionCodes() map[uint8]string {
// no command-specific cc
return map[uint8]string{}
}
func (res *GetCommandEnablesResponse) Format() string {
// Todo
return ""
}
func (c *Client) GetCommandEnables(channelNumber uint8, commandRangeMask CommandRangeMask, netFn NetFn, lun uint8, code uint8, oemIANA uint32) (response *GetCommandEnablesResponse, err error) {
request := &GetCommandEnablesRequest{
ChannelNumber: channelNumber,
CommandRangeMask: commandRangeMask,
NetFn: netFn,
LUN: lun,
CodeForNetFn2C: code,
OEM_IANA: oemIANA,
}
response = &GetCommandEnablesResponse{}
err = c.Exchange(request, response)
return
}