1 # Copyright (c) 2016 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 """Proxy ARP library"""
16 from resources.libraries.python.InterfaceUtil import InterfaceUtil
17 from resources.libraries.python.PapiExecutor import PapiExecutor
18 from resources.libraries.python.VatExecutor import VatTerminal
21 class ProxyArp(object):
22 """Proxy ARP utilities."""
25 def vpp_add_proxy_arp(node, lo_ip4_addr, hi_ip4_addr):
26 """Enable proxy ARP for a range of IP addresses.
28 :param node: VPP node to enable proxy ARP.
29 :param lo_ip4_addr: The lower limit of the IP addresses.
30 :param hi_ip4_addr: The upper limit of the IP addresses.
32 :type lo_ip4_addr: str
33 :type hi_ip4_addr: str
35 with VatTerminal(node) as vat:
36 vat.vat_terminal_exec_cmd_from_template("add_proxy_arp.vat",
37 lo_ip4_addr=lo_ip4_addr,
38 hi_ip4_addr=hi_ip4_addr)
41 def vpp_proxy_arp_interface_enable(node, interface):
42 """Enable proxy ARP on interface.
44 :param node: VPP node to enable proxy ARP on interface.
45 :param interface: Interface to enable proxy ARP.
47 :type interface: str or int
50 cmd = 'proxy_arp_intfc_enable_disable'
52 sw_if_index=InterfaceUtil.get_interface_index(node, interface),
54 err_msg = 'Failed to enable proxy ARP on interface {ifc}'.format(
56 with PapiExecutor(node) as papi_exec:
57 papi_exec.add(cmd, **args).get_replies(err_msg). \
58 verify_reply(err_msg=err_msg)