-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathcmd_get_device_guid.go
54 lines (43 loc) · 1.09 KB
/
cmd_get_device_guid.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
package ipmi
import (
"context"
"fmt"
)
// 20.8 Get Device GUID Command
type GetDeviceGUIDRequest struct {
// empty
}
type GetDeviceGUIDResponse struct {
GUID [16]byte
}
func (req *GetDeviceGUIDRequest) Command() Command {
return CommandGetDeviceGUID
}
func (req *GetDeviceGUIDRequest) Pack() []byte {
return []byte{}
}
func (res *GetDeviceGUIDResponse) CompletionCodes() map[uint8]string {
return map[uint8]string{}
}
func (res *GetDeviceGUIDResponse) Unpack(msg []byte) error {
if len(msg) < 16 {
return ErrUnpackedDataTooShortWith(len(msg), 16)
}
guid, _, _ := unpackBytes(msg, 0, 16)
res.GUID = array16(guid)
return nil
}
func (res *GetDeviceGUIDResponse) Format() string {
guidMode := GUIDModeSMBIOS
u, err := ParseGUID(res.GUID[:], guidMode)
if err != nil {
return fmt.Sprintf("<invalid UUID bytes> (%s)", err)
}
return fmt.Sprintf("GUID: %s", u.String())
}
func (c *Client) GetDeviceGUID(ctx context.Context) (response *GetDeviceGUIDResponse, err error) {
request := &GetDeviceGUIDRequest{}
response = &GetDeviceGUIDResponse{}
err = c.Exchange(ctx, request, response)
return
}