aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-07-20 14:53:48 +0200
committerDamjan Marion <dmarion.lists@gmail.com>2016-07-21 09:30:48 +0000
commit948b95a9a08d38e7f74a160c11193f73a90e98c9 (patch)
treed73867ac2357dba4f9b5b12a69e4041b9d5a3df6
parent84bde8dc132f9be5cd208cf1ff446f366896a103 (diff)
VPP-123: remove japi (the old Java API)
MANUAL_JAVA flag (used only by the japi) was also removed. Change-Id: Ied21521b2410af1c357afb04cbf9e849632ddc5f Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
-rw-r--r--build-data/platforms/arm32.mk2
-rw-r--r--vpp-api/java/Makefile.am73
-rw-r--r--vpp-api/java/configure.ac2
-rw-r--r--vpp-api/java/japi/org/openvpp/vppjapi/vppApiCallbacks.java35
-rw-r--r--vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java30
-rw-r--r--vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java21
-rw-r--r--vpp-api/java/japi/org/openvpp/vppjapi/vppConn.java237
-rw-r--r--vpp-api/java/japi/org/openvpp/vppjapi/vppIPv4Address.java26
-rw-r--r--vpp-api/java/japi/org/openvpp/vppjapi/vppIPv6Address.java27
-rw-r--r--vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceCounters.java77
-rw-r--r--vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceDetails.java71
-rw-r--r--vpp-api/java/japi/org/openvpp/vppjapi/vppL2Fib.java35
-rw-r--r--vpp-api/java/japi/org/openvpp/vppjapi/vppVersion.java31
-rw-r--r--vpp-api/java/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java35
-rw-r--r--vpp-api/java/japi/test/demo.java170
-rw-r--r--vpp-api/java/japi/test/vppApi.java52
-rw-r--r--vpp-api/java/japi/vppjni.c1954
-rw-r--r--vpp-api/java/japi/vppjni.h309
-rw-r--r--vpp-api/java/japi/vppjni_bridge_domain.h510
-rw-r--r--vpp-api/java/japi/vppjni_env.c111
-rw-r--r--vpp-api/java/japi/vppjni_env.h118
-rw-r--r--vpp/vpp-api/vpe.api92
-rw-r--r--vppapigen/gram.y3
-rw-r--r--vppapigen/lex.c79
-rw-r--r--vppapigen/node.c756
-rw-r--r--vppapigen/node.h9
26 files changed, 60 insertions, 4805 deletions
diff --git a/build-data/platforms/arm32.mk b/build-data/platforms/arm32.mk
index ab8d5864..7b80061b 100644
--- a/build-data/platforms/arm32.mk
+++ b/build-data/platforms/arm32.mk
@@ -19,7 +19,7 @@ arm32_uses_dpdk = yes
arm32_uses_openssl = no
arm32_root_packages = vpp vlib vlib-api vnet svm vpp-api-test \
- vpp-japi gmod
+ jvpp gmod
vlib_configure_args_arm32 = --with-pre-data=128
vnet_configure_args_arm32 = --with-dpdk --without-ipsec --without-ipv6sr
diff --git a/vpp-api/java/Makefile.am b/vpp-api/java/Makefile.am
index c06caf54..d3f3c4f4 100644
--- a/vpp-api/java/Makefile.am
+++ b/vpp-api/java/Makefile.am
@@ -21,80 +21,11 @@ bin_PROGRAMS =
CLEANFILES =
lib_LTLIBRARIES =
-nobase_include_HEADERS = \
- japi/org_openvpp_vppjapi_vppApi.h \
- japi/org_openvpp_vppjapi_vppConn.h
-
-lib_LTLIBRARIES += libvppjni.la
-
-libvppjni_la_SOURCES = japi/vppjni.c japi/vppapi.c japi/vppjni_env.h japi/vppjni_env.c
-libvppjni_la_LIBADD = -lvlibmemoryclient -lvlibapi -lsvm -lvppinfra \
- -lpthread -lm -lrt
-libvppjni_la_LDFLAGS = -module
-libvppjni_la_CPPFLAGS = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
-
-jarfile = vppjapi-$(PACKAGE_VERSION).jar
-packagedir = org/openvpp/vppjapi
-JAVAROOT = .
-
-$(jarfile): libvppjni.la
- cd .libs ; $(JAR) cf $(JARFLAGS) ../$@ libvppjni.so.0.0.0 ../$(packagedir)/*.class ; cd ..
-
-BUILT_SOURCES += japi/org_openvpp_vppjapi_vppConn.h japi/vppapi.c
-
-japi/org_openvpp_vppjapi_vppConn.h: \
- japi/org/openvpp/vppjapi/vppVersion.java \
- japi/org/openvpp/vppjapi/vppInterfaceDetails.java \
- japi/org/openvpp/vppjapi/vppInterfaceCounters.java \
- japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java \
- japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java \
- japi/org/openvpp/vppjapi/vppL2Fib.java \
- japi/org/openvpp/vppjapi/vppIPv4Address.java \
- japi/org/openvpp/vppjapi/vppIPv6Address.java \
- japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java \
- japi/org/openvpp/vppjapi/vppConn.java \
- japi/org/openvpp/vppjapi/vppApiCallbacks.java \
- ../../vpp/vpp-api/vpe.api.h
- $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppVersion.java ; \
- $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppVersion ; \
- $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppInterfaceDetails.java ; \
- $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppInterfaceDetails ; \
- $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppInterfaceCounters.java ; \
- $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppInterfaceCounters ; \
- $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java ; \
- $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppBridgeDomainInterfaceDetails ; \
- $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java ; \
- $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppBridgeDomainDetails ; \
- $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppL2Fib.java ; \
- $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppL2Fib ; \
- $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppIPv4Address.java ; \
- $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppIPv4Address ; \
- $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppIPv6Address.java ; \
- $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppIPv6Address ; \
- $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java ; \
- $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppVxlanTunnelDetails ; \
- $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppConn.java ; \
- $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppConn ;
-
-japi/vppapi.c: japi/org_openvpp_vppjapi_vppConn.h
- pushd .. ; dir=`pwd` ; popd ; \
- instdir=`echo $${dir} | sed -e 's:build-root/build:build-root/install:'` ; \
- vppapigen --input $${instdir}/../vpp/vpp-api/vpe.api --jni japi/vppapi.c --app vpe ; \
- vppapigen --input $${instdir}/../vpp/vpp-api/vpe.api --java japi/vppApi.java --app vpe ; \
- $(JAVAC) -classpath . -d . japi/vppApi.java ; \
- $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppApi ; \
- $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppApiCallbacks.java ; \
- $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppApiCallbacks ;
-
-demo = japi/test/demo.class
-$(demo): $(jarfile)
- $(JAVAC) -cp $(jarfile) -d $(JAVAROOT) @srcdir@/japi/test/demo.java
-
#
# jVpp binding
#
-nobase_include_HEADERS += \
+nobase_include_HEADERS = \
jvpp/org_openvpp_jvpp_VppJNIConnection.h
lib_LTLIBRARIES += libjvpp.la
@@ -138,4 +69,4 @@ jvpp/org_openvpp_jvpp_VppJNIConnection.h: $(prefix)/../vpp/vpp-api/vpe.api
$(jarfile_jvpp): libjvpp.la
cd .libs ; $(JAR) cf $(JARFLAGS) ../$@ libjvpp.so.0.0.0 ../$(packagedir_jvpp)/* ; cd ..;
-all-local: $(jarfile) $(jarfile_jvpp) $(demo)
+all-local: $(jarfile_jvpp)
diff --git a/vpp-api/java/configure.ac b/vpp-api/java/configure.ac
index 2b9f2587..d2033ee4 100644
--- a/vpp-api/java/configure.ac
+++ b/vpp-api/java/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT(vpp-japi, 16.09)
+AC_INIT(jvpp, 16.09)
LT_INIT
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppApiCallbacks.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppApiCallbacks.java
deleted file mode 100644
index df5b9533..00000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppApiCallbacks.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-import java.io.IOException;
-import org.openvpp.vppjapi.vppApi;
-
-public abstract class vppApiCallbacks extends vppApi {
- public vppApiCallbacks(String clientName) throws IOException {
- super(clientName);
- }
-/* Disabled!
- *
- * public abstract void interfaceDetails(
- int ifIndex, String interfaceName, int supIfIndex, byte[] physAddr,
- byte adminUp, byte linkUp, byte linkDuplex, byte linkSpeed,
- int subId, byte subDot1ad, byte subNumberOfTags, int subOuterVlanId, int subInnerVlanId,
- byte subExactMatch, byte subDefault, byte subOuterVlanIdAny, byte subInnerVlanIdAny,
- int vtrOp, int vtrPushDot1q, int vtrTag1, int vtrTag2);
- */
-
-}
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java
deleted file mode 100644
index db859a07..00000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-import org.openvpp.vppjapi.vppBridgeDomainInterfaceDetails;
-
-public final class vppBridgeDomainDetails {
- public String name;
- public int bdId;
- public boolean flood;
- public boolean uuFlood;
- public boolean forward;
- public boolean learn;
- public boolean arpTerm;
- public String bviInterfaceName;
- public vppBridgeDomainInterfaceDetails[] interfaces;
-}
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java
deleted file mode 100644
index ab99ee45..00000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-public final class vppBridgeDomainInterfaceDetails {
- public String interfaceName;
- public byte splitHorizonGroup;
-}
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppConn.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppConn.java
deleted file mode 100644
index 3e8c12a9..00000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppConn.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
-import java.nio.file.attribute.PosixFilePermission;
-import java.nio.file.attribute.PosixFilePermissions;
-import java.util.Set;
-
-import org.openvpp.vppjapi.vppVersion;
-import org.openvpp.vppjapi.vppInterfaceDetails;
-import org.openvpp.vppjapi.vppInterfaceCounters;
-import org.openvpp.vppjapi.vppBridgeDomainDetails;
-import org.openvpp.vppjapi.vppIPv4Address;
-import org.openvpp.vppjapi.vppIPv6Address;
-import org.openvpp.vppjapi.vppVxlanTunnelDetails;
-
-public class vppConn implements AutoCloseable {
- private static final String LIBNAME = "libvppjni.so.0.0.0";
-
- static {
- try {
- loadLibrary();
- } catch (Exception e) {
- System.out.printf("Can't find vpp jni library: %s\n", LIBNAME);
- throw new ExceptionInInitializerError(e);
- }
- }
-
- private static void loadStream(final InputStream is) throws IOException {
- final Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxr-x---");
- final Path p = Files.createTempFile(LIBNAME, null, PosixFilePermissions.asFileAttribute(perms));
- try {
- Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING);
-
- try {
- Runtime.getRuntime().load(p.toString());
- } catch (UnsatisfiedLinkError e) {
- throw new IOException(String.format("Failed to load library %s", p), e);
- }
- } finally {
- try {
- Files.deleteIfExists(p);
- } catch (IOException e) {
- }
- }
- }
-
- private static void loadLibrary() throws IOException {
- try (final InputStream is = vppConn.class.getResourceAsStream('/' + LIBNAME)) {
- if (is == null) {
- throw new IOException(String.format("Failed to open library resource %s",
- LIBNAME));
- }
- loadStream(is);
- }
- }
-
- private static vppConn currentConnection = null;
- private final String clientName;
- private volatile boolean disconnected = false;
-
- // Hidden on purpose to prevent external instantiation
- vppConn(final String clientName) throws IOException {
- this.clientName = clientName;
-
- synchronized (vppConn.class) {
- if (currentConnection != null) {
- throw new IOException("Already connected as " + currentConnection.clientName);
- }
-
- final int ret = clientConnect(clientName);
- if (ret != 0) {
- throw new IOException("Connection returned error " + ret);
- }
-
- currentConnection = this;
- }
- }
-
- @Override
- public synchronized final void close() {
- if (!disconnected) {
- disconnected = true;
-
- synchronized (vppConn.class) {
- clientDisconnect();
- currentConnection = null;
- }
- }
- }
-
- /**
- * Check if this instance is connected.
- *
- * @throws IllegalStateException if this instance was disconnected.
- */
- protected final void checkConnected() {
- if (disconnected) {
- throw new IllegalStateException("Disconnected client " + clientName);
- }
- }
-
- public final int getRetval(int context, int release) {
- checkConnected();
- return getRetval0(context, release);
- }
-
- public final String getInterfaceList (String nameFilter) {
- checkConnected();
- return getInterfaceList0(nameFilter);
- }
-
- public final int swIfIndexFromName (String interfaceName) {
- checkConnected();
- return swIfIndexFromName0(interfaceName);
- }
-
- public final String interfaceNameFromSwIfIndex (int swIfIndex) {
- checkConnected();
- return interfaceNameFromSwIfIndex0(swIfIndex);
- }
-
- public final void clearInterfaceTable () {
- checkConnected();
- clearInterfaceTable0();
- }
-
- public final vppInterfaceDetails[] swInterfaceDump (byte nameFilterValid, byte [] nameFilter) {
- checkConnected();
- return swInterfaceDump0(nameFilterValid, nameFilter);
- }
-
- public final int bridgeDomainIdFromName(String bridgeDomain) {
- checkConnected();
- return bridgeDomainIdFromName0(bridgeDomain);
- }
-
- public final int findOrAddBridgeDomainId(String bridgeDomain) {
- checkConnected();
- return findOrAddBridgeDomainId0(bridgeDomain);
- }
-
- public final vppVersion getVppVersion() {
- checkConnected();
- return getVppVersion0();
- }
-
- public final vppInterfaceCounters getInterfaceCounters(int swIfIndex) {
- checkConnected();
- return getInterfaceCounters0(swIfIndex);
- }
-
- public final int[] bridgeDomainDump(int bdId) {
- checkConnected();
- return bridgeDomainDump0(bdId);
- }
-
- public final vppBridgeDomainDetails getBridgeDomainDetails(int bdId) {
- checkConnected();
- return getBridgeDomainDetails0(bdId);
- }
-
- public final vppL2Fib[] l2FibTableDump(int bdId) {
- checkConnected();
- return l2FibTableDump0(bdId);
- }
-
- public final int bridgeDomainIdFromInterfaceName(String interfaceName) {
- checkConnected();
- return bridgeDomainIdFromInterfaceName0(interfaceName);
- }
-
- public final vppIPv4Address[] ipv4AddressDump(String interfaceName) {
- checkConnected();
- return ipv4AddressDump0(interfaceName);
- }
-
- public final vppIPv6Address[] ipv6AddressDump(String interfaceName) {
- checkConnected();
- return ipv6AddressDump0(interfaceName);
- }
-
- public final vppVxlanTunnelDetails[] vxlanTunnelDump(int swIfIndex) {
- checkConnected();
- return vxlanTunnelDump0(swIfIndex);
- }
-
- public final int setInterfaceDescription(String ifName, String ifDesc) {
- checkConnected();
- return setInterfaceDescription0(ifName, ifDesc);
- }
-
- public final String getInterfaceDescription(String ifName) {
- checkConnected();
- return getInterfaceDescription0(ifName);
- }
-
- private static native int clientConnect(String clientName);
- private static native void clientDisconnect();
- private static native int getRetval0(int context, int release);
- private static native String getInterfaceList0(String nameFilter);
- private static native int swIfIndexFromName0(String interfaceName);
- private static native String interfaceNameFromSwIfIndex0(int swIfIndex);
- private static native void clearInterfaceTable0();
- private static native vppInterfaceDetails[] swInterfaceDump0(byte nameFilterValid, byte [] nameFilter);
- private static native int bridgeDomainIdFromName0(String bridgeDomain);
- private static native int findOrAddBridgeDomainId0(String bridgeDomain);
- private static native vppVersion getVppVersion0();
- private static native vppInterfaceCounters getInterfaceCounters0(int swIfIndex);
- private static native int[] bridgeDomainDump0(int bdId);
- private static native vppBridgeDomainDetails getBridgeDomainDetails0(int bdId);
- private static native vppL2Fib[] l2FibTableDump0(int bdId);
- private static native int bridgeDomainIdFromInterfaceName0(String interfaceName);
- private static native vppIPv4Address[] ipv4AddressDump0(String interfaceName);
- private static native vppIPv6Address[] ipv6AddressDump0(String interfaceName);
- private static native vppVxlanTunnelDetails[] vxlanTunnelDump0(int swIfIndex);
- private static native int setInterfaceDescription0(String ifName, String ifDesc);
- private static native String getInterfaceDescription0(String ifName);
-}
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv4Address.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv4Address.java
deleted file mode 100644
index 046ceab5..00000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv4Address.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-public final class vppIPv4Address {
- public final int ip;
- public final byte prefixLength;
-
- public vppIPv4Address(int ip, byte prefixLength) {
- this.ip = ip;
- this.prefixLength = prefixLength;
- }
-}
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv6Address.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv6Address.java
deleted file mode 100644
index 6690a5db..00000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv6Address.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-public class vppIPv6Address {
- // FIXME: this is dangerous
- public final byte[] ip;
- public final byte prefixLength;
-
- public vppIPv6Address(byte[] ip, byte prefixLength) {
- this.ip = ip;
- this.prefixLength = prefixLength;
- }
-}
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceCounters.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceCounters.java
deleted file mode 100644
index b2687fb8..00000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceCounters.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-public final class vppInterfaceCounters {
-
- public final long rxOctets;
- public final long rxIp4;
- public final long rxIp6;
- public final long rxUnicast;
- public final long rxMulticast;
- public final long rxBroadcast;
- public final long rxDiscard;
- public final long rxFifoFull;
- public final long rxError;
- public final long rxUnknownProto;
- public final long rxMiss;
-
- public final long txOctets;
- public final long txIp4;
- public final long txIp6;
- public final long txUnicast;
- public final long txMulticast;
- public final long txBroadcast;
- public final long txDiscard;
- public final long txFifoFull;
- public final long txError;
- public final long txUnknownProto;
- public final long txMiss;
-
- public vppInterfaceCounters(
- long rxOctets, long rxIp4, long rxIp6, long rxUni, long rxMulti,
- long rxBcast, long rxDiscard, long rxFifoFull, long rxError,
- long rxUnknownProto, long rxMiss,
- long txOctets, long txIp4, long txIp6, long txUni, long txMulti,
- long txBcast, long txDiscard, long txFifoFull, long txError,
- long txUnknownProto, long txMiss)
- {
- this.rxOctets = rxOctets;
- this.rxIp4 = rxIp4;
- this.rxIp6 = rxIp6;
- this.rxUnicast = rxUni;
- this.rxMulticast = rxMulti;
- this.rxBroadcast = rxBcast;
- this.rxDiscard = rxDiscard;
- this.rxFifoFull = rxFifoFull;
- this.rxError = rxError;
- this.rxUnknownProto = rxUnknownProto;
- this.rxMiss = rxMiss;
-
- this.txOctets = txOctets;
- this.txIp4 = txIp4;
- this.txIp6 = txIp6;
- this.txUnicast = txUni;
- this.txMulticast = txMulti;
- this.txBroadcast = txBcast;
- this.txDiscard = txDiscard;
- this.txFifoFull = txFifoFull;
- this.txError = txError;
- this.txUnknownProto = txUnknownProto;
- this.txMiss = txMiss;
- }
-}
-
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceDetails.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceDetails.java
deleted file mode 100644
index 742dd25a..00000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceDetails.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-public final class vppInterfaceDetails {
- public final int ifIndex;
- public final String interfaceName;
- public final int supIfIndex;
- // FIXME: this is dangerous
- public final byte[] physAddr;
- public final byte adminUp;
- public final byte linkUp;
- public final byte linkDuplex;
- public final byte linkSpeed;
- public final int subId;
- public final byte subDot1ad;
- public final byte subNumberOfTags;
- public final int subOuterVlanId;
- public final int subInnerVlanId;
- public final byte subExactMatch;
- public final byte subDefault;
- public final byte subOuterVlanIdAny;
- public final byte subInnerVlanIdAny;
- public final int vtrOp;
- public final int vtrPushDot1q;
- public final int vtrTag1;
- public final int vtrTag2;
- public final int linkMtu;
-
- public vppInterfaceDetails(int ifIndex, String interfaceName, int supIfIndex, byte[] physAddr, byte adminUp,
- byte linkUp, byte linkDuplex, byte linkSpeed, int subId, byte subDot1ad, byte subNumberOfTags,
- int subOuterVlanId, int subInnerVlanId, byte subExactMatch, byte subDefault, byte subOuterVlanIdAny,
- byte subInnerVlanIdAny, int vtrOp, int vtrPushDot1q, int vtrTag1, int vtrTag2, int linkMtu)
- {
- this.ifIndex = ifIndex;
- this.interfaceName = interfaceName;
- this.supIfIndex = supIfIndex;
- this.physAddr = physAddr;
- this.adminUp = adminUp;
- this.linkUp = linkUp;
- this.linkDuplex = linkDuplex;
- this.linkSpeed = linkSpeed;
- this.subId = subId;
- this.subDot1ad = subDot1ad;
- this.subNumberOfTags = subNumberOfTags;
- this.subOuterVlanId = subOuterVlanId;
- this.subInnerVlanId = subInnerVlanId;
- this.subExactMatch = subExactMatch;
- this.subDefault = subDefault;
- this.subOuterVlanIdAny = subOuterVlanIdAny;
- this.subInnerVlanIdAny = subInnerVlanIdAny;
- this.vtrOp = vtrOp;
- this.vtrPushDot1q = vtrPushDot1q;
- this.vtrTag1 = vtrTag1;
- this.vtrTag2 = vtrTag2;
- this.linkMtu = linkMtu;
- }
-}
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppL2Fib.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppL2Fib.java
deleted file mode 100644
index b38d801e..00000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppL2Fib.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-public final class vppL2Fib {
- // FIXME: this is dangerous
- public final byte[] physAddress;
- public final boolean staticConfig;
- public final String outgoingInterface;
- public final boolean filter;
- public final boolean bridgedVirtualInterface;
-
- public vppL2Fib(byte[] physAddress, boolean staticConfig,
- String outgoingInterface, boolean filter,
- boolean bridgedVirtualInterface) {
- this.physAddress = physAddress;
- this.staticConfig = staticConfig;
- this.outgoingInterface = outgoingInterface;
- this.filter = filter;
- this.bridgedVirtualInterface = bridgedVirtualInterface;
- }
-}
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppVersion.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppVersion.java
deleted file mode 100644
index 6408dee2..00000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppVersion.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-public final class vppVersion {
- public final String programName;
- public final String buildDirectory;
- public final String gitBranch;
- public final String buildDate;
-
- public vppVersion(String progName, String buildDir, String gitBranch, String buildDate) {
- this.programName = progName;
- this.buildDirectory = buildDir;
- this.gitBranch = gitBranch;
- this.buildDate = buildDate;
- }
-}
-
diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java
deleted file mode 100644
index fe3d0bca..00000000
--- a/vpp-api/java/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openvpp.vppjapi;
-
-public final class vppVxlanTunnelDetails {
- public final byte[] srcAddress;
- public final byte[] dstAddress;
- public final int encapVrfId;
- public final int vni;
- public final int decapNextIndex;
- public final boolean isIpv6;
-
- public vppVxlanTunnelDetails(byte[] srcAddress, byte[] dstAddress,
- int encapVrfId, int vni, int decapNextIndex, boolean isIpv6) {
- this.srcAddress = srcAddress;
- this.dstAddress = dstAddress;
- this.encapVrfId = encapVrfId;
- this.vni = vni;
- this.decapNextIndex = decapNextIndex;
- this.isIpv6 = isIpv6;
- }
-}
diff --git a/vpp-api/java/japi/test/demo.java b/vpp-api/java/japi/test/demo.java
deleted file mode 100644
index ea1db84b..00000000
--- a/vpp-api/java/japi/test/demo.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.openvpp.vppjapi.*;
-
-public class demo {
- public static void main (String[] args) throws Exception {
- vppApi api = new vppApi ("JavaTest");
- System.out.printf ("Connected OK...");
-
- String intlist;
- int [] contexts;
- int i, limit;
- int trips;
- int rv, errors, saved_error;
- long before, after;
-
- if (false)
- {
- intlist = api.getInterfaceList ("");
- System.out.printf ("Unfiltered interface list:\n%s", intlist);
-
- trips = 0;
-
- contexts = new int[6];
-
- for (i = 0; i < 6; i++)
- {
- contexts[i] = api.swInterfaceSetFlags
- (5 + i /* sw_if_index */,
- (byte)1 /* admin_up */,
- (byte)1 /* link_up (ignored) */,
- (byte)0 /* deleted */);
- }
-
- /* Thread.sleep (1); */
- errors = 0;
- saved_error = 0;
-
- for (i = 0; i < 6; i ++)
- {
- while (true)
- {
- rv = api.getRetval (contexts[i], 1 /* release */);
- if (rv != -77)
- break;
- Thread.sleep (1);
- trips++;
- }
- if (rv < 0)
- {
- saved_error = rv;
- errors++;
- }
- }
-
- if (errors == 0)
- System.out.printf ("intfcs up...\n");
- else
- System.out.printf
- ("%d errors, last error %d...\n", errors, saved_error);
- }
-
- limit = 250000;
- saved_error = 0;
- errors = 0;
- contexts = new int [limit];
- byte [] address = new byte [4];
- byte [] zeros = new byte [4];
-
- address[0] = (byte)192;
- address[1] = (byte)168;
- address[2] = (byte)2;
- address[3] = (byte)1;
-
- for (i = 0; i < 4; i++)
- zeros[i] = 0;
-
- System.out.printf ("start %d route ops ...", limit);
-
- before = System.currentTimeMillis();
-
- for (i = 0; i < limit; i++) {
- contexts[i] = api.ipAddDelRoute
- (0 /* int nextHopSwIfIndex */,
- 0 /* int vrfId */,
- 0 /* int lookupInVrf */,
- 0 /* int resolveAttempts */,
- 0 /* int classifyTableIndex */,
- (byte)0 /* byte createVrfIfNeeded */,
- (byte)0 /* byte resolveIfNeeded */,
- (byte)1 /* byte isAdd */,
- (byte)1 /* byte isDrop */,
- (byte)0 /* byte isIpv6 */,
- (byte)0 /* byte isLocal */,
- (byte)0 /* byte isClassify */,
- (byte)0 /* byte isMultipath */,
- (byte)0 /* byte notLast */,
- (byte)0 /* byte nextHopWeight */,
- (byte)32 /* byte dstAddressLength */,
- address,
- zeros);
-
- address[3] += 1;
- if (address[3] == 0)
- {
- address[2] += 1;
- if (address[2] == 0)
- {
- address[1] += 1;
- {
- if (address[1] == 0)
- {
- address[0] += 1;
- }
- }
- }
- }
- }
-
- trips = 0;
-
- for (i = 0; i < limit; i++)
- {
- while (true)
- {
- rv = api.getRetval (contexts[i], 1 /* release */);
- if (rv != -77)
- break;
- Thread.sleep (1);
- trips++;
- }
- if (rv < 0)
- {
- saved_error = rv;
- errors++;
- }
- }
-
- after = System.currentTimeMillis();
-
-
- if (errors == 0)
- System.out.printf ("done %d route ops (all OK)...\n", limit);
- else
- System.out.printf
- ("%d errors, last error %d...\n", errors, saved_error);
-
- System.out.printf ("result in %d trips\n", trips);
-
- System.out.printf ("%d routes in %d milliseconds, %d routes/msec\n",
- limit, after - before,
- limit / (after - before));
-
- api.close();
- System.out.printf ("Done...\n");
- }
-}
diff --git a/vpp-api/java/japi/test/vppApi.java b/vpp-api/java/japi/test/vppApi.java
deleted file mode 100644
index 87af3292..00000000
--- a/vpp-api/java/japi/test/vppApi.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.net.InetAddress;
-import org.openvpp.vppjapi.*;
-
-public class vppApi {
-
- native int controlPing();
- native void test (byte[] array, byte[] array2);
-
- public static void main (String[] args) throws Exception {
- vppConn api = new vppConn ();
- String ipv6 = "db01::feed";
- String ipv4 = "192.168.1.1";
- InetAddress addr6 = InetAddress.getByName(ipv6);
- InetAddress addr4 = InetAddress.getByName(ipv4);
- byte[] ip4bytes = addr4.getAddress();
- byte[] ip6bytes = addr6.getAddress();
- int rv;
-
- api.test(ip4bytes,ip6bytes);
-
- rv = api.clientConnect ("JavaTest");
- if (rv == 0)
- System.out.printf ("Connected OK...");
- else
- {
- System.out.printf ("clientConnect returned %d\n", rv);
- System.exit (1);
- }
- rv = api.controlPing();
- System.out.printf ("data plane pid is %d\n", rv);
-
- Thread.sleep (5000);
-
- api.clientDisconnect();
- System.out.printf ("Done...\n");
- }
-}
diff --git a/vpp-api/java/japi/vppjni.c b/vpp-api/java/japi/vppjni.c
deleted file mode 100644
index 2b58b360..00000000
--- a/vpp-api/java/japi/vppjni.c
+++ /dev/null
@@ -1,1954 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#define _GNU_SOURCE /* for strcasestr(3) */
-#include <vnet/vnet.h>
-
-#define vl_api_version(n,v) static u32 vpe_api_version = (v);
-#include <vpp-api/vpe.api.h>
-#undef vl_api_version
-
-#include <jni.h>
-#include <japi/vppjni.h>
-#include <japi/vppjni_bridge_domain.h>
-#include <japi/vppjni_env.h>
-#include <japi/org_openvpp_vppjapi_vppConn.h>
-#include <japi/org_openvpp_vppjapi_vppApi.h>
-
-#include <vpp-api/vpe_msg_enum.h>
-#define vl_typedefs /* define message structures */
-#include <vpp-api/vpe_all_api_h.h>
-#undef vl_typedefs
-
-#define vl_endianfun
-#include <vpp-api/vpe_all_api_h.h>
-#undef vl_endianfun
-
-/* instantiate all the print functions we know about */
-#define vl_print(handle, ...)
-#define vl_printfun
-#include <vpp-api/vpe_all_api_h.h>
-#undef vl_printfun
-
-#ifndef VPPJNI_DEBUG
-#define VPPJNI_DEBUG 0
-#endif
-
-#if VPPJNI_DEBUG == 1
- #define DEBUG_LOG(...) clib_warning(__VA_ARGS__)
-#else
- #define DEBUG_LOG(...)
-#endif
-
-static int connect_to_vpe(char *name);
-
-/*
- * The Java runtime isn't compile w/ -fstack-protector,
- * so we have to supply missing external references for the
- * regular vpp libraries. Weak reference in case folks get religion
- * at a later date...
- */
-void __stack_chk_guard (void) __attribute__((weak));
-void __stack_chk_guard (void) { }
-
-BIND_JAPI_CLASS(vppBridgeDomainDetails, "()V");
-BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, arpTerm);
-BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, flood);
-BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, forward);
-BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, learn);
-BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, uuFlood);
-BIND_JAPI_INT_FIELD(vppBridgeDomainDetails, bdId);
-BIND_JAPI_STRING_FIELD(vppBridgeDomainDetails, name);
-BIND_JAPI_STRING_FIELD(vppBridgeDomainDetails, bviInterfaceName);
-BIND_JAPI_OBJ_FIELD(vppBridgeDomainDetails, interfaces, "[Lorg/openvpp/vppjapi/vppBridgeDomainInterfaceDetails;");
-
-BIND_JAPI_CLASS(vppBridgeDomainInterfaceDetails, "()V");
-BIND_JAPI_BYTE_FIELD(vppBridgeDomainInterfaceDetails, splitHorizonGroup);
-BIND_JAPI_STRING_FIELD(vppBridgeDomainInterfaceDetails, interfaceName);
-
-BIND_JAPI_CLASS(vppInterfaceCounters, "(JJJJJJJJJJJJJJJJJJJJJJ)V");
-BIND_JAPI_CLASS(vppInterfaceDetails, "(ILjava/lang/String;I[BBBBBIBBIIBBBBIIIII)V");
-BIND_JAPI_CLASS(vppIPv4Address, "(IB)V");
-BIND_JAPI_CLASS(vppIPv6Address, "([BB)V");
-BIND_JAPI_CLASS(vppL2Fib, "([BZLjava/lang/String;ZZ)V");
-BIND_JAPI_CLASS(vppVersion, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
-BIND_JAPI_CLASS(vppVxlanTunnelDetails, "(IIIII)V");
-
-void vl_client_add_api_signatures (vl_api_memclnt_create_t *mp)
-{
- /*
- * Send the main API signature in slot 0. This bit of code must
- * match the checks in ../vpe/api/api.c: vl_msg_api_version_check().
- */
- mp->api_versions[0] = clib_host_to_net_u32 (vpe_api_version);
-}
-
-/* Note: non-static, called once to set up the initial intfc table */
-static int sw_interface_dump (vppjni_main_t * jm)
-{
- vl_api_sw_interface_dump_t *mp;
- f64 timeout;
- hash_pair_t * p;
- name_sort_t * nses = 0, * ns;
- sw_interface_subif_t * sub = NULL;
-
- /* Toss the old name table */
- hash_foreach_pair (p, jm->sw_if_index_by_interface_name,
- ({
- vec_add2 (nses, ns, 1);
- ns->name = (u8 *)(p->key);
- ns->value = (u32) p->value[0];
- }));
-
- hash_free (jm->sw_if_index_by_interface_name);
-
- vec_foreach (ns, nses)
- vec_free (ns->name);
-
- vec_free (nses);
-
- vec_foreach (sub, jm->sw_if_subif_table) {
- vec_free (sub->interface_name);
- }
- vec_free (jm->sw_if_subif_table);
-
- /* recreate the interface name hash table */
- jm->sw_if_index_by_interface_name
- = hash_create_string (0, sizeof(uword));
-
- /* Get list of ethernets */
- M(SW_INTERFACE_DUMP, sw_interface_dump);
- mp->name_filter_valid = 1;
- strncpy ((char *) mp->name_filter, "Ether", sizeof(mp->name_filter)-1);
- S;
-
- /* and local / loopback interfaces */
- M(SW_INTERFACE_DUMP, sw_interface_dump);
- mp->name_filter_valid = 1;
- strncpy ((char *) mp->name_filter, "lo", sizeof(mp->name_filter)-1);
- S;
-
- /* and vxlan tunnel interfaces */
- M(SW_INTERFACE_DUMP, sw_interface_dump);
- mp->name_filter_valid = 1;
- strncpy ((char *) mp->name_filter, "vxlan", sizeof(mp->name_filter)-1);
- S;
-
- /* and tap tunnel interfaces */
- M(SW_INTERFACE_DUMP, sw_interface_dump);
- mp->name_filter_valid = 1;
- strncpy ((char *) mp->name_filter, "tap", sizeof(mp->name_filter)-1);
- S;
-
- /* and host (af_packet) interfaces */
- M(SW_INTERFACE_DUMP, sw_interface_dump);
- mp->name_filter_valid = 1;
- strncpy ((char *) mp->name_filter, "host", sizeof(mp->name_filter)-1);
- S;
-
- /* and l2tpv3 tunnel interfaces */
- M(SW_INTERFACE_DUMP, sw_interface_dump);
- mp->name_filter_valid = 1;
- strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
- sizeof(mp->name_filter)-1);
- S;
-
- /* Use a control ping for synchronization */
- {
- vl_api_control_ping_t * mp;
- M(CONTROL_PING, control_ping);
- S;
- }
- W;
-}
-
-JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getVppVersion0
- (JNIEnv *env, jobject obj)
-{
- vppjni_main_t * jm = &vppjni_main;
-
- vppjni_lock (jm, 11);
- jstring progName = (*env)->NewStringUTF(env, (char *)jm->program_name);
- jstring buildDir = (*env)->NewStringUTF(env, (char *)jm->build_directory);
- jstring version = (*env)->NewStringUTF(env, (char *)jm->version);
- jstring buildDate = (*env)->NewStringUTF(env, (char *)jm->build_date);
- vppjni_unlock (jm);
-
- return vppVersionObject(env, progName, buildDir, version, buildDate);
-}
-
-static int jm_show_version (vppjni_main_t *jm)
-{
- int rv;
- vl_api_show_version_t *mp;
- f64 timeout;
-
- vppjni_lock (jm, 10);
- M(SHOW_VERSION, show_version);
-
- S;
- vppjni_unlock (jm);
- WNR;
- return rv;
-}
-
-static int jm_stats_enable_disable (vppjni_main_t *jm, u8 enable)
-{
- vl_api_want_stats_t * mp;
- f64 timeout;
- int rv;
-
- vppjni_lock (jm, 13);
-
- M(WANT_STATS, want_stats);
-
- mp->enable_disable = enable;
-
- S;
- vppjni_unlock (jm);
- WNR;
-
- // already subscribed / already disabled (it's ok)
- if (rv == -2 || rv == -3)
- rv = 0;
- return rv;
-}
-
-JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_setInterfaceDescription0
- (JNIEnv *env, jobject obj, jstring ifName, jstring ifDesc)
-{
- int rv = 0;
- vppjni_main_t * jm = &vppjni_main;
- uword * p;
- u32 sw_if_index = ~0;
- sw_if_config_t *cfg;
-
- const char *if_name_str = (*env)->GetStringUTFChars (env, ifName, 0);
- const char *if_desc_str = (*env)->GetStringUTFChars (env, ifDesc, 0);
-
- vppjni_lock (jm, 23);
-
- p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name_str);
- if (p == 0) {
- rv = -1;
- goto out;
- }
- sw_if_index = (jint) p[0];
-
- u8 *if_desc = 0;
- vec_validate_init_c_string (if_desc, if_desc_str, strlen(if_desc_str));
- (*env)->ReleaseStringUTFChars (env, ifDesc, if_desc_str);
-
- p = hash_get (jm->sw_if_config_by_sw_if_index, sw_if_index);
- if (p != 0) {
- cfg = (sw_if_config_t *) (p[0]);
- if (cfg->desc)
- vec_free(cfg->desc);
- } else {
- cfg = (sw_if_config_t *) clib_mem_alloc(sizeof(sw_if_config_t));
- hash_set (jm->sw_if_config_by_sw_if_index, sw_if_index, cfg);
- }
-
- cfg->desc = if_desc;
-
-out:
- (*env)->ReleaseStringUTFChars (env, ifName, if_name_str);
- vppjni_unlock (jm);
- return rv;
-}
-
-JNIEXPORT jstring JNICALL Java_org_openvpp_vppjapi_vppConn_getInterfaceDescription0
-(JNIEnv * env, jobject obj, jstring ifName)
-{
- vppjni_main_t * jm = &vppjni_main;
- u32 sw_if_index = ~0;
- uword * p;
- jstring ifDesc = NULL;
- const char *if_name_str = (*env)->GetStringUTFChars (env, ifName, 0);
- if (!if_name_str)
- return NULL;
-
- vppjni_lock (jm, 24);
- p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name_str);
- if (p == 0)
- goto out;
-
- sw_if_index = (jint) p[0];
-
- p = hash_get (jm->sw_if_config_by_sw_if_index, sw_if_index);
- if (p == 0)
- goto out;
-
- sw_if_config_t *cfg = (sw_if_config_t *) (p[0]);
- u8 * s = format (0, "%s%c", cfg->desc, 0);
- ifDesc = (*env)->NewStringUTF(env, (char *)s);
-
-out:
- vppjni_unlock (jm);
-
- return ifDesc;
-}
-
-JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_clientConnect
- (JNIEnv *env, jobject obj, jstring clientName)
-{
- int rv;
- const char *client_name;
- void vl_msg_reply_handler_hookup(void);
- vppjni_main_t * jm = &vppjni_main;
- api_main_t * am = &api_main;
- u8 * heap;
- mheap_t * h;
- f64 timeout;
-
- /*
- * Bail out now if we're not running as root
- */
- if (geteuid() != 0)
- return -1;
-
- if (jm->is_connected)
- return -2;
-
- client_name = (*env)->GetStringUTFChars(env, clientName, 0);
- if (!client_name)
- return -3;
-
- if (jm->heap == 0)
- clib_mem_init (0, 128<<20);
-
- heap = clib_mem_get_per_cpu_heap();
- h = mheap_header (heap);
-
- clib_time_init (&jm->clib_time);
-
- rv = connect_to_vpe ((char *) client_name);
-
- if (rv < 0)
- clib_warning ("connection failed, rv %d", rv);
-
- (*env)->ReleaseStringUTFChars (env, clientName, client_name);
-
- if (rv == 0) {
- vl_msg_reply_handler_hookup ();
- jm->is_connected = 1;
- /* make the main heap thread-safe */
- h->flags |= MHEAP_FLAG_THREAD_SAFE;
-
- jm->reply_hash = hash_create (0, sizeof (uword));
- //jm->callback_hash = hash_create (0, sizeof (uword));
- //jm->ping_hash = hash_create (0, sizeof (uword));
- jm->api_main = am;
- vjbd_main_init(&jm->vjbd_main);
- jm->sw_if_index_by_interface_name =
- hash_create_string (0, sizeof (uword));
- jm->sw_if_config_by_sw_if_index =
- hash_create (0, sizeof (uword));
-
- {
- // call control ping first to attach rx thread to java thread
- vl_api_control_ping_t * mp;
- M(CONTROL_PING, control_ping);
- S;
- WNR;
-
- if (rv != 0) {
- clib_warning ("first control ping failed: %d", rv);
- }
- }
- rv = jm_show_version(jm);
- if (rv != 0)
- clib_warning ("unable to retrieve vpp version (rv: %d)", rv);
- rv = sw_interface_dump(jm);
- if (rv != 0)
- clib_warning ("unable to retrieve interface list (rv: %d)", rv);
- rv = jm_stats_enable_disable(jm, 1);
- if (rv != 0)
- clib_warning ("unable to subscribe to stats (rv: %d)", rv);
- }
- DEBUG_LOG ("clientConnect result: %d", rv);
-
- return rv;
-}
-
-JNIEXPORT void JNICALL Java_org_openvpp_vppjapi_vppConn_clientDisconnect
- (JNIEnv *env, jobject obj)
-{
- u8 *save_heap;
- vppjni_main_t * jm = &vppjni_main;
- vl_client_disconnect_from_vlib();
-
- save_heap = jm->heap;
- memset (jm, 0, sizeof (*jm));
- jm->heap = save_heap;
-}
-
-void vl_api_generic_reply_handler (vl_api_generic_reply_t *mp)
-{
- api_main_t * am = &api_main;
- u16 msg_id = clib_net_to_host_u16 (mp->_vl_msg_id);
- trace_cfg_t *cfgp;
- i32 retval = clib_net_to_host_u32 (mp->retval);
- int total_bytes = sizeof(mp);
- vppjni_main_t * jm = &vppjni_main;
- u8 * saved_reply = 0;
- u32 context = clib_host_to_net_u32 (mp->context);
-
- cfgp = am->api_trace_cfg + msg_id;
-
- if (!cfgp)
- clib_warning ("msg id %d: no trace configuration\n", msg_id);
- else
- total_bytes = cfgp->size;
-
- jm->context_id_received = context;
-
- DEBUG_LOG ("Received generic reply for msg id %d", msg_id);
-
- /* A generic reply, successful, we're done */
- if (retval >= 0 && total_bytes == sizeof(*mp))
- return;
-
- /* Save the reply */
- vec_validate (saved_reply, total_bytes - 1);
- clib_memcpy (saved_reply, mp, total_bytes);
-
- vppjni_lock (jm, 2);
- hash_set (jm->reply_hash, context, saved_reply);
- jm->saved_reply_count ++;
- vppjni_unlock (jm);
-}
-
-JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_getRetval0
-(JNIEnv * env, jobject obj, jint context, jint release)
-{
- vppjni_main_t * jm = &vppjni_main;
- vl_api_generic_reply_t * mp;
- uword * p;
- int rv = 0;
-
- /* Dunno yet? */
- if (context > jm->context_id_received)
- return (VNET_API_ERROR_RESPONSE_NOT_READY);
-
- vppjni_lock (jm, 1);
- p = hash_get (jm->reply_hash, context);
-
- /*
- * Two cases: a generic "yes" reply - won't be in the hash table
- * or "no", or "more data" which will be in the table.
- */
- if (p == 0)
- goto out;
-
- mp = (vl_api_generic_reply_t *) (p[0]);
- rv = clib_net_to_host_u32 (mp->retval);
-
- if (release) {
- u8 * free_me = (u8 *) mp;
- vec_free (free_me);
- hash_unset (jm->reply_hash, context);
- jm->saved_reply_count --;
- }
-
-out:
- vppjni_unlock (jm);
- return (rv);
-}
-
-static int
-name_sort_cmp (void * a1, void * a2)
-{
- name_sort_t * n1 = a1;
- name_sort_t * n2 = a2;
-
- return strcmp ((char *)n1->name, (char *)n2->name);
-}
-
-JNIEXPORT jstring JNICALL Java_org_openvpp_vppjapi_vppConn_getInterfaceList0
- (JNIEnv * env, jobject obj, jstring name_filter)
-{
- vppjni_main_t * jm = &vppjni_main;
- jstring rv;
- hash_pair_t * p;
- name_sort_t * nses = 0, * ns;
- const char *this_name;
- u8 * s = 0;
- const char * nf = (*env)->GetStringUTFChars (env, name_filter, NULL);
- if (!nf)
- return NULL;
-
- vppjni_lock (jm, 4);
-
- hash_foreach_pair (p, jm->sw_if_index_by_interface_name,
- ({
- this_name = (const char *)(p->key);
- if (strlen (nf) == 0 || strcasestr (this_name, nf)) {
- vec_add2 (nses, ns, 1);
- ns->name = (u8 *)(p->key);
- ns->value = (u32) p->value[0];
- }
- }));
-
- vec_sort_with_function (nses, name_sort_cmp);
-
- vec_foreach (ns, nses)
- s = format (s, "%s: %d, ", ns->name, ns->value);
-
- _vec_len (s) = vec_len (s) - 2;
- vec_terminate_c_string (s);
- vppjni_unlock (jm);
-
- vec_free (nses);
-
- (*env)->ReleaseStringUTFChars (env, name_filter, nf);
-
- rv = (*env)->NewStringUTF (env, (char *) s);
- vec_free (s);
-
- return rv;
-}
-
-JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_swIfIndexFromName0
- (JNIEnv * env, jobject obj, jstring interfaceName)
-{
- vppjni_main_t * jm = &vppjni_main;
- jint rv = -1;
- const char * if_name = (*env)->GetStringUTFChars (env, interfaceName, NULL);
- if (if_name) {
- uword * p;
-
- vppjni_lock (jm, 5);
-
- p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name);
-
- if (p != 0)
- rv = (jint) p[0];
-
- vppjni_unlock (jm);
-
- (*env)->ReleaseStringUTFChars (env, interfaceName, if_name);
- }
-
- return rv;
-}
-
-JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getInterfaceCounters0
-(JNIEnv * env, jobject obj, jint swIfIndex)
-{
- vppjni_main_t * jm = &vppjni_main;
- sw_interface_stats_t *s;
- u32 sw_if_index = swIfIndex;
- jobject result = NULL;
-
- vppjni_lock (jm, 16);
-
- if (sw_if_index >= vec_len(jm->sw_if_stats_by_sw_if_index)) {
- goto out;
- }
- s = &jm->sw_if_stats_by_sw_if_index[sw_if_index];
- if (!s->valid) {
- goto out;
- }
-
- result = vppInterfaceCountersObject(env,
- s->rx.octets, s->rx.pkts.ip4, s->rx.pkts.ip6, s->rx.pkts.unicast,
- s->rx.pkts.multicast, s->rx.pkts.broadcast, s->rx.pkts.discard,
- s->rx.pkts.fifo_full, s->rx.pkts.error, s->rx.pkts.unknown_proto,
- s->rx.pkts.miss,
- s->tx.octets, s->tx.pkts.ip4, s->tx.pkts.ip6, s->tx.pkts.unicast,
- s->tx.pkts.multicast, s->tx.pkts.broadcast, s->tx.pkts.discard,
- s->tx.pkts.fifo_full, s->tx.pkts.error, s->tx.pkts.unknown_proto,
- s->tx.pkts.miss);
-
-out:
- vppjni_unlock (jm);
- return result;
-}
-
-JNIEXPORT jstring JNICALL Java_org_openvpp_vppjapi_vppConn_interfaceNameFromSwIfIndex0
-(JNIEnv * env, jobject obj, jint swIfIndex)
-{
- vppjni_main_t * jm = &vppjni_main;
- sw_interface_details_t *sw_if_details;
- u32 sw_if_index;
- jstring ifname = NULL;
-
- vppjni_lock (jm, 8);
-
- sw_if_index = swIfIndex;
-
- if (sw_if_index >= vec_len(jm->sw_if_table)) {
- goto out;
- }
- sw_if_details = &jm->sw_if_table[sw_if_index];
- if (!sw_if_details->valid) {
- goto out;
- }
-
- u8 * s = format (0, "%s%c", sw_if_details->interface_name, 0);
- ifname = (*env)->NewStringUTF(env, (char *)s);
-
-out:
- vppjni_unlock (jm);
-
- return ifname;
-}
-
-JNIEXPORT void JNICALL Java_org_openvpp_vppjapi_vppConn_clearInterfaceTable0
-(JNIEnv * env, jobject obj)
-{
- vppjni_main_t * jm = &vppjni_main;
-
- vppjni_lock (jm, 21);
-
- vec_reset_length(jm->sw_if_table);
-
- vppjni_unlock (jm);
-}
-
-static jobjectArray sw_if_dump_get_interfaces ();
-
-JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_swInterfaceDump0
-(JNIEnv * env, jobject obj, jbyte name_filter_valid, jbyteArray name_filter)
-{
- vppjni_main_t *jm = &vppjni_main;
- f64 timeout;
- vl_api_sw_interface_dump_t * mp;
- u32 my_context_id;
- int rv;
- rv = vppjni_sanity_check (jm);
- if (rv) {
- clib_warning("swInterfaceDump sanity_check rv = %d", rv);
- return NULL;
- }
-
- vppjni_lock (jm, 7);
- my_context_id = vppjni_get_context_id (jm);
- jsize cnt = (*env)->GetArrayLength (env, name_filter);
-
- M(SW_INTERFACE_DUMP, sw_interface_dump);
- mp->context = clib_host_to_net_u32 (my_context_id);
- mp->name_filter_valid = name_filter_valid;
-
- if (cnt > sizeof(mp->name_filter))
- cnt = sizeof(mp->name_filter);
-
- (*env)->GetByteArrayRegion(env, name_filter, 0, cnt, (jbyte *)mp->name_filter);
-
- DEBUG_LOG ("interface filter (%d, %s, len: %d)", mp->name_filter_valid, (char *)mp->name_filter, cnt);
-
- jm->collect_indices = 1;
-
- S;
- {
- // now send control ping so we know when it ends
- vl_api_control_ping_t * mp;
- M(CONTROL_PING, control_ping);
- mp->context = clib_host_to_net_u32 (my_context_id);
-
- S;
- }
- vppjni_unlock (jm);
- WNR;
-
- vppjni_lock (jm, 7);
- jobjectArray result = sw_if_dump_get_interfaces(env);
- vppjni_unlock (jm);
- return result;
-}
-
-static jobjectArray sw_if_dump_get_interfaces (JNIEnv * env)
-{
- vppjni_main_t * jm = &vppjni_main;
- sw_interface_details_t *sw_if_details;
- u32 i;
-
- int len = vec_len(jm->sw_if_dump_if_indices);
-
- jobjectArray ifArray = vppInterfaceDetailsArray(env, len);
-
- for (i = 0; i < len; i++) {
- u32 sw_if_index = jm->sw_if_dump_if_indices[i];
- ASSERT(sw_if_index < vec_len(jm->sw_if_table));
- sw_if_details = &jm->sw_if_table[sw_if_index];
- ASSERT(sw_if_details->valid);
-
- u8 * s = format (0, "%s%c", sw_if_details->interface_name, 0);
-
- jstring ifname = (*env)->NewStringUTF(env, (char *)s);
- jint ifIndex = sw_if_details->sw_if_index;
- jint supIfIndex = sw_if_details->sup_sw_if_index;
- jbyteArray physAddr = (*env)->NewByteArray(env,
- sw_if_details->l2_address_length);
- (*env)->SetByteArrayRegion(env, physAddr, 0,
- sw_if_details->l2_address_length,
- (signed char*)sw_if_details->l2_address);
- jint subId = sw_if_details->sub_id;
- jint subOuterVlanId = sw_if_details->sub_outer_vlan_id;
- jint subInnerVlanId = sw_if_details->sub_inner_vlan_id;
- jint vtrOp = sw_if_details->vtr_op;
- jint vtrPushDot1q = sw_if_details->vtr_push_dot1q;
- jint vtrTag1 = sw_if_details->vtr_tag1;
- jint vtrTag2 = sw_if_details->vtr_tag2;
- jint linkMtu = sw_if_details->link_mtu;
-
- jbyte adminUpDown = sw_if_details->admin_up_down;
- jbyte linkUpDown = sw_if_details->link_up_down;
- jbyte linkDuplex = sw_if_details->link_duplex;
- jbyte linkSpeed = sw_if_details->link_speed;
- jbyte subDot1ad = sw_if_details->sub_dot1ad;
- jbyte subNumberOfTags = sw_if_details->sub_number_of_tags;
- jbyte subExactMatch = sw_if_details->sub_exact_match;
- jbyte subDefault = sw_if_details->sub_default;
- jbyte subOuterVlanIdAny = sw_if_details->sub_outer_vlan_id_any;
- jbyte subInnerVlanIdAny = sw_if_details->sub_inner_vlan_id_any;
-
- jobject ifObj = vppInterfaceDetailsObject(env,
- ifIndex, ifname,
- supIfIndex, physAddr, adminUpDown, linkUpDown,
- linkDuplex, linkSpeed, subId, subDot1ad,
- subNumberOfTags, subOuterVlanId, subInnerVlanId,
- subExactMatch, subDefault, subOuterVlanIdAny,
- subInnerVlanIdAny, vtrOp, vtrPushDot1q, vtrTag1, vtrTag2, linkMtu);
- (*env)->SetObjectArrayElement(env, ifArray, i, ifObj);
- }
-
- jm->collect_indices = 0;
- vec_reset_length(jm->sw_if_dump_if_indices);
- return ifArray;
-}
-
-JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_findOrAddBridgeDomainId0
- (JNIEnv * env, jobject obj, jstring bridgeDomain)
-{
- vppjni_main_t * jm = &vppjni_main;
- jint rv = -1;
- const char * bdName = (*env)->GetStringUTFChars (env, bridgeDomain, NULL);
- if (bdName) {
- static u8 * bd_name = 0;
-
- vec_validate_init_c_string (bd_name, bdName, strlen(bdName));
- (*env)->ReleaseStringUTFChars (env, bridgeDomain, bdName);
-
- vppjni_lock (jm, 6);
- rv = (jint)vjbd_find_or_add_bd (&jm->vjbd_main, bd_name);
- vppjni_unlock (jm);
-
- _vec_len(bd_name) = 0;
- }
- return rv;
-}
-
-JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_bridgeDomainIdFromName0
- (JNIEnv * env, jobject obj, jstring bridgeDomain)
-{
- vppjni_main_t * jm = &vppjni_main;
- jint rv = -1;
- const char * bdName = (*env)->GetStringUTFChars (env, bridgeDomain, NULL);
- if (bdName) {
- static u8 * bd_name = 0;
-
- vec_validate_init_c_string (bd_name, bdName, strlen(bdName));
- (*env)->ReleaseStringUTFChars (env, bridgeDomain, bdName);
-
- vppjni_lock (jm, 20);
- rv = (jint)vjbd_id_from_name(&jm->vjbd_main, (u8 *)bd_name);
- vppjni_unlock (jm);
-
- _vec_len(bd_name) = 0;
- }
-
- return rv;
-}
-
-JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_bridgeDomainIdFromInterfaceName0
- (JNIEnv * env, jobject obj, jstring interfaceName)
-{
- vppjni_main_t * jm = &vppjni_main;
- vjbd_main_t * bdm = &jm->vjbd_main;
- u32 sw_if_index;
- jint rv = -1;
- const char * if_name;
- uword * p;
-
- if_name = (*env)->GetStringUTFChars (env, interfaceName, NULL);
-
- vppjni_lock (jm, 14);
-
- p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name);
-
- if (p != 0) {
- sw_if_index = (jint) p[0];
- p = hash_get (bdm->bd_id_by_sw_if_index, sw_if_index);
- if (p != 0) {
- rv = (jint) p[0];
- }
- }
-
- vppjni_unlock (jm);
-
- (*env)->ReleaseStringUTFChars (env, interfaceName, if_name);
-
- return rv;
-}
-
-/*
- * Special-case: build the interface table, maintain
- * the next loopback sw_if_index vbl.
- */
-static void vl_api_sw_interface_details_t_handler
-(vl_api_sw_interface_details_t * mp)
-{
- vppjni_main_t * jm = &vppjni_main;
- static sw_interface_details_t empty_sw_if_details = {0,};
- sw_interface_details_t *sw_if_details;
- u32 sw_if_index;
-
- vppjni_lock (jm, 1);
-
- sw_if_index = ntohl (mp->sw_if_index);
-
- u8 * s = format (0, "%s%c", mp->interface_name, 0);
-
- if (jm->collect_indices) {
- u32 pos = vec_len(jm->sw_if_dump_if_indices);
- vec_validate(jm->sw_if_dump_if_indices, pos);
- jm->sw_if_dump_if_indices[pos] = sw_if_index;
- }
-
- vec_validate_init_empty(jm->sw_if_table, sw_if_index, empty_sw_if_details);
- sw_if_details = &jm->sw_if_table[sw_if_index];
- sw_if_details->valid = 1;
-
- snprintf((char *)sw_if_details->interface_name,
- sizeof(sw_if_details->interface_name), "%s", (char *)s);
- sw_if_details->sw_if_index = sw_if_index;
- sw_if_details->sup_sw_if_index = ntohl(mp->sup_sw_if_index);
- sw_if_details->l2_address_length = ntohl (mp->l2_address_length);
- ASSERT(sw_if_details->l2_address_length <= sizeof(sw_if_details->l2_address));
- clib_memcpy(sw_if_details->l2_address, mp->l2_address,
- sw_if_details->l2_address_length);
- sw_if_details->sub_id = ntohl (mp->sub_id);
- sw_if_details->sub_outer_vlan_id = ntohl (mp->sub_outer_vlan_id);
- sw_if_details->sub_inner_vlan_id = ntohl (mp->sub_inner_vlan_id);
- sw_if_details->vtr_op = ntohl (mp->vtr_op);
- sw_if_details->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
- sw_if_details->vtr_tag1 = ntohl (mp->vtr_tag1);
- sw_if_details->vtr_tag2 = ntohl (mp->vtr_tag2);
-
- sw_if_details->admin_up_down = mp->admin_up_down;
- sw_if_details->link_up_down = mp->link_up_down;
- sw_if_details->link_duplex = mp->link_duplex;
- sw_if_details->link_speed = mp->link_speed;
- sw_if_details->sub_dot1ad = mp->sub_dot1ad;
- sw_if_details->sub_number_of_tags = mp->sub_number_of_tags;
- sw_if_details->sub_exact_match = mp->sub_exact_match;
- sw_if_details->sub_default = mp->sub_default;
- sw_if_details->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
- sw_if_details->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
-
- hash_set_mem (jm->sw_if_index_by_interface_name, s, sw_if_index);
- DEBUG_LOG ("Got interface %s", (char *)s);
-
- /* In sub interface case, fill the sub interface table entry */
- if (mp->sw_if_index != mp->sup_sw_if_index) {
- sw_interface_subif_t * sub = NULL;
-
- vec_add2(jm->sw_if_subif_table, sub, 1);
-
- vec_validate(sub->interface_name, strlen((char *)s) + 1);
- strncpy((char *)sub->interface_name, (char *)s,
- vec_len(sub->interface_name));
- sub->sw_if_index = ntohl(mp->sw_if_index);
- sub->sub_id = ntohl(mp->sub_id);
-
- sub->sub_dot1ad = mp->sub_dot1ad;
- sub->sub_number_of_tags = mp->sub_number_of_tags;
- sub->sub_outer_vlan_id = ntohs(mp->sub_outer_vlan_id);
- sub->sub_inner_vlan_id = ntohs(mp->sub_inner_vlan_id);
- sub->sub_exact_match = mp->sub_exact_match;
- sub->sub_default = mp->sub_default;
- sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
- sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
-
- /* vlan tag rewrite */
- sub->vtr_op = ntohl(mp->vtr_op);
- sub->vtr_push_dot1q = ntohl(mp->vtr_push_dot1q);
- sub->vtr_tag1 = ntohl(mp->vtr_tag1);
- sub->vtr_tag2 = ntohl(mp->vtr_tag2);
- }
- vppjni_unlock (jm);
-}
-
-static void vl_api_sw_interface_set_flags_t_handler
-(vl_api_sw_interface_set_flags_t * mp)
-{
- /* $$$ nothing for the moment */
-}
-
-static jintArray create_array_of_bd_ids(JNIEnv * env, jint bd_id)
-{
- vppjni_main_t *jm = &vppjni_main;
- vjbd_main_t * bdm = &jm->vjbd_main;
- u32 *buf = NULL;
- u32 i;
-
- if (bd_id != ~0) {
- vec_add1(buf, bd_id);
- } else {
- for (i = 0; i < vec_len(bdm->bd_oper); i++) {
- u32 bd_id = bdm->bd_oper[i].bd_id;
- vec_add1(buf, bd_id);
- }
- }
-
- jintArray bdidArray = (*env)->NewIntArray(env, vec_len(buf));
- if (!bdidArray) {
- goto out;
- }
-
- (*env)->SetIntArrayRegion(env, bdidArray, 0, vec_len(buf), (int*)buf);
-
-out:
- vec_free(buf);
- return bdidArray;
-}
-
-static void bridge_domain_oper_free(void)
-{
- vppjni_main_t *jm = &vppjni_main;
- vjbd_main_t *bdm = &jm->vjbd_main;
- u32 i;
-
- for (i = 0; i < vec_len(bdm->bd_oper); i++) {
- vec_free(bdm->bd_oper->l2fib_oper);
- }
- vec_reset_length(bdm->bd_oper);
- hash_free(bdm->bd_id_by_sw_if_index);
- hash_free(bdm->oper_bd_index_by_bd_id);
-}
-
-JNIEXPORT jintArray JNICALL Java_org_openvpp_vppjapi_vppConn_bridgeDomainDump0
-(JNIEnv * env, jobject obj, jint bd_id)
-{
- vppjni_main_t *jm = &vppjni_main;
- vl_api_bridge_domain_dump_t * mp;
- u32 my_context_id;
- f64 timeout;
- int rv;
- rv = vppjni_sanity_check (jm);
- if (rv) return NULL;
-
- vppjni_lock (jm, 15);
-
- if (~0 == bd_id) {
- bridge_domain_oper_free();
- }
-
- my_context_id = vppjni_get_context_id (jm);
- M(BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
- mp->context = clib_host_to_net_u32 (my_context_id);
- mp->bd_id = clib_host_to_net_u32(bd_id);
- S;
-
- /* Use a control ping for synchronization */
- {
- vl_api_control_ping_t * mp;
- M(CONTROL_PING, control_ping);
- S;
- }
-
- WNR;
- if (0 != rv) {
- return NULL;
- }
-
- jintArray ret = create_array_of_bd_ids(env, bd_id);
-
- vppjni_unlock (jm);
-
- return ret;
-}
-
-static void
-vl_api_bridge_domain_details_t_handler (vl_api_bridge_domain_details_t * mp)
-{
- vppjni_main_t *jm = &vppjni_main;
- vjbd_main_t * bdm = &jm->vjbd_main;
- vjbd_oper_t * bd_oper;
- u32 bd_id, bd_index;
-
- bd_id = ntohl (mp->bd_id);
-
- bd_index = vec_len(bdm->bd_oper);
- vec_validate (bdm->bd_oper, bd_index);
- bd_oper = vec_elt_at_index(bdm->bd_oper, bd_index);
-
- hash_set(bdm->oper_bd_index_by_bd_id, bd_id, bd_index);
-
- bd_oper->bd_id = bd_id;
- bd_oper->flood = mp->flood != 0;
- bd_oper->forward = mp->forward != 0;
- bd_oper->learn = mp->learn != 0;
- bd_oper->uu_flood = mp->uu_flood != 0;
- bd_oper->arp_term = mp->arp_term != 0;
- bd_oper->bvi_sw_if_index = ntohl (mp->bvi_sw_if_index);
- bd_oper->n_sw_ifs = ntohl (mp->n_sw_ifs);
-
- bd_oper->bd_sw_if_oper = 0;
-}
-
-static void
-vl_api_bridge_domain_sw_if_details_t_handler
-(vl_api_bridge_domain_sw_if_details_t * mp)
-{
- vppjni_main_t *jm = &vppjni_main;
- vjbd_main_t * bdm = &jm->vjbd_main;
- bd_sw_if_oper_t * bd_sw_if_oper;
- u32 bd_id, sw_if_index;
-
- bd_id = ntohl (mp->bd_id);
- sw_if_index = ntohl (mp->sw_if_index);
-
- uword *p;
- p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id);
- if (p == 0) {
- clib_warning("Invalid bd_id %d in bridge_domain_sw_if_details_t_handler", bd_id);
- return;
- }
- u32 oper_bd_index = (jint) p[0];
- vjbd_oper_t *bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index);
-
- u32 len = vec_len(bd_oper->bd_sw_if_oper);
- vec_validate(bd_oper->bd_sw_if_oper, len);
- bd_sw_if_oper = &bd_oper->bd_sw_if_oper[len];
- bd_sw_if_oper->bd_id = bd_id;
- bd_sw_if_oper->sw_if_index = sw_if_index;
- bd_sw_if_oper->shg = mp->shg;
-
- hash_set(bdm->bd_id_by_sw_if_index, sw_if_index, bd_id);
-}
-
-static const char* interface_name_from_sw_if_index(u32 sw_if_index)
-{
- vppjni_main_t *jm = &vppjni_main;
-
- if (sw_if_index >= vec_len(jm->sw_if_table)) {
- return NULL;
- }
- if (!jm->sw_if_table[sw_if_index].valid) {
- return NULL;
- }
- return (const char*)jm->sw_if_table[sw_if_index].interface_name;
-}
-
-JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getBridgeDomainDetails0
-(JNIEnv * env, jobject obj, jint bdId)
-{
- vppjni_main_t *jm = &vppjni_main;
- vjbd_main_t * bdm = &jm->vjbd_main;
- u32 oper_bd_index;
- u32 bd_id = bdId;
- jobject rv = NULL;
- uword *p;
-
- vppjni_lock (jm, 16);
-
- p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id);
- if (p == 0) {
- rv = NULL;
- goto out;
- }
- oper_bd_index = (jint) p[0];
-
- vjbd_oper_t *bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index);
-
-
- /* setting BridgeDomainDetails */
-
- jobject bddObj = vppBridgeDomainDetailsObject(env);
-
- u8 *vec_bd_name = vjbd_oper_name_from_id(bdm, bd_id);
- if (NULL == vec_bd_name) {
- rv = NULL;
- goto out;
- }
- char *str_bd_name = (char*)format (0, "%s%c", vec_bd_name, 0);
- vec_free(vec_bd_name);
- jstring bdName = (*env)->NewStringUTF(env, str_bd_name);
- vec_free(str_bd_name);
- if (NULL == bdName) {
- rv = NULL;
- goto out;
- }
-
- set_vppBridgeDomainDetails_name(env, bddObj, bdName);
- set_vppBridgeDomainDetails_bdId(env, bddObj, bdId);
- set_vppBridgeDomainDetails_flood(env, bddObj, (jboolean)bd_oper->flood);
- set_vppBridgeDomainDetails_uuFlood(env, bddObj, (jboolean)bd_oper->uu_flood);
- set_vppBridgeDomainDetails_forward(env, bddObj, (jboolean)bd_oper->forward);
- set_vppBridgeDomainDetails_learn(env, bddObj, (jboolean)bd_oper->learn);
- set_vppBridgeDomainDetails_arpTerm(env, bddObj, (jboolean)bd_oper->arp_term);
-
- jstring bviInterfaceName = NULL;
- if (~0 != bd_oper->bvi_sw_if_index) {
- const char *str_if_name = interface_name_from_sw_if_index(bd_oper->bvi_sw_if_index);
- if (NULL == str_if_name) {
- clib_warning("Could not get interface name for sw_if_index %d", bd_oper->bvi_sw_if_index);
- rv = NULL;
- goto out;
- }
- bviInterfaceName = (*env)->NewStringUTF(env, str_if_name);
- if (NULL == bviInterfaceName) {
- rv = NULL;
- goto out;
- }
- }
-
- set_vppBridgeDomainDetails_bviInterfaceName(env, bddObj, bviInterfaceName);
-
- /* setting BridgeDomainInterfaceDetails */
-
- u32 len = vec_len(bd_oper->bd_sw_if_oper);
- ASSERT(len == bd_oper->n_sw_ifs);
-
- jobjectArray bdidArray = vppBridgeDomainInterfaceDetailsArray(env, len);
-
- u32 i;
- for (i = 0; i < len; i++) {
- bd_sw_if_oper_t *sw_if_oper = &bd_oper->bd_sw_if_oper[i];
-
- jobject bdidObj = vppBridgeDomainInterfaceDetailsObject(env);
- (*env)->SetObjectArrayElement(env, bdidArray, i, bdidObj);
-
- u32 sw_if_index = sw_if_oper->sw_if_index;
- const char *str_if_name = interface_name_from_sw_if_index(sw_if_index);
- if (NULL == str_if_name) {
- rv = NULL;
- goto out;
- }
- jstring interfaceName = (*env)->NewStringUTF(env, str_if_name);
- if (NULL == interfaceName) {
- rv = NULL;
- goto out;
- }
-
- set_vppBridgeDomainInterfaceDetails_interfaceName(env, bdidObj, interfaceName);
- set_vppBridgeDomainInterfaceDetails_splitHorizonGroup(env, bdidObj, (jbyte)sw_if_oper->shg);
- }
-
- set_vppBridgeDomainDetails_interfaces(env, bddObj, bdidArray);
-
- rv = bddObj;
-
-out:
-
- vppjni_unlock (jm);
-
- return rv;
-}
-
-static jobject l2_fib_create_object(JNIEnv *env, bd_l2fib_oper_t *l2_fib)
-{
- u32 sw_if_index = l2_fib->sw_if_index;
- const char *str_if_name = interface_name_from_sw_if_index(sw_if_index);
- if (NULL == str_if_name) {
- return NULL;
- }
- jstring interfaceName = (*env)->NewStringUTF(env, str_if_name);
- if (NULL == interfaceName) {
- return NULL;
- }
-
- jbyteArray physAddr = (*env)->NewByteArray(env, 6);
- (*env)->SetByteArrayRegion(env, physAddr, 0, 6,
- (signed char*)l2_fib->mac_addr.fields.mac);
- jboolean staticConfig = !l2_fib->learned;
- jstring outgoingInterface = interfaceName;
- jboolean filter = l2_fib->filter;
- jboolean bridgedVirtualInterface = l2_fib->bvi;
-
- return vppL2FibObject(env, physAddr, staticConfig, outgoingInterface, filter, bridgedVirtualInterface);
-}
-
-JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_l2FibTableDump0
-(JNIEnv * env, jobject obj, jint bd_id)
-{
- vppjni_main_t *jm = &vppjni_main;
- vjbd_main_t * bdm = &jm->vjbd_main;
- vl_api_l2_fib_table_dump_t *mp;
- jobjectArray l2FibArray = NULL;
- vjbd_oper_t *bd_oper;
- u32 oper_bd_index;
- uword *p;
- f64 timeout;
- int rv;
- u32 i;
-
- vppjni_lock (jm, 17);
-
- //vjbd_l2fib_oper_reset (bdm);
-
- p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id);
- if (p == 0) {
- goto done;
- }
- oper_bd_index = p[0];
- bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index);
- vec_reset_length (bd_oper->l2fib_oper);
-
- /* Get list of l2 fib table entries */
- M(L2_FIB_TABLE_DUMP, l2_fib_table_dump);
- mp->bd_id = ntohl(bd_id);
- S;
-
- /* Use a control ping for synchronization */
- {
- vl_api_control_ping_t * mp;
- M(CONTROL_PING, control_ping);
- S;
- }
-
- WNR;
- if (0 != rv) {
- goto done;
- }
-
- u32 count = vec_len(bd_oper->l2fib_oper);
- bd_l2fib_oper_t *l2fib_oper = bd_oper->l2fib_oper;
-
- l2FibArray = vppL2FibArray(env, count);
- for (i = 0; i < count; i++) {
- bd_l2fib_oper_t *l2_fib = &l2fib_oper[i];
- jobject l2FibObj = l2_fib_create_object(env, l2_fib);
- (*env)->SetObjectArrayElement(env, l2FibArray, i, l2FibObj);
- }
-
-done:
- vppjni_unlock (jm);
-
- return l2FibArray;
-}
-
-static void
-vl_api_l2_fib_table_entry_t_handler (vl_api_l2_fib_table_entry_t * mp)
-{
- //static u8 * mac_addr;
- vppjni_main_t *jm = &vppjni_main;
- vjbd_main_t * bdm = &jm->vjbd_main;
- vjbd_oper_t * bd_oper;
- u32 bd_id, oper_bd_index;
- //uword mhash_val_l2fi;
- bd_l2fib_oper_t * l2fib_oper;
- l2fib_u64_mac_t * l2fe_u64_mac = (l2fib_u64_mac_t *)&mp->mac;
-
- bd_id = ntohl (mp->bd_id);
-
- uword *p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id);
- if (p == 0) {
- return;
- }
- oper_bd_index = (jint) p[0];
- bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index);
-
-#if 0
- vec_validate (mac_addr, MAC_ADDRESS_SIZE);
- clib_memcpy (mac_addr, l2fe_u64_mac->fields.mac, MAC_ADDRESS_SIZE);
- mhash_val_l2fi = vec_len (bd_oper->l2fib_oper);
- if (mhash_elts (&bd_oper->l2fib_index_by_mac) == 0)
- mhash_init (&bd_oper->l2fib_index_by_mac, sizeof (u32), MAC_ADDRESS_SIZE);
- mhash_set_mem (&bd_oper->l2fib_index_by_mac, mac_addr, &mhash_val_l2fi, 0);
-#endif
-
- vec_add2 (bd_oper->l2fib_oper, l2fib_oper, 1);
-
- l2fib_oper->bd_id = bd_id;
- l2fib_oper->mac_addr.raw = l2fib_mac_to_u64 (l2fe_u64_mac->fields.mac);
- l2fib_oper->sw_if_index = ntohl (mp->sw_if_index);
- l2fib_oper->learned = !mp->static_mac;
- l2fib_oper->filter = mp->filter_mac;
- l2fib_oper->bvi = mp->bvi_mac;
-}
-
-static int ipAddressDump
-(JNIEnv * env, jobject obj, jstring interfaceName, jboolean isIPv6)
-{
- vppjni_main_t *jm = &vppjni_main;
- vl_api_ip_address_dump_t * mp;
- const char *if_name;
- u32 my_context_id;
- u32 sw_if_index;
- f64 timeout;
- uword *p;
- int rv = 0;
-
- if (NULL == interfaceName) {
- return -1;
- }
-
- if_name = (*env)->GetStringUTFChars (env, interfaceName, NULL);
- if (!if_name) {
- return -1;
- }
-
- p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name);
- (*env)->ReleaseStringUTFChars (env, interfaceName, if_name);
- if (p == 0) {
- return -1;
- }
- sw_if_index = (u32) p[0];
-
- rv = vppjni_sanity_check (jm);
- if (0 != rv) {
- return rv;
- }
-
- my_context_id = vppjni_get_context_id (jm);
- M(IP_ADDRESS_DUMP, ip_address_dump);
- mp->context = clib_host_to_net_u32 (my_context_id);
- mp->sw_if_index = clib_host_to_net_u32(sw_if_index);
- mp->is_ipv6 = isIPv6;
- jm->is_ipv6 = isIPv6;
- S;
-
- /* Use a control ping for synchronization */
- {
- vl_api_control_ping_t * mp;
- M(CONTROL_PING, control_ping);
- S;
- }
-
- WNR;
-
- return rv;
-}
-
-JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_ipv4AddressDump0
-(JNIEnv * env, jobject obj, jstring interfaceName)
-{
- vppjni_main_t *jm = &vppjni_main;
- jobject returnArray = NULL;
- int i;
-
- vppjni_lock (jm, 18);
-
- vec_reset_length(jm->ipv4_addresses);
-
- if (0 != ipAddressDump(env, obj, interfaceName, 0)) {
- goto done;
- }
-
- u32 count = vec_len(jm->ipv4_addresses);
- ipv4_address_t *ipv4_address = jm->ipv4_addresses;
-
- jobjectArray ipv4AddressArray = vppIPv4AddressArray(env, count);
-
- for (i = 0; i < count; i++) {
- ipv4_address_t *address = &ipv4_address[i];
-
- jint ip = address->ip;
- jbyte prefixLength = address->prefix_length;
-
- jobject ipv4AddressObj = vppIPv4AddressObject(env, ip, prefixLength);
-
- (*env)->SetObjectArrayElement(env, ipv4AddressArray, i, ipv4AddressObj);
- }
-
- returnArray = ipv4AddressArray;
-
-done:
- vppjni_unlock (jm);
- return returnArray;
-}
-
-JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_ipv6AddressDump0
-(JNIEnv * env, jobject obj, jstring interfaceName)
-{
- vppjni_main_t *jm = &vppjni_main;
- jobject returnArray = NULL;
- int i;
-
- vppjni_lock (jm, 19);
-
- vec_reset_length(jm->ipv6_addresses);
-
- if (0 != ipAddressDump(env, obj, interfaceName, 1)) {
- goto done;
- }
-
- u32 count = vec_len(jm->ipv6_addresses);
- ipv6_address_t *ipv6_address = jm->ipv6_addresses;
-
- jobjectArray ipv6AddressArray = vppIPv6AddressArray(env, count);
-
- for (i = 0; i < count; i++) {
- ipv6_address_t *address = &ipv6_address[i];
-
- jbyteArray ip = (*env)->NewByteArray(env, 16);
- (*env)->SetByteArrayRegion(env, ip, 0, 16,
- (signed char*)address->ip);
-
- jbyte prefixLength = address->prefix_length;
-
- jobject ipv6AddressObj = vppIPv6AddressObject(env, ip, prefixLength);
-
- (*env)->SetObjectArrayElement(env, ipv6AddressArray, i, ipv6AddressObj);
- }
-
- returnArray = ipv6AddressArray;
-
-done:
- vppjni_unlock (jm);
- return returnArray;
-}
-
-static void vl_api_ip_address_details_t_handler (vl_api_ip_address_details_t * mp)
-{
- vppjni_main_t * jm = &vppjni_main;
-
- if (!jm->is_ipv6) {
- ipv4_address_t *address = 0;
- vec_add2(jm->ipv4_addresses, address, 1);
- clib_memcpy(&address->ip, mp->ip, 4);
- address->prefix_length = mp->prefix_length;
- } else {
- ipv6_address_t *address = 0;
- vec_add2(jm->ipv6_addresses, address, 1);
- clib_memcpy(address->ip, mp->ip, 16);
- address->prefix_length = mp->prefix_length;
- }
-}
-
-#define VXLAN_TUNNEL_INTERFACE_NAME_PREFIX "vxlan_tunnel"
-
-JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_vxlanTunnelDump0
-(JNIEnv * env, jobject obj, jint swIfIndex)
-{
- vppjni_main_t *jm = &vppjni_main;
- vl_api_vxlan_tunnel_dump_t * mp;
- jobjectArray returnArray = NULL;
- u32 my_context_id;
- f64 timeout;
- int rv = 0;
- int i;
-
- vppjni_lock (jm, 22);
-
- vec_reset_length(jm->vxlan_tunnel_details);
-
- my_context_id = vppjni_get_context_id (jm);
- M(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
- mp->context = clib_host_to_net_u32 (my_context_id);
- mp->sw_if_index = clib_host_to_net_u32 (swIfIndex);
- S;
-
- /* Use a control ping for synchronization */
- {
- vl_api_control_ping_t * mp;
- M(CONTROL_PING, control_ping);
- S;
- }
-
- WNR;
- if (0 != rv) {
- goto done;
- }
-
- u32 count = vec_len(jm->vxlan_tunnel_details);
-
- jobjectArray vxlanTunnelDetailsArray = vppVxlanTunnelDetailsArray(env, count);
-
- for (i = 0; i < count; i++) {
- vxlan_tunnel_details_t *details = &jm->vxlan_tunnel_details[i];
-
-
- /* This interface to support both v4 and v6 addresses is nasty */
- jbyteArray src_address = (*env)->NewByteArray(env, 16);
- (*env)->SetByteArrayRegion(env, src_address, 0, 16,
- (signed char*)details->src_address);
-
- jbyteArray dst_address = (*env)->NewByteArray(env, 16);
- (*env)->SetByteArrayRegion(env, dst_address, 0, 16,
- (signed char*)details->dst_address);
-
- jint encap_vrf_id = details->encap_vrf_id;
- jint vni = details->vni;
- jint decap_next_index = details->decap_next_index;
- jboolean is_ipv6 = details->is_ipv6 ? 1 : 0;
-
- jobject vxlanTunnelDetailsObj = vppVxlanTunnelDetailsObject(env,
- src_address, dst_address, encap_vrf_id, vni,
- decap_next_index, is_ipv6);
-
- (*env)->SetObjectArrayElement(env, vxlanTunnelDetailsArray, i,
- vxlanTunnelDetailsObj);
- }
-
- returnArray = vxlanTunnelDetailsArray;
-
-done:
- vppjni_unlock (jm);
- return returnArray;
-}
-
-static void vl_api_vxlan_tunnel_details_t_handler
-(vl_api_vxlan_tunnel_details_t * mp)
-{
- vppjni_main_t * jm = &vppjni_main;
- vxlan_tunnel_details_t *tunnel_details;
-
- vec_add2(jm->vxlan_tunnel_details, tunnel_details, 1);
- if (mp->is_ipv6){
- u64 *s, *d;
-
- /* this is ugly - why is this in host order at all? -cluke */
- /* Per notes from Ole, Maros and Keith, this should all be
- * superceded with a new api builder soon, so this interface will
- * be short lived -cluke */
- s = (void *)mp->src_address;
- d = (void *)tunnel_details->src_address;
-#if CLIB_ARCH_IS_LITTLE_ENDIAN
- d[0] = clib_net_to_host_u64(s[1]);
- d[1] = clib_net_to_host_u64(s[0]);
-#else /* big endian */
- d[0] = s[0];
- d[1] = s[1];
-#endif
-
- s = (void *)mp->dst_address;
- d = (void *)tunnel_details->dst_address;
-#if CLIB_ARCH_IS_LITTLE_ENDIAN
- d[0] = clib_net_to_host_u64(s[1]);
- d[1] = clib_net_to_host_u64(s[0]);
-#else /* big endian */
- d[0] = s[0];
- d[1] = s[1];
-#endif
- } else {
- u32 *s, *d;
-
- /* the type changed from a u32 to u8[16] - this does
- * the same as dst = ntohl(src) with the u32 of a v4
- * address in the first 32 bits */
-
- s = (void *)mp->src_address;
- d = (void *)tunnel_details->src_address;
- d[0] = ntohl(s[0]);
-
- s = (void *)mp->dst_address;
- d = (void *)tunnel_details->dst_address;
- d[0] = ntohl(s[0]);
- }
- tunnel_details->encap_vrf_id = ntohl(mp->encap_vrf_id);
- tunnel_details->vni = ntohl(mp->vni);
- tunnel_details->decap_next_index = ntohl(mp->decap_next_index);
- tunnel_details->is_ipv6 = mp->is_ipv6;
-}
-
-/* cleanup handler for RX thread */
-static void cleanup_rx_thread(void *arg)
-{
- vppjni_main_t * jm = &vppjni_main;
-
- vppjni_lock (jm, 99);
-
- int getEnvStat = (*jm->jvm)->GetEnv(jm->jvm, (void **)&(jm->jenv), JNI_VERSION_1_6);
- if (getEnvStat == JNI_EVERSION) {
- clib_warning ("Unsupported JNI version\n");
- jm->retval = -999;
- goto out;
- } else if (getEnvStat != JNI_EDETACHED) {
- (*jm->jvm)->DetachCurrentThread(jm->jvm);
- }
-out:
- vppjni_unlock (jm);
-}
-
-static void
-vl_api_show_version_reply_t_handler (vl_api_show_version_reply_t * mp)
-{
- vppjni_main_t * jm = &vppjni_main;
- i32 retval = ntohl(mp->retval);
-
- if (retval >= 0) {
- DEBUG_LOG ("show version request succeeded(%d)");
- strncpy((char*)jm->program_name, (const char*)mp->program,
- sizeof(jm->program_name)-1);
- jm->program_name[sizeof(jm->program_name)-1] = 0;
-
- strncpy((char*)jm->build_directory, (const char*)mp->build_directory,
- sizeof(jm->build_directory)-1);
- jm->build_directory[sizeof(jm->build_directory)-1] = 0;
-
- strncpy((char*)jm->version, (const char*)mp->version,
- sizeof(jm->version)-1);
- jm->version[sizeof(jm->version)-1] = 0;
-
- strncpy((char*)jm->build_date, (const char*)mp->build_date,
- sizeof(jm->build_date)-1);
- jm->build_date[sizeof(jm->build_date)-1] = 0;
- } else {
- clib_error ("show version request failed(%d)", retval);
- }
- jm->retval = retval;
- jm->result_ready = 1;
-}
-
-static void vl_api_want_stats_reply_t_handler (vl_api_want_stats_reply_t * mp)
-{
- vppjni_main_t * jm = &vppjni_main;
- jm->retval = mp->retval; // FIXME: vpp api does not do ntohl on this retval
- jm->result_ready = 1;
-}
-
-// control ping needs to be very first thing called
-// to attach rx thread to java thread
-static void vl_api_control_ping_reply_t_handler
-(vl_api_control_ping_reply_t * mp)
-{
- vppjni_main_t * jm = &vppjni_main;
- i32 retval = ntohl(mp->retval);
- jm->retval = retval;
-
- // attach to java thread if not attached
- int getEnvStat = (*jm->jvm)->GetEnv(jm->jvm, (void **)&(jm->jenv), JNI_VERSION_1_6);
- if (getEnvStat == JNI_EDETACHED) {
- if ((*jm->jvm)->AttachCurrentThread(jm->jvm, (void **)&(jm->jenv), NULL) != 0) {
- clib_warning("Failed to attach thread\n");
- jm->retval = -999;
- goto out;
- }
-
- // workaround as we can't use pthread_cleanup_push
- pthread_key_create(&jm->cleanup_rx_thread_key, cleanup_rx_thread);
- // destructor is only called if the value of key is non null
- pthread_setspecific(jm->cleanup_rx_thread_key, (void *)1);
- } else if (getEnvStat == JNI_EVERSION) {
- clib_warning ("Unsupported JNI version\n");
- jm->retval = -999;
- goto out;
- }
- // jm->jenv is now stable global reference that can be reused (only within RX thread)
-
-#if 0
- // ! callback system removed for now
- //
- // get issuer msg-id
- p = hash_get (jm->ping_hash, context);
- if (p != 0) { // ping marks end of some dump call
- JNIEnv *env = jm->jenv;
- u16 msg_id = (u16)p[0];
-
- // we will no longer need this
- hash_unset (jm->ping_hash, context);
-
- // get original caller obj
- p = hash_get (jm->callback_hash, context);
-
- if (p == 0) // don't have callback stored
- goto out;
-
- jobject obj = (jobject)p[0]; // object that called original call
-
- switch (msg_id) {
- case VL_API_SW_INTERFACE_DUMP:
- if (0 != sw_if_dump_call_all_callbacks(obj)) {
- goto out2;
- }
- break;
- default:
- clib_warning("Unhandled control ping issuer msg-id: %d", msg_id);
- goto out2;
- break;
- }
-out2:
- // free the saved obj
- hash_unset (jm->callback_hash, context);
- // delete global reference
- (*env)->DeleteGlobalRef(env, obj);
- }
-#endif
-
-out:
- jm->result_ready = 1;
-}
-
-#ifndef VPPJNI_DEBUG_COUNTERS
-#define VPPJNI_DEBUG_COUNTERS 0
-#endif
-
-static void vl_api_vnet_interface_counters_t_handler
-(vl_api_vnet_interface_counters_t *mp)
-{
- vppjni_main_t *jm = &vppjni_main;
- CLIB_UNUSED(char *counter_name);
- u32 count, sw_if_index;
- int i;
- static sw_interface_stats_t empty_stats = {0, };
-
- vppjni_lock (jm, 12);
- count = ntohl (mp->count);
- sw_if_index = ntohl (mp->first_sw_if_index);
- if (mp->is_combined == 0) {
- u64 * vp, v;
- vp = (u64 *) mp->data;
-
- for (i = 0; i < count; i++) {
- sw_interface_details_t *sw_if = NULL;
-
- v = clib_mem_unaligned (vp, u64);
- v = clib_net_to_host_u64 (v);
- vp++;
-
- if (sw_if_index < vec_len(jm->sw_if_table))
- sw_if = vec_elt_at_index(jm->sw_if_table, sw_if_index);
-
- if (sw_if /* && (sw_if->admin_up_down == 1)*/ && sw_if->interface_name[0] != 0) {
- vec_validate_init_empty(jm->sw_if_stats_by_sw_if_index, sw_if_index, empty_stats);
- sw_interface_stats_t * s = vec_elt_at_index(jm->sw_if_stats_by_sw_if_index, sw_if_index);
-
- s->sw_if_index = sw_if_index;
- s->valid = 1;
-
- switch (mp->vnet_counter_type) {
- case VNET_INTERFACE_COUNTER_DROP:
- counter_name = "drop";
- s->rx.pkts.discard = v;
- break;
- case VNET_INTERFACE_COUNTER_PUNT:
- counter_name = "punt";
- s->rx.pkts.unknown_proto = v;
- break;
- case VNET_INTERFACE_COUNTER_IP4:
- counter_name = "ip4";
- s->rx.pkts.ip4 = v;
- break;
- case VNET_INTERFACE_COUNTER_IP6:
- counter_name = "ip6";
- s->rx.pkts.ip6 = v;
- break;
- case VNET_INTERFACE_COUNTER_RX_NO_BUF:
- counter_name = "rx-no-buf";
- s->rx.pkts.fifo_full = v;
- break;
- case VNET_INTERFACE_COUNTER_RX_MISS:
- counter_name = "rx-miss";
- s->rx.pkts.miss = v;
- break;
- case VNET_INTERFACE_COUNTER_RX_ERROR:
- counter_name = "rx-error";
- s->rx.pkts.error = v;
- break;
- case VNET_INTERFACE_COUNTER_TX_ERROR:
- counter_name = "tx-error (fifo-full)";
- s->tx.pkts.fifo_full = v;
- break;
- default:
- counter_name = "bogus";
- break;
- }
-
-#if VPPJNI_DEBUG_COUNTERS == 1
- clib_warning ("%s (%d): %s (%lld)\n", sw_if->interface_name, s->sw_if_index,
- counter_name, v);
-#endif
- }
- sw_if_index++;
- }
- } else {
- vlib_counter_t *vp;
- u64 packets, bytes;
- vp = (vlib_counter_t *) mp->data;
-
- for (i = 0; i < count; i++) {
- sw_interface_details_t *sw_if = NULL;
-
- packets = clib_mem_unaligned (&vp->packets, u64);
- packets = clib_net_to_host_u64 (packets);
- bytes = clib_mem_unaligned (&vp->bytes, u64);
- bytes = clib_net_to_host_u64 (bytes);
- vp++;
-
- if (sw_if_index < vec_len(jm->sw_if_table))
- sw_if = vec_elt_at_index(jm->sw_if_table, sw_if_index);
-
- if (sw_if /* && (sw_if->admin_up_down == 1) */ && sw_if->interface_name[0] != 0) {
- vec_validate_init_empty(jm->sw_if_stats_by_sw_if_index, sw_if_index, empty_stats);
- sw_interface_stats_t * s = vec_elt_at_index(jm->sw_if_stats_by_sw_if_index, sw_if_index);
-
- s->valid = 1;
- s->sw_if_index = sw_if_index;
-
- switch (mp->vnet_counter_type) {
- case VNET_INTERFACE_COUNTER_RX:
- s->rx.pkts.unicast = packets;
- s->rx.octets = bytes;
- counter_name = "rx";
- break;
-
- case VNET_INTERFACE_COUNTER_TX:
- s->tx.pkts.unicast = packets;
- s->tx.octets = bytes;
- counter_name = "tx";
- break;
-
- default:
- counter_name = "bogus";
- break;
- }
-
-#if VPPJNI_DEBUG_COUNTERS == 1
- clib_warning ("%s (%d): %s.packets %lld\n",
- sw_if->interface_name,
- sw_if_index, counter_name, packets);
- clib_warning ("%s (%d): %s.bytes %lld\n",
- sw_if->interface_name,
- sw_if_index, counter_name, bytes);
-#endif
- }
- sw_if_index++;
- }
- }
- vppjni_unlock (jm);
-}
-
-jint JNI_OnLoad(JavaVM *vm, void *reserved) {
- vppjni_main_t * jm = &vppjni_main;
- JNIEnv* env;
- if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_6) != JNI_OK) {
- return JNI_ERR;
- }
-
- if (vppjni_init(env) != 0) {
- return JNI_ERR;
- }
-
- jm->jvm = vm;
- return JNI_VERSION_1_6;
-}
-
-void JNI_OnUnload(JavaVM *vm, void *reserved) {
- vppjni_main_t * jm = &vppjni_main;
- JNIEnv* env;
- if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_6) != JNI_OK) {
- return;
- }
-
- vppjni_uninit(env);
-
- jm->jenv = NULL;
- jm->jvm = NULL;
-}
-
-#define foreach_vpe_api_msg \
-_(CONTROL_PING_REPLY, control_ping_reply) \
-_(SW_INTERFACE_DETAILS, sw_interface_details) \
-_(SHOW_VERSION_REPLY, show_version_reply) \
-_(WANT_STATS_REPLY, want_stats_reply) \
-_(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
-_(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
-_(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
-_(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
-_(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
-_(IP_ADDRESS_DETAILS, ip_address_details) \
-_(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details)
-
-static int connect_to_vpe(char *name)
-{
- vppjni_main_t * jm = &vppjni_main;
- api_main_t * am = &api_main;
-
- if (vl_client_connect_to_vlib("/vpe-api", name, 32) < 0)
- return -1;
-
- jm->my_client_index = am->my_client_index;
- jm->vl_input_queue = am->shmem_hdr->vl_input_queue;
-
-#define _(N,n) \
- vl_msg_api_set_handlers(VL_API_##N, #n, \
- vl_api_##n##_t_handler, \
- vl_noop_handler, \
- vl_api_##n##_t_endian, \
- vl_api_##n##_t_print, \
- sizeof(vl_api_##n##_t), 1);
- foreach_vpe_api_msg;
-#undef _
-
- return 0;
-}
-
-/* Format an IP6 address. */
-u8 * format_ip6_address (u8 * s, va_list * args)
-{
- ip6_address_t * a = va_arg (*args, ip6_address_t *);
- u32 max_zero_run = 0, this_zero_run = 0;
- int max_zero_run_index = -1, this_zero_run_index=0;
- int in_zero_run = 0, i;
- int last_double_colon = 0;
-
- /* Ugh, this is a pain. Scan forward looking for runs of 0's */
- for (i = 0; i < ARRAY_LEN (a->as_u16); i++) {
- if (a->as_u16[i] == 0) {
- if (in_zero_run) {
- this_zero_run++;
- } else {
- in_zero_run = 1;
- this_zero_run =1;
- this_zero_run_index = i;
- }
- } else {
- if (in_zero_run) {
- /* offer to compress the biggest run of > 1 zero */
- if (this_zero_run > max_zero_run && this_zero_run > 1) {
- max_zero_run_index = this_zero_run_index;
- max_zero_run = this_zero_run;
- }
- }
- in_zero_run = 0;
- this_zero_run = 0;
- }
- }
-
- if (in_zero_run) {
- if (this_zero_run > max_zero_run && this_zero_run > 1) {
- max_zero_run_index = this_zero_run_index;
- max_zero_run = this_zero_run;
- }
- }
-
- for (i = 0; i < ARRAY_LEN (a->as_u16); i++) {
- if (i == max_zero_run_index) {
- s = format (s, "::");
- i += max_zero_run - 1;
- last_double_colon = 1;
- } else {
- s = format (s, "%s%x",
- (last_double_colon || i == 0) ? "" : ":",
- clib_net_to_host_u16 (a->as_u16[i]));
- last_double_colon = 0;
- }
- }
-
- return s;
-}
-
-/* Format an IP4 address. */
-u8 * format_ip4_address (u8 * s, va_list * args)
-{
- u8 * a = va_arg (*args, u8 *);
- return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
-}
-
-
diff --git a/vpp-api/java/japi/vppjni.h b/vpp-api/java/japi/vppjni.h
deleted file mode 100644
index bc738367..00000000
--- a/vpp-api/java/japi/vppjni.h
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __included_vppjni_h__
-#define __included_vppjni_h__
-
-#include <vnet/vnet.h>
-#include <vnet/ip/ip.h>
-#include <vnet/api_errno.h>
-#include <vlibapi/api.h>
-#include <vlibmemory/api.h>
-#include <jni.h>
-#include <japi/vppjni_bridge_domain.h>
-
-typedef struct {
- u8 * name;
- u32 value;
-} name_sort_t;
-
-typedef struct {
- u8 valid; // used in a vector of sw_interface_details_t
-
- u8 interface_name[64];
- u32 sw_if_index;
- u32 sup_sw_if_index;
- u32 l2_address_length;
- u8 l2_address[8];
- u8 admin_up_down;
- u8 link_up_down;
- u8 link_duplex;
- u8 link_speed;
- u16 link_mtu;
- u32 sub_id;
- u8 sub_dot1ad;
- u8 sub_number_of_tags;
- u16 sub_outer_vlan_id;
- u16 sub_inner_vlan_id;
- u8 sub_exact_match;
- u8 sub_default;
- u8 sub_outer_vlan_id_any;
- u8 sub_inner_vlan_id_any;
- u32 vtr_op;
- u32 vtr_push_dot1q;
- u32 vtr_tag1;
- u32 vtr_tag2;
-} sw_interface_details_t;
-
-typedef struct {
- u8 * interface_name;
- u32 sw_if_index;
- /*
- * Subinterface ID. A number 0-N to uniquely identify
- * this subinterface under the super interface
- */
- u32 sub_id;
-
- /* 0 = dot1q, 1=dot1ad */
- u8 sub_dot1ad;
-
- /* Number of tags 0-2 */
- u8 sub_number_of_tags;
- u16 sub_outer_vlan_id;
- u16 sub_inner_vlan_id;
- u8 sub_exact_match;
- u8 sub_default;
- u8 sub_outer_vlan_id_any;
- u8 sub_inner_vlan_id_any;
-
- /* vlan tag rewrite */
- u32 vtr_op;
- u32 vtr_push_dot1q;
- u32 vtr_tag1;
- u32 vtr_tag2;
-} sw_interface_subif_t;
-
-typedef struct {
- u8 *desc;
-} sw_if_config_t;
-
-typedef struct {
- u32 ip;
- u8 prefix_length;
-} ipv4_address_t;
-
-typedef struct {
- u8 ip[16];
- u8 prefix_length;
-} ipv6_address_t;
-
-typedef struct {
- u64 ip4;
- u64 ip6;
- u64 unicast;
- u64 multicast;
- u64 broadcast;
- u64 discard;
- u64 fifo_full;
- u64 error;
- u64 unknown_proto;
- u64 miss;
-} packet_counters_t;
-
-typedef struct {
- u64 octets;
- packet_counters_t pkts;
-} if_counters_t;
-
-typedef struct {
- u8 valid;
- u32 sw_if_index;
- if_counters_t rx;
- if_counters_t tx;
-} sw_interface_stats_t;
-
-typedef struct {
- u8 src_address[16];
- u8 dst_address[16];
- u32 encap_vrf_id;
- u32 vni;
- u32 decap_next_index;
- u8 is_ipv6;
-} vxlan_tunnel_details_t;
-
-
-typedef struct {
- /* Context IDs */
- volatile u32 context_id_sent;
- volatile u32 context_id_received;
-
- /* Spinlock */
- volatile u32 lock;
- u32 tag;
-
- /* To recycle pseudo-synchronous message code from vpp_api_test... */
- volatile u32 result_ready;
- volatile i32 retval;
- volatile u8 *shmem_result;
-
- /* thread cleanup */
- pthread_key_t cleanup_rx_thread_key;
- /* attachment of rx thread to java thread */
- JNIEnv *jenv;
- JavaVM *jvm;
- uword *callback_hash; // map context_id => jobject
- uword *ping_hash; // map ping context_id => msg type called
-
- /* Timestamp */
- clib_time_t clib_time;
-
- /* connected indication */
- u8 is_connected;
-
- /* context -> non-trivial reply hash */
- uword * reply_hash;
- u32 saved_reply_count;
-
- /* interface name map */
- uword * sw_if_index_by_interface_name;
-
- /* interface counters */
- sw_interface_stats_t * sw_if_stats_by_sw_if_index;
-
- /* interface table */
- sw_interface_details_t * sw_if_table;
-
- uword * sw_if_config_by_sw_if_index;
-
- /* interface indices of responses to one sw_if_dump request */
- u8 collect_indices;
- u32 * sw_if_dump_if_indices;
-
- /* program name, build_dir, version */
- u8 program_name[32];
- u8 build_directory[256];
- u8 version[32];
- u8 build_date[32];
-
- /* subinterface table */
- sw_interface_subif_t * sw_if_subif_table;
-
- /* used in ip_address_dump request and response handling */
- ipv4_address_t *ipv4_addresses;
- ipv6_address_t *ipv6_addresses;
- u8 is_ipv6;
-
- /* used in vxlan_tunnel_dump request and response handling */
- vxlan_tunnel_details_t *vxlan_tunnel_details;
-
- /* main heap */
- u8 * heap;
-
- /* convenience */
- unix_shared_memory_queue_t * vl_input_queue;
- api_main_t * api_main;
- u32 my_client_index;
-
- vjbd_main_t vjbd_main;
-} vppjni_main_t;
-
-vppjni_main_t vppjni_main __attribute__((aligned (64)));
-
-
-static inline u32 vppjni_get_context_id (vppjni_main_t * jm)
-{
- u32 my_context_id;
- my_context_id = __sync_add_and_fetch (&jm->context_id_sent, 1);
- return my_context_id;
-}
-
-static inline void vppjni_lock (vppjni_main_t * jm, u32 tag)
-{
- while (__sync_lock_test_and_set (&jm->lock, 1))
- ;
- jm->tag = tag;
-}
-
-static inline void vppjni_unlock (vppjni_main_t * jm)
-{
- jm->tag = 0;
- CLIB_MEMORY_BARRIER();
- jm->lock = 0;
-}
-
-static inline f64 vppjni_time_now (vppjni_main_t *jm)
-{
- return clib_time_now (&jm->clib_time);
-}
-
-static inline int vppjni_sanity_check (vppjni_main_t * jm)
-{
- if (!jm->is_connected)
- return VNET_API_ERROR_NOT_CONNECTED;
- return 0;
-}
-
-#define __PACKED(x) x __attribute__((packed))
-
-typedef __PACKED(struct _vl_api_generic_reply {
- u16 _vl_msg_id;
- u32 context;
- i32 retval;
- u8 data[0];
-}) vl_api_generic_reply_t;
-
-void vl_api_generic_reply_handler (vl_api_generic_reply_t *mp);
-
-/* M: construct, but don't yet send a message */
-
-#define M(T,t) \
-do { \
- jm->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T); \
- mp->client_index = jm->my_client_index; \
- } while(0);
-
-#define M2(T,t,n) \
-do { \
- jm->result_ready = 0; \
- mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
- memset (mp, 0, sizeof (*mp)); \
- mp->_vl_msg_id = ntohs (VL_API_##T); \
- mp->client_index = jm->my_client_index; \
- } while(0);
-
-
-/* S: send a message */
-#define S (vl_msg_api_send_shmem (jm->vl_input_queue, (u8 *)&mp))
-
-/* W: wait for results, with timeout */
-#define W \
- do { \
- timeout = vppjni_time_now (jm) + 1.0; \
- \
- while (vppjni_time_now (jm) < timeout) { \
- if (jm->result_ready == 1) { \
- return (jm->retval); \
- } \
- } \
- return -99; \
-} while(0);
-
-/* WNR: wait for results, with timeout (without returning) */
-#define WNR \
- do { \
- timeout = vppjni_time_now (jm) + 1.0; \
- \
- rv = -99; \
- while (vppjni_time_now (jm) < timeout) { \
- if (jm->result_ready == 1) { \
- rv = (jm->retval); \
- break; \
- } \
- } \
-} while(0);
-
-#endif /* __included_vppjni_h__ */
diff --git a/vpp-api/java/japi/vppjni_bridge_domain.h b/vpp-api/java/japi/vppjni_bridge_domain.h
deleted file mode 100644
index b614a5be..00000000
--- a/vpp-api/java/japi/vppjni_bridge_domain.h
+++ /dev/null
@@ -1,510 +0,0 @@
-/*---------------------------------------------------------------------------
- * Copyright (c) 2009-2014 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *---------------------------------------------------------------------------
- */
-
-#ifndef __included_vppjni_bridge_domain_h__
-#define __included_vppjni_bridge_domain_h__
-
-#include <vlib/vlib.h>
-#include <vppinfra/clib.h>
-#include <vppinfra/mhash.h>
-
-/*
- * The L2fib key is the mac address and bridge domain ID
- */
-#define MAC_ADDRESS_SIZE 6
-
-typedef struct {
- union {
- struct {
- u16 unused1;
- u8 mac[MAC_ADDRESS_SIZE];
- } fields;
- u64 raw;
- };
-} l2fib_u64_mac_t;
-
-/*
- * The l2fib entry results
- */
-typedef struct {
- u32 bd_id;
- l2fib_u64_mac_t mac_addr;
- u32 sw_if_index;
- u8 learned:1;
- u8 bvi:1;
- u8 filter:1; // drop packets to/from this mac
- u8 unused1:5;
-} bd_l2fib_oper_t;
-
-typedef struct {
- u32 bd_id;
- u8 * bd_name;
-} bd_local_cfg_t;
-
-typedef struct {
- u32 bd_id;
- u32 sw_if_index;
- u32 shg;
-} bd_sw_if_oper_t;
-
-typedef struct {
- u32 bd_id;
- u8 flood:1;
- u8 forward:1;
- u8 learn:1;
- u8 uu_flood:1;
- u8 arp_term:1;
- u8 unused1:3;
- u32 bvi_sw_if_index;
- u32 n_sw_ifs;
- bd_sw_if_oper_t * bd_sw_if_oper;
- f64 last_sync_time;
- mhash_t l2fib_index_by_mac;
- bd_l2fib_oper_t * l2fib_oper; // vector indexed by l2fib_index
-} vjbd_oper_t;
-
-#define BD_OPER_REFRESH_INTERVAL 2.0
-#define BD_OPER_L2FIB_REFRESH_INTERVAL 5.0
-
-typedef struct {
- u32 next_bd_id;
- uword * bd_index_bitmap;
- uword * bd_index_by_id;
- mhash_t bd_id_by_name;
- bd_local_cfg_t * local_cfg; // vector indexed by bd_index
- vjbd_oper_t * bd_oper; // vector indexed by oper_bd_index
- f64 bd_oper_last_sync_all_time;
- bd_sw_if_oper_t * sw_if_oper; // vector indexed by sw_if_index
- f64 l2fib_oper_last_sync_time;
- uword * bd_id_by_sw_if_index;
- uword * oper_bd_index_by_bd_id;
-} vjbd_main_t;
-
-extern vjbd_main_t vjbd_main;
-
-always_inline
-u64 l2fib_mac_to_u64 (u8 * mac_address) {
- u64 temp;
-
- // The mac address in memory is A:B:C:D:E:F
- // The bd id in register is H:L
-#if CLIB_ARCH_IS_LITTLE_ENDIAN
- // Create the in-register key as F:E:D:C:B:A:H:L
- // In memory the key is L:H:A:B:C:D:E:F
- temp = *((u64 *)(mac_address - 2));
- temp = (temp & ~0xffff);
-#else
- // Create the in-register key as H:L:A:B:C:D:E:F
- // In memory the key is H:L:A:B:C:D:E:F
- temp = *((u64 *)(mac_address)) >> 16;
-#endif
-
- return temp;
-}
-
-static_always_inline void vjbd_main_init (vjbd_main_t *bdm)
-{
- bdm->bd_index_by_id = hash_create (0, sizeof(uword));
- mhash_init_vec_string (&bdm->bd_id_by_name, sizeof (u32));
- bdm->bd_id_by_sw_if_index = hash_create (0, sizeof (u32));
- bdm->oper_bd_index_by_bd_id = hash_create (0, sizeof (u32));
-}
-
-static_always_inline u32 vjbd_id_is_valid (vjbd_main_t * bdm, u32 bd_id)
-{
- return ((bd_id != 0) && (bd_id != ~0) && (bd_id <= bdm->next_bd_id));
-}
-
-static_always_inline u32 vjbd_index_is_free (vjbd_main_t * bdm, u16 bd_index)
-{
- u32 bd_id = vec_elt_at_index(bdm->local_cfg, bd_index)->bd_id;
-
- return (!clib_bitmap_get (bdm->bd_index_bitmap, (bd_index)) &&
- (bd_index < vec_len (bdm->local_cfg)) &&
- ((bd_id == 0) || (bd_id == ~0)));
-}
-
-static_always_inline u32 vjbd_index_is_valid (vjbd_main_t * bdm, u16 bd_index)
-{
- return (clib_bitmap_get (bdm->bd_index_bitmap, bd_index) &&
- (bd_index < vec_len (bdm->local_cfg)));
-}
-
-static_always_inline u32 vjbd_id_from_name (vjbd_main_t * bdm,
- const u8 * bd_name)
-{
- u32 bd_id;
- uword * p;
-
- ASSERT (vec_c_string_is_terminated (bd_name));
-
- if (bdm->next_bd_id == 0)
- return ~0;
-
- p = mhash_get (&bdm->bd_id_by_name, (void *)bd_name);
- if (p)
- {
- bd_id = p[0];
- ASSERT (vjbd_id_is_valid (bdm, bd_id));
- }
- else
- bd_id = ~0;
-
- return bd_id;
-}
-
-static_always_inline u32 vjbd_index_from_id (vjbd_main_t * bdm, u32 bd_id)
-{
- uword * p;
- u16 bd_index;
-
- ASSERT (vjbd_id_is_valid (bdm, bd_id));
-
- p = hash_get (bdm->bd_index_by_id, bd_id);
-
- ASSERT (p); // there is always an index associated with a valid bd_id
- bd_index = p[0];
-
- ASSERT (vjbd_index_is_valid (bdm, bd_index));
-
- return bd_index;
-}
-
-static_always_inline u32 vjbd_id_from_index (vjbd_main_t * bdm, u16 bd_index)
-{
- u32 bd_id;
-
- ASSERT (vjbd_index_is_valid (bdm, bd_index));
-
- bd_id = vec_elt_at_index(bdm->local_cfg, bd_index)->bd_id;
-
- ASSERT (vjbd_id_is_valid (bdm, bd_id));
-
- return bd_id;
-}
-
-static_always_inline u8 * vjbd_name_from_id (vjbd_main_t * bdm, u32 bd_id)
-{
- u16 bd_index = vjbd_index_from_id (bdm, bd_id);
-
- return vec_elt_at_index(bdm->local_cfg, bd_index)->bd_name;
-}
-
-static_always_inline u8 * vjbd_oper_name_from_id (vjbd_main_t * bdm, u32 bd_id)
-{
- if (vjbd_id_is_valid (bdm, bd_id)) {
- return format(0, "%s", vjbd_name_from_id(bdm, bd_id));
- } else {
- return format(0, "BridgeDomainOper%d", bd_id);
- }
-}
-
-static_always_inline vjbd_oper_t * vjbd_oper_from_id (vjbd_main_t * bdm,
- u32 bd_id)
-{
- u16 bd_index = vjbd_index_from_id (bdm, bd_id);
- return vec_elt_at_index (bdm->bd_oper, bd_index);
-}
-
-static_always_inline void vjbd_oper_maybe_sync_from_vpp (vjbd_main_t * bdm,
- u32 bd_id)
-{
-#ifdef VPPJNI_OPER
- vppjni_vpe_api_msg_main_t *ovam = ovam_get_main ();
-
- if (bd_id == ~0)
- {
- if ((ovam_time_now (ovam) - bdm->bd_oper_last_sync_all_time) >
- BD_OPER_REFRESH_INTERVAL)
- {
- ovam_bridge_domain_dump (bd_id);
- bdm->bd_oper_last_sync_all_time = ovam_time_now (ovam);
- }
- }
-
- else
- {
- vjbd_oper_t * bd_oper = vjbd_oper_from_id (bdm, bd_id);
-
- if ((ovam_time_now (ovam) - bd_oper->last_sync_time) >
- BD_OPER_REFRESH_INTERVAL)
- {
- ovam_bridge_domain_dump (bd_id);
-
- bd_oper->last_sync_time = ovam_time_now (ovam);
- }
- }
-#endif
-}
-
-static_always_inline u32 vjbd_id_from_sw_if_index (vjbd_main_t * bdm,
- u32 sw_if_index)
-{
- bd_sw_if_oper_t * bd_sw_if_oper;
- u32 bd_id = ~0;
-
- vjbd_oper_maybe_sync_from_vpp (bdm, ~0);
- if (sw_if_index < vec_len (bdm->sw_if_oper))
- {
- bd_sw_if_oper = vec_elt_at_index (bdm->sw_if_oper, sw_if_index);
- bd_id = bd_sw_if_oper->bd_id;
- }
-
- return bd_id;
-}
-
-static_always_inline u8 * vjbd_name_from_sw_if_index (vjbd_main_t * bdm,
- u32 sw_if_index)
-{
- u32 bd_id, bd_index;
- u8 * bd_name = 0;
-
- /* DAW-FIXME:
- ASSERT (ovam_sw_if_index_valid (ovam_get_main(), sw_if_index));
- */
- vjbd_oper_maybe_sync_from_vpp (bdm, ~0);
- bd_id = vjbd_id_from_sw_if_index (bdm, sw_if_index);
- if (vjbd_id_is_valid (bdm, bd_id))
- {
- bd_index = vjbd_index_from_id (bdm, bd_id);
- bd_name = vec_elt_at_index (bdm->local_cfg, bd_index)->bd_name;
- }
-
- return bd_name;
-}
-
-static_always_inline u32
-vjbd_oper_l2fib_index_from_mac (vjbd_oper_t * bd_oper, u8 * mac)
-{
- u32 l2fib_index;
- uword * p;
-
- p = mhash_get (&bd_oper->l2fib_index_by_mac, mac);
- if (p)
- {
- l2fib_index = p[0];
- ASSERT (l2fib_index < vec_len (bd_oper->l2fib_oper));
- }
- else
- l2fib_index = ~0;
-
- return l2fib_index;
-}
-
-static_always_inline u32 vjbd_local_cfg_next_id (vjbd_main_t * bdm,
- u32 bd_id)
-{
- u32 i, end = vec_len (bdm->local_cfg);
- u32 next_bd_id = 0;
-
- if ((bd_id == 0) || vjbd_id_is_valid (bdm, bd_id))
- for (i = 0; i < end; i++)
- {
- u32 curr_bd_id = bdm->local_cfg[i].bd_id;
- if ((curr_bd_id != ~0) && (curr_bd_id > bd_id) &&
- ((next_bd_id == 0) || (curr_bd_id < next_bd_id)))
- next_bd_id = curr_bd_id;
- }
-
- return next_bd_id;
-}
-
-static_always_inline u32 vjbd_sw_if_oper_next_index (vjbd_main_t * bdm,
- u32 start, u32 bd_id)
-{
- u32 i, end = vec_len (bdm->sw_if_oper);
-
- if (vjbd_id_is_valid (bdm, bd_id))
- for (i = start; i < end; i++)
- if (bdm->sw_if_oper[i].bd_id == bd_id)
- return i;
-
- return ~0;
-}
-
-static_always_inline void
-vjbd_oper_l2fib_maybe_sync_from_vpp (vjbd_main_t * bdm)
-{
-#ifdef VPPJNI_OPER
- vppjni_vpe_api_msg_main_t *ovam = ovam_get_main ();
- if ((ovam_time_now (ovam) - bdm->l2fib_oper_last_sync_time) >
- BD_OPER_L2FIB_REFRESH_INTERVAL)
- {
- ovam_l2fib_table_dump ();
- bdm->l2fib_oper_last_sync_time = ovam_time_now (ovam);
- }
-#endif
-}
-
-static_always_inline void vjbd_l2fib_oper_reset (vjbd_main_t * bdm)
-{
- vjbd_oper_t * bd_oper;
-
- vec_foreach (bd_oper, bdm->bd_oper)
- {
- mhash_init (&bd_oper->l2fib_index_by_mac, sizeof (u32), MAC_ADDRESS_SIZE);
- vec_reset_length (bd_oper->l2fib_oper);
- }
-}
-
-static_always_inline void vjbd_oper_reset (vjbd_main_t * bdm, u32 bd_id)
-{
- u16 bd_index;
- u32 si, len;
- vjbd_oper_t * bd_oper;
- u32 end;
-
- if (!bdm->bd_oper)
- {
- ASSERT (vec_len (bdm->sw_if_oper) == 0);
- return;
- }
-
- if (bd_id == ~0)
- {
- bdm->bd_oper_last_sync_all_time = 0.0;
- bd_index = 0;
- end = vec_len (bdm->bd_oper);
- }
- else
- {
- bd_index = vjbd_index_from_id (bdm, bd_id);
- end = bd_index + 1;
- }
-
- for (; bd_index < end; bd_index++)
- {
- bd_oper = vec_elt_at_index (bdm->bd_oper, bd_index);
- bd_oper->last_sync_time = 0.0;
-
- len = vec_len (bdm->sw_if_oper);
- for (si = vjbd_sw_if_oper_next_index (bdm, 0, bd_id);
- (si != ~0) && (si < len);
- si = vjbd_sw_if_oper_next_index (bdm, si + 1, bd_id))
- {
- bd_sw_if_oper_t * bd_sw_if_oper;
-
- bd_sw_if_oper = vec_elt_at_index (bdm->sw_if_oper, si);
- bd_sw_if_oper->bd_id = ~0;
- }
- }
-}
-
-static_always_inline void
-vjbd_sw_if_add_del (u32 sw_if_index ,u32 bd_id, u8 bvi, u8 shg, u8 is_add)
-{
- vjbd_main_t * bdm = &vjbd_main;
- u16 bd_index = vjbd_index_from_id (bdm, bd_id);
- vjbd_oper_t * bd_oper = vec_elt_at_index (bdm->bd_oper, bd_index);
- bd_sw_if_oper_t * bd_sw_if_oper;
-
- ASSERT (vjbd_id_is_valid (bdm, bd_id));
- /* DAW-FIXME
- ASSERT (ovam_sw_if_index_valid (ovam_get_main (), sw_if_index));
- */
-
- vec_validate (bdm->sw_if_oper, sw_if_index);
- bd_sw_if_oper = vec_elt_at_index (bdm->sw_if_oper, sw_if_index);
- if (is_add)
- {
- bd_sw_if_oper->bd_id = bd_id;
- bd_sw_if_oper->shg = shg;
- bd_oper->bvi_sw_if_index = bvi ? sw_if_index : ~0;
- }
- else
- {
- bd_sw_if_oper->bd_id = 0;
- bd_sw_if_oper->shg = 0;
- if (bd_oper->bvi_sw_if_index == sw_if_index)
- bd_oper->bvi_sw_if_index = ~0;
- }
-}
-
-static_always_inline u32 vjbd_id_sw_if_count (vjbd_main_t * bdm, u32 bd_id)
-{
- u32 count = 0, i, end = vec_len (bdm->sw_if_oper);
-
- if (vjbd_id_is_valid (bdm, bd_id))
- for (count = i = 0; i < end; i++)
- if (bdm->sw_if_oper[i].bd_id == bd_id)
- count++;
-
- return count;
-}
-
-static_always_inline u32 vjbd_find_or_add_bd (vjbd_main_t * bdm, u8 * bd_name)
-{
- u16 bd_index;
- u32 bd_id;
- bd_local_cfg_t * bd_local_cfg;
- uword mhash_val_bd_id;
-
- bd_id = vjbd_id_from_name (bdm, bd_name);
- if (bd_id != ~0)
- return bd_id;
-
- mhash_val_bd_id = bd_id = ++bdm->next_bd_id;
- mhash_set_mem (&bdm->bd_id_by_name, (void *)bd_name, &mhash_val_bd_id, 0);
-
- bd_index = clib_bitmap_first_clear (bdm->bd_index_bitmap);
- vec_validate (bdm->local_cfg, bd_index);
- vec_validate (bdm->bd_oper, bd_index);
-
- ASSERT (vjbd_index_is_free (bdm, bd_index));
-
- bd_local_cfg = vec_elt_at_index (bdm->local_cfg, bd_index);
- bd_local_cfg->bd_id = bd_id;
- vec_validate_init_c_string (bd_local_cfg->bd_name, bd_name,
- vec_len (bd_name) - 1);
- hash_set (bdm->bd_index_by_id, bd_id, bd_index);
- bdm->bd_index_bitmap = clib_bitmap_set (bdm->bd_index_bitmap,
- bd_index, 1);
- return bd_id;
-}
-
-static_always_inline void vjbd_delete_bd (vjbd_main_t * bdm, u32 bd_id)
-{
- u16 bd_index;
- bd_local_cfg_t * bd_local_cfg;
-
- ASSERT (vjbd_id_is_valid (bdm, bd_id));
-
- // bd must not have any members before deleting
- ASSERT (!vjbd_id_sw_if_count (bdm, bd_id));
-
- bd_index = vjbd_index_from_id (bdm, bd_id);
- bd_local_cfg = vec_elt_at_index (bdm->local_cfg, bd_index);
- vjbd_oper_reset (bdm, bd_id);
-
- mhash_unset (&bdm->bd_id_by_name, vjbd_name_from_id (bdm, bd_id), 0);
- bdm->bd_index_bitmap = clib_bitmap_set (bdm->bd_index_bitmap,
- bd_index, 0);
- hash_unset (bdm->bd_index_by_id, bd_id);
- bd_local_cfg->bd_id = ~0;
- vec_validate_init_c_string (bd_local_cfg->bd_name, "", 0);
-
- if (clib_bitmap_is_zero (bdm->bd_index_bitmap))
- {
- vec_reset_length (bdm->local_cfg);
- vec_reset_length (bdm->bd_oper);
- }
-
- /* Force a resync of all bd_oper data. */
- bdm->bd_oper_last_sync_all_time = 0.0;
- vjbd_oper_maybe_sync_from_vpp (bdm, ~0);
-}
-
-#endif /* __included_vppjni_vpp_bridge_domain_h__ */
diff --git a/vpp-api/java/japi/vppjni_env.c b/vpp-api/java/japi/vppjni_env.c
deleted file mode 100644
index 1c4ea6eb..00000000
--- a/vpp-api/java/japi/vppjni_env.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <jni.h>
-
-#include "vppjni_env.h"
-
-// Head of the class registration list.
-static vppjni_class_t *class_head;
-// Head of the class registration list.
-static vppjni_field_t *field_head;
-
-void vppjni_register_class(vppjni_class_t *ptr)
-{
- vppjni_class_t **where = &class_head;
- while (*where != NULL) {
- where = &((*where)->next);
- }
- *where = ptr;
-}
-
-void vppjni_register_field(vppjni_field_t *ptr) {
- vppjni_field_t **where = &field_head;
- while (*where != NULL) {
- where = &((*where)->next);
- }
- *where = ptr;
-}
-
-jobject vppjni_new_object(JNIEnv *env, const vppjni_class_t *ptr, va_list ap) {
- jobject obj = (*env)->NewObjectV(env, ptr->jclass, ptr->jinit, ap);
- if ((*env)->ExceptionCheck(env)) {
- (*env)->ExceptionDescribe(env);
- return NULL;
- }
-
- return obj;
-}
-
-int vppjni_init(JNIEnv *env)
-{
- vppjni_class_t *cwlk;
- vppjni_field_t *fwlk;
-
- for (cwlk = class_head; cwlk != NULL; cwlk = cwlk->next) {
- jclass cls;
- jmethodID method;
-
- cls = (*env)->FindClass(env, cwlk->fqcn);
- if ((*env)->ExceptionCheck(env)) {
- (*env)->ExceptionDescribe(env);
- vppjni_uninit(env);
- return JNI_ERR;
- }
-
- method = (*env)->GetMethodID(env, cls, "<init>", cwlk->init_sig);
- if ((*env)->ExceptionCheck(env)) {
- (*env)->ExceptionDescribe(env);
- vppjni_uninit(env);
- return JNI_ERR;
- }
-
- cwlk->jclass = (*env)->NewGlobalRef(env, cls);
- if (cwlk->jclass == NULL) {
- vppjni_uninit(env);
- return JNI_ERR;
- }
- cwlk->jinit = method;
- }
-
- for (fwlk = field_head; fwlk != NULL; fwlk = fwlk->next) {
- fwlk->jfield = (*env)->GetFieldID(env, fwlk->clsref->jclass, fwlk->name, fwlk->type);
- if ((*env)->ExceptionCheck(env)) {
- (*env)->ExceptionDescribe(env);
- vppjni_uninit(env);
- return JNI_ERR;
- }
- }
-
- return 0;
-}
-
-void vppjni_uninit(JNIEnv *env) {
- vppjni_class_t *cwlk;
- vppjni_field_t *fwlk;
-
- for (fwlk = field_head; fwlk != NULL; fwlk = fwlk->next) {
- fwlk->jfield = NULL;
- }
-
- for (cwlk = class_head; cwlk != NULL; cwlk = cwlk->next) {
- if (cwlk->jclass != NULL ) {
- (*env)->DeleteGlobalRef(env, cwlk->jclass);
- }
-
- cwlk->jclass = NULL;
- cwlk->jinit = NULL;
- }
-}
-
diff --git a/vpp-api/java/japi/vppjni_env.h b/vpp-api/java/japi/vppjni_env.h
deleted file mode 100644
index 44029c2c..00000000
--- a/vpp-api/java/japi/vppjni_env.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Utilities for accessing Java classes/method/fields in an efficient
- * manner.
- */
-
-/*
- * A potentially-uninitialized reference to a Java class
- */
-typedef struct vppjni_class {
- // Fully-Qualified Class Name
- const char *fqcn;
- // Constructor signature
- const char *init_sig;
- // Global reference to class handle
- jclass jclass;
- // Constructor method handle
- jmethodID jinit;
- // Next item in linked list
- struct vppjni_class *next;
-} vppjni_class_t;
-
-typedef struct jenv_field {
- // Field name
- const char *name;
- // Field type
- const char *type;
- // Defining class reference
- const vppjni_class_t *clsref;
- // Field handle
- jfieldID jfield;
- // Next item in linked list
- struct jenv_field *next;
-} vppjni_field_t;
-
-#define VPPJNI_CLASS_SYMBOL(name) vppjni_class_##name
-#define VPPJNI_CLASS_INIT(name) vppjni_class_##name##_init
-#define BIND_JAPI_CLASS(name, sig) \
- static vppjni_class_t VPPJNI_CLASS_SYMBOL(name); \
- static void VPPJNI_CLASS_INIT(name)(void) __attribute__((__constructor__)); \
- static void VPPJNI_CLASS_INIT(name)() \
- { \
- VPPJNI_CLASS_SYMBOL(name).fqcn = "org/openvpp/vppjapi/" #name; \
- VPPJNI_CLASS_SYMBOL(name).init_sig = sig; \
- vppjni_register_class(&VPPJNI_CLASS_SYMBOL(name)); \
- } \
- static __attribute__((unused)) jobject name##Array(JNIEnv *env, jsize length) \
- { \
- return (*env)->NewObjectArray(env, length, VPPJNI_CLASS_SYMBOL(name).jclass, NULL); \
- } \
- static jobject name##Object(JNIEnv *env, ...) \
- { \
- va_list ap; \
- va_start(ap, env); \
- jobject obj = vppjni_new_object(env, &VPPJNI_CLASS_SYMBOL(name), ap); \
- va_end(ap); \
- return obj; \
- }
-
-#define VPPJNI_FIELD_SYMBOL(cls, name) vppjni_field_##cls##_##name
-#define VPPJNI_FIELD_INIT(cls, name) vppjni_field_##cls##_##name##_init
-#define BIND_JAPI_FIELD(cls, field, sig) \
- static vppjni_field_t VPPJNI_FIELD_SYMBOL(cls, field); \
- static void VPPJNI_FIELD_INIT(cls, field)(void) __attribute__((__constructor__)); \
- static void VPPJNI_FIELD_INIT(cls, field)() \
- { \
- VPPJNI_FIELD_SYMBOL(cls, field).name = #field; \
- VPPJNI_FIELD_SYMBOL(cls, field).type = sig; \
- VPPJNI_FIELD_SYMBOL(cls, field).clsref = &VPPJNI_CLASS_SYMBOL(cls); \
- vppjni_register_field(&VPPJNI_FIELD_SYMBOL(cls, field)); \
- }
-#define BIND_JAPI_BOOL_FIELD(cls, field) \
- BIND_JAPI_FIELD(cls, field, "Z"); \
- static void set_##cls##_##field(JNIEnv *env, jobject obj, jboolean value) \
- { \
- (*env)->SetBooleanField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \
- }
-#define BIND_JAPI_BYTE_FIELD(cls, field) \
- BIND_JAPI_FIELD(cls, field, "B"); \
- static void set_##cls##_##field(JNIEnv *env, jobject obj, jbyte value) \
- { \
- (*env)->SetByteField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \
- }
-#define BIND_JAPI_INT_FIELD(cls, field) \
- BIND_JAPI_FIELD(cls, field, "I"); \
- static void set_##cls##_##field(JNIEnv *env, jobject obj, jint value) \
- { \
- (*env)->SetIntField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \
- }
-#define BIND_JAPI_OBJ_FIELD(cls, field, sig) \
- BIND_JAPI_FIELD(cls, field, sig); \
- static void set_##cls##_##field(JNIEnv *env, jobject obj, jobject value) \
- { \
- (*env)->SetObjectField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \
- }
-#define BIND_JAPI_STRING_FIELD(cls, field) \
- BIND_JAPI_OBJ_FIELD(cls, field, "Ljava/lang/String;")
-
-jobject vppjni_new_object(JNIEnv *env, const vppjni_class_t *ptr, va_list ap) __attribute__ ((visibility ("hidden")));
-void vppjni_register_class(vppjni_class_t *ptr) __attribute__ ((visibility ("hidden")));
-void vppjni_register_field(vppjni_field_t *ptr) __attribute__ ((visibility ("hidden")));
-int vppjni_init(JNIEnv *env) __attribute__ ((visibility ("hidden")));
-void vppjni_uninit(JNIEnv *env) __attribute__ ((visibility ("hidden")));
-
diff --git a/vpp/vpp-api/vpe.api b/vpp/vpp-api/vpe.api
index 78a87f36..69ef7088 100644
--- a/vpp/vpp-api/vpe.api
+++ b/vpp/vpp-api/vpe.api
@@ -66,7 +66,7 @@ define want_interface_events_reply {
@param vtr_tag1
@param vtr_tag2
*/
-manual_java define sw_interface_details {
+define sw_interface_details {
u32 context;
u32 sw_if_index;
@@ -144,7 +144,7 @@ define sw_interface_set_flags_reply {
};
/* works */
-manual_java define sw_interface_dump {
+define sw_interface_dump {
u32 client_index;
u32 context;
u8 name_filter_valid;
@@ -293,7 +293,7 @@ define sw_interface_tap_dump {
@param sw_if_index - software index of tap interface
@param dev_name - Linux tap device name
*/
-manual_java define sw_interface_tap_details {
+define sw_interface_tap_details {
u32 context;
u32 sw_if_index;
u8 dev_name[64];
@@ -612,7 +612,7 @@ define want_stats {
@param context - returned sender context, to match reply w/ request
@param retval - return code
*/
-manual_java define want_stats_reply {
+define want_stats_reply {
u32 context;
i32 retval;
};
@@ -624,7 +624,7 @@ manual_java define want_stats_reply {
@param count - number of interfaces this stats block includes counters for
@param data - contiguous block of vlib_counter_t structures
*/
-manual_java define vnet_interface_counters {
+define vnet_interface_counters {
/* enums - plural - in vnet/interface.h */
u8 vnet_counter_type;
u8 is_combined;
@@ -640,7 +640,7 @@ typeonly manual_print manual_endian define ip4_fib_counter {
u64 bytes;
};
-manual_java manual_print manual_endian define vnet_ip4_fib_counters {
+manual_print manual_endian define vnet_ip4_fib_counters {
u32 vrf_id;
u32 count;
vl_api_ip4_fib_counter_t c[count];
@@ -653,7 +653,7 @@ typeonly manual_print manual_endian define ip6_fib_counter {
u64 bytes;
};
-manual_java manual_print manual_endian define vnet_ip6_fib_counters {
+manual_print manual_endian define vnet_ip6_fib_counters {
u32 vrf_id;
u32 count;
vl_api_ip6_fib_counter_t c[count];
@@ -687,7 +687,7 @@ define vnet_summary_stats_reply {
@param dst_address[] -
@param state
*/
-manual_java define oam_event {
+define oam_event {
u8 dst_address[4];
u8 state;
};
@@ -1055,7 +1055,7 @@ define delete_loopback_reply {
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
*/
-manual_java define control_ping {
+define control_ping {
u32 client_index;
u32 context;
};
@@ -1066,7 +1066,7 @@ manual_java define control_ping {
@param retval - return code for the request
@param vpe_pid - the pid of the vpe, returned by the server
*/
-manual_java define control_ping_reply {
+define control_ping_reply {
u32 context;
i32 retval;
u32 client_index;
@@ -1738,7 +1738,7 @@ define l2tpv3_set_tunnel_cookies_reply {
i32 retval;
};
-manual_java define sw_if_l2tpv3_tunnel_details {
+define sw_if_l2tpv3_tunnel_details {
u32 context;
u32 sw_if_index;
u8 interface_name[64];
@@ -1838,13 +1838,13 @@ define vxlan_add_del_tunnel_reply {
u32 sw_if_index;
};
-manual_java define vxlan_tunnel_dump {
+define vxlan_tunnel_dump {
u32 client_index;
u32 context;
u32 sw_if_index;
};
-manual_java define vxlan_tunnel_details {
+define vxlan_tunnel_details {
u32 context;
u32 sw_if_index;
u8 src_address[16];
@@ -1870,13 +1870,13 @@ define gre_add_del_tunnel_reply {
u32 sw_if_index;
};
-manual_java define gre_tunnel_dump {
+define gre_tunnel_dump {
u32 client_index;
u32 context;
u32 sw_if_index;
};
-manual_java define gre_tunnel_details {
+define gre_tunnel_details {
u32 context;
u32 sw_if_index;
u32 src_address;
@@ -2024,7 +2024,7 @@ define show_version {
@param version - version of the program
@param build_directory - root of the workspace where the program was built
*/
-manual_java define show_version_reply {
+define show_version_reply {
u32 context;
i32 retval;
u8 program[32];
@@ -2042,7 +2042,7 @@ manual_java define show_version_reply {
@param sock_filename - socket filename
@param num_regions - number of used memory regions
*/
-manual_java define sw_interface_vhost_user_details {
+define sw_interface_vhost_user_details {
u32 context;
u32 sw_if_index;
u8 interface_name[64];
@@ -2060,21 +2060,21 @@ define sw_interface_vhost_user_dump {
u32 context;
};
-manual_java define ip_address_details {
+define ip_address_details {
u32 client_index;
u32 context;
u8 ip[16];
u8 prefix_length;
};
-manual_java define ip_address_dump {
+define ip_address_dump {
u32 client_index;
u32 context;
u32 sw_if_index;
u8 is_ipv6;
};
-manual_java define ip_details {
+define ip_details {
u32 sw_if_index;
u32 context;
};
@@ -2093,7 +2093,7 @@ define ip_dump {
@param filter_mac - the entry is a mac filter entry.
@param bvi_mac - the mac address is a bridge virtual interface
*/
-manual_java define l2_fib_table_entry {
+define l2_fib_table_entry {
u32 context;
u32 bd_id;
u64 mac;
@@ -2107,7 +2107,7 @@ manual_java define l2_fib_table_entry {
@param client_index - opaque cookie to identify the sender
@param bd_id - the l2 fib / bridge domain table identifier
*/
-manual_java define l2_fib_table_dump {
+define l2_fib_table_dump {
u32 client_index;
u32 context;
u32 bd_id;
@@ -2132,13 +2132,13 @@ define vxlan_gpe_add_del_tunnel_reply {
u32 sw_if_index;
};
-manual_java define vxlan_gpe_tunnel_dump {
+define vxlan_gpe_tunnel_dump {
u32 client_index;
u32 context;
u32 sw_if_index;
};
-manual_java define vxlan_gpe_tunnel_details {
+define vxlan_gpe_tunnel_details {
u32 context;
u32 sw_if_index;
u8 local[16];
@@ -2500,7 +2500,7 @@ define lisp_eid_table_add_del_map_reply {
@param priority - locator priority
@param weight - locator weight
*/
-manual_java define lisp_locator_set_details {
+define lisp_locator_set_details {
u32 context;
u8 local;
u8 locator_set_name[64];
@@ -2527,7 +2527,7 @@ define lisp_locator_set_dump {
@param eid - array of address bytes
@param eid_prefix_len - prefix len
*/
-manual_java define lisp_local_eid_table_details {
+define lisp_local_eid_table_details {
u32 context;
u8 locator_set_name[64];
u8 eid_type;
@@ -2564,7 +2564,7 @@ define lisp_local_eid_table_dump {
@param vrf - VRF index
@param vni - vitual network instance
*/
-manual_java define lisp_eid_table_map_details {
+define lisp_eid_table_map_details {
u32 context;
u32 vni;
u32 vrf;
@@ -2579,7 +2579,7 @@ define lisp_eid_table_map_dump {
u32 context;
};
-manual_java define lisp_gpe_tunnel_details {
+define lisp_gpe_tunnel_details {
u32 context;
u32 tunnels;
u8 is_ipv6;
@@ -2610,7 +2610,7 @@ define lisp_gpe_tunnel_dump {
@param is_ipv6 - if non-zero the address is ipv6, else ipv4
@param ip_address - array of address bytes
*/
-manual_java define lisp_map_resolver_details {
+define lisp_map_resolver_details {
u32 context;
u8 is_ipv6;
u8 ip_address[16];
@@ -2629,7 +2629,7 @@ define lisp_map_resolver_dump {
@param context - sender context, to match reply w/ request
@param is_en - enable protocol if non-zero, else disable
*/
-manual_java define lisp_enable_disable_status_details {
+define lisp_enable_disable_status_details {
u32 context;
u8 feature_status;
u8 gpe_status;
@@ -2773,7 +2773,7 @@ define bridge_domain_add_del_reply {
@param context - sender context, to match reply w/ request
@param bd_id - the bridge domain id desired or ~0 to request all bds
*/
-manual_java define bridge_domain_dump {
+define bridge_domain_dump {
u32 client_index;
u32 context;
u32 bd_id;
@@ -2788,7 +2788,7 @@ manual_java define bridge_domain_dump {
@param arp_term - arp termination state on all interfaces in the bd
@param n_sw_ifs - number of sw_if_index's in the domain
*/
-manual_java define bridge_domain_details {
+define bridge_domain_details {
u32 context;
u32 bd_id;
u8 flood;
@@ -2805,7 +2805,7 @@ manual_java define bridge_domain_details {
@param sw_if_index - sw_if_index in the domain
@param shg - split horizon group for the interface
*/
-manual_java define bridge_domain_sw_if_details {
+define bridge_domain_sw_if_details {
u32 context;
u32 bd_id;
u32 sw_if_index;
@@ -3240,7 +3240,7 @@ define ikev2_set_local_key_reply {
@param router_address - Router IP address
@param host_mac - Host MAC address
*/
-manual_java define dhcp_compl_event {
+define dhcp_compl_event {
u32 client_index;
u32 pid;
u8 hostname[64];
@@ -3345,7 +3345,7 @@ define map_domain_dump {
u32 context;
};
-manual_java define map_domain_details {
+define map_domain_details {
u32 context;
u32 domain_index;
u8 ip6_prefix[16];
@@ -3368,7 +3368,7 @@ define map_rule_dump {
u32 domain_index;
};
-manual_java define map_rule_details {
+define map_rule_details {
u32 context;
u8 ip6_dst[16];
u16 psid;
@@ -3720,7 +3720,7 @@ define policer_dump {
@param extended_bucket - extended bucket
@param last_update_time - last update time
*/
-manual_java define policer_details {
+define policer_details {
u32 context;
u8 name[64];
@@ -3822,7 +3822,7 @@ define mpls_gre_tunnel_dump {
@param nlabels - number of resolved labels
@param labels - resolved labels
*/
-manual_java define mpls_gre_tunnel_details {
+define mpls_gre_tunnel_details {
u32 context;
u32 tunnel_index;
@@ -3861,7 +3861,7 @@ define mpls_eth_tunnel_dump {
@param nlabels - number of resolved labels
@param labels - resolved labels
*/
-manual_java define mpls_eth_tunnel_details {
+define mpls_eth_tunnel_details {
u32 context;
u32 tunnel_index;
@@ -3894,7 +3894,7 @@ define mpls_fib_encap_dump {
@param nlabels - number of resolved labels
@param labels - resolved labels
*/
-manual_java define mpls_fib_encap_details {
+define mpls_fib_encap_details {
u32 context;
u32 fib_index;
@@ -3924,7 +3924,7 @@ define mpls_fib_decap_dump {
@param tx_table_id - tx fib id
@param swif_tag -
*/
-manual_java define mpls_fib_decap_details {
+define mpls_fib_decap_details {
u32 context;
u32 fib_index;
@@ -3951,7 +3951,7 @@ define classify_table_ids {
@param count - number of ids returned in response
@param ids - array of classify table ids
*/
-manual_java define classify_table_ids_reply {
+define classify_table_ids_reply {
u32 context;
i32 retval;
u32 count;
@@ -3977,7 +3977,7 @@ define classify_table_by_interface {
@param ip4_table_id - ip4 classify table index
@param ip6_table_id - ip6 classify table index
*/
-manual_java define classify_table_by_interface_reply {
+define classify_table_by_interface_reply {
u32 context;
i32 retval;
u32 sw_if_index;
@@ -4009,7 +4009,7 @@ define classify_table_info {
@param miss_next_index - index of miss table
@param mask[] - match mask
*/
-manual_java define classify_table_info_reply {
+define classify_table_info_reply {
u32 context;
i32 retval;
u32 table_id;
@@ -4043,7 +4043,7 @@ define classify_session_dump {
@param advance - advance value of session
@param match[] - match value for session
*/
-manual_java define classify_session_details {
+define classify_session_details {
u32 context;
i32 retval;
u32 table_id;
@@ -4101,7 +4101,7 @@ define ipfix_dump {
@param path_mtu - Path MTU between exporter and collector
@param template_interval - number of seconds after which to resend template
*/
-manual_java define ipfix_details {
+define ipfix_details {
u32 context;
u8 collector_address[16];
u16 collector_port;
diff --git a/vppapigen/gram.y b/vppapigen/gram.y
index ccdcc8f2..de26af8d 100644
--- a/vppapigen/gram.y
+++ b/vppapigen/gram.y
@@ -38,7 +38,7 @@ void generate (YYSTYPE);
%token NAME RPAR LPAR SEMI LBRACK RBRACK NUMBER PRIMTYPE BARF
%token TPACKED DEFINE LCURLY RCURLY STRING UNION
%token HELPER_STRING COMMA
-%token NOVERSION MANUAL_PRINT MANUAL_ENDIAN MANUAL_JAVA TYPEONLY DONT_TRACE
+%token NOVERSION MANUAL_PRINT MANUAL_ENDIAN TYPEONLY DONT_TRACE
%%
@@ -62,7 +62,6 @@ flist: flist flag {$$ = (YYSTYPE)(unsigned long long)
flag:
MANUAL_PRINT {$$ = $1;}
| MANUAL_ENDIAN {$$ = $1;}
- | MANUAL_JAVA {$$ = $1;}
| DONT_TRACE {$$ = $1;}
| TYPEONLY {$$ = $1;}
;
diff --git a/vppapigen/lex.c b/vppapigen/lex.c
index f1d49a87..d7d8cbaf 100644
--- a/vppapigen/lex.c
+++ b/vppapigen/lex.c
@@ -28,8 +28,7 @@
#include "node.h"
#include "gram.h"
-FILE *ifp, *ofp, *javafp, *jnifp, *pythonfp;
-char *java_class = "vppApi";
+FILE *ifp, *ofp, *pythonfp;
char *vlib_app_name = "vpp";
int dump_tree;
time_t starttime;
@@ -258,8 +257,6 @@ int main (int argc, char **argv)
{
int curarg = 1;
char *ofile=0;
- char *jofile=0;
- char *jnifile=0;
char *pythonfile=0;
char *show_name=0;
@@ -331,40 +328,6 @@ int main (int argc, char **argv)
}
continue;
}
- if (!strncmp (argv [curarg], "--java", 4)) {
- curarg++;
- if (curarg < argc) {
- javafp = fopen (argv[curarg], "w");
- if (javafp == NULL) {
- fprintf (stderr, "Couldn't open java output file %s\n",
- argv[curarg]);
- exit (1);
- }
- jofile = argv[curarg];
- curarg++;
- } else {
- fprintf(stderr, "Missing filename after --java\n");
- exit(1);
- }
- continue;
- }
- if (!strncmp (argv [curarg], "--jni", 4)) {
- curarg++;
- if (curarg < argc) {
- jnifp = fopen (argv[curarg], "w");
- if (jnifp == NULL) {
- fprintf (stderr, "Couldn't open jni output file %s\n",
- argv[curarg]);
- exit (1);
- }
- jnifile = argv[curarg];
- curarg++;
- } else {
- fprintf(stderr, "Missing filename after --jni\n");
- exit(1);
- }
- continue;
- }
if (!strncmp (argv [curarg], "--python", 8)) {
curarg++;
if (curarg < argc) {
@@ -393,17 +356,6 @@ int main (int argc, char **argv)
}
continue;
}
- if (!strncmp (argv [curarg], "--class", 3)) {
- curarg++;
- if (curarg < argc) {
- java_class = argv[curarg];
- curarg++;
- } else {
- fprintf(stderr, "Missing class name after --class\n");
- exit(1);
- }
- continue;
- }
usage(argv[0]);
exit (1);
@@ -411,12 +363,6 @@ int main (int argc, char **argv)
if (ofp == NULL) {
ofile = 0;
}
- if (javafp == NULL) {
- jofile = 0;
- }
- if (jnifp == NULL) {
- jnifile = 0;
- }
if (pythonfp == NULL) {
pythonfile = 0;
}
@@ -437,14 +383,6 @@ int main (int argc, char **argv)
printf ("Output written to %s\n", ofile);
fclose (ofp);
}
- if (jofile) {
- printf ("Java class defn written to %s\n", jofile);
- fclose (javafp);
- }
- if (jnifile) {
- printf ("Java native bindings written to %s\n", jnifile);
- fclose (jnifp);
- }
if (pythonfile) {
printf ("Python bindings written to %s\n", pythonfile);
fclose (pythonfp);
@@ -457,15 +395,6 @@ int main (int argc, char **argv)
printf ("Removing %s\n", ofile);
unlink (ofile);
}
- fclose (javafp);
- if (jofile) {
- printf ("Removing %s\n", jofile);
- unlink (jofile);
- }
- if (jnifile) {
- printf ("Removing %s\n", jnifile);
- unlink (jnifile);
- }
if (pythonfile) {
printf ("Removing %s\n", pythonfile);
unlink (pythonfile);
@@ -926,7 +855,6 @@ int yylex (void)
case NOVERSION: crc = CRC16 (crc, 274); break;
case MANUAL_PRINT: crc = CRC16 (crc, 275); break;
case MANUAL_ENDIAN: crc = CRC16 (crc, 276); break;
- case MANUAL_JAVA: crc = CRC16 (crc, 277); break;
case TYPEONLY: crc = CRC16 (crc, 278); break;
case DONT_TRACE: crc = CRC16 (crc, 279); break;
@@ -965,7 +893,6 @@ static struct keytab {
{"i64", NODE_I64},
{"i8", NODE_I8},
{"manual_endian", NODE_MANUAL_ENDIAN},
- {"manual_java", NODE_MANUAL_JAVA},
{"manual_print", NODE_MANUAL_PRINT},
{"noversion", NODE_NOVERSION},
{"packed", NODE_PACKED},
@@ -1025,10 +952,6 @@ static int name_check (const char *s, YYSTYPE *token_value)
*token_value = (YYSTYPE) NODE_FLAG_MANUAL_ENDIAN;
return (MANUAL_ENDIAN);
- case NODE_MANUAL_JAVA:
- *token_value = (YYSTYPE) NODE_FLAG_MANUAL_JAVA;
- return (MANUAL_JAVA);
-
case NODE_TYPEONLY:
*token_value = (YYSTYPE) NODE_FLAG_TYPEONLY;
return(TYPEONLY);
diff --git a/vppapigen/node.c b/vppapigen/node.c
index 449540c3..ef812787 100644
--- a/vppapigen/node.c
+++ b/vppapigen/node.c
@@ -32,10 +32,7 @@
#define YYSTYPE void *
FILE *ofp;
-FILE *javafp;
-FILE *jnifp;
FILE *pythonfp;
-char *java_class;
time_t starttime;
char *vlib_app_name;
char *input_filename;
@@ -53,11 +50,6 @@ static char current_id;
static char current_is_complex;
static char *current_endianfun;
static char *current_type_name;
-static int current_java_parameter_number;
-static int current_java_emitted_parameter;
-static int current_java_parameter_need_comma_space;
-void *current_java_methodfun;
-void *current_java_jnifun;
void indent_me(FILE *ofp)
{
@@ -99,31 +91,6 @@ char *lowercase (char *s)
return(tmpbuf);
}
-/*
- * javah maps foo_bar to foo_1bar for whatever freakin' reason
- * So, adjust java names accordingly.
- */
-char *java_name_mangle (void * name_arg)
-{
- char * name = name_arg;
- static u8 * s;
- int i;
-
- vec_reset_length (s);
-
- s = format (s, "%s%c", name, 0);
-
- for (i = 0; i < vec_len(s); i++)
- if (s[i] == '_') {
- vec_delete (s, 1, i);
- if (s[i] >= 'a' && s[i] <= 'z')
- s[i] -= ('a' - 'A');
- }
- vec_add1 (s, 0);
-
- return ((char *) s);
-}
-
void primtype_recursive_print(node_t *this, i8 *fmt)
{
fputs((char *)fmt, stdout);
@@ -157,11 +124,6 @@ void primtype_recursive_generate(node_t *this, enum passid which, FILE *ofp,
current_endianfun = vftp->endian_converter;
break;
- case JAVA_METHOD_PASS:
- vftp = the_vft[this->type];
- current_java_methodfun = vftp->java_method_function;
- break;
-
case PYTHON_PASS:
fputs("('", pythonfp);
fputs((char *)type_name, pythonfp);
@@ -179,163 +141,6 @@ void primtype_recursive_generate(node_t *this, enum passid which, FILE *ofp,
}
}
-static int hidden_from_java(const node_t * deeper)
-{
- if (current_java_parameter_number++ < 3) {
- if (!strncmp ((char *)(deeper->data[0]), "client_index", 12))
- return 1;
- else if (!strncmp ((char *)(deeper->data[0]), "context", 7))
- return 1;
- else if (!strncmp ((char *)(deeper->data[0]), "_vl_msg_id", 10))
- return 1;
- }
-
- return 0;
-}
-
-void primtype_java_method (node_t * this, enum passid which, FILE *ofp,
- char *java_type_name)
-{
- node_t * deeper;
-
- deeper = this->deeper;
-
- /* We'll take care of _msg_id, client_index, and context ourselves */
- if (hidden_from_java(deeper)) {
- return;
- }
-
- if (deeper->type == NODE_SCALAR)
- fprintf (ofp, "%s %s", java_type_name,
- java_name_mangle(deeper->data[0]));
- else
- fprintf (ofp, "%s [] %s", java_type_name,
- java_name_mangle(deeper->data[0]));
-
- current_java_emitted_parameter = 1;
-}
-
-void primtype_java_parameter (node_t * this, enum passid which, FILE *ofp,
- char *java_type_name)
-{
- node_t * deeper;
-
- deeper = this->deeper;
-
- /* We'll take care of _msg_id, client_index, and context ourselves */
- if (hidden_from_java(deeper)) {
- return;
- }
- if (current_java_parameter_need_comma_space) {
- current_java_parameter_need_comma_space = 0;
- fputs (", ", ofp);
- }
-
- if (deeper->type == NODE_SCALAR)
- fprintf (ofp, "%s %s", java_type_name, (char *)(deeper->data[0]));
- else
- fprintf (ofp, "%sArray %s", java_type_name, (char *)(deeper->data[0]));
-
- current_java_emitted_parameter = 1;
-}
-
-void primtype_java_setup (node_t * this, enum passid which, FILE *ofp,
- char *java_type_name, char *array_element_name)
-{
- node_t * deeper;
-
- deeper = this->deeper;
-
- /* We'll take care of _msg_id, client_index, and context ourselves */
- if (hidden_from_java(deeper)) {
- return;
- }
-
- if (deeper->type == NODE_VECTOR) {
- indent_me(ofp);
- fprintf (ofp,
- "%s * %sP = (*env)->Get%sArrayElements (env, %s, NULL);\n",
- java_type_name, (char *)(deeper->data[0]),
- array_element_name, (char *)(deeper->data[0]));
- }
-
- current_java_emitted_parameter = 1;
-}
-
-void primtype_java_code (node_t * this, enum passid which, FILE *ofp,
- char *java_type_name, char * swapper)
-{
- node_t * deeper;
- char * s;
-
- deeper = this->deeper;
-
- /* We'll take care of _msg_id, client_index, and context ourselves */
- if (hidden_from_java(deeper)) {
- return;
- }
-
- indent_me(ofp);
-
- s = (char *)(deeper->data[0]);
-
- if (swapper == 0) {
- if (deeper->type == NODE_VECTOR)
- fprintf (ofp, "memcpy (mp->%s, %sP, sizeof (mp->%s));\n",
- s, s, s);
- else
- fprintf (ofp, "mp->%s = %s;\n", s, s);
- } else {
- if (deeper->type == NODE_VECTOR) {
- fprintf(ofp, "{\n");
- indent += 4;
- indent_me(ofp);
- fprintf(ofp, "int _i;\n");
- indent_me(ofp);
- fprintf(ofp, "for (_i = 0; _i < %lu; _i++) {\n",
- (u64)(deeper->data[1]));
- indent += 4;
- indent_me(ofp);
- fprintf(ofp, "mp->%s[_i] = %s(%sP[_i]);\n",
- s, swapper, s);
- indent -= 4;
- indent_me(ofp);
- fprintf(ofp, "}\n");
- indent -= 4;
- indent_me(ofp);
- fprintf(ofp, "}\n");
- } else {
- fprintf (ofp, "mp->%s = %s(%s);\n", s, swapper, s);
- }
- }
-
- current_java_emitted_parameter = 1;
-}
-
-void primtype_java_teardown (node_t * this, enum passid which, FILE *ofp,
- char * array_element_name)
-{
- node_t * deeper;
-
- deeper = this->deeper;
-
- /* We'll take care of _msg_id, client_index, and context ourselves */
- if (hidden_from_java(deeper)) {
- return;
- }
-
- if (deeper->type == NODE_VECTOR) {
- indent_me(ofp);
- fprintf (ofp,
- "(*env)->Release%sArrayElements (env, %s, %sP, 0);\n",
- array_element_name,
- (char *)(deeper->data[0]),
- (char *)(deeper->data[0]));
- }
-
- current_java_emitted_parameter = 1;
-}
-
void node_illegal_print (node_t *this)
{
fprintf(stderr, "node_illegal_print called\n");
@@ -348,24 +153,10 @@ void node_illegal_generate (node_t *this, enum passid notused, FILE *ofp)
exit(0);
}
-void node_illegal_java_method (node_t *this, enum passid notused, FILE *ofp)
-{
- fprintf(stderr, "node_illegal_java_method called\n");
- exit(0);
-}
-
-void node_illegal_java_jni (node_t *this, enum passid notused, FILE *ofp)
-{
- fprintf(stderr, "node_illegal_java_jni called\n");
- exit(0);
-}
-
node_vft_t node_illegal_vft = {
node_illegal_print,
node_illegal_generate,
- "illegal",
- node_illegal_java_method,
- node_illegal_java_jni,
+ "illegal"
};
void node_u8_print (node_t *this)
@@ -378,40 +169,10 @@ void node_u8_generate (node_t *this, enum passid which, FILE *ofp)
primtype_recursive_generate(this, which, ofp, "u8", "%u", "(unsigned)");
}
-void node_u8_java_method (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_method (this, which, ofp, "byte");
-}
-
-void node_u8_java_parameter (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_parameter (this, which, ofp, "jbyte");
-}
-
-void node_u8_java_setup (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_setup (this, which, ofp, "jbyte", "Byte");
-}
-
-void node_u8_java_code (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_code (this, which, ofp, "jbyte", 0 /* swapper */);
-}
-
-void node_u8_java_teardown (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_teardown (this, which, ofp, "Byte");
-}
-
node_vft_t node_u8_vft = {
node_u8_print,
node_u8_generate,
- "",
- node_u8_java_method,
- node_u8_java_parameter,
- node_u8_java_setup,
- node_u8_java_code,
- node_u8_java_teardown,
+ ""
};
void node_u16_print (node_t *this)
@@ -424,40 +185,10 @@ void node_u16_generate (node_t *this, enum passid which, FILE *ofp)
primtype_recursive_generate(this, which, ofp, "u16", "%u", "(unsigned)");
}
-void node_u16_java_method (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_method (this, which, ofp, "short");
-}
-
-void node_u16_java_parameter (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_parameter (this, which, ofp, "jshort");
-}
-
-void node_u16_java_setup (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_setup (this, which, ofp, "jshort", "Short");
-}
-
-void node_u16_java_code (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_code (this, which, ofp, "jshort", "clib_host_to_net_u16");
-}
-
-void node_u16_java_teardown (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_teardown (this, which, ofp, "Short");
-}
-
node_vft_t node_u16_vft = {
node_u16_print,
node_u16_generate,
- "clib_net_to_host_u16",
- node_u16_java_method,
- node_u16_java_parameter,
- node_u16_java_setup,
- node_u16_java_code,
- node_u16_java_teardown,
+ "clib_net_to_host_u16"
};
void node_u32_print (node_t *this)
@@ -470,40 +201,10 @@ void node_u32_generate (node_t *this, enum passid which, FILE *ofp)
primtype_recursive_generate(this, which, ofp, "u32", "%u", "(unsigned)");
}
-void node_u32_java_method (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_method (this, which, ofp, "int");
-}
-
-void node_u32_java_parameter (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_parameter (this, which, ofp, "jint");
-}
-
-void node_u32_java_setup (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_setup (this, which, ofp, "jint", "Int");
-}
-
-void node_u32_java_code (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_code (this, which, ofp, "jint", "clib_host_to_net_u32");
-}
-
-void node_u32_java_teardown (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_teardown (this, which, ofp, "Int");
-}
-
node_vft_t node_u32_vft = {
node_u32_print,
node_u32_generate,
"clib_net_to_host_u32",
- node_u32_java_method,
- node_u32_java_parameter,
- node_u32_java_setup,
- node_u32_java_code,
- node_u32_java_teardown,
};
void node_u64_print (node_t *this)
@@ -517,40 +218,10 @@ void node_u64_generate (node_t *this, enum passid which, FILE *ofp)
"(long long)");
}
-void node_u64_java_method (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_method (this, which, ofp, "long");
-}
-
-void node_u64_java_parameter (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_parameter (this, which, ofp, "jlong");
-}
-
-void node_u64_java_setup (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_setup (this, which, ofp, "jlong", "Long");
-}
-
-void node_u64_java_code (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_code (this, which, ofp, "jlong", "clib_host_to_net_u64");
-}
-
-void node_u64_java_teardown (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_teardown (this, which, ofp, "Long");
-}
-
node_vft_t node_u64_vft = {
node_u64_print,
node_u64_generate,
- "clib_net_to_host_u64",
- node_u64_java_method,
- node_u64_java_parameter,
- node_u64_java_setup,
- node_u64_java_code,
- node_u64_java_teardown,
+ "clib_net_to_host_u64"
};
void node_i8_print (node_t *this)
@@ -566,12 +237,7 @@ void node_i8_generate (node_t *this, enum passid which, FILE *ofp)
node_vft_t node_i8_vft = {
node_i8_print,
node_i8_generate,
- "",
- node_u8_java_method,
- node_u8_java_parameter,
- node_u8_java_setup,
- node_u8_java_code,
- node_u8_java_teardown,
+ ""
};
void node_i16_print (node_t *this)
@@ -587,12 +253,7 @@ void node_i16_generate (node_t *this, enum passid which, FILE *ofp)
node_vft_t node_i16_vft = {
node_i16_print,
node_i16_generate,
- "clib_net_to_host_u16",
- node_u16_java_method,
- node_u16_java_parameter,
- node_u16_java_setup,
- node_u16_java_code,
- node_u16_java_teardown,
+ "clib_net_to_host_u16"
};
void node_i32_print (node_t *this)
@@ -608,12 +269,7 @@ void node_i32_generate (node_t *this, enum passid which, FILE *ofp)
node_vft_t node_i32_vft = {
node_i32_print,
node_i32_generate,
- "clib_net_to_host_u32",
- node_u32_java_method,
- node_u32_java_parameter,
- node_u32_java_setup,
- node_u32_java_code,
- node_u32_java_teardown,
+ "clib_net_to_host_u32"
};
void node_i64_print (node_t *this)
@@ -630,12 +286,7 @@ void node_i64_generate (node_t *this, enum passid which, FILE *ofp)
node_vft_t node_i64_vft = {
node_i64_print,
node_i64_generate,
- "clib_net_to_host_u64",
- node_u64_java_method,
- node_u64_java_parameter,
- node_u64_java_setup,
- node_u64_java_code,
- node_u64_java_teardown,
+ "clib_net_to_host_u64"
};
void node_f64_print (node_t *this)
@@ -648,44 +299,11 @@ void node_f64_generate (node_t *this, enum passid which, FILE *ofp)
primtype_recursive_generate(this, which, ofp, "f64", "%.2f",
"(double)");
}
-void node_f64_java_method (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_method (this, which, ofp, "double");
-}
-
-void node_f64_java_parameter (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_parameter (this, which, ofp, "jdouble");
-}
-
-void node_f64_java_setup (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_setup (this, which, ofp, "jdouble", "Double");
-}
-
-void node_f64_java_code (node_t *this, enum passid which, FILE *ofp)
-{
- /*
- * Current API code doesn't try to endian-swap doubles
- * FP formats aren't portable yadda yadda yadda
- */
- primtype_java_code (this, which, ofp, "jdouble", 0 /* $$$ */);
-}
-
-void node_f64_java_teardown (node_t *this, enum passid which, FILE *ofp)
-{
- primtype_java_teardown (this, which, ofp, "Double");
-}
node_vft_t node_f64_vft = {
node_f64_print,
node_f64_generate,
" ", /* FP numbers are sent in host byte order */
- node_f64_java_method,
- node_f64_java_parameter,
- node_f64_java_setup,
- node_f64_java_code,
- node_f64_java_teardown,
};
@@ -716,18 +334,6 @@ void node_define_print (node_t *this)
fprintf(stdout, "};\n");
}
-static void emit_java_arg_declaration(node_t *child, FILE *fp) {
- current_java_parameter_number = 0;
- while (child) {
- node_vft_t *vftp = the_vft[child->type];
- current_java_emitted_parameter = 0;
- vftp->java_method_function(child, JAVA_METHOD_PASS, fp);
- child = child->peer;
- if (child && current_java_emitted_parameter)
- fputs (", ", fp);
- }
-}
-
void node_define_generate (node_t *this, enum passid which, FILE *fp)
{
node_t *child, *save_child;
@@ -757,132 +363,6 @@ void node_define_generate (node_t *this, enum passid which, FILE *fp)
}
break;
- case JAVA_METHOD_PASS:
- indent += 4;
- indent_me(fp);
-
- /* Generate private native declaration */
- fprintf (fp, "private static native int %s0(", java_name_mangle(CDATA0));
- emit_java_arg_declaration(this->deeper, fp);
- fputs (");\n", fp);
-
- /* Generate public Java method */
- indent_me(fp);
- fprintf (fp, "public final int %s(", java_name_mangle(CDATA0));
- emit_java_arg_declaration(this->deeper, fp);
- fputs (") {\n", fp);
-
- indent += 4;
- indent_me(fp);
- fputs ("checkConnected();\n", fp);
- indent_me(fp);
- fprintf (fp, "return %s.%s0(", java_class, java_name_mangle(CDATA0));
-
- child = this->deeper;
- current_java_parameter_number = 0;
- while (child && hidden_from_java(child->deeper)) {
- child = child->peer;
- }
- while (child) {
- fputs(java_name_mangle((char *)(child->deeper->data[0])), fp);
- child = child->peer;
- if (child)
- fputs (", ", fp);
- }
-
- fputs (");\n", fp);
- indent -= 4;
- indent_me(fp);
- fputs ("}\n\n", fp);
- indent -= 4;
- break;
-
- case JAVA_JNI_PASS:
- /* Generate function prototype */
- fprintf (fp, "JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_%s_%s0\n",
- java_class, java_name_mangle(CDATA0));
-
- fprintf (fp, "(JNIEnv * env, jclass clazz");
- current_java_parameter_need_comma_space = 1;
- child = this->deeper;
- save_child = child;
- while (child) {
- node_vft_t *vftp = the_vft[child->type];
- current_java_emitted_parameter = 0;
- vftp->java_jni_parameter(child, which, fp);
- child = child->peer;
- if (child && current_java_emitted_parameter)
- fputs (", ", fp);
- }
- fprintf (fp, ")\n{\n");
- indent += 4;
-
- /* define the api message pointer */
- indent_me(fp);
- fprintf (fp, "vppjni_main_t *jm = &vppjni_main;\n");
- indent_me(fp);
- fprintf (fp, "vl_api_%s_t * mp;\n", current_def_name);
- indent_me(fp);
- fprintf (fp, "u32 my_context_id;\n");
- indent_me(fp);
- fprintf (fp, "int rv;\n");
-
- indent_me(fp);
- fprintf (fp, "rv = vppjni_sanity_check (jm);\n");
- indent_me(fp);
- fprintf (fp, "if (rv) return rv;\n");
-
- indent_me(fp);
- fprintf (fp, "my_context_id = vppjni_get_context_id (jm);\n");
-
- /* Generate array setups, if any */
- child = save_child;
- while (child) {
- node_vft_t *vftp = the_vft[child->type];
- current_java_parameter_number = 0;
- current_java_emitted_parameter = 0;
- vftp->java_jni_setup(child, which, fp);
- child = child->peer;
- }
-
- /* Setup the API message */
- indent_me(fp);
- fprintf (fp, "M(%s, %s);\n", uppercase(current_def_name),
- current_def_name);
- indent_me(fp);
- fprintf (fp, "mp->context = clib_host_to_net_u32 (my_context_id);\n");
- /* $$$ Set up context hash table or some such... */
-
- /* Generate code */
- child = save_child;
- while (child) {
- node_vft_t *vftp = the_vft[child->type];
- current_java_parameter_number = 0;
- current_java_emitted_parameter = 0;
- vftp->java_jni_code(child, which, fp);
- child = child->peer;
- }
-
- /* Generate array teardowns */
- child = save_child;
- while (child) {
- node_vft_t *vftp = the_vft[child->type];
- current_java_parameter_number = 0;
- current_java_emitted_parameter = 0;
- vftp->java_jni_teardown(child, which, fp);
- child = child->peer;
- }
-
- /* Send the message, return context_id */
- indent_me (fp);
- fprintf (fp, "S;\n");
- indent_me (fp);
- fprintf (fp, "return my_context_id;\n");
-
- indent -= 4;
- fprintf (fp, "}\n\n");
- break;
-
case PYTHON_PASS:
fprintf(fp, "('%s',\n", CDATA0);
child = this->deeper;
@@ -1834,214 +1314,6 @@ void add_msg_ids(YYSTYPE a1)
}
}
-void generate_java_top_boilerplate(FILE *fp)
-
-{
- char *datestring = ctime(&starttime);
- fixed_name = fixup_input_filename();
-
- datestring[24] = 0;
-
- fprintf (fp, "/*\n");
- fprintf (fp, " * VLIB API java binding %s\n", datestring);
- fprintf (fp, " * Input file: %s\n", input_filename);
- fprintf (fp, " * Automatically generated: please edit the input file ");
- fprintf (fp, "NOT this file!\n");
- fprintf (fp, " */\n\n");
-
- fprintf (fp, "package org.openvpp.vppjapi;\n\n");
- fprintf (fp, "import java.io.IOException;\n\n");
- fprintf (fp, "public class %s extends vppConn {\n",
- java_class);
- fprintf (fp, " public %s(String clientName) throws IOException {\n", java_class);
- fprintf (fp, " super(clientName);\n");
- fprintf (fp, " }\n\n");
-}
-
-void generate_java_bottom_boilerplate(FILE *fp)
-{
- fprintf (fp, "}\n");
-}
-
-
-void generate_java_class_definition (YYSTYPE a1, FILE *fp)
-{
- node_t *np = (node_t *)a1;
- node_vft_t *vftp;
-
- fprintf(fp, "/****** API methods *****/\n\n");
-
- /* Walk the top-level node-list */
- while (np) {
- if (np->type == NODE_DEFINE) {
- if (!(np->flags & (NODE_FLAG_MANUAL_JAVA | NODE_FLAG_TYPEONLY))) {
- /* Suppress messages named "xyz_reply" */
- char * cp = (char *) np->data[0];
- while (*cp)
- cp++;
- cp -= 6;
- if (strncmp (cp, "_reply", 6)) {
- current_java_parameter_number = 0;
- vftp = the_vft[np->type];
- vftp->generate(np, JAVA_METHOD_PASS, fp);
- }
- }
- }
- np = np->peer;
- }
-
- fprintf(fp, "\n/****** end of API methods *****/\n");
-}
-
-void generate_jni_reply_handler_list (YYSTYPE a1, FILE *fp)
-{
- node_t *np = (node_t *)a1;
- node_vft_t *vftp;
-
- fprintf (fp, "#define foreach_api_reply_handler \\\n");
-
- /* Walk the top-level node-list */
- while (np) {
- if (np->type == NODE_DEFINE) {
- if (!(np->flags & (NODE_FLAG_MANUAL_JAVA | NODE_FLAG_TYPEONLY))) {
- /* emit messages named "xyz_reply" */
- char * cp = (char *) np->data[0];
- while (*cp)
- cp++;
- cp -= 6;
- if (!strncmp (cp, "_reply", 6)) {
- fprintf (fp, "_(%s, %s) \\\n",
- uppercase(np->data[0]), (char *)(np->data[0]));
- }
- }
- }
- np = np->peer;
- }
-
- fprintf (fp, "\n\n");
-}
-
-char * m_macro_boilerplate =
-"#define M(T,t) \\\n"
-"do { \\\n"
-" api_result_ready = 0; \\\n"
-" mp = vl_msg_api_alloc(sizeof(*mp)); \\\n"
-" memset (mp, 0, sizeof (*mp)); \\\n"
-" mp->_vl_msg_id = ntohs (VL_API_##T); \\\n"
-" mp->client_index = api_main.my_client_index; \\\n"
-"} while(0);\n\n"
-"#define M2(T,t,n) \\\n"
-"do { \\\n"
-" api_result_ready = 0; \\\n"
-" mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \\\n"
-" memset (mp, 0, sizeof (*mp)); \\\n"
-" mp->_vl_msg_id = ntohs (VL_API_##T); \\\n"
-" mp->client_index = api_main.my_client_index; \\\n"
-"} while(0);\n\n";
-
-char * s_macro_boilerplate =
-"#define S (vl_msg_api_send_shmem (api_main.shmem_hdr->vl_input_queue, \\\n"
-"(u8 *)&mp));\n\n";
-
-char * w_macro_boilerplate =
-"#define W \\\n"
-"do { \\\n"
-" timeout = clib_time_now (&clib_time) + 1.0; \\\n"
-" \\\n"
-" while (clib_time_now (&clib_time) < timeout) { \\\n"
-" if (api_result_ready == 1) { \\\n"
-" return ((jint) api_result); \\\n"
-" } \\\n"
-" } \\\n"
-" return -99; \\\n"
-"} while(0);\n\n";
-
-void generate_jni_top_boilerplate(FILE *fp)
-
-{
- char *datestring = ctime(&starttime);
- fixed_name = fixup_input_filename();
-
- datestring[24] = 0;
-
- fprintf (fp, "/*\n");
- fprintf (fp, " * VLIB Java native code %s\n", datestring);
- fprintf (fp, " * Input file: %s\n", input_filename);
- fprintf (fp, " * Automatically generated: please edit the input file ");
- fprintf (fp, "NOT this file!\n");
- fprintf (fp, " */\n\n");
-
- fprintf (fp, "#include <japi/vppjni.h>\n");
-
- fprintf (fp,
- "#define vl_api_version(n,v) static u32 %s_api_version %s = v;\n",
- vlib_app_name, "__attribute__((unused))");
- fprintf (fp, "#include <vpp-api/%s.api.h>\n", vlib_app_name);
- fprintf (fp, "#undef vl_api_version\n\n");
-
- fprintf (fp, "#include <japi/org_openvpp_vppjapi_vppConn.h>\n");
- fprintf (fp, "#include <japi/org_openvpp_vppjapi_%s.h>\n\n", java_class);
-
- fprintf (fp, "#include <vpp-api/%s_msg_enum.h>\n", vlib_app_name);
- fprintf (fp, "#define vl_typedefs /* define message structures */\n");
- fprintf (fp, "#include <vpp-api/%s_all_api_h.h> \n", vlib_app_name);
- fprintf (fp, "#undef vl_typedefs\n\n");
-
- fprintf (fp, "#define vl_endianfun \n");
- fprintf (fp, "#include <vpp-api/%s_all_api_h.h> \n", vlib_app_name);
- fprintf (fp, "#undef vl_endianfun\n\n");
-
- fprintf (fp, "#define vl_print(handle, ...)\n");
- fprintf (fp, "#define vl_printfun\n");
- fprintf (fp, "#include <vpp-api/%s_all_api_h.h>\n", vlib_app_name);
- fprintf (fp, "#undef vl_printfun\n\n");
-}
-
-void generate_jni_code (YYSTYPE a1, FILE *fp)
-{
- node_t *np = (node_t *)a1;
- node_vft_t *vftp;
-
- /* Walk the top-level node-list */
- while (np) {
- if (np->type == NODE_DEFINE) {
- if (!(np->flags & (NODE_FLAG_MANUAL_JAVA | NODE_FLAG_TYPEONLY))) {
- /* Suppress messages named "xyz_reply" */
- char * cp = (char *) np->data[0];
- while (*cp)
- cp++;
- cp -= 6;
- if (strncmp (cp, "_reply", 6)) {
- current_def_name = np->data[0];
- current_java_parameter_number = 0;
- vftp = the_vft[np->type];
- vftp->generate(np, JAVA_JNI_PASS, fp);
- }
- }
- }
- np = np->peer;
- }
-}
-
-char *hookup_boilerplate =
-"void vl_msg_reply_handler_hookup (void)\n"
-"{\n"
-"#define _(N,n) \\\n"
-" vl_msg_api_set_handlers (VL_API_##N, #n, \\\n"
-" vl_api_generic_reply_handler, \\\n"
-" vl_noop_handler, \\\n"
-" vl_api_##n##_t_endian, \\\n"
-" vl_api_##n##_t_print, \\\n"
-" sizeof(vl_api_##n##_t), 1); \n"
-" foreach_api_reply_handler;\n"
-"#undef _\n\n"
-"}\n\n";
-
-void generate_jni_bottom_boilerplate(FILE *fp)
-{
- fputs (hookup_boilerplate, fp);
-}
-
void generate_python (YYSTYPE a1, FILE *fp)
{
node_t *np = (node_t *)a1;
@@ -2079,18 +1351,6 @@ void generate(YYSTYPE a1)
generate_bottom_boilerplate(ofp);
}
-
- if (javafp) {
- generate_java_top_boilerplate(javafp);
- generate_java_class_definition(a1, javafp);
- generate_java_bottom_boilerplate(javafp);
- }
- if (jnifp) {
- generate_jni_top_boilerplate(jnifp);
- generate_jni_reply_handler_list (a1, jnifp);
- generate_jni_code(a1, jnifp);
- generate_jni_bottom_boilerplate(jnifp);
- }
if (pythonfp) {
generate_python(a1, pythonfp);
}
diff --git a/vppapigen/node.h b/vppapigen/node.h
index fc331507..f80985e1 100644
--- a/vppapigen/node.h
+++ b/vppapigen/node.h
@@ -52,7 +52,6 @@ enum node_subclass { /* WARNING: indices must match the vft... */
NODE_TYPEONLY,
NODE_MANUAL_PRINT,
NODE_MANUAL_ENDIAN,
- NODE_MANUAL_JAVA,
NODE_DONT_TRACE,
};
@@ -61,8 +60,6 @@ enum passid {
UNION_DEF_PASS,
ENDIANFUN_PASS,
PRINTFUN_PASS,
- JAVA_METHOD_PASS,
- JAVA_JNI_PASS,
PYTHON_PASS,
};
@@ -83,7 +80,6 @@ typedef struct node_ {
#define NODE_FLAG_MANUAL_PRINT (1<<0)
#define NODE_FLAG_MANUAL_ENDIAN (1<<1)
-#define NODE_FLAG_MANUAL_JAVA (1<<2)
#define NODE_FLAG_TYPEONLY (1<<3)
#define NODE_FLAG_DONT_TRACE (1<<4)
@@ -91,11 +87,6 @@ typedef struct node_vft_ {
void (*print)(struct node_ *);
void (*generate)(struct node_ *, enum passid id, FILE *ofp);
char *endian_converter;
- void (*java_method_function)(struct node_ *, enum passid id, FILE *ofp);
- void (*java_jni_parameter)(struct node_ *, enum passid id, FILE *ofp);
- void (*java_jni_setup)(struct node_ *, enum passid id, FILE *ofp);
- void (*java_jni_code)(struct node_ *, enum passid id, FILE *ofp);
- void (*java_jni_teardown)(struct node_ *, enum passid id, FILE *ofp);
} node_vft_t;
#endif /* _node_h */