mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 02:30:03 +01:00
netif.py: Use macFromString, macToString. mac.py: new file Signed-off-by: Mike Wray <mike.wray@hp.com> Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
12 lines
268 B
Python
12 lines
268 B
Python
|
|
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
|