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.*;
18 public class demo extends vppApi {
19 public static void main (String[] args) throws Exception {
20 vppApi api = new vppApi ();
25 int rv, errors, saved_error;
28 rv = api.clientConnect ("JavaTest");
30 System.out.printf ("Connected OK...");
33 System.out.printf ("clientConnect returned %d\n", rv);
39 intlist = api.getInterfaceList ("");
40 System.out.printf ("Unfiltered interface list:\n%s", intlist);
44 contexts = new int[6];
46 for (i = 0; i < 6; i++)
48 contexts[i] = api.swInterfaceSetFlags
49 (5 + i /* sw_if_index */,
50 (byte)1 /* admin_up */,
51 (byte)1 /* link_up (ignored) */,
52 (byte)0 /* deleted */);
55 /* Thread.sleep (1); */
59 for (i = 0; i < 6; i ++)
63 rv = api.getRetval (contexts[i], 1 /* release */);
77 System.out.printf ("intfcs up...\n");
80 ("%d errors, last error %d...\n", errors, saved_error);
86 contexts = new int [limit];
87 byte [] address = new byte [4];
88 byte [] zeros = new byte [4];
90 address[0] = (byte)192;
91 address[1] = (byte)168;
95 for (i = 0; i < 4; i++)
98 System.out.printf ("start %d route ops ...", limit);
100 before = System.currentTimeMillis();
102 for (i = 0; i < limit; i++) {
103 contexts[i] = api.ipAddDelRoute
104 (0 /* int nextHopSwIfIndex */,
106 0 /* int lookupInVrf */,
107 0 /* int resolveAttempts */,
108 0 /* int classifyTableIndex */,
109 (byte)0 /* byte createVrfIfNeeded */,
110 (byte)0 /* byte resolveIfNeeded */,
111 (byte)1 /* byte isAdd */,
112 (byte)1 /* byte isDrop */,
113 (byte)0 /* byte isIpv6 */,
114 (byte)0 /* byte isLocal */,
115 (byte)0 /* byte isClassify */,
116 (byte)0 /* byte isMultipath */,
117 (byte)0 /* byte notLast */,
118 (byte)0 /* byte nextHopWeight */,
119 (byte)32 /* byte dstAddressLength */,
142 for (i = 0; i < limit; i++)
146 rv = api.getRetval (contexts[i], 1 /* release */);
159 after = System.currentTimeMillis();
163 System.out.printf ("done %d route ops (all OK)...\n", limit);
166 ("%d errors, last error %d...\n", errors, saved_error);
168 System.out.printf ("result in %d trips\n", trips);
170 System.out.printf ("%d routes in %d milliseconds, %d routes/msec\n",
171 limit, after - before,
172 limit / (after - before));
174 api.clientDisconnect();
175 System.out.printf ("Done...\n");