Implement some of the missing IPv6 flowmod treatments

Work toward ONOS-509

The following treatments are added/implemented:
  - IPV6_SRC
  - IPV6_DST
  - IPV6_FLABEL

Also:
 - Renamed L3ModificationInstruction.L3SubType.IP_SRC and IP_DST
   to IPV4_SRC and IPV4_DST (for naming consistency).
 - Few minor fixes in related code: Javadocs, comments, log messages,
   and IP address usage.

Change-Id: I551056f767a37e7cb6ae7d79f4a3929183500b57
diff --git a/web/api/src/test/java/org/onosproject/codec/impl/InstructionCodecTest.java b/web/api/src/test/java/org/onosproject/codec/impl/InstructionCodecTest.java
index 8bf4439..923573e 100644
--- a/web/api/src/test/java/org/onosproject/codec/impl/InstructionCodecTest.java
+++ b/web/api/src/test/java/org/onosproject/codec/impl/InstructionCodecTest.java
@@ -17,8 +17,8 @@
 
 import org.junit.Before;
 import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.Ip6Address;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.VlanId;
 import org.onosproject.codec.CodecContext;
@@ -144,11 +144,11 @@
     }
 
     /**
-     * Tests the encoding of mod ip instructions.
+     * Tests the encoding of mod IPv4 src instructions.
      */
     @Test
-    public void modIPInstructionTest() {
-        final IpAddress ip = IpPrefix.valueOf("1.2.3.4/24").address();
+    public void modIPSrcInstructionTest() {
+        final Ip4Address ip = Ip4Address.valueOf("1.2.3.4");
         final L3ModificationInstruction.ModIPInstruction instruction =
                 (L3ModificationInstruction.ModIPInstruction)
                         Instructions.modL3Src(ip);
@@ -158,6 +158,62 @@
     }
 
     /**
+     * Tests the encoding of mod IPv4 dst instructions.
+     */
+    @Test
+    public void modIPDstInstructionTest() {
+        final Ip4Address ip = Ip4Address.valueOf("1.2.3.4");
+        final L3ModificationInstruction.ModIPInstruction instruction =
+                (L3ModificationInstruction.ModIPInstruction)
+                        Instructions.modL3Dst(ip);
+        final ObjectNode instructionJson =
+                instructionCodec.encode(instruction, context);
+        assertThat(instructionJson, matchesInstruction(instruction));
+    }
+
+    /**
+     * Tests the encoding of mod IPv6 src instructions.
+     */
+    @Test
+    public void modIPv6SrcInstructionTest() {
+        final Ip6Address ip = Ip6Address.valueOf("1111::2222");
+        final L3ModificationInstruction.ModIPInstruction instruction =
+                (L3ModificationInstruction.ModIPInstruction)
+                        Instructions.modL3IPv6Src(ip);
+        final ObjectNode instructionJson =
+                instructionCodec.encode(instruction, context);
+        assertThat(instructionJson, matchesInstruction(instruction));
+    }
+
+    /**
+     * Tests the encoding of mod IPv6 dst instructions.
+     */
+    @Test
+    public void modIPv6DstInstructionTest() {
+        final Ip6Address ip = Ip6Address.valueOf("1111::2222");
+        final L3ModificationInstruction.ModIPInstruction instruction =
+                (L3ModificationInstruction.ModIPInstruction)
+                        Instructions.modL3IPv6Dst(ip);
+        final ObjectNode instructionJson =
+                instructionCodec.encode(instruction, context);
+        assertThat(instructionJson, matchesInstruction(instruction));
+    }
+
+    /**
+     * Tests the encoding of mod IPv6 flow label instructions.
+     */
+    @Test
+    public void modIPv6FlowLabelInstructionTest() {
+        final int flowLabel = 0xfffff;
+        final L3ModificationInstruction.ModIPv6FlowLabelInstruction instruction =
+                (L3ModificationInstruction.ModIPv6FlowLabelInstruction)
+                        Instructions.modL3IPv6FlowLabel(flowLabel);
+        final ObjectNode instructionJson =
+                instructionCodec.encode(instruction, context);
+        assertThat(instructionJson, matchesInstruction(instruction));
+    }
+
+    /**
      * Tests the encoding of mod MPLS label instructions.
      */
     @Test