T3: Support for Ipv6 in CLI command
Change-Id: I88ca31e60ff5fb0b61206cd13cd62ecaf24fa876
diff --git a/apps/t3/src/main/java/org/onosproject/t3/cli/TroubleshootTraceCommand.java b/apps/t3/src/main/java/org/onosproject/t3/cli/TroubleshootTraceCommand.java
index a42872a..fdeb944 100644
--- a/apps/t3/src/main/java/org/onosproject/t3/cli/TroubleshootTraceCommand.java
+++ b/apps/t3/src/main/java/org/onosproject/t3/cli/TroubleshootTraceCommand.java
@@ -18,7 +18,6 @@
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option;
-import org.onlab.packet.EthType;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.TpPort;
@@ -34,6 +33,8 @@
import java.util.List;
+import static org.onlab.packet.EthType.EtherType;
+
/**
* Starts a Static Packet Trace for a given input and prints the result.
*/
@@ -71,8 +72,8 @@
@Option(name = "-stp", aliases = "--srcTcpPort", description = "Source TCP Port")
String srcTcpPort = null;
- @Option(name = "-d", aliases = "--dstIp", description = "Destination IP", valueToShowInHelp = "255.255.255.255")
- String dstIp = "255.255.255.255";
+ @Option(name = "-d", aliases = "--dstIp", description = "Destination IP")
+ String dstIp = null;
@Option(name = "-dm", aliases = "--dstMac", description = "Destination MAC")
String dstMac = null;
@@ -90,13 +91,18 @@
protected void execute() {
TroubleshootService service = get(TroubleshootService.class);
ConnectPoint cp = ConnectPoint.deviceConnectPoint(srcPort);
+ EtherType type = EtherType.valueOf(ethType.toUpperCase());
//Input Port must be specified
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder()
.matchInPort(cp.port());
if (srcIp != null) {
- selectorBuilder.matchIPSrc(IpAddress.valueOf(srcIp).toIpPrefix());
+ if (type.equals(EtherType.IPV6)) {
+ selectorBuilder.matchIPv6Src(IpAddress.valueOf(srcIp).toIpPrefix());
+ } else {
+ selectorBuilder.matchIPSrc(IpAddress.valueOf(srcIp).toIpPrefix());
+ }
}
if (srcMac != null) {
@@ -104,14 +110,19 @@
}
//if EthType option is not specified using IPv4
- selectorBuilder.matchEthType(EthType.EtherType.valueOf(ethType.toUpperCase()).ethType().toShort());
+ selectorBuilder.matchEthType(type.ethType().toShort());
if (srcTcpPort != null) {
selectorBuilder.matchTcpSrc(TpPort.tpPort(Integer.parseInt(srcTcpPort)));
}
- //if destination Ip option is not specified using broadcast 255.255.255.255
- selectorBuilder.matchIPDst(IpAddress.valueOf(dstIp).toIpPrefix());
+ if (dstIp != null) {
+ if (type.equals(EtherType.IPV6)) {
+ selectorBuilder.matchIPv6Dst(IpAddress.valueOf(dstIp).toIpPrefix());
+ } else {
+ selectorBuilder.matchIPDst(IpAddress.valueOf(dstIp).toIpPrefix());
+ }
+ }
if (dstMac != null) {
selectorBuilder.matchEthDst(MacAddress.valueOf(dstMac));