1 Star 0 Fork 0

叶海丰/ipmi-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cmd_get_device_guid.go 1.14 KB
一键复制 编辑 原始数据 按行查看 历史
叶海丰 提交于 12个月前 . init
package ipmi
import (
"fmt"
"github.com/google/uuid"
)
// 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 {
uuidRFC4122MSB := make([]byte, 16)
for i := 0; i < 16; i++ {
uuidRFC4122MSB[i] = res.GUID[:][15-i]
}
u, err := uuid.FromBytes(uuidRFC4122MSB)
if err != nil {
return "Invalid UUID Bytes"
}
return fmt.Sprintf(`GUID: %s`, u.String())
}
func (c *Client) GetDeviceGUID() (response *GetDeviceGUIDResponse, err error) {
request := &GetDeviceGUIDRequest{}
response = &GetDeviceGUIDResponse{}
err = c.Exchange(request, response)
return
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/rogax/ipmi-go.git
git@gitee.com:rogax/ipmi-go.git
rogax
ipmi-go
ipmi-go
86ae46cfb58e

搜索帮助