summaryrefslogtreecommitdiffstats
path: root/vpp-common/vpp-translate-utils/src
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-01-03 18:12:41 +0100
committerMarek Gradzki <mgradzki@cisco.com>2017-01-04 12:44:41 +0100
commitaf188c5c99d4b4fcb669a6e666b2b421ad69e8d9 (patch)
tree625eaa7bee2d6dfa4aab10e3b861c40bcfb0593a /vpp-common/vpp-translate-utils/src
parent9debe7fe89600b0e1d136f488119dddeb0c5702d (diff)
HONEYCOMB-310: readers&initializers for vpp and macip acls
Change-Id: I8892479123091e43bf191c544b6628d6254be564 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'vpp-common/vpp-translate-utils/src')
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv6Translator.java12
1 files changed, 12 insertions, 0 deletions
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(