Committed by
Gerrit Code Review
ONOS-1264 Expose IPv6 support at the ONOS CLI level
Change-Id: I12b16eb97b011899984fda00db229b5a8ff00fa3
Showing
2 changed files
with
85 additions
and
14 deletions
| ... | @@ -22,12 +22,13 @@ import java.util.LinkedList; | ... | @@ -22,12 +22,13 @@ import java.util.LinkedList; |
| 22 | import java.util.List; | 22 | import java.util.List; |
| 23 | 23 | ||
| 24 | import org.apache.karaf.shell.commands.Option; | 24 | import org.apache.karaf.shell.commands.Option; |
| 25 | +import org.onlab.packet.Ip6Address; | ||
| 26 | +import org.onlab.packet.IpAddress; | ||
| 25 | import org.onosproject.cli.AbstractShellCommand; | 27 | import org.onosproject.cli.AbstractShellCommand; |
| 26 | import org.onosproject.core.ApplicationId; | 28 | import org.onosproject.core.ApplicationId; |
| 27 | import org.onosproject.core.CoreService; | 29 | import org.onosproject.core.CoreService; |
| 28 | import org.onosproject.net.Link; | 30 | import org.onosproject.net.Link; |
| 29 | import org.onosproject.net.flow.DefaultTrafficSelector; | 31 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 30 | -import org.onosproject.net.flow.DefaultTrafficTreatment; | ||
| 31 | import org.onosproject.net.flow.TrafficSelector; | 32 | import org.onosproject.net.flow.TrafficSelector; |
| 32 | import org.onosproject.net.flow.TrafficTreatment; | 33 | import org.onosproject.net.flow.TrafficTreatment; |
| 33 | import org.onosproject.net.intent.Constraint; | 34 | import org.onosproject.net.intent.Constraint; |
| ... | @@ -70,6 +71,30 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { | ... | @@ -70,6 +71,30 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { |
| 70 | required = false, multiValued = false) | 71 | required = false, multiValued = false) |
| 71 | private String dstIpString = null; | 72 | private String dstIpString = null; |
| 72 | 73 | ||
| 74 | + @Option(name = "--fLabel", description = "IPv6 Flow Label", | ||
| 75 | + required = false, multiValued = false) | ||
| 76 | + private String fLabelString = null; | ||
| 77 | + | ||
| 78 | + @Option(name = "--icmp6Type", description = "ICMPv6 Type", | ||
| 79 | + required = false, multiValued = false) | ||
| 80 | + private String icmp6TypeString = null; | ||
| 81 | + | ||
| 82 | + @Option(name = "--icmp6Code", description = "ICMPv6 Code", | ||
| 83 | + required = false, multiValued = false) | ||
| 84 | + private String icmp6CodeString = null; | ||
| 85 | + | ||
| 86 | + @Option(name = "--ndTarget", description = "IPv6 Neighbor Discovery Target Address", | ||
| 87 | + required = false, multiValued = false) | ||
| 88 | + private String ndTargetString = null; | ||
| 89 | + | ||
| 90 | + @Option(name = "--ndSLL", description = "IPv6 Neighbor Discovery Source Link-Layer", | ||
| 91 | + required = false, multiValued = false) | ||
| 92 | + private String ndSLLString = null; | ||
| 93 | + | ||
| 94 | + @Option(name = "--ndTLL", description = "IPv6 Neighbor Discovery Target Link-Layer", | ||
| 95 | + required = false, multiValued = false) | ||
| 96 | + private String ndTLLString = null; | ||
| 97 | + | ||
| 73 | @Option(name = "--tcpSrc", description = "Source TCP Port", | 98 | @Option(name = "--tcpSrc", description = "Source TCP Port", |
| 74 | required = false, multiValued = false) | 99 | required = false, multiValued = false) |
| 75 | private String srcTcpString = null; | 100 | private String srcTcpString = null; |
| ... | @@ -78,6 +103,10 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { | ... | @@ -78,6 +103,10 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { |
| 78 | required = false, multiValued = false) | 103 | required = false, multiValued = false) |
| 79 | private String dstTcpString = null; | 104 | private String dstTcpString = null; |
| 80 | 105 | ||
| 106 | + @Option(name = "--extHdr", description = "IPv6 Extension Header Pseudo-field", | ||
| 107 | + required = false, multiValued = false) | ||
| 108 | + private String extHdrString = null; | ||
| 109 | + | ||
| 81 | @Option(name = "-b", aliases = "--bandwidth", description = "Bandwidth", | 110 | @Option(name = "-b", aliases = "--bandwidth", description = "Bandwidth", |
| 82 | required = false, multiValued = false) | 111 | required = false, multiValued = false) |
| 83 | private String bandwidthString = null; | 112 | private String bandwidthString = null; |
| ... | @@ -104,6 +133,15 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { | ... | @@ -104,6 +133,15 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { |
| 104 | required = false, multiValued = false) | 133 | required = false, multiValued = false) |
| 105 | private String setEthDstString = null; | 134 | private String setEthDstString = null; |
| 106 | 135 | ||
| 136 | + @Option(name = "--setIpSrc", description = "Rewrite Source IP Address", | ||
| 137 | + required = false, multiValued = false) | ||
| 138 | + private String setIpSrcString = null; | ||
| 139 | + | ||
| 140 | + @Option(name = "--setIpDst", description = "Rewrite Destination IP Address", | ||
| 141 | + required = false, multiValued = false) | ||
| 142 | + private String setIpDstString = null; | ||
| 143 | + | ||
| 144 | + | ||
| 107 | // Priorities | 145 | // Priorities |
| 108 | @Option(name = "-p", aliases = "--priority", description = "Priority", | 146 | @Option(name = "-p", aliases = "--priority", description = "Priority", |
| 109 | required = false, multiValued = false) | 147 | required = false, multiValued = false) |
| ... | @@ -174,6 +212,30 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { | ... | @@ -174,6 +212,30 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { |
| 174 | selectorBuilder.matchIPProtocol((byte) ipProtoShort); | 212 | selectorBuilder.matchIPProtocol((byte) ipProtoShort); |
| 175 | } | 213 | } |
| 176 | 214 | ||
| 215 | + if (!isNullOrEmpty(fLabelString)) { | ||
| 216 | + selectorBuilder.matchIPv6FlowLabel(Integer.parseInt(fLabelString)); | ||
| 217 | + } | ||
| 218 | + | ||
| 219 | + if (!isNullOrEmpty(icmp6TypeString)) { | ||
| 220 | + selectorBuilder.matchIcmpv6Type((byte) Integer.parseInt(icmp6TypeString)); | ||
| 221 | + } | ||
| 222 | + | ||
| 223 | + if (!isNullOrEmpty(icmp6CodeString)) { | ||
| 224 | + selectorBuilder.matchIcmpv6Code((byte) Integer.parseInt(icmp6CodeString)); | ||
| 225 | + } | ||
| 226 | + | ||
| 227 | + if (!isNullOrEmpty(ndTargetString)) { | ||
| 228 | + selectorBuilder.matchIPv6NDTargetAddress(Ip6Address.valueOf(ndTargetString)); | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + if (!isNullOrEmpty(ndSLLString)) { | ||
| 232 | + selectorBuilder.matchIPv6NDSourceLinkLayerAddress(MacAddress.valueOf(ndSLLString)); | ||
| 233 | + } | ||
| 234 | + | ||
| 235 | + if (!isNullOrEmpty(ndTLLString)) { | ||
| 236 | + selectorBuilder.matchIPv6NDTargetLinkLayerAddress(MacAddress.valueOf(ndTLLString)); | ||
| 237 | + } | ||
| 238 | + | ||
| 177 | if (!isNullOrEmpty(srcTcpString)) { | 239 | if (!isNullOrEmpty(srcTcpString)) { |
| 178 | selectorBuilder.matchTcpSrc((short) Integer.parseInt(srcTcpString)); | 240 | selectorBuilder.matchTcpSrc((short) Integer.parseInt(srcTcpString)); |
| 179 | } | 241 | } |
| ... | @@ -182,6 +244,10 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { | ... | @@ -182,6 +244,10 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { |
| 182 | selectorBuilder.matchTcpDst((short) Integer.parseInt(dstTcpString)); | 244 | selectorBuilder.matchTcpDst((short) Integer.parseInt(dstTcpString)); |
| 183 | } | 245 | } |
| 184 | 246 | ||
| 247 | + if (!isNullOrEmpty(extHdrString)) { | ||
| 248 | + selectorBuilder.matchIPv6ExthdrFlags(Integer.parseInt(extHdrString)); | ||
| 249 | + } | ||
| 250 | + | ||
| 185 | return selectorBuilder.build(); | 251 | return selectorBuilder.build(); |
| 186 | } | 252 | } |
| 187 | 253 | ||
| ... | @@ -192,23 +258,25 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { | ... | @@ -192,23 +258,25 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { |
| 192 | * @return traffic treatment | 258 | * @return traffic treatment |
| 193 | */ | 259 | */ |
| 194 | protected TrafficTreatment buildTrafficTreatment() { | 260 | protected TrafficTreatment buildTrafficTreatment() { |
| 195 | - boolean hasEthSrc = !isNullOrEmpty(setEthSrcString); | 261 | + final TrafficTreatment.Builder treatmentBuilder = builder(); |
| 196 | - boolean hasEthDst = !isNullOrEmpty(setEthDstString); | ||
| 197 | 262 | ||
| 198 | - if (!hasEthSrc && !hasEthDst) { | 263 | + if (!isNullOrEmpty(setEthSrcString)) { |
| 199 | - return DefaultTrafficTreatment.emptyTreatment(); | 264 | + treatmentBuilder.setEthSrc(MacAddress.valueOf(setEthSrcString)); |
| 200 | } | 265 | } |
| 201 | 266 | ||
| 202 | - final TrafficTreatment.Builder builder = builder(); | 267 | + if (!isNullOrEmpty(setEthDstString)) { |
| 203 | - if (hasEthSrc) { | 268 | + treatmentBuilder.setEthDst(MacAddress.valueOf(setEthDstString)); |
| 204 | - final MacAddress setEthSrc = MacAddress.valueOf(setEthSrcString); | ||
| 205 | - builder.setEthSrc(setEthSrc); | ||
| 206 | } | 269 | } |
| 207 | - if (hasEthDst) { | 270 | + |
| 208 | - final MacAddress setEthDst = MacAddress.valueOf(setEthDstString); | 271 | + if (!isNullOrEmpty(setIpSrcString)) { |
| 209 | - builder.setEthDst(setEthDst); | 272 | + treatmentBuilder.setIpSrc(IpAddress.valueOf(setIpSrcString)); |
| 273 | + } | ||
| 274 | + | ||
| 275 | + if (!isNullOrEmpty(setIpDstString)) { | ||
| 276 | + treatmentBuilder.setIpSrc(IpAddress.valueOf(setIpDstString)); | ||
| 210 | } | 277 | } |
| 211 | - return builder.build(); | 278 | + |
| 279 | + return treatmentBuilder.build(); | ||
| 212 | } | 280 | } |
| 213 | 281 | ||
| 214 | /** | 282 | /** | ... | ... |
| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | package org.onosproject.cli.net; | 16 | package org.onosproject.cli.net; |
| 17 | 17 | ||
| 18 | import org.onlab.packet.IPv4; | 18 | import org.onlab.packet.IPv4; |
| 19 | +import org.onlab.packet.IPv6; | ||
| 19 | 20 | ||
| 20 | /** | 21 | /** |
| 21 | * Known protocol values for IP protocol field that can be supplied to the CLI. | 22 | * Known protocol values for IP protocol field that can be supplied to the CLI. |
| ... | @@ -26,7 +27,9 @@ public enum IpProtocol { | ... | @@ -26,7 +27,9 @@ public enum IpProtocol { |
| 26 | /** TCP. **/ | 27 | /** TCP. **/ |
| 27 | TCP(IPv4.PROTOCOL_TCP), | 28 | TCP(IPv4.PROTOCOL_TCP), |
| 28 | /** UDP. **/ | 29 | /** UDP. **/ |
| 29 | - UDP(IPv4.PROTOCOL_UDP); | 30 | + UDP(IPv4.PROTOCOL_UDP), |
| 31 | + /** ICMP6. **/ | ||
| 32 | + ICMP6(IPv6.PROTOCOL_ICMP6); | ||
| 30 | 33 | ||
| 31 | private short value; | 34 | private short value; |
| 32 | 35 | ... | ... |
-
Please register or login to post a comment