X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Fvpp_interface.py;h=3235d3f68c66145e0610b48dee9b4d7a9df4da0e;hb=7f99183a20d60cd5c648cc23d7a2f30a594a215b;hp=1fe6652cfc763e377a72acfe8b4c11cd7dcc82b3;hpb=93cc3ee3b3a9c9224a1446625882205f3282a949;p=vpp.git diff --git a/test/vpp_interface.py b/test/vpp_interface.py index 1fe6652cfc7..3235d3f68c6 100644 --- a/test/vpp_interface.py +++ b/test/vpp_interface.py @@ -1,7 +1,11 @@ -from abc import abstractmethod, ABCMeta +import binascii import socket +from abc import abstractmethod, ABCMeta + +from six import moves -from util import Host, mk_ll_addr, mactobinary +from util import Host, mk_ll_addr +from vpp_mac import mactobinary, binarytomac class VppInterface(object): @@ -228,17 +232,16 @@ class VppInterface(object): r = self.test.vapi.sw_interface_dump() for intf in r: if intf.sw_if_index == self.sw_if_index: - self._name = intf.interface_name.split(b'\0', 1)[0] - self._local_mac = \ - ':'.join(intf.l2_address.encode('hex')[i:i + 2] - for i in range(0, 12, 2)) + self._name = intf.interface_name.split(b'\0', + 1)[0].decode('utf8') + self._local_mac = binarytomac(intf.l2_address) self._dump = intf break else: raise Exception( "Could not find interface with sw_if_index %d " "in interface dump %s" % - (self.sw_if_index, repr(r))) + (self.sw_if_index, moves.reprlib.repr(r))) self._local_ip6_ll = mk_ll_addr(self.local_mac) self._local_ip6n_ll = socket.inet_pton(socket.AF_INET6, self.local_ip6_ll) @@ -271,7 +274,7 @@ class VppInterface(object): :param vrf_id: The FIB table / VRF ID. (Default value = 0) """ for host in self._remote_hosts: - macn = host.mac.replace(":", "").decode('hex') + macn = mactobinary(host.mac) ipn = host.ip4n self.test.vapi.ip_neighbor_add_del( self.sw_if_index, macn, ipn) @@ -302,7 +305,7 @@ class VppInterface(object): :param vrf_id: The FIB table / VRF ID. (Default value = 0) """ for host in self._remote_hosts: - macn = host.mac.replace(":", "").decode('hex') + macn = mactobinary(host.mac) ipn = host.ip6n self.test.vapi.ip_neighbor_add_del( self.sw_if_index, macn, ipn, is_ipv6=1)