blob: ca01f18d71da0c289411eb7d0a7a6447b253f41e [file] [log] [blame]
Andrew Yourtchenkofa1456a2016-11-11 16:32:52 +00001--[[
2/*
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:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16]]
17
18
19vpp = require "vpp-lapi"
20
21root_dir = "/home/ubuntu/vpp"
22pneum_path = root_dir .. "/build-root/install-vpp_debug-native/vpp-api/lib64/libpneum.so"
23
24vpp:init({ pneum_path = pneum_path })
25
26vpp:consume_api(root_dir .. "/build-root/install-vpp_debug-native/vlib-api/vlibmemory/memclnt.api")
27vpp:consume_api(root_dir .. "/build-root/install-vpp_debug-native/vpp/vpp-api/vpe.api")
28vpp:connect("aytest")
29vpp:consume_api(root_dir .. "/plugins/acl-plugin/acl/acl.api", "acl")
30
31-- api calls
32reply = vpp:api_call("show_version")
33print("Version: ", reply[1].version)
34print(vpp.hex_dump(reply[1].version))
35print(vpp.dump(reply))
36print("---")
37
38reply = vpp:api_call("acl_del", { context = 42, acl_index = 230 })
39print(vpp.dump(reply))
40print("---")
41
42reply = vpp:api_call("acl_del", { context = 42, acl_index = 8 })
43print(vpp.dump(reply))
44print("---")
45
46reply = vpp:api_call("acl_del", { context = 42, acl_index = 15 })
47print(vpp.dump(reply))
48print("---")
49
50reply = vpp:api_call("acl_add", { context = 42, count = 2, r = { { is_permit = 1, is_ipv6 = 1 }, { is_permit = 0, is_ipv6 = 1 } } })
51print(vpp.dump(reply))
52print("---")
53interface_acl_in = reply[1].acl_index
54
55reply = 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 } } })
56print(vpp.dump(reply))
57print("---")
58interface_acl_out = reply[1].acl_index
59
60
61reply = vpp:api_call("acl_interface_add_del", { context = 42, sw_if_index = 0, is_add = 1, is_input = 1, acl_index = interface_acl_in })
62print(vpp.dump(reply))
63print("---")
64reply = vpp:api_call("acl_interface_add_del", { context = 42, sw_if_index = 0, is_add = 1, is_input = 1, acl_index = interface_acl_in })
65print(vpp.dump(reply))
66print("---")
67
68reply = vpp:api_call("acl_interface_add_del", { context = 42, sw_if_index = 0, is_add = 1, is_input = 0, acl_index = interface_acl_out })
69print(vpp.dump(reply))
70print("---")
71reply = vpp:api_call("acl_interface_add_del", { context = 42, sw_if_index = 0, is_add = 1, is_input = 0, acl_index = interface_acl_out })
72print(vpp.dump(reply))
73print("---")
74
75reply = vpp:api_call("acl_add", { context = 42, count = 0 })
76print(vpp.dump(reply))
77print("---")
78
79acl_index_to_delete = reply[1].acl_index
80print("Deleting " .. tostring(acl_index_to_delete))
81reply = vpp:api_call("acl_del", { context = 42, acl_index = acl_index_to_delete })
82print(vpp.dump(reply))
83print("---")
84
85reply = vpp:api_call("acl_dump", { context = 42, sw_if_index = 0})
86for ri, rv in ipairs(reply) do
87 print("Reply message #" .. tostring(ri))
88 print(vpp.dump(rv))
89 for ai, av in ipairs(rv.r) do
90 print("ACL rule #" .. tostring(ai) .. " : " .. vpp.dump(av))
91 end
92
93end
94print("---")
95
96reply = vpp:api_call("acl_del", { context = 42, acl_index = interface_acl_out })
97print(vpp.dump(reply))
98print("---")
99reply = vpp:api_call("acl_del", { context = 42, acl_index = interface_acl_in })
100print(vpp.dump(reply))
101print("---")
102
103reply = vpp:api_call("acl_dump", { context = 42, sw_if_index = 0})
104print(vpp.dump(reply))
105print("---")
106
107
108vpp:disconnect()
109
110