X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Fvpp_mac.py;h=b20bf54634c03ffeaa2ff989e37cca5ea8a7b3e3;hb=02782d6ebd13ce02f2d3facebb54fec3c2137c88;hp=27814cdc761eaa29538615197d1d8b08edf72744;hpb=dd89173cc177f7130eca426eb4fa5737ec59c91d;p=vpp.git diff --git a/test/vpp_mac.py b/test/vpp_mac.py index 27814cdc761..b20bf54634c 100644 --- a/test/vpp_mac.py +++ b/test/vpp_mac.py @@ -2,13 +2,24 @@ 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(): def __init__(self, addr): - self.address = addr + self._address = addr def encode(self): return { @@ -21,11 +32,7 @@ class VppMacAddress(): @property def address(self): - return self.address - - @address.setter - def address(self, value): - self.address = value + return self._address def __str__(self): return self.address