|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen staging] golang/xenlight: define Mac builtin type
commit 1db777e5e407ec12906deeac9c90e673e66865d8
Author: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>
AuthorDate: Mon Dec 16 18:08:03 2019 +0000
Commit: George Dunlap <george.dunlap@xxxxxxxxxx>
CommitDate: Mon Dec 16 18:08:03 2019 +0000
golang/xenlight: define Mac builtin type
Define Mac as [6]byte and implement fromC, toC, and String functions.
Signed-off-by: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>
Reviewed-by: George Dunlap <george.dunlap@xxxxxxxxxx>
---
tools/golang/xenlight/xenlight.go | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/tools/golang/xenlight/xenlight.go
b/tools/golang/xenlight/xenlight.go
index 72afc3cf14..17d146771e 100644
--- a/tools/golang/xenlight/xenlight.go
+++ b/tools/golang/xenlight/xenlight.go
@@ -181,6 +181,39 @@ func (d *Defbool) toC() (C.libxl_defbool, error) {
return c, nil
}
+// Mac represents a libxl_mac, or simply a MAC address.
+type Mac [6]byte
+
+// String formats a Mac address to string representation.
+func (mac Mac) String() string {
+ s := "%02x:%02x:%02x:%02x:%02x:%02x"
+ opts := make([]interface{}, 6)
+
+ for i, v := range mac {
+ opts[i] = v
+ }
+
+ return fmt.Sprintf(s, opts...)
+}
+
+func (mac *Mac) fromC(cmac *C.libxl_mac) error {
+ for i := range *mac {
+ mac[i] = byte(cmac[i])
+ }
+
+ return nil
+}
+
+func (mac Mac) toC() (C.libxl_mac, error) {
+ var cmac C.libxl_mac
+
+ for i, v := range mac {
+ cmac[i] = C.uint8_t(v)
+ }
+
+ return cmac, nil
+}
+
type Context struct {
ctx *C.libxl_ctx
logger *C.xentoollog_logger_stdiostream
--
generated by git-patchbot for /home/xen/git/xen.git#staging
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |