l2fib: MAC: Fix uint64 to u8 byte array
[vpp.git] / test / vpp_papi_provider.py
index b6759ec..d84012b 100644 (file)
@@ -195,7 +195,7 @@ class VppPapiProvider(object):
         return cli + "\n" + str(self.cli(cli))
 
     def _convert_mac(self, mac):
-        return int(mac.replace(":", ""), 16) << 16
+        return mac.replace(':', '').decode('hex')
 
     def show_version(self):
         """ """
@@ -385,6 +385,38 @@ class VppPapiProvider(object):
                          'decap_next_index': decap_next_index,
                          'vni': vni})
 
+    def geneve_add_del_tunnel(
+            self,
+            local_addr,
+            remote_addr,
+            mcast_sw_if_index=0xFFFFFFFF,
+            is_add=1,
+            is_ipv6=0,
+            encap_vrf_id=0,
+            decap_next_index=0xFFFFFFFF,
+            vni=0):
+        """
+
+        :param remote_addr:
+        :param local_addr:
+        :param is_add:  (Default value = 1)
+        :param is_ipv6:  (Default value = 0)
+        :param encap_vrf_id:  (Default value = 0)
+        :param decap_next_index:  (Default value = 0xFFFFFFFF)
+        :param mcast_sw_if_index:  (Default value = 0xFFFFFFFF)
+        :param vni:  (Default value = 0)
+
+        """
+        return self.api(self.papi.geneve_add_del_tunnel,
+                        {'is_add': is_add,
+                         'is_ipv6': is_ipv6,
+                         'local_address': local_addr,
+                         'remote_address': remote_addr,
+                         'mcast_sw_if_index': mcast_sw_if_index,
+                         'encap_vrf_id': encap_vrf_id,
+                         'decap_next_index': decap_next_index,
+                         'vni': vni})
+
     def bridge_domain_add_del(self, bd_id, flood=1, uu_flood=1, forward=1,
                               learn=1, arp_term=0, is_add=1):
         """Create/delete bridge domain.
@@ -714,7 +746,8 @@ class VppPapiProvider(object):
             is_local=0,
             is_classify=0,
             is_multipath=0,
-            not_last=0):
+            is_l2_bridged=0,
+            is_source_lookup=0):
         """
 
         :param dst_address_length:
@@ -733,7 +766,8 @@ class VppPapiProvider(object):
         :param is_multipath:  (Default value = 0)
         :param is_resolve_host:  (Default value = 0)
         :param is_resolve_attached:  (Default value = 0)
-        :param not_last:  (Default value = 0)
+        :param is_l2_bridged:  (Default value = 0)
+        :param is_source_lookup:  (Default value = 0)
         :param next_hop_weight:  (Default value = 1)
 
         """
@@ -754,7 +788,8 @@ class VppPapiProvider(object):
              'is_multipath': is_multipath,
              'is_resolve_host': is_resolve_host,
              'is_resolve_attached': is_resolve_attached,
-             'not_last': not_last,
+             'is_l2_bridged': is_l2_bridged,
+             'is_source_lookup': is_source_lookup,
              'next_hop_weight': next_hop_weight,
              'dst_address_length': dst_address_length,
              'dst_address': dst_address,
@@ -986,8 +1021,7 @@ class VppPapiProvider(object):
             is_drop=0,
             is_multipath=0,
             classify_table_index=0xFFFFFFFF,
-            is_classify=0,
-            not_last=0):
+            is_classify=0):
         """
 
         :param dst_address_length:
@@ -1007,7 +1041,6 @@ class VppPapiProvider(object):
         :param is_multicast:  (Default value = 0)
         :param is_resolve_host:  (Default value = 0)
         :param is_resolve_attached:  (Default value = 0)
-        :param not_last:  (Default value = 0)
         :param next_hop_weight:  (Default value = 1)
 
         """
@@ -1290,7 +1323,7 @@ class VppPapiProvider(object):
             protocol,
             vrf_id=0,
             local_num=0,
-            locals=None,
+            locals=[],
             is_add=1):
         """Add/delete NAT44 load balancing static mapping
 
@@ -1313,6 +1346,29 @@ class VppPapiProvider(object):
         """
         return self.api(self.papi.nat44_lb_static_mapping_dump, {})
 
+    def nat44_del_session(
+            self,
+            addr,
+            port,
+            protocol,
+            vrf_id=0,
+            is_in=1):
+        """Delete NAT44 session
+
+        :param addr: IPv4 address
+        :param por: port number
+        :param protocol: IP protocol number
+        :param vrf_id: VRF ID
+        :param is_in: 1 if inside network addres and port pari, 0 if outside
+        """
+        return self.api(
+            self.papi.nat44_del_session,
+            {'address': addr,
+             'port': port,
+             'protocol': protocol,
+             'vrf_id': vrf_id,
+             'is_in': is_in})
+
     def nat_det_add_del_map(
             self,
             in_addr,
@@ -2004,7 +2060,7 @@ class VppPapiProvider(object):
                             eid,
                             eid_prefix_len=0,
                             vni=0,
-                            rlocs=None,
+                            rlocs=[],
                             rlocs_num=0,
                             is_src_dst=0,
                             is_add=1):
@@ -2388,3 +2444,60 @@ class VppPapiProvider(object):
 
         return self.api(
             self.papi.macip_acl_dump, {'acl_index': acl_index})
+
+    def policer_add_del(self,
+                        name,
+                        cir,
+                        eir,
+                        cb,
+                        eb,
+                        is_add=1,
+                        rate_type=0,
+                        round_type=0,
+                        ptype=0,
+                        color_aware=0,
+                        conform_action_type=1,
+                        conform_dscp=0,
+                        exceed_action_type=0,
+                        exceed_dscp=0,
+                        violate_action_type=0,
+                        violate_dscp=0):
+        return self.api(self.papi.policer_add_del,
+                        {'name': name,
+                         'cir': cir,
+                         'eir': eir,
+                         'cb': cb,
+                         'eb': eb,
+                         'is_add': is_add,
+                         'rate_type': rate_type,
+                         'round_type': round_type,
+                         'type': ptype,
+                         'color_aware': color_aware,
+                         'conform_action_type': conform_action_type,
+                         'conform_dscp': conform_dscp,
+                         'exceed_action_type': exceed_action_type,
+                         'exceed_dscp': exceed_dscp,
+                         'violate_action_type': violate_action_type,
+                         'violate_dscp': violate_dscp})
+
+    def ip_punt_police(self,
+                       policer_index,
+                       is_ip6=0,
+                       is_add=1):
+        return self.api(self.papi.ip_punt_police,
+                        {'policer_index': policer_index,
+                         'is_add': is_add,
+                         'is_ip6': is_ip6})
+
+    def ip_punt_redirect(self,
+                         rx_sw_if_index,
+                         tx_sw_if_index,
+                         nh,
+                         is_ip6=0,
+                         is_add=1):
+        return self.api(self.papi.ip_punt_redirect,
+                        {'rx_sw_if_index': rx_sw_if_index,
+                         'tx_sw_if_index': tx_sw_if_index,
+                         'nh': nh,
+                         'is_add': is_add,
+                         'is_ip6': is_ip6})