X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Fvpp_mac.py;h=b20bf54634c03ffeaa2ff989e37cca5ea8a7b3e3;hb=02782d6ebd13ce02f2d3facebb54fec3c2137c88;hp=787d77c58bdb504d12db9f0ee5b98ae04181068a;hpb=91afaab068e4f3452eda35053959a9015ae1d0d0;p=vpp.git diff --git a/test/vpp_mac.py b/test/vpp_mac.py index 787d77c58bd..b20bf54634c 100644 --- a/test/vpp_mac.py +++ b/test/vpp_mac.py @@ -2,8 +2,19 @@ MAC Types """ +import binascii -from util import mactobinary + +def mactobinary(mac): + """ Convert the : separated format into binary packet data for the API """ + return binascii.unhexlify(mac.replace(':', '')) + + +def binarytomac(binary): + """ Convert binary packed data in a : separated string """ + x = b':'.join(binascii.hexlify(binary)[i:i + 2] + for i in range(0, 12, 2)) + return str(x.decode('ascii')) class VppMacAddress():