diff options
Diffstat (limited to 'vpp-japi/japi/org/openvpp')
7 files changed, 310 insertions, 0 deletions
diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppApiCallbacks.java b/vpp-japi/japi/org/openvpp/vppjapi/vppApiCallbacks.java new file mode 100644 index 00000000..38c7c4e7 --- /dev/null +++ b/vpp-japi/japi/org/openvpp/vppjapi/vppApiCallbacks.java @@ -0,0 +1,27 @@ +/* + * 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.vppApi; + +public abstract class vppApiCallbacks extends vppApi { + 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-japi/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java b/vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java new file mode 100644 index 00000000..01fe11d6 --- /dev/null +++ b/vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java @@ -0,0 +1,30 @@ +/* + * 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 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-japi/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java b/vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java new file mode 100644 index 00000000..f17c0620 --- /dev/null +++ b/vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java @@ -0,0 +1,21 @@ +/* + * 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 vppBridgeDomainInterfaceDetails { + public String interfaceName; + public byte splitHorizonGroup; +} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppConn.java b/vpp-japi/japi/org/openvpp/vppjapi/vppConn.java new file mode 100644 index 00000000..12a3f179 --- /dev/null +++ b/vpp-japi/japi/org/openvpp/vppjapi/vppConn.java @@ -0,0 +1,89 @@ +/* + * 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.vppInterfaceCounters; +import org.openvpp.vppjapi.vppBridgeDomainDetails; +import org.openvpp.vppjapi.vppL2Fib; + +public class vppConn { + private static final String LIBNAME = "libvppjni.so.0.0.0"; + + static { + try { + loadLibrary(); + } catch (IOException | RuntimeException e) { + System.out.printf ("Can't find vpp jni library: %s\n", LIBNAME); + } + } + + 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); + } + } + + public native int clientConnect(String clientName); + public native void clientDisconnect(); + public native int getRetval(int context, int release); + public native String getInterfaceList (String nameFilter); + public native int swIfIndexFromName (String interfaceName); + public native String interfaceNameFromSwIfIndex (int swIfIndex); + public native void clearInterfaceTable (); + public native int swInterfaceDump (byte nameFilterValid, byte [] nameFilter); + public native int bridgeDomainIdFromName(String bridgeDomain); + public native int findOrAddBridgeDomainId(String bridgeDomain); + public native vppVersion getVppVersion(); + public native vppInterfaceCounters getInterfaceCounters(int swIfIndex); + public native int[] bridgeDomainDump(int bdId); + public native vppBridgeDomainDetails getBridgeDomainDetails(int bdId); + public native vppL2Fib[] l2FibTableDump(int bdId); + public native int bridgeDomainIdFromInterfaceName(String interfaceName); +} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceCounters.java b/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceCounters.java new file mode 100644 index 00000000..1777d5d5 --- /dev/null +++ b/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceCounters.java @@ -0,0 +1,77 @@ +/* + * 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 vppInterfaceCounters { + + public long rxOctets; + public long rxIp4; + public long rxIp6; + public long rxUnicast; + public long rxMulticast; + public long rxBroadcast; + public long rxDiscard; + public long rxFifoFull; + public long rxError; + public long rxUnknownProto; + public long rxMiss; + + public long txOctets; + public long txIp4; + public long txIp6; + public long txUnicast; + public long txMulticast; + public long txBroadcast; + public long txDiscard; + public long txFifoFull; + public long txError; + public long txUnknownProto; + public 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-japi/japi/org/openvpp/vppjapi/vppL2Fib.java b/vpp-japi/japi/org/openvpp/vppjapi/vppL2Fib.java new file mode 100644 index 00000000..9f43449d --- /dev/null +++ b/vpp-japi/japi/org/openvpp/vppjapi/vppL2Fib.java @@ -0,0 +1,34 @@ +/* + * 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 vppL2Fib { + public byte[] physAddress; + public boolean staticConfig; + public String outgoingInterface; + public boolean filter; + public boolean bridgedVirtualInterface; + + public vppL2Fib(byte[] _physAddress, boolean _staticConfig, + String _outgoingInterface, boolean _filter, + boolean _bridgedVirtualInterface) { + physAddress = _physAddress; + staticConfig = _staticConfig; + outgoingInterface = _outgoingInterface; + filter = _filter; + bridgedVirtualInterface = _bridgedVirtualInterface; + } +} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppVersion.java b/vpp-japi/japi/org/openvpp/vppjapi/vppVersion.java new file mode 100644 index 00000000..557ca7b7 --- /dev/null +++ b/vpp-japi/japi/org/openvpp/vppjapi/vppVersion.java @@ -0,0 +1,32 @@ +/* + * 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 vppVersion { + public String programName; + public String buildDirectory; + public String gitBranch; + public String buildDate; + + public vppVersion(String _progName, String _buildDir, String _gitBranch, String _buildDate) + { + programName = _progName; + buildDirectory = _buildDir; + gitBranch = _gitBranch; + buildDate = _buildDate; + } +} + |