VPP-1508: Tests: Fix vpp_api struct.error under py3.
[vpp.git] / test / test_ip4.py
index 492e96a..ab733ac 100644 (file)
@@ -4,6 +4,7 @@ import random
 import socket
 import unittest
 
+import scapy.compat
 from scapy.contrib.mpls import MPLS
 from scapy.layers.inet import IP, UDP, TCP, ICMP, icmptypes, icmpcodes
 from scapy.layers.l2 import Ether, Dot1Q, ARP
@@ -310,7 +311,7 @@ class TestIPv4FibCrud(VppTestCase):
         dest_addr_len = 32
         n_next_hop_addr = socket.inet_pton(socket.AF_INET, next_hop_addr)
         for _ in range(count):
-            n_dest_addr = '{:08x}'.format(dest_addr).decode('hex')
+            n_dest_addr = binascii.unhexlify('{:08x}'.format(dest_addr))
             self.vapi.ip_add_del_route(n_dest_addr, dest_addr_len,
                                        n_next_hop_addr)
             added_ips.append(socket.inet_ntoa(n_dest_addr))
@@ -325,7 +326,7 @@ class TestIPv4FibCrud(VppTestCase):
         dest_addr_len = 32
         n_next_hop_addr = socket.inet_pton(socket.AF_INET, next_hop_addr)
         for _ in range(count):
-            n_dest_addr = '{:08x}'.format(dest_addr).decode('hex')
+            n_dest_addr = binascii.unhexlify('{:08x}'.format(dest_addr))
             self.vapi.ip_add_del_route(n_dest_addr, dest_addr_len,
                                        n_next_hop_addr, is_add=0)
             removed_ips.append(socket.inet_ntoa(n_dest_addr))
@@ -1145,7 +1146,7 @@ class TestIPPunt(VppTestCase):
         #
         # add a policer
         #
-        policer = self.vapi.policer_add_del("ip4-punt", 400, 0, 10, 0,
+        policer = self.vapi.policer_add_del(b"ip4-punt", 400, 0, 10, 0,
                                             rate_type=1)
         self.vapi.ip_punt_police(policer.policer_index)
 
@@ -1166,7 +1167,7 @@ class TestIPPunt(VppTestCase):
         # remove the poilcer. back to full rx
         #
         self.vapi.ip_punt_police(policer.policer_index, is_add=0)
-        self.vapi.policer_add_del("ip4-punt", 400, 0, 10, 0,
+        self.vapi.policer_add_del(b"ip4-punt", 400, 0, 10, 0,
                                   rate_type=1, is_add=0)
         self.send_and_expect(self.pg0, pkts, self.pg1)