From 868f11f4f4da49198b8102509fb0234578be25e8 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Mon, 20 Nov 2017 15:27:44 +0100 Subject: Refactor IP translators to use IetfInetUtil Use efficient factory methods for ietf-inet-types DTOs where possible. Also cleans up some duplicated and unused code. Change-Id: I58f4163edba0dcd30e5e044cf701788446d86a0f Signed-off-by: Marek Gradzki --- .../ace/extractor/AceDataExtractorTestCase.java | 4 +-- .../hc2vpp/nat/read/Nat64PrefixesCustomizer.java | 2 +- .../routing/read/Ipv6RouteCustomizerTest.java | 6 ++--- .../common/translate/util/Ipv4Translator.java | 29 +++------------------- .../common/translate/util/Ipv6Translator.java | 27 +++----------------- .../common/translate/util/Ipv6TranslatorTest.java | 18 +++++++------- 6 files changed, 22 insertions(+), 64 deletions(-) diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/ace/extractor/AceDataExtractorTestCase.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/ace/extractor/AceDataExtractorTestCase.java index fc925c992..14afdcd3f 100644 --- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/ace/extractor/AceDataExtractorTestCase.java +++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/ace/extractor/AceDataExtractorTestCase.java @@ -40,8 +40,8 @@ abstract class AceDataExtractorTestCase { protected static final int DEFAULT_IPV4_PREFIX_VALUE = 0; protected static final byte[] DEFAULT_IPV6_ADDRESS_BYTES = new byte[16]; - protected static final Ipv6Prefix IPV6_PREFIX = new Ipv6Prefix("2001:db8:a0b:12f0:0:0:0:1/64"); - protected static final Ipv6Prefix IPV6_2_PREFIX = new Ipv6Prefix("2001:db8:a0b:12f0:0:0:0:2/48"); + protected static final Ipv6Prefix IPV6_PREFIX = new Ipv6Prefix("2001:db8:a0b:12f0::1/64"); + protected static final Ipv6Prefix IPV6_2_PREFIX = new Ipv6Prefix("2001:db8:a0b:12f0::2/48"); protected static final byte[] IPV6_PREFIX_BYTES = {32, 1, 13, -72, 10, 11, 18, -16, 0, 0, 0, 0, 0, 0, 0, 1}; protected static final byte[] IPV6_2_PREFIX_BYTES = {32, 1, 13, -72, 10, 11, 18, -16, 0, 0, 0, 0, 0, 0, 0, 2}; protected static final byte IPV6_PREFIX_VALUE = (byte) 64; diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/Nat64PrefixesCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/Nat64PrefixesCustomizer.java index f3997dc79..5026a0127 100644 --- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/Nat64PrefixesCustomizer.java +++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/Nat64PrefixesCustomizer.java @@ -113,7 +113,7 @@ final class Nat64PrefixesCustomizer if (prefixDetails != null) { builder.setNat64PrefixId(prefixId); builder.setNat64Prefix( - arrayToIpv6Prefix(prefixDetails.prefix, UnsignedBytes.toInt(prefixDetails.prefixLen))); + toIpv6Prefix(prefixDetails.prefix, UnsignedBytes.toInt(prefixDetails.prefixLen))); } } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizerTest.java index 79d906719..3626056b8 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizerTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizerTest.java @@ -211,7 +211,7 @@ public class Ipv6RouteCustomizerTest extends ListReaderCustomizerTest