From af188c5c99d4b4fcb669a6e666b2b421ad69e8d9 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Tue, 3 Jan 2017 18:12:41 +0100 Subject: HONEYCOMB-310: readers&initializers for vpp and macip acls Change-Id: I8892479123091e43bf191c544b6628d6254be564 Signed-off-by: Marek Gradzki --- .../io/fd/hc2vpp/common/translate/util/Ipv6Translator.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'vpp-common/vpp-translate-utils/src/main/java/io/fd') diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv6Translator.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv6Translator.java index 2d0b51b40..396391dd7 100644 --- a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv6Translator.java +++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv6Translator.java @@ -141,6 +141,18 @@ public interface Ipv6Translator extends ByteDataTranslator { return address.getIpv6Prefix() != null; } + /** + * Sets correct length of ip4 array in case vpp returns array of length greater than 4. + * @param ip array to be truncated + * @return ip array of length 4 + */ + default byte[] truncateIp4Array(final byte[] ip) { + // 16, which causes problems for toIpv4Prefix + final byte[] result = new byte[4]; + System.arraycopy(ip, 0, result, 0, 4); + return result; + } + default Ipv6Prefix toIpv6Prefix(final byte[] address, final int prefix) { try { return new Ipv6Prefix( -- cgit 1.2.3-korg