forked from bougou/go-ipmi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_get_system_interface_capabilities.go
76 lines (62 loc) · 2.09 KB
/
cmd_get_system_interface_capabilities.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
package ipmi
// 22.9 Get System Interface Capabilities Command
type GetSystemInterfaceCapabilitiesRequest struct {
SystemInterfaceType SystemInterfaceType
}
type GetSystemInterfaceCapabilitiesResponse struct {
// For System Interface Type = SSIF
TranscationSupportMask uint8
PECSupported bool
SSIFVersion uint8
InputMessageSizeBytes uint8
OutputMessageSizeBytes uint8
// For System Interface Type = KCS or SMIC
SystemInterfaceVersion uint8
InputMaximumMessageSizeBytes uint8
}
type SystemInterfaceType uint8
const (
SystemInterfaceTypeSSIF SystemInterfaceType = 0x00
SystemInterfaceTypeKCS SystemInterfaceType = 0x01
SystemInterfaceTypeSMIC SystemInterfaceType = 0x02
)
func (req *GetSystemInterfaceCapabilitiesRequest) Command() Command {
return CommandGetSystemInterfaceCapabilities
}
func (req *GetSystemInterfaceCapabilitiesRequest) Pack() []byte {
return []byte{uint8(req.SystemInterfaceType)}
}
func (res *GetSystemInterfaceCapabilitiesResponse) Unpack(msg []byte) error {
// at least 3 bytes
if len(msg) < 3 {
return ErrUnpackedDataTooShort
}
// For System Interface Type = SSIF:
b, _, _ := unpackUint8(msg, 1)
res.TranscationSupportMask = b >> 6
res.PECSupported = isBit3Set(b)
res.SSIFVersion = b & 0x07
res.InputMessageSizeBytes, _, _ = unpackUint8(msg, 2)
// For System Interface Type = KCS or SMIC
res.SystemInterfaceVersion = b & 0x07
res.InputMaximumMessageSizeBytes, _, _ = unpackUint8(msg, 2)
if len(msg) >= 4 {
res.OutputMessageSizeBytes, _, _ = unpackUint8(msg, 3)
}
return nil
}
func (*GetSystemInterfaceCapabilitiesResponse) CompletionCodes() map[uint8]string {
// no command-specific cc
return map[uint8]string{}
}
func (res *GetSystemInterfaceCapabilitiesResponse) Format() string {
return ""
}
func (c *Client) GetSystemInterfaceCapabilities(interfaceType SystemInterfaceType) (response *GetSystemInterfaceCapabilitiesResponse, err error) {
request := &GetSystemInterfaceCapabilitiesRequest{
SystemInterfaceType: interfaceType,
}
response = &GetSystemInterfaceCapabilitiesResponse{}
err = c.Exchange(request, response)
return
}