aboutsummaryrefslogtreecommitdiffstats
path: root/tools/python/xen/util/mac.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/python/xen/util/mac.py')
-rw-r--r--tools/python/xen/util/mac.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/python/xen/util/mac.py b/tools/python/xen/util/mac.py
new file mode 100644
index 0000000000..47dffd80d5
--- /dev/null
+++ b/tools/python/xen/util/mac.py
@@ -0,0 +1,11 @@
+
+from string import join, split
+
+def macToString(mac):
+ return ':'.join(map(lambda x: "%02x" % x, mac))
+
+def macFromString(str):
+ mac = [ int(x, 16) for x in str.split(':') ]
+ if len(mac) != 6:
+ raise ValueError("invalid mac: %s" % str)
+ return mac