Work toward common IP address classes.

Ported the following IP address classes from the older codebase:
Ip4Address, Ip6Address, Ip4Prefix, Ip6Prefix (and the corresponding
unit tests).
NOTE: Those classes are not ready to be used yet.

Change-Id: I234875abbc9df8daa2f8ae28706af591dd2c5f2d
diff --git a/utils/misc/src/test/java/org/onlab/packet/Ip4AddressTest.java b/utils/misc/src/test/java/org/onlab/packet/Ip4AddressTest.java
new file mode 100644
index 0000000..6680af4
--- /dev/null
+++ b/utils/misc/src/test/java/org/onlab/packet/Ip4AddressTest.java
@@ -0,0 +1,330 @@
+package org.onlab.packet;
+
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+/**
+ * Tests for class {@link Ip4Address}.
+ */
+public class Ip4AddressTest {
+    /**
+     * Tests the immutability of {@link Ip4Address}.
+     */
+    @Test
+    public void testImmutable() {
+        assertThatClassIsImmutable(Ip4Address.class);
+    }
+
+    /**
+     * Tests the length of the address in bytes (octets).
+     */
+    @Test
+    public void testAddrBytelen() {
+        assertThat(Ip4Address.BYTE_LENGTH, is(4));
+    }
+
+    /**
+     * Tests the length of the address in bits.
+     */
+    @Test
+    public void testAddrBitlen() {
+        assertThat(Ip4Address.BIT_LENGTH, is(32));
+    }
+
+    /**
+     * Tests default class constructor.
+     */
+    @Test
+    public void testDefaultConstructor() {
+        Ip4Address ip4Address = new Ip4Address();
+        assertThat(ip4Address.toString(), is("0.0.0.0"));
+    }
+
+    /**
+     * Tests valid class copy constructor.
+     */
+    @Test
+    public void testCopyConstructor() {
+        Ip4Address fromAddr = new Ip4Address("1.2.3.4");
+        Ip4Address ip4Address = new Ip4Address(fromAddr);
+        assertThat(ip4Address.toString(), is("1.2.3.4"));
+
+        fromAddr = new Ip4Address("0.0.0.0");
+        ip4Address = new Ip4Address(fromAddr);
+        assertThat(ip4Address.toString(), is("0.0.0.0"));
+
+        fromAddr = new Ip4Address("255.255.255.255");
+        ip4Address = new Ip4Address(fromAddr);
+        assertThat(ip4Address.toString(), is("255.255.255.255"));
+    }
+
+    /**
+     * Tests invalid class copy constructor for a null object to copy from.
+     */
+    @Test(expected = NullPointerException.class)
+    public void testInvalidConstructorNullObject() {
+        Ip4Address fromAddr = null;
+        Ip4Address ip4Address = new Ip4Address(fromAddr);
+    }
+
+    /**
+     * Tests valid class constructor for an integer value.
+     */
+    @Test
+    public void testConstructorForInteger() {
+        Ip4Address ip4Address = new Ip4Address(0x01020304);
+        assertThat(ip4Address.toString(), is("1.2.3.4"));
+
+        ip4Address = new Ip4Address(0);
+        assertThat(ip4Address.toString(), is("0.0.0.0"));
+
+        ip4Address = new Ip4Address(0xffffffff);
+        assertThat(ip4Address.toString(), is("255.255.255.255"));
+    }
+
+    /**
+     * Tests valid class constructor for an array value.
+     */
+    @Test
+    public void testConstructorForArray() {
+        final byte[] value1 = new byte[] {1, 2, 3, 4};
+        Ip4Address ip4Address = new Ip4Address(value1);
+        assertThat(ip4Address.toString(), is("1.2.3.4"));
+
+        final byte[] value2 = new byte[] {0, 0, 0, 0};
+        ip4Address = new Ip4Address(value2);
+        assertThat(ip4Address.toString(), is("0.0.0.0"));
+
+        final byte[] value3 = new byte[] {(byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff};
+        ip4Address = new Ip4Address(value3);
+        assertThat(ip4Address.toString(), is("255.255.255.255"));
+    }
+
+    /**
+     * Tests valid class constructor for an array value and an offset.
+     */
+    @Test
+    public void testConstructorForArrayAndOffset() {
+        final byte[] value1 = new byte[] {11, 22, 33,   // Preamble
+                                          1, 2, 3, 4,
+                                          44, 55};      // Extra bytes
+        Ip4Address ip4Address = new Ip4Address(value1, 3);
+        assertThat(ip4Address.toString(), is("1.2.3.4"));
+
+        final byte[] value2 = new byte[] {11, 22,       // Preamble
+                                          0, 0, 0, 0,
+                                          33};          // Extra bytes
+        ip4Address = new Ip4Address(value2, 2);
+        assertThat(ip4Address.toString(), is("0.0.0.0"));
+
+        final byte[] value3 = new byte[] {11, 22,       // Preamble
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          33};          // Extra bytes
+        ip4Address = new Ip4Address(value3, 2);
+        assertThat(ip4Address.toString(), is("255.255.255.255"));
+    }
+
+    /**
+     * Tests invalid class constructor for a null array.
+     */
+    @Test(expected = NullPointerException.class)
+    public void testInvalidConstructorNullArray() {
+        final byte[] fromArray = null;
+        Ip4Address ip4Address = new Ip4Address(fromArray);
+    }
+
+    /**
+     * Tests invalid class constructor for an array that is too short.
+     */
+    @Test(expected = IllegalArgumentException.class)
+    public void testInvalidConstructorShortArray() {
+        final byte[] fromArray = new byte[] {1, 2, 3};
+        Ip4Address ip4Address = new Ip4Address(fromArray);
+    }
+
+    /**
+     * Tests invalid class constructor for an array and an invalid offset.
+     */
+    @Test(expected = IllegalArgumentException.class)
+    public void testInvalidConstructorArrayInvalidOffset() {
+        final byte[] value1 = new byte[] {11, 22, 33,   // Preamble
+                                          1, 2, 3, 4,
+                                          44, 55};      // Extra bytes
+        Ip4Address ip4Address = new Ip4Address(value1, 6);
+    }
+
+    /**
+     * Tests valid class constructor for a string.
+     */
+    @Test
+    public void testConstructorForString() {
+        Ip4Address ip4Address = new Ip4Address("1.2.3.4");
+        assertThat(ip4Address.toString(), is("1.2.3.4"));
+
+        ip4Address = new Ip4Address("0.0.0.0");
+        assertThat(ip4Address.toString(), is("0.0.0.0"));
+
+        ip4Address = new Ip4Address("255.255.255.255");
+        assertThat(ip4Address.toString(), is("255.255.255.255"));
+    }
+
+    /**
+     * Tests invalid class constructor for a null string.
+     */
+    @Test(expected = NullPointerException.class)
+    public void testInvalidConstructorNullString() {
+        String fromString = null;
+        Ip4Address ip4Address = new Ip4Address(fromString);
+    }
+
+    /**
+     * Tests invalid class constructor for an empty string.
+     */
+    @Test(expected = IllegalArgumentException.class)
+    public void testInvalidConstructors() {
+        // Check constructor for invalid ID: empty string
+        Ip4Address ip4Address = new Ip4Address("");
+    }
+
+    /**
+     * Tests returning the address as a byte array.
+     */
+    @Test
+    public void testAddressToOctets() {
+        final byte[] value1 = new byte[] {1, 2, 3, 4};
+        Ip4Address ip4Address = new Ip4Address("1.2.3.4");
+        assertThat(ip4Address.toOctets(), is(value1));
+
+        final byte[] value2 = new byte[] {0, 0, 0, 0};
+        ip4Address = new Ip4Address("0.0.0.0");
+        assertThat(ip4Address.toOctets(), is(value2));
+
+        final byte[] value3 = new byte[] {(byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff};
+        ip4Address = new Ip4Address("255.255.255.255");
+        assertThat(ip4Address.toOctets(), is(value3));
+    }
+
+    /**
+     * Tests making a mask prefix for a given prefix length.
+     */
+    @Test
+    public void testMakeMaskPrefix() {
+        Ip4Address ip4Address = Ip4Address.makeMaskPrefix(25);
+        assertThat(ip4Address.toString(), is("255.255.255.128"));
+
+        ip4Address = Ip4Address.makeMaskPrefix(0);
+        assertThat(ip4Address.toString(), is("0.0.0.0"));
+
+        ip4Address = Ip4Address.makeMaskPrefix(32);
+        assertThat(ip4Address.toString(), is("255.255.255.255"));
+    }
+
+    /**
+     * Tests making of a masked address.
+     */
+    @Test
+    public void testMakeMaskedAddress() {
+        Ip4Address ip4Address = new Ip4Address("1.2.3.5");
+        Ip4Address ip4AddressMasked =
+            Ip4Address.makeMaskedAddress(ip4Address, 24);
+        assertThat(ip4AddressMasked.toString(), is("1.2.3.0"));
+
+        ip4AddressMasked = Ip4Address.makeMaskedAddress(ip4Address, 0);
+        assertThat(ip4AddressMasked.toString(), is("0.0.0.0"));
+
+        ip4AddressMasked = Ip4Address.makeMaskedAddress(ip4Address, 32);
+        assertThat(ip4AddressMasked.toString(), is("1.2.3.5"));
+    }
+
+    /**
+     * Tests getting the value of an address.
+     */
+    @Test
+    public void testGetValue() {
+        Ip4Address ip4Address = new Ip4Address("1.2.3.4");
+        assertThat(ip4Address.getValue(), is(0x01020304));
+
+        ip4Address = new Ip4Address("0.0.0.0");
+        assertThat(ip4Address.getValue(), is(0));
+
+        ip4Address = new Ip4Address("255.255.255.255");
+        assertThat(ip4Address.getValue(), is(-1));
+    }
+
+    /**
+     * Tests equality of {@link Ip4Address}.
+     */
+    @Test
+    public void testEquality() {
+        Ip4Address addr1 = new Ip4Address("1.2.3.4");
+        Ip4Address addr2 = new Ip4Address("1.2.3.4");
+        assertThat(addr1, is(addr2));
+
+        addr1 = new Ip4Address("0.0.0.0");
+        addr2 = new Ip4Address("0.0.0.0");
+        assertThat(addr1, is(addr2));
+
+        addr1 = new Ip4Address("255.255.255.255");
+        addr2 = new Ip4Address("255.255.255.255");
+        assertThat(addr1, is(addr2));
+    }
+
+    /**
+     * Tests non-equality of {@link Ip4Address}.
+     */
+    @Test
+    public void testNonEquality() {
+        Ip4Address addr1 = new Ip4Address("1.2.3.4");
+        Ip4Address addr2 = new Ip4Address("1.2.3.5");
+        Ip4Address addr3 = new Ip4Address("0.0.0.0");
+        Ip4Address addr4 = new Ip4Address("255.255.255.255");
+        assertThat(addr1, is(not(addr2)));
+        assertThat(addr3, is(not(addr2)));
+        assertThat(addr4, is(not(addr2)));
+    }
+
+    /**
+     * Tests comparison of {@link Ip4Address}.
+     */
+    @Test
+    public void testComparison() {
+        Ip4Address addr1 = new Ip4Address("1.2.3.4");
+        Ip4Address addr2 = new Ip4Address("1.2.3.4");
+        Ip4Address addr3 = new Ip4Address("1.2.3.3");
+        Ip4Address addr4 = new Ip4Address("1.2.3.5");
+        assertTrue(addr1.compareTo(addr2) == 0);
+        assertTrue(addr1.compareTo(addr3) > 0);
+        assertTrue(addr1.compareTo(addr4) < 0);
+
+        addr1 = new Ip4Address("255.2.3.4");
+        addr2 = new Ip4Address("255.2.3.4");
+        addr3 = new Ip4Address("255.2.3.3");
+        addr4 = new Ip4Address("255.2.3.5");
+        assertTrue(addr1.compareTo(addr2) == 0);
+        assertTrue(addr1.compareTo(addr3) > 0);
+        assertTrue(addr1.compareTo(addr4) < 0);
+    }
+
+    /**
+     * Tests object string representation.
+     */
+    @Test
+    public void testToString() {
+        Ip4Address ip4Address = new Ip4Address("1.2.3.4");
+        assertThat(ip4Address.toString(), is("1.2.3.4"));
+
+        ip4Address = new Ip4Address("0.0.0.0");
+        assertThat(ip4Address.toString(), is("0.0.0.0"));
+
+        ip4Address = new Ip4Address("255.255.255.255");
+        assertThat(ip4Address.toString(), is("255.255.255.255"));
+    }
+}
diff --git a/utils/misc/src/test/java/org/onlab/packet/Ip4PrefixTest.java b/utils/misc/src/test/java/org/onlab/packet/Ip4PrefixTest.java
new file mode 100644
index 0000000..3e502d3
--- /dev/null
+++ b/utils/misc/src/test/java/org/onlab/packet/Ip4PrefixTest.java
@@ -0,0 +1,195 @@
+package org.onlab.packet;
+
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertThat;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+/**
+ * Tests for class {@link Ip4Prefix}.
+ */
+public class Ip4PrefixTest {
+    /**
+     * Tests the immutability of {@link Ip4Prefix}.
+     */
+    @Test
+    public void testImmutable() {
+        assertThatClassIsImmutable(Ip4Prefix.class);
+    }
+
+    /**
+     * Tests default class constructor.
+     */
+    @Test
+    public void testDefaultConstructor() {
+        Ip4Prefix ip4prefix = new Ip4Prefix();
+        assertThat(ip4prefix.toString(), is("0.0.0.0/0"));
+    }
+
+    /**
+     * Tests valid class copy constructor.
+     */
+    @Test
+    public void testCopyConstructor() {
+        Ip4Prefix fromAddr = new Ip4Prefix("1.2.3.0/24");
+        Ip4Prefix ip4prefix = new Ip4Prefix(fromAddr);
+        assertThat(ip4prefix.toString(), is("1.2.3.0/24"));
+
+        fromAddr = new Ip4Prefix("0.0.0.0/0");
+        ip4prefix = new Ip4Prefix(fromAddr);
+        assertThat(ip4prefix.toString(), is("0.0.0.0/0"));
+
+        fromAddr = new Ip4Prefix("255.255.255.255/32");
+        ip4prefix = new Ip4Prefix(fromAddr);
+        assertThat(ip4prefix.toString(), is("255.255.255.255/32"));
+    }
+
+    /**
+     * Tests invalid class copy constructor for a null object to copy from.
+     */
+    @Test(expected = NullPointerException.class)
+    public void testInvalidConstructorNullObject() {
+        Ip4Prefix fromAddr = null;
+        Ip4Prefix ip4prefix = new Ip4Prefix(fromAddr);
+    }
+
+    /**
+     * Tests valid class constructor for an address and prefix length.
+     */
+    @Test
+    public void testConstructorForAddressAndPrefixLength() {
+        Ip4Prefix ip4prefix =
+            new Ip4Prefix(new Ip4Address("1.2.3.0"), (short) 24);
+        assertThat(ip4prefix.toString(), is("1.2.3.0/24"));
+
+        ip4prefix = new Ip4Prefix(new Ip4Address("1.2.3.4"), (short) 24);
+        assertThat(ip4prefix.toString(), is("1.2.3.0/24"));
+
+        ip4prefix = new Ip4Prefix(new Ip4Address("1.2.3.5"), (short) 32);
+        assertThat(ip4prefix.toString(), is("1.2.3.5/32"));
+
+        ip4prefix = new Ip4Prefix(new Ip4Address("0.0.0.0"), (short) 0);
+        assertThat(ip4prefix.toString(), is("0.0.0.0/0"));
+
+        ip4prefix =
+            new Ip4Prefix(new Ip4Address("255.255.255.255"), (short) 32);
+        assertThat(ip4prefix.toString(), is("255.255.255.255/32"));
+    }
+
+    /**
+     * Tests valid class constructor for a string.
+     */
+    @Test
+    public void testConstructorForString() {
+        Ip4Prefix ip4prefix = new Ip4Prefix("1.2.3.0/24");
+        assertThat(ip4prefix.toString(), is("1.2.3.0/24"));
+
+        ip4prefix = new Ip4Prefix("1.2.3.4/24");
+        assertThat(ip4prefix.toString(), is("1.2.3.0/24"));
+
+        ip4prefix = new Ip4Prefix("1.2.3.5/32");
+        assertThat(ip4prefix.toString(), is("1.2.3.5/32"));
+
+        ip4prefix = new Ip4Prefix("0.0.0.0/0");
+        assertThat(ip4prefix.toString(), is("0.0.0.0/0"));
+
+        ip4prefix = new Ip4Prefix("255.255.255.255/32");
+        assertThat(ip4prefix.toString(), is("255.255.255.255/32"));
+    }
+
+    /**
+     * Tests invalid class constructor for a null string.
+     */
+    @Test(expected = NullPointerException.class)
+    public void testInvalidConstructorNullString() {
+        String fromString = null;
+        Ip4Prefix ip4prefix = new Ip4Prefix(fromString);
+    }
+
+    /**
+     * Tests invalid class constructor for an empty string.
+     */
+    @Test(expected = IllegalArgumentException.class)
+    public void testInvalidConstructors() {
+        // Check constructor for invalid ID: empty string
+        Ip4Prefix ip4prefix = new Ip4Prefix("");
+    }
+
+    /**
+     * Tests getting the value of an address.
+     */
+    @Test
+    public void testGetValue() {
+        Ip4Prefix ip4prefix = new Ip4Prefix("1.2.3.0/24");
+        assertThat(ip4prefix.getAddress(), equalTo(new Ip4Address("1.2.3.0")));
+        assertThat(ip4prefix.getPrefixLen(), is((short) 24));
+
+        ip4prefix = new Ip4Prefix("0.0.0.0/0");
+        assertThat(ip4prefix.getAddress(), equalTo(new Ip4Address("0.0.0.0")));
+        assertThat(ip4prefix.getPrefixLen(), is((short) 0));
+
+        ip4prefix = new Ip4Prefix("255.255.255.255/32");
+        assertThat(ip4prefix.getAddress(),
+                   equalTo(new Ip4Address("255.255.255.255")));
+        assertThat(ip4prefix.getPrefixLen(), is((short) 32));
+    }
+
+    /**
+     * Tests equality of {@link Ip4Address}.
+     */
+    @Test
+    public void testEquality() {
+        Ip4Prefix addr1net = new Ip4Prefix("1.2.3.0/24");
+        Ip4Prefix addr2net = new Ip4Prefix("1.2.3.0/24");
+        assertThat(addr1net, is(addr2net));
+
+        addr1net = new Ip4Prefix("1.2.3.0/24");
+        addr2net = new Ip4Prefix("1.2.3.4/24");
+        assertThat(addr1net, is(addr2net));
+
+        addr1net = new Ip4Prefix("0.0.0.0/0");
+        addr2net = new Ip4Prefix("0.0.0.0/0");
+        assertThat(addr1net, is(addr2net));
+
+        addr1net = new Ip4Prefix("255.255.255.255/32");
+        addr2net = new Ip4Prefix("255.255.255.255/32");
+        assertThat(addr1net, is(addr2net));
+    }
+
+    /**
+     * Tests non-equality of {@link Ip4Address}.
+     */
+    @Test
+    public void testNonEquality() {
+        Ip4Prefix addr1net = new Ip4Prefix("1.2.0.0/16");
+        Ip4Prefix addr2net = new Ip4Prefix("1.3.0.0/16");
+        Ip4Prefix addr3net = new Ip4Prefix("1.3.0.0/24");
+        Ip4Prefix addr4net = new Ip4Prefix("0.0.0.0/0");
+        Ip4Prefix addr5net = new Ip4Prefix("255.255.255.255/32");
+        assertThat(addr1net, is(not(addr2net)));
+        assertThat(addr3net, is(not(addr2net)));
+        assertThat(addr4net, is(not(addr2net)));
+        assertThat(addr5net, is(not(addr2net)));
+    }
+
+    /**
+     * Tests object string representation.
+     */
+    @Test
+    public void testToString() {
+        Ip4Prefix ip4prefix = new Ip4Prefix("1.2.3.0/24");
+        assertThat(ip4prefix.toString(), is("1.2.3.0/24"));
+
+        ip4prefix = new Ip4Prefix("1.2.3.4/24");
+        assertThat(ip4prefix.toString(), is("1.2.3.0/24"));
+
+        ip4prefix = new Ip4Prefix("0.0.0.0/0");
+        assertThat(ip4prefix.toString(), is("0.0.0.0/0"));
+
+        ip4prefix = new Ip4Prefix("255.255.255.255/32");
+        assertThat(ip4prefix.toString(), is("255.255.255.255/32"));
+    }
+}
diff --git a/utils/misc/src/test/java/org/onlab/packet/Ip6AddressTest.java b/utils/misc/src/test/java/org/onlab/packet/Ip6AddressTest.java
new file mode 100644
index 0000000..a053301
--- /dev/null
+++ b/utils/misc/src/test/java/org/onlab/packet/Ip6AddressTest.java
@@ -0,0 +1,437 @@
+package org.onlab.packet;
+
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+/**
+ * Tests for class {@link Ip6Address}.
+ */
+public class Ip6AddressTest {
+    /**
+     * Tests the immutability of {@link Ip6Address}.
+     */
+    @Test
+    public void testImmutable() {
+        assertThatClassIsImmutable(Ip6Address.class);
+    }
+
+    /**
+     * Tests the length of the address in bytes (octets).
+     */
+    @Test
+    public void testAddrBytelen() {
+        assertThat(Ip6Address.BYTE_LENGTH, is(16));
+    }
+
+    /**
+     * Tests the length of the address in bits.
+     */
+    @Test
+    public void testAddrBitlen() {
+        assertThat(Ip6Address.BIT_LENGTH, is(128));
+    }
+
+    /**
+     * Tests default class constructor.
+     */
+    @Test
+    public void testDefaultConstructor() {
+        Ip6Address ip6Address = new Ip6Address();
+        assertThat(ip6Address.toString(), is("::"));
+    }
+
+    /**
+     * Tests valid class copy constructor.
+     */
+    @Test
+    public void testCopyConstructor() {
+        Ip6Address fromAddr =
+            new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8888");
+        Ip6Address ip6Address = new Ip6Address(fromAddr);
+        assertThat(ip6Address.toString(),
+                   is("1111:2222:3333:4444:5555:6666:7777:8888"));
+
+        fromAddr = new Ip6Address("::");
+        ip6Address = new Ip6Address(fromAddr);
+        assertThat(ip6Address.toString(), is("::"));
+
+        fromAddr = new Ip6Address("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
+        ip6Address = new Ip6Address(fromAddr);
+        assertThat(ip6Address.toString(),
+                   is("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
+    }
+
+    /**
+     * Tests invalid class copy constructor for a null object to copy from.
+     */
+    @Test(expected = NullPointerException.class)
+    public void testInvalidConstructorNullObject() {
+        Ip6Address fromAddr = null;
+        Ip6Address ip6Address = new Ip6Address(fromAddr);
+    }
+
+    /**
+     * Tests valid class constructor for integer values.
+     */
+    @Test
+    public void testConstructorForInteger() {
+        Ip6Address ip6Address =
+            new Ip6Address(0x1111222233334444L, 0x5555666677778888L);
+        assertThat(ip6Address.toString(),
+                   is("1111:2222:3333:4444:5555:6666:7777:8888"));
+
+        ip6Address = new Ip6Address(0L, 0L);
+        assertThat(ip6Address.toString(), is("::"));
+
+        ip6Address = new Ip6Address(-1L, -1L);
+        assertThat(ip6Address.toString(),
+                   is("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
+    }
+
+    /**
+     * Tests valid class constructor for an array value.
+     */
+    @Test
+    public void testConstructorForArray() {
+        final byte[] value1 = new byte[] {0x11, 0x11, 0x22, 0x22,
+                                          0x33, 0x33, 0x44, 0x44,
+                                          0x55, 0x55, 0x66, 0x66,
+                                          0x77, 0x77,
+                                          (byte) 0x88, (byte) 0x88};
+        Ip6Address ip6Address = new Ip6Address(value1);
+        assertThat(ip6Address.toString(),
+                   is("1111:2222:3333:4444:5555:6666:7777:8888"));
+
+        final byte[] value2 = new byte[] {0x00, 0x00, 0x00, 0x00,
+                                          0x00, 0x00, 0x00, 0x00,
+                                          0x00, 0x00, 0x00, 0x00,
+                                          0x00, 0x00, 0x00, 0x00};
+        ip6Address = new Ip6Address(value2);
+        assertThat(ip6Address.toString(), is("::"));
+
+        final byte[] value3 = new byte[] {(byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff};
+        ip6Address = new Ip6Address(value3);
+        assertThat(ip6Address.toString(),
+                   is("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
+    }
+
+    /**
+     * Tests valid class constructor for an array value and an offset.
+     */
+    @Test
+    public void testConstructorForArrayAndOffset() {
+        final byte[] value1 = new byte[] {11, 22, 33,           // Preamble
+                                          0x11, 0x11, 0x22, 0x22,
+                                          0x33, 0x33, 0x44, 0x44,
+                                          0x55, 0x55, 0x66, 0x66,
+                                          0x77, 0x77,
+                                          (byte) 0x88, (byte) 0x88,
+                                          44, 55};              // Extra bytes
+        Ip6Address ip6Address = new Ip6Address(value1, 3);
+        assertThat(ip6Address.toString(),
+                   is("1111:2222:3333:4444:5555:6666:7777:8888"));
+
+        final byte[] value2 = new byte[] {11, 22,               // Preamble
+                                          0x00, 0x00, 0x00, 0x00,
+                                          0x00, 0x00, 0x00, 0x00,
+                                          0x00, 0x00, 0x00, 0x00,
+                                          0x00, 0x00, 0x00, 0x00,
+                                          33};                  // Extra bytes
+        ip6Address = new Ip6Address(value2, 2);
+        assertThat(ip6Address.toString(), is("::"));
+
+        final byte[] value3 = new byte[] {11, 22,               // Preamble
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          33};                  // Extra bytes
+        ip6Address = new Ip6Address(value3, 2);
+        assertThat(ip6Address.toString(),
+                   is("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
+    }
+
+    /**
+     * Tests invalid class constructor for a null array.
+     */
+    @Test(expected = NullPointerException.class)
+    public void testInvalidConstructorNullArray() {
+        final byte[] fromArray = null;
+        Ip6Address ip6Address = new Ip6Address(fromArray);
+    }
+
+    /**
+     * Tests invalid class constructor for an array that is too short.
+     */
+    @Test(expected = IllegalArgumentException.class)
+    public void testInvalidConstructorShortArray() {
+        final byte[] fromArray = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9};
+        Ip6Address ip6Address = new Ip6Address(fromArray);
+    }
+
+    /**
+     * Tests invalid class constructor for an array and an invalid offset.
+     */
+    @Test(expected = IllegalArgumentException.class)
+    public void testInvalidConstructorArrayInvalidOffset() {
+        final byte[] value1 = new byte[] {11, 22, 33,           // Preamble
+                                          0x11, 0x11, 0x22, 0x22,
+                                          0x33, 0x33, 0x44, 0x44,
+                                          0x55, 0x55, 0x66, 0x66,
+                                          0x77, 0x77,
+                                          (byte) 0x88, (byte) 0x88,
+                                          44, 55};              // Extra bytes
+        Ip6Address ip6Address = new Ip6Address(value1, 6);
+    }
+
+    /**
+     * Tests valid class constructor for a string.
+     */
+    @Test
+    public void testConstructorForString() {
+        Ip6Address ip6Address =
+            new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8888");
+        assertThat(ip6Address.toString(),
+                   is("1111:2222:3333:4444:5555:6666:7777:8888"));
+
+        ip6Address = new Ip6Address("::");
+        assertThat(ip6Address.toString(), is("::"));
+
+        ip6Address = new Ip6Address("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
+        assertThat(ip6Address.toString(),
+                   is("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
+    }
+
+    /**
+     * Tests invalid class constructor for a null string.
+     */
+    @Test(expected = NullPointerException.class)
+    public void testInvalidConstructorNullString() {
+        String fromString = null;
+        Ip6Address ip6Address = new Ip6Address(fromString);
+    }
+
+    /**
+     * Tests invalid class constructor for an empty string.
+     */
+    @Test(expected = IllegalArgumentException.class)
+    public void testInvalidConstructors() {
+        // Check constructor for invalid ID: empty string
+        Ip6Address ip6Address = new Ip6Address("");
+    }
+
+    /**
+     * Tests returning the address as a byte array.
+     */
+    @Test
+    public void testAddressToOctets() {
+        final byte[] value1 = new byte[] {0x11, 0x11, 0x22, 0x22,
+                                          0x33, 0x33, 0x44, 0x44,
+                                          0x55, 0x55, 0x66, 0x66,
+                                          0x77, 0x77,
+                                          (byte) 0x88, (byte) 0x88};
+        Ip6Address ip6Address =
+            new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8888");
+        assertThat(ip6Address.toOctets(), is(value1));
+
+        final byte[] value2 = new byte[] {0x00, 0x00, 0x00, 0x00,
+                                          0x00, 0x00, 0x00, 0x00,
+                                          0x00, 0x00, 0x00, 0x00,
+                                          0x00, 0x00, 0x00, 0x00};
+        ip6Address = new Ip6Address("::");
+        assertThat(ip6Address.toOctets(), is(value2));
+
+        final byte[] value3 = new byte[] {(byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff,
+                                          (byte) 0xff, (byte) 0xff};
+        ip6Address = new Ip6Address("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
+        assertThat(ip6Address.toOctets(), is(value3));
+    }
+
+    /**
+     * Tests making a mask prefix for a given prefix length.
+     */
+    @Test
+    public void testMakeMaskPrefix() {
+        Ip6Address ip6Address = Ip6Address.makeMaskPrefix(8);
+        assertThat(ip6Address.toString(), is("ff00::"));
+
+        ip6Address = Ip6Address.makeMaskPrefix(120);
+        assertThat(ip6Address.toString(),
+                   is("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ff00"));
+
+        ip6Address = Ip6Address.makeMaskPrefix(0);
+        assertThat(ip6Address.toString(), is("::"));
+
+        ip6Address = Ip6Address.makeMaskPrefix(128);
+        assertThat(ip6Address.toString(),
+                   is("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
+
+        ip6Address = Ip6Address.makeMaskPrefix(64);
+        assertThat(ip6Address.toString(), is("ffff:ffff:ffff:ffff::"));
+    }
+
+    /**
+     * Tests making of a masked address.
+     */
+    @Test
+    public void testMakeMaskedAddress() {
+        Ip6Address ip6Address =
+            new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8885");
+        Ip6Address ip6AddressMasked =
+            Ip6Address.makeMaskedAddress(ip6Address, 8);
+        assertThat(ip6AddressMasked.toString(), is("1100::"));
+
+        ip6AddressMasked = Ip6Address.makeMaskedAddress(ip6Address, 120);
+        assertThat(ip6AddressMasked.toString(),
+                   is("1111:2222:3333:4444:5555:6666:7777:8800"));
+
+        ip6AddressMasked = Ip6Address.makeMaskedAddress(ip6Address, 0);
+        assertThat(ip6AddressMasked.toString(), is("::"));
+
+        ip6AddressMasked = Ip6Address.makeMaskedAddress(ip6Address, 128);
+        assertThat(ip6AddressMasked.toString(),
+                   is("1111:2222:3333:4444:5555:6666:7777:8885"));
+
+        ip6AddressMasked = Ip6Address.makeMaskedAddress(ip6Address, 64);
+        assertThat(ip6AddressMasked.toString(), is("1111:2222:3333:4444::"));
+    }
+
+    /**
+     * Tests getting the value of an address.
+     */
+    @Test
+    public void testGetValue() {
+        Ip6Address ip6Address =
+            new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8888");
+        assertThat(ip6Address.getValueHigh(), is(0x1111222233334444L));
+        assertThat(ip6Address.getValueLow(), is(0x5555666677778888L));
+
+        ip6Address = new Ip6Address(0, 0);
+        assertThat(ip6Address.getValueHigh(), is(0L));
+        assertThat(ip6Address.getValueLow(), is(0L));
+
+        ip6Address = new Ip6Address(-1L, -1L);
+        assertThat(ip6Address.getValueHigh(), is(-1L));
+        assertThat(ip6Address.getValueLow(), is(-1L));
+    }
+
+    /**
+     * Tests equality of {@link Ip6Address}.
+     */
+    @Test
+    public void testEquality() {
+        Ip6Address addr1 =
+            new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8888");
+        Ip6Address addr2 =
+            new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8888");
+        assertThat(addr1, is(addr2));
+
+        addr1 = new Ip6Address("::");
+        addr2 = new Ip6Address("::");
+        assertThat(addr1, is(addr2));
+
+        addr1 = new Ip6Address("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
+        addr2 = new Ip6Address("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
+        assertThat(addr1, is(addr2));
+    }
+
+    /**
+     * Tests non-equality of {@link Ip6Address}.
+     */
+    @Test
+    public void testNonEquality() {
+        Ip6Address addr1 =
+            new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8888");
+        Ip6Address addr2 =
+            new Ip6Address("1111:2222:3333:4444:5555:6666:7777:888A");
+        Ip6Address addr3 = new Ip6Address("::");
+        Ip6Address addr4 =
+            new Ip6Address("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
+        assertThat(addr1, is(not(addr2)));
+        assertThat(addr3, is(not(addr2)));
+        assertThat(addr4, is(not(addr2)));
+    }
+
+    /**
+     * Tests comparison of {@link Ip6Address}.
+     */
+    @Test
+    public void testComparison() {
+        Ip6Address addr1 =
+            new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8888");
+        Ip6Address addr2 =
+            new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8888");
+        Ip6Address addr3 =
+            new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8887");
+        Ip6Address addr4 =
+            new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8889");
+        assertTrue(addr1.compareTo(addr2) == 0);
+        assertTrue(addr1.compareTo(addr3) > 0);
+        assertTrue(addr1.compareTo(addr4) < 0);
+
+        addr1 = new Ip6Address("ffff:2222:3333:4444:5555:6666:7777:8888");
+        addr2 = new Ip6Address("ffff:2222:3333:4444:5555:6666:7777:8888");
+        addr3 = new Ip6Address("ffff:2222:3333:4444:5555:6666:7777:8887");
+        addr4 = new Ip6Address("ffff:2222:3333:4444:5555:6666:7777:8889");
+        assertTrue(addr1.compareTo(addr2) == 0);
+        assertTrue(addr1.compareTo(addr3) > 0);
+        assertTrue(addr1.compareTo(addr4) < 0);
+
+        addr1 = new Ip6Address("ffff:2222:3333:4444:5555:6666:7777:8888");
+        addr2 = new Ip6Address("ffff:2222:3333:4444:5555:6666:7777:8888");
+        addr3 = new Ip6Address("ffff:2222:3333:4443:5555:6666:7777:8888");
+        addr4 = new Ip6Address("ffff:2222:3333:4445:5555:6666:7777:8888");
+        assertTrue(addr1.compareTo(addr2) == 0);
+        assertTrue(addr1.compareTo(addr3) > 0);
+        assertTrue(addr1.compareTo(addr4) < 0);
+    }
+
+    /**
+     * Tests object string representation.
+     */
+    @Test
+    public void testToString() {
+        Ip6Address ip6Address =
+            new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8888");
+        assertThat(ip6Address.toString(),
+                   is("1111:2222:3333:4444:5555:6666:7777:8888"));
+
+        ip6Address = new Ip6Address("1111::8888");
+        assertThat(ip6Address.toString(), is("1111::8888"));
+
+        ip6Address = new Ip6Address("1111::");
+        assertThat(ip6Address.toString(), is("1111::"));
+
+        ip6Address = new Ip6Address("::8888");
+        assertThat(ip6Address.toString(), is("::8888"));
+
+        ip6Address = new Ip6Address("::");
+        assertThat(ip6Address.toString(), is("::"));
+
+        ip6Address = new Ip6Address("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
+        assertThat(ip6Address.toString(),
+                   is("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
+    }
+}
diff --git a/utils/misc/src/test/java/org/onlab/packet/Ip6PrefixTest.java b/utils/misc/src/test/java/org/onlab/packet/Ip6PrefixTest.java
new file mode 100644
index 0000000..dcacdc7
--- /dev/null
+++ b/utils/misc/src/test/java/org/onlab/packet/Ip6PrefixTest.java
@@ -0,0 +1,255 @@
+package org.onlab.packet;
+
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertThat;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+/**
+ * Tests for class {@link Ip6Prefix}.
+ */
+public class Ip6PrefixTest {
+    /**
+     * Tests the immutability of {@link Ip6Prefix}.
+     */
+    @Test
+    public void testImmutable() {
+        assertThatClassIsImmutable(Ip6Prefix.class);
+    }
+
+    /**
+     * Tests default class constructor.
+     */
+    @Test
+    public void testDefaultConstructor() {
+        Ip6Prefix ip6prefix = new Ip6Prefix();
+        assertThat(ip6prefix.toString(), is("::/0"));
+    }
+
+    /**
+     * Tests valid class copy constructor.
+     */
+    @Test
+    public void testCopyConstructor() {
+        Ip6Prefix fromAddr = new Ip6Prefix("1100::/8");
+        Ip6Prefix ip6prefix = new Ip6Prefix(fromAddr);
+        assertThat(ip6prefix.toString(), is("1100::/8"));
+
+        fromAddr = new Ip6Prefix("::/0");
+        ip6prefix = new Ip6Prefix(fromAddr);
+        assertThat(ip6prefix.toString(), is("::/0"));
+
+        fromAddr =
+            new Ip6Prefix("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128");
+        ip6prefix = new Ip6Prefix(fromAddr);
+        assertThat(ip6prefix.toString(),
+                   is("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128"));
+    }
+
+    /**
+     * Tests invalid class copy constructor for a null object to copy from.
+     */
+    @Test(expected = NullPointerException.class)
+    public void testInvalidConstructorNullObject() {
+        Ip6Prefix fromAddr = null;
+        Ip6Prefix ip6prefix = new Ip6Prefix(fromAddr);
+    }
+
+    /**
+     * Tests valid class constructor for an address and prefix length.
+     */
+    @Test
+    public void testConstructorForAddressAndPrefixLength() {
+        Ip6Prefix ip6prefix =
+            new Ip6Prefix(new Ip6Address("1100::"), (short) 8);
+        assertThat(ip6prefix.toString(), is("1100::/8"));
+
+        ip6prefix =
+            new Ip6Prefix(new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8885"),
+                        (short) 8);
+        assertThat(ip6prefix.toString(), is("1100::/8"));
+
+        ip6prefix =
+            new Ip6Prefix(new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8800"),
+                        (short) 120);
+        assertThat(ip6prefix.toString(),
+                   is("1111:2222:3333:4444:5555:6666:7777:8800/120"));
+
+        ip6prefix = new Ip6Prefix(new Ip6Address("::"), (short) 0);
+        assertThat(ip6prefix.toString(), is("::/0"));
+
+        ip6prefix =
+            new Ip6Prefix(new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8885"),
+                        (short) 128);
+        assertThat(ip6prefix.toString(),
+                   is("1111:2222:3333:4444:5555:6666:7777:8885/128"));
+
+        ip6prefix =
+            new Ip6Prefix(new Ip6Address("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"),
+                        (short) 128);
+        assertThat(ip6prefix.toString(),
+                   is("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128"));
+
+        ip6prefix =
+            new Ip6Prefix(new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8885"),
+                        (short) 64);
+        assertThat(ip6prefix.toString(), is("1111:2222:3333:4444::/64"));
+    }
+
+    /**
+     * Tests valid class constructor for a string.
+     */
+    @Test
+    public void testConstructorForString() {
+        Ip6Prefix ip6prefix = new Ip6Prefix("1100::/8");
+        assertThat(ip6prefix.toString(), is("1100::/8"));
+
+        ip6prefix = new Ip6Prefix("1111:2222:3333:4444:5555:6666:7777:8885/8");
+        assertThat(ip6prefix.toString(), is("1100::/8"));
+
+        ip6prefix =
+            new Ip6Prefix("1111:2222:3333:4444:5555:6666:7777:8800/120");
+        assertThat(ip6prefix.toString(),
+                   is("1111:2222:3333:4444:5555:6666:7777:8800/120"));
+
+        ip6prefix = new Ip6Prefix("::/0");
+        assertThat(ip6prefix.toString(), is("::/0"));
+
+        ip6prefix =
+            new Ip6Prefix("1111:2222:3333:4444:5555:6666:7777:8885/128");
+        assertThat(ip6prefix.toString(),
+                   is("1111:2222:3333:4444:5555:6666:7777:8885/128"));
+
+        ip6prefix = new Ip6Prefix("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128");
+        assertThat(ip6prefix.toString(),
+                   is("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128"));
+
+        ip6prefix =
+            new Ip6Prefix("1111:2222:3333:4444:5555:6666:7777:8885/64");
+        assertThat(ip6prefix.toString(), is("1111:2222:3333:4444::/64"));
+    }
+
+    /**
+     * Tests invalid class constructor for a null string.
+     */
+    @Test(expected = NullPointerException.class)
+    public void testInvalidConstructorNullString() {
+        String fromString = null;
+        Ip6Prefix ip6prefix = new Ip6Prefix(fromString);
+    }
+
+    /**
+     * Tests invalid class constructor for an empty string.
+     */
+    @Test(expected = IllegalArgumentException.class)
+    public void testInvalidConstructors() {
+        // Check constructor for invalid ID: empty string
+        Ip6Prefix ip6prefix = new Ip6Prefix("");
+    }
+
+    /**
+     * Tests getting the value of an address.
+     */
+    @Test
+    public void testGetValue() {
+        Ip6Prefix ip6prefix = new Ip6Prefix("1100::/8");
+        assertThat(ip6prefix.getAddress(), equalTo(new Ip6Address("1100::")));
+        assertThat(ip6prefix.getPrefixLen(), is((short) 8));
+
+        ip6prefix = new Ip6Prefix("1111:2222:3333:4444:5555:6666:7777:8885/8");
+        assertThat(ip6prefix.getAddress(), equalTo(new Ip6Address("1100::")));
+        assertThat(ip6prefix.getPrefixLen(), is((short) 8));
+
+        ip6prefix =
+            new Ip6Prefix("1111:2222:3333:4444:5555:6666:7777:8800/120");
+        assertThat(ip6prefix.getAddress(),
+                   equalTo(new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8800")));
+        assertThat(ip6prefix.getPrefixLen(), is((short) 120));
+
+        ip6prefix = new Ip6Prefix("::/0");
+        assertThat(ip6prefix.getAddress(), equalTo(new Ip6Address("::")));
+        assertThat(ip6prefix.getPrefixLen(), is((short) 0));
+
+        ip6prefix =
+            new Ip6Prefix("1111:2222:3333:4444:5555:6666:7777:8885/128");
+        assertThat(ip6prefix.getAddress(),
+                   equalTo(new Ip6Address("1111:2222:3333:4444:5555:6666:7777:8885")));
+        assertThat(ip6prefix.getPrefixLen(), is((short) 128));
+
+        ip6prefix =
+            new Ip6Prefix("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128");
+        assertThat(ip6prefix.getAddress(),
+                   equalTo(new Ip6Address("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")));
+        assertThat(ip6prefix.getPrefixLen(), is((short) 128));
+
+        ip6prefix =
+            new Ip6Prefix("1111:2222:3333:4444:5555:6666:7777:8885/64");
+        assertThat(ip6prefix.getAddress(),
+                   equalTo(new Ip6Address("1111:2222:3333:4444::")));
+        assertThat(ip6prefix.getPrefixLen(), is((short) 64));
+    }
+
+    /**
+     * Tests equality of {@link Ip6Address}.
+     */
+    @Test
+    public void testEquality() {
+        Ip6Prefix addr1net = new Ip6Prefix("1100::/8");
+        Ip6Prefix addr2net = new Ip6Prefix("1100::/8");
+        assertThat(addr1net, is(addr2net));
+
+        addr1net = new Ip6Prefix("1111:2222:3333:4444:5555:6666:7777:8885/8");
+        addr2net = new Ip6Prefix("1100::/8");
+        assertThat(addr1net, is(addr2net));
+
+        addr1net = new Ip6Prefix("::/0");
+        addr2net = new Ip6Prefix("::/0");
+        assertThat(addr1net, is(addr2net));
+
+        addr1net =
+            new Ip6Prefix("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128");
+        addr2net =
+            new Ip6Prefix("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128");
+        assertThat(addr1net, is(addr2net));
+    }
+
+    /**
+     * Tests non-equality of {@link Ip6Address}.
+     */
+    @Test
+    public void testNonEquality() {
+        Ip6Prefix addr1net = new Ip6Prefix("1100::/8");
+        Ip6Prefix addr2net = new Ip6Prefix("1200::/8");
+        Ip6Prefix addr3net = new Ip6Prefix("1200::/12");
+        Ip6Prefix addr4net = new Ip6Prefix("::/0");
+        Ip6Prefix addr5net =
+            new Ip6Prefix("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128");
+        assertThat(addr1net, is(not(addr2net)));
+        assertThat(addr3net, is(not(addr2net)));
+        assertThat(addr4net, is(not(addr2net)));
+        assertThat(addr5net, is(not(addr2net)));
+    }
+
+    /**
+     * Tests object string representation.
+     */
+    @Test
+    public void testToString() {
+        Ip6Prefix ip6prefix = new Ip6Prefix("1100::/8");
+        assertThat(ip6prefix.toString(), is("1100::/8"));
+
+        ip6prefix = new Ip6Prefix("1111:2222:3333:4444:5555:6666:7777:8885/8");
+        assertThat(ip6prefix.toString(), is("1100::/8"));
+
+        ip6prefix = new Ip6Prefix("::/0");
+        assertThat(ip6prefix.toString(), is("::/0"));
+
+        ip6prefix =
+            new Ip6Prefix("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128");
+        assertThat(ip6prefix.toString(),
+                   is("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128"));
+    }
+}