-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathcmd_get_netfn_support.go
75 lines (62 loc) · 1.63 KB
/
cmd_get_netfn_support.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
package ipmi
import "context"
// 21.2 Get NetFn Support Command
type GetNetFnSupportRequest struct {
ChannelNumber uint8
}
type GetNetFnSupportResponse struct {
LUN3Support LUNSupport
LUN2Support LUNSupport
LUN1Support LUNSupport
LUN0Support LUNSupport
// Todo
NetFnPairsSupport []byte
}
type LUNSupport uint8
func (l LUNSupport) String() string {
m := map[LUNSupport]string{
0x00: "no commands supported",
0x01: "commands exist on LUN - no restriction",
0x02: "commands exist on LUN - restricted",
0x03: "reserved",
}
s, ok := m[l]
if ok {
return s
}
return ""
}
func (req *GetNetFnSupportRequest) Command() Command {
return CommandGetNetFnSupport
}
func (req *GetNetFnSupportRequest) Pack() []byte {
return []byte{req.ChannelNumber}
}
func (res *GetNetFnSupportResponse) Unpack(msg []byte) error {
if len(msg) < 17 {
return ErrUnpackedDataTooShortWith(len(msg), 17)
}
b, _, _ := unpackUint8(msg, 0)
res.LUN3Support = LUNSupport(b >> 6)
res.LUN2Support = LUNSupport((b & 0x3f) >> 4)
res.LUN1Support = LUNSupport((b & 0x0f) >> 2)
res.LUN0Support = LUNSupport(b & 0x03)
res.NetFnPairsSupport, _, _ = unpackBytes(msg, 1, 16)
return nil
}
func (*GetNetFnSupportResponse) CompletionCodes() map[uint8]string {
// no command-specific cc
return map[uint8]string{}
}
func (res *GetNetFnSupportResponse) Format() string {
// Todo
return ""
}
func (c *Client) GetNetFnSupport(ctx context.Context, channelNumber uint8) (response *GetNetFnSupportResponse, err error) {
request := &GetNetFnSupportRequest{
ChannelNumber: channelNumber,
}
response = &GetNetFnSupportResponse{}
err = c.Exchange(ctx, request, response)
return
}