forked from bougou/go-ipmi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_set_bmc_global_enables.go
87 lines (73 loc) · 2.25 KB
/
cmd_set_bmc_global_enables.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
package ipmi
import "fmt"
// 22.1 Set BMC Global Enables Command
type SetBMCGlobalEnablesRequest struct {
// Generic system mgmt. software must do a "read-modifywrite" 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(enableSystemEventLogging bool, enableEventMessageBuffer bool, enableEventMessageBufferFullInterrupt bool, enableReceiveMessageQueueInterrupt bool) (response *SetBMCGlobalEnablesResponse, err error) {
getRes, err := c.GetBMCGlobalEnables()
if err != nil {
return nil, fmt.Errorf("GetBMCGlobalEnables failed, err: %s", 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(request, response)
return
}