2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 import org.openvpp.vppjapi.*;
19 public static void main (String[] args) throws Exception {
20 vppApi api = new vppApi ("JavaTest");
21 System.out.printf ("Connected OK...");
27 int rv, errors, saved_error;
32 intlist = api.getInterfaceList ("");
33 System.out.printf ("Unfiltered interface list:\n%s", intlist);
37 contexts = new int[6];
39 for (i = 0; i < 6; i++)
41 contexts[i] = api.swInterfaceSetFlags
42 (5 + i /* sw_if_index */,
43 (byte)1 /* admin_up */,
44 (byte)1 /* link_up (ignored) */,
45 (byte)0 /* deleted */);
48 /* Thread.sleep (1); */
52 for (i = 0; i < 6; i ++)
56 rv = api.getRetval (contexts[i], 1 /* release */);
70 System.out.printf ("intfcs up...\n");
73 ("%d errors, last error %d...\n", errors, saved_error);
79 contexts = new int [limit];
80 byte [] address = new byte [4];
81 byte [] zeros = new byte [4];
83 address[0] = (byte)192;
84 address[1] = (byte)168;
88 for (i = 0; i < 4; i++)
91 System.out.printf ("start %d route ops ...", limit);
93 before = System.currentTimeMillis();
95 for (i = 0; i < limit; i++) {
96 contexts[i] = api.ipAddDelRoute
97 (0 /* int nextHopSwIfIndex */,
99 0 /* int lookupInVrf */,
100 0 /* int resolveAttempts */,
101 0 /* int classifyTableIndex */,
102 (byte)0 /* byte createVrfIfNeeded */,
103 (byte)0 /* byte resolveIfNeeded */,
104 (byte)1 /* byte isAdd */,
105 (byte)1 /* byte isDrop */,
106 (byte)0 /* byte isIpv6 */,
107 (byte)0 /* byte isLocal */,
108 (byte)0 /* byte isClassify */,
109 (byte)0 /* byte isMultipath */,
110 (byte)0 /* byte notLast */,
111 (byte)0 /* byte nextHopWeight */,
112 (byte)32 /* byte dstAddressLength */,
135 for (i = 0; i < limit; i++)
139 rv = api.getRetval (contexts[i], 1 /* release */);
152 after = System.currentTimeMillis();
156 System.out.printf ("done %d route ops (all OK)...\n", limit);
159 ("%d errors, last error %d...\n", errors, saved_error);
161 System.out.printf ("result in %d trips\n", trips);
163 System.out.printf ("%d routes in %d milliseconds, %d routes/msec\n",
164 limit, after - before,
165 limit / (after - before));
168 System.out.printf ("Done...\n");