From 7f99183a20d60cd5c648cc23d7a2f30a594a215b Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Thu, 6 Dec 2018 17:35:12 +0100 Subject: Test framework: StringIO fixes for Python3 Add 2/3 support to binarytomac and mactobinary and move to vpp_mac.py Change-Id: I3dc7e4a24486aee22140c781aae7e44e58935877 Signed-off-by: Ole Troan --- test/vpp_mac.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'test/vpp_mac.py') 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(): -- cgit 1.2.3-korg