File: cmd_get_sdr_repo_alloc_info.go

package info (click to toggle)
golang-github-bougou-go-ipmi 0.7.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,880 kB
  • sloc: makefile: 38
file content (54 lines) | stat: -rw-r--r-- 1,417 bytes parent folder | download | duplicates (2)
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
package ipmi

import (
	"context"
	"fmt"
)

// 33.10 Get SDR Repository Allocation Info Command
type GetSDRRepoAllocInfoRequest struct {
	// empty
}

type GetSDRRepoAllocInfoResponse struct {
	PossibleAllocUnits uint16
	AllocUnitsSize     uint16 // Allocation unit size in bytes. 0000h indicates unspecified.
	FreeAllocUnits     uint16
	LargestFreeBlock   uint16
	MaximumRecordSize  uint8
}

func (req *GetSDRRepoAllocInfoRequest) Pack() []byte {
	return nil
}

func (req *GetSDRRepoAllocInfoRequest) Command() Command {
	return CommandGetSDRRepoAllocInfo
}

func (res *GetSDRRepoAllocInfoResponse) Unpack(msg []byte) error {
	if len(msg) < 9 {
		return ErrUnpackedDataTooShortWith(len(msg), 9)
	}
	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 *GetSDRRepoAllocInfoResponse) CompletionCodes() map[uint8]string {
	return map[uint8]string{}
}

func (res *GetSDRRepoAllocInfoResponse) Format() string {
	return fmt.Sprintf("%v", res)
}

func (c *Client) GetSDRRepoAllocInfo(ctx context.Context) (response *GetSDRRepoAllocInfoResponse, err error) {
	request := &GetSDRRepoAllocInfoRequest{}
	response = &GetSDRRepoAllocInfoResponse{}
	err = c.Exchange(ctx, request, response)
	return
}