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
|
package ipmi
import (
"context"
"fmt"
)
// 22.1 Set BMC Global Enables Command
type SetBMCGlobalEnablesRequest struct {
// Generic system mgmt. software must do a "read-modify-write" using the Get BMC Global Enables and Set BMC Global Enables to avoid altering EnableOEM_X field.
EnableOEM2 bool
EnableOEM1 bool
EnableOEM0 bool
EnableSystemEventLogging bool
EnableEventMessageBuffer bool
EnableEventMessageBufferFullInterrupt bool
EnableReceiveMessageQueueInterrupt bool
}
type SetBMCGlobalEnablesResponse struct {
// empty
}
func (req *SetBMCGlobalEnablesRequest) Command() Command {
return CommandSetBMCGlobalEnables
}
func (req *SetBMCGlobalEnablesRequest) Pack() []byte {
var b uint8 = 0
if req.EnableOEM2 {
b = setBit7(b)
}
if req.EnableOEM1 {
b = setBit6(b)
}
if req.EnableOEM0 {
b = setBit5(b)
}
if req.EnableSystemEventLogging {
b = setBit3(b)
}
if req.EnableEventMessageBuffer {
b = setBit2(b)
}
if req.EnableEventMessageBufferFullInterrupt {
b = setBit1(b)
}
if req.EnableReceiveMessageQueueInterrupt {
b = setBit0(b)
}
return []byte{b}
}
func (res *SetBMCGlobalEnablesResponse) Unpack(msg []byte) error {
return nil
}
func (*SetBMCGlobalEnablesResponse) CompletionCodes() map[uint8]string {
// no command-specific cc
return map[uint8]string{}
}
func (res *SetBMCGlobalEnablesResponse) Format() string {
// Todo
return ""
}
func (c *Client) SetBMCGlobalEnables(ctx context.Context, enableSystemEventLogging bool, enableEventMessageBuffer bool, enableEventMessageBufferFullInterrupt bool, enableReceiveMessageQueueInterrupt bool) (response *SetBMCGlobalEnablesResponse, err error) {
getRes, err := c.GetBMCGlobalEnables(ctx)
if err != nil {
return nil, fmt.Errorf("GetBMCGlobalEnables failed, err: %w", err)
}
request := &SetBMCGlobalEnablesRequest{
EnableOEM2: getRes.OEM2Enabled,
EnableOEM1: getRes.OEM1Enabled,
EnableOEM0: getRes.OEM0Enabled,
EnableSystemEventLogging: enableSystemEventLogging,
EnableEventMessageBuffer: enableEventMessageBuffer,
EnableEventMessageBufferFullInterrupt: enableEventMessageBufferFullInterrupt,
EnableReceiveMessageQueueInterrupt: enableReceiveMessageQueueInterrupt,
}
response = &SetBMCGlobalEnablesResponse{}
err = c.Exchange(ctx, request, response)
return
}
|