2 * 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.
17 package io.fd.vpp.jvpp.ioampot.examples;
19 import io.fd.vpp.jvpp.JVpp;
20 import io.fd.vpp.jvpp.JVppRegistry;
21 import io.fd.vpp.jvpp.JVppRegistryImpl;
22 import io.fd.vpp.jvpp.VppCallbackException;
23 import io.fd.vpp.jvpp.ioampot.JVppIoampotImpl;
24 import io.fd.vpp.jvpp.ioampot.callback.PotProfileAddReplyCallback;
25 import io.fd.vpp.jvpp.ioampot.dto.PotProfileAdd;
26 import io.fd.vpp.jvpp.ioampot.dto.PotProfileAddReply;
27 import java.nio.charset.StandardCharsets;
29 public class IoamPotApiExample {
31 static class IoamPotTestCallback implements PotProfileAddReplyCallback {
34 public void onPotProfileAddReply(final PotProfileAddReply reply) {
35 System.out.printf("Received PotProfileAddReply reply: context=%d%n",
40 public void onError(VppCallbackException ex) {
41 System.out.printf("Received onError exception: call=%s, context=%d, retval=%d%n", ex.getMethodName(),
42 ex.getCtxId(), ex.getErrorCode());
46 public static void main(String[] args) throws Exception {
50 private static void ioamPotTestApi() throws Exception {
51 System.out.println("Testing Java API for ioam pot plugin");
52 try (final JVppRegistry registry = new JVppRegistryImpl("ioamPotApiExample");
53 final JVpp jvpp = new JVppIoampotImpl()) {
54 registry.register(jvpp, new IoamPotTestCallback());
56 System.out.println("Sending ioam pot profile add request...");
57 PotProfileAdd request = new PotProfileAdd();
59 request.validator = 4;
60 request.secretKey = 1;
61 request.secretShare = 2;
65 request.polynomialPublic = 1234;
66 request.listNameLen = (byte)"test pot profile".getBytes(StandardCharsets.UTF_8).length;
67 request.listName = "test pot profile".getBytes(StandardCharsets.UTF_8);
68 final int result = jvpp.send(request);
69 System.out.printf("PotProfileAdd send result = %d%n", result);
73 System.out.println("Disconnecting...");