File: cmd_add_sel_entry.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 (51 lines) | stat: -rw-r--r-- 1,144 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
package ipmi

import (
	"context"
	"fmt"
)

// 31.6 Add SEL Entry Command
type AddSELEntryRequest struct {
	SEL *SEL
}

type AddSELEntryResponse struct {
	RecordID uint16 // Record ID for added record, LS Byte first
}

func (req *AddSELEntryRequest) Command() Command {
	return CommandAddSELEntry
}

func (req *AddSELEntryRequest) Pack() []byte {
	return req.SEL.Pack()
}

func (res *AddSELEntryResponse) Unpack(msg []byte) error {
	if len(msg) < 2 {
		return ErrUnpackedDataTooShortWith(len(msg), 2)
	}
	res.RecordID, _, _ = unpackUint16L(msg, 0)
	return nil
}

func (res *AddSELEntryResponse) CompletionCodes() map[uint8]string {
	return map[uint8]string{
		0x80: "operation not supported for this Record Type",
		0x81: "cannot execute command, SEL erase in progress",
	}
}

func (res *AddSELEntryResponse) Format() string {
	return fmt.Sprintf("Record ID : %d (%#02x)", res.RecordID, res.RecordID)
}

func (c *Client) AddSELEntry(ctx context.Context, sel *SEL) (response *AddSELEntryResponse, err error) {
	request := &AddSELEntryRequest{
		SEL: sel,
	}
	response = &AddSELEntryResponse{}
	err = c.Exchange(ctx, request, response)
	return
}