forked from bougou/go-ipmi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_get_sel_alloc_info.go
60 lines (51 loc) · 1.51 KB
/
cmd_get_sel_alloc_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
package ipmi
import "fmt"
type GetSELAllocInfoRequest struct {
// empty
}
type GetSELAllocInfoResponse struct {
PossibleAllocUnits uint16
AllocUnitsSize uint16 // Allocation unit size in bytes. 0000h indicates unspecified.
FreeAllocUnits uint16
LargestFreeBlock uint16
MaximumRecordSize uint8
}
func (req *GetSELAllocInfoRequest) Pack() []byte {
return []byte{}
}
func (req *GetSELAllocInfoRequest) Command() Command {
return CommandGetSELAllocInfo
}
func (res *GetSELAllocInfoResponse) Unpack(msg []byte) error {
if len(msg) < 9 {
return ErrUnpackedDataTooShort
}
res.PossibleAllocUnits, _, _ = unpackUint16L(msg, 0)
res.AllocUnitsSize, _, _ = unpackUint16L(msg, 2)
res.FreeAllocUnits, _, _ = unpackUint16L(msg, 4)
res.LargestFreeBlock, _, _ = unpackUint16L(msg, 6)
res.MaximumRecordSize, _, _ = unpackUint8(msg, 8)
return nil
}
func (res *GetSELAllocInfoResponse) CompletionCodes() map[uint8]string {
return map[uint8]string{}
}
func (res *GetSELAllocInfoResponse) Format() string {
return fmt.Sprintf(`# of Alloc Units : %d
Alloc Unit Size : %d
# Free Units : %d
Largest Free Blk : %d
Max Record Size : %d`,
res.PossibleAllocUnits,
res.AllocUnitsSize,
res.FreeAllocUnits,
res.LargestFreeBlock,
res.MaximumRecordSize,
)
}
func (c *Client) GetSELAllocInfo() (response *GetSELAllocInfoResponse, err error) {
request := &GetSELAllocInfoRequest{}
response = &GetSELAllocInfoResponse{}
err = c.Exchange(request, response)
return
}