aboutsummaryrefslogtreecommitdiffstats
path: root/test/vpp_mac.py
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2018-12-06 17:35:12 +0100
committerNeale Ranns <nranns@cisco.com>2018-12-10 08:01:56 +0000
commit7f99183a20d60cd5c648cc23d7a2f30a594a215b (patch)
treebb3934aab296ce5fa531bfc5ab47921a113ffd26 /test/vpp_mac.py
parent521a8d7df423a0b5aaf259d49ca9230705bc25ee (diff)
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 <ot@cisco.com>
Diffstat (limited to 'test/vpp_mac.py')
-rw-r--r--test/vpp_mac.py13
1 files changed, 12 insertions, 1 deletions
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():