Add special Twice-NAT feature (VPP-1221)
[vpp.git] / test / vpp_papi_provider.py
index da59bc8..53be992 100644 (file)
@@ -568,7 +568,8 @@ class VppPapiProvider(object):
                          'enable': enable})
 
     def bridge_flags(self, bd_id, is_set, feature_bitmap):
-        """Enable/disable required feature of the bridge domain with defined ID.
+        """Enable/disable required feature of the bridge domain with defined
+        ID.
 
         :param int bd_id: Bridge domain ID.
         :param int is_set: Set to 1 to enable, set to 0 to disable the feature.
@@ -667,6 +668,16 @@ class VppPapiProvider(object):
                         {'sw_if_index': sw_if_index,
                          'mtu': mtu})
 
+    def sw_interface_set_promiscuous(self, sw_if_index, enable):
+        """
+        :param sw_if_index:
+        :param enable:
+
+        """
+        return self.api(self.papi.sw_interface_set_promiscuous,
+                        {'sw_if_index': sw_if_index,
+                         'enable': enable})
+
     def sw_interface_set_mac_address(self, sw_if_index, mac):
         return self.api(self.papi.sw_interface_set_mac_address,
                         {'sw_if_index': sw_if_index,
@@ -1083,6 +1094,11 @@ class VppPapiProvider(object):
     def udp_encap_dump(self):
         return self.api(self.papi.udp_encap_dump, {})
 
+    def want_udp_encap_stats(self, enable=1):
+        return self.api(self.papi.want_udp_encap_stats,
+                        {'enable': enable,
+                         'pid': os.getpid()})
+
     def mpls_fib_dump(self):
         return self.api(self.papi.mpls_fib_dump, {})
 
@@ -1286,6 +1302,7 @@ class VppPapiProvider(object):
             vrf_id=0,
             protocol=0,
             twice_nat=0,
+            self_twice_nat=0,
             out2in_only=0,
             tag="",
             is_add=1):
@@ -1300,6 +1317,9 @@ class VppPapiProvider(object):
         :param vrf_id: VRF ID
         :param protocol: IP protocol (Default value = 0)
         :param twice_nat: 1 if translate external host address and port
+        :param self_twice_nat: 1 if translate external host address and port
+                               whenever external host address equals
+                               local address of internal host
         :param out2in_only: if 1 rule is matching only out2in direction
         :param tag: Opaque string tag
         :param is_add: 1 if add, 0 if delete (Default value = 1)
@@ -1316,6 +1336,7 @@ class VppPapiProvider(object):
              'vrf_id': vrf_id,
              'protocol': protocol,
              'twice_nat': twice_nat,
+             'self_twice_nat': self_twice_nat,
              'out2in_only': out2in_only,
              'tag': tag})
 
@@ -1480,6 +1501,7 @@ class VppPapiProvider(object):
             protocol,
             vrf_id=0,
             twice_nat=0,
+            self_twice_nat=0,
             out2in_only=0,
             tag='',
             local_num=0,
@@ -1499,6 +1521,7 @@ class VppPapiProvider(object):
              'protocol': protocol,
              'vrf_id': vrf_id,
              'twice_nat': twice_nat,
+             'self_twice_nat': self_twice_nat,
              'out2in_only': out2in_only,
              'tag': tag,
              'local_num': local_num,
@@ -2284,6 +2307,7 @@ class VppPapiProvider(object):
                           e_flags,
                           next_hop_afi,
                           next_hop_sw_if_index,
+                          next_hop_address,
                           i_flags,
                           bier_imp=0,
                           rpf_id=0,
@@ -2308,7 +2332,8 @@ class VppPapiProvider(object):
              'next_hop_afi': next_hop_afi,
              'grp_address_length': grp_address_length,
              'grp_address': grp_address,
-             'src_address': src_address})
+             'src_address': src_address,
+             'nh_address': next_hop_address})
 
     def mfib_signal_dump(self):
         return self.api(self.papi.mfib_signal_dump, {})
@@ -2760,6 +2785,12 @@ class VppPapiProvider(object):
                         {'acl_index': acl_index},
                         expected_retval=expected_retval)
 
+    def acl_interface_list_dump(self, sw_if_index=0xFFFFFFFF,
+                                expected_retval=0):
+        return self.api(self.papi.acl_interface_list_dump,
+                        {'sw_if_index': sw_if_index},
+                        expected_retval=expected_retval)
+
     def macip_acl_add(self, rules, tag=""):
         """ Add MACIP acl
 
@@ -3203,6 +3234,15 @@ class VppPapiProvider(object):
         """ Get IP reassembly parameters """
         return self.api(self.papi.ip_reassembly_get, {'is_ip6': is_ip6})
 
+    def ip_reassembly_enable_disable(self, sw_if_index, enable_ip4=False,
+                                     enable_ip6=False):
+        """ Enable/disable IP reassembly """
+        return self.api(self.papi.ip_reassembly_enable_disable,
+                        {'sw_if_index': sw_if_index,
+                         'enable_ip4': 1 if enable_ip4 else 0,
+                         'enable_ip6': 1 if enable_ip6 else 0,
+                         })
+
     def gbp_endpoint_add_del(self, is_add, sw_if_index, addr, is_ip6, epg):
         """ GBP endpoint Add/Del """
         return self.api(self.papi.gbp_endpoint_add_del,
@@ -3217,6 +3257,59 @@ class VppPapiProvider(object):
         """ GBP endpoint Dump """
         return self.api(self.papi.gbp_endpoint_dump, {})
 
+    def gbp_endpoint_group_add_del(self, is_add, epg, bd,
+                                   ip4_rd,
+                                   ip6_rd,
+                                   uplink_sw_if_index):
+        """ GBP endpoint group Add/Del """
+        return self.api(self.papi.gbp_endpoint_group_add_del,
+                        {'is_add': is_add,
+                         'epg': {
+                             'uplink_sw_if_index': uplink_sw_if_index,
+                             'bd_id': bd,
+                             'ip4_table_id': ip4_rd,
+                             'ip6_table_id': ip6_rd,
+                             'epg_id': epg}})
+
+    def gbp_endpoint_group_dump(self):
+        """ GBP endpoint group Dump """
+        return self.api(self.papi.gbp_endpoint_group_dump, {})
+
+    def gbp_recirc_add_del(self, is_add, sw_if_index, epg, is_ext):
+        """ GBP recirc Add/Del """
+        return self.api(self.papi.gbp_recirc_add_del,
+                        {'is_add': is_add,
+                         'recirc': {
+                             'is_ext': is_ext,
+                             'sw_if_index': sw_if_index,
+                             'epg_id': epg}})
+
+    def gbp_recirc_dump(self):
+        """ GBP recirc Dump """
+        return self.api(self.papi.gbp_recirc_dump, {})
+
+    def gbp_subnet_add_del(self, is_add, table_id,
+                           is_internal,
+                           addr, addr_len,
+                           sw_if_index=0xffffffff,
+                           epg_id=0xffffffff,
+                           is_ip6=False):
+        """ GBP Subnet Add/Del """
+        return self.api(self.papi.gbp_subnet_add_del,
+                        {'is_add': is_add,
+                         'subnet': {
+                             'is_internal': is_internal,
+                             'is_ip6': is_ip6,
+                             'sw_if_index': sw_if_index,
+                             'epg_id': epg_id,
+                             'address': addr,
+                             'address_length': addr_len,
+                             'table_id': table_id}})
+
+    def gbp_subnet_dump(self):
+        """ GBP Subnet Dump """
+        return self.api(self.papi.gbp_subnet_dump, {})
+
     def gbp_contract_add_del(self, is_add, src_epg, dst_epg, acl_index):
         """ GBP contract Add/Del """
         return self.api(self.papi.gbp_contract_add_del,
@@ -3291,3 +3384,180 @@ class VppPapiProvider(object):
                         {'sw_if_index': sw_if_index,
                          'input_source': input_source,
                          'enable': enable})
+
+    def igmp_listen(self, enable, sw_if_index, saddr, gaddr):
+        """ Listen for new (S,G) on specified interface
+
+        :param enable: add/del
+        :param sw_if_index: interface sw index
+        :param saddr: source ip4 addr
+        :param gaddr: group ip4 addr
+        """
+        return self.api(self.papi.igmp_listen,
+                        {'enable': enable,
+                         'sw_if_index': sw_if_index,
+                         'saddr': saddr,
+                         'gaddr': gaddr})
+
+    def igmp_dump(self, sw_if_index=None):
+        """ Dump all (S,G) interface configurations """
+        if sw_if_index is None:
+            dump_all = 1
+            sw_if_index = 0
+        else:
+            dump_all = 0
+        return self.api(self.papi.igmp_dump, {'sw_if_index': sw_if_index,
+                                              'dump_all': dump_all})
+
+    def igmp_clear_interface(self, sw_if_index):
+        """ Remove all (S,G)s from specified interface
+            doesn't send IGMP report!
+        """
+        return self.api(
+            self.papi.igmp_clear_interface, {
+                'sw_if_index': sw_if_index})
+
+    def want_igmp_events(self, enable=1):
+        return self.api(self.papi.want_igmp_events, {'enable': enable,
+                                                     'pid': os.getpid()})
+
+    def bond_create(
+            self,
+            mode,
+            lb,
+            use_custom_mac,
+            mac_address=''):
+        """
+        :param mode: mode
+        :param lb: load balance
+        :param use_custom_mac: use custom mac
+        :param mac_address: mac address
+        """
+        return self.api(
+            self.papi.bond_create,
+            {'mode': mode,
+             'lb': lb,
+             'use_custom_mac': use_custom_mac,
+             'mac_address': mac_address
+             })
+
+    def bond_delete(
+            self,
+            sw_if_index):
+        """
+        :param sw_if_index: interface the operation is applied to
+        """
+        return self.api(self.papi.bond_delete,
+                        {'sw_if_index': sw_if_index})
+
+    def bond_enslave(
+            self,
+            sw_if_index,
+            bond_sw_if_index,
+            is_passive,
+            is_long_timeout):
+        """
+        :param sw_if_index: slave sw_if_index
+        :param bond_sw_if_index: bond sw_if_index
+        :param is_passive: is passive lacp speaker
+        :param is_long_time: 90 seconds timeout instead of 3 seconds timeout
+        """
+        return self.api(
+            self.papi.bond_enslave,
+            {'sw_if_index': sw_if_index,
+             'bond_sw_if_index': bond_sw_if_index,
+             'is_passive': is_passive,
+             'is_long_timeout': is_long_timeout
+             })
+
+    def bond_detach_slave(
+            self,
+            sw_if_index):
+        """
+        :param sw_if_index: slave interface the operation is applied to
+        """
+        return self.api(self.papi.bond_detach_slave,
+                        {'sw_if_index': sw_if_index})
+
+    def sw_interface_slave_dump(
+            self,
+            sw_if_index):
+        """
+        :param sw_if_index: bond sw_if_index
+        """
+        return self.api(self.papi.sw_interface_slave_dump,
+                        {'sw_if_index': sw_if_index})
+
+    def sw_interface_bond_dump(
+            self):
+        """
+
+        """
+        return self.api(self.papi.sw_interface_bond_dump,
+                        {})
+
+    def create_vhost_user_if(
+            self,
+            is_server,
+            sock_filename,
+            renumber,
+            custom_dev_instance,
+            use_custom_mac,
+            mac_address,
+            tag=''):
+        """
+        :param is_server: is server
+        :param sock_filename: socket name
+        :param renumber: renumber
+        :param custom_dev_instance: custom dev instance
+        :param use_custom_mac: use custom mac
+        :param mac_address: mac address
+        :param tag: tag (default ''
+        """
+        return self.api(
+            self.papi.create_vhost_user_if,
+            {'is_server': is_server,
+             'sock_filename': sock_filename,
+             'renumber': renumber,
+             'custom_dev_instance': custom_dev_instance,
+             'use_custom_mac': use_custom_mac,
+             'mac_address': mac_address,
+             'tag': tag
+             })
+
+    def delete_vhost_user_if(
+            self,
+            sw_if_index):
+        """
+        :param sw_if_index: interface the operation is applied to
+        """
+        return self.api(self.papi.delete_vhost_user_if,
+                        {'sw_if_index': sw_if_index, })
+
+    def sw_interface_vhost_user_dump(
+            self):
+        """
+
+        """
+        return self.api(self.papi.sw_interface_vhost_user_dump,
+                        {})
+
+    def abf_policy_add_del(self, is_add, policy):
+        return self.api(
+            self.papi.abf_policy_add_del,
+            {'is_add': is_add,
+             'policy': policy})
+
+    def abf_itf_attach_add_del(self, is_add, attach):
+        return self.api(
+            self.papi.abf_itf_attach_add_del,
+            {'is_add': is_add,
+             'attach': attach})
+
+    def abf_policy_dump(self):
+        return self.api(
+            self.papi.abf_policy_dump, {})
+
+    def abf_itf_attach_dump(self):
+        return self.api(
+            self.papi.abf_itf_attach_dump, {})