P2P Ethernet
[vpp.git] / test / vpp_papi_provider.py
index ff8e2cf..801a6c2 100644 (file)
@@ -25,7 +25,15 @@ MPLS_LABEL_INVALID = MPLS_IETF_MAX_LABEL + 1
 
 
 class L2_VTR_OP:
+    L2_DISABLED = 0
+    L2_PUSH_1 = 1
+    L2_PUSH_2 = 2
     L2_POP_1 = 3
+    L2_POP_2 = 4
+    L2_TRANSLATE_1_1 = 5
+    L2_TRANSLATE_1_2 = 6
+    L2_TRANSLATE_2_1 = 7
+    L2_TRANSLATE_2_2 = 8
 
 
 class UnexpectedApiReturnValueError(Exception):
@@ -403,6 +411,14 @@ class VppPapiProvider(object):
                          'arp_term': arp_term,
                          'is_add': is_add})
 
+    def bd_ip_mac_add_del(self, bd_id, mac, ip, is_ipv6=0, is_add=1):
+        return self.api(self.papi.bd_ip_mac_add_del,
+                        {'bd_id': bd_id,
+                         'is_add': is_add,
+                         'is_ipv6': is_ipv6,
+                         'ip_address': ip,
+                         'mac_address': mac})
+
     def l2fib_add_del(self, mac, bd_id, sw_if_index, is_add=1, static_mac=0,
                       filter_mac=0, bvi_mac=0):
         """Create/delete L2 FIB entry.
@@ -428,6 +444,27 @@ class VppPapiProvider(object):
                          'filter_mac': filter_mac,
                          'bvi_mac': bvi_mac})
 
+    def l2fib_flush_int(self, sw_if_index):
+        """Flush L2 FIB entries for sw_if_index.
+
+        :param int sw_if_index: Software interface index of the interface.
+        """
+        return self.api(self.papi.l2fib_flush_int,
+                        {'sw_if_index': sw_if_index})
+
+    def l2fib_flush_bd(self, bd_id):
+        """Flush L2 FIB entries for bd_id.
+
+        :param int sw_if_index: Bridge Domain id.
+        """
+        return self.api(self.papi.l2fib_flush_bd,
+                        {'bd_id': bd_id})
+
+    def l2fib_flush_all(self):
+        """Flush all L2 FIB.
+        """
+        return self.api(self.papi.l2fib_flush_all, {})
+
     def sw_interface_set_l2_bridge(self, sw_if_index, bd_id,
                                    shg=0, bvi=0, enable=1):
         """Add/remove interface to/from bridge domain.
@@ -564,6 +601,19 @@ class VppPapiProvider(object):
              'outer_vlan_id': outer_vlan,
              'inner_vlan_id': inner_vlan})
 
+    def create_p2pethernet_subif(self, sw_if_index, remote_mac, subif_id):
+        """Create p2p ethernet subinterface
+
+        :param sw_if_index: main (parent) interface
+        :param remote_mac: client (remote) mac address
+
+        """
+        return self.api(
+            self.papi.p2p_ethernet_add,
+            {'parent_if_index': sw_if_index,
+             'remote_mac': remote_mac,
+             'subif_id': subif_id})
+
     def delete_subif(self, sw_if_index):
         """Delete subinterface
 
@@ -572,6 +622,18 @@ class VppPapiProvider(object):
         return self.api(self.papi.delete_subif,
                         {'sw_if_index': sw_if_index})
 
+    def delete_p2pethernet_subif(self, sw_if_index, remote_mac):
+        """Delete p2p ethernet subinterface
+
+        :param sw_if_index: main (parent) interface
+        :param remote_mac: client (remote) mac address
+
+        """
+        return self.api(
+            self.papi.p2p_ethernet_del,
+            {'parent_if_index': sw_if_index,
+             'remote_mac': remote_mac})
+
     def create_vlan_subif(self, sw_if_index, vlan):
         """
 
@@ -810,17 +872,20 @@ class VppPapiProvider(object):
         )
 
     def sw_interface_span_enable_disable(
-            self, sw_if_index_from, sw_if_index_to, state=1):
+            self, sw_if_index_from, sw_if_index_to, state=1, is_l2=0):
         """
 
         :param sw_if_index_from:
         :param sw_if_index_to:
         :param state:
+        :param is_l2:
         """
         return self.api(self.papi.sw_interface_span_enable_disable,
                         {'sw_if_index_from': sw_if_index_from,
                          'sw_if_index_to': sw_if_index_to,
-                         'state': state})
+                         'state': state,
+                         'is_l2': is_l2,
+                         })
 
     def gre_tunnel_add_del(self,
                            src_address,
@@ -1018,6 +1083,23 @@ class VppPapiProvider(object):
              'is_inside': is_inside,
              'sw_if_index': sw_if_index})
 
+    def snat_interface_add_del_output_feature(
+            self,
+            sw_if_index,
+            is_inside=1,
+            is_add=1):
+        """Enable/disable S-NAT output feature on the interface
+
+        :param sw_if_index: Software index of the interface
+        :param is_inside: 1 if inside, 0 if outside (Default value = 1)
+        :param is_add: 1 if add, 0 if delete (Default value = 1)
+        """
+        return self.api(
+            self.papi.snat_interface_add_del_output_feature,
+            {'is_add': is_add,
+             'is_inside': is_inside,
+             'sw_if_index': sw_if_index})
+
     def snat_add_static_mapping(
             self,
             local_ip,
@@ -1091,6 +1173,12 @@ class VppPapiProvider(object):
         """
         return self.api(self.papi.snat_interface_dump, {})
 
+    def snat_interface_output_feature_dump(self):
+        """Dump interfaces with S-NAT output feature
+        :return: Dictionary of interfaces with S-NAT output feature
+        """
+        return self.api(self.papi.snat_interface_output_feature_dump, {})
+
     def snat_static_mapping_dump(self):
         """Dump S-NAT static mappings
         :return: Dictionary of S-NAT static mappings
@@ -1306,6 +1394,146 @@ class VppPapiProvider(object):
             {'is_ip4': is_ip4,
              'user_addr': user_addr})
 
+    def nat64_add_del_pool_addr_range(
+            self,
+            start_addr,
+            end_addr,
+            vrf_id=0xFFFFFFFF,
+            is_add=1):
+        """Add/del address range to NAT64 pool
+
+        :param start_addr: First IP address
+        :param end_addr: Last IP address
+        :param vrf_id: VRF id for the address range
+        :param is_add: 1 if add, 0 if delete (Default value = 1)
+        """
+        return self.api(
+            self.papi.nat64_add_del_pool_addr_range,
+            {'start_addr': start_addr,
+             'end_addr': end_addr,
+             'vrf_id': vrf_id,
+             'is_add': is_add})
+
+    def nat64_pool_addr_dump(self):
+        """Dump NAT64 pool addresses
+        :return: Dictionary of NAT64 pool addresses
+        """
+        return self.api(self.papi.nat64_pool_addr_dump, {})
+
+    def nat64_add_del_interface(
+            self,
+            sw_if_index,
+            is_inside=1,
+            is_add=1):
+        """Enable/disable NAT64 feature on the interface
+           :param sw_if_index: Index of the interface
+           :param is_inside: 1 if inside, 0 if outside (Default value = 1)
+           :param is_add: 1 if add, 0 if delete (Default value = 1)
+        """
+        return self.api(
+            self.papi.nat64_add_del_interface,
+            {'sw_if_index': sw_if_index,
+             'is_inside': is_inside,
+             'is_add': is_add})
+
+    def nat64_interface_dump(self):
+        """Dump interfaces with NAT64 feature
+        :return: Dictionary of interfaces with NAT64 feature
+        """
+        return self.api(self.papi.nat64_interface_dump, {})
+
+    def nat64_add_del_static_bib(
+            self,
+            in_ip,
+            out_ip,
+            in_port,
+            out_port,
+            protocol,
+            vrf_id=0,
+            is_add=1):
+        """Add/delete S-NAT static BIB entry
+
+        :param in_ip: Inside IPv6 address
+        :param out_ip: Outside IPv4 address
+        :param in_port: Inside port number
+        :param out_port: Outside port number
+        :param protocol: IP protocol
+        :param vrf_id: VRF ID (Default value = 0)
+        :param is_add: 1 if add, 0 if delete (Default value = 1)
+        """
+        return self.api(
+            self.papi.nat64_add_del_static_bib,
+            {'i_addr': in_ip,
+             'o_addr': out_ip,
+             'i_port': in_port,
+             'o_port': out_port,
+             'vrf_id': vrf_id,
+             'proto': protocol,
+             'is_add': is_add})
+
+    def nat64_bib_dump(self, protocol):
+        """Dump NAT64 BIB
+
+        :param protocol: IP protocol
+        :returns: Dictionary of NAT64 BIB entries
+        """
+        return self.api(self.papi.nat64_bib_dump, {'proto': protocol})
+
+    def nat64_set_timeouts(self, udp=300, icmp=60, tcp_trans=240, tcp_est=7440,
+                           tcp_incoming_syn=6):
+        """Set values of timeouts for NAT64 (in seconds)
+
+        :param udpi: UDP timeout (Default value = 300)
+        :param icmp: ICMP timeout (Default value = 60)
+        :param tcp_trans: TCP transitory timeout (Default value = 240)
+        :param tcp_est: TCP established timeout (Default value = 7440)
+        :param tcp_incoming_syn: TCP incoming SYN timeout (Default value = 6)
+        """
+        return self.api(
+            self.papi.nat64_set_timeouts,
+            {'udp': udp,
+             'icmp': icmp,
+             'tcp_trans': tcp_trans,
+             'tcp_est': tcp_est,
+             'tcp_incoming_syn': tcp_incoming_syn})
+
+    def nat64_get_timeouts(self):
+        """Get values of timeouts for NAT64
+
+        :return: Timeouts for NAT64 (in seconds)
+        """
+        return self.api(self.papi.nat64_get_timeouts, {})
+
+    def nat64_st_dump(self, protocol):
+        """Dump NAT64 session table
+
+        :param protocol: IP protocol
+        :returns: Dictionary of NAT64 sesstion table entries
+        """
+        return self.api(self.papi.nat64_st_dump, {'proto': protocol})
+
+    def nat64_add_del_prefix(self, prefix, plen, vrf_id=0, is_add=1):
+        """Add/del NAT64 prefix
+
+        :param prefix: NAT64 prefix
+        :param plen: NAT64 prefix length
+        :param vrf_id: VRF id of tenant (Default 0)
+        :param is_add: 1 if add, 0 if delete (Default value = 1)
+        """
+        return self.api(
+            self.papi.nat64_add_del_prefix,
+            {'prefix': prefix,
+             'prefix_len': plen,
+             'vrf_id': vrf_id,
+             'is_add': is_add})
+
+    def nat64_prefix_dump(self):
+        """Dump NAT64 prefix
+
+        :returns: Dictionary of NAT64 prefixes
+        """
+        return self.api(self.papi.nat64_prefix_dump, {})
+
     def control_ping(self):
         self.api(self.papi.control_ping)
 
@@ -1578,6 +1806,23 @@ class VppPapiProvider(object):
                 'oui': oui,
             })
 
+    def dhcp_client(self,
+                    sw_if_index,
+                    hostname,
+                    client_id='',
+                    is_add=1,
+                    want_dhcp_events=0):
+        return self.api(
+            self.papi.dhcp_client_config,
+            {
+                'sw_if_index': sw_if_index,
+                'hostname': hostname,
+                'client_id': client_id,
+                'is_add': is_add,
+                'want_dhcp_event': want_dhcp_events,
+                'pid': os.getpid(),
+            })
+
     def ip_mroute_add_del(self,
                           src_address,
                           grp_address,
@@ -1807,3 +2052,38 @@ class VppPapiProvider(object):
                          'encap_vrf_id': encap_vrf_id,
                          'decap_next_index': decap_next_index,
                          'teid': teid})
+
+    def vxlan_gpe_add_del_tunnel(
+            self,
+            src_addr,
+            dst_addr,
+            mcast_sw_if_index=0xFFFFFFFF,
+            is_add=1,
+            is_ipv6=0,
+            encap_vrf_id=0,
+            decap_vrf_id=0,
+            protocol=3,
+            vni=0):
+        """
+
+        :param local:
+        :param remote:
+        :param is_add:  (Default value = 1)
+        :param is_ipv6:  (Default value = 0)
+        :param encap_vrf_id:  (Default value = 0)
+        :param decap_vrf_id:  (Default value = 0)
+        :param mcast_sw_if_index:  (Default value = 0xFFFFFFFF)
+        :param protocol:  (Default value = 3)
+        :param vni:  (Default value = 0)
+
+        """
+        return self.api(self.papi.vxlan_gpe_add_del_tunnel,
+                        {'is_add': is_add,
+                         'is_ipv6': is_ipv6,
+                         'local': src_addr,
+                         'remote': dst_addr,
+                         'mcast_sw_if_index': mcast_sw_if_index,
+                         'encap_vrf_id': encap_vrf_id,
+                         'decap_vrf_id': decap_vrf_id,
+                         'protocol': protocol,
+                         'vni': vni})