Skip to content

Instantly share code, notes, and snippets.

@ebraminio
Created September 1, 2016 11:54
Show Gist options
  • Save ebraminio/c228ec2cfba4c09cb4717ffd6dc28dc3 to your computer and use it in GitHub Desktop.
Save ebraminio/c228ec2cfba4c09cb4717ffd6dc28dc3 to your computer and use it in GitHub Desktop.
// https://gist.github.com/DavidWittman/b7a509632ed92fccf237 (SuperMicro)
package main
import (
"fmt"
"net"
"github.com/vmware/goipmi"
)
type macAddrResponse struct {
ipmi.CompletionCode
_ [4]byte
Mac [6]byte
}
func main() {
ipmiReq := &ipmi.Request{
NetworkFunction: ipmi.NetworkFunction(0x30),
Command: ipmi.Command(0x21),
Data: []byte{},
}
ipmiRes := &macAddrResponse{}
conn := &ipmi.Connection{
Hostname: "IP",
Port: 623,
Username: "USER",
Password: "PASS",
Interface: "lanplus",
}
client, err := ipmi.NewClient(conn)
if err != nil {
fmt.Println(err)
return
}
err = client.Send(ipmiReq, ipmiRes)
if err != nil {
fmt.Println(err)
return
}
var mac net.HardwareAddr
mac = ipmiRes.Mac[:]
fmt.Println(mac.String())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment