forked from bougou/go-ipmi
/
cmd_suspend_bmc_arps.go
68 lines (55 loc) · 1.42 KB
/
cmd_suspend_bmc_arps.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
package ipmi
// 23.3 Suspend BMC ARPs Command
type SuspendARPsRequest struct {
ChannelNumber uint8
SuspendARP bool
SuspendGratuitousARP bool
}
type SuspendARPsResponse struct {
// Present state of ARP suspension
IsARPOccurring bool
IsGratuitousARPOccurring bool
}
func (req *SuspendARPsRequest) Pack() []byte {
out := make([]byte, 2)
packUint8(req.ChannelNumber, out, 0)
var b uint8
if req.SuspendARP {
b = setBit1(b)
}
if req.SuspendGratuitousARP {
b = setBit0(b)
}
packUint8(b, out, 1)
return out
}
func (req *SuspendARPsRequest) Command() Command {
return CommandSuspendARPs
}
func (res *SuspendARPsResponse) CompletionCodes() map[uint8]string {
return map[uint8]string{
0x80: "parameter not supported.",
}
}
func (res *SuspendARPsResponse) Unpack(msg []byte) error {
if len(msg) < 1 {
return ErrUnpackedDataTooShort
}
b, _, _ := unpackUint8(msg, 0)
res.IsARPOccurring = isBit1Set(b)
res.IsGratuitousARPOccurring = isBit0Set(b)
return nil
}
func (res *SuspendARPsResponse) Format() string {
return ""
}
func (c *Client) SuspendARPs(channelNumber uint8, suspendARP bool, suspendGratuitousARP bool) (response *SuspendARPsResponse, err error) {
request := &SuspendARPsRequest{
ChannelNumber: channelNumber,
SuspendARP: suspendARP,
SuspendGratuitousARP: suspendGratuitousARP,
}
response = &SuspendARPsResponse{}
err = c.Exchange(request, response)
return
}