ONOS-1264 Expose IPv6 support at the ONOS CLI level

Change-Id: I12b16eb97b011899984fda00db229b5a8ff00fa3
diff --git a/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
index 500126a..10889fe 100644
--- a/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
@@ -22,12 +22,13 @@
 import java.util.List;
 
 import org.apache.karaf.shell.commands.Option;
+import org.onlab.packet.Ip6Address;
+import org.onlab.packet.IpAddress;
 import org.onosproject.cli.AbstractShellCommand;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
 import org.onosproject.net.Link;
 import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
 import org.onosproject.net.flow.TrafficSelector;
 import org.onosproject.net.flow.TrafficTreatment;
 import org.onosproject.net.intent.Constraint;
@@ -70,6 +71,30 @@
             required = false, multiValued = false)
     private String dstIpString = null;
 
+    @Option(name = "--fLabel", description = "IPv6 Flow Label",
+            required = false, multiValued = false)
+    private String fLabelString = null;
+
+    @Option(name = "--icmp6Type", description = "ICMPv6 Type",
+            required = false, multiValued = false)
+    private String icmp6TypeString = null;
+
+    @Option(name = "--icmp6Code", description = "ICMPv6 Code",
+            required = false, multiValued = false)
+    private String icmp6CodeString = null;
+
+    @Option(name = "--ndTarget", description = "IPv6 Neighbor Discovery Target Address",
+            required = false, multiValued = false)
+    private String ndTargetString = null;
+
+    @Option(name = "--ndSLL", description = "IPv6 Neighbor Discovery Source Link-Layer",
+            required = false, multiValued = false)
+    private String ndSLLString = null;
+
+    @Option(name = "--ndTLL", description = "IPv6 Neighbor Discovery Target Link-Layer",
+            required = false, multiValued = false)
+    private String ndTLLString = null;
+
     @Option(name = "--tcpSrc", description = "Source TCP Port",
             required = false, multiValued = false)
     private String srcTcpString = null;
@@ -78,6 +103,10 @@
             required = false, multiValued = false)
     private String dstTcpString = null;
 
+    @Option(name = "--extHdr", description = "IPv6 Extension Header Pseudo-field",
+            required = false, multiValued = false)
+    private String extHdrString = null;
+
     @Option(name = "-b", aliases = "--bandwidth", description = "Bandwidth",
             required = false, multiValued = false)
     private String bandwidthString = null;
@@ -104,6 +133,15 @@
             required = false, multiValued = false)
     private String setEthDstString = null;
 
+    @Option(name = "--setIpSrc", description = "Rewrite Source IP Address",
+            required = false, multiValued = false)
+    private String setIpSrcString = null;
+
+    @Option(name = "--setIpDst", description = "Rewrite Destination IP Address",
+            required = false, multiValued = false)
+    private String setIpDstString = null;
+
+
     // Priorities
     @Option(name = "-p", aliases = "--priority", description = "Priority",
             required = false, multiValued = false)
@@ -174,6 +212,30 @@
             selectorBuilder.matchIPProtocol((byte) ipProtoShort);
         }
 
+        if (!isNullOrEmpty(fLabelString)) {
+            selectorBuilder.matchIPv6FlowLabel(Integer.parseInt(fLabelString));
+        }
+
+        if (!isNullOrEmpty(icmp6TypeString)) {
+            selectorBuilder.matchIcmpv6Type((byte) Integer.parseInt(icmp6TypeString));
+        }
+
+        if (!isNullOrEmpty(icmp6CodeString)) {
+            selectorBuilder.matchIcmpv6Code((byte) Integer.parseInt(icmp6CodeString));
+        }
+
+        if (!isNullOrEmpty(ndTargetString)) {
+            selectorBuilder.matchIPv6NDTargetAddress(Ip6Address.valueOf(ndTargetString));
+        }
+
+        if (!isNullOrEmpty(ndSLLString)) {
+            selectorBuilder.matchIPv6NDSourceLinkLayerAddress(MacAddress.valueOf(ndSLLString));
+        }
+
+        if (!isNullOrEmpty(ndTLLString)) {
+            selectorBuilder.matchIPv6NDTargetLinkLayerAddress(MacAddress.valueOf(ndTLLString));
+        }
+
         if (!isNullOrEmpty(srcTcpString)) {
             selectorBuilder.matchTcpSrc((short) Integer.parseInt(srcTcpString));
         }
@@ -182,6 +244,10 @@
             selectorBuilder.matchTcpDst((short) Integer.parseInt(dstTcpString));
         }
 
+        if (!isNullOrEmpty(extHdrString)) {
+            selectorBuilder.matchIPv6ExthdrFlags(Integer.parseInt(extHdrString));
+        }
+
         return selectorBuilder.build();
     }
 
@@ -192,23 +258,25 @@
      * @return traffic treatment
      */
     protected TrafficTreatment buildTrafficTreatment() {
-        boolean hasEthSrc = !isNullOrEmpty(setEthSrcString);
-        boolean hasEthDst = !isNullOrEmpty(setEthDstString);
+        final TrafficTreatment.Builder treatmentBuilder = builder();
 
-        if (!hasEthSrc && !hasEthDst) {
-            return DefaultTrafficTreatment.emptyTreatment();
+        if (!isNullOrEmpty(setEthSrcString)) {
+            treatmentBuilder.setEthSrc(MacAddress.valueOf(setEthSrcString));
         }
 
-        final TrafficTreatment.Builder builder = builder();
-        if (hasEthSrc) {
-            final MacAddress setEthSrc = MacAddress.valueOf(setEthSrcString);
-            builder.setEthSrc(setEthSrc);
+        if (!isNullOrEmpty(setEthDstString)) {
+            treatmentBuilder.setEthDst(MacAddress.valueOf(setEthDstString));
         }
-        if (hasEthDst) {
-            final MacAddress setEthDst = MacAddress.valueOf(setEthDstString);
-            builder.setEthDst(setEthDst);
+
+        if (!isNullOrEmpty(setIpSrcString)) {
+            treatmentBuilder.setIpSrc(IpAddress.valueOf(setIpSrcString));
         }
-        return builder.build();
+
+        if (!isNullOrEmpty(setIpDstString)) {
+            treatmentBuilder.setIpSrc(IpAddress.valueOf(setIpDstString));
+        }
+
+        return treatmentBuilder.build();
     }
 
     /**
diff --git a/cli/src/main/java/org/onosproject/cli/net/IpProtocol.java b/cli/src/main/java/org/onosproject/cli/net/IpProtocol.java
index d197df9..5e0d865 100644
--- a/cli/src/main/java/org/onosproject/cli/net/IpProtocol.java
+++ b/cli/src/main/java/org/onosproject/cli/net/IpProtocol.java
@@ -16,6 +16,7 @@
 package org.onosproject.cli.net;
 
 import org.onlab.packet.IPv4;
+import org.onlab.packet.IPv6;
 
 /**
  * Known protocol values for IP protocol field that can be supplied to the CLI.
@@ -26,7 +27,9 @@
     /** TCP. **/
     TCP(IPv4.PROTOCOL_TCP),
     /** UDP. **/
-    UDP(IPv4.PROTOCOL_UDP);
+    UDP(IPv4.PROTOCOL_UDP),
+    /** ICMP6. **/
+    ICMP6(IPv6.PROTOCOL_ICMP6);
 
     private short value;