- return self.api(self.papi.sw_interface_add_del_address,
- {'sw_if_index': sw_if_index,
- 'is_add': is_add,
- 'is_ipv6': is_ipv6,
- 'del_all': del_all,
- 'address_length': addr_len,
- 'address': addr})
-
- def sw_interface_set_unnumbered(self, sw_if_index, ip_sw_if_index,
- is_add=1):
- """ Set the Interface to be unnumbered
-
- :param is_add: (Default value = 1)
- :param sw_if_index - interface That will be unnumbered
- :param ip_sw_if_index - interface with an IP addres
-
- """
- return self.api(self.papi.sw_interface_set_unnumbered,
- {'sw_if_index': ip_sw_if_index,
- 'unnumbered_sw_if_index': sw_if_index,
- 'is_add': is_add})
-
- def sw_interface_enable_disable_mpls(self, sw_if_index,
- is_enable=1):
- """
- Enable/Disable MPLS on the interface
- :param sw_if_index:
- :param is_enable: (Default value = 1)
-
- """
- return self.api(self.papi.sw_interface_set_mpls_enable,
- {'sw_if_index': sw_if_index,
- 'enable': is_enable})
-
- def sw_interface_ra_suppress(self, sw_if_index, suppress=1):
- return self.api(self.papi.sw_interface_ip6nd_ra_config,
- {'sw_if_index': sw_if_index,
- 'suppress': suppress})
-
- def set_ip_flow_hash(self,
- table_id,
- src=1,
- dst=1,
- sport=1,
- dport=1,
- proto=1,
- reverse=0,
- is_ip6=0):
- return self.api(self.papi.set_ip_flow_hash,
- {'vrf_id': table_id,
- 'src': src,
- 'dst': dst,
- 'dport': dport,
- 'sport': sport,
- 'proto': proto,
- 'reverse': reverse,
- 'is_ipv6': is_ip6})
-
- def ip6_nd_proxy(self, address, sw_if_index, is_del=0):
- return self.api(self.papi.ip6nd_proxy_add_del,
- {'address': address,
- 'sw_if_index': sw_if_index,
- 'is_del': is_del})
-
- def ip6_sw_interface_ra_config(self, sw_if_index,
- no,
- suppress,
- send_unicast):
- return self.api(self.papi.sw_interface_ip6nd_ra_config,
- {'sw_if_index': sw_if_index,
- 'is_no': no,
- 'suppress': suppress,
- 'send_unicast': send_unicast})
-
- def ip6_sw_interface_ra_prefix(self,
- sw_if_index,
- address,
- address_length,
- use_default=0,
- no_advertise=0,
- off_link=0,
- no_autoconfig=0,
- no_onlink=0,
- is_no=0,
- val_lifetime=0xffffffff,
- pref_lifetime=0xffffffff):
- return self.api(self.papi.sw_interface_ip6nd_ra_prefix,
- {'sw_if_index': sw_if_index,
- 'address': address,
- 'address_length': address_length,
- 'use_default': use_default,
- 'no_advertise': no_advertise,
- 'off_link': off_link,
- 'no_autoconfig': no_autoconfig,
- 'no_onlink': no_onlink,
- 'is_no': is_no,
- 'val_lifetime': val_lifetime,
- 'pref_lifetime': pref_lifetime})
-
- def ip6_sw_interface_enable_disable(self, sw_if_index, enable):
- """
- Enable/Disable An interface for IPv6
- """
- return self.api(self.papi.sw_interface_ip6_enable_disable,
- {'sw_if_index': sw_if_index,
- 'enable': enable})
-
- def vxlan_add_del_tunnel(
- self,
- src_addr,
- dst_addr,
- mcast_sw_if_index=0xFFFFFFFF,
- is_add=1,
- is_ipv6=0,
- encap_vrf_id=0,
- decap_next_index=0xFFFFFFFF,
- vni=0):
- """
-
- :param dst_addr:
- :param src_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.vxlan_add_del_tunnel,
- {'is_add': is_add,
- 'is_ipv6': is_ipv6,
- 'src_address': src_addr,
- 'dst_address': dst_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.
-
- :param int bd_id: Bridge domain index.
- :param int flood: Enable/disable bcast/mcast flooding in the BD.
- (Default value = 1)
- :param int uu_flood: Enable/disable unknown unicast flood in the BD.
- (Default value = 1)
- :param int forward: Enable/disable forwarding on all interfaces in
- the BD. (Default value = 1)
- :param int learn: Enable/disable learning on all interfaces in the BD.
- (Default value = 1)
- :param int arp_term: Enable/disable arp termination in the BD.
- (Default value = 1)
- :param int is_add: Add or delete flag. (Default value = 1)
- """
- return self.api(self.papi.bridge_domain_add_del,
- {'bd_id': bd_id,
- 'flood': flood,
- 'uu_flood': uu_flood,
- 'forward': forward,
- 'learn': learn,
- '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.
-
- :param str mac: MAC address to create FIB entry for.
- :param int bd_id: Bridge domain index.
- :param int sw_if_index: Software interface index of the interface.
- :param int is_add: Add or delete flag. (Default value = 1)
- :param int static_mac: Set to 1 to create static MAC entry.
- (Default value = 0)
- :param int filter_mac: Set to 1 to drop packet that's source or
- destination MAC address contains defined MAC address.
- (Default value = 0)
- :param int bvi_mac: Set to 1 to create entry that points to BVI
- interface. (Default value = 0)
- """
- return self.api(self.papi.l2fib_add_del,
- {'mac': self._convert_mac(mac),
- 'bd_id': bd_id,
- 'sw_if_index': sw_if_index,
- 'is_add': is_add,
- 'static_mac': static_mac,
- '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.
-
- :param int sw_if_index: Software interface index of the interface.
- :param int bd_id: Bridge domain index.
- :param int shg: Split-horizon group index. (Default value = 0)
- :param int bvi: Set interface as a bridge group virtual interface.
- (Default value = 0)
- :param int enable: Add or remove interface. (Default value = 1)
- """
- return self.api(self.papi.sw_interface_set_l2_bridge,
- {'rx_sw_if_index': sw_if_index,
- 'bd_id': bd_id,
- 'shg': shg,
- 'bvi': bvi,
- 'enable': enable})
-
- def bridge_flags(self, bd_id, is_set, feature_bitmap):
- """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.
- :param int feature_bitmap: Bitmap value of the feature to be set:
- - learn (1 << 0),
- - forward (1 << 1),
- - flood (1 << 2),
- - uu-flood (1 << 3) or
- - arp-term (1 << 4).
- """
- return self.api(self.papi.bridge_flags,
- {'bd_id': bd_id,
- 'is_set': is_set,
- 'feature_bitmap': feature_bitmap})
-
- def bridge_domain_dump(self, bd_id=0):
- """
-
- :param int bd_id: Bridge domain ID. (Default value = 0 => dump of all
- existing bridge domains returned)
- :return: Dictionary of bridge domain(s) data.
- """
- return self.api(self.papi.bridge_domain_dump,
- {'bd_id': bd_id})
-
- def sw_interface_set_l2_xconnect(self, rx_sw_if_index, tx_sw_if_index,
- enable):
- """Create or delete unidirectional cross-connect from Tx interface to
- Rx interface.
-
- :param int rx_sw_if_index: Software interface index of Rx interface.
- :param int tx_sw_if_index: Software interface index of Tx interface.
- :param int enable: Create cross-connect if equal to 1, delete
- cross-connect if equal to 0.
-
- """
- return self.api(self.papi.sw_interface_set_l2_xconnect,
- {'rx_sw_if_index': rx_sw_if_index,
- 'tx_sw_if_index': tx_sw_if_index,
- 'enable': enable})
-
- def sw_interface_set_l2_tag_rewrite(
- self,
- sw_if_index,
- vtr_oper,
- push=0,
- tag1=0,
- tag2=0):
- """L2 interface vlan tag rewrite configure request
- :param client_index - opaque cookie to identify the sender
- :param context - sender context, to match reply w/ request
- :param sw_if_index - interface the operation is applied to
- :param vtr_op - Choose from l2_vtr_op_t enum values
- :param push_dot1q - first pushed flag dot1q id set, else dot1ad
- :param tag1 - Needed for any push or translate vtr op
- :param tag2 - Needed for any push 2 or translate x-2 vtr ops
-
- """
- return self.api(self.papi.l2_interface_vlan_tag_rewrite,
- {'sw_if_index': sw_if_index,
- 'vtr_op': vtr_oper,
- 'push_dot1q': push,
- 'tag1': tag1,
- 'tag2': tag2})
-
- def sw_interface_set_flags(self, sw_if_index, admin_up_down):
- """