1 Star 0 Fork 0

叶海丰/ipmi-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cmd_get_system_guid.go 1.26 KB
一键复制 编辑 原始数据 按行查看 历史
叶海丰 提交于 12个月前 . init
package ipmi
import (
"fmt"
"time"
"github.com/google/uuid"
)
// 22.14 Get System GUID Command
type GetSystemGUIDRequest struct {
// empty
}
type GetSystemGUIDResponse struct {
GUID [16]byte
}
func (req *GetSystemGUIDRequest) Command() Command {
return CommandGetSystemGUID
}
func (req *GetSystemGUIDRequest) Pack() []byte {
return nil
}
func (res *GetSystemGUIDResponse) Unpack(msg []byte) error {
if len(msg) < 16 {
return ErrUnpackedDataTooShortWith(len(msg), 16)
}
b, _, _ := unpackBytes(msg, 0, 16)
res.GUID = array16(b)
return nil
}
func (*GetSystemGUIDResponse) CompletionCodes() map[uint8]string {
// no command-specific cc
return map[uint8]string{}
}
func (res *GetSystemGUIDResponse) 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"
}
sec, nsec := u.Time().UnixTime()
return fmt.Sprintf(`System GUID : %s
Timestamp : %s`,
u.String(),
time.Unix(sec, nsec).Format(time.RFC3339),
)
}
func (c *Client) GetSystemGUID() (response *GetSystemGUIDResponse, err error) {
request := &GetSystemGUIDRequest{}
response = &GetSystemGUIDResponse{}
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

搜索帮助