forked from bougou/go-ipmi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_get_sdr_repo_info.go
122 lines (105 loc) · 3.39 KB
/
cmd_get_sdr_repo_info.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package ipmi
import (
"fmt"
"time"
)
// 33.9 Get SDR Repository Info Command
type GetSDRRepoInfoRequest struct {
// empty
}
type GetSDRRepoInfoResponse struct {
SDRVersion uint8 // version number of the SDR command set for the SDR Device. 51h for this specification.
RecordCount uint16 // LS Byte first
FreeSpeceBytes uint16 // LS Byte first
MostRecentAddititionTime time.Time
MostRecentEraseTime time.Time
SDROperationSupport SDROperationSupport
}
type SDROperationSupport struct {
Overflow bool
SupportModalSDRRepoUpdate bool // A modal SDR Repository is only updated when the controller is in an SDR Repository update mode.
SupportNonModalSDRRepoUpdate bool // A non-modal SDR Repository can be written to at any time
SupportDeleteSDR bool
SupportParitialAddSDR bool
SupportReserveSDRRepo bool
SupportGetSDRRepoAllocInfo bool
}
func (req *GetSDRRepoInfoRequest) Pack() []byte {
return []byte{}
}
func (req *GetSDRRepoInfoRequest) Command() Command {
return CommandGetSDRRepoInfo
}
func (res *GetSDRRepoInfoResponse) Unpack(msg []byte) error {
if len(msg) < 14 {
return ErrUnpackedDataTooShort
}
res.SDRVersion, _, _ = unpackUint8(msg, 0)
res.RecordCount, _, _ = unpackUint16L(msg, 1)
res.FreeSpeceBytes, _, _ = unpackUint16L(msg, 3)
addTS, _, _ := unpackUint32L(msg, 5)
res.MostRecentAddititionTime = parseTimestamp(addTS)
deleteTS, _, _ := unpackUint32L(msg, 9)
res.MostRecentEraseTime = parseTimestamp(deleteTS)
b, _, _ := unpackUint8(msg, 13)
res.SDROperationSupport = SDROperationSupport{
Overflow: isBit7Set(b),
SupportModalSDRRepoUpdate: isBit6Set(b),
SupportNonModalSDRRepoUpdate: isBit5Set(b),
SupportDeleteSDR: isBit3Set(b),
SupportParitialAddSDR: isBit2Set(b),
SupportReserveSDRRepo: isBit1Set(b),
SupportGetSDRRepoAllocInfo: isBit0Set(b),
}
return nil
}
func (res *GetSDRRepoInfoResponse) Format() string {
s := ""
if res.SDROperationSupport.SupportModalSDRRepoUpdate {
if s != "" {
s += "/ modal"
} else {
s += "modal"
}
}
if res.SDROperationSupport.SupportNonModalSDRRepoUpdate {
if s != "" {
s += "/ non-modal"
} else {
s += "non-modal"
}
}
return fmt.Sprintf(`SDR Version : %#02x
Record Count : %d
Free Space : %d bytes
Most recent Addition : %s
Most recent Erase : %s
SDR overflow : %v
SDR Repository Update Support : %s
Delete SDR supported : %v
Partial Add SDR supported : %v
Reserve SDR repository supported : %v
SDR Repository Alloc info supported : %v`,
res.SDRVersion,
res.RecordCount,
res.FreeSpeceBytes,
res.MostRecentAddititionTime,
res.MostRecentEraseTime,
res.SDROperationSupport.Overflow,
s,
res.SDROperationSupport.SupportDeleteSDR,
res.SDROperationSupport.SupportParitialAddSDR,
res.SDROperationSupport.SupportReserveSDRRepo,
res.SDROperationSupport.SupportGetSDRRepoAllocInfo,
)
}
func (res *GetSDRRepoInfoResponse) CompletionCodes() map[uint8]string {
// no command-specific cc
return map[uint8]string{}
}
func (c *Client) GetSDRRepoInfo() (response *GetSDRRepoInfoResponse, err error) {
request := &GetSDRRepoInfoRequest{}
response = &GetSDRRepoInfoResponse{}
err = c.Exchange(request, response)
return
}