Fix "Old Style VLA" build warnings
[vpp.git] / src / vpp-api / lua / examples / example-classifier.lua
1 --[[
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
19 local vpp = require "vpp-lapi"
20 local bit = require("bit")
21
22 root_dir = "/home/ubuntu/vpp"
23 pneum_path = root_dir .. "/build-root/install-vpp_debug-native/vpp-api/lib64/libpneum.so"
24
25
26 vpp:init({ pneum_path = pneum_path })
27
28 vpp:json_api(root_dir .. "/build-root/install-vpp_debug-native/vpp/vpp-api/vpe.api.json")
29
30 vpp:connect("aytest")
31
32 -- api calls
33
34 print("Calling API to add a new classifier table")
35 reply = vpp:api_call("classify_add_del_table", {
36   context = 43,
37   memory_size = bit.lshift(2, 20),
38   client_index = 42,
39   is_add = 1,
40   nbuckets = 32,
41   skip_n_vectors = 0,
42   match_n_vectors = 1,
43   mask_len = 16,
44   mask = "\255\255\255\255\255\255\255\255" .. "\255\255\255\255\255\255\255\255"
45 })
46 print(vpp.dump(reply))
47 print("---")
48
49
50 vpp:disconnect()
51
52