summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/v3po2vpp')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java31
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizer.java19
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizerTest.java25
3 files changed, 37 insertions, 38 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java
index 188f83d0f..666fa31fa 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java
@@ -49,42 +49,19 @@ public interface InterfaceDataTranslator extends ByteDataTranslator, JvppReplyCo
InterfaceDataTranslator INSTANCE = new InterfaceDataTranslator() {
};
- Gauge64 vppLinkSpeed0 = new Gauge64(BigInteger.ZERO);
- Gauge64 vppLinkSpeed1 = new Gauge64(BigInteger.valueOf(10L * 1000000));
- Gauge64 vppLinkSpeed2 = new Gauge64(BigInteger.valueOf(100L * 1000000));
- Gauge64 vppLinkSpeed4 = new Gauge64(BigInteger.valueOf(1000L * 1000000));
- Gauge64 vppLinkSpeed8 = new Gauge64(BigInteger.valueOf(10000L * 1000000));
- Gauge64 vppLinkSpeed16 = new Gauge64(BigInteger.valueOf(40000L * 1000000));
- Gauge64 vppLinkSpeed32 = new Gauge64(BigInteger.valueOf(100000L * 1000000));
-
int PHYSICAL_ADDRESS_LENGTH = 6;
Collector<SwInterfaceDetails, ?, SwInterfaceDetails> SINGLE_ITEM_COLLECTOR =
RWUtils.singleItemCollector();
/**
- * Convert VPP's link speed bitmask to Yang type. 1 = 10M, 2 = 100M, 4 = 1G, 8 = 10G, 16 = 40G, 32 = 100G
+ * Convert VPP's link speed in kbits per second to Yang type.
*
- * @param vppLinkSpeed Link speed in bitmask format from VPP.
+ * @param vppLinkSpeed Link speed in kbits per second from VPP.
* @return Converted value from VPP link speed
*/
- default Gauge64 vppInterfaceSpeedToYang(byte vppLinkSpeed) {
- switch (vppLinkSpeed) {
- case 1:
- return vppLinkSpeed1;
- case 2:
- return vppLinkSpeed2;
- case 4:
- return vppLinkSpeed4;
- case 8:
- return vppLinkSpeed8;
- case 16:
- return vppLinkSpeed16;
- case 32:
- return vppLinkSpeed32;
- default:
- return vppLinkSpeed0;
- }
+ default Gauge64 vppInterfaceSpeedToYang(int vppLinkSpeed) {
+ return new Gauge64(BigInteger.valueOf(Integer.toUnsignedLong(vppLinkSpeed) * 1000));
}
/**
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizer.java
index fc0aba36d..2e13ecc01 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizer.java
@@ -28,6 +28,11 @@ import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.BdIpMacAddDel;
import io.fd.vpp.jvpp.core.dto.BdIpMacAddDelReply;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import io.fd.vpp.jvpp.core.types.Address;
+import io.fd.vpp.jvpp.core.types.AddressFamily;
+import io.fd.vpp.jvpp.core.types.AddressUnion;
+import io.fd.vpp.jvpp.core.types.Ip4Address;
+import io.fd.vpp.jvpp.core.types.MacAddress;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone;
@@ -94,12 +99,16 @@ public class ArpTerminationTableEntryCustomizer extends FutureJVppCustomizer
final BdIpMacAddDel request = new BdIpMacAddDel();
request.bdId = bdId;
request.isAdd = booleanToByte(isAdd);
- request.macAddress = parseMac(entry.getPhysAddress().getValue());
-
+ MacAddress macAddress = new MacAddress();
+ macAddress.bytes = parseMac(entry.getPhysAddress().getValue());
+ request.mac = macAddress;
final IpAddressNoZone ipAddress = entry.getIpAddress();
-
- request.ipAddress = ipAddressToArray(ipAddress);
- request.isIpv6 = booleanToByte(isIpv6(ipAddress));
+ Ip4Address ip4Address = new Ip4Address();
+ ip4Address.address = ipAddressToArray(ipAddress);
+ Address address = new Address();
+ address.af = AddressFamily.ADDRESS_IP4;
+ address.un = new AddressUnion(ip4Address);
+ request.ip = address;
return request;
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizerTest.java
index 86604b465..aba48fd58 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizerTest.java
@@ -32,6 +32,11 @@ import io.fd.vpp.jvpp.VppBaseCallException;
import io.fd.vpp.jvpp.VppInvocationException;
import io.fd.vpp.jvpp.core.dto.BdIpMacAddDel;
import io.fd.vpp.jvpp.core.dto.BdIpMacAddDelReply;
+import io.fd.vpp.jvpp.core.types.Address;
+import io.fd.vpp.jvpp.core.types.AddressFamily;
+import io.fd.vpp.jvpp.core.types.AddressUnion;
+import io.fd.vpp.jvpp.core.types.Ip4Address;
+import io.fd.vpp.jvpp.core.types.MacAddress;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone;
@@ -83,7 +88,8 @@ public class ArpTerminationTableEntryCustomizerTest extends WriterCustomizerTest
physAddress = new PhysAddress("01:02:03:04:05:06");
ipAddress = new IpAddressNoZone(Ipv4AddressNoZone.getDefaultInstance("1.2.3.4"));
- ip6Address = new IpAddressNoZone(Ipv6AddressNoZone.getDefaultInstance("2001:0db8:0a0b:12f0:0000:0000:0000:0001"));
+ ip6Address =
+ new IpAddressNoZone(Ipv6AddressNoZone.getDefaultInstance("2001:0db8:0a0b:12f0:0000:0000:0000:0001"));
entry = generateArpEntry(ipAddress, physAddress);
ip6entry = generateArpEntry(ip6Address, physAddress);
id = getArpEntryId(ipAddress, physAddress);
@@ -103,8 +109,15 @@ public class ArpTerminationTableEntryCustomizerTest extends WriterCustomizerTest
private BdIpMacAddDel generateBdIpMacAddDelRequest(final byte[] ipAddress, final byte[] macAddress,
final byte isAdd) {
final BdIpMacAddDel request = new BdIpMacAddDel();
- request.ipAddress = ipAddress;
- request.macAddress = macAddress;
+ Address address = new Address();
+ address.af = AddressFamily.ADDRESS_IP4;
+ Ip4Address ip4Address = new Ip4Address();
+ ip4Address.address = ipAddress;
+ address.un = new AddressUnion(ip4Address);
+ request.ip = address;
+ MacAddress macAddr = new MacAddress();
+ macAddr.bytes = macAddress;
+ request.mac = macAddr;
request.bdId = BD_ID;
request.isAdd = isAdd;
return request;
@@ -123,8 +136,8 @@ public class ArpTerminationTableEntryCustomizerTest extends WriterCustomizerTest
ArgumentCaptor<BdIpMacAddDel> argumentCaptor = ArgumentCaptor.forClass(BdIpMacAddDel.class);
verify(api).bdIpMacAddDel(argumentCaptor.capture());
final BdIpMacAddDel actual = argumentCaptor.getValue();
- assertArrayEquals(expected.macAddress, actual.macAddress);
- assertArrayEquals(expected.ipAddress, actual.ipAddress);
+ assertArrayEquals(expected.mac.bytes, actual.mac.bytes);
+ assertArrayEquals(expected.ip.un.getIp4().address, actual.ip.un.getIp4().address);
assertEquals(expected.bdId, actual.bdId);
assertEquals(expected.isAdd, actual.isAdd);
}
@@ -189,4 +202,4 @@ public class ArpTerminationTableEntryCustomizerTest extends WriterCustomizerTest
}
fail("WriteFailedException.DeleteFailedException was expected");
}
-} \ No newline at end of file
+}