Committed by
Pavlin Radoslavov
ONOS-635 Adding ICMPv6 type and code builder for HostMonitor.
aovid duplicate call of toString. Apply changes to FlowEntryBuilder and FlowModBuilder as well. Fix missing break; issue. Change-Id: I1a2e59ca943bbcc9677b9fc0cb9eb2f7cb3d7aa3
Showing
5 changed files
with
156 additions
and
4 deletions
| ... | @@ -194,6 +194,16 @@ public final class DefaultTrafficSelector implements TrafficSelector { | ... | @@ -194,6 +194,16 @@ public final class DefaultTrafficSelector implements TrafficSelector { |
| 194 | } | 194 | } |
| 195 | 195 | ||
| 196 | @Override | 196 | @Override |
| 197 | + public Builder matchIcmpv6Type(Byte icmpv6Type) { | ||
| 198 | + return add(Criteria.matchIcmpv6Type(icmpv6Type)); | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + @Override | ||
| 202 | + public Builder matchIcmpv6Code(Byte icmpv6Code) { | ||
| 203 | + return add(Criteria.matchIcmpv6Code(icmpv6Code)); | ||
| 204 | + } | ||
| 205 | + | ||
| 206 | + @Override | ||
| 197 | public Builder matchMplsLabel(Integer mplsLabel) { | 207 | public Builder matchMplsLabel(Integer mplsLabel) { |
| 198 | return add(Criteria.matchMplsLabel(mplsLabel)); | 208 | return add(Criteria.matchMplsLabel(mplsLabel)); |
| 199 | } | 209 | } | ... | ... |
| ... | @@ -163,6 +163,22 @@ public interface TrafficSelector { | ... | @@ -163,6 +163,22 @@ public interface TrafficSelector { |
| 163 | public Builder matchIPv6Dst(IpPrefix ip); | 163 | public Builder matchIPv6Dst(IpPrefix ip); |
| 164 | 164 | ||
| 165 | /** | 165 | /** |
| 166 | + * Matches a ICMPv6 type. | ||
| 167 | + * | ||
| 168 | + * @param icmpv6Type a ICMPv6 type | ||
| 169 | + * @return a selection builder | ||
| 170 | + */ | ||
| 171 | + public Builder matchIcmpv6Type(Byte icmpv6Type); | ||
| 172 | + | ||
| 173 | + /** | ||
| 174 | + * Matches a ICMPv6 code. | ||
| 175 | + * | ||
| 176 | + * @param icmpv6Code a ICMPv6 code | ||
| 177 | + * @return a selection builder | ||
| 178 | + */ | ||
| 179 | + public Builder matchIcmpv6Code(Byte icmpv6Code); | ||
| 180 | + | ||
| 181 | + /** | ||
| 166 | * Matches on a MPLS label . | 182 | * Matches on a MPLS label . |
| 167 | * @param mplsLabel a MPLS label. | 183 | * @param mplsLabel a MPLS label. |
| 168 | * @return a selection builder | 184 | * @return a selection builder | ... | ... |
| ... | @@ -167,6 +167,26 @@ public final class Criteria { | ... | @@ -167,6 +167,26 @@ public final class Criteria { |
| 167 | return new IPCriterion(ip, Type.IPV6_DST); | 167 | return new IPCriterion(ip, Type.IPV6_DST); |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | + /* | ||
| 171 | + * Creates a match on ICMPv6 type field using the specified value. | ||
| 172 | + * | ||
| 173 | + * @param icmpv6Type ICMPv6 type | ||
| 174 | + * @return match criterion | ||
| 175 | + */ | ||
| 176 | + public static Criterion matchIcmpv6Type(Byte icmpv6Type) { | ||
| 177 | + return new Icmpv6TypeCriterion(icmpv6Type); | ||
| 178 | + } | ||
| 179 | + | ||
| 180 | + /** | ||
| 181 | + * Creates a match on ICMPv6 code field using the specified value. | ||
| 182 | + * | ||
| 183 | + * @param icmpv6Code ICMPv6 code | ||
| 184 | + * @return match criterion | ||
| 185 | + */ | ||
| 186 | + public static Criterion matchIcmpv6Code(Byte icmpv6Code) { | ||
| 187 | + return new Icmpv6CodeCriterion(icmpv6Code); | ||
| 188 | + } | ||
| 189 | + | ||
| 170 | /** | 190 | /** |
| 171 | * Creates a match on MPLS label. | 191 | * Creates a match on MPLS label. |
| 172 | * @param mplsLabel MPLS label | 192 | * @param mplsLabel MPLS label |
| ... | @@ -588,6 +608,96 @@ public final class Criteria { | ... | @@ -588,6 +608,96 @@ public final class Criteria { |
| 588 | } | 608 | } |
| 589 | 609 | ||
| 590 | /** | 610 | /** |
| 611 | + * Implementation of ICMPv6 type criterion. | ||
| 612 | + */ | ||
| 613 | + public static final class Icmpv6TypeCriterion implements Criterion { | ||
| 614 | + | ||
| 615 | + private final Byte icmpv6Type; | ||
| 616 | + | ||
| 617 | + public Icmpv6TypeCriterion(Byte icmpv6Type) { | ||
| 618 | + this.icmpv6Type = icmpv6Type; | ||
| 619 | + } | ||
| 620 | + | ||
| 621 | + @Override | ||
| 622 | + public Type type() { | ||
| 623 | + return Type.ICMPV6_TYPE; | ||
| 624 | + } | ||
| 625 | + | ||
| 626 | + public Byte icmpv6Type() { | ||
| 627 | + return icmpv6Type; | ||
| 628 | + } | ||
| 629 | + | ||
| 630 | + @Override | ||
| 631 | + public String toString() { | ||
| 632 | + return toStringHelper(type().toString()) | ||
| 633 | + .add("icmpv6Type", icmpv6Type & 0xff).toString(); | ||
| 634 | + } | ||
| 635 | + | ||
| 636 | + @Override | ||
| 637 | + public int hashCode() { | ||
| 638 | + return Objects.hash(icmpv6Type, type()); | ||
| 639 | + } | ||
| 640 | + | ||
| 641 | + @Override | ||
| 642 | + public boolean equals(Object obj) { | ||
| 643 | + if (this == obj) { | ||
| 644 | + return true; | ||
| 645 | + } | ||
| 646 | + if (obj instanceof Icmpv6TypeCriterion) { | ||
| 647 | + Icmpv6TypeCriterion that = (Icmpv6TypeCriterion) obj; | ||
| 648 | + return Objects.equals(icmpv6Type, that.icmpv6Type) && | ||
| 649 | + Objects.equals(this.type(), that.type()); | ||
| 650 | + } | ||
| 651 | + return false; | ||
| 652 | + } | ||
| 653 | + } | ||
| 654 | + | ||
| 655 | + /** | ||
| 656 | + * Implementation of ICMPv6 code criterion. | ||
| 657 | + */ | ||
| 658 | + public static final class Icmpv6CodeCriterion implements Criterion { | ||
| 659 | + | ||
| 660 | + private final Byte icmpv6Code; | ||
| 661 | + | ||
| 662 | + public Icmpv6CodeCriterion(Byte icmpv6Code) { | ||
| 663 | + this.icmpv6Code = icmpv6Code; | ||
| 664 | + } | ||
| 665 | + | ||
| 666 | + @Override | ||
| 667 | + public Type type() { | ||
| 668 | + return Type.ICMPV6_CODE; | ||
| 669 | + } | ||
| 670 | + | ||
| 671 | + public Byte icmpv6Code() { | ||
| 672 | + return icmpv6Code; | ||
| 673 | + } | ||
| 674 | + | ||
| 675 | + @Override | ||
| 676 | + public String toString() { | ||
| 677 | + return toStringHelper(type().toString()) | ||
| 678 | + .add("icmpv6Code", icmpv6Code & 0xff).toString(); | ||
| 679 | + } | ||
| 680 | + | ||
| 681 | + @Override | ||
| 682 | + public int hashCode() { | ||
| 683 | + return Objects.hash(icmpv6Code, type()); | ||
| 684 | + } | ||
| 685 | + | ||
| 686 | + @Override | ||
| 687 | + public boolean equals(Object obj) { | ||
| 688 | + if (this == obj) { | ||
| 689 | + return true; | ||
| 690 | + } | ||
| 691 | + if (obj instanceof Icmpv6CodeCriterion) { | ||
| 692 | + Icmpv6CodeCriterion that = (Icmpv6CodeCriterion) obj; | ||
| 693 | + return Objects.equals(icmpv6Code, that.icmpv6Code) && | ||
| 694 | + Objects.equals(this.type(), that.type()); | ||
| 695 | + } | ||
| 696 | + return false; | ||
| 697 | + } | ||
| 698 | + } | ||
| 699 | + | ||
| 700 | + /** | ||
| 591 | * Implementation of MPLS tag criterion. | 701 | * Implementation of MPLS tag criterion. |
| 592 | */ | 702 | */ |
| 593 | public static final class MplsCriterion implements Criterion { | 703 | public static final class MplsCriterion implements Criterion { | ... | ... |
| ... | @@ -428,6 +428,14 @@ public class FlowEntryBuilder { | ... | @@ -428,6 +428,14 @@ public class FlowEntryBuilder { |
| 428 | } | 428 | } |
| 429 | builder.matchIPv6Src(sipv6); | 429 | builder.matchIPv6Src(sipv6); |
| 430 | break; | 430 | break; |
| 431 | + case ICMPV6_TYPE: | ||
| 432 | + byte icmpv6type = (byte) match.get(MatchField.ICMPV6_TYPE).getValue(); | ||
| 433 | + builder.matchIcmpv6Type(icmpv6type); | ||
| 434 | + break; | ||
| 435 | + case ICMPV6_CODE: | ||
| 436 | + byte icmpv6code = (byte) match.get(MatchField.ICMPV6_CODE).getValue(); | ||
| 437 | + builder.matchIcmpv6Code(icmpv6code); | ||
| 438 | + break; | ||
| 431 | case ARP_OP: | 439 | case ARP_OP: |
| 432 | case ARP_SHA: | 440 | case ARP_SHA: |
| 433 | case ARP_SPA: | 441 | case ARP_SPA: |
| ... | @@ -435,8 +443,6 @@ public class FlowEntryBuilder { | ... | @@ -435,8 +443,6 @@ public class FlowEntryBuilder { |
| 435 | case ARP_TPA: | 443 | case ARP_TPA: |
| 436 | case ICMPV4_CODE: | 444 | case ICMPV4_CODE: |
| 437 | case ICMPV4_TYPE: | 445 | case ICMPV4_TYPE: |
| 438 | - case ICMPV6_CODE: | ||
| 439 | - case ICMPV6_TYPE: | ||
| 440 | case IN_PHY_PORT: | 446 | case IN_PHY_PORT: |
| 441 | case IPV6_FLABEL: | 447 | case IPV6_FLABEL: |
| 442 | case IPV6_ND_SLL: | 448 | case IPV6_ND_SLL: | ... | ... |
| ... | @@ -31,6 +31,8 @@ import org.onosproject.net.flow.criteria.Criteria.PortCriterion; | ... | @@ -31,6 +31,8 @@ import org.onosproject.net.flow.criteria.Criteria.PortCriterion; |
| 31 | import org.onosproject.net.flow.criteria.Criteria.TcpPortCriterion; | 31 | import org.onosproject.net.flow.criteria.Criteria.TcpPortCriterion; |
| 32 | import org.onosproject.net.flow.criteria.Criteria.VlanIdCriterion; | 32 | import org.onosproject.net.flow.criteria.Criteria.VlanIdCriterion; |
| 33 | import org.onosproject.net.flow.criteria.Criteria.VlanPcpCriterion; | 33 | import org.onosproject.net.flow.criteria.Criteria.VlanPcpCriterion; |
| 34 | +import org.onosproject.net.flow.criteria.Criteria.Icmpv6TypeCriterion; | ||
| 35 | +import org.onosproject.net.flow.criteria.Criteria.Icmpv6CodeCriterion; | ||
| 34 | import org.onosproject.net.flow.criteria.Criterion; | 36 | import org.onosproject.net.flow.criteria.Criterion; |
| 35 | import org.onlab.packet.Ip4Address; | 37 | import org.onlab.packet.Ip4Address; |
| 36 | import org.onlab.packet.Ip4Prefix; | 38 | import org.onlab.packet.Ip4Prefix; |
| ... | @@ -254,6 +256,16 @@ public abstract class FlowModBuilder { | ... | @@ -254,6 +256,16 @@ public abstract class FlowModBuilder { |
| 254 | IPv6Address.of(ip6Prefix.address().toString())); | 256 | IPv6Address.of(ip6Prefix.address().toString())); |
| 255 | } | 257 | } |
| 256 | break; | 258 | break; |
| 259 | + case ICMPV6_TYPE: | ||
| 260 | + Icmpv6TypeCriterion icmpv6type = (Icmpv6TypeCriterion) c; | ||
| 261 | + mBuilder.setExact(MatchField.ICMPV6_TYPE, | ||
| 262 | + U8.of(icmpv6type.icmpv6Type().byteValue())); | ||
| 263 | + break; | ||
| 264 | + case ICMPV6_CODE: | ||
| 265 | + Icmpv6CodeCriterion icmpv6code = (Icmpv6CodeCriterion) c; | ||
| 266 | + mBuilder.setExact(MatchField.ICMPV6_CODE, | ||
| 267 | + U8.of(icmpv6code.icmpv6Code().byteValue())); | ||
| 268 | + break; | ||
| 257 | case ARP_OP: | 269 | case ARP_OP: |
| 258 | case ARP_SHA: | 270 | case ARP_SHA: |
| 259 | case ARP_SPA: | 271 | case ARP_SPA: |
| ... | @@ -261,8 +273,6 @@ public abstract class FlowModBuilder { | ... | @@ -261,8 +273,6 @@ public abstract class FlowModBuilder { |
| 261 | case ARP_TPA: | 273 | case ARP_TPA: |
| 262 | case ICMPV4_CODE: | 274 | case ICMPV4_CODE: |
| 263 | case ICMPV4_TYPE: | 275 | case ICMPV4_TYPE: |
| 264 | - case ICMPV6_CODE: | ||
| 265 | - case ICMPV6_TYPE: | ||
| 266 | case IN_PHY_PORT: | 276 | case IN_PHY_PORT: |
| 267 | case IPV6_EXTHDR: | 277 | case IPV6_EXTHDR: |
| 268 | case IPV6_FLABEL: | 278 | case IPV6_FLABEL: | ... | ... |
-
Please register or login to post a comment