3 * Copyright (c) 2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 vpp = require "vpp-lapi"
21 root_dir = "/home/ubuntu/vpp"
22 pneum_path = root_dir .. "/build-root/install-vpp_debug-native/vpp-api/lib64/libpneum.so"
24 vpp:init({ pneum_path = pneum_path })
26 vpp:consume_api(root_dir .. "/build-root/install-vpp_debug-native/vlib-api/vlibmemory/memclnt.api")
27 vpp:consume_api(root_dir .. "/build-root/install-vpp_debug-native/vpp/vpp-api/vpe.api")
29 vpp:consume_api(root_dir .. "/plugins/acl-plugin/acl/acl.api", "acl")
32 reply = vpp:api_call("show_version")
33 print("Version: ", reply[1].version)
34 print(vpp.hex_dump(reply[1].version))
35 print(vpp.dump(reply))
38 reply = vpp:api_call("acl_del", { context = 42, acl_index = 230 })
39 print(vpp.dump(reply))
42 reply = vpp:api_call("acl_del", { context = 42, acl_index = 8 })
43 print(vpp.dump(reply))
46 reply = vpp:api_call("acl_del", { context = 42, acl_index = 15 })
47 print(vpp.dump(reply))
50 reply = vpp:api_call("acl_add", { context = 42, count = 2, r = { { is_permit = 1, is_ipv6 = 1 }, { is_permit = 0, is_ipv6 = 1 } } })
51 print(vpp.dump(reply))
53 interface_acl_in = reply[1].acl_index
55 reply = vpp:api_call("acl_add", { context = 42, count = 3, r = { { is_permit = 1, is_ipv6 = 1 }, { is_permit = 0, is_ipv6 = 1 }, { is_permit = 1, is_ipv6 = 0 } } })
56 print(vpp.dump(reply))
58 interface_acl_out = reply[1].acl_index
61 reply = vpp:api_call("acl_interface_add_del", { context = 42, sw_if_index = 0, is_add = 1, is_input = 1, acl_index = interface_acl_in })
62 print(vpp.dump(reply))
64 reply = vpp:api_call("acl_interface_add_del", { context = 42, sw_if_index = 0, is_add = 1, is_input = 1, acl_index = interface_acl_in })
65 print(vpp.dump(reply))
68 reply = vpp:api_call("acl_interface_add_del", { context = 42, sw_if_index = 0, is_add = 1, is_input = 0, acl_index = interface_acl_out })
69 print(vpp.dump(reply))
71 reply = vpp:api_call("acl_interface_add_del", { context = 42, sw_if_index = 0, is_add = 1, is_input = 0, acl_index = interface_acl_out })
72 print(vpp.dump(reply))
75 reply = vpp:api_call("acl_add", { context = 42, count = 0 })
76 print(vpp.dump(reply))
79 acl_index_to_delete = reply[1].acl_index
80 print("Deleting " .. tostring(acl_index_to_delete))
81 reply = vpp:api_call("acl_del", { context = 42, acl_index = acl_index_to_delete })
82 print(vpp.dump(reply))
85 reply = vpp:api_call("acl_dump", { context = 42, sw_if_index = 0})
86 for ri, rv in ipairs(reply) do
87 print("Reply message #" .. tostring(ri))
89 for ai, av in ipairs(rv.r) do
90 print("ACL rule #" .. tostring(ai) .. " : " .. vpp.dump(av))
96 reply = vpp:api_call("acl_del", { context = 42, acl_index = interface_acl_out })
97 print(vpp.dump(reply))
99 reply = vpp:api_call("acl_del", { context = 42, acl_index = interface_acl_in })
100 print(vpp.dump(reply))
103 reply = vpp:api_call("acl_dump", { context = 42, sw_if_index = 0})
104 print(vpp.dump(reply))